/[gpgoe]/trunk/src/GPGOE.c
ViewVC logotype

Diff of /trunk/src/GPGOE.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1 by twoaday, Fri Mar 24 13:36:54 2006 UTC revision 16 by twoaday, Tue Apr 11 06:56:23 2006 UTC
# Line 27  Line 27 
27  #include "gpgme.h"  #include "gpgme.h"
28  #include "GPGOE.h"  #include "GPGOE.h"
29    
   
30  /* Global DLL module handle. */  /* Global DLL module handle. */
31  HINSTANCE mod_hinst_dll;  HINSTANCE mod_hinst_dll;
32    
33    /* Outlook Express old window procedure. */
34    WNDPROC oe_proc_old;
35    
36  /* DLL hook handle for the CBT function. */  /* DLL hook handle for the CBT function. */
37  static HHOOK ctb_hook = NULL;  static HHOOK ctb_hook = NULL;
38    
39  /* Outlook Express window handle. */  /* Outlook Express window handle. */
40  static HWND oe_hwnd = NULL;  static HWND oe_hwnd = NULL;
41    
 /* Outlook Express old window procedure. */  
 WNDPROC oe_proc_old;  
   
42    
43  /* Main DLL entry point. */  /* Main DLL entry point. */
44  BOOL WINAPI  BOOL WINAPI
# Line 65  DllMain (HINSTANCE hinst_dll, DWORD reas Line 64  DllMain (HINSTANCE hinst_dll, DWORD reas
64  }  }
65    
66    
67    /* Quick and dirty check if the dialog is a common dialog
68       and the 'File {Open, Save}' style. */
69    static int
70    is_common_file_dlg (HWND h)
71    {
72        HWND button = GetDlgItem (h, 1040);
73        char wclass[200];
74    
75        if (button == NULL)
76            return 0;
77        if (GetClassName (button, wclass, 200) > 0
78            && !stricmp (wclass, "Button"))
79            return -1;
80        return 0;
81    }
82    
83    
84    
85  /* CTB hook procedure.  /* CTB hook procedure.
86     Monitors the creation of all windows and subclass the window     Monitors the creation of all windows and subclass the window
87     if it belongs to the Outlook Express message class. */     if it belongs to the Outlook Express (message) class. */
88  static LRESULT CALLBACK  static LRESULT CALLBACK
89  ctb_proc (int code, WPARAM wparam, LPARAM lparam)  ctb_proc (int code, WPARAM wparam, LPARAM lparam)
90  {  {
# Line 94  ctb_proc (int code, WPARAM wparam, LPARA Line 111  ctb_proc (int code, WPARAM wparam, LPARA
111              else              else
112                  oe_hwnd = hwnd;                  oe_hwnd = hwnd;
113          }          }
114    
115            if (!strcmp (wclass, "Outlook Express Browser Class")) {
116                oe_main_proc_old = (WNDPROC)GetWindowLong (hwnd, GWL_WNDPROC);
117                if (!oe_main_proc_old)
118                    show_error (NULL, "GPGOE", MB_ICONERROR|MB_OK,
119                                "Could not get window procedure ec=%d",
120                                (int)GetLastError ());
121                else if (!SetWindowLong (hwnd, GWL_WNDPROC, (LONG)(WNDPROC)oe_main_proc))
122                    show_error (NULL, "GPGOE", MB_ICONERROR|MB_OK,
123                                "Could not set window procedure: ec=%d",
124                                (int)GetLastError ());
125            }
126            break;
127    
128        case HCBT_ACTIVATE:
129    #if 0
130            if (plugin_active != NULL &&
131                WaitForSingleObject (plugin_active, 0) == WAIT_OBJECT_0) {
132                char wclass[200];
133    
134                if (GetClassName (hwnd, wclass, sizeof (wclass)-1) <= 0 ||
135                    !strstr (wclass, "#32770") || !is_common_file_dlg (hwnd))
136                    break;
137                of_proc_old = (WNDPROC)GetWindowLong (hwnd, GWL_WNDPROC);
138                SetWindowLong (hwnd, GWL_WNDPROC, (LONG)(WNDPROC)of_proc);
139            }
140    #endif
141          break;          break;
142      }        }  
143      return CallNextHookEx (ctb_hook, code, wparam, lparam);      return CallNextHookEx (ctb_hook, code, wparam, lparam);
144  }  }
145    
146    
147  /* Initialize the hooks.  /* Initialize the hooks; a named mutex prevents that the
148     To prevent double initialisation, we use a named mutex. */     initialisation is done twice.
149       Return value: 0 on success. */
150  int  int
151  gpgoe_initialize (void)  gpgoe_initialize (void)
152  {  {
# Line 113  gpgoe_initialize (void) Line 158  gpgoe_initialize (void)
158  }  }
159    
160    
161  /* Deinitialize the hooks and close all handles. */  /* Deinitialize the hooks and close all handles.
162       Return value: 0 on success. */
163  int  int
164  gpgoe_remove (void)  gpgoe_remove (void)
165  {  {
     int rc = 0;  
166      HANDLE hd;      HANDLE hd;
167        int rc;
168    
169      hd = CreateMutex (NULL, TRUE, "gpgoe");      hd = CreateMutex (NULL, TRUE, "gpgoe");
170      if (GetLastError() == ERROR_ALREADY_EXISTS) {      if (GetLastError() == ERROR_ALREADY_EXISTS) {

Legend:
Removed from v.1  
changed lines
  Added in v.16

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26