// frmContactEditor-Save.cpp - frmContactEditor save contact subroutines.
//
// (c) 2012-2015 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 "frmContactEditor.h"
#include "../enums.h"
#include "../version.h"
#include "../vcard/vcard.h"
#include "../vcard/vcard34conv.h"
#include "../common/textprocessing.h"
#include "../common/preferences.h"
#include "../common/uuid.h"
#include "../common/dirs.h"
void frmContactEditor::SaveContact( wxCommandEvent& event )
{
// Check if Display As combo box has a value in it.
// Do not go any further if there is no value.
wxString cmbDisplayAsValue = cmbDisplayAs->GetValue();
if (cmbDisplayAsValue.IsEmpty()){
wxMessageBox(_("Display As value cannot be left blank."), _("Display As value empty"), wxICON_ERROR);
return;
}
// Save the updated contact data.
vCard ContactData;
wxString FilenameFinal;
bool ReplaceContact = FALSE;
if (StartupEditMode == TRUE){
if (cmbType->GetCurrentSelection() == 1 ||
cmbType->GetCurrentSelection() == 3 ||
cmbType->GetCurrentSelection() == 4){
if (IsGroup == TRUE){
// Mark contact for replacing.
ReplaceContact = TRUE;
IsGroup = FALSE;
}
} else if (cmbType->GetCurrentSelection() == 2){
if (IsGroup == FALSE){
// Mark contact for replacing.
ReplaceContact = TRUE;
IsGroup = TRUE;
}
}
if (ReplaceContact == TRUE){
wxString wxDelSplitFilename;
wxString wxDelFinalFilename;
wxString wxSDelDataURL;
wxStringTokenizer wSTDelFilename(wxSContactFilename, wxT("/"));
while(wSTDelFilename.HasMoreTokens()){
wxDelSplitFilename = wSTDelFilename.GetNextToken();
}
wxSDelDataURL = wxDelSplitFilename;
// Delete the contact from the server as it will be useless in certain
// address book clients.
ActMgrPtr->AddTask(2, cmbDisplayAs->GetValue(), wxSContactAccount, wxSDelDataURL, wxDelSplitFilename, wxSContactFilename, wxT(""));
// Clear the filename so the trigger to recreate the UID is done.
wxSContactFilename.Clear();
EditMode = FALSE;
}
}
if (wxSContactFilename.IsEmpty()){
// Generate a random UUID.
UIDToken = GenerateUUID();
UIDToken = UIDToken.MakeUpper();
// Setup the filename.
FilenameFinal = GetAccountDir(wxSContactAccount, FALSE);
#if defined(__HAIKU__)
//preffilename = wxT("noo");
#elif defined(__WIN32__)
FilenameFinal = GetAccountDir(wxSContactAccount, FALSE);
FilenameFinal.Append(UIDToken);
FilenameFinal.Append(wxT(".vcf"));
wxSContactFilename = FilenameFinal;
#else
FilenameFinal = GetAccountDir(wxSContactAccount, FALSE);
FilenameFinal.Append(UIDToken);
FilenameFinal.Append(wxT(".vcf"));
wxSContactFilename = FilenameFinal;
#endif
} else {
if (UIDToken.IsEmpty()){
// UID Token is empty. (Shouldn't be).
// Generate a new UID Token.
/*boost::uuids::uuid ContactUUID = boost::uuids::random_generator()();
std::string sstContactUUID = boost::uuids::to_string(ContactUUID);
wxString strContactUUID(sstContactUUID.c_str(), wxConvUTF8);
UIDToken = strContactUUID;*/
UIDToken = GenerateUUID();
UIDToken = UIDToken.MakeUpper();
}
FilenameFinal = wxSContactFilename;
}
// Setup the data and write it into the account folder.
// Begin preperations to write the contact to a file.
bool boolValue = FALSE;
bool boolValue2 = FALSE;
bool FNFirst = TRUE;
bool NNGeneralFirst = TRUE;
bool NNHomeFirst = TRUE;
bool NNWorkFirst = TRUE;
int intFNCount = 0;
std::map::iterator intiter;
std::map::iterator striter;
ContactData.Add(wxT("BEGIN"), wxT("VCARD"), FALSE);
ContactData.Add(wxT("VERSION"), wxT("4.0"), FALSE);
// Setup the version string.
strValue.Append(wxT("-//Xestia//Address Book Version "));
strValue.Append(wxT(XSDAB_VERSION));
strValue.Append(wxT("//KW"));
ContactData.Add(wxT("PRODID"), strValue, FALSE);
// Setup the name.
strValue.Clear();
// Setup the name field.
strValue = txtSurname->GetValue() + wxT(";") +
txtForename->GetValue() + wxT(";") +
txtOtherNames->GetValue() + wxT(";") +
txtTitle->GetValue() + wxT(";") +
txtSuffix->GetValue();
strValue2 = ContactData.Convert(cmbDisplayAs->GetValue(), FALSE);
strValue2.Trim();
if (NameTokens.IsEmpty()){
ContactData.Add(wxT("N;SORT-AS=\"") + strValue2 + wxT("\""), strValue, FALSE);
} else {
ContactData.Add(wxT("N;SORT-AS=\"") + strValue2 + wxT("\";") + NameTokens, strValue, FALSE);
}
if (cmbType->GetCurrentSelection() == 1){
ContactData.AddRaw(wxT("KIND"), wxT("individual"));
} else if (cmbType->GetCurrentSelection() == 2){
ContactData.AddRaw(wxT("KIND"), wxT("group"));
// Go through each of the members and write them out.
for (std::map::iterator itemiter = GroupsList.begin();
itemiter != GroupsList.end(); ++itemiter){
ContactData.Add(wxT("MEMBER:urn:uuid"), itemiter->second, FALSE);
}
} else if (cmbType->GetCurrentSelection() == 3){
ContactData.AddRaw(wxT("KIND"), wxT("org"));
} else if (cmbType->GetCurrentSelection() == 4){
ContactData.AddRaw(wxT("KIND"), wxT("location"));
}
// Setup the nicknames (General, Home & Business).
strValue.Clear();
strValue2.Clear();
strValue3.Clear();
boolValue = FALSE;
boolValue2 = FALSE;
intValue2 = 0;
intValue = 0;
// Setup the gender.
if (cmbGender->GetCurrentSelection() != 0){
switch(cmbGender->GetCurrentSelection()){
case 1:
strValue = wxT("M");
break;
case 2:
strValue = wxT("F");
break;
case 3:
strValue = wxT("O");
break;
case 4:
strValue = wxT("N");
break;
case 5:
strValue = wxT("U");
break;
}
}
if (!txtGenderDescription->IsEmpty()){
strValue2 = txtGenderDescription->GetValue();
}
if (!strValue.IsEmpty() || !strValue2.IsEmpty()){
EscapeString(&strValue2, FALSE);
if (!GenderTokens.IsEmpty()){
if (!strValue2.IsEmpty()){
ContactData.AddRaw(wxT("GENDER;") + GenderTokens, strValue + wxT(";") + strValue2);
} else {
ContactData.AddRaw(wxT("GENDER;") + GenderTokens, strValue);
}
} else {
if (!strValue2.IsEmpty()){
ContactData.AddRaw(wxT("GENDER"), strValue + wxT(";") + strValue2);
} else {
ContactData.AddRaw(wxT("GENDER"), strValue);
}
}
}
strValue.Clear();
strValue2.Clear();
strValue3.Clear();
boolValue = FALSE;
boolValue2 = FALSE;
intValue2 = 0;
intValue = 0;
// Process Label.
strValue3 = BirthdayAltID;
if (!strValue3.IsEmpty()){
strValue3.Trim();
strValue3.Trim();
boolValue2 = TRUE;
strValue2.Append(wxT("ALTID=\"") + strValue3 + wxT("\""));
boolValue = TRUE;
}
//strValue3 = ContactData.Convert(GeneralAddressList, FALSE);
//strValue2 =
// Process Language.
strValue3 = BirthdayCalScale;
if (!strValue3.IsEmpty()){
strValue3.Trim();
strValue3.Trim();
if (boolValue2 == TRUE){
strValue2.Append(wxT(";"));
} else {
boolValue2 = TRUE;
}
strValue2.Append(wxT("CALSCALE=") + strValue3);
boolValue = TRUE;
}
// Process Tokens.
strValue2 = BirthdayTokens;
// Get the birthday and write it.
ResetSaveProcessData();
if (!txtBirthday->IsEmpty()){
strValue = txtBirthday->GetValue();
if (!strValue.IsEmpty() || !strValue2.IsEmpty()){
if (!strValue2.IsEmpty()){
EscapeString(&strValue2, FALSE);
EscapeString(&strValue, FALSE);
ContactData.AddRaw(wxT("BDAY;VALUE=text;") + strValue2 + wxT(";"), strValue);
} else {
EscapeString(&strValue, FALSE);
ContactData.AddRaw(wxT("BDAY;VALUE=text"), strValue);
}
}
} else {
// Deal with date.
// Get Day, Month & Year.
wxDateTime BirthdayDate;
wxDateTime::Month BirthdayMonth;
int BirthdayDay;
int BirthdayYear;
wxString DataBeforeT;
wxString DataAfterT;
wxString FinalBirthdayString;
bool ProcessDataAfterT = FALSE;
BirthdayDate = dapBirthday->GetValue();
if (BirthdayDate.IsValid()){
BirthdayDay = BirthdayDate.GetDay();
BirthdayMonth = BirthdayDate.GetMonth();
BirthdayYear = BirthdayDate.GetYear();
// Look for T and replace data before this.
wxStringTokenizer wSTDate(Birthday, wxT("T"));
while (wSTDate.HasMoreTokens()){
if (ProcessDataAfterT == FALSE){
DataBeforeT = wSTDate.GetNextToken();
ProcessDataAfterT = TRUE;
} else {
DataAfterT = wSTDate.GetNextToken();
break;
}
}
// If there is not T then replace altogether.
wxString FinalBirthdayDay;
wxString FinalBirthdayMonth;
wxString FinalBirthdayYear;
if (BirthdayDay < 10){
FinalBirthdayDay = wxT("0") + wxString::Format(wxT("%i"), BirthdayDay);
} else {
FinalBirthdayDay = wxString::Format(wxT("%i"), BirthdayDay);
}
if (((int)BirthdayMonth + 1) < 10){
FinalBirthdayMonth = wxT("0") + wxString::Format(wxT("%i"), ((int)BirthdayMonth + 1));
} else {
FinalBirthdayMonth = wxString::Format(wxT("%i"), ((int)BirthdayMonth + 1));
}
if (BirthdayYear == 0){
FinalBirthdayYear = wxT("--");
} else {
FinalBirthdayYear = wxString::Format(wxT("%i"), BirthdayYear);
}
if (!DataAfterT.IsEmpty()){
FinalBirthdayString = FinalBirthdayYear + FinalBirthdayMonth + FinalBirthdayDay + wxT("T") + DataAfterT;
} else {
FinalBirthdayString = FinalBirthdayYear + FinalBirthdayMonth + FinalBirthdayDay;
}
if (!FinalBirthdayString.IsEmpty() || !strValue2.IsEmpty()){
if (!strValue2.IsEmpty()){
EscapeString(&strValue2, FALSE);
EscapeString(&strValue, FALSE);
ContactData.AddRaw(wxT("BDAY") + strValue2 + wxT(";"), FinalBirthdayString);
} else {
EscapeString(&strValue, FALSE);
ContactData.AddRaw(wxT("BDAY"), FinalBirthdayString);
}
}
}
}
ResetSaveProcessData();
// Process Label.
strValue3 = AnniversaryAltID;
if (!strValue3.IsEmpty()){
strValue3.Trim();
strValue3.Trim();
boolValue2 = TRUE;
strValue2.Append(wxT("ALTID=\"") + strValue3 + wxT("\""));
boolValue = TRUE;
}
//strValue3 = ContactData.Convert(GeneralAddressList, FALSE);
//strValue2 =
// Process Language.
strValue3 = AnniversaryCalScale;
if (!strValue3.IsEmpty()){
strValue3.Trim();
strValue3.Trim();
if (boolValue2 == TRUE){
strValue2.Append(wxT(";"));
} else {
boolValue2 = TRUE;
}
strValue2.Append(wxT("CALSCALE=") + strValue3);
boolValue = TRUE;
}
// Process Tokens.
strValue2 = AnniversaryTokens;
// Deal with ANNIVERSARY.
if (!txtAnniversary->IsEmpty()){
strValue = txtAnniversary->GetValue();
if (!strValue.IsEmpty() || !strValue2.IsEmpty()){
if (!strValue2.IsEmpty()){
EscapeString(&strValue2, FALSE);
EscapeString(&strValue, FALSE);
ContactData.AddRaw(wxT("ANNIVERSARY;VALUE=text;") + strValue2 + wxT(";"), strValue);
} else {
EscapeString(&strValue, FALSE);
ContactData.AddRaw(wxT("ANNIVERSARY;VALUE=text"), strValue);
}
}
} else {
// Look for T and replace data before this.
// Get Day, Month & Year.
wxDateTime AnniversaryDate;
wxDateTime::Month AnniversaryMonth;
int AnniversaryDay;
int AnniversaryYear;
wxString DataBeforeT;
wxString DataAfterT;
wxString FinalAnniversaryString;
bool ProcessDataAfterT = FALSE;
AnniversaryDate = dapAnniversary->GetValue();
if (AnniversaryDate.IsValid()){
AnniversaryDay = AnniversaryDate.GetDay();
AnniversaryMonth = AnniversaryDate.GetMonth();
AnniversaryYear = AnniversaryDate.GetYear();
// Look for T and replace data before this.
wxStringTokenizer wSTDate(Anniversary, wxT("T"));
while (wSTDate.HasMoreTokens()){
if (ProcessDataAfterT == FALSE){
DataBeforeT = wSTDate.GetNextToken();
ProcessDataAfterT = TRUE;
} else {
DataAfterT = wSTDate.GetNextToken();
break;
}
}
// If there is not T then replace altogether.
wxString FinalAnniversaryDay;
wxString FinalAnniversaryMonth;
wxString FinalAnniversaryYear;
if (AnniversaryDay < 10){
FinalAnniversaryDay = wxT("0") + wxString::Format(wxT("%i"), AnniversaryDay);
} else {
FinalAnniversaryDay = wxString::Format(wxT("%i"), AnniversaryDay);
}
if (((int)AnniversaryMonth + 1) < 10){
FinalAnniversaryMonth = wxT("0") + wxString::Format(wxT("%i"), ((int)AnniversaryMonth + 1));
} else {
FinalAnniversaryMonth = wxString::Format(wxT("%i"), ((int)AnniversaryMonth + 1));
}
if (AnniversaryYear == 0){
FinalAnniversaryYear = wxT("--");
} else {
FinalAnniversaryYear = wxString::Format(wxT("%i"), AnniversaryYear);
}
if (!DataAfterT.IsEmpty()){
FinalAnniversaryString = FinalAnniversaryYear + FinalAnniversaryMonth + FinalAnniversaryDay + wxT("T") + DataAfterT;
} else {
FinalAnniversaryString = FinalAnniversaryYear + FinalAnniversaryMonth + FinalAnniversaryDay;
}
if (!FinalAnniversaryString.IsEmpty() || !strValue2.IsEmpty()){
if (!strValue2.IsEmpty()){
EscapeString(&strValue2, FALSE);
EscapeString(&strValue, FALSE);
ContactData.AddRaw(wxT("ANNIVERSARY") + strValue2 + wxT(";"), FinalAnniversaryString);
} else {
EscapeString(&strValue, FALSE);
ContactData.AddRaw(wxT("ANNIVERSARY"), FinalAnniversaryString);
}
}
}
}
// Setup the addresses (General, Home, Business).
//intValue = GeneralAddressList.size();
ResetSaveProcessData();
for (std::map::iterator iter = GeneralAddressList.begin();
iter != GeneralAddressList.end(); ++iter){
int intSeekValue = iter->first;
wxString strAddressString;
wxString strAddressFinalValue;
std::map::iterator iterValue;
strAddressString.Append(wxT(";;"));
// Get Address
iterValue = GeneralAddressList.find(intSeekValue);
strAddressFinalValue = iterValue->second;
ProcessCaptureStrings(&strAddressFinalValue);
strAddressString.Append(strAddressFinalValue + wxT(";"));
strAddressFinalValue.Clear();
// Get Town
iterValue = GeneralAddressListTown.find(intSeekValue);
strAddressFinalValue = iterValue->second;
ProcessCaptureStrings(&strAddressFinalValue);
strAddressString.Append(strAddressFinalValue + wxT(";"));
strAddressFinalValue.Clear();
// Get County
iterValue = GeneralAddressListCounty.find(intSeekValue);
strAddressFinalValue = iterValue->second;
ProcessCaptureStrings(&strAddressFinalValue);
strAddressString.Append(strAddressFinalValue + wxT(";"));
strAddressFinalValue.Clear();
// Get Post Code
iterValue = GeneralAddressListPostCode.find(intSeekValue);
strAddressFinalValue = iterValue->second;
ProcessCaptureStrings(&strAddressFinalValue);
strAddressString.Append(strAddressFinalValue + wxT(";"));
strAddressFinalValue.Clear();
// Get Country
iterValue = GeneralAddressListCountry.find(intSeekValue);
strAddressFinalValue = iterValue->second;
ProcessCaptureStrings(&strAddressFinalValue);
strAddressString.Append(strAddressFinalValue);
strAddressFinalValue.Clear();
ProcessSaveData(wxT("ADR"), &strValue2, &boolValue2, &boolValue,
&iter, &strAddressString, &ContactData,
wxT("LABEL"), &GeneralAddressListLabel,
wxT("LANGUAGE"), &GeneralAddressListLang,
wxT("ALTID"), &GeneralAddressListAltID,
wxT("PID"), &GeneralAddressListPID,
wxT("GEO"), &GeneralAddressListGeo,
wxT("TZ"), &GeneralAddressListTimezone,
wxT("MEDIATYPE"), &GeneralAddressListMediatype,
wxT("PREF"), &GeneralAddressListPref,
wxT(""), &GeneralAddressListTokens );
ResetSaveProcessData();
}
ResetSaveProcessData();
for (std::map::iterator iter = HomeAddressList.begin();
iter != HomeAddressList.end(); ++iter){
int intSeekValue = iter->first;
wxString strAddressString;
wxString strAddressFinalValue;
std::map::iterator iterValue;
strAddressString.Append(wxT(";;"));
// Get Address
iterValue = HomeAddressList.find(intSeekValue);
strAddressFinalValue = iterValue->second;
ProcessCaptureStrings(&strAddressFinalValue);
strAddressString.Append(strAddressFinalValue + wxT(";"));
// Get Town
iterValue = HomeAddressListTown.find(intSeekValue);
strAddressFinalValue = iterValue->second;
ProcessCaptureStrings(&strAddressFinalValue);
strAddressString.Append(strAddressFinalValue + wxT(";"));
// Get County
iterValue = HomeAddressListCounty.find(intSeekValue);
strAddressFinalValue = iterValue->second;
ProcessCaptureStrings(&strAddressFinalValue);
strAddressString.Append(strAddressFinalValue + wxT(";"));
// Get Post Code
iterValue = HomeAddressListPostCode.find(intSeekValue);
strAddressFinalValue = iterValue->second;
ProcessCaptureStrings(&strAddressFinalValue);
strAddressString.Append(strAddressFinalValue + wxT(";"));
// Get Country
iterValue = HomeAddressListCountry.find(intSeekValue);
strAddressFinalValue = iterValue->second;
ProcessCaptureStrings(&strAddressFinalValue);
strAddressString.Append(strAddressFinalValue);
ProcessSaveData(wxT("ADR;TYPE=home"), &strValue2, &boolValue2, &boolValue,
&iter, &strAddressString, &ContactData,
wxT("LABEL"), &HomeAddressListLabel,
wxT("LANGUAGE"), &HomeAddressListLang,
wxT("ALTID"), &HomeAddressListAltID,
wxT("PID"), &HomeAddressListPID,
wxT("GEO"), &HomeAddressListGeo,
wxT("TZ"), &HomeAddressListTimezone,
wxT("MEDIATYPE"), &HomeAddressListMediatype,
wxT("PREF"), &HomeAddressListPref,
wxT(""), &HomeAddressListTokens );
ResetSaveProcessData();
}
ResetSaveProcessData();
for (std::map::iterator iter = BusinessAddressList.begin();
iter != BusinessAddressList.end(); ++iter){
int intSeekValue = iter->first;
wxString strAddressString;
wxString strAddressFinalValue;
std::map::iterator iterValue;
strAddressString.Append(wxT(";;"));
// Get Address
iterValue = BusinessAddressList.find(intSeekValue);
strAddressFinalValue = iterValue->second;
ProcessCaptureStrings(&strAddressFinalValue);
strAddressString.Append(strAddressFinalValue + wxT(";"));
// Get Town
iterValue = BusinessAddressListTown.find(intSeekValue);
strAddressFinalValue = iterValue->second;
ProcessCaptureStrings(&strAddressFinalValue);
strAddressString.Append(strAddressFinalValue + wxT(";"));
// Get County
iterValue = BusinessAddressListCounty.find(intSeekValue);
strAddressFinalValue = iterValue->second;
ProcessCaptureStrings(&strAddressFinalValue);
strAddressString.Append(strAddressFinalValue + wxT(";"));
// Get Post Code
iterValue = BusinessAddressListPostCode.find(intSeekValue);
strAddressFinalValue = iterValue->second;
ProcessCaptureStrings(&strAddressFinalValue);
strAddressString.Append(strAddressFinalValue + wxT(";"));
// Get Country
iterValue = BusinessAddressListCountry.find(intSeekValue);
strAddressFinalValue = iterValue->second;
ProcessCaptureStrings(&strAddressFinalValue);
strAddressString.Append(strAddressFinalValue);
ProcessSaveData(wxT("ADR;TYPE=work"), &strValue2, &boolValue2, &boolValue,
&iter, &strAddressString, &ContactData,
wxT("LABEL"), &BusinessAddressListLabel,
wxT("LANGUAGE"), &BusinessAddressListLang,
wxT("ALTID"), &BusinessAddressListAltID,
wxT("PID"), &BusinessAddressListPID,
wxT("GEO"), &BusinessAddressListGeo,
wxT("TZ"), &BusinessAddressListTimezone,
wxT("MEDIATYPE"), &BusinessAddressListMediatype,
wxT("PREF"), &BusinessAddressListPref,
wxT(""), &BusinessAddressListTokens );
ResetSaveProcessData();
}
// Sort out nicknames (if any).
for (std::map::iterator iter = GeneralNicknamesList.begin();
iter != GeneralNicknamesList.end(); ++iter){
intValue2 = iter->first;
// Process Alternative ID.
ProcessSaveData(wxT("NICKNAME"), &strValue2, &boolValue2, &boolValue,
&iter, &GeneralNicknamesList, &ContactData,
wxT("LANGUAGE"), &GeneralNicknamesListLanguage,
wxT("ALTID"), &GeneralNicknamesListAltID,
wxT("PID"), &GeneralNicknamesListPID,
wxT("PREF"), &GeneralNicknamesListPref,
wxT(""), &GeneralNicknamesListTokens );
ResetSaveProcessData();
}
ResetSaveProcessData();
for (std::map::iterator iter = HomeNicknamesList.begin();
iter != HomeNicknamesList.end(); ++iter){
ProcessSaveData(wxT("NICKNAME;TYPE=home"), &strValue2, &boolValue2, &boolValue,
&iter, &HomeNicknamesList, &ContactData,
wxT("LANGUAGE"), &HomeNicknamesListLanguage,
wxT("ALTID"), &HomeNicknamesListAltID,
wxT("PID"), &HomeNicknamesListPID,
wxT("PREF"), &HomeNicknamesListPref,
wxT(""), &HomeNicknamesListTokens );
ResetSaveProcessData();
}
ResetSaveProcessData();
for (std::map::iterator iter = BusinessNicknamesList.begin();
iter != BusinessNicknamesList.end(); ++iter){
ProcessSaveData(wxT("NICKNAME;TYPE=work"), &strValue2, &boolValue2, &boolValue,
&iter, &BusinessNicknamesList, &ContactData,
wxT("LANGUAGE"), &BusinessNicknamesListLanguage,
wxT("ALTID"), &BusinessNicknamesListAltID,
wxT("PID"), &BusinessNicknamesListPID,
wxT("PREF"), &BusinessNicknamesListPref,
wxT(""), &BusinessNicknamesListTokens );
ResetSaveProcessData();
}
ResetSaveProcessData();
// Sort out email (general, home and business).
for (std::map::iterator iter = GeneralEmailList.begin();
iter != GeneralEmailList.end(); ++iter){
//strValue3 = ContactData.Convert(GeneralAddressList, FALSE);
//strValue2 =
wxString strAddressFinalValue;
std::map::iterator iterValue;
ProcessSaveData(wxT("EMAIL"), &strValue2, &boolValue2, &boolValue,
&iter, &GeneralEmailList, &ContactData,
wxT("ALTID"), &GeneralEmailListAltID,
wxT("PID"), &GeneralEmailListPID,
wxT("PREF"), &GeneralEmailListPref,
wxT(""), &GeneralEmailListTokens );
ResetSaveProcessData();
}
ResetSaveProcessData();
for (std::map::iterator iter = HomeEmailList.begin();
iter != HomeEmailList.end(); ++iter){
//strValue3 = ContactData.Convert(GeneralAddressList, FALSE);
//strValue2 =
ProcessSaveData(wxT("EMAIL;TYPE=home"), &strValue2, &boolValue2, &boolValue,
&iter, &HomeEmailList, &ContactData,
wxT("ALTID"), &HomeEmailListAltID,
wxT("PID"), &HomeEmailListPID,
wxT("PREF"), &HomeEmailListPref,
wxT(""), &HomeEmailListTokens );
ResetSaveProcessData();
}
ResetSaveProcessData();
for (std::map::iterator iter = BusinessEmailList.begin();
iter != BusinessEmailList.end(); ++iter){
//strValue3 = ContactData.Convert(GeneralAddressList, FALSE);
//strValue2 =
ProcessSaveData(wxT("EMAIL;TYPE=work"), &strValue2, &boolValue2, &boolValue,
&iter, &BusinessEmailList, &ContactData,
wxT("ALTID"), &BusinessEmailListAltID,
wxT("PID"), &BusinessEmailListPID,
wxT("PREF"), &BusinessEmailListPref,
wxT(""), &BusinessEmailListTokens );
ResetSaveProcessData();
}
ResetSaveProcessData();
for (std::map::iterator iter = GeneralIMList.begin();
iter != GeneralIMList.end(); ++iter){
intValue2 = iter->first;
// Process Alternative ID.
ProcessSaveData(wxT("IMPP"), &strValue2, &boolValue2, &boolValue,
&iter, &GeneralIMList, &ContactData,
wxT("ALTID"), &GeneralIMListAltID,
wxT("PID"), &GeneralIMListPID,
wxT("MEDIATYPE"), &GeneralIMListMediatype,
wxT("PREF"), &GeneralIMListPref,
wxT(""), &GeneralIMListTokens );
ResetSaveProcessData();
}
ResetSaveProcessData();
for (std::map::iterator iter = HomeIMList.begin();
iter != HomeIMList.end(); ++iter){
ProcessSaveData(wxT("IMPP;TYPE=home"), &strValue2, &boolValue2, &boolValue,
&iter, &HomeIMList, &ContactData,
wxT("ALTID"), &HomeIMListAltID,
wxT("PID"), &HomeIMListPID,
wxT("MEDIATYPE"), &HomeIMListMediatype,
wxT("PREF"), &HomeIMListPref,
wxT(""), &HomeIMListTokens );
ResetSaveProcessData();
}
ResetSaveProcessData();
for (std::map::iterator iter = BusinessIMList.begin();
iter != BusinessIMList.end(); ++iter){
ProcessSaveData(wxT("IMPP;TYPE=work"), &strValue2, &boolValue2, &boolValue,
&iter, &BusinessIMList, &ContactData,
wxT("ALTID"), &BusinessIMListAltID,
wxT("PID"), &BusinessIMListPID,
wxT("MEDIATYPE"), &BusinessIMListMediatype,
wxT("PREF"), &BusinessIMListPref,
wxT(""), &BusinessIMListTokens );
ResetSaveProcessData();
}
ResetSaveProcessData();
for (std::map::iterator iter = GeneralTelephoneList.begin();
iter != GeneralTelephoneList.end(); ++iter){
wxString strAddressFinalValue = iter->second;
ProcessCaptureStrings(&strAddressFinalValue);
strAddressFinalValue.insert(0, wxT("tel:"));
ProcessSaveData(wxT("TEL"), &strValue2, &boolValue2, &boolValue,
&iter, &strAddressFinalValue, &ContactData,
wxT("ALTID"), &GeneralTelephoneListAltID,
wxT("PID"), &GeneralTelephoneListPID,
wxT("TYPE"), &GeneralTelephoneListType,
wxT("PREF"), &GeneralTelephoneListPref,
wxT(""), &GeneralTelephoneListTokens );
ResetSaveProcessData();
}
ResetSaveProcessData();
for (std::map::iterator iter = HomeTelephoneList.begin();
iter != HomeTelephoneList.end(); ++iter){
wxString strAddressFinalValue = iter->second;
ProcessCaptureStrings(&strAddressFinalValue);
strAddressFinalValue.insert(0, wxT("tel:"));
ProcessSaveData(wxT("TEL"), &strValue2, &boolValue2, &boolValue,
&iter, &strAddressFinalValue, &ContactData,
wxT("ALTID"), &HomeTelephoneListAltID,
wxT("PID"), &HomeTelephoneListPID,
wxT("TYPE"), &HomeTelephoneListType,
wxT("PREF"), &HomeTelephoneListPref,
wxT(""), &HomeTelephoneListTokens );
ResetSaveProcessData();
}
ResetSaveProcessData();
for (std::map::iterator iter = BusinessTelephoneList.begin();
iter != BusinessTelephoneList.end(); ++iter){
wxString strAddressFinalValue = iter->second;
ProcessCaptureStrings(&strAddressFinalValue);
strAddressFinalValue.insert(0, wxT("tel:"));
ProcessSaveData(wxT("TEL"), &strValue2, &boolValue2, &boolValue,
&iter, &strAddressFinalValue, &ContactData,
wxT("ALTID"), &BusinessTelephoneListAltID,
wxT("PID"), &BusinessTelephoneListPID,
wxT("TYPE"), &BusinessTelephoneListType,
wxT("PREF"), &BusinessTelephoneListPref,
wxT(""), &BusinessTelephoneListTokens );
ResetSaveProcessData();
}
ResetSaveProcessData();
for (std::map::iterator iter = GeneralLanguageList.begin();
iter != GeneralLanguageList.end(); ++iter){
intValue2 = iter->first;
ProcessSaveData(wxT("LANG"), &strValue2, &boolValue2, &boolValue,
&iter, &GeneralLanguageList, &ContactData,
wxT("ALTID"), &GeneralLanguageListAltID,
wxT("PID"), &GeneralLanguageListPID,
wxT("PREF"), &GeneralLanguageListPref,
wxT(""), &GeneralLanguageListTokens );
ResetSaveProcessData();
}
ResetSaveProcessData();
for (std::map::iterator iter = HomeLanguageList.begin();
iter != HomeLanguageList.end(); ++iter){
ProcessSaveData(wxT("LANG;TYPE=home"), &strValue2, &boolValue2, &boolValue,
&iter, &HomeLanguageList, &ContactData,
wxT("ALTID"), &HomeLanguageListAltID,
wxT("PID"), &HomeLanguageListPID,
wxT("PREF"), &HomeLanguageListPref,
wxT(""), &HomeLanguageListTokens );
ResetSaveProcessData();
}
ResetSaveProcessData();
for (std::map::iterator iter = BusinessLanguageList.begin();
iter != BusinessLanguageList.end(); ++iter){
ProcessSaveData(wxT("LANG;TYPE=work"), &strValue2, &boolValue2, &boolValue,
&iter, &BusinessLanguageList, &ContactData,
wxT("ALTID"), &BusinessLanguageListAltID,
wxT("PID"), &BusinessLanguageListPID,
wxT("PREF"), &BusinessLanguageListPref,
wxT(""), &BusinessLanguageListTokens );
ResetSaveProcessData();
}
ResetSaveProcessData();
for (std::map::iterator iter = GeneralTZList.begin();
iter != GeneralTZList.end(); ++iter){
ProcessSaveData(wxT("TZ"), &strValue2, &boolValue2, &boolValue,
&iter, &GeneralTZList, &ContactData,
wxT("ALTID"), &GeneralTZListAltID,
wxT("PID"), &GeneralTZListPID,
wxT("MEDIATYPE"), &GeneralTZListMediatype,
wxT("PREF"), &GeneralTZListPref,
wxT(""), &GeneralTZListTokens );
ResetSaveProcessData();
}
ResetSaveProcessData();
for (std::map::iterator iter = HomeTZList.begin();
iter != HomeTZList.end(); ++iter){
ProcessSaveData(wxT("TZ;TYPE=home"), &strValue2, &boolValue2, &boolValue,
&iter, &HomeTZList, &ContactData,
wxT("ALTID"), &HomeTZListAltID,
wxT("PID"), &HomeTZListPID,
wxT("MEDIATYPE"), &HomeTZListMediatype,
wxT("PREF"), &HomeTZListPref,
wxT(""), &HomeTZListTokens );
ResetSaveProcessData();
}
ResetSaveProcessData();
for (std::map::iterator iter = BusinessTZList.begin();
iter != BusinessTZList.end(); ++iter){
ProcessSaveData(wxT("TZ;TYPE=work"), &strValue2, &boolValue2, &boolValue,
&iter, &BusinessTZList, &ContactData,
wxT("ALTID"), &BusinessTZListAltID,
wxT("PID"), &BusinessTZListPID,
wxT("MEDIATYPE"), &BusinessTZListMediatype,
wxT("PREF"), &BusinessTZListPref,
wxT(""), &BusinessTZListTokens );
ResetSaveProcessData();
}
ResetSaveProcessData();
for (std::map::iterator iter = GeneralGeographyList.begin();
iter != GeneralGeographyList.end(); ++iter){
wxString strAddressFinalValue = iter->second;
ProcessCaptureStrings(&strAddressFinalValue);
strAddressFinalValue.insert(0, wxT("geo:"));
ProcessSaveData(wxT("GEO"), &strValue2, &boolValue2, &boolValue,
&iter, &strAddressFinalValue, &ContactData,
wxT("ALTID"), &GeneralGeographyListAltID,
wxT("PID"), &GeneralGeographyListPID,
wxT("MEDIATYPE"), &GeneralGeographyListMediatype,
wxT("PREF"), &GeneralGeographyListPref,
wxT(""), &GeneralGeographyListTokens );
ResetSaveProcessData();
}
ResetSaveProcessData();
for (std::map::iterator iter = HomeGeographyList.begin();
iter != HomeGeographyList.end(); ++iter){
wxString strAddressFinalValue = iter->second;
ProcessCaptureStrings(&strAddressFinalValue);
strAddressFinalValue.insert(0, wxT("geo:"));
ProcessSaveData(wxT("GEO;TYPE=home"), &strValue2, &boolValue2, &boolValue,
&iter, &HomeGeographyList, &ContactData,
wxT("ALTID"), &HomeGeographyListAltID,
wxT("PID"), &HomeGeographyListPID,
wxT("MEDIATYPE"), &HomeGeographyListMediatype,
wxT("PREF"), &HomeGeographyListPref,
wxT(""), &HomeGeographyListTokens );
ResetSaveProcessData();
}
ResetSaveProcessData();
for (std::map::iterator iter = BusinessGeographyList.begin();
iter != BusinessGeographyList.end(); ++iter){
wxString strAddressFinalValue = iter->second;
ProcessCaptureStrings(&strAddressFinalValue);
strAddressFinalValue.insert(0, wxT("geo:"));
ProcessSaveData(wxT("GEO;TYPE=work"), &strValue2, &boolValue2, &boolValue,
&iter, &BusinessGeographyList, &ContactData,
wxT("ALTID"), &BusinessGeographyListAltID,
wxT("PID"), &BusinessGeographyListPID,
wxT("MEDIATYPE"), &BusinessGeographyListMediatype,
wxT("PREF"), &BusinessGeographyListPref,
wxT(""), &BusinessGeographyListTokens );
ResetSaveProcessData();
}
ResetSaveProcessData();
for (std::map::iterator iter = GeneralRelatedList.begin();
iter != GeneralRelatedList.end(); ++iter){
ProcessSaveData(wxT("RELATED"), &strValue2, &boolValue2, &boolValue,
&iter, &GeneralRelatedList, &ContactData,
wxT("ALTID"), &GeneralRelatedListAltID,
wxT("PID"), &GeneralRelatedListPID,
wxT("LANGUAGE"), &GeneralRelatedListLanguage,
wxT("TYPE"), &GeneralRelatedListRelType,
wxT("PREF"), &GeneralRelatedListPref,
wxT(""), &GeneralRelatedListTokens );
ResetSaveProcessData();
}
ResetSaveProcessData();
for (std::map::iterator iter = GeneralWebsiteList.begin();
iter != GeneralWebsiteList.end(); ++iter){
ProcessSaveData(wxT("URL"), &strValue2, &boolValue2, &boolValue,
&iter, &GeneralWebsiteList, &ContactData,
wxT("ALTID"), &GeneralWebsiteListAltID,
wxT("PID"), &GeneralWebsiteListPID,
wxT("MEDIATYPE"), &GeneralWebsiteListMediatype,
wxT("PREF"), &GeneralWebsiteListPref,
wxT(""), &GeneralWebsiteListTokens );
ResetSaveProcessData();
}
ResetSaveProcessData();
for (std::map::iterator iter = HomeWebsiteList.begin();
iter != HomeWebsiteList.end(); ++iter){
ProcessSaveData(wxT("URL;TYPE=home"), &strValue2, &boolValue2, &boolValue,
&iter, &HomeWebsiteList, &ContactData,
wxT("ALTID"), &HomeWebsiteListAltID,
wxT("PID"), &HomeWebsiteListPID,
wxT("MEDIATYPE"), &HomeWebsiteListMediatype,
wxT("PREF"), &HomeWebsiteListPref,
wxT(""), &HomeWebsiteListTokens );
ResetSaveProcessData();
}
ResetSaveProcessData();
for (std::map::iterator iter = BusinessWebsiteList.begin();
iter != BusinessWebsiteList.end(); ++iter){
ProcessSaveData(wxT("URL;TYPE=work"), &strValue2, &boolValue2, &boolValue,
&iter, &BusinessWebsiteList, &ContactData,
wxT("ALTID"), &BusinessWebsiteListAltID,
wxT("PID"), &BusinessWebsiteListPID,
wxT("MEDIATYPE"), &BusinessWebsiteListMediatype,
wxT("PREF"), &BusinessWebsiteListPref,
wxT(""), &BusinessWebsiteListTokens );
ResetSaveProcessData();
}
ResetSaveProcessData();
for (std::map::iterator iter = GeneralTitleList.begin();
iter != GeneralTitleList.end(); ++iter){
ProcessSaveData(wxT("TITLE"), &strValue2, &boolValue2, &boolValue,
&iter, &GeneralTitleList, &ContactData,
wxT("ALTID"), &GeneralTitleListAltID,
wxT("PID"), &GeneralTitleListPID,
wxT("LANGUAGE"), &GeneralTitleListLanguage,
wxT("PREF"), &GeneralTitleListPref,
wxT(""), &GeneralTitleListTokens );
ResetSaveProcessData();
}
ResetSaveProcessData();
for (std::map::iterator iter = HomeTitleList.begin();
iter != HomeTitleList.end(); ++iter){
ProcessSaveData(wxT("TITLE;TYPE=home"), &strValue2, &boolValue2, &boolValue,
&iter, &HomeTitleList, &ContactData,
wxT("ALTID"), &HomeTitleListAltID,
wxT("PID"), &HomeTitleListPID,
wxT("LANGUAGE"), &HomeTitleListLanguage,
wxT("PREF"), &HomeTitleListPref,
wxT(""), &HomeTitleListTokens );
ResetSaveProcessData();
}
ResetSaveProcessData();
for (std::map::iterator iter = BusinessTitleList.begin();
iter != BusinessTitleList.end(); ++iter){
ProcessSaveData(wxT("TITLE;TYPE=work"), &strValue2, &boolValue2, &boolValue,
&iter, &BusinessTitleList, &ContactData,
wxT("ALTID"), &BusinessTitleListAltID,
wxT("PID"), &BusinessTitleListPID,
wxT("LANGUAGE"), &BusinessTitleListLanguage,
wxT("PREF"), &BusinessTitleListPref,
wxT(""), &BusinessTitleListTokens );
ResetSaveProcessData();
}
ResetSaveProcessData();
for (std::map::iterator iter = GeneralRoleList.begin();
iter != GeneralRoleList.end(); ++iter){
ProcessSaveData(wxT("ROLE"), &strValue2, &boolValue2, &boolValue,
&iter, &GeneralRoleList, &ContactData,
wxT("ALTID"), &GeneralRoleListAltID,
wxT("PID"), &GeneralRoleListPID,
wxT("LANGUAGE"), &GeneralRoleListLanguage,
wxT("PREF"), &GeneralRoleListPref,
wxT(""), &GeneralRoleListTokens );
ResetSaveProcessData();
}
ResetSaveProcessData();
for (std::map::iterator iter = HomeRoleList.begin();
iter != HomeRoleList.end(); ++iter){
ProcessSaveData(wxT("ROLE;TYPE=home"), &strValue2, &boolValue2, &boolValue,
&iter, &HomeRoleList, &ContactData,
wxT("ALTID"), &HomeRoleListAltID,
wxT("PID"), &HomeRoleListPID,
wxT("LANGUAGE"), &HomeRoleListLanguage,
wxT("PREF"), &HomeRoleListPref,
wxT(""), &HomeRoleListTokens );
ResetSaveProcessData();
}
ResetSaveProcessData();
for (std::map::iterator iter = BusinessRoleList.begin();
iter != BusinessRoleList.end(); ++iter){
ProcessSaveData(wxT("ROLE;TYPE=work"), &strValue2, &boolValue2, &boolValue,
&iter, &BusinessRoleList, &ContactData,
wxT("ALTID"), &BusinessRoleListAltID,
wxT("PID"), &BusinessRoleListPID,
wxT("LANGUAGE"), &BusinessRoleListLanguage,
wxT("PREF"), &BusinessRoleListPref,
wxT(""), &BusinessRoleListTokens );
ResetSaveProcessData();
}
ResetSaveProcessData();
for (std::map::iterator iter = GeneralOrganisationsList.begin();
iter != GeneralOrganisationsList.end(); ++iter){
ProcessSaveData(wxT("ORG"), &strValue2, &boolValue2, &boolValue,
&iter, &GeneralOrganisationsList, &ContactData,
wxT("ALTID"), &GeneralOrganisationsListAltID,
wxT("PID"), &GeneralOrganisationsListPID,
wxT("LANGUAGE"), &GeneralOrganisationsListLanguage,
wxT("SORT-AS"), &GeneralOrganisationsListSortAs,
wxT("PREF"), &GeneralOrganisationsListPref,
wxT(""), &GeneralOrganisationsListTokens );
ResetSaveProcessData();
}
ResetSaveProcessData();
for (std::map::iterator iter = HomeOrganisationsList.begin();
iter != HomeOrganisationsList.end(); ++iter){
ProcessSaveData(wxT("ORG;TYPE=home"), &strValue2, &boolValue2, &boolValue,
&iter, &HomeOrganisationsList, &ContactData,
wxT("ALTID"), &HomeOrganisationsListAltID,
wxT("PID"), &HomeOrganisationsListPID,
wxT("LANGUAGE"), &HomeOrganisationsListLanguage,
wxT("SORT-AS"), &HomeOrganisationsListSortAs,
wxT("PREF"), &HomeOrganisationsListPref,
wxT(""), &HomeOrganisationsListTokens );
ResetSaveProcessData();
}
ResetSaveProcessData();
for (std::map::iterator iter = BusinessOrganisationsList.begin();
iter != BusinessOrganisationsList.end(); ++iter){
ProcessSaveData(wxT("ORG;TYPE=work"), &strValue2, &boolValue2, &boolValue,
&iter, &BusinessOrganisationsList, &ContactData,
wxT("ALTID"), &BusinessOrganisationsListAltID,
wxT("PID"), &BusinessOrganisationsListPID,
wxT("LANGUAGE"), &BusinessOrganisationsListLanguage,
wxT("SORT-AS"), &BusinessOrganisationsListSortAs,
wxT("PREF"), &BusinessOrganisationsListPref,
wxT(""), &BusinessOrganisationsListTokens );
ResetSaveProcessData();
}
ResetSaveProcessData();
for (std::map::iterator iter = GeneralNoteList.begin();
iter != GeneralNoteList.end(); ++iter){
ProcessSaveData(wxT("NOTE"), &strValue2, &boolValue2, &boolValue,
&iter, &GeneralNoteList, &ContactData,
wxT("ALTID"), &GeneralNoteListAltID,
wxT("PID"), &GeneralNoteListPID,
wxT("LANGUAGE"), &GeneralNoteListLanguage,
wxT("PREF"), &GeneralNoteListPref,
wxT(""), &GeneralNoteListTokens );
ResetSaveProcessData();
}
ResetSaveProcessData();
for (std::map::iterator iter = HomeNoteList.begin();
iter != HomeNoteList.end(); ++iter){
ProcessSaveData(wxT("NOTE;TYPE=home"), &strValue2, &boolValue2, &boolValue,
&iter, &HomeNoteList, &ContactData,
wxT("ALTID"), &HomeNoteListAltID,
wxT("PID"), &HomeNoteListPID,
wxT("LANGUAGE"), &HomeNoteListLanguage,
wxT("PREF"), &HomeNoteListPref,
wxT(""), &HomeNoteListTokens );
ResetSaveProcessData();
}
ResetSaveProcessData();
for (std::map::iterator iter = BusinessNoteList.begin();
iter != BusinessNoteList.end(); ++iter){
ProcessSaveData(wxT("NOTE;TYPE=work"), &strValue2, &boolValue2, &boolValue,
&iter, &BusinessNoteList, &ContactData,
wxT("ALTID"), &BusinessNoteListAltID,
wxT("PID"), &BusinessNoteListPID,
wxT("LANGUAGE"), &BusinessNoteListLanguage,
wxT("PREF"), &BusinessNoteListPref,
wxT(""), &BusinessNoteListTokens );
ResetSaveProcessData();
}
ResetSaveProcessData();
for (std::map::iterator iter = CategoriesList.begin();
iter != CategoriesList.end(); ++iter){
ProcessSaveData(wxT("CATEGORIES"), &strValue2, &boolValue2, &boolValue,
&iter, &CategoriesList, &ContactData,
wxT("ALTID"), &CategoriesListAltID,
wxT("PID"), &CategoriesListPID,
wxT("TYPE"), &CategoriesListType,
wxT("PREF"), &CategoriesListPref,
wxT(""), &CategoriesListTokens );
ResetSaveProcessData();
}
// Pictures.
for (std::map::iterator iter = PicturesList.begin();
iter != PicturesList.end(); ++iter){
int intValueIndex = iter->first;
std::map::iterator stdstriter;
std::map::iterator enciter;
striter = PicturesListPictureType.find(intValueIndex);
enciter = PicturesListPicEncType.find(intValueIndex);
ProcessSaveData(wxT("PHOTO"), &strValue2, &boolValue2, &boolValue,
&iter, &PicturesList, &striter,
&enciter, &ContactData,
wxT("ALTID"), &PicturesListAltID,
wxT("PID"), &PicturesListPID,
wxT("TYPE"), &PicturesListType,
wxT("PREF"), &PicturesListPref,
wxT(""), &PicturesListTokens);
ResetSaveProcessData();
}
ResetSaveProcessData();
// Logos.
for (std::map::iterator iter = LogosList.begin();
iter != LogosList.end(); ++iter){
int intValueIndex = iter->first;
std::map::iterator stdstriter;
std::map::iterator enciter;
striter = LogosListPictureType.find(intValueIndex);
enciter = LogosListPicEncType.find(intValueIndex);
ProcessSaveData(wxT("LOGO"), &strValue2, &boolValue2, &boolValue,
&iter, &LogosList, &striter,
&enciter, &ContactData,
wxT("ALTID"), &LogosListAltID,
wxT("PID"), &LogosListPID,
wxT("TYPE"), &LogosListType,
wxT("PREF"), &LogosListPref,
wxT(""), &LogosListTokens );
ResetSaveProcessData();
}
ResetSaveProcessData();
// Sounds.
for (std::map::iterator iter = SoundsList.begin();
iter != SoundsList.end(); ++iter){
int intValueIndex = iter->first;
std::map::iterator stdstriter;
std::map::iterator enciter;
striter = SoundsListAudioType.find(intValueIndex);
enciter = SoundsListAudioEncType.find(intValueIndex);
ProcessSaveData(wxT("SOUND"), &strValue2, &boolValue2, &boolValue,
&iter, &SoundsList, &striter,
&enciter, &ContactData,
wxT("ALTID"), &SoundsListAltID,
wxT("PID"), &SoundsListPID,
wxT("TYPE"), &SoundsListType,
wxT("PREF"), &SoundsListPref,
wxT(""), &SoundsListTokens );
ResetSaveProcessData();
}
ResetSaveProcessData();
for (std::map::iterator iter = CalendarList.begin();
iter != CalendarList.end(); ++iter){
ProcessSaveData(wxT("CALURI"), &strValue2, &boolValue2, &boolValue,
&iter, &CalendarList, &ContactData,
wxT("ALTID"), &CalendarListAltID,
wxT("PID"), &CalendarListPID,
wxT("MEDIATYPE"), &CalendarListMediatype,
wxT("TYPE"), &CalendarListType,
wxT("PREF"), &CalendarListPref,
wxT(""), &CalendarListTokens );
ResetSaveProcessData();
}
ResetSaveProcessData();
for (std::map::iterator iter = CalendarRequestList.begin();
iter != CalendarRequestList.end(); ++iter){
ProcessSaveData(wxT("CALADRURI"), &strValue2, &boolValue2, &boolValue,
&iter, &CalendarRequestList, &ContactData,
wxT("ALTID"), &CalendarRequestListAltID,
wxT("PID"), &CalendarRequestListPID,
wxT("MEDIATYPE"), &CalendarRequestListMediatype,
wxT("TYPE"), &CalendarRequestListType,
wxT("PREF"), &CalendarRequestListPref,
wxT(""), &CalendarRequestListTokens );
ResetSaveProcessData();
}
ResetSaveProcessData();
for (std::map::iterator iter = FreeBusyList.begin();
iter != FreeBusyList.end(); ++iter){
ProcessSaveData(wxT("FBURL"), &strValue2, &boolValue2, &boolValue,
&iter, &FreeBusyList, &ContactData,
wxT("ALTID"), &FreeBusyListAltID,
wxT("PID"), &FreeBusyListPID,
wxT("MEDIATYPE"), &FreeBusyListMediatype,
wxT("TYPE"), &FreeBusyListType,
wxT("PREF"), &FreeBusyListPref,
wxT(""), &FreeBusyListTokens );
ResetSaveProcessData();
}
for (std::map::iterator iter = KeyList.begin();
iter != KeyList.end(); ++iter){
intValue2 = iter->first;
// Process Alternative ID.
striter = KeyListAltID.find(intValue2);
if (striter->first == intValue2){
strValue3 = striter->second;
if (!strValue3.IsEmpty()){
strValue3.Trim();
strValue3.Trim();
if (boolValue2 == TRUE){
strValue2.Append(wxT(";"));
} else {
boolValue2 = TRUE;
}
strValue2.Append(wxT("ALTID=") + strValue3);
boolValue = TRUE;
}
}
// Process PID.
striter = KeyListPID.find(intValue2);
if (striter->first == intValue2){
strValue3 = striter->second;
if (!strValue3.IsEmpty()){
strValue3.Trim();
strValue3.Trim();
if (boolValue2 == TRUE){
strValue2.Append(wxT(";"));
} else {
boolValue2 = TRUE;
}
strValue2.Append(wxT("PID=") + strValue3);
boolValue = TRUE;
}
}
// Process Type.
striter = KeyListType.find(intValue2);
if (striter->first == intValue2){
strValue3 = striter->second;
if (!strValue3.IsEmpty()){
strValue3.Trim();
strValue3.Trim();
if (boolValue2 == TRUE){
strValue2.Append(wxT(";"));
} else {
boolValue2 = TRUE;
}
strValue2.Append(wxT("TYPE=") + strValue3);
boolValue = TRUE;
}
}
intiter = KeyListPref.find(intValue2);
if (intiter->first == intValue2){
intValue3 = intiter->second;
if (intValue3){
if (boolValue2 == TRUE){
strValue2.Append(wxT(";"));
} else {
boolValue2 = TRUE;
}
strValue2.Append(wxT("PREF=") + wxString::Format(wxT("%i"), intValue3));
boolValue = TRUE;
}
}
// Process Tokens.
striter = KeyListTokens.find(intValue2);
if (striter->first == intValue2){
strValue3 = striter->second;
if (!strValue3.IsEmpty()){
strValue3.Trim();
strValue3.Trim();
if (boolValue2 == TRUE){
strValue2.Append(wxT(";"));
} else {
boolValue2 = TRUE;
}
strValue2.Append(strValue3);
boolValue = TRUE;
}
}
// Get the key information.
std::map::iterator enciter;
striter = KeyListDataType.find(intValue2);
//enciter = KeyListAudioEncType.find(intValue2);
wxString strValueData;
strValueData = iter->second;
//strValueData.insert(0, wxT("data:") + striter->second + wxT(";") + enciter->second + wxT(","));
strValueData.insert(0, wxT("data:") + striter->second + wxT(";base64,"));
// Add to the vCard.
if (boolValue == TRUE){
ContactData.AddRaw(wxT("KEY;") + strValue2, strValueData);
} else {
ContactData.Add(wxT("KEY"), strValueData, TRUE);
}
ResetSaveProcessData();
}
// Vendor specific items.
ResetSaveProcessData();
for (std::map::iterator iter = VendorList.begin();
iter != VendorList.end(); ++iter){
intValue2 = iter->first;
// Get the IANA PEN number.
striter = VendorListPEN.find(intValue2);
if (striter->first == intValue2){
strValue2 = striter->second;
}
// Get the element name.
striter = VendorListElement.find(intValue2);
if (striter->first == intValue2){
strValue3 = striter->second;
}
// Get the address.
striter = VendorList.find(intValue2);
if (striter->first == intValue2){
strValue = striter->second;
}
// Add to the vCard.
if (boolValue == TRUE){
ContactData.AddRaw(wxT("VND-") + strValue2 + wxT("-") + strValue3, strValue);
} else {
ContactData.Add(wxT("VND-") + strValue2 + wxT("-") + strValue3, strValue, FALSE);
}
ResetSaveProcessData();
}
ResetSaveProcessData();
// X-Tokens.
for (std::map::iterator iter = XTokenList.begin();
iter != XTokenList.end(); ++iter){
intValue2 = iter->first;
// Get the element name.
striter = XTokenListTokens.find(intValue2);
if (striter->first == intValue2){
strValue2 = striter->second;
}
// Get the address.
striter = XTokenList.find(intValue2);
if (striter->first == intValue2){
strValue = striter->second;
}
// Add to the vCard.
if (boolValue == TRUE){
ContactData.AddRaw(wxT("X-") + strValue2, strValue);
} else {
ContactData.Add(wxT("X-") + strValue2, strValue, FALSE);
}
ResetSaveProcessData();
}
ResetSaveProcessData();
if (FullNamesList.size() == 0){
wxString FullName = cmbDisplayAs->GetValue();
FullNamesList.insert(std::make_pair(0, FullName));
FullNamesListAltID.insert(std::make_pair(0, wxT("")));
FullNamesListPID.insert(std::make_pair(0, wxT("")));
FullNamesListType.insert(std::make_pair(0, wxT("")));
FullNamesListLanguage.insert(std::make_pair(0, wxT("")));
FullNamesListPref.insert(std::make_pair(0, 0));
FullNamesListTokens.insert(std::make_pair(0, wxT("")));
FNFirst = FALSE;
}
for (std::map::iterator iter = FullNamesList.begin();
iter != FullNamesList.end(); ++iter){
if (FNFirst == TRUE){
iter->second = cmbDisplayAs->GetValue();
FNFirst = FALSE;
}
std::map::iterator mapS;
mapS = FullNamesListTokens.find(iter->first);
ProcessSaveData(wxT("FN"), &strValue2, &boolValue2, &boolValue,
&iter, &FullNamesList, &ContactData,
wxT("ALTID"), &FullNamesListAltID,
wxT("PID"), &FullNamesListPID,
wxT("TYPE"), &FullNamesListType,
wxT("LANGUAGE"), &FullNamesListLanguage,
wxT("PREF"), &FullNamesListPref,
wxT(""), &FullNamesListTokens );
// Get the address.
ResetSaveProcessData();
}
//ContactData.Add(wxT("FN"), cmbDisplayAs->GetValue(), FALSE);
// Insert revision (REV) date.
// Get today's date and time.
wxDateTime DateTimeNow = wxDateTime::Now();
wxString DateRev;
// Set year, month and date.
int intYear = DateTimeNow.GetYear();
int intMonth = DateTimeNow.GetMonth();
int intDay = DateTimeNow.GetDay();
DateRev.Append(wxT("0") + wxString::Format(wxT("%i"), intYear));
if (intMonth < 10){
DateRev.Append(wxT("0") + wxString::Format(wxT("%i"), intMonth));
} else {
DateRev.Append(wxString::Format(wxT("%i"), intMonth));
}
if (intDay < 10){
DateRev.Append(wxT("0") + wxString::Format(wxT("%i"), intDay));
} else {
DateRev.Append(wxString::Format(wxT("%i"), intDay));
}
//DateRev.Append(wx);
//DateRev.Append(wx);
//DateRev.Append(wx);
DateRev.Append(wxT("T"));
// Set hour, minute and second.
int intHour = DateTimeNow.GetHour();
int intMinute = DateTimeNow.GetMinute();
int intSecond = DateTimeNow.GetSecond();
if (intHour < 10){
DateRev.Append(wxT("0") + wxString::Format(wxT("%i"), intHour));
} else {
DateRev.Append(wxString::Format(wxT("%i"), intHour));
}
if (intMinute < 10){
DateRev.Append(wxT("0") + wxString::Format(wxT("%i"), intMinute));
} else {
DateRev.Append(wxString::Format(wxT("%i"), intMinute));
}
if (intSecond < 10){
DateRev.Append(wxT("0") + wxString::Format(wxT("%i"), intSecond));
} else {
DateRev.Append(wxString::Format(wxT("%i"), intSecond));
}
// DateRev.Append(wx);
// DateRev.Append(wx);
// DateRev.Append(wxString DateTimeNow->);
DateRev.Append(wxT("Z"));
ContactData.Add(wxT("UID"), UIDToken, FALSE);
// End the vCard File.
ContactData.Add(wxT("END"), wxT("VCARD"), FALSE);
FMTimer.Stop();
ContactData.WriteFile(FilenameFinal);
vCard34Conv ConvFileFun;
wxString wxSData;
ConvFileFun.ConvertToV3(FilenameFinal, &wxSData);
wxString AccountDirPrefix;
wxString AccountDir;
wxString PrefDir;
#if defined(__HAIKU__)
//preffilename = wxT("noo");
#elif defined(__APPLE__)
PrefDir = GetUserPrefDir();
wxStringTokenizer wSTFilename(wxSContactFilename, wxT("/"));
#elif defined(__WIN32__)
PrefDir = GetUserPrefDir();
wxStringTokenizer wSTFilename(wxSContactFilename, wxT("\\"));
#else
PrefDir = GetUserPrefDir();
wxStringTokenizer wSTFilename(wxSContactFilename, wxT("/"));
#endif
XABPreferences PrefData(PrefDir);
wxString AccountType;
for (int i = 0; i < PrefData.accounts.GetCount(); i++){
AccountDir = PrefData.accounts.GetAccountDirectory(i) + wxT(".carddav");
if (AccountDir == wxSContactAccount){
AccountDirPrefix = PrefData.accounts.GetAccountDirPrefix(i);
AccountDirPrefix.Trim();
AccountType = PrefData.accounts.GetAccountType(i);
break;
}
}
wxString wxSplitFilename;
wxString wxSDataURL;
while(wSTFilename.HasMoreTokens()){
wxSplitFilename = wSTFilename.GetNextToken();
}
wxSDataURL = wxSplitFilename;
//wxSDataURL.Append(wxSplitFilename);
// Find out if the filename exists in the table.
if (AccountType == wxT("CardDAV") || AccountType == wxT("carddav")){
wxString ETagResult;
wxString ETagOriginal;
ETagDB *ETagDBPtr = NULL;
ETagDBPtr = ETagTmrPtr->GetPointer(wxSContactAccount);
wxString wxSETag = ETagDBPtr->GetETag(wxSplitFilename);
wxString wxSETagOrig = ETagDBPtr->GetETagOriginal(wxSplitFilename);
if (wxSETagOrig.IsEmpty()){
// Generate the ETag.
wxSETagOrig = wxString::Format(wxT("%X%X%X%X"), rand() % 1024, rand() % 1024, rand() % 1024, rand() % 1024);
}
if (wxSETag.IsEmpty()){
// Update empty ETag.
wxSETag = wxSETagOrig;
ETagDBPtr->UpdateETag(wxSplitFilename, wxSETag, wxSETagOrig);
}
else {
// Don't change original ETag.
wxSETag = wxString::Format(wxT("%X%X%X%X"), rand() % 1024, rand() % 1024, rand() % 1024, rand() % 1024);
ETagDBPtr->UpdateETag(wxSplitFilename, wxSETag);
}
if (EditMode == FALSE){
ActMgrPtr->AddTask(0, cmbDisplayAs->GetValue(), wxSContactAccount, wxSDataURL, wxSplitFilename, FilenameFinal, wxSData);
EditMode = TRUE;
FMTimer.SetFilename(FilenameFinal);
FMTimer.UpdateTimestamp();
FMTimer.Start(10000, FALSE);
wxCommandEvent reloadevent(RELOADCONTACTLIST);
reloadevent.SetString(wxSContactAccount);
wxPostEvent(this->GetParent(), reloadevent);
}
else {
ActMgrPtr->AddTask(1, cmbDisplayAs->GetValue(), wxSContactAccount, wxSDataURL, wxSplitFilename, FilenameFinal, wxSData);
FMTimer.UpdateTimestamp();
FMTimer.Start(10000, FALSE);
}
}
// Send a notification to update the main window
// with the new details.
UCNotif *ucd;
ucd = new UCNotif;
// TODO: Workout nickname settings by priority and
// type.
ucd->ContactAccount = wxSContactAccount;
ucd->ContactFilename = FilenameFinal;
ucd->ContactName = cmbDisplayAs->GetValue();
ucd->ContactNameArray = ContactData.GetName();
for (std::map::iterator gniter = GeneralNicknamesList.begin();
gniter != GeneralNicknamesList.end(); gniter++){
ucd->ContactNickname = gniter->second;
break;
}
wxCommandEvent event2(CE_UPDATECONTACTLIST);
event2.SetClientData(ucd);
wxPostEvent(MainPtr, event2);
}
void frmContactEditor::SaveCloseContact( wxCommandEvent& event )
{
// Save the updated contact data and close the form.
wxCommandEvent NullEvent;
this->SaveContact(NullEvent);
this->Close();
}