Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added copyright and license to the C++ source and header files in the import directory.
[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         std::map<int,ImportDataContact> FinalData;
28         
29         // Go through each of the file names, load them up and collect the
30         // contact information.
31         
32         std::map<int,wxString>* CardData;
33         
34         for (int i = 0; i < FileListInc->GetCount(); i++){
35         
36                 vCard ContactData;
37                 
38                 ContactData.LoadFile(FileListInc->Item(i));
39                 
40                 CardData = ContactData.GetAllCards();
41                 int FileIndex = 0;
42                 
43                 for(std::map<int,wxString>::iterator iter = CardData->begin(); 
44                         iter != CardData->end();
45                         iter++){
46                 
47                         // Check if contact really is a vCard 4.0 contact.
48                         
49                         vCard ContactCheck;
50                         ContactCheck.LoadString(iter->second);
51                         
52                         wxString ContactVer = ContactCheck.Get(wxT("VERSION"));
53         
54                         if (ContactVer != wxT("4.0")){
55                         
56                                 continue;
57                         
58                         }
59                         
60                         // If contact is vCard 4.0 then continue otherwise
61                         // go to the next contact.
62                 
63                         ImportDataContact SelectedContact;
64                         SelectedContact.Filename = FileListInc->Item(i);
65                         SelectedContact.FilenameIndex = FileIndex;
66                         SelectedContact.ContactData = iter->second;
67                         SelectedContact.UIDValue = ContactCheck.Get(wxT("UID"));
68                 
69                         FinalData.insert(std::make_pair(FileIndex, SelectedContact));
70                 
71                         FileIndex++;
73                 }
74                 
75         }
76         
77         return FinalData;
79
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