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)
m_publicIPAddress = 0;
m_autoRenewTickets = 0;
m_autoRenewalAttempted = 0;
-
+ m_pWarningMessage = NULL;
m_bIconAdded = FALSE;
m_bIconDeleted = FALSE;
#ifndef KRB5_TC_NOTICKET
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 )
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");
}
#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,
#endif
INT m_hKerb5State;
INT m_hAFSState;
+ CString* m_pWarningMessage;
BOOL m_bIconAdded;
BOOL m_bIconDeleted;
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)