Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Initial import of code already done for Xestia Address Book
[xestiaab/.git] / source / export / export.cpp
1 #include <wx/filedlg.h>
2 #include <wx/arrstr.h>
3 #include <csignal>
5 #include "../frmMain.h"
6 #include "export-vcard3.h"
7 #include "export-vcard4.h"
9 void ExportRun(frmMain *frmMainPtrInc, wxArrayString *FileListInc){
11         frmMainPtrInc->PauseAllTimers();
13         wxString FileTypes;
14         
15         bool DirMode = FALSE;
16         long ContactsExported = 0;
17         long ContactsCollected = 0;
18         int ExportType = 0;
19         int ExportCount = 0;
20         wxString FinalFilename;
21         
22         FileTypes.Append(wxT("vCard 4.0 (directory, one contact per file) (*.vcf)"));
23         FileTypes.Append(wxT("|*.vcf|"));
24         FileTypes.Append(wxT("vCard 4.0 (file, all contacts in one file) (*.vcf)"));
25         FileTypes.Append(wxT("|*.vcf|"));
26         FileTypes.Append(wxT("vCard 3.0 (directory, one contact per file) (*.vcf)"));
27         FileTypes.Append(wxT("|*.vcf|"));
28         FileTypes.Append(wxT("vCard 3.0 (file, all contacts in one file) (*.vcf)"));
29         FileTypes.Append(wxT("|*.vcf"));
31         // Open up the dialog to export file data.
32         
33         wxFileDialog ExportDlg(frmMainPtrInc, wxT("Export Contacts"), wxT(""), wxT(""),
34                 FileTypes, wxFD_SAVE|wxFD_OVERWRITE_PROMPT);
35         
36         if (ExportDlg.ShowModal() == wxID_CANCEL){
37         
38                 frmMainPtrInc->ResumeAllTimers();
39                 return;
40         
41         }
43         // Find which data type is being used.
44                 
45         ExportType = ExportDlg.GetFilterIndex();
47         if (ExportType == 0 || ExportType == 2){
48                 DirMode = TRUE;
49         }
51         // Process the filename based on data type.
52         
53         if (DirMode == FALSE){
54         
55                 // All contacts exported into one file. Setup the filename.
56         
57                 FinalFilename = ExportDlg.GetPath();
58         
59         } else {
60         
61                 // One contact per filename. Setup the directory name.
62         
63                 FinalFilename = ExportDlg.GetDirectory();
64         
65         }
67         if (ExportType == 0 || ExportType == 1){
68         
69                 ExportVCard4(DirMode, FinalFilename, FileListInc, &ExportCount);
70         
71         }
72         
73         // vCard 3.0 export
74         
75         if (ExportType == 2 || ExportType == 3){
76         
77                 ExportVCard3(DirMode, FinalFilename, FileListInc, &ExportCount);
79         }
80         
81         // Notify the user of how many contacts
82         // were exported.
83         
84         wxMessageBox(wxString::Format(_("%i contacts exported."), ExportCount), _("Contacts exported"));
85         //wxMessageBox(_("Selected contacts have been exported."), _("Contacts exported"));
86         
87         frmMainPtrInc->ResumeAllTimers();
89
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy