1 // **************************************************************************************
3 // By: Arthur David Leather
5 // Copyright @1998 Massachusetts Institute of Technology - All rights reserved.
6 // Description: H file for LeashView.cpp. Contains variables and functions
7 // for the Leash FormView
11 // MM/DD/YY Inits Description of Change
12 // 12/02/98 ADL Original
13 // **************************************************************************************
16 #if !defined(AFX_LeashVIEW_H__6F45AD99_561B_11D0_8FCF_00C04FC2A0C2__INCLUDED_)
17 #define AFX_LeashVIEW_H__6F45AD99_561B_11D0_8FCF_00C04FC2A0C2__INCLUDED_
21 #endif // _MSC_VER >= 1000
23 #define GOOD_TICKETS 1 // Don't change this value
24 #define EXPIRED_TICKETS 2 // Don't change this value
26 #define ONE_SECOND 1000
27 #define SMALL_ICONS 16
28 #define LARGE_ICONS 32
30 #define UPDATE_DISPLAY_TIME 60 //seconds
32 #define ACTIVE_CLOCK 0
34 #define EXPIRED_CLOCK 2
35 #define ACTIVE_TICKET 3
37 #define EXPIRED_TICKET 5
38 #define TICKET_NOT_INSTALLED 6
39 #define ACTIVE_PARENT_NODE 7
40 #define LOW_PARENT_NODE 8
41 #define EXPIRED_PARENT_NODE 9
42 #define NONE_PARENT_NODE 10
43 #define LOW_TRAY_ICON 11
44 #define EXPIRED_TRAY_ICON 12
45 #define ACTIVE_TRAY_ICON 13
46 #define NONE_TRAY_ICON 14
47 #define TKT_ADDRESS 15
48 #define TKT_SESSION 16
49 #define TKT_ENCRYPTION 17
50 #define IMAGE_COUNT 18
52 #define NODE_IS_EXPANDED 2
58 #undef NO_TICKETS // XXX - this is evil but necessary thanks to silliness...
61 #define WM_TRAYICON (WM_USER+100)
62 #define WM_WARNINGPOPUP (WM_USER+101)
64 enum ticketTimeLeft{NO_TICKETS, ZERO_MINUTES_LEFT, FIVE_MINUTES_LEFT, TEN_MINUTES_LEFT,
65 FIFTEEN_MINUTES_LEFT, TWENTY_MINUTES_LEFT, PLENTY_OF_TIME,
67 // Don't change 'NO_TICKET's' value
69 class CLeashDebugWindow;
90 class CCacheDisplayData
93 CCacheDisplayData(const char *ccache_name) :
95 m_ccacheName(strdup(ccache_name)),
111 CCacheDisplayData *m_next;
113 int m_index; // item index in list view
114 int m_focus; // sub-item with focus
115 unsigned int m_expanded; // true when each individual ticket is displayed
116 unsigned int m_selected; // true when this ccache is selected
117 unsigned int m_isRenewable; // true when tgt is renewable
118 unsigned int m_isDefault; // true when this is the default ccache
123 ListItemInfo() : m_font(NULL), m_durationFont(NULL) {}
124 HFONT m_durationFont; // For renewable/valid until; italic when expired
125 HFONT m_font; // For all other items
128 class CLeashView : public CListView
132 CLeashDebugWindow* m_pDebugWindow;
133 CCacheDisplayData* m_ccacheDisplay;
134 CImageList m_imageList;
136 HTREEITEM m_hPrincipal;
139 TV_INSERTSTRUCT m_tvinsert;
144 BOOL m_alreadyPlayed;
145 INT m_upperCaseRealm;
146 INT m_destroyTicketsOnExit;
149 INT m_lowTicketAlarm;
150 INT m_hPrincipalState;
152 CString* m_pWarningMessage;
158 HFONT m_BoldItalicFont;
159 ListItemInfo* m_aListItemInfo;
161 static ViewColumnInfo sm_viewColumns[NUM_VIEW_COLUMNS];
163 static INT m_autoRenewTickets;
164 static INT m_ticketStatusKrb5;
165 static INT m_autoRenewalAttempted;
166 static INT m_warningOfTicketTimeLeftKrb5;
167 static INT m_warningOfTicketTimeLeftLockKrb5;
168 static INT m_updateDisplayCount;
169 static INT m_alreadyPlayedDisplayCount;
170 static time_t m_ticketTimeLeft;
171 static BOOL m_lowTicketAlarmSound;
172 static LONG m_timerMsgNotInProgress;
174 void ToggleViewColumn(eViewColumn viewOption);
175 VOID ResetTreeNodes();
176 VOID ApplicationInfoMissingMsg();
177 VOID GetScrollBarState(CSize sizeClient, CSize& needSb,
178 CSize& sizeRange, CPoint& ptMove,
181 VOID GetScrollBarSizes(CSize& sizeSb);
182 BOOL GetTrueClientSize(CSize& size, CSize& sizeSb);
183 HFONT GetSubItemFont(int iItem, int iSubItem);
185 //void GetRowWidthHeight(CDC* pDC, LPCSTR theString, int& nRowWidth,
186 // int& nRowHeight, int& nCharWidth);
187 static VOID AlarmBeep();
188 static VOID CALLBACK EXPORT TimerProc(HWND hWnd, UINT nMsg, UINT_PTR nIDEvent,
190 static VOID UpdateTicketTime(TICKETINFO& ticketinfo);
191 static INT GetLowTicketStatus(int);
192 static time_t LeashTime();
193 static BOOL IsExpired(TicketList *ticket);
194 static BOOL IsExpired(TICKETINFO *info);
195 static VOID AddDisplayItem(CListCtrl &list,
196 CCacheDisplayData *elem,
206 void SetTrayIcon(int nim, int state=0);
207 void SetTrayText(int nim, CString tip);
209 BOOL UpdateDisplay();
210 static UINT InitTicket(void *);
211 static UINT RenewTicket(void *);
212 static UINT ImportTicket(void *);
213 // Queue a warning popup message.
214 // This is a workaround to the MFC deficiency that you cannot safely create
215 // a modal dialog while processing messages within AfxPreTranslateMessage()
216 // returns TRUE if message is queued successfully.
217 BOOL PostWarningMessage(const CString& message);
218 afx_msg LRESULT OnWarningPopup(WPARAM wParam, LPARAM lParam);
220 BOOL IsExpanded(TICKETINFO *);
222 protected: // create from serialization only
223 DECLARE_DYNCREATE(CLeashView)
228 //LeashDoc* GetDocument();
230 //{{AFX_DATA(CLeashView)
231 enum { IDD = IDD_DIALOG1 };
232 // NOTE: the ClassWizard will add data members here
239 // ClassWizard generated virtual function overrides
240 //{{AFX_VIRTUAL(CLeashView)
242 virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
243 virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL);
244 virtual VOID OnInitialUpdate();
245 virtual BOOL PreTranslateMessage(MSG* pMsg);
247 virtual VOID OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView);
252 virtual ~CLeashView();
255 virtual VOID AssertValid() const;
256 virtual VOID Dump(CDumpContext& dc) const;
259 // Generated message map functions
261 //{{AFX_MSG(CLeashView)
262 afx_msg VOID OnItemexpandedTreeview(NMHDR* pNMHDR, LRESULT* pResult);
263 afx_msg INT OnCreate(LPCREATESTRUCT lpCreateStruct);
264 afx_msg VOID OnShowWindow(BOOL bShow, UINT nStatus);
265 afx_msg VOID OnClose(void);
266 afx_msg VOID OnInitTicket();
267 afx_msg VOID OnRenewTicket();
268 afx_msg VOID OnDestroyTicket();
269 afx_msg VOID OnMakeDefault();
270 afx_msg VOID OnChangePassword();
271 afx_msg VOID OnUpdateDisplay();
272 afx_msg VOID OnSynTime();
273 afx_msg VOID OnDebugMode();
274 afx_msg VOID OnLargeIcons();
275 afx_msg VOID OnTimeIssued();
276 afx_msg VOID OnValidUntil();
277 afx_msg VOID OnRenewableUntil();
278 afx_msg VOID OnShowTicketFlags();
279 afx_msg VOID OnEncryptionType();
280 afx_msg VOID OnCcacheName();
281 afx_msg VOID OnUppercaseRealm();
282 afx_msg VOID OnKillTixOnExit();
283 afx_msg VOID OnDestroy();
284 afx_msg VOID OnUpdateDestroyTicket(CCmdUI* pCmdUI);
285 afx_msg VOID OnUpdateInitTicket(CCmdUI* pCmdUI);
286 afx_msg VOID OnUpdateRenewTicket(CCmdUI* pCmdUI);
287 afx_msg VOID OnUpdateTimeIssued(CCmdUI* pCmdUI);
288 afx_msg VOID OnUpdateValidUntil(CCmdUI* pCmdUI);
289 afx_msg VOID OnUpdateRenewableUntil(CCmdUI* pCmdUI);
290 afx_msg VOID OnUpdateShowTicketFlags(CCmdUI* pCmdUI);
291 afx_msg VOID OnUpdateEncryptionType(CCmdUI* pCmdUI);
292 afx_msg VOID OnUpdateCcacheName(CCmdUI* pCmdUI);
293 afx_msg VOID OnUpdateUppercaseRealm(CCmdUI* pCmdUI);
294 afx_msg VOID OnUpdateKillTixOnExit(CCmdUI* pCmdUI);
295 afx_msg VOID OnUpdateLowTicketAlarm(CCmdUI* pCmdUI);
296 afx_msg VOID OnUpdateAutoRenew(CCmdUI* pCmdUI);
297 afx_msg VOID OnUpdateMakeDefault(CCmdUI* pCmdUI);
298 afx_msg VOID OnAppAbout();
299 afx_msg VOID OnUpdateDebugMode(CCmdUI* pCmdUI);
300 afx_msg VOID OnUpdateCfgFiles(CCmdUI* pCmdUI);
301 afx_msg VOID OnKrb5Properties();
302 afx_msg void OnLeashProperties();
303 afx_msg void OnLeashRestore();
304 afx_msg void OnLeashMinimize();
305 afx_msg void OnLowTicketAlarm();
306 afx_msg void OnUpdateKrb5Properties(CCmdUI* pCmdUI);
307 afx_msg void OnKrbProperties();
308 afx_msg void OnUpdateProperties(CCmdUI* pCmdUI);
309 afx_msg void OnHelpKerberos();
310 afx_msg void OnHelpLeash32();
311 afx_msg void OnHelpWhyuseleash32();
312 afx_msg void OnSysColorChange();
313 afx_msg void OnAutoRenew();
314 afx_msg LRESULT OnGoodbye(WPARAM wParam, LPARAM lParam);
315 afx_msg LRESULT OnTrayIcon(WPARAM wParam, LPARAM lParam);
316 afx_msg LRESULT OnObtainTGTWithParam(WPARAM wParam, LPARAM lParam);
317 afx_msg void OnItemChanged(NMHDR* pNmHdr, LRESULT* pResult);
319 DECLARE_MESSAGE_MAP()
321 afx_msg void OnLvnItemchanging(NMHDR *pNMHDR, LRESULT *pResult);
322 afx_msg void OnLvnItemActivate(NMHDR *pNMHDR, LRESULT *pResult);
323 afx_msg void OnLvnKeydown(NMHDR *pNMHDR, LRESULT *pResult);
324 afx_msg void OnNMCustomdraw(NMHDR *pNMHDR, LRESULT *pResult);
328 #ifndef _DEBUG // debug version in CLeashView.cpp
329 inline LeashDoc* CLeashView::GetDocument()
330 { return (LeashDoc*)m_pDocument; }
334 /////////////////////////////////////////////////////////////////////////////
336 //{{AFX_INSERT_LOCATION}}
337 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
339 #endif // !defined(AFX_LeashVIEW_H__6F45AD99_561B_11D0_8FCF_00C04FC2A0C2__INCLUDED_)