1 // import-vcard4.cpp - Import vCard4 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 "import-struct.h"
25 std::map<int,ImportDataContact> ImportVCard4(wxArrayString *FileListInc){
27 // Import from a vCard 4.0 file.
29 std::map<int,ImportDataContact> FinalData;
31 // Go through each of the file names, load them up and collect the
32 // contact information.
34 std::map<int,wxString>* CardData;
36 for (int i = 0; i < FileListInc->GetCount(); i++){
40 ContactData.LoadFile(FileListInc->Item(i));
42 CardData = ContactData.GetAllCards();
45 for(std::map<int,wxString>::iterator iter = CardData->begin();
46 iter != CardData->end();
49 // Check if contact really is a vCard 4.0 contact.
52 ContactCheck.LoadString(iter->second);
54 wxString ContactVer = ContactCheck.Get(wxT("VERSION"));
56 if (ContactVer != wxT("4.0")){
62 // If contact is vCard 4.0 then continue otherwise
63 // go to the next contact.
65 ImportDataContact SelectedContact;
66 SelectedContact.Filename = FileListInc->Item(i);
67 SelectedContact.FilenameIndex = FileIndex;
68 SelectedContact.ContactData = iter->second;
69 SelectedContact.UIDValue = ContactCheck.Get(wxT("UID"));
71 FinalData.insert(std::make_pair(FileIndex, SelectedContact));