Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Made FN used ProcessData to add data and then append to SaveData
[xestiaab/.git] / source / contacteditor / cdo / ContactDataObject-Save.cpp
1 // ContactDataObject-Save.cpp - Client Data Object.
2 //
3 // (c) 2012-2016 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 "ContactDataObject.h"
20 #include "../../version.h"
22 ContactSaveStatus ContactDataObject::SaveString(wxString *SaveData){
23         
24         ContactSaveStatus SaveDataStatus = CONTACTSAVE_UNITTESTFAIL;
25         
26         // Write the header for the vCard data file.
27         
28         SaveData->Append("BEGIN:VCARD\n");
29         SaveData->Append("VERSION:4.0\n");
30         
31         // Write the product ID.
32         
33 #ifdef XAB_UNITTEST
34         
35         SaveData->Append("PRODID:-//Xestia//Address Book Unit Testing//KW\n");
36         
37 #else
38         
39         SaveData->Append(wxT("PRODID:-//Xestia//Address Book Version "));
40         SaveData->Append(wxT(XSDAB_VERSION));
41         SaveData->Append(wxT("//KW\n"));
42         
43 #endif
44         
45         // Process FN.
46         
47         wxString ProcessData = "";
48         
49         for (std::map<int, wxString>::iterator FNIter = FullNamesList.begin();
50                 FNIter != FullNamesList.end(); FNIter++){
51                 
52                 ProcessData.Append("FN");
54                 // Check if there is a value for TYPE.
55                 
56                 if (FullNamesListType[FNIter->first].size() > 0){
57                 
58                         ProcessData.Append(";TYPE=");
59                         ProcessData.Append(FullNamesListType[FNIter->first]);
60                         
61                 }
63                 // Check if there is a value for LANGUAGE.
64                 
65                 if (FullNamesListLanguage[FNIter->first].size() > 0){
66                 
67                         ProcessData.Append(";LANGUAGE=");
68                         ProcessData.Append(FullNamesListLanguage[FNIter->first]);
69                         
70                 }
71                 
72                 // Check if there is a value for ALTID.
73                 
74                 if (FullNamesListAltID[FNIter->first].size() > 0){
75                 
76                         ProcessData.Append(";ALTID=");
77                         ProcessData.Append(FullNamesListAltID[FNIter->first]);
78                         
79                 }
80                 
81                 // Check if there is a value for PID.
83                 if (FullNamesListPID[FNIter->first].size() > 0){
84                 
85                         ProcessData.Append(";PID=");
86                         ProcessData.Append(FullNamesListPID[FNIter->first]);
87                         
88                 }
90                 // Check if there is a value for PREF.
92                 if (FullNamesListPref[FNIter->first] > 0){
93                 
94                         ProcessData.Append(";PREF=");
95                         ProcessData.Append(wxString::Format("%i", FullNamesListPref[FNIter->first]));
96                         
97                 }
99                 // Check if there is a value for tokens.
101                 if (FullNamesListTokens[FNIter->first].size() > 0){
102                 
103                         ProcessData.Append(";");
104                         ProcessData.Append(FullNamesListTokens[FNIter->first]);
105                         
106                 }
107                 
108                 ProcessData.Append(":");
109                 ProcessData.Append(FNIter->second);
110                 ProcessData.Append("\n");
111                 
112                 ProcessData = OutputText(&ProcessData);
113                 
114                 SaveData->Append(ProcessData);
115                 ProcessData.clear();
116                         
117         }
118         
119         // Process TITLE.
121         for (std::map<int, wxString>::iterator TitleIter = GeneralTitleList.begin();
122                 TitleIter != GeneralTitleList.end(); TitleIter++){
123                 
124                 SaveData->Append("TITLE:");
125                 SaveData->Append(TitleIter->second);
126                 SaveData->Append("\n");
127                         
128         }
129         
130         // Write the end part of the vCard data file.
131         
132         SaveData->Append("END:VCARD");
133         
134         SaveDataStatus = CONTACTSAVE_OK;
135         
136         return SaveDataStatus;
137         
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