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 std::map<int,ImportDataContact> FinalData;
30 // Go through each of the file names, load them up and collect the
31 // contact information.
33 std::map<int,wxString>* CardData;
35 for (int i = 0; i < FileListInc->GetCount(); i++){
39 ContactData.LoadFile(FileListInc->Item(i));
41 CardData = ContactData.GetAllCards();
44 for(std::map<int,wxString>::iterator iter = CardData->begin();
45 iter != CardData->end();
48 // Check if contact really is a vCard 4.0 contact.
51 ContactCheck.LoadString(iter->second);
53 wxString ContactVer = ContactCheck.Get(wxT("VERSION"));
55 if (ContactVer != wxT("3.0")){
61 wxString ContactDatav3;
64 vCard34Conv vCardConvObj;
65 vCardConvObj.ConvertToV4(&ContactDatav3, &ContactDatav4);
67 // Convert data from vCard 3.0 to vCard 4.0
69 ImportDataContact SelectedContact;
70 SelectedContact.Filename = FileListInc->Item(i);
71 SelectedContact.FilenameIndex = FileIndex;
72 SelectedContact.ContactData = ContactDatav4.WriteString();
73 SelectedContact.UIDValue = ContactDatav4.Get(wxT("UID"));