Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added copyright and licence header to the C++ source and header files in the export...
[xestiaab/.git] / source / export / export.cpp
1 // export.cpp - Export subroutines.
2 //
3 // (c) 2012-2015 Xestia Software Development.
4 //
5 // This file is part of Xestia Address Book.
6 //
7 // Xestia Address Book is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by the
9 // Free Software Foundation, version 3 of the license.
10 //
11 // Xestia Address Book is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License along
17 // with Xestia Address Book. If not, see <http://www.gnu.org/licenses/>
19 #include <wx/filedlg.h>
20 #include <wx/arrstr.h>
21 #include <csignal>
23 #include "../frmMain.h"
24 #include "export-vcard3.h"
25 #include "export-vcard4.h"
27 void ExportRun(frmMain *frmMainPtrInc, wxArrayString *FileListInc){
29         frmMainPtrInc->PauseAllTimers();
31         wxString FileTypes;
32         
33         bool DirMode = FALSE;
34         long ContactsExported = 0;
35         long ContactsCollected = 0;
36         int ExportType = 0;
37         int ExportCount = 0;
38         wxString FinalFilename;
39         
40         FileTypes.Append(wxT("vCard 4.0 (directory, one contact per file) (*.vcf)"));
41         FileTypes.Append(wxT("|*.vcf|"));
42         FileTypes.Append(wxT("vCard 4.0 (file, all contacts in one file) (*.vcf)"));
43         FileTypes.Append(wxT("|*.vcf|"));
44         FileTypes.Append(wxT("vCard 3.0 (directory, one contact per file) (*.vcf)"));
45         FileTypes.Append(wxT("|*.vcf|"));
46         FileTypes.Append(wxT("vCard 3.0 (file, all contacts in one file) (*.vcf)"));
47         FileTypes.Append(wxT("|*.vcf"));
49         // Open up the dialog to export file data.
50         
51         wxFileDialog ExportDlg(frmMainPtrInc, wxT("Export Contacts"), wxT(""), wxT(""),
52                 FileTypes, wxFD_SAVE|wxFD_OVERWRITE_PROMPT);
53         
54         if (ExportDlg.ShowModal() == wxID_CANCEL){
55         
56                 frmMainPtrInc->ResumeAllTimers();
57                 return;
58         
59         }
61         // Find which data type is being used.
62                 
63         ExportType = ExportDlg.GetFilterIndex();
65         if (ExportType == 0 || ExportType == 2){
66                 DirMode = TRUE;
67         }
69         // Process the filename based on data type.
70         
71         if (DirMode == FALSE){
72         
73                 // All contacts exported into one file. Setup the filename.
74         
75                 FinalFilename = ExportDlg.GetPath();
76         
77         } else {
78         
79                 // One contact per filename. Setup the directory name.
80         
81                 FinalFilename = ExportDlg.GetDirectory();
82         
83         }
85         if (ExportType == 0 || ExportType == 1){
86         
87                 ExportVCard4(DirMode, FinalFilename, FileListInc, &ExportCount);
88         
89         }
90         
91         // vCard 3.0 export
92         
93         if (ExportType == 2 || ExportType == 3){
94         
95                 ExportVCard3(DirMode, FinalFilename, FileListInc, &ExportCount);
97         }
98         
99         // Notify the user of how many contacts
100         // were exported.
101         
102         wxMessageBox(wxString::Format(_("%i contacts exported."), ExportCount), _("Contacts exported"));
103         
104         frmMainPtrInc->ResumeAllTimers();
106
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