rx: Remove RX_CALL_BUSY
[openafs.git] / src / WINNT / afsapplib / afsapplib.cpp
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 extern "C" {
11 #include <afs/param.h>
12 #include <afs/stds.h>
13 }
14
15 #include <WINNT/afsapplib.h>
16
17
18 /*
19  * VARIABLES __________________________________________________________________
20  *
21  */
22
23 static HWND g_hMain = NULL;
24 static TCHAR g_szAppName[ cchNAME ] = TEXT("");
25
26
27 /*
28  * PROTOTYPES _________________________________________________________________
29  *
30  */
31
32 extern void OnCoverWindow (WPARAM wp, LPARAM lp);
33 extern void OnExpiredCredentials (WPARAM wp, LPARAM lp);
34 extern void OnCreateErrorDialog (WPARAM wp, LPARAM lp);
35
36 HRESULT CALLBACK AfsAppLib_MainHook (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp);
37
38
39 /*
40  * ROUTINES ___________________________________________________________________
41  *
42  */
43
44 void AfsAppLib_SetAppName (LPTSTR pszName)
45 {
46    lstrcpy (g_szAppName, pszName);
47 }
48
49
50 void AfsAppLib_GetAppName (LPTSTR pszName)
51 {
52    lstrcpy (pszName, g_szAppName);
53 }
54
55
56 void AfsAppLib_SetMainWindow (HWND hMain)
57 {
58    if (g_hMain != NULL)
59       Subclass_RemoveHook (g_hMain, AfsAppLib_MainHook);
60
61    if ((g_hMain = hMain) != NULL)
62       Subclass_AddHook (g_hMain, AfsAppLib_MainHook);
63 }
64
65
66 HWND AfsAppLib_GetMainWindow (void)
67 {
68    return g_hMain;
69 }
70
71
72 HRESULT CALLBACK AfsAppLib_MainHook (HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
73 {
74    PVOID oldProc = Subclass_FindNextHook (hWnd, AfsAppLib_MainHook);
75
76    switch (msg)
77       {
78       case WM_COVER_WINDOW:
79          OnCoverWindow (wp, lp);
80          break;
81
82       case WM_EXPIRED_CREDENTIALS:
83          OnExpiredCredentials (wp, lp);
84          break;
85
86       case WM_CREATE_ERROR_DIALOG:
87          OnCreateErrorDialog (wp, lp);
88          break;
89
90       case WM_DESTROY:
91          AfsAppLib_SetMainWindow (NULL);
92          break;
93       }
94
95    if (oldProc)
96       return (CallWindowProc ((WNDPROC)oldProc, hWnd, msg, wp, lp));
97    else
98       return (DefWindowProc (hWnd, msg, wp, lp));
99 }
100