1 // import-vcard3.cpp - Import vCard3 subroutines
3 // (c) 2012-2015 Xestia Software Development.
5 // This file is part of Xestia Address Book.
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.
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.
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/>
22 #include "../vcard/vcard.h"
23 #include "../vcard/vcard34conv.h"
24 #include "import-struct.h"
26 std::map<int,ImportDataContact> ImportVCard3(wxArrayString *FileListInc){
28 // Import from a vCard 3.0 file.
30 std::map<int,ImportDataContact> FinalData;
32 // Go through each of the file names, load them up and collect the
33 // contact information.
35 std::map<int,wxString>* CardData;
37 for (int i = 0; i < FileListInc->GetCount(); i++){
41 ContactData.LoadFile(FileListInc->Item(i));
43 CardData = ContactData.GetAllCards();
46 for(std::map<int,wxString>::iterator iter = CardData->begin();
47 iter != CardData->end();
50 // Check if contact really is a vCard 4.0 contact.
53 ContactCheck.LoadString(iter->second);
55 wxString ContactVer = ContactCheck.Get(wxT("VERSION"));
57 if (ContactVer != wxT("3.0")){
63 wxString ContactDatav3;
66 vCard34Conv vCardConvObj;
67 vCardConvObj.ConvertToV4(&ContactDatav3, &ContactDatav4);
69 // Convert data from vCard 3.0 to vCard 4.0
71 ImportDataContact SelectedContact;
72 SelectedContact.Filename = FileListInc->Item(i);
73 SelectedContact.FilenameIndex = FileIndex;
74 SelectedContact.ContactData = ContactDatav4.WriteString();
75 SelectedContact.UIDValue = ContactDatav4.Get(wxT("UID"));