Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
frmPreferences: Removed std::cout printing contact background colour
[xestiaab/.git] / source / import / import-vcard4.cpp
1 // import-vcard4.cpp - Import vCard4 subroutines
2 //
3 // (c) 2012-2015 Xestia Software Development.
4 //
5 // This file is part of Xestia Address Book.
6 //
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.
10 //
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.
15 //
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/>
19 #include <map>
20 #include <wx/wx.h>
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.
28         
29         std::map<int,ImportDataContact> FinalData;
30         
31         // Go through each of the file names, load them up and collect the
32         // contact information.
33         
34         std::map<int,wxString>* CardData;
35         
36         for (int i = 0; i < FileListInc->GetCount(); i++){
37         
38                 vCard ContactData;
39                 
40                 ContactData.LoadFile(FileListInc->Item(i));
41                 
42                 CardData = ContactData.GetAllCards();
43                 int FileIndex = 0;
44                 
45                 for(std::map<int,wxString>::iterator iter = CardData->begin(); 
46                         iter != CardData->end();
47                         iter++){
48                 
49                         // Check if contact really is a vCard 4.0 contact.
50                         
51                         vCard ContactCheck;
52                         ContactCheck.LoadString(iter->second);
53                         
54                         wxString ContactVer = ContactCheck.Get(wxT("VERSION"));
55         
56                         if (ContactVer != wxT("4.0")){
57                         
58                                 continue;
59                         
60                         }
61                         
62                         // If contact is vCard 4.0 then continue otherwise
63                         // go to the next contact.
64                 
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"));
70                 
71                         FinalData.insert(std::make_pair(FileIndex, SelectedContact));
72                 
73                         FileIndex++;
75                 }
76                 
77         }
78         
79         return FinalData;
81
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy