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;
684 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
685 intiter != SplitPoints.end(); ++intiter){
687 SLiter = SplitLength.find(intiter->first);
689 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
691 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
692 PropertyName = PropertyElement.GetNextToken();
693 PropertyValue = PropertyElement.GetNextToken();
695 intPrevValue = intiter->second;
697 CaptureString(&PropertyValue, FALSE);
699 if (PropertyName == wxT("ALTID")){
701 XMLListAltID.erase(*XMLCount);
702 XMLListAltID.insert(std::make_pair(*XMLCount, PropertyValue));
708 XMLList.insert(std::make_pair(*XMLCount, PropertySeg2));
712 void ContactDataObject::ProcessMember(wxString PropertySeg1, wxString PropertySeg2, int *GroupCount){
714 std::map<int, int> SplitPoints;
715 std::map<int, int> SplitLength;
717 int intPrevValue = 8;
721 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
725 wxString PropertyName;
726 wxString PropertyValue;
727 wxString PropertyData;
728 wxString PropertyTokens;
729 std::map<int,int>::iterator SLiter;
730 bool FirstToken = TRUE;
732 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
733 intiter != SplitPoints.end(); ++intiter){
735 SLiter = SplitLength.find(intiter->first);
737 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
739 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
740 PropertyName = PropertyElement.GetNextToken();
741 PropertyValue = PropertyElement.GetNextToken();
743 intPrevValue = intiter->second;
745 CaptureString(&PropertyValue, FALSE);
747 if (PropertyName == wxT("ALTID")){
749 GroupsListAltID.erase(*GroupCount);
750 GroupsListAltID.insert(std::make_pair(*GroupCount, PropertyValue));
752 } else if (PropertyName == wxT("PID")){
754 GroupsListPID.erase(*GroupCount);
755 GroupsListPID.insert(std::make_pair(*GroupCount, PropertyValue));
757 } else if (PropertyName == wxT("PREF")){
759 ProcessIntegerValue(&GroupsListPref, &PropertyValue, GroupCount);
761 } else if (PropertyName == wxT("MEDIATYPE")){
763 GroupsListMediaType.erase(*GroupCount);
764 GroupsListMediaType.insert(std::make_pair(*GroupCount, PropertyValue));
766 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
768 if (FirstToken == TRUE){
770 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
775 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
783 GroupsList.insert(std::make_pair(*GroupCount, PropertySeg2));
785 if (!PropertyTokens.IsEmpty()){
787 GroupsListTokens.insert(std::make_pair(*GroupCount, PropertyTokens));
794 void ContactDataObject::ProcessFN(wxString PropertySeg1, wxString PropertySeg2, int *FNCount){
796 std::map<int, int> SplitPoints;
797 std::map<int, int> SplitLength;
799 int intPrevValue = 4;
803 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
807 wxString PropertyName;
808 wxString PropertyValue;
809 wxString PropertyData;
810 wxString PropertyTokens;
811 std::map<int,int>::iterator SLiter;
812 bool FirstToken = TRUE;
814 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
815 intiter != SplitPoints.end(); ++intiter){
817 SLiter = SplitLength.find(intiter->first);
819 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
821 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
822 PropertyName = PropertyElement.GetNextToken();
823 PropertyValue = PropertyElement.GetNextToken();
825 intPrevValue = intiter->second;
827 CaptureString(&PropertyValue, FALSE);
829 if (PropertyName == wxT("TYPE")){
831 if (!PropertyValue.IsEmpty() || PropertyValue == wxT("home") ||
832 PropertyValue == wxT("work") ){
834 FullNamesListType.erase(*FNCount);
835 FullNamesListType.insert(std::make_pair(*FNCount, PropertyValue));
839 } else if (PropertyName == wxT("LANGUAGE")){
841 FullNamesListLanguage.erase(*FNCount);
842 FullNamesListLanguage.insert(std::make_pair(*FNCount, PropertyValue));
844 } else if (PropertyName == wxT("ALTID")){
846 FullNamesListAltID.erase(*FNCount);
847 FullNamesListAltID.insert(std::make_pair(*FNCount, PropertyValue));
849 } else if (PropertyName == wxT("PID")){
851 FullNamesListPID.erase(*FNCount);
852 FullNamesListPID.insert(std::make_pair(*FNCount, PropertyValue));
854 } else if (PropertyName == wxT("PREF")){
856 ProcessIntegerValue(&FullNamesListPref, &PropertyValue, FNCount);
858 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
860 if (FirstToken == TRUE){
862 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
867 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
875 FullNamesList.insert(std::make_pair(*FNCount, PropertySeg2));
877 if (!PropertyTokens.IsEmpty()){
879 FullNamesListTokens.insert(std::make_pair(*FNCount, PropertyTokens));
885 void ContactDataObject::ProcessN(wxString PropertySeg1, wxString PropertySeg2){
887 std::map<int, int> SplitPoints;
888 std::map<int, int> SplitLength;
890 int intPrevValue = 3;
894 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
898 wxString PropertyName;
899 wxString PropertyValue;
900 wxString PropertyData;
901 wxString PropertyTokens;
902 std::map<int,int>::iterator SLiter;
903 bool FirstToken = TRUE;
905 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
906 intiter != SplitPoints.end(); ++intiter){
908 SLiter = SplitLength.find(intiter->first);
910 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
912 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
913 PropertyName = PropertyElement.GetNextToken();
914 PropertyValue = PropertyElement.GetNextToken();
916 intPrevValue = intiter->second;
918 CaptureString(&PropertyValue, FALSE);
920 if (PropertyName == wxT("ALTID")){
922 NameAltID = PropertyValue;
924 } else if (PropertyName == wxT("LANGUAGE")){
926 NameLanguage = PropertyValue;
928 } else if (PropertyName == wxT("SORT-AS")){
930 if (PropertyValue.Left(1) == wxT("\"") && PropertyValue.Right(1) == wxT("\"") &&
931 PropertyValue.Len() >= 3){
932 NameDisplayAs = PropertyValue.Mid(1, (PropertyValue.Len() - 2));
935 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
937 if (FirstToken == TRUE){
939 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
944 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
952 // Split the name data.
954 int intSplitSeek = 0;
955 int intSplitsFound = 0;
956 int intSplitSize = 0;
957 int intPropertyLen = PropertySeg2.Len();
959 std::map<int,wxString> NameValues;
962 for (int i = 0; i <= intPropertyLen; i++){
964 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
966 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, intSplitSize)));
971 if (intSplitsFound == 4){
973 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, wxString::npos)));
987 // Split the data into several parts.
989 for (std::map<int, wxString>::iterator iter = NameValues.begin();
990 iter != NameValues.end(); ++iter){
992 if (iter->first == 1){
994 // Deal with family name.
996 NameSurname = iter->second;
998 } else if (iter->first == 2){
1000 // Deal with given names.
1002 NameForename = iter->second;
1004 } else if (iter->first == 3){
1006 // Deal with additional names.
1008 NameOtherNames = iter->second;
1010 } else if (iter->first == 4){
1012 // Deal with honorifix prefixes and suffixes.
1014 NameTitle = iter->second;
1018 if (iter == NameValues.end()){
1024 NameSuffix = iter->second;
1030 // Add the name token data.
1032 if (!PropertyTokens.IsEmpty()){
1034 NameTokens = PropertyTokens;
1040 void ContactDataObject::ProcessClientPIDMap(wxString PropertySeg1, wxString PropertySeg2, int *ClientPIDCount){
1042 size_t intPropertyLen = PropertySeg1.Len();
1043 std::map<int, int> SplitPoints;
1044 std::map<int, int> SplitLength;
1045 std::map<int, int>::iterator SLiter;
1046 wxString PropertyData;
1047 wxString PropertyName;
1048 wxString PropertyValue;
1049 wxString PropertyTokens;
1050 bool FirstToken = TRUE;
1051 int intSplitsFound = 0;
1052 int intSplitSize = 0;
1053 int intPrevValue = 14;
1057 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1061 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1062 intiter != SplitPoints.end(); ++intiter){
1064 SLiter = SplitLength.find(intiter->first);
1066 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1068 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1069 PropertyName = PropertyElement.GetNextToken();
1070 PropertyValue = PropertyElement.GetNextToken();
1072 intPrevValue = intiter->second;
1074 // Process properties.
1076 size_t intPropertyValueLen = PropertyValue.Len();
1078 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
1080 PropertyValue.Trim();
1081 PropertyValue.RemoveLast();
1085 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1087 PropertyValue.Remove(0, 1);
1091 CaptureString(&PropertyValue, FALSE);
1093 if (PropertyName.IsEmpty() || PropertyName.IsEmpty()){
1099 if (FirstToken == TRUE){
1101 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1106 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1112 CaptureString(&PropertySeg2, FALSE);
1114 ClientPIDList.insert(std::make_pair(*ClientPIDCount, PropertySeg2));
1116 if (!PropertyTokens.IsEmpty()){
1118 ClientPIDListTokens.insert(std::make_pair(*ClientPIDCount, PropertyTokens));
1124 void ContactDataObject::ProcessNickname(wxString PropertySeg1, wxString PropertySeg2, int *NicknameCount){
1126 std::map<int, int> SplitPoints;
1127 std::map<int, int> SplitLength;
1129 int intPrevValue = 10;
1132 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1136 PropertyType PropType = PROPERTY_NONE;
1138 // Look for type before continuing.
1140 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1144 std::map<int, wxString> *NicknamesList = NULL;
1145 std::map<int, wxString> *NicknamesListType = NULL;
1146 std::map<int, wxString> *NicknamesListLanguage = NULL;
1147 std::map<int, wxString> *NicknamesListAltID = NULL;
1148 std::map<int, wxString> *NicknamesListPID = NULL;
1149 std::map<int, wxString> *NicknamesListTokens = NULL;
1150 std::map<int, int> *NicknamesListPref = NULL;
1154 NicknamesList = &GeneralNicknamesList;
1155 NicknamesListType = &GeneralNicknamesListType;
1156 NicknamesListLanguage = &GeneralNicknamesListLanguage;
1157 NicknamesListAltID = &GeneralNicknamesListAltID;
1158 NicknamesListPID = &GeneralNicknamesListPID;
1159 NicknamesListTokens = &GeneralNicknamesListTokens;
1160 NicknamesListPref = &GeneralNicknamesListPref;
1163 NicknamesList = &HomeNicknamesList;
1164 NicknamesListType = &HomeNicknamesListType;
1165 NicknamesListLanguage = &HomeNicknamesListLanguage;
1166 NicknamesListAltID = &HomeNicknamesListAltID;
1167 NicknamesListPID = &HomeNicknamesListPID;
1168 NicknamesListTokens = &HomeNicknamesListTokens;
1169 NicknamesListPref = &HomeNicknamesListPref;
1172 NicknamesList = &BusinessNicknamesList;
1173 NicknamesListType = &BusinessNicknamesListType;
1174 NicknamesListLanguage = &BusinessNicknamesListLanguage;
1175 NicknamesListAltID = &BusinessNicknamesListAltID;
1176 NicknamesListPID = &BusinessNicknamesListPID;
1177 NicknamesListTokens = &BusinessNicknamesListTokens;
1178 NicknamesListPref = &BusinessNicknamesListPref;
1182 std::map<int, int>::iterator SLiter;
1183 wxString PropertyData;
1184 wxString PropertyName;
1185 wxString PropertyValue;
1186 wxString PropertyTokens;
1187 bool FirstToken = TRUE;
1189 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1190 intiter != SplitPoints.end(); ++intiter){
1192 SLiter = SplitLength.find(intiter->first);
1194 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1196 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1197 PropertyName = PropertyElement.GetNextToken();
1198 PropertyValue = PropertyElement.GetNextToken();
1200 intPrevValue = intiter->second;
1202 CaptureString(&PropertyValue, FALSE);
1204 if (PropertyName == wxT("ALTID")){
1206 NicknamesListAltID->erase(*NicknameCount);
1207 NicknamesListAltID->insert(std::make_pair(*NicknameCount, PropertyValue));
1209 } else if (PropertyName == wxT("PID")){
1211 NicknamesListPID->erase(*NicknameCount);
1212 NicknamesListPID->insert(std::make_pair(*NicknameCount, PropertyValue));
1214 } else if (PropertyName == wxT("PREF")){
1216 ProcessIntegerValue(NicknamesListPref, &PropertyValue, NicknameCount);
1218 } else if (PropertyName == wxT("LANGUAGE")){
1220 NicknamesListLanguage->erase(*NicknameCount);
1221 NicknamesListLanguage->insert(std::make_pair(*NicknameCount, PropertyValue));
1225 // Something else we don't know about so append
1226 // to the tokens variable.
1228 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1230 if (FirstToken == TRUE){
1232 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1237 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1247 NicknamesList->insert(std::make_pair(*NicknameCount, PropertySeg2));
1249 // Add the name token data.
1251 if (!PropertyTokens.IsEmpty()){
1253 NicknamesListTokens->insert(std::make_pair(*NicknameCount, PropertyTokens));
1259 void ContactDataObject::ProcessGender(wxString PropertySeg1, wxString PropertySeg2){
1261 std::map<int, int> SplitPoints;
1262 std::map<int, int> SplitLength;
1263 std::map<int, int>::iterator SLiter;
1264 wxString PropertyData;
1265 wxString PropertyName;
1266 wxString PropertyValue;
1267 wxString PropertyTokens;
1268 bool FirstToken = TRUE;
1269 int intPrevValue = 8;
1271 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1275 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1276 intiter != SplitPoints.end(); ++intiter){
1278 SLiter = SplitLength.find(intiter->first);
1280 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1282 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1283 PropertyName = PropertyElement.GetNextToken();
1284 PropertyValue = PropertyElement.GetNextToken();
1286 intPrevValue = intiter->second;
1288 // Process properties.
1290 size_t intPropertyValueLen = PropertyValue.Len();
1292 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
1294 PropertyValue.Trim();
1295 PropertyValue.RemoveLast();
1299 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1301 PropertyValue.Remove(0, 1);
1305 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1307 if (FirstToken == TRUE){
1309 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1314 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1322 wxStringTokenizer GenderData (PropertySeg2, wxT(";"));
1324 wxString GenderComponent;
1326 if (GenderData.CountTokens() >= 2){
1328 Gender = GenderData.GetNextToken();
1329 GenderDetails = GenderData.GetString();
1331 CaptureString(&GenderDetails, FALSE);
1335 Gender = GenderData.GetNextToken();
1339 if (!PropertyTokens.IsEmpty()){
1341 GenderTokens = PropertyTokens;
1347 void ContactDataObject::ProcessBirthday(wxString PropertySeg1, wxString PropertySeg2){
1349 // Process date. Preserve the remainder in the string.
1351 std::map<int, int> SplitPoints;
1352 std::map<int, int> SplitLength;
1353 std::map<int, int>::iterator SLiter;
1354 wxString PropertyData;
1355 wxString PropertyName;
1356 wxString PropertyValue;
1357 wxString PropertyTokens;
1358 bool BirthdayText = FALSE;
1359 int intPrevValue = 6;
1361 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1365 // Look for type before continuing.
1367 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1368 intiter != SplitPoints.end(); ++intiter){
1370 SLiter = SplitLength.find(intiter->first);
1372 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1374 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1375 PropertyName = PropertyElement.GetNextToken();
1376 PropertyValue = PropertyElement.GetNextToken();
1378 intPrevValue = intiter->second;
1380 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && BirthdayText == FALSE){
1382 CaptureString(&PropertySeg2, FALSE);
1383 Birthday = PropertySeg2;
1384 BirthdayText = TRUE;
1390 // Setup blank lines for later on.
1393 bool FirstToken = TRUE;
1395 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1396 intiter != SplitPoints.end(); ++intiter){
1398 SLiter = SplitLength.find(intiter->first);
1400 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1402 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1403 PropertyName = PropertyElement.GetNextToken();
1404 PropertyValue = PropertyElement.GetNextToken();
1406 intPrevValue = intiter->second;
1408 // Process properties.
1410 CaptureString(&PropertyValue, FALSE);
1412 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1414 PropertyValue.Trim();
1415 PropertyValue.RemoveLast();
1419 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1421 PropertyValue.Remove(0, 1);
1425 if (PropertyName == wxT("ALTID")){
1427 BirthdayAltID = PropertyValue;
1429 } else if (PropertyName == wxT("CALSCALE")){
1431 BirthdayCalScale = PropertyValue;
1433 } else if (PropertyName != wxT("VALUE")) {
1435 // Something else we don't know about so append
1436 // to the tokens variable.
1438 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1440 if (FirstToken == TRUE){
1442 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1447 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1457 // Add the data to the variables and form.
1459 if (BirthdayText == FALSE){
1461 Birthday = PropertySeg2;
1465 if (!PropertyTokens.IsEmpty()){
1467 BirthdayTokens = PropertyTokens;
1473 void ContactDataObject::ProcessAnniversary(wxString PropertySeg1, wxString PropertySeg2){
1475 // Process date. Preserve the remainder in the string.
1477 std::map<int, int> SplitPoints;
1478 std::map<int, int> SplitLength;
1479 std::map<int, int>::iterator SLiter;
1480 wxString PropertyData;
1481 wxString PropertyName;
1482 wxString PropertyValue;
1483 wxString PropertyTokens;
1484 bool AnniversaryText = FALSE;
1485 int intPrevValue = 13;
1487 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1491 // Look for type before continuing.
1493 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1494 intiter != SplitPoints.end(); ++intiter){
1496 SLiter = SplitLength.find(intiter->first);
1498 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1500 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1501 PropertyName = PropertyElement.GetNextToken();
1502 PropertyValue = PropertyElement.GetNextToken();
1504 intPrevValue = intiter->second;
1506 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && AnniversaryText == FALSE){
1508 CaptureString(&PropertySeg2, FALSE);
1509 Anniversary = PropertySeg2;
1510 AnniversaryText = TRUE;
1516 // Setup blank lines for later on.
1519 bool FirstToken = TRUE;
1521 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1522 intiter != SplitPoints.end(); ++intiter){
1524 SLiter = SplitLength.find(intiter->first);
1526 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1528 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1529 PropertyName = PropertyElement.GetNextToken();
1530 PropertyValue = PropertyElement.GetNextToken();
1532 intPrevValue = intiter->second;
1534 // Process properties.
1536 CaptureString(&PropertyValue, FALSE);
1538 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1540 PropertyValue.Trim();
1541 PropertyValue.RemoveLast();
1545 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1547 PropertyValue.Remove(0, 1);
1551 if (PropertyName == wxT("ALTID")){
1553 AnniversaryAltID = PropertyValue;
1555 } else if (PropertyName == wxT("CALSCALE")){
1557 AnniversaryCalScale = PropertyValue;
1559 } else if (PropertyName != wxT("VALUE")) {
1561 // Something else we don't know about so append
1562 // to the tokens variable.
1564 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1566 if (FirstToken == TRUE){
1568 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1573 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1583 // Add the data to the variables and form.
1585 if (AnniversaryText == FALSE){
1587 Anniversary = PropertySeg2;
1591 if (!PropertyTokens.IsEmpty()){
1593 AnniversaryTokens = PropertyTokens;
1599 void ContactDataObject::ProcessTimeZone(wxString PropertySeg1, wxString PropertySeg2, int *TimeZoneCount){
1601 std::map<int, int> SplitPoints;
1602 std::map<int, int> SplitLength;
1604 int intPrevValue = 4;
1607 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1611 PropertyType PropType = PROPERTY_NONE;
1613 // Look for type before continuing.
1615 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1619 std::map<int, wxString> *TZList = NULL;
1620 std::map<int, wxString> *TZListType = NULL;
1621 std::map<int, wxString> *TZListMediatype = NULL;
1622 std::map<int, wxString> *TZListAltID = NULL;
1623 std::map<int, wxString> *TZListPID = NULL;
1624 std::map<int, wxString> *TZListTokens = NULL;
1625 std::map<int, int> *TZListPref = NULL;
1629 TZList = &GeneralTZList;
1630 TZListType = &GeneralTZListType;
1631 TZListMediatype = &GeneralTZListMediatype;
1632 TZListAltID = &GeneralTZListAltID;
1633 TZListPID = &GeneralTZListPID;
1634 TZListTokens = &GeneralTZListTokens;
1635 TZListPref = &GeneralTZListPref;
1638 TZList = &HomeTZList;
1639 TZListType = &HomeTZListType;
1640 TZListMediatype = &HomeTZListMediatype;
1641 TZListAltID = &HomeTZListAltID;
1642 TZListPID = &HomeTZListPID;
1643 TZListTokens = &HomeTZListTokens;
1644 TZListPref = &HomeTZListPref;
1647 TZList = &BusinessTZList;
1648 TZListType = &BusinessTZListType;
1649 TZListMediatype = &BusinessTZListMediatype;
1650 TZListAltID = &BusinessTZListAltID;
1651 TZListPID = &BusinessTZListPID;
1652 TZListTokens = &BusinessTZListTokens;
1653 TZListPref = &BusinessTZListPref;
1657 std::map<int, int>::iterator SLiter;
1658 wxString PropertyData;
1659 wxString PropertyName;
1660 wxString PropertyValue;
1661 wxString PropertyTokens;
1662 bool FirstToken = TRUE;
1664 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1665 intiter != SplitPoints.end(); ++intiter){
1667 SLiter = SplitLength.find(intiter->first);
1669 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1671 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1672 PropertyName = PropertyElement.GetNextToken();
1673 PropertyValue = PropertyElement.GetNextToken();
1675 intPrevValue = intiter->second;
1677 CaptureString(&PropertyValue, FALSE);
1679 if (PropertyName == wxT("ALTID")){
1681 TZListAltID->erase(*TimeZoneCount);
1682 TZListAltID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1684 } else if (PropertyName == wxT("PID")){
1686 TZListPID->erase(*TimeZoneCount);
1687 TZListPID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1689 } else if (PropertyName == wxT("PREF")){
1691 ProcessIntegerValue(TZListPref, &PropertyValue, TimeZoneCount);
1693 } else if (PropertyName == wxT("MEDIATYPE")){
1695 TZListMediatype->erase(*TimeZoneCount);
1696 TZListMediatype->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1700 // Something else we don't know about so append
1701 // to the tokens variable.
1703 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1705 if (FirstToken == TRUE){
1707 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1712 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1722 TZList->insert(std::make_pair(*TimeZoneCount, PropertySeg2));
1724 // Add the name token data.
1726 if (!PropertyTokens.IsEmpty()){
1728 TZListTokens->insert(std::make_pair(*TimeZoneCount, PropertyTokens));
1735 void ContactDataObject::ProcessAddress(wxString PropertySeg1, wxString PropertySeg2, int *AddressCount){
1737 size_t intPropertyLen = PropertySeg1.Len();
1738 std::map<int, int> SplitPoints;
1739 std::map<int, int> SplitLength;
1740 std::map<int, int>::iterator SLiter;
1741 wxString PropertyData;
1742 wxString PropertyName;
1743 wxString PropertyValue;
1744 wxString PropertyTokens;
1745 wxString AddressLabel;
1746 wxString AddressLang;
1747 wxString AddressAltID;
1748 wxString AddressPID;
1749 wxString AddressTokens;
1750 wxString AddressGeo;
1751 wxString AddressTimezone;
1752 wxString AddressType;
1753 wxString AddressMediatype;
1754 wxString AddressPOBox;
1755 wxString AddressExtended;
1756 wxString AddressStreet;
1757 wxString AddressLocality;
1758 wxString AddressCity;
1759 wxString AddressRegion;
1760 wxString AddressPostalCode;
1761 wxString AddressCountry;
1762 bool FirstToken = TRUE;
1763 int intSplitsFound = 0;
1764 int intSplitSize = 0;
1765 int intPrevValue = 5;
1770 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1774 PropertyType PropType = PROPERTY_NONE;
1776 // Look for type before continuing.
1778 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1782 std::map<int, wxString> *AddressList = NULL;
1783 std::map<int, wxString> *AddressListTown = NULL;
1784 std::map<int, wxString> *AddressListCounty = NULL;
1785 std::map<int, wxString> *AddressListPostCode = NULL;
1786 std::map<int, wxString> *AddressListCountry = NULL;
1787 std::map<int, wxString> *AddressListLabel = NULL;
1788 std::map<int, wxString> *AddressListLang = NULL;
1789 std::map<int, wxString> *AddressListAltID = NULL;
1790 std::map<int, wxString> *AddressListPID = NULL;
1791 std::map<int, wxString> *AddressListTokens = NULL;
1792 std::map<int, wxString> *AddressListGeo = NULL;
1793 std::map<int, wxString> *AddressListTimezone = NULL;
1794 std::map<int, wxString> *AddressListType = NULL;
1795 std::map<int, wxString> *AddressListMediatype = NULL;
1796 std::map<int, int> *AddressListPref = NULL;
1800 AddressList = &GeneralAddressList;
1801 AddressListTown = &GeneralAddressListTown;
1802 AddressListCounty = &GeneralAddressListCounty;
1803 AddressListPostCode = &GeneralAddressListPostCode;
1804 AddressListCountry = &GeneralAddressListCountry;
1805 AddressListLabel = &GeneralAddressListLabel;
1806 AddressListLang = &GeneralAddressListLang;
1807 AddressListAltID = &GeneralAddressListAltID;
1808 AddressListPID = &GeneralAddressListPID;
1809 AddressListTokens = &GeneralAddressListTokens;
1810 AddressListGeo = &GeneralAddressListGeo;
1811 AddressListTimezone = &GeneralAddressListTimezone;
1812 AddressListType = &GeneralAddressListType;
1813 AddressListMediatype = &GeneralAddressListMediatype;
1814 AddressListPref = &GeneralAddressListPref;
1817 AddressList = &HomeAddressList;
1818 AddressListTown = &HomeAddressListTown;
1819 AddressListCounty = &HomeAddressListCounty;
1820 AddressListPostCode = &HomeAddressListPostCode;
1821 AddressListCountry = &HomeAddressListCountry;
1822 AddressListLabel = &HomeAddressListLabel;
1823 AddressListLang = &HomeAddressListLang;
1824 AddressListAltID = &HomeAddressListAltID;
1825 AddressListPID = &HomeAddressListPID;
1826 AddressListTokens = &HomeAddressListTokens;
1827 AddressListGeo = &HomeAddressListGeo;
1828 AddressListTimezone = &HomeAddressListTimezone;
1829 AddressListType = &HomeAddressListType;
1830 AddressListMediatype = &HomeAddressListMediatype;
1831 AddressListPref = &HomeAddressListPref;
1834 AddressList = &BusinessAddressList;
1835 AddressListTown = &BusinessAddressListTown;
1836 AddressListCounty = &BusinessAddressListCounty;
1837 AddressListPostCode = &BusinessAddressListPostCode;
1838 AddressListCountry = &BusinessAddressListCountry;
1839 AddressListLabel = &BusinessAddressListLabel;
1840 AddressListLang = &BusinessAddressListLang;
1841 AddressListAltID = &BusinessAddressListAltID;
1842 AddressListPID = &BusinessAddressListPID;
1843 AddressListTokens = &BusinessAddressListTokens;
1844 AddressListGeo = &BusinessAddressListGeo;
1845 AddressListTimezone = &BusinessAddressListTimezone;
1846 AddressListType = &BusinessAddressListType;
1847 AddressListMediatype = &BusinessAddressListMediatype;
1848 AddressListPref = &BusinessAddressListPref;
1854 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1855 intiter != SplitPoints.end(); ++intiter){
1857 SLiter = SplitLength.find(intiter->first);
1859 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1861 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1862 PropertyName = PropertyElement.GetNextToken();
1863 PropertyValue = PropertyElement.GetNextToken();
1865 intPrevValue = intiter->second;
1867 CaptureString(&PropertyValue, FALSE);
1869 // Process properties.
1871 if (PropertyName == wxT("LABEL")){
1873 AddressListLabel->erase(*AddressCount);
1874 AddressListLabel->insert(std::make_pair(*AddressCount, PropertyValue));
1876 } else if (PropertyName == wxT("LANGUAGE")){
1878 AddressListLang->erase(*AddressCount);
1879 AddressListLang->insert(std::make_pair(*AddressCount, PropertyValue));
1881 } else if (PropertyName == wxT("ALTID")){
1883 AddressListAltID->erase(*AddressCount);
1884 AddressListAltID->insert(std::make_pair(*AddressCount, PropertyValue));
1886 } else if (PropertyName == wxT("PID")){
1888 AddressListPID->erase(*AddressCount);
1889 AddressListPID->insert(std::make_pair(*AddressCount, PropertyValue));
1891 } else if (PropertyName == wxT("GEO")){
1893 AddressListGeo->erase(*AddressCount);
1894 AddressListGeo->insert(std::make_pair(*AddressCount, PropertyValue));
1896 } else if (PropertyName == wxT("TZ")){
1898 AddressListTimezone->erase(*AddressCount);
1899 AddressListTimezone->insert(std::make_pair(*AddressCount, PropertyValue));
1901 } else if (PropertyName == wxT("MEDIATYPE")){
1903 AddressListMediatype->erase(*AddressCount);
1904 AddressListMediatype->insert(std::make_pair(*AddressCount, PropertyValue));
1906 } else if (PropertyName == wxT("PREF")){
1908 ProcessIntegerValue(AddressListPref, &PropertyValue, AddressCount);
1912 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1914 if (FirstToken == TRUE){
1916 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1921 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1931 // Split the address.
1933 //std::map<int, int>::iterator SLiter;
1934 intPropertyLen = PropertySeg2.Len();
1935 SplitPoints.clear();
1936 SplitLength.clear();
1941 for (int i = 0; i <= intPropertyLen; i++){
1945 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
1948 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
1950 if (intSplitsFound == 6){
1952 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1957 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1967 // Split the data into several parts.
1969 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1970 intiter != SplitPoints.end(); ++intiter){
1972 if (intiter->first == 1){
1974 // Deal with PO Box.
1976 SLiter = SplitLength.find(1);
1978 //txtSurname->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(0, SLiter->second), TRUE));
1979 AddressPOBox = PropertySeg2.Mid(0, SLiter->second);
1980 intPrevValue = intiter->second;
1982 } else if (intiter->first == 2){
1984 // Deal with extended address.
1986 SLiter = SplitLength.find(2);
1988 AddressExtended = PropertySeg2.Mid(intPrevValue, SLiter->second);
1989 //txtForename->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1990 intPrevValue = intiter->second;
1992 } else if (intiter->first == 3){
1994 // Deal with street address.
1996 SLiter = SplitLength.find(3);
1998 AddressStreet = PropertySeg2.Mid(intPrevValue, SLiter->second);
1999 //txtOtherNames->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2000 intPrevValue = intiter->second;
2002 } else if (intiter->first == 4){
2004 // Deal with locality
2006 SLiter = SplitLength.find(4);
2008 AddressLocality = PropertySeg2.Mid(intPrevValue, SLiter->second);
2009 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2010 intPrevValue = intiter->second;
2012 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
2014 } else if (intiter->first == 5){
2016 // Deal with region.
2018 SLiter = SplitLength.find(5);
2020 AddressRegion = PropertySeg2.Mid(intPrevValue, SLiter->second);
2021 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2022 intPrevValue = intiter->second;
2024 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
2026 } else if (intiter->first == 6){
2028 // Deal with post code.
2030 SLiter = SplitLength.find(6);
2032 AddressPostalCode = PropertySeg2.Mid(intPrevValue, SLiter->second);
2033 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2034 intPrevValue = intiter->second;
2036 // Deal with country.
2038 AddressCountry = PropertySeg2.Mid(intPrevValue, wxString::npos);
2039 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
2047 // Add the data to the General/Home/Work address variables.
2049 CaptureString(&AddressStreet, FALSE);
2050 CaptureString(&AddressLocality, FALSE);
2051 CaptureString(&AddressRegion, FALSE);
2052 CaptureString(&AddressPostalCode, FALSE);
2053 CaptureString(&AddressCountry, FALSE);
2055 if (!PropertyTokens.IsEmpty()){
2057 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
2061 AddressListCountry->insert(std::make_pair(*AddressCount, AddressCountry));
2062 AddressList->insert(std::make_pair(*AddressCount, AddressStreet));
2063 AddressListTown->insert(std::make_pair(*AddressCount, AddressLocality));
2064 AddressListCounty->insert(std::make_pair(*AddressCount, AddressRegion));
2065 AddressListPostCode->insert(std::make_pair(*AddressCount, AddressPostalCode));
2069 AddressListType->insert(std::make_pair(*AddressCount, wxT("")));
2072 AddressListType->insert(std::make_pair(*AddressCount, wxT("home")));
2075 AddressListType->insert(std::make_pair(*AddressCount, wxT("work")));
2079 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
2083 void ContactDataObject::ProcessEmail(wxString PropertySeg1, wxString PropertySeg2, int *EmailCount){
2085 std::map<int, int> SplitPoints;
2086 std::map<int, int> SplitLength;
2088 int intPrevValue = 7;
2091 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2095 PropertyType PropType = PROPERTY_NONE;
2097 // Look for type before continuing.
2099 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2101 std::map<int, wxString> *EmailList = NULL;
2102 std::map<int, wxString> *EmailListType = NULL;
2103 std::map<int, wxString> *EmailListAltID = NULL;
2104 std::map<int, wxString> *EmailListPID = NULL;
2105 std::map<int, wxString> *EmailListTokens = NULL;
2106 std::map<int, int> *EmailListPref = NULL;
2110 EmailList = &GeneralEmailList;
2111 EmailListType = &GeneralEmailListType;
2112 EmailListAltID = &GeneralEmailListAltID;
2113 EmailListPID = &GeneralEmailListPID;
2114 EmailListTokens = &GeneralEmailListTokens;
2115 EmailListPref = &GeneralEmailListPref;
2118 EmailList = &HomeEmailList;
2119 EmailListType = &HomeEmailListType;
2120 EmailListAltID = &HomeEmailListAltID;
2121 EmailListPID = &HomeEmailListPID;
2122 EmailListTokens = &HomeEmailListTokens;
2123 EmailListPref = &HomeEmailListPref;
2126 EmailList = &BusinessEmailList;
2127 EmailListType = &BusinessEmailListType;
2128 EmailListAltID = &BusinessEmailListAltID;
2129 EmailListPID = &BusinessEmailListPID;
2130 EmailListTokens = &BusinessEmailListTokens;
2131 EmailListPref = &BusinessEmailListPref;
2137 std::map<int,int>::iterator SLiter;
2138 wxString PropertyData;
2139 wxString PropertyName;
2140 wxString PropertyValue;
2141 wxString PropertyTokens;
2142 bool FirstToken = TRUE;
2144 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2145 intiter != SplitPoints.end(); ++intiter){
2147 SLiter = SplitLength.find(intiter->first);
2149 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2151 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2152 PropertyName = PropertyElement.GetNextToken();
2153 PropertyValue = PropertyElement.GetNextToken();
2155 intPrevValue = intiter->second;
2157 CaptureString(&PropertyValue, FALSE);
2159 // Process properties.
2161 if (PropertyName == wxT("ALTID")){
2163 EmailListAltID->erase(*EmailCount);
2164 EmailListAltID->insert(std::make_pair(*EmailCount, PropertyValue));
2166 } else if (PropertyName == wxT("PID")){
2168 EmailListPID->erase(*EmailCount);
2169 EmailListPID->insert(std::make_pair(*EmailCount, PropertyValue));
2171 } else if (PropertyName == wxT("PREF")){
2173 ProcessIntegerValue(EmailListPref, &PropertyValue, EmailCount);
2177 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2179 if (FirstToken == TRUE){
2181 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2186 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2196 EmailList->insert(std::make_pair(*EmailCount, PropertySeg2));
2198 // Add the name token data.
2200 if (!PropertyTokens.IsEmpty()){
2202 EmailListTokens->insert(std::make_pair(*EmailCount, PropertyTokens));
2209 void ContactDataObject::ProcessIM(wxString PropertySeg1, wxString PropertySeg2, int *IMCount){
2211 std::map<int, int> SplitPoints;
2212 std::map<int, int> SplitLength;
2214 int intPrevValue = 6;
2217 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2221 PropertyType PropType = PROPERTY_NONE;
2223 // Look for type before continuing.
2225 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2227 std::map<int, wxString> *IMList = NULL;
2228 std::map<int, wxString> *IMListType = NULL;
2229 std::map<int, wxString> *IMListAltID = NULL;
2230 std::map<int, wxString> *IMListPID = NULL;
2231 std::map<int, wxString> *IMListTokens = NULL;
2232 std::map<int, wxString> *IMListMediatype = NULL;
2233 std::map<int, int> *IMListPref = NULL;
2237 IMList = &GeneralIMList;
2238 IMListType = &GeneralIMListType;
2239 IMListAltID = &GeneralIMListAltID;
2240 IMListPID = &GeneralIMListPID;
2241 IMListTokens = &GeneralIMListTokens;
2242 IMListMediatype = &GeneralIMListMediatype;
2243 IMListPref = &GeneralIMListPref;
2246 IMList = &HomeIMList;
2247 IMListType = &HomeIMListType;
2248 IMListAltID = &HomeIMListAltID;
2249 IMListPID = &HomeIMListPID;
2250 IMListTokens = &HomeIMListTokens;
2251 IMListMediatype = &HomeIMListMediatype;
2252 IMListPref = &HomeIMListPref;
2255 IMList = &BusinessIMList;
2256 IMListType = &BusinessIMListType;
2257 IMListAltID = &BusinessIMListAltID;
2258 IMListPID = &BusinessIMListPID;
2259 IMListTokens = &BusinessIMListTokens;
2260 IMListMediatype = &BusinessIMListMediatype;
2261 IMListPref = &BusinessIMListPref;
2267 std::map<int,int>::iterator SLiter;
2268 wxString PropertyData;
2269 wxString PropertyName;
2270 wxString PropertyValue;
2271 wxString PropertyTokens;
2272 bool FirstToken = TRUE;
2274 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2275 intiter != SplitPoints.end(); ++intiter){
2277 SLiter = SplitLength.find(intiter->first);
2279 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2281 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2282 PropertyName = PropertyElement.GetNextToken();
2283 PropertyValue = PropertyElement.GetNextToken();
2285 intPrevValue = intiter->second;
2287 CaptureString(&PropertyValue, FALSE);
2289 // Process properties.
2291 if (PropertyName == wxT("ALTID")){
2293 IMListAltID->erase(*IMCount);
2294 IMListAltID->insert(std::make_pair(*IMCount, PropertyValue));
2296 } else if (PropertyName == wxT("PID")){
2298 IMListPID->erase(*IMCount);
2299 IMListPID->insert(std::make_pair(*IMCount, PropertyValue));
2301 } else if (PropertyName == wxT("MEDIATYPE")){
2303 IMListMediatype->erase(*IMCount);
2304 IMListMediatype->insert(std::make_pair(*IMCount, PropertyValue));
2306 } else if (PropertyName == wxT("PREF")){
2308 ProcessIntegerValue(IMListPref, &PropertyValue, IMCount);
2312 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2314 if (FirstToken == TRUE){
2316 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2321 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2331 IMList->insert(std::make_pair(*IMCount, PropertySeg2));
2333 // Add the name token data.
2335 if (!PropertyTokens.IsEmpty()){
2337 IMListTokens->insert(std::make_pair(*IMCount, PropertyTokens));
2343 void ContactDataObject::ProcessTelephone(wxString PropertySeg1, wxString PropertySeg2, int *TelephoneCount){
2345 std::map<int, int> SplitPoints;
2346 std::map<int, int> SplitLength;
2347 std::map<int, int>::iterator SLiter;
2351 PropertyType PropType = PROPERTY_NONE;
2353 // Look for type before continuing.
2356 wxString TelTypeDetail;
2357 wxString PropertyData;
2358 wxString PropertyName;
2359 wxString PropertyValue;
2360 wxString PropertyTokens;
2362 std::map<int,int> TypeSplitPoints;
2363 std::map<int,int> TypeSplitLength;
2364 std::map<int,int>::iterator TSLiter;
2366 int intSplitSize = 0;
2367 int intSplitsFound = 0;
2368 int intSplitPoint = 0;
2370 int intPrevValue = 5;
2372 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2376 // Look for type before continuing.
2378 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2379 intiter != SplitPoints.end(); ++intiter){
2381 SLiter = SplitLength.find(intiter->first);
2383 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2385 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2386 PropertyName = PropertyElement.GetNextToken();
2387 PropertyValue = PropertyElement.GetNextToken();
2389 intPrevValue = intiter->second;
2391 if (PropertyName == wxT("TYPE")){
2393 // Process each value in type and translate each
2396 // Strip out the quotes if they are there.
2398 size_t intPropertyValueLen = PropertyValue.Len();
2400 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2402 PropertyValue.Trim();
2403 PropertyValue.RemoveLast();
2407 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2409 PropertyValue.Remove(0, 1);
2413 TelTypeDetail = PropertyValue;
2419 for (int i = 0; i <= intPropertyValueLen; i++){
2423 if (PropertyValue.Mid(i, 1) == wxT(",") && PropertyValue.Mid((i - 1), 1) != wxT("\\")){
2425 if (intSplitsFound == 0){
2427 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2428 TypeSplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2432 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2433 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2446 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2447 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2449 int intTypeSeek = 0;
2451 for (std::map<int, int>::iterator typeiter = TypeSplitPoints.begin();
2452 typeiter != TypeSplitPoints.end(); ++typeiter){
2454 wxString TypePropertyName;
2456 TSLiter = TypeSplitLength.find(typeiter->first);
2458 TypePropertyName = PropertyValue.Mid(typeiter->second, TSLiter->second);
2460 if (intTypeSeek == 0){
2465 TelTypeUI.Append(wxT(","));
2469 if (TypePropertyName == wxT("home")){
2471 PropType = PROPERTY_HOME;
2473 } else if (TypePropertyName == wxT("work")){
2475 PropType = PROPERTY_WORK;
2480 if (TypePropertyName == wxT("text")){
2482 TelTypeUI.Append(_("text"));
2485 } else if (TypePropertyName == wxT("voice")){
2487 TelTypeUI.Append(_("voice"));
2490 } else if (TypePropertyName == wxT("fax")){
2492 TelTypeUI.Append(_("fax"));
2495 } else if (TypePropertyName == wxT("cell")){
2497 TelTypeUI.Append(_("mobile"));
2500 } else if (TypePropertyName == wxT("video")){
2502 TelTypeUI.Append(_("video"));
2505 } else if (TypePropertyName == wxT("pager")){
2507 TelTypeUI.Append(_("pager"));
2510 } else if (TypePropertyName == wxT("textphone")){
2512 TelTypeUI.Append(_("textphone"));
2523 std::map<int, wxString> *TelephoneList = NULL;
2524 std::map<int, wxString> *TelephoneListType = NULL;
2525 std::map<int, wxString> *TelephoneListAltID = NULL;
2526 std::map<int, wxString> *TelephoneListPID = NULL;
2527 std::map<int, wxString> *TelephoneListTokens = NULL;
2528 std::map<int, wxString> *TelephoneListTypeInfo = NULL;
2529 std::map<int, int> *TelephoneListPref = NULL;
2533 TelephoneList = &GeneralTelephoneList;
2534 TelephoneListType = &GeneralTelephoneListType;
2535 TelephoneListAltID = &GeneralTelephoneListAltID;
2536 TelephoneListPID = &GeneralTelephoneListPID;
2537 TelephoneListTokens = &GeneralTelephoneListTokens;
2538 TelephoneListTypeInfo = &GeneralTelephoneListTypeInfo;
2539 TelephoneListPref = &GeneralTelephoneListPref;
2542 TelephoneList = &HomeTelephoneList;
2543 TelephoneListType = &HomeTelephoneListType;
2544 TelephoneListAltID = &HomeTelephoneListAltID;
2545 TelephoneListPID = &HomeTelephoneListPID;
2546 TelephoneListTokens = &HomeTelephoneListTokens;
2547 TelephoneListTypeInfo = &HomeTelephoneListTypeInfo;
2548 TelephoneListPref = &HomeTelephoneListPref;
2551 TelephoneList = &BusinessTelephoneList;
2552 TelephoneListType = &BusinessTelephoneListType;
2553 TelephoneListAltID = &BusinessTelephoneListAltID;
2554 TelephoneListPID = &BusinessTelephoneListPID;
2555 TelephoneListTokens = &BusinessTelephoneListTokens;
2556 TelephoneListTypeInfo = &BusinessTelephoneListTypeInfo;
2557 TelephoneListPref = &BusinessTelephoneListPref;
2561 // Process the properties.
2563 bool FirstToken = TRUE;
2566 SplitPoints.clear();
2567 SplitLength.clear();
2569 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2573 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2574 intiter != SplitPoints.end(); ++intiter){
2576 SLiter = SplitLength.find(intiter->first);
2578 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2580 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2581 PropertyName = PropertyElement.GetNextToken();
2582 PropertyValue = PropertyElement.GetNextToken();
2584 intPrevValue = intiter->second;
2586 CaptureString(&PropertyValue, FALSE);
2588 // Process properties.
2590 if (PropertyName == wxT("ALTID")){
2592 TelephoneListAltID->erase(*TelephoneCount);
2593 TelephoneListAltID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2595 } else if (PropertyName == wxT("PID")){
2597 TelephoneListPID->erase(*TelephoneCount);
2598 TelephoneListPID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2600 } else if (PropertyName == wxT("PREF")){
2602 ProcessIntegerValue(TelephoneListPref, &PropertyValue, TelephoneCount);
2606 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2608 if (FirstToken == TRUE){
2610 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2615 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2625 TelephoneList->insert(std::make_pair(*TelephoneCount, PropertySeg2));
2626 TelephoneListTypeInfo->insert(std::make_pair(*TelephoneCount, TelTypeUI));
2628 // Add the name token data.
2630 if (!PropertyTokens.IsEmpty()){
2632 TelephoneListTokens->insert(std::make_pair(*TelephoneCount, PropertyTokens));
2638 void ContactDataObject::ProcessLanguage(wxString PropertySeg1, wxString PropertySeg2, int *LanguageCount){
2640 std::map<int, int> SplitPoints;
2641 std::map<int, int> SplitLength;
2643 int intPrevValue = 6;
2646 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2650 PropertyType PropType = PROPERTY_NONE;
2652 // Look for type before continuing.
2654 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2656 std::map<int, wxString> *LanguageList = NULL;
2657 std::map<int, wxString> *LanguageListType = NULL;
2658 std::map<int, wxString> *LanguageListAltID = NULL;
2659 std::map<int, wxString> *LanguageListPID = NULL;
2660 std::map<int, wxString> *LanguageListTokens = NULL;
2661 std::map<int, int> *LanguageListPref = NULL;
2665 LanguageList = &GeneralLanguageList;
2666 LanguageListType = &GeneralLanguageListType;
2667 LanguageListAltID = &GeneralLanguageListAltID;
2668 LanguageListPID = &GeneralLanguageListPID;
2669 LanguageListTokens = &GeneralLanguageListTokens;
2670 LanguageListPref = &GeneralLanguageListPref;
2673 LanguageList = &HomeLanguageList;
2674 LanguageListType = &HomeLanguageListType;
2675 LanguageListAltID = &HomeLanguageListAltID;
2676 LanguageListPID = &HomeLanguageListPID;
2677 LanguageListTokens = &HomeLanguageListTokens;
2678 LanguageListPref = &HomeLanguageListPref;
2681 LanguageList = &BusinessLanguageList;
2682 LanguageListType = &BusinessLanguageListType;
2683 LanguageListAltID = &BusinessLanguageListAltID;
2684 LanguageListPID = &BusinessLanguageListPID;
2685 LanguageListTokens = &BusinessLanguageListTokens;
2686 LanguageListPref = &BusinessLanguageListPref;
2692 std::map<int,int>::iterator SLiter;
2693 wxString PropertyData;
2694 wxString PropertyName;
2695 wxString PropertyValue;
2696 wxString PropertyTokens;
2697 bool FirstToken = TRUE;
2699 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2700 intiter != SplitPoints.end(); ++intiter){
2702 SLiter = SplitLength.find(intiter->first);
2704 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2706 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2707 PropertyName = PropertyElement.GetNextToken();
2708 PropertyValue = PropertyElement.GetNextToken();
2710 intPrevValue = intiter->second;
2712 CaptureString(&PropertyValue, FALSE);
2714 // Process properties.
2716 if (PropertyName == wxT("ALTID")){
2718 LanguageListAltID->erase(*LanguageCount);
2719 LanguageListAltID->insert(std::make_pair(*LanguageCount, PropertyValue));
2721 } else if (PropertyName == wxT("PID")){
2723 LanguageListPID->erase(*LanguageCount);
2724 LanguageListPID->insert(std::make_pair(*LanguageCount, PropertyValue));
2726 } else if (PropertyName == wxT("PREF")){
2728 ProcessIntegerValue(LanguageListPref, &PropertyValue, LanguageCount);
2732 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2734 if (FirstToken == TRUE){
2736 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2741 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2751 LanguageList->insert(std::make_pair(*LanguageCount, PropertySeg2));
2753 // Add the name token data.
2755 if (!PropertyTokens.IsEmpty()){
2757 LanguageListTokens->insert(std::make_pair(*LanguageCount, PropertyTokens));
2763 void ContactDataObject::ProcessGeographic(wxString PropertySeg1, wxString PropertySeg2, int *GeographicCount){
2765 std::map<int, int> SplitPoints;
2766 std::map<int, int> SplitLength;
2768 int intPrevValue = 5;
2771 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2775 PropertyType PropType = PROPERTY_NONE;
2777 // Look for type before continuing.
2779 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2781 std::map<int, wxString> *GeopositionList = NULL;
2782 std::map<int, wxString> *GeopositionListType = NULL;
2783 std::map<int, wxString> *GeopositionListAltID = NULL;
2784 std::map<int, wxString> *GeopositionListPID = NULL;
2785 std::map<int, wxString> *GeopositionListTokens = NULL;
2786 std::map<int, wxString> *GeopositionListMediatype = NULL;
2787 std::map<int, int> *GeopositionListPref = NULL;
2791 GeopositionList = &GeneralGeographyList;
2792 GeopositionListType = &GeneralGeographyListType;
2793 GeopositionListAltID = &GeneralGeographyListAltID;
2794 GeopositionListPID = &GeneralGeographyListPID;
2795 GeopositionListTokens = &GeneralGeographyListTokens;
2796 GeopositionListMediatype = &GeneralGeographyListMediatype;
2797 GeopositionListPref = &GeneralGeographyListPref;
2800 GeopositionList = &HomeGeographyList;
2801 GeopositionListType = &HomeGeographyListType;
2802 GeopositionListAltID = &HomeGeographyListAltID;
2803 GeopositionListPID = &HomeGeographyListPID;
2804 GeopositionListTokens = &HomeGeographyListTokens;
2805 GeopositionListMediatype = &HomeGeographyListMediatype;
2806 GeopositionListPref = &HomeGeographyListPref;
2809 GeopositionList = &BusinessGeographyList;
2810 GeopositionListType = &BusinessGeographyListType;
2811 GeopositionListAltID = &BusinessGeographyListAltID;
2812 GeopositionListPID = &BusinessGeographyListPID;
2813 GeopositionListTokens = &BusinessGeographyListTokens;
2814 GeopositionListMediatype = &BusinessGeographyListMediatype;
2815 GeopositionListPref = &BusinessGeographyListPref;
2821 std::map<int,int>::iterator SLiter;
2822 wxString PropertyData;
2823 wxString PropertyName;
2824 wxString PropertyValue;
2825 wxString PropertyTokens;
2826 bool FirstToken = TRUE;
2828 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2829 intiter != SplitPoints.end(); ++intiter){
2831 SLiter = SplitLength.find(intiter->first);
2833 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2835 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2836 PropertyName = PropertyElement.GetNextToken();
2837 PropertyValue = PropertyElement.GetNextToken();
2839 intPrevValue = intiter->second;
2841 CaptureString(&PropertyValue, FALSE);
2843 // Process properties.
2845 if (PropertyName == wxT("ALTID")){
2847 GeopositionListAltID->erase(*GeographicCount);
2848 GeopositionListAltID->insert(std::make_pair(*GeographicCount, PropertyValue));
2850 } else if (PropertyName == wxT("PID")){
2852 GeopositionListPID->erase(*GeographicCount);
2853 GeopositionListPID->insert(std::make_pair(*GeographicCount, PropertyValue));
2855 } else if (PropertyName == wxT("MEDIATYPE")){
2857 GeopositionListMediatype->erase(*GeographicCount);
2858 GeopositionListMediatype->insert(std::make_pair(*GeographicCount, PropertyValue));
2860 } else if (PropertyName == wxT("PREF")){
2862 ProcessIntegerValue(GeopositionListPref, &PropertyValue, GeographicCount);
2866 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2868 if (FirstToken == TRUE){
2870 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2875 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2885 GeopositionList->insert(std::make_pair(*GeographicCount, PropertySeg2));
2887 // Add the name token data.
2889 if (!PropertyTokens.IsEmpty()){
2891 GeopositionListTokens->insert(std::make_pair(*GeographicCount, PropertyTokens));
2897 void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertySeg2, int *RelatedCount){
2899 size_t intPropertyLen = PropertySeg1.Len();
2900 std::map<int, int> SplitPoints;
2901 std::map<int, int> SplitLength;
2902 std::map<int, int>::iterator SLiter;
2903 wxString PropertyData;
2904 wxString PropertyName;
2905 wxString PropertyValue;
2906 wxString PropertyTokens;
2907 wxString RelatedType;
2908 wxString RelatedTypeOriginal;
2909 wxString RelatedName;
2910 bool FirstToken = TRUE;
2911 int intSplitsFound = 0;
2912 int intSplitSize = 0;
2913 int intPrevValue = 9;
2917 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2921 // Look for type before continuing.
2923 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2924 intiter != SplitPoints.end(); ++intiter){
2926 SLiter = SplitLength.find(intiter->first);
2928 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2930 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2931 PropertyName = PropertyElement.GetNextToken();
2932 PropertyValue = PropertyElement.GetNextToken();
2934 intPrevValue = intiter->second;
2938 RelatedTypeOriginal = PropertyValue;
2940 if (PropertyName == wxT("TYPE")){
2942 if (PropertyValue == wxT("contact")){
2944 RelatedType = _("Contact");
2946 } else if (PropertyValue == wxT("acquaintance")){
2948 RelatedType = _("Acquaintance");
2950 } else if (PropertyValue == wxT("friend")){
2952 RelatedType = _("Friend");
2954 } else if (PropertyValue == wxT("met")){
2956 RelatedType = _("Met");
2958 } else if (PropertyValue == wxT("co-worker")){
2960 RelatedType = _("Co-worker");
2962 } else if (PropertyValue == wxT("colleague")){
2964 RelatedType = _("Colleague");
2966 } else if (PropertyValue == wxT("co-resident")){
2968 RelatedType = _("Co-resident");
2970 } else if (PropertyValue == wxT("neighbor")){
2972 RelatedType = _("Neighbour");
2974 } else if (PropertyValue == wxT("child")){
2976 RelatedType = _("Child");
2978 } else if (PropertyValue == wxT("parent")){
2980 RelatedType = _("Parent");
2982 } else if (PropertyValue == wxT("sibling")){
2984 RelatedType = _("Sibling");
2986 } else if (PropertyValue == wxT("spouse")){
2988 RelatedType = _("Spouse");
2990 } else if (PropertyValue == wxT("kin")){
2992 RelatedType = _("Kin");
2994 } else if (PropertyValue == wxT("muse")){
2996 RelatedType = _("Muse");
2998 } else if (PropertyValue == wxT("crush")){
3000 RelatedType = _("Crush");
3002 } else if (PropertyValue == wxT("date")){
3004 RelatedType = _("Date");
3006 } else if (PropertyValue == wxT("sweetheart")){
3008 RelatedType = _("Sweetheart");
3010 } else if (PropertyValue == wxT("me")){
3012 RelatedType = _("Me");
3014 } else if (PropertyValue == wxT("agent")){
3016 RelatedType = _("Agent");
3018 } else if (PropertyValue == wxT("emergency")){
3020 RelatedType = _("Emergency");
3024 RelatedType = PropertyValue;
3034 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3035 intiter != SplitPoints.end(); ++intiter){
3037 SLiter = SplitLength.find(intiter->first);
3039 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3041 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3042 PropertyName = PropertyElement.GetNextToken();
3043 PropertyValue = PropertyElement.GetNextToken();
3045 intPrevValue = intiter->second;
3047 // Process properties.
3049 size_t intPropertyValueLen = PropertyValue.Len();
3051 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3053 PropertyValue.Trim();
3054 PropertyValue.RemoveLast();
3058 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3060 PropertyValue.Remove(0, 1);
3064 CaptureString(&PropertyValue, FALSE);
3066 if (PropertyName == wxT("ALTID")){
3068 GeneralRelatedListAltID.erase(*RelatedCount);
3069 GeneralRelatedListAltID.insert(std::make_pair(*RelatedCount, PropertyValue));
3071 } else if (PropertyName == wxT("PID")){
3073 GeneralRelatedListPID.erase(*RelatedCount);
3074 GeneralRelatedListPID.insert(std::make_pair(*RelatedCount, PropertyValue));
3076 } else if (PropertyName == wxT("PREF")){
3078 int PriorityNumber = 0;
3079 bool ValidNumber = TRUE;
3082 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3085 catch(std::invalid_argument &e){
3086 ValidNumber = FALSE;
3089 if (ValidNumber == TRUE){
3091 GeneralRelatedListPref.erase(*RelatedCount);
3092 GeneralRelatedListPref.insert(std::make_pair(*RelatedCount, PriorityNumber));
3096 } else if (PropertyName == wxT("LANGUAGE")){
3098 ProcessIntegerValue(&GeneralRelatedListPref, &PropertyValue, RelatedCount);
3100 } else if (PropertyName != wxT("TYPE")) {
3102 // Something else we don't know about so append
3103 // to the tokens variable.
3105 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3107 if (FirstToken == TRUE){
3109 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3114 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3124 // Add the data to the General/Home/Work address variables.
3126 GeneralRelatedList.erase(*RelatedCount);
3127 GeneralRelatedListRelType.erase(*RelatedCount);
3128 GeneralRelatedListType.erase(*RelatedCount);
3129 GeneralRelatedListTokens.erase(*RelatedCount);
3130 GeneralRelatedList.insert(std::make_pair(*RelatedCount, PropertySeg2));
3131 GeneralRelatedListRelType.insert(std::make_pair(*RelatedCount, RelatedType));
3132 GeneralRelatedListType.insert(std::make_pair(*RelatedCount, RelatedType));
3133 GeneralRelatedListTokens.insert(std::make_pair(*RelatedCount, PropertyTokens));
3137 void ContactDataObject::ProcessURL(wxString PropertySeg1, wxString PropertySeg2, int *URLCount){
3139 std::map<int, int> SplitPoints;
3140 std::map<int, int> SplitLength;
3141 std::map<int, int>::iterator SLiter;
3142 wxString PropertyData;
3143 wxString PropertyName;
3144 wxString PropertyValue;
3145 wxString PropertyTokens;
3146 bool FirstToken = TRUE;
3147 int intPrevValue = 5;
3152 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3156 PropertyType PropType = PROPERTY_NONE;
3158 // Look for type before continuing.
3160 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3162 // Setup the pointers.
3164 std::map<int, wxString> *WebsiteList = NULL;
3165 std::map<int, wxString> *WebsiteListAltID = NULL;
3166 std::map<int, wxString> *WebsiteListPID = NULL;
3167 std::map<int, wxString> *WebsiteListType = NULL;
3168 std::map<int, wxString> *WebsiteListTokens = NULL;
3169 std::map<int, wxString> *WebsiteListMediatype = NULL;
3170 std::map<int, int> *WebsiteListPref = NULL;
3172 // Setup blank lines for later on.
3176 WebsiteList = &GeneralWebsiteList;
3177 WebsiteListType = &GeneralWebsiteListType;
3178 WebsiteListAltID = &GeneralWebsiteListAltID;
3179 WebsiteListPID = &GeneralWebsiteListPID;
3180 WebsiteListTokens = &GeneralWebsiteListTokens;
3181 WebsiteListMediatype = &GeneralWebsiteListMediatype;
3182 WebsiteListPref = &GeneralWebsiteListPref;
3185 WebsiteList = &HomeWebsiteList;
3186 WebsiteListType = &HomeWebsiteListType;
3187 WebsiteListAltID = &HomeWebsiteListAltID;
3188 WebsiteListPID = &HomeWebsiteListPID;
3189 WebsiteListTokens = &HomeWebsiteListTokens;
3190 WebsiteListMediatype = &HomeWebsiteListMediatype;
3191 WebsiteListPref = &HomeWebsiteListPref;
3194 WebsiteList = &BusinessWebsiteList;
3195 WebsiteListType = &BusinessWebsiteListType;
3196 WebsiteListAltID = &BusinessWebsiteListAltID;
3197 WebsiteListPID = &BusinessWebsiteListPID;
3198 WebsiteListTokens = &BusinessWebsiteListTokens;
3199 WebsiteListMediatype = &BusinessWebsiteListMediatype;
3200 WebsiteListPref = &BusinessWebsiteListPref;
3206 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3207 intiter != SplitPoints.end(); ++intiter){
3209 SLiter = SplitLength.find(intiter->first);
3211 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3213 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3214 PropertyName = PropertyElement.GetNextToken();
3215 PropertyValue = PropertyElement.GetNextToken();
3217 intPrevValue = intiter->second;
3219 // Process properties.
3221 size_t intPropertyValueLen = PropertyValue.Len();
3223 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3225 PropertyValue.Trim();
3226 PropertyValue.RemoveLast();
3230 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3232 PropertyValue.Remove(0, 1);
3236 CaptureString(&PropertyValue, FALSE);
3238 if (PropertyName == wxT("ALTID")){
3240 WebsiteListAltID->erase(*URLCount);
3241 WebsiteListAltID->insert(std::make_pair(*URLCount, PropertyValue));
3243 } else if (PropertyName == wxT("PID")){
3245 WebsiteListPID->erase(*URLCount);
3246 WebsiteListPID->insert(std::make_pair(*URLCount, PropertyValue));
3248 } else if (PropertyName == wxT("PREF")){
3250 ProcessIntegerValue(WebsiteListPref, &PropertyValue, URLCount);
3252 } else if (PropertyName == wxT("MEDIATYPE")){
3254 WebsiteListMediatype->erase(*URLCount);
3255 WebsiteListMediatype->insert(std::make_pair(*URLCount, PropertyValue));
3259 // Something else we don't know about so append
3260 // to the tokens variable.
3262 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3264 if (FirstToken == TRUE){
3266 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3271 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3281 // Add the data to the General/Home/Work address variables.
3283 CaptureString(&PropertySeg2, FALSE);
3285 WebsiteList->insert(std::make_pair(*URLCount, PropertySeg2));
3287 if (!PropertyTokens.IsEmpty()){
3289 WebsiteListTokens->insert(std::make_pair(*URLCount, PropertyTokens));
3295 void ContactDataObject::ProcessTitle(wxString PropertySeg1, wxString PropertySeg2, int *TitleCount){
3297 std::map<int, int> SplitPoints;
3298 std::map<int, int> SplitLength;
3299 std::map<int, int>::iterator SLiter;
3300 wxString PropertyData;
3301 wxString PropertyName;
3302 wxString PropertyValue;
3303 wxString PropertyTokens;
3304 bool FirstToken = TRUE;
3305 int intPrevValue = 7;
3310 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3314 PropertyType PropType = PROPERTY_NONE;
3316 // Look for type before continuing.
3318 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3320 // Setup the pointers.
3322 std::map<int, wxString> *TitleList = NULL;
3323 std::map<int, wxString> *TitleListAltID = NULL;
3324 std::map<int, wxString> *TitleListPID = NULL;
3325 std::map<int, wxString> *TitleListType = NULL;
3326 std::map<int, wxString> *TitleListTokens = NULL;
3327 std::map<int, wxString> *TitleListLanguage = NULL;
3328 std::map<int, int> *TitleListPref = NULL;
3330 // Setup blank lines for later on.
3334 TitleList = &GeneralTitleList;
3335 TitleListType = &GeneralTitleListType;
3336 TitleListAltID = &GeneralTitleListAltID;
3337 TitleListPID = &GeneralTitleListPID;
3338 TitleListTokens = &GeneralTitleListTokens;
3339 TitleListLanguage = &GeneralTitleListLanguage;
3340 TitleListPref = &GeneralTitleListPref;
3343 TitleList = &HomeTitleList;
3344 TitleListType = &HomeTitleListType;
3345 TitleListAltID = &HomeTitleListAltID;
3346 TitleListPID = &HomeTitleListPID;
3347 TitleListTokens = &HomeTitleListTokens;
3348 TitleListLanguage = &HomeTitleListLanguage;
3349 TitleListPref = &HomeTitleListPref;
3352 TitleList = &BusinessTitleList;
3353 TitleListType = &BusinessTitleListType;
3354 TitleListAltID = &BusinessTitleListAltID;
3355 TitleListPID = &BusinessTitleListPID;
3356 TitleListTokens = &BusinessTitleListTokens;
3357 TitleListLanguage = &BusinessTitleListLanguage;
3358 TitleListPref = &BusinessTitleListPref;
3364 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3365 intiter != SplitPoints.end(); ++intiter){
3367 SLiter = SplitLength.find(intiter->first);
3369 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3371 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3372 PropertyName = PropertyElement.GetNextToken();
3373 PropertyValue = PropertyElement.GetNextToken();
3375 intPrevValue = intiter->second;
3377 // Process properties.
3379 size_t intPropertyValueLen = PropertyValue.Len();
3381 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3383 PropertyValue.Trim();
3384 PropertyValue.RemoveLast();
3388 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3390 PropertyValue.Remove(0, 1);
3394 CaptureString(&PropertyValue, FALSE);
3396 if (PropertyName == wxT("ALTID")){
3398 TitleListAltID->erase(*TitleCount);
3399 TitleListAltID->insert(std::make_pair(*TitleCount, PropertyValue));
3401 } else if (PropertyName == wxT("PID")){
3403 TitleListPID->erase(*TitleCount);
3404 TitleListPID->insert(std::make_pair(*TitleCount, PropertyValue));
3406 } else if (PropertyName == wxT("PREF")){
3408 ProcessIntegerValue(TitleListPref, &PropertyValue, TitleCount);
3410 } else if (PropertyName == wxT("LANGUAGE")){
3412 TitleListLanguage->erase(*TitleCount);
3413 TitleListLanguage->insert(std::make_pair(*TitleCount, PropertyValue));
3417 // Something else we don't know about so append
3418 // to the tokens variable.
3420 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3422 if (FirstToken == TRUE){
3424 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3429 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3439 // Add the data to the General/Home/Work address variables.
3441 CaptureString(&PropertySeg2, FALSE);
3443 TitleList->insert(std::make_pair(*TitleCount, PropertySeg2));
3445 if (!PropertyTokens.IsEmpty()){
3447 TitleListTokens->insert(std::make_pair(*TitleCount, PropertyTokens));
3453 void ContactDataObject::ProcessRole(wxString PropertySeg1, wxString PropertySeg2, int *RoleCount){
3455 std::map<int, int> SplitPoints;
3456 std::map<int, int> SplitLength;
3457 std::map<int, int>::iterator SLiter;
3458 wxString PropertyData;
3459 wxString PropertyName;
3460 wxString PropertyValue;
3461 wxString PropertyTokens;
3462 bool FirstToken = TRUE;
3463 int intPrevValue = 6;
3468 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3472 PropertyType PropType = PROPERTY_NONE;
3474 // Look for type before continuing.
3476 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3478 // Setup the pointers.
3480 std::map<int, wxString> *RoleList = NULL;
3481 std::map<int, wxString> *RoleListAltID = NULL;
3482 std::map<int, wxString> *RoleListPID = NULL;
3483 std::map<int, wxString> *RoleListType = NULL;
3484 std::map<int, wxString> *RoleListTokens = NULL;
3485 std::map<int, wxString> *RoleListLanguage = NULL;
3486 std::map<int, int> *RoleListPref = NULL;
3488 // Setup blank lines for later on.
3492 RoleList = &GeneralRoleList;
3493 RoleListType = &GeneralRoleListType;
3494 RoleListAltID = &GeneralRoleListAltID;
3495 RoleListPID = &GeneralRoleListPID;
3496 RoleListTokens = &GeneralRoleListTokens;
3497 RoleListLanguage = &GeneralRoleListLanguage;
3498 RoleListPref = &GeneralRoleListPref;
3501 RoleList = &HomeRoleList;
3502 RoleListType = &HomeRoleListType;
3503 RoleListAltID = &HomeRoleListAltID;
3504 RoleListPID = &HomeRoleListPID;
3505 RoleListTokens = &HomeRoleListTokens;
3506 RoleListLanguage = &HomeRoleListLanguage;
3507 RoleListPref = &HomeRoleListPref;
3510 RoleList = &BusinessRoleList;
3511 RoleListType = &BusinessRoleListType;
3512 RoleListAltID = &BusinessRoleListAltID;
3513 RoleListPID = &BusinessRoleListPID;
3514 RoleListTokens = &BusinessRoleListTokens;
3515 RoleListLanguage = &BusinessRoleListLanguage;
3516 RoleListPref = &BusinessRoleListPref;
3522 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3523 intiter != SplitPoints.end(); ++intiter){
3525 SLiter = SplitLength.find(intiter->first);
3527 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3529 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3530 PropertyName = PropertyElement.GetNextToken();
3531 PropertyValue = PropertyElement.GetNextToken();
3533 intPrevValue = intiter->second;
3535 // Process properties.
3537 size_t intPropertyValueLen = PropertyValue.Len();
3539 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3541 PropertyValue.Trim();
3542 PropertyValue.RemoveLast();
3546 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3548 PropertyValue.Remove(0, 1);
3552 CaptureString(&PropertyValue, FALSE);
3554 if (PropertyName == wxT("ALTID")){
3556 RoleListAltID->erase(*RoleCount);
3557 RoleListAltID->insert(std::make_pair(*RoleCount, PropertyValue));
3559 } else if (PropertyName == wxT("PID")){
3561 RoleListPID->erase(*RoleCount);
3562 RoleListPID->insert(std::make_pair(*RoleCount, PropertyValue));
3564 } else if (PropertyName == wxT("PREF")){
3566 ProcessIntegerValue(RoleListPref, &PropertyValue, RoleCount);
3568 } else if (PropertyName == wxT("LANGUAGE")){
3570 RoleListLanguage->erase(*RoleCount);
3571 RoleListLanguage->insert(std::make_pair(*RoleCount, PropertyValue));
3575 // Something else we don't know about so append
3576 // to the tokens variable.
3578 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3580 if (FirstToken == TRUE){
3582 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3587 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3597 // Add the data to the General/Home/Work address variables.
3599 CaptureString(&PropertySeg2, FALSE);
3601 RoleList->insert(std::make_pair(*RoleCount, PropertySeg2));
3603 if (!PropertyTokens.IsEmpty()){
3605 RoleListTokens->insert(std::make_pair(*RoleCount, PropertyTokens));
3611 void ContactDataObject::ProcessOrganisation(wxString PropertySeg1, wxString PropertySeg2, int *OrganisationCount){
3613 std::map<int, int> SplitPoints;
3614 std::map<int, int> SplitLength;
3615 std::map<int, int>::iterator SLiter;
3616 wxString PropertyData;
3617 wxString PropertyName;
3618 wxString PropertyValue;
3619 wxString PropertyTokens;
3620 bool FirstToken = TRUE;
3621 int intPrevValue = 5;
3626 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3630 PropertyType PropType = PROPERTY_NONE;
3632 // Look for type before continuing.
3634 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3636 // Setup the pointers.
3638 std::map<int, wxString> *OrganisationsList = NULL;
3639 std::map<int, wxString> *OrganisationsListAltID = NULL;
3640 std::map<int, wxString> *OrganisationsListPID = NULL;
3641 std::map<int, wxString> *OrganisationsListType = NULL;
3642 std::map<int, wxString> *OrganisationsListTokens = NULL;
3643 std::map<int, wxString> *OrganisationsListLanguage = NULL;
3644 std::map<int, wxString> *OrganisationsListSortAs = NULL;
3645 std::map<int, int> *OrganisationsListPref = NULL;
3647 // Setup blank lines for later on.
3651 OrganisationsList = &GeneralOrganisationsList;
3652 OrganisationsListType = &GeneralOrganisationsListType;
3653 OrganisationsListAltID = &GeneralOrganisationsListAltID;
3654 OrganisationsListPID = &GeneralOrganisationsListPID;
3655 OrganisationsListTokens = &GeneralOrganisationsListTokens;
3656 OrganisationsListLanguage = &GeneralOrganisationsListLanguage;
3657 OrganisationsListSortAs = &GeneralOrganisationsListSortAs;
3658 OrganisationsListPref = &GeneralOrganisationsListPref;
3661 OrganisationsList = &HomeOrganisationsList;
3662 OrganisationsListType = &HomeOrganisationsListType;
3663 OrganisationsListAltID = &HomeOrganisationsListAltID;
3664 OrganisationsListPID = &HomeOrganisationsListPID;
3665 OrganisationsListTokens = &HomeOrganisationsListTokens;
3666 OrganisationsListLanguage = &HomeOrganisationsListLanguage;
3667 OrganisationsListSortAs = &HomeOrganisationsListSortAs;
3668 OrganisationsListPref = &HomeOrganisationsListPref;
3671 OrganisationsList = &BusinessOrganisationsList;
3672 OrganisationsListType = &BusinessOrganisationsListType;
3673 OrganisationsListAltID = &BusinessOrganisationsListAltID;
3674 OrganisationsListPID = &BusinessOrganisationsListPID;
3675 OrganisationsListTokens = &BusinessOrganisationsListTokens;
3676 OrganisationsListLanguage = &BusinessOrganisationsListLanguage;
3677 OrganisationsListSortAs = &BusinessOrganisationsListSortAs;
3678 OrganisationsListPref = &BusinessOrganisationsListPref;
3684 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3685 intiter != SplitPoints.end(); ++intiter){
3687 SLiter = SplitLength.find(intiter->first);
3689 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3691 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3692 PropertyName = PropertyElement.GetNextToken();
3693 PropertyValue = PropertyElement.GetNextToken();
3695 intPrevValue = intiter->second;
3697 // Process properties.
3699 size_t intPropertyValueLen = PropertyValue.Len();
3701 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3703 PropertyValue.Trim();
3704 PropertyValue.RemoveLast();
3708 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3710 PropertyValue.Remove(0, 1);
3714 CaptureString(&PropertyValue, FALSE);
3716 if (PropertyName == wxT("ALTID")){
3718 OrganisationsListAltID->erase(*OrganisationCount);
3719 OrganisationsListAltID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3721 } else if (PropertyName == wxT("PID")){
3723 OrganisationsListPID->erase(*OrganisationCount);
3724 OrganisationsListPID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3726 } else if (PropertyName == wxT("SORT-AS")){
3728 OrganisationsListSortAs->erase(*OrganisationCount);
3729 OrganisationsListSortAs->insert(std::make_pair(*OrganisationCount, PropertyValue));
3731 } else if (PropertyName == wxT("PREF")){
3733 ProcessIntegerValue(OrganisationsListPref, &PropertyValue, OrganisationCount);
3735 } else if (PropertyName == wxT("LANGUAGE")){
3737 OrganisationsListLanguage->erase(*OrganisationCount);
3738 OrganisationsListLanguage->insert(std::make_pair(*OrganisationCount, PropertyValue));
3742 // Something else we don't know about so append
3743 // to the tokens variable.
3745 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3747 if (FirstToken == TRUE){
3749 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3754 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3764 // Add the data to the General/Home/Work address variables.
3766 CaptureString(&PropertySeg2, FALSE);
3768 OrganisationsList->insert(std::make_pair(*OrganisationCount, PropertySeg2));
3770 if (!PropertyTokens.IsEmpty()){
3772 OrganisationsListTokens->insert(std::make_pair(*OrganisationCount, PropertyTokens));
3778 void ContactDataObject::ProcessNote(wxString PropertySeg1, wxString PropertySeg2, int *NoteCount){
3780 std::map<int, int> SplitPoints;
3781 std::map<int, int> SplitLength;
3782 std::map<int, int>::iterator SLiter;
3783 wxString PropertyData;
3784 wxString PropertyName;
3785 wxString PropertyValue;
3786 wxString PropertyTokens;
3787 bool FirstToken = TRUE;
3788 int intPrevValue = 6;
3793 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3797 PropertyType PropType = PROPERTY_NONE;
3799 // Look for type before continuing.
3801 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3803 // Setup the pointers.
3805 std::map<int, wxString> *NoteList = NULL;
3806 std::map<int, wxString> *NoteListAltID = NULL;
3807 std::map<int, wxString> *NoteListPID = NULL;
3808 std::map<int, wxString> *NoteListType = NULL;
3809 std::map<int, wxString> *NoteListTokens = NULL;
3810 std::map<int, wxString> *NoteListLanguage = NULL;
3811 std::map<int, int> *NoteListPref = NULL;
3813 // Setup blank lines for later on.
3817 NoteList = &GeneralNoteList;
3818 NoteListType = &GeneralNoteListType;
3819 NoteListAltID = &GeneralNoteListAltID;
3820 NoteListPID = &GeneralNoteListPID;
3821 NoteListTokens = &GeneralNoteListTokens;
3822 NoteListLanguage = &GeneralNoteListLanguage;
3823 NoteListPref = &GeneralNoteListPref;
3826 NoteList = &HomeNoteList;
3827 NoteListType = &HomeNoteListType;
3828 NoteListAltID = &HomeNoteListAltID;
3829 NoteListPID = &HomeNoteListPID;
3830 NoteListTokens = &HomeNoteListTokens;
3831 NoteListLanguage = &HomeNoteListLanguage;
3832 NoteListPref = &HomeNoteListPref;
3835 NoteList = &BusinessNoteList;
3836 NoteListType = &BusinessNoteListType;
3837 NoteListAltID = &BusinessNoteListAltID;
3838 NoteListPID = &BusinessNoteListPID;
3839 NoteListTokens = &BusinessNoteListTokens;
3840 NoteListLanguage = &BusinessNoteListLanguage;
3841 NoteListPref = &BusinessNoteListPref;
3847 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3848 intiter != SplitPoints.end(); ++intiter){
3850 SLiter = SplitLength.find(intiter->first);
3852 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3854 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3855 PropertyName = PropertyElement.GetNextToken();
3856 PropertyValue = PropertyElement.GetNextToken();
3858 intPrevValue = intiter->second;
3860 // Process properties.
3862 size_t intPropertyValueLen = PropertyValue.Len();
3864 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3866 PropertyValue.Trim();
3867 PropertyValue.RemoveLast();
3871 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3873 PropertyValue.Remove(0, 1);
3877 CaptureString(&PropertyValue, FALSE);
3879 if (PropertyName == wxT("ALTID")){
3881 NoteListAltID->erase(*NoteCount);
3882 NoteListAltID->insert(std::make_pair(*NoteCount, PropertyValue));
3884 } else if (PropertyName == wxT("PID")){
3886 NoteListPID->erase(*NoteCount);
3887 NoteListPID->insert(std::make_pair(*NoteCount, PropertyValue));
3889 } else if (PropertyName == wxT("PREF")){
3891 ProcessIntegerValue(NoteListPref, &PropertyValue, NoteCount);
3893 } else if (PropertyName == wxT("LANGUAGE")){
3895 NoteListLanguage->erase(*NoteCount);
3896 NoteListLanguage->insert(std::make_pair(*NoteCount, PropertyValue));
3900 // Something else we don't know about so append
3901 // to the tokens variable.
3903 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3905 if (FirstToken == TRUE){
3907 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3912 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3922 // Add the data to the General/Home/Work address variables.
3924 CaptureString(&PropertySeg2, FALSE);
3926 NoteList->insert(std::make_pair(*NoteCount, PropertySeg2));
3928 if (!PropertyTokens.IsEmpty()){
3930 NoteListTokens->insert(std::make_pair(*NoteCount, PropertyTokens));
3936 void ContactDataObject::ProcessCategory(wxString PropertySeg1, wxString PropertySeg2, int *CategoryCount){
3938 std::map<int, int> SplitPoints;
3939 std::map<int, int> SplitLength;
3940 std::map<int, int>::iterator SLiter;
3941 wxString PropertyData;
3942 wxString PropertyName;
3943 wxString PropertyValue;
3944 wxString PropertyTokens;
3945 bool FirstToken = TRUE;
3946 int intPrevValue = 12;
3951 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3955 PropertyType PropType = PROPERTY_NONE;
3957 // Look for type before continuing.
3959 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3961 // Setup blank lines for later on.
3967 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
3970 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
3976 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3977 intiter != SplitPoints.end(); ++intiter){
3979 SLiter = SplitLength.find(intiter->first);
3981 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3983 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3984 PropertyName = PropertyElement.GetNextToken();
3985 PropertyValue = PropertyElement.GetNextToken();
3987 intPrevValue = intiter->second;
3989 // Process properties.
3991 size_t intPropertyValueLen = PropertyValue.Len();
3993 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3995 PropertyValue.Trim();
3996 PropertyValue.RemoveLast();
4000 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4002 PropertyValue.Remove(0, 1);
4006 CaptureString(&PropertyValue, FALSE);
4008 if (PropertyName == wxT("ALTID")){
4010 CategoriesListAltID.erase(*CategoryCount);
4011 CategoriesListAltID.insert(std::make_pair(*CategoryCount, PropertyValue));
4013 } else if (PropertyName == wxT("PID")){
4015 CategoriesListPID.erase(*CategoryCount);
4016 CategoriesListPID.insert(std::make_pair(*CategoryCount, PropertyValue));
4018 } else if (PropertyName == wxT("PREF")){
4020 ProcessIntegerValue(&CategoriesListPref, &PropertyValue, CategoryCount);
4022 } else if (PropertyName == wxT("LANGUAGE")){
4024 CategoriesListLanguage.erase(*CategoryCount);
4025 CategoriesListLanguage.insert(std::make_pair(*CategoryCount, PropertyValue));
4029 // Something else we don't know about so append
4030 // to the tokens variable.
4032 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4034 if (FirstToken == TRUE){
4036 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4041 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4051 // Deal with multiple categories.
4053 int intOrigCatCount = *CategoryCount;
4054 bool FirstCategoryProcessed = TRUE;
4055 bool AfterFirstToken = FALSE;
4056 int intSplitSize = 0;
4057 int intSplitsFound = 0;
4058 int intSplitSeek = 0;
4059 int intPropertyLen = PropertySeg2.Len();
4061 SplitPoints.clear();
4062 SplitLength.clear();
4065 for (int i = 0; i <= intPropertyLen; i++){
4067 if (intSplitSize == 0 && PropertySeg2.Mid(i, 1) == wxT(" ")){
4075 if (PropertySeg2.Mid(i, 1) == wxT(",") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
4077 if (AfterFirstToken == TRUE){
4079 SplitPoints.insert(std::make_pair(intSplitsFound, (i - intSplitSize + 1)));
4080 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
4084 SplitPoints.insert(std::make_pair(intSplitsFound, 0));
4085 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
4086 AfterFirstToken = TRUE;
4098 if (SplitPoints.size() > 0){
4100 SplitPoints.insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
4101 SplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
4105 if (SplitPoints.size() == 0){
4107 CategoriesList.insert(std::make_pair(*CategoryCount, PropertySeg2));
4109 if (!PropertyTokens.IsEmpty()){
4111 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4117 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4118 intiter != SplitPoints.end(); ++intiter){
4120 SLiter = SplitLength.find(intiter->first);
4122 intPrevValue = intiter->second;
4124 PropertyData = PropertySeg2.Mid(intPrevValue, (SLiter->second + 1));
4126 // Add the data to the General/Home/Work address variables.
4128 // Trim any whitespace from the start and end.
4130 PropertyData = PropertyData.Trim(FALSE);
4131 PropertyData = PropertyData.Trim(TRUE);
4133 CaptureString(&PropertyData, FALSE);
4135 if (FirstCategoryProcessed == TRUE){
4137 FirstCategoryProcessed = FALSE;
4139 CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4141 if (!PropertyTokens.IsEmpty()){
4143 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4153 CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4155 if (!PropertyTokens.IsEmpty()){
4157 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4163 // Copy the properties to each of the categories (if it exists).
4165 if (!PropertyTokens.IsEmpty()){
4167 CategoriesListTokens.insert(std::make_pair(*CategoryCount, CategoriesListTokens.find(intOrigCatCount)->second));
4171 // Check if ALTID was used.
4173 if (CategoriesListAltID.find(intOrigCatCount) != CategoriesListAltID.end()){
4175 CategoriesListAltID.insert(std::make_pair(*CategoryCount, CategoriesListAltID.find(intOrigCatCount)->second));
4179 // Check if PID was used.
4181 if (CategoriesListPID.find(intOrigCatCount) != CategoriesListPID.end()){
4183 CategoriesListPID.insert(std::make_pair(*CategoryCount, CategoriesListPID.find(intOrigCatCount)->second));
4187 // Check if PREF was used.
4189 if (CategoriesListPref.find(intOrigCatCount) != CategoriesListPref.end()){
4191 CategoriesListPref.insert(std::make_pair(*CategoryCount, CategoriesListPref.find(intOrigCatCount)->second));
4195 // Check if LANGUAGE was used.
4197 if (CategoriesListLanguage.find(intOrigCatCount) != CategoriesListLanguage.end()){
4199 CategoriesListLanguage.insert(std::make_pair(*CategoryCount, CategoriesListLanguage.find(intOrigCatCount)->second));
4203 // Check if TYPE was used.
4209 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
4212 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
4220 void ContactDataObject::ProcessPhoto(wxString PropertySeg1, wxString PropertySeg2, int *PhotoCount){
4222 size_t intPropertyLen = PropertySeg1.Len();
4223 std::map<int, int> SplitPoints;
4224 std::map<int, int> SplitLength;
4225 std::map<int, int>::iterator SLiter;
4226 wxString PropertyData;
4227 wxString PropertyName;
4228 wxString PropertyValue;
4229 wxString PropertyTokens;
4230 bool FirstToken = TRUE;
4231 int intSplitsFound = 0;
4232 int intSplitSize = 0;
4233 int intPrevValue = 7;
4237 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4241 PropertyType PropType = PROPERTY_NONE;
4243 // Look for type before continuing.
4245 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4249 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4250 intiter != SplitPoints.end(); ++intiter){
4252 SLiter = SplitLength.find(intiter->first);
4254 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4256 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4257 PropertyName = PropertyElement.GetNextToken();
4258 PropertyValue = PropertyElement.GetNextToken();
4260 intPrevValue = intiter->second;
4262 // Process properties.
4264 size_t intPropertyValueLen = PropertyValue.Len();
4266 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4268 PropertyValue.Trim();
4269 PropertyValue.RemoveLast();
4273 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4275 PropertyValue.Remove(0, 1);
4279 CaptureString(&PropertyValue, FALSE);
4281 if (PropertyName == wxT("ALTID")){
4283 PicturesListAltID.erase(*PhotoCount);
4284 PicturesListAltID.insert(std::make_pair(*PhotoCount, PropertyValue));
4286 } else if (PropertyName == wxT("PID")){
4288 PicturesListPID.erase(*PhotoCount);
4289 PicturesListPID.insert(std::make_pair(*PhotoCount, PropertyValue));
4291 } else if (PropertyName == wxT("PREF")){
4293 ProcessIntegerValue(&PicturesListPref, &PropertyValue, PhotoCount);
4295 } else if (PropertyName == wxT("MEDIATYPE")){
4297 PicturesListMediatype.erase(*PhotoCount);
4298 PicturesListMediatype.insert(std::make_pair(*PhotoCount, PropertyValue));
4302 // Something else we don't know about so append
4303 // to the tokens variable.
4305 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4307 if (FirstToken == TRUE){
4309 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4314 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4324 intPropertyLen = PropertySeg2.Len();
4325 SplitPoints.clear();
4326 SplitLength.clear();
4331 CaptureString(&PropertySeg2, FALSE);
4333 for (int i = 0; i <= intPropertyLen; i++){
4337 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4340 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4342 if (intSplitsFound == 6){
4344 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4349 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4359 wxString wxSPhotoURI;
4360 wxString wxSPhotoMIME;
4361 wxString wxSPhotoEncoding;
4362 wxString wxSPhotoData;
4363 std::string base64enc;
4365 if (intSplitsFound == 0){
4369 std::map<int, int>::iterator striter;
4371 striter = SplitLength.find(1);
4373 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4375 while (wSTDataType.HasMoreTokens() == TRUE){
4377 wxSPhotoURI = wSTDataType.GetNextToken();
4378 wxSPhotoMIME = wSTDataType.GetNextToken();
4383 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
4385 while (wSTDataInfo.HasMoreTokens() == TRUE){
4387 wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4388 wxSPhotoData = wSTDataInfo.GetNextToken();
4389 base64enc = wxSPhotoData.mb_str();
4396 // Add the data to the General/Home/Work address variables.
4398 PicturesList.insert(std::make_pair(*PhotoCount, base64enc));
4399 PicturesListPictureType.insert(std::make_pair(*PhotoCount, wxSPhotoMIME));
4400 PicturesListPicEncType.insert(std::make_pair(*PhotoCount, wxSPhotoEncoding));
4406 PicturesListType.insert(std::make_pair(*PhotoCount, "home"));
4409 PicturesListType.insert(std::make_pair(*PhotoCount, "work"));
4413 if (!PropertyTokens.IsEmpty()){
4415 PicturesListTokens.insert(std::make_pair(*PhotoCount, PropertyTokens));
4421 void ContactDataObject::ProcessLogo(wxString PropertySeg1, wxString PropertySeg2, int *LogoCount){
4423 size_t intPropertyLen = PropertySeg1.Len();
4424 std::map<int, int> SplitPoints;
4425 std::map<int, int> SplitLength;
4426 std::map<int, int>::iterator SLiter;
4427 wxString PropertyData;
4428 wxString PropertyName;
4429 wxString PropertyValue;
4430 wxString PropertyTokens;
4431 bool FirstToken = TRUE;
4432 int intSplitsFound = 0;
4433 int intSplitSize = 0;
4434 int intPrevValue = 6;
4438 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4442 PropertyType PropType = PROPERTY_NONE;
4444 // Look for type before continuing.
4446 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4450 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4451 intiter != SplitPoints.end(); ++intiter){
4453 SLiter = SplitLength.find(intiter->first);
4455 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4457 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4458 PropertyName = PropertyElement.GetNextToken();
4459 PropertyValue = PropertyElement.GetNextToken();
4461 intPrevValue = intiter->second;
4463 // Process properties.
4465 size_t intPropertyValueLen = PropertyValue.Len();
4467 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4469 PropertyValue.Trim();
4470 PropertyValue.RemoveLast();
4474 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4476 PropertyValue.Remove(0, 1);
4480 CaptureString(&PropertyValue, FALSE);
4482 if (PropertyName == wxT("ALTID")){
4484 LogosListAltID.erase(*LogoCount);
4485 LogosListAltID.insert(std::make_pair(*LogoCount, PropertyValue));
4487 } else if (PropertyName == wxT("PID")){
4489 LogosListPID.erase(*LogoCount);
4490 LogosListPID.insert(std::make_pair(*LogoCount, PropertyValue));
4492 } else if (PropertyName == wxT("PREF")){
4494 ProcessIntegerValue(&LogosListPref, &PropertyValue, LogoCount);
4496 } else if (PropertyName == wxT("MEDIATYPE")){
4498 LogosListMediatype.erase(*LogoCount);
4499 LogosListMediatype.insert(std::make_pair(*LogoCount, PropertyValue));
4503 // Something else we don't know about so append
4504 // to the tokens variable.
4506 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4508 if (FirstToken == TRUE){
4510 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4515 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4525 intPropertyLen = PropertySeg2.Len();
4526 SplitPoints.clear();
4527 SplitLength.clear();
4532 CaptureString(&PropertySeg2, FALSE);
4534 for (int i = 0; i <= intPropertyLen; i++){
4538 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4541 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4543 if (intSplitsFound == 6){
4545 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4550 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4560 wxString wxSPhotoURI;
4561 wxString wxSPhotoMIME;
4562 wxString wxSPhotoEncoding;
4563 wxString wxSPhotoData;
4564 std::string base64enc;
4566 if (intSplitsFound == 0){
4570 std::map<int, int>::iterator striter;
4572 striter = SplitLength.find(1);
4574 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4576 while (wSTDataType.HasMoreTokens() == TRUE){
4578 wxSPhotoURI = wSTDataType.GetNextToken();
4579 wxSPhotoMIME = wSTDataType.GetNextToken();
4584 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
4586 while (wSTDataInfo.HasMoreTokens() == TRUE){
4588 wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4589 wxSPhotoData = wSTDataInfo.GetNextToken();
4590 base64enc = wxSPhotoData.mb_str();
4597 // Add the data to the General/Home/Work address variables.
4599 LogosList.insert(std::make_pair(*LogoCount, base64enc));
4600 LogosListPictureType.insert(std::make_pair(*LogoCount, wxSPhotoMIME));
4601 LogosListPicEncType.insert(std::make_pair(*LogoCount, wxSPhotoEncoding));
4607 LogosListType.insert(std::make_pair(*LogoCount, "home"));
4610 LogosListType.insert(std::make_pair(*LogoCount, "work"));
4614 if (!PropertyTokens.IsEmpty()){
4616 LogosListTokens.insert(std::make_pair(*LogoCount, PropertyTokens));
4622 void ContactDataObject::ProcessSound(wxString PropertySeg1, wxString PropertySeg2, int *SoundCount){
4624 size_t intPropertyLen = PropertySeg1.Len();
4625 std::map<int, int> SplitPoints;
4626 std::map<int, int> SplitLength;
4627 std::map<int, int>::iterator SLiter;
4628 wxString PropertyData;
4629 wxString PropertyName;
4630 wxString PropertyValue;
4631 wxString PropertyTokens;
4632 bool FirstToken = TRUE;
4633 int intSplitsFound = 0;
4634 int intSplitSize = 0;
4635 int intPrevValue = 7;
4639 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4643 PropertyType PropType = PROPERTY_NONE;
4645 // Look for type before continuing.
4647 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4651 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4652 intiter != SplitPoints.end(); ++intiter){
4654 SLiter = SplitLength.find(intiter->first);
4656 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4658 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4659 PropertyName = PropertyElement.GetNextToken();
4660 PropertyValue = PropertyElement.GetNextToken();
4662 intPrevValue = intiter->second;
4664 // Process properties.
4666 size_t intPropertyValueLen = PropertyValue.Len();
4668 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4670 PropertyValue.Trim();
4671 PropertyValue.RemoveLast();
4675 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4677 PropertyValue.Remove(0, 1);
4681 CaptureString(&PropertyValue, FALSE);
4683 if (PropertyName == wxT("ALTID")){
4685 SoundsListAltID.erase(*SoundCount);
4686 SoundsListAltID.insert(std::make_pair(*SoundCount, PropertyValue));
4688 } else if (PropertyName == wxT("PID")){
4690 SoundsListPID.erase(*SoundCount);
4691 SoundsListPID.insert(std::make_pair(*SoundCount, PropertyValue));
4693 } else if (PropertyName == wxT("PREF")){
4695 ProcessIntegerValue(&SoundsListPref, &PropertyValue, SoundCount);
4697 } else if (PropertyName == wxT("MEDIATYPE")){
4699 SoundsListMediatype.erase(*SoundCount);
4700 SoundsListMediatype.insert(std::make_pair(*SoundCount, PropertyValue));
4702 } else if (PropertyName == wxT("LANGUAGE")){
4704 SoundsListLanguage.erase(*SoundCount);
4705 SoundsListLanguage.insert(std::make_pair(*SoundCount, PropertyValue));
4709 // Something else we don't know about so append
4710 // to the tokens variable.
4712 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4714 if (FirstToken == TRUE){
4716 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4721 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4731 intPropertyLen = PropertySeg2.Len();
4732 SplitPoints.clear();
4733 SplitLength.clear();
4738 CaptureString(&PropertySeg2, FALSE);
4740 for (int i = 0; i <= intPropertyLen; i++){
4744 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4747 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4749 if (intSplitsFound == 6){
4751 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4756 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4766 wxString wxSSoundURI;
4767 wxString wxSSoundMIME;
4768 wxString wxSSoundEncoding;
4769 wxString wxSSoundData;
4770 std::string base64enc;
4772 if (intSplitsFound == 0){
4776 std::map<int, int>::iterator striter;
4778 striter = SplitLength.find(1);
4780 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4782 while (wSTDataType.HasMoreTokens() == TRUE){
4784 wxSSoundURI = wSTDataType.GetNextToken();
4785 wxSSoundMIME = wSTDataType.GetNextToken();
4790 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
4792 while (wSTDataInfo.HasMoreTokens() == TRUE){
4794 wxSSoundEncoding = wSTDataInfo.GetNextToken();
4795 wxSSoundData = wSTDataInfo.GetNextToken();
4796 base64enc = wxSSoundData.mb_str();
4803 // Add the data to the General/Home/Work address variables.
4809 SoundsListType.insert(std::make_pair(*SoundCount, "home"));
4812 SoundsListType.insert(std::make_pair(*SoundCount, "work"));
4816 SoundsList.insert(std::make_pair(*SoundCount, base64enc));
4817 SoundsListAudioEncType.insert(std::make_pair(*SoundCount, wxSSoundEncoding));
4818 SoundsListAudioType.insert(std::make_pair(*SoundCount, wxSSoundMIME));
4820 if (!PropertyTokens.IsEmpty()){
4822 SoundsListTokens.insert(std::make_pair(*SoundCount, PropertyTokens));
4828 void ContactDataObject::ProcessCalendarURI(wxString PropertySeg1, wxString PropertySeg2, int *CalURICount){
4830 size_t intPropertyLen = PropertySeg1.Len();
4831 std::map<int, int> SplitPoints;
4832 std::map<int, int> SplitLength;
4833 std::map<int, int>::iterator SLiter;
4834 wxString PropertyData;
4835 wxString PropertyName;
4836 wxString PropertyValue;
4837 wxString PropertyTokens;
4838 bool FirstToken = TRUE;
4839 int intSplitsFound = 0;
4840 int intSplitSize = 0;
4841 int intPrevValue = 8;
4845 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4849 PropertyType PropType = PROPERTY_NONE;
4851 // Look for type before continuing.
4853 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4857 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4858 intiter != SplitPoints.end(); ++intiter){
4860 SLiter = SplitLength.find(intiter->first);
4862 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4864 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4865 PropertyName = PropertyElement.GetNextToken();
4866 PropertyValue = PropertyElement.GetNextToken();
4868 intPrevValue = intiter->second;
4870 // Process properties.
4872 size_t intPropertyValueLen = PropertyValue.Len();
4874 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4876 PropertyValue.Trim();
4877 PropertyValue.RemoveLast();
4881 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4883 PropertyValue.Remove(0, 1);
4887 CaptureString(&PropertyValue, FALSE);
4889 if (PropertyName == wxT("ALTID")){
4891 CalendarListAltID.erase(*CalURICount);
4892 CalendarListAltID.insert(std::make_pair(*CalURICount, PropertyValue));
4894 } else if (PropertyName == wxT("PID")){
4896 CalendarListPID.erase(*CalURICount);
4897 CalendarListPID.insert(std::make_pair(*CalURICount, PropertyValue));
4899 } else if (PropertyName == wxT("PREF")){
4901 ProcessIntegerValue(&CalendarListPref, &PropertyValue, CalURICount);
4903 } else if (PropertyName == wxT("MEDIATYPE")){
4905 CalendarListMediatype.erase(*CalURICount);
4906 CalendarListMediatype.insert(std::make_pair(*CalURICount, PropertyValue));
4910 // Something else we don't know about so append
4911 // to the tokens variable.
4913 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4915 if (FirstToken == TRUE){
4917 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4922 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4932 intPropertyLen = PropertySeg2.Len();
4933 SplitPoints.clear();
4934 SplitLength.clear();
4939 CaptureString(&PropertySeg2, FALSE);
4941 // Add the data to the General/Home/Work address variables.
4947 CalendarListType.insert(std::make_pair(*CalURICount, "home"));
4950 CalendarListType.insert(std::make_pair(*CalURICount, "work"));
4954 CalendarList.insert(std::make_pair(*CalURICount, PropertySeg2));
4956 if (!PropertyTokens.IsEmpty()){
4958 CalendarListTokens.insert(std::make_pair(*CalURICount, PropertyTokens));
4964 void ContactDataObject::ProcessCalendarAddressURI(wxString PropertySeg1, wxString PropertySeg2, int *CalAdrURICount){
4966 size_t intPropertyLen = PropertySeg1.Len();
4967 std::map<int, int> SplitPoints;
4968 std::map<int, int> SplitLength;
4969 std::map<int, int>::iterator SLiter;
4970 wxString PropertyData;
4971 wxString PropertyName;
4972 wxString PropertyValue;
4973 wxString PropertyTokens;
4974 bool FirstToken = TRUE;
4975 int intSplitsFound = 0;
4976 int intSplitSize = 0;
4977 int intPrevValue = 8;
4981 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4985 PropertyType PropType = PROPERTY_NONE;
4987 // Look for type before continuing.
4989 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4993 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4994 intiter != SplitPoints.end(); ++intiter){
4996 SLiter = SplitLength.find(intiter->first);
4998 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5000 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5001 PropertyName = PropertyElement.GetNextToken();
5002 PropertyValue = PropertyElement.GetNextToken();
5004 intPrevValue = intiter->second;
5006 // Process properties.
5008 size_t intPropertyValueLen = PropertyValue.Len();
5010 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5012 PropertyValue.Trim();
5013 PropertyValue.RemoveLast();
5017 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5019 PropertyValue.Remove(0, 1);
5023 CaptureString(&PropertyValue, FALSE);
5025 if (PropertyName == wxT("ALTID")){
5027 CalendarRequestListAltID.erase(*CalAdrURICount);
5028 CalendarRequestListAltID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5030 } else if (PropertyName == wxT("PID")){
5032 CalendarRequestListPID.erase(*CalAdrURICount);
5033 CalendarRequestListPID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5035 } else if (PropertyName == wxT("PREF")){
5037 ProcessIntegerValue(&CalendarRequestListPref, &PropertyValue, CalAdrURICount);
5039 } else if (PropertyName == wxT("MEDIATYPE")){
5041 CalendarRequestListMediatype.erase(*CalAdrURICount);
5042 CalendarRequestListMediatype.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5046 // Something else we don't know about so append
5047 // to the tokens variable.
5049 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5051 if (FirstToken == TRUE){
5053 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5058 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5068 intPropertyLen = PropertySeg2.Len();
5069 SplitPoints.clear();
5070 SplitLength.clear();
5075 CaptureString(&PropertySeg2, FALSE);
5077 // Add the data to the General/Home/Work address variables.
5083 CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "home"));
5086 CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "work"));
5090 CalendarRequestList.insert(std::make_pair(*CalAdrURICount, PropertySeg2));
5092 if (!PropertyTokens.IsEmpty()){
5094 CalendarRequestListTokens.insert(std::make_pair(*CalAdrURICount, PropertyTokens));
5100 void ContactDataObject::ProcessCalendarFreeBusy(wxString PropertySeg1, wxString PropertySeg2, int *FreeBusyAddressCount){
5102 size_t intPropertyLen = PropertySeg1.Len();
5103 std::map<int, int> SplitPoints;
5104 std::map<int, int> SplitLength;
5105 std::map<int, int>::iterator SLiter;
5106 wxString PropertyData;
5107 wxString PropertyName;
5108 wxString PropertyValue;
5109 wxString PropertyTokens;
5110 bool FirstToken = TRUE;
5111 int intSplitsFound = 0;
5112 int intSplitSize = 0;
5113 int intPrevValue = 7;
5117 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5121 PropertyType PropType = PROPERTY_NONE;
5123 // Look for type before continuing.
5125 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5129 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
5130 intiter != SplitPoints.end(); ++intiter){
5132 SLiter = SplitLength.find(intiter->first);
5134 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5136 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5137 PropertyName = PropertyElement.GetNextToken();
5138 PropertyValue = PropertyElement.GetNextToken();
5140 intPrevValue = intiter->second;
5142 // Process properties.
5144 size_t intPropertyValueLen = PropertyValue.Len();
5146 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5148 PropertyValue.Trim();
5149 PropertyValue.RemoveLast();
5153 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5155 PropertyValue.Remove(0, 1);
5159 CaptureString(&PropertyValue, FALSE);
5161 if (PropertyName == wxT("ALTID")){
5163 FreeBusyListAltID.erase(*FreeBusyAddressCount);
5164 FreeBusyListAltID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5166 } else if (PropertyName == wxT("PID")){
5168 FreeBusyListPID.erase(*FreeBusyAddressCount);
5169 FreeBusyListPID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5171 } else if (PropertyName == wxT("PREF")){
5173 ProcessIntegerValue(&FreeBusyListPref, &PropertyValue, FreeBusyAddressCount);
5175 } else if (PropertyName == wxT("MEDIATYPE")){
5177 FreeBusyListMediatype.erase(*FreeBusyAddressCount);
5178 FreeBusyListMediatype.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5182 // Something else we don't know about so append
5183 // to the tokens variable.
5185 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5187 if (FirstToken == TRUE){
5189 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5194 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5204 intPropertyLen = PropertySeg2.Len();
5205 SplitPoints.clear();
5206 SplitLength.clear();
5211 CaptureString(&PropertySeg2, FALSE);
5213 // Add the data to the General/Home/Work address variables.
5219 FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "home"));
5222 FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "work"));
5226 FreeBusyList.insert(std::make_pair(*FreeBusyAddressCount, PropertySeg2));
5228 if (!PropertyTokens.IsEmpty()){
5230 FreeBusyListTokens.insert(std::make_pair(*FreeBusyAddressCount, PropertyTokens));
5236 void ContactDataObject::ProcessKey(wxString PropertySeg1, wxString PropertySeg2, int *KeyCount){
5238 size_t intPropertyLen = PropertySeg1.Len();
5239 std::map<int, int> SplitPoints;
5240 std::map<int, int> SplitLength;
5241 std::map<int, int>::iterator SLiter;
5242 wxString PropertyData;
5243 wxString PropertyName;
5244 wxString PropertyValue;
5245 wxString PropertyTokens;
5246 bool FirstToken = TRUE;
5247 int intSplitsFound = 0;
5248 int intSplitSize = 0;
5249 int intPrevValue = 5;
5254 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5258 PropertyType PropType = PROPERTY_NONE;
5260 // Look for type before continuing.
5262 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5266 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
5267 intiter != SplitPoints.end(); ++intiter){
5269 SLiter = SplitLength.find(intiter->first);
5271 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5273 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5274 PropertyName = PropertyElement.GetNextToken();
5275 PropertyValue = PropertyElement.GetNextToken();
5277 intPrevValue = intiter->second;
5279 // Process properties.
5281 size_t intPropertyValueLen = PropertyValue.Len();
5283 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5285 PropertyValue.Trim();
5286 PropertyValue.RemoveLast();
5290 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5292 PropertyValue.Remove(0, 1);
5296 if (PropertyName == wxT("ALTID")){
5298 KeyListAltID.erase(*KeyCount);
5299 KeyListAltID.insert(std::make_pair(*KeyCount, PropertyValue));
5301 } else if (PropertyName == wxT("PID")){
5303 KeyListPID.erase(*KeyCount);
5304 KeyListPID.insert(std::make_pair(*KeyCount, PropertyValue));
5306 } else if (PropertyName == wxT("PREF")){
5308 ProcessIntegerValue(&KeyListPref, &PropertyValue, KeyCount);
5312 // Something else we don't know about so append
5313 // to the tokens variable.
5315 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5317 if (FirstToken == TRUE){
5319 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5324 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5334 intPropertyLen = PropertySeg2.Len();
5335 SplitPoints.clear();
5336 SplitLength.clear();
5341 for (int i = 0; i <= intPropertyLen; i++){
5345 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
5348 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
5350 if (intSplitsFound == 6){
5352 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5357 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5368 wxString wxSKeyMIME;
5369 wxString wxSKeyEncoding;
5370 wxString wxSKeyData;
5371 std::string base64enc;
5373 if (intSplitsFound == 0){
5377 std::map<int, int>::iterator striter;
5379 striter = SplitLength.find(1);
5381 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
5383 while (wSTDataType.HasMoreTokens() == TRUE){
5385 wxSKeyURI = wSTDataType.GetNextToken();
5386 wxSKeyMIME = wSTDataType.GetNextToken();
5391 if (wxSKeyURI == wxT("data")){
5393 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
5395 while (wSTDataInfo.HasMoreTokens() == TRUE){
5397 wxSKeyEncoding = wSTDataInfo.GetNextToken();
5398 wxSKeyData = wSTDataInfo.GetNextToken();
5407 // Add the data to the General/Home/Work address variables.
5409 if (wxSKeyURI == wxT("data")){
5411 KeyListDataEncType.erase(*KeyCount);
5412 KeyListKeyType.erase(*KeyCount);
5413 KeyListDataEncType.insert(std::make_pair(*KeyCount, wxSKeyEncoding));
5414 KeyListKeyType.insert(std::make_pair(*KeyCount, TRUE));
5416 KeyList.erase(*KeyCount);
5417 KeyList.insert(std::make_pair(*KeyCount, wxSKeyData));
5421 KeyList.erase(*KeyCount);
5422 KeyList.insert(std::make_pair(*KeyCount, PropertySeg2));
5426 KeyListDataType.insert(std::make_pair(*KeyCount, wxSKeyMIME));
5432 KeyListType.insert(std::make_pair(*KeyCount, wxT("home")));
5435 KeyListType.insert(std::make_pair(*KeyCount, wxT("work")));
5439 if (!PropertyTokens.IsEmpty()){
5441 KeyListTokens.insert(std::make_pair(*KeyCount, PropertyTokens));
5447 void ContactDataObject::ProcessVendor(wxString PropertySeg1, wxString PropertySeg2, int *VendorCount){
5449 // Split the Vendor three ways.
5451 wxStringTokenizer wSTVendorDetails(PropertySeg1, wxT("-"));
5454 wxString wxSVNDPropName;
5457 while (wSTVendorDetails.HasMoreTokens() == TRUE){
5459 wSTVendorDetails.GetNextToken();
5460 wxSVNDID = wSTVendorDetails.GetNextToken();
5461 wxSVNDPropName = wSTVendorDetails.GetNextToken();
5466 if (!wxSVNDID.IsEmpty() && !wxSVNDPropName.IsEmpty()){
5468 // Add the data to the vendor variables.
5470 VendorList.erase(*VendorCount);
5471 VendorListPEN.erase(*VendorCount);
5472 VendorListElement.erase(*VendorCount);
5474 VendorList.insert(std::make_pair(*VendorCount, PropertySeg2));
5475 VendorListPEN.insert(std::make_pair(*VendorCount, wxSVNDID));
5476 VendorListElement.insert(std::make_pair(*VendorCount, wxSVNDPropName));
5482 void ProcessStringValue(wxString *PropertyName,
5483 wxString PropertyNameMatch,
5484 std::map<int,wxString> *MapPtr,
5485 wxString *PropertyValue,
5487 bool *PropertyMatched){
5489 if (*PropertyName == PropertyNameMatch){
5490 MapPtr->erase(*ItemCount);
5491 MapPtr->insert(std::make_pair(*ItemCount, *PropertyValue));
5492 *PropertyMatched = TRUE;
5497 void ProcessIntegerValue(wxString *PropertyName,
5498 wxString PropertyNameMatch,
5499 std::map<int,int> *PrefPtr,
5500 wxString *PropertyValue,
5502 bool *PropertyMatched){
5504 if (*PropertyName == PropertyNameMatch){
5505 *PropertyMatched = TRUE;
5510 int PriorityNumber = 0;
5511 bool ValidNumber = TRUE;
5514 PriorityNumber = std::stoi(PropertyValue->ToStdString());
5517 catch(std::invalid_argument &e){
5518 ValidNumber = FALSE;
5521 if (ValidNumber == TRUE){
5523 PrefPtr->erase(*ItemCount);
5524 PrefPtr->insert(std::make_pair(*ItemCount, PriorityNumber));
5530 void ProcessIntegerValue(std::map<int,int> *PrefPtr,
5531 wxString *PropertyValue,
5534 int PriorityNumber = 0;
5535 bool ValidNumber = TRUE;
5538 PriorityNumber = std::stoi(PropertyValue->ToStdString());
5541 catch(std::invalid_argument &e){
5542 ValidNumber = FALSE;
5545 if (ValidNumber == TRUE){
5547 PrefPtr->erase(*ItemCount);
5548 PrefPtr->insert(std::make_pair(*ItemCount, PriorityNumber));
5554 void SplitValues(wxString *PropertyLine,
5555 std::map<int,int> *SplitPoints,
5556 std::map<int,int> *SplitLength,
5559 size_t intPropertyLen = PropertyLine->Len();
5560 int intSplitsFound = 0;
5561 int intSplitSize = 0;
5562 int intSplitSeek = 0;
5564 for (int i = intSize; i <= intPropertyLen; i++){
5568 if (PropertyLine->Mid(i, 1) == wxT(";") &&
5569 PropertyLine->Mid((i - 1), 1) != wxT("\\")){
5571 if (intSplitsFound == 0){
5573 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
5577 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5581 SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
5591 if (intSplitsFound == 0){
5593 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
5594 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5598 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
5599 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5605 void CheckType(wxString *PropertySeg1,
5606 std::map<int,int> *SplitPoints,
5607 std::map<int,int> *SplitLength,
5609 PropertyType *PropType){
5611 wxString PropertyData;
5612 wxString PropertyName;
5613 wxString PropertyValue;
5614 std::map<int,int>::iterator SLiter;
5616 for (std::map<int, int>::iterator intiter = SplitPoints->begin();
5617 intiter != SplitPoints->end(); ++intiter){
5619 SLiter = SplitLength->find(intiter->first);
5621 PropertyData = PropertySeg1->Mid(*intPrevValue, (SLiter->second));
5623 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5624 PropertyName = PropertyElement.GetNextToken();
5625 PropertyValue = PropertyElement.GetNextToken();
5627 *intPrevValue = intiter->second;
5629 if (PropertyName == wxT("TYPE")){
5631 if (PropertyValue == wxT("work")){
5633 *PropType = PROPERTY_WORK;
5635 } else if (PropertyValue == wxT("home")){
5637 *PropType = PROPERTY_HOME;
5641 *PropType = PROPERTY_NONE;