1 // frmContactEditor-Save.cpp - frmContactEditor save contact subroutines.
3 // (c) 2012-2015 Xestia Software Development.
5 // This file is part of Xestia Address Book.
7 // Xestia Address Book is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by the
9 // Free Software Foundation, version 3 of the license.
11 // Xestia Address Book is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with Xestia Address Book. If not, see <http://www.gnu.org/licenses/>
19 #include "frmContactEditor.h"
21 #include "../version.h"
22 #include "../vcard/vcard.h"
23 #include "../vcard/vcard34conv.h"
24 #include "../common/textprocessing.h"
25 #include "../common/preferences.h"
26 #include "../common/uuid.h"
27 #include "../common/dirs.h"
29 void frmContactEditor::SaveContact( wxCommandEvent& event )
32 // Check if Display As combo box has a value in it.
33 // Do not go any further if there is no value.
35 wxString cmbDisplayAsValue = cmbDisplayAs->GetValue();
37 if (cmbDisplayAsValue.IsEmpty()){
39 wxMessageBox(_("Display As value cannot be left blank."), _("Display As value empty"), wxICON_ERROR);
44 // Save the updated contact data.
47 wxString FilenameFinal;
48 bool ReplaceContact = FALSE;
50 if (StartupEditMode == TRUE){
52 if (cmbType->GetCurrentSelection() == 1 ||
53 cmbType->GetCurrentSelection() == 3 ||
54 cmbType->GetCurrentSelection() == 4){
58 // Mark contact for replacing.
60 ReplaceContact = TRUE;
65 } else if (cmbType->GetCurrentSelection() == 2){
67 if (IsGroup == FALSE){
69 // Mark contact for replacing.
71 ReplaceContact = TRUE;
78 if (ReplaceContact == TRUE){
80 wxString wxDelSplitFilename;
81 wxString wxDelFinalFilename;
82 wxString wxSDelDataURL;
83 wxStringTokenizer wSTDelFilename(wxSContactFilename, wxT("/"));
84 while(wSTDelFilename.HasMoreTokens()){
86 wxDelSplitFilename = wSTDelFilename.GetNextToken();
90 wxSDelDataURL = wxDelSplitFilename;
92 // Delete the contact from the server as it will be useless in certain
93 // address book clients.
95 ActMgrPtr->AddTask(2, cmbDisplayAs->GetValue(), wxSContactAccount, wxSDelDataURL, wxDelSplitFilename, wxSContactFilename, wxT(""));
97 // Clear the filename so the trigger to recreate the UID is done.
99 wxSContactFilename.Clear();
106 if (wxSContactFilename.IsEmpty()){
108 // Generate a random UUID.
110 UIDToken = GenerateUUID();
111 UIDToken = UIDToken.MakeUpper();
113 // Setup the filename.
115 FilenameFinal = GetAccountDir(wxSContactAccount, FALSE);
117 #if defined(__HAIKU__)
119 //preffilename = wxT("noo");
121 #elif defined(__WIN32__)
123 FilenameFinal = GetAccountDir(wxSContactAccount, FALSE);
124 FilenameFinal.Append(UIDToken);
125 FilenameFinal.Append(wxT(".vcf"));
126 wxSContactFilename = FilenameFinal;
130 FilenameFinal = GetAccountDir(wxSContactAccount, FALSE);
131 FilenameFinal.Append(UIDToken);
132 FilenameFinal.Append(wxT(".vcf"));
133 wxSContactFilename = FilenameFinal;
139 if (UIDToken.IsEmpty()){
141 // UID Token is empty. (Shouldn't be).
142 // Generate a new UID Token.
144 UIDToken = GenerateUUID();
145 UIDToken = UIDToken.MakeUpper();
148 FilenameFinal = wxSContactFilename;
152 // Setup the data and write it into the account folder.
154 // Begin preperations to write the contact to a file.
156 bool boolValue = FALSE;
157 bool boolValue2 = FALSE;
159 bool NNGeneralFirst = TRUE;
160 bool NNHomeFirst = TRUE;
161 bool NNWorkFirst = TRUE;
163 std::map<int,int>::iterator intiter;
164 std::map<int,wxString>::iterator striter;
166 ContactData.Add(wxT("BEGIN"), wxT("VCARD"), FALSE);
167 ContactData.Add(wxT("VERSION"), wxT("4.0"), FALSE);
169 // Setup the version string.
171 strValue.Append(wxT("-//Xestia//Address Book Version "));
172 strValue.Append(wxT(XSDAB_VERSION));
173 strValue.Append(wxT("//KW"));
175 ContactData.Add(wxT("PRODID"), strValue, FALSE);
181 // Setup the name field.
183 strValue = txtSurname->GetValue() + wxT(";") +
184 txtForename->GetValue() + wxT(";") +
185 txtOtherNames->GetValue() + wxT(";") +
186 txtTitle->GetValue() + wxT(";") +
187 txtSuffix->GetValue();
189 strValue2 = ContactData.Convert(cmbDisplayAs->GetValue(), FALSE);
192 if (NameTokens.IsEmpty()){
193 ContactData.Add(wxT("N;SORT-AS=\"") + strValue2 + wxT("\""), strValue, FALSE);
195 ContactData.Add(wxT("N;SORT-AS=\"") + strValue2 + wxT("\";") + NameTokens, strValue, FALSE);
198 if (cmbType->GetCurrentSelection() == 1){
200 ContactData.AddRaw(wxT("KIND"), wxT("individual"));
202 } else if (cmbType->GetCurrentSelection() == 2){
204 ContactData.AddRaw(wxT("KIND"), wxT("group"));
206 // Go through each of the members and write them out.
208 for (std::map<int, wxString>::iterator itemiter = GroupsList.begin();
209 itemiter != GroupsList.end(); ++itemiter){
211 ContactData.Add(wxT("MEMBER:urn:uuid"), itemiter->second, FALSE);
215 } else if (cmbType->GetCurrentSelection() == 3){
217 ContactData.AddRaw(wxT("KIND"), wxT("org"));
219 } else if (cmbType->GetCurrentSelection() == 4){
221 ContactData.AddRaw(wxT("KIND"), wxT("location"));
226 // Setup the nicknames (General, Home & Business).
239 if (cmbGender->GetCurrentSelection() != 0){
241 switch(cmbGender->GetCurrentSelection()){
272 if (!txtGenderDescription->IsEmpty()){
274 strValue2 = txtGenderDescription->GetValue();
278 if (!strValue.IsEmpty() || !strValue2.IsEmpty()){
280 EscapeString(&strValue2, FALSE);
282 if (!GenderTokens.IsEmpty()){
284 if (!strValue2.IsEmpty()){
286 ContactData.AddRaw(wxT("GENDER;") + GenderTokens, strValue + wxT(";") + strValue2);
290 ContactData.AddRaw(wxT("GENDER;") + GenderTokens, strValue);
296 if (!strValue2.IsEmpty()){
298 ContactData.AddRaw(wxT("GENDER"), strValue + wxT(";") + strValue2);
302 ContactData.AddRaw(wxT("GENDER"), strValue);
321 strValue3 = BirthdayAltID;
323 if (!strValue3.IsEmpty()){
328 strValue2.Append(wxT("ALTID=\"") + strValue3 + wxT("\""));
334 //strValue3 = ContactData.Convert(GeneralAddressList, FALSE);
339 strValue3 = BirthdayCalScale;
341 if (!strValue3.IsEmpty()){
346 if (boolValue2 == TRUE){
348 strValue2.Append(wxT(";"));
356 strValue2.Append(wxT("CALSCALE=") + strValue3);
364 strValue2 = BirthdayTokens;
366 // Get the birthday and write it.
368 ResetSaveProcessData();
370 if (!txtBirthday->IsEmpty()){
372 strValue = txtBirthday->GetValue();
374 if (!strValue.IsEmpty() || !strValue2.IsEmpty()){
376 if (!strValue2.IsEmpty()){
378 EscapeString(&strValue2, FALSE);
379 EscapeString(&strValue, FALSE);
381 ContactData.AddRaw(wxT("BDAY;VALUE=text;") + strValue2 + wxT(";"), strValue);
385 EscapeString(&strValue, FALSE);
387 ContactData.AddRaw(wxT("BDAY;VALUE=text"), strValue);
397 // Get Day, Month & Year.
399 wxDateTime BirthdayDate;
400 wxDateTime::Month BirthdayMonth;
403 wxString DataBeforeT;
405 wxString FinalBirthdayString;
406 bool ProcessDataAfterT = FALSE;
408 BirthdayDate = dapBirthday->GetValue();
410 if (BirthdayDate.IsValid()){
412 BirthdayDay = BirthdayDate.GetDay();
413 BirthdayMonth = BirthdayDate.GetMonth();
414 BirthdayYear = BirthdayDate.GetYear();
416 // Look for T and replace data before this.
418 wxStringTokenizer wSTDate(Birthday, wxT("T"));
420 while (wSTDate.HasMoreTokens()){
422 if (ProcessDataAfterT == FALSE){
424 DataBeforeT = wSTDate.GetNextToken();
425 ProcessDataAfterT = TRUE;
429 DataAfterT = wSTDate.GetNextToken();
436 // If there is not T then replace altogether.
438 wxString FinalBirthdayDay;
439 wxString FinalBirthdayMonth;
440 wxString FinalBirthdayYear;
442 if (BirthdayDay < 10){
444 FinalBirthdayDay = wxT("0") + wxString::Format(wxT("%i"), BirthdayDay);
448 FinalBirthdayDay = wxString::Format(wxT("%i"), BirthdayDay);
452 if (((int)BirthdayMonth + 1) < 10){
454 FinalBirthdayMonth = wxT("0") + wxString::Format(wxT("%i"), ((int)BirthdayMonth + 1));
458 FinalBirthdayMonth = wxString::Format(wxT("%i"), ((int)BirthdayMonth + 1));
462 if (BirthdayYear == 0){
464 FinalBirthdayYear = wxT("--");
468 FinalBirthdayYear = wxString::Format(wxT("%i"), BirthdayYear);
472 if (!DataAfterT.IsEmpty()){
474 FinalBirthdayString = FinalBirthdayYear + FinalBirthdayMonth + FinalBirthdayDay + wxT("T") + DataAfterT;
478 FinalBirthdayString = FinalBirthdayYear + FinalBirthdayMonth + FinalBirthdayDay;
482 if (!FinalBirthdayString.IsEmpty() || !strValue2.IsEmpty()){
484 if (!strValue2.IsEmpty()){
486 EscapeString(&strValue2, FALSE);
487 EscapeString(&strValue, FALSE);
489 ContactData.AddRaw(wxT("BDAY") + strValue2 + wxT(";"), FinalBirthdayString);
493 EscapeString(&strValue, FALSE);
495 ContactData.AddRaw(wxT("BDAY"), FinalBirthdayString);
505 ResetSaveProcessData();
509 strValue3 = AnniversaryAltID;
511 if (!strValue3.IsEmpty()){
516 strValue2.Append(wxT("ALTID=\"") + strValue3 + wxT("\""));
522 //strValue3 = ContactData.Convert(GeneralAddressList, FALSE);
527 strValue3 = AnniversaryCalScale;
529 if (!strValue3.IsEmpty()){
534 if (boolValue2 == TRUE){
536 strValue2.Append(wxT(";"));
544 strValue2.Append(wxT("CALSCALE=") + strValue3);
552 strValue2 = AnniversaryTokens;
554 // Deal with ANNIVERSARY.
556 if (!txtAnniversary->IsEmpty()){
558 strValue = txtAnniversary->GetValue();
560 if (!strValue.IsEmpty() || !strValue2.IsEmpty()){
562 if (!strValue2.IsEmpty()){
564 EscapeString(&strValue2, FALSE);
565 EscapeString(&strValue, FALSE);
567 ContactData.AddRaw(wxT("ANNIVERSARY;VALUE=text;") + strValue2 + wxT(";"), strValue);
571 EscapeString(&strValue, FALSE);
573 ContactData.AddRaw(wxT("ANNIVERSARY;VALUE=text"), strValue);
581 // Look for T and replace data before this.
583 // Get Day, Month & Year.
585 wxDateTime AnniversaryDate;
586 wxDateTime::Month AnniversaryMonth;
589 wxString DataBeforeT;
591 wxString FinalAnniversaryString;
592 bool ProcessDataAfterT = FALSE;
594 AnniversaryDate = dapAnniversary->GetValue();
596 if (AnniversaryDate.IsValid()){
598 AnniversaryDay = AnniversaryDate.GetDay();
599 AnniversaryMonth = AnniversaryDate.GetMonth();
600 AnniversaryYear = AnniversaryDate.GetYear();
602 // Look for T and replace data before this.
604 wxStringTokenizer wSTDate(Anniversary, wxT("T"));
606 while (wSTDate.HasMoreTokens()){
608 if (ProcessDataAfterT == FALSE){
610 DataBeforeT = wSTDate.GetNextToken();
611 ProcessDataAfterT = TRUE;
615 DataAfterT = wSTDate.GetNextToken();
622 // If there is not T then replace altogether.
624 wxString FinalAnniversaryDay;
625 wxString FinalAnniversaryMonth;
626 wxString FinalAnniversaryYear;
628 if (AnniversaryDay < 10){
630 FinalAnniversaryDay = wxT("0") + wxString::Format(wxT("%i"), AnniversaryDay);
634 FinalAnniversaryDay = wxString::Format(wxT("%i"), AnniversaryDay);
638 if (((int)AnniversaryMonth + 1) < 10){
640 FinalAnniversaryMonth = wxT("0") + wxString::Format(wxT("%i"), ((int)AnniversaryMonth + 1));
644 FinalAnniversaryMonth = wxString::Format(wxT("%i"), ((int)AnniversaryMonth + 1));
648 if (AnniversaryYear == 0){
650 FinalAnniversaryYear = wxT("--");
654 FinalAnniversaryYear = wxString::Format(wxT("%i"), AnniversaryYear);
658 if (!DataAfterT.IsEmpty()){
660 FinalAnniversaryString = FinalAnniversaryYear + FinalAnniversaryMonth + FinalAnniversaryDay + wxT("T") + DataAfterT;
664 FinalAnniversaryString = FinalAnniversaryYear + FinalAnniversaryMonth + FinalAnniversaryDay;
668 if (!FinalAnniversaryString.IsEmpty() || !strValue2.IsEmpty()){
670 if (!strValue2.IsEmpty()){
672 EscapeString(&strValue2, FALSE);
673 EscapeString(&strValue, FALSE);
675 ContactData.AddRaw(wxT("ANNIVERSARY") + strValue2 + wxT(";"), FinalAnniversaryString);
679 EscapeString(&strValue, FALSE);
681 ContactData.AddRaw(wxT("ANNIVERSARY"), FinalAnniversaryString);
691 // Setup the addresses (General, Home, Business).
693 //intValue = GeneralAddressList.size();
694 ResetSaveProcessData();
696 for (std::map<int,wxString>::iterator iter = GeneralAddressList.begin();
697 iter != GeneralAddressList.end(); ++iter){
699 int intSeekValue = iter->first;
701 wxString strAddressString;
702 wxString strAddressFinalValue;
703 std::map<int, wxString>::iterator iterValue;
705 strAddressString.Append(wxT(";;"));
709 iterValue = GeneralAddressList.find(intSeekValue);
710 strAddressFinalValue = iterValue->second;
711 ProcessCaptureStrings(&strAddressFinalValue);
712 strAddressString.Append(strAddressFinalValue + wxT(";"));
713 strAddressFinalValue.Clear();
717 iterValue = GeneralAddressListTown.find(intSeekValue);
718 strAddressFinalValue = iterValue->second;
719 ProcessCaptureStrings(&strAddressFinalValue);
720 strAddressString.Append(strAddressFinalValue + wxT(";"));
721 strAddressFinalValue.Clear();
725 iterValue = GeneralAddressListCounty.find(intSeekValue);
726 strAddressFinalValue = iterValue->second;
727 ProcessCaptureStrings(&strAddressFinalValue);
728 strAddressString.Append(strAddressFinalValue + wxT(";"));
729 strAddressFinalValue.Clear();
733 iterValue = GeneralAddressListPostCode.find(intSeekValue);
734 strAddressFinalValue = iterValue->second;
735 ProcessCaptureStrings(&strAddressFinalValue);
736 strAddressString.Append(strAddressFinalValue + wxT(";"));
737 strAddressFinalValue.Clear();
741 iterValue = GeneralAddressListCountry.find(intSeekValue);
742 strAddressFinalValue = iterValue->second;
743 ProcessCaptureStrings(&strAddressFinalValue);
744 strAddressString.Append(strAddressFinalValue);
745 strAddressFinalValue.Clear();
747 ProcessSaveData(wxT("ADR"), &strValue2, &boolValue2, &boolValue,
748 &iter, &strAddressString, &ContactData,
749 wxT("LABEL"), &GeneralAddressListLabel,
750 wxT("LANGUAGE"), &GeneralAddressListLang,
751 wxT("ALTID"), &GeneralAddressListAltID,
752 wxT("PID"), &GeneralAddressListPID,
753 wxT("GEO"), &GeneralAddressListGeo,
754 wxT("TZ"), &GeneralAddressListTimezone,
755 wxT("MEDIATYPE"), &GeneralAddressListMediatype,
756 wxT("PREF"), &GeneralAddressListPref,
757 wxT(""), &GeneralAddressListTokens );
759 ResetSaveProcessData();
763 ResetSaveProcessData();
765 for (std::map<int,wxString>::iterator iter = HomeAddressList.begin();
766 iter != HomeAddressList.end(); ++iter){
768 int intSeekValue = iter->first;
770 wxString strAddressString;
771 wxString strAddressFinalValue;
772 std::map<int, wxString>::iterator iterValue;
774 strAddressString.Append(wxT(";;"));
778 iterValue = HomeAddressList.find(intSeekValue);
779 strAddressFinalValue = iterValue->second;
780 ProcessCaptureStrings(&strAddressFinalValue);
782 strAddressString.Append(strAddressFinalValue + wxT(";"));
786 iterValue = HomeAddressListTown.find(intSeekValue);
787 strAddressFinalValue = iterValue->second;
788 ProcessCaptureStrings(&strAddressFinalValue);
790 strAddressString.Append(strAddressFinalValue + wxT(";"));
794 iterValue = HomeAddressListCounty.find(intSeekValue);
795 strAddressFinalValue = iterValue->second;
796 ProcessCaptureStrings(&strAddressFinalValue);
798 strAddressString.Append(strAddressFinalValue + wxT(";"));
802 iterValue = HomeAddressListPostCode.find(intSeekValue);
803 strAddressFinalValue = iterValue->second;
804 ProcessCaptureStrings(&strAddressFinalValue);
806 strAddressString.Append(strAddressFinalValue + wxT(";"));
810 iterValue = HomeAddressListCountry.find(intSeekValue);
811 strAddressFinalValue = iterValue->second;
812 ProcessCaptureStrings(&strAddressFinalValue);
814 strAddressString.Append(strAddressFinalValue);
816 ProcessSaveData(wxT("ADR;TYPE=home"), &strValue2, &boolValue2, &boolValue,
817 &iter, &strAddressString, &ContactData,
818 wxT("LABEL"), &HomeAddressListLabel,
819 wxT("LANGUAGE"), &HomeAddressListLang,
820 wxT("ALTID"), &HomeAddressListAltID,
821 wxT("PID"), &HomeAddressListPID,
822 wxT("GEO"), &HomeAddressListGeo,
823 wxT("TZ"), &HomeAddressListTimezone,
824 wxT("MEDIATYPE"), &HomeAddressListMediatype,
825 wxT("PREF"), &HomeAddressListPref,
826 wxT(""), &HomeAddressListTokens );
828 ResetSaveProcessData();
832 ResetSaveProcessData();
834 for (std::map<int,wxString>::iterator iter = BusinessAddressList.begin();
835 iter != BusinessAddressList.end(); ++iter){
837 int intSeekValue = iter->first;
839 wxString strAddressString;
840 wxString strAddressFinalValue;
841 std::map<int, wxString>::iterator iterValue;
843 strAddressString.Append(wxT(";;"));
847 iterValue = BusinessAddressList.find(intSeekValue);
848 strAddressFinalValue = iterValue->second;
849 ProcessCaptureStrings(&strAddressFinalValue);
851 strAddressString.Append(strAddressFinalValue + wxT(";"));
855 iterValue = BusinessAddressListTown.find(intSeekValue);
856 strAddressFinalValue = iterValue->second;
857 ProcessCaptureStrings(&strAddressFinalValue);
859 strAddressString.Append(strAddressFinalValue + wxT(";"));
863 iterValue = BusinessAddressListCounty.find(intSeekValue);
864 strAddressFinalValue = iterValue->second;
865 ProcessCaptureStrings(&strAddressFinalValue);
867 strAddressString.Append(strAddressFinalValue + wxT(";"));
871 iterValue = BusinessAddressListPostCode.find(intSeekValue);
872 strAddressFinalValue = iterValue->second;
873 ProcessCaptureStrings(&strAddressFinalValue);
875 strAddressString.Append(strAddressFinalValue + wxT(";"));
879 iterValue = BusinessAddressListCountry.find(intSeekValue);
880 strAddressFinalValue = iterValue->second;
881 ProcessCaptureStrings(&strAddressFinalValue);
883 strAddressString.Append(strAddressFinalValue);
885 ProcessSaveData(wxT("ADR;TYPE=work"), &strValue2, &boolValue2, &boolValue,
886 &iter, &strAddressString, &ContactData,
887 wxT("LABEL"), &BusinessAddressListLabel,
888 wxT("LANGUAGE"), &BusinessAddressListLang,
889 wxT("ALTID"), &BusinessAddressListAltID,
890 wxT("PID"), &BusinessAddressListPID,
891 wxT("GEO"), &BusinessAddressListGeo,
892 wxT("TZ"), &BusinessAddressListTimezone,
893 wxT("MEDIATYPE"), &BusinessAddressListMediatype,
894 wxT("PREF"), &BusinessAddressListPref,
895 wxT(""), &BusinessAddressListTokens );
897 ResetSaveProcessData();
901 // Sort out nicknames (if any).
903 for (std::map<int,wxString>::iterator iter = GeneralNicknamesList.begin();
904 iter != GeneralNicknamesList.end(); ++iter){
906 intValue2 = iter->first;
908 // Process Alternative ID.
910 ProcessSaveData(wxT("NICKNAME"), &strValue2, &boolValue2, &boolValue,
911 &iter, &GeneralNicknamesList, &ContactData,
912 wxT("LANGUAGE"), &GeneralNicknamesListLanguage,
913 wxT("ALTID"), &GeneralNicknamesListAltID,
914 wxT("PID"), &GeneralNicknamesListPID,
915 wxT("PREF"), &GeneralNicknamesListPref,
916 wxT(""), &GeneralNicknamesListTokens );
918 ResetSaveProcessData();
922 ResetSaveProcessData();
924 for (std::map<int,wxString>::iterator iter = HomeNicknamesList.begin();
925 iter != HomeNicknamesList.end(); ++iter){
927 ProcessSaveData(wxT("NICKNAME;TYPE=home"), &strValue2, &boolValue2, &boolValue,
928 &iter, &HomeNicknamesList, &ContactData,
929 wxT("LANGUAGE"), &HomeNicknamesListLanguage,
930 wxT("ALTID"), &HomeNicknamesListAltID,
931 wxT("PID"), &HomeNicknamesListPID,
932 wxT("PREF"), &HomeNicknamesListPref,
933 wxT(""), &HomeNicknamesListTokens );
935 ResetSaveProcessData();
939 ResetSaveProcessData();
941 for (std::map<int,wxString>::iterator iter = BusinessNicknamesList.begin();
942 iter != BusinessNicknamesList.end(); ++iter){
944 ProcessSaveData(wxT("NICKNAME;TYPE=work"), &strValue2, &boolValue2, &boolValue,
945 &iter, &BusinessNicknamesList, &ContactData,
946 wxT("LANGUAGE"), &BusinessNicknamesListLanguage,
947 wxT("ALTID"), &BusinessNicknamesListAltID,
948 wxT("PID"), &BusinessNicknamesListPID,
949 wxT("PREF"), &BusinessNicknamesListPref,
950 wxT(""), &BusinessNicknamesListTokens );
952 ResetSaveProcessData();
956 ResetSaveProcessData();
958 // Sort out email (general, home and business).
960 for (std::map<int,wxString>::iterator iter = GeneralEmailList.begin();
961 iter != GeneralEmailList.end(); ++iter){
963 //strValue3 = ContactData.Convert(GeneralAddressList, FALSE);
966 wxString strAddressFinalValue;
967 std::map<int, wxString>::iterator iterValue;
969 ProcessSaveData(wxT("EMAIL"), &strValue2, &boolValue2, &boolValue,
970 &iter, &GeneralEmailList, &ContactData,
971 wxT("ALTID"), &GeneralEmailListAltID,
972 wxT("PID"), &GeneralEmailListPID,
973 wxT("PREF"), &GeneralEmailListPref,
974 wxT(""), &GeneralEmailListTokens );
976 ResetSaveProcessData();
980 ResetSaveProcessData();
982 for (std::map<int,wxString>::iterator iter = HomeEmailList.begin();
983 iter != HomeEmailList.end(); ++iter){
985 //strValue3 = ContactData.Convert(GeneralAddressList, FALSE);
988 ProcessSaveData(wxT("EMAIL;TYPE=home"), &strValue2, &boolValue2, &boolValue,
989 &iter, &HomeEmailList, &ContactData,
990 wxT("ALTID"), &HomeEmailListAltID,
991 wxT("PID"), &HomeEmailListPID,
992 wxT("PREF"), &HomeEmailListPref,
993 wxT(""), &HomeEmailListTokens );
995 ResetSaveProcessData();
999 ResetSaveProcessData();
1001 for (std::map<int,wxString>::iterator iter = BusinessEmailList.begin();
1002 iter != BusinessEmailList.end(); ++iter){
1004 //strValue3 = ContactData.Convert(GeneralAddressList, FALSE);
1007 ProcessSaveData(wxT("EMAIL;TYPE=work"), &strValue2, &boolValue2, &boolValue,
1008 &iter, &BusinessEmailList, &ContactData,
1009 wxT("ALTID"), &BusinessEmailListAltID,
1010 wxT("PID"), &BusinessEmailListPID,
1011 wxT("PREF"), &BusinessEmailListPref,
1012 wxT(""), &BusinessEmailListTokens );
1014 ResetSaveProcessData();
1018 ResetSaveProcessData();
1020 for (std::map<int,wxString>::iterator iter = GeneralIMList.begin();
1021 iter != GeneralIMList.end(); ++iter){
1023 intValue2 = iter->first;
1025 // Process Alternative ID.
1027 ProcessSaveData(wxT("IMPP"), &strValue2, &boolValue2, &boolValue,
1028 &iter, &GeneralIMList, &ContactData,
1029 wxT("ALTID"), &GeneralIMListAltID,
1030 wxT("PID"), &GeneralIMListPID,
1031 wxT("MEDIATYPE"), &GeneralIMListMediatype,
1032 wxT("PREF"), &GeneralIMListPref,
1033 wxT(""), &GeneralIMListTokens );
1035 ResetSaveProcessData();
1039 ResetSaveProcessData();
1041 for (std::map<int,wxString>::iterator iter = HomeIMList.begin();
1042 iter != HomeIMList.end(); ++iter){
1044 ProcessSaveData(wxT("IMPP;TYPE=home"), &strValue2, &boolValue2, &boolValue,
1045 &iter, &HomeIMList, &ContactData,
1046 wxT("ALTID"), &HomeIMListAltID,
1047 wxT("PID"), &HomeIMListPID,
1048 wxT("MEDIATYPE"), &HomeIMListMediatype,
1049 wxT("PREF"), &HomeIMListPref,
1050 wxT(""), &HomeIMListTokens );
1052 ResetSaveProcessData();
1056 ResetSaveProcessData();
1058 for (std::map<int,wxString>::iterator iter = BusinessIMList.begin();
1059 iter != BusinessIMList.end(); ++iter){
1061 ProcessSaveData(wxT("IMPP;TYPE=work"), &strValue2, &boolValue2, &boolValue,
1062 &iter, &BusinessIMList, &ContactData,
1063 wxT("ALTID"), &BusinessIMListAltID,
1064 wxT("PID"), &BusinessIMListPID,
1065 wxT("MEDIATYPE"), &BusinessIMListMediatype,
1066 wxT("PREF"), &BusinessIMListPref,
1067 wxT(""), &BusinessIMListTokens );
1069 ResetSaveProcessData();
1073 ResetSaveProcessData();
1075 for (std::map<int,wxString>::iterator iter = GeneralTelephoneList.begin();
1076 iter != GeneralTelephoneList.end(); ++iter){
1078 wxString strAddressFinalValue = iter->second;
1080 ProcessCaptureStrings(&strAddressFinalValue);
1082 strAddressFinalValue.insert(0, wxT("tel:"));
1084 ProcessSaveData(wxT("TEL"), &strValue2, &boolValue2, &boolValue,
1085 &iter, &strAddressFinalValue, &ContactData,
1086 wxT("ALTID"), &GeneralTelephoneListAltID,
1087 wxT("PID"), &GeneralTelephoneListPID,
1088 wxT("TYPE"), &GeneralTelephoneListType,
1089 wxT("PREF"), &GeneralTelephoneListPref,
1090 wxT(""), &GeneralTelephoneListTokens );
1092 ResetSaveProcessData();
1096 ResetSaveProcessData();
1098 for (std::map<int,wxString>::iterator iter = HomeTelephoneList.begin();
1099 iter != HomeTelephoneList.end(); ++iter){
1101 wxString strAddressFinalValue = iter->second;
1103 ProcessCaptureStrings(&strAddressFinalValue);
1105 strAddressFinalValue.insert(0, wxT("tel:"));
1107 ProcessSaveData(wxT("TEL"), &strValue2, &boolValue2, &boolValue,
1108 &iter, &strAddressFinalValue, &ContactData,
1109 wxT("ALTID"), &HomeTelephoneListAltID,
1110 wxT("PID"), &HomeTelephoneListPID,
1111 wxT("TYPE"), &HomeTelephoneListType,
1112 wxT("PREF"), &HomeTelephoneListPref,
1113 wxT(""), &HomeTelephoneListTokens );
1115 ResetSaveProcessData();
1119 ResetSaveProcessData();
1121 for (std::map<int,wxString>::iterator iter = BusinessTelephoneList.begin();
1122 iter != BusinessTelephoneList.end(); ++iter){
1124 wxString strAddressFinalValue = iter->second;
1126 ProcessCaptureStrings(&strAddressFinalValue);
1128 strAddressFinalValue.insert(0, wxT("tel:"));
1130 ProcessSaveData(wxT("TEL"), &strValue2, &boolValue2, &boolValue,
1131 &iter, &strAddressFinalValue, &ContactData,
1132 wxT("ALTID"), &BusinessTelephoneListAltID,
1133 wxT("PID"), &BusinessTelephoneListPID,
1134 wxT("TYPE"), &BusinessTelephoneListType,
1135 wxT("PREF"), &BusinessTelephoneListPref,
1136 wxT(""), &BusinessTelephoneListTokens );
1138 ResetSaveProcessData();
1142 ResetSaveProcessData();
1144 for (std::map<int,wxString>::iterator iter = GeneralLanguageList.begin();
1145 iter != GeneralLanguageList.end(); ++iter){
1147 intValue2 = iter->first;
1149 ProcessSaveData(wxT("LANG"), &strValue2, &boolValue2, &boolValue,
1150 &iter, &GeneralLanguageList, &ContactData,
1151 wxT("ALTID"), &GeneralLanguageListAltID,
1152 wxT("PID"), &GeneralLanguageListPID,
1153 wxT("PREF"), &GeneralLanguageListPref,
1154 wxT(""), &GeneralLanguageListTokens );
1156 ResetSaveProcessData();
1160 ResetSaveProcessData();
1162 for (std::map<int,wxString>::iterator iter = HomeLanguageList.begin();
1163 iter != HomeLanguageList.end(); ++iter){
1165 ProcessSaveData(wxT("LANG;TYPE=home"), &strValue2, &boolValue2, &boolValue,
1166 &iter, &HomeLanguageList, &ContactData,
1167 wxT("ALTID"), &HomeLanguageListAltID,
1168 wxT("PID"), &HomeLanguageListPID,
1169 wxT("PREF"), &HomeLanguageListPref,
1170 wxT(""), &HomeLanguageListTokens );
1172 ResetSaveProcessData();
1176 ResetSaveProcessData();
1178 for (std::map<int,wxString>::iterator iter = BusinessLanguageList.begin();
1179 iter != BusinessLanguageList.end(); ++iter){
1181 ProcessSaveData(wxT("LANG;TYPE=work"), &strValue2, &boolValue2, &boolValue,
1182 &iter, &BusinessLanguageList, &ContactData,
1183 wxT("ALTID"), &BusinessLanguageListAltID,
1184 wxT("PID"), &BusinessLanguageListPID,
1185 wxT("PREF"), &BusinessLanguageListPref,
1186 wxT(""), &BusinessLanguageListTokens );
1188 ResetSaveProcessData();
1192 ResetSaveProcessData();
1194 for (std::map<int,wxString>::iterator iter = GeneralTZList.begin();
1195 iter != GeneralTZList.end(); ++iter){
1197 ProcessSaveData(wxT("TZ"), &strValue2, &boolValue2, &boolValue,
1198 &iter, &GeneralTZList, &ContactData,
1199 wxT("ALTID"), &GeneralTZListAltID,
1200 wxT("PID"), &GeneralTZListPID,
1201 wxT("MEDIATYPE"), &GeneralTZListMediatype,
1202 wxT("PREF"), &GeneralTZListPref,
1203 wxT(""), &GeneralTZListTokens );
1205 ResetSaveProcessData();
1209 ResetSaveProcessData();
1211 for (std::map<int,wxString>::iterator iter = HomeTZList.begin();
1212 iter != HomeTZList.end(); ++iter){
1214 ProcessSaveData(wxT("TZ;TYPE=home"), &strValue2, &boolValue2, &boolValue,
1215 &iter, &HomeTZList, &ContactData,
1216 wxT("ALTID"), &HomeTZListAltID,
1217 wxT("PID"), &HomeTZListPID,
1218 wxT("MEDIATYPE"), &HomeTZListMediatype,
1219 wxT("PREF"), &HomeTZListPref,
1220 wxT(""), &HomeTZListTokens );
1222 ResetSaveProcessData();
1226 ResetSaveProcessData();
1228 for (std::map<int,wxString>::iterator iter = BusinessTZList.begin();
1229 iter != BusinessTZList.end(); ++iter){
1231 ProcessSaveData(wxT("TZ;TYPE=work"), &strValue2, &boolValue2, &boolValue,
1232 &iter, &BusinessTZList, &ContactData,
1233 wxT("ALTID"), &BusinessTZListAltID,
1234 wxT("PID"), &BusinessTZListPID,
1235 wxT("MEDIATYPE"), &BusinessTZListMediatype,
1236 wxT("PREF"), &BusinessTZListPref,
1237 wxT(""), &BusinessTZListTokens );
1239 ResetSaveProcessData();
1243 ResetSaveProcessData();
1245 for (std::map<int,wxString>::iterator iter = GeneralGeographyList.begin();
1246 iter != GeneralGeographyList.end(); ++iter){
1248 wxString strAddressFinalValue = iter->second;
1250 ProcessCaptureStrings(&strAddressFinalValue);
1252 strAddressFinalValue.insert(0, wxT("geo:"));
1254 ProcessSaveData(wxT("GEO"), &strValue2, &boolValue2, &boolValue,
1255 &iter, &strAddressFinalValue, &ContactData,
1256 wxT("ALTID"), &GeneralGeographyListAltID,
1257 wxT("PID"), &GeneralGeographyListPID,
1258 wxT("MEDIATYPE"), &GeneralGeographyListMediatype,
1259 wxT("PREF"), &GeneralGeographyListPref,
1260 wxT(""), &GeneralGeographyListTokens );
1262 ResetSaveProcessData();
1266 ResetSaveProcessData();
1268 for (std::map<int,wxString>::iterator iter = HomeGeographyList.begin();
1269 iter != HomeGeographyList.end(); ++iter){
1271 wxString strAddressFinalValue = iter->second;
1273 ProcessCaptureStrings(&strAddressFinalValue);
1275 strAddressFinalValue.insert(0, wxT("geo:"));
1277 ProcessSaveData(wxT("GEO;TYPE=home"), &strValue2, &boolValue2, &boolValue,
1278 &iter, &HomeGeographyList, &ContactData,
1279 wxT("ALTID"), &HomeGeographyListAltID,
1280 wxT("PID"), &HomeGeographyListPID,
1281 wxT("MEDIATYPE"), &HomeGeographyListMediatype,
1282 wxT("PREF"), &HomeGeographyListPref,
1283 wxT(""), &HomeGeographyListTokens );
1285 ResetSaveProcessData();
1289 ResetSaveProcessData();
1291 for (std::map<int,wxString>::iterator iter = BusinessGeographyList.begin();
1292 iter != BusinessGeographyList.end(); ++iter){
1294 wxString strAddressFinalValue = iter->second;
1296 ProcessCaptureStrings(&strAddressFinalValue);
1298 strAddressFinalValue.insert(0, wxT("geo:"));
1300 ProcessSaveData(wxT("GEO;TYPE=work"), &strValue2, &boolValue2, &boolValue,
1301 &iter, &BusinessGeographyList, &ContactData,
1302 wxT("ALTID"), &BusinessGeographyListAltID,
1303 wxT("PID"), &BusinessGeographyListPID,
1304 wxT("MEDIATYPE"), &BusinessGeographyListMediatype,
1305 wxT("PREF"), &BusinessGeographyListPref,
1306 wxT(""), &BusinessGeographyListTokens );
1308 ResetSaveProcessData();
1312 ResetSaveProcessData();
1314 for (std::map<int,wxString>::iterator iter = GeneralRelatedList.begin();
1315 iter != GeneralRelatedList.end(); ++iter){
1317 ProcessSaveData(wxT("RELATED"), &strValue2, &boolValue2, &boolValue,
1318 &iter, &GeneralRelatedList, &ContactData,
1319 wxT("ALTID"), &GeneralRelatedListAltID,
1320 wxT("PID"), &GeneralRelatedListPID,
1321 wxT("LANGUAGE"), &GeneralRelatedListLanguage,
1322 wxT("TYPE"), &GeneralRelatedListRelType,
1323 wxT("PREF"), &GeneralRelatedListPref,
1324 wxT(""), &GeneralRelatedListTokens );
1326 ResetSaveProcessData();
1330 ResetSaveProcessData();
1332 for (std::map<int,wxString>::iterator iter = GeneralWebsiteList.begin();
1333 iter != GeneralWebsiteList.end(); ++iter){
1335 ProcessSaveData(wxT("URL"), &strValue2, &boolValue2, &boolValue,
1336 &iter, &GeneralWebsiteList, &ContactData,
1337 wxT("ALTID"), &GeneralWebsiteListAltID,
1338 wxT("PID"), &GeneralWebsiteListPID,
1339 wxT("MEDIATYPE"), &GeneralWebsiteListMediatype,
1340 wxT("PREF"), &GeneralWebsiteListPref,
1341 wxT(""), &GeneralWebsiteListTokens );
1343 ResetSaveProcessData();
1347 ResetSaveProcessData();
1349 for (std::map<int,wxString>::iterator iter = HomeWebsiteList.begin();
1350 iter != HomeWebsiteList.end(); ++iter){
1352 ProcessSaveData(wxT("URL;TYPE=home"), &strValue2, &boolValue2, &boolValue,
1353 &iter, &HomeWebsiteList, &ContactData,
1354 wxT("ALTID"), &HomeWebsiteListAltID,
1355 wxT("PID"), &HomeWebsiteListPID,
1356 wxT("MEDIATYPE"), &HomeWebsiteListMediatype,
1357 wxT("PREF"), &HomeWebsiteListPref,
1358 wxT(""), &HomeWebsiteListTokens );
1360 ResetSaveProcessData();
1364 ResetSaveProcessData();
1366 for (std::map<int,wxString>::iterator iter = BusinessWebsiteList.begin();
1367 iter != BusinessWebsiteList.end(); ++iter){
1369 ProcessSaveData(wxT("URL;TYPE=work"), &strValue2, &boolValue2, &boolValue,
1370 &iter, &BusinessWebsiteList, &ContactData,
1371 wxT("ALTID"), &BusinessWebsiteListAltID,
1372 wxT("PID"), &BusinessWebsiteListPID,
1373 wxT("MEDIATYPE"), &BusinessWebsiteListMediatype,
1374 wxT("PREF"), &BusinessWebsiteListPref,
1375 wxT(""), &BusinessWebsiteListTokens );
1377 ResetSaveProcessData();
1381 ResetSaveProcessData();
1383 for (std::map<int,wxString>::iterator iter = GeneralTitleList.begin();
1384 iter != GeneralTitleList.end(); ++iter){
1386 ProcessSaveData(wxT("TITLE"), &strValue2, &boolValue2, &boolValue,
1387 &iter, &GeneralTitleList, &ContactData,
1388 wxT("ALTID"), &GeneralTitleListAltID,
1389 wxT("PID"), &GeneralTitleListPID,
1390 wxT("LANGUAGE"), &GeneralTitleListLanguage,
1391 wxT("PREF"), &GeneralTitleListPref,
1392 wxT(""), &GeneralTitleListTokens );
1394 ResetSaveProcessData();
1398 ResetSaveProcessData();
1400 for (std::map<int,wxString>::iterator iter = HomeTitleList.begin();
1401 iter != HomeTitleList.end(); ++iter){
1403 ProcessSaveData(wxT("TITLE;TYPE=home"), &strValue2, &boolValue2, &boolValue,
1404 &iter, &HomeTitleList, &ContactData,
1405 wxT("ALTID"), &HomeTitleListAltID,
1406 wxT("PID"), &HomeTitleListPID,
1407 wxT("LANGUAGE"), &HomeTitleListLanguage,
1408 wxT("PREF"), &HomeTitleListPref,
1409 wxT(""), &HomeTitleListTokens );
1411 ResetSaveProcessData();
1415 ResetSaveProcessData();
1417 for (std::map<int,wxString>::iterator iter = BusinessTitleList.begin();
1418 iter != BusinessTitleList.end(); ++iter){
1420 ProcessSaveData(wxT("TITLE;TYPE=work"), &strValue2, &boolValue2, &boolValue,
1421 &iter, &BusinessTitleList, &ContactData,
1422 wxT("ALTID"), &BusinessTitleListAltID,
1423 wxT("PID"), &BusinessTitleListPID,
1424 wxT("LANGUAGE"), &BusinessTitleListLanguage,
1425 wxT("PREF"), &BusinessTitleListPref,
1426 wxT(""), &BusinessTitleListTokens );
1428 ResetSaveProcessData();
1432 ResetSaveProcessData();
1434 for (std::map<int,wxString>::iterator iter = GeneralRoleList.begin();
1435 iter != GeneralRoleList.end(); ++iter){
1437 ProcessSaveData(wxT("ROLE"), &strValue2, &boolValue2, &boolValue,
1438 &iter, &GeneralRoleList, &ContactData,
1439 wxT("ALTID"), &GeneralRoleListAltID,
1440 wxT("PID"), &GeneralRoleListPID,
1441 wxT("LANGUAGE"), &GeneralRoleListLanguage,
1442 wxT("PREF"), &GeneralRoleListPref,
1443 wxT(""), &GeneralRoleListTokens );
1445 ResetSaveProcessData();
1449 ResetSaveProcessData();
1451 for (std::map<int,wxString>::iterator iter = HomeRoleList.begin();
1452 iter != HomeRoleList.end(); ++iter){
1454 ProcessSaveData(wxT("ROLE;TYPE=home"), &strValue2, &boolValue2, &boolValue,
1455 &iter, &HomeRoleList, &ContactData,
1456 wxT("ALTID"), &HomeRoleListAltID,
1457 wxT("PID"), &HomeRoleListPID,
1458 wxT("LANGUAGE"), &HomeRoleListLanguage,
1459 wxT("PREF"), &HomeRoleListPref,
1460 wxT(""), &HomeRoleListTokens );
1462 ResetSaveProcessData();
1466 ResetSaveProcessData();
1468 for (std::map<int,wxString>::iterator iter = BusinessRoleList.begin();
1469 iter != BusinessRoleList.end(); ++iter){
1471 ProcessSaveData(wxT("ROLE;TYPE=work"), &strValue2, &boolValue2, &boolValue,
1472 &iter, &BusinessRoleList, &ContactData,
1473 wxT("ALTID"), &BusinessRoleListAltID,
1474 wxT("PID"), &BusinessRoleListPID,
1475 wxT("LANGUAGE"), &BusinessRoleListLanguage,
1476 wxT("PREF"), &BusinessRoleListPref,
1477 wxT(""), &BusinessRoleListTokens );
1479 ResetSaveProcessData();
1483 ResetSaveProcessData();
1485 for (std::map<int,wxString>::iterator iter = GeneralOrganisationsList.begin();
1486 iter != GeneralOrganisationsList.end(); ++iter){
1488 ProcessSaveData(wxT("ORG"), &strValue2, &boolValue2, &boolValue,
1489 &iter, &GeneralOrganisationsList, &ContactData,
1490 wxT("ALTID"), &GeneralOrganisationsListAltID,
1491 wxT("PID"), &GeneralOrganisationsListPID,
1492 wxT("LANGUAGE"), &GeneralOrganisationsListLanguage,
1493 wxT("SORT-AS"), &GeneralOrganisationsListSortAs,
1494 wxT("PREF"), &GeneralOrganisationsListPref,
1495 wxT(""), &GeneralOrganisationsListTokens );
1497 ResetSaveProcessData();
1501 ResetSaveProcessData();
1503 for (std::map<int,wxString>::iterator iter = HomeOrganisationsList.begin();
1504 iter != HomeOrganisationsList.end(); ++iter){
1506 ProcessSaveData(wxT("ORG;TYPE=home"), &strValue2, &boolValue2, &boolValue,
1507 &iter, &HomeOrganisationsList, &ContactData,
1508 wxT("ALTID"), &HomeOrganisationsListAltID,
1509 wxT("PID"), &HomeOrganisationsListPID,
1510 wxT("LANGUAGE"), &HomeOrganisationsListLanguage,
1511 wxT("SORT-AS"), &HomeOrganisationsListSortAs,
1512 wxT("PREF"), &HomeOrganisationsListPref,
1513 wxT(""), &HomeOrganisationsListTokens );
1515 ResetSaveProcessData();
1519 ResetSaveProcessData();
1521 for (std::map<int,wxString>::iterator iter = BusinessOrganisationsList.begin();
1522 iter != BusinessOrganisationsList.end(); ++iter){
1524 ProcessSaveData(wxT("ORG;TYPE=work"), &strValue2, &boolValue2, &boolValue,
1525 &iter, &BusinessOrganisationsList, &ContactData,
1526 wxT("ALTID"), &BusinessOrganisationsListAltID,
1527 wxT("PID"), &BusinessOrganisationsListPID,
1528 wxT("LANGUAGE"), &BusinessOrganisationsListLanguage,
1529 wxT("SORT-AS"), &BusinessOrganisationsListSortAs,
1530 wxT("PREF"), &BusinessOrganisationsListPref,
1531 wxT(""), &BusinessOrganisationsListTokens );
1533 ResetSaveProcessData();
1537 ResetSaveProcessData();
1539 for (std::map<int,wxString>::iterator iter = GeneralNoteList.begin();
1540 iter != GeneralNoteList.end(); ++iter){
1542 ProcessSaveData(wxT("NOTE"), &strValue2, &boolValue2, &boolValue,
1543 &iter, &GeneralNoteList, &ContactData,
1544 wxT("ALTID"), &GeneralNoteListAltID,
1545 wxT("PID"), &GeneralNoteListPID,
1546 wxT("LANGUAGE"), &GeneralNoteListLanguage,
1547 wxT("PREF"), &GeneralNoteListPref,
1548 wxT(""), &GeneralNoteListTokens );
1550 ResetSaveProcessData();
1554 ResetSaveProcessData();
1556 for (std::map<int,wxString>::iterator iter = HomeNoteList.begin();
1557 iter != HomeNoteList.end(); ++iter){
1559 ProcessSaveData(wxT("NOTE;TYPE=home"), &strValue2, &boolValue2, &boolValue,
1560 &iter, &HomeNoteList, &ContactData,
1561 wxT("ALTID"), &HomeNoteListAltID,
1562 wxT("PID"), &HomeNoteListPID,
1563 wxT("LANGUAGE"), &HomeNoteListLanguage,
1564 wxT("PREF"), &HomeNoteListPref,
1565 wxT(""), &HomeNoteListTokens );
1567 ResetSaveProcessData();
1571 ResetSaveProcessData();
1573 for (std::map<int,wxString>::iterator iter = BusinessNoteList.begin();
1574 iter != BusinessNoteList.end(); ++iter){
1576 ProcessSaveData(wxT("NOTE;TYPE=work"), &strValue2, &boolValue2, &boolValue,
1577 &iter, &BusinessNoteList, &ContactData,
1578 wxT("ALTID"), &BusinessNoteListAltID,
1579 wxT("PID"), &BusinessNoteListPID,
1580 wxT("LANGUAGE"), &BusinessNoteListLanguage,
1581 wxT("PREF"), &BusinessNoteListPref,
1582 wxT(""), &BusinessNoteListTokens );
1584 ResetSaveProcessData();
1588 ResetSaveProcessData();
1590 for (std::map<int,wxString>::iterator iter = CategoriesList.begin();
1591 iter != CategoriesList.end(); ++iter){
1593 ProcessSaveData(wxT("CATEGORIES"), &strValue2, &boolValue2, &boolValue,
1594 &iter, &CategoriesList, &ContactData,
1595 wxT("ALTID"), &CategoriesListAltID,
1596 wxT("PID"), &CategoriesListPID,
1597 wxT("TYPE"), &CategoriesListType,
1598 wxT("PREF"), &CategoriesListPref,
1599 wxT(""), &CategoriesListTokens );
1601 ResetSaveProcessData();
1607 for (std::map<int, std::string>::iterator iter = PicturesList.begin();
1608 iter != PicturesList.end(); ++iter){
1610 int intValueIndex = iter->first;
1612 std::map<int, std::string>::iterator stdstriter;
1613 std::map<int, wxString>::iterator enciter;
1615 striter = PicturesListPictureType.find(intValueIndex);
1616 enciter = PicturesListPicEncType.find(intValueIndex);
1618 ProcessSaveData(wxT("PHOTO"), &strValue2, &boolValue2, &boolValue,
1619 &iter, &PicturesList, &striter,
1620 &enciter, &ContactData,
1621 wxT("ALTID"), &PicturesListAltID,
1622 wxT("PID"), &PicturesListPID,
1623 wxT("TYPE"), &PicturesListType,
1624 wxT("PREF"), &PicturesListPref,
1625 wxT(""), &PicturesListTokens);
1627 ResetSaveProcessData();
1631 ResetSaveProcessData();
1635 for (std::map<int, std::string>::iterator iter = LogosList.begin();
1636 iter != LogosList.end(); ++iter){
1638 int intValueIndex = iter->first;
1640 std::map<int, std::string>::iterator stdstriter;
1641 std::map<int, wxString>::iterator enciter;
1643 striter = LogosListPictureType.find(intValueIndex);
1644 enciter = LogosListPicEncType.find(intValueIndex);
1646 ProcessSaveData(wxT("LOGO"), &strValue2, &boolValue2, &boolValue,
1647 &iter, &LogosList, &striter,
1648 &enciter, &ContactData,
1649 wxT("ALTID"), &LogosListAltID,
1650 wxT("PID"), &LogosListPID,
1651 wxT("TYPE"), &LogosListType,
1652 wxT("PREF"), &LogosListPref,
1653 wxT(""), &LogosListTokens );
1655 ResetSaveProcessData();
1659 ResetSaveProcessData();
1663 for (std::map<int, std::string>::iterator iter = SoundsList.begin();
1664 iter != SoundsList.end(); ++iter){
1666 int intValueIndex = iter->first;
1668 std::map<int, std::string>::iterator stdstriter;
1669 std::map<int, wxString>::iterator enciter;
1671 striter = SoundsListAudioType.find(intValueIndex);
1672 enciter = SoundsListAudioEncType.find(intValueIndex);
1674 ProcessSaveData(wxT("SOUND"), &strValue2, &boolValue2, &boolValue,
1675 &iter, &SoundsList, &striter,
1676 &enciter, &ContactData,
1677 wxT("ALTID"), &SoundsListAltID,
1678 wxT("PID"), &SoundsListPID,
1679 wxT("TYPE"), &SoundsListType,
1680 wxT("PREF"), &SoundsListPref,
1681 wxT(""), &SoundsListTokens );
1683 ResetSaveProcessData();
1687 ResetSaveProcessData();
1689 for (std::map<int,wxString>::iterator iter = CalendarList.begin();
1690 iter != CalendarList.end(); ++iter){
1692 ProcessSaveData(wxT("CALURI"), &strValue2, &boolValue2, &boolValue,
1693 &iter, &CalendarList, &ContactData,
1694 wxT("ALTID"), &CalendarListAltID,
1695 wxT("PID"), &CalendarListPID,
1696 wxT("MEDIATYPE"), &CalendarListMediatype,
1697 wxT("TYPE"), &CalendarListType,
1698 wxT("PREF"), &CalendarListPref,
1699 wxT(""), &CalendarListTokens );
1701 ResetSaveProcessData();
1705 ResetSaveProcessData();
1707 for (std::map<int,wxString>::iterator iter = CalendarRequestList.begin();
1708 iter != CalendarRequestList.end(); ++iter){
1710 ProcessSaveData(wxT("CALADRURI"), &strValue2, &boolValue2, &boolValue,
1711 &iter, &CalendarRequestList, &ContactData,
1712 wxT("ALTID"), &CalendarRequestListAltID,
1713 wxT("PID"), &CalendarRequestListPID,
1714 wxT("MEDIATYPE"), &CalendarRequestListMediatype,
1715 wxT("TYPE"), &CalendarRequestListType,
1716 wxT("PREF"), &CalendarRequestListPref,
1717 wxT(""), &CalendarRequestListTokens );
1719 ResetSaveProcessData();
1723 ResetSaveProcessData();
1725 for (std::map<int,wxString>::iterator iter = FreeBusyList.begin();
1726 iter != FreeBusyList.end(); ++iter){
1728 ProcessSaveData(wxT("FBURL"), &strValue2, &boolValue2, &boolValue,
1729 &iter, &FreeBusyList, &ContactData,
1730 wxT("ALTID"), &FreeBusyListAltID,
1731 wxT("PID"), &FreeBusyListPID,
1732 wxT("MEDIATYPE"), &FreeBusyListMediatype,
1733 wxT("TYPE"), &FreeBusyListType,
1734 wxT("PREF"), &FreeBusyListPref,
1735 wxT(""), &FreeBusyListTokens );
1737 ResetSaveProcessData();
1741 for (std::map<int, wxString>::iterator iter = KeyList.begin();
1742 iter != KeyList.end(); ++iter){
1744 intValue2 = iter->first;
1746 // Process Alternative ID.
1748 striter = KeyListAltID.find(intValue2);
1750 if (striter->first == intValue2){
1752 strValue3 = striter->second;
1754 if (!strValue3.IsEmpty()){
1759 if (boolValue2 == TRUE){
1761 strValue2.Append(wxT(";"));
1769 strValue2.Append(wxT("ALTID=") + strValue3);
1779 striter = KeyListPID.find(intValue2);
1781 if (striter->first == intValue2){
1783 strValue3 = striter->second;
1785 if (!strValue3.IsEmpty()){
1790 if (boolValue2 == TRUE){
1792 strValue2.Append(wxT(";"));
1800 strValue2.Append(wxT("PID=") + strValue3);
1810 striter = KeyListType.find(intValue2);
1812 if (striter->first == intValue2){
1814 strValue3 = striter->second;
1816 if (!strValue3.IsEmpty()){
1821 if (boolValue2 == TRUE){
1823 strValue2.Append(wxT(";"));
1831 strValue2.Append(wxT("TYPE=") + strValue3);
1839 intiter = KeyListPref.find(intValue2);
1841 if (intiter->first == intValue2){
1843 intValue3 = intiter->second;
1847 if (boolValue2 == TRUE){
1849 strValue2.Append(wxT(";"));
1857 strValue2.Append(wxT("PREF=") + wxString::Format(wxT("%i"), intValue3));
1867 striter = KeyListTokens.find(intValue2);
1869 if (striter->first == intValue2){
1871 strValue3 = striter->second;
1873 if (!strValue3.IsEmpty()){
1878 if (boolValue2 == TRUE){
1880 strValue2.Append(wxT(";"));
1888 strValue2.Append(strValue3);
1896 // Get the key information.
1898 std::map<int, wxString>::iterator enciter;
1900 striter = KeyListDataType.find(intValue2);
1901 //enciter = KeyListAudioEncType.find(intValue2);
1903 wxString strValueData;
1905 strValueData = iter->second;
1906 //strValueData.insert(0, wxT("data:") + striter->second + wxT(";") + enciter->second + wxT(","));
1907 strValueData.insert(0, wxT("data:") + striter->second + wxT(";base64,"));
1910 // Add to the vCard.
1912 if (boolValue == TRUE){
1914 ContactData.AddRaw(wxT("KEY;") + strValue2, strValueData);
1918 ContactData.Add(wxT("KEY"), strValueData, TRUE);
1922 ResetSaveProcessData();
1926 // Vendor specific items.
1928 ResetSaveProcessData();
1930 for (std::map<int,wxString>::iterator iter = VendorList.begin();
1931 iter != VendorList.end(); ++iter){
1933 intValue2 = iter->first;
1935 // Get the IANA PEN number.
1937 striter = VendorListPEN.find(intValue2);
1939 if (striter->first == intValue2){
1941 strValue2 = striter->second;
1945 // Get the element name.
1947 striter = VendorListElement.find(intValue2);
1949 if (striter->first == intValue2){
1951 strValue3 = striter->second;
1957 striter = VendorList.find(intValue2);
1959 if (striter->first == intValue2){
1961 strValue = striter->second;
1965 // Add to the vCard.
1967 if (boolValue == TRUE){
1969 ContactData.AddRaw(wxT("VND-") + strValue2 + wxT("-") + strValue3, strValue);
1973 ContactData.Add(wxT("VND-") + strValue2 + wxT("-") + strValue3, strValue, FALSE);
1977 ResetSaveProcessData();
1981 ResetSaveProcessData();
1985 for (std::map<int,wxString>::iterator iter = XTokenList.begin();
1986 iter != XTokenList.end(); ++iter){
1988 intValue2 = iter->first;
1990 // Get the element name.
1992 striter = XTokenListTokens.find(intValue2);
1994 if (striter->first == intValue2){
1996 strValue2 = striter->second;
2002 striter = XTokenList.find(intValue2);
2004 if (striter->first == intValue2){
2006 strValue = striter->second;
2010 // Add to the vCard.
2012 if (boolValue == TRUE){
2014 ContactData.AddRaw(wxT("X-") + strValue2, strValue);
2018 ContactData.Add(wxT("X-") + strValue2, strValue, FALSE);
2022 ResetSaveProcessData();
2026 ResetSaveProcessData();
2028 if (FullNamesList.size() == 0){
2030 wxString FullName = cmbDisplayAs->GetValue();
2031 FullNamesList.insert(std::make_pair(0, FullName));
2032 FullNamesListAltID.insert(std::make_pair(0, wxT("")));
2033 FullNamesListPID.insert(std::make_pair(0, wxT("")));
2034 FullNamesListType.insert(std::make_pair(0, wxT("")));
2035 FullNamesListLanguage.insert(std::make_pair(0, wxT("")));
2036 FullNamesListPref.insert(std::make_pair(0, 0));
2037 FullNamesListTokens.insert(std::make_pair(0, wxT("")));
2042 for (std::map<int, wxString>::iterator iter = FullNamesList.begin();
2043 iter != FullNamesList.end(); ++iter){
2045 if (FNFirst == TRUE){
2047 iter->second = cmbDisplayAs->GetValue();
2052 std::map<int,wxString>::iterator mapS;
2054 mapS = FullNamesListTokens.find(iter->first);
2056 ProcessSaveData(wxT("FN"), &strValue2, &boolValue2, &boolValue,
2057 &iter, &FullNamesList, &ContactData,
2058 wxT("ALTID"), &FullNamesListAltID,
2059 wxT("PID"), &FullNamesListPID,
2060 wxT("TYPE"), &FullNamesListType,
2061 wxT("LANGUAGE"), &FullNamesListLanguage,
2062 wxT("PREF"), &FullNamesListPref,
2063 wxT(""), &FullNamesListTokens );
2067 ResetSaveProcessData();
2071 //ContactData.Add(wxT("FN"), cmbDisplayAs->GetValue(), FALSE);
2073 // Insert revision (REV) date.
2075 // Get today's date and time.
2077 wxDateTime DateTimeNow = wxDateTime::Now();
2081 // Set year, month and date.
2083 int intYear = DateTimeNow.GetYear();
2084 int intMonth = DateTimeNow.GetMonth();
2085 int intDay = DateTimeNow.GetDay();
2087 DateRev.Append(wxT("0") + wxString::Format(wxT("%i"), intYear));
2091 DateRev.Append(wxT("0") + wxString::Format(wxT("%i"), intMonth));
2095 DateRev.Append(wxString::Format(wxT("%i"), intMonth));
2101 DateRev.Append(wxT("0") + wxString::Format(wxT("%i"), intDay));
2105 DateRev.Append(wxString::Format(wxT("%i"), intDay));
2109 //DateRev.Append(wx);
2110 //DateRev.Append(wx);
2111 //DateRev.Append(wx);
2112 DateRev.Append(wxT("T"));
2114 // Set hour, minute and second.
2116 int intHour = DateTimeNow.GetHour();
2117 int intMinute = DateTimeNow.GetMinute();
2118 int intSecond = DateTimeNow.GetSecond();
2122 DateRev.Append(wxT("0") + wxString::Format(wxT("%i"), intHour));
2126 DateRev.Append(wxString::Format(wxT("%i"), intHour));
2130 if (intMinute < 10){
2132 DateRev.Append(wxT("0") + wxString::Format(wxT("%i"), intMinute));
2136 DateRev.Append(wxString::Format(wxT("%i"), intMinute));
2140 if (intSecond < 10){
2142 DateRev.Append(wxT("0") + wxString::Format(wxT("%i"), intSecond));
2146 DateRev.Append(wxString::Format(wxT("%i"), intSecond));
2150 // DateRev.Append(wx);
2151 // DateRev.Append(wx);
2152 // DateRev.Append(wxString DateTimeNow->);
2153 DateRev.Append(wxT("Z"));
2155 ContactData.Add(wxT("UID"), UIDToken, FALSE);
2157 // End the vCard File.
2159 ContactData.Add(wxT("END"), wxT("VCARD"), FALSE);
2162 ContactData.WriteFile(FilenameFinal);
2164 vCard34Conv ConvFileFun;
2168 ConvFileFun.ConvertToV3(FilenameFinal, &wxSData);
2170 wxString AccountDirPrefix;
2171 wxString AccountDir;
2174 #if defined(__HAIKU__)
2176 //preffilename = wxT("noo");
2178 #elif defined(__APPLE__)
2180 PrefDir = GetUserPrefDir();
2182 wxStringTokenizer wSTFilename(wxSContactFilename, wxT("/"));
2184 #elif defined(__WIN32__)
2186 PrefDir = GetUserPrefDir();
2188 wxStringTokenizer wSTFilename(wxSContactFilename, wxT("\\"));
2192 PrefDir = GetUserPrefDir();
2194 wxStringTokenizer wSTFilename(wxSContactFilename, wxT("/"));
2198 XABPreferences PrefData(PrefDir);
2200 wxString AccountType;
2202 for (int i = 0; i < PrefData.accounts.GetCount(); i++){
2204 AccountDir = PrefData.accounts.GetAccountDirectory(i) + wxT(".carddav");
2206 if (AccountDir == wxSContactAccount){
2208 AccountDirPrefix = PrefData.accounts.GetAccountDirPrefix(i);
2209 AccountDirPrefix.Trim();
2210 AccountType = PrefData.accounts.GetAccountType(i);
2217 wxString wxSplitFilename;
2218 wxString wxSDataURL;
2220 while(wSTFilename.HasMoreTokens()){
2222 wxSplitFilename = wSTFilename.GetNextToken();
2226 wxSDataURL = wxSplitFilename;
2227 //wxSDataURL.Append(wxSplitFilename);
2229 // Find out if the filename exists in the table.
2231 if (AccountType == wxT("CardDAV") || AccountType == wxT("carddav")){
2233 wxString ETagResult;
2234 wxString ETagOriginal;
2236 ETagDB *ETagDBPtr = NULL;
2238 ETagDBPtr = ETagTmrPtr->GetPointer(wxSContactAccount);
2240 wxString wxSETag = ETagDBPtr->GetETag(wxSplitFilename);
2241 wxString wxSETagOrig = ETagDBPtr->GetETagOriginal(wxSplitFilename);
2243 if (wxSETagOrig.IsEmpty()){
2245 // Generate the ETag.
2247 wxSETagOrig = wxString::Format(wxT("%X%X%X%X"), rand() % 1024, rand() % 1024, rand() % 1024, rand() % 1024);
2251 if (wxSETag.IsEmpty()){
2253 // Update empty ETag.
2255 wxSETag = wxSETagOrig;
2256 ETagDBPtr->UpdateETag(wxSplitFilename, wxSETag, wxSETagOrig);
2261 // Don't change original ETag.
2263 wxSETag = wxString::Format(wxT("%X%X%X%X"), rand() % 1024, rand() % 1024, rand() % 1024, rand() % 1024);
2264 ETagDBPtr->UpdateETag(wxSplitFilename, wxSETag);
2268 if (EditMode == FALSE){
2270 ActMgrPtr->AddTask(0, cmbDisplayAs->GetValue(), wxSContactAccount, wxSDataURL, wxSplitFilename, FilenameFinal, wxSData);
2272 FMTimer.SetFilename(FilenameFinal);
2273 FMTimer.UpdateTimestamp();
2274 FMTimer.Start(10000, FALSE);
2276 wxCommandEvent reloadevent(RELOADCONTACTLIST);
2277 reloadevent.SetString(wxSContactAccount);
2278 wxPostEvent(this->GetParent(), reloadevent);
2283 ActMgrPtr->AddTask(1, cmbDisplayAs->GetValue(), wxSContactAccount, wxSDataURL, wxSplitFilename, FilenameFinal, wxSData);
2284 FMTimer.UpdateTimestamp();
2285 FMTimer.Start(10000, FALSE);
2291 // Send a notification to update the main window
2292 // with the new details.
2297 // TODO: Workout nickname settings by priority and
2300 ucd->ContactAccount = wxSContactAccount;
2301 ucd->ContactFilename = FilenameFinal;
2302 ucd->ContactName = cmbDisplayAs->GetValue();
2303 ucd->ContactNameArray = ContactData.GetName();
2305 for (std::map<int,wxString>::iterator gniter = GeneralNicknamesList.begin();
2306 gniter != GeneralNicknamesList.end(); gniter++){
2308 ucd->ContactNickname = gniter->second;
2313 wxCommandEvent event2(CE_UPDATECONTACTLIST);
2314 event2.SetClientData(ucd);
2315 wxPostEvent(MainPtr, event2);
2319 void frmContactEditor::SaveCloseContact( wxCommandEvent& event )
2322 // Save the updated contact data and close the form.
2324 wxCommandEvent NullEvent;
2325 this->SaveContact(NullEvent);