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

Diff of /trunk/Src/WinPT.cpp

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

revision 132 by twoaday, Mon Dec 19 13:05:59 2005 UTC revision 133 by twoaday, Mon Jan 9 09:15:29 2006 UTC
# Line 1  Line 1 
1  /* WinPT.cpp - Windows Privacy Tray (WinPT)  /* WinPT.cpp - Windows Privacy Tray (WinPT)
2   *      Copyright (C) 2000-2005 Timo Schulz   *      Copyright (C) 2000-2006 Timo Schulz
3   *   *
4   * This file is part of WinPT.   * This file is part of WinPT.
5   *   *
# Line 156  load_gpg_env (void) Line 156  load_gpg_env (void)
156      return 0;      return 0;
157  }  }
158    
159    
160  /* check if the default key from the gpg.conf file is available in the  /* check if the default key from the gpg.conf file is available in the
161     keyring. if not, bail out because encryption won't work properly then. */     keyring. if not, bail out because encryption won't work properly then. */
162  static int  static int
# Line 262  load_keyserver_conf (int quiet) Line 263  load_keyserver_conf (int quiet)
263  }  }
264    
265    
266    /* Check if both keyrings are empty. This indicates that
267       WinPT should offer to generate a key pair. */
268    static bool
269    check_for_empty_keyrings (bool pub_only)
270    {
271        char *p;
272        int n = 0;
273    
274        p = get_gnupg_keyring (1, 0);
275        if (file_exist_check (p) == 0 && get_file_size (p) == 0)
276            n++;
277        free_if_alloc (p);
278        if (pub_only)
279            return n == 1? true : false;
280        p = get_gnupg_keyring (0, 0);
281        if (file_exist_check (p) == 0 && get_file_size (p) == 0)
282            n++;
283        free_if_alloc (p);
284        return n==2? true : false;
285    }
286    
287    
288  /* Enable the mobility mode. */  /* Enable the mobility mode. */
289  static void  static void
290  enable_mobile_mode (void)  enable_mobile_mode (void)
# Line 445  WinMain (HINSTANCE hinst, HINSTANCE hpre Line 468  WinMain (HINSTANCE hinst, HINSTANCE hpre
468              return 0;              return 0;
469          }          }
470      }      }
471        if (check_for_empty_keyrings (false))
472            first_start = 1;
473    
474      if (!first_start) {      if (!first_start) {
475          rc = gpg_check_permissions (1);          rc = gpg_check_permissions (1);
# Line 539  WinMain (HINSTANCE hinst, HINSTANCE hpre Line 564  WinMain (HINSTANCE hinst, HINSTANCE hpre
564      }      }
565            
566      if (start_gpgprefs) {      if (start_gpgprefs) {
         char *ring;  
567          DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_GPGPREFS, hwnd,          DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_GPGPREFS, hwnd,
568                          gpgprefs_dlg_proc, 0);                          gpgprefs_dlg_proc, 0);
569          ring = get_gnupg_keyring (0, !NO_STRICT);          if (check_for_empty_keyrings (true))
570          if (gnupg_access_keyring (0) == -1 && get_file_size (ring) == 0)              first_start = 1; /* The public keyring is empty! */
             first_start = 1; /* The keyring is empty! */  
         free_if_alloc (ring);  
571      }      }
572    
573      if (first_start) {      if (first_start) {
# Line 576  start: Line 598  start:
598              }              }
599              break;              break;
600    
601          case -1:          case -1: /* Cancel/Abort. */
602              DestroyWindow (hwnd);              DestroyWindow (hwnd);
603              free_gnupg_table ();              free_gnupg_table ();
604              return 0;              return 0;

Legend:
Removed from v.132  
changed lines
  Added in v.133

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26