/[gpgoe]/trunk/init/GPGOEInit.c
ViewVC logotype

Diff of /trunk/init/GPGOEInit.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 4 by twoaday, Sat Mar 25 09:02:36 2006 UTC
# Line 18  Line 18 
18   * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA   * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
19   */   */
20    
21    #ifdef HAVE_CONFIG_H
22    #include <config.h>
23    #endif
24  #include <windows.h>  #include <windows.h>
   
25  #include "resource.h"  #include "resource.h"
26    
27  /*-- GPGOE DLL calls --*/  /*-- GPGOE DLL calls --*/
28  int gpgoe_initialize (void);  int gpgoe_initialize (void);
29  int gpgoe_remove (void);  int gpgoe_remove (void);
30    
31    
32    /* Global hinstance for this module. */
33  static HINSTANCE glob_hinst = NULL;  static HINSTANCE glob_hinst = NULL;
34    
35    
36    /* Main procedure for the taskbar program. */
37  LRESULT CALLBACK  LRESULT CALLBACK
38  gpgoe_main_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)  gpgoe_main_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
39  {  {
40      NOTIFYICONDATA NID;      NOTIFYICONDATA NID;
41      int id;      int id;
42    
43      switch (msg)      switch (msg) {
     {  
44      case WM_CREATE:      case WM_CREATE:
45          NID.cbSize = sizeof(NID);          NID.cbSize = sizeof (NID);
46          NID.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;            NID.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;  
47          NID.uCallbackMessage = WM_USER;          NID.uCallbackMessage = WM_USER;
48          NID.hWnd = hwnd;          NID.hWnd = hwnd;
49          NID.hIcon = LoadIcon(glob_hinst, MAKEINTRESOURCE(IDI_GPGOE));          NID.hIcon = LoadIcon (glob_hinst, MAKEINTRESOURCE (IDI_GPGOE));
50          strcpy(NID.szTip, "GPG for Outlook Express");          strcpy (NID.szTip, "GPG for Outlook Express");
51          Shell_NotifyIcon (NIM_ADD, &NID);          Shell_NotifyIcon (NIM_ADD, &NID);
52          DestroyIcon (NID.hIcon);                  DestroyIcon (NID.hIcon);        
53          if (gpgoe_initialize ()) {          if (gpgoe_initialize ()) {
54              MessageBox (hwnd, "Couldn't register GPG OE hook", "Error", MB_ICONERROR|MB_OK);              MessageBox (hwnd, "Couldn't register GPG OE hook",
55                            "Error", MB_ICONERROR|MB_OK);
56              ExitProcess (0);              ExitProcess (0);
57          }          }
58          break;          break;
# Line 55  gpgoe_main_proc(HWND hwnd, UINT msg, WPA Line 60  gpgoe_main_proc(HWND hwnd, UINT msg, WPA
60      case WM_DESTROY:      case WM_DESTROY:
61      case WM_ENDSESSION:      case WM_ENDSESSION:
62          gpgoe_remove ();          gpgoe_remove ();
63          Shell_NotifyIcon(NIM_DELETE, &NID);          Shell_NotifyIcon (NIM_DELETE, &NID);
64          PostQuitMessage (0);          PostQuitMessage (0);
65          ExitProcess (0);          ExitProcess (0);
66          return 0;          return 0;
# Line 63  gpgoe_main_proc(HWND hwnd, UINT msg, WPA Line 68  gpgoe_main_proc(HWND hwnd, UINT msg, WPA
68      case WM_USER:      case WM_USER:
69          switch (lparam) {          switch (lparam) {
70          case WM_LBUTTONDBLCLK:          case WM_LBUTTONDBLCLK:
71              SetForegroundWindow(hwnd);              SetForegroundWindow (hwnd);
72              id = MessageBox (NULL, "Remove the GPG OE plug-in from the system?",              id = MessageBox (NULL, "Remove the GPG OE plug-in from the system?",
73                               "Are you sure?", MB_YESNO|MB_ICONINFORMATION);                               "Are you sure?", MB_YESNO|MB_ICONINFORMATION);
74              if (id == IDYES)              if (id == IDYES)
# Line 88  gpgoe_main_proc(HWND hwnd, UINT msg, WPA Line 93  gpgoe_main_proc(HWND hwnd, UINT msg, WPA
93    
94          case WM_COMMAND:          case WM_COMMAND:
95              if (LOWORD (wparam) == ID_INIT_QUIT)              if (LOWORD (wparam) == ID_INIT_QUIT)
96                  SendMessage(hwnd, WM_DESTROY, 0, 0);                  SendMessage (hwnd, WM_DESTROY, 0, 0);
97              break;              break;
98      }      }
99      return DefWindowProc(hwnd, msg, wparam, lparam);      return DefWindowProc (hwnd, msg, wparam, lparam);
100  }  }
101    
102    
# Line 107  WinMain (HINSTANCE hinst, HINSTANCE prev Line 112  WinMain (HINSTANCE hinst, HINSTANCE prev
112      if (GetLastError () == ERROR_ALREADY_EXISTS)      if (GetLastError () == ERROR_ALREADY_EXISTS)
113          return 0;          return 0;
114    
115      memset(&wc, 0, sizeof(wc));      memset (&wc, 0, sizeof(wc));
116      wc.hInstance = hinst;      wc.hInstance = hinst;
117      wc.lpszClassName = "GPGOE";      wc.lpszClassName = "GPGOE";
118      wc.lpfnWndProc = (WNDPROC)gpgoe_main_proc;      wc.lpfnWndProc = (WNDPROC)gpgoe_main_proc;
119      if (!RegisterClass(&wc)) {      if (!RegisterClass (&wc)) {
120          MessageBox(NULL, "Couldn't register the window class", "Error",          MessageBox (NULL, "Couldn't register the window class",
121              MB_ICONERROR|MB_OK);                      "Error", MB_ICONERROR|MB_OK);
122          return 1;                return 1;
123      }      }
124    
125      hwnd = CreateWindow ("GPGOE", "GPGOE", 0, 0, 0, 0, 0, NULL, NULL, hinst, NULL);      hwnd = CreateWindow ("GPGOE", "GPGOE", 0, 0, 0, 0, 0,
126                             NULL, NULL, hinst, NULL);
127      if (!hwnd) {      if (!hwnd) {
128          MessageBox (NULL, "Couldn't create window", "Error", MB_ICONERROR|MB_OK);          MessageBox (NULL, "Couldn't create window",
129                        "Error", MB_ICONERROR|MB_OK);
130          return 1;          return 1;
131      }      }
132      UpdateWindow (hwnd);      UpdateWindow (hwnd);

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26