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

Diff of /trunk/Src/wptFileManager.cpp

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

revision 119 by twoaday, Fri Dec 9 08:04:51 2005 UTC revision 177 by twoaday, Tue Feb 14 15:46:29 2006 UTC
# Line 21  Line 21 
21  /* TODO:  /* TODO:
22   *    check_armor_type: we should check the whole file and not only the first line!   *    check_armor_type: we should check the whole file and not only the first line!
23   */   */
24    
25  #ifdef HAVE_CONFIG_H  #ifdef HAVE_CONFIG_H
26  #include <config.h>  #include <config.h>
27  #endif  #endif
# Line 49  Line 50 
50  #include "wptRegistry.h"  #include "wptRegistry.h"
51  #include "wptImport.h"  #include "wptImport.h"
52  #include "wptCrypto.h"  #include "wptCrypto.h"
53    #include "wptKeyManager.h"
54  #include "openpgp.h"  #include "openpgp.h"
55    
56  #define op_begin()  SetCursor (LoadCursor (NULL, IDC_WAIT))  #define op_begin()  SetCursor (LoadCursor (NULL, IDC_WAIT))
# Line 112  overwrite_file (const char *fname) Line 114  overwrite_file (const char *fname)
114    
115  /* Removes 'critical' attributes from the file @fname.  /* Removes 'critical' attributes from the file @fname.
116     If @force is 1, the user is not asked for permission. */     If @force is 1, the user is not asked for permission. */
117  static void  void
118  remove_crit_file_attrs (const char *fname, int force)  remove_crit_file_attrs (const char *fname, int force)
119  {  {
120      u32 fattr;      u32 fattr;
# Line 527  fm_add_dropped_files (listview_ctrl_t lv Line 529  fm_add_dropped_files (listview_ctrl_t lv
529          if (rc == -1)          if (rc == -1)
530              break; /* XXX: fixme? */              break; /* XXX: fixme? */
531      }      }
532        DragFinish (dd_files);
533      return rc;      return rc;
534  }  }
535    
# Line 570  fm_add_opened_files (listview_ctrl_t lv, Line 573  fm_add_opened_files (listview_ctrl_t lv,
573      open.lStructSize = sizeof (OPENFILENAME);      open.lStructSize = sizeof (OPENFILENAME);
574      open.hInstance = glob_hinst;      open.hInstance = glob_hinst;
575      open.lpstrTitle = _("File Open");      open.lpstrTitle = _("File Open");
576      open.lpstrFilter = _("All Files (*.*)\0*.*\0\0");      open.lpstrFilter = "All Files (*.*)\0*.*\0\0";
577      open.hwndOwner = dlg;      open.hwndOwner = dlg;
578      open.lpstrFile = file;      open.lpstrFile = file;
579      open.nMaxFile = sizeof (file) - 1;      open.nMaxFile = sizeof (file) - 1;
# Line 918  fm_parse_files (listview_ctrl_t lv, HWND Line 921  fm_parse_files (listview_ctrl_t lv, HWND
921          fm_encrypt_into_zip (ctx, lv);          fm_encrypt_into_zip (ctx, lv);
922    
923      for (i = 0; i < listview_count_items (lv, 0); i++) {      for (i = 0; i < listview_count_items (lv, 0); i++) {
924          if( !listview_get_item_state( lv, i ) )          if (!listview_get_item_state (lv, i))
925              continue;              continue;
926          listview_get_item_text(lv, i, 1, fname, sizeof (fname) - 1);          listview_get_item_text (lv, i, 1, fname, sizeof (fname) - 1);
927          if( file_exist_check (fname) && !is_directory (fname)) {          if( file_exist_check (fname) && !is_directory (fname)) {
928              log_box (_("File Manager"), MB_ERR,              log_box (_("File Manager"), MB_ERR,
929                       _("\"%s\" does not exist"), fname);                       _("\"%s\" does not exist"), fname);
# Line 939  fm_parse_files (listview_ctrl_t lv, HWND Line 942  fm_parse_files (listview_ctrl_t lv, HWND
942          case FM_SIGNENCRYPT: rc = fm_encrypt( ctx, fname, 1 ); break;          case FM_SIGNENCRYPT: rc = fm_encrypt( ctx, fname, 1 ); break;
943          case FM_DECRYPT:     rc = fm_decrypt( ctx, fname );    break;          case FM_DECRYPT:     rc = fm_decrypt( ctx, fname );    break;
944          case FM_SIGN:        rc = fm_sign( ctx, fname );       break;          case FM_SIGN:        rc = fm_sign( ctx, fname );       break;
945          case FM_SYMENC:      rc = fm_sym_encrypt( ctx, fname );break;          case FM_SYMENC:      rc = fm_sym_encrypt (ctx, fname); break;
946          case FM_VERIFY:      rc = fm_verify (ctx, sig_detached, fname);break;          case FM_VERIFY:      rc = fm_verify (ctx, sig_detached, fname);break;
947          case FM_IMPORT:          case FM_IMPORT:
948              free_if_alloc (ctx->opaque);              free_if_alloc (ctx->opaque);
949              ctx->opaque = m_strdup (fname);              ctx->opaque = m_strdup (fname);
950              if (!ctx->opaque)              if (!ctx->opaque)
951                  BUG (0);                  BUG (0);
952              DialogBoxParam( glob_hinst, (LPCSTR)IDD_WINPT_IMPORT, dlg,              DialogBoxParam (glob_hinst, (LPCSTR)IDD_WINPT_IMPORT, dlg,
953                             file_import_dlg_proc, (LPARAM)ctx );                              file_import_dlg_proc, (LPARAM)ctx);
954              if (ctx->cancel == 1)              if (ctx->cancel == 1)
955                  continue;                  continue;
956              rc = fm_import (ctx, fname);              rc = fm_import (ctx, fname);
957              break;              break;
958          }          }
959            if (ctx->cancel == 1) {
960                ctx->cancel = 0;
961                continue;
962            }
963          fm_set_status (lv, i, fm_cmd, ctx->sigmode, !rc, ctx->output);          fm_set_status (lv, i, fm_cmd, ctx->sigmode, !rc, ctx->output);
964          free_if_alloc (ctx->output);          free_if_alloc (ctx->output);
965          progress_cleanup (&pfx);          progress_cleanup (&pfx);
# Line 1153  fm_sym_encrypt (fm_state_t c, const char Line 1160  fm_sym_encrypt (fm_state_t c, const char
1160      char ext[5], * pass;          char ext[5], * pass;    
1161            
1162      pass = request_passphrase2 (_("Symmetric"), 0, &cancel);      pass = request_passphrase2 (_("Symmetric"), 0, &cancel);
1163      if (cancel)      if (cancel) {
1164            c->cancel = 1;
1165          return 0;          return 0;
1166        }
1167            
1168      /* XXX gpgme_control (ctx, GPGME_CTRL_CIPHER, -1);*/      /* XXX gpgme_control (ctx, GPGME_CTRL_CIPHER, -1);*/
1169      c->output = new char[strlen (name) + 5 + 1];      c->output = new char[strlen (name) + 5 + 1];
# Line 1669  leave: Line 1678  leave:
1678  }  }
1679    
1680    
 /* Generate a user friendly file name based on the key @k. */  
 static char*  
 gen_key_outname (gpgme_key_t k)  
 {  
     char *p;  
     size_t i;  
   
     p = new char[strlen (k->uids->name)+1+8];  
     if (!p)      
         BUG (NULL);  
     sprintf (p, "%s.asc", k->uids->name);  
     for (i=0; i < strlen (p); i++) {  
         if (p[i] == ' ')  
             p[i] = '_';  
     }  
     return p;  
 }  
   
   
1681  /* Export the selected keys from the File Manager to a file. */  /* Export the selected keys from the File Manager to a file. */
1682  int  int
1683  fm_export (fm_state_t c)  fm_export (fm_state_t c)
# Line 1707  fm_export (fm_state_t c) Line 1697  fm_export (fm_state_t c)
1697      }      }
1698    
1699      if (rset[1] == NULL) /* count == 1*/      if (rset[1] == NULL) /* count == 1*/
1700          p = gen_key_outname (rset[0]);          p = km_gen_export_filename (rset[0]->subkeys->keyid+8, 0);
1701    
1702      name = get_filesave_dlg (c->dlg, _("Choose Name for Key File"),      name = get_filesave_dlg (c->dlg, _("Choose Name for Key File"),
1703                               NULL, p? p : NULL);                               NULL, p? p : NULL);

Legend:
Removed from v.119  
changed lines
  Added in v.177

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26