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 /*boost::uuids::uuid ContactUUID = boost::uuids::random_generator()();
145 std::string sstContactUUID = boost::uuids::to_string(ContactUUID);
146 wxString strContactUUID(sstContactUUID.c_str(), wxConvUTF8);
147 UIDToken = strContactUUID;*/
148 UIDToken = GenerateUUID();
149 UIDToken = UIDToken.MakeUpper();
152 FilenameFinal = wxSContactFilename;
156 // Setup the data and write it into the account folder.
158 // Begin preperations to write the contact to a file.
160 bool boolValue = FALSE;
161 bool boolValue2 = FALSE;
163 bool NNGeneralFirst = TRUE;
164 bool NNHomeFirst = TRUE;
165 bool NNWorkFirst = TRUE;
167 std::map<int,int>::iterator intiter;
168 std::map<int,wxString>::iterator striter;
170 ContactData.Add(wxT("BEGIN"), wxT("VCARD"), FALSE);
171 ContactData.Add(wxT("VERSION"), wxT("4.0"), FALSE);
173 // Setup the version string.
175 strValue.Append(wxT("-//Xestia//Address Book Version "));
176 strValue.Append(wxT(XSDAB_VERSION));
177 strValue.Append(wxT("//KW"));
179 ContactData.Add(wxT("PRODID"), strValue, FALSE);
185 // Setup the name field.
187 strValue = txtSurname->GetValue() + wxT(";") +
188 txtForename->GetValue() + wxT(";") +
189 txtOtherNames->GetValue() + wxT(";") +
190 txtTitle->GetValue() + wxT(";") +
191 txtSuffix->GetValue();
193 strValue2 = ContactData.Convert(cmbDisplayAs->GetValue(), FALSE);
196 if (NameTokens.IsEmpty()){
197 ContactData.Add(wxT("N;SORT-AS=\"") + strValue2 + wxT("\""), strValue, FALSE);
199 ContactData.Add(wxT("N;SORT-AS=\"") + strValue2 + wxT("\";") + NameTokens, strValue, FALSE);
202 if (cmbType->GetCurrentSelection() == 1){
204 ContactData.AddRaw(wxT("KIND"), wxT("individual"));
206 } else if (cmbType->GetCurrentSelection() == 2){
208 ContactData.AddRaw(wxT("KIND"), wxT("group"));
210 // Go through each of the members and write them out.
212 for (std::map<int, wxString>::iterator itemiter = GroupsList.begin();
213 itemiter != GroupsList.end(); ++itemiter){
215 ContactData.Add(wxT("MEMBER:urn:uuid"), itemiter->second, FALSE);
219 } else if (cmbType->GetCurrentSelection() == 3){
221 ContactData.AddRaw(wxT("KIND"), wxT("org"));
223 } else if (cmbType->GetCurrentSelection() == 4){
225 ContactData.AddRaw(wxT("KIND"), wxT("location"));
230 // Setup the nicknames (General, Home & Business).
243 if (cmbGender->GetCurrentSelection() != 0){
245 switch(cmbGender->GetCurrentSelection()){
276 if (!txtGenderDescription->IsEmpty()){
278 strValue2 = txtGenderDescription->GetValue();
282 if (!strValue.IsEmpty() || !strValue2.IsEmpty()){
284 EscapeString(&strValue2, FALSE);
286 if (!GenderTokens.IsEmpty()){
288 if (!strValue2.IsEmpty()){
290 ContactData.AddRaw(wxT("GENDER;") + GenderTokens, strValue + wxT(";") + strValue2);
294 ContactData.AddRaw(wxT("GENDER;") + GenderTokens, strValue);
300 if (!strValue2.IsEmpty()){
302 ContactData.AddRaw(wxT("GENDER"), strValue + wxT(";") + strValue2);
306 ContactData.AddRaw(wxT("GENDER"), strValue);
325 strValue3 = BirthdayAltID;
327 if (!strValue3.IsEmpty()){
332 strValue2.Append(wxT("ALTID=\"") + strValue3 + wxT("\""));
338 //strValue3 = ContactData.Convert(GeneralAddressList, FALSE);
343 strValue3 = BirthdayCalScale;
345 if (!strValue3.IsEmpty()){
350 if (boolValue2 == TRUE){
352 strValue2.Append(wxT(";"));
360 strValue2.Append(wxT("CALSCALE=") + strValue3);
368 strValue2 = BirthdayTokens;
370 // Get the birthday and write it.
372 ResetSaveProcessData();
374 if (!txtBirthday->IsEmpty()){
376 strValue = txtBirthday->GetValue();
378 if (!strValue.IsEmpty() || !strValue2.IsEmpty()){
380 if (!strValue2.IsEmpty()){
382 EscapeString(&strValue2, FALSE);
383 EscapeString(&strValue, FALSE);
385 ContactData.AddRaw(wxT("BDAY;VALUE=text;") + strValue2 + wxT(";"), strValue);
389 EscapeString(&strValue, FALSE);
391 ContactData.AddRaw(wxT("BDAY;VALUE=text"), strValue);
401 // Get Day, Month & Year.
403 wxDateTime BirthdayDate;
404 wxDateTime::Month BirthdayMonth;
407 wxString DataBeforeT;
409 wxString FinalBirthdayString;
410 bool ProcessDataAfterT = FALSE;
412 BirthdayDate = dapBirthday->GetValue();
414 if (BirthdayDate.IsValid()){
416 BirthdayDay = BirthdayDate.GetDay();
417 BirthdayMonth = BirthdayDate.GetMonth();
418 BirthdayYear = BirthdayDate.GetYear();
420 // Look for T and replace data before this.
422 wxStringTokenizer wSTDate(Birthday, wxT("T"));
424 while (wSTDate.HasMoreTokens()){
426 if (ProcessDataAfterT == FALSE){
428 DataBeforeT = wSTDate.GetNextToken();
429 ProcessDataAfterT = TRUE;
433 DataAfterT = wSTDate.GetNextToken();
440 // If there is not T then replace altogether.
442 wxString FinalBirthdayDay;
443 wxString FinalBirthdayMonth;
444 wxString FinalBirthdayYear;
446 if (BirthdayDay < 10){
448 FinalBirthdayDay = wxT("0") + wxString::Format(wxT("%i"), BirthdayDay);
452 FinalBirthdayDay = wxString::Format(wxT("%i"), BirthdayDay);
456 if (((int)BirthdayMonth + 1) < 10){
458 FinalBirthdayMonth = wxT("0") + wxString::Format(wxT("%i"), ((int)BirthdayMonth + 1));
462 FinalBirthdayMonth = wxString::Format(wxT("%i"), ((int)BirthdayMonth + 1));
466 if (BirthdayYear == 0){
468 FinalBirthdayYear = wxT("--");
472 FinalBirthdayYear = wxString::Format(wxT("%i"), BirthdayYear);
476 if (!DataAfterT.IsEmpty()){
478 FinalBirthdayString = FinalBirthdayYear + FinalBirthdayMonth + FinalBirthdayDay + wxT("T") + DataAfterT;
482 FinalBirthdayString = FinalBirthdayYear + FinalBirthdayMonth + FinalBirthdayDay;
486 if (!FinalBirthdayString.IsEmpty() || !strValue2.IsEmpty()){
488 if (!strValue2.IsEmpty()){
490 EscapeString(&strValue2, FALSE);
491 EscapeString(&strValue, FALSE);
493 ContactData.AddRaw(wxT("BDAY") + strValue2 + wxT(";"), FinalBirthdayString);
497 EscapeString(&strValue, FALSE);
499 ContactData.AddRaw(wxT("BDAY"), FinalBirthdayString);
509 ResetSaveProcessData();
513 strValue3 = AnniversaryAltID;
515 if (!strValue3.IsEmpty()){
520 strValue2.Append(wxT("ALTID=\"") + strValue3 + wxT("\""));
526 //strValue3 = ContactData.Convert(GeneralAddressList, FALSE);
531 strValue3 = AnniversaryCalScale;
533 if (!strValue3.IsEmpty()){
538 if (boolValue2 == TRUE){
540 strValue2.Append(wxT(";"));
548 strValue2.Append(wxT("CALSCALE=") + strValue3);
556 strValue2 = AnniversaryTokens;
558 // Deal with ANNIVERSARY.
560 if (!txtAnniversary->IsEmpty()){
562 strValue = txtAnniversary->GetValue();
564 if (!strValue.IsEmpty() || !strValue2.IsEmpty()){
566 if (!strValue2.IsEmpty()){
568 EscapeString(&strValue2, FALSE);
569 EscapeString(&strValue, FALSE);
571 ContactData.AddRaw(wxT("ANNIVERSARY;VALUE=text;") + strValue2 + wxT(";"), strValue);
575 EscapeString(&strValue, FALSE);
577 ContactData.AddRaw(wxT("ANNIVERSARY;VALUE=text"), strValue);
585 // Look for T and replace data before this.
587 // Get Day, Month & Year.
589 wxDateTime AnniversaryDate;
590 wxDateTime::Month AnniversaryMonth;
593 wxString DataBeforeT;
595 wxString FinalAnniversaryString;
596 bool ProcessDataAfterT = FALSE;
598 AnniversaryDate = dapAnniversary->GetValue();
600 if (AnniversaryDate.IsValid()){
602 AnniversaryDay = AnniversaryDate.GetDay();
603 AnniversaryMonth = AnniversaryDate.GetMonth();
604 AnniversaryYear = AnniversaryDate.GetYear();
606 // Look for T and replace data before this.
608 wxStringTokenizer wSTDate(Anniversary, wxT("T"));
610 while (wSTDate.HasMoreTokens()){
612 if (ProcessDataAfterT == FALSE){
614 DataBeforeT = wSTDate.GetNextToken();
615 ProcessDataAfterT = TRUE;
619 DataAfterT = wSTDate.GetNextToken();
626 // If there is not T then replace altogether.
628 wxString FinalAnniversaryDay;
629 wxString FinalAnniversaryMonth;
630 wxString FinalAnniversaryYear;
632 if (AnniversaryDay < 10){
634 FinalAnniversaryDay = wxT("0") + wxString::Format(wxT("%i"), AnniversaryDay);
638 FinalAnniversaryDay = wxString::Format(wxT("%i"), AnniversaryDay);
642 if (((int)AnniversaryMonth + 1) < 10){
644 FinalAnniversaryMonth = wxT("0") + wxString::Format(wxT("%i"), ((int)AnniversaryMonth + 1));
648 FinalAnniversaryMonth = wxString::Format(wxT("%i"), ((int)AnniversaryMonth + 1));
652 if (AnniversaryYear == 0){
654 FinalAnniversaryYear = wxT("--");
658 FinalAnniversaryYear = wxString::Format(wxT("%i"), AnniversaryYear);
662 if (!DataAfterT.IsEmpty()){
664 FinalAnniversaryString = FinalAnniversaryYear + FinalAnniversaryMonth + FinalAnniversaryDay + wxT("T") + DataAfterT;
668 FinalAnniversaryString = FinalAnniversaryYear + FinalAnniversaryMonth + FinalAnniversaryDay;
672 if (!FinalAnniversaryString.IsEmpty() || !strValue2.IsEmpty()){
674 if (!strValue2.IsEmpty()){
676 EscapeString(&strValue2, FALSE);
677 EscapeString(&strValue, FALSE);
679 ContactData.AddRaw(wxT("ANNIVERSARY") + strValue2 + wxT(";"), FinalAnniversaryString);
683 EscapeString(&strValue, FALSE);
685 ContactData.AddRaw(wxT("ANNIVERSARY"), FinalAnniversaryString);
695 // Setup the addresses (General, Home, Business).
697 //intValue = GeneralAddressList.size();
698 ResetSaveProcessData();
700 for (std::map<int,wxString>::iterator iter = GeneralAddressList.begin();
701 iter != GeneralAddressList.end(); ++iter){
703 int intSeekValue = iter->first;
705 wxString strAddressString;
706 wxString strAddressFinalValue;
707 std::map<int, wxString>::iterator iterValue;
709 strAddressString.Append(wxT(";;"));
713 iterValue = GeneralAddressList.find(intSeekValue);
714 strAddressFinalValue = iterValue->second;
715 ProcessCaptureStrings(&strAddressFinalValue);
716 strAddressString.Append(strAddressFinalValue + wxT(";"));
717 strAddressFinalValue.Clear();
721 iterValue = GeneralAddressListTown.find(intSeekValue);
722 strAddressFinalValue = iterValue->second;
723 ProcessCaptureStrings(&strAddressFinalValue);
724 strAddressString.Append(strAddressFinalValue + wxT(";"));
725 strAddressFinalValue.Clear();
729 iterValue = GeneralAddressListCounty.find(intSeekValue);
730 strAddressFinalValue = iterValue->second;
731 ProcessCaptureStrings(&strAddressFinalValue);
732 strAddressString.Append(strAddressFinalValue + wxT(";"));
733 strAddressFinalValue.Clear();
737 iterValue = GeneralAddressListPostCode.find(intSeekValue);
738 strAddressFinalValue = iterValue->second;
739 ProcessCaptureStrings(&strAddressFinalValue);
740 strAddressString.Append(strAddressFinalValue + wxT(";"));
741 strAddressFinalValue.Clear();
745 iterValue = GeneralAddressListCountry.find(intSeekValue);
746 strAddressFinalValue = iterValue->second;
747 ProcessCaptureStrings(&strAddressFinalValue);
748 strAddressString.Append(strAddressFinalValue);
749 strAddressFinalValue.Clear();
751 ProcessSaveData(wxT("ADR"), &strValue2, &boolValue2, &boolValue,
752 &iter, &strAddressString, &ContactData,
753 wxT("LABEL"), &GeneralAddressListLabel,
754 wxT("LANGUAGE"), &GeneralAddressListLang,
755 wxT("ALTID"), &GeneralAddressListAltID,
756 wxT("PID"), &GeneralAddressListPID,
757 wxT("GEO"), &GeneralAddressListGeo,
758 wxT("TZ"), &GeneralAddressListTimezone,
759 wxT("MEDIATYPE"), &GeneralAddressListMediatype,
760 wxT("PREF"), &GeneralAddressListPref,
761 wxT(""), &GeneralAddressListTokens );
763 ResetSaveProcessData();
767 ResetSaveProcessData();
769 for (std::map<int,wxString>::iterator iter = HomeAddressList.begin();
770 iter != HomeAddressList.end(); ++iter){
772 int intSeekValue = iter->first;
774 wxString strAddressString;
775 wxString strAddressFinalValue;
776 std::map<int, wxString>::iterator iterValue;
778 strAddressString.Append(wxT(";;"));
782 iterValue = HomeAddressList.find(intSeekValue);
783 strAddressFinalValue = iterValue->second;
784 ProcessCaptureStrings(&strAddressFinalValue);
786 strAddressString.Append(strAddressFinalValue + wxT(";"));
790 iterValue = HomeAddressListTown.find(intSeekValue);
791 strAddressFinalValue = iterValue->second;
792 ProcessCaptureStrings(&strAddressFinalValue);
794 strAddressString.Append(strAddressFinalValue + wxT(";"));
798 iterValue = HomeAddressListCounty.find(intSeekValue);
799 strAddressFinalValue = iterValue->second;
800 ProcessCaptureStrings(&strAddressFinalValue);
802 strAddressString.Append(strAddressFinalValue + wxT(";"));
806 iterValue = HomeAddressListPostCode.find(intSeekValue);
807 strAddressFinalValue = iterValue->second;
808 ProcessCaptureStrings(&strAddressFinalValue);
810 strAddressString.Append(strAddressFinalValue + wxT(";"));
814 iterValue = HomeAddressListCountry.find(intSeekValue);
815 strAddressFinalValue = iterValue->second;
816 ProcessCaptureStrings(&strAddressFinalValue);
818 strAddressString.Append(strAddressFinalValue);
820 ProcessSaveData(wxT("ADR;TYPE=home"), &strValue2, &boolValue2, &boolValue,
821 &iter, &strAddressString, &ContactData,
822 wxT("LABEL"), &HomeAddressListLabel,
823 wxT("LANGUAGE"), &HomeAddressListLang,
824 wxT("ALTID"), &HomeAddressListAltID,
825 wxT("PID"), &HomeAddressListPID,
826 wxT("GEO"), &HomeAddressListGeo,
827 wxT("TZ"), &HomeAddressListTimezone,
828 wxT("MEDIATYPE"), &HomeAddressListMediatype,
829 wxT("PREF"), &HomeAddressListPref,
830 wxT(""), &HomeAddressListTokens );
832 ResetSaveProcessData();
836 ResetSaveProcessData();
838 for (std::map<int,wxString>::iterator iter = BusinessAddressList.begin();
839 iter != BusinessAddressList.end(); ++iter){
841 int intSeekValue = iter->first;
843 wxString strAddressString;
844 wxString strAddressFinalValue;
845 std::map<int, wxString>::iterator iterValue;
847 strAddressString.Append(wxT(";;"));
851 iterValue = BusinessAddressList.find(intSeekValue);
852 strAddressFinalValue = iterValue->second;
853 ProcessCaptureStrings(&strAddressFinalValue);
855 strAddressString.Append(strAddressFinalValue + wxT(";"));
859 iterValue = BusinessAddressListTown.find(intSeekValue);
860 strAddressFinalValue = iterValue->second;
861 ProcessCaptureStrings(&strAddressFinalValue);
863 strAddressString.Append(strAddressFinalValue + wxT(";"));
867 iterValue = BusinessAddressListCounty.find(intSeekValue);
868 strAddressFinalValue = iterValue->second;
869 ProcessCaptureStrings(&strAddressFinalValue);
871 strAddressString.Append(strAddressFinalValue + wxT(";"));
875 iterValue = BusinessAddressListPostCode.find(intSeekValue);
876 strAddressFinalValue = iterValue->second;
877 ProcessCaptureStrings(&strAddressFinalValue);
879 strAddressString.Append(strAddressFinalValue + wxT(";"));
883 iterValue = BusinessAddressListCountry.find(intSeekValue);
884 strAddressFinalValue = iterValue->second;
885 ProcessCaptureStrings(&strAddressFinalValue);
887 strAddressString.Append(strAddressFinalValue);
889 ProcessSaveData(wxT("ADR;TYPE=work"), &strValue2, &boolValue2, &boolValue,
890 &iter, &strAddressString, &ContactData,
891 wxT("LABEL"), &BusinessAddressListLabel,
892 wxT("LANGUAGE"), &BusinessAddressListLang,
893 wxT("ALTID"), &BusinessAddressListAltID,
894 wxT("PID"), &BusinessAddressListPID,
895 wxT("GEO"), &BusinessAddressListGeo,
896 wxT("TZ"), &BusinessAddressListTimezone,
897 wxT("MEDIATYPE"), &BusinessAddressListMediatype,
898 wxT("PREF"), &BusinessAddressListPref,
899 wxT(""), &BusinessAddressListTokens );
901 ResetSaveProcessData();
905 // Sort out nicknames (if any).
907 for (std::map<int,wxString>::iterator iter = GeneralNicknamesList.begin();
908 iter != GeneralNicknamesList.end(); ++iter){
910 intValue2 = iter->first;
912 // Process Alternative ID.
914 ProcessSaveData(wxT("NICKNAME"), &strValue2, &boolValue2, &boolValue,
915 &iter, &GeneralNicknamesList, &ContactData,
916 wxT("LANGUAGE"), &GeneralNicknamesListLanguage,
917 wxT("ALTID"), &GeneralNicknamesListAltID,
918 wxT("PID"), &GeneralNicknamesListPID,
919 wxT("PREF"), &GeneralNicknamesListPref,
920 wxT(""), &GeneralNicknamesListTokens );
922 ResetSaveProcessData();
926 ResetSaveProcessData();
928 for (std::map<int,wxString>::iterator iter = HomeNicknamesList.begin();
929 iter != HomeNicknamesList.end(); ++iter){
931 ProcessSaveData(wxT("NICKNAME;TYPE=home"), &strValue2, &boolValue2, &boolValue,
932 &iter, &HomeNicknamesList, &ContactData,
933 wxT("LANGUAGE"), &HomeNicknamesListLanguage,
934 wxT("ALTID"), &HomeNicknamesListAltID,
935 wxT("PID"), &HomeNicknamesListPID,
936 wxT("PREF"), &HomeNicknamesListPref,
937 wxT(""), &HomeNicknamesListTokens );
939 ResetSaveProcessData();
943 ResetSaveProcessData();
945 for (std::map<int,wxString>::iterator iter = BusinessNicknamesList.begin();
946 iter != BusinessNicknamesList.end(); ++iter){
948 ProcessSaveData(wxT("NICKNAME;TYPE=work"), &strValue2, &boolValue2, &boolValue,
949 &iter, &BusinessNicknamesList, &ContactData,
950 wxT("LANGUAGE"), &BusinessNicknamesListLanguage,
951 wxT("ALTID"), &BusinessNicknamesListAltID,
952 wxT("PID"), &BusinessNicknamesListPID,
953 wxT("PREF"), &BusinessNicknamesListPref,
954 wxT(""), &BusinessNicknamesListTokens );
956 ResetSaveProcessData();
960 ResetSaveProcessData();
962 // Sort out email (general, home and business).
964 for (std::map<int,wxString>::iterator iter = GeneralEmailList.begin();
965 iter != GeneralEmailList.end(); ++iter){
967 //strValue3 = ContactData.Convert(GeneralAddressList, FALSE);
970 wxString strAddressFinalValue;
971 std::map<int, wxString>::iterator iterValue;
973 ProcessSaveData(wxT("EMAIL"), &strValue2, &boolValue2, &boolValue,
974 &iter, &GeneralEmailList, &ContactData,
975 wxT("ALTID"), &GeneralEmailListAltID,
976 wxT("PID"), &GeneralEmailListPID,
977 wxT("PREF"), &GeneralEmailListPref,
978 wxT(""), &GeneralEmailListTokens );
980 ResetSaveProcessData();
984 ResetSaveProcessData();
986 for (std::map<int,wxString>::iterator iter = HomeEmailList.begin();
987 iter != HomeEmailList.end(); ++iter){
989 //strValue3 = ContactData.Convert(GeneralAddressList, FALSE);
992 ProcessSaveData(wxT("EMAIL;TYPE=home"), &strValue2, &boolValue2, &boolValue,
993 &iter, &HomeEmailList, &ContactData,
994 wxT("ALTID"), &HomeEmailListAltID,
995 wxT("PID"), &HomeEmailListPID,
996 wxT("PREF"), &HomeEmailListPref,
997 wxT(""), &HomeEmailListTokens );
999 ResetSaveProcessData();
1003 ResetSaveProcessData();
1005 for (std::map<int,wxString>::iterator iter = BusinessEmailList.begin();
1006 iter != BusinessEmailList.end(); ++iter){
1008 //strValue3 = ContactData.Convert(GeneralAddressList, FALSE);
1011 ProcessSaveData(wxT("EMAIL;TYPE=work"), &strValue2, &boolValue2, &boolValue,
1012 &iter, &BusinessEmailList, &ContactData,
1013 wxT("ALTID"), &BusinessEmailListAltID,
1014 wxT("PID"), &BusinessEmailListPID,
1015 wxT("PREF"), &BusinessEmailListPref,
1016 wxT(""), &BusinessEmailListTokens );
1018 ResetSaveProcessData();
1022 ResetSaveProcessData();
1024 for (std::map<int,wxString>::iterator iter = GeneralIMList.begin();
1025 iter != GeneralIMList.end(); ++iter){
1027 intValue2 = iter->first;
1029 // Process Alternative ID.
1031 ProcessSaveData(wxT("IMPP"), &strValue2, &boolValue2, &boolValue,
1032 &iter, &GeneralIMList, &ContactData,
1033 wxT("ALTID"), &GeneralIMListAltID,
1034 wxT("PID"), &GeneralIMListPID,
1035 wxT("MEDIATYPE"), &GeneralIMListMediatype,
1036 wxT("PREF"), &GeneralIMListPref,
1037 wxT(""), &GeneralIMListTokens );
1039 ResetSaveProcessData();
1043 ResetSaveProcessData();
1045 for (std::map<int,wxString>::iterator iter = HomeIMList.begin();
1046 iter != HomeIMList.end(); ++iter){
1048 ProcessSaveData(wxT("IMPP;TYPE=home"), &strValue2, &boolValue2, &boolValue,
1049 &iter, &HomeIMList, &ContactData,
1050 wxT("ALTID"), &HomeIMListAltID,
1051 wxT("PID"), &HomeIMListPID,
1052 wxT("MEDIATYPE"), &HomeIMListMediatype,
1053 wxT("PREF"), &HomeIMListPref,
1054 wxT(""), &HomeIMListTokens );
1056 ResetSaveProcessData();
1060 ResetSaveProcessData();
1062 for (std::map<int,wxString>::iterator iter = BusinessIMList.begin();
1063 iter != BusinessIMList.end(); ++iter){
1065 ProcessSaveData(wxT("IMPP;TYPE=work"), &strValue2, &boolValue2, &boolValue,
1066 &iter, &BusinessIMList, &ContactData,
1067 wxT("ALTID"), &BusinessIMListAltID,
1068 wxT("PID"), &BusinessIMListPID,
1069 wxT("MEDIATYPE"), &BusinessIMListMediatype,
1070 wxT("PREF"), &BusinessIMListPref,
1071 wxT(""), &BusinessIMListTokens );
1073 ResetSaveProcessData();
1077 ResetSaveProcessData();
1079 for (std::map<int,wxString>::iterator iter = GeneralTelephoneList.begin();
1080 iter != GeneralTelephoneList.end(); ++iter){
1082 wxString strAddressFinalValue = iter->second;
1084 ProcessCaptureStrings(&strAddressFinalValue);
1086 strAddressFinalValue.insert(0, wxT("tel:"));
1088 ProcessSaveData(wxT("TEL"), &strValue2, &boolValue2, &boolValue,
1089 &iter, &strAddressFinalValue, &ContactData,
1090 wxT("ALTID"), &GeneralTelephoneListAltID,
1091 wxT("PID"), &GeneralTelephoneListPID,
1092 wxT("TYPE"), &GeneralTelephoneListType,
1093 wxT("PREF"), &GeneralTelephoneListPref,
1094 wxT(""), &GeneralTelephoneListTokens );
1096 ResetSaveProcessData();
1100 ResetSaveProcessData();
1102 for (std::map<int,wxString>::iterator iter = HomeTelephoneList.begin();
1103 iter != HomeTelephoneList.end(); ++iter){
1105 wxString strAddressFinalValue = iter->second;
1107 ProcessCaptureStrings(&strAddressFinalValue);
1109 strAddressFinalValue.insert(0, wxT("tel:"));
1111 ProcessSaveData(wxT("TEL"), &strValue2, &boolValue2, &boolValue,
1112 &iter, &strAddressFinalValue, &ContactData,
1113 wxT("ALTID"), &HomeTelephoneListAltID,
1114 wxT("PID"), &HomeTelephoneListPID,
1115 wxT("TYPE"), &HomeTelephoneListType,
1116 wxT("PREF"), &HomeTelephoneListPref,
1117 wxT(""), &HomeTelephoneListTokens );
1119 ResetSaveProcessData();
1123 ResetSaveProcessData();
1125 for (std::map<int,wxString>::iterator iter = BusinessTelephoneList.begin();
1126 iter != BusinessTelephoneList.end(); ++iter){
1128 wxString strAddressFinalValue = iter->second;
1130 ProcessCaptureStrings(&strAddressFinalValue);
1132 strAddressFinalValue.insert(0, wxT("tel:"));
1134 ProcessSaveData(wxT("TEL"), &strValue2, &boolValue2, &boolValue,
1135 &iter, &strAddressFinalValue, &ContactData,
1136 wxT("ALTID"), &BusinessTelephoneListAltID,
1137 wxT("PID"), &BusinessTelephoneListPID,
1138 wxT("TYPE"), &BusinessTelephoneListType,
1139 wxT("PREF"), &BusinessTelephoneListPref,
1140 wxT(""), &BusinessTelephoneListTokens );
1142 ResetSaveProcessData();
1146 ResetSaveProcessData();
1148 for (std::map<int,wxString>::iterator iter = GeneralLanguageList.begin();
1149 iter != GeneralLanguageList.end(); ++iter){
1151 intValue2 = iter->first;
1153 ProcessSaveData(wxT("LANG"), &strValue2, &boolValue2, &boolValue,
1154 &iter, &GeneralLanguageList, &ContactData,
1155 wxT("ALTID"), &GeneralLanguageListAltID,
1156 wxT("PID"), &GeneralLanguageListPID,
1157 wxT("PREF"), &GeneralLanguageListPref,
1158 wxT(""), &GeneralLanguageListTokens );
1160 ResetSaveProcessData();
1164 ResetSaveProcessData();
1166 for (std::map<int,wxString>::iterator iter = HomeLanguageList.begin();
1167 iter != HomeLanguageList.end(); ++iter){
1169 ProcessSaveData(wxT("LANG;TYPE=home"), &strValue2, &boolValue2, &boolValue,
1170 &iter, &HomeLanguageList, &ContactData,
1171 wxT("ALTID"), &HomeLanguageListAltID,
1172 wxT("PID"), &HomeLanguageListPID,
1173 wxT("PREF"), &HomeLanguageListPref,
1174 wxT(""), &HomeLanguageListTokens );
1176 ResetSaveProcessData();
1180 ResetSaveProcessData();
1182 for (std::map<int,wxString>::iterator iter = BusinessLanguageList.begin();
1183 iter != BusinessLanguageList.end(); ++iter){
1185 ProcessSaveData(wxT("LANG;TYPE=work"), &strValue2, &boolValue2, &boolValue,
1186 &iter, &BusinessLanguageList, &ContactData,
1187 wxT("ALTID"), &BusinessLanguageListAltID,
1188 wxT("PID"), &BusinessLanguageListPID,
1189 wxT("PREF"), &BusinessLanguageListPref,
1190 wxT(""), &BusinessLanguageListTokens );
1192 ResetSaveProcessData();
1196 ResetSaveProcessData();
1198 for (std::map<int,wxString>::iterator iter = GeneralTZList.begin();
1199 iter != GeneralTZList.end(); ++iter){
1201 ProcessSaveData(wxT("TZ"), &strValue2, &boolValue2, &boolValue,
1202 &iter, &GeneralTZList, &ContactData,
1203 wxT("ALTID"), &GeneralTZListAltID,
1204 wxT("PID"), &GeneralTZListPID,
1205 wxT("MEDIATYPE"), &GeneralTZListMediatype,
1206 wxT("PREF"), &GeneralTZListPref,
1207 wxT(""), &GeneralTZListTokens );
1209 ResetSaveProcessData();
1213 ResetSaveProcessData();
1215 for (std::map<int,wxString>::iterator iter = HomeTZList.begin();
1216 iter != HomeTZList.end(); ++iter){
1218 ProcessSaveData(wxT("TZ;TYPE=home"), &strValue2, &boolValue2, &boolValue,
1219 &iter, &HomeTZList, &ContactData,
1220 wxT("ALTID"), &HomeTZListAltID,
1221 wxT("PID"), &HomeTZListPID,
1222 wxT("MEDIATYPE"), &HomeTZListMediatype,
1223 wxT("PREF"), &HomeTZListPref,
1224 wxT(""), &HomeTZListTokens );
1226 ResetSaveProcessData();
1230 ResetSaveProcessData();
1232 for (std::map<int,wxString>::iterator iter = BusinessTZList.begin();
1233 iter != BusinessTZList.end(); ++iter){
1235 ProcessSaveData(wxT("TZ;TYPE=work"), &strValue2, &boolValue2, &boolValue,
1236 &iter, &BusinessTZList, &ContactData,
1237 wxT("ALTID"), &BusinessTZListAltID,
1238 wxT("PID"), &BusinessTZListPID,
1239 wxT("MEDIATYPE"), &BusinessTZListMediatype,
1240 wxT("PREF"), &BusinessTZListPref,
1241 wxT(""), &BusinessTZListTokens );
1243 ResetSaveProcessData();
1247 ResetSaveProcessData();
1249 for (std::map<int,wxString>::iterator iter = GeneralGeographyList.begin();
1250 iter != GeneralGeographyList.end(); ++iter){
1252 wxString strAddressFinalValue = iter->second;
1254 ProcessCaptureStrings(&strAddressFinalValue);
1256 strAddressFinalValue.insert(0, wxT("geo:"));
1258 ProcessSaveData(wxT("GEO"), &strValue2, &boolValue2, &boolValue,
1259 &iter, &strAddressFinalValue, &ContactData,
1260 wxT("ALTID"), &GeneralGeographyListAltID,
1261 wxT("PID"), &GeneralGeographyListPID,
1262 wxT("MEDIATYPE"), &GeneralGeographyListMediatype,
1263 wxT("PREF"), &GeneralGeographyListPref,
1264 wxT(""), &GeneralGeographyListTokens );
1266 ResetSaveProcessData();
1270 ResetSaveProcessData();
1272 for (std::map<int,wxString>::iterator iter = HomeGeographyList.begin();
1273 iter != HomeGeographyList.end(); ++iter){
1275 wxString strAddressFinalValue = iter->second;
1277 ProcessCaptureStrings(&strAddressFinalValue);
1279 strAddressFinalValue.insert(0, wxT("geo:"));
1281 ProcessSaveData(wxT("GEO;TYPE=home"), &strValue2, &boolValue2, &boolValue,
1282 &iter, &HomeGeographyList, &ContactData,
1283 wxT("ALTID"), &HomeGeographyListAltID,
1284 wxT("PID"), &HomeGeographyListPID,
1285 wxT("MEDIATYPE"), &HomeGeographyListMediatype,
1286 wxT("PREF"), &HomeGeographyListPref,
1287 wxT(""), &HomeGeographyListTokens );
1289 ResetSaveProcessData();
1293 ResetSaveProcessData();
1295 for (std::map<int,wxString>::iterator iter = BusinessGeographyList.begin();
1296 iter != BusinessGeographyList.end(); ++iter){
1298 wxString strAddressFinalValue = iter->second;
1300 ProcessCaptureStrings(&strAddressFinalValue);
1302 strAddressFinalValue.insert(0, wxT("geo:"));
1304 ProcessSaveData(wxT("GEO;TYPE=work"), &strValue2, &boolValue2, &boolValue,
1305 &iter, &BusinessGeographyList, &ContactData,
1306 wxT("ALTID"), &BusinessGeographyListAltID,
1307 wxT("PID"), &BusinessGeographyListPID,
1308 wxT("MEDIATYPE"), &BusinessGeographyListMediatype,
1309 wxT("PREF"), &BusinessGeographyListPref,
1310 wxT(""), &BusinessGeographyListTokens );
1312 ResetSaveProcessData();
1316 ResetSaveProcessData();
1318 for (std::map<int,wxString>::iterator iter = GeneralRelatedList.begin();
1319 iter != GeneralRelatedList.end(); ++iter){
1321 ProcessSaveData(wxT("RELATED"), &strValue2, &boolValue2, &boolValue,
1322 &iter, &GeneralRelatedList, &ContactData,
1323 wxT("ALTID"), &GeneralRelatedListAltID,
1324 wxT("PID"), &GeneralRelatedListPID,
1325 wxT("LANGUAGE"), &GeneralRelatedListLanguage,
1326 wxT("TYPE"), &GeneralRelatedListRelType,
1327 wxT("PREF"), &GeneralRelatedListPref,
1328 wxT(""), &GeneralRelatedListTokens );
1330 ResetSaveProcessData();
1334 ResetSaveProcessData();
1336 for (std::map<int,wxString>::iterator iter = GeneralWebsiteList.begin();
1337 iter != GeneralWebsiteList.end(); ++iter){
1339 ProcessSaveData(wxT("URL"), &strValue2, &boolValue2, &boolValue,
1340 &iter, &GeneralWebsiteList, &ContactData,
1341 wxT("ALTID"), &GeneralWebsiteListAltID,
1342 wxT("PID"), &GeneralWebsiteListPID,
1343 wxT("MEDIATYPE"), &GeneralWebsiteListMediatype,
1344 wxT("PREF"), &GeneralWebsiteListPref,
1345 wxT(""), &GeneralWebsiteListTokens );
1347 ResetSaveProcessData();
1351 ResetSaveProcessData();
1353 for (std::map<int,wxString>::iterator iter = HomeWebsiteList.begin();
1354 iter != HomeWebsiteList.end(); ++iter){
1356 ProcessSaveData(wxT("URL;TYPE=home"), &strValue2, &boolValue2, &boolValue,
1357 &iter, &HomeWebsiteList, &ContactData,
1358 wxT("ALTID"), &HomeWebsiteListAltID,
1359 wxT("PID"), &HomeWebsiteListPID,
1360 wxT("MEDIATYPE"), &HomeWebsiteListMediatype,
1361 wxT("PREF"), &HomeWebsiteListPref,
1362 wxT(""), &HomeWebsiteListTokens );
1364 ResetSaveProcessData();
1368 ResetSaveProcessData();
1370 for (std::map<int,wxString>::iterator iter = BusinessWebsiteList.begin();
1371 iter != BusinessWebsiteList.end(); ++iter){
1373 ProcessSaveData(wxT("URL;TYPE=work"), &strValue2, &boolValue2, &boolValue,
1374 &iter, &BusinessWebsiteList, &ContactData,
1375 wxT("ALTID"), &BusinessWebsiteListAltID,
1376 wxT("PID"), &BusinessWebsiteListPID,
1377 wxT("MEDIATYPE"), &BusinessWebsiteListMediatype,
1378 wxT("PREF"), &BusinessWebsiteListPref,
1379 wxT(""), &BusinessWebsiteListTokens );
1381 ResetSaveProcessData();
1385 ResetSaveProcessData();
1387 for (std::map<int,wxString>::iterator iter = GeneralTitleList.begin();
1388 iter != GeneralTitleList.end(); ++iter){
1390 ProcessSaveData(wxT("TITLE"), &strValue2, &boolValue2, &boolValue,
1391 &iter, &GeneralTitleList, &ContactData,
1392 wxT("ALTID"), &GeneralTitleListAltID,
1393 wxT("PID"), &GeneralTitleListPID,
1394 wxT("LANGUAGE"), &GeneralTitleListLanguage,
1395 wxT("PREF"), &GeneralTitleListPref,
1396 wxT(""), &GeneralTitleListTokens );
1398 ResetSaveProcessData();
1402 ResetSaveProcessData();
1404 for (std::map<int,wxString>::iterator iter = HomeTitleList.begin();
1405 iter != HomeTitleList.end(); ++iter){
1407 ProcessSaveData(wxT("TITLE;TYPE=home"), &strValue2, &boolValue2, &boolValue,
1408 &iter, &HomeTitleList, &ContactData,
1409 wxT("ALTID"), &HomeTitleListAltID,
1410 wxT("PID"), &HomeTitleListPID,
1411 wxT("LANGUAGE"), &HomeTitleListLanguage,
1412 wxT("PREF"), &HomeTitleListPref,
1413 wxT(""), &HomeTitleListTokens );
1415 ResetSaveProcessData();
1419 ResetSaveProcessData();
1421 for (std::map<int,wxString>::iterator iter = BusinessTitleList.begin();
1422 iter != BusinessTitleList.end(); ++iter){
1424 ProcessSaveData(wxT("TITLE;TYPE=work"), &strValue2, &boolValue2, &boolValue,
1425 &iter, &BusinessTitleList, &ContactData,
1426 wxT("ALTID"), &BusinessTitleListAltID,
1427 wxT("PID"), &BusinessTitleListPID,
1428 wxT("LANGUAGE"), &BusinessTitleListLanguage,
1429 wxT("PREF"), &BusinessTitleListPref,
1430 wxT(""), &BusinessTitleListTokens );
1432 ResetSaveProcessData();
1436 ResetSaveProcessData();
1438 for (std::map<int,wxString>::iterator iter = GeneralRoleList.begin();
1439 iter != GeneralRoleList.end(); ++iter){
1441 ProcessSaveData(wxT("ROLE"), &strValue2, &boolValue2, &boolValue,
1442 &iter, &GeneralRoleList, &ContactData,
1443 wxT("ALTID"), &GeneralRoleListAltID,
1444 wxT("PID"), &GeneralRoleListPID,
1445 wxT("LANGUAGE"), &GeneralRoleListLanguage,
1446 wxT("PREF"), &GeneralRoleListPref,
1447 wxT(""), &GeneralRoleListTokens );
1449 ResetSaveProcessData();
1453 ResetSaveProcessData();
1455 for (std::map<int,wxString>::iterator iter = HomeRoleList.begin();
1456 iter != HomeRoleList.end(); ++iter){
1458 ProcessSaveData(wxT("ROLE;TYPE=home"), &strValue2, &boolValue2, &boolValue,
1459 &iter, &HomeRoleList, &ContactData,
1460 wxT("ALTID"), &HomeRoleListAltID,
1461 wxT("PID"), &HomeRoleListPID,
1462 wxT("LANGUAGE"), &HomeRoleListLanguage,
1463 wxT("PREF"), &HomeRoleListPref,
1464 wxT(""), &HomeRoleListTokens );
1466 ResetSaveProcessData();
1470 ResetSaveProcessData();
1472 for (std::map<int,wxString>::iterator iter = BusinessRoleList.begin();
1473 iter != BusinessRoleList.end(); ++iter){
1475 ProcessSaveData(wxT("ROLE;TYPE=work"), &strValue2, &boolValue2, &boolValue,
1476 &iter, &BusinessRoleList, &ContactData,
1477 wxT("ALTID"), &BusinessRoleListAltID,
1478 wxT("PID"), &BusinessRoleListPID,
1479 wxT("LANGUAGE"), &BusinessRoleListLanguage,
1480 wxT("PREF"), &BusinessRoleListPref,
1481 wxT(""), &BusinessRoleListTokens );
1483 ResetSaveProcessData();
1487 ResetSaveProcessData();
1489 for (std::map<int,wxString>::iterator iter = GeneralOrganisationsList.begin();
1490 iter != GeneralOrganisationsList.end(); ++iter){
1492 ProcessSaveData(wxT("ORG"), &strValue2, &boolValue2, &boolValue,
1493 &iter, &GeneralOrganisationsList, &ContactData,
1494 wxT("ALTID"), &GeneralOrganisationsListAltID,
1495 wxT("PID"), &GeneralOrganisationsListPID,
1496 wxT("LANGUAGE"), &GeneralOrganisationsListLanguage,
1497 wxT("SORT-AS"), &GeneralOrganisationsListSortAs,
1498 wxT("PREF"), &GeneralOrganisationsListPref,
1499 wxT(""), &GeneralOrganisationsListTokens );
1501 ResetSaveProcessData();
1505 ResetSaveProcessData();
1507 for (std::map<int,wxString>::iterator iter = HomeOrganisationsList.begin();
1508 iter != HomeOrganisationsList.end(); ++iter){
1510 ProcessSaveData(wxT("ORG;TYPE=home"), &strValue2, &boolValue2, &boolValue,
1511 &iter, &HomeOrganisationsList, &ContactData,
1512 wxT("ALTID"), &HomeOrganisationsListAltID,
1513 wxT("PID"), &HomeOrganisationsListPID,
1514 wxT("LANGUAGE"), &HomeOrganisationsListLanguage,
1515 wxT("SORT-AS"), &HomeOrganisationsListSortAs,
1516 wxT("PREF"), &HomeOrganisationsListPref,
1517 wxT(""), &HomeOrganisationsListTokens );
1519 ResetSaveProcessData();
1523 ResetSaveProcessData();
1525 for (std::map<int,wxString>::iterator iter = BusinessOrganisationsList.begin();
1526 iter != BusinessOrganisationsList.end(); ++iter){
1528 ProcessSaveData(wxT("ORG;TYPE=work"), &strValue2, &boolValue2, &boolValue,
1529 &iter, &BusinessOrganisationsList, &ContactData,
1530 wxT("ALTID"), &BusinessOrganisationsListAltID,
1531 wxT("PID"), &BusinessOrganisationsListPID,
1532 wxT("LANGUAGE"), &BusinessOrganisationsListLanguage,
1533 wxT("SORT-AS"), &BusinessOrganisationsListSortAs,
1534 wxT("PREF"), &BusinessOrganisationsListPref,
1535 wxT(""), &BusinessOrganisationsListTokens );
1537 ResetSaveProcessData();
1541 ResetSaveProcessData();
1543 for (std::map<int,wxString>::iterator iter = GeneralNoteList.begin();
1544 iter != GeneralNoteList.end(); ++iter){
1546 ProcessSaveData(wxT("NOTE"), &strValue2, &boolValue2, &boolValue,
1547 &iter, &GeneralNoteList, &ContactData,
1548 wxT("ALTID"), &GeneralNoteListAltID,
1549 wxT("PID"), &GeneralNoteListPID,
1550 wxT("LANGUAGE"), &GeneralNoteListLanguage,
1551 wxT("PREF"), &GeneralNoteListPref,
1552 wxT(""), &GeneralNoteListTokens );
1554 ResetSaveProcessData();
1558 ResetSaveProcessData();
1560 for (std::map<int,wxString>::iterator iter = HomeNoteList.begin();
1561 iter != HomeNoteList.end(); ++iter){
1563 ProcessSaveData(wxT("NOTE;TYPE=home"), &strValue2, &boolValue2, &boolValue,
1564 &iter, &HomeNoteList, &ContactData,
1565 wxT("ALTID"), &HomeNoteListAltID,
1566 wxT("PID"), &HomeNoteListPID,
1567 wxT("LANGUAGE"), &HomeNoteListLanguage,
1568 wxT("PREF"), &HomeNoteListPref,
1569 wxT(""), &HomeNoteListTokens );
1571 ResetSaveProcessData();
1575 ResetSaveProcessData();
1577 for (std::map<int,wxString>::iterator iter = BusinessNoteList.begin();
1578 iter != BusinessNoteList.end(); ++iter){
1580 ProcessSaveData(wxT("NOTE;TYPE=work"), &strValue2, &boolValue2, &boolValue,
1581 &iter, &BusinessNoteList, &ContactData,
1582 wxT("ALTID"), &BusinessNoteListAltID,
1583 wxT("PID"), &BusinessNoteListPID,
1584 wxT("LANGUAGE"), &BusinessNoteListLanguage,
1585 wxT("PREF"), &BusinessNoteListPref,
1586 wxT(""), &BusinessNoteListTokens );
1588 ResetSaveProcessData();
1592 ResetSaveProcessData();
1594 for (std::map<int,wxString>::iterator iter = CategoriesList.begin();
1595 iter != CategoriesList.end(); ++iter){
1597 ProcessSaveData(wxT("CATEGORIES"), &strValue2, &boolValue2, &boolValue,
1598 &iter, &CategoriesList, &ContactData,
1599 wxT("ALTID"), &CategoriesListAltID,
1600 wxT("PID"), &CategoriesListPID,
1601 wxT("TYPE"), &CategoriesListType,
1602 wxT("PREF"), &CategoriesListPref,
1603 wxT(""), &CategoriesListTokens );
1605 ResetSaveProcessData();
1611 for (std::map<int, std::string>::iterator iter = PicturesList.begin();
1612 iter != PicturesList.end(); ++iter){
1614 int intValueIndex = iter->first;
1616 std::map<int, std::string>::iterator stdstriter;
1617 std::map<int, wxString>::iterator enciter;
1619 striter = PicturesListPictureType.find(intValueIndex);
1620 enciter = PicturesListPicEncType.find(intValueIndex);
1622 ProcessSaveData(wxT("PHOTO"), &strValue2, &boolValue2, &boolValue,
1623 &iter, &PicturesList, &striter,
1624 &enciter, &ContactData,
1625 wxT("ALTID"), &PicturesListAltID,
1626 wxT("PID"), &PicturesListPID,
1627 wxT("TYPE"), &PicturesListType,
1628 wxT("PREF"), &PicturesListPref,
1629 wxT(""), &PicturesListTokens);
1631 ResetSaveProcessData();
1635 ResetSaveProcessData();
1639 for (std::map<int, std::string>::iterator iter = LogosList.begin();
1640 iter != LogosList.end(); ++iter){
1642 int intValueIndex = iter->first;
1644 std::map<int, std::string>::iterator stdstriter;
1645 std::map<int, wxString>::iterator enciter;
1647 striter = LogosListPictureType.find(intValueIndex);
1648 enciter = LogosListPicEncType.find(intValueIndex);
1650 ProcessSaveData(wxT("LOGO"), &strValue2, &boolValue2, &boolValue,
1651 &iter, &LogosList, &striter,
1652 &enciter, &ContactData,
1653 wxT("ALTID"), &LogosListAltID,
1654 wxT("PID"), &LogosListPID,
1655 wxT("TYPE"), &LogosListType,
1656 wxT("PREF"), &LogosListPref,
1657 wxT(""), &LogosListTokens );
1659 ResetSaveProcessData();
1663 ResetSaveProcessData();
1667 for (std::map<int, std::string>::iterator iter = SoundsList.begin();
1668 iter != SoundsList.end(); ++iter){
1670 int intValueIndex = iter->first;
1672 std::map<int, std::string>::iterator stdstriter;
1673 std::map<int, wxString>::iterator enciter;
1675 striter = SoundsListAudioType.find(intValueIndex);
1676 enciter = SoundsListAudioEncType.find(intValueIndex);
1678 ProcessSaveData(wxT("SOUND"), &strValue2, &boolValue2, &boolValue,
1679 &iter, &SoundsList, &striter,
1680 &enciter, &ContactData,
1681 wxT("ALTID"), &SoundsListAltID,
1682 wxT("PID"), &SoundsListPID,
1683 wxT("TYPE"), &SoundsListType,
1684 wxT("PREF"), &SoundsListPref,
1685 wxT(""), &SoundsListTokens );
1687 ResetSaveProcessData();
1691 ResetSaveProcessData();
1693 for (std::map<int,wxString>::iterator iter = CalendarList.begin();
1694 iter != CalendarList.end(); ++iter){
1696 ProcessSaveData(wxT("CALURI"), &strValue2, &boolValue2, &boolValue,
1697 &iter, &CalendarList, &ContactData,
1698 wxT("ALTID"), &CalendarListAltID,
1699 wxT("PID"), &CalendarListPID,
1700 wxT("MEDIATYPE"), &CalendarListMediatype,
1701 wxT("TYPE"), &CalendarListType,
1702 wxT("PREF"), &CalendarListPref,
1703 wxT(""), &CalendarListTokens );
1705 ResetSaveProcessData();
1709 ResetSaveProcessData();
1711 for (std::map<int,wxString>::iterator iter = CalendarRequestList.begin();
1712 iter != CalendarRequestList.end(); ++iter){
1714 ProcessSaveData(wxT("CALADRURI"), &strValue2, &boolValue2, &boolValue,
1715 &iter, &CalendarRequestList, &ContactData,
1716 wxT("ALTID"), &CalendarRequestListAltID,
1717 wxT("PID"), &CalendarRequestListPID,
1718 wxT("MEDIATYPE"), &CalendarRequestListMediatype,
1719 wxT("TYPE"), &CalendarRequestListType,
1720 wxT("PREF"), &CalendarRequestListPref,
1721 wxT(""), &CalendarRequestListTokens );
1723 ResetSaveProcessData();
1727 ResetSaveProcessData();
1729 for (std::map<int,wxString>::iterator iter = FreeBusyList.begin();
1730 iter != FreeBusyList.end(); ++iter){
1732 ProcessSaveData(wxT("FBURL"), &strValue2, &boolValue2, &boolValue,
1733 &iter, &FreeBusyList, &ContactData,
1734 wxT("ALTID"), &FreeBusyListAltID,
1735 wxT("PID"), &FreeBusyListPID,
1736 wxT("MEDIATYPE"), &FreeBusyListMediatype,
1737 wxT("TYPE"), &FreeBusyListType,
1738 wxT("PREF"), &FreeBusyListPref,
1739 wxT(""), &FreeBusyListTokens );
1741 ResetSaveProcessData();
1745 for (std::map<int, wxString>::iterator iter = KeyList.begin();
1746 iter != KeyList.end(); ++iter){
1748 intValue2 = iter->first;
1750 // Process Alternative ID.
1752 striter = KeyListAltID.find(intValue2);
1754 if (striter->first == intValue2){
1756 strValue3 = striter->second;
1758 if (!strValue3.IsEmpty()){
1763 if (boolValue2 == TRUE){
1765 strValue2.Append(wxT(";"));
1773 strValue2.Append(wxT("ALTID=") + strValue3);
1783 striter = KeyListPID.find(intValue2);
1785 if (striter->first == intValue2){
1787 strValue3 = striter->second;
1789 if (!strValue3.IsEmpty()){
1794 if (boolValue2 == TRUE){
1796 strValue2.Append(wxT(";"));
1804 strValue2.Append(wxT("PID=") + strValue3);
1814 striter = KeyListType.find(intValue2);
1816 if (striter->first == intValue2){
1818 strValue3 = striter->second;
1820 if (!strValue3.IsEmpty()){
1825 if (boolValue2 == TRUE){
1827 strValue2.Append(wxT(";"));
1835 strValue2.Append(wxT("TYPE=") + strValue3);
1843 intiter = KeyListPref.find(intValue2);
1845 if (intiter->first == intValue2){
1847 intValue3 = intiter->second;
1851 if (boolValue2 == TRUE){
1853 strValue2.Append(wxT(";"));
1861 strValue2.Append(wxT("PREF=") + wxString::Format(wxT("%i"), intValue3));
1871 striter = KeyListTokens.find(intValue2);
1873 if (striter->first == intValue2){
1875 strValue3 = striter->second;
1877 if (!strValue3.IsEmpty()){
1882 if (boolValue2 == TRUE){
1884 strValue2.Append(wxT(";"));
1892 strValue2.Append(strValue3);
1900 // Get the key information.
1902 std::map<int, wxString>::iterator enciter;
1904 striter = KeyListDataType.find(intValue2);
1905 //enciter = KeyListAudioEncType.find(intValue2);
1907 wxString strValueData;
1909 strValueData = iter->second;
1910 //strValueData.insert(0, wxT("data:") + striter->second + wxT(";") + enciter->second + wxT(","));
1911 strValueData.insert(0, wxT("data:") + striter->second + wxT(";base64,"));
1914 // Add to the vCard.
1916 if (boolValue == TRUE){
1918 ContactData.AddRaw(wxT("KEY;") + strValue2, strValueData);
1922 ContactData.Add(wxT("KEY"), strValueData, TRUE);
1926 ResetSaveProcessData();
1930 // Vendor specific items.
1932 ResetSaveProcessData();
1934 for (std::map<int,wxString>::iterator iter = VendorList.begin();
1935 iter != VendorList.end(); ++iter){
1937 intValue2 = iter->first;
1939 // Get the IANA PEN number.
1941 striter = VendorListPEN.find(intValue2);
1943 if (striter->first == intValue2){
1945 strValue2 = striter->second;
1949 // Get the element name.
1951 striter = VendorListElement.find(intValue2);
1953 if (striter->first == intValue2){
1955 strValue3 = striter->second;
1961 striter = VendorList.find(intValue2);
1963 if (striter->first == intValue2){
1965 strValue = striter->second;
1969 // Add to the vCard.
1971 if (boolValue == TRUE){
1973 ContactData.AddRaw(wxT("VND-") + strValue2 + wxT("-") + strValue3, strValue);
1977 ContactData.Add(wxT("VND-") + strValue2 + wxT("-") + strValue3, strValue, FALSE);
1981 ResetSaveProcessData();
1985 ResetSaveProcessData();
1989 for (std::map<int,wxString>::iterator iter = XTokenList.begin();
1990 iter != XTokenList.end(); ++iter){
1992 intValue2 = iter->first;
1994 // Get the element name.
1996 striter = XTokenListTokens.find(intValue2);
1998 if (striter->first == intValue2){
2000 strValue2 = striter->second;
2006 striter = XTokenList.find(intValue2);
2008 if (striter->first == intValue2){
2010 strValue = striter->second;
2014 // Add to the vCard.
2016 if (boolValue == TRUE){
2018 ContactData.AddRaw(wxT("X-") + strValue2, strValue);
2022 ContactData.Add(wxT("X-") + strValue2, strValue, FALSE);
2026 ResetSaveProcessData();
2030 ResetSaveProcessData();
2032 if (FullNamesList.size() == 0){
2034 wxString FullName = cmbDisplayAs->GetValue();
2035 FullNamesList.insert(std::make_pair(0, FullName));
2036 FullNamesListAltID.insert(std::make_pair(0, wxT("")));
2037 FullNamesListPID.insert(std::make_pair(0, wxT("")));
2038 FullNamesListType.insert(std::make_pair(0, wxT("")));
2039 FullNamesListLanguage.insert(std::make_pair(0, wxT("")));
2040 FullNamesListPref.insert(std::make_pair(0, 0));
2041 FullNamesListTokens.insert(std::make_pair(0, wxT("")));
2046 for (std::map<int, wxString>::iterator iter = FullNamesList.begin();
2047 iter != FullNamesList.end(); ++iter){
2049 if (FNFirst == TRUE){
2051 iter->second = cmbDisplayAs->GetValue();
2056 std::map<int,wxString>::iterator mapS;
2058 mapS = FullNamesListTokens.find(iter->first);
2060 ProcessSaveData(wxT("FN"), &strValue2, &boolValue2, &boolValue,
2061 &iter, &FullNamesList, &ContactData,
2062 wxT("ALTID"), &FullNamesListAltID,
2063 wxT("PID"), &FullNamesListPID,
2064 wxT("TYPE"), &FullNamesListType,
2065 wxT("LANGUAGE"), &FullNamesListLanguage,
2066 wxT("PREF"), &FullNamesListPref,
2067 wxT(""), &FullNamesListTokens );
2071 ResetSaveProcessData();
2075 //ContactData.Add(wxT("FN"), cmbDisplayAs->GetValue(), FALSE);
2077 // Insert revision (REV) date.
2079 // Get today's date and time.
2081 wxDateTime DateTimeNow = wxDateTime::Now();
2085 // Set year, month and date.
2087 int intYear = DateTimeNow.GetYear();
2088 int intMonth = DateTimeNow.GetMonth();
2089 int intDay = DateTimeNow.GetDay();
2091 DateRev.Append(wxT("0") + wxString::Format(wxT("%i"), intYear));
2095 DateRev.Append(wxT("0") + wxString::Format(wxT("%i"), intMonth));
2099 DateRev.Append(wxString::Format(wxT("%i"), intMonth));
2105 DateRev.Append(wxT("0") + wxString::Format(wxT("%i"), intDay));
2109 DateRev.Append(wxString::Format(wxT("%i"), intDay));
2113 //DateRev.Append(wx);
2114 //DateRev.Append(wx);
2115 //DateRev.Append(wx);
2116 DateRev.Append(wxT("T"));
2118 // Set hour, minute and second.
2120 int intHour = DateTimeNow.GetHour();
2121 int intMinute = DateTimeNow.GetMinute();
2122 int intSecond = DateTimeNow.GetSecond();
2126 DateRev.Append(wxT("0") + wxString::Format(wxT("%i"), intHour));
2130 DateRev.Append(wxString::Format(wxT("%i"), intHour));
2134 if (intMinute < 10){
2136 DateRev.Append(wxT("0") + wxString::Format(wxT("%i"), intMinute));
2140 DateRev.Append(wxString::Format(wxT("%i"), intMinute));
2144 if (intSecond < 10){
2146 DateRev.Append(wxT("0") + wxString::Format(wxT("%i"), intSecond));
2150 DateRev.Append(wxString::Format(wxT("%i"), intSecond));
2154 // DateRev.Append(wx);
2155 // DateRev.Append(wx);
2156 // DateRev.Append(wxString DateTimeNow->);
2157 DateRev.Append(wxT("Z"));
2159 ContactData.Add(wxT("UID"), UIDToken, FALSE);
2161 // End the vCard File.
2163 ContactData.Add(wxT("END"), wxT("VCARD"), FALSE);
2166 ContactData.WriteFile(FilenameFinal);
2168 vCard34Conv ConvFileFun;
2172 ConvFileFun.ConvertToV3(FilenameFinal, &wxSData);
2174 wxString AccountDirPrefix;
2175 wxString AccountDir;
2178 #if defined(__HAIKU__)
2180 //preffilename = wxT("noo");
2182 #elif defined(__APPLE__)
2184 PrefDir = GetUserPrefDir();
2186 wxStringTokenizer wSTFilename(wxSContactFilename, wxT("/"));
2188 #elif defined(__WIN32__)
2190 PrefDir = GetUserPrefDir();
2192 wxStringTokenizer wSTFilename(wxSContactFilename, wxT("\\"));
2196 PrefDir = GetUserPrefDir();
2198 wxStringTokenizer wSTFilename(wxSContactFilename, wxT("/"));
2202 XABPreferences PrefData(PrefDir);
2204 wxString AccountType;
2206 for (int i = 0; i < PrefData.accounts.GetCount(); i++){
2208 AccountDir = PrefData.accounts.GetAccountDirectory(i) + wxT(".carddav");
2210 if (AccountDir == wxSContactAccount){
2212 AccountDirPrefix = PrefData.accounts.GetAccountDirPrefix(i);
2213 AccountDirPrefix.Trim();
2214 AccountType = PrefData.accounts.GetAccountType(i);
2221 wxString wxSplitFilename;
2222 wxString wxSDataURL;
2224 while(wSTFilename.HasMoreTokens()){
2226 wxSplitFilename = wSTFilename.GetNextToken();
2230 wxSDataURL = wxSplitFilename;
2231 //wxSDataURL.Append(wxSplitFilename);
2233 // Find out if the filename exists in the table.
2235 if (AccountType == wxT("CardDAV") || AccountType == wxT("carddav")){
2237 wxString ETagResult;
2238 wxString ETagOriginal;
2240 ETagDB *ETagDBPtr = NULL;
2242 ETagDBPtr = ETagTmrPtr->GetPointer(wxSContactAccount);
2244 wxString wxSETag = ETagDBPtr->GetETag(wxSplitFilename);
2245 wxString wxSETagOrig = ETagDBPtr->GetETagOriginal(wxSplitFilename);
2247 if (wxSETagOrig.IsEmpty()){
2249 // Generate the ETag.
2251 wxSETagOrig = wxString::Format(wxT("%X%X%X%X"), rand() % 1024, rand() % 1024, rand() % 1024, rand() % 1024);
2255 if (wxSETag.IsEmpty()){
2257 // Update empty ETag.
2259 wxSETag = wxSETagOrig;
2260 ETagDBPtr->UpdateETag(wxSplitFilename, wxSETag, wxSETagOrig);
2265 // Don't change original ETag.
2267 wxSETag = wxString::Format(wxT("%X%X%X%X"), rand() % 1024, rand() % 1024, rand() % 1024, rand() % 1024);
2268 ETagDBPtr->UpdateETag(wxSplitFilename, wxSETag);
2272 if (EditMode == FALSE){
2274 ActMgrPtr->AddTask(0, cmbDisplayAs->GetValue(), wxSContactAccount, wxSDataURL, wxSplitFilename, FilenameFinal, wxSData);
2276 FMTimer.SetFilename(FilenameFinal);
2277 FMTimer.UpdateTimestamp();
2278 FMTimer.Start(10000, FALSE);
2280 wxCommandEvent reloadevent(RELOADCONTACTLIST);
2281 reloadevent.SetString(wxSContactAccount);
2282 wxPostEvent(this->GetParent(), reloadevent);
2287 ActMgrPtr->AddTask(1, cmbDisplayAs->GetValue(), wxSContactAccount, wxSDataURL, wxSplitFilename, FilenameFinal, wxSData);
2288 FMTimer.UpdateTimestamp();
2289 FMTimer.Start(10000, FALSE);
2295 // Send a notification to update the main window
2296 // with the new details.
2301 // TODO: Workout nickname settings by priority and
2304 ucd->ContactAccount = wxSContactAccount;
2305 ucd->ContactFilename = FilenameFinal;
2306 ucd->ContactName = cmbDisplayAs->GetValue();
2307 ucd->ContactNameArray = ContactData.GetName();
2309 for (std::map<int,wxString>::iterator gniter = GeneralNicknamesList.begin();
2310 gniter != GeneralNicknamesList.end(); gniter++){
2312 ucd->ContactNickname = gniter->second;
2317 wxCommandEvent event2(CE_UPDATECONTACTLIST);
2318 event2.SetClientData(ucd);
2319 wxPostEvent(MainPtr, event2);
2323 void frmContactEditor::SaveCloseContact( wxCommandEvent& event )
2326 // Save the updated contact data and close the form.
2328 wxCommandEvent NullEvent;
2329 this->SaveContact(NullEvent);