Fix autoconf 2.70 compatibility
[platform/upstream/krb5.git] / src / windows / leash / LeashView.h
1 //      **************************************************************************************
2 //      File:                   LeashView.h
3 //      By:                             Arthur David Leather
4 //      Created:                12/02/98
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
8 //
9 //      History:
10 //
11 //      MM/DD/YY        Inits   Description of Change
12 //      12/02/98        ADL             Original
13 //      **************************************************************************************
14
15
16 #if !defined(AFX_LeashVIEW_H__6F45AD99_561B_11D0_8FCF_00C04FC2A0C2__INCLUDED_)
17 #define AFX_LeashVIEW_H__6F45AD99_561B_11D0_8FCF_00C04FC2A0C2__INCLUDED_
18
19 #if _MSC_VER >= 1000
20 #pragma once
21 #endif // _MSC_VER >= 1000
22
23 #define GOOD_TICKETS    1  // Don't change this value
24 #define EXPIRED_TICKETS 2  // Don't change this value
25 #define TICKETS_LOW             3
26 #define ONE_SECOND              1000
27 #define SMALL_ICONS     16
28 #define LARGE_ICONS     32
29
30 #define UPDATE_DISPLAY_TIME 60  //seconds
31
32 #define ACTIVE_CLOCK          0
33 #define LOW_CLOCK             1
34 #define EXPIRED_CLOCK         2
35 #define ACTIVE_TICKET         3
36 #define LOW_TICKET            4
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
51
52 #define NODE_IS_EXPANDED 2
53
54 #define CX_BORDER   1
55 #define CY_BORDER   1
56
57 #ifdef NO_TICKETS
58 #undef NO_TICKETS // XXX - this is evil but necessary thanks to silliness...
59 #endif
60
61 #define WM_TRAYICON (WM_USER+100)
62 #define WM_WARNINGPOPUP (WM_USER+101)
63
64 enum ticketTimeLeft{NO_TICKETS, ZERO_MINUTES_LEFT, FIVE_MINUTES_LEFT, TEN_MINUTES_LEFT,
65                                         FIFTEEN_MINUTES_LEFT, TWENTY_MINUTES_LEFT, PLENTY_OF_TIME,
66                     NOT_INSTALLED};
67 // Don't change 'NO_TICKET's' value
68
69 class CLeashDebugWindow;
70 class ViewColumnInfo
71 {
72 public:
73     const char * m_name;
74     int m_enabled;
75     int m_id;
76     int m_columnWidth;
77 };
78
79 enum eViewColumn {
80     PRINCIPAL,
81     TIME_ISSUED,
82     RENEWABLE_UNTIL,
83     VALID_UNTIL,
84     ENCRYPTION_TYPE,
85     TICKET_FLAGS,
86     CACHE_NAME,
87     NUM_VIEW_COLUMNS
88 };
89
90 class CCacheDisplayData
91 {
92 public:
93     CCacheDisplayData(const char *ccache_name) :
94       m_next(NULL),
95       m_ccacheName(strdup(ccache_name)),
96       m_index(-1),
97       m_focus(-1),
98       m_expanded(0),
99       m_selected(0),
100       m_isRenewable(0),
101       m_isDefault(0)
102     {
103     }
104
105     ~CCacheDisplayData()
106     {
107         if (m_ccacheName)
108             free(m_ccacheName);
109     }
110
111     CCacheDisplayData *m_next;
112     char *m_ccacheName;
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
119 };
120
121 struct ListItemInfo
122 {
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
126 };
127
128 class CLeashView : public CListView
129 {
130 private:
131 ////@#+Remove
132     CLeashDebugWindow*  m_pDebugWindow;
133     CCacheDisplayData*  m_ccacheDisplay;
134         CImageList                      m_imageList;
135         CWinApp*                        m_pApp;
136         HTREEITEM                       m_hPrincipal;
137         HTREEITEM                       m_hKerb5;
138     HTREEITEM           m_hk5tkt;
139         TV_INSERTSTRUCT         m_tvinsert;
140         HMENU                           m_hMenu;
141     BOOL                                m_startup;
142         BOOL                            m_isMinimum;
143         BOOL                            m_debugStartUp;
144         BOOL                            m_alreadyPlayed;
145     INT                                 m_upperCaseRealm;
146         INT                                     m_destroyTicketsOnExit;
147         INT                                     m_debugWindow;
148         INT                                     m_largeIcons;
149         INT                                     m_lowTicketAlarm;
150         INT                                     m_hPrincipalState;
151         INT                                     m_hKerb5State;
152     CString*            m_pWarningMessage;
153     BOOL                m_bIconAdded;
154     BOOL                m_bIconDeleted;
155     HFONT               m_BaseFont;
156     HFONT               m_BoldFont;
157     HFONT               m_ItalicFont;
158     HFONT               m_BoldItalicFont;
159     ListItemInfo*       m_aListItemInfo;
160
161     static ViewColumnInfo sm_viewColumns[NUM_VIEW_COLUMNS];
162
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;
173
174     void ToggleViewColumn(eViewColumn viewOption);
175         VOID ResetTreeNodes();
176     VOID ApplicationInfoMissingMsg();
177     VOID GetScrollBarState(CSize sizeClient, CSize& needSb,
178                                CSize& sizeRange, CPoint& ptMove,
179                            BOOL bInsideClient);
180     VOID UpdateBars();
181     VOID GetScrollBarSizes(CSize& sizeSb);
182     BOOL GetTrueClientSize(CSize& size, CSize& sizeSb);
183     HFONT GetSubItemFont(int iItem, int iSubItem);
184
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,
189                                           DWORD dwTime);
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,
197                                int iItem,
198                                char *principal,
199                                time_t issued,
200                                time_t valid_until,
201                                time_t renew_until,
202                                char *encTypes,
203                                unsigned long flags,
204                                char *cache_name);
205
206     void   SetTrayIcon(int nim, int state=0);
207     void   SetTrayText(int nim, CString tip);
208
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);
219
220     BOOL    IsExpanded(TICKETINFO *);
221
222 protected: // create from serialization only
223         DECLARE_DYNCREATE(CLeashView)
224
225 // Attributes
226 public:
227     static BOOL  m_importedTickets;
228
229     CLeashView();
230         //LeashDoc* GetDocument();
231
232         //{{AFX_DATA(CLeashView)
233         enum { IDD = IDD_DIALOG1 };
234                 // NOTE: the ClassWizard will add data members here
235         //}}AFX_DATA
236
237 // Operations
238 public:
239
240 // Overrides
241         // ClassWizard generated virtual function overrides
242         //{{AFX_VIRTUAL(CLeashView)
243         public:
244         virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
245         virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL);
246         virtual VOID OnInitialUpdate();
247         virtual BOOL PreTranslateMessage(MSG* pMsg);
248         protected:
249         virtual VOID OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView);
250         //}}AFX_VIRTUAL
251
252 // Implementation
253 public:
254         virtual ~CLeashView();
255
256 #ifdef _DEBUG
257         virtual VOID AssertValid() const;
258         virtual VOID Dump(CDumpContext& dc) const;
259 #endif
260
261 // Generated message map functions
262 protected:
263         //{{AFX_MSG(CLeashView)
264     afx_msg VOID OnItemexpandedTreeview(NMHDR* pNMHDR, LRESULT* pResult);
265         afx_msg INT OnCreate(LPCREATESTRUCT lpCreateStruct);
266         afx_msg VOID OnShowWindow(BOOL bShow, UINT nStatus);
267     afx_msg VOID OnClose(void);
268         afx_msg VOID OnInitTicket();
269         afx_msg VOID OnRenewTicket();
270         afx_msg VOID OnImportTicket();
271         afx_msg VOID OnDestroyTicket();
272         afx_msg VOID OnMakeDefault();
273         afx_msg VOID OnChangePassword();
274         afx_msg VOID OnUpdateDisplay();
275         afx_msg VOID OnSynTime();
276         afx_msg VOID OnDebugMode();
277         afx_msg VOID OnLargeIcons();
278         afx_msg VOID OnTimeIssued();
279         afx_msg VOID OnValidUntil();
280         afx_msg VOID OnRenewableUntil();
281         afx_msg VOID OnShowTicketFlags();
282         afx_msg VOID OnEncryptionType();
283         afx_msg VOID OnCcacheName();
284         afx_msg VOID OnUppercaseRealm();
285         afx_msg VOID OnKillTixOnExit();
286         afx_msg VOID OnDestroy();
287         afx_msg VOID OnUpdateDestroyTicket(CCmdUI* pCmdUI);
288         afx_msg VOID OnUpdateImportTicket(CCmdUI* pCmdUI);
289         afx_msg VOID OnUpdateInitTicket(CCmdUI* pCmdUI);
290         afx_msg VOID OnUpdateRenewTicket(CCmdUI* pCmdUI);
291         afx_msg VOID OnUpdateTimeIssued(CCmdUI* pCmdUI);
292         afx_msg VOID OnUpdateValidUntil(CCmdUI* pCmdUI);
293         afx_msg VOID OnUpdateRenewableUntil(CCmdUI* pCmdUI);
294         afx_msg VOID OnUpdateShowTicketFlags(CCmdUI* pCmdUI);
295         afx_msg VOID OnUpdateEncryptionType(CCmdUI* pCmdUI);
296         afx_msg VOID OnUpdateCcacheName(CCmdUI* pCmdUI);
297         afx_msg VOID OnUpdateUppercaseRealm(CCmdUI* pCmdUI);
298         afx_msg VOID OnUpdateKillTixOnExit(CCmdUI* pCmdUI);
299         afx_msg VOID OnUpdateLowTicketAlarm(CCmdUI* pCmdUI);
300         afx_msg VOID OnUpdateAutoRenew(CCmdUI* pCmdUI);
301         afx_msg VOID OnUpdateMakeDefault(CCmdUI* pCmdUI);
302         afx_msg VOID OnAppAbout();
303         afx_msg VOID OnUpdateDebugMode(CCmdUI* pCmdUI);
304         afx_msg VOID OnUpdateCfgFiles(CCmdUI* pCmdUI);
305         afx_msg VOID OnKrb5Properties();
306         afx_msg void OnLeashProperties();
307         afx_msg void OnLeashRestore();
308         afx_msg void OnLeashMinimize();
309         afx_msg void OnLowTicketAlarm();
310         afx_msg void OnUpdateKrb5Properties(CCmdUI* pCmdUI);
311     afx_msg void OnKrbProperties();
312         afx_msg void OnUpdateProperties(CCmdUI* pCmdUI);
313         afx_msg void OnHelpKerberos();
314         afx_msg void OnHelpLeash32();
315         afx_msg void OnHelpWhyuseleash32();
316     afx_msg void OnSysColorChange();
317     afx_msg void OnAutoRenew();
318         afx_msg LRESULT OnGoodbye(WPARAM wParam, LPARAM lParam);
319         afx_msg LRESULT OnTrayIcon(WPARAM wParam, LPARAM lParam);
320     afx_msg LRESULT OnObtainTGTWithParam(WPARAM wParam, LPARAM lParam);
321     afx_msg void OnItemChanged(NMHDR* pNmHdr, LRESULT* pResult);
322     //}}AFX_MSG
323         DECLARE_MESSAGE_MAP()
324 public:
325     afx_msg void OnLvnItemchanging(NMHDR *pNMHDR, LRESULT *pResult);
326     afx_msg void OnLvnItemActivate(NMHDR *pNMHDR, LRESULT *pResult);
327     afx_msg void OnLvnKeydown(NMHDR *pNMHDR, LRESULT *pResult);
328     afx_msg void OnNMCustomdraw(NMHDR *pNMHDR, LRESULT *pResult);
329 };
330
331 /*
332 #ifndef _DEBUG  // debug version in CLeashView.cpp
333 inline LeashDoc* CLeashView::GetDocument()
334    { return (LeashDoc*)m_pDocument; }
335 #endif
336 */
337
338 /////////////////////////////////////////////////////////////////////////////
339
340 //{{AFX_INSERT_LOCATION}}
341 // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
342
343 #endif // !defined(AFX_LeashVIEW_H__6F45AD99_561B_11D0_8FCF_00C04FC2A0C2__INCLUDED_)