thread-and-timer-corrections-to-afscreds-20031121
[openafs.git] / src / WINNT / client_creds / afscreds.h
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 #ifndef AFSCREDS_H
11 #define AFSCREDS_H
12
13
14 /*
15  * INCLUSIONS _________________________________________________________________
16  *
17  */
18
19 #include <WINNT/TaLocale.h>
20 #undef REALLOC /* RT ticket 2120; So we can redefine it later */
21 #include <windows.h>
22 #include <commctrl.h>
23 #include <regstr.h>
24 #include <time.h>
25 #include <shellapi.h>
26 #include <WINNT/al_wizard.h>
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 #include <osithrdnt.h>
31 #include <osisleep.h>
32 #include <osibasel.h>
33 #ifdef __cplusplus
34 }
35 #endif
36 #include "resource.h"
37 #include "checklist.h"
38 #include "window.h"
39 #include "shortcut.h"
40 #include "trayicon.h"
41 #include "creds.h"
42 #include "credstab.h"
43 #include "advtab.h"
44 #include "mounttab.h"
45 #include "afswiz.h"
46 #include "drivemap.h"
47 #include "help.hid"
48
49
50 /*
51  * REG PATHS __________________________________________________________________
52  *
53  */
54
55 #define REGSTR_BASE          HKEY_LOCAL_MACHINE
56 #define REGSTR_PATH_AFS      TEXT("Software\\TransarcCorporation\\AFS Client\\CurrentVersion")
57 #define REGSTR_PATH_AFSCREDS TEXT("Software\\TransarcCorporation\\AFS Client\\AfsCreds")
58
59 #define REGVAL_AFS_TITLE     TEXT("Title")
60 #define REGVAL_AFS_VERSION   TEXT("VersionString")
61 #define REGVAL_AFS_PATCH     TEXT("PatchLevel")
62 #define REGVAL_AFS_PATH      TEXT("PathName")
63
64 #define cszSHORTCUT_NAME     TEXT("AFS Credentials.lnk")
65
66
67 /*
68  * VARIABLES __________________________________________________________________
69  *
70  */
71
72 typedef struct
73    {
74    TCHAR szCell[ MAX_PATH ];
75    TCHAR szUser[ MAX_PATH ];
76    SYSTEMTIME stExpires;
77    BOOL fRemind;
78    } CREDS, *LPCREDS;
79
80 typedef struct
81    {
82    HWND hMain;
83    CREDS *aCreds;
84    size_t cCreds;
85    DWORD tickLastRetest;
86    LONG fShowingMessage;
87    LPWIZARD pWizard;
88    BOOL fStartup;
89    BOOL fIsWinNT;
90    TCHAR szHelpFile[ MAX_PATH ];
91    osi_mutex_t expirationCheckLock;
92    osi_mutex_t credsLock;
93    } GLOBALS;
94
95 extern GLOBALS g;
96
97
98 /*
99  * TIMING _____________________________________________________________________
100  *
101  */
102
103 #define cminREMIND_TEST      1    // test every minute for expired creds
104 #define cminREMIND_WARN      15   // warn if creds expire in 15 minutes
105
106 #define cmsecMOUSEOVER       1000 // retest freq when mouse is over tray icon
107 #define cmsecSERVICE         2000 // retest freq when starting/stopping service
108
109 #define c100ns1SECOND        (LONGLONG)10000000
110 #define cmsec1SECOND         1000
111 #define cmsec1MINUTE         60000
112 #define csec1MINUTE          60
113
114
115 #define ID_REMIND_TIMER      1000
116 #define ID_SERVICE_TIMER     1001
117 #define ID_WIZARD_TIMER      1002
118
119
120 /*
121  * MACROS _____________________________________________________________________
122  *
123  */
124
125 #ifndef FileExists
126 #define FileExists(_psz)  ((GetFileAttributes (_psz) == 0xFFFFFFFF) ? FALSE : TRUE)
127 #endif
128
129 #ifndef THIS_HINST
130 #define THIS_HINST  (HINSTANCE)GetModuleHandle(NULL)
131 #endif
132
133 #ifndef iswhite
134 #define iswhite(_ch) ( ((_ch)==TEXT(' ')) || ((_ch)==TEXT('\t')) || ((_ch)==TEXT('\r')) || ((_ch)==TEXT('\n')) )
135 #endif
136
137 #ifndef cxRECT
138 #define cxRECT(_r) ((_r).right - (_r).left)
139 #endif
140
141 #ifndef cyRECT
142 #define cyRECT(_r) ((_r).bottom - (_r).top)
143 #endif
144
145 #ifndef REALLOC
146 #define REALLOC(_a,_c,_r,_i) AfsCredsReallocFunction ((LPVOID*)&_a,sizeof(*_a),&_c,_r,_i)
147 #endif
148
149
150 /*
151  * PROTOTYPES _________________________________________________________________
152  *
153  */
154
155 void Quit (void);
156
157 BOOL AfsCredsReallocFunction (LPVOID *ppTarget, size_t cbElement, size_t *pcTarget, size_t cReq, size_t cInc);
158
159 void LoadRemind (size_t iCreds);
160 void SaveRemind (size_t iCreds);
161
162 void TimeToSystemTime (SYSTEMTIME *pst, time_t TimeT);
163
164 LPARAM GetTabParam (HWND hTab, int iTab);
165 HWND GetTabChild (HWND hTab);
166
167
168 #endif
169