1 // ContactDataObject.cpp - Client Data Object.
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 "ContactDataObject.h"
21 ContactLoadStatus ContactDataObject::LoadFile(wxString Filename){
23 if (!wxFileExists(Filename)){
25 return CONTACTLOAD_FILEMISSING;
31 if (!ContactFile.Open(Filename, wxFile::read, wxS_DEFAULT)){
33 return CONTACTLOAD_FILEERROR;
37 // Check that the vCard is a valid vCard 4.0 file.
39 vCard vCard4FormatCheck;
41 vCard4FormatCheck.LoadFile(Filename);
43 if (vCard4FormatCheck.Get("VERSION") != wxT("4.0")){
45 return CONTACTLOAD_FILEINVALIDFORMAT;
49 // Check that the vCard meets the base specification.
51 if (!vCard4FormatCheck.MeetBaseSpecification()){
53 return CONTACTLOAD_FILEBASESPECFAIL;
57 wxStringTokenizer wSTContactFileLines(vCard4FormatCheck.WriteString(), wxT("\r\n"));
59 std::map<int, wxString> ContactFileLines;
61 int ContactLineSeek = 0;
63 while (wSTContactFileLines.HasMoreTokens() == TRUE){
65 wxString ContactLine = wSTContactFileLines.GetNextToken();
66 ContactFileLines.insert(std::make_pair(ContactLineSeek, ContactLine));
71 wxString wxSPropertyNextLine;
73 bool ExtraLineSeek = TRUE;
74 bool QuoteMode = FALSE;
75 bool PropertyFind = TRUE;
76 bool KindProcessed = FALSE;
77 bool NameProcessed = FALSE;
78 bool GenderProcessed = FALSE;
79 bool BirthdayProcessed = FALSE;
80 bool AnniversaryProcessed = FALSE;
81 bool UIDProcessed = FALSE;
82 bool RevisionProcessed = FALSE;
83 int ContactLineLen = 0;
84 int QuoteBreakPoint = 0;
88 int NicknameCount = 0;
89 int TimeZoneCount = 0;
93 int TelephoneCount = 0;
94 int LanguageCount = 0;
95 int GeographicCount = 0;
100 int OrganisationCount = 0;
102 int CategoryCount = 0;
106 int CalendarCount = 0;
107 int CalendarAddressCount = 0;
108 int FreeBusyAddressCount = 0;
113 int ClientPIDCount = 0;
114 wxString ContactLine;
115 wxString PropertyLine;
116 wxString PropertySeg1;
117 wxString PropertySeg2;
118 wxString PropertyNextLine;
121 for (std::map<int,wxString>::iterator iter = ContactFileLines.begin();
122 iter != ContactFileLines.end(); ++iter){
124 ExtraLineSeek = TRUE;
130 PropertyLine.Clear();
131 PropertySeg1.Clear();
132 PropertySeg2.Clear();
135 ContactLine = iter->second;
137 while (ExtraLineSeek == TRUE){
139 // Check if there is extra data on the next line
140 // (indicated by space or tab at the start) and add data.
144 if (iter == ContactFileLines.end()){
151 PropertyNextLine = iter->second;
153 if (PropertyNextLine.Mid(0, 1) == wxT(" ") || PropertyNextLine.Mid(0, 1) == wxT("\t")){
155 PropertyNextLine.Remove(0, 1);
156 ContactLine.Append(PropertyNextLine);
161 ExtraLineSeek = FALSE;
167 ContactLineLen = ContactLine.Len();
169 // Make sure we are not in quotation mode.
170 // Make sure colon does not have \ or \\ before it.
172 for (int i = 0; i <= ContactLineLen; i++){
174 if ((ContactLine.Mid(i, 1) == wxT(";") || ContactLine.Mid(i, 1) == wxT(":")) && PropertyFind == TRUE){
176 PropertyFind = FALSE;
178 } else if (PropertyFind == TRUE){
180 Property.Append(ContactLine.Mid(i, 1));
184 if (ContactLine.Mid(i, 1) == wxT("\"")){
186 if (QuoteMode == TRUE){
198 if (ContactLine.Mid(i, 1) == wxT(":") && ContactLine.Mid((i - 1), 1) != wxT("\\") && QuoteMode == FALSE){
207 // Split that line at the point into two variables (ignore the colon).
209 PropertySeg1 = ContactLine.Mid(0, QuoteBreakPoint);
210 PropertySeg2 = ContactLine.Mid((QuoteBreakPoint + 1));
212 if (Property == wxT("KIND") && KindProcessed == FALSE){
214 ProcessKind(PropertySeg2);
216 } else if (Property == wxT("UID") && UIDProcessed == FALSE){
218 UIDToken = PropertySeg2;
221 } else if (Property == wxT("SOURCE")){
223 ProcessSource(PropertySeg1, PropertySeg2, &SourceCount);
226 } else if (Property == wxT("XML")){
228 ProcessXML(PropertySeg1, PropertySeg2, &XMLCount);
231 } else if (Property == wxT("REV") && RevisionProcessed == FALSE){
233 ProcessRevision(PropertySeg1, PropertySeg2);
234 RevisionProcessed = TRUE;
236 } else if (Property == wxT("MEMBER")){
238 ProcessMember(PropertySeg1, PropertySeg2, &GroupCount);
241 } else if (Property == wxT("FN")){
243 ProcessFN(PropertySeg1, PropertySeg2, &FNCount);
246 } else if (Property == wxT("N") && NameProcessed == FALSE){
248 ProcessN(PropertySeg1, PropertySeg2);
249 NameProcessed = TRUE;
251 } else if (Property == wxT("CLIENTPIDMAP")){
253 ProcessClientPIDMap(PropertySeg1, PropertySeg2, &ClientPIDCount);
256 } else if (Property == wxT("NICKNAME")){
258 ProcessNickname(PropertySeg1, PropertySeg2, &NicknameCount);
261 } else if (Property == wxT("GENDER") && GenderProcessed == FALSE){
263 ProcessGender(PropertySeg1, PropertySeg2);
264 GenderProcessed = TRUE;
266 } else if (Property == wxT("BDAY") && BirthdayProcessed == FALSE){
268 ProcessBirthday(PropertySeg1, PropertySeg2);
269 BirthdayProcessed = TRUE;
271 } else if (Property == wxT("ANNIVERSARY") && AnniversaryProcessed == FALSE){
273 ProcessAnniversary(PropertySeg1, PropertySeg2);
274 AnniversaryProcessed = TRUE;
276 } else if (Property == wxT("TZ")){
278 ProcessTimeZone(PropertySeg1, PropertySeg2, &TimeZoneCount);
281 } else if (Property == wxT("ADR")){
283 ProcessAddress(PropertySeg1, PropertySeg2, &AddressCount);
286 } else if (Property == wxT("EMAIL")){
288 ProcessEmail(PropertySeg1, PropertySeg2, &EmailCount);
291 } else if (Property == wxT("IMPP")){
293 ProcessIM(PropertySeg1, PropertySeg2, &IMCount);
296 } else if (Property == wxT("TEL")){
298 ProcessTelephone(PropertySeg1, PropertySeg2, &TelephoneCount);
301 } else if (Property == wxT("LANG")){
303 // See frmContactEditor-LoadLanguage.cpp
305 ProcessLanguage(PropertySeg1, PropertySeg2, &LanguageCount);
308 } else if (Property == wxT("GEO")){
310 // See frmContactEditor-LoadGeo.cpp
312 ProcessGeographic(PropertySeg1, PropertySeg2, &GeographicCount);
315 } else if (Property == wxT("RELATED")){
317 // See fromContactEditor-LoadRelated.cpp
319 ProcessRelated(PropertySeg1, PropertySeg2, &RelatedCount);
322 } else if (Property == wxT("URL")){
324 // See frmContactEditor-LoadURL.cpp
326 ProcessURL(PropertySeg1, PropertySeg2, &URLCount);
329 } else if (Property == wxT("TITLE")) {
331 // See frmContactEditor-LoadTitle.cpp
333 ProcessTitle(PropertySeg1, PropertySeg2, &TitleCount);
336 } else if (Property == wxT("ROLE")) {
338 // See frmContactEditor-LoadTitle.cpp
340 ProcessRole(PropertySeg1, PropertySeg2, &RoleCount);
343 } else if (Property == wxT("ORG")) {
345 // See frmContactEditor-LoadOrg.cpp
347 ProcessOrganisation(PropertySeg1, PropertySeg2, &OrganisationCount);
350 } else if (Property == wxT("NOTE")) {
352 // See frmContactEditor-LoadNote.cpp
354 ProcessNote(PropertySeg1, PropertySeg2, &NoteCount);
357 } else if (Property == wxT("CATEGORIES")) {
359 // See frmContactEditor-LoadCategory.cpp
361 ProcessCategory(PropertySeg1, PropertySeg2, &CategoryCount);
364 } else if (Property == wxT("PHOTO")) {
366 // See frmContactEditor-LoadPhoto.cpp
368 ProcessPhoto(PropertySeg1, PropertySeg2, &PhotoCount);
371 } else if (Property == wxT("LOGO")) {
373 // See frmContactEditor-LoadPhoto.cpp
375 ProcessLogo(PropertySeg1, PropertySeg2, &LogoCount);
378 } else if (Property == wxT("LOGO")) {
380 // See frmContactEditor-LoadPhoto.cpp
382 ProcessLogo(PropertySeg1, PropertySeg2, &LogoCount);
385 } else if (Property == wxT("SOUND")) {
387 // See frmContactEditor-LoadSound.cpp
389 ProcessSound(PropertySeg1, PropertySeg2, &SoundCount);
392 } else if (Property == wxT("CALURI")){
394 // See frmContactEditor-LoadCalendar.cpp
396 ProcessCalendarURI(PropertySeg1, PropertySeg2, &CalendarCount);
399 } else if (Property == wxT("CALADRURI")){
401 ProcessCalendarAddressURI(PropertySeg1, PropertySeg2, &CalendarAddressCount);
402 CalendarAddressCount++;
404 } else if (Property == wxT("FBURL")){
406 // See frmContactEditor-LoadCalendar.cpp
408 ProcessCalendarFreeBusy(PropertySeg1, PropertySeg2, &FreeBusyAddressCount);
409 FreeBusyAddressCount++;
411 } else if (Property == wxT("KEY")){
413 // See frmContactEditor-LoadKey.cpp
415 ProcessKey(PropertySeg1, PropertySeg2, &KeyCount);
418 } else if (Property.Mid(0, 3) == wxT("VND")){
420 ProcessVendor(PropertySeg1, PropertySeg2, &VendorCount);
423 } else if (Property.Mid(0, 2) == wxT("X-")){
425 XTokenList.insert(std::make_pair(XTokenCount, PropertySeg2));
426 XTokenListTokens.insert(std::make_pair(XTokenCount, PropertySeg1.Mid(2)));
433 return CONTACTLOAD_OK;
437 void ContactDataObject::ProcessKind(wxString KindType){
439 if (KindType == wxT("individual")){
441 ContactKind = CONTACTKIND_INDIVIDUAL;
443 } else if (KindType == wxT("group")){
445 ContactKind = CONTACTKIND_GROUP;
447 } else if (KindType == wxT("org")){
449 ContactKind = CONTACTKIND_ORGANISATION;
451 } else if (KindType == wxT("location")){
453 ContactKind = CONTACTKIND_LOCATION;
457 ContactKind = CONTACTKIND_NONE;
462 void ContactDataObject::ProcessRevision(wxString PropertySeg1, wxString PropertySeg2){
464 size_t intPropertyLen = PropertySeg1.Len();
465 std::map<int, int> SplitPoints;
466 std::map<int, int> SplitLength;
467 std::map<int, int>::iterator SLiter;
468 wxString PropertyData;
469 wxString PropertyName;
470 wxString PropertyValue;
471 wxString PropertyTokens;
472 bool FirstToken = TRUE;
473 int intSplitsFound = 0;
474 int intSplitSize = 0;
475 int intPrevValue = 5;
479 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
483 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
484 intiter != SplitPoints.end(); ++intiter){
486 SLiter = SplitLength.find(intiter->first);
488 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
490 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
491 PropertyName = PropertyElement.GetNextToken();
492 PropertyValue = PropertyElement.GetNextToken();
494 intPrevValue = intiter->second;
496 // Process properties.
498 size_t intPropertyValueLen = PropertyValue.Len();
500 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
502 PropertyValue.Trim();
503 PropertyValue.RemoveLast();
507 if (PropertyValue.Mid(0, 1) == wxT("\"")){
509 PropertyValue.Remove(0, 1);
513 CaptureString(&PropertyValue, FALSE);
515 if (FirstToken == TRUE){
517 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
522 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
528 CaptureString(&PropertySeg2, FALSE);
530 Revision = PropertySeg2;
532 if (!PropertyTokens.IsEmpty()){
534 RevisionTokens = PropertyTokens;
541 void ContactDataObject::ProcessSource(wxString PropertySeg1, wxString PropertySeg2, int *SourceCount){
543 size_t intPropertyLen = PropertySeg1.Len();
544 std::map<int, int> SplitPoints;
545 std::map<int, int> SplitLength;
546 std::map<int, int>::iterator SLiter;
547 wxString PropertyData;
548 wxString PropertyName;
549 wxString PropertyValue;
550 wxString PropertyTokens;
551 bool FirstToken = TRUE;
552 bool PropertyMatched = FALSE;
553 int intSplitsFound = 0;
554 int intSplitSize = 0;
555 int intPrevValue = 8;
559 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
563 PropertyType PropType = PROPERTY_NONE;
565 // Look for type before continuing.
567 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
571 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
572 intiter != SplitPoints.end(); ++intiter){
574 SLiter = SplitLength.find(intiter->first);
576 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
578 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
579 PropertyName = PropertyElement.GetNextToken();
580 PropertyValue = PropertyElement.GetNextToken();
582 intPrevValue = intiter->second;
584 // Process properties.
586 size_t intPropertyValueLen = PropertyValue.Len();
588 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
590 PropertyValue.Trim();
591 PropertyValue.RemoveLast();
595 if (PropertyValue.Mid(0, 1) == wxT("\"")){
597 PropertyValue.Remove(0, 1);
601 CaptureString(&PropertyValue, FALSE);
603 ProcessStringValue(&PropertyName, "ALTID", &SourceListAltID, &PropertyValue, SourceCount, &PropertyMatched);
604 ProcessStringValue(&PropertyName, "PID", &SourceListPID, &PropertyValue, SourceCount, &PropertyMatched);
605 ProcessStringValue(&PropertyName, "MEDIATYPE", &SourceListMediatype, &PropertyValue, SourceCount, &PropertyMatched);
606 ProcessIntegerValue(&PropertyName, "PREF", &SourceListPref, &PropertyValue, SourceCount, &PropertyMatched);
608 if (PropertyMatched == TRUE){
610 PropertyMatched = FALSE;
615 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
617 if (FirstToken == TRUE){
619 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
624 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
632 intPropertyLen = PropertySeg2.Len();
639 CaptureString(&PropertySeg2, FALSE);
641 // Add the data to the General/Home/Work address variables.
647 SourceListType.insert(std::make_pair(*SourceCount, "home"));
650 SourceListType.insert(std::make_pair(*SourceCount, "work"));
654 SourceList.insert(std::make_pair(*SourceCount, PropertySeg2));
656 if (!PropertyTokens.IsEmpty()){
658 SourceListTokens.insert(std::make_pair(*SourceCount, PropertyTokens));
664 void ContactDataObject::ProcessXML(wxString PropertySeg1, wxString PropertySeg2, int *XMLCount){
666 std::map<int, int> SplitPoints;
667 std::map<int, int> SplitLength;
669 int intPrevValue = 5;
673 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
677 wxString PropertyName;
678 wxString PropertyValue;
679 wxString PropertyData;
680 wxString PropertyTokens;
681 std::map<int,int>::iterator SLiter;
682 bool FirstToken = TRUE;
683 bool PropertyMatched = FALSE;
685 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
686 intiter != SplitPoints.end(); ++intiter){
688 SLiter = SplitLength.find(intiter->first);
690 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
692 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
693 PropertyName = PropertyElement.GetNextToken();
694 PropertyValue = PropertyElement.GetNextToken();
696 intPrevValue = intiter->second;
698 CaptureString(&PropertyValue, FALSE);
700 ProcessStringValue(&PropertyName, "ALTID", &XMLListAltID, &PropertyValue, XMLCount, &PropertyMatched);
702 if (PropertyMatched == TRUE){
704 PropertyMatched = FALSE;
711 XMLList.insert(std::make_pair(*XMLCount, PropertySeg2));
715 void ContactDataObject::ProcessMember(wxString PropertySeg1, wxString PropertySeg2, int *GroupCount){
717 std::map<int, int> SplitPoints;
718 std::map<int, int> SplitLength;
720 int intPrevValue = 8;
724 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
728 wxString PropertyName;
729 wxString PropertyValue;
730 wxString PropertyData;
731 wxString PropertyTokens;
732 std::map<int,int>::iterator SLiter;
733 bool FirstToken = TRUE;
734 bool PropertyMatched = FALSE;
736 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
737 intiter != SplitPoints.end(); ++intiter){
739 SLiter = SplitLength.find(intiter->first);
741 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
743 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
744 PropertyName = PropertyElement.GetNextToken();
745 PropertyValue = PropertyElement.GetNextToken();
747 intPrevValue = intiter->second;
749 CaptureString(&PropertyValue, FALSE);
751 ProcessStringValue(&PropertyName, "ALTID", &GroupsListAltID, &PropertyValue, GroupCount, &PropertyMatched);
752 ProcessStringValue(&PropertyName, "PID", &GroupsListPID, &PropertyValue, GroupCount, &PropertyMatched);
753 ProcessStringValue(&PropertyName, "MEDIATYPE", &GroupsListMediaType, &PropertyValue, GroupCount, &PropertyMatched);
754 ProcessIntegerValue(&PropertyName, "PREF", &GroupsListPref, &PropertyValue, GroupCount, &PropertyMatched);
756 if (PropertyMatched == TRUE){
758 PropertyMatched = FALSE;
763 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
765 if (FirstToken == TRUE){
767 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
772 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
780 GroupsList.insert(std::make_pair(*GroupCount, PropertySeg2));
782 if (!PropertyTokens.IsEmpty()){
784 GroupsListTokens.insert(std::make_pair(*GroupCount, PropertyTokens));
791 void ContactDataObject::ProcessFN(wxString PropertySeg1, wxString PropertySeg2, int *FNCount){
793 std::map<int, int> SplitPoints;
794 std::map<int, int> SplitLength;
796 int intPrevValue = 4;
800 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
804 wxString PropertyName;
805 wxString PropertyValue;
806 wxString PropertyData;
807 wxString PropertyTokens;
808 std::map<int,int>::iterator SLiter;
809 bool FirstToken = TRUE;
811 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
812 intiter != SplitPoints.end(); ++intiter){
814 SLiter = SplitLength.find(intiter->first);
816 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
818 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
819 PropertyName = PropertyElement.GetNextToken();
820 PropertyValue = PropertyElement.GetNextToken();
822 intPrevValue = intiter->second;
824 CaptureString(&PropertyValue, FALSE);
826 if (PropertyName == wxT("TYPE")){
828 if (!PropertyValue.IsEmpty() || PropertyValue == wxT("home") ||
829 PropertyValue == wxT("work") ){
831 FullNamesListType.erase(*FNCount);
832 FullNamesListType.insert(std::make_pair(*FNCount, PropertyValue));
836 } else if (PropertyName == wxT("LANGUAGE")){
838 FullNamesListLanguage.erase(*FNCount);
839 FullNamesListLanguage.insert(std::make_pair(*FNCount, PropertyValue));
841 } else if (PropertyName == wxT("ALTID")){
843 FullNamesListAltID.erase(*FNCount);
844 FullNamesListAltID.insert(std::make_pair(*FNCount, PropertyValue));
846 } else if (PropertyName == wxT("PID")){
848 FullNamesListPID.erase(*FNCount);
849 FullNamesListPID.insert(std::make_pair(*FNCount, PropertyValue));
851 } else if (PropertyName == wxT("PREF")){
853 ProcessIntegerValue(&FullNamesListPref, &PropertyValue, FNCount);
855 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
857 if (FirstToken == TRUE){
859 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
864 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
872 FullNamesList.insert(std::make_pair(*FNCount, PropertySeg2));
874 if (!PropertyTokens.IsEmpty()){
876 FullNamesListTokens.insert(std::make_pair(*FNCount, PropertyTokens));
882 void ContactDataObject::ProcessN(wxString PropertySeg1, wxString PropertySeg2){
884 std::map<int, int> SplitPoints;
885 std::map<int, int> SplitLength;
887 int intPrevValue = 3;
891 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
895 wxString PropertyName;
896 wxString PropertyValue;
897 wxString PropertyData;
898 wxString PropertyTokens;
899 std::map<int,int>::iterator SLiter;
900 bool FirstToken = TRUE;
902 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
903 intiter != SplitPoints.end(); ++intiter){
905 SLiter = SplitLength.find(intiter->first);
907 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
909 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
910 PropertyName = PropertyElement.GetNextToken();
911 PropertyValue = PropertyElement.GetNextToken();
913 intPrevValue = intiter->second;
915 CaptureString(&PropertyValue, FALSE);
917 if (PropertyName == wxT("ALTID")){
919 NameAltID = PropertyValue;
921 } else if (PropertyName == wxT("LANGUAGE")){
923 NameLanguage = PropertyValue;
925 } else if (PropertyName == wxT("SORT-AS")){
927 if (PropertyValue.Left(1) == wxT("\"") && PropertyValue.Right(1) == wxT("\"") &&
928 PropertyValue.Len() >= 3){
929 NameDisplayAs = PropertyValue.Mid(1, (PropertyValue.Len() - 2));
932 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
934 if (FirstToken == TRUE){
936 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
941 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
949 // Split the name data.
951 int intSplitSeek = 0;
952 int intSplitsFound = 0;
953 int intSplitSize = 0;
954 int intPropertyLen = PropertySeg2.Len();
956 std::map<int,wxString> NameValues;
959 for (int i = 0; i <= intPropertyLen; i++){
961 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
963 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, intSplitSize)));
968 if (intSplitsFound == 4){
970 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, wxString::npos)));
984 // Split the data into several parts.
986 for (std::map<int, wxString>::iterator iter = NameValues.begin();
987 iter != NameValues.end(); ++iter){
989 if (iter->first == 1){
991 // Deal with family name.
993 NameSurname = iter->second;
995 } else if (iter->first == 2){
997 // Deal with given names.
999 NameForename = iter->second;
1001 } else if (iter->first == 3){
1003 // Deal with additional names.
1005 NameOtherNames = iter->second;
1007 } else if (iter->first == 4){
1009 // Deal with honorifix prefixes and suffixes.
1011 NameTitle = iter->second;
1015 if (iter == NameValues.end()){
1021 NameSuffix = iter->second;
1027 // Add the name token data.
1029 if (!PropertyTokens.IsEmpty()){
1031 NameTokens = PropertyTokens;
1037 void ContactDataObject::ProcessClientPIDMap(wxString PropertySeg1, wxString PropertySeg2, int *ClientPIDCount){
1039 size_t intPropertyLen = PropertySeg1.Len();
1040 std::map<int, int> SplitPoints;
1041 std::map<int, int> SplitLength;
1042 std::map<int, int>::iterator SLiter;
1043 wxString PropertyData;
1044 wxString PropertyName;
1045 wxString PropertyValue;
1046 wxString PropertyTokens;
1047 bool FirstToken = TRUE;
1048 int intSplitsFound = 0;
1049 int intSplitSize = 0;
1050 int intPrevValue = 14;
1054 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1058 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1059 intiter != SplitPoints.end(); ++intiter){
1061 SLiter = SplitLength.find(intiter->first);
1063 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1065 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1066 PropertyName = PropertyElement.GetNextToken();
1067 PropertyValue = PropertyElement.GetNextToken();
1069 intPrevValue = intiter->second;
1071 // Process properties.
1073 size_t intPropertyValueLen = PropertyValue.Len();
1075 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
1077 PropertyValue.Trim();
1078 PropertyValue.RemoveLast();
1082 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1084 PropertyValue.Remove(0, 1);
1088 CaptureString(&PropertyValue, FALSE);
1090 if (PropertyName.IsEmpty() || PropertyName.IsEmpty()){
1096 if (FirstToken == TRUE){
1098 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1103 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1109 CaptureString(&PropertySeg2, FALSE);
1111 ClientPIDList.insert(std::make_pair(*ClientPIDCount, PropertySeg2));
1113 if (!PropertyTokens.IsEmpty()){
1115 ClientPIDListTokens.insert(std::make_pair(*ClientPIDCount, PropertyTokens));
1121 void ContactDataObject::ProcessNickname(wxString PropertySeg1, wxString PropertySeg2, int *NicknameCount){
1123 std::map<int, int> SplitPoints;
1124 std::map<int, int> SplitLength;
1126 int intPrevValue = 10;
1129 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1133 PropertyType PropType = PROPERTY_NONE;
1135 // Look for type before continuing.
1137 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1141 std::map<int, wxString> *NicknamesList = NULL;
1142 std::map<int, wxString> *NicknamesListType = NULL;
1143 std::map<int, wxString> *NicknamesListLanguage = NULL;
1144 std::map<int, wxString> *NicknamesListAltID = NULL;
1145 std::map<int, wxString> *NicknamesListPID = NULL;
1146 std::map<int, wxString> *NicknamesListTokens = NULL;
1147 std::map<int, int> *NicknamesListPref = NULL;
1151 NicknamesList = &GeneralNicknamesList;
1152 NicknamesListType = &GeneralNicknamesListType;
1153 NicknamesListLanguage = &GeneralNicknamesListLanguage;
1154 NicknamesListAltID = &GeneralNicknamesListAltID;
1155 NicknamesListPID = &GeneralNicknamesListPID;
1156 NicknamesListTokens = &GeneralNicknamesListTokens;
1157 NicknamesListPref = &GeneralNicknamesListPref;
1160 NicknamesList = &HomeNicknamesList;
1161 NicknamesListType = &HomeNicknamesListType;
1162 NicknamesListLanguage = &HomeNicknamesListLanguage;
1163 NicknamesListAltID = &HomeNicknamesListAltID;
1164 NicknamesListPID = &HomeNicknamesListPID;
1165 NicknamesListTokens = &HomeNicknamesListTokens;
1166 NicknamesListPref = &HomeNicknamesListPref;
1169 NicknamesList = &BusinessNicknamesList;
1170 NicknamesListType = &BusinessNicknamesListType;
1171 NicknamesListLanguage = &BusinessNicknamesListLanguage;
1172 NicknamesListAltID = &BusinessNicknamesListAltID;
1173 NicknamesListPID = &BusinessNicknamesListPID;
1174 NicknamesListTokens = &BusinessNicknamesListTokens;
1175 NicknamesListPref = &BusinessNicknamesListPref;
1179 std::map<int, int>::iterator SLiter;
1180 wxString PropertyData;
1181 wxString PropertyName;
1182 wxString PropertyValue;
1183 wxString PropertyTokens;
1184 bool FirstToken = TRUE;
1186 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1187 intiter != SplitPoints.end(); ++intiter){
1189 SLiter = SplitLength.find(intiter->first);
1191 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1193 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1194 PropertyName = PropertyElement.GetNextToken();
1195 PropertyValue = PropertyElement.GetNextToken();
1197 intPrevValue = intiter->second;
1199 CaptureString(&PropertyValue, FALSE);
1201 if (PropertyName == wxT("ALTID")){
1203 NicknamesListAltID->erase(*NicknameCount);
1204 NicknamesListAltID->insert(std::make_pair(*NicknameCount, PropertyValue));
1206 } else if (PropertyName == wxT("PID")){
1208 NicknamesListPID->erase(*NicknameCount);
1209 NicknamesListPID->insert(std::make_pair(*NicknameCount, PropertyValue));
1211 } else if (PropertyName == wxT("PREF")){
1213 ProcessIntegerValue(NicknamesListPref, &PropertyValue, NicknameCount);
1215 } else if (PropertyName == wxT("LANGUAGE")){
1217 NicknamesListLanguage->erase(*NicknameCount);
1218 NicknamesListLanguage->insert(std::make_pair(*NicknameCount, PropertyValue));
1222 // Something else we don't know about so append
1223 // to the tokens variable.
1225 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1227 if (FirstToken == TRUE){
1229 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1234 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1244 NicknamesList->insert(std::make_pair(*NicknameCount, PropertySeg2));
1246 // Add the name token data.
1248 if (!PropertyTokens.IsEmpty()){
1250 NicknamesListTokens->insert(std::make_pair(*NicknameCount, PropertyTokens));
1256 void ContactDataObject::ProcessGender(wxString PropertySeg1, wxString PropertySeg2){
1258 std::map<int, int> SplitPoints;
1259 std::map<int, int> SplitLength;
1260 std::map<int, int>::iterator SLiter;
1261 wxString PropertyData;
1262 wxString PropertyName;
1263 wxString PropertyValue;
1264 wxString PropertyTokens;
1265 bool FirstToken = TRUE;
1266 int intPrevValue = 8;
1268 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1272 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1273 intiter != SplitPoints.end(); ++intiter){
1275 SLiter = SplitLength.find(intiter->first);
1277 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1279 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1280 PropertyName = PropertyElement.GetNextToken();
1281 PropertyValue = PropertyElement.GetNextToken();
1283 intPrevValue = intiter->second;
1285 // Process properties.
1287 size_t intPropertyValueLen = PropertyValue.Len();
1289 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
1291 PropertyValue.Trim();
1292 PropertyValue.RemoveLast();
1296 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1298 PropertyValue.Remove(0, 1);
1302 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1304 if (FirstToken == TRUE){
1306 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1311 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1319 wxStringTokenizer GenderData (PropertySeg2, wxT(";"));
1321 wxString GenderComponent;
1323 if (GenderData.CountTokens() >= 2){
1325 Gender = GenderData.GetNextToken();
1326 GenderDetails = GenderData.GetString();
1328 CaptureString(&GenderDetails, FALSE);
1332 Gender = GenderData.GetNextToken();
1336 if (!PropertyTokens.IsEmpty()){
1338 GenderTokens = PropertyTokens;
1344 void ContactDataObject::ProcessBirthday(wxString PropertySeg1, wxString PropertySeg2){
1346 // Process date. Preserve the remainder in the string.
1348 std::map<int, int> SplitPoints;
1349 std::map<int, int> SplitLength;
1350 std::map<int, int>::iterator SLiter;
1351 wxString PropertyData;
1352 wxString PropertyName;
1353 wxString PropertyValue;
1354 wxString PropertyTokens;
1355 bool BirthdayText = FALSE;
1356 int intPrevValue = 6;
1358 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1362 // Look for type before continuing.
1364 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1365 intiter != SplitPoints.end(); ++intiter){
1367 SLiter = SplitLength.find(intiter->first);
1369 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1371 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1372 PropertyName = PropertyElement.GetNextToken();
1373 PropertyValue = PropertyElement.GetNextToken();
1375 intPrevValue = intiter->second;
1377 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && BirthdayText == FALSE){
1379 CaptureString(&PropertySeg2, FALSE);
1380 Birthday = PropertySeg2;
1381 BirthdayText = TRUE;
1387 // Setup blank lines for later on.
1390 bool FirstToken = TRUE;
1392 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1393 intiter != SplitPoints.end(); ++intiter){
1395 SLiter = SplitLength.find(intiter->first);
1397 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1399 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1400 PropertyName = PropertyElement.GetNextToken();
1401 PropertyValue = PropertyElement.GetNextToken();
1403 intPrevValue = intiter->second;
1405 // Process properties.
1407 CaptureString(&PropertyValue, FALSE);
1409 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1411 PropertyValue.Trim();
1412 PropertyValue.RemoveLast();
1416 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1418 PropertyValue.Remove(0, 1);
1422 if (PropertyName == wxT("ALTID")){
1424 BirthdayAltID = PropertyValue;
1426 } else if (PropertyName == wxT("CALSCALE")){
1428 BirthdayCalScale = PropertyValue;
1430 } else if (PropertyName != wxT("VALUE")) {
1432 // Something else we don't know about so append
1433 // to the tokens variable.
1435 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1437 if (FirstToken == TRUE){
1439 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1444 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1454 // Add the data to the variables and form.
1456 if (BirthdayText == FALSE){
1458 Birthday = PropertySeg2;
1462 if (!PropertyTokens.IsEmpty()){
1464 BirthdayTokens = PropertyTokens;
1470 void ContactDataObject::ProcessAnniversary(wxString PropertySeg1, wxString PropertySeg2){
1472 // Process date. Preserve the remainder in the string.
1474 std::map<int, int> SplitPoints;
1475 std::map<int, int> SplitLength;
1476 std::map<int, int>::iterator SLiter;
1477 wxString PropertyData;
1478 wxString PropertyName;
1479 wxString PropertyValue;
1480 wxString PropertyTokens;
1481 bool AnniversaryText = FALSE;
1482 int intPrevValue = 13;
1484 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1488 // Look for type before continuing.
1490 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1491 intiter != SplitPoints.end(); ++intiter){
1493 SLiter = SplitLength.find(intiter->first);
1495 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1497 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1498 PropertyName = PropertyElement.GetNextToken();
1499 PropertyValue = PropertyElement.GetNextToken();
1501 intPrevValue = intiter->second;
1503 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && AnniversaryText == FALSE){
1505 CaptureString(&PropertySeg2, FALSE);
1506 Anniversary = PropertySeg2;
1507 AnniversaryText = TRUE;
1513 // Setup blank lines for later on.
1516 bool FirstToken = TRUE;
1518 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1519 intiter != SplitPoints.end(); ++intiter){
1521 SLiter = SplitLength.find(intiter->first);
1523 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1525 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1526 PropertyName = PropertyElement.GetNextToken();
1527 PropertyValue = PropertyElement.GetNextToken();
1529 intPrevValue = intiter->second;
1531 // Process properties.
1533 CaptureString(&PropertyValue, FALSE);
1535 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1537 PropertyValue.Trim();
1538 PropertyValue.RemoveLast();
1542 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1544 PropertyValue.Remove(0, 1);
1548 if (PropertyName == wxT("ALTID")){
1550 AnniversaryAltID = PropertyValue;
1552 } else if (PropertyName == wxT("CALSCALE")){
1554 AnniversaryCalScale = PropertyValue;
1556 } else if (PropertyName != wxT("VALUE")) {
1558 // Something else we don't know about so append
1559 // to the tokens variable.
1561 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1563 if (FirstToken == TRUE){
1565 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1570 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1580 // Add the data to the variables and form.
1582 if (AnniversaryText == FALSE){
1584 Anniversary = PropertySeg2;
1588 if (!PropertyTokens.IsEmpty()){
1590 AnniversaryTokens = PropertyTokens;
1596 void ContactDataObject::ProcessTimeZone(wxString PropertySeg1, wxString PropertySeg2, int *TimeZoneCount){
1598 std::map<int, int> SplitPoints;
1599 std::map<int, int> SplitLength;
1601 int intPrevValue = 4;
1604 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1608 PropertyType PropType = PROPERTY_NONE;
1610 // Look for type before continuing.
1612 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1616 std::map<int, wxString> *TZList = NULL;
1617 std::map<int, wxString> *TZListType = NULL;
1618 std::map<int, wxString> *TZListMediatype = NULL;
1619 std::map<int, wxString> *TZListAltID = NULL;
1620 std::map<int, wxString> *TZListPID = NULL;
1621 std::map<int, wxString> *TZListTokens = NULL;
1622 std::map<int, int> *TZListPref = NULL;
1626 TZList = &GeneralTZList;
1627 TZListType = &GeneralTZListType;
1628 TZListMediatype = &GeneralTZListMediatype;
1629 TZListAltID = &GeneralTZListAltID;
1630 TZListPID = &GeneralTZListPID;
1631 TZListTokens = &GeneralTZListTokens;
1632 TZListPref = &GeneralTZListPref;
1635 TZList = &HomeTZList;
1636 TZListType = &HomeTZListType;
1637 TZListMediatype = &HomeTZListMediatype;
1638 TZListAltID = &HomeTZListAltID;
1639 TZListPID = &HomeTZListPID;
1640 TZListTokens = &HomeTZListTokens;
1641 TZListPref = &HomeTZListPref;
1644 TZList = &BusinessTZList;
1645 TZListType = &BusinessTZListType;
1646 TZListMediatype = &BusinessTZListMediatype;
1647 TZListAltID = &BusinessTZListAltID;
1648 TZListPID = &BusinessTZListPID;
1649 TZListTokens = &BusinessTZListTokens;
1650 TZListPref = &BusinessTZListPref;
1654 std::map<int, int>::iterator SLiter;
1655 wxString PropertyData;
1656 wxString PropertyName;
1657 wxString PropertyValue;
1658 wxString PropertyTokens;
1659 bool FirstToken = TRUE;
1661 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1662 intiter != SplitPoints.end(); ++intiter){
1664 SLiter = SplitLength.find(intiter->first);
1666 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1668 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1669 PropertyName = PropertyElement.GetNextToken();
1670 PropertyValue = PropertyElement.GetNextToken();
1672 intPrevValue = intiter->second;
1674 CaptureString(&PropertyValue, FALSE);
1676 if (PropertyName == wxT("ALTID")){
1678 TZListAltID->erase(*TimeZoneCount);
1679 TZListAltID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1681 } else if (PropertyName == wxT("PID")){
1683 TZListPID->erase(*TimeZoneCount);
1684 TZListPID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1686 } else if (PropertyName == wxT("PREF")){
1688 ProcessIntegerValue(TZListPref, &PropertyValue, TimeZoneCount);
1690 } else if (PropertyName == wxT("MEDIATYPE")){
1692 TZListMediatype->erase(*TimeZoneCount);
1693 TZListMediatype->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1697 // Something else we don't know about so append
1698 // to the tokens variable.
1700 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1702 if (FirstToken == TRUE){
1704 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1709 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1719 TZList->insert(std::make_pair(*TimeZoneCount, PropertySeg2));
1721 // Add the name token data.
1723 if (!PropertyTokens.IsEmpty()){
1725 TZListTokens->insert(std::make_pair(*TimeZoneCount, PropertyTokens));
1732 void ContactDataObject::ProcessAddress(wxString PropertySeg1, wxString PropertySeg2, int *AddressCount){
1734 size_t intPropertyLen = PropertySeg1.Len();
1735 std::map<int, int> SplitPoints;
1736 std::map<int, int> SplitLength;
1737 std::map<int, int>::iterator SLiter;
1738 wxString PropertyData;
1739 wxString PropertyName;
1740 wxString PropertyValue;
1741 wxString PropertyTokens;
1742 wxString AddressLabel;
1743 wxString AddressLang;
1744 wxString AddressAltID;
1745 wxString AddressPID;
1746 wxString AddressTokens;
1747 wxString AddressGeo;
1748 wxString AddressTimezone;
1749 wxString AddressType;
1750 wxString AddressMediatype;
1751 wxString AddressPOBox;
1752 wxString AddressExtended;
1753 wxString AddressStreet;
1754 wxString AddressLocality;
1755 wxString AddressCity;
1756 wxString AddressRegion;
1757 wxString AddressPostalCode;
1758 wxString AddressCountry;
1759 bool FirstToken = TRUE;
1760 int intSplitsFound = 0;
1761 int intSplitSize = 0;
1762 int intPrevValue = 5;
1767 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1771 PropertyType PropType = PROPERTY_NONE;
1773 // Look for type before continuing.
1775 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1779 std::map<int, wxString> *AddressList = NULL;
1780 std::map<int, wxString> *AddressListTown = NULL;
1781 std::map<int, wxString> *AddressListCounty = NULL;
1782 std::map<int, wxString> *AddressListPostCode = NULL;
1783 std::map<int, wxString> *AddressListCountry = NULL;
1784 std::map<int, wxString> *AddressListLabel = NULL;
1785 std::map<int, wxString> *AddressListLang = NULL;
1786 std::map<int, wxString> *AddressListAltID = NULL;
1787 std::map<int, wxString> *AddressListPID = NULL;
1788 std::map<int, wxString> *AddressListTokens = NULL;
1789 std::map<int, wxString> *AddressListGeo = NULL;
1790 std::map<int, wxString> *AddressListTimezone = NULL;
1791 std::map<int, wxString> *AddressListType = NULL;
1792 std::map<int, wxString> *AddressListMediatype = NULL;
1793 std::map<int, int> *AddressListPref = NULL;
1797 AddressList = &GeneralAddressList;
1798 AddressListTown = &GeneralAddressListTown;
1799 AddressListCounty = &GeneralAddressListCounty;
1800 AddressListPostCode = &GeneralAddressListPostCode;
1801 AddressListCountry = &GeneralAddressListCountry;
1802 AddressListLabel = &GeneralAddressListLabel;
1803 AddressListLang = &GeneralAddressListLang;
1804 AddressListAltID = &GeneralAddressListAltID;
1805 AddressListPID = &GeneralAddressListPID;
1806 AddressListTokens = &GeneralAddressListTokens;
1807 AddressListGeo = &GeneralAddressListGeo;
1808 AddressListTimezone = &GeneralAddressListTimezone;
1809 AddressListType = &GeneralAddressListType;
1810 AddressListMediatype = &GeneralAddressListMediatype;
1811 AddressListPref = &GeneralAddressListPref;
1814 AddressList = &HomeAddressList;
1815 AddressListTown = &HomeAddressListTown;
1816 AddressListCounty = &HomeAddressListCounty;
1817 AddressListPostCode = &HomeAddressListPostCode;
1818 AddressListCountry = &HomeAddressListCountry;
1819 AddressListLabel = &HomeAddressListLabel;
1820 AddressListLang = &HomeAddressListLang;
1821 AddressListAltID = &HomeAddressListAltID;
1822 AddressListPID = &HomeAddressListPID;
1823 AddressListTokens = &HomeAddressListTokens;
1824 AddressListGeo = &HomeAddressListGeo;
1825 AddressListTimezone = &HomeAddressListTimezone;
1826 AddressListType = &HomeAddressListType;
1827 AddressListMediatype = &HomeAddressListMediatype;
1828 AddressListPref = &HomeAddressListPref;
1831 AddressList = &BusinessAddressList;
1832 AddressListTown = &BusinessAddressListTown;
1833 AddressListCounty = &BusinessAddressListCounty;
1834 AddressListPostCode = &BusinessAddressListPostCode;
1835 AddressListCountry = &BusinessAddressListCountry;
1836 AddressListLabel = &BusinessAddressListLabel;
1837 AddressListLang = &BusinessAddressListLang;
1838 AddressListAltID = &BusinessAddressListAltID;
1839 AddressListPID = &BusinessAddressListPID;
1840 AddressListTokens = &BusinessAddressListTokens;
1841 AddressListGeo = &BusinessAddressListGeo;
1842 AddressListTimezone = &BusinessAddressListTimezone;
1843 AddressListType = &BusinessAddressListType;
1844 AddressListMediatype = &BusinessAddressListMediatype;
1845 AddressListPref = &BusinessAddressListPref;
1851 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1852 intiter != SplitPoints.end(); ++intiter){
1854 SLiter = SplitLength.find(intiter->first);
1856 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1858 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1859 PropertyName = PropertyElement.GetNextToken();
1860 PropertyValue = PropertyElement.GetNextToken();
1862 intPrevValue = intiter->second;
1864 CaptureString(&PropertyValue, FALSE);
1866 // Process properties.
1868 if (PropertyName == wxT("LABEL")){
1870 AddressListLabel->erase(*AddressCount);
1871 AddressListLabel->insert(std::make_pair(*AddressCount, PropertyValue));
1873 } else if (PropertyName == wxT("LANGUAGE")){
1875 AddressListLang->erase(*AddressCount);
1876 AddressListLang->insert(std::make_pair(*AddressCount, PropertyValue));
1878 } else if (PropertyName == wxT("ALTID")){
1880 AddressListAltID->erase(*AddressCount);
1881 AddressListAltID->insert(std::make_pair(*AddressCount, PropertyValue));
1883 } else if (PropertyName == wxT("PID")){
1885 AddressListPID->erase(*AddressCount);
1886 AddressListPID->insert(std::make_pair(*AddressCount, PropertyValue));
1888 } else if (PropertyName == wxT("GEO")){
1890 AddressListGeo->erase(*AddressCount);
1891 AddressListGeo->insert(std::make_pair(*AddressCount, PropertyValue));
1893 } else if (PropertyName == wxT("TZ")){
1895 AddressListTimezone->erase(*AddressCount);
1896 AddressListTimezone->insert(std::make_pair(*AddressCount, PropertyValue));
1898 } else if (PropertyName == wxT("MEDIATYPE")){
1900 AddressListMediatype->erase(*AddressCount);
1901 AddressListMediatype->insert(std::make_pair(*AddressCount, PropertyValue));
1903 } else if (PropertyName == wxT("PREF")){
1905 ProcessIntegerValue(AddressListPref, &PropertyValue, AddressCount);
1909 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1911 if (FirstToken == TRUE){
1913 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1918 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1928 // Split the address.
1930 //std::map<int, int>::iterator SLiter;
1931 intPropertyLen = PropertySeg2.Len();
1932 SplitPoints.clear();
1933 SplitLength.clear();
1938 for (int i = 0; i <= intPropertyLen; i++){
1942 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
1945 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
1947 if (intSplitsFound == 6){
1949 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1954 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1964 // Split the data into several parts.
1966 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1967 intiter != SplitPoints.end(); ++intiter){
1969 if (intiter->first == 1){
1971 // Deal with PO Box.
1973 SLiter = SplitLength.find(1);
1975 //txtSurname->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(0, SLiter->second), TRUE));
1976 AddressPOBox = PropertySeg2.Mid(0, SLiter->second);
1977 intPrevValue = intiter->second;
1979 } else if (intiter->first == 2){
1981 // Deal with extended address.
1983 SLiter = SplitLength.find(2);
1985 AddressExtended = PropertySeg2.Mid(intPrevValue, SLiter->second);
1986 //txtForename->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1987 intPrevValue = intiter->second;
1989 } else if (intiter->first == 3){
1991 // Deal with street address.
1993 SLiter = SplitLength.find(3);
1995 AddressStreet = PropertySeg2.Mid(intPrevValue, SLiter->second);
1996 //txtOtherNames->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1997 intPrevValue = intiter->second;
1999 } else if (intiter->first == 4){
2001 // Deal with locality
2003 SLiter = SplitLength.find(4);
2005 AddressLocality = PropertySeg2.Mid(intPrevValue, SLiter->second);
2006 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2007 intPrevValue = intiter->second;
2009 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
2011 } else if (intiter->first == 5){
2013 // Deal with region.
2015 SLiter = SplitLength.find(5);
2017 AddressRegion = PropertySeg2.Mid(intPrevValue, SLiter->second);
2018 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2019 intPrevValue = intiter->second;
2021 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
2023 } else if (intiter->first == 6){
2025 // Deal with post code.
2027 SLiter = SplitLength.find(6);
2029 AddressPostalCode = PropertySeg2.Mid(intPrevValue, SLiter->second);
2030 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2031 intPrevValue = intiter->second;
2033 // Deal with country.
2035 AddressCountry = PropertySeg2.Mid(intPrevValue, wxString::npos);
2036 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
2044 // Add the data to the General/Home/Work address variables.
2046 CaptureString(&AddressStreet, FALSE);
2047 CaptureString(&AddressLocality, FALSE);
2048 CaptureString(&AddressRegion, FALSE);
2049 CaptureString(&AddressPostalCode, FALSE);
2050 CaptureString(&AddressCountry, FALSE);
2052 if (!PropertyTokens.IsEmpty()){
2054 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
2058 AddressListCountry->insert(std::make_pair(*AddressCount, AddressCountry));
2059 AddressList->insert(std::make_pair(*AddressCount, AddressStreet));
2060 AddressListTown->insert(std::make_pair(*AddressCount, AddressLocality));
2061 AddressListCounty->insert(std::make_pair(*AddressCount, AddressRegion));
2062 AddressListPostCode->insert(std::make_pair(*AddressCount, AddressPostalCode));
2066 AddressListType->insert(std::make_pair(*AddressCount, wxT("")));
2069 AddressListType->insert(std::make_pair(*AddressCount, wxT("home")));
2072 AddressListType->insert(std::make_pair(*AddressCount, wxT("work")));
2076 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
2080 void ContactDataObject::ProcessEmail(wxString PropertySeg1, wxString PropertySeg2, int *EmailCount){
2082 std::map<int, int> SplitPoints;
2083 std::map<int, int> SplitLength;
2085 int intPrevValue = 7;
2088 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2092 PropertyType PropType = PROPERTY_NONE;
2094 // Look for type before continuing.
2096 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2098 std::map<int, wxString> *EmailList = NULL;
2099 std::map<int, wxString> *EmailListType = NULL;
2100 std::map<int, wxString> *EmailListAltID = NULL;
2101 std::map<int, wxString> *EmailListPID = NULL;
2102 std::map<int, wxString> *EmailListTokens = NULL;
2103 std::map<int, int> *EmailListPref = NULL;
2107 EmailList = &GeneralEmailList;
2108 EmailListType = &GeneralEmailListType;
2109 EmailListAltID = &GeneralEmailListAltID;
2110 EmailListPID = &GeneralEmailListPID;
2111 EmailListTokens = &GeneralEmailListTokens;
2112 EmailListPref = &GeneralEmailListPref;
2115 EmailList = &HomeEmailList;
2116 EmailListType = &HomeEmailListType;
2117 EmailListAltID = &HomeEmailListAltID;
2118 EmailListPID = &HomeEmailListPID;
2119 EmailListTokens = &HomeEmailListTokens;
2120 EmailListPref = &HomeEmailListPref;
2123 EmailList = &BusinessEmailList;
2124 EmailListType = &BusinessEmailListType;
2125 EmailListAltID = &BusinessEmailListAltID;
2126 EmailListPID = &BusinessEmailListPID;
2127 EmailListTokens = &BusinessEmailListTokens;
2128 EmailListPref = &BusinessEmailListPref;
2134 std::map<int,int>::iterator SLiter;
2135 wxString PropertyData;
2136 wxString PropertyName;
2137 wxString PropertyValue;
2138 wxString PropertyTokens;
2139 bool FirstToken = TRUE;
2141 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2142 intiter != SplitPoints.end(); ++intiter){
2144 SLiter = SplitLength.find(intiter->first);
2146 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2148 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2149 PropertyName = PropertyElement.GetNextToken();
2150 PropertyValue = PropertyElement.GetNextToken();
2152 intPrevValue = intiter->second;
2154 CaptureString(&PropertyValue, FALSE);
2156 // Process properties.
2158 if (PropertyName == wxT("ALTID")){
2160 EmailListAltID->erase(*EmailCount);
2161 EmailListAltID->insert(std::make_pair(*EmailCount, PropertyValue));
2163 } else if (PropertyName == wxT("PID")){
2165 EmailListPID->erase(*EmailCount);
2166 EmailListPID->insert(std::make_pair(*EmailCount, PropertyValue));
2168 } else if (PropertyName == wxT("PREF")){
2170 ProcessIntegerValue(EmailListPref, &PropertyValue, EmailCount);
2174 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2176 if (FirstToken == TRUE){
2178 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2183 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2193 EmailList->insert(std::make_pair(*EmailCount, PropertySeg2));
2195 // Add the name token data.
2197 if (!PropertyTokens.IsEmpty()){
2199 EmailListTokens->insert(std::make_pair(*EmailCount, PropertyTokens));
2206 void ContactDataObject::ProcessIM(wxString PropertySeg1, wxString PropertySeg2, int *IMCount){
2208 std::map<int, int> SplitPoints;
2209 std::map<int, int> SplitLength;
2211 int intPrevValue = 6;
2214 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2218 PropertyType PropType = PROPERTY_NONE;
2220 // Look for type before continuing.
2222 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2224 std::map<int, wxString> *IMList = NULL;
2225 std::map<int, wxString> *IMListType = NULL;
2226 std::map<int, wxString> *IMListAltID = NULL;
2227 std::map<int, wxString> *IMListPID = NULL;
2228 std::map<int, wxString> *IMListTokens = NULL;
2229 std::map<int, wxString> *IMListMediatype = NULL;
2230 std::map<int, int> *IMListPref = NULL;
2234 IMList = &GeneralIMList;
2235 IMListType = &GeneralIMListType;
2236 IMListAltID = &GeneralIMListAltID;
2237 IMListPID = &GeneralIMListPID;
2238 IMListTokens = &GeneralIMListTokens;
2239 IMListMediatype = &GeneralIMListMediatype;
2240 IMListPref = &GeneralIMListPref;
2243 IMList = &HomeIMList;
2244 IMListType = &HomeIMListType;
2245 IMListAltID = &HomeIMListAltID;
2246 IMListPID = &HomeIMListPID;
2247 IMListTokens = &HomeIMListTokens;
2248 IMListMediatype = &HomeIMListMediatype;
2249 IMListPref = &HomeIMListPref;
2252 IMList = &BusinessIMList;
2253 IMListType = &BusinessIMListType;
2254 IMListAltID = &BusinessIMListAltID;
2255 IMListPID = &BusinessIMListPID;
2256 IMListTokens = &BusinessIMListTokens;
2257 IMListMediatype = &BusinessIMListMediatype;
2258 IMListPref = &BusinessIMListPref;
2264 std::map<int,int>::iterator SLiter;
2265 wxString PropertyData;
2266 wxString PropertyName;
2267 wxString PropertyValue;
2268 wxString PropertyTokens;
2269 bool FirstToken = TRUE;
2271 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2272 intiter != SplitPoints.end(); ++intiter){
2274 SLiter = SplitLength.find(intiter->first);
2276 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2278 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2279 PropertyName = PropertyElement.GetNextToken();
2280 PropertyValue = PropertyElement.GetNextToken();
2282 intPrevValue = intiter->second;
2284 CaptureString(&PropertyValue, FALSE);
2286 // Process properties.
2288 if (PropertyName == wxT("ALTID")){
2290 IMListAltID->erase(*IMCount);
2291 IMListAltID->insert(std::make_pair(*IMCount, PropertyValue));
2293 } else if (PropertyName == wxT("PID")){
2295 IMListPID->erase(*IMCount);
2296 IMListPID->insert(std::make_pair(*IMCount, PropertyValue));
2298 } else if (PropertyName == wxT("MEDIATYPE")){
2300 IMListMediatype->erase(*IMCount);
2301 IMListMediatype->insert(std::make_pair(*IMCount, PropertyValue));
2303 } else if (PropertyName == wxT("PREF")){
2305 ProcessIntegerValue(IMListPref, &PropertyValue, IMCount);
2309 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2311 if (FirstToken == TRUE){
2313 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2318 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2328 IMList->insert(std::make_pair(*IMCount, PropertySeg2));
2330 // Add the name token data.
2332 if (!PropertyTokens.IsEmpty()){
2334 IMListTokens->insert(std::make_pair(*IMCount, PropertyTokens));
2340 void ContactDataObject::ProcessTelephone(wxString PropertySeg1, wxString PropertySeg2, int *TelephoneCount){
2342 std::map<int, int> SplitPoints;
2343 std::map<int, int> SplitLength;
2344 std::map<int, int>::iterator SLiter;
2348 PropertyType PropType = PROPERTY_NONE;
2350 // Look for type before continuing.
2353 wxString TelTypeDetail;
2354 wxString PropertyData;
2355 wxString PropertyName;
2356 wxString PropertyValue;
2357 wxString PropertyTokens;
2359 std::map<int,int> TypeSplitPoints;
2360 std::map<int,int> TypeSplitLength;
2361 std::map<int,int>::iterator TSLiter;
2363 int intSplitSize = 0;
2364 int intSplitsFound = 0;
2365 int intSplitPoint = 0;
2367 int intPrevValue = 5;
2369 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2373 // Look for type before continuing.
2375 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2376 intiter != SplitPoints.end(); ++intiter){
2378 SLiter = SplitLength.find(intiter->first);
2380 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2382 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2383 PropertyName = PropertyElement.GetNextToken();
2384 PropertyValue = PropertyElement.GetNextToken();
2386 intPrevValue = intiter->second;
2388 if (PropertyName == wxT("TYPE")){
2390 // Process each value in type and translate each
2393 // Strip out the quotes if they are there.
2395 size_t intPropertyValueLen = PropertyValue.Len();
2397 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2399 PropertyValue.Trim();
2400 PropertyValue.RemoveLast();
2404 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2406 PropertyValue.Remove(0, 1);
2410 TelTypeDetail = PropertyValue;
2416 for (int i = 0; i <= intPropertyValueLen; i++){
2420 if (PropertyValue.Mid(i, 1) == wxT(",") && PropertyValue.Mid((i - 1), 1) != wxT("\\")){
2422 if (intSplitsFound == 0){
2424 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2425 TypeSplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2429 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2430 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2443 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2444 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2446 int intTypeSeek = 0;
2448 for (std::map<int, int>::iterator typeiter = TypeSplitPoints.begin();
2449 typeiter != TypeSplitPoints.end(); ++typeiter){
2451 wxString TypePropertyName;
2453 TSLiter = TypeSplitLength.find(typeiter->first);
2455 TypePropertyName = PropertyValue.Mid(typeiter->second, TSLiter->second);
2457 if (intTypeSeek == 0){
2462 TelTypeUI.Append(wxT(","));
2466 if (TypePropertyName == wxT("home")){
2468 PropType = PROPERTY_HOME;
2470 } else if (TypePropertyName == wxT("work")){
2472 PropType = PROPERTY_WORK;
2477 if (TypePropertyName == wxT("text")){
2479 TelTypeUI.Append(_("text"));
2482 } else if (TypePropertyName == wxT("voice")){
2484 TelTypeUI.Append(_("voice"));
2487 } else if (TypePropertyName == wxT("fax")){
2489 TelTypeUI.Append(_("fax"));
2492 } else if (TypePropertyName == wxT("cell")){
2494 TelTypeUI.Append(_("mobile"));
2497 } else if (TypePropertyName == wxT("video")){
2499 TelTypeUI.Append(_("video"));
2502 } else if (TypePropertyName == wxT("pager")){
2504 TelTypeUI.Append(_("pager"));
2507 } else if (TypePropertyName == wxT("textphone")){
2509 TelTypeUI.Append(_("textphone"));
2520 std::map<int, wxString> *TelephoneList = NULL;
2521 std::map<int, wxString> *TelephoneListType = NULL;
2522 std::map<int, wxString> *TelephoneListAltID = NULL;
2523 std::map<int, wxString> *TelephoneListPID = NULL;
2524 std::map<int, wxString> *TelephoneListTokens = NULL;
2525 std::map<int, wxString> *TelephoneListTypeInfo = NULL;
2526 std::map<int, int> *TelephoneListPref = NULL;
2530 TelephoneList = &GeneralTelephoneList;
2531 TelephoneListType = &GeneralTelephoneListType;
2532 TelephoneListAltID = &GeneralTelephoneListAltID;
2533 TelephoneListPID = &GeneralTelephoneListPID;
2534 TelephoneListTokens = &GeneralTelephoneListTokens;
2535 TelephoneListTypeInfo = &GeneralTelephoneListTypeInfo;
2536 TelephoneListPref = &GeneralTelephoneListPref;
2539 TelephoneList = &HomeTelephoneList;
2540 TelephoneListType = &HomeTelephoneListType;
2541 TelephoneListAltID = &HomeTelephoneListAltID;
2542 TelephoneListPID = &HomeTelephoneListPID;
2543 TelephoneListTokens = &HomeTelephoneListTokens;
2544 TelephoneListTypeInfo = &HomeTelephoneListTypeInfo;
2545 TelephoneListPref = &HomeTelephoneListPref;
2548 TelephoneList = &BusinessTelephoneList;
2549 TelephoneListType = &BusinessTelephoneListType;
2550 TelephoneListAltID = &BusinessTelephoneListAltID;
2551 TelephoneListPID = &BusinessTelephoneListPID;
2552 TelephoneListTokens = &BusinessTelephoneListTokens;
2553 TelephoneListTypeInfo = &BusinessTelephoneListTypeInfo;
2554 TelephoneListPref = &BusinessTelephoneListPref;
2558 // Process the properties.
2560 bool FirstToken = TRUE;
2563 SplitPoints.clear();
2564 SplitLength.clear();
2566 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2570 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2571 intiter != SplitPoints.end(); ++intiter){
2573 SLiter = SplitLength.find(intiter->first);
2575 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2577 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2578 PropertyName = PropertyElement.GetNextToken();
2579 PropertyValue = PropertyElement.GetNextToken();
2581 intPrevValue = intiter->second;
2583 CaptureString(&PropertyValue, FALSE);
2585 // Process properties.
2587 if (PropertyName == wxT("ALTID")){
2589 TelephoneListAltID->erase(*TelephoneCount);
2590 TelephoneListAltID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2592 } else if (PropertyName == wxT("PID")){
2594 TelephoneListPID->erase(*TelephoneCount);
2595 TelephoneListPID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2597 } else if (PropertyName == wxT("PREF")){
2599 ProcessIntegerValue(TelephoneListPref, &PropertyValue, TelephoneCount);
2603 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2605 if (FirstToken == TRUE){
2607 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2612 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2622 TelephoneList->insert(std::make_pair(*TelephoneCount, PropertySeg2));
2623 TelephoneListTypeInfo->insert(std::make_pair(*TelephoneCount, TelTypeUI));
2625 // Add the name token data.
2627 if (!PropertyTokens.IsEmpty()){
2629 TelephoneListTokens->insert(std::make_pair(*TelephoneCount, PropertyTokens));
2635 void ContactDataObject::ProcessLanguage(wxString PropertySeg1, wxString PropertySeg2, int *LanguageCount){
2637 std::map<int, int> SplitPoints;
2638 std::map<int, int> SplitLength;
2640 int intPrevValue = 6;
2643 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2647 PropertyType PropType = PROPERTY_NONE;
2649 // Look for type before continuing.
2651 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2653 std::map<int, wxString> *LanguageList = NULL;
2654 std::map<int, wxString> *LanguageListType = NULL;
2655 std::map<int, wxString> *LanguageListAltID = NULL;
2656 std::map<int, wxString> *LanguageListPID = NULL;
2657 std::map<int, wxString> *LanguageListTokens = NULL;
2658 std::map<int, int> *LanguageListPref = NULL;
2662 LanguageList = &GeneralLanguageList;
2663 LanguageListType = &GeneralLanguageListType;
2664 LanguageListAltID = &GeneralLanguageListAltID;
2665 LanguageListPID = &GeneralLanguageListPID;
2666 LanguageListTokens = &GeneralLanguageListTokens;
2667 LanguageListPref = &GeneralLanguageListPref;
2670 LanguageList = &HomeLanguageList;
2671 LanguageListType = &HomeLanguageListType;
2672 LanguageListAltID = &HomeLanguageListAltID;
2673 LanguageListPID = &HomeLanguageListPID;
2674 LanguageListTokens = &HomeLanguageListTokens;
2675 LanguageListPref = &HomeLanguageListPref;
2678 LanguageList = &BusinessLanguageList;
2679 LanguageListType = &BusinessLanguageListType;
2680 LanguageListAltID = &BusinessLanguageListAltID;
2681 LanguageListPID = &BusinessLanguageListPID;
2682 LanguageListTokens = &BusinessLanguageListTokens;
2683 LanguageListPref = &BusinessLanguageListPref;
2689 std::map<int,int>::iterator SLiter;
2690 wxString PropertyData;
2691 wxString PropertyName;
2692 wxString PropertyValue;
2693 wxString PropertyTokens;
2694 bool FirstToken = TRUE;
2696 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2697 intiter != SplitPoints.end(); ++intiter){
2699 SLiter = SplitLength.find(intiter->first);
2701 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2703 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2704 PropertyName = PropertyElement.GetNextToken();
2705 PropertyValue = PropertyElement.GetNextToken();
2707 intPrevValue = intiter->second;
2709 CaptureString(&PropertyValue, FALSE);
2711 // Process properties.
2713 if (PropertyName == wxT("ALTID")){
2715 LanguageListAltID->erase(*LanguageCount);
2716 LanguageListAltID->insert(std::make_pair(*LanguageCount, PropertyValue));
2718 } else if (PropertyName == wxT("PID")){
2720 LanguageListPID->erase(*LanguageCount);
2721 LanguageListPID->insert(std::make_pair(*LanguageCount, PropertyValue));
2723 } else if (PropertyName == wxT("PREF")){
2725 ProcessIntegerValue(LanguageListPref, &PropertyValue, LanguageCount);
2729 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2731 if (FirstToken == TRUE){
2733 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2738 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2748 LanguageList->insert(std::make_pair(*LanguageCount, PropertySeg2));
2750 // Add the name token data.
2752 if (!PropertyTokens.IsEmpty()){
2754 LanguageListTokens->insert(std::make_pair(*LanguageCount, PropertyTokens));
2760 void ContactDataObject::ProcessGeographic(wxString PropertySeg1, wxString PropertySeg2, int *GeographicCount){
2762 std::map<int, int> SplitPoints;
2763 std::map<int, int> SplitLength;
2765 int intPrevValue = 5;
2768 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2772 PropertyType PropType = PROPERTY_NONE;
2774 // Look for type before continuing.
2776 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2778 std::map<int, wxString> *GeopositionList = NULL;
2779 std::map<int, wxString> *GeopositionListType = NULL;
2780 std::map<int, wxString> *GeopositionListAltID = NULL;
2781 std::map<int, wxString> *GeopositionListPID = NULL;
2782 std::map<int, wxString> *GeopositionListTokens = NULL;
2783 std::map<int, wxString> *GeopositionListMediatype = NULL;
2784 std::map<int, int> *GeopositionListPref = NULL;
2788 GeopositionList = &GeneralGeographyList;
2789 GeopositionListType = &GeneralGeographyListType;
2790 GeopositionListAltID = &GeneralGeographyListAltID;
2791 GeopositionListPID = &GeneralGeographyListPID;
2792 GeopositionListTokens = &GeneralGeographyListTokens;
2793 GeopositionListMediatype = &GeneralGeographyListMediatype;
2794 GeopositionListPref = &GeneralGeographyListPref;
2797 GeopositionList = &HomeGeographyList;
2798 GeopositionListType = &HomeGeographyListType;
2799 GeopositionListAltID = &HomeGeographyListAltID;
2800 GeopositionListPID = &HomeGeographyListPID;
2801 GeopositionListTokens = &HomeGeographyListTokens;
2802 GeopositionListMediatype = &HomeGeographyListMediatype;
2803 GeopositionListPref = &HomeGeographyListPref;
2806 GeopositionList = &BusinessGeographyList;
2807 GeopositionListType = &BusinessGeographyListType;
2808 GeopositionListAltID = &BusinessGeographyListAltID;
2809 GeopositionListPID = &BusinessGeographyListPID;
2810 GeopositionListTokens = &BusinessGeographyListTokens;
2811 GeopositionListMediatype = &BusinessGeographyListMediatype;
2812 GeopositionListPref = &BusinessGeographyListPref;
2818 std::map<int,int>::iterator SLiter;
2819 wxString PropertyData;
2820 wxString PropertyName;
2821 wxString PropertyValue;
2822 wxString PropertyTokens;
2823 bool FirstToken = TRUE;
2825 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2826 intiter != SplitPoints.end(); ++intiter){
2828 SLiter = SplitLength.find(intiter->first);
2830 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2832 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2833 PropertyName = PropertyElement.GetNextToken();
2834 PropertyValue = PropertyElement.GetNextToken();
2836 intPrevValue = intiter->second;
2838 CaptureString(&PropertyValue, FALSE);
2840 // Process properties.
2842 if (PropertyName == wxT("ALTID")){
2844 GeopositionListAltID->erase(*GeographicCount);
2845 GeopositionListAltID->insert(std::make_pair(*GeographicCount, PropertyValue));
2847 } else if (PropertyName == wxT("PID")){
2849 GeopositionListPID->erase(*GeographicCount);
2850 GeopositionListPID->insert(std::make_pair(*GeographicCount, PropertyValue));
2852 } else if (PropertyName == wxT("MEDIATYPE")){
2854 GeopositionListMediatype->erase(*GeographicCount);
2855 GeopositionListMediatype->insert(std::make_pair(*GeographicCount, PropertyValue));
2857 } else if (PropertyName == wxT("PREF")){
2859 ProcessIntegerValue(GeopositionListPref, &PropertyValue, GeographicCount);
2863 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2865 if (FirstToken == TRUE){
2867 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2872 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2882 GeopositionList->insert(std::make_pair(*GeographicCount, PropertySeg2));
2884 // Add the name token data.
2886 if (!PropertyTokens.IsEmpty()){
2888 GeopositionListTokens->insert(std::make_pair(*GeographicCount, PropertyTokens));
2894 void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertySeg2, int *RelatedCount){
2896 size_t intPropertyLen = PropertySeg1.Len();
2897 std::map<int, int> SplitPoints;
2898 std::map<int, int> SplitLength;
2899 std::map<int, int>::iterator SLiter;
2900 wxString PropertyData;
2901 wxString PropertyName;
2902 wxString PropertyValue;
2903 wxString PropertyTokens;
2904 wxString RelatedType;
2905 wxString RelatedTypeOriginal;
2906 wxString RelatedName;
2907 bool FirstToken = TRUE;
2908 int intSplitsFound = 0;
2909 int intSplitSize = 0;
2910 int intPrevValue = 9;
2914 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2918 // Look for type before continuing.
2920 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2921 intiter != SplitPoints.end(); ++intiter){
2923 SLiter = SplitLength.find(intiter->first);
2925 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2927 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2928 PropertyName = PropertyElement.GetNextToken();
2929 PropertyValue = PropertyElement.GetNextToken();
2931 intPrevValue = intiter->second;
2935 RelatedTypeOriginal = PropertyValue;
2937 if (PropertyName == wxT("TYPE")){
2939 if (PropertyValue == wxT("contact")){
2941 RelatedType = _("Contact");
2943 } else if (PropertyValue == wxT("acquaintance")){
2945 RelatedType = _("Acquaintance");
2947 } else if (PropertyValue == wxT("friend")){
2949 RelatedType = _("Friend");
2951 } else if (PropertyValue == wxT("met")){
2953 RelatedType = _("Met");
2955 } else if (PropertyValue == wxT("co-worker")){
2957 RelatedType = _("Co-worker");
2959 } else if (PropertyValue == wxT("colleague")){
2961 RelatedType = _("Colleague");
2963 } else if (PropertyValue == wxT("co-resident")){
2965 RelatedType = _("Co-resident");
2967 } else if (PropertyValue == wxT("neighbor")){
2969 RelatedType = _("Neighbour");
2971 } else if (PropertyValue == wxT("child")){
2973 RelatedType = _("Child");
2975 } else if (PropertyValue == wxT("parent")){
2977 RelatedType = _("Parent");
2979 } else if (PropertyValue == wxT("sibling")){
2981 RelatedType = _("Sibling");
2983 } else if (PropertyValue == wxT("spouse")){
2985 RelatedType = _("Spouse");
2987 } else if (PropertyValue == wxT("kin")){
2989 RelatedType = _("Kin");
2991 } else if (PropertyValue == wxT("muse")){
2993 RelatedType = _("Muse");
2995 } else if (PropertyValue == wxT("crush")){
2997 RelatedType = _("Crush");
2999 } else if (PropertyValue == wxT("date")){
3001 RelatedType = _("Date");
3003 } else if (PropertyValue == wxT("sweetheart")){
3005 RelatedType = _("Sweetheart");
3007 } else if (PropertyValue == wxT("me")){
3009 RelatedType = _("Me");
3011 } else if (PropertyValue == wxT("agent")){
3013 RelatedType = _("Agent");
3015 } else if (PropertyValue == wxT("emergency")){
3017 RelatedType = _("Emergency");
3021 RelatedType = PropertyValue;
3031 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3032 intiter != SplitPoints.end(); ++intiter){
3034 SLiter = SplitLength.find(intiter->first);
3036 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3038 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3039 PropertyName = PropertyElement.GetNextToken();
3040 PropertyValue = PropertyElement.GetNextToken();
3042 intPrevValue = intiter->second;
3044 // Process properties.
3046 size_t intPropertyValueLen = PropertyValue.Len();
3048 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3050 PropertyValue.Trim();
3051 PropertyValue.RemoveLast();
3055 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3057 PropertyValue.Remove(0, 1);
3061 CaptureString(&PropertyValue, FALSE);
3063 if (PropertyName == wxT("ALTID")){
3065 GeneralRelatedListAltID.erase(*RelatedCount);
3066 GeneralRelatedListAltID.insert(std::make_pair(*RelatedCount, PropertyValue));
3068 } else if (PropertyName == wxT("PID")){
3070 GeneralRelatedListPID.erase(*RelatedCount);
3071 GeneralRelatedListPID.insert(std::make_pair(*RelatedCount, PropertyValue));
3073 } else if (PropertyName == wxT("PREF")){
3075 int PriorityNumber = 0;
3076 bool ValidNumber = TRUE;
3079 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3082 catch(std::invalid_argument &e){
3083 ValidNumber = FALSE;
3086 if (ValidNumber == TRUE){
3088 GeneralRelatedListPref.erase(*RelatedCount);
3089 GeneralRelatedListPref.insert(std::make_pair(*RelatedCount, PriorityNumber));
3093 } else if (PropertyName == wxT("LANGUAGE")){
3095 ProcessIntegerValue(&GeneralRelatedListPref, &PropertyValue, RelatedCount);
3097 } else if (PropertyName != wxT("TYPE")) {
3099 // Something else we don't know about so append
3100 // to the tokens variable.
3102 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3104 if (FirstToken == TRUE){
3106 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3111 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3121 // Add the data to the General/Home/Work address variables.
3123 GeneralRelatedList.erase(*RelatedCount);
3124 GeneralRelatedListRelType.erase(*RelatedCount);
3125 GeneralRelatedListType.erase(*RelatedCount);
3126 GeneralRelatedListTokens.erase(*RelatedCount);
3127 GeneralRelatedList.insert(std::make_pair(*RelatedCount, PropertySeg2));
3128 GeneralRelatedListRelType.insert(std::make_pair(*RelatedCount, RelatedType));
3129 GeneralRelatedListType.insert(std::make_pair(*RelatedCount, RelatedType));
3130 GeneralRelatedListTokens.insert(std::make_pair(*RelatedCount, PropertyTokens));
3134 void ContactDataObject::ProcessURL(wxString PropertySeg1, wxString PropertySeg2, int *URLCount){
3136 std::map<int, int> SplitPoints;
3137 std::map<int, int> SplitLength;
3138 std::map<int, int>::iterator SLiter;
3139 wxString PropertyData;
3140 wxString PropertyName;
3141 wxString PropertyValue;
3142 wxString PropertyTokens;
3143 bool FirstToken = TRUE;
3144 int intPrevValue = 5;
3149 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3153 PropertyType PropType = PROPERTY_NONE;
3155 // Look for type before continuing.
3157 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3159 // Setup the pointers.
3161 std::map<int, wxString> *WebsiteList = NULL;
3162 std::map<int, wxString> *WebsiteListAltID = NULL;
3163 std::map<int, wxString> *WebsiteListPID = NULL;
3164 std::map<int, wxString> *WebsiteListType = NULL;
3165 std::map<int, wxString> *WebsiteListTokens = NULL;
3166 std::map<int, wxString> *WebsiteListMediatype = NULL;
3167 std::map<int, int> *WebsiteListPref = NULL;
3169 // Setup blank lines for later on.
3173 WebsiteList = &GeneralWebsiteList;
3174 WebsiteListType = &GeneralWebsiteListType;
3175 WebsiteListAltID = &GeneralWebsiteListAltID;
3176 WebsiteListPID = &GeneralWebsiteListPID;
3177 WebsiteListTokens = &GeneralWebsiteListTokens;
3178 WebsiteListMediatype = &GeneralWebsiteListMediatype;
3179 WebsiteListPref = &GeneralWebsiteListPref;
3182 WebsiteList = &HomeWebsiteList;
3183 WebsiteListType = &HomeWebsiteListType;
3184 WebsiteListAltID = &HomeWebsiteListAltID;
3185 WebsiteListPID = &HomeWebsiteListPID;
3186 WebsiteListTokens = &HomeWebsiteListTokens;
3187 WebsiteListMediatype = &HomeWebsiteListMediatype;
3188 WebsiteListPref = &HomeWebsiteListPref;
3191 WebsiteList = &BusinessWebsiteList;
3192 WebsiteListType = &BusinessWebsiteListType;
3193 WebsiteListAltID = &BusinessWebsiteListAltID;
3194 WebsiteListPID = &BusinessWebsiteListPID;
3195 WebsiteListTokens = &BusinessWebsiteListTokens;
3196 WebsiteListMediatype = &BusinessWebsiteListMediatype;
3197 WebsiteListPref = &BusinessWebsiteListPref;
3203 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3204 intiter != SplitPoints.end(); ++intiter){
3206 SLiter = SplitLength.find(intiter->first);
3208 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3210 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3211 PropertyName = PropertyElement.GetNextToken();
3212 PropertyValue = PropertyElement.GetNextToken();
3214 intPrevValue = intiter->second;
3216 // Process properties.
3218 size_t intPropertyValueLen = PropertyValue.Len();
3220 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3222 PropertyValue.Trim();
3223 PropertyValue.RemoveLast();
3227 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3229 PropertyValue.Remove(0, 1);
3233 CaptureString(&PropertyValue, FALSE);
3235 if (PropertyName == wxT("ALTID")){
3237 WebsiteListAltID->erase(*URLCount);
3238 WebsiteListAltID->insert(std::make_pair(*URLCount, PropertyValue));
3240 } else if (PropertyName == wxT("PID")){
3242 WebsiteListPID->erase(*URLCount);
3243 WebsiteListPID->insert(std::make_pair(*URLCount, PropertyValue));
3245 } else if (PropertyName == wxT("PREF")){
3247 ProcessIntegerValue(WebsiteListPref, &PropertyValue, URLCount);
3249 } else if (PropertyName == wxT("MEDIATYPE")){
3251 WebsiteListMediatype->erase(*URLCount);
3252 WebsiteListMediatype->insert(std::make_pair(*URLCount, PropertyValue));
3256 // Something else we don't know about so append
3257 // to the tokens variable.
3259 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3261 if (FirstToken == TRUE){
3263 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3268 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3278 // Add the data to the General/Home/Work address variables.
3280 CaptureString(&PropertySeg2, FALSE);
3282 WebsiteList->insert(std::make_pair(*URLCount, PropertySeg2));
3284 if (!PropertyTokens.IsEmpty()){
3286 WebsiteListTokens->insert(std::make_pair(*URLCount, PropertyTokens));
3292 void ContactDataObject::ProcessTitle(wxString PropertySeg1, wxString PropertySeg2, int *TitleCount){
3294 std::map<int, int> SplitPoints;
3295 std::map<int, int> SplitLength;
3296 std::map<int, int>::iterator SLiter;
3297 wxString PropertyData;
3298 wxString PropertyName;
3299 wxString PropertyValue;
3300 wxString PropertyTokens;
3301 bool FirstToken = TRUE;
3302 int intPrevValue = 7;
3307 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3311 PropertyType PropType = PROPERTY_NONE;
3313 // Look for type before continuing.
3315 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3317 // Setup the pointers.
3319 std::map<int, wxString> *TitleList = NULL;
3320 std::map<int, wxString> *TitleListAltID = NULL;
3321 std::map<int, wxString> *TitleListPID = NULL;
3322 std::map<int, wxString> *TitleListType = NULL;
3323 std::map<int, wxString> *TitleListTokens = NULL;
3324 std::map<int, wxString> *TitleListLanguage = NULL;
3325 std::map<int, int> *TitleListPref = NULL;
3327 // Setup blank lines for later on.
3331 TitleList = &GeneralTitleList;
3332 TitleListType = &GeneralTitleListType;
3333 TitleListAltID = &GeneralTitleListAltID;
3334 TitleListPID = &GeneralTitleListPID;
3335 TitleListTokens = &GeneralTitleListTokens;
3336 TitleListLanguage = &GeneralTitleListLanguage;
3337 TitleListPref = &GeneralTitleListPref;
3340 TitleList = &HomeTitleList;
3341 TitleListType = &HomeTitleListType;
3342 TitleListAltID = &HomeTitleListAltID;
3343 TitleListPID = &HomeTitleListPID;
3344 TitleListTokens = &HomeTitleListTokens;
3345 TitleListLanguage = &HomeTitleListLanguage;
3346 TitleListPref = &HomeTitleListPref;
3349 TitleList = &BusinessTitleList;
3350 TitleListType = &BusinessTitleListType;
3351 TitleListAltID = &BusinessTitleListAltID;
3352 TitleListPID = &BusinessTitleListPID;
3353 TitleListTokens = &BusinessTitleListTokens;
3354 TitleListLanguage = &BusinessTitleListLanguage;
3355 TitleListPref = &BusinessTitleListPref;
3361 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3362 intiter != SplitPoints.end(); ++intiter){
3364 SLiter = SplitLength.find(intiter->first);
3366 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3368 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3369 PropertyName = PropertyElement.GetNextToken();
3370 PropertyValue = PropertyElement.GetNextToken();
3372 intPrevValue = intiter->second;
3374 // Process properties.
3376 size_t intPropertyValueLen = PropertyValue.Len();
3378 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3380 PropertyValue.Trim();
3381 PropertyValue.RemoveLast();
3385 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3387 PropertyValue.Remove(0, 1);
3391 CaptureString(&PropertyValue, FALSE);
3393 if (PropertyName == wxT("ALTID")){
3395 TitleListAltID->erase(*TitleCount);
3396 TitleListAltID->insert(std::make_pair(*TitleCount, PropertyValue));
3398 } else if (PropertyName == wxT("PID")){
3400 TitleListPID->erase(*TitleCount);
3401 TitleListPID->insert(std::make_pair(*TitleCount, PropertyValue));
3403 } else if (PropertyName == wxT("PREF")){
3405 ProcessIntegerValue(TitleListPref, &PropertyValue, TitleCount);
3407 } else if (PropertyName == wxT("LANGUAGE")){
3409 TitleListLanguage->erase(*TitleCount);
3410 TitleListLanguage->insert(std::make_pair(*TitleCount, PropertyValue));
3414 // Something else we don't know about so append
3415 // to the tokens variable.
3417 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3419 if (FirstToken == TRUE){
3421 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3426 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3436 // Add the data to the General/Home/Work address variables.
3438 CaptureString(&PropertySeg2, FALSE);
3440 TitleList->insert(std::make_pair(*TitleCount, PropertySeg2));
3442 if (!PropertyTokens.IsEmpty()){
3444 TitleListTokens->insert(std::make_pair(*TitleCount, PropertyTokens));
3450 void ContactDataObject::ProcessRole(wxString PropertySeg1, wxString PropertySeg2, int *RoleCount){
3452 std::map<int, int> SplitPoints;
3453 std::map<int, int> SplitLength;
3454 std::map<int, int>::iterator SLiter;
3455 wxString PropertyData;
3456 wxString PropertyName;
3457 wxString PropertyValue;
3458 wxString PropertyTokens;
3459 bool FirstToken = TRUE;
3460 int intPrevValue = 6;
3465 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3469 PropertyType PropType = PROPERTY_NONE;
3471 // Look for type before continuing.
3473 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3475 // Setup the pointers.
3477 std::map<int, wxString> *RoleList = NULL;
3478 std::map<int, wxString> *RoleListAltID = NULL;
3479 std::map<int, wxString> *RoleListPID = NULL;
3480 std::map<int, wxString> *RoleListType = NULL;
3481 std::map<int, wxString> *RoleListTokens = NULL;
3482 std::map<int, wxString> *RoleListLanguage = NULL;
3483 std::map<int, int> *RoleListPref = NULL;
3485 // Setup blank lines for later on.
3489 RoleList = &GeneralRoleList;
3490 RoleListType = &GeneralRoleListType;
3491 RoleListAltID = &GeneralRoleListAltID;
3492 RoleListPID = &GeneralRoleListPID;
3493 RoleListTokens = &GeneralRoleListTokens;
3494 RoleListLanguage = &GeneralRoleListLanguage;
3495 RoleListPref = &GeneralRoleListPref;
3498 RoleList = &HomeRoleList;
3499 RoleListType = &HomeRoleListType;
3500 RoleListAltID = &HomeRoleListAltID;
3501 RoleListPID = &HomeRoleListPID;
3502 RoleListTokens = &HomeRoleListTokens;
3503 RoleListLanguage = &HomeRoleListLanguage;
3504 RoleListPref = &HomeRoleListPref;
3507 RoleList = &BusinessRoleList;
3508 RoleListType = &BusinessRoleListType;
3509 RoleListAltID = &BusinessRoleListAltID;
3510 RoleListPID = &BusinessRoleListPID;
3511 RoleListTokens = &BusinessRoleListTokens;
3512 RoleListLanguage = &BusinessRoleListLanguage;
3513 RoleListPref = &BusinessRoleListPref;
3519 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3520 intiter != SplitPoints.end(); ++intiter){
3522 SLiter = SplitLength.find(intiter->first);
3524 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3526 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3527 PropertyName = PropertyElement.GetNextToken();
3528 PropertyValue = PropertyElement.GetNextToken();
3530 intPrevValue = intiter->second;
3532 // Process properties.
3534 size_t intPropertyValueLen = PropertyValue.Len();
3536 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3538 PropertyValue.Trim();
3539 PropertyValue.RemoveLast();
3543 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3545 PropertyValue.Remove(0, 1);
3549 CaptureString(&PropertyValue, FALSE);
3551 if (PropertyName == wxT("ALTID")){
3553 RoleListAltID->erase(*RoleCount);
3554 RoleListAltID->insert(std::make_pair(*RoleCount, PropertyValue));
3556 } else if (PropertyName == wxT("PID")){
3558 RoleListPID->erase(*RoleCount);
3559 RoleListPID->insert(std::make_pair(*RoleCount, PropertyValue));
3561 } else if (PropertyName == wxT("PREF")){
3563 ProcessIntegerValue(RoleListPref, &PropertyValue, RoleCount);
3565 } else if (PropertyName == wxT("LANGUAGE")){
3567 RoleListLanguage->erase(*RoleCount);
3568 RoleListLanguage->insert(std::make_pair(*RoleCount, PropertyValue));
3572 // Something else we don't know about so append
3573 // to the tokens variable.
3575 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3577 if (FirstToken == TRUE){
3579 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3584 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3594 // Add the data to the General/Home/Work address variables.
3596 CaptureString(&PropertySeg2, FALSE);
3598 RoleList->insert(std::make_pair(*RoleCount, PropertySeg2));
3600 if (!PropertyTokens.IsEmpty()){
3602 RoleListTokens->insert(std::make_pair(*RoleCount, PropertyTokens));
3608 void ContactDataObject::ProcessOrganisation(wxString PropertySeg1, wxString PropertySeg2, int *OrganisationCount){
3610 std::map<int, int> SplitPoints;
3611 std::map<int, int> SplitLength;
3612 std::map<int, int>::iterator SLiter;
3613 wxString PropertyData;
3614 wxString PropertyName;
3615 wxString PropertyValue;
3616 wxString PropertyTokens;
3617 bool FirstToken = TRUE;
3618 int intPrevValue = 5;
3623 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3627 PropertyType PropType = PROPERTY_NONE;
3629 // Look for type before continuing.
3631 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3633 // Setup the pointers.
3635 std::map<int, wxString> *OrganisationsList = NULL;
3636 std::map<int, wxString> *OrganisationsListAltID = NULL;
3637 std::map<int, wxString> *OrganisationsListPID = NULL;
3638 std::map<int, wxString> *OrganisationsListType = NULL;
3639 std::map<int, wxString> *OrganisationsListTokens = NULL;
3640 std::map<int, wxString> *OrganisationsListLanguage = NULL;
3641 std::map<int, wxString> *OrganisationsListSortAs = NULL;
3642 std::map<int, int> *OrganisationsListPref = NULL;
3644 // Setup blank lines for later on.
3648 OrganisationsList = &GeneralOrganisationsList;
3649 OrganisationsListType = &GeneralOrganisationsListType;
3650 OrganisationsListAltID = &GeneralOrganisationsListAltID;
3651 OrganisationsListPID = &GeneralOrganisationsListPID;
3652 OrganisationsListTokens = &GeneralOrganisationsListTokens;
3653 OrganisationsListLanguage = &GeneralOrganisationsListLanguage;
3654 OrganisationsListSortAs = &GeneralOrganisationsListSortAs;
3655 OrganisationsListPref = &GeneralOrganisationsListPref;
3658 OrganisationsList = &HomeOrganisationsList;
3659 OrganisationsListType = &HomeOrganisationsListType;
3660 OrganisationsListAltID = &HomeOrganisationsListAltID;
3661 OrganisationsListPID = &HomeOrganisationsListPID;
3662 OrganisationsListTokens = &HomeOrganisationsListTokens;
3663 OrganisationsListLanguage = &HomeOrganisationsListLanguage;
3664 OrganisationsListSortAs = &HomeOrganisationsListSortAs;
3665 OrganisationsListPref = &HomeOrganisationsListPref;
3668 OrganisationsList = &BusinessOrganisationsList;
3669 OrganisationsListType = &BusinessOrganisationsListType;
3670 OrganisationsListAltID = &BusinessOrganisationsListAltID;
3671 OrganisationsListPID = &BusinessOrganisationsListPID;
3672 OrganisationsListTokens = &BusinessOrganisationsListTokens;
3673 OrganisationsListLanguage = &BusinessOrganisationsListLanguage;
3674 OrganisationsListSortAs = &BusinessOrganisationsListSortAs;
3675 OrganisationsListPref = &BusinessOrganisationsListPref;
3681 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3682 intiter != SplitPoints.end(); ++intiter){
3684 SLiter = SplitLength.find(intiter->first);
3686 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3688 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3689 PropertyName = PropertyElement.GetNextToken();
3690 PropertyValue = PropertyElement.GetNextToken();
3692 intPrevValue = intiter->second;
3694 // Process properties.
3696 size_t intPropertyValueLen = PropertyValue.Len();
3698 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3700 PropertyValue.Trim();
3701 PropertyValue.RemoveLast();
3705 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3707 PropertyValue.Remove(0, 1);
3711 CaptureString(&PropertyValue, FALSE);
3713 if (PropertyName == wxT("ALTID")){
3715 OrganisationsListAltID->erase(*OrganisationCount);
3716 OrganisationsListAltID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3718 } else if (PropertyName == wxT("PID")){
3720 OrganisationsListPID->erase(*OrganisationCount);
3721 OrganisationsListPID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3723 } else if (PropertyName == wxT("SORT-AS")){
3725 OrganisationsListSortAs->erase(*OrganisationCount);
3726 OrganisationsListSortAs->insert(std::make_pair(*OrganisationCount, PropertyValue));
3728 } else if (PropertyName == wxT("PREF")){
3730 ProcessIntegerValue(OrganisationsListPref, &PropertyValue, OrganisationCount);
3732 } else if (PropertyName == wxT("LANGUAGE")){
3734 OrganisationsListLanguage->erase(*OrganisationCount);
3735 OrganisationsListLanguage->insert(std::make_pair(*OrganisationCount, PropertyValue));
3739 // Something else we don't know about so append
3740 // to the tokens variable.
3742 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3744 if (FirstToken == TRUE){
3746 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3751 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3761 // Add the data to the General/Home/Work address variables.
3763 CaptureString(&PropertySeg2, FALSE);
3765 OrganisationsList->insert(std::make_pair(*OrganisationCount, PropertySeg2));
3767 if (!PropertyTokens.IsEmpty()){
3769 OrganisationsListTokens->insert(std::make_pair(*OrganisationCount, PropertyTokens));
3775 void ContactDataObject::ProcessNote(wxString PropertySeg1, wxString PropertySeg2, int *NoteCount){
3777 std::map<int, int> SplitPoints;
3778 std::map<int, int> SplitLength;
3779 std::map<int, int>::iterator SLiter;
3780 wxString PropertyData;
3781 wxString PropertyName;
3782 wxString PropertyValue;
3783 wxString PropertyTokens;
3784 bool FirstToken = TRUE;
3785 int intPrevValue = 6;
3790 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3794 PropertyType PropType = PROPERTY_NONE;
3796 // Look for type before continuing.
3798 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3800 // Setup the pointers.
3802 std::map<int, wxString> *NoteList = NULL;
3803 std::map<int, wxString> *NoteListAltID = NULL;
3804 std::map<int, wxString> *NoteListPID = NULL;
3805 std::map<int, wxString> *NoteListType = NULL;
3806 std::map<int, wxString> *NoteListTokens = NULL;
3807 std::map<int, wxString> *NoteListLanguage = NULL;
3808 std::map<int, int> *NoteListPref = NULL;
3810 // Setup blank lines for later on.
3814 NoteList = &GeneralNoteList;
3815 NoteListType = &GeneralNoteListType;
3816 NoteListAltID = &GeneralNoteListAltID;
3817 NoteListPID = &GeneralNoteListPID;
3818 NoteListTokens = &GeneralNoteListTokens;
3819 NoteListLanguage = &GeneralNoteListLanguage;
3820 NoteListPref = &GeneralNoteListPref;
3823 NoteList = &HomeNoteList;
3824 NoteListType = &HomeNoteListType;
3825 NoteListAltID = &HomeNoteListAltID;
3826 NoteListPID = &HomeNoteListPID;
3827 NoteListTokens = &HomeNoteListTokens;
3828 NoteListLanguage = &HomeNoteListLanguage;
3829 NoteListPref = &HomeNoteListPref;
3832 NoteList = &BusinessNoteList;
3833 NoteListType = &BusinessNoteListType;
3834 NoteListAltID = &BusinessNoteListAltID;
3835 NoteListPID = &BusinessNoteListPID;
3836 NoteListTokens = &BusinessNoteListTokens;
3837 NoteListLanguage = &BusinessNoteListLanguage;
3838 NoteListPref = &BusinessNoteListPref;
3844 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3845 intiter != SplitPoints.end(); ++intiter){
3847 SLiter = SplitLength.find(intiter->first);
3849 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3851 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3852 PropertyName = PropertyElement.GetNextToken();
3853 PropertyValue = PropertyElement.GetNextToken();
3855 intPrevValue = intiter->second;
3857 // Process properties.
3859 size_t intPropertyValueLen = PropertyValue.Len();
3861 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3863 PropertyValue.Trim();
3864 PropertyValue.RemoveLast();
3868 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3870 PropertyValue.Remove(0, 1);
3874 CaptureString(&PropertyValue, FALSE);
3876 if (PropertyName == wxT("ALTID")){
3878 NoteListAltID->erase(*NoteCount);
3879 NoteListAltID->insert(std::make_pair(*NoteCount, PropertyValue));
3881 } else if (PropertyName == wxT("PID")){
3883 NoteListPID->erase(*NoteCount);
3884 NoteListPID->insert(std::make_pair(*NoteCount, PropertyValue));
3886 } else if (PropertyName == wxT("PREF")){
3888 ProcessIntegerValue(NoteListPref, &PropertyValue, NoteCount);
3890 } else if (PropertyName == wxT("LANGUAGE")){
3892 NoteListLanguage->erase(*NoteCount);
3893 NoteListLanguage->insert(std::make_pair(*NoteCount, PropertyValue));
3897 // Something else we don't know about so append
3898 // to the tokens variable.
3900 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3902 if (FirstToken == TRUE){
3904 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3909 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3919 // Add the data to the General/Home/Work address variables.
3921 CaptureString(&PropertySeg2, FALSE);
3923 NoteList->insert(std::make_pair(*NoteCount, PropertySeg2));
3925 if (!PropertyTokens.IsEmpty()){
3927 NoteListTokens->insert(std::make_pair(*NoteCount, PropertyTokens));
3933 void ContactDataObject::ProcessCategory(wxString PropertySeg1, wxString PropertySeg2, int *CategoryCount){
3935 std::map<int, int> SplitPoints;
3936 std::map<int, int> SplitLength;
3937 std::map<int, int>::iterator SLiter;
3938 wxString PropertyData;
3939 wxString PropertyName;
3940 wxString PropertyValue;
3941 wxString PropertyTokens;
3942 bool FirstToken = TRUE;
3943 int intPrevValue = 12;
3948 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3952 PropertyType PropType = PROPERTY_NONE;
3954 // Look for type before continuing.
3956 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3958 // Setup blank lines for later on.
3964 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
3967 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
3973 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3974 intiter != SplitPoints.end(); ++intiter){
3976 SLiter = SplitLength.find(intiter->first);
3978 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3980 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3981 PropertyName = PropertyElement.GetNextToken();
3982 PropertyValue = PropertyElement.GetNextToken();
3984 intPrevValue = intiter->second;
3986 // Process properties.
3988 size_t intPropertyValueLen = PropertyValue.Len();
3990 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3992 PropertyValue.Trim();
3993 PropertyValue.RemoveLast();
3997 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3999 PropertyValue.Remove(0, 1);
4003 CaptureString(&PropertyValue, FALSE);
4005 if (PropertyName == wxT("ALTID")){
4007 CategoriesListAltID.erase(*CategoryCount);
4008 CategoriesListAltID.insert(std::make_pair(*CategoryCount, PropertyValue));
4010 } else if (PropertyName == wxT("PID")){
4012 CategoriesListPID.erase(*CategoryCount);
4013 CategoriesListPID.insert(std::make_pair(*CategoryCount, PropertyValue));
4015 } else if (PropertyName == wxT("PREF")){
4017 ProcessIntegerValue(&CategoriesListPref, &PropertyValue, CategoryCount);
4019 } else if (PropertyName == wxT("LANGUAGE")){
4021 CategoriesListLanguage.erase(*CategoryCount);
4022 CategoriesListLanguage.insert(std::make_pair(*CategoryCount, PropertyValue));
4026 // Something else we don't know about so append
4027 // to the tokens variable.
4029 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4031 if (FirstToken == TRUE){
4033 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4038 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4048 // Deal with multiple categories.
4050 int intOrigCatCount = *CategoryCount;
4051 bool FirstCategoryProcessed = TRUE;
4052 bool AfterFirstToken = FALSE;
4053 int intSplitSize = 0;
4054 int intSplitsFound = 0;
4055 int intSplitSeek = 0;
4056 int intPropertyLen = PropertySeg2.Len();
4058 SplitPoints.clear();
4059 SplitLength.clear();
4062 for (int i = 0; i <= intPropertyLen; i++){
4064 if (intSplitSize == 0 && PropertySeg2.Mid(i, 1) == wxT(" ")){
4072 if (PropertySeg2.Mid(i, 1) == wxT(",") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
4074 if (AfterFirstToken == TRUE){
4076 SplitPoints.insert(std::make_pair(intSplitsFound, (i - intSplitSize + 1)));
4077 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
4081 SplitPoints.insert(std::make_pair(intSplitsFound, 0));
4082 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
4083 AfterFirstToken = TRUE;
4095 if (SplitPoints.size() > 0){
4097 SplitPoints.insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
4098 SplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
4102 if (SplitPoints.size() == 0){
4104 CategoriesList.insert(std::make_pair(*CategoryCount, PropertySeg2));
4106 if (!PropertyTokens.IsEmpty()){
4108 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4114 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4115 intiter != SplitPoints.end(); ++intiter){
4117 SLiter = SplitLength.find(intiter->first);
4119 intPrevValue = intiter->second;
4121 PropertyData = PropertySeg2.Mid(intPrevValue, (SLiter->second + 1));
4123 // Add the data to the General/Home/Work address variables.
4125 // Trim any whitespace from the start and end.
4127 PropertyData = PropertyData.Trim(FALSE);
4128 PropertyData = PropertyData.Trim(TRUE);
4130 CaptureString(&PropertyData, FALSE);
4132 if (FirstCategoryProcessed == TRUE){
4134 FirstCategoryProcessed = FALSE;
4136 CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4138 if (!PropertyTokens.IsEmpty()){
4140 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4150 CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4152 if (!PropertyTokens.IsEmpty()){
4154 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4160 // Copy the properties to each of the categories (if it exists).
4162 if (!PropertyTokens.IsEmpty()){
4164 CategoriesListTokens.insert(std::make_pair(*CategoryCount, CategoriesListTokens.find(intOrigCatCount)->second));
4168 // Check if ALTID was used.
4170 if (CategoriesListAltID.find(intOrigCatCount) != CategoriesListAltID.end()){
4172 CategoriesListAltID.insert(std::make_pair(*CategoryCount, CategoriesListAltID.find(intOrigCatCount)->second));
4176 // Check if PID was used.
4178 if (CategoriesListPID.find(intOrigCatCount) != CategoriesListPID.end()){
4180 CategoriesListPID.insert(std::make_pair(*CategoryCount, CategoriesListPID.find(intOrigCatCount)->second));
4184 // Check if PREF was used.
4186 if (CategoriesListPref.find(intOrigCatCount) != CategoriesListPref.end()){
4188 CategoriesListPref.insert(std::make_pair(*CategoryCount, CategoriesListPref.find(intOrigCatCount)->second));
4192 // Check if LANGUAGE was used.
4194 if (CategoriesListLanguage.find(intOrigCatCount) != CategoriesListLanguage.end()){
4196 CategoriesListLanguage.insert(std::make_pair(*CategoryCount, CategoriesListLanguage.find(intOrigCatCount)->second));
4200 // Check if TYPE was used.
4206 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
4209 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
4217 void ContactDataObject::ProcessPhoto(wxString PropertySeg1, wxString PropertySeg2, int *PhotoCount){
4219 size_t intPropertyLen = PropertySeg1.Len();
4220 std::map<int, int> SplitPoints;
4221 std::map<int, int> SplitLength;
4222 std::map<int, int>::iterator SLiter;
4223 wxString PropertyData;
4224 wxString PropertyName;
4225 wxString PropertyValue;
4226 wxString PropertyTokens;
4227 bool FirstToken = TRUE;
4228 int intSplitsFound = 0;
4229 int intSplitSize = 0;
4230 int intPrevValue = 7;
4234 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4238 PropertyType PropType = PROPERTY_NONE;
4240 // Look for type before continuing.
4242 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4246 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4247 intiter != SplitPoints.end(); ++intiter){
4249 SLiter = SplitLength.find(intiter->first);
4251 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4253 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4254 PropertyName = PropertyElement.GetNextToken();
4255 PropertyValue = PropertyElement.GetNextToken();
4257 intPrevValue = intiter->second;
4259 // Process properties.
4261 size_t intPropertyValueLen = PropertyValue.Len();
4263 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4265 PropertyValue.Trim();
4266 PropertyValue.RemoveLast();
4270 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4272 PropertyValue.Remove(0, 1);
4276 CaptureString(&PropertyValue, FALSE);
4278 if (PropertyName == wxT("ALTID")){
4280 PicturesListAltID.erase(*PhotoCount);
4281 PicturesListAltID.insert(std::make_pair(*PhotoCount, PropertyValue));
4283 } else if (PropertyName == wxT("PID")){
4285 PicturesListPID.erase(*PhotoCount);
4286 PicturesListPID.insert(std::make_pair(*PhotoCount, PropertyValue));
4288 } else if (PropertyName == wxT("PREF")){
4290 ProcessIntegerValue(&PicturesListPref, &PropertyValue, PhotoCount);
4292 } else if (PropertyName == wxT("MEDIATYPE")){
4294 PicturesListMediatype.erase(*PhotoCount);
4295 PicturesListMediatype.insert(std::make_pair(*PhotoCount, PropertyValue));
4299 // Something else we don't know about so append
4300 // to the tokens variable.
4302 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4304 if (FirstToken == TRUE){
4306 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4311 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4321 intPropertyLen = PropertySeg2.Len();
4322 SplitPoints.clear();
4323 SplitLength.clear();
4328 CaptureString(&PropertySeg2, FALSE);
4330 for (int i = 0; i <= intPropertyLen; i++){
4334 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4337 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4339 if (intSplitsFound == 6){
4341 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4346 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4356 wxString wxSPhotoURI;
4357 wxString wxSPhotoMIME;
4358 wxString wxSPhotoEncoding;
4359 wxString wxSPhotoData;
4360 std::string base64enc;
4362 if (intSplitsFound == 0){
4366 std::map<int, int>::iterator striter;
4368 striter = SplitLength.find(1);
4370 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4372 while (wSTDataType.HasMoreTokens() == TRUE){
4374 wxSPhotoURI = wSTDataType.GetNextToken();
4375 wxSPhotoMIME = wSTDataType.GetNextToken();
4380 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
4382 while (wSTDataInfo.HasMoreTokens() == TRUE){
4384 wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4385 wxSPhotoData = wSTDataInfo.GetNextToken();
4386 base64enc = wxSPhotoData.mb_str();
4393 // Add the data to the General/Home/Work address variables.
4395 PicturesList.insert(std::make_pair(*PhotoCount, base64enc));
4396 PicturesListPictureType.insert(std::make_pair(*PhotoCount, wxSPhotoMIME));
4397 PicturesListPicEncType.insert(std::make_pair(*PhotoCount, wxSPhotoEncoding));
4403 PicturesListType.insert(std::make_pair(*PhotoCount, "home"));
4406 PicturesListType.insert(std::make_pair(*PhotoCount, "work"));
4410 if (!PropertyTokens.IsEmpty()){
4412 PicturesListTokens.insert(std::make_pair(*PhotoCount, PropertyTokens));
4418 void ContactDataObject::ProcessLogo(wxString PropertySeg1, wxString PropertySeg2, int *LogoCount){
4420 size_t intPropertyLen = PropertySeg1.Len();
4421 std::map<int, int> SplitPoints;
4422 std::map<int, int> SplitLength;
4423 std::map<int, int>::iterator SLiter;
4424 wxString PropertyData;
4425 wxString PropertyName;
4426 wxString PropertyValue;
4427 wxString PropertyTokens;
4428 bool FirstToken = TRUE;
4429 int intSplitsFound = 0;
4430 int intSplitSize = 0;
4431 int intPrevValue = 6;
4435 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4439 PropertyType PropType = PROPERTY_NONE;
4441 // Look for type before continuing.
4443 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4447 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4448 intiter != SplitPoints.end(); ++intiter){
4450 SLiter = SplitLength.find(intiter->first);
4452 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4454 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4455 PropertyName = PropertyElement.GetNextToken();
4456 PropertyValue = PropertyElement.GetNextToken();
4458 intPrevValue = intiter->second;
4460 // Process properties.
4462 size_t intPropertyValueLen = PropertyValue.Len();
4464 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4466 PropertyValue.Trim();
4467 PropertyValue.RemoveLast();
4471 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4473 PropertyValue.Remove(0, 1);
4477 CaptureString(&PropertyValue, FALSE);
4479 if (PropertyName == wxT("ALTID")){
4481 LogosListAltID.erase(*LogoCount);
4482 LogosListAltID.insert(std::make_pair(*LogoCount, PropertyValue));
4484 } else if (PropertyName == wxT("PID")){
4486 LogosListPID.erase(*LogoCount);
4487 LogosListPID.insert(std::make_pair(*LogoCount, PropertyValue));
4489 } else if (PropertyName == wxT("PREF")){
4491 ProcessIntegerValue(&LogosListPref, &PropertyValue, LogoCount);
4493 } else if (PropertyName == wxT("MEDIATYPE")){
4495 LogosListMediatype.erase(*LogoCount);
4496 LogosListMediatype.insert(std::make_pair(*LogoCount, PropertyValue));
4500 // Something else we don't know about so append
4501 // to the tokens variable.
4503 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4505 if (FirstToken == TRUE){
4507 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4512 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4522 intPropertyLen = PropertySeg2.Len();
4523 SplitPoints.clear();
4524 SplitLength.clear();
4529 CaptureString(&PropertySeg2, FALSE);
4531 for (int i = 0; i <= intPropertyLen; i++){
4535 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4538 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4540 if (intSplitsFound == 6){
4542 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4547 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4557 wxString wxSPhotoURI;
4558 wxString wxSPhotoMIME;
4559 wxString wxSPhotoEncoding;
4560 wxString wxSPhotoData;
4561 std::string base64enc;
4563 if (intSplitsFound == 0){
4567 std::map<int, int>::iterator striter;
4569 striter = SplitLength.find(1);
4571 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4573 while (wSTDataType.HasMoreTokens() == TRUE){
4575 wxSPhotoURI = wSTDataType.GetNextToken();
4576 wxSPhotoMIME = wSTDataType.GetNextToken();
4581 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
4583 while (wSTDataInfo.HasMoreTokens() == TRUE){
4585 wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4586 wxSPhotoData = wSTDataInfo.GetNextToken();
4587 base64enc = wxSPhotoData.mb_str();
4594 // Add the data to the General/Home/Work address variables.
4596 LogosList.insert(std::make_pair(*LogoCount, base64enc));
4597 LogosListPictureType.insert(std::make_pair(*LogoCount, wxSPhotoMIME));
4598 LogosListPicEncType.insert(std::make_pair(*LogoCount, wxSPhotoEncoding));
4604 LogosListType.insert(std::make_pair(*LogoCount, "home"));
4607 LogosListType.insert(std::make_pair(*LogoCount, "work"));
4611 if (!PropertyTokens.IsEmpty()){
4613 LogosListTokens.insert(std::make_pair(*LogoCount, PropertyTokens));
4619 void ContactDataObject::ProcessSound(wxString PropertySeg1, wxString PropertySeg2, int *SoundCount){
4621 size_t intPropertyLen = PropertySeg1.Len();
4622 std::map<int, int> SplitPoints;
4623 std::map<int, int> SplitLength;
4624 std::map<int, int>::iterator SLiter;
4625 wxString PropertyData;
4626 wxString PropertyName;
4627 wxString PropertyValue;
4628 wxString PropertyTokens;
4629 bool FirstToken = TRUE;
4630 int intSplitsFound = 0;
4631 int intSplitSize = 0;
4632 int intPrevValue = 7;
4636 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4640 PropertyType PropType = PROPERTY_NONE;
4642 // Look for type before continuing.
4644 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4648 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4649 intiter != SplitPoints.end(); ++intiter){
4651 SLiter = SplitLength.find(intiter->first);
4653 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4655 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4656 PropertyName = PropertyElement.GetNextToken();
4657 PropertyValue = PropertyElement.GetNextToken();
4659 intPrevValue = intiter->second;
4661 // Process properties.
4663 size_t intPropertyValueLen = PropertyValue.Len();
4665 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4667 PropertyValue.Trim();
4668 PropertyValue.RemoveLast();
4672 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4674 PropertyValue.Remove(0, 1);
4678 CaptureString(&PropertyValue, FALSE);
4680 if (PropertyName == wxT("ALTID")){
4682 SoundsListAltID.erase(*SoundCount);
4683 SoundsListAltID.insert(std::make_pair(*SoundCount, PropertyValue));
4685 } else if (PropertyName == wxT("PID")){
4687 SoundsListPID.erase(*SoundCount);
4688 SoundsListPID.insert(std::make_pair(*SoundCount, PropertyValue));
4690 } else if (PropertyName == wxT("PREF")){
4692 ProcessIntegerValue(&SoundsListPref, &PropertyValue, SoundCount);
4694 } else if (PropertyName == wxT("MEDIATYPE")){
4696 SoundsListMediatype.erase(*SoundCount);
4697 SoundsListMediatype.insert(std::make_pair(*SoundCount, PropertyValue));
4699 } else if (PropertyName == wxT("LANGUAGE")){
4701 SoundsListLanguage.erase(*SoundCount);
4702 SoundsListLanguage.insert(std::make_pair(*SoundCount, PropertyValue));
4706 // Something else we don't know about so append
4707 // to the tokens variable.
4709 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4711 if (FirstToken == TRUE){
4713 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4718 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4728 intPropertyLen = PropertySeg2.Len();
4729 SplitPoints.clear();
4730 SplitLength.clear();
4735 CaptureString(&PropertySeg2, FALSE);
4737 for (int i = 0; i <= intPropertyLen; i++){
4741 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4744 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4746 if (intSplitsFound == 6){
4748 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4753 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4763 wxString wxSSoundURI;
4764 wxString wxSSoundMIME;
4765 wxString wxSSoundEncoding;
4766 wxString wxSSoundData;
4767 std::string base64enc;
4769 if (intSplitsFound == 0){
4773 std::map<int, int>::iterator striter;
4775 striter = SplitLength.find(1);
4777 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4779 while (wSTDataType.HasMoreTokens() == TRUE){
4781 wxSSoundURI = wSTDataType.GetNextToken();
4782 wxSSoundMIME = wSTDataType.GetNextToken();
4787 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
4789 while (wSTDataInfo.HasMoreTokens() == TRUE){
4791 wxSSoundEncoding = wSTDataInfo.GetNextToken();
4792 wxSSoundData = wSTDataInfo.GetNextToken();
4793 base64enc = wxSSoundData.mb_str();
4800 // Add the data to the General/Home/Work address variables.
4806 SoundsListType.insert(std::make_pair(*SoundCount, "home"));
4809 SoundsListType.insert(std::make_pair(*SoundCount, "work"));
4813 SoundsList.insert(std::make_pair(*SoundCount, base64enc));
4814 SoundsListAudioEncType.insert(std::make_pair(*SoundCount, wxSSoundEncoding));
4815 SoundsListAudioType.insert(std::make_pair(*SoundCount, wxSSoundMIME));
4817 if (!PropertyTokens.IsEmpty()){
4819 SoundsListTokens.insert(std::make_pair(*SoundCount, PropertyTokens));
4825 void ContactDataObject::ProcessCalendarURI(wxString PropertySeg1, wxString PropertySeg2, int *CalURICount){
4827 size_t intPropertyLen = PropertySeg1.Len();
4828 std::map<int, int> SplitPoints;
4829 std::map<int, int> SplitLength;
4830 std::map<int, int>::iterator SLiter;
4831 wxString PropertyData;
4832 wxString PropertyName;
4833 wxString PropertyValue;
4834 wxString PropertyTokens;
4835 bool FirstToken = TRUE;
4836 int intSplitsFound = 0;
4837 int intSplitSize = 0;
4838 int intPrevValue = 8;
4842 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4846 PropertyType PropType = PROPERTY_NONE;
4848 // Look for type before continuing.
4850 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4854 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4855 intiter != SplitPoints.end(); ++intiter){
4857 SLiter = SplitLength.find(intiter->first);
4859 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4861 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4862 PropertyName = PropertyElement.GetNextToken();
4863 PropertyValue = PropertyElement.GetNextToken();
4865 intPrevValue = intiter->second;
4867 // Process properties.
4869 size_t intPropertyValueLen = PropertyValue.Len();
4871 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4873 PropertyValue.Trim();
4874 PropertyValue.RemoveLast();
4878 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4880 PropertyValue.Remove(0, 1);
4884 CaptureString(&PropertyValue, FALSE);
4886 if (PropertyName == wxT("ALTID")){
4888 CalendarListAltID.erase(*CalURICount);
4889 CalendarListAltID.insert(std::make_pair(*CalURICount, PropertyValue));
4891 } else if (PropertyName == wxT("PID")){
4893 CalendarListPID.erase(*CalURICount);
4894 CalendarListPID.insert(std::make_pair(*CalURICount, PropertyValue));
4896 } else if (PropertyName == wxT("PREF")){
4898 ProcessIntegerValue(&CalendarListPref, &PropertyValue, CalURICount);
4900 } else if (PropertyName == wxT("MEDIATYPE")){
4902 CalendarListMediatype.erase(*CalURICount);
4903 CalendarListMediatype.insert(std::make_pair(*CalURICount, PropertyValue));
4907 // Something else we don't know about so append
4908 // to the tokens variable.
4910 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4912 if (FirstToken == TRUE){
4914 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4919 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4929 intPropertyLen = PropertySeg2.Len();
4930 SplitPoints.clear();
4931 SplitLength.clear();
4936 CaptureString(&PropertySeg2, FALSE);
4938 // Add the data to the General/Home/Work address variables.
4944 CalendarListType.insert(std::make_pair(*CalURICount, "home"));
4947 CalendarListType.insert(std::make_pair(*CalURICount, "work"));
4951 CalendarList.insert(std::make_pair(*CalURICount, PropertySeg2));
4953 if (!PropertyTokens.IsEmpty()){
4955 CalendarListTokens.insert(std::make_pair(*CalURICount, PropertyTokens));
4961 void ContactDataObject::ProcessCalendarAddressURI(wxString PropertySeg1, wxString PropertySeg2, int *CalAdrURICount){
4963 size_t intPropertyLen = PropertySeg1.Len();
4964 std::map<int, int> SplitPoints;
4965 std::map<int, int> SplitLength;
4966 std::map<int, int>::iterator SLiter;
4967 wxString PropertyData;
4968 wxString PropertyName;
4969 wxString PropertyValue;
4970 wxString PropertyTokens;
4971 bool FirstToken = TRUE;
4972 int intSplitsFound = 0;
4973 int intSplitSize = 0;
4974 int intPrevValue = 8;
4978 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4982 PropertyType PropType = PROPERTY_NONE;
4984 // Look for type before continuing.
4986 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4990 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4991 intiter != SplitPoints.end(); ++intiter){
4993 SLiter = SplitLength.find(intiter->first);
4995 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4997 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4998 PropertyName = PropertyElement.GetNextToken();
4999 PropertyValue = PropertyElement.GetNextToken();
5001 intPrevValue = intiter->second;
5003 // Process properties.
5005 size_t intPropertyValueLen = PropertyValue.Len();
5007 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5009 PropertyValue.Trim();
5010 PropertyValue.RemoveLast();
5014 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5016 PropertyValue.Remove(0, 1);
5020 CaptureString(&PropertyValue, FALSE);
5022 if (PropertyName == wxT("ALTID")){
5024 CalendarRequestListAltID.erase(*CalAdrURICount);
5025 CalendarRequestListAltID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5027 } else if (PropertyName == wxT("PID")){
5029 CalendarRequestListPID.erase(*CalAdrURICount);
5030 CalendarRequestListPID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5032 } else if (PropertyName == wxT("PREF")){
5034 ProcessIntegerValue(&CalendarRequestListPref, &PropertyValue, CalAdrURICount);
5036 } else if (PropertyName == wxT("MEDIATYPE")){
5038 CalendarRequestListMediatype.erase(*CalAdrURICount);
5039 CalendarRequestListMediatype.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5043 // Something else we don't know about so append
5044 // to the tokens variable.
5046 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5048 if (FirstToken == TRUE){
5050 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5055 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5065 intPropertyLen = PropertySeg2.Len();
5066 SplitPoints.clear();
5067 SplitLength.clear();
5072 CaptureString(&PropertySeg2, FALSE);
5074 // Add the data to the General/Home/Work address variables.
5080 CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "home"));
5083 CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "work"));
5087 CalendarRequestList.insert(std::make_pair(*CalAdrURICount, PropertySeg2));
5089 if (!PropertyTokens.IsEmpty()){
5091 CalendarRequestListTokens.insert(std::make_pair(*CalAdrURICount, PropertyTokens));
5097 void ContactDataObject::ProcessCalendarFreeBusy(wxString PropertySeg1, wxString PropertySeg2, int *FreeBusyAddressCount){
5099 size_t intPropertyLen = PropertySeg1.Len();
5100 std::map<int, int> SplitPoints;
5101 std::map<int, int> SplitLength;
5102 std::map<int, int>::iterator SLiter;
5103 wxString PropertyData;
5104 wxString PropertyName;
5105 wxString PropertyValue;
5106 wxString PropertyTokens;
5107 bool FirstToken = TRUE;
5108 int intSplitsFound = 0;
5109 int intSplitSize = 0;
5110 int intPrevValue = 7;
5114 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5118 PropertyType PropType = PROPERTY_NONE;
5120 // Look for type before continuing.
5122 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5126 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
5127 intiter != SplitPoints.end(); ++intiter){
5129 SLiter = SplitLength.find(intiter->first);
5131 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5133 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5134 PropertyName = PropertyElement.GetNextToken();
5135 PropertyValue = PropertyElement.GetNextToken();
5137 intPrevValue = intiter->second;
5139 // Process properties.
5141 size_t intPropertyValueLen = PropertyValue.Len();
5143 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5145 PropertyValue.Trim();
5146 PropertyValue.RemoveLast();
5150 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5152 PropertyValue.Remove(0, 1);
5156 CaptureString(&PropertyValue, FALSE);
5158 if (PropertyName == wxT("ALTID")){
5160 FreeBusyListAltID.erase(*FreeBusyAddressCount);
5161 FreeBusyListAltID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5163 } else if (PropertyName == wxT("PID")){
5165 FreeBusyListPID.erase(*FreeBusyAddressCount);
5166 FreeBusyListPID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5168 } else if (PropertyName == wxT("PREF")){
5170 ProcessIntegerValue(&FreeBusyListPref, &PropertyValue, FreeBusyAddressCount);
5172 } else if (PropertyName == wxT("MEDIATYPE")){
5174 FreeBusyListMediatype.erase(*FreeBusyAddressCount);
5175 FreeBusyListMediatype.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5179 // Something else we don't know about so append
5180 // to the tokens variable.
5182 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5184 if (FirstToken == TRUE){
5186 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5191 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5201 intPropertyLen = PropertySeg2.Len();
5202 SplitPoints.clear();
5203 SplitLength.clear();
5208 CaptureString(&PropertySeg2, FALSE);
5210 // Add the data to the General/Home/Work address variables.
5216 FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "home"));
5219 FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "work"));
5223 FreeBusyList.insert(std::make_pair(*FreeBusyAddressCount, PropertySeg2));
5225 if (!PropertyTokens.IsEmpty()){
5227 FreeBusyListTokens.insert(std::make_pair(*FreeBusyAddressCount, PropertyTokens));
5233 void ContactDataObject::ProcessKey(wxString PropertySeg1, wxString PropertySeg2, int *KeyCount){
5235 size_t intPropertyLen = PropertySeg1.Len();
5236 std::map<int, int> SplitPoints;
5237 std::map<int, int> SplitLength;
5238 std::map<int, int>::iterator SLiter;
5239 wxString PropertyData;
5240 wxString PropertyName;
5241 wxString PropertyValue;
5242 wxString PropertyTokens;
5243 bool FirstToken = TRUE;
5244 int intSplitsFound = 0;
5245 int intSplitSize = 0;
5246 int intPrevValue = 5;
5251 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5255 PropertyType PropType = PROPERTY_NONE;
5257 // Look for type before continuing.
5259 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5263 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
5264 intiter != SplitPoints.end(); ++intiter){
5266 SLiter = SplitLength.find(intiter->first);
5268 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5270 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5271 PropertyName = PropertyElement.GetNextToken();
5272 PropertyValue = PropertyElement.GetNextToken();
5274 intPrevValue = intiter->second;
5276 // Process properties.
5278 size_t intPropertyValueLen = PropertyValue.Len();
5280 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5282 PropertyValue.Trim();
5283 PropertyValue.RemoveLast();
5287 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5289 PropertyValue.Remove(0, 1);
5293 if (PropertyName == wxT("ALTID")){
5295 KeyListAltID.erase(*KeyCount);
5296 KeyListAltID.insert(std::make_pair(*KeyCount, PropertyValue));
5298 } else if (PropertyName == wxT("PID")){
5300 KeyListPID.erase(*KeyCount);
5301 KeyListPID.insert(std::make_pair(*KeyCount, PropertyValue));
5303 } else if (PropertyName == wxT("PREF")){
5305 ProcessIntegerValue(&KeyListPref, &PropertyValue, KeyCount);
5309 // Something else we don't know about so append
5310 // to the tokens variable.
5312 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5314 if (FirstToken == TRUE){
5316 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5321 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5331 intPropertyLen = PropertySeg2.Len();
5332 SplitPoints.clear();
5333 SplitLength.clear();
5338 for (int i = 0; i <= intPropertyLen; i++){
5342 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
5345 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
5347 if (intSplitsFound == 6){
5349 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5354 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5365 wxString wxSKeyMIME;
5366 wxString wxSKeyEncoding;
5367 wxString wxSKeyData;
5368 std::string base64enc;
5370 if (intSplitsFound == 0){
5374 std::map<int, int>::iterator striter;
5376 striter = SplitLength.find(1);
5378 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
5380 while (wSTDataType.HasMoreTokens() == TRUE){
5382 wxSKeyURI = wSTDataType.GetNextToken();
5383 wxSKeyMIME = wSTDataType.GetNextToken();
5388 if (wxSKeyURI == wxT("data")){
5390 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
5392 while (wSTDataInfo.HasMoreTokens() == TRUE){
5394 wxSKeyEncoding = wSTDataInfo.GetNextToken();
5395 wxSKeyData = wSTDataInfo.GetNextToken();
5404 // Add the data to the General/Home/Work address variables.
5406 if (wxSKeyURI == wxT("data")){
5408 KeyListDataEncType.erase(*KeyCount);
5409 KeyListKeyType.erase(*KeyCount);
5410 KeyListDataEncType.insert(std::make_pair(*KeyCount, wxSKeyEncoding));
5411 KeyListKeyType.insert(std::make_pair(*KeyCount, TRUE));
5413 KeyList.erase(*KeyCount);
5414 KeyList.insert(std::make_pair(*KeyCount, wxSKeyData));
5418 KeyList.erase(*KeyCount);
5419 KeyList.insert(std::make_pair(*KeyCount, PropertySeg2));
5423 KeyListDataType.insert(std::make_pair(*KeyCount, wxSKeyMIME));
5429 KeyListType.insert(std::make_pair(*KeyCount, wxT("home")));
5432 KeyListType.insert(std::make_pair(*KeyCount, wxT("work")));
5436 if (!PropertyTokens.IsEmpty()){
5438 KeyListTokens.insert(std::make_pair(*KeyCount, PropertyTokens));
5444 void ContactDataObject::ProcessVendor(wxString PropertySeg1, wxString PropertySeg2, int *VendorCount){
5446 // Split the Vendor three ways.
5448 wxStringTokenizer wSTVendorDetails(PropertySeg1, wxT("-"));
5451 wxString wxSVNDPropName;
5454 while (wSTVendorDetails.HasMoreTokens() == TRUE){
5456 wSTVendorDetails.GetNextToken();
5457 wxSVNDID = wSTVendorDetails.GetNextToken();
5458 wxSVNDPropName = wSTVendorDetails.GetNextToken();
5463 if (!wxSVNDID.IsEmpty() && !wxSVNDPropName.IsEmpty()){
5465 // Add the data to the vendor variables.
5467 VendorList.erase(*VendorCount);
5468 VendorListPEN.erase(*VendorCount);
5469 VendorListElement.erase(*VendorCount);
5471 VendorList.insert(std::make_pair(*VendorCount, PropertySeg2));
5472 VendorListPEN.insert(std::make_pair(*VendorCount, wxSVNDID));
5473 VendorListElement.insert(std::make_pair(*VendorCount, wxSVNDPropName));
5479 void ProcessStringValue(wxString *PropertyName,
5480 wxString PropertyNameMatch,
5481 std::map<int,wxString> *MapPtr,
5482 wxString *PropertyValue,
5484 bool *PropertyMatched){
5486 if (*PropertyName == PropertyNameMatch){
5487 MapPtr->erase(*ItemCount);
5488 MapPtr->insert(std::make_pair(*ItemCount, *PropertyValue));
5489 *PropertyMatched = TRUE;
5494 void ProcessIntegerValue(wxString *PropertyName,
5495 wxString PropertyNameMatch,
5496 std::map<int,int> *PrefPtr,
5497 wxString *PropertyValue,
5499 bool *PropertyMatched){
5501 if (*PropertyName == PropertyNameMatch){
5502 *PropertyMatched = TRUE;
5507 int PriorityNumber = 0;
5508 bool ValidNumber = TRUE;
5511 PriorityNumber = std::stoi(PropertyValue->ToStdString());
5514 catch(std::invalid_argument &e){
5515 ValidNumber = FALSE;
5518 if (ValidNumber == TRUE){
5520 PrefPtr->erase(*ItemCount);
5521 PrefPtr->insert(std::make_pair(*ItemCount, PriorityNumber));
5527 void ProcessIntegerValue(std::map<int,int> *PrefPtr,
5528 wxString *PropertyValue,
5531 int PriorityNumber = 0;
5532 bool ValidNumber = TRUE;
5535 PriorityNumber = std::stoi(PropertyValue->ToStdString());
5538 catch(std::invalid_argument &e){
5539 ValidNumber = FALSE;
5542 if (ValidNumber == TRUE){
5544 PrefPtr->erase(*ItemCount);
5545 PrefPtr->insert(std::make_pair(*ItemCount, PriorityNumber));
5551 void SplitValues(wxString *PropertyLine,
5552 std::map<int,int> *SplitPoints,
5553 std::map<int,int> *SplitLength,
5556 size_t intPropertyLen = PropertyLine->Len();
5557 int intSplitsFound = 0;
5558 int intSplitSize = 0;
5559 int intSplitSeek = 0;
5561 for (int i = intSize; i <= intPropertyLen; i++){
5565 if (PropertyLine->Mid(i, 1) == wxT(";") &&
5566 PropertyLine->Mid((i - 1), 1) != wxT("\\")){
5568 if (intSplitsFound == 0){
5570 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
5574 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5578 SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
5588 if (intSplitsFound == 0){
5590 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
5591 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5595 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
5596 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5602 void CheckType(wxString *PropertySeg1,
5603 std::map<int,int> *SplitPoints,
5604 std::map<int,int> *SplitLength,
5606 PropertyType *PropType){
5608 wxString PropertyData;
5609 wxString PropertyName;
5610 wxString PropertyValue;
5611 std::map<int,int>::iterator SLiter;
5613 for (std::map<int, int>::iterator intiter = SplitPoints->begin();
5614 intiter != SplitPoints->end(); ++intiter){
5616 SLiter = SplitLength->find(intiter->first);
5618 PropertyData = PropertySeg1->Mid(*intPrevValue, (SLiter->second));
5620 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5621 PropertyName = PropertyElement.GetNextToken();
5622 PropertyValue = PropertyElement.GetNextToken();
5624 *intPrevValue = intiter->second;
5626 if (PropertyName == wxT("TYPE")){
5628 if (PropertyValue == wxT("work")){
5630 *PropType = PROPERTY_WORK;
5632 } else if (PropertyValue == wxT("home")){
5634 *PropType = PROPERTY_HOME;
5638 *PropType = PROPERTY_NONE;