// export.cpp - Export subroutines.
//
// (c) 2012-2015 Xestia Software Development.
//
// This file is part of Xestia Address Book.
//
// Xestia Address Book is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by the
// Free Software Foundation, version 3 of the license.
//
// Xestia Address Book is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with Xestia Address Book. If not, see
#include
#include
#include
#include "../frmMain.h"
#include "export-vcard3.h"
#include "export-vcard4.h"
void ExportRun(frmMain *frmMainPtrInc, wxArrayString *FileListInc){
// Run the export function. Bring up the export file save
// dialog and run the required export functions as needed.
frmMainPtrInc->PauseAllTimers();
wxString FileTypes;
bool DirMode = FALSE;
int ExportType = 0;
int ExportCount = 0;
wxString FinalFilename;
FileTypes.Append(wxT("vCard 4.0 (directory, one contact per file) (*.vcf)"));
FileTypes.Append(wxT("|*.vcf|"));
FileTypes.Append(wxT("vCard 4.0 (file, all contacts in one file) (*.vcf)"));
FileTypes.Append(wxT("|*.vcf|"));
FileTypes.Append(wxT("vCard 3.0 (directory, one contact per file) (*.vcf)"));
FileTypes.Append(wxT("|*.vcf|"));
FileTypes.Append(wxT("vCard 3.0 (file, all contacts in one file) (*.vcf)"));
FileTypes.Append(wxT("|*.vcf"));
// Open up the dialog to export file data.
wxFileDialog ExportDlg(frmMainPtrInc, wxT("Export Contacts"), wxT(""), wxT(""),
FileTypes, wxFD_SAVE|wxFD_OVERWRITE_PROMPT);
if (ExportDlg.ShowModal() == wxID_CANCEL){
frmMainPtrInc->ResumeAllTimers();
return;
}
// Find which data type is being used.
ExportType = ExportDlg.GetFilterIndex();
if (ExportType == 0 || ExportType == 2){
DirMode = TRUE;
}
// Process the filename based on data type.
if (DirMode == FALSE){
// All contacts exported into one file. Setup the filename.
FinalFilename = ExportDlg.GetPath();
} else {
// One contact per filename. Setup the directory name.
FinalFilename = ExportDlg.GetDirectory();
}
if (ExportType == 0 || ExportType == 1){
ExportVCard4(DirMode, FinalFilename, FileListInc, &ExportCount);
}
// vCard 3.0 export
if (ExportType == 2 || ExportType == 3){
ExportVCard3(DirMode, FinalFilename, FileListInc, &ExportCount);
}
// Notify the user of how many contacts
// were exported.
wxMessageBox(wxString::Format(_("%i contacts exported."), ExportCount), _("Contacts exported"));
frmMainPtrInc->ResumeAllTimers();
}