Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
frmPreferences: Removed std::cout printing contact background colour
[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         // Import from a vCard 3.0 file.
29         
30         std::map<int,ImportDataContact> FinalData;
31         
32         // Go through each of the file names, load them up and collect the
33         // contact information.
34         
35         std::map<int,wxString>* CardData;
36         
37         for (int i = 0; i < FileListInc->GetCount(); i++){
38         
39                 vCard ContactData;
40                 
41                 ContactData.LoadFile(FileListInc->Item(i));
42                 
43                 CardData = ContactData.GetAllCards();
44                 int FileIndex = 0;
45                 
46                 for(std::map<int,wxString>::iterator iter = CardData->begin(); 
47                         iter != CardData->end();
48                         iter++){
49                 
50                         // Check if contact really is a vCard 4.0 contact.
51                         
52                         vCard ContactCheck;
53                         ContactCheck.LoadString(iter->second);
54                         
55                         wxString ContactVer = ContactCheck.Get(wxT("VERSION"));
56                         
57                         if (ContactVer != wxT("3.0")){
58                         
59                                 continue;
60                         
61                         }
62                 
63                         wxString ContactDatav3;
64                         vCard ContactDatav4;
65                         
66                         vCard34Conv vCardConvObj;               
67                         vCardConvObj.ConvertToV4(&ContactDatav3, &ContactDatav4);
68                 
69                         // Convert data from vCard 3.0 to vCard 4.0
70                 
71                         ImportDataContact SelectedContact;
72                         SelectedContact.Filename = FileListInc->Item(i);
73                         SelectedContact.FilenameIndex = FileIndex;
74                         SelectedContact.ContactData = ContactDatav4.WriteString();
75                         SelectedContact.UIDValue = ContactDatav4.Get(wxT("UID"));
76                 
77                         FileIndex++;
78                 
79                 }
80                 
81         }
82         
83         return FinalData;
85
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