/[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 18 by twoaday, Thu Apr 13 07:41:30 2006 UTC revision 24 by twoaday, Tue Dec 13 10:40:30 2011 UTC
# Line 1  Line 1 
1  /* GPGOE.c - GnuPG for Outlook Express  /* GPGOE.c - GnuPG for Outlook Express
2   *      Copyright (C) 2001, 2002, 2003, 2006 Timo Schulz   *      Copyright (C) 2001, 2002, 2003, 2006, 2007 Timo Schulz
3   *   *
4   * This file is part of GPGOE.   * This file is part of GPGOE.
5   *   *
# Line 12  Line 12 
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   * GNU General Public License for more details.   * GNU General Public License for more details.
  *  
  * You should have received a copy of the GNU Lesser General Public License  
  * along with GPGOE; if not, write to the Free Software Foundation,  
  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA  
15   */   */
16    
17  #ifdef HAVE_CONFIG_H  #ifdef HAVE_CONFIG_H
# Line 41  static HWND oe_hwnd = NULL; Line 37  static HWND oe_hwnd = NULL;
37    
38  /* We need a shared section to define variables which  /* We need a shared section to define variables which
39     will keep their values in all address spaces. */     will keep their values in all address spaces. */
40  #ifdef __GNUC__  #ifndef __GNUC__
41  #define ATTR_SEC __attribute__((section (".SHARDAT"), shared))  #pragma  data_seg(".SHARDAT")
 #else  
 #define ATTR_SEC  
 #pragma data_seg(".SHARDAT")  
42  #endif  #endif
43  static int gpgoe_active_modes ATTR_SEC = 0;  /* Supported GPGOE feature modes. */
44    int gpgoe_active_modes ATTR_SEC = 0;
45    
46    /* FIXME: we currently limit the passphrase to N octets. */
47    char gpgoe_pass_cache[HASH_BUCKETS][MAX_PASS_LEN];
48  #ifndef __GNUC__  #ifndef __GNUC__
49  #pragma data_seg()  #pragma data_seg()
50  #endif  #endif
 #undef ATTR_SEC  
   
   
 /* Supported plug-in modes. */  
 enum gpgoe_mode_t {  
     GPGOE_MODE_NORMAL     = 0,  
     GPGOE_MODE_PLAINREPLY = 1      /* decrypt mails before a reply. */  
 };  
51    
52    
53  /* Main DLL entry point. */  /* Main DLL entry point. */
# Line 85  DllMain (HINSTANCE hinst_dll, DWORD reas Line 74  DllMain (HINSTANCE hinst_dll, DWORD reas
74  }  }
75    
76    
77    #if 0
78  /* Quick and dirty check if the dialog is a common dialog  /* Quick and dirty check if the dialog is a common dialog
79     and the 'File {Open, Save}' style. */     and the 'File {Open, Save}' style. */
80  static int  static int
# Line 100  is_common_file_dlg (HWND h) Line 90  is_common_file_dlg (HWND h)
90          return -1;          return -1;
91      return 0;      return 0;
92  }  }
93    #endif
94    
95    
96  /* CTB hook procedure.  /* CTB hook procedure.
# Line 118  ctb_proc (int code, WPARAM wparam, LPARA Line 108  ctb_proc (int code, WPARAM wparam, LPARA
108      hwnd = (HWND)wparam;      hwnd = (HWND)wparam;
109      switch (code) {      switch (code) {
110      case HCBT_CREATEWND:      case HCBT_CREATEWND:
111          GetClassName (hwnd, wclass, sizeof (wclass) - 1);          GetClassName (hwnd, wclass, DIM (wclass) - 1);
112          if (!strcmp (wclass, "ATH_Note")) {          if (!strcmp (wclass, "ATH_Note")) {
113              oe_proc_old = (WNDPROC) GetWindowLong (hwnd, GWL_WNDPROC);              oe_proc_old = (WNDPROC) GetWindowLong (hwnd, GWL_WNDPROC);
114              if (!oe_proc_old)              if (!oe_proc_old)
# Line 147  ctb_proc (int code, WPARAM wparam, LPARA Line 137  ctb_proc (int code, WPARAM wparam, LPARA
137          }          }
138          break;          break;
139    
 #if 0  
140      case HCBT_ACTIVATE:      case HCBT_ACTIVATE:
141          if (plugin_active != NULL &&  #if 0 /* Disable the attachment related code for now. */
142            if (plugin_active != NULL &&
143              WaitForSingleObject (plugin_active, 0) == WAIT_OBJECT_0) {              WaitForSingleObject (plugin_active, 0) == WAIT_OBJECT_0) {
             char wclass[200];  
144    
145              if (GetClassName (hwnd, wclass, sizeof (wclass)-1) <= 0 ||              if (GetClassName (hwnd, wclass, sizeof (wclass)-1) <= 0 ||
146                  !strstr (wclass, "#32770") || !is_common_file_dlg (hwnd))                  !strstr (wclass, "#32770") || !is_common_file_dlg (hwnd))
# Line 159  ctb_proc (int code, WPARAM wparam, LPARA Line 148  ctb_proc (int code, WPARAM wparam, LPARA
148              of_proc_old = (WNDPROC)GetWindowLong (hwnd, GWL_WNDPROC);              of_proc_old = (WNDPROC)GetWindowLong (hwnd, GWL_WNDPROC);
149              SetWindowLong (hwnd, GWL_WNDPROC, (LONG)(WNDPROC)of_proc);              SetWindowLong (hwnd, GWL_WNDPROC, (LONG)(WNDPROC)of_proc);
150          }          }
151    #endif
152          break;          break;
 #endif    
153      }        }  
154      return CallNextHookEx (ctb_hook, code, wparam, lparam);      return CallNextHookEx (ctb_hook, code, wparam, lparam);
155  }  }
# Line 172  ctb_proc (int code, WPARAM wparam, LPARA Line 161  ctb_proc (int code, WPARAM wparam, LPARA
161  int  int
162  gpgoe_initialize (void)  gpgoe_initialize (void)
163  {  {
164        reset_pass_cache ();
165      CreateMutex (NULL, TRUE, "gpgoe");      CreateMutex (NULL, TRUE, "gpgoe");
166      if (GetLastError () == ERROR_ALREADY_EXISTS)      if (GetLastError () == ERROR_ALREADY_EXISTS)
167          return 0;          return 0;
# Line 187  gpgoe_remove (void) Line 177  gpgoe_remove (void)
177  {  {
178      HANDLE hd;      HANDLE hd;
179      int rc;      int rc;
180        
181      hd = CreateMutex (NULL, TRUE, "gpgoe");      hd = CreateMutex (NULL, TRUE, "gpgoe");
182      if (GetLastError() == ERROR_ALREADY_EXISTS) {      if (GetLastError() == ERROR_ALREADY_EXISTS) {
183          oe_hwnd = NULL;          oe_hwnd = NULL;
# Line 195  gpgoe_remove (void) Line 185  gpgoe_remove (void)
185      }      }
186      SetWindowLong (oe_hwnd, GWL_WNDPROC, (LONG)(WNDPROC)oe_proc_old);      SetWindowLong (oe_hwnd, GWL_WNDPROC, (LONG)(WNDPROC)oe_proc_old);
187      rc = UnhookWindowsHookEx (ctb_hook);      rc = UnhookWindowsHookEx (ctb_hook);
188    
189        /* reset global variables. */
190        reset_pass_cache ();
191        gpgoe_active_modes = 0;
192    
193      return rc ? 0 : (int)GetLastError ();      return rc ? 0 : (int)GetLastError ();
194  }  }
195    
# Line 212  gpgoe_get_active_modes (void) Line 207  gpgoe_get_active_modes (void)
207  {  {
208      return gpgoe_active_modes;      return gpgoe_active_modes;
209  }  }
   

Legend:
Removed from v.18  
changed lines
  Added in v.24

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26