/[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 116 by twoaday, Fri Nov 18 07:20:40 2005 UTC revision 117 by twoaday, Thu Dec 8 09:26:32 2005 UTC
# Line 43  static gpg_filetype gpg_filetypes[] = { Line 43  static gpg_filetype gpg_filetypes[] = {
43      {0}      {0}
44  };  };
45    
46    
47  struct reg_hotkey_s reg_hotkeys[] = {  struct reg_hotkey_s reg_hotkeys[] = {
48      {"ClipEncrypt", "", 0},      {"ClipEncrypt", "", 0},
49      {"ClipDecrypt", "", 0},      {"ClipDecrypt", "", 0},
# Line 60  winpt_reg_prefs_s reg_prefs; Line 61  winpt_reg_prefs_s reg_prefs;
61  #define WINPT_REG "Software\\WinPT"  #define WINPT_REG "Software\\WinPT"
62    
63    
64    /* Return != 0 if GPGee is installed. */
65    int
66    is_gpgee_installed (void)
67    {
68        HKEY hk;
69        LONG ec;
70    
71        ec = RegOpenKeyEx (HKEY_CURRENT_USER, "Software\\GPGee", 0, KEY_READ, &hk);
72        if (ec == ERROR_SUCCESS) {
73            RegCloseKey (hk);
74            return -1;
75        }
76    
77        return 0;
78    }
79    
80    
81    /* Free all members in the registry preference struct. */
82  void  void
83  free_reg_prefs (void)  free_reg_prefs (void)
84  {  {
# Line 67  free_reg_prefs (void) Line 86  free_reg_prefs (void)
86      free_if_alloc (reg_prefs.kserv_conf);      free_if_alloc (reg_prefs.kserv_conf);
87      free_if_alloc (reg_prefs.homedir);      free_if_alloc (reg_prefs.homedir);
88      memset (&reg_prefs, 0, sizeof reg_prefs);      memset (&reg_prefs, 0, sizeof reg_prefs);
89  } /* free_reg_prefs */  }
90    
91    
92  /* Register the given WinPT filetype. */  /* Register the given WinPT filetype. */
# Line 80  regist_single_filetype (gpg_filetype *gf Line 99  regist_single_filetype (gpg_filetype *gf
99      GetModuleFileName (glob_hinst, prog, sizeof (prog)-1);      GetModuleFileName (glob_hinst, prog, sizeof (prog)-1);
100      _snprintf (icon, sizeof (icon) -1, "%s,%d", prog, gfile->nicon);      _snprintf (icon, sizeof (icon) -1, "%s,%d", prog, gfile->nicon);
101      return create_file_type (prog, gfile->ext, gfile->descr, icon);      return create_file_type (prog, gfile->ext, gfile->descr, icon);
102  } /* regist_single_filetype */  }
103    
104    
105  /* Install the GPG related into the W32 resgistry, if the entry already  /* Install the GPG related into the W32 resgistry, if the entry already
# Line 116  regist_inst_gnupg (int create_mokey) Line 135  regist_inst_gnupg (int create_mokey)
135  } /* regist_inst_gpg */  } /* regist_inst_gpg */
136    
137    
138  /* Install WinPT into the W32 registry, if the entry already  /* Install WinPT into the W32 registry, if the entry already
139     exists the function returns immediately. @with_ext can be     exists the function returns immediately. @with_ext can be
140     used to register some file types (if 1). @created contains     used to register some file types (if 1). @created contains
141     1 if the registry key was created.     1 if the registry key was created.
142     Return value: 0 on success. */     Return value: 0 on success. */
143  int  int
144  regist_inst_winpt (int with_ext, int * created)  regist_inst_winpt (int with_ext, int *created)
145  {  {
146      HKEY reg;      HKEY reg;
147      char *p = NULL;      char *p = NULL;
# Line 133  regist_inst_winpt (int with_ext, int * c Line 152  regist_inst_winpt (int with_ext, int * c
152          *created = 0;          *created = 0;
153    
154      p = get_reg_entry (HKEY_CURRENT_USER, WINPT_REG, "Extensions");      p = get_reg_entry (HKEY_CURRENT_USER, WINPT_REG, "Extensions");
155      if (p && *p == '1')      if ((p && *p == '1') || is_gpgee_installed ())
156          with_ext = 0;          with_ext = 0;
157      free_if_alloc (p);      free_if_alloc (p);
158    
# Line 162  regist_inst_winpt (int with_ext, int * c Line 181  regist_inst_winpt (int with_ext, int * c
181                    
182  start:  start:
183      rc = RegOpenKeyEx (HKEY_CURRENT_USER, WINPT_REG, 0, KEY_READ, &reg);      rc = RegOpenKeyEx (HKEY_CURRENT_USER, WINPT_REG, 0, KEY_READ, &reg);
184      if (rc_ok (rc)) {        if (rc_ok (rc)) {
185          RegCloseKey (reg);          RegCloseKey (reg);
186          rc = RegOpenKeyEx (HKEY_CURRENT_USER, WINPT_REG"\\Keyserver", 0, KEY_READ, &reg);          rc = RegOpenKeyEx (HKEY_CURRENT_USER, WINPT_REG"\\Keyserver", 0, KEY_READ, &reg);
187          if (!rc_ok (rc)) {          if( !rc_ok (rc)) {
188              RegCreateKey (HKEY_CURRENT_USER, WINPT_REG"\\Keyserver", &reg);              RegCreateKey (HKEY_CURRENT_USER, WINPT_REG"\\Keyserver", &reg);
189              RegCloseKey (reg);              RegCloseKey (reg);
190          }          }
# Line 181  start: Line 200  start:
200              set_reg_entry (HKEY_CURRENT_USER, WINPT_REG, "Extensions", "1");              set_reg_entry (HKEY_CURRENT_USER, WINPT_REG, "Extensions", "1");
201          return 0;          return 0;
202      }      }
203      rc = RegCreateKey(HKEY_CURRENT_USER, WINPT_REG, &reg);      rc = RegCreateKey (HKEY_CURRENT_USER, WINPT_REG, &reg);
204      if (!rc_ok (rc))      if (!rc_ok (rc))
205          return WPTERR_REGISTRY;          return WPTERR_REGISTRY;
206      if (created)      if (created)
# Line 196  start: Line 215  start:
215                  break;                  break;
216              }              }
217          }          }
218          set_reg_entry (HKEY_CURRENT_USER, WINPT_REG,          set_reg_entry (HKEY_CURRENT_USER, WINPT_REG, "Install Directory", modpath);
                        "Install Directory", modpath);  
219      }      }
       
220      return 0;      return 0;
221  }  }
222    
# Line 380  set_reg_entry_gpg (const char * key, con Line 397  set_reg_entry_gpg (const char * key, con
397  }  }
398    
399    
400    
401    
402  int  int
403  set_reg_entry_mo (const char * value)  set_reg_entry_mo (const char * value)
404  {        {      
# Line 421  get_reg_entry_mo (void) Line 440  get_reg_entry_mo (void)
440  {        {      
441      char *p, *pp;      char *p, *pp;
442      const char *lang;      const char *lang;
443        
444      p = get_reg_entry (HKEY_CURRENT_USER,      p = get_reg_entry (HKEY_CURRENT_USER,
445                         "Control Panel\\Mingw32\\NLS", "MODir");                         "Control Panel\\Mingw32\\NLS", "MODir");
446      if (p)      if (p)
447          return p;          return p;
448        
449      lang = get_gettext_langid ();      lang = get_gettext_langid ();
450      if (!lang)      if (!lang)    
451          return NULL;          return NULL;    
452      pp = new char[strlen ("share\\xxxxx\\locale\\LC_MESSAGES")+8];      pp = new char[strlen ("share\\xxxxx\\locale\\LC_MESSAGES")+8];
453      if (!pp)      if (!pp)    
454          BUG (NULL);          BUG (NULL);
455      sprintf (pp, "share\\locale\\%s\\LC_MESSAGES", lang);      sprintf (pp, "share\\locale\\%s\\LC_MESSAGES", lang);
456      p = get_reg_entry_gpg4win (pp);      p = get_reg_entry_gpg4win (pp);
# Line 474  set_reg_winpt_single (int id, int val) Line 493  set_reg_winpt_single (int id, int val)
493  int  int
494  get_reg_winpt_single (int id)  get_reg_winpt_single (int id)
495  {  {
496      char * buf = NULL;      char *buf = NULL;
497      int val = 0;      int val = 0;
498    
499      buf = get_reg_entry (HKEY_CURRENT_USER, WINPT_REG, cfg[id]);      buf = get_reg_entry (HKEY_CURRENT_USER, WINPT_REG, cfg[id]);
# Line 602  get_reg_winpt_flag (const char * name) Line 621  get_reg_winpt_flag (const char * name)
621  int  int
622  get_reg_winpt_prefs (winpt_reg_prefs_s * opt)  get_reg_winpt_prefs (winpt_reg_prefs_s * opt)
623  {  {
624      char * val = NULL;      char *val = NULL;
625      size_t i;      size_t i;
626    
627      for (i=1; i < DIM (cfg); i++) {      for (i=1; i < DIM (cfg); i++) {

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26