/[winpt]/trunk/Src/wptRegistry.cpp
ViewVC logotype

Diff of /trunk/Src/wptRegistry.cpp

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

revision 117 by twoaday, Thu Dec 8 09:26:32 2005 UTC revision 167 by twoaday, Thu Jan 26 10:17:17 2006 UTC
# Line 36  Line 36 
36    
37  #define rc_ok(rc) ((rc) == ERROR_SUCCESS)  #define rc_ok(rc) ((rc) == ERROR_SUCCESS)
38    
 static gpg_filetype gpg_filetypes[] = {  
     {"GPG Detached Signature", ".sig", 1},  
     {"GPG Encrypted Data",     ".gpg", 2},  
     {"GPG Armored Data",       ".asc", 2},  
     {0}  
 };  
39    
40    
41  struct reg_hotkey_s reg_hotkeys[] = {  struct reg_hotkey_s reg_hotkeys[] = {
# Line 61  winpt_reg_prefs_s reg_prefs; Line 55  winpt_reg_prefs_s reg_prefs;
55  #define WINPT_REG "Software\\WinPT"  #define WINPT_REG "Software\\WinPT"
56    
57    
58    /* Return != 0 if GPG4win is installed. */
59    int
60    is_gpg4win_installed (void)
61    {
62        char *p;
63    
64        p = get_reg_entry_gpg4win (NULL);
65        if (!p)
66            return 0;
67        if (dir_exist_check (p)) {
68            free_if_alloc (p);
69            return 0;
70        }
71        free_if_alloc (p);
72        return -1;
73    }
74    
75    
76  /* Return != 0 if GPGee is installed. */  /* Return != 0 if GPGee is installed. */
77  int  int
78  is_gpgee_installed (void)  is_gpgee_installed (void)
# Line 93  free_reg_prefs (void) Line 105  free_reg_prefs (void)
105  static int  static int
106  regist_single_filetype (gpg_filetype *gfile)  regist_single_filetype (gpg_filetype *gfile)
107  {  {
108      char icon[256], prog[256];      char icon[256];
109        char prog[256];
110            
111      memset (&icon, 0, sizeof (icon));      memset (&icon, 0, sizeof (icon));
112      GetModuleFileName (glob_hinst, prog, sizeof (prog)-1);      GetModuleFileName (glob_hinst, prog, sizeof (prog)-1);
# Line 132  regist_inst_gnupg (int create_mokey) Line 145  regist_inst_gnupg (int create_mokey)
145      }      }
146    
147      return 0;      return 0;
148  } /* regist_inst_gpg */  }
149    
150    
151  /* Install WinPT into the W32 registry, if the entry already  /* Install WinPT into the W32 registry, if the entry already
# Line 142  regist_inst_gnupg (int create_mokey) Line 155  regist_inst_gnupg (int create_mokey)
155     Return value: 0 on success. */     Return value: 0 on success. */
156  int  int
157  regist_inst_winpt (int with_ext, int *created)  regist_inst_winpt (int with_ext, int *created)
158  {  {    
159      HKEY reg;      HKEY reg;
160      char *p = NULL;      char *p = NULL;
161      char modpath[MAX_PATH+1];      char modpath[MAX_PATH+1];
162      int rc, i, id, n = 0;      int rc, i, id, n = 0;
163    
164        gpg_filetype gpg_filetypes[] = {
165            {_("GPG Detached Signature"), ".sig", 1},
166            {_("GPG Encrypted Data"),     ".gpg", 2},
167            {_("GPG Armored Data"),       ".asc", 2},
168            {0}
169        };
170    
171      if (created)      if (created)
172          *created = 0;          *created = 0;
173    
# Line 184  start: Line 204  start:
204      if (rc_ok (rc)) {      if (rc_ok (rc)) {
205          RegCloseKey (reg);          RegCloseKey (reg);
206          rc = RegOpenKeyEx (HKEY_CURRENT_USER, WINPT_REG"\\Keyserver", 0, KEY_READ, &reg);          rc = RegOpenKeyEx (HKEY_CURRENT_USER, WINPT_REG"\\Keyserver", 0, KEY_READ, &reg);
207          if( !rc_ok (rc)) {          if (!rc_ok (rc)) {
208              RegCreateKey (HKEY_CURRENT_USER, WINPT_REG"\\Keyserver", &reg);              RegCreateKey (HKEY_CURRENT_USER, WINPT_REG"\\Keyserver", &reg);
209              RegCloseKey (reg);              RegCloseKey (reg);
210          }          }
# Line 197  start: Line 217  start:
217          }          }
218          free_if_alloc (p);          free_if_alloc (p);
219          if (n)          if (n)
220              set_reg_entry (HKEY_CURRENT_USER, WINPT_REG, "Extensions", "1");              set_reg_entry( HKEY_CURRENT_USER, WINPT_REG, "Extensions", "1" );
221          return 0;          return 0;
222      }      }
223      rc = RegCreateKey (HKEY_CURRENT_USER, WINPT_REG, &reg);      rc = RegCreateKey (HKEY_CURRENT_USER, WINPT_REG, &reg);
# Line 206  start: Line 226  start:
226      if (created)      if (created)
227          *created = 1;          *created = 1;
228      RegCloseKey (reg);      RegCloseKey (reg);
229      if (n)      if (n > 0 || is_gpgee_installed ())
230          set_reg_entry (HKEY_CURRENT_USER, WINPT_REG, "Extensions", "1");          set_reg_entry (HKEY_CURRENT_USER, WINPT_REG, "Extensions", "1");
231      if ((n=GetModuleFileName (NULL, modpath, MAX_PATH-1)) > 0) {      if ((n=GetModuleFileName (NULL, modpath, MAX_PATH-1)) > 0) {
232          while (n-- > 0) {          while (n-- > 0) {
# Line 224  start: Line 244  start:
244  /* Create a new filetype in the W32 registry.  /* Create a new filetype in the W32 registry.
245     We should really care of errors! Otherwise we can damage the registry! */     We should really care of errors! Otherwise we can damage the registry! */
246  int  int
247  create_file_type( const char *exefile, const char *ext, const char *extname, char *iconfile )  create_file_type (const char *exefile, const char *ext,
248                      const char *extname, char *iconfile)
249  {  {
250      int rc;      int rc;
251      HKEY reg = NULL;      HKEY reg = NULL;
# Line 290  expand_path (const char *path) Line 311  expand_path (const char *path)
311          return NULL;          return NULL;
312      len += 1;      len += 1;
313      p = new char[len+1];      p = new char[len+1];
314      if( !p )      if (!p)
315          return NULL;          return NULL;
316      len = ExpandEnvironmentStrings (path, p, len);      len = ExpandEnvironmentStrings (path, p, len);
317      if (!len) {      if (!len) {
# Line 298  expand_path (const char *path) Line 319  expand_path (const char *path)
319          return NULL;          return NULL;
320      }      }
321      return p;      return p;
322  } /* expand_path */  }
323    
324    
325  /* Retrieve a registry entry with the directory given in @dir  /* Retrieve a registry entry with the directory given in @dir
# Line 311  get_reg_entry (HKEY root_key, const char Line 332  get_reg_entry (HKEY root_key, const char
332      char text[384] = {0};      char text[384] = {0};
333      DWORD nbytes, type;      DWORD nbytes, type;
334      HKEY reg_key = NULL;      HKEY reg_key = NULL;
335      char *p = NULL;      char * p = NULL;
336            
337      rc = RegOpenKeyEx (root_key, dir, 0, KEY_QUERY_VALUE, &reg_key);      rc = RegOpenKeyEx (root_key, dir, 0, KEY_QUERY_VALUE, &reg_key);
338      if( !rc_ok( rc ) )      if( !rc_ok( rc ) )
# Line 397  set_reg_entry_gpg (const char * key, con Line 418  set_reg_entry_gpg (const char * key, con
418  }  }
419    
420    
   
   
421  int  int
422  set_reg_entry_mo (const char * value)  set_reg_entry_mo (const char * value)
423  {        {      
# Line 407  set_reg_entry_mo (const char * value) Line 426  set_reg_entry_mo (const char * value)
426  }  }
427    
428    
429  char *  char*
430  get_reg_entry_gpg (const char *key)  get_reg_entry_gpg (const char *key)
431  {  {
432      return get_reg_entry (HKEY_CURRENT_USER, "Software\\GNU\\GnuPG", key);      char *p;
433        p = get_reg_entry (HKEY_CURRENT_USER, "Software\\GNU\\GnuPG", key);
434        if (!p || strlen (p) == 0) {
435            free_if_alloc (p);
436            return NULL;
437        }
438        return p;
439  }  }
440    
441    
# Line 493  set_reg_winpt_single (int id, int val) Line 518  set_reg_winpt_single (int id, int val)
518  int  int
519  get_reg_winpt_single (int id)  get_reg_winpt_single (int id)
520  {  {
521      char *buf = NULL;      char * buf = NULL;
522      int val = 0;      int val = 0;
523    
524      buf = get_reg_entry (HKEY_CURRENT_USER, WINPT_REG, cfg[id]);      buf = get_reg_entry (HKEY_CURRENT_USER, WINPT_REG, cfg[id]);
# Line 568  set_reg_winpt_prefs (winpt_reg_prefs_s * Line 593  set_reg_winpt_prefs (winpt_reg_prefs_s *
593          if (rc)          if (rc)
594              goto leave;              goto leave;
595      }      }
     if (opt->kserv_conf) {  
         rc = set_reg_entry (HKEY_CURRENT_USER, WINPT_REG, "KeyserverConfig",  
                             opt->kserv_conf);  
         if (rc)  
             goto leave;  
     }  
596    
597      for (i=0; reg_hotkeys[i].reg_entry; i++) {      for (i=0; reg_hotkeys[i].reg_entry; i++) {
598          strcpy (buf, " ");          strcpy (buf, " ");
# Line 684  get_reg_winpt_prefs (winpt_reg_prefs_s * Line 703  get_reg_winpt_prefs (winpt_reg_prefs_s *
703      if (val && val[0] != ' ')      if (val && val[0] != ' ')
704          opt->backup.path = m_strdup (val);          opt->backup.path = m_strdup (val);
705      free_if_alloc (val);      free_if_alloc (val);
   
     val = get_reg_entry (HKEY_CURRENT_USER, WINPT_REG, "KeyserverConfig");  
     if (val && val[0] != ' ')  
         opt->kserv_conf = m_strdup (val);  
     free_if_alloc (val);  
706            
707      for (i=0; reg_hotkeys[i].reg_entry; i++) {      for (i=0; reg_hotkeys[i].reg_entry; i++) {
708          val = get_reg_entry (HKEY_CURRENT_USER, WINPT_REG, reg_hotkeys[i].reg_entry);          val = get_reg_entry (HKEY_CURRENT_USER, WINPT_REG, reg_hotkeys[i].reg_entry);

Legend:
Removed from v.117  
changed lines
  Added in v.167

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26