// ContactDataObject-Save.cpp - Client Data Object.
//
// (c) 2012-2016 Xestia Software Development.
//
// This file is part of Xestia Address Book.
//
// Xestia Address Book is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by the
// Free Software Foundation, version 3 of the license.
//
// Xestia Address Book is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with Xestia Address Book. If not, see
#include "ContactDataObject.h"
#include "../../version.h"
ContactSaveStatus ContactDataObject::SaveString(wxString *SaveData){
ContactSaveStatus SaveDataStatus = CONTACTSAVE_UNITTESTFAIL;
// Write the header for the vCard data file.
SaveData->Append("BEGIN:VCARD\n");
SaveData->Append("VERSION:4.0\n");
// Write the product ID.
#ifdef XAB_UNITTEST
SaveData->Append("PRODID:-//Xestia//Address Book Unit Testing//KW\n");
#else
SaveData->Append(wxT("PRODID:-//Xestia//Address Book Version "));
SaveData->Append(wxT(XSDAB_VERSION));
SaveData->Append(wxT("//KW\n"));
#endif
wxString ProcessData = "";
// Process UID.
if (UIDToken.size() > 0){
ProcessData.Append("UID:");
ProcessData.Append(UIDToken);
ProcessData.Append("\n");
SaveData->Append(ProcessData);
ProcessData.clear();
}
// Process KIND.
switch(ContactKind){
case CONTACTKIND_NONE:
break;
case CONTACTKIND_INDIVIDUAL:
SaveData->Append("KIND:individual\n");
break;
case CONTACTKIND_GROUP:
SaveData->Append("KIND:group\n");
break;
case CONTACTKIND_ORGANISATION:
SaveData->Append("KIND:org\n");
break;
case CONTACTKIND_LOCATION:
SaveData->Append("KIND:location\n");
break;
default:
break;
}
// TODO: Sortout REV.
// Process XML.
for (std::map::iterator XMLIter = XMLList.begin();
XMLIter != XMLList.end(); XMLIter++){
ProcessData.Append("XML");
if (XMLListAltID[XMLIter->first].size() > 0){
ProcessData.Append(";ALTID=");
ProcessData.Append(XMLListAltID[XMLIter->first]);
}
ProcessData.Append(":");
ProcessData.Append(XMLIter->second);
ProcessData.Append("\n");
ProcessData = OutputText(&ProcessData);
SaveData->Append(ProcessData);
ProcessData.clear();
}
// Process SOURCE.
SaveSource(&SourceList, &SourceListAltID,
&SourceListPID, &SourceListType,
&SourceListMediatype, &SourceListPref,
&SourceListTokens, SaveData);
// Process CLIENTPIDMAP.
for (std::map::iterator CPIDIter = ClientPIDList.begin();
CPIDIter != ClientPIDList.end(); CPIDIter++){
ProcessData.Append("CLIENTPIDMAP");
if (ClientPIDListTokens[CPIDIter->first].size() > 0){
ProcessData.Append(";");
ProcessData.Append(ClientPIDListTokens[CPIDIter->first]);
}
ProcessData.Append(":");
ProcessData.Append(CPIDIter->second);
ProcessData.Append("\n");
ProcessData = OutputText(&ProcessData);
SaveData->Append(ProcessData);
ProcessData.clear();
}
// Process FN.
for (std::map::iterator FNIter = FullNamesList.begin();
FNIter != FullNamesList.end(); FNIter++){
ProcessData.Append("FN");
// Check if there is a value for TYPE.
if (FullNamesListType[FNIter->first].size() > 0){
ProcessData.Append(";TYPE=");
ProcessData.Append(FullNamesListType[FNIter->first]);
}
// Check if there is a value for LANGUAGE.
if (FullNamesListLanguage[FNIter->first].size() > 0){
ProcessData.Append(";LANGUAGE=");
ProcessData.Append(FullNamesListLanguage[FNIter->first]);
}
// Check if there is a value for ALTID.
if (FullNamesListAltID[FNIter->first].size() > 0){
ProcessData.Append(";ALTID=");
ProcessData.Append(FullNamesListAltID[FNIter->first]);
}
// Check if there is a value for PID.
if (FullNamesListPID[FNIter->first].size() > 0){
ProcessData.Append(";PID=");
ProcessData.Append(FullNamesListPID[FNIter->first]);
}
// Check if there is a value for PREF.
if (FullNamesListPref[FNIter->first] > 0){
ProcessData.Append(";PREF=");
ProcessData.Append(wxString::Format("%i", FullNamesListPref[FNIter->first]));
}
// Check if there is a value for tokens.
if (FullNamesListTokens[FNIter->first].size() > 0){
ProcessData.Append(";");
ProcessData.Append(FullNamesListTokens[FNIter->first]);
}
ProcessData.Append(":");
ProcessData.Append(FNIter->second);
ProcessData.Append("\n");
ProcessData = OutputText(&ProcessData);
SaveData->Append(ProcessData);
ProcessData.clear();
}
// Process NICKNAME.
SaveNickname(&GeneralNicknamesList, &GeneralNicknamesListAltID,
&GeneralNicknamesListPID, &GeneralNicknamesListType,
&GeneralNicknamesListLanguage, &GeneralNicknamesListPref,
&GeneralNicknamesListTokens, SaveData, "");
SaveNickname(&HomeNicknamesList, &HomeNicknamesListAltID,
&HomeNicknamesListPID, &HomeNicknamesListType,
&HomeNicknamesListLanguage, &HomeNicknamesListPref,
&HomeNicknamesListTokens, SaveData, "home");
SaveNickname(&BusinessNicknamesList, &BusinessNicknamesListAltID,
&BusinessNicknamesListPID, &BusinessNicknamesListType,
&BusinessNicknamesListLanguage, &BusinessNicknamesListPref,
&BusinessNicknamesListTokens, SaveData, "work");
// Process TITLE.
SaveTitle(&GeneralTitleList, &GeneralTitleListLanguage,
&GeneralTitleListAltID, &GeneralTitleListPID,
&GeneralTitleListType, &GeneralTitleListPref,
&GeneralTitleListTokens, SaveData, "");
SaveTitle(&HomeTitleList, &HomeTitleListLanguage,
&HomeTitleListAltID, &HomeTitleListPID,
&HomeTitleListType, &HomeTitleListPref,
&HomeTitleListTokens, SaveData, "home");
SaveTitle(&BusinessTitleList, &BusinessTitleListLanguage,
&BusinessTitleListAltID, &BusinessTitleListPID,
&BusinessTitleListType, &BusinessTitleListPref,
&BusinessTitleListTokens, SaveData, "work");
// Process TZ.
SaveTimezone(&GeneralTZList, &GeneralTZListAltID,
&GeneralTZListPID, &GeneralTZListType,
&GeneralTZListMediatype, &GeneralTZListPref,
&GeneralTZListTokens, SaveData, "");
SaveTimezone(&HomeTZList, &HomeTZListAltID,
&HomeTZListPID, &HomeTZListType,
&HomeTZListMediatype, &HomeTZListPref,
&HomeTZListTokens, SaveData, "home");
SaveTimezone(&BusinessTZList, &BusinessTZListAltID,
&BusinessTZListPID, &BusinessTZListType,
&BusinessTZListMediatype, &BusinessTZListPref,
&BusinessTZListTokens, SaveData, "work");
// Process ADR.
SaveAddress(&GeneralAddressList, &GeneralAddressListTown,
&GeneralAddressListCounty, &GeneralAddressListPostCode,
&GeneralAddressListCountry, &GeneralAddressListLabel,
&GeneralAddressListLang, &GeneralAddressListAltID,
&GeneralAddressListPID, &GeneralAddressListGeo,
&GeneralAddressListTimezone, &GeneralAddressListType,
&GeneralAddressListMediatype, &GeneralAddressListPref,
&GeneralAddressListTokens, SaveData, "");
SaveAddress(&HomeAddressList, &HomeAddressListTown,
&HomeAddressListCounty, &HomeAddressListPostCode,
&HomeAddressListCountry, &HomeAddressListLabel,
&HomeAddressListLang, &HomeAddressListAltID,
&HomeAddressListPID, &HomeAddressListGeo,
&HomeAddressListTimezone, &HomeAddressListType,
&HomeAddressListMediatype, &HomeAddressListPref,
&HomeAddressListTokens, SaveData, "home");
SaveAddress(&BusinessAddressList, &BusinessAddressListTown,
&BusinessAddressListCounty, &BusinessAddressListPostCode,
&BusinessAddressListCountry, &BusinessAddressListLabel,
&BusinessAddressListLang, &BusinessAddressListAltID,
&BusinessAddressListPID, &BusinessAddressListGeo,
&BusinessAddressListTimezone, &BusinessAddressListType,
&BusinessAddressListMediatype, &BusinessAddressListPref,
&BusinessAddressListTokens, SaveData, "work");
// Process EMAIL.
SaveEmail(&GeneralEmailList, &GeneralEmailListAltID,
&GeneralEmailListPID, &GeneralEmailListType,
&GeneralEmailListPref, &GeneralEmailListTokens,
SaveData, "");
SaveEmail(&HomeEmailList, &HomeEmailListAltID,
&HomeEmailListPID, &HomeEmailListType,
&HomeEmailListPref, &HomeEmailListTokens,
SaveData, "home");
SaveEmail(&BusinessEmailList, &BusinessEmailListAltID,
&BusinessEmailListPID, &BusinessEmailListType,
&BusinessEmailListPref, &BusinessEmailListTokens,
SaveData, "work");
// TODO: Process IMPP.
// TODO: Process TEL.
// Process LANG.
SaveLanguage(&GeneralLanguageList, &GeneralLanguageListAltID,
&GeneralLanguageListPID, &GeneralLanguageListType,
&GeneralLanguageListPref, &GeneralLanguageListTokens,
SaveData, "");
SaveLanguage(&HomeLanguageList, &HomeLanguageListAltID,
&HomeLanguageListPID, &HomeLanguageListType,
&HomeLanguageListPref, &HomeLanguageListTokens,
SaveData, "home");
SaveLanguage(&BusinessLanguageList, &BusinessLanguageListAltID,
&BusinessLanguageListPID, &BusinessLanguageListType,
&BusinessLanguageListPref, &BusinessLanguageListTokens,
SaveData, "work");
// Process GEO.
SaveGeoposition(&GeneralGeographyList, &GeneralGeographyListAltID,
&GeneralGeographyListPID, &GeneralGeographyListType,
&GeneralGeographyListMediatype, &GeneralGeographyListDataType,
&GeneralGeographyListPref, &GeneralGeographyListTokens,
SaveData, "");
SaveGeoposition(&HomeGeographyList, &HomeGeographyListAltID,
&HomeGeographyListPID, &HomeGeographyListType,
&HomeGeographyListMediatype, &HomeGeographyListDataType,
&HomeGeographyListPref, &HomeGeographyListTokens,
SaveData, "home");
SaveGeoposition(&BusinessGeographyList, &BusinessGeographyListAltID,
&BusinessGeographyListPID, &BusinessGeographyListType,
&BusinessGeographyListMediatype, &BusinessGeographyListDataType,
&BusinessGeographyListPref, &BusinessGeographyListTokens,
SaveData, "work");
// Process RELATED.
int Moo = 0;
for (std::map::iterator RelatedIter = GeneralRelatedList.begin();
RelatedIter != GeneralRelatedList.end(); RelatedIter++){
ProcessData.Append("RELATED");
// Check if there is a value for TYPE.
if (GeneralRelatedListRelType[RelatedIter->first].size() > 0){
wxString RelatedType = "";
ProcessData.Append(";TYPE=");
if (GeneralRelatedListRelType[RelatedIter->first] == _("Contact")){
RelatedType = wxT("contact");
} else if (GeneralRelatedListRelType[RelatedIter->first] == _("Acquaintance")){
RelatedType = wxT("acquaintance");
} else if (GeneralRelatedListRelType[RelatedIter->first] == _("Friend")){
RelatedType = wxT("friend");
} else if (GeneralRelatedListRelType[RelatedIter->first] == _("Met")){
RelatedType = wxT("met");
} else if (GeneralRelatedListRelType[RelatedIter->first] == _("Co-worker")){
RelatedType = wxT("co-worker");
} else if (GeneralRelatedListRelType[RelatedIter->first] == _("Colleague")){
RelatedType = wxT("colleague");
} else if (GeneralRelatedListRelType[RelatedIter->first] == _("Co-resident")){
RelatedType = wxT("co-resident");
} else if (GeneralRelatedListRelType[RelatedIter->first] == _("Neighbour")){
RelatedType = wxT("neighbor");
} else if (GeneralRelatedListRelType[RelatedIter->first] == _("Child")){
RelatedType = wxT("child");
} else if (GeneralRelatedListRelType[RelatedIter->first] == _("Parent")){
RelatedType = wxT("parent");
} else if (GeneralRelatedListRelType[RelatedIter->first] == _("Sibling")){
RelatedType = wxT("sibling");
} else if (GeneralRelatedListRelType[RelatedIter->first] == _("Spouse")){
RelatedType = wxT("spouse");
} else if (GeneralRelatedListRelType[RelatedIter->first] == _("Kin")){
RelatedType = wxT("kin");
} else if (GeneralRelatedListRelType[RelatedIter->first] == _("Muse")){
RelatedType = wxT("muse");
} else if (GeneralRelatedListRelType[RelatedIter->first] == _("Crush")){
RelatedType = wxT("crush");
} else if (GeneralRelatedListRelType[RelatedIter->first] == _("Date")){
RelatedType = wxT("date");
} else if (GeneralRelatedListRelType[RelatedIter->first]== _("Sweetheart")){
RelatedType = wxT("sweetheart");
} else if (GeneralRelatedListRelType[RelatedIter->first] == _("Me")){
RelatedType = wxT("me");
} else if (GeneralRelatedListRelType[RelatedIter->first] == _("Agent")){
RelatedType = wxT("agent");
} else if (GeneralRelatedListRelType[RelatedIter->first] == _("Emergency")){
RelatedType = wxT("emergency");
} else {
RelatedType = GeneralRelatedListRelType[RelatedIter->first];
}
ProcessData.Append(RelatedType);
}
// Check if there is a value for LANGUAGE.
if (GeneralRelatedListLanguage[RelatedIter->first].size() > 0){
ProcessData.Append(";LANGUAGE=");
ProcessData.Append(GeneralRelatedListLanguage[RelatedIter->first]);
}
// Check if there is a value for ALTID.
if (GeneralRelatedListAltID[RelatedIter->first].size() > 0){
ProcessData.Append(";ALTID=");
ProcessData.Append(GeneralRelatedListAltID[RelatedIter->first]);
}
// Check if there is a value for PID.
if (GeneralRelatedListPID[RelatedIter->first].size() > 0){
ProcessData.Append(";PID=");
ProcessData.Append(GeneralRelatedListPID[RelatedIter->first]);
}
// Check if there is a value for PREF.
if (GeneralRelatedListPref[RelatedIter->first] > 0){
ProcessData.Append(";PREF=");
ProcessData.Append(wxString::Format("%i", GeneralRelatedListPref[RelatedIter->first]));
}
// Check if there is a value for tokens.
if (GeneralRelatedListTokens[RelatedIter->first].size() > 0){
ProcessData.Append(";");
ProcessData.Append(GeneralRelatedListTokens[RelatedIter->first]);
}
ProcessData.Append(":");
ProcessData.Append(RelatedIter->second);
ProcessData.Append("\n");
ProcessData = OutputText(&ProcessData);
SaveData->Append(ProcessData);
ProcessData.clear();
}
// Write the end part of the vCard data file.
SaveData->Append("END:VCARD");
SaveDataStatus = CONTACTSAVE_OK;
return SaveDataStatus;
}
void ContactDataObject::SaveTitle(map *TitleList, map *TitleListLanguage,
map *TitleListAltID, map *TitleListPID,
map *TitleListType, map *TitleListPref,
map *TitleListTokens, wxString *SaveData, wxString DataType){
wxString ProcessData = "";
for (std::map::iterator TitleIter = TitleList->begin();
TitleIter != TitleList->end(); TitleIter++){
ProcessData.Append("TITLE");
// Check if there is a value for TYPE.
if (DataType.size() > 0){
ProcessData.Append(";TYPE=");
ProcessData.Append(DataType);
}
// Check if there is a value for ALTID.
if ((*TitleListAltID)[TitleIter->first].size() > 0){
ProcessData.Append(";ALTID=");
ProcessData.Append((*TitleListAltID)[TitleIter->first]);
}
// Check if there is a value for LANGUAGE.
if ((*TitleListLanguage)[TitleIter->first].size() > 0){
ProcessData.Append(";LANGUAGE=");
ProcessData.Append((*TitleListLanguage)[TitleIter->first]);
}
// Check if there is a value for PID.
if ((*TitleListPID)[TitleIter->first].size() > 0){
ProcessData.Append(";PID=");
ProcessData.Append((*TitleListPID)[TitleIter->first]);
}
// Check if there is a value for PREF.
if ((*TitleListPref)[TitleIter->first] > 0){
ProcessData.Append(";PREF=");
ProcessData.Append(wxString::Format("%i", (*TitleListPref)[TitleIter->first]));
}
// Check if there is a value for tokens.
if ((*TitleListTokens)[TitleIter->first].size() > 0){
ProcessData.Append(";");
ProcessData.Append((*TitleListTokens)[TitleIter->first]);
}
ProcessData.Append(":");
ProcessData.Append(TitleIter->second);
ProcessData.Append("\n");
ProcessData = OutputText(&ProcessData);
SaveData->Append(ProcessData);
ProcessData.clear();
}
}
void ContactDataObject::SaveSource(map *SourceList, map *SourceListAltID,
map *SourceListPID, map *SourceListType,
map *SourceListMediatype, map *SourceListPref,
map *SourceListTokens, wxString *SaveData){
wxString ProcessData = "";
for (std::map::iterator SourceIter = SourceList->begin();
SourceIter != SourceList->end(); SourceIter++){
ProcessData.Append("SOURCE");
// Check if there is a value for TYPE.
if ((*SourceListType)[SourceIter->first].size() > 0){
ProcessData.Append(";TYPE=");
ProcessData.Append((*SourceListType)[SourceIter->first]);
}
// Check if there is a value for ALTID.
if ((*SourceListAltID)[SourceIter->first].size() > 0){
ProcessData.Append(";ALTID=");
ProcessData.Append((*SourceListAltID)[SourceIter->first]);
}
// Check if there is a value for MEDIATYPE.
if ((*SourceListMediatype)[SourceIter->first].size() > 0){
ProcessData.Append(";MEDIATYPE=");
ProcessData.Append((*SourceListMediatype)[SourceIter->first]);
}
// Check if there is a value for PID.
if ((*SourceListPID)[SourceIter->first].size() > 0){
ProcessData.Append(";PID=");
ProcessData.Append((*SourceListPID)[SourceIter->first]);
}
// Check if there is a value for PREF.
if ((*SourceListPref)[SourceIter->first] > 0){
ProcessData.Append(";PREF=");
ProcessData.Append(wxString::Format("%i", (*SourceListPref)[SourceIter->first]));
}
// Check if there is a value for tokens.
if ((*SourceListTokens)[SourceIter->first].size() > 0){
ProcessData.Append(";");
ProcessData.Append((*SourceListTokens)[SourceIter->first]);
}
ProcessData.Append(":");
ProcessData.Append(SourceIter->second);
ProcessData.Append("\n");
ProcessData = OutputText(&ProcessData);
SaveData->Append(ProcessData);
ProcessData.clear();
}
}
void ContactDataObject::SaveNickname(map *NicknameList, map *NicknameListAltID,
map *NicknameListPID, map *NicknameListType,
map *NicknameListLanguage, map *NicknameListPref,
map *NicknameListTokens, wxString *SaveData, wxString DataType){
wxString ProcessData = "";
for (std::map::iterator NicknameIter = NicknameList->begin();
NicknameIter != NicknameList->end(); NicknameIter++){
ProcessData.Append("NICKNAME");
// Check if there is a value for TYPE.
if (DataType.size() > 0){
ProcessData.Append(";TYPE=");
ProcessData.Append(DataType);
}
// Check if there is a value for ALTID.
if ((*NicknameListAltID)[NicknameIter->first].size() > 0){
ProcessData.Append(";ALTID=");
ProcessData.Append((*NicknameListAltID)[NicknameIter->first]);
}
// Check if there is a value for MEDIATYPE.
if ((*NicknameListLanguage)[NicknameIter->first].size() > 0){
ProcessData.Append(";LANGUAGE=");
ProcessData.Append((*NicknameListLanguage)[NicknameIter->first]);
}
// Check if there is a value for PID.
if ((*NicknameListPID)[NicknameIter->first].size() > 0){
ProcessData.Append(";PID=");
ProcessData.Append((*NicknameListPID)[NicknameIter->first]);
}
// Check if there is a value for PREF.
if ((*NicknameListPref)[NicknameIter->first] > 0){
ProcessData.Append(";PREF=");
ProcessData.Append(wxString::Format("%i", (*NicknameListPref)[NicknameIter->first]));
}
// Check if there is a value for tokens.
if ((*NicknameListTokens)[NicknameIter->first].size() > 0){
ProcessData.Append(";");
ProcessData.Append((*NicknameListTokens)[NicknameIter->first]);
}
ProcessData.Append(":");
ProcessData.Append(NicknameIter->second);
ProcessData.Append("\n");
ProcessData = OutputText(&ProcessData);
SaveData->Append(ProcessData);
ProcessData.clear();
}
}
void ContactDataObject::SaveTimezone(map *TZList, map *TZListAltID,
map *TZListPID, map *TZListType,
map *TZListMediatype, map *TZListPref,
map *TZListTokens, wxString *SaveData, wxString DataType){
wxString ProcessData = "";
for (std::map::iterator TZIter = TZList->begin();
TZIter != TZList->end(); TZIter++){
ProcessData.Append("TZ");
// Check if there is a value for TYPE.
if (DataType.size() > 0){
ProcessData.Append(";TYPE=");
ProcessData.Append(DataType);
}
// Check if there is a value for ALTID.
if ((*TZListAltID)[TZIter->first].size() > 0){
ProcessData.Append(";ALTID=");
ProcessData.Append((*TZListAltID)[TZIter->first]);
}
// Check if there is a value for MEDIATYPE.
if ((*TZListMediatype)[TZIter->first].size() > 0){
ProcessData.Append(";MEDIATYPE=");
ProcessData.Append((*TZListMediatype)[TZIter->first]);
}
// Check if there is a value for PID.
if ((*TZListPID)[TZIter->first].size() > 0){
ProcessData.Append(";PID=");
ProcessData.Append((*TZListPID)[TZIter->first]);
}
// Check if there is a value for PREF.
if ((*TZListPref)[TZIter->first] > 0){
ProcessData.Append(";PREF=");
ProcessData.Append(wxString::Format("%i", (*TZListPref)[TZIter->first]));
}
// Check if there is a value for tokens.
if ((*TZListTokens)[TZIter->first].size() > 0){
ProcessData.Append(";");
ProcessData.Append((*TZListTokens)[TZIter->first]);
}
ProcessData.Append(":");
ProcessData.Append(TZIter->second);
ProcessData.Append("\n");
ProcessData = OutputText(&ProcessData);
SaveData->Append(ProcessData);
ProcessData.clear();
}
}
void ContactDataObject::SaveAddress(map *AddressList, map *AddressListTown,
map *AddressListCounty, map *AddressListPostCode,
map *AddressListCountry, map *AddressListLabel,
map *AddressListLang, map *AddressListAltID,
map *AddressListPID, map *AddressListGeo,
map *AddressListTimezone, map *AddressListType,
map *AddressListMediatype, map *AddressListPref,
map *AddressListTokens, wxString *SaveData, wxString DataType){
wxString ProcessData = "";
for (std::map::iterator AddressIter = AddressList->begin();
AddressIter != AddressList->end(); AddressIter++){
ProcessData.Append("ADR");
// Check if there is a value for TYPE.
if (DataType.size() > 0){
ProcessData.Append(";TYPE=");
ProcessData.Append(DataType);
}
// Check if there is a value for ALTID.
if ((*AddressListAltID)[AddressIter->first].size() > 0){
ProcessData.Append(";ALTID=");
ProcessData.Append((*AddressListAltID)[AddressIter->first]);
}
// Check if there is a value for GEO.
if ((*AddressListGeo)[AddressIter->first].size() > 0){
ProcessData.Append(";GEO=\"");
ProcessData.Append((*AddressListGeo)[AddressIter->first]);
ProcessData.Append("\"");
}
// Check if there is a value for LABEL.
if ((*AddressListLabel)[AddressIter->first].size() > 0){
wxString AddressProcessed = "";
AddressProcessed = (*AddressListLabel)[AddressIter->first];
AddressProcessed.Replace("\n", "\\n", true);
ProcessData.Append(";LABEL=");
ProcessData.Append(AddressProcessed);
}
// Check if there is a value for LANGUAGE.
if ((*AddressListLang)[AddressIter->first].size() > 0){
ProcessData.Append(";LANGUAGE=");
ProcessData.Append((*AddressListLang)[AddressIter->first]);
}
// Check if there is a value for MEDIATYPE.
if ((*AddressListMediatype)[AddressIter->first].size() > 0){
ProcessData.Append(";MEDIATYPE=");
ProcessData.Append((*AddressListMediatype)[AddressIter->first]);
}
// Check if there is a value for PID.
if ((*AddressListPID)[AddressIter->first].size() > 0){
ProcessData.Append(";PID=");
ProcessData.Append((*AddressListPID)[AddressIter->first]);
}
// Check if there is a value for PREF.
if ((*AddressListPref)[AddressIter->first] > 0){
ProcessData.Append(";PREF=");
ProcessData.Append(wxString::Format("%i", (*AddressListPref)[AddressIter->first]));
}
// Check if there is a value for TZ.
if ((*AddressListTimezone)[AddressIter->first].size() > 0){
ProcessData.Append(";TZ=");
ProcessData.Append((*AddressListTimezone)[AddressIter->first]);
}
// Check if there is a value for tokens.
if ((*AddressListTokens)[AddressIter->first].size() > 0){
ProcessData.Append(";");
ProcessData.Append((*AddressListTokens)[AddressIter->first]);
}
// Build the address.
ProcessData.Append(":;;");
ProcessData.Append((*AddressList)[AddressIter->first]);
ProcessData.Append(";");
ProcessData.Append((*AddressListTown)[AddressIter->first]);
ProcessData.Append(";");
ProcessData.Append((*AddressListCounty)[AddressIter->first]);
ProcessData.Append(";");
ProcessData.Append((*AddressListPostCode)[AddressIter->first]);
ProcessData.Append(";");
ProcessData.Append((*AddressListCountry)[AddressIter->first]);
ProcessData.Append("\n");
ProcessData = OutputText(&ProcessData);
SaveData->Append(ProcessData);
ProcessData.clear();
}
}
void ContactDataObject::SaveEmail(map *EmailList, map *EmailListAltID,
map *EmailListPID, map *EmailListType,
map *EmailListPref, map *EmailListTokens,
wxString *SaveData, wxString DataType){
wxString ProcessData = "";
for (std::map::iterator EmailIter = EmailList->begin();
EmailIter != EmailList->end(); EmailIter++){
ProcessData.Append("EMAIL");
// Check if there is a value for TYPE.
if (DataType.size() > 0){
ProcessData.Append(";TYPE=");
ProcessData.Append(DataType);
}
// Check if there is a value for ALTID.
if ((*EmailListAltID)[EmailIter->first].size() > 0){
ProcessData.Append(";ALTID=");
ProcessData.Append((*EmailListAltID)[EmailIter->first]);
}
// Check if there is a value for PID.
if ((*EmailListPID)[EmailIter->first].size() > 0){
ProcessData.Append(";PID=");
ProcessData.Append((*EmailListPID)[EmailIter->first]);
}
// Check if there is a value for PREF.
if ((*EmailListPref)[EmailIter->first] > 0){
ProcessData.Append(";PREF=");
ProcessData.Append(wxString::Format("%i", (*EmailListPref)[EmailIter->first]));
}
// Check if there is a value for tokens.
if ((*EmailListTokens)[EmailIter->first].size() > 0){
ProcessData.Append(";");
ProcessData.Append((*EmailListTokens)[EmailIter->first]);
}
ProcessData.Append(":");
ProcessData.Append(EmailIter->second);
ProcessData.Append("\n");
ProcessData = OutputText(&ProcessData);
SaveData->Append(ProcessData);
ProcessData.clear();
}
}
void ContactDataObject::SaveLanguage(map *LanguageList, map *LanguageListAltID,
map *LanguageListPID, map *LanguageListType,
map *LangaugeListPref, map *LanguageListTokens,
wxString *SaveData, wxString DataType){
wxString ProcessData = "";
for (std::map::iterator LanguageIter = LanguageList->begin();
LanguageIter != LanguageList->end(); LanguageIter++){
ProcessData.Append("LANG");
// Check if there is a value for TYPE.
if (DataType.size() > 0){
ProcessData.Append(";TYPE=");
ProcessData.Append(DataType);
}
// Check if there is a value for ALTID.
if ((*LanguageListAltID)[LanguageIter->first].size() > 0){
ProcessData.Append(";ALTID=");
ProcessData.Append((*LanguageListAltID)[LanguageIter->first]);
}
// Check if there is a value for PID.
if ((*LanguageListPID)[LanguageIter->first].size() > 0){
ProcessData.Append(";PID=");
ProcessData.Append((*LanguageListPID)[LanguageIter->first]);
}
// Check if there is a value for PREF.
if ((*LangaugeListPref)[LanguageIter->first] > 0){
ProcessData.Append(";PREF=");
ProcessData.Append(wxString::Format("%i", (*LangaugeListPref)[LanguageIter->first]));
}
// Check if there is a value for tokens.
if ((*LanguageListTokens)[LanguageIter->first].size() > 0){
ProcessData.Append(";");
ProcessData.Append((*LanguageListTokens)[LanguageIter->first]);
}
ProcessData.Append(":");
ProcessData.Append(LanguageIter->second);
ProcessData.Append("\n");
ProcessData = OutputText(&ProcessData);
SaveData->Append(ProcessData);
ProcessData.clear();
}
}
void ContactDataObject::SaveGeoposition(map *GeographyList, map *GeographyListAltID,
map *GeographyListPID, map *GeographyListType,
map *GeographyListMediatype, map *GeographyListDataType,
map *GeographyListPref, map *GeographyListTokens,
wxString *SaveData, wxString DataType){
wxString ProcessData = "";
for (std::map::iterator GeographyIter = GeographyList->begin();
GeographyIter != GeographyList->end(); GeographyIter++){
ProcessData.Append("GEO");
// Check if there is a value for TYPE.
if (DataType.size() > 0){
ProcessData.Append(";TYPE=");
ProcessData.Append(DataType);
}
// Check if there is a value for ALTID.
if ((*GeographyListAltID)[GeographyIter->first].size() > 0){
ProcessData.Append(";ALTID=");
ProcessData.Append((*GeographyListAltID)[GeographyIter->first]);
}
// Check if there is a value for MEDIATYPE.
if ((*GeographyListMediatype)[GeographyIter->first].size() > 0){
ProcessData.Append(";MEDIATYPE=");
ProcessData.Append((*GeographyListMediatype)[GeographyIter->first]);
}
// Check if there is a value for PID.
if ((*GeographyListPID)[GeographyIter->first].size() > 0){
ProcessData.Append(";PID=");
ProcessData.Append((*GeographyListPID)[GeographyIter->first]);
}
// Check if there is a value for PREF.
if ((*GeographyListPref)[GeographyIter->first] > 0){
ProcessData.Append(";PREF=");
ProcessData.Append(wxString::Format("%i", (*GeographyListPref)[GeographyIter->first]));
}
// Check if there is a value for tokens.
if ((*GeographyListTokens)[GeographyIter->first].size() > 0){
ProcessData.Append(";");
ProcessData.Append((*GeographyListTokens)[GeographyIter->first]);
}
ProcessData.Append(":");
ProcessData.Append((*GeographyListDataType)[GeographyIter->first]);
ProcessData.Append(":");
ProcessData.Append(GeographyIter->second);
ProcessData.Append("\n");
ProcessData = OutputText(&ProcessData);
SaveData->Append(ProcessData);
ProcessData.clear();
}
}