/[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 167 by twoaday, Thu Jan 26 10:17:17 2006 UTC revision 179 by twoaday, Fri Feb 24 13:12:26 2006 UTC
# Line 36  Line 36 
36    
37  #define rc_ok(rc) ((rc) == ERROR_SUCCESS)  #define rc_ok(rc) ((rc) == ERROR_SUCCESS)
38    
39    #define WINPT_REG "Software\\WinPT"
40    
41    /* GPG file association context. */
42    struct gpg_filetype {    
43        const char *descr;
44        const char *ext;
45        int nicon;
46    };
47    
48  struct reg_hotkey_s reg_hotkeys[] = {  struct reg_hotkey_s reg_hotkeys[] = {
49      {"ClipEncrypt", "", 0},      {"ClipEncrypt", "", 0},
# Line 50  struct reg_hotkey_s reg_hotkeys[] = { Line 57  struct reg_hotkey_s reg_hotkeys[] = {
57      {NULL, "", 0}      {NULL, "", 0}
58  };  };
59    
60    /* Global WinPT registry prefereneces. */
61  winpt_reg_prefs_s reg_prefs;  winpt_reg_prefs_s reg_prefs;
62    
 #define WINPT_REG "Software\\WinPT"  
   
63    
64  /* Return != 0 if GPG4win is installed. */  /* Return != 0 if GPG4win is installed. */
65  int  int
# Line 159  regist_inst_winpt (int with_ext, int *cr Line 165  regist_inst_winpt (int with_ext, int *cr
165      HKEY reg;      HKEY reg;
166      char *p = NULL;      char *p = NULL;
167      char modpath[MAX_PATH+1];      char modpath[MAX_PATH+1];
168      int rc, i, id, n = 0;      int rc, i, id, n;
169    
170      gpg_filetype gpg_filetypes[] = {      gpg_filetype gpg_filetypes[] = {
171          {_("GPG Detached Signature"), ".sig", 1},          {_("GPG Detached Signature"), ".sig", 1},
# Line 170  regist_inst_winpt (int with_ext, int *cr Line 176  regist_inst_winpt (int with_ext, int *cr
176    
177      if (created)      if (created)
178          *created = 0;          *created = 0;
179        if (is_gpgee_installed ())
     p = get_reg_entry (HKEY_CURRENT_USER, WINPT_REG, "Extensions");  
     if ((p && *p == '1') || is_gpgee_installed ())  
180          with_ext = 0;          with_ext = 0;
     free_if_alloc (p);  
181    
     if (with_ext) {  
         id = msg_box (NULL, _("WinPT can register some GPG file types for you so they can "  
                               "be processed with a double click in the explorer.\n"  
                               "Do you want to continue?"), _("WinPT"), MB_YESNO|MB_INFO);  
         if (id == IDNO) {  
             set_reg_entry (HKEY_CURRENT_USER, WINPT_REG, "Extensions", "1");  
             goto start;  
         }  
         for (i = 0; gpg_filetypes[i].ext; i++) {  
             rc = RegOpenKeyEx (HKEY_CLASSES_ROOT, gpg_filetypes[i].ext, 0, KEY_READ, &reg);  
             if (rc_ok (rc)) {  
                 RegCloseKey (reg);  
                 id = log_box (_("WinPT WARNING"), MB_YESNO|MB_INFO,  
                               _("It seems there was already a '%s' file type registered by another application.\n"  
                                 "Do you want to overwrite it?"), gpg_filetypes[i].ext);  
                 if (id == IDNO)  
                     continue;  
             }  
             regist_single_filetype (&gpg_filetypes[i]);  
             n++;  
         }  
     }  
           
 start:  
182      rc = RegOpenKeyEx (HKEY_CURRENT_USER, WINPT_REG, 0, KEY_READ, &reg);      rc = RegOpenKeyEx (HKEY_CURRENT_USER, WINPT_REG, 0, KEY_READ, &reg);
183      if (rc_ok (rc)) {      if (rc_ok (rc)) {
184          RegCloseKey (reg);          RegCloseKey (reg);
# Line 216  start: Line 195  start:
195              set_reg_entry_keyserver ("Default", DEF_HKP_KEYSERVER);              set_reg_entry_keyserver ("Default", DEF_HKP_KEYSERVER);
196          }          }
197          free_if_alloc (p);          free_if_alloc (p);
         if (n)  
             set_reg_entry( HKEY_CURRENT_USER, WINPT_REG, "Extensions", "1" );  
198          return 0;          return 0;
199      }      }
200      rc = RegCreateKey (HKEY_CURRENT_USER, WINPT_REG, &reg);      rc = RegCreateKey (HKEY_CURRENT_USER, WINPT_REG, &reg);
# Line 226  start: Line 203  start:
203      if (created)      if (created)
204          *created = 1;          *created = 1;
205      RegCloseKey (reg);      RegCloseKey (reg);
206      if (n > 0 || is_gpgee_installed ())      if (with_ext) {
207          set_reg_entry (HKEY_CURRENT_USER, WINPT_REG, "Extensions", "1");          id = msg_box (NULL, _("WinPT can register some GPG file types for you so they can "
208                                  "be processed with a double click in the explorer.\n"
209                                  "Do you want to continue?"), _("WinPT"), MB_YESNO|MB_INFO);
210            if (id == IDYES) {
211                for (i = 0; gpg_filetypes[i].ext; i++) {
212                    rc = RegOpenKeyEx (HKEY_CLASSES_ROOT, gpg_filetypes[i].ext, 0, KEY_READ, &reg);
213                    if (rc_ok (rc)) {
214                    RegCloseKey (reg);
215                        id = log_box (_("WinPT WARNING"), MB_YESNO|MB_INFO,
216                                      _("It seems there was already a '%s' file type registered by another application.\n"
217                                        "Do you want to overwrite it?"), gpg_filetypes[i].ext);
218                        if (id == IDNO)
219                            continue;
220                    }
221                    regist_single_filetype (&gpg_filetypes[i]);
222                }
223            }
224        }
225      if ((n=GetModuleFileName (NULL, modpath, MAX_PATH-1)) > 0) {      if ((n=GetModuleFileName (NULL, modpath, MAX_PATH-1)) > 0) {
226          while (n-- > 0) {          while (n-- > 0) {
227              if (modpath[n] == '\\') {              if (modpath[n] == '\\') {
# Line 485  get_reg_entry_mo (void) Line 479  get_reg_entry_mo (void)
479    
480    
481  /* All valid configuration commands. */  /* All valid configuration commands. */
482  static const char * cfg [] = {  static const char *cfg [] = {
483          NULL,      NULL,      
484          "CacheTime",      "CacheTime",
485          "WordWrap",      "WordWrap",
486          "FastMode",      "FastMode",
487          "Viewer",      "Viewer",
488          "KeylistMode",      "WipeMode",
489          "WipeMode",      "AlwaysTrust",
490          "AlwaysTrust",      "AutoBackup",
491          "AutoBackup",      "BackupMode",
492          "BackupMode",      "DisableHotkeys",  
493          "DisableHotkeys",            "NoCompressMultiMedia",    
494          "NoCompressMultiMedia",      "Expert",
495          "Expert",      "FMProgressBar",
496          "FMProgressBar",  };
     };  
497    
498    
499  int  int
# Line 559  set_reg_winpt_prefs (winpt_reg_prefs_s * Line 552  set_reg_winpt_prefs (winpt_reg_prefs_s *
552          case CFG_VIEWER:          case CFG_VIEWER:
553              sprintf (buf, "%d", opt->use_viewer);              sprintf (buf, "%d", opt->use_viewer);
554              break;              break;
         case CFG_KEYLISTMODE:  
             sprintf (buf, "%d", opt->keylist_mode);  
             break;  
555          case CFG_ALWAYSTRUST:          case CFG_ALWAYSTRUST:
556              sprintf (buf, "%d", opt->always_trust);              sprintf (buf, "%d", opt->always_trust);
557              break;              break;
# Line 670  get_reg_winpt_prefs (winpt_reg_prefs_s * Line 660  get_reg_winpt_prefs (winpt_reg_prefs_s *
660          case CFG_VIEWER:          case CFG_VIEWER:
661              opt->use_viewer = atol (val);              opt->use_viewer = atol (val);
662              break;              break;
         case CFG_KEYLISTMODE:  
             opt->keylist_mode = atol (val);  
             break;  
663          case CFG_WIPEMODE:          case CFG_WIPEMODE:
664              opt->wipe_mode = atol (val);              opt->wipe_mode = atol (val);
665              break;              break;

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26