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

Diff of /trunk/Src/wptFileSaveDlg.cpp

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

revision 23 by twoaday, Fri Sep 30 10:10:16 2005 UTC revision 105 by twoaday, Wed Nov 30 10:22:00 2005 UTC
# Line 1  Line 1 
1  /* wptFileSaveDlg.cpp - Save a file  /* wptFileSaveDlg.cpp - Save a file
2   *      Copyright (C) 2002, 2003 Timo Schulz   *      Copyright (C) 2002, 2003, 2005 Timo Schulz
3   *   *
4   * This file is part of WinPT.   * This file is part of WinPT.
5   *   *
6   * WinPT is free software; you can redistribute it and/or modify   * WinPT is free software; you can redistribute it and/or modify
7   * it under the terms of the GNU General Public License as published by   * it under the terms of the GNU General Public License as published by
8   * the Free Software Foundation; either version 2 of the License, or   * the Free Software Foundation; either version 2 of the License, or
9   * (at your option) any later version.   * (at your option) any later version.
10   *   *
11   * WinPT is distributed in the hope that it will be useful,   * WinPT is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   * GNU General Public License for more details.   * GNU General Public License for more details.
15   *   *
16   * You should have received a copy of the GNU General Public License   * You should have received a copy of the GNU General Public License
17   * along with WinPT; if not, write to the Free Software Foundation,   * along with WinPT; if not, write to the Free Software Foundation,
18   * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA   * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
19   */   */
20    #ifdef HAVE_CONFIG_H
21  #include <windows.h>  #include <config.h>
22    #endif
23  #include "../resource.h"  
24  #include "wptTypes.h"  #include <windows.h>
25  #include "wptNLS.h"  
26  #include "wptGPG.h"  #include "resource.h"
27  #include "wptW32API.h"  #include "wptTypes.h"
28  #include "wptErrors.h"  #include "wptNLS.h"
29    #include "wptGPG.h"
30  static void  #include "wptW32API.h"
31  switch_buttons( HWND dlg, int file )  #include "wptErrors.h"
32  {  
33      int check1 = file? BST_CHECKED : BST_UNCHECKED;  static void
34      int check2 = file? BST_UNCHECKED: BST_CHECKED;  switch_buttons (HWND dlg, int file)
35        {
36      CheckDlgButton( dlg, IDC_FILE_SAVE_TOFILE, check1 );      int check1 = file? BST_CHECKED : BST_UNCHECKED;
37      CheckDlgButton( dlg, IDC_FILE_SAVE_CLIP, check2 );          int check2 = file? BST_UNCHECKED: BST_CHECKED;
38  } /* switch_buttons */      
39        CheckDlgButton (dlg, IDC_FILE_SAVE_TOFILE, check1);
40        CheckDlgButton (dlg, IDC_FILE_SAVE_CLIP, check2);
41  BOOL CALLBACK  }
42  file_save_dlg_proc( HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam )  
43  {      
44      gpgme_data_t sig, plain;  /* Dialog box procedure to save the plaintext of a signature
45      gpgme_error_t err;     plus some additional information. */
46      const char *filename;  BOOL CALLBACK
47      int has_data;  file_save_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam)
48      char file[768];  {    
49            gpgme_data_t sig, plain;
50      switch ( msg ) {      gpgme_error_t err;
51      case WM_INITDIALOG:      const char *filename;
52          #ifndef LANG_DE      int has_data;
53          SetWindowText( dlg, _("Save Plaintext") );      char file[768];
54          #endif      
55          switch_buttons( dlg, 0 );      switch (msg) {
56          SetForegroundWindow( dlg );      case WM_INITDIALOG:
57          return TRUE;          SetWindowText (dlg, _("Save Plaintext"));
58                    SetDlgItemText (dlg, IDCANCEL, _("&Cancel"));
59      case WM_SYSCOMMAND:          SetDlgItemText (dlg, IDC_FILE_SAVE, _("&Save additional information"));
60          if( LOWORD( wparam ) == SC_CLOSE )          SetDlgItemText (dlg, IDC_FILE_SAVE_TOFILE, _("Save to &file"));
61              EndDialog( dlg, TRUE );          SetDlgItemText (dlg, IDC_FILE_SAVE_CLIP, _("Send to &clipboard"));
62          return FALSE;          switch_buttons (dlg, 0);
63                    SetForegroundWindow (dlg);
64      case WM_COMMAND:          return TRUE;
65          switch ( LOWORD(wparam) ) {          
66          case IDC_FILE_SAVE_SELECT:      case WM_SYSCOMMAND:
67              filename = get_filename_dlg( dlg, FILE_SAVE, _("Destination for Plaintext"), NULL, NULL );          if (LOWORD (wparam) == SC_CLOSE)
68              if( filename ) {              EndDialog (dlg, TRUE);
69                  SetDlgItemText( dlg, IDC_FILE_SAVE_FILE, filename );          return FALSE;
70                  switch_buttons( dlg, 1 );          
71              }      case WM_COMMAND:
72              return TRUE;          switch ( LOWORD(wparam) ) {
73                        case IDC_FILE_SAVE_SELECT:
74          case IDOK:              filename = get_filesave_dlg( dlg, _("Destination for Plaintext"), NULL, NULL );
75              if( IsDlgButtonChecked( dlg, IDC_FILE_SAVE_TOFILE ) ) {              if( filename ) {
76                  if( !GetDlgItemText( dlg, IDC_FILE_SAVE_FILE, file, sizeof file - 1 ) ) {                  SetDlgItemText( dlg, IDC_FILE_SAVE_FILE, filename );
77                      msg_box( dlg, _("Please enter a filename."), _("Save Plaintext"), MB_INFO );                  switch_buttons( dlg, 1 );
78                      return FALSE;              }
79                  }              return TRUE;
80                  err = gpg_data_new_from_clipboard (&sig, 0);              
81                  if( err ) {          case IDOK:
82                      msg_box( dlg, winpt_strerror( WPTERR_CLIP_GET ), _("Save Plaintext"), MB_ERR );              if( IsDlgButtonChecked( dlg, IDC_FILE_SAVE_TOFILE ) ) {
83                      return FALSE;                  if( !GetDlgItemText( dlg, IDC_FILE_SAVE_FILE, file, sizeof file - 1 ) ) {
84                  }                      msg_box( dlg, _("Please enter a filename."), _("Save Plaintext"), MB_INFO );
85                  gpg_data_extract_plaintext( sig, &plain );                      return FALSE;
86                  gpg_data_release_and_set_file( plain, file );                  }
87                  gpgme_data_release( sig );                  err = gpg_data_new_from_clipboard (&sig, 0);
88                  msg_box( dlg, _("Finished"), _("Save Plaintext"), MB_OK );                  if( err ) {
89              }                      msg_box( dlg, winpt_strerror( WPTERR_CLIP_GET ), _("Save Plaintext"), MB_ERR );
90              else if( IsDlgButtonChecked( dlg, IDC_FILE_SAVE_CLIP ) ) {                      return FALSE;
91                  if( !gpgme_clip_istext_avail( &has_data ) && !has_data ) {                  }
92                      msg_box( dlg, winpt_strerror( WPTERR_CLIP_ISEMPTY ), _("Save Plaintext"), MB_ERR );                  gpg_data_extract_plaintext( sig, &plain );
93                      return FALSE;                  gpg_data_release_and_set_file( plain, file );
94                  }                  gpgme_data_release( sig );
95                  err = gpg_data_new_from_clipboard (&sig, 0);                  msg_box( dlg, _("Finished"), _("Save Plaintext"), MB_OK );
96                  if( err ) {              }
97                      msg_box( dlg, winpt_strerror( WPTERR_CLIP_GET ), _("Save Plaintext"), MB_ERR );              else if( IsDlgButtonChecked( dlg, IDC_FILE_SAVE_CLIP ) ) {
98                      return FALSE;                  if( !gpg_clip_istext_avail( &has_data ) && !has_data ) {
99                  }                      msg_box( dlg, winpt_strerror( WPTERR_CLIP_ISEMPTY ), _("Save Plaintext"), MB_ERR );
100                  gpg_data_extract_plaintext( sig, &plain );                      return FALSE;
101                  gpg_data_release_and_set_clipboard( plain, 0 );                  }
102                  gpgme_data_release( sig );                  err = gpg_data_new_from_clipboard (&sig, 0);
103                  msg_box( dlg, _("Finished"), _("Save Plaintext"), MB_OK );                  if( err ) {
104              }                      msg_box( dlg, winpt_strerror( WPTERR_CLIP_GET ), _("Save Plaintext"), MB_ERR );
105              EndDialog( dlg, TRUE );                      return FALSE;
106              return TRUE;                  }
107                                gpg_data_extract_plaintext( sig, &plain );
108          case IDCANCEL:                  gpg_data_release_and_set_clipboard( plain, 0 );
109              EndDialog( dlg, FALSE );                  gpgme_data_release( sig );
110              return FALSE;                  msg_box( dlg, _("Finished"), _("Save Plaintext"), MB_OK );
111          }              }
112          break;              EndDialog( dlg, TRUE );
113      }              return TRUE;
114                    
115      return FALSE;          case IDCANCEL:
116  } /* file_save_dlg_proc */              EndDialog( dlg, FALSE );
117                return FALSE;
118            }
119            break;
120        }
121        
122        return FALSE;
123    }

Legend:
Removed from v.23  
changed lines
  Added in v.105

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26