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-vcard3.cpp
1 // import-vcard3.cpp - Import vCard3 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 "../vcard/vcard34conv.h"
24 #include "import-struct.h"
26 std::map<int,ImportDataContact> ImportVCard3(wxArrayString *FileListInc){
28         std::map<int,ImportDataContact> FinalData;
29         
30         // Go through each of the file names, load them up and collect the
31         // contact information.
32         
33         std::map<int,wxString>* CardData;
34         
35         for (int i = 0; i < FileListInc->GetCount(); i++){
36         
37                 vCard ContactData;
38                 
39                 ContactData.LoadFile(FileListInc->Item(i));
40                 
41                 CardData = ContactData.GetAllCards();
42                 int FileIndex = 0;
43                 
44                 for(std::map<int,wxString>::iterator iter = CardData->begin(); 
45                         iter != CardData->end();
46                         iter++){
47                 
48                         // Check if contact really is a vCard 4.0 contact.
49                         
50                         vCard ContactCheck;
51                         ContactCheck.LoadString(iter->second);
52                         
53                         wxString ContactVer = ContactCheck.Get(wxT("VERSION"));
54                         
55                         if (ContactVer != wxT("3.0")){
56                         
57                                 continue;
58                         
59                         }
60                 
61                         wxString ContactDatav3;
62                         vCard ContactDatav4;
63                         
64                         vCard34Conv vCardConvObj;               
65                         vCardConvObj.ConvertToV4(&ContactDatav3, &ContactDatav4);
66                 
67                         // Convert data from vCard 3.0 to vCard 4.0
68                 
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"));
74                 
75                         FileIndex++;
76                 
77                 }
78                 
79         }
80         
81         return FinalData;
83
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