X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;ds=inline;f=source%2Fimport%2Fimport.cpp;h=ed92080255f85cd11682c32b5658d94c967da9d3;hb=d6023ac2bba9572d1bca7da3d5960f6c07082624;hp=948f83ff3f6738aa92393a02401139783b34a950;hpb=12cb154b8acff8a1c0f23cb2a93b9ac725d700a5;p=xestiaab%2F.git
diff --git a/source/import/import.cpp b/source/import/import.cpp
index 948f83f..ed92080 100644
--- a/source/import/import.cpp
+++ b/source/import/import.cpp
@@ -1,3 +1,21 @@
+// import.cpp - Import 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
@@ -23,10 +41,7 @@ void ImportRun(frmMain *frmMainPtrInc){
wxString FileTypes;
- long ContactsExported = 0;
- long ContactsCollected = 0;
- int ExportType = 0;
- int ExportCount = 0;
+ int ImportType = 0;
wxString FinalFilename;
wxArrayString SelectedFileList;
wxString SelectedFileDirectory;
@@ -41,12 +56,12 @@ void ImportRun(frmMain *frmMainPtrInc){
FileTypes.Append(wxT("vCard 3.0 Contact(s) (*.vcf)"));
FileTypes.Append(wxT("|*.vcf"));
- // Open up the dialog to export file data.
+ // Open up the dialog to import file data.
- wxFileDialog ExportDlg(frmMainPtrInc, wxT("Import Contacts"), wxT(""), wxT(""),
+ wxFileDialog ImportDlg(frmMainPtrInc, wxT("Import Contacts"), wxT(""), wxT(""),
FileTypes, wxFD_OPEN|wxFD_MULTIPLE);
- if (ExportDlg.ShowModal() == wxID_CANCEL){
+ if (ImportDlg.ShowModal() == wxID_CANCEL){
frmMainPtrInc->ResumeAllTimers();
return;
@@ -55,29 +70,25 @@ void ImportRun(frmMain *frmMainPtrInc){
// Get the list of filenames.
- ExportDlg.GetPaths(SelectedFileList);
+ ImportDlg.GetPaths(SelectedFileList);
// Find which data type is being used.
- ExportType = ExportDlg.GetFilterIndex();
+ ImportType = ImportDlg.GetFilterIndex();
std::map ContactData;
- if (ExportType == 0){
+ if (ImportType == 0){
ContactData = ImportVCard4(&SelectedFileList);
-
- //ImportVCard4(DirMode, FinalFilename, FileListInc, &ExportCount);
-
+
}
- // vCard 3.0 export
+ // vCard 3.0 import
- if (ExportType == 1){
+ if (ImportType == 1){
ContactData = ImportVCard3(&SelectedFileList);
-
- //ImportVCard3(DirMode, FinalFilename, FileListInc, &ExportCount);
}
@@ -104,6 +115,18 @@ void ImportRun(frmMain *frmMainPtrInc){
AccountName = frmIC->GetAccount();
AccountType = frmIC->GetAccountType();
+ if (frmIC->GetDialogResult() == FALSE){
+
+ // User decided not to import. Clean up the
+ // dialog.
+
+ delete frmIC;
+ frmIC = NULL;
+ frmMainPtrInc->ResumeAllTimers();
+ return;
+
+ }
+
delete frmIC;
frmIC = NULL;
@@ -140,7 +163,7 @@ void ImportRun(frmMain *frmMainPtrInc){
if (iter->second.ContactSelected == TRUE){
- // Workout the file name. void CloseWindow( wxCommandEvent& event );
+ // Workout the file name.
// Get the UID value and check if it is empty.
// If it isn't empty, check it can be used for a valid
// filename other wise generate a file name for the purposes
@@ -151,7 +174,7 @@ void ImportRun(frmMain *frmMainPtrInc){
#if defined(__HAIKU__)
- //preffilename = wxT("noo");
+
#elif defined(__WIN32__)
@@ -204,14 +227,6 @@ void ImportRun(frmMain *frmMainPtrInc){
UIDToken = iter->second.UIDValue;
}
-
- //GenerateUUID();
-
- /*if (iter->second.ContactSelected.UIDValue.IsEmpty()){
-
-
-
- }*/
// Check if the file exists in the directory already.
@@ -289,17 +304,19 @@ void ImportRun(frmMain *frmMainPtrInc){
if (AccountType != wxT("Local") && AccountType != wxT("local")){
- wxString *AccNamePostEventPtr = new wxString;
+ wxString AccNamePostEvent;
+
+ AccNamePostEvent.Clear();
+ AccNamePostEvent.Append(AccountName);
+ AccNamePostEvent.Trim();
wxCommandEvent accevent(SYNCACCOUNT);
- accevent.SetClientData(AccNamePostEventPtr);
+ accevent.SetString(AccNamePostEvent);
wxPostEvent(frmMainPtrInc, accevent);
}
- //wxPostEvent
-
// Resume the timers.
frmMainPtrInc->ResumeAllTimers();