// import-vcard3.cpp - Import vCard3 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 "../vcard/vcard.h" #include "../vcard/vcard34conv.h" #include "import-struct.h" std::map ImportVCard3(wxArrayString *FileListInc){ // Import from a vCard 3.0 file. std::map FinalData; // Go through each of the file names, load them up and collect the // contact information. std::map* CardData; for (int i = 0; i < FileListInc->GetCount(); i++){ vCard ContactData; ContactData.LoadFile(FileListInc->Item(i)); CardData = ContactData.GetAllCards(); int FileIndex = 0; for(std::map::iterator iter = CardData->begin(); iter != CardData->end(); iter++){ // Check if contact really is a vCard 4.0 contact. vCard ContactCheck; ContactCheck.LoadString(iter->second); wxString ContactVer = ContactCheck.Get(wxT("VERSION")); if (ContactVer != wxT("3.0")){ continue; } wxString ContactDatav3; vCard ContactDatav4; vCard34Conv vCardConvObj; vCardConvObj.ConvertToV4(&ContactDatav3, &ContactDatav4); // Convert data from vCard 3.0 to vCard 4.0 ImportDataContact SelectedContact; SelectedContact.Filename = FileListInc->Item(i); SelectedContact.FilenameIndex = FileIndex; SelectedContact.ContactData = ContactDatav4.WriteString(); SelectedContact.UIDValue = ContactDatav4.Get(wxT("UID")); FileIndex++; } } return FinalData; }