+// frmContactEditor-Save.cpp - frmContactEditor save contact subroutines.
+//
+// (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 <http://www.gnu.org/licenses/>
+
#include "frmContactEditor.h"
#include "../enums.h"
#include "../version.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.
+ // Do not save if the account is an unsupported account.
+
+ if (boolUnsupportedAccount == true){
+
+ wxMessageBox(_("Cannot make changes to a contact from an unsupported account type."), _("Unsupported account"), wxICON_ERROR);
+ return;
+
+ }
+
+ // 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();
+ wxString cmbDisplayAsValue = cmbDisplayAs->GetValue();
- if (cmbDisplayAsValue.IsEmpty()){
+ if (cmbDisplayAsValue.IsEmpty()){
- wxMessageBox(_("Display As value cannot be left blank."), _("Display As value empty"), wxICON_ERROR);
- return;
+ wxMessageBox(_("Display As value cannot be left blank."), _("Display As value empty"), wxICON_ERROR);
+ return;
- }
+ }
+
+ // Save the updated contact data.
- // Save the updated contact data.
+ //vCard ContactData;
+ wxString FilenameFinal;
+ bool ReplaceContact = FALSE;
- vCard ContactData;
- wxString FilenameFinal;
- bool ReplaceContact = FALSE;
+ if (StartupEditMode == TRUE){
- if (cmbType->GetCurrentSelection() == 1 ||
- cmbType->GetCurrentSelection() == 3 ||
- cmbType->GetCurrentSelection() == 4){
+ if (cmbType->GetCurrentSelection() == 1 ||
+ cmbType->GetCurrentSelection() == 3 ||
+ cmbType->GetCurrentSelection() == 4){
- if (IsGroup == TRUE){
+ if (IsGroup == TRUE){
- // Mark contact for replacing.
+ // Mark contact for replacing.
- ReplaceContact = TRUE;
-
- }
+ ReplaceContact = TRUE;
+ IsGroup = FALSE;
+
+ }
- } else if (cmbType->GetCurrentSelection() == 2){
+ } else if (cmbType->GetCurrentSelection() == 2){
- if (IsGroup == TRUE){
+ if (IsGroup == FALSE){
- // Mark contact for replacing.
+ // Mark contact for replacing.
- ReplaceContact = TRUE;
-
- }
+ ReplaceContact = TRUE;
+ IsGroup = TRUE;
+
+ }
- }
+ }
- if (ReplaceContact == TRUE){
+ if (ReplaceContact == TRUE){
- wxString wxDelSplitFilename;
- wxString wxDelFinalFilename;
- wxString wxSDelDataURL;
- wxStringTokenizer wSTDelFilename(wxSContactFilename, wxT("/"));
- while(wSTDelFilename.HasMoreTokens()){
+ wxString wxDelSplitFilename;
+ wxString wxDelFinalFilename;
+ wxString wxSDelDataURL;
+ wxStringTokenizer wSTDelFilename(wxSContactFilename, wxT("/"));
+
+ while(wSTDelFilename.HasMoreTokens()){
- wxDelSplitFilename = wSTDelFilename.GetNextToken();
+ wxDelSplitFilename = wSTDelFilename.GetNextToken();
- }
+ }
- wxSDelDataURL = wxDelSplitFilename;
+ wxSDelDataURL = wxDelSplitFilename;
- // Delete the contact from the server as it will be useless in certain
- // address book clients.
+ // 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(""));
+ ActMgrPtr->AddTask(2, cmbDisplayAs->GetValue(), wxSContactAccount, wxSDelDataURL, wxDelSplitFilename, wxSContactFilename, wxT(""));
- // Clear the filename so the trigger to recreate the UID is done.
+ // Clear the filename so the trigger to recreate the UID is done.
- wxSContactFilename.Clear();
- EditMode = FALSE;
+ wxSContactFilename.Clear();
+ EditMode = FALSE;
- }
+ }
- if (wxSContactFilename.IsEmpty()){
+ }
+
+ if (wxSContactFilename.IsEmpty()){
- // Generate a random UUID.
+ // Generate a random UUID.
- UIDToken = GenerateUUID();
- UIDToken = UIDToken.MakeUpper();
+ ContactEditorData.UIDToken = GenerateUUID();
+ ContactEditorData.UIDToken = ContactEditorData.UIDToken.MakeUpper();
- // Setup the filename.
+ // Setup the filename.
- FilenameFinal = GetAccountDir(wxSContactAccount, FALSE);
+ 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;
+ FilenameFinal = GetAccountDir(wxSContactAccount, FALSE);
+ FilenameFinal.Append(ContactEditorData.UIDToken);
+ FilenameFinal.Append(wxT(".vcf"));
+ wxSContactFilename = FilenameFinal;
#else
- FilenameFinal = GetAccountDir(wxSContactAccount, FALSE);
- FilenameFinal.Append(UIDToken);
- FilenameFinal.Append(wxT(".vcf"));
- wxSContactFilename = FilenameFinal;
+ FilenameFinal = GetAccountDir(wxSContactAccount, FALSE);
+ FilenameFinal.Append(ContactEditorData.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<int,int>::iterator intiter;
- std::map<int,wxString>::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<int, wxString>::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();
+ } else {
- if (boolValue2 == TRUE){
+ if (ContactEditorData.UIDToken.IsEmpty()){
- strValue2.Append(wxT(";"));
+ // UID Token is empty. (Shouldn't be).
+ // Generate a new UID Token.
- } else {
+ ContactEditorData.UIDToken = GenerateUUID();
+ ContactEditorData.UIDToken = ContactEditorData.UIDToken.MakeUpper();
- boolValue2 = TRUE;
-
- }
-
- strValue2.Append(wxT("CALSCALE=") + strValue3);
+ }
+
+ FilenameFinal = wxSContactFilename;
- boolValue = TRUE;
-
- }
-
- // Process Tokens.
+ }
- strValue2 = BirthdayTokens;
+ // Setup the data and write it into the account folder.
- // Get the birthday and write it.
+ // Begin preperations to write the contact to a file.
- ResetSaveProcessData();
+ bool FNFirst = TRUE;
+ std::map<int,int>::iterator intiter;
+ std::map<int,wxString>::iterator striter;
- if (!txtBirthday->IsEmpty()){
+ // Set some values for saving.
+
+ ContactEditorData.NameForename = txtForename->GetValue();
+ ContactEditorData.NameSurname = txtSurname->GetValue();
+ ContactEditorData.NameOtherNames = txtOtherNames->GetValue();
+ ContactEditorData.NameTitle = txtTitle->GetValue();
+ ContactEditorData.NameSuffix = txtSuffix->GetValue();
+
+ ContactEditorData.GenderDetails = txtGenderDescription->GetValue();
+
+ // Process Birthday: Get Day, Month & Year.
- strValue = txtBirthday->GetValue();
+ wxDateTime BirthdayDate;
+ wxDateTime::Month BirthdayMonth;
+ int BirthdayDay;
+ int BirthdayYear;
+ wxString DataBeforeT;
+ wxString DataAfterT;
+ wxString FinalBirthdayString;
+ bool ProcessDataAfterT = FALSE;
- 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);
-
- }
-
- }
+ BirthdayDate = dapBirthday->GetValue();
- } 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()){
+ if (!txtBirthday->IsEmpty()){
+
+ // Birthday value is text so use this.
+
+ ContactEditorData.Birthday = txtBirthday->GetValue();
+
+ } else if (BirthdayDate.IsValid()){
- BirthdayDay = BirthdayDate.GetDay();
- BirthdayMonth = BirthdayDate.GetMonth();
- BirthdayYear = BirthdayDate.GetYear();
+ BirthdayDay = BirthdayDate.GetDay();
+ BirthdayMonth = BirthdayDate.GetMonth();
+ BirthdayYear = BirthdayDate.GetYear();
- // Look for T and replace data before this.
+ // Look for T and replace data before this.
- wxStringTokenizer wSTDate(Birthday, wxT("T"));
+ wxStringTokenizer wSTDate(ContactEditorData.Birthday, wxT("T"));
- while (wSTDate.HasMoreTokens()){
+ while (wSTDate.HasMoreTokens()){
- if (ProcessDataAfterT == FALSE){
+ if (ProcessDataAfterT == FALSE){
- DataBeforeT = wSTDate.GetNextToken();
- ProcessDataAfterT = TRUE;
+ DataBeforeT = wSTDate.GetNextToken();
+ ProcessDataAfterT = TRUE;
- } else {
+ } else {
- DataAfterT = wSTDate.GetNextToken();
- break;
+ DataAfterT = wSTDate.GetNextToken();
+ break;
- }
+ }
- }
-
- // If there is not T then replace altogether.
+ }
- wxString FinalBirthdayDay;
- wxString FinalBirthdayMonth;
- wxString FinalBirthdayYear;
+ // If there is not T then replace altogether.
- if (BirthdayDay < 10){
-
- FinalBirthdayDay = wxT("0") + wxString::Format(wxT("%i"), BirthdayDay);
-
- } else {
-
- FinalBirthdayDay = wxString::Format(wxT("%i"), BirthdayDay);
-
- }
+ wxString FinalBirthdayDay;
+ wxString FinalBirthdayMonth;
+ wxString FinalBirthdayYear;
- if (((int)BirthdayMonth + 1) < 10){
+ if (BirthdayDay < 10){
- FinalBirthdayMonth = wxT("0") + wxString::Format(wxT("%i"), ((int)BirthdayMonth + 1));
+ FinalBirthdayDay = wxT("0") + wxString::Format(wxT("%i"), BirthdayDay);
- } else {
+ } else {
- FinalBirthdayMonth = wxString::Format(wxT("%i"), ((int)BirthdayMonth + 1));
+ FinalBirthdayDay = wxString::Format(wxT("%i"), BirthdayDay);
- }
+ }
- if (BirthdayYear == 0){
+ if (((int)BirthdayMonth + 1) < 10){
- FinalBirthdayYear = wxT("--");
+ FinalBirthdayMonth = wxT("0") + wxString::Format(wxT("%i"), ((int)BirthdayMonth + 1));
- } else {
+ } else {
- FinalBirthdayYear = wxString::Format(wxT("%i"), BirthdayYear);
+ FinalBirthdayMonth = wxString::Format(wxT("%i"), ((int)BirthdayMonth + 1));
- }
+ }
- if (!DataAfterT.IsEmpty()){
-
- FinalBirthdayString = FinalBirthdayYear + FinalBirthdayMonth + FinalBirthdayDay + wxT("T") + DataAfterT;
-
- } else {
+ if (BirthdayYear == 0){
- FinalBirthdayString = FinalBirthdayYear + FinalBirthdayMonth + FinalBirthdayDay;
+ FinalBirthdayYear = wxT("--");
- }
-
- if (!FinalBirthdayString.IsEmpty() || !strValue2.IsEmpty()){
+ } else {
- 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);
-
- }
+ FinalBirthdayYear = wxString::Format(wxT("%i"), BirthdayYear);
- }
-
- }
-
- }
-
- 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);
+ if (!DataAfterT.IsEmpty()){
- ContactData.AddRaw(wxT("ANNIVERSARY;VALUE=text;") + strValue2 + wxT(";"), strValue);
+ FinalBirthdayString = FinalBirthdayYear + FinalBirthdayMonth + FinalBirthdayDay + wxT("T") + DataAfterT;
- } else {
+ } else {
- EscapeString(&strValue, FALSE);
+ FinalBirthdayString = FinalBirthdayYear + FinalBirthdayMonth + FinalBirthdayDay;
- ContactData.AddRaw(wxT("ANNIVERSARY;VALUE=text"), strValue);
-
- }
-
- }
-
- } else {
-
- // Look for T and replace data before this.
+ }
+
+ if(!FinalBirthdayString.IsEmpty()){
+
+ ContactEditorData.Birthday = FinalBirthdayString;
+
+ }
+
+ }
+
+ // Process Anniversary: Get Day, Month & Year.
+
+ wxDateTime AnniversaryDate;
+ wxDateTime::Month AnniversaryMonth;
+ int AnniversaryDay;
+ int AnniversaryYear;
+ DataBeforeT = "";
+ DataAfterT = "";
+ wxString FinalAnniversaryString;
+ ProcessDataAfterT = FALSE;
- // Get Day, Month & Year.
+ AnniversaryDate = dapAnniversary->GetValue();
- wxDateTime AnniversaryDate;
- wxDateTime::Month AnniversaryMonth;
- int AnniversaryDay;
- int AnniversaryYear;
- wxString DataBeforeT;
- wxString DataAfterT;
- wxString FinalAnniversaryString;
- bool ProcessDataAfterT = FALSE;
-
- AnniversaryDate = dapAnniversary->GetValue();
-
- if (AnniversaryDate.IsValid()){
+ if (!txtAnniversary->IsEmpty()){
+
+ // Birthday value is text so use this.
+
+ ContactEditorData.Anniversary = txtAnniversary->GetValue();
+
+ } else if (AnniversaryDate.IsValid()){
- AnniversaryDay = AnniversaryDate.GetDay();
- AnniversaryMonth = AnniversaryDate.GetMonth();
- AnniversaryYear = AnniversaryDate.GetYear();
+ AnniversaryDay = AnniversaryDate.GetDay();
+ AnniversaryMonth = AnniversaryDate.GetMonth();
+ AnniversaryYear = AnniversaryDate.GetYear();
- // Look for T and replace data before this.
+ // Look for T and replace data before this.
- wxStringTokenizer wSTDate(Anniversary, wxT("T"));
+ wxStringTokenizer wSTDate(ContactEditorData.Anniversary, wxT("T"));
- while (wSTDate.HasMoreTokens()){
+ while (wSTDate.HasMoreTokens()){
- if (ProcessDataAfterT == FALSE){
+ if (ProcessDataAfterT == FALSE){
- DataBeforeT = wSTDate.GetNextToken();
- ProcessDataAfterT = TRUE;
+ DataBeforeT = wSTDate.GetNextToken();
+ ProcessDataAfterT = TRUE;
- } else {
+ } else {
- DataAfterT = wSTDate.GetNextToken();
- break;
+ DataAfterT = wSTDate.GetNextToken();
+ break;
- }
+ }
- }
+ }
- // If there is not T then replace altogether.
+ // If there is not T then replace altogether.
- wxString FinalAnniversaryDay;
- wxString FinalAnniversaryMonth;
- wxString FinalAnniversaryYear;
-
- if (AnniversaryDay < 10){
+ wxString FinalAnniversaryDay;
+ wxString FinalAnniversaryMonth;
+ wxString FinalAnniversaryYear;
+
+ if (AnniversaryDay < 10){
- FinalAnniversaryDay = wxT("0") + wxString::Format(wxT("%i"), AnniversaryDay);
+ FinalAnniversaryDay = wxT("0") + wxString::Format(wxT("%i"), AnniversaryDay);
- } else {
+ } else {
- FinalAnniversaryDay = wxString::Format(wxT("%i"), AnniversaryDay);
+ FinalAnniversaryDay = wxString::Format(wxT("%i"), AnniversaryDay);
- }
+ }
- if (((int)AnniversaryMonth + 1) < 10){
+ if (((int)AnniversaryMonth + 1) < 10){
- FinalAnniversaryMonth = wxT("0") + wxString::Format(wxT("%i"), ((int)AnniversaryMonth + 1));
+ FinalAnniversaryMonth = wxT("0") + wxString::Format(wxT("%i"), ((int)AnniversaryMonth + 1));
- } else {
+ } else {
- FinalAnniversaryMonth = wxString::Format(wxT("%i"), ((int)AnniversaryMonth + 1));
+ FinalAnniversaryMonth = wxString::Format(wxT("%i"), ((int)AnniversaryMonth + 1));
- }
+ }
- if (AnniversaryYear == 0){
+ if (AnniversaryYear == 0){
- FinalAnniversaryYear = wxT("--");
+ FinalAnniversaryYear = wxT("--");
- } else {
+ } else {
- FinalAnniversaryYear = wxString::Format(wxT("%i"), AnniversaryYear);
+ FinalAnniversaryYear = wxString::Format(wxT("%i"), AnniversaryYear);
- }
+ }
- if (!DataAfterT.IsEmpty()){
-
- FinalAnniversaryString = FinalAnniversaryYear + FinalAnniversaryMonth + FinalAnniversaryDay + wxT("T") + DataAfterT;
+ if (!DataAfterT.IsEmpty()){
- } else {
+ FinalAnniversaryString = FinalAnniversaryYear + FinalAnniversaryMonth + FinalAnniversaryDay + wxT("T") + DataAfterT;
- FinalAnniversaryString = FinalAnniversaryYear + FinalAnniversaryMonth + FinalAnniversaryDay;
+ } else {
- }
-
- 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);
-
- }
+ FinalAnniversaryString = FinalAnniversaryYear + FinalAnniversaryMonth + FinalAnniversaryDay;
- }
-
- }
-
- }
+ }
+
+ if(!FinalAnniversaryString.IsEmpty()){
+
+ ContactEditorData.Birthday = FinalAnniversaryString;
+
+ }
+
+ }
+
+ // Process full name.
+
+ if (ContactEditorData.FullNamesList.size() > 0){
+
+ ContactEditorData.FullNamesList[0] = cmbDisplayAs->GetValue();
+
+ } else {
+
+ ContactEditorData.FullNamesList.insert(std::make_pair(0, cmbDisplayAs->GetValue()));
+ ContactEditorData.FullNamesListAltID.insert(std::make_pair(0, wxT("")));
+ ContactEditorData.FullNamesListPID.insert(std::make_pair(0, wxT("")));
+ ContactEditorData.FullNamesListType.insert(std::make_pair(0, wxT("")));
+ ContactEditorData.FullNamesListLanguage.insert(std::make_pair(0, wxT("")));
+ ContactEditorData.FullNamesListPref.insert(std::make_pair(0, 0));
+ ContactEditorData.FullNamesListTokens.insert(std::make_pair(0, wxT("")));
+
+ }
- // Setup the addresses (General, Home, Business).
+ FMTimer.Stop();
+ ContactEditorData.SaveFile(FilenameFinal);
- //intValue = GeneralAddressList.size();
- ResetSaveProcessData();
+ vCard34Conv ConvFileFun;
- for (std::map<int,wxString>::iterator iter = GeneralAddressList.begin();
- iter != GeneralAddressList.end(); ++iter){
-
- int intSeekValue = iter->first;
-
- wxString strAddressString;
- wxString strAddressFinalValue;
- std::map<int, wxString>::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();
-
- }
+ wxString wxSData;
- ResetSaveProcessData();
+ ConvFileFun.ConvertToV3(FilenameFinal, &wxSData);
- for (std::map<int,wxString>::iterator iter = HomeAddressList.begin();
- iter != HomeAddressList.end(); ++iter){
-
- int intSeekValue = iter->first;
-
- wxString strAddressString;
- wxString strAddressFinalValue;
- std::map<int, wxString>::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();
-
- }
+ wxString AccountDirPrefix;
+ wxString AccountDir;
+ wxString PrefDir;
- ResetSaveProcessData();
+#if defined(__HAIKU__)
+
+#elif defined(__APPLE__)
- for (std::map<int,wxString>::iterator iter = BusinessAddressList.begin();
- iter != BusinessAddressList.end(); ++iter){
-
- int intSeekValue = iter->first;
-
- wxString strAddressString;
- wxString strAddressFinalValue;
- std::map<int, wxString>::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();
-
- }
+ PrefDir = GetUserPrefDir();
- // Sort out nicknames (if any).
+ wxStringTokenizer wSTFilename(wxSContactFilename, wxT("/"));
- for (std::map<int,wxString>::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();
-
- }
+#elif defined(__WIN32__)
- ResetSaveProcessData();
+ PrefDir = GetUserPrefDir();
- for (std::map<int,wxString>::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();
-
- }
+ wxStringTokenizer wSTFilename(wxSContactFilename, wxT("\\"));
- ResetSaveProcessData();
+#else
- for (std::map<int,wxString>::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();
-
- }
+ PrefDir = GetUserPrefDir();
- ResetSaveProcessData();
+ wxStringTokenizer wSTFilename(wxSContactFilename, wxT("/"));
- // Sort out email (general, home and business).
+#endif
+
+ XABPreferences PrefData(PrefDir);
- for (std::map<int,wxString>::iterator iter = GeneralEmailList.begin();
- iter != GeneralEmailList.end(); ++iter){
-
- //strValue3 = ContactData.Convert(GeneralAddressList, FALSE);
- //strValue2 =
-
- wxString strAddressFinalValue;
- std::map<int, wxString>::iterator iterValue;
+ wxString AccountType;
+
+ for (int i = 0; i < PrefData.accounts.GetCount(); i++){
- ProcessSaveData(wxT("EMAIL"), &strValue2, &boolValue2, &boolValue,
- &iter, &GeneralEmailList, &ContactData,
- wxT("ALTID"), &GeneralEmailListAltID,
- wxT("PID"), &GeneralEmailListPID,
- wxT("PREF"), &GeneralEmailListPref,
- wxT(""), &GeneralEmailListTokens );
+ AccountDir = PrefData.accounts.GetAccountDirectory(i) + wxT(".carddav");
- ResetSaveProcessData();
+ if (AccountDir == wxSContactAccount){
+
+ AccountDirPrefix = PrefData.accounts.GetAccountDirPrefix(i);
+ AccountDirPrefix.Trim();
+ AccountType = PrefData.accounts.GetAccountType(i);
+ break;
+
+ }
- }
+ }
- ResetSaveProcessData();
+ wxString wxSplitFilename;
+ wxString wxSDataURL;
- for (std::map<int,wxString>::iterator iter = HomeEmailList.begin();
- iter != HomeEmailList.end(); ++iter){
-
- //strValue3 = ContactData.Convert(GeneralAddressList, FALSE);
- //strValue2 =
+ while(wSTFilename.HasMoreTokens()){
- ProcessSaveData(wxT("EMAIL;TYPE=home"), &strValue2, &boolValue2, &boolValue,
- &iter, &HomeEmailList, &ContactData,
- wxT("ALTID"), &HomeEmailListAltID,
- wxT("PID"), &HomeEmailListPID,
- wxT("PREF"), &HomeEmailListPref,
- wxT(""), &HomeEmailListTokens );
+ wxSplitFilename = wSTFilename.GetNextToken();
- ResetSaveProcessData();
-
- }
+ }
+
+ wxSDataURL = wxSplitFilename;
- ResetSaveProcessData();
+ // Find out if the filename exists in the table.
- for (std::map<int,wxString>::iterator iter = BusinessEmailList.begin();
- iter != BusinessEmailList.end(); ++iter){
+ if (AccountType == wxT("CardDAV") || AccountType == wxT("carddav")){
- //strValue3 = ContactData.Convert(GeneralAddressList, FALSE);
- //strValue2 =
+ wxString ETagResult;
+ wxString ETagOriginal;
- ProcessSaveData(wxT("EMAIL;TYPE=work"), &strValue2, &boolValue2, &boolValue,
- &iter, &BusinessEmailList, &ContactData,
- wxT("ALTID"), &BusinessEmailListAltID,
- wxT("PID"), &BusinessEmailListPID,
- wxT("PREF"), &BusinessEmailListPref,
- wxT(""), &BusinessEmailListTokens );
+ ETagDB *ETagDBPtr = NULL;
- ResetSaveProcessData();
+ ETagDBPtr = ETagTmrPtr->GetPointer(wxSContactAccount);
- }
-
- ResetSaveProcessData();
-
- for (std::map<int,wxString>::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<int,wxString>::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<int,wxString>::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<int,wxString>::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<int,wxString>::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<int,wxString>::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<int,wxString>::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<int,wxString>::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<int,wxString>::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<int,wxString>::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<int,wxString>::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<int,wxString>::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<int,wxString>::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<int,wxString>::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<int,wxString>::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<int,wxString>::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<int,wxString>::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<int,wxString>::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<int,wxString>::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<int,wxString>::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<int,wxString>::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<int,wxString>::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<int,wxString>::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<int,wxString>::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<int,wxString>::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<int,wxString>::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<int,wxString>::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<int,wxString>::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<int,wxString>::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<int,wxString>::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<int,wxString>::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<int,wxString>::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<int, std::string>::iterator iter = PicturesList.begin();
- iter != PicturesList.end(); ++iter){
-
- int intValueIndex = iter->first;
-
- std::map<int, std::string>::iterator stdstriter;
- std::map<int, wxString>::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<int, std::string>::iterator iter = LogosList.begin();
- iter != LogosList.end(); ++iter){
-
- int intValueIndex = iter->first;
-
- std::map<int, std::string>::iterator stdstriter;
- std::map<int, wxString>::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<int, std::string>::iterator iter = SoundsList.begin();
- iter != SoundsList.end(); ++iter){
-
- int intValueIndex = iter->first;
-
- std::map<int, std::string>::iterator stdstriter;
- std::map<int, wxString>::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<int,wxString>::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<int,wxString>::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<int,wxString>::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<int, wxString>::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<int, wxString>::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<int,wxString>::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<int,wxString>::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<int, wxString>::iterator iter = FullNamesList.begin();
- iter != FullNamesList.end(); ++iter){
-
- if (FNFirst == TRUE){
-
- iter->second = cmbDisplayAs->GetValue();
- FNFirst = FALSE;
-
- }
-
- std::map<int,wxString>::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");
+ wxString wxSETag = ETagDBPtr->GetETag(wxSplitFilename);
+ wxString wxSETagOrig = ETagDBPtr->GetETagOriginal(wxSplitFilename);
-#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()){
+ if (wxSETagOrig.IsEmpty()){
- // Generate the ETag.
+ // Generate the ETag.
- wxSETagOrig = wxString::Format(wxT("%X%X%X%X"), rand() % 1024, rand() % 1024, rand() % 1024, rand() % 1024);
+ wxSETagOrig = wxString::Format(wxT("%X%X%X%X"), rand() % 1024, rand() % 1024, rand() % 1024, rand() % 1024);
- }
+ }
- if (wxSETag.IsEmpty()){
+ if (wxSETag.IsEmpty()){
- // Update empty ETag.
+ // Update empty ETag.
- wxSETag = wxSETagOrig;
- ETagDBPtr->UpdateETag(wxSplitFilename, wxSETag, wxSETagOrig);
+ wxSETag = wxSETagOrig;
+ ETagDBPtr->AddETag(wxSplitFilename, wxSETag, "");
- }
- else {
+ } else {
- // Don't change original ETag.
+ // 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);
+ 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);
+ 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);
+ wxCommandEvent reloadevent(RELOADCONTACTLIST);
+ reloadevent.SetString(wxSContactAccount);
+ wxPostEvent(this->GetParent(), reloadevent);
- }
- else {
+ } else {
- ActMgrPtr->AddTask(1, cmbDisplayAs->GetValue(), wxSContactAccount, wxSDataURL, wxSplitFilename, FilenameFinal, wxSData);
- FMTimer.UpdateTimestamp();
- FMTimer.Start(10000, FALSE);
+ 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.
+ // Send a notification to update the main window
+ // with the new details.
- UCNotif *ucd;
- ucd = new UCNotif;
+ UCNotif *ucd;
+ ucd = new UCNotif;
- // TODO: Workout nickname settings by priority and
- // type.
+ // TODO: Workout nickname settings by priority and
+ // type.
- ucd->ContactAccount = wxSContactAccount;
- ucd->ContactFilename = FilenameFinal;
- ucd->ContactName = cmbDisplayAs->GetValue();
- ucd->ContactNameArray = ContactData.GetName();
+ vCardName NameData;
+
+ NameData.Forename = txtForename->GetValue();
+ NameData.Surname = txtSurname->GetValue();
+ NameData.OtherNames = txtOtherNames->GetValue();
+ NameData.Title = txtTitle->GetValue();
+ NameData.Suffix = txtSuffix->GetValue();
+
+ ucd->ContactAccount = wxSContactAccount;
+ ucd->ContactFilename = FilenameFinal;
+ ucd->ContactName = cmbDisplayAs->GetValue();
+ ucd->ContactNameArray = NameData;
- for (std::map<int,wxString>::iterator gniter = GeneralNicknamesList.begin();
- gniter != GeneralNicknamesList.end(); gniter++){
+ for (std::map<int,wxString>::iterator gniter = ContactEditorData.GeneralNicknamesList.begin();
+ gniter != ContactEditorData.GeneralNicknamesList.end(); gniter++){
- ucd->ContactNickname = gniter->second;
- break;
+ ucd->ContactNickname = gniter->second;
+ break;
- }
+ }
- wxCommandEvent event2(CE_UPDATECONTACTLIST);
- event2.SetClientData(ucd);
- wxPostEvent(MainPtr, event2);
+ wxCommandEvent event2(CE_UPDATECONTACTLIST);
+ event2.SetClientData(ucd);
+ wxPostEvent(MainPtr, event2);
}
void frmContactEditor::SaveCloseContact( wxCommandEvent& event )
{
- // Save the updated contact data and close the form.
+ // Save the updated contact data and close the form.
- wxCommandEvent NullEvent;
- this->SaveContact(NullEvent);
- this->Close();
+ wxCommandEvent NullEvent;
+ this->SaveContact(NullEvent);
+ this->Close();
}
\ No newline at end of file