1 // ContactDataObject.cpp - Client Data Object.
3 // (c) 2012-2015 Xestia Software Development.
5 // This file is part of Xestia Address Book.
7 // Xestia Address Book is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by the
9 // Free Software Foundation, version 3 of the license.
11 // Xestia Address Book is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with Xestia Address Book. If not, see <http://www.gnu.org/licenses/>
19 #include "ContactDataObject.h"
21 ContactLoadStatus ContactDataObject::LoadFile(wxString Filename){
23 if (!wxFileExists(Filename)){
25 return CONTACTLOAD_FILEMISSING;
31 if (!ContactFile.Open(Filename, wxFile::read, wxS_DEFAULT)){
33 return CONTACTLOAD_FILEERROR;
37 // Check that the vCard is a valid vCard 4.0 file.
39 vCard vCard4FormatCheck;
41 vCard4FormatCheck.LoadFile(Filename);
43 if (vCard4FormatCheck.Get("VERSION") != wxT("4.0")){
45 return CONTACTLOAD_FILEINVALIDFORMAT;
49 // Check that the vCard meets the base specification.
51 if (!vCard4FormatCheck.MeetBaseSpecification()){
53 return CONTACTLOAD_FILEBASESPECFAIL;
57 wxStringTokenizer wSTContactFileLines(vCard4FormatCheck.WriteString(), wxT("\r\n"));
59 std::map<int, wxString> ContactFileLines;
61 int ContactLineSeek = 0;
63 while (wSTContactFileLines.HasMoreTokens() == TRUE){
65 wxString ContactLine = wSTContactFileLines.GetNextToken();
66 ContactFileLines.insert(std::make_pair(ContactLineSeek, ContactLine));
71 wxString wxSPropertyNextLine;
73 bool ExtraLineSeek = TRUE;
74 bool QuoteMode = FALSE;
75 bool PropertyFind = TRUE;
76 bool KindProcessed = FALSE;
77 bool NameProcessed = FALSE;
78 bool GenderProcessed = FALSE;
79 bool BirthdayProcessed = FALSE;
80 bool AnniversaryProcessed = FALSE;
81 bool UIDProcessed = FALSE;
82 bool RevisionProcessed = FALSE;
83 int ContactLineLen = 0;
84 int QuoteBreakPoint = 0;
88 int NicknameCount = 0;
89 int TimeZoneCount = 0;
93 int TelephoneCount = 0;
94 int LanguageCount = 0;
95 int GeographicCount = 0;
100 int OrganisationCount = 0;
102 int CategoryCount = 0;
106 int CalendarCount = 0;
107 int CalendarAddressCount = 0;
108 int FreeBusyAddressCount = 0;
113 int ClientPIDCount = 0;
114 wxString ContactLine;
115 wxString PropertyLine;
116 wxString PropertySeg1;
117 wxString PropertySeg2;
118 wxString PropertyNextLine;
121 for (std::map<int,wxString>::iterator iter = ContactFileLines.begin();
122 iter != ContactFileLines.end(); ++iter){
124 ExtraLineSeek = TRUE;
130 PropertyLine.Clear();
131 PropertySeg1.Clear();
132 PropertySeg2.Clear();
135 ContactLine = iter->second;
137 while (ExtraLineSeek == TRUE){
139 // Check if there is extra data on the next line
140 // (indicated by space or tab at the start) and add data.
144 if (iter == ContactFileLines.end()){
151 PropertyNextLine = iter->second;
153 if (PropertyNextLine.Mid(0, 1) == wxT(" ") || PropertyNextLine.Mid(0, 1) == wxT("\t")){
155 PropertyNextLine.Remove(0, 1);
156 ContactLine.Append(PropertyNextLine);
161 ExtraLineSeek = FALSE;
167 ContactLineLen = ContactLine.Len();
169 // Make sure we are not in quotation mode.
170 // Make sure colon does not have \ or \\ before it.
172 for (int i = 0; i <= ContactLineLen; i++){
174 if ((ContactLine.Mid(i, 1) == wxT(";") || ContactLine.Mid(i, 1) == wxT(":")) && PropertyFind == TRUE){
176 PropertyFind = FALSE;
178 } else if (PropertyFind == TRUE){
180 Property.Append(ContactLine.Mid(i, 1));
184 if (ContactLine.Mid(i, 1) == wxT("\"")){
186 if (QuoteMode == TRUE){
198 if (ContactLine.Mid(i, 1) == wxT(":") && ContactLine.Mid((i - 1), 1) != wxT("\\") && QuoteMode == FALSE){
207 // Split that line at the point into two variables (ignore the colon).
209 PropertySeg1 = ContactLine.Mid(0, QuoteBreakPoint);
210 PropertySeg2 = ContactLine.Mid((QuoteBreakPoint + 1));
212 if (Property == wxT("KIND") && KindProcessed == FALSE){
214 ProcessKind(PropertySeg2);
216 } else if (Property == wxT("UID") && UIDProcessed == FALSE){
218 UIDToken = PropertySeg2;
221 } else if (Property == wxT("SOURCE")){
223 ProcessSource(PropertySeg1, PropertySeg2, &SourceCount);
226 } else if (Property == wxT("XML")){
228 ProcessXML(PropertySeg1, PropertySeg2, &XMLCount);
231 } else if (Property == wxT("REV") && RevisionProcessed == FALSE){
233 ProcessRevision(PropertySeg1, PropertySeg2);
234 RevisionProcessed = TRUE;
236 } else if (Property == wxT("MEMBER")){
238 ProcessMember(PropertySeg1, PropertySeg2, &GroupCount);
241 } else if (Property == wxT("FN")){
243 ProcessFN(PropertySeg1, PropertySeg2, &FNCount);
246 } else if (Property == wxT("N") && NameProcessed == FALSE){
248 ProcessN(PropertySeg1, PropertySeg2);
249 NameProcessed = TRUE;
251 } else if (Property == wxT("CLIENTPIDMAP")){
253 ProcessClientPIDMap(PropertySeg1, PropertySeg2, &ClientPIDCount);
256 } else if (Property == wxT("NICKNAME")){
258 ProcessNickname(PropertySeg1, PropertySeg2, &NicknameCount);
261 } else if (Property == wxT("GENDER") && GenderProcessed == FALSE){
263 ProcessGender(PropertySeg1, PropertySeg2);
264 GenderProcessed = TRUE;
266 } else if (Property == wxT("BDAY") && BirthdayProcessed == FALSE){
268 ProcessBirthday(PropertySeg1, PropertySeg2);
269 BirthdayProcessed = TRUE;
271 } else if (Property == wxT("ANNIVERSARY") && AnniversaryProcessed == FALSE){
273 ProcessAnniversary(PropertySeg1, PropertySeg2);
274 AnniversaryProcessed = TRUE;
276 } else if (Property == wxT("TZ")){
278 ProcessTimeZone(PropertySeg1, PropertySeg2, &TimeZoneCount);
281 } else if (Property == wxT("ADR")){
283 ProcessAddress(PropertySeg1, PropertySeg2, &AddressCount);
286 } else if (Property == wxT("EMAIL")){
288 ProcessEmail(PropertySeg1, PropertySeg2, &EmailCount);
291 } else if (Property == wxT("IMPP")){
293 ProcessIM(PropertySeg1, PropertySeg2, &IMCount);
296 } else if (Property == wxT("TEL")){
298 ProcessTelephone(PropertySeg1, PropertySeg2, &TelephoneCount);
301 } else if (Property == wxT("LANG")){
303 // See frmContactEditor-LoadLanguage.cpp
305 ProcessLanguage(PropertySeg1, PropertySeg2, &LanguageCount);
308 } else if (Property == wxT("GEO")){
310 // See frmContactEditor-LoadGeo.cpp
312 ProcessGeographic(PropertySeg1, PropertySeg2, &GeographicCount);
315 } else if (Property == wxT("RELATED")){
317 // See fromContactEditor-LoadRelated.cpp
319 ProcessRelated(PropertySeg1, PropertySeg2, &RelatedCount);
322 } else if (Property == wxT("URL")){
324 // See frmContactEditor-LoadURL.cpp
326 ProcessURL(PropertySeg1, PropertySeg2, &URLCount);
329 } else if (Property == wxT("TITLE")) {
331 // See frmContactEditor-LoadTitle.cpp
333 ProcessTitle(PropertySeg1, PropertySeg2, &TitleCount);
336 } else if (Property == wxT("ROLE")) {
338 // See frmContactEditor-LoadTitle.cpp
340 ProcessRole(PropertySeg1, PropertySeg2, &RoleCount);
343 } else if (Property == wxT("ORG")) {
345 // See frmContactEditor-LoadOrg.cpp
347 ProcessOrganisation(PropertySeg1, PropertySeg2, &OrganisationCount);
350 } else if (Property == wxT("NOTE")) {
352 // See frmContactEditor-LoadNote.cpp
354 ProcessNote(PropertySeg1, PropertySeg2, &NoteCount);
357 } else if (Property == wxT("CATEGORIES")) {
359 // See frmContactEditor-LoadCategory.cpp
361 ProcessCategory(PropertySeg1, PropertySeg2, &CategoryCount);
364 } else if (Property == wxT("PHOTO")) {
366 // See frmContactEditor-LoadPhoto.cpp
368 ProcessPhoto(PropertySeg1, PropertySeg2, &PhotoCount);
371 } else if (Property == wxT("LOGO")) {
373 // See frmContactEditor-LoadPhoto.cpp
375 ProcessLogo(PropertySeg1, PropertySeg2, &LogoCount);
378 } else if (Property == wxT("LOGO")) {
380 // See frmContactEditor-LoadPhoto.cpp
382 ProcessLogo(PropertySeg1, PropertySeg2, &LogoCount);
385 } else if (Property == wxT("SOUND")) {
387 // See frmContactEditor-LoadSound.cpp
389 ProcessSound(PropertySeg1, PropertySeg2, &SoundCount);
392 } else if (Property == wxT("CALURI")){
394 // See frmContactEditor-LoadCalendar.cpp
396 ProcessCalendarURI(PropertySeg1, PropertySeg2, &CalendarCount);
399 } else if (Property == wxT("CALADRURI")){
401 ProcessCalendarAddressURI(PropertySeg1, PropertySeg2, &CalendarAddressCount);
402 CalendarAddressCount++;
404 } else if (Property == wxT("FBURL")){
406 // See frmContactEditor-LoadCalendar.cpp
408 ProcessCalendarFreeBusy(PropertySeg1, PropertySeg2, &FreeBusyAddressCount);
409 FreeBusyAddressCount++;
411 } else if (Property == wxT("KEY")){
413 // See frmContactEditor-LoadKey.cpp
415 ProcessKey(PropertySeg1, PropertySeg2, &KeyCount);
418 } else if (Property.Mid(0, 3) == wxT("VND")){
420 ProcessVendor(PropertySeg1, PropertySeg2, &VendorCount);
423 } else if (Property.Mid(0, 2) == wxT("X-")){
425 XTokenList.insert(std::make_pair(XTokenCount, PropertySeg2));
426 XTokenListTokens.insert(std::make_pair(XTokenCount, PropertySeg1.Mid(2)));
433 return CONTACTLOAD_OK;
437 void ContactDataObject::ProcessKind(wxString KindType){
439 if (KindType == wxT("individual")){
441 ContactKind = CONTACTKIND_INDIVIDUAL;
443 } else if (KindType == wxT("group")){
445 ContactKind = CONTACTKIND_GROUP;
447 } else if (KindType == wxT("org")){
449 ContactKind = CONTACTKIND_ORGANISATION;
451 } else if (KindType == wxT("location")){
453 ContactKind = CONTACTKIND_LOCATION;
457 ContactKind = CONTACTKIND_NONE;
462 void ContactDataObject::ProcessRevision(wxString PropertySeg1, wxString PropertySeg2){
464 size_t intPropertyLen = PropertySeg1.Len();
465 std::map<int, int> SplitPoints;
466 std::map<int, int> SplitLength;
467 std::map<int, int>::iterator SLiter;
468 wxString PropertyData;
469 wxString PropertyName;
470 wxString PropertyValue;
471 wxString PropertyTokens;
472 bool FirstToken = TRUE;
473 int intSplitsFound = 0;
474 int intSplitSize = 0;
475 int intPrevValue = 5;
479 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
483 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
484 intiter != SplitPoints.end(); ++intiter){
486 SLiter = SplitLength.find(intiter->first);
488 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
490 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
491 PropertyName = PropertyElement.GetNextToken();
492 PropertyValue = PropertyElement.GetNextToken();
494 intPrevValue = intiter->second;
496 // Process properties.
498 size_t intPropertyValueLen = PropertyValue.Len();
500 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
502 PropertyValue.Trim();
503 PropertyValue.RemoveLast();
507 if (PropertyValue.Mid(0, 1) == wxT("\"")){
509 PropertyValue.Remove(0, 1);
513 CaptureString(&PropertyValue, FALSE);
515 if (FirstToken == TRUE){
517 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
522 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
528 CaptureString(&PropertySeg2, FALSE);
530 Revision = PropertySeg2;
532 if (!PropertyTokens.IsEmpty()){
534 RevisionTokens = PropertyTokens;
541 void ContactDataObject::ProcessSource(wxString PropertySeg1, wxString PropertySeg2, int *SourceCount){
543 size_t intPropertyLen = PropertySeg1.Len();
544 std::map<int, int> SplitPoints;
545 std::map<int, int> SplitLength;
546 std::map<int, int>::iterator SLiter;
547 wxString PropertyData;
548 wxString PropertyName;
549 wxString PropertyValue;
550 wxString PropertyTokens;
551 bool FirstToken = TRUE;
552 bool PropertyMatched = FALSE;
553 int intSplitsFound = 0;
554 int intSplitSize = 0;
555 int intPrevValue = 8;
559 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
563 PropertyType PropType = PROPERTY_NONE;
565 // Look for type before continuing.
567 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
571 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
572 intiter != SplitPoints.end(); ++intiter){
574 SLiter = SplitLength.find(intiter->first);
576 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
578 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
579 PropertyName = PropertyElement.GetNextToken();
580 PropertyValue = PropertyElement.GetNextToken();
582 intPrevValue = intiter->second;
584 // Process properties.
586 size_t intPropertyValueLen = PropertyValue.Len();
588 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
590 PropertyValue.Trim();
591 PropertyValue.RemoveLast();
595 if (PropertyValue.Mid(0, 1) == wxT("\"")){
597 PropertyValue.Remove(0, 1);
601 CaptureString(&PropertyValue, FALSE);
603 ProcessStringValue(&PropertyName, "ALTID", &SourceListAltID, &PropertyValue, SourceCount, &PropertyMatched);
604 ProcessStringValue(&PropertyName, "PID", &SourceListPID, &PropertyValue, SourceCount, &PropertyMatched);
605 ProcessStringValue(&PropertyName, "MEDIATYPE", &SourceListMediatype, &PropertyValue, SourceCount, &PropertyMatched);
606 ProcessIntegerValue(&PropertyName, "PREF", &SourceListPref, &PropertyValue, SourceCount, &PropertyMatched);
608 if (PropertyMatched == TRUE){
610 PropertyMatched = FALSE;
615 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
617 if (FirstToken == TRUE){
619 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
624 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
632 intPropertyLen = PropertySeg2.Len();
639 CaptureString(&PropertySeg2, FALSE);
641 // Add the data to the General/Home/Work address variables.
647 SourceListType.insert(std::make_pair(*SourceCount, "home"));
650 SourceListType.insert(std::make_pair(*SourceCount, "work"));
654 SourceList.insert(std::make_pair(*SourceCount, PropertySeg2));
656 if (!PropertyTokens.IsEmpty()){
658 SourceListTokens.insert(std::make_pair(*SourceCount, PropertyTokens));
664 void ContactDataObject::ProcessXML(wxString PropertySeg1, wxString PropertySeg2, int *XMLCount){
666 std::map<int, int> SplitPoints;
667 std::map<int, int> SplitLength;
669 int intPrevValue = 5;
673 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
677 wxString PropertyName;
678 wxString PropertyValue;
679 wxString PropertyData;
680 wxString PropertyTokens;
681 std::map<int,int>::iterator SLiter;
682 bool FirstToken = TRUE;
683 bool PropertyMatched = FALSE;
685 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
686 intiter != SplitPoints.end(); ++intiter){
688 SLiter = SplitLength.find(intiter->first);
690 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
692 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
693 PropertyName = PropertyElement.GetNextToken();
694 PropertyValue = PropertyElement.GetNextToken();
696 intPrevValue = intiter->second;
698 CaptureString(&PropertyValue, FALSE);
700 ProcessStringValue(&PropertyName, "ALTID", &XMLListAltID, &PropertyValue, XMLCount, &PropertyMatched);
702 if (PropertyMatched == TRUE){
704 PropertyMatched = FALSE;
711 XMLList.insert(std::make_pair(*XMLCount, PropertySeg2));
715 void ContactDataObject::ProcessMember(wxString PropertySeg1, wxString PropertySeg2, int *GroupCount){
717 std::map<int, int> SplitPoints;
718 std::map<int, int> SplitLength;
720 int intPrevValue = 8;
724 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
728 wxString PropertyName;
729 wxString PropertyValue;
730 wxString PropertyData;
731 wxString PropertyTokens;
732 std::map<int,int>::iterator SLiter;
733 bool FirstToken = TRUE;
734 bool PropertyMatched = FALSE;
736 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
737 intiter != SplitPoints.end(); ++intiter){
739 SLiter = SplitLength.find(intiter->first);
741 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
743 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
744 PropertyName = PropertyElement.GetNextToken();
745 PropertyValue = PropertyElement.GetNextToken();
747 intPrevValue = intiter->second;
749 CaptureString(&PropertyValue, FALSE);
751 ProcessStringValue(&PropertyName, "ALTID", &GroupsListAltID, &PropertyValue, GroupCount, &PropertyMatched);
752 ProcessStringValue(&PropertyName, "PID", &GroupsListPID, &PropertyValue, GroupCount, &PropertyMatched);
753 ProcessStringValue(&PropertyName, "MEDIATYPE", &GroupsListMediaType, &PropertyValue, GroupCount, &PropertyMatched);
754 ProcessIntegerValue(&PropertyName, "PREF", &GroupsListPref, &PropertyValue, GroupCount, &PropertyMatched);
756 if (PropertyMatched == TRUE){
758 PropertyMatched = FALSE;
763 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
765 if (FirstToken == TRUE){
767 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
772 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
780 GroupsList.insert(std::make_pair(*GroupCount, PropertySeg2));
782 if (!PropertyTokens.IsEmpty()){
784 GroupsListTokens.insert(std::make_pair(*GroupCount, PropertyTokens));
791 void ContactDataObject::ProcessFN(wxString PropertySeg1, wxString PropertySeg2, int *FNCount){
793 std::map<int, int> SplitPoints;
794 std::map<int, int> SplitLength;
796 int intPrevValue = 4;
800 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
804 wxString PropertyName;
805 wxString PropertyValue;
806 wxString PropertyData;
807 wxString PropertyTokens;
808 std::map<int,int>::iterator SLiter;
809 bool FirstToken = TRUE;
810 bool PropertyMatched = FALSE;
812 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
813 intiter != SplitPoints.end(); ++intiter){
815 SLiter = SplitLength.find(intiter->first);
817 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
819 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
820 PropertyName = PropertyElement.GetNextToken();
821 PropertyValue = PropertyElement.GetNextToken();
823 intPrevValue = intiter->second;
825 CaptureString(&PropertyValue, FALSE);
827 if (PropertyName == wxT("TYPE")){
829 if (!PropertyValue.IsEmpty() || PropertyValue == wxT("home") ||
830 PropertyValue == wxT("work") ){
832 FullNamesListType.erase(*FNCount);
833 FullNamesListType.insert(std::make_pair(*FNCount, PropertyValue));
837 PropertyMatched = TRUE;
841 ProcessStringValue(&PropertyName, "ALTID", &FullNamesListAltID, &PropertyValue, FNCount, &PropertyMatched);
842 ProcessStringValue(&PropertyName, "PID", &FullNamesListPID, &PropertyValue, FNCount, &PropertyMatched);
843 ProcessStringValue(&PropertyName, "LANGUAGE", &FullNamesListLanguage, &PropertyValue, FNCount, &PropertyMatched);
844 ProcessIntegerValue(&PropertyName, "PREF", &FullNamesListPref, &PropertyValue, FNCount, &PropertyMatched);
846 if (PropertyMatched == TRUE){
848 PropertyMatched = FALSE;
853 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
855 if (FirstToken == TRUE){
857 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
862 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
870 FullNamesList.insert(std::make_pair(*FNCount, PropertySeg2));
872 if (!PropertyTokens.IsEmpty()){
874 FullNamesListTokens.insert(std::make_pair(*FNCount, PropertyTokens));
880 void ContactDataObject::ProcessN(wxString PropertySeg1, wxString PropertySeg2){
882 std::map<int, int> SplitPoints;
883 std::map<int, int> SplitLength;
885 int intPrevValue = 3;
889 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
893 wxString PropertyName;
894 wxString PropertyValue;
895 wxString PropertyData;
896 wxString PropertyTokens;
897 std::map<int,int>::iterator SLiter;
898 bool FirstToken = TRUE;
900 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
901 intiter != SplitPoints.end(); ++intiter){
903 SLiter = SplitLength.find(intiter->first);
905 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
907 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
908 PropertyName = PropertyElement.GetNextToken();
909 PropertyValue = PropertyElement.GetNextToken();
911 intPrevValue = intiter->second;
913 CaptureString(&PropertyValue, FALSE);
915 if (PropertyName == wxT("ALTID")){
917 NameAltID = PropertyValue;
919 } else if (PropertyName == wxT("LANGUAGE")){
921 NameLanguage = PropertyValue;
923 } else if (PropertyName == wxT("SORT-AS")){
925 if (PropertyValue.Left(1) == wxT("\"") && PropertyValue.Right(1) == wxT("\"") &&
926 PropertyValue.Len() >= 3){
927 NameDisplayAs = PropertyValue.Mid(1, (PropertyValue.Len() - 2));
930 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
932 if (FirstToken == TRUE){
934 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
939 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
947 // Split the name data.
949 int intSplitSeek = 0;
950 int intSplitsFound = 0;
951 int intSplitSize = 0;
952 int intPropertyLen = PropertySeg2.Len();
954 std::map<int,wxString> NameValues;
957 for (int i = 0; i <= intPropertyLen; i++){
959 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
961 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, intSplitSize)));
966 if (intSplitsFound == 4){
968 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, wxString::npos)));
982 // Split the data into several parts.
984 for (std::map<int, wxString>::iterator iter = NameValues.begin();
985 iter != NameValues.end(); ++iter){
987 if (iter->first == 1){
989 // Deal with family name.
991 NameSurname = iter->second;
993 } else if (iter->first == 2){
995 // Deal with given names.
997 NameForename = iter->second;
999 } else if (iter->first == 3){
1001 // Deal with additional names.
1003 NameOtherNames = iter->second;
1005 } else if (iter->first == 4){
1007 // Deal with honorifix prefixes and suffixes.
1009 NameTitle = iter->second;
1013 if (iter == NameValues.end()){
1019 NameSuffix = iter->second;
1025 // Add the name token data.
1027 if (!PropertyTokens.IsEmpty()){
1029 NameTokens = PropertyTokens;
1035 void ContactDataObject::ProcessClientPIDMap(wxString PropertySeg1, wxString PropertySeg2, int *ClientPIDCount){
1037 size_t intPropertyLen = PropertySeg1.Len();
1038 std::map<int, int> SplitPoints;
1039 std::map<int, int> SplitLength;
1040 std::map<int, int>::iterator SLiter;
1041 wxString PropertyData;
1042 wxString PropertyName;
1043 wxString PropertyValue;
1044 wxString PropertyTokens;
1045 bool FirstToken = TRUE;
1046 int intSplitsFound = 0;
1047 int intSplitSize = 0;
1048 int intPrevValue = 14;
1052 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1056 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1057 intiter != SplitPoints.end(); ++intiter){
1059 SLiter = SplitLength.find(intiter->first);
1061 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1063 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1064 PropertyName = PropertyElement.GetNextToken();
1065 PropertyValue = PropertyElement.GetNextToken();
1067 intPrevValue = intiter->second;
1069 // Process properties.
1071 CaptureString(&PropertyValue, FALSE);
1073 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1075 if (FirstToken == TRUE){
1077 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1082 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1090 CaptureString(&PropertySeg2, FALSE);
1092 ClientPIDList.insert(std::make_pair(*ClientPIDCount, PropertySeg2));
1094 if (!PropertyTokens.IsEmpty()){
1096 ClientPIDListTokens.insert(std::make_pair(*ClientPIDCount, PropertyTokens));
1102 void ContactDataObject::ProcessNickname(wxString PropertySeg1, wxString PropertySeg2, int *NicknameCount){
1104 std::map<int, int> SplitPoints;
1105 std::map<int, int> SplitLength;
1107 int intPrevValue = 10;
1110 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1114 PropertyType PropType = PROPERTY_NONE;
1116 // Look for type before continuing.
1118 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1122 std::map<int, wxString> *NicknamesList = NULL;
1123 std::map<int, wxString> *NicknamesListType = NULL;
1124 std::map<int, wxString> *NicknamesListLanguage = NULL;
1125 std::map<int, wxString> *NicknamesListAltID = NULL;
1126 std::map<int, wxString> *NicknamesListPID = NULL;
1127 std::map<int, wxString> *NicknamesListTokens = NULL;
1128 std::map<int, int> *NicknamesListPref = NULL;
1132 NicknamesList = &GeneralNicknamesList;
1133 NicknamesListType = &GeneralNicknamesListType;
1134 NicknamesListLanguage = &GeneralNicknamesListLanguage;
1135 NicknamesListAltID = &GeneralNicknamesListAltID;
1136 NicknamesListPID = &GeneralNicknamesListPID;
1137 NicknamesListTokens = &GeneralNicknamesListTokens;
1138 NicknamesListPref = &GeneralNicknamesListPref;
1141 NicknamesList = &HomeNicknamesList;
1142 NicknamesListType = &HomeNicknamesListType;
1143 NicknamesListLanguage = &HomeNicknamesListLanguage;
1144 NicknamesListAltID = &HomeNicknamesListAltID;
1145 NicknamesListPID = &HomeNicknamesListPID;
1146 NicknamesListTokens = &HomeNicknamesListTokens;
1147 NicknamesListPref = &HomeNicknamesListPref;
1150 NicknamesList = &BusinessNicknamesList;
1151 NicknamesListType = &BusinessNicknamesListType;
1152 NicknamesListLanguage = &BusinessNicknamesListLanguage;
1153 NicknamesListAltID = &BusinessNicknamesListAltID;
1154 NicknamesListPID = &BusinessNicknamesListPID;
1155 NicknamesListTokens = &BusinessNicknamesListTokens;
1156 NicknamesListPref = &BusinessNicknamesListPref;
1160 std::map<int, int>::iterator SLiter;
1161 wxString PropertyData;
1162 wxString PropertyName;
1163 wxString PropertyValue;
1164 wxString PropertyTokens;
1165 bool FirstToken = TRUE;
1166 bool PropertyMatched = FALSE;
1168 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1169 intiter != SplitPoints.end(); ++intiter){
1171 SLiter = SplitLength.find(intiter->first);
1173 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1175 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1176 PropertyName = PropertyElement.GetNextToken();
1177 PropertyValue = PropertyElement.GetNextToken();
1179 intPrevValue = intiter->second;
1181 CaptureString(&PropertyValue, FALSE);
1183 ProcessStringValue(&PropertyName, "ALTID", NicknamesListAltID, &PropertyValue, NicknameCount, &PropertyMatched);
1184 ProcessStringValue(&PropertyName, "PID", NicknamesListPID, &PropertyValue, NicknameCount, &PropertyMatched);
1185 ProcessStringValue(&PropertyName, "LANGUAGE", NicknamesListLanguage, &PropertyValue, NicknameCount, &PropertyMatched);
1186 ProcessIntegerValue(&PropertyName, "PREF", NicknamesListPref, &PropertyValue, NicknameCount, &PropertyMatched);
1188 if (PropertyMatched == TRUE){
1190 PropertyMatched = FALSE;
1195 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1197 if (FirstToken == TRUE){
1199 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1204 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1212 NicknamesList->insert(std::make_pair(*NicknameCount, PropertySeg2));
1214 // Add the name token data.
1216 if (!PropertyTokens.IsEmpty()){
1218 NicknamesListTokens->insert(std::make_pair(*NicknameCount, PropertyTokens));
1224 void ContactDataObject::ProcessGender(wxString PropertySeg1, wxString PropertySeg2){
1226 std::map<int, int> SplitPoints;
1227 std::map<int, int> SplitLength;
1228 std::map<int, int>::iterator SLiter;
1229 wxString PropertyData;
1230 wxString PropertyName;
1231 wxString PropertyValue;
1232 wxString PropertyTokens;
1233 bool FirstToken = TRUE;
1234 int intPrevValue = 8;
1236 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1240 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1241 intiter != SplitPoints.end(); ++intiter){
1243 SLiter = SplitLength.find(intiter->first);
1245 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1247 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1248 PropertyName = PropertyElement.GetNextToken();
1249 PropertyValue = PropertyElement.GetNextToken();
1251 intPrevValue = intiter->second;
1253 // Process properties.
1255 size_t intPropertyValueLen = PropertyValue.Len();
1257 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
1259 PropertyValue.Trim();
1260 PropertyValue.RemoveLast();
1264 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1266 PropertyValue.Remove(0, 1);
1270 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1272 if (FirstToken == TRUE){
1274 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1279 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1287 wxStringTokenizer GenderData (PropertySeg2, wxT(";"));
1289 wxString GenderComponent;
1291 if (GenderData.CountTokens() >= 2){
1293 Gender = GenderData.GetNextToken();
1294 GenderDetails = GenderData.GetString();
1296 CaptureString(&GenderDetails, FALSE);
1300 Gender = GenderData.GetNextToken();
1304 if (!PropertyTokens.IsEmpty()){
1306 GenderTokens = PropertyTokens;
1312 void ContactDataObject::ProcessBirthday(wxString PropertySeg1, wxString PropertySeg2){
1314 // Process date. Preserve the remainder in the string.
1316 std::map<int, int> SplitPoints;
1317 std::map<int, int> SplitLength;
1318 std::map<int, int>::iterator SLiter;
1319 wxString PropertyData;
1320 wxString PropertyName;
1321 wxString PropertyValue;
1322 wxString PropertyTokens;
1323 bool BirthdayText = FALSE;
1324 int intPrevValue = 6;
1326 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1330 // Look for type before continuing.
1332 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1333 intiter != SplitPoints.end(); ++intiter){
1335 SLiter = SplitLength.find(intiter->first);
1337 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1339 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1340 PropertyName = PropertyElement.GetNextToken();
1341 PropertyValue = PropertyElement.GetNextToken();
1343 intPrevValue = intiter->second;
1345 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && BirthdayText == FALSE){
1347 CaptureString(&PropertySeg2, FALSE);
1348 Birthday = PropertySeg2;
1349 BirthdayText = TRUE;
1355 // Setup blank lines for later on.
1358 bool FirstToken = TRUE;
1360 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1361 intiter != SplitPoints.end(); ++intiter){
1363 SLiter = SplitLength.find(intiter->first);
1365 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1367 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1368 PropertyName = PropertyElement.GetNextToken();
1369 PropertyValue = PropertyElement.GetNextToken();
1371 intPrevValue = intiter->second;
1373 // Process properties.
1375 CaptureString(&PropertyValue, FALSE);
1377 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1379 PropertyValue.Trim();
1380 PropertyValue.RemoveLast();
1384 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1386 PropertyValue.Remove(0, 1);
1390 if (PropertyName == wxT("ALTID")){
1392 BirthdayAltID = PropertyValue;
1394 } else if (PropertyName == wxT("CALSCALE")){
1396 BirthdayCalScale = PropertyValue;
1398 } else if (PropertyName != wxT("VALUE")) {
1400 // Something else we don't know about so append
1401 // to the tokens variable.
1403 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1405 if (FirstToken == TRUE){
1407 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1412 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1422 // Add the data to the variables and form.
1424 if (BirthdayText == FALSE){
1426 Birthday = PropertySeg2;
1430 if (!PropertyTokens.IsEmpty()){
1432 BirthdayTokens = PropertyTokens;
1438 void ContactDataObject::ProcessAnniversary(wxString PropertySeg1, wxString PropertySeg2){
1440 // Process date. Preserve the remainder in the string.
1442 std::map<int, int> SplitPoints;
1443 std::map<int, int> SplitLength;
1444 std::map<int, int>::iterator SLiter;
1445 wxString PropertyData;
1446 wxString PropertyName;
1447 wxString PropertyValue;
1448 wxString PropertyTokens;
1449 bool AnniversaryText = FALSE;
1450 int intPrevValue = 13;
1452 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1456 // Look for type before continuing.
1458 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1459 intiter != SplitPoints.end(); ++intiter){
1461 SLiter = SplitLength.find(intiter->first);
1463 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1465 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1466 PropertyName = PropertyElement.GetNextToken();
1467 PropertyValue = PropertyElement.GetNextToken();
1469 intPrevValue = intiter->second;
1471 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && AnniversaryText == FALSE){
1473 CaptureString(&PropertySeg2, FALSE);
1474 Anniversary = PropertySeg2;
1475 AnniversaryText = TRUE;
1481 // Setup blank lines for later on.
1484 bool FirstToken = TRUE;
1486 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1487 intiter != SplitPoints.end(); ++intiter){
1489 SLiter = SplitLength.find(intiter->first);
1491 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1493 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1494 PropertyName = PropertyElement.GetNextToken();
1495 PropertyValue = PropertyElement.GetNextToken();
1497 intPrevValue = intiter->second;
1499 // Process properties.
1501 CaptureString(&PropertyValue, FALSE);
1503 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1505 PropertyValue.Trim();
1506 PropertyValue.RemoveLast();
1510 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1512 PropertyValue.Remove(0, 1);
1516 if (PropertyName == wxT("ALTID")){
1518 AnniversaryAltID = PropertyValue;
1520 } else if (PropertyName == wxT("CALSCALE")){
1522 AnniversaryCalScale = PropertyValue;
1524 } else if (PropertyName != wxT("VALUE")) {
1526 // Something else we don't know about so append
1527 // to the tokens variable.
1529 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1531 if (FirstToken == TRUE){
1533 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1538 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1548 // Add the data to the variables and form.
1550 if (AnniversaryText == FALSE){
1552 Anniversary = PropertySeg2;
1556 if (!PropertyTokens.IsEmpty()){
1558 AnniversaryTokens = PropertyTokens;
1564 void ContactDataObject::ProcessTimeZone(wxString PropertySeg1, wxString PropertySeg2, int *TimeZoneCount){
1566 std::map<int, int> SplitPoints;
1567 std::map<int, int> SplitLength;
1569 int intPrevValue = 4;
1572 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1576 PropertyType PropType = PROPERTY_NONE;
1578 // Look for type before continuing.
1580 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1584 std::map<int, wxString> *TZList = NULL;
1585 std::map<int, wxString> *TZListType = NULL;
1586 std::map<int, wxString> *TZListMediatype = NULL;
1587 std::map<int, wxString> *TZListAltID = NULL;
1588 std::map<int, wxString> *TZListPID = NULL;
1589 std::map<int, wxString> *TZListTokens = NULL;
1590 std::map<int, int> *TZListPref = NULL;
1594 TZList = &GeneralTZList;
1595 TZListType = &GeneralTZListType;
1596 TZListMediatype = &GeneralTZListMediatype;
1597 TZListAltID = &GeneralTZListAltID;
1598 TZListPID = &GeneralTZListPID;
1599 TZListTokens = &GeneralTZListTokens;
1600 TZListPref = &GeneralTZListPref;
1603 TZList = &HomeTZList;
1604 TZListType = &HomeTZListType;
1605 TZListMediatype = &HomeTZListMediatype;
1606 TZListAltID = &HomeTZListAltID;
1607 TZListPID = &HomeTZListPID;
1608 TZListTokens = &HomeTZListTokens;
1609 TZListPref = &HomeTZListPref;
1612 TZList = &BusinessTZList;
1613 TZListType = &BusinessTZListType;
1614 TZListMediatype = &BusinessTZListMediatype;
1615 TZListAltID = &BusinessTZListAltID;
1616 TZListPID = &BusinessTZListPID;
1617 TZListTokens = &BusinessTZListTokens;
1618 TZListPref = &BusinessTZListPref;
1622 std::map<int, int>::iterator SLiter;
1623 wxString PropertyData;
1624 wxString PropertyName;
1625 wxString PropertyValue;
1626 wxString PropertyTokens;
1627 bool FirstToken = TRUE;
1628 bool PropertyMatched = FALSE;
1630 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1631 intiter != SplitPoints.end(); ++intiter){
1633 SLiter = SplitLength.find(intiter->first);
1635 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1637 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1638 PropertyName = PropertyElement.GetNextToken();
1639 PropertyValue = PropertyElement.GetNextToken();
1641 intPrevValue = intiter->second;
1643 CaptureString(&PropertyValue, FALSE);
1645 ProcessStringValue(&PropertyName, "ALTID", TZListAltID, &PropertyValue, TimeZoneCount, &PropertyMatched);
1646 ProcessStringValue(&PropertyName, "PID", TZListPID, &PropertyValue, TimeZoneCount, &PropertyMatched);
1647 ProcessStringValue(&PropertyName, "MEDIATYPE", TZListMediatype, &PropertyValue, TimeZoneCount, &PropertyMatched);
1648 ProcessIntegerValue(&PropertyName, "PREF", TZListPref, &PropertyValue, TimeZoneCount, &PropertyMatched);
1650 if (PropertyMatched == TRUE){
1652 PropertyMatched = FALSE;
1657 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1659 if (FirstToken == TRUE){
1661 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1666 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1674 TZList->insert(std::make_pair(*TimeZoneCount, PropertySeg2));
1676 // Add the name token data.
1678 if (!PropertyTokens.IsEmpty()){
1680 TZListTokens->insert(std::make_pair(*TimeZoneCount, PropertyTokens));
1687 void ContactDataObject::ProcessAddress(wxString PropertySeg1, wxString PropertySeg2, int *AddressCount){
1689 size_t intPropertyLen = PropertySeg1.Len();
1690 std::map<int, int> SplitPoints;
1691 std::map<int, int> SplitLength;
1692 std::map<int, int>::iterator SLiter;
1693 wxString PropertyData;
1694 wxString PropertyName;
1695 wxString PropertyValue;
1696 wxString PropertyTokens;
1697 wxString AddressLabel;
1698 wxString AddressLang;
1699 wxString AddressAltID;
1700 wxString AddressPID;
1701 wxString AddressTokens;
1702 wxString AddressGeo;
1703 wxString AddressTimezone;
1704 wxString AddressType;
1705 wxString AddressMediatype;
1706 wxString AddressPOBox;
1707 wxString AddressExtended;
1708 wxString AddressStreet;
1709 wxString AddressLocality;
1710 wxString AddressCity;
1711 wxString AddressRegion;
1712 wxString AddressPostalCode;
1713 wxString AddressCountry;
1714 bool FirstToken = TRUE;
1715 int intSplitsFound = 0;
1716 int intSplitSize = 0;
1717 int intPrevValue = 5;
1721 bool PropertyMatched = FALSE;
1723 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1727 PropertyType PropType = PROPERTY_NONE;
1729 // Look for type before continuing.
1731 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1735 std::map<int, wxString> *AddressList = NULL;
1736 std::map<int, wxString> *AddressListTown = NULL;
1737 std::map<int, wxString> *AddressListCounty = NULL;
1738 std::map<int, wxString> *AddressListPostCode = NULL;
1739 std::map<int, wxString> *AddressListCountry = NULL;
1740 std::map<int, wxString> *AddressListLabel = NULL;
1741 std::map<int, wxString> *AddressListLang = NULL;
1742 std::map<int, wxString> *AddressListAltID = NULL;
1743 std::map<int, wxString> *AddressListPID = NULL;
1744 std::map<int, wxString> *AddressListTokens = NULL;
1745 std::map<int, wxString> *AddressListGeo = NULL;
1746 std::map<int, wxString> *AddressListTimezone = NULL;
1747 std::map<int, wxString> *AddressListType = NULL;
1748 std::map<int, wxString> *AddressListMediatype = NULL;
1749 std::map<int, int> *AddressListPref = NULL;
1753 AddressList = &GeneralAddressList;
1754 AddressListTown = &GeneralAddressListTown;
1755 AddressListCounty = &GeneralAddressListCounty;
1756 AddressListPostCode = &GeneralAddressListPostCode;
1757 AddressListCountry = &GeneralAddressListCountry;
1758 AddressListLabel = &GeneralAddressListLabel;
1759 AddressListLang = &GeneralAddressListLang;
1760 AddressListAltID = &GeneralAddressListAltID;
1761 AddressListPID = &GeneralAddressListPID;
1762 AddressListTokens = &GeneralAddressListTokens;
1763 AddressListGeo = &GeneralAddressListGeo;
1764 AddressListTimezone = &GeneralAddressListTimezone;
1765 AddressListType = &GeneralAddressListType;
1766 AddressListMediatype = &GeneralAddressListMediatype;
1767 AddressListPref = &GeneralAddressListPref;
1770 AddressList = &HomeAddressList;
1771 AddressListTown = &HomeAddressListTown;
1772 AddressListCounty = &HomeAddressListCounty;
1773 AddressListPostCode = &HomeAddressListPostCode;
1774 AddressListCountry = &HomeAddressListCountry;
1775 AddressListLabel = &HomeAddressListLabel;
1776 AddressListLang = &HomeAddressListLang;
1777 AddressListAltID = &HomeAddressListAltID;
1778 AddressListPID = &HomeAddressListPID;
1779 AddressListTokens = &HomeAddressListTokens;
1780 AddressListGeo = &HomeAddressListGeo;
1781 AddressListTimezone = &HomeAddressListTimezone;
1782 AddressListType = &HomeAddressListType;
1783 AddressListMediatype = &HomeAddressListMediatype;
1784 AddressListPref = &HomeAddressListPref;
1787 AddressList = &BusinessAddressList;
1788 AddressListTown = &BusinessAddressListTown;
1789 AddressListCounty = &BusinessAddressListCounty;
1790 AddressListPostCode = &BusinessAddressListPostCode;
1791 AddressListCountry = &BusinessAddressListCountry;
1792 AddressListLabel = &BusinessAddressListLabel;
1793 AddressListLang = &BusinessAddressListLang;
1794 AddressListAltID = &BusinessAddressListAltID;
1795 AddressListPID = &BusinessAddressListPID;
1796 AddressListTokens = &BusinessAddressListTokens;
1797 AddressListGeo = &BusinessAddressListGeo;
1798 AddressListTimezone = &BusinessAddressListTimezone;
1799 AddressListType = &BusinessAddressListType;
1800 AddressListMediatype = &BusinessAddressListMediatype;
1801 AddressListPref = &BusinessAddressListPref;
1807 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1808 intiter != SplitPoints.end(); ++intiter){
1810 SLiter = SplitLength.find(intiter->first);
1812 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1814 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1815 PropertyName = PropertyElement.GetNextToken();
1816 PropertyValue = PropertyElement.GetNextToken();
1818 intPrevValue = intiter->second;
1820 CaptureString(&PropertyValue, FALSE);
1822 // Process properties.
1824 ProcessStringValue(&PropertyName, "LABEL", AddressListLabel, &PropertyValue, AddressCount, &PropertyMatched);
1825 ProcessStringValue(&PropertyName, "LANGUAGE", AddressListLang, &PropertyValue, AddressCount, &PropertyMatched);
1826 ProcessStringValue(&PropertyName, "ALTID", AddressListAltID, &PropertyValue, AddressCount, &PropertyMatched);
1827 ProcessStringValue(&PropertyName, "PID", AddressListPID, &PropertyValue, AddressCount, &PropertyMatched);
1828 ProcessStringValue(&PropertyName, "GEO", AddressListGeo, &PropertyValue, AddressCount, &PropertyMatched);
1829 ProcessStringValue(&PropertyName, "TZ", AddressListTimezone, &PropertyValue, AddressCount, &PropertyMatched);
1830 ProcessStringValue(&PropertyName, "MEDIATYPE", AddressListMediatype, &PropertyValue, AddressCount, &PropertyMatched);
1831 ProcessIntegerValue(&PropertyName, "PREF", AddressListPref, &PropertyValue, AddressCount, &PropertyMatched);
1833 if (PropertyMatched == TRUE){
1835 PropertyMatched = FALSE;
1840 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1842 if (FirstToken == TRUE){
1844 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1849 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1857 // Split the address.
1859 //std::map<int, int>::iterator SLiter;
1860 intPropertyLen = PropertySeg2.Len();
1861 SplitPoints.clear();
1862 SplitLength.clear();
1867 for (int i = 0; i <= intPropertyLen; i++){
1871 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
1874 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
1876 if (intSplitsFound == 6){
1878 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1883 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1893 // Split the data into several parts.
1895 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1896 intiter != SplitPoints.end(); ++intiter){
1898 if (intiter->first == 1){
1900 // Deal with PO Box.
1902 SLiter = SplitLength.find(1);
1904 AddressPOBox = PropertySeg2.Mid(0, SLiter->second);
1905 intPrevValue = intiter->second;
1907 } else if (intiter->first == 2){
1909 // Deal with extended address.
1911 SLiter = SplitLength.find(2);
1913 AddressExtended = PropertySeg2.Mid(intPrevValue, SLiter->second);
1914 intPrevValue = intiter->second;
1916 } else if (intiter->first == 3){
1918 // Deal with street address.
1920 SLiter = SplitLength.find(3);
1922 AddressStreet = PropertySeg2.Mid(intPrevValue, SLiter->second);
1923 intPrevValue = intiter->second;
1925 } else if (intiter->first == 4){
1927 // Deal with locality
1929 SLiter = SplitLength.find(4);
1931 AddressLocality = PropertySeg2.Mid(intPrevValue, SLiter->second);
1932 intPrevValue = intiter->second;
1934 } else if (intiter->first == 5){
1936 // Deal with region.
1938 SLiter = SplitLength.find(5);
1940 AddressRegion = PropertySeg2.Mid(intPrevValue, SLiter->second);
1941 intPrevValue = intiter->second;
1944 } else if (intiter->first == 6){
1946 // Deal with post code.
1948 SLiter = SplitLength.find(6);
1950 AddressPostalCode = PropertySeg2.Mid(intPrevValue, SLiter->second);
1951 intPrevValue = intiter->second;
1953 // Deal with country.
1955 AddressCountry = PropertySeg2.Mid(intPrevValue, wxString::npos);
1963 // Add the data to the General/Home/Work address variables.
1965 CaptureString(&AddressStreet, FALSE);
1966 CaptureString(&AddressLocality, FALSE);
1967 CaptureString(&AddressRegion, FALSE);
1968 CaptureString(&AddressPostalCode, FALSE);
1969 CaptureString(&AddressCountry, FALSE);
1971 if (!PropertyTokens.IsEmpty()){
1973 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
1977 AddressListCountry->insert(std::make_pair(*AddressCount, AddressCountry));
1978 AddressList->insert(std::make_pair(*AddressCount, AddressStreet));
1979 AddressListTown->insert(std::make_pair(*AddressCount, AddressLocality));
1980 AddressListCounty->insert(std::make_pair(*AddressCount, AddressRegion));
1981 AddressListPostCode->insert(std::make_pair(*AddressCount, AddressPostalCode));
1985 AddressListType->insert(std::make_pair(*AddressCount, wxT("")));
1988 AddressListType->insert(std::make_pair(*AddressCount, wxT("home")));
1991 AddressListType->insert(std::make_pair(*AddressCount, wxT("work")));
1995 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
1999 void ContactDataObject::ProcessEmail(wxString PropertySeg1, wxString PropertySeg2, int *EmailCount){
2001 std::map<int, int> SplitPoints;
2002 std::map<int, int> SplitLength;
2004 int intPrevValue = 7;
2007 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2011 PropertyType PropType = PROPERTY_NONE;
2013 // Look for type before continuing.
2015 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2017 std::map<int, wxString> *EmailList = NULL;
2018 std::map<int, wxString> *EmailListType = NULL;
2019 std::map<int, wxString> *EmailListAltID = NULL;
2020 std::map<int, wxString> *EmailListPID = NULL;
2021 std::map<int, wxString> *EmailListTokens = NULL;
2022 std::map<int, int> *EmailListPref = NULL;
2026 EmailList = &GeneralEmailList;
2027 EmailListType = &GeneralEmailListType;
2028 EmailListAltID = &GeneralEmailListAltID;
2029 EmailListPID = &GeneralEmailListPID;
2030 EmailListTokens = &GeneralEmailListTokens;
2031 EmailListPref = &GeneralEmailListPref;
2034 EmailList = &HomeEmailList;
2035 EmailListType = &HomeEmailListType;
2036 EmailListAltID = &HomeEmailListAltID;
2037 EmailListPID = &HomeEmailListPID;
2038 EmailListTokens = &HomeEmailListTokens;
2039 EmailListPref = &HomeEmailListPref;
2042 EmailList = &BusinessEmailList;
2043 EmailListType = &BusinessEmailListType;
2044 EmailListAltID = &BusinessEmailListAltID;
2045 EmailListPID = &BusinessEmailListPID;
2046 EmailListTokens = &BusinessEmailListTokens;
2047 EmailListPref = &BusinessEmailListPref;
2053 std::map<int,int>::iterator SLiter;
2054 wxString PropertyData;
2055 wxString PropertyName;
2056 wxString PropertyValue;
2057 wxString PropertyTokens;
2058 bool FirstToken = TRUE;
2059 bool PropertyMatched = FALSE;
2061 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2062 intiter != SplitPoints.end(); ++intiter){
2064 SLiter = SplitLength.find(intiter->first);
2066 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2068 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2069 PropertyName = PropertyElement.GetNextToken();
2070 PropertyValue = PropertyElement.GetNextToken();
2072 intPrevValue = intiter->second;
2074 CaptureString(&PropertyValue, FALSE);
2076 // Process properties.
2078 ProcessStringValue(&PropertyName, "ALTID", EmailListAltID, &PropertyValue, EmailCount, &PropertyMatched);
2079 ProcessStringValue(&PropertyName, "PID", EmailListPID, &PropertyValue, EmailCount, &PropertyMatched);
2080 ProcessIntegerValue(&PropertyName, "PREF", EmailListPref, &PropertyValue, EmailCount, &PropertyMatched);
2082 if (PropertyMatched == TRUE){
2084 PropertyMatched = FALSE;
2089 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2091 if (FirstToken == TRUE){
2093 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2098 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2106 EmailList->insert(std::make_pair(*EmailCount, PropertySeg2));
2108 // Add the name token data.
2110 if (!PropertyTokens.IsEmpty()){
2112 EmailListTokens->insert(std::make_pair(*EmailCount, PropertyTokens));
2119 void ContactDataObject::ProcessIM(wxString PropertySeg1, wxString PropertySeg2, int *IMCount){
2121 std::map<int, int> SplitPoints;
2122 std::map<int, int> SplitLength;
2124 int intPrevValue = 6;
2127 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2131 PropertyType PropType = PROPERTY_NONE;
2133 // Look for type before continuing.
2135 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2137 std::map<int, wxString> *IMList = NULL;
2138 std::map<int, wxString> *IMListType = NULL;
2139 std::map<int, wxString> *IMListAltID = NULL;
2140 std::map<int, wxString> *IMListPID = NULL;
2141 std::map<int, wxString> *IMListTokens = NULL;
2142 std::map<int, wxString> *IMListMediatype = NULL;
2143 std::map<int, int> *IMListPref = NULL;
2147 IMList = &GeneralIMList;
2148 IMListType = &GeneralIMListType;
2149 IMListAltID = &GeneralIMListAltID;
2150 IMListPID = &GeneralIMListPID;
2151 IMListTokens = &GeneralIMListTokens;
2152 IMListMediatype = &GeneralIMListMediatype;
2153 IMListPref = &GeneralIMListPref;
2156 IMList = &HomeIMList;
2157 IMListType = &HomeIMListType;
2158 IMListAltID = &HomeIMListAltID;
2159 IMListPID = &HomeIMListPID;
2160 IMListTokens = &HomeIMListTokens;
2161 IMListMediatype = &HomeIMListMediatype;
2162 IMListPref = &HomeIMListPref;
2165 IMList = &BusinessIMList;
2166 IMListType = &BusinessIMListType;
2167 IMListAltID = &BusinessIMListAltID;
2168 IMListPID = &BusinessIMListPID;
2169 IMListTokens = &BusinessIMListTokens;
2170 IMListMediatype = &BusinessIMListMediatype;
2171 IMListPref = &BusinessIMListPref;
2177 std::map<int,int>::iterator SLiter;
2178 wxString PropertyData;
2179 wxString PropertyName;
2180 wxString PropertyValue;
2181 wxString PropertyTokens;
2182 bool FirstToken = TRUE;
2183 bool PropertyMatched = FALSE;
2185 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2186 intiter != SplitPoints.end(); ++intiter){
2188 SLiter = SplitLength.find(intiter->first);
2190 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2192 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2193 PropertyName = PropertyElement.GetNextToken();
2194 PropertyValue = PropertyElement.GetNextToken();
2196 intPrevValue = intiter->second;
2198 CaptureString(&PropertyValue, FALSE);
2200 ProcessStringValue(&PropertyName, "ALTID", IMListAltID, &PropertyValue, IMCount, &PropertyMatched);
2201 ProcessStringValue(&PropertyName, "PID", IMListPID, &PropertyValue, IMCount, &PropertyMatched);
2202 ProcessStringValue(&PropertyName, "MEDIATYPE", IMListMediatype, &PropertyValue, IMCount, &PropertyMatched);
2203 ProcessIntegerValue(&PropertyName, "PREF", IMListPref, &PropertyValue, IMCount, &PropertyMatched);
2205 // Process properties.
2207 if (PropertyMatched == TRUE){
2209 PropertyMatched = FALSE;
2214 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2216 if (FirstToken == TRUE){
2218 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2223 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2231 IMList->insert(std::make_pair(*IMCount, PropertySeg2));
2233 // Add the name token data.
2235 if (!PropertyTokens.IsEmpty()){
2237 IMListTokens->insert(std::make_pair(*IMCount, PropertyTokens));
2243 void ContactDataObject::ProcessTelephone(wxString PropertySeg1, wxString PropertySeg2, int *TelephoneCount){
2245 std::map<int, int> SplitPoints;
2246 std::map<int, int> SplitLength;
2247 std::map<int, int>::iterator SLiter;
2251 PropertyType PropType = PROPERTY_NONE;
2253 // Look for type before continuing.
2256 wxString TelTypeDetail;
2257 wxString PropertyData;
2258 wxString PropertyName;
2259 wxString PropertyValue;
2260 wxString PropertyTokens;
2262 std::map<int,int> TypeSplitPoints;
2263 std::map<int,int> TypeSplitLength;
2264 std::map<int,int>::iterator TSLiter;
2266 int intSplitSize = 0;
2267 int intSplitsFound = 0;
2268 int intSplitPoint = 0;
2270 int intPrevValue = 5;
2272 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2276 // Look for type before continuing.
2278 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2279 intiter != SplitPoints.end(); ++intiter){
2281 SLiter = SplitLength.find(intiter->first);
2283 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2285 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2286 PropertyName = PropertyElement.GetNextToken();
2287 PropertyValue = PropertyElement.GetNextToken();
2289 intPrevValue = intiter->second;
2291 if (PropertyName == wxT("TYPE")){
2293 // Process each value in type and translate each
2296 // Strip out the quotes if they are there.
2298 size_t intPropertyValueLen = PropertyValue.Len();
2300 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2302 PropertyValue.Trim();
2303 PropertyValue.RemoveLast();
2307 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2309 PropertyValue.Remove(0, 1);
2313 TelTypeDetail = PropertyValue;
2319 for (int i = 0; i <= intPropertyValueLen; i++){
2323 if (PropertyValue.Mid(i, 1) == wxT(",") && PropertyValue.Mid((i - 1), 1) != wxT("\\")){
2325 if (intSplitsFound == 0){
2327 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2328 TypeSplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2332 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2333 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2346 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2347 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2349 int intTypeSeek = 0;
2351 for (std::map<int, int>::iterator typeiter = TypeSplitPoints.begin();
2352 typeiter != TypeSplitPoints.end(); ++typeiter){
2354 wxString TypePropertyName;
2356 TSLiter = TypeSplitLength.find(typeiter->first);
2358 TypePropertyName = PropertyValue.Mid(typeiter->second, TSLiter->second);
2360 if (intTypeSeek == 0){
2365 TelTypeUI.Append(wxT(","));
2369 if (TypePropertyName == wxT("home")){
2371 PropType = PROPERTY_HOME;
2373 } else if (TypePropertyName == wxT("work")){
2375 PropType = PROPERTY_WORK;
2380 if (TypePropertyName == wxT("text")){
2382 TelTypeUI.Append(_("text"));
2385 } else if (TypePropertyName == wxT("voice")){
2387 TelTypeUI.Append(_("voice"));
2390 } else if (TypePropertyName == wxT("fax")){
2392 TelTypeUI.Append(_("fax"));
2395 } else if (TypePropertyName == wxT("cell")){
2397 TelTypeUI.Append(_("mobile"));
2400 } else if (TypePropertyName == wxT("video")){
2402 TelTypeUI.Append(_("video"));
2405 } else if (TypePropertyName == wxT("pager")){
2407 TelTypeUI.Append(_("pager"));
2410 } else if (TypePropertyName == wxT("textphone")){
2412 TelTypeUI.Append(_("textphone"));
2423 std::map<int, wxString> *TelephoneList = NULL;
2424 std::map<int, wxString> *TelephoneListType = NULL;
2425 std::map<int, wxString> *TelephoneListAltID = NULL;
2426 std::map<int, wxString> *TelephoneListPID = NULL;
2427 std::map<int, wxString> *TelephoneListTokens = NULL;
2428 std::map<int, wxString> *TelephoneListTypeInfo = NULL;
2429 std::map<int, int> *TelephoneListPref = NULL;
2433 TelephoneList = &GeneralTelephoneList;
2434 TelephoneListType = &GeneralTelephoneListType;
2435 TelephoneListAltID = &GeneralTelephoneListAltID;
2436 TelephoneListPID = &GeneralTelephoneListPID;
2437 TelephoneListTokens = &GeneralTelephoneListTokens;
2438 TelephoneListTypeInfo = &GeneralTelephoneListTypeInfo;
2439 TelephoneListPref = &GeneralTelephoneListPref;
2442 TelephoneList = &HomeTelephoneList;
2443 TelephoneListType = &HomeTelephoneListType;
2444 TelephoneListAltID = &HomeTelephoneListAltID;
2445 TelephoneListPID = &HomeTelephoneListPID;
2446 TelephoneListTokens = &HomeTelephoneListTokens;
2447 TelephoneListTypeInfo = &HomeTelephoneListTypeInfo;
2448 TelephoneListPref = &HomeTelephoneListPref;
2451 TelephoneList = &BusinessTelephoneList;
2452 TelephoneListType = &BusinessTelephoneListType;
2453 TelephoneListAltID = &BusinessTelephoneListAltID;
2454 TelephoneListPID = &BusinessTelephoneListPID;
2455 TelephoneListTokens = &BusinessTelephoneListTokens;
2456 TelephoneListTypeInfo = &BusinessTelephoneListTypeInfo;
2457 TelephoneListPref = &BusinessTelephoneListPref;
2461 // Process the properties.
2463 bool FirstToken = TRUE;
2466 SplitPoints.clear();
2467 SplitLength.clear();
2469 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2473 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2474 intiter != SplitPoints.end(); ++intiter){
2476 SLiter = SplitLength.find(intiter->first);
2478 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2480 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2481 PropertyName = PropertyElement.GetNextToken();
2482 PropertyValue = PropertyElement.GetNextToken();
2484 intPrevValue = intiter->second;
2486 CaptureString(&PropertyValue, FALSE);
2488 // Process properties.
2490 if (PropertyName == wxT("ALTID")){
2492 TelephoneListAltID->erase(*TelephoneCount);
2493 TelephoneListAltID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2495 } else if (PropertyName == wxT("PID")){
2497 TelephoneListPID->erase(*TelephoneCount);
2498 TelephoneListPID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2500 } else if (PropertyName == wxT("PREF")){
2502 ProcessIntegerValue(TelephoneListPref, &PropertyValue, TelephoneCount);
2506 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2508 if (FirstToken == TRUE){
2510 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2515 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2525 TelephoneList->insert(std::make_pair(*TelephoneCount, PropertySeg2));
2526 TelephoneListTypeInfo->insert(std::make_pair(*TelephoneCount, TelTypeUI));
2528 // Add the name token data.
2530 if (!PropertyTokens.IsEmpty()){
2532 TelephoneListTokens->insert(std::make_pair(*TelephoneCount, PropertyTokens));
2538 void ContactDataObject::ProcessLanguage(wxString PropertySeg1, wxString PropertySeg2, int *LanguageCount){
2540 std::map<int, int> SplitPoints;
2541 std::map<int, int> SplitLength;
2543 int intPrevValue = 6;
2546 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2550 PropertyType PropType = PROPERTY_NONE;
2552 // Look for type before continuing.
2554 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2556 std::map<int, wxString> *LanguageList = NULL;
2557 std::map<int, wxString> *LanguageListType = NULL;
2558 std::map<int, wxString> *LanguageListAltID = NULL;
2559 std::map<int, wxString> *LanguageListPID = NULL;
2560 std::map<int, wxString> *LanguageListTokens = NULL;
2561 std::map<int, int> *LanguageListPref = NULL;
2565 LanguageList = &GeneralLanguageList;
2566 LanguageListType = &GeneralLanguageListType;
2567 LanguageListAltID = &GeneralLanguageListAltID;
2568 LanguageListPID = &GeneralLanguageListPID;
2569 LanguageListTokens = &GeneralLanguageListTokens;
2570 LanguageListPref = &GeneralLanguageListPref;
2573 LanguageList = &HomeLanguageList;
2574 LanguageListType = &HomeLanguageListType;
2575 LanguageListAltID = &HomeLanguageListAltID;
2576 LanguageListPID = &HomeLanguageListPID;
2577 LanguageListTokens = &HomeLanguageListTokens;
2578 LanguageListPref = &HomeLanguageListPref;
2581 LanguageList = &BusinessLanguageList;
2582 LanguageListType = &BusinessLanguageListType;
2583 LanguageListAltID = &BusinessLanguageListAltID;
2584 LanguageListPID = &BusinessLanguageListPID;
2585 LanguageListTokens = &BusinessLanguageListTokens;
2586 LanguageListPref = &BusinessLanguageListPref;
2592 std::map<int,int>::iterator SLiter;
2593 wxString PropertyData;
2594 wxString PropertyName;
2595 wxString PropertyValue;
2596 wxString PropertyTokens;
2597 bool FirstToken = TRUE;
2599 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2600 intiter != SplitPoints.end(); ++intiter){
2602 SLiter = SplitLength.find(intiter->first);
2604 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2606 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2607 PropertyName = PropertyElement.GetNextToken();
2608 PropertyValue = PropertyElement.GetNextToken();
2610 intPrevValue = intiter->second;
2612 CaptureString(&PropertyValue, FALSE);
2614 // Process properties.
2616 if (PropertyName == wxT("ALTID")){
2618 LanguageListAltID->erase(*LanguageCount);
2619 LanguageListAltID->insert(std::make_pair(*LanguageCount, PropertyValue));
2621 } else if (PropertyName == wxT("PID")){
2623 LanguageListPID->erase(*LanguageCount);
2624 LanguageListPID->insert(std::make_pair(*LanguageCount, PropertyValue));
2626 } else if (PropertyName == wxT("PREF")){
2628 ProcessIntegerValue(LanguageListPref, &PropertyValue, LanguageCount);
2632 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2634 if (FirstToken == TRUE){
2636 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2641 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2651 LanguageList->insert(std::make_pair(*LanguageCount, PropertySeg2));
2653 // Add the name token data.
2655 if (!PropertyTokens.IsEmpty()){
2657 LanguageListTokens->insert(std::make_pair(*LanguageCount, PropertyTokens));
2663 void ContactDataObject::ProcessGeographic(wxString PropertySeg1, wxString PropertySeg2, int *GeographicCount){
2665 std::map<int, int> SplitPoints;
2666 std::map<int, int> SplitLength;
2668 int intPrevValue = 5;
2671 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2675 PropertyType PropType = PROPERTY_NONE;
2677 // Look for type before continuing.
2679 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2681 std::map<int, wxString> *GeopositionList = NULL;
2682 std::map<int, wxString> *GeopositionListType = NULL;
2683 std::map<int, wxString> *GeopositionListAltID = NULL;
2684 std::map<int, wxString> *GeopositionListPID = NULL;
2685 std::map<int, wxString> *GeopositionListTokens = NULL;
2686 std::map<int, wxString> *GeopositionListMediatype = NULL;
2687 std::map<int, int> *GeopositionListPref = NULL;
2691 GeopositionList = &GeneralGeographyList;
2692 GeopositionListType = &GeneralGeographyListType;
2693 GeopositionListAltID = &GeneralGeographyListAltID;
2694 GeopositionListPID = &GeneralGeographyListPID;
2695 GeopositionListTokens = &GeneralGeographyListTokens;
2696 GeopositionListMediatype = &GeneralGeographyListMediatype;
2697 GeopositionListPref = &GeneralGeographyListPref;
2700 GeopositionList = &HomeGeographyList;
2701 GeopositionListType = &HomeGeographyListType;
2702 GeopositionListAltID = &HomeGeographyListAltID;
2703 GeopositionListPID = &HomeGeographyListPID;
2704 GeopositionListTokens = &HomeGeographyListTokens;
2705 GeopositionListMediatype = &HomeGeographyListMediatype;
2706 GeopositionListPref = &HomeGeographyListPref;
2709 GeopositionList = &BusinessGeographyList;
2710 GeopositionListType = &BusinessGeographyListType;
2711 GeopositionListAltID = &BusinessGeographyListAltID;
2712 GeopositionListPID = &BusinessGeographyListPID;
2713 GeopositionListTokens = &BusinessGeographyListTokens;
2714 GeopositionListMediatype = &BusinessGeographyListMediatype;
2715 GeopositionListPref = &BusinessGeographyListPref;
2721 std::map<int,int>::iterator SLiter;
2722 wxString PropertyData;
2723 wxString PropertyName;
2724 wxString PropertyValue;
2725 wxString PropertyTokens;
2726 bool FirstToken = TRUE;
2728 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2729 intiter != SplitPoints.end(); ++intiter){
2731 SLiter = SplitLength.find(intiter->first);
2733 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2735 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2736 PropertyName = PropertyElement.GetNextToken();
2737 PropertyValue = PropertyElement.GetNextToken();
2739 intPrevValue = intiter->second;
2741 CaptureString(&PropertyValue, FALSE);
2743 // Process properties.
2745 if (PropertyName == wxT("ALTID")){
2747 GeopositionListAltID->erase(*GeographicCount);
2748 GeopositionListAltID->insert(std::make_pair(*GeographicCount, PropertyValue));
2750 } else if (PropertyName == wxT("PID")){
2752 GeopositionListPID->erase(*GeographicCount);
2753 GeopositionListPID->insert(std::make_pair(*GeographicCount, PropertyValue));
2755 } else if (PropertyName == wxT("MEDIATYPE")){
2757 GeopositionListMediatype->erase(*GeographicCount);
2758 GeopositionListMediatype->insert(std::make_pair(*GeographicCount, PropertyValue));
2760 } else if (PropertyName == wxT("PREF")){
2762 ProcessIntegerValue(GeopositionListPref, &PropertyValue, GeographicCount);
2766 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2768 if (FirstToken == TRUE){
2770 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2775 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2785 GeopositionList->insert(std::make_pair(*GeographicCount, PropertySeg2));
2787 // Add the name token data.
2789 if (!PropertyTokens.IsEmpty()){
2791 GeopositionListTokens->insert(std::make_pair(*GeographicCount, PropertyTokens));
2797 void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertySeg2, int *RelatedCount){
2799 size_t intPropertyLen = PropertySeg1.Len();
2800 std::map<int, int> SplitPoints;
2801 std::map<int, int> SplitLength;
2802 std::map<int, int>::iterator SLiter;
2803 wxString PropertyData;
2804 wxString PropertyName;
2805 wxString PropertyValue;
2806 wxString PropertyTokens;
2807 wxString RelatedType;
2808 wxString RelatedTypeOriginal;
2809 wxString RelatedName;
2810 bool FirstToken = TRUE;
2811 int intSplitsFound = 0;
2812 int intSplitSize = 0;
2813 int intPrevValue = 9;
2817 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2821 // Look for type before continuing.
2823 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2824 intiter != SplitPoints.end(); ++intiter){
2826 SLiter = SplitLength.find(intiter->first);
2828 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2830 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2831 PropertyName = PropertyElement.GetNextToken();
2832 PropertyValue = PropertyElement.GetNextToken();
2834 intPrevValue = intiter->second;
2838 RelatedTypeOriginal = PropertyValue;
2840 if (PropertyName == wxT("TYPE")){
2842 if (PropertyValue == wxT("contact")){
2844 RelatedType = _("Contact");
2846 } else if (PropertyValue == wxT("acquaintance")){
2848 RelatedType = _("Acquaintance");
2850 } else if (PropertyValue == wxT("friend")){
2852 RelatedType = _("Friend");
2854 } else if (PropertyValue == wxT("met")){
2856 RelatedType = _("Met");
2858 } else if (PropertyValue == wxT("co-worker")){
2860 RelatedType = _("Co-worker");
2862 } else if (PropertyValue == wxT("colleague")){
2864 RelatedType = _("Colleague");
2866 } else if (PropertyValue == wxT("co-resident")){
2868 RelatedType = _("Co-resident");
2870 } else if (PropertyValue == wxT("neighbor")){
2872 RelatedType = _("Neighbour");
2874 } else if (PropertyValue == wxT("child")){
2876 RelatedType = _("Child");
2878 } else if (PropertyValue == wxT("parent")){
2880 RelatedType = _("Parent");
2882 } else if (PropertyValue == wxT("sibling")){
2884 RelatedType = _("Sibling");
2886 } else if (PropertyValue == wxT("spouse")){
2888 RelatedType = _("Spouse");
2890 } else if (PropertyValue == wxT("kin")){
2892 RelatedType = _("Kin");
2894 } else if (PropertyValue == wxT("muse")){
2896 RelatedType = _("Muse");
2898 } else if (PropertyValue == wxT("crush")){
2900 RelatedType = _("Crush");
2902 } else if (PropertyValue == wxT("date")){
2904 RelatedType = _("Date");
2906 } else if (PropertyValue == wxT("sweetheart")){
2908 RelatedType = _("Sweetheart");
2910 } else if (PropertyValue == wxT("me")){
2912 RelatedType = _("Me");
2914 } else if (PropertyValue == wxT("agent")){
2916 RelatedType = _("Agent");
2918 } else if (PropertyValue == wxT("emergency")){
2920 RelatedType = _("Emergency");
2924 RelatedType = PropertyValue;
2934 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2935 intiter != SplitPoints.end(); ++intiter){
2937 SLiter = SplitLength.find(intiter->first);
2939 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2941 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2942 PropertyName = PropertyElement.GetNextToken();
2943 PropertyValue = PropertyElement.GetNextToken();
2945 intPrevValue = intiter->second;
2947 // Process properties.
2949 size_t intPropertyValueLen = PropertyValue.Len();
2951 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2953 PropertyValue.Trim();
2954 PropertyValue.RemoveLast();
2958 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2960 PropertyValue.Remove(0, 1);
2964 CaptureString(&PropertyValue, FALSE);
2966 if (PropertyName == wxT("ALTID")){
2968 GeneralRelatedListAltID.erase(*RelatedCount);
2969 GeneralRelatedListAltID.insert(std::make_pair(*RelatedCount, PropertyValue));
2971 } else if (PropertyName == wxT("PID")){
2973 GeneralRelatedListPID.erase(*RelatedCount);
2974 GeneralRelatedListPID.insert(std::make_pair(*RelatedCount, PropertyValue));
2976 } else if (PropertyName == wxT("PREF")){
2978 int PriorityNumber = 0;
2979 bool ValidNumber = TRUE;
2982 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2985 catch(std::invalid_argument &e){
2986 ValidNumber = FALSE;
2989 if (ValidNumber == TRUE){
2991 GeneralRelatedListPref.erase(*RelatedCount);
2992 GeneralRelatedListPref.insert(std::make_pair(*RelatedCount, PriorityNumber));
2996 } else if (PropertyName == wxT("LANGUAGE")){
2998 ProcessIntegerValue(&GeneralRelatedListPref, &PropertyValue, RelatedCount);
3000 } else if (PropertyName != wxT("TYPE")) {
3002 // Something else we don't know about so append
3003 // to the tokens variable.
3005 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3007 if (FirstToken == TRUE){
3009 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3014 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3024 // Add the data to the General/Home/Work address variables.
3026 GeneralRelatedList.erase(*RelatedCount);
3027 GeneralRelatedListRelType.erase(*RelatedCount);
3028 GeneralRelatedListType.erase(*RelatedCount);
3029 GeneralRelatedListTokens.erase(*RelatedCount);
3030 GeneralRelatedList.insert(std::make_pair(*RelatedCount, PropertySeg2));
3031 GeneralRelatedListRelType.insert(std::make_pair(*RelatedCount, RelatedType));
3032 GeneralRelatedListType.insert(std::make_pair(*RelatedCount, RelatedType));
3033 GeneralRelatedListTokens.insert(std::make_pair(*RelatedCount, PropertyTokens));
3037 void ContactDataObject::ProcessURL(wxString PropertySeg1, wxString PropertySeg2, int *URLCount){
3039 std::map<int, int> SplitPoints;
3040 std::map<int, int> SplitLength;
3041 std::map<int, int>::iterator SLiter;
3042 wxString PropertyData;
3043 wxString PropertyName;
3044 wxString PropertyValue;
3045 wxString PropertyTokens;
3046 bool FirstToken = TRUE;
3047 int intPrevValue = 5;
3052 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3056 PropertyType PropType = PROPERTY_NONE;
3058 // Look for type before continuing.
3060 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3062 // Setup the pointers.
3064 std::map<int, wxString> *WebsiteList = NULL;
3065 std::map<int, wxString> *WebsiteListAltID = NULL;
3066 std::map<int, wxString> *WebsiteListPID = NULL;
3067 std::map<int, wxString> *WebsiteListType = NULL;
3068 std::map<int, wxString> *WebsiteListTokens = NULL;
3069 std::map<int, wxString> *WebsiteListMediatype = NULL;
3070 std::map<int, int> *WebsiteListPref = NULL;
3072 // Setup blank lines for later on.
3076 WebsiteList = &GeneralWebsiteList;
3077 WebsiteListType = &GeneralWebsiteListType;
3078 WebsiteListAltID = &GeneralWebsiteListAltID;
3079 WebsiteListPID = &GeneralWebsiteListPID;
3080 WebsiteListTokens = &GeneralWebsiteListTokens;
3081 WebsiteListMediatype = &GeneralWebsiteListMediatype;
3082 WebsiteListPref = &GeneralWebsiteListPref;
3085 WebsiteList = &HomeWebsiteList;
3086 WebsiteListType = &HomeWebsiteListType;
3087 WebsiteListAltID = &HomeWebsiteListAltID;
3088 WebsiteListPID = &HomeWebsiteListPID;
3089 WebsiteListTokens = &HomeWebsiteListTokens;
3090 WebsiteListMediatype = &HomeWebsiteListMediatype;
3091 WebsiteListPref = &HomeWebsiteListPref;
3094 WebsiteList = &BusinessWebsiteList;
3095 WebsiteListType = &BusinessWebsiteListType;
3096 WebsiteListAltID = &BusinessWebsiteListAltID;
3097 WebsiteListPID = &BusinessWebsiteListPID;
3098 WebsiteListTokens = &BusinessWebsiteListTokens;
3099 WebsiteListMediatype = &BusinessWebsiteListMediatype;
3100 WebsiteListPref = &BusinessWebsiteListPref;
3106 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3107 intiter != SplitPoints.end(); ++intiter){
3109 SLiter = SplitLength.find(intiter->first);
3111 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3113 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3114 PropertyName = PropertyElement.GetNextToken();
3115 PropertyValue = PropertyElement.GetNextToken();
3117 intPrevValue = intiter->second;
3119 // Process properties.
3121 size_t intPropertyValueLen = PropertyValue.Len();
3123 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3125 PropertyValue.Trim();
3126 PropertyValue.RemoveLast();
3130 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3132 PropertyValue.Remove(0, 1);
3136 CaptureString(&PropertyValue, FALSE);
3138 if (PropertyName == wxT("ALTID")){
3140 WebsiteListAltID->erase(*URLCount);
3141 WebsiteListAltID->insert(std::make_pair(*URLCount, PropertyValue));
3143 } else if (PropertyName == wxT("PID")){
3145 WebsiteListPID->erase(*URLCount);
3146 WebsiteListPID->insert(std::make_pair(*URLCount, PropertyValue));
3148 } else if (PropertyName == wxT("PREF")){
3150 ProcessIntegerValue(WebsiteListPref, &PropertyValue, URLCount);
3152 } else if (PropertyName == wxT("MEDIATYPE")){
3154 WebsiteListMediatype->erase(*URLCount);
3155 WebsiteListMediatype->insert(std::make_pair(*URLCount, PropertyValue));
3159 // Something else we don't know about so append
3160 // to the tokens variable.
3162 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3164 if (FirstToken == TRUE){
3166 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3171 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3181 // Add the data to the General/Home/Work address variables.
3183 CaptureString(&PropertySeg2, FALSE);
3185 WebsiteList->insert(std::make_pair(*URLCount, PropertySeg2));
3187 if (!PropertyTokens.IsEmpty()){
3189 WebsiteListTokens->insert(std::make_pair(*URLCount, PropertyTokens));
3195 void ContactDataObject::ProcessTitle(wxString PropertySeg1, wxString PropertySeg2, int *TitleCount){
3197 std::map<int, int> SplitPoints;
3198 std::map<int, int> SplitLength;
3199 std::map<int, int>::iterator SLiter;
3200 wxString PropertyData;
3201 wxString PropertyName;
3202 wxString PropertyValue;
3203 wxString PropertyTokens;
3204 bool FirstToken = TRUE;
3205 int intPrevValue = 7;
3210 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3214 PropertyType PropType = PROPERTY_NONE;
3216 // Look for type before continuing.
3218 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3220 // Setup the pointers.
3222 std::map<int, wxString> *TitleList = NULL;
3223 std::map<int, wxString> *TitleListAltID = NULL;
3224 std::map<int, wxString> *TitleListPID = NULL;
3225 std::map<int, wxString> *TitleListType = NULL;
3226 std::map<int, wxString> *TitleListTokens = NULL;
3227 std::map<int, wxString> *TitleListLanguage = NULL;
3228 std::map<int, int> *TitleListPref = NULL;
3230 // Setup blank lines for later on.
3234 TitleList = &GeneralTitleList;
3235 TitleListType = &GeneralTitleListType;
3236 TitleListAltID = &GeneralTitleListAltID;
3237 TitleListPID = &GeneralTitleListPID;
3238 TitleListTokens = &GeneralTitleListTokens;
3239 TitleListLanguage = &GeneralTitleListLanguage;
3240 TitleListPref = &GeneralTitleListPref;
3243 TitleList = &HomeTitleList;
3244 TitleListType = &HomeTitleListType;
3245 TitleListAltID = &HomeTitleListAltID;
3246 TitleListPID = &HomeTitleListPID;
3247 TitleListTokens = &HomeTitleListTokens;
3248 TitleListLanguage = &HomeTitleListLanguage;
3249 TitleListPref = &HomeTitleListPref;
3252 TitleList = &BusinessTitleList;
3253 TitleListType = &BusinessTitleListType;
3254 TitleListAltID = &BusinessTitleListAltID;
3255 TitleListPID = &BusinessTitleListPID;
3256 TitleListTokens = &BusinessTitleListTokens;
3257 TitleListLanguage = &BusinessTitleListLanguage;
3258 TitleListPref = &BusinessTitleListPref;
3264 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3265 intiter != SplitPoints.end(); ++intiter){
3267 SLiter = SplitLength.find(intiter->first);
3269 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3271 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3272 PropertyName = PropertyElement.GetNextToken();
3273 PropertyValue = PropertyElement.GetNextToken();
3275 intPrevValue = intiter->second;
3277 // Process properties.
3279 size_t intPropertyValueLen = PropertyValue.Len();
3281 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3283 PropertyValue.Trim();
3284 PropertyValue.RemoveLast();
3288 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3290 PropertyValue.Remove(0, 1);
3294 CaptureString(&PropertyValue, FALSE);
3296 if (PropertyName == wxT("ALTID")){
3298 TitleListAltID->erase(*TitleCount);
3299 TitleListAltID->insert(std::make_pair(*TitleCount, PropertyValue));
3301 } else if (PropertyName == wxT("PID")){
3303 TitleListPID->erase(*TitleCount);
3304 TitleListPID->insert(std::make_pair(*TitleCount, PropertyValue));
3306 } else if (PropertyName == wxT("PREF")){
3308 ProcessIntegerValue(TitleListPref, &PropertyValue, TitleCount);
3310 } else if (PropertyName == wxT("LANGUAGE")){
3312 TitleListLanguage->erase(*TitleCount);
3313 TitleListLanguage->insert(std::make_pair(*TitleCount, PropertyValue));
3317 // Something else we don't know about so append
3318 // to the tokens variable.
3320 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3322 if (FirstToken == TRUE){
3324 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3329 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3339 // Add the data to the General/Home/Work address variables.
3341 CaptureString(&PropertySeg2, FALSE);
3343 TitleList->insert(std::make_pair(*TitleCount, PropertySeg2));
3345 if (!PropertyTokens.IsEmpty()){
3347 TitleListTokens->insert(std::make_pair(*TitleCount, PropertyTokens));
3353 void ContactDataObject::ProcessRole(wxString PropertySeg1, wxString PropertySeg2, int *RoleCount){
3355 std::map<int, int> SplitPoints;
3356 std::map<int, int> SplitLength;
3357 std::map<int, int>::iterator SLiter;
3358 wxString PropertyData;
3359 wxString PropertyName;
3360 wxString PropertyValue;
3361 wxString PropertyTokens;
3362 bool FirstToken = TRUE;
3363 int intPrevValue = 6;
3368 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3372 PropertyType PropType = PROPERTY_NONE;
3374 // Look for type before continuing.
3376 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3378 // Setup the pointers.
3380 std::map<int, wxString> *RoleList = NULL;
3381 std::map<int, wxString> *RoleListAltID = NULL;
3382 std::map<int, wxString> *RoleListPID = NULL;
3383 std::map<int, wxString> *RoleListType = NULL;
3384 std::map<int, wxString> *RoleListTokens = NULL;
3385 std::map<int, wxString> *RoleListLanguage = NULL;
3386 std::map<int, int> *RoleListPref = NULL;
3388 // Setup blank lines for later on.
3392 RoleList = &GeneralRoleList;
3393 RoleListType = &GeneralRoleListType;
3394 RoleListAltID = &GeneralRoleListAltID;
3395 RoleListPID = &GeneralRoleListPID;
3396 RoleListTokens = &GeneralRoleListTokens;
3397 RoleListLanguage = &GeneralRoleListLanguage;
3398 RoleListPref = &GeneralRoleListPref;
3401 RoleList = &HomeRoleList;
3402 RoleListType = &HomeRoleListType;
3403 RoleListAltID = &HomeRoleListAltID;
3404 RoleListPID = &HomeRoleListPID;
3405 RoleListTokens = &HomeRoleListTokens;
3406 RoleListLanguage = &HomeRoleListLanguage;
3407 RoleListPref = &HomeRoleListPref;
3410 RoleList = &BusinessRoleList;
3411 RoleListType = &BusinessRoleListType;
3412 RoleListAltID = &BusinessRoleListAltID;
3413 RoleListPID = &BusinessRoleListPID;
3414 RoleListTokens = &BusinessRoleListTokens;
3415 RoleListLanguage = &BusinessRoleListLanguage;
3416 RoleListPref = &BusinessRoleListPref;
3422 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3423 intiter != SplitPoints.end(); ++intiter){
3425 SLiter = SplitLength.find(intiter->first);
3427 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3429 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3430 PropertyName = PropertyElement.GetNextToken();
3431 PropertyValue = PropertyElement.GetNextToken();
3433 intPrevValue = intiter->second;
3435 // Process properties.
3437 size_t intPropertyValueLen = PropertyValue.Len();
3439 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3441 PropertyValue.Trim();
3442 PropertyValue.RemoveLast();
3446 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3448 PropertyValue.Remove(0, 1);
3452 CaptureString(&PropertyValue, FALSE);
3454 if (PropertyName == wxT("ALTID")){
3456 RoleListAltID->erase(*RoleCount);
3457 RoleListAltID->insert(std::make_pair(*RoleCount, PropertyValue));
3459 } else if (PropertyName == wxT("PID")){
3461 RoleListPID->erase(*RoleCount);
3462 RoleListPID->insert(std::make_pair(*RoleCount, PropertyValue));
3464 } else if (PropertyName == wxT("PREF")){
3466 ProcessIntegerValue(RoleListPref, &PropertyValue, RoleCount);
3468 } else if (PropertyName == wxT("LANGUAGE")){
3470 RoleListLanguage->erase(*RoleCount);
3471 RoleListLanguage->insert(std::make_pair(*RoleCount, PropertyValue));
3475 // Something else we don't know about so append
3476 // to the tokens variable.
3478 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3480 if (FirstToken == TRUE){
3482 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3487 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3497 // Add the data to the General/Home/Work address variables.
3499 CaptureString(&PropertySeg2, FALSE);
3501 RoleList->insert(std::make_pair(*RoleCount, PropertySeg2));
3503 if (!PropertyTokens.IsEmpty()){
3505 RoleListTokens->insert(std::make_pair(*RoleCount, PropertyTokens));
3511 void ContactDataObject::ProcessOrganisation(wxString PropertySeg1, wxString PropertySeg2, int *OrganisationCount){
3513 std::map<int, int> SplitPoints;
3514 std::map<int, int> SplitLength;
3515 std::map<int, int>::iterator SLiter;
3516 wxString PropertyData;
3517 wxString PropertyName;
3518 wxString PropertyValue;
3519 wxString PropertyTokens;
3520 bool FirstToken = TRUE;
3521 int intPrevValue = 5;
3526 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3530 PropertyType PropType = PROPERTY_NONE;
3532 // Look for type before continuing.
3534 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3536 // Setup the pointers.
3538 std::map<int, wxString> *OrganisationsList = NULL;
3539 std::map<int, wxString> *OrganisationsListAltID = NULL;
3540 std::map<int, wxString> *OrganisationsListPID = NULL;
3541 std::map<int, wxString> *OrganisationsListType = NULL;
3542 std::map<int, wxString> *OrganisationsListTokens = NULL;
3543 std::map<int, wxString> *OrganisationsListLanguage = NULL;
3544 std::map<int, wxString> *OrganisationsListSortAs = NULL;
3545 std::map<int, int> *OrganisationsListPref = NULL;
3547 // Setup blank lines for later on.
3551 OrganisationsList = &GeneralOrganisationsList;
3552 OrganisationsListType = &GeneralOrganisationsListType;
3553 OrganisationsListAltID = &GeneralOrganisationsListAltID;
3554 OrganisationsListPID = &GeneralOrganisationsListPID;
3555 OrganisationsListTokens = &GeneralOrganisationsListTokens;
3556 OrganisationsListLanguage = &GeneralOrganisationsListLanguage;
3557 OrganisationsListSortAs = &GeneralOrganisationsListSortAs;
3558 OrganisationsListPref = &GeneralOrganisationsListPref;
3561 OrganisationsList = &HomeOrganisationsList;
3562 OrganisationsListType = &HomeOrganisationsListType;
3563 OrganisationsListAltID = &HomeOrganisationsListAltID;
3564 OrganisationsListPID = &HomeOrganisationsListPID;
3565 OrganisationsListTokens = &HomeOrganisationsListTokens;
3566 OrganisationsListLanguage = &HomeOrganisationsListLanguage;
3567 OrganisationsListSortAs = &HomeOrganisationsListSortAs;
3568 OrganisationsListPref = &HomeOrganisationsListPref;
3571 OrganisationsList = &BusinessOrganisationsList;
3572 OrganisationsListType = &BusinessOrganisationsListType;
3573 OrganisationsListAltID = &BusinessOrganisationsListAltID;
3574 OrganisationsListPID = &BusinessOrganisationsListPID;
3575 OrganisationsListTokens = &BusinessOrganisationsListTokens;
3576 OrganisationsListLanguage = &BusinessOrganisationsListLanguage;
3577 OrganisationsListSortAs = &BusinessOrganisationsListSortAs;
3578 OrganisationsListPref = &BusinessOrganisationsListPref;
3584 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3585 intiter != SplitPoints.end(); ++intiter){
3587 SLiter = SplitLength.find(intiter->first);
3589 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3591 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3592 PropertyName = PropertyElement.GetNextToken();
3593 PropertyValue = PropertyElement.GetNextToken();
3595 intPrevValue = intiter->second;
3597 // Process properties.
3599 size_t intPropertyValueLen = PropertyValue.Len();
3601 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3603 PropertyValue.Trim();
3604 PropertyValue.RemoveLast();
3608 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3610 PropertyValue.Remove(0, 1);
3614 CaptureString(&PropertyValue, FALSE);
3616 if (PropertyName == wxT("ALTID")){
3618 OrganisationsListAltID->erase(*OrganisationCount);
3619 OrganisationsListAltID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3621 } else if (PropertyName == wxT("PID")){
3623 OrganisationsListPID->erase(*OrganisationCount);
3624 OrganisationsListPID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3626 } else if (PropertyName == wxT("SORT-AS")){
3628 OrganisationsListSortAs->erase(*OrganisationCount);
3629 OrganisationsListSortAs->insert(std::make_pair(*OrganisationCount, PropertyValue));
3631 } else if (PropertyName == wxT("PREF")){
3633 ProcessIntegerValue(OrganisationsListPref, &PropertyValue, OrganisationCount);
3635 } else if (PropertyName == wxT("LANGUAGE")){
3637 OrganisationsListLanguage->erase(*OrganisationCount);
3638 OrganisationsListLanguage->insert(std::make_pair(*OrganisationCount, PropertyValue));
3642 // Something else we don't know about so append
3643 // to the tokens variable.
3645 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3647 if (FirstToken == TRUE){
3649 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3654 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3664 // Add the data to the General/Home/Work address variables.
3666 CaptureString(&PropertySeg2, FALSE);
3668 OrganisationsList->insert(std::make_pair(*OrganisationCount, PropertySeg2));
3670 if (!PropertyTokens.IsEmpty()){
3672 OrganisationsListTokens->insert(std::make_pair(*OrganisationCount, PropertyTokens));
3678 void ContactDataObject::ProcessNote(wxString PropertySeg1, wxString PropertySeg2, int *NoteCount){
3680 std::map<int, int> SplitPoints;
3681 std::map<int, int> SplitLength;
3682 std::map<int, int>::iterator SLiter;
3683 wxString PropertyData;
3684 wxString PropertyName;
3685 wxString PropertyValue;
3686 wxString PropertyTokens;
3687 bool FirstToken = TRUE;
3688 int intPrevValue = 6;
3693 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3697 PropertyType PropType = PROPERTY_NONE;
3699 // Look for type before continuing.
3701 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3703 // Setup the pointers.
3705 std::map<int, wxString> *NoteList = NULL;
3706 std::map<int, wxString> *NoteListAltID = NULL;
3707 std::map<int, wxString> *NoteListPID = NULL;
3708 std::map<int, wxString> *NoteListType = NULL;
3709 std::map<int, wxString> *NoteListTokens = NULL;
3710 std::map<int, wxString> *NoteListLanguage = NULL;
3711 std::map<int, int> *NoteListPref = NULL;
3713 // Setup blank lines for later on.
3717 NoteList = &GeneralNoteList;
3718 NoteListType = &GeneralNoteListType;
3719 NoteListAltID = &GeneralNoteListAltID;
3720 NoteListPID = &GeneralNoteListPID;
3721 NoteListTokens = &GeneralNoteListTokens;
3722 NoteListLanguage = &GeneralNoteListLanguage;
3723 NoteListPref = &GeneralNoteListPref;
3726 NoteList = &HomeNoteList;
3727 NoteListType = &HomeNoteListType;
3728 NoteListAltID = &HomeNoteListAltID;
3729 NoteListPID = &HomeNoteListPID;
3730 NoteListTokens = &HomeNoteListTokens;
3731 NoteListLanguage = &HomeNoteListLanguage;
3732 NoteListPref = &HomeNoteListPref;
3735 NoteList = &BusinessNoteList;
3736 NoteListType = &BusinessNoteListType;
3737 NoteListAltID = &BusinessNoteListAltID;
3738 NoteListPID = &BusinessNoteListPID;
3739 NoteListTokens = &BusinessNoteListTokens;
3740 NoteListLanguage = &BusinessNoteListLanguage;
3741 NoteListPref = &BusinessNoteListPref;
3747 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3748 intiter != SplitPoints.end(); ++intiter){
3750 SLiter = SplitLength.find(intiter->first);
3752 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3754 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3755 PropertyName = PropertyElement.GetNextToken();
3756 PropertyValue = PropertyElement.GetNextToken();
3758 intPrevValue = intiter->second;
3760 // Process properties.
3762 size_t intPropertyValueLen = PropertyValue.Len();
3764 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3766 PropertyValue.Trim();
3767 PropertyValue.RemoveLast();
3771 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3773 PropertyValue.Remove(0, 1);
3777 CaptureString(&PropertyValue, FALSE);
3779 if (PropertyName == wxT("ALTID")){
3781 NoteListAltID->erase(*NoteCount);
3782 NoteListAltID->insert(std::make_pair(*NoteCount, PropertyValue));
3784 } else if (PropertyName == wxT("PID")){
3786 NoteListPID->erase(*NoteCount);
3787 NoteListPID->insert(std::make_pair(*NoteCount, PropertyValue));
3789 } else if (PropertyName == wxT("PREF")){
3791 ProcessIntegerValue(NoteListPref, &PropertyValue, NoteCount);
3793 } else if (PropertyName == wxT("LANGUAGE")){
3795 NoteListLanguage->erase(*NoteCount);
3796 NoteListLanguage->insert(std::make_pair(*NoteCount, PropertyValue));
3800 // Something else we don't know about so append
3801 // to the tokens variable.
3803 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3805 if (FirstToken == TRUE){
3807 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3812 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3822 // Add the data to the General/Home/Work address variables.
3824 CaptureString(&PropertySeg2, FALSE);
3826 NoteList->insert(std::make_pair(*NoteCount, PropertySeg2));
3828 if (!PropertyTokens.IsEmpty()){
3830 NoteListTokens->insert(std::make_pair(*NoteCount, PropertyTokens));
3836 void ContactDataObject::ProcessCategory(wxString PropertySeg1, wxString PropertySeg2, int *CategoryCount){
3838 std::map<int, int> SplitPoints;
3839 std::map<int, int> SplitLength;
3840 std::map<int, int>::iterator SLiter;
3841 wxString PropertyData;
3842 wxString PropertyName;
3843 wxString PropertyValue;
3844 wxString PropertyTokens;
3845 bool FirstToken = TRUE;
3846 int intPrevValue = 12;
3851 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3855 PropertyType PropType = PROPERTY_NONE;
3857 // Look for type before continuing.
3859 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3861 // Setup blank lines for later on.
3867 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
3870 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
3876 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3877 intiter != SplitPoints.end(); ++intiter){
3879 SLiter = SplitLength.find(intiter->first);
3881 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3883 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3884 PropertyName = PropertyElement.GetNextToken();
3885 PropertyValue = PropertyElement.GetNextToken();
3887 intPrevValue = intiter->second;
3889 // Process properties.
3891 size_t intPropertyValueLen = PropertyValue.Len();
3893 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3895 PropertyValue.Trim();
3896 PropertyValue.RemoveLast();
3900 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3902 PropertyValue.Remove(0, 1);
3906 CaptureString(&PropertyValue, FALSE);
3908 if (PropertyName == wxT("ALTID")){
3910 CategoriesListAltID.erase(*CategoryCount);
3911 CategoriesListAltID.insert(std::make_pair(*CategoryCount, PropertyValue));
3913 } else if (PropertyName == wxT("PID")){
3915 CategoriesListPID.erase(*CategoryCount);
3916 CategoriesListPID.insert(std::make_pair(*CategoryCount, PropertyValue));
3918 } else if (PropertyName == wxT("PREF")){
3920 ProcessIntegerValue(&CategoriesListPref, &PropertyValue, CategoryCount);
3922 } else if (PropertyName == wxT("LANGUAGE")){
3924 CategoriesListLanguage.erase(*CategoryCount);
3925 CategoriesListLanguage.insert(std::make_pair(*CategoryCount, PropertyValue));
3929 // Something else we don't know about so append
3930 // to the tokens variable.
3932 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3934 if (FirstToken == TRUE){
3936 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3941 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3951 // Deal with multiple categories.
3953 int intOrigCatCount = *CategoryCount;
3954 bool FirstCategoryProcessed = TRUE;
3955 bool AfterFirstToken = FALSE;
3956 int intSplitSize = 0;
3957 int intSplitsFound = 0;
3958 int intSplitSeek = 0;
3959 int intPropertyLen = PropertySeg2.Len();
3961 SplitPoints.clear();
3962 SplitLength.clear();
3965 for (int i = 0; i <= intPropertyLen; i++){
3967 if (intSplitSize == 0 && PropertySeg2.Mid(i, 1) == wxT(" ")){
3975 if (PropertySeg2.Mid(i, 1) == wxT(",") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
3977 if (AfterFirstToken == TRUE){
3979 SplitPoints.insert(std::make_pair(intSplitsFound, (i - intSplitSize + 1)));
3980 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
3984 SplitPoints.insert(std::make_pair(intSplitsFound, 0));
3985 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
3986 AfterFirstToken = TRUE;
3998 if (SplitPoints.size() > 0){
4000 SplitPoints.insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
4001 SplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
4005 if (SplitPoints.size() == 0){
4007 CategoriesList.insert(std::make_pair(*CategoryCount, PropertySeg2));
4009 if (!PropertyTokens.IsEmpty()){
4011 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4017 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4018 intiter != SplitPoints.end(); ++intiter){
4020 SLiter = SplitLength.find(intiter->first);
4022 intPrevValue = intiter->second;
4024 PropertyData = PropertySeg2.Mid(intPrevValue, (SLiter->second + 1));
4026 // Add the data to the General/Home/Work address variables.
4028 // Trim any whitespace from the start and end.
4030 PropertyData = PropertyData.Trim(FALSE);
4031 PropertyData = PropertyData.Trim(TRUE);
4033 CaptureString(&PropertyData, FALSE);
4035 if (FirstCategoryProcessed == TRUE){
4037 FirstCategoryProcessed = FALSE;
4039 CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4041 if (!PropertyTokens.IsEmpty()){
4043 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4053 CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4055 if (!PropertyTokens.IsEmpty()){
4057 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4063 // Copy the properties to each of the categories (if it exists).
4065 if (!PropertyTokens.IsEmpty()){
4067 CategoriesListTokens.insert(std::make_pair(*CategoryCount, CategoriesListTokens.find(intOrigCatCount)->second));
4071 // Check if ALTID was used.
4073 if (CategoriesListAltID.find(intOrigCatCount) != CategoriesListAltID.end()){
4075 CategoriesListAltID.insert(std::make_pair(*CategoryCount, CategoriesListAltID.find(intOrigCatCount)->second));
4079 // Check if PID was used.
4081 if (CategoriesListPID.find(intOrigCatCount) != CategoriesListPID.end()){
4083 CategoriesListPID.insert(std::make_pair(*CategoryCount, CategoriesListPID.find(intOrigCatCount)->second));
4087 // Check if PREF was used.
4089 if (CategoriesListPref.find(intOrigCatCount) != CategoriesListPref.end()){
4091 CategoriesListPref.insert(std::make_pair(*CategoryCount, CategoriesListPref.find(intOrigCatCount)->second));
4095 // Check if LANGUAGE was used.
4097 if (CategoriesListLanguage.find(intOrigCatCount) != CategoriesListLanguage.end()){
4099 CategoriesListLanguage.insert(std::make_pair(*CategoryCount, CategoriesListLanguage.find(intOrigCatCount)->second));
4103 // Check if TYPE was used.
4109 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
4112 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
4120 void ContactDataObject::ProcessPhoto(wxString PropertySeg1, wxString PropertySeg2, int *PhotoCount){
4122 size_t intPropertyLen = PropertySeg1.Len();
4123 std::map<int, int> SplitPoints;
4124 std::map<int, int> SplitLength;
4125 std::map<int, int>::iterator SLiter;
4126 wxString PropertyData;
4127 wxString PropertyName;
4128 wxString PropertyValue;
4129 wxString PropertyTokens;
4130 bool FirstToken = TRUE;
4131 int intSplitsFound = 0;
4132 int intSplitSize = 0;
4133 int intPrevValue = 7;
4137 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4141 PropertyType PropType = PROPERTY_NONE;
4143 // Look for type before continuing.
4145 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4149 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4150 intiter != SplitPoints.end(); ++intiter){
4152 SLiter = SplitLength.find(intiter->first);
4154 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4156 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4157 PropertyName = PropertyElement.GetNextToken();
4158 PropertyValue = PropertyElement.GetNextToken();
4160 intPrevValue = intiter->second;
4162 // Process properties.
4164 size_t intPropertyValueLen = PropertyValue.Len();
4166 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4168 PropertyValue.Trim();
4169 PropertyValue.RemoveLast();
4173 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4175 PropertyValue.Remove(0, 1);
4179 CaptureString(&PropertyValue, FALSE);
4181 if (PropertyName == wxT("ALTID")){
4183 PicturesListAltID.erase(*PhotoCount);
4184 PicturesListAltID.insert(std::make_pair(*PhotoCount, PropertyValue));
4186 } else if (PropertyName == wxT("PID")){
4188 PicturesListPID.erase(*PhotoCount);
4189 PicturesListPID.insert(std::make_pair(*PhotoCount, PropertyValue));
4191 } else if (PropertyName == wxT("PREF")){
4193 ProcessIntegerValue(&PicturesListPref, &PropertyValue, PhotoCount);
4195 } else if (PropertyName == wxT("MEDIATYPE")){
4197 PicturesListMediatype.erase(*PhotoCount);
4198 PicturesListMediatype.insert(std::make_pair(*PhotoCount, PropertyValue));
4202 // Something else we don't know about so append
4203 // to the tokens variable.
4205 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4207 if (FirstToken == TRUE){
4209 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4214 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4224 intPropertyLen = PropertySeg2.Len();
4225 SplitPoints.clear();
4226 SplitLength.clear();
4231 CaptureString(&PropertySeg2, FALSE);
4233 for (int i = 0; i <= intPropertyLen; i++){
4237 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4240 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4242 if (intSplitsFound == 6){
4244 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4249 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4259 wxString wxSPhotoURI;
4260 wxString wxSPhotoMIME;
4261 wxString wxSPhotoEncoding;
4262 wxString wxSPhotoData;
4263 std::string base64enc;
4265 if (intSplitsFound == 0){
4269 std::map<int, int>::iterator striter;
4271 striter = SplitLength.find(1);
4273 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4275 while (wSTDataType.HasMoreTokens() == TRUE){
4277 wxSPhotoURI = wSTDataType.GetNextToken();
4278 wxSPhotoMIME = wSTDataType.GetNextToken();
4283 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
4285 while (wSTDataInfo.HasMoreTokens() == TRUE){
4287 wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4288 wxSPhotoData = wSTDataInfo.GetNextToken();
4289 base64enc = wxSPhotoData.mb_str();
4296 // Add the data to the General/Home/Work address variables.
4298 PicturesList.insert(std::make_pair(*PhotoCount, base64enc));
4299 PicturesListPictureType.insert(std::make_pair(*PhotoCount, wxSPhotoMIME));
4300 PicturesListPicEncType.insert(std::make_pair(*PhotoCount, wxSPhotoEncoding));
4306 PicturesListType.insert(std::make_pair(*PhotoCount, "home"));
4309 PicturesListType.insert(std::make_pair(*PhotoCount, "work"));
4313 if (!PropertyTokens.IsEmpty()){
4315 PicturesListTokens.insert(std::make_pair(*PhotoCount, PropertyTokens));
4321 void ContactDataObject::ProcessLogo(wxString PropertySeg1, wxString PropertySeg2, int *LogoCount){
4323 size_t intPropertyLen = PropertySeg1.Len();
4324 std::map<int, int> SplitPoints;
4325 std::map<int, int> SplitLength;
4326 std::map<int, int>::iterator SLiter;
4327 wxString PropertyData;
4328 wxString PropertyName;
4329 wxString PropertyValue;
4330 wxString PropertyTokens;
4331 bool FirstToken = TRUE;
4332 int intSplitsFound = 0;
4333 int intSplitSize = 0;
4334 int intPrevValue = 6;
4338 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4342 PropertyType PropType = PROPERTY_NONE;
4344 // Look for type before continuing.
4346 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4350 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4351 intiter != SplitPoints.end(); ++intiter){
4353 SLiter = SplitLength.find(intiter->first);
4355 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4357 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4358 PropertyName = PropertyElement.GetNextToken();
4359 PropertyValue = PropertyElement.GetNextToken();
4361 intPrevValue = intiter->second;
4363 // Process properties.
4365 size_t intPropertyValueLen = PropertyValue.Len();
4367 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4369 PropertyValue.Trim();
4370 PropertyValue.RemoveLast();
4374 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4376 PropertyValue.Remove(0, 1);
4380 CaptureString(&PropertyValue, FALSE);
4382 if (PropertyName == wxT("ALTID")){
4384 LogosListAltID.erase(*LogoCount);
4385 LogosListAltID.insert(std::make_pair(*LogoCount, PropertyValue));
4387 } else if (PropertyName == wxT("PID")){
4389 LogosListPID.erase(*LogoCount);
4390 LogosListPID.insert(std::make_pair(*LogoCount, PropertyValue));
4392 } else if (PropertyName == wxT("PREF")){
4394 ProcessIntegerValue(&LogosListPref, &PropertyValue, LogoCount);
4396 } else if (PropertyName == wxT("MEDIATYPE")){
4398 LogosListMediatype.erase(*LogoCount);
4399 LogosListMediatype.insert(std::make_pair(*LogoCount, PropertyValue));
4403 // Something else we don't know about so append
4404 // to the tokens variable.
4406 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4408 if (FirstToken == TRUE){
4410 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4415 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4425 intPropertyLen = PropertySeg2.Len();
4426 SplitPoints.clear();
4427 SplitLength.clear();
4432 CaptureString(&PropertySeg2, FALSE);
4434 for (int i = 0; i <= intPropertyLen; i++){
4438 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4441 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4443 if (intSplitsFound == 6){
4445 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4450 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4460 wxString wxSPhotoURI;
4461 wxString wxSPhotoMIME;
4462 wxString wxSPhotoEncoding;
4463 wxString wxSPhotoData;
4464 std::string base64enc;
4466 if (intSplitsFound == 0){
4470 std::map<int, int>::iterator striter;
4472 striter = SplitLength.find(1);
4474 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4476 while (wSTDataType.HasMoreTokens() == TRUE){
4478 wxSPhotoURI = wSTDataType.GetNextToken();
4479 wxSPhotoMIME = wSTDataType.GetNextToken();
4484 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
4486 while (wSTDataInfo.HasMoreTokens() == TRUE){
4488 wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4489 wxSPhotoData = wSTDataInfo.GetNextToken();
4490 base64enc = wxSPhotoData.mb_str();
4497 // Add the data to the General/Home/Work address variables.
4499 LogosList.insert(std::make_pair(*LogoCount, base64enc));
4500 LogosListPictureType.insert(std::make_pair(*LogoCount, wxSPhotoMIME));
4501 LogosListPicEncType.insert(std::make_pair(*LogoCount, wxSPhotoEncoding));
4507 LogosListType.insert(std::make_pair(*LogoCount, "home"));
4510 LogosListType.insert(std::make_pair(*LogoCount, "work"));
4514 if (!PropertyTokens.IsEmpty()){
4516 LogosListTokens.insert(std::make_pair(*LogoCount, PropertyTokens));
4522 void ContactDataObject::ProcessSound(wxString PropertySeg1, wxString PropertySeg2, int *SoundCount){
4524 size_t intPropertyLen = PropertySeg1.Len();
4525 std::map<int, int> SplitPoints;
4526 std::map<int, int> SplitLength;
4527 std::map<int, int>::iterator SLiter;
4528 wxString PropertyData;
4529 wxString PropertyName;
4530 wxString PropertyValue;
4531 wxString PropertyTokens;
4532 bool FirstToken = TRUE;
4533 int intSplitsFound = 0;
4534 int intSplitSize = 0;
4535 int intPrevValue = 7;
4539 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4543 PropertyType PropType = PROPERTY_NONE;
4545 // Look for type before continuing.
4547 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4551 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4552 intiter != SplitPoints.end(); ++intiter){
4554 SLiter = SplitLength.find(intiter->first);
4556 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4558 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4559 PropertyName = PropertyElement.GetNextToken();
4560 PropertyValue = PropertyElement.GetNextToken();
4562 intPrevValue = intiter->second;
4564 // Process properties.
4566 size_t intPropertyValueLen = PropertyValue.Len();
4568 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4570 PropertyValue.Trim();
4571 PropertyValue.RemoveLast();
4575 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4577 PropertyValue.Remove(0, 1);
4581 CaptureString(&PropertyValue, FALSE);
4583 if (PropertyName == wxT("ALTID")){
4585 SoundsListAltID.erase(*SoundCount);
4586 SoundsListAltID.insert(std::make_pair(*SoundCount, PropertyValue));
4588 } else if (PropertyName == wxT("PID")){
4590 SoundsListPID.erase(*SoundCount);
4591 SoundsListPID.insert(std::make_pair(*SoundCount, PropertyValue));
4593 } else if (PropertyName == wxT("PREF")){
4595 ProcessIntegerValue(&SoundsListPref, &PropertyValue, SoundCount);
4597 } else if (PropertyName == wxT("MEDIATYPE")){
4599 SoundsListMediatype.erase(*SoundCount);
4600 SoundsListMediatype.insert(std::make_pair(*SoundCount, PropertyValue));
4602 } else if (PropertyName == wxT("LANGUAGE")){
4604 SoundsListLanguage.erase(*SoundCount);
4605 SoundsListLanguage.insert(std::make_pair(*SoundCount, PropertyValue));
4609 // Something else we don't know about so append
4610 // to the tokens variable.
4612 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4614 if (FirstToken == TRUE){
4616 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4621 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4631 intPropertyLen = PropertySeg2.Len();
4632 SplitPoints.clear();
4633 SplitLength.clear();
4638 CaptureString(&PropertySeg2, FALSE);
4640 for (int i = 0; i <= intPropertyLen; i++){
4644 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4647 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4649 if (intSplitsFound == 6){
4651 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4656 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4666 wxString wxSSoundURI;
4667 wxString wxSSoundMIME;
4668 wxString wxSSoundEncoding;
4669 wxString wxSSoundData;
4670 std::string base64enc;
4672 if (intSplitsFound == 0){
4676 std::map<int, int>::iterator striter;
4678 striter = SplitLength.find(1);
4680 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4682 while (wSTDataType.HasMoreTokens() == TRUE){
4684 wxSSoundURI = wSTDataType.GetNextToken();
4685 wxSSoundMIME = wSTDataType.GetNextToken();
4690 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
4692 while (wSTDataInfo.HasMoreTokens() == TRUE){
4694 wxSSoundEncoding = wSTDataInfo.GetNextToken();
4695 wxSSoundData = wSTDataInfo.GetNextToken();
4696 base64enc = wxSSoundData.mb_str();
4703 // Add the data to the General/Home/Work address variables.
4709 SoundsListType.insert(std::make_pair(*SoundCount, "home"));
4712 SoundsListType.insert(std::make_pair(*SoundCount, "work"));
4716 SoundsList.insert(std::make_pair(*SoundCount, base64enc));
4717 SoundsListAudioEncType.insert(std::make_pair(*SoundCount, wxSSoundEncoding));
4718 SoundsListAudioType.insert(std::make_pair(*SoundCount, wxSSoundMIME));
4720 if (!PropertyTokens.IsEmpty()){
4722 SoundsListTokens.insert(std::make_pair(*SoundCount, PropertyTokens));
4728 void ContactDataObject::ProcessCalendarURI(wxString PropertySeg1, wxString PropertySeg2, int *CalURICount){
4730 size_t intPropertyLen = PropertySeg1.Len();
4731 std::map<int, int> SplitPoints;
4732 std::map<int, int> SplitLength;
4733 std::map<int, int>::iterator SLiter;
4734 wxString PropertyData;
4735 wxString PropertyName;
4736 wxString PropertyValue;
4737 wxString PropertyTokens;
4738 bool FirstToken = TRUE;
4739 int intSplitsFound = 0;
4740 int intSplitSize = 0;
4741 int intPrevValue = 8;
4745 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4749 PropertyType PropType = PROPERTY_NONE;
4751 // Look for type before continuing.
4753 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4757 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4758 intiter != SplitPoints.end(); ++intiter){
4760 SLiter = SplitLength.find(intiter->first);
4762 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4764 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4765 PropertyName = PropertyElement.GetNextToken();
4766 PropertyValue = PropertyElement.GetNextToken();
4768 intPrevValue = intiter->second;
4770 // Process properties.
4772 size_t intPropertyValueLen = PropertyValue.Len();
4774 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4776 PropertyValue.Trim();
4777 PropertyValue.RemoveLast();
4781 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4783 PropertyValue.Remove(0, 1);
4787 CaptureString(&PropertyValue, FALSE);
4789 if (PropertyName == wxT("ALTID")){
4791 CalendarListAltID.erase(*CalURICount);
4792 CalendarListAltID.insert(std::make_pair(*CalURICount, PropertyValue));
4794 } else if (PropertyName == wxT("PID")){
4796 CalendarListPID.erase(*CalURICount);
4797 CalendarListPID.insert(std::make_pair(*CalURICount, PropertyValue));
4799 } else if (PropertyName == wxT("PREF")){
4801 ProcessIntegerValue(&CalendarListPref, &PropertyValue, CalURICount);
4803 } else if (PropertyName == wxT("MEDIATYPE")){
4805 CalendarListMediatype.erase(*CalURICount);
4806 CalendarListMediatype.insert(std::make_pair(*CalURICount, PropertyValue));
4810 // Something else we don't know about so append
4811 // to the tokens variable.
4813 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4815 if (FirstToken == TRUE){
4817 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4822 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4832 intPropertyLen = PropertySeg2.Len();
4833 SplitPoints.clear();
4834 SplitLength.clear();
4839 CaptureString(&PropertySeg2, FALSE);
4841 // Add the data to the General/Home/Work address variables.
4847 CalendarListType.insert(std::make_pair(*CalURICount, "home"));
4850 CalendarListType.insert(std::make_pair(*CalURICount, "work"));
4854 CalendarList.insert(std::make_pair(*CalURICount, PropertySeg2));
4856 if (!PropertyTokens.IsEmpty()){
4858 CalendarListTokens.insert(std::make_pair(*CalURICount, PropertyTokens));
4864 void ContactDataObject::ProcessCalendarAddressURI(wxString PropertySeg1, wxString PropertySeg2, int *CalAdrURICount){
4866 size_t intPropertyLen = PropertySeg1.Len();
4867 std::map<int, int> SplitPoints;
4868 std::map<int, int> SplitLength;
4869 std::map<int, int>::iterator SLiter;
4870 wxString PropertyData;
4871 wxString PropertyName;
4872 wxString PropertyValue;
4873 wxString PropertyTokens;
4874 bool FirstToken = TRUE;
4875 int intSplitsFound = 0;
4876 int intSplitSize = 0;
4877 int intPrevValue = 8;
4881 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4885 PropertyType PropType = PROPERTY_NONE;
4887 // Look for type before continuing.
4889 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4893 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4894 intiter != SplitPoints.end(); ++intiter){
4896 SLiter = SplitLength.find(intiter->first);
4898 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4900 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4901 PropertyName = PropertyElement.GetNextToken();
4902 PropertyValue = PropertyElement.GetNextToken();
4904 intPrevValue = intiter->second;
4906 // Process properties.
4908 size_t intPropertyValueLen = PropertyValue.Len();
4910 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4912 PropertyValue.Trim();
4913 PropertyValue.RemoveLast();
4917 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4919 PropertyValue.Remove(0, 1);
4923 CaptureString(&PropertyValue, FALSE);
4925 if (PropertyName == wxT("ALTID")){
4927 CalendarRequestListAltID.erase(*CalAdrURICount);
4928 CalendarRequestListAltID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
4930 } else if (PropertyName == wxT("PID")){
4932 CalendarRequestListPID.erase(*CalAdrURICount);
4933 CalendarRequestListPID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
4935 } else if (PropertyName == wxT("PREF")){
4937 ProcessIntegerValue(&CalendarRequestListPref, &PropertyValue, CalAdrURICount);
4939 } else if (PropertyName == wxT("MEDIATYPE")){
4941 CalendarRequestListMediatype.erase(*CalAdrURICount);
4942 CalendarRequestListMediatype.insert(std::make_pair(*CalAdrURICount, PropertyValue));
4946 // Something else we don't know about so append
4947 // to the tokens variable.
4949 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4951 if (FirstToken == TRUE){
4953 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4958 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4968 intPropertyLen = PropertySeg2.Len();
4969 SplitPoints.clear();
4970 SplitLength.clear();
4975 CaptureString(&PropertySeg2, FALSE);
4977 // Add the data to the General/Home/Work address variables.
4983 CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "home"));
4986 CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "work"));
4990 CalendarRequestList.insert(std::make_pair(*CalAdrURICount, PropertySeg2));
4992 if (!PropertyTokens.IsEmpty()){
4994 CalendarRequestListTokens.insert(std::make_pair(*CalAdrURICount, PropertyTokens));
5000 void ContactDataObject::ProcessCalendarFreeBusy(wxString PropertySeg1, wxString PropertySeg2, int *FreeBusyAddressCount){
5002 size_t intPropertyLen = PropertySeg1.Len();
5003 std::map<int, int> SplitPoints;
5004 std::map<int, int> SplitLength;
5005 std::map<int, int>::iterator SLiter;
5006 wxString PropertyData;
5007 wxString PropertyName;
5008 wxString PropertyValue;
5009 wxString PropertyTokens;
5010 bool FirstToken = TRUE;
5011 int intSplitsFound = 0;
5012 int intSplitSize = 0;
5013 int intPrevValue = 7;
5017 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5021 PropertyType PropType = PROPERTY_NONE;
5023 // Look for type before continuing.
5025 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5029 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
5030 intiter != SplitPoints.end(); ++intiter){
5032 SLiter = SplitLength.find(intiter->first);
5034 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5036 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5037 PropertyName = PropertyElement.GetNextToken();
5038 PropertyValue = PropertyElement.GetNextToken();
5040 intPrevValue = intiter->second;
5042 // Process properties.
5044 size_t intPropertyValueLen = PropertyValue.Len();
5046 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5048 PropertyValue.Trim();
5049 PropertyValue.RemoveLast();
5053 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5055 PropertyValue.Remove(0, 1);
5059 CaptureString(&PropertyValue, FALSE);
5061 if (PropertyName == wxT("ALTID")){
5063 FreeBusyListAltID.erase(*FreeBusyAddressCount);
5064 FreeBusyListAltID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5066 } else if (PropertyName == wxT("PID")){
5068 FreeBusyListPID.erase(*FreeBusyAddressCount);
5069 FreeBusyListPID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5071 } else if (PropertyName == wxT("PREF")){
5073 ProcessIntegerValue(&FreeBusyListPref, &PropertyValue, FreeBusyAddressCount);
5075 } else if (PropertyName == wxT("MEDIATYPE")){
5077 FreeBusyListMediatype.erase(*FreeBusyAddressCount);
5078 FreeBusyListMediatype.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5082 // Something else we don't know about so append
5083 // to the tokens variable.
5085 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5087 if (FirstToken == TRUE){
5089 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5094 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5104 intPropertyLen = PropertySeg2.Len();
5105 SplitPoints.clear();
5106 SplitLength.clear();
5111 CaptureString(&PropertySeg2, FALSE);
5113 // Add the data to the General/Home/Work address variables.
5119 FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "home"));
5122 FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "work"));
5126 FreeBusyList.insert(std::make_pair(*FreeBusyAddressCount, PropertySeg2));
5128 if (!PropertyTokens.IsEmpty()){
5130 FreeBusyListTokens.insert(std::make_pair(*FreeBusyAddressCount, PropertyTokens));
5136 void ContactDataObject::ProcessKey(wxString PropertySeg1, wxString PropertySeg2, int *KeyCount){
5138 size_t intPropertyLen = PropertySeg1.Len();
5139 std::map<int, int> SplitPoints;
5140 std::map<int, int> SplitLength;
5141 std::map<int, int>::iterator SLiter;
5142 wxString PropertyData;
5143 wxString PropertyName;
5144 wxString PropertyValue;
5145 wxString PropertyTokens;
5146 bool FirstToken = TRUE;
5147 int intSplitsFound = 0;
5148 int intSplitSize = 0;
5149 int intPrevValue = 5;
5154 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5158 PropertyType PropType = PROPERTY_NONE;
5160 // Look for type before continuing.
5162 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5166 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
5167 intiter != SplitPoints.end(); ++intiter){
5169 SLiter = SplitLength.find(intiter->first);
5171 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5173 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5174 PropertyName = PropertyElement.GetNextToken();
5175 PropertyValue = PropertyElement.GetNextToken();
5177 intPrevValue = intiter->second;
5179 // Process properties.
5181 size_t intPropertyValueLen = PropertyValue.Len();
5183 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5185 PropertyValue.Trim();
5186 PropertyValue.RemoveLast();
5190 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5192 PropertyValue.Remove(0, 1);
5196 if (PropertyName == wxT("ALTID")){
5198 KeyListAltID.erase(*KeyCount);
5199 KeyListAltID.insert(std::make_pair(*KeyCount, PropertyValue));
5201 } else if (PropertyName == wxT("PID")){
5203 KeyListPID.erase(*KeyCount);
5204 KeyListPID.insert(std::make_pair(*KeyCount, PropertyValue));
5206 } else if (PropertyName == wxT("PREF")){
5208 ProcessIntegerValue(&KeyListPref, &PropertyValue, KeyCount);
5212 // Something else we don't know about so append
5213 // to the tokens variable.
5215 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5217 if (FirstToken == TRUE){
5219 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5224 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5234 intPropertyLen = PropertySeg2.Len();
5235 SplitPoints.clear();
5236 SplitLength.clear();
5241 for (int i = 0; i <= intPropertyLen; i++){
5245 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
5248 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
5250 if (intSplitsFound == 6){
5252 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5257 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5268 wxString wxSKeyMIME;
5269 wxString wxSKeyEncoding;
5270 wxString wxSKeyData;
5271 std::string base64enc;
5273 if (intSplitsFound == 0){
5277 std::map<int, int>::iterator striter;
5279 striter = SplitLength.find(1);
5281 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
5283 while (wSTDataType.HasMoreTokens() == TRUE){
5285 wxSKeyURI = wSTDataType.GetNextToken();
5286 wxSKeyMIME = wSTDataType.GetNextToken();
5291 if (wxSKeyURI == wxT("data")){
5293 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
5295 while (wSTDataInfo.HasMoreTokens() == TRUE){
5297 wxSKeyEncoding = wSTDataInfo.GetNextToken();
5298 wxSKeyData = wSTDataInfo.GetNextToken();
5307 // Add the data to the General/Home/Work address variables.
5309 if (wxSKeyURI == wxT("data")){
5311 KeyListDataEncType.erase(*KeyCount);
5312 KeyListKeyType.erase(*KeyCount);
5313 KeyListDataEncType.insert(std::make_pair(*KeyCount, wxSKeyEncoding));
5314 KeyListKeyType.insert(std::make_pair(*KeyCount, TRUE));
5316 KeyList.erase(*KeyCount);
5317 KeyList.insert(std::make_pair(*KeyCount, wxSKeyData));
5321 KeyList.erase(*KeyCount);
5322 KeyList.insert(std::make_pair(*KeyCount, PropertySeg2));
5326 KeyListDataType.insert(std::make_pair(*KeyCount, wxSKeyMIME));
5332 KeyListType.insert(std::make_pair(*KeyCount, wxT("home")));
5335 KeyListType.insert(std::make_pair(*KeyCount, wxT("work")));
5339 if (!PropertyTokens.IsEmpty()){
5341 KeyListTokens.insert(std::make_pair(*KeyCount, PropertyTokens));
5347 void ContactDataObject::ProcessVendor(wxString PropertySeg1, wxString PropertySeg2, int *VendorCount){
5349 // Split the Vendor three ways.
5351 wxStringTokenizer wSTVendorDetails(PropertySeg1, wxT("-"));
5354 wxString wxSVNDPropName;
5357 while (wSTVendorDetails.HasMoreTokens() == TRUE){
5359 wSTVendorDetails.GetNextToken();
5360 wxSVNDID = wSTVendorDetails.GetNextToken();
5361 wxSVNDPropName = wSTVendorDetails.GetNextToken();
5366 if (!wxSVNDID.IsEmpty() && !wxSVNDPropName.IsEmpty()){
5368 // Add the data to the vendor variables.
5370 VendorList.erase(*VendorCount);
5371 VendorListPEN.erase(*VendorCount);
5372 VendorListElement.erase(*VendorCount);
5374 VendorList.insert(std::make_pair(*VendorCount, PropertySeg2));
5375 VendorListPEN.insert(std::make_pair(*VendorCount, wxSVNDID));
5376 VendorListElement.insert(std::make_pair(*VendorCount, wxSVNDPropName));
5382 void ProcessStringValue(wxString *PropertyName,
5383 wxString PropertyNameMatch,
5384 std::map<int,wxString> *MapPtr,
5385 wxString *PropertyValue,
5387 bool *PropertyMatched){
5389 if (*PropertyName == PropertyNameMatch){
5390 MapPtr->erase(*ItemCount);
5391 MapPtr->insert(std::make_pair(*ItemCount, *PropertyValue));
5392 *PropertyMatched = TRUE;
5397 void ProcessIntegerValue(wxString *PropertyName,
5398 wxString PropertyNameMatch,
5399 std::map<int,int> *PrefPtr,
5400 wxString *PropertyValue,
5402 bool *PropertyMatched){
5404 if (*PropertyName == PropertyNameMatch){
5405 *PropertyMatched = TRUE;
5410 int PriorityNumber = 0;
5411 bool ValidNumber = TRUE;
5414 PriorityNumber = std::stoi(PropertyValue->ToStdString());
5417 catch(std::invalid_argument &e){
5418 ValidNumber = FALSE;
5421 if (ValidNumber == TRUE){
5423 PrefPtr->erase(*ItemCount);
5424 PrefPtr->insert(std::make_pair(*ItemCount, PriorityNumber));
5430 void ProcessIntegerValue(std::map<int,int> *PrefPtr,
5431 wxString *PropertyValue,
5434 int PriorityNumber = 0;
5435 bool ValidNumber = TRUE;
5438 PriorityNumber = std::stoi(PropertyValue->ToStdString());
5441 catch(std::invalid_argument &e){
5442 ValidNumber = FALSE;
5445 if (ValidNumber == TRUE){
5447 PrefPtr->erase(*ItemCount);
5448 PrefPtr->insert(std::make_pair(*ItemCount, PriorityNumber));
5454 void SplitValues(wxString *PropertyLine,
5455 std::map<int,int> *SplitPoints,
5456 std::map<int,int> *SplitLength,
5459 size_t intPropertyLen = PropertyLine->Len();
5460 int intSplitsFound = 0;
5461 int intSplitSize = 0;
5462 int intSplitSeek = 0;
5464 for (int i = intSize; i <= intPropertyLen; i++){
5468 if (PropertyLine->Mid(i, 1) == wxT(";") &&
5469 PropertyLine->Mid((i - 1), 1) != wxT("\\")){
5471 if (intSplitsFound == 0){
5473 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
5477 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5481 SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
5491 if (intSplitsFound == 0){
5493 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
5494 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5498 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
5499 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5505 void CheckType(wxString *PropertySeg1,
5506 std::map<int,int> *SplitPoints,
5507 std::map<int,int> *SplitLength,
5509 PropertyType *PropType){
5511 wxString PropertyData;
5512 wxString PropertyName;
5513 wxString PropertyValue;
5514 std::map<int,int>::iterator SLiter;
5516 for (std::map<int, int>::iterator intiter = SplitPoints->begin();
5517 intiter != SplitPoints->end(); ++intiter){
5519 SLiter = SplitLength->find(intiter->first);
5521 PropertyData = PropertySeg1->Mid(*intPrevValue, (SLiter->second));
5523 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5524 PropertyName = PropertyElement.GetNextToken();
5525 PropertyValue = PropertyElement.GetNextToken();
5527 *intPrevValue = intiter->second;
5529 if (PropertyName == wxT("TYPE")){
5531 if (PropertyValue == wxT("work")){
5533 *PropType = PROPERTY_WORK;
5535 } else if (PropertyValue == wxT("home")){
5537 *PropType = PROPERTY_HOME;
5541 *PropType = PROPERTY_NONE;