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

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26