[26220] in CVS-changelog-for-Kerberos-V5

home help back first fref pref prev next nref lref last post

svn rev #25561: trunk/src/windows/leash/

daemon@ATHENA.MIT.EDU (tlyu@mit.edu)
Mon Dec 12 15:45:58 2011

Date: Mon, 12 Dec 2011 15:45:55 -0500
From: tlyu@mit.edu
Message-Id: <201112122045.pBCKjt1x005527@drugstore.mit.edu>
To: cvs-krb5@mit.edu
Reply-To: krbdev@mit.edu
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: cvs-krb5-bounces@mit.edu

http://src.mit.edu/fisheye/changelog/krb5/?cs=25561
Commit By: tlyu
Log Message:
ticket: 7050
subject: kfw fix: restructure low ticket warning popup code to workaround mfc bug

mfc bug causes assertions when dialog is generated from
within PreTranslateMessages() (MSG input param points to a global
variable which is corrupted in the dialog message loop).  So we need
to instead PostMessage() to cause the popup later.
Also fixed logic to cause warning dialog to actually be modal as intended
when the leash window is not minimized.

Signed-off-by: Kevin Wasserman <kevin.wasserman@painless-security.com>


Changed Files:
U   trunk/src/windows/leash/LeashView.cpp
U   trunk/src/windows/leash/LeashView.h
Modified: trunk/src/windows/leash/LeashView.cpp
===================================================================
--- trunk/src/windows/leash/LeashView.cpp	2011-12-12 20:45:52 UTC (rev 25560)
+++ trunk/src/windows/leash/LeashView.cpp	2011-12-12 20:45:55 UTC (rev 25561)
@@ -44,6 +44,7 @@
 
 BEGIN_MESSAGE_MAP(CLeashView, CFormView)
 	//{{AFX_MSG_MAP(CLeashView)
+    ON_MESSAGE(WM_WARNINGPOPUP, OnWarningPopup)
 	ON_MESSAGE(WM_GOODBYE, OnGoodbye)
     ON_MESSAGE(WM_TRAYICON, OnTrayIcon)
     ON_NOTIFY(TVN_ITEMEXPANDED, IDC_TREEVIEW, OnItemexpandedTreeview)
@@ -172,7 +173,7 @@
     m_publicIPAddress = 0;
     m_autoRenewTickets = 0;
     m_autoRenewalAttempted = 0;
-
+    m_pWarningMessage = NULL;
     m_bIconAdded = FALSE;
     m_bIconDeleted = FALSE;
 #ifndef KRB5_TC_NOTICKET
@@ -2073,6 +2074,27 @@
         m_bIconDeleted = TRUE;
 }
 
+BOOL CLeashView::PostWarningMessage(const CString& message)
+{
+    if (m_pWarningMessage)
+    {
+        return FALSE; // can't post more than one warning at a time
+    }
+    m_pWarningMessage = new CString(message);
+    PostMessage(WM_WARNINGPOPUP);
+    return TRUE;
+}
+
+LRESULT CLeashView::OnWarningPopup(WPARAM wParam, LPARAM lParam)
+{
+    CLeashMessageBox leashMessageBox(CMainFrame::m_isMinimum ? GetDesktopWindow() : NULL,
+                                        *m_pWarningMessage, 100000);
+    leashMessageBox.DoModal();
+    delete m_pWarningMessage;
+    m_pWarningMessage = NULL;
+    return 0L;
+}
+
 BOOL CLeashView::PreTranslateMessage(MSG* pMsg)
 {
 	if ( pMsg->message == ID_OBTAIN_TGT_WITH_LPARAM )
@@ -2464,9 +2486,7 @@
 
                 ReleaseMutex(ticketinfo.lockObj);
                 AlarmBeep();
-                CLeashMessageBox leashMessageBox(!CMainFrame::m_isMinimum ? GetDesktopWindow() : NULL,
-                                                  lowTicketWarning, 100000);
-                leashMessageBox.DoModal();
+                PostWarningMessage(lowTicketWarning);
                 if (WaitForSingleObject( ticketinfo.lockObj, 100 ) != WAIT_OBJECT_0)
                     throw("Unable to lock ticketinfo");
             }

Modified: trunk/src/windows/leash/LeashView.h
===================================================================
--- trunk/src/windows/leash/LeashView.h	2011-12-12 20:45:52 UTC (rev 25560)
+++ trunk/src/windows/leash/LeashView.h	2011-12-12 20:45:55 UTC (rev 25561)
@@ -59,6 +59,7 @@
 #endif
 
 #define WM_TRAYICON (WM_USER+100)
+#define WM_WARNINGPOPUP (WM_USER+101)
 
 enum ticketTimeLeft{NO_TICKETS, ZERO_MINUTES_LEFT, FIVE_MINUTES_LEFT, TEN_MINUTES_LEFT,
 					FIFTEEN_MINUTES_LEFT, TWENTY_MINUTES_LEFT, PLENTY_OF_TIME,
@@ -106,6 +107,7 @@
 #endif
 	INT					m_hKerb5State;
 	INT					m_hAFSState;
+    CString*            m_pWarningMessage;
     BOOL                m_bIconAdded;
     BOOL                m_bIconDeleted;
 
@@ -154,6 +156,12 @@
     static UINT InitTicket(void *);
     static UINT RenewTicket(void *);
     static UINT ImportTicket(void *);
+    // Queue a warning popup message.
+    // This is a workaround to the MFC deficiency that you cannot safely create
+    // a modal dialog while processing messages within AfxPreTranslateMessage()
+    // returns TRUE if message is queued successfully.
+    BOOL PostWarningMessage(const CString& message);
+    afx_msg LRESULT OnWarningPopup(WPARAM wParam, LPARAM lParam);
 
 protected: // create from serialization only
 	DECLARE_DYNCREATE(CLeashView)

_______________________________________________
cvs-krb5 mailing list
cvs-krb5@mit.edu
https://mailman.mit.edu/mailman/listinfo/cvs-krb5

home help back first fref pref prev next nref lref last post