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;
810 bool PropertyMatched = FALSE;
812 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
813 intiter != SplitPoints.end(); ++intiter){
815 SLiter = SplitLength.find(intiter->first);
817 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
819 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
820 PropertyName = PropertyElement.GetNextToken();
821 PropertyValue = PropertyElement.GetNextToken();
823 intPrevValue = intiter->second;
825 CaptureString(&PropertyValue, FALSE);
827 if (PropertyName == wxT("TYPE")){
829 if (!PropertyValue.IsEmpty() || PropertyValue == wxT("home") ||
830 PropertyValue == wxT("work") ){
832 FullNamesListType.erase(*FNCount);
833 FullNamesListType.insert(std::make_pair(*FNCount, PropertyValue));
837 PropertyMatched = TRUE;
841 ProcessStringValue(&PropertyName, "ALTID", &FullNamesListAltID, &PropertyValue, FNCount, &PropertyMatched);
842 ProcessStringValue(&PropertyName, "PID", &FullNamesListPID, &PropertyValue, FNCount, &PropertyMatched);
843 ProcessStringValue(&PropertyName, "LANGUAGE", &FullNamesListLanguage, &PropertyValue, FNCount, &PropertyMatched);
844 ProcessIntegerValue(&PropertyName, "PREF", &FullNamesListPref, &PropertyValue, FNCount, &PropertyMatched);
846 if (PropertyMatched == TRUE){
848 PropertyMatched = FALSE;
853 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
855 if (FirstToken == TRUE){
857 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
862 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
870 FullNamesList.insert(std::make_pair(*FNCount, PropertySeg2));
872 if (!PropertyTokens.IsEmpty()){
874 FullNamesListTokens.insert(std::make_pair(*FNCount, PropertyTokens));
880 void ContactDataObject::ProcessN(wxString PropertySeg1, wxString PropertySeg2){
882 std::map<int, int> SplitPoints;
883 std::map<int, int> SplitLength;
885 int intPrevValue = 3;
889 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
893 wxString PropertyName;
894 wxString PropertyValue;
895 wxString PropertyData;
896 wxString PropertyTokens;
897 std::map<int,int>::iterator SLiter;
898 bool FirstToken = TRUE;
900 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
901 intiter != SplitPoints.end(); ++intiter){
903 SLiter = SplitLength.find(intiter->first);
905 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
907 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
908 PropertyName = PropertyElement.GetNextToken();
909 PropertyValue = PropertyElement.GetNextToken();
911 intPrevValue = intiter->second;
913 CaptureString(&PropertyValue, FALSE);
915 if (PropertyName == wxT("ALTID")){
917 NameAltID = PropertyValue;
919 } else if (PropertyName == wxT("LANGUAGE")){
921 NameLanguage = PropertyValue;
923 } else if (PropertyName == wxT("SORT-AS")){
925 if (PropertyValue.Left(1) == wxT("\"") && PropertyValue.Right(1) == wxT("\"") &&
926 PropertyValue.Len() >= 3){
927 NameDisplayAs = PropertyValue.Mid(1, (PropertyValue.Len() - 2));
930 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
932 if (FirstToken == TRUE){
934 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
939 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
947 // Split the name data.
949 int intSplitSeek = 0;
950 int intSplitsFound = 0;
951 int intSplitSize = 0;
952 int intPropertyLen = PropertySeg2.Len();
954 std::map<int,wxString> NameValues;
957 for (int i = 0; i <= intPropertyLen; i++){
959 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
961 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, intSplitSize)));
966 if (intSplitsFound == 4){
968 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, wxString::npos)));
982 // Split the data into several parts.
984 for (std::map<int, wxString>::iterator iter = NameValues.begin();
985 iter != NameValues.end(); ++iter){
987 if (iter->first == 1){
989 // Deal with family name.
991 NameSurname = iter->second;
993 } else if (iter->first == 2){
995 // Deal with given names.
997 NameForename = iter->second;
999 } else if (iter->first == 3){
1001 // Deal with additional names.
1003 NameOtherNames = iter->second;
1005 } else if (iter->first == 4){
1007 // Deal with honorifix prefixes and suffixes.
1009 NameTitle = iter->second;
1013 if (iter == NameValues.end()){
1019 NameSuffix = iter->second;
1025 // Add the name token data.
1027 if (!PropertyTokens.IsEmpty()){
1029 NameTokens = PropertyTokens;
1035 void ContactDataObject::ProcessClientPIDMap(wxString PropertySeg1, wxString PropertySeg2, int *ClientPIDCount){
1037 size_t intPropertyLen = PropertySeg1.Len();
1038 std::map<int, int> SplitPoints;
1039 std::map<int, int> SplitLength;
1040 std::map<int, int>::iterator SLiter;
1041 wxString PropertyData;
1042 wxString PropertyName;
1043 wxString PropertyValue;
1044 wxString PropertyTokens;
1045 bool FirstToken = TRUE;
1046 int intSplitsFound = 0;
1047 int intSplitSize = 0;
1048 int intPrevValue = 14;
1052 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1056 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1057 intiter != SplitPoints.end(); ++intiter){
1059 SLiter = SplitLength.find(intiter->first);
1061 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1063 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1064 PropertyName = PropertyElement.GetNextToken();
1065 PropertyValue = PropertyElement.GetNextToken();
1067 intPrevValue = intiter->second;
1069 // Process properties.
1071 CaptureString(&PropertyValue, FALSE);
1073 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1075 if (FirstToken == TRUE){
1077 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1082 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1090 CaptureString(&PropertySeg2, FALSE);
1092 ClientPIDList.insert(std::make_pair(*ClientPIDCount, PropertySeg2));
1094 if (!PropertyTokens.IsEmpty()){
1096 ClientPIDListTokens.insert(std::make_pair(*ClientPIDCount, PropertyTokens));
1102 void ContactDataObject::ProcessNickname(wxString PropertySeg1, wxString PropertySeg2, int *NicknameCount){
1104 std::map<int, int> SplitPoints;
1105 std::map<int, int> SplitLength;
1107 int intPrevValue = 10;
1110 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1114 PropertyType PropType = PROPERTY_NONE;
1116 // Look for type before continuing.
1118 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1122 std::map<int, wxString> *NicknamesList = NULL;
1123 std::map<int, wxString> *NicknamesListType = NULL;
1124 std::map<int, wxString> *NicknamesListLanguage = NULL;
1125 std::map<int, wxString> *NicknamesListAltID = NULL;
1126 std::map<int, wxString> *NicknamesListPID = NULL;
1127 std::map<int, wxString> *NicknamesListTokens = NULL;
1128 std::map<int, int> *NicknamesListPref = NULL;
1132 NicknamesList = &GeneralNicknamesList;
1133 NicknamesListType = &GeneralNicknamesListType;
1134 NicknamesListLanguage = &GeneralNicknamesListLanguage;
1135 NicknamesListAltID = &GeneralNicknamesListAltID;
1136 NicknamesListPID = &GeneralNicknamesListPID;
1137 NicknamesListTokens = &GeneralNicknamesListTokens;
1138 NicknamesListPref = &GeneralNicknamesListPref;
1141 NicknamesList = &HomeNicknamesList;
1142 NicknamesListType = &HomeNicknamesListType;
1143 NicknamesListLanguage = &HomeNicknamesListLanguage;
1144 NicknamesListAltID = &HomeNicknamesListAltID;
1145 NicknamesListPID = &HomeNicknamesListPID;
1146 NicknamesListTokens = &HomeNicknamesListTokens;
1147 NicknamesListPref = &HomeNicknamesListPref;
1150 NicknamesList = &BusinessNicknamesList;
1151 NicknamesListType = &BusinessNicknamesListType;
1152 NicknamesListLanguage = &BusinessNicknamesListLanguage;
1153 NicknamesListAltID = &BusinessNicknamesListAltID;
1154 NicknamesListPID = &BusinessNicknamesListPID;
1155 NicknamesListTokens = &BusinessNicknamesListTokens;
1156 NicknamesListPref = &BusinessNicknamesListPref;
1160 std::map<int, int>::iterator SLiter;
1161 wxString PropertyData;
1162 wxString PropertyName;
1163 wxString PropertyValue;
1164 wxString PropertyTokens;
1165 bool FirstToken = TRUE;
1166 bool PropertyMatched = FALSE;
1168 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1169 intiter != SplitPoints.end(); ++intiter){
1171 SLiter = SplitLength.find(intiter->first);
1173 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1175 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1176 PropertyName = PropertyElement.GetNextToken();
1177 PropertyValue = PropertyElement.GetNextToken();
1179 intPrevValue = intiter->second;
1181 CaptureString(&PropertyValue, FALSE);
1183 ProcessStringValue(&PropertyName, "ALTID", NicknamesListAltID, &PropertyValue, NicknameCount, &PropertyMatched);
1184 ProcessStringValue(&PropertyName, "PID", NicknamesListPID, &PropertyValue, NicknameCount, &PropertyMatched);
1185 ProcessStringValue(&PropertyName, "LANGUAGE", NicknamesListLanguage, &PropertyValue, NicknameCount, &PropertyMatched);
1186 ProcessIntegerValue(&PropertyName, "PREF", NicknamesListPref, &PropertyValue, NicknameCount, &PropertyMatched);
1188 if (PropertyMatched == TRUE){
1190 PropertyMatched = FALSE;
1195 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1197 if (FirstToken == TRUE){
1199 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1204 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1212 NicknamesList->insert(std::make_pair(*NicknameCount, PropertySeg2));
1214 // Add the name token data.
1216 if (!PropertyTokens.IsEmpty()){
1218 NicknamesListTokens->insert(std::make_pair(*NicknameCount, PropertyTokens));
1224 void ContactDataObject::ProcessGender(wxString PropertySeg1, wxString PropertySeg2){
1226 std::map<int, int> SplitPoints;
1227 std::map<int, int> SplitLength;
1228 std::map<int, int>::iterator SLiter;
1229 wxString PropertyData;
1230 wxString PropertyName;
1231 wxString PropertyValue;
1232 wxString PropertyTokens;
1233 bool FirstToken = TRUE;
1234 int intPrevValue = 8;
1236 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1240 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1241 intiter != SplitPoints.end(); ++intiter){
1243 SLiter = SplitLength.find(intiter->first);
1245 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1247 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1248 PropertyName = PropertyElement.GetNextToken();
1249 PropertyValue = PropertyElement.GetNextToken();
1251 intPrevValue = intiter->second;
1253 // Process properties.
1255 size_t intPropertyValueLen = PropertyValue.Len();
1257 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
1259 PropertyValue.Trim();
1260 PropertyValue.RemoveLast();
1264 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1266 PropertyValue.Remove(0, 1);
1270 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1272 if (FirstToken == TRUE){
1274 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1279 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1287 wxStringTokenizer GenderData (PropertySeg2, wxT(";"));
1289 wxString GenderComponent;
1291 if (GenderData.CountTokens() >= 2){
1293 Gender = GenderData.GetNextToken();
1294 GenderDetails = GenderData.GetString();
1296 CaptureString(&GenderDetails, FALSE);
1300 Gender = GenderData.GetNextToken();
1304 if (!PropertyTokens.IsEmpty()){
1306 GenderTokens = PropertyTokens;
1312 void ContactDataObject::ProcessBirthday(wxString PropertySeg1, wxString PropertySeg2){
1314 // Process date. Preserve the remainder in the string.
1316 std::map<int, int> SplitPoints;
1317 std::map<int, int> SplitLength;
1318 std::map<int, int>::iterator SLiter;
1319 wxString PropertyData;
1320 wxString PropertyName;
1321 wxString PropertyValue;
1322 wxString PropertyTokens;
1323 bool BirthdayText = FALSE;
1324 int intPrevValue = 6;
1326 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1330 // Look for type before continuing.
1332 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1333 intiter != SplitPoints.end(); ++intiter){
1335 SLiter = SplitLength.find(intiter->first);
1337 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1339 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1340 PropertyName = PropertyElement.GetNextToken();
1341 PropertyValue = PropertyElement.GetNextToken();
1343 intPrevValue = intiter->second;
1345 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && BirthdayText == FALSE){
1347 CaptureString(&PropertySeg2, FALSE);
1348 Birthday = PropertySeg2;
1349 BirthdayText = TRUE;
1355 // Setup blank lines for later on.
1358 bool FirstToken = TRUE;
1360 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1361 intiter != SplitPoints.end(); ++intiter){
1363 SLiter = SplitLength.find(intiter->first);
1365 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1367 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1368 PropertyName = PropertyElement.GetNextToken();
1369 PropertyValue = PropertyElement.GetNextToken();
1371 intPrevValue = intiter->second;
1373 // Process properties.
1375 CaptureString(&PropertyValue, FALSE);
1377 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1379 PropertyValue.Trim();
1380 PropertyValue.RemoveLast();
1384 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1386 PropertyValue.Remove(0, 1);
1390 if (PropertyName == wxT("ALTID")){
1392 BirthdayAltID = PropertyValue;
1394 } else if (PropertyName == wxT("CALSCALE")){
1396 BirthdayCalScale = PropertyValue;
1398 } else if (PropertyName != wxT("VALUE")) {
1400 // Something else we don't know about so append
1401 // to the tokens variable.
1403 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1405 if (FirstToken == TRUE){
1407 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1412 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1422 // Add the data to the variables and form.
1424 if (BirthdayText == FALSE){
1426 Birthday = PropertySeg2;
1430 if (!PropertyTokens.IsEmpty()){
1432 BirthdayTokens = PropertyTokens;
1438 void ContactDataObject::ProcessAnniversary(wxString PropertySeg1, wxString PropertySeg2){
1440 // Process date. Preserve the remainder in the string.
1442 std::map<int, int> SplitPoints;
1443 std::map<int, int> SplitLength;
1444 std::map<int, int>::iterator SLiter;
1445 wxString PropertyData;
1446 wxString PropertyName;
1447 wxString PropertyValue;
1448 wxString PropertyTokens;
1449 bool AnniversaryText = FALSE;
1450 int intPrevValue = 13;
1452 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1456 // Look for type before continuing.
1458 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1459 intiter != SplitPoints.end(); ++intiter){
1461 SLiter = SplitLength.find(intiter->first);
1463 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1465 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1466 PropertyName = PropertyElement.GetNextToken();
1467 PropertyValue = PropertyElement.GetNextToken();
1469 intPrevValue = intiter->second;
1471 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && AnniversaryText == FALSE){
1473 CaptureString(&PropertySeg2, FALSE);
1474 Anniversary = PropertySeg2;
1475 AnniversaryText = TRUE;
1481 // Setup blank lines for later on.
1484 bool FirstToken = TRUE;
1486 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1487 intiter != SplitPoints.end(); ++intiter){
1489 SLiter = SplitLength.find(intiter->first);
1491 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1493 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1494 PropertyName = PropertyElement.GetNextToken();
1495 PropertyValue = PropertyElement.GetNextToken();
1497 intPrevValue = intiter->second;
1499 // Process properties.
1501 CaptureString(&PropertyValue, FALSE);
1503 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1505 PropertyValue.Trim();
1506 PropertyValue.RemoveLast();
1510 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1512 PropertyValue.Remove(0, 1);
1516 if (PropertyName == wxT("ALTID")){
1518 AnniversaryAltID = PropertyValue;
1520 } else if (PropertyName == wxT("CALSCALE")){
1522 AnniversaryCalScale = PropertyValue;
1524 } else if (PropertyName != wxT("VALUE")) {
1526 // Something else we don't know about so append
1527 // to the tokens variable.
1529 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1531 if (FirstToken == TRUE){
1533 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1538 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1548 // Add the data to the variables and form.
1550 if (AnniversaryText == FALSE){
1552 Anniversary = PropertySeg2;
1556 if (!PropertyTokens.IsEmpty()){
1558 AnniversaryTokens = PropertyTokens;
1564 void ContactDataObject::ProcessTimeZone(wxString PropertySeg1, wxString PropertySeg2, int *TimeZoneCount){
1566 std::map<int, int> SplitPoints;
1567 std::map<int, int> SplitLength;
1569 int intPrevValue = 4;
1572 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1576 PropertyType PropType = PROPERTY_NONE;
1578 // Look for type before continuing.
1580 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1584 std::map<int, wxString> *TZList = NULL;
1585 std::map<int, wxString> *TZListType = NULL;
1586 std::map<int, wxString> *TZListMediatype = NULL;
1587 std::map<int, wxString> *TZListAltID = NULL;
1588 std::map<int, wxString> *TZListPID = NULL;
1589 std::map<int, wxString> *TZListTokens = NULL;
1590 std::map<int, int> *TZListPref = NULL;
1594 TZList = &GeneralTZList;
1595 TZListType = &GeneralTZListType;
1596 TZListMediatype = &GeneralTZListMediatype;
1597 TZListAltID = &GeneralTZListAltID;
1598 TZListPID = &GeneralTZListPID;
1599 TZListTokens = &GeneralTZListTokens;
1600 TZListPref = &GeneralTZListPref;
1603 TZList = &HomeTZList;
1604 TZListType = &HomeTZListType;
1605 TZListMediatype = &HomeTZListMediatype;
1606 TZListAltID = &HomeTZListAltID;
1607 TZListPID = &HomeTZListPID;
1608 TZListTokens = &HomeTZListTokens;
1609 TZListPref = &HomeTZListPref;
1612 TZList = &BusinessTZList;
1613 TZListType = &BusinessTZListType;
1614 TZListMediatype = &BusinessTZListMediatype;
1615 TZListAltID = &BusinessTZListAltID;
1616 TZListPID = &BusinessTZListPID;
1617 TZListTokens = &BusinessTZListTokens;
1618 TZListPref = &BusinessTZListPref;
1622 std::map<int, int>::iterator SLiter;
1623 wxString PropertyData;
1624 wxString PropertyName;
1625 wxString PropertyValue;
1626 wxString PropertyTokens;
1627 bool FirstToken = TRUE;
1629 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1630 intiter != SplitPoints.end(); ++intiter){
1632 SLiter = SplitLength.find(intiter->first);
1634 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1636 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1637 PropertyName = PropertyElement.GetNextToken();
1638 PropertyValue = PropertyElement.GetNextToken();
1640 intPrevValue = intiter->second;
1642 CaptureString(&PropertyValue, FALSE);
1644 if (PropertyName == wxT("ALTID")){
1646 TZListAltID->erase(*TimeZoneCount);
1647 TZListAltID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1649 } else if (PropertyName == wxT("PID")){
1651 TZListPID->erase(*TimeZoneCount);
1652 TZListPID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1654 } else if (PropertyName == wxT("PREF")){
1656 ProcessIntegerValue(TZListPref, &PropertyValue, TimeZoneCount);
1658 } else if (PropertyName == wxT("MEDIATYPE")){
1660 TZListMediatype->erase(*TimeZoneCount);
1661 TZListMediatype->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1665 // Something else we don't know about so append
1666 // to the tokens variable.
1668 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1670 if (FirstToken == TRUE){
1672 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1677 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1687 TZList->insert(std::make_pair(*TimeZoneCount, PropertySeg2));
1689 // Add the name token data.
1691 if (!PropertyTokens.IsEmpty()){
1693 TZListTokens->insert(std::make_pair(*TimeZoneCount, PropertyTokens));
1700 void ContactDataObject::ProcessAddress(wxString PropertySeg1, wxString PropertySeg2, int *AddressCount){
1702 size_t intPropertyLen = PropertySeg1.Len();
1703 std::map<int, int> SplitPoints;
1704 std::map<int, int> SplitLength;
1705 std::map<int, int>::iterator SLiter;
1706 wxString PropertyData;
1707 wxString PropertyName;
1708 wxString PropertyValue;
1709 wxString PropertyTokens;
1710 wxString AddressLabel;
1711 wxString AddressLang;
1712 wxString AddressAltID;
1713 wxString AddressPID;
1714 wxString AddressTokens;
1715 wxString AddressGeo;
1716 wxString AddressTimezone;
1717 wxString AddressType;
1718 wxString AddressMediatype;
1719 wxString AddressPOBox;
1720 wxString AddressExtended;
1721 wxString AddressStreet;
1722 wxString AddressLocality;
1723 wxString AddressCity;
1724 wxString AddressRegion;
1725 wxString AddressPostalCode;
1726 wxString AddressCountry;
1727 bool FirstToken = TRUE;
1728 int intSplitsFound = 0;
1729 int intSplitSize = 0;
1730 int intPrevValue = 5;
1735 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1739 PropertyType PropType = PROPERTY_NONE;
1741 // Look for type before continuing.
1743 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1747 std::map<int, wxString> *AddressList = NULL;
1748 std::map<int, wxString> *AddressListTown = NULL;
1749 std::map<int, wxString> *AddressListCounty = NULL;
1750 std::map<int, wxString> *AddressListPostCode = NULL;
1751 std::map<int, wxString> *AddressListCountry = NULL;
1752 std::map<int, wxString> *AddressListLabel = NULL;
1753 std::map<int, wxString> *AddressListLang = NULL;
1754 std::map<int, wxString> *AddressListAltID = NULL;
1755 std::map<int, wxString> *AddressListPID = NULL;
1756 std::map<int, wxString> *AddressListTokens = NULL;
1757 std::map<int, wxString> *AddressListGeo = NULL;
1758 std::map<int, wxString> *AddressListTimezone = NULL;
1759 std::map<int, wxString> *AddressListType = NULL;
1760 std::map<int, wxString> *AddressListMediatype = NULL;
1761 std::map<int, int> *AddressListPref = NULL;
1765 AddressList = &GeneralAddressList;
1766 AddressListTown = &GeneralAddressListTown;
1767 AddressListCounty = &GeneralAddressListCounty;
1768 AddressListPostCode = &GeneralAddressListPostCode;
1769 AddressListCountry = &GeneralAddressListCountry;
1770 AddressListLabel = &GeneralAddressListLabel;
1771 AddressListLang = &GeneralAddressListLang;
1772 AddressListAltID = &GeneralAddressListAltID;
1773 AddressListPID = &GeneralAddressListPID;
1774 AddressListTokens = &GeneralAddressListTokens;
1775 AddressListGeo = &GeneralAddressListGeo;
1776 AddressListTimezone = &GeneralAddressListTimezone;
1777 AddressListType = &GeneralAddressListType;
1778 AddressListMediatype = &GeneralAddressListMediatype;
1779 AddressListPref = &GeneralAddressListPref;
1782 AddressList = &HomeAddressList;
1783 AddressListTown = &HomeAddressListTown;
1784 AddressListCounty = &HomeAddressListCounty;
1785 AddressListPostCode = &HomeAddressListPostCode;
1786 AddressListCountry = &HomeAddressListCountry;
1787 AddressListLabel = &HomeAddressListLabel;
1788 AddressListLang = &HomeAddressListLang;
1789 AddressListAltID = &HomeAddressListAltID;
1790 AddressListPID = &HomeAddressListPID;
1791 AddressListTokens = &HomeAddressListTokens;
1792 AddressListGeo = &HomeAddressListGeo;
1793 AddressListTimezone = &HomeAddressListTimezone;
1794 AddressListType = &HomeAddressListType;
1795 AddressListMediatype = &HomeAddressListMediatype;
1796 AddressListPref = &HomeAddressListPref;
1799 AddressList = &BusinessAddressList;
1800 AddressListTown = &BusinessAddressListTown;
1801 AddressListCounty = &BusinessAddressListCounty;
1802 AddressListPostCode = &BusinessAddressListPostCode;
1803 AddressListCountry = &BusinessAddressListCountry;
1804 AddressListLabel = &BusinessAddressListLabel;
1805 AddressListLang = &BusinessAddressListLang;
1806 AddressListAltID = &BusinessAddressListAltID;
1807 AddressListPID = &BusinessAddressListPID;
1808 AddressListTokens = &BusinessAddressListTokens;
1809 AddressListGeo = &BusinessAddressListGeo;
1810 AddressListTimezone = &BusinessAddressListTimezone;
1811 AddressListType = &BusinessAddressListType;
1812 AddressListMediatype = &BusinessAddressListMediatype;
1813 AddressListPref = &BusinessAddressListPref;
1819 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1820 intiter != SplitPoints.end(); ++intiter){
1822 SLiter = SplitLength.find(intiter->first);
1824 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1826 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1827 PropertyName = PropertyElement.GetNextToken();
1828 PropertyValue = PropertyElement.GetNextToken();
1830 intPrevValue = intiter->second;
1832 CaptureString(&PropertyValue, FALSE);
1834 // Process properties.
1836 if (PropertyName == wxT("LABEL")){
1838 AddressListLabel->erase(*AddressCount);
1839 AddressListLabel->insert(std::make_pair(*AddressCount, PropertyValue));
1841 } else if (PropertyName == wxT("LANGUAGE")){
1843 AddressListLang->erase(*AddressCount);
1844 AddressListLang->insert(std::make_pair(*AddressCount, PropertyValue));
1846 } else if (PropertyName == wxT("ALTID")){
1848 AddressListAltID->erase(*AddressCount);
1849 AddressListAltID->insert(std::make_pair(*AddressCount, PropertyValue));
1851 } else if (PropertyName == wxT("PID")){
1853 AddressListPID->erase(*AddressCount);
1854 AddressListPID->insert(std::make_pair(*AddressCount, PropertyValue));
1856 } else if (PropertyName == wxT("GEO")){
1858 AddressListGeo->erase(*AddressCount);
1859 AddressListGeo->insert(std::make_pair(*AddressCount, PropertyValue));
1861 } else if (PropertyName == wxT("TZ")){
1863 AddressListTimezone->erase(*AddressCount);
1864 AddressListTimezone->insert(std::make_pair(*AddressCount, PropertyValue));
1866 } else if (PropertyName == wxT("MEDIATYPE")){
1868 AddressListMediatype->erase(*AddressCount);
1869 AddressListMediatype->insert(std::make_pair(*AddressCount, PropertyValue));
1871 } else if (PropertyName == wxT("PREF")){
1873 ProcessIntegerValue(AddressListPref, &PropertyValue, AddressCount);
1877 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1879 if (FirstToken == TRUE){
1881 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1886 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1896 // Split the address.
1898 //std::map<int, int>::iterator SLiter;
1899 intPropertyLen = PropertySeg2.Len();
1900 SplitPoints.clear();
1901 SplitLength.clear();
1906 for (int i = 0; i <= intPropertyLen; i++){
1910 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
1913 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
1915 if (intSplitsFound == 6){
1917 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1922 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1932 // Split the data into several parts.
1934 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1935 intiter != SplitPoints.end(); ++intiter){
1937 if (intiter->first == 1){
1939 // Deal with PO Box.
1941 SLiter = SplitLength.find(1);
1943 //txtSurname->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(0, SLiter->second), TRUE));
1944 AddressPOBox = PropertySeg2.Mid(0, SLiter->second);
1945 intPrevValue = intiter->second;
1947 } else if (intiter->first == 2){
1949 // Deal with extended address.
1951 SLiter = SplitLength.find(2);
1953 AddressExtended = PropertySeg2.Mid(intPrevValue, SLiter->second);
1954 //txtForename->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1955 intPrevValue = intiter->second;
1957 } else if (intiter->first == 3){
1959 // Deal with street address.
1961 SLiter = SplitLength.find(3);
1963 AddressStreet = PropertySeg2.Mid(intPrevValue, SLiter->second);
1964 //txtOtherNames->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1965 intPrevValue = intiter->second;
1967 } else if (intiter->first == 4){
1969 // Deal with locality
1971 SLiter = SplitLength.find(4);
1973 AddressLocality = PropertySeg2.Mid(intPrevValue, SLiter->second);
1974 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1975 intPrevValue = intiter->second;
1977 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1979 } else if (intiter->first == 5){
1981 // Deal with region.
1983 SLiter = SplitLength.find(5);
1985 AddressRegion = PropertySeg2.Mid(intPrevValue, SLiter->second);
1986 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1987 intPrevValue = intiter->second;
1989 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
1991 } else if (intiter->first == 6){
1993 // Deal with post code.
1995 SLiter = SplitLength.find(6);
1997 AddressPostalCode = PropertySeg2.Mid(intPrevValue, SLiter->second);
1998 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1999 intPrevValue = intiter->second;
2001 // Deal with country.
2003 AddressCountry = PropertySeg2.Mid(intPrevValue, wxString::npos);
2004 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
2012 // Add the data to the General/Home/Work address variables.
2014 CaptureString(&AddressStreet, FALSE);
2015 CaptureString(&AddressLocality, FALSE);
2016 CaptureString(&AddressRegion, FALSE);
2017 CaptureString(&AddressPostalCode, FALSE);
2018 CaptureString(&AddressCountry, FALSE);
2020 if (!PropertyTokens.IsEmpty()){
2022 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
2026 AddressListCountry->insert(std::make_pair(*AddressCount, AddressCountry));
2027 AddressList->insert(std::make_pair(*AddressCount, AddressStreet));
2028 AddressListTown->insert(std::make_pair(*AddressCount, AddressLocality));
2029 AddressListCounty->insert(std::make_pair(*AddressCount, AddressRegion));
2030 AddressListPostCode->insert(std::make_pair(*AddressCount, AddressPostalCode));
2034 AddressListType->insert(std::make_pair(*AddressCount, wxT("")));
2037 AddressListType->insert(std::make_pair(*AddressCount, wxT("home")));
2040 AddressListType->insert(std::make_pair(*AddressCount, wxT("work")));
2044 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
2048 void ContactDataObject::ProcessEmail(wxString PropertySeg1, wxString PropertySeg2, int *EmailCount){
2050 std::map<int, int> SplitPoints;
2051 std::map<int, int> SplitLength;
2053 int intPrevValue = 7;
2056 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2060 PropertyType PropType = PROPERTY_NONE;
2062 // Look for type before continuing.
2064 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2066 std::map<int, wxString> *EmailList = NULL;
2067 std::map<int, wxString> *EmailListType = NULL;
2068 std::map<int, wxString> *EmailListAltID = NULL;
2069 std::map<int, wxString> *EmailListPID = NULL;
2070 std::map<int, wxString> *EmailListTokens = NULL;
2071 std::map<int, int> *EmailListPref = NULL;
2075 EmailList = &GeneralEmailList;
2076 EmailListType = &GeneralEmailListType;
2077 EmailListAltID = &GeneralEmailListAltID;
2078 EmailListPID = &GeneralEmailListPID;
2079 EmailListTokens = &GeneralEmailListTokens;
2080 EmailListPref = &GeneralEmailListPref;
2083 EmailList = &HomeEmailList;
2084 EmailListType = &HomeEmailListType;
2085 EmailListAltID = &HomeEmailListAltID;
2086 EmailListPID = &HomeEmailListPID;
2087 EmailListTokens = &HomeEmailListTokens;
2088 EmailListPref = &HomeEmailListPref;
2091 EmailList = &BusinessEmailList;
2092 EmailListType = &BusinessEmailListType;
2093 EmailListAltID = &BusinessEmailListAltID;
2094 EmailListPID = &BusinessEmailListPID;
2095 EmailListTokens = &BusinessEmailListTokens;
2096 EmailListPref = &BusinessEmailListPref;
2102 std::map<int,int>::iterator SLiter;
2103 wxString PropertyData;
2104 wxString PropertyName;
2105 wxString PropertyValue;
2106 wxString PropertyTokens;
2107 bool FirstToken = TRUE;
2109 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2110 intiter != SplitPoints.end(); ++intiter){
2112 SLiter = SplitLength.find(intiter->first);
2114 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2116 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2117 PropertyName = PropertyElement.GetNextToken();
2118 PropertyValue = PropertyElement.GetNextToken();
2120 intPrevValue = intiter->second;
2122 CaptureString(&PropertyValue, FALSE);
2124 // Process properties.
2126 if (PropertyName == wxT("ALTID")){
2128 EmailListAltID->erase(*EmailCount);
2129 EmailListAltID->insert(std::make_pair(*EmailCount, PropertyValue));
2131 } else if (PropertyName == wxT("PID")){
2133 EmailListPID->erase(*EmailCount);
2134 EmailListPID->insert(std::make_pair(*EmailCount, PropertyValue));
2136 } else if (PropertyName == wxT("PREF")){
2138 ProcessIntegerValue(EmailListPref, &PropertyValue, EmailCount);
2142 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2144 if (FirstToken == TRUE){
2146 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2151 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2161 EmailList->insert(std::make_pair(*EmailCount, PropertySeg2));
2163 // Add the name token data.
2165 if (!PropertyTokens.IsEmpty()){
2167 EmailListTokens->insert(std::make_pair(*EmailCount, PropertyTokens));
2174 void ContactDataObject::ProcessIM(wxString PropertySeg1, wxString PropertySeg2, int *IMCount){
2176 std::map<int, int> SplitPoints;
2177 std::map<int, int> SplitLength;
2179 int intPrevValue = 6;
2182 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2186 PropertyType PropType = PROPERTY_NONE;
2188 // Look for type before continuing.
2190 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2192 std::map<int, wxString> *IMList = NULL;
2193 std::map<int, wxString> *IMListType = NULL;
2194 std::map<int, wxString> *IMListAltID = NULL;
2195 std::map<int, wxString> *IMListPID = NULL;
2196 std::map<int, wxString> *IMListTokens = NULL;
2197 std::map<int, wxString> *IMListMediatype = NULL;
2198 std::map<int, int> *IMListPref = NULL;
2202 IMList = &GeneralIMList;
2203 IMListType = &GeneralIMListType;
2204 IMListAltID = &GeneralIMListAltID;
2205 IMListPID = &GeneralIMListPID;
2206 IMListTokens = &GeneralIMListTokens;
2207 IMListMediatype = &GeneralIMListMediatype;
2208 IMListPref = &GeneralIMListPref;
2211 IMList = &HomeIMList;
2212 IMListType = &HomeIMListType;
2213 IMListAltID = &HomeIMListAltID;
2214 IMListPID = &HomeIMListPID;
2215 IMListTokens = &HomeIMListTokens;
2216 IMListMediatype = &HomeIMListMediatype;
2217 IMListPref = &HomeIMListPref;
2220 IMList = &BusinessIMList;
2221 IMListType = &BusinessIMListType;
2222 IMListAltID = &BusinessIMListAltID;
2223 IMListPID = &BusinessIMListPID;
2224 IMListTokens = &BusinessIMListTokens;
2225 IMListMediatype = &BusinessIMListMediatype;
2226 IMListPref = &BusinessIMListPref;
2232 std::map<int,int>::iterator SLiter;
2233 wxString PropertyData;
2234 wxString PropertyName;
2235 wxString PropertyValue;
2236 wxString PropertyTokens;
2237 bool FirstToken = TRUE;
2239 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2240 intiter != SplitPoints.end(); ++intiter){
2242 SLiter = SplitLength.find(intiter->first);
2244 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2246 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2247 PropertyName = PropertyElement.GetNextToken();
2248 PropertyValue = PropertyElement.GetNextToken();
2250 intPrevValue = intiter->second;
2252 CaptureString(&PropertyValue, FALSE);
2254 // Process properties.
2256 if (PropertyName == wxT("ALTID")){
2258 IMListAltID->erase(*IMCount);
2259 IMListAltID->insert(std::make_pair(*IMCount, PropertyValue));
2261 } else if (PropertyName == wxT("PID")){
2263 IMListPID->erase(*IMCount);
2264 IMListPID->insert(std::make_pair(*IMCount, PropertyValue));
2266 } else if (PropertyName == wxT("MEDIATYPE")){
2268 IMListMediatype->erase(*IMCount);
2269 IMListMediatype->insert(std::make_pair(*IMCount, PropertyValue));
2271 } else if (PropertyName == wxT("PREF")){
2273 ProcessIntegerValue(IMListPref, &PropertyValue, IMCount);
2277 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2279 if (FirstToken == TRUE){
2281 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2286 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2296 IMList->insert(std::make_pair(*IMCount, PropertySeg2));
2298 // Add the name token data.
2300 if (!PropertyTokens.IsEmpty()){
2302 IMListTokens->insert(std::make_pair(*IMCount, PropertyTokens));
2308 void ContactDataObject::ProcessTelephone(wxString PropertySeg1, wxString PropertySeg2, int *TelephoneCount){
2310 std::map<int, int> SplitPoints;
2311 std::map<int, int> SplitLength;
2312 std::map<int, int>::iterator SLiter;
2316 PropertyType PropType = PROPERTY_NONE;
2318 // Look for type before continuing.
2321 wxString TelTypeDetail;
2322 wxString PropertyData;
2323 wxString PropertyName;
2324 wxString PropertyValue;
2325 wxString PropertyTokens;
2327 std::map<int,int> TypeSplitPoints;
2328 std::map<int,int> TypeSplitLength;
2329 std::map<int,int>::iterator TSLiter;
2331 int intSplitSize = 0;
2332 int intSplitsFound = 0;
2333 int intSplitPoint = 0;
2335 int intPrevValue = 5;
2337 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2341 // Look for type before continuing.
2343 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2344 intiter != SplitPoints.end(); ++intiter){
2346 SLiter = SplitLength.find(intiter->first);
2348 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2350 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2351 PropertyName = PropertyElement.GetNextToken();
2352 PropertyValue = PropertyElement.GetNextToken();
2354 intPrevValue = intiter->second;
2356 if (PropertyName == wxT("TYPE")){
2358 // Process each value in type and translate each
2361 // Strip out the quotes if they are there.
2363 size_t intPropertyValueLen = PropertyValue.Len();
2365 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2367 PropertyValue.Trim();
2368 PropertyValue.RemoveLast();
2372 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2374 PropertyValue.Remove(0, 1);
2378 TelTypeDetail = PropertyValue;
2384 for (int i = 0; i <= intPropertyValueLen; i++){
2388 if (PropertyValue.Mid(i, 1) == wxT(",") && PropertyValue.Mid((i - 1), 1) != wxT("\\")){
2390 if (intSplitsFound == 0){
2392 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2393 TypeSplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2397 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2398 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2411 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2412 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2414 int intTypeSeek = 0;
2416 for (std::map<int, int>::iterator typeiter = TypeSplitPoints.begin();
2417 typeiter != TypeSplitPoints.end(); ++typeiter){
2419 wxString TypePropertyName;
2421 TSLiter = TypeSplitLength.find(typeiter->first);
2423 TypePropertyName = PropertyValue.Mid(typeiter->second, TSLiter->second);
2425 if (intTypeSeek == 0){
2430 TelTypeUI.Append(wxT(","));
2434 if (TypePropertyName == wxT("home")){
2436 PropType = PROPERTY_HOME;
2438 } else if (TypePropertyName == wxT("work")){
2440 PropType = PROPERTY_WORK;
2445 if (TypePropertyName == wxT("text")){
2447 TelTypeUI.Append(_("text"));
2450 } else if (TypePropertyName == wxT("voice")){
2452 TelTypeUI.Append(_("voice"));
2455 } else if (TypePropertyName == wxT("fax")){
2457 TelTypeUI.Append(_("fax"));
2460 } else if (TypePropertyName == wxT("cell")){
2462 TelTypeUI.Append(_("mobile"));
2465 } else if (TypePropertyName == wxT("video")){
2467 TelTypeUI.Append(_("video"));
2470 } else if (TypePropertyName == wxT("pager")){
2472 TelTypeUI.Append(_("pager"));
2475 } else if (TypePropertyName == wxT("textphone")){
2477 TelTypeUI.Append(_("textphone"));
2488 std::map<int, wxString> *TelephoneList = NULL;
2489 std::map<int, wxString> *TelephoneListType = NULL;
2490 std::map<int, wxString> *TelephoneListAltID = NULL;
2491 std::map<int, wxString> *TelephoneListPID = NULL;
2492 std::map<int, wxString> *TelephoneListTokens = NULL;
2493 std::map<int, wxString> *TelephoneListTypeInfo = NULL;
2494 std::map<int, int> *TelephoneListPref = NULL;
2498 TelephoneList = &GeneralTelephoneList;
2499 TelephoneListType = &GeneralTelephoneListType;
2500 TelephoneListAltID = &GeneralTelephoneListAltID;
2501 TelephoneListPID = &GeneralTelephoneListPID;
2502 TelephoneListTokens = &GeneralTelephoneListTokens;
2503 TelephoneListTypeInfo = &GeneralTelephoneListTypeInfo;
2504 TelephoneListPref = &GeneralTelephoneListPref;
2507 TelephoneList = &HomeTelephoneList;
2508 TelephoneListType = &HomeTelephoneListType;
2509 TelephoneListAltID = &HomeTelephoneListAltID;
2510 TelephoneListPID = &HomeTelephoneListPID;
2511 TelephoneListTokens = &HomeTelephoneListTokens;
2512 TelephoneListTypeInfo = &HomeTelephoneListTypeInfo;
2513 TelephoneListPref = &HomeTelephoneListPref;
2516 TelephoneList = &BusinessTelephoneList;
2517 TelephoneListType = &BusinessTelephoneListType;
2518 TelephoneListAltID = &BusinessTelephoneListAltID;
2519 TelephoneListPID = &BusinessTelephoneListPID;
2520 TelephoneListTokens = &BusinessTelephoneListTokens;
2521 TelephoneListTypeInfo = &BusinessTelephoneListTypeInfo;
2522 TelephoneListPref = &BusinessTelephoneListPref;
2526 // Process the properties.
2528 bool FirstToken = TRUE;
2531 SplitPoints.clear();
2532 SplitLength.clear();
2534 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2538 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2539 intiter != SplitPoints.end(); ++intiter){
2541 SLiter = SplitLength.find(intiter->first);
2543 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2545 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2546 PropertyName = PropertyElement.GetNextToken();
2547 PropertyValue = PropertyElement.GetNextToken();
2549 intPrevValue = intiter->second;
2551 CaptureString(&PropertyValue, FALSE);
2553 // Process properties.
2555 if (PropertyName == wxT("ALTID")){
2557 TelephoneListAltID->erase(*TelephoneCount);
2558 TelephoneListAltID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2560 } else if (PropertyName == wxT("PID")){
2562 TelephoneListPID->erase(*TelephoneCount);
2563 TelephoneListPID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2565 } else if (PropertyName == wxT("PREF")){
2567 ProcessIntegerValue(TelephoneListPref, &PropertyValue, TelephoneCount);
2571 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2573 if (FirstToken == TRUE){
2575 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2580 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2590 TelephoneList->insert(std::make_pair(*TelephoneCount, PropertySeg2));
2591 TelephoneListTypeInfo->insert(std::make_pair(*TelephoneCount, TelTypeUI));
2593 // Add the name token data.
2595 if (!PropertyTokens.IsEmpty()){
2597 TelephoneListTokens->insert(std::make_pair(*TelephoneCount, PropertyTokens));
2603 void ContactDataObject::ProcessLanguage(wxString PropertySeg1, wxString PropertySeg2, int *LanguageCount){
2605 std::map<int, int> SplitPoints;
2606 std::map<int, int> SplitLength;
2608 int intPrevValue = 6;
2611 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2615 PropertyType PropType = PROPERTY_NONE;
2617 // Look for type before continuing.
2619 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2621 std::map<int, wxString> *LanguageList = NULL;
2622 std::map<int, wxString> *LanguageListType = NULL;
2623 std::map<int, wxString> *LanguageListAltID = NULL;
2624 std::map<int, wxString> *LanguageListPID = NULL;
2625 std::map<int, wxString> *LanguageListTokens = NULL;
2626 std::map<int, int> *LanguageListPref = NULL;
2630 LanguageList = &GeneralLanguageList;
2631 LanguageListType = &GeneralLanguageListType;
2632 LanguageListAltID = &GeneralLanguageListAltID;
2633 LanguageListPID = &GeneralLanguageListPID;
2634 LanguageListTokens = &GeneralLanguageListTokens;
2635 LanguageListPref = &GeneralLanguageListPref;
2638 LanguageList = &HomeLanguageList;
2639 LanguageListType = &HomeLanguageListType;
2640 LanguageListAltID = &HomeLanguageListAltID;
2641 LanguageListPID = &HomeLanguageListPID;
2642 LanguageListTokens = &HomeLanguageListTokens;
2643 LanguageListPref = &HomeLanguageListPref;
2646 LanguageList = &BusinessLanguageList;
2647 LanguageListType = &BusinessLanguageListType;
2648 LanguageListAltID = &BusinessLanguageListAltID;
2649 LanguageListPID = &BusinessLanguageListPID;
2650 LanguageListTokens = &BusinessLanguageListTokens;
2651 LanguageListPref = &BusinessLanguageListPref;
2657 std::map<int,int>::iterator SLiter;
2658 wxString PropertyData;
2659 wxString PropertyName;
2660 wxString PropertyValue;
2661 wxString PropertyTokens;
2662 bool FirstToken = TRUE;
2664 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2665 intiter != SplitPoints.end(); ++intiter){
2667 SLiter = SplitLength.find(intiter->first);
2669 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2671 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2672 PropertyName = PropertyElement.GetNextToken();
2673 PropertyValue = PropertyElement.GetNextToken();
2675 intPrevValue = intiter->second;
2677 CaptureString(&PropertyValue, FALSE);
2679 // Process properties.
2681 if (PropertyName == wxT("ALTID")){
2683 LanguageListAltID->erase(*LanguageCount);
2684 LanguageListAltID->insert(std::make_pair(*LanguageCount, PropertyValue));
2686 } else if (PropertyName == wxT("PID")){
2688 LanguageListPID->erase(*LanguageCount);
2689 LanguageListPID->insert(std::make_pair(*LanguageCount, PropertyValue));
2691 } else if (PropertyName == wxT("PREF")){
2693 ProcessIntegerValue(LanguageListPref, &PropertyValue, LanguageCount);
2697 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2699 if (FirstToken == TRUE){
2701 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2706 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2716 LanguageList->insert(std::make_pair(*LanguageCount, PropertySeg2));
2718 // Add the name token data.
2720 if (!PropertyTokens.IsEmpty()){
2722 LanguageListTokens->insert(std::make_pair(*LanguageCount, PropertyTokens));
2728 void ContactDataObject::ProcessGeographic(wxString PropertySeg1, wxString PropertySeg2, int *GeographicCount){
2730 std::map<int, int> SplitPoints;
2731 std::map<int, int> SplitLength;
2733 int intPrevValue = 5;
2736 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2740 PropertyType PropType = PROPERTY_NONE;
2742 // Look for type before continuing.
2744 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2746 std::map<int, wxString> *GeopositionList = NULL;
2747 std::map<int, wxString> *GeopositionListType = NULL;
2748 std::map<int, wxString> *GeopositionListAltID = NULL;
2749 std::map<int, wxString> *GeopositionListPID = NULL;
2750 std::map<int, wxString> *GeopositionListTokens = NULL;
2751 std::map<int, wxString> *GeopositionListMediatype = NULL;
2752 std::map<int, int> *GeopositionListPref = NULL;
2756 GeopositionList = &GeneralGeographyList;
2757 GeopositionListType = &GeneralGeographyListType;
2758 GeopositionListAltID = &GeneralGeographyListAltID;
2759 GeopositionListPID = &GeneralGeographyListPID;
2760 GeopositionListTokens = &GeneralGeographyListTokens;
2761 GeopositionListMediatype = &GeneralGeographyListMediatype;
2762 GeopositionListPref = &GeneralGeographyListPref;
2765 GeopositionList = &HomeGeographyList;
2766 GeopositionListType = &HomeGeographyListType;
2767 GeopositionListAltID = &HomeGeographyListAltID;
2768 GeopositionListPID = &HomeGeographyListPID;
2769 GeopositionListTokens = &HomeGeographyListTokens;
2770 GeopositionListMediatype = &HomeGeographyListMediatype;
2771 GeopositionListPref = &HomeGeographyListPref;
2774 GeopositionList = &BusinessGeographyList;
2775 GeopositionListType = &BusinessGeographyListType;
2776 GeopositionListAltID = &BusinessGeographyListAltID;
2777 GeopositionListPID = &BusinessGeographyListPID;
2778 GeopositionListTokens = &BusinessGeographyListTokens;
2779 GeopositionListMediatype = &BusinessGeographyListMediatype;
2780 GeopositionListPref = &BusinessGeographyListPref;
2786 std::map<int,int>::iterator SLiter;
2787 wxString PropertyData;
2788 wxString PropertyName;
2789 wxString PropertyValue;
2790 wxString PropertyTokens;
2791 bool FirstToken = TRUE;
2793 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2794 intiter != SplitPoints.end(); ++intiter){
2796 SLiter = SplitLength.find(intiter->first);
2798 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2800 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2801 PropertyName = PropertyElement.GetNextToken();
2802 PropertyValue = PropertyElement.GetNextToken();
2804 intPrevValue = intiter->second;
2806 CaptureString(&PropertyValue, FALSE);
2808 // Process properties.
2810 if (PropertyName == wxT("ALTID")){
2812 GeopositionListAltID->erase(*GeographicCount);
2813 GeopositionListAltID->insert(std::make_pair(*GeographicCount, PropertyValue));
2815 } else if (PropertyName == wxT("PID")){
2817 GeopositionListPID->erase(*GeographicCount);
2818 GeopositionListPID->insert(std::make_pair(*GeographicCount, PropertyValue));
2820 } else if (PropertyName == wxT("MEDIATYPE")){
2822 GeopositionListMediatype->erase(*GeographicCount);
2823 GeopositionListMediatype->insert(std::make_pair(*GeographicCount, PropertyValue));
2825 } else if (PropertyName == wxT("PREF")){
2827 ProcessIntegerValue(GeopositionListPref, &PropertyValue, GeographicCount);
2831 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2833 if (FirstToken == TRUE){
2835 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2840 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2850 GeopositionList->insert(std::make_pair(*GeographicCount, PropertySeg2));
2852 // Add the name token data.
2854 if (!PropertyTokens.IsEmpty()){
2856 GeopositionListTokens->insert(std::make_pair(*GeographicCount, PropertyTokens));
2862 void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertySeg2, int *RelatedCount){
2864 size_t intPropertyLen = PropertySeg1.Len();
2865 std::map<int, int> SplitPoints;
2866 std::map<int, int> SplitLength;
2867 std::map<int, int>::iterator SLiter;
2868 wxString PropertyData;
2869 wxString PropertyName;
2870 wxString PropertyValue;
2871 wxString PropertyTokens;
2872 wxString RelatedType;
2873 wxString RelatedTypeOriginal;
2874 wxString RelatedName;
2875 bool FirstToken = TRUE;
2876 int intSplitsFound = 0;
2877 int intSplitSize = 0;
2878 int intPrevValue = 9;
2882 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2886 // Look for type before continuing.
2888 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2889 intiter != SplitPoints.end(); ++intiter){
2891 SLiter = SplitLength.find(intiter->first);
2893 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2895 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2896 PropertyName = PropertyElement.GetNextToken();
2897 PropertyValue = PropertyElement.GetNextToken();
2899 intPrevValue = intiter->second;
2903 RelatedTypeOriginal = PropertyValue;
2905 if (PropertyName == wxT("TYPE")){
2907 if (PropertyValue == wxT("contact")){
2909 RelatedType = _("Contact");
2911 } else if (PropertyValue == wxT("acquaintance")){
2913 RelatedType = _("Acquaintance");
2915 } else if (PropertyValue == wxT("friend")){
2917 RelatedType = _("Friend");
2919 } else if (PropertyValue == wxT("met")){
2921 RelatedType = _("Met");
2923 } else if (PropertyValue == wxT("co-worker")){
2925 RelatedType = _("Co-worker");
2927 } else if (PropertyValue == wxT("colleague")){
2929 RelatedType = _("Colleague");
2931 } else if (PropertyValue == wxT("co-resident")){
2933 RelatedType = _("Co-resident");
2935 } else if (PropertyValue == wxT("neighbor")){
2937 RelatedType = _("Neighbour");
2939 } else if (PropertyValue == wxT("child")){
2941 RelatedType = _("Child");
2943 } else if (PropertyValue == wxT("parent")){
2945 RelatedType = _("Parent");
2947 } else if (PropertyValue == wxT("sibling")){
2949 RelatedType = _("Sibling");
2951 } else if (PropertyValue == wxT("spouse")){
2953 RelatedType = _("Spouse");
2955 } else if (PropertyValue == wxT("kin")){
2957 RelatedType = _("Kin");
2959 } else if (PropertyValue == wxT("muse")){
2961 RelatedType = _("Muse");
2963 } else if (PropertyValue == wxT("crush")){
2965 RelatedType = _("Crush");
2967 } else if (PropertyValue == wxT("date")){
2969 RelatedType = _("Date");
2971 } else if (PropertyValue == wxT("sweetheart")){
2973 RelatedType = _("Sweetheart");
2975 } else if (PropertyValue == wxT("me")){
2977 RelatedType = _("Me");
2979 } else if (PropertyValue == wxT("agent")){
2981 RelatedType = _("Agent");
2983 } else if (PropertyValue == wxT("emergency")){
2985 RelatedType = _("Emergency");
2989 RelatedType = PropertyValue;
2999 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3000 intiter != SplitPoints.end(); ++intiter){
3002 SLiter = SplitLength.find(intiter->first);
3004 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3006 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3007 PropertyName = PropertyElement.GetNextToken();
3008 PropertyValue = PropertyElement.GetNextToken();
3010 intPrevValue = intiter->second;
3012 // Process properties.
3014 size_t intPropertyValueLen = PropertyValue.Len();
3016 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3018 PropertyValue.Trim();
3019 PropertyValue.RemoveLast();
3023 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3025 PropertyValue.Remove(0, 1);
3029 CaptureString(&PropertyValue, FALSE);
3031 if (PropertyName == wxT("ALTID")){
3033 GeneralRelatedListAltID.erase(*RelatedCount);
3034 GeneralRelatedListAltID.insert(std::make_pair(*RelatedCount, PropertyValue));
3036 } else if (PropertyName == wxT("PID")){
3038 GeneralRelatedListPID.erase(*RelatedCount);
3039 GeneralRelatedListPID.insert(std::make_pair(*RelatedCount, PropertyValue));
3041 } else if (PropertyName == wxT("PREF")){
3043 int PriorityNumber = 0;
3044 bool ValidNumber = TRUE;
3047 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3050 catch(std::invalid_argument &e){
3051 ValidNumber = FALSE;
3054 if (ValidNumber == TRUE){
3056 GeneralRelatedListPref.erase(*RelatedCount);
3057 GeneralRelatedListPref.insert(std::make_pair(*RelatedCount, PriorityNumber));
3061 } else if (PropertyName == wxT("LANGUAGE")){
3063 ProcessIntegerValue(&GeneralRelatedListPref, &PropertyValue, RelatedCount);
3065 } else if (PropertyName != wxT("TYPE")) {
3067 // Something else we don't know about so append
3068 // to the tokens variable.
3070 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3072 if (FirstToken == TRUE){
3074 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3079 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3089 // Add the data to the General/Home/Work address variables.
3091 GeneralRelatedList.erase(*RelatedCount);
3092 GeneralRelatedListRelType.erase(*RelatedCount);
3093 GeneralRelatedListType.erase(*RelatedCount);
3094 GeneralRelatedListTokens.erase(*RelatedCount);
3095 GeneralRelatedList.insert(std::make_pair(*RelatedCount, PropertySeg2));
3096 GeneralRelatedListRelType.insert(std::make_pair(*RelatedCount, RelatedType));
3097 GeneralRelatedListType.insert(std::make_pair(*RelatedCount, RelatedType));
3098 GeneralRelatedListTokens.insert(std::make_pair(*RelatedCount, PropertyTokens));
3102 void ContactDataObject::ProcessURL(wxString PropertySeg1, wxString PropertySeg2, int *URLCount){
3104 std::map<int, int> SplitPoints;
3105 std::map<int, int> SplitLength;
3106 std::map<int, int>::iterator SLiter;
3107 wxString PropertyData;
3108 wxString PropertyName;
3109 wxString PropertyValue;
3110 wxString PropertyTokens;
3111 bool FirstToken = TRUE;
3112 int intPrevValue = 5;
3117 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3121 PropertyType PropType = PROPERTY_NONE;
3123 // Look for type before continuing.
3125 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3127 // Setup the pointers.
3129 std::map<int, wxString> *WebsiteList = NULL;
3130 std::map<int, wxString> *WebsiteListAltID = NULL;
3131 std::map<int, wxString> *WebsiteListPID = NULL;
3132 std::map<int, wxString> *WebsiteListType = NULL;
3133 std::map<int, wxString> *WebsiteListTokens = NULL;
3134 std::map<int, wxString> *WebsiteListMediatype = NULL;
3135 std::map<int, int> *WebsiteListPref = NULL;
3137 // Setup blank lines for later on.
3141 WebsiteList = &GeneralWebsiteList;
3142 WebsiteListType = &GeneralWebsiteListType;
3143 WebsiteListAltID = &GeneralWebsiteListAltID;
3144 WebsiteListPID = &GeneralWebsiteListPID;
3145 WebsiteListTokens = &GeneralWebsiteListTokens;
3146 WebsiteListMediatype = &GeneralWebsiteListMediatype;
3147 WebsiteListPref = &GeneralWebsiteListPref;
3150 WebsiteList = &HomeWebsiteList;
3151 WebsiteListType = &HomeWebsiteListType;
3152 WebsiteListAltID = &HomeWebsiteListAltID;
3153 WebsiteListPID = &HomeWebsiteListPID;
3154 WebsiteListTokens = &HomeWebsiteListTokens;
3155 WebsiteListMediatype = &HomeWebsiteListMediatype;
3156 WebsiteListPref = &HomeWebsiteListPref;
3159 WebsiteList = &BusinessWebsiteList;
3160 WebsiteListType = &BusinessWebsiteListType;
3161 WebsiteListAltID = &BusinessWebsiteListAltID;
3162 WebsiteListPID = &BusinessWebsiteListPID;
3163 WebsiteListTokens = &BusinessWebsiteListTokens;
3164 WebsiteListMediatype = &BusinessWebsiteListMediatype;
3165 WebsiteListPref = &BusinessWebsiteListPref;
3171 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3172 intiter != SplitPoints.end(); ++intiter){
3174 SLiter = SplitLength.find(intiter->first);
3176 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3178 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3179 PropertyName = PropertyElement.GetNextToken();
3180 PropertyValue = PropertyElement.GetNextToken();
3182 intPrevValue = intiter->second;
3184 // Process properties.
3186 size_t intPropertyValueLen = PropertyValue.Len();
3188 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3190 PropertyValue.Trim();
3191 PropertyValue.RemoveLast();
3195 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3197 PropertyValue.Remove(0, 1);
3201 CaptureString(&PropertyValue, FALSE);
3203 if (PropertyName == wxT("ALTID")){
3205 WebsiteListAltID->erase(*URLCount);
3206 WebsiteListAltID->insert(std::make_pair(*URLCount, PropertyValue));
3208 } else if (PropertyName == wxT("PID")){
3210 WebsiteListPID->erase(*URLCount);
3211 WebsiteListPID->insert(std::make_pair(*URLCount, PropertyValue));
3213 } else if (PropertyName == wxT("PREF")){
3215 ProcessIntegerValue(WebsiteListPref, &PropertyValue, URLCount);
3217 } else if (PropertyName == wxT("MEDIATYPE")){
3219 WebsiteListMediatype->erase(*URLCount);
3220 WebsiteListMediatype->insert(std::make_pair(*URLCount, PropertyValue));
3224 // Something else we don't know about so append
3225 // to the tokens variable.
3227 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3229 if (FirstToken == TRUE){
3231 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3236 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3246 // Add the data to the General/Home/Work address variables.
3248 CaptureString(&PropertySeg2, FALSE);
3250 WebsiteList->insert(std::make_pair(*URLCount, PropertySeg2));
3252 if (!PropertyTokens.IsEmpty()){
3254 WebsiteListTokens->insert(std::make_pair(*URLCount, PropertyTokens));
3260 void ContactDataObject::ProcessTitle(wxString PropertySeg1, wxString PropertySeg2, int *TitleCount){
3262 std::map<int, int> SplitPoints;
3263 std::map<int, int> SplitLength;
3264 std::map<int, int>::iterator SLiter;
3265 wxString PropertyData;
3266 wxString PropertyName;
3267 wxString PropertyValue;
3268 wxString PropertyTokens;
3269 bool FirstToken = TRUE;
3270 int intPrevValue = 7;
3275 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3279 PropertyType PropType = PROPERTY_NONE;
3281 // Look for type before continuing.
3283 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3285 // Setup the pointers.
3287 std::map<int, wxString> *TitleList = NULL;
3288 std::map<int, wxString> *TitleListAltID = NULL;
3289 std::map<int, wxString> *TitleListPID = NULL;
3290 std::map<int, wxString> *TitleListType = NULL;
3291 std::map<int, wxString> *TitleListTokens = NULL;
3292 std::map<int, wxString> *TitleListLanguage = NULL;
3293 std::map<int, int> *TitleListPref = NULL;
3295 // Setup blank lines for later on.
3299 TitleList = &GeneralTitleList;
3300 TitleListType = &GeneralTitleListType;
3301 TitleListAltID = &GeneralTitleListAltID;
3302 TitleListPID = &GeneralTitleListPID;
3303 TitleListTokens = &GeneralTitleListTokens;
3304 TitleListLanguage = &GeneralTitleListLanguage;
3305 TitleListPref = &GeneralTitleListPref;
3308 TitleList = &HomeTitleList;
3309 TitleListType = &HomeTitleListType;
3310 TitleListAltID = &HomeTitleListAltID;
3311 TitleListPID = &HomeTitleListPID;
3312 TitleListTokens = &HomeTitleListTokens;
3313 TitleListLanguage = &HomeTitleListLanguage;
3314 TitleListPref = &HomeTitleListPref;
3317 TitleList = &BusinessTitleList;
3318 TitleListType = &BusinessTitleListType;
3319 TitleListAltID = &BusinessTitleListAltID;
3320 TitleListPID = &BusinessTitleListPID;
3321 TitleListTokens = &BusinessTitleListTokens;
3322 TitleListLanguage = &BusinessTitleListLanguage;
3323 TitleListPref = &BusinessTitleListPref;
3329 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3330 intiter != SplitPoints.end(); ++intiter){
3332 SLiter = SplitLength.find(intiter->first);
3334 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3336 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3337 PropertyName = PropertyElement.GetNextToken();
3338 PropertyValue = PropertyElement.GetNextToken();
3340 intPrevValue = intiter->second;
3342 // Process properties.
3344 size_t intPropertyValueLen = PropertyValue.Len();
3346 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3348 PropertyValue.Trim();
3349 PropertyValue.RemoveLast();
3353 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3355 PropertyValue.Remove(0, 1);
3359 CaptureString(&PropertyValue, FALSE);
3361 if (PropertyName == wxT("ALTID")){
3363 TitleListAltID->erase(*TitleCount);
3364 TitleListAltID->insert(std::make_pair(*TitleCount, PropertyValue));
3366 } else if (PropertyName == wxT("PID")){
3368 TitleListPID->erase(*TitleCount);
3369 TitleListPID->insert(std::make_pair(*TitleCount, PropertyValue));
3371 } else if (PropertyName == wxT("PREF")){
3373 ProcessIntegerValue(TitleListPref, &PropertyValue, TitleCount);
3375 } else if (PropertyName == wxT("LANGUAGE")){
3377 TitleListLanguage->erase(*TitleCount);
3378 TitleListLanguage->insert(std::make_pair(*TitleCount, PropertyValue));
3382 // Something else we don't know about so append
3383 // to the tokens variable.
3385 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3387 if (FirstToken == TRUE){
3389 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3394 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3404 // Add the data to the General/Home/Work address variables.
3406 CaptureString(&PropertySeg2, FALSE);
3408 TitleList->insert(std::make_pair(*TitleCount, PropertySeg2));
3410 if (!PropertyTokens.IsEmpty()){
3412 TitleListTokens->insert(std::make_pair(*TitleCount, PropertyTokens));
3418 void ContactDataObject::ProcessRole(wxString PropertySeg1, wxString PropertySeg2, int *RoleCount){
3420 std::map<int, int> SplitPoints;
3421 std::map<int, int> SplitLength;
3422 std::map<int, int>::iterator SLiter;
3423 wxString PropertyData;
3424 wxString PropertyName;
3425 wxString PropertyValue;
3426 wxString PropertyTokens;
3427 bool FirstToken = TRUE;
3428 int intPrevValue = 6;
3433 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3437 PropertyType PropType = PROPERTY_NONE;
3439 // Look for type before continuing.
3441 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3443 // Setup the pointers.
3445 std::map<int, wxString> *RoleList = NULL;
3446 std::map<int, wxString> *RoleListAltID = NULL;
3447 std::map<int, wxString> *RoleListPID = NULL;
3448 std::map<int, wxString> *RoleListType = NULL;
3449 std::map<int, wxString> *RoleListTokens = NULL;
3450 std::map<int, wxString> *RoleListLanguage = NULL;
3451 std::map<int, int> *RoleListPref = NULL;
3453 // Setup blank lines for later on.
3457 RoleList = &GeneralRoleList;
3458 RoleListType = &GeneralRoleListType;
3459 RoleListAltID = &GeneralRoleListAltID;
3460 RoleListPID = &GeneralRoleListPID;
3461 RoleListTokens = &GeneralRoleListTokens;
3462 RoleListLanguage = &GeneralRoleListLanguage;
3463 RoleListPref = &GeneralRoleListPref;
3466 RoleList = &HomeRoleList;
3467 RoleListType = &HomeRoleListType;
3468 RoleListAltID = &HomeRoleListAltID;
3469 RoleListPID = &HomeRoleListPID;
3470 RoleListTokens = &HomeRoleListTokens;
3471 RoleListLanguage = &HomeRoleListLanguage;
3472 RoleListPref = &HomeRoleListPref;
3475 RoleList = &BusinessRoleList;
3476 RoleListType = &BusinessRoleListType;
3477 RoleListAltID = &BusinessRoleListAltID;
3478 RoleListPID = &BusinessRoleListPID;
3479 RoleListTokens = &BusinessRoleListTokens;
3480 RoleListLanguage = &BusinessRoleListLanguage;
3481 RoleListPref = &BusinessRoleListPref;
3487 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3488 intiter != SplitPoints.end(); ++intiter){
3490 SLiter = SplitLength.find(intiter->first);
3492 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3494 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3495 PropertyName = PropertyElement.GetNextToken();
3496 PropertyValue = PropertyElement.GetNextToken();
3498 intPrevValue = intiter->second;
3500 // Process properties.
3502 size_t intPropertyValueLen = PropertyValue.Len();
3504 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3506 PropertyValue.Trim();
3507 PropertyValue.RemoveLast();
3511 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3513 PropertyValue.Remove(0, 1);
3517 CaptureString(&PropertyValue, FALSE);
3519 if (PropertyName == wxT("ALTID")){
3521 RoleListAltID->erase(*RoleCount);
3522 RoleListAltID->insert(std::make_pair(*RoleCount, PropertyValue));
3524 } else if (PropertyName == wxT("PID")){
3526 RoleListPID->erase(*RoleCount);
3527 RoleListPID->insert(std::make_pair(*RoleCount, PropertyValue));
3529 } else if (PropertyName == wxT("PREF")){
3531 ProcessIntegerValue(RoleListPref, &PropertyValue, RoleCount);
3533 } else if (PropertyName == wxT("LANGUAGE")){
3535 RoleListLanguage->erase(*RoleCount);
3536 RoleListLanguage->insert(std::make_pair(*RoleCount, PropertyValue));
3540 // Something else we don't know about so append
3541 // to the tokens variable.
3543 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3545 if (FirstToken == TRUE){
3547 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3552 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3562 // Add the data to the General/Home/Work address variables.
3564 CaptureString(&PropertySeg2, FALSE);
3566 RoleList->insert(std::make_pair(*RoleCount, PropertySeg2));
3568 if (!PropertyTokens.IsEmpty()){
3570 RoleListTokens->insert(std::make_pair(*RoleCount, PropertyTokens));
3576 void ContactDataObject::ProcessOrganisation(wxString PropertySeg1, wxString PropertySeg2, int *OrganisationCount){
3578 std::map<int, int> SplitPoints;
3579 std::map<int, int> SplitLength;
3580 std::map<int, int>::iterator SLiter;
3581 wxString PropertyData;
3582 wxString PropertyName;
3583 wxString PropertyValue;
3584 wxString PropertyTokens;
3585 bool FirstToken = TRUE;
3586 int intPrevValue = 5;
3591 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3595 PropertyType PropType = PROPERTY_NONE;
3597 // Look for type before continuing.
3599 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3601 // Setup the pointers.
3603 std::map<int, wxString> *OrganisationsList = NULL;
3604 std::map<int, wxString> *OrganisationsListAltID = NULL;
3605 std::map<int, wxString> *OrganisationsListPID = NULL;
3606 std::map<int, wxString> *OrganisationsListType = NULL;
3607 std::map<int, wxString> *OrganisationsListTokens = NULL;
3608 std::map<int, wxString> *OrganisationsListLanguage = NULL;
3609 std::map<int, wxString> *OrganisationsListSortAs = NULL;
3610 std::map<int, int> *OrganisationsListPref = NULL;
3612 // Setup blank lines for later on.
3616 OrganisationsList = &GeneralOrganisationsList;
3617 OrganisationsListType = &GeneralOrganisationsListType;
3618 OrganisationsListAltID = &GeneralOrganisationsListAltID;
3619 OrganisationsListPID = &GeneralOrganisationsListPID;
3620 OrganisationsListTokens = &GeneralOrganisationsListTokens;
3621 OrganisationsListLanguage = &GeneralOrganisationsListLanguage;
3622 OrganisationsListSortAs = &GeneralOrganisationsListSortAs;
3623 OrganisationsListPref = &GeneralOrganisationsListPref;
3626 OrganisationsList = &HomeOrganisationsList;
3627 OrganisationsListType = &HomeOrganisationsListType;
3628 OrganisationsListAltID = &HomeOrganisationsListAltID;
3629 OrganisationsListPID = &HomeOrganisationsListPID;
3630 OrganisationsListTokens = &HomeOrganisationsListTokens;
3631 OrganisationsListLanguage = &HomeOrganisationsListLanguage;
3632 OrganisationsListSortAs = &HomeOrganisationsListSortAs;
3633 OrganisationsListPref = &HomeOrganisationsListPref;
3636 OrganisationsList = &BusinessOrganisationsList;
3637 OrganisationsListType = &BusinessOrganisationsListType;
3638 OrganisationsListAltID = &BusinessOrganisationsListAltID;
3639 OrganisationsListPID = &BusinessOrganisationsListPID;
3640 OrganisationsListTokens = &BusinessOrganisationsListTokens;
3641 OrganisationsListLanguage = &BusinessOrganisationsListLanguage;
3642 OrganisationsListSortAs = &BusinessOrganisationsListSortAs;
3643 OrganisationsListPref = &BusinessOrganisationsListPref;
3649 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3650 intiter != SplitPoints.end(); ++intiter){
3652 SLiter = SplitLength.find(intiter->first);
3654 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3656 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3657 PropertyName = PropertyElement.GetNextToken();
3658 PropertyValue = PropertyElement.GetNextToken();
3660 intPrevValue = intiter->second;
3662 // Process properties.
3664 size_t intPropertyValueLen = PropertyValue.Len();
3666 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3668 PropertyValue.Trim();
3669 PropertyValue.RemoveLast();
3673 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3675 PropertyValue.Remove(0, 1);
3679 CaptureString(&PropertyValue, FALSE);
3681 if (PropertyName == wxT("ALTID")){
3683 OrganisationsListAltID->erase(*OrganisationCount);
3684 OrganisationsListAltID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3686 } else if (PropertyName == wxT("PID")){
3688 OrganisationsListPID->erase(*OrganisationCount);
3689 OrganisationsListPID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3691 } else if (PropertyName == wxT("SORT-AS")){
3693 OrganisationsListSortAs->erase(*OrganisationCount);
3694 OrganisationsListSortAs->insert(std::make_pair(*OrganisationCount, PropertyValue));
3696 } else if (PropertyName == wxT("PREF")){
3698 ProcessIntegerValue(OrganisationsListPref, &PropertyValue, OrganisationCount);
3700 } else if (PropertyName == wxT("LANGUAGE")){
3702 OrganisationsListLanguage->erase(*OrganisationCount);
3703 OrganisationsListLanguage->insert(std::make_pair(*OrganisationCount, PropertyValue));
3707 // Something else we don't know about so append
3708 // to the tokens variable.
3710 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3712 if (FirstToken == TRUE){
3714 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3719 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3729 // Add the data to the General/Home/Work address variables.
3731 CaptureString(&PropertySeg2, FALSE);
3733 OrganisationsList->insert(std::make_pair(*OrganisationCount, PropertySeg2));
3735 if (!PropertyTokens.IsEmpty()){
3737 OrganisationsListTokens->insert(std::make_pair(*OrganisationCount, PropertyTokens));
3743 void ContactDataObject::ProcessNote(wxString PropertySeg1, wxString PropertySeg2, int *NoteCount){
3745 std::map<int, int> SplitPoints;
3746 std::map<int, int> SplitLength;
3747 std::map<int, int>::iterator SLiter;
3748 wxString PropertyData;
3749 wxString PropertyName;
3750 wxString PropertyValue;
3751 wxString PropertyTokens;
3752 bool FirstToken = TRUE;
3753 int intPrevValue = 6;
3758 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3762 PropertyType PropType = PROPERTY_NONE;
3764 // Look for type before continuing.
3766 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3768 // Setup the pointers.
3770 std::map<int, wxString> *NoteList = NULL;
3771 std::map<int, wxString> *NoteListAltID = NULL;
3772 std::map<int, wxString> *NoteListPID = NULL;
3773 std::map<int, wxString> *NoteListType = NULL;
3774 std::map<int, wxString> *NoteListTokens = NULL;
3775 std::map<int, wxString> *NoteListLanguage = NULL;
3776 std::map<int, int> *NoteListPref = NULL;
3778 // Setup blank lines for later on.
3782 NoteList = &GeneralNoteList;
3783 NoteListType = &GeneralNoteListType;
3784 NoteListAltID = &GeneralNoteListAltID;
3785 NoteListPID = &GeneralNoteListPID;
3786 NoteListTokens = &GeneralNoteListTokens;
3787 NoteListLanguage = &GeneralNoteListLanguage;
3788 NoteListPref = &GeneralNoteListPref;
3791 NoteList = &HomeNoteList;
3792 NoteListType = &HomeNoteListType;
3793 NoteListAltID = &HomeNoteListAltID;
3794 NoteListPID = &HomeNoteListPID;
3795 NoteListTokens = &HomeNoteListTokens;
3796 NoteListLanguage = &HomeNoteListLanguage;
3797 NoteListPref = &HomeNoteListPref;
3800 NoteList = &BusinessNoteList;
3801 NoteListType = &BusinessNoteListType;
3802 NoteListAltID = &BusinessNoteListAltID;
3803 NoteListPID = &BusinessNoteListPID;
3804 NoteListTokens = &BusinessNoteListTokens;
3805 NoteListLanguage = &BusinessNoteListLanguage;
3806 NoteListPref = &BusinessNoteListPref;
3812 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3813 intiter != SplitPoints.end(); ++intiter){
3815 SLiter = SplitLength.find(intiter->first);
3817 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3819 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3820 PropertyName = PropertyElement.GetNextToken();
3821 PropertyValue = PropertyElement.GetNextToken();
3823 intPrevValue = intiter->second;
3825 // Process properties.
3827 size_t intPropertyValueLen = PropertyValue.Len();
3829 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3831 PropertyValue.Trim();
3832 PropertyValue.RemoveLast();
3836 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3838 PropertyValue.Remove(0, 1);
3842 CaptureString(&PropertyValue, FALSE);
3844 if (PropertyName == wxT("ALTID")){
3846 NoteListAltID->erase(*NoteCount);
3847 NoteListAltID->insert(std::make_pair(*NoteCount, PropertyValue));
3849 } else if (PropertyName == wxT("PID")){
3851 NoteListPID->erase(*NoteCount);
3852 NoteListPID->insert(std::make_pair(*NoteCount, PropertyValue));
3854 } else if (PropertyName == wxT("PREF")){
3856 ProcessIntegerValue(NoteListPref, &PropertyValue, NoteCount);
3858 } else if (PropertyName == wxT("LANGUAGE")){
3860 NoteListLanguage->erase(*NoteCount);
3861 NoteListLanguage->insert(std::make_pair(*NoteCount, PropertyValue));
3865 // Something else we don't know about so append
3866 // to the tokens variable.
3868 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3870 if (FirstToken == TRUE){
3872 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3877 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3887 // Add the data to the General/Home/Work address variables.
3889 CaptureString(&PropertySeg2, FALSE);
3891 NoteList->insert(std::make_pair(*NoteCount, PropertySeg2));
3893 if (!PropertyTokens.IsEmpty()){
3895 NoteListTokens->insert(std::make_pair(*NoteCount, PropertyTokens));
3901 void ContactDataObject::ProcessCategory(wxString PropertySeg1, wxString PropertySeg2, int *CategoryCount){
3903 std::map<int, int> SplitPoints;
3904 std::map<int, int> SplitLength;
3905 std::map<int, int>::iterator SLiter;
3906 wxString PropertyData;
3907 wxString PropertyName;
3908 wxString PropertyValue;
3909 wxString PropertyTokens;
3910 bool FirstToken = TRUE;
3911 int intPrevValue = 12;
3916 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3920 PropertyType PropType = PROPERTY_NONE;
3922 // Look for type before continuing.
3924 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3926 // Setup blank lines for later on.
3932 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
3935 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
3941 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3942 intiter != SplitPoints.end(); ++intiter){
3944 SLiter = SplitLength.find(intiter->first);
3946 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3948 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3949 PropertyName = PropertyElement.GetNextToken();
3950 PropertyValue = PropertyElement.GetNextToken();
3952 intPrevValue = intiter->second;
3954 // Process properties.
3956 size_t intPropertyValueLen = PropertyValue.Len();
3958 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3960 PropertyValue.Trim();
3961 PropertyValue.RemoveLast();
3965 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3967 PropertyValue.Remove(0, 1);
3971 CaptureString(&PropertyValue, FALSE);
3973 if (PropertyName == wxT("ALTID")){
3975 CategoriesListAltID.erase(*CategoryCount);
3976 CategoriesListAltID.insert(std::make_pair(*CategoryCount, PropertyValue));
3978 } else if (PropertyName == wxT("PID")){
3980 CategoriesListPID.erase(*CategoryCount);
3981 CategoriesListPID.insert(std::make_pair(*CategoryCount, PropertyValue));
3983 } else if (PropertyName == wxT("PREF")){
3985 ProcessIntegerValue(&CategoriesListPref, &PropertyValue, CategoryCount);
3987 } else if (PropertyName == wxT("LANGUAGE")){
3989 CategoriesListLanguage.erase(*CategoryCount);
3990 CategoriesListLanguage.insert(std::make_pair(*CategoryCount, PropertyValue));
3994 // Something else we don't know about so append
3995 // to the tokens variable.
3997 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3999 if (FirstToken == TRUE){
4001 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4006 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4016 // Deal with multiple categories.
4018 int intOrigCatCount = *CategoryCount;
4019 bool FirstCategoryProcessed = TRUE;
4020 bool AfterFirstToken = FALSE;
4021 int intSplitSize = 0;
4022 int intSplitsFound = 0;
4023 int intSplitSeek = 0;
4024 int intPropertyLen = PropertySeg2.Len();
4026 SplitPoints.clear();
4027 SplitLength.clear();
4030 for (int i = 0; i <= intPropertyLen; i++){
4032 if (intSplitSize == 0 && PropertySeg2.Mid(i, 1) == wxT(" ")){
4040 if (PropertySeg2.Mid(i, 1) == wxT(",") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
4042 if (AfterFirstToken == TRUE){
4044 SplitPoints.insert(std::make_pair(intSplitsFound, (i - intSplitSize + 1)));
4045 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
4049 SplitPoints.insert(std::make_pair(intSplitsFound, 0));
4050 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
4051 AfterFirstToken = TRUE;
4063 if (SplitPoints.size() > 0){
4065 SplitPoints.insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
4066 SplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
4070 if (SplitPoints.size() == 0){
4072 CategoriesList.insert(std::make_pair(*CategoryCount, PropertySeg2));
4074 if (!PropertyTokens.IsEmpty()){
4076 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4082 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4083 intiter != SplitPoints.end(); ++intiter){
4085 SLiter = SplitLength.find(intiter->first);
4087 intPrevValue = intiter->second;
4089 PropertyData = PropertySeg2.Mid(intPrevValue, (SLiter->second + 1));
4091 // Add the data to the General/Home/Work address variables.
4093 // Trim any whitespace from the start and end.
4095 PropertyData = PropertyData.Trim(FALSE);
4096 PropertyData = PropertyData.Trim(TRUE);
4098 CaptureString(&PropertyData, FALSE);
4100 if (FirstCategoryProcessed == TRUE){
4102 FirstCategoryProcessed = FALSE;
4104 CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4106 if (!PropertyTokens.IsEmpty()){
4108 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4118 CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4120 if (!PropertyTokens.IsEmpty()){
4122 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4128 // Copy the properties to each of the categories (if it exists).
4130 if (!PropertyTokens.IsEmpty()){
4132 CategoriesListTokens.insert(std::make_pair(*CategoryCount, CategoriesListTokens.find(intOrigCatCount)->second));
4136 // Check if ALTID was used.
4138 if (CategoriesListAltID.find(intOrigCatCount) != CategoriesListAltID.end()){
4140 CategoriesListAltID.insert(std::make_pair(*CategoryCount, CategoriesListAltID.find(intOrigCatCount)->second));
4144 // Check if PID was used.
4146 if (CategoriesListPID.find(intOrigCatCount) != CategoriesListPID.end()){
4148 CategoriesListPID.insert(std::make_pair(*CategoryCount, CategoriesListPID.find(intOrigCatCount)->second));
4152 // Check if PREF was used.
4154 if (CategoriesListPref.find(intOrigCatCount) != CategoriesListPref.end()){
4156 CategoriesListPref.insert(std::make_pair(*CategoryCount, CategoriesListPref.find(intOrigCatCount)->second));
4160 // Check if LANGUAGE was used.
4162 if (CategoriesListLanguage.find(intOrigCatCount) != CategoriesListLanguage.end()){
4164 CategoriesListLanguage.insert(std::make_pair(*CategoryCount, CategoriesListLanguage.find(intOrigCatCount)->second));
4168 // Check if TYPE was used.
4174 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
4177 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
4185 void ContactDataObject::ProcessPhoto(wxString PropertySeg1, wxString PropertySeg2, int *PhotoCount){
4187 size_t intPropertyLen = PropertySeg1.Len();
4188 std::map<int, int> SplitPoints;
4189 std::map<int, int> SplitLength;
4190 std::map<int, int>::iterator SLiter;
4191 wxString PropertyData;
4192 wxString PropertyName;
4193 wxString PropertyValue;
4194 wxString PropertyTokens;
4195 bool FirstToken = TRUE;
4196 int intSplitsFound = 0;
4197 int intSplitSize = 0;
4198 int intPrevValue = 7;
4202 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4206 PropertyType PropType = PROPERTY_NONE;
4208 // Look for type before continuing.
4210 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4214 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4215 intiter != SplitPoints.end(); ++intiter){
4217 SLiter = SplitLength.find(intiter->first);
4219 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4221 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4222 PropertyName = PropertyElement.GetNextToken();
4223 PropertyValue = PropertyElement.GetNextToken();
4225 intPrevValue = intiter->second;
4227 // Process properties.
4229 size_t intPropertyValueLen = PropertyValue.Len();
4231 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4233 PropertyValue.Trim();
4234 PropertyValue.RemoveLast();
4238 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4240 PropertyValue.Remove(0, 1);
4244 CaptureString(&PropertyValue, FALSE);
4246 if (PropertyName == wxT("ALTID")){
4248 PicturesListAltID.erase(*PhotoCount);
4249 PicturesListAltID.insert(std::make_pair(*PhotoCount, PropertyValue));
4251 } else if (PropertyName == wxT("PID")){
4253 PicturesListPID.erase(*PhotoCount);
4254 PicturesListPID.insert(std::make_pair(*PhotoCount, PropertyValue));
4256 } else if (PropertyName == wxT("PREF")){
4258 ProcessIntegerValue(&PicturesListPref, &PropertyValue, PhotoCount);
4260 } else if (PropertyName == wxT("MEDIATYPE")){
4262 PicturesListMediatype.erase(*PhotoCount);
4263 PicturesListMediatype.insert(std::make_pair(*PhotoCount, PropertyValue));
4267 // Something else we don't know about so append
4268 // to the tokens variable.
4270 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4272 if (FirstToken == TRUE){
4274 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4279 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4289 intPropertyLen = PropertySeg2.Len();
4290 SplitPoints.clear();
4291 SplitLength.clear();
4296 CaptureString(&PropertySeg2, FALSE);
4298 for (int i = 0; i <= intPropertyLen; i++){
4302 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4305 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4307 if (intSplitsFound == 6){
4309 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4314 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4324 wxString wxSPhotoURI;
4325 wxString wxSPhotoMIME;
4326 wxString wxSPhotoEncoding;
4327 wxString wxSPhotoData;
4328 std::string base64enc;
4330 if (intSplitsFound == 0){
4334 std::map<int, int>::iterator striter;
4336 striter = SplitLength.find(1);
4338 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4340 while (wSTDataType.HasMoreTokens() == TRUE){
4342 wxSPhotoURI = wSTDataType.GetNextToken();
4343 wxSPhotoMIME = wSTDataType.GetNextToken();
4348 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
4350 while (wSTDataInfo.HasMoreTokens() == TRUE){
4352 wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4353 wxSPhotoData = wSTDataInfo.GetNextToken();
4354 base64enc = wxSPhotoData.mb_str();
4361 // Add the data to the General/Home/Work address variables.
4363 PicturesList.insert(std::make_pair(*PhotoCount, base64enc));
4364 PicturesListPictureType.insert(std::make_pair(*PhotoCount, wxSPhotoMIME));
4365 PicturesListPicEncType.insert(std::make_pair(*PhotoCount, wxSPhotoEncoding));
4371 PicturesListType.insert(std::make_pair(*PhotoCount, "home"));
4374 PicturesListType.insert(std::make_pair(*PhotoCount, "work"));
4378 if (!PropertyTokens.IsEmpty()){
4380 PicturesListTokens.insert(std::make_pair(*PhotoCount, PropertyTokens));
4386 void ContactDataObject::ProcessLogo(wxString PropertySeg1, wxString PropertySeg2, int *LogoCount){
4388 size_t intPropertyLen = PropertySeg1.Len();
4389 std::map<int, int> SplitPoints;
4390 std::map<int, int> SplitLength;
4391 std::map<int, int>::iterator SLiter;
4392 wxString PropertyData;
4393 wxString PropertyName;
4394 wxString PropertyValue;
4395 wxString PropertyTokens;
4396 bool FirstToken = TRUE;
4397 int intSplitsFound = 0;
4398 int intSplitSize = 0;
4399 int intPrevValue = 6;
4403 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4407 PropertyType PropType = PROPERTY_NONE;
4409 // Look for type before continuing.
4411 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4415 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4416 intiter != SplitPoints.end(); ++intiter){
4418 SLiter = SplitLength.find(intiter->first);
4420 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4422 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4423 PropertyName = PropertyElement.GetNextToken();
4424 PropertyValue = PropertyElement.GetNextToken();
4426 intPrevValue = intiter->second;
4428 // Process properties.
4430 size_t intPropertyValueLen = PropertyValue.Len();
4432 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4434 PropertyValue.Trim();
4435 PropertyValue.RemoveLast();
4439 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4441 PropertyValue.Remove(0, 1);
4445 CaptureString(&PropertyValue, FALSE);
4447 if (PropertyName == wxT("ALTID")){
4449 LogosListAltID.erase(*LogoCount);
4450 LogosListAltID.insert(std::make_pair(*LogoCount, PropertyValue));
4452 } else if (PropertyName == wxT("PID")){
4454 LogosListPID.erase(*LogoCount);
4455 LogosListPID.insert(std::make_pair(*LogoCount, PropertyValue));
4457 } else if (PropertyName == wxT("PREF")){
4459 ProcessIntegerValue(&LogosListPref, &PropertyValue, LogoCount);
4461 } else if (PropertyName == wxT("MEDIATYPE")){
4463 LogosListMediatype.erase(*LogoCount);
4464 LogosListMediatype.insert(std::make_pair(*LogoCount, PropertyValue));
4468 // Something else we don't know about so append
4469 // to the tokens variable.
4471 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4473 if (FirstToken == TRUE){
4475 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4480 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4490 intPropertyLen = PropertySeg2.Len();
4491 SplitPoints.clear();
4492 SplitLength.clear();
4497 CaptureString(&PropertySeg2, FALSE);
4499 for (int i = 0; i <= intPropertyLen; i++){
4503 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4506 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4508 if (intSplitsFound == 6){
4510 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4515 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4525 wxString wxSPhotoURI;
4526 wxString wxSPhotoMIME;
4527 wxString wxSPhotoEncoding;
4528 wxString wxSPhotoData;
4529 std::string base64enc;
4531 if (intSplitsFound == 0){
4535 std::map<int, int>::iterator striter;
4537 striter = SplitLength.find(1);
4539 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4541 while (wSTDataType.HasMoreTokens() == TRUE){
4543 wxSPhotoURI = wSTDataType.GetNextToken();
4544 wxSPhotoMIME = wSTDataType.GetNextToken();
4549 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
4551 while (wSTDataInfo.HasMoreTokens() == TRUE){
4553 wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4554 wxSPhotoData = wSTDataInfo.GetNextToken();
4555 base64enc = wxSPhotoData.mb_str();
4562 // Add the data to the General/Home/Work address variables.
4564 LogosList.insert(std::make_pair(*LogoCount, base64enc));
4565 LogosListPictureType.insert(std::make_pair(*LogoCount, wxSPhotoMIME));
4566 LogosListPicEncType.insert(std::make_pair(*LogoCount, wxSPhotoEncoding));
4572 LogosListType.insert(std::make_pair(*LogoCount, "home"));
4575 LogosListType.insert(std::make_pair(*LogoCount, "work"));
4579 if (!PropertyTokens.IsEmpty()){
4581 LogosListTokens.insert(std::make_pair(*LogoCount, PropertyTokens));
4587 void ContactDataObject::ProcessSound(wxString PropertySeg1, wxString PropertySeg2, int *SoundCount){
4589 size_t intPropertyLen = PropertySeg1.Len();
4590 std::map<int, int> SplitPoints;
4591 std::map<int, int> SplitLength;
4592 std::map<int, int>::iterator SLiter;
4593 wxString PropertyData;
4594 wxString PropertyName;
4595 wxString PropertyValue;
4596 wxString PropertyTokens;
4597 bool FirstToken = TRUE;
4598 int intSplitsFound = 0;
4599 int intSplitSize = 0;
4600 int intPrevValue = 7;
4604 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4608 PropertyType PropType = PROPERTY_NONE;
4610 // Look for type before continuing.
4612 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4616 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4617 intiter != SplitPoints.end(); ++intiter){
4619 SLiter = SplitLength.find(intiter->first);
4621 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4623 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4624 PropertyName = PropertyElement.GetNextToken();
4625 PropertyValue = PropertyElement.GetNextToken();
4627 intPrevValue = intiter->second;
4629 // Process properties.
4631 size_t intPropertyValueLen = PropertyValue.Len();
4633 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4635 PropertyValue.Trim();
4636 PropertyValue.RemoveLast();
4640 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4642 PropertyValue.Remove(0, 1);
4646 CaptureString(&PropertyValue, FALSE);
4648 if (PropertyName == wxT("ALTID")){
4650 SoundsListAltID.erase(*SoundCount);
4651 SoundsListAltID.insert(std::make_pair(*SoundCount, PropertyValue));
4653 } else if (PropertyName == wxT("PID")){
4655 SoundsListPID.erase(*SoundCount);
4656 SoundsListPID.insert(std::make_pair(*SoundCount, PropertyValue));
4658 } else if (PropertyName == wxT("PREF")){
4660 ProcessIntegerValue(&SoundsListPref, &PropertyValue, SoundCount);
4662 } else if (PropertyName == wxT("MEDIATYPE")){
4664 SoundsListMediatype.erase(*SoundCount);
4665 SoundsListMediatype.insert(std::make_pair(*SoundCount, PropertyValue));
4667 } else if (PropertyName == wxT("LANGUAGE")){
4669 SoundsListLanguage.erase(*SoundCount);
4670 SoundsListLanguage.insert(std::make_pair(*SoundCount, PropertyValue));
4674 // Something else we don't know about so append
4675 // to the tokens variable.
4677 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4679 if (FirstToken == TRUE){
4681 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4686 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4696 intPropertyLen = PropertySeg2.Len();
4697 SplitPoints.clear();
4698 SplitLength.clear();
4703 CaptureString(&PropertySeg2, FALSE);
4705 for (int i = 0; i <= intPropertyLen; i++){
4709 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4712 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4714 if (intSplitsFound == 6){
4716 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4721 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4731 wxString wxSSoundURI;
4732 wxString wxSSoundMIME;
4733 wxString wxSSoundEncoding;
4734 wxString wxSSoundData;
4735 std::string base64enc;
4737 if (intSplitsFound == 0){
4741 std::map<int, int>::iterator striter;
4743 striter = SplitLength.find(1);
4745 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4747 while (wSTDataType.HasMoreTokens() == TRUE){
4749 wxSSoundURI = wSTDataType.GetNextToken();
4750 wxSSoundMIME = wSTDataType.GetNextToken();
4755 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
4757 while (wSTDataInfo.HasMoreTokens() == TRUE){
4759 wxSSoundEncoding = wSTDataInfo.GetNextToken();
4760 wxSSoundData = wSTDataInfo.GetNextToken();
4761 base64enc = wxSSoundData.mb_str();
4768 // Add the data to the General/Home/Work address variables.
4774 SoundsListType.insert(std::make_pair(*SoundCount, "home"));
4777 SoundsListType.insert(std::make_pair(*SoundCount, "work"));
4781 SoundsList.insert(std::make_pair(*SoundCount, base64enc));
4782 SoundsListAudioEncType.insert(std::make_pair(*SoundCount, wxSSoundEncoding));
4783 SoundsListAudioType.insert(std::make_pair(*SoundCount, wxSSoundMIME));
4785 if (!PropertyTokens.IsEmpty()){
4787 SoundsListTokens.insert(std::make_pair(*SoundCount, PropertyTokens));
4793 void ContactDataObject::ProcessCalendarURI(wxString PropertySeg1, wxString PropertySeg2, int *CalURICount){
4795 size_t intPropertyLen = PropertySeg1.Len();
4796 std::map<int, int> SplitPoints;
4797 std::map<int, int> SplitLength;
4798 std::map<int, int>::iterator SLiter;
4799 wxString PropertyData;
4800 wxString PropertyName;
4801 wxString PropertyValue;
4802 wxString PropertyTokens;
4803 bool FirstToken = TRUE;
4804 int intSplitsFound = 0;
4805 int intSplitSize = 0;
4806 int intPrevValue = 8;
4810 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4814 PropertyType PropType = PROPERTY_NONE;
4816 // Look for type before continuing.
4818 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4822 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4823 intiter != SplitPoints.end(); ++intiter){
4825 SLiter = SplitLength.find(intiter->first);
4827 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4829 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4830 PropertyName = PropertyElement.GetNextToken();
4831 PropertyValue = PropertyElement.GetNextToken();
4833 intPrevValue = intiter->second;
4835 // Process properties.
4837 size_t intPropertyValueLen = PropertyValue.Len();
4839 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4841 PropertyValue.Trim();
4842 PropertyValue.RemoveLast();
4846 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4848 PropertyValue.Remove(0, 1);
4852 CaptureString(&PropertyValue, FALSE);
4854 if (PropertyName == wxT("ALTID")){
4856 CalendarListAltID.erase(*CalURICount);
4857 CalendarListAltID.insert(std::make_pair(*CalURICount, PropertyValue));
4859 } else if (PropertyName == wxT("PID")){
4861 CalendarListPID.erase(*CalURICount);
4862 CalendarListPID.insert(std::make_pair(*CalURICount, PropertyValue));
4864 } else if (PropertyName == wxT("PREF")){
4866 ProcessIntegerValue(&CalendarListPref, &PropertyValue, CalURICount);
4868 } else if (PropertyName == wxT("MEDIATYPE")){
4870 CalendarListMediatype.erase(*CalURICount);
4871 CalendarListMediatype.insert(std::make_pair(*CalURICount, PropertyValue));
4875 // Something else we don't know about so append
4876 // to the tokens variable.
4878 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4880 if (FirstToken == TRUE){
4882 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4887 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4897 intPropertyLen = PropertySeg2.Len();
4898 SplitPoints.clear();
4899 SplitLength.clear();
4904 CaptureString(&PropertySeg2, FALSE);
4906 // Add the data to the General/Home/Work address variables.
4912 CalendarListType.insert(std::make_pair(*CalURICount, "home"));
4915 CalendarListType.insert(std::make_pair(*CalURICount, "work"));
4919 CalendarList.insert(std::make_pair(*CalURICount, PropertySeg2));
4921 if (!PropertyTokens.IsEmpty()){
4923 CalendarListTokens.insert(std::make_pair(*CalURICount, PropertyTokens));
4929 void ContactDataObject::ProcessCalendarAddressURI(wxString PropertySeg1, wxString PropertySeg2, int *CalAdrURICount){
4931 size_t intPropertyLen = PropertySeg1.Len();
4932 std::map<int, int> SplitPoints;
4933 std::map<int, int> SplitLength;
4934 std::map<int, int>::iterator SLiter;
4935 wxString PropertyData;
4936 wxString PropertyName;
4937 wxString PropertyValue;
4938 wxString PropertyTokens;
4939 bool FirstToken = TRUE;
4940 int intSplitsFound = 0;
4941 int intSplitSize = 0;
4942 int intPrevValue = 8;
4946 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4950 PropertyType PropType = PROPERTY_NONE;
4952 // Look for type before continuing.
4954 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4958 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4959 intiter != SplitPoints.end(); ++intiter){
4961 SLiter = SplitLength.find(intiter->first);
4963 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4965 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4966 PropertyName = PropertyElement.GetNextToken();
4967 PropertyValue = PropertyElement.GetNextToken();
4969 intPrevValue = intiter->second;
4971 // Process properties.
4973 size_t intPropertyValueLen = PropertyValue.Len();
4975 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4977 PropertyValue.Trim();
4978 PropertyValue.RemoveLast();
4982 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4984 PropertyValue.Remove(0, 1);
4988 CaptureString(&PropertyValue, FALSE);
4990 if (PropertyName == wxT("ALTID")){
4992 CalendarRequestListAltID.erase(*CalAdrURICount);
4993 CalendarRequestListAltID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
4995 } else if (PropertyName == wxT("PID")){
4997 CalendarRequestListPID.erase(*CalAdrURICount);
4998 CalendarRequestListPID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5000 } else if (PropertyName == wxT("PREF")){
5002 ProcessIntegerValue(&CalendarRequestListPref, &PropertyValue, CalAdrURICount);
5004 } else if (PropertyName == wxT("MEDIATYPE")){
5006 CalendarRequestListMediatype.erase(*CalAdrURICount);
5007 CalendarRequestListMediatype.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5011 // Something else we don't know about so append
5012 // to the tokens variable.
5014 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5016 if (FirstToken == TRUE){
5018 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5023 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5033 intPropertyLen = PropertySeg2.Len();
5034 SplitPoints.clear();
5035 SplitLength.clear();
5040 CaptureString(&PropertySeg2, FALSE);
5042 // Add the data to the General/Home/Work address variables.
5048 CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "home"));
5051 CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "work"));
5055 CalendarRequestList.insert(std::make_pair(*CalAdrURICount, PropertySeg2));
5057 if (!PropertyTokens.IsEmpty()){
5059 CalendarRequestListTokens.insert(std::make_pair(*CalAdrURICount, PropertyTokens));
5065 void ContactDataObject::ProcessCalendarFreeBusy(wxString PropertySeg1, wxString PropertySeg2, int *FreeBusyAddressCount){
5067 size_t intPropertyLen = PropertySeg1.Len();
5068 std::map<int, int> SplitPoints;
5069 std::map<int, int> SplitLength;
5070 std::map<int, int>::iterator SLiter;
5071 wxString PropertyData;
5072 wxString PropertyName;
5073 wxString PropertyValue;
5074 wxString PropertyTokens;
5075 bool FirstToken = TRUE;
5076 int intSplitsFound = 0;
5077 int intSplitSize = 0;
5078 int intPrevValue = 7;
5082 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5086 PropertyType PropType = PROPERTY_NONE;
5088 // Look for type before continuing.
5090 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5094 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
5095 intiter != SplitPoints.end(); ++intiter){
5097 SLiter = SplitLength.find(intiter->first);
5099 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5101 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5102 PropertyName = PropertyElement.GetNextToken();
5103 PropertyValue = PropertyElement.GetNextToken();
5105 intPrevValue = intiter->second;
5107 // Process properties.
5109 size_t intPropertyValueLen = PropertyValue.Len();
5111 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5113 PropertyValue.Trim();
5114 PropertyValue.RemoveLast();
5118 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5120 PropertyValue.Remove(0, 1);
5124 CaptureString(&PropertyValue, FALSE);
5126 if (PropertyName == wxT("ALTID")){
5128 FreeBusyListAltID.erase(*FreeBusyAddressCount);
5129 FreeBusyListAltID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5131 } else if (PropertyName == wxT("PID")){
5133 FreeBusyListPID.erase(*FreeBusyAddressCount);
5134 FreeBusyListPID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5136 } else if (PropertyName == wxT("PREF")){
5138 ProcessIntegerValue(&FreeBusyListPref, &PropertyValue, FreeBusyAddressCount);
5140 } else if (PropertyName == wxT("MEDIATYPE")){
5142 FreeBusyListMediatype.erase(*FreeBusyAddressCount);
5143 FreeBusyListMediatype.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5147 // Something else we don't know about so append
5148 // to the tokens variable.
5150 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5152 if (FirstToken == TRUE){
5154 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5159 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5169 intPropertyLen = PropertySeg2.Len();
5170 SplitPoints.clear();
5171 SplitLength.clear();
5176 CaptureString(&PropertySeg2, FALSE);
5178 // Add the data to the General/Home/Work address variables.
5184 FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "home"));
5187 FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "work"));
5191 FreeBusyList.insert(std::make_pair(*FreeBusyAddressCount, PropertySeg2));
5193 if (!PropertyTokens.IsEmpty()){
5195 FreeBusyListTokens.insert(std::make_pair(*FreeBusyAddressCount, PropertyTokens));
5201 void ContactDataObject::ProcessKey(wxString PropertySeg1, wxString PropertySeg2, int *KeyCount){
5203 size_t intPropertyLen = PropertySeg1.Len();
5204 std::map<int, int> SplitPoints;
5205 std::map<int, int> SplitLength;
5206 std::map<int, int>::iterator SLiter;
5207 wxString PropertyData;
5208 wxString PropertyName;
5209 wxString PropertyValue;
5210 wxString PropertyTokens;
5211 bool FirstToken = TRUE;
5212 int intSplitsFound = 0;
5213 int intSplitSize = 0;
5214 int intPrevValue = 5;
5219 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5223 PropertyType PropType = PROPERTY_NONE;
5225 // Look for type before continuing.
5227 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5231 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
5232 intiter != SplitPoints.end(); ++intiter){
5234 SLiter = SplitLength.find(intiter->first);
5236 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5238 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5239 PropertyName = PropertyElement.GetNextToken();
5240 PropertyValue = PropertyElement.GetNextToken();
5242 intPrevValue = intiter->second;
5244 // Process properties.
5246 size_t intPropertyValueLen = PropertyValue.Len();
5248 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5250 PropertyValue.Trim();
5251 PropertyValue.RemoveLast();
5255 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5257 PropertyValue.Remove(0, 1);
5261 if (PropertyName == wxT("ALTID")){
5263 KeyListAltID.erase(*KeyCount);
5264 KeyListAltID.insert(std::make_pair(*KeyCount, PropertyValue));
5266 } else if (PropertyName == wxT("PID")){
5268 KeyListPID.erase(*KeyCount);
5269 KeyListPID.insert(std::make_pair(*KeyCount, PropertyValue));
5271 } else if (PropertyName == wxT("PREF")){
5273 ProcessIntegerValue(&KeyListPref, &PropertyValue, KeyCount);
5277 // Something else we don't know about so append
5278 // to the tokens variable.
5280 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5282 if (FirstToken == TRUE){
5284 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5289 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5299 intPropertyLen = PropertySeg2.Len();
5300 SplitPoints.clear();
5301 SplitLength.clear();
5306 for (int i = 0; i <= intPropertyLen; i++){
5310 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
5313 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
5315 if (intSplitsFound == 6){
5317 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5322 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5333 wxString wxSKeyMIME;
5334 wxString wxSKeyEncoding;
5335 wxString wxSKeyData;
5336 std::string base64enc;
5338 if (intSplitsFound == 0){
5342 std::map<int, int>::iterator striter;
5344 striter = SplitLength.find(1);
5346 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
5348 while (wSTDataType.HasMoreTokens() == TRUE){
5350 wxSKeyURI = wSTDataType.GetNextToken();
5351 wxSKeyMIME = wSTDataType.GetNextToken();
5356 if (wxSKeyURI == wxT("data")){
5358 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
5360 while (wSTDataInfo.HasMoreTokens() == TRUE){
5362 wxSKeyEncoding = wSTDataInfo.GetNextToken();
5363 wxSKeyData = wSTDataInfo.GetNextToken();
5372 // Add the data to the General/Home/Work address variables.
5374 if (wxSKeyURI == wxT("data")){
5376 KeyListDataEncType.erase(*KeyCount);
5377 KeyListKeyType.erase(*KeyCount);
5378 KeyListDataEncType.insert(std::make_pair(*KeyCount, wxSKeyEncoding));
5379 KeyListKeyType.insert(std::make_pair(*KeyCount, TRUE));
5381 KeyList.erase(*KeyCount);
5382 KeyList.insert(std::make_pair(*KeyCount, wxSKeyData));
5386 KeyList.erase(*KeyCount);
5387 KeyList.insert(std::make_pair(*KeyCount, PropertySeg2));
5391 KeyListDataType.insert(std::make_pair(*KeyCount, wxSKeyMIME));
5397 KeyListType.insert(std::make_pair(*KeyCount, wxT("home")));
5400 KeyListType.insert(std::make_pair(*KeyCount, wxT("work")));
5404 if (!PropertyTokens.IsEmpty()){
5406 KeyListTokens.insert(std::make_pair(*KeyCount, PropertyTokens));
5412 void ContactDataObject::ProcessVendor(wxString PropertySeg1, wxString PropertySeg2, int *VendorCount){
5414 // Split the Vendor three ways.
5416 wxStringTokenizer wSTVendorDetails(PropertySeg1, wxT("-"));
5419 wxString wxSVNDPropName;
5422 while (wSTVendorDetails.HasMoreTokens() == TRUE){
5424 wSTVendorDetails.GetNextToken();
5425 wxSVNDID = wSTVendorDetails.GetNextToken();
5426 wxSVNDPropName = wSTVendorDetails.GetNextToken();
5431 if (!wxSVNDID.IsEmpty() && !wxSVNDPropName.IsEmpty()){
5433 // Add the data to the vendor variables.
5435 VendorList.erase(*VendorCount);
5436 VendorListPEN.erase(*VendorCount);
5437 VendorListElement.erase(*VendorCount);
5439 VendorList.insert(std::make_pair(*VendorCount, PropertySeg2));
5440 VendorListPEN.insert(std::make_pair(*VendorCount, wxSVNDID));
5441 VendorListElement.insert(std::make_pair(*VendorCount, wxSVNDPropName));
5447 void ProcessStringValue(wxString *PropertyName,
5448 wxString PropertyNameMatch,
5449 std::map<int,wxString> *MapPtr,
5450 wxString *PropertyValue,
5452 bool *PropertyMatched){
5454 if (*PropertyName == PropertyNameMatch){
5455 MapPtr->erase(*ItemCount);
5456 MapPtr->insert(std::make_pair(*ItemCount, *PropertyValue));
5457 *PropertyMatched = TRUE;
5462 void ProcessIntegerValue(wxString *PropertyName,
5463 wxString PropertyNameMatch,
5464 std::map<int,int> *PrefPtr,
5465 wxString *PropertyValue,
5467 bool *PropertyMatched){
5469 if (*PropertyName == PropertyNameMatch){
5470 *PropertyMatched = TRUE;
5475 int PriorityNumber = 0;
5476 bool ValidNumber = TRUE;
5479 PriorityNumber = std::stoi(PropertyValue->ToStdString());
5482 catch(std::invalid_argument &e){
5483 ValidNumber = FALSE;
5486 if (ValidNumber == TRUE){
5488 PrefPtr->erase(*ItemCount);
5489 PrefPtr->insert(std::make_pair(*ItemCount, PriorityNumber));
5495 void ProcessIntegerValue(std::map<int,int> *PrefPtr,
5496 wxString *PropertyValue,
5499 int PriorityNumber = 0;
5500 bool ValidNumber = TRUE;
5503 PriorityNumber = std::stoi(PropertyValue->ToStdString());
5506 catch(std::invalid_argument &e){
5507 ValidNumber = FALSE;
5510 if (ValidNumber == TRUE){
5512 PrefPtr->erase(*ItemCount);
5513 PrefPtr->insert(std::make_pair(*ItemCount, PriorityNumber));
5519 void SplitValues(wxString *PropertyLine,
5520 std::map<int,int> *SplitPoints,
5521 std::map<int,int> *SplitLength,
5524 size_t intPropertyLen = PropertyLine->Len();
5525 int intSplitsFound = 0;
5526 int intSplitSize = 0;
5527 int intSplitSeek = 0;
5529 for (int i = intSize; i <= intPropertyLen; i++){
5533 if (PropertyLine->Mid(i, 1) == wxT(";") &&
5534 PropertyLine->Mid((i - 1), 1) != wxT("\\")){
5536 if (intSplitsFound == 0){
5538 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
5542 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5546 SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
5556 if (intSplitsFound == 0){
5558 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
5559 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5563 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
5564 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5570 void CheckType(wxString *PropertySeg1,
5571 std::map<int,int> *SplitPoints,
5572 std::map<int,int> *SplitLength,
5574 PropertyType *PropType){
5576 wxString PropertyData;
5577 wxString PropertyName;
5578 wxString PropertyValue;
5579 std::map<int,int>::iterator SLiter;
5581 for (std::map<int, int>::iterator intiter = SplitPoints->begin();
5582 intiter != SplitPoints->end(); ++intiter){
5584 SLiter = SplitLength->find(intiter->first);
5586 PropertyData = PropertySeg1->Mid(*intPrevValue, (SLiter->second));
5588 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5589 PropertyName = PropertyElement.GetNextToken();
5590 PropertyValue = PropertyElement.GetNextToken();
5592 *intPrevValue = intiter->second;
5594 if (PropertyName == wxT("TYPE")){
5596 if (PropertyValue == wxT("work")){
5598 *PropType = PROPERTY_WORK;
5600 } else if (PropertyValue == wxT("home")){
5602 *PropType = PROPERTY_HOME;
5606 *PropType = PROPERTY_NONE;