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;
2184 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2185 intiter != SplitPoints.end(); ++intiter){
2187 SLiter = SplitLength.find(intiter->first);
2189 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2191 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2192 PropertyName = PropertyElement.GetNextToken();
2193 PropertyValue = PropertyElement.GetNextToken();
2195 intPrevValue = intiter->second;
2197 CaptureString(&PropertyValue, FALSE);
2199 // Process properties.
2201 if (PropertyName == wxT("ALTID")){
2203 IMListAltID->erase(*IMCount);
2204 IMListAltID->insert(std::make_pair(*IMCount, PropertyValue));
2206 } else if (PropertyName == wxT("PID")){
2208 IMListPID->erase(*IMCount);
2209 IMListPID->insert(std::make_pair(*IMCount, PropertyValue));
2211 } else if (PropertyName == wxT("MEDIATYPE")){
2213 IMListMediatype->erase(*IMCount);
2214 IMListMediatype->insert(std::make_pair(*IMCount, PropertyValue));
2216 } else if (PropertyName == wxT("PREF")){
2218 ProcessIntegerValue(IMListPref, &PropertyValue, IMCount);
2222 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2224 if (FirstToken == TRUE){
2226 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2231 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2241 IMList->insert(std::make_pair(*IMCount, PropertySeg2));
2243 // Add the name token data.
2245 if (!PropertyTokens.IsEmpty()){
2247 IMListTokens->insert(std::make_pair(*IMCount, PropertyTokens));
2253 void ContactDataObject::ProcessTelephone(wxString PropertySeg1, wxString PropertySeg2, int *TelephoneCount){
2255 std::map<int, int> SplitPoints;
2256 std::map<int, int> SplitLength;
2257 std::map<int, int>::iterator SLiter;
2261 PropertyType PropType = PROPERTY_NONE;
2263 // Look for type before continuing.
2266 wxString TelTypeDetail;
2267 wxString PropertyData;
2268 wxString PropertyName;
2269 wxString PropertyValue;
2270 wxString PropertyTokens;
2272 std::map<int,int> TypeSplitPoints;
2273 std::map<int,int> TypeSplitLength;
2274 std::map<int,int>::iterator TSLiter;
2276 int intSplitSize = 0;
2277 int intSplitsFound = 0;
2278 int intSplitPoint = 0;
2280 int intPrevValue = 5;
2282 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2286 // Look for type before continuing.
2288 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2289 intiter != SplitPoints.end(); ++intiter){
2291 SLiter = SplitLength.find(intiter->first);
2293 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2295 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2296 PropertyName = PropertyElement.GetNextToken();
2297 PropertyValue = PropertyElement.GetNextToken();
2299 intPrevValue = intiter->second;
2301 if (PropertyName == wxT("TYPE")){
2303 // Process each value in type and translate each
2306 // Strip out the quotes if they are there.
2308 size_t intPropertyValueLen = PropertyValue.Len();
2310 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2312 PropertyValue.Trim();
2313 PropertyValue.RemoveLast();
2317 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2319 PropertyValue.Remove(0, 1);
2323 TelTypeDetail = PropertyValue;
2329 for (int i = 0; i <= intPropertyValueLen; i++){
2333 if (PropertyValue.Mid(i, 1) == wxT(",") && PropertyValue.Mid((i - 1), 1) != wxT("\\")){
2335 if (intSplitsFound == 0){
2337 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2338 TypeSplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2342 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2343 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2356 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2357 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2359 int intTypeSeek = 0;
2361 for (std::map<int, int>::iterator typeiter = TypeSplitPoints.begin();
2362 typeiter != TypeSplitPoints.end(); ++typeiter){
2364 wxString TypePropertyName;
2366 TSLiter = TypeSplitLength.find(typeiter->first);
2368 TypePropertyName = PropertyValue.Mid(typeiter->second, TSLiter->second);
2370 if (intTypeSeek == 0){
2375 TelTypeUI.Append(wxT(","));
2379 if (TypePropertyName == wxT("home")){
2381 PropType = PROPERTY_HOME;
2383 } else if (TypePropertyName == wxT("work")){
2385 PropType = PROPERTY_WORK;
2390 if (TypePropertyName == wxT("text")){
2392 TelTypeUI.Append(_("text"));
2395 } else if (TypePropertyName == wxT("voice")){
2397 TelTypeUI.Append(_("voice"));
2400 } else if (TypePropertyName == wxT("fax")){
2402 TelTypeUI.Append(_("fax"));
2405 } else if (TypePropertyName == wxT("cell")){
2407 TelTypeUI.Append(_("mobile"));
2410 } else if (TypePropertyName == wxT("video")){
2412 TelTypeUI.Append(_("video"));
2415 } else if (TypePropertyName == wxT("pager")){
2417 TelTypeUI.Append(_("pager"));
2420 } else if (TypePropertyName == wxT("textphone")){
2422 TelTypeUI.Append(_("textphone"));
2433 std::map<int, wxString> *TelephoneList = NULL;
2434 std::map<int, wxString> *TelephoneListType = NULL;
2435 std::map<int, wxString> *TelephoneListAltID = NULL;
2436 std::map<int, wxString> *TelephoneListPID = NULL;
2437 std::map<int, wxString> *TelephoneListTokens = NULL;
2438 std::map<int, wxString> *TelephoneListTypeInfo = NULL;
2439 std::map<int, int> *TelephoneListPref = NULL;
2443 TelephoneList = &GeneralTelephoneList;
2444 TelephoneListType = &GeneralTelephoneListType;
2445 TelephoneListAltID = &GeneralTelephoneListAltID;
2446 TelephoneListPID = &GeneralTelephoneListPID;
2447 TelephoneListTokens = &GeneralTelephoneListTokens;
2448 TelephoneListTypeInfo = &GeneralTelephoneListTypeInfo;
2449 TelephoneListPref = &GeneralTelephoneListPref;
2452 TelephoneList = &HomeTelephoneList;
2453 TelephoneListType = &HomeTelephoneListType;
2454 TelephoneListAltID = &HomeTelephoneListAltID;
2455 TelephoneListPID = &HomeTelephoneListPID;
2456 TelephoneListTokens = &HomeTelephoneListTokens;
2457 TelephoneListTypeInfo = &HomeTelephoneListTypeInfo;
2458 TelephoneListPref = &HomeTelephoneListPref;
2461 TelephoneList = &BusinessTelephoneList;
2462 TelephoneListType = &BusinessTelephoneListType;
2463 TelephoneListAltID = &BusinessTelephoneListAltID;
2464 TelephoneListPID = &BusinessTelephoneListPID;
2465 TelephoneListTokens = &BusinessTelephoneListTokens;
2466 TelephoneListTypeInfo = &BusinessTelephoneListTypeInfo;
2467 TelephoneListPref = &BusinessTelephoneListPref;
2471 // Process the properties.
2473 bool FirstToken = TRUE;
2476 SplitPoints.clear();
2477 SplitLength.clear();
2479 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2483 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2484 intiter != SplitPoints.end(); ++intiter){
2486 SLiter = SplitLength.find(intiter->first);
2488 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2490 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2491 PropertyName = PropertyElement.GetNextToken();
2492 PropertyValue = PropertyElement.GetNextToken();
2494 intPrevValue = intiter->second;
2496 CaptureString(&PropertyValue, FALSE);
2498 // Process properties.
2500 if (PropertyName == wxT("ALTID")){
2502 TelephoneListAltID->erase(*TelephoneCount);
2503 TelephoneListAltID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2505 } else if (PropertyName == wxT("PID")){
2507 TelephoneListPID->erase(*TelephoneCount);
2508 TelephoneListPID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2510 } else if (PropertyName == wxT("PREF")){
2512 ProcessIntegerValue(TelephoneListPref, &PropertyValue, TelephoneCount);
2516 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2518 if (FirstToken == TRUE){
2520 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2525 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2535 TelephoneList->insert(std::make_pair(*TelephoneCount, PropertySeg2));
2536 TelephoneListTypeInfo->insert(std::make_pair(*TelephoneCount, TelTypeUI));
2538 // Add the name token data.
2540 if (!PropertyTokens.IsEmpty()){
2542 TelephoneListTokens->insert(std::make_pair(*TelephoneCount, PropertyTokens));
2548 void ContactDataObject::ProcessLanguage(wxString PropertySeg1, wxString PropertySeg2, int *LanguageCount){
2550 std::map<int, int> SplitPoints;
2551 std::map<int, int> SplitLength;
2553 int intPrevValue = 6;
2556 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2560 PropertyType PropType = PROPERTY_NONE;
2562 // Look for type before continuing.
2564 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2566 std::map<int, wxString> *LanguageList = NULL;
2567 std::map<int, wxString> *LanguageListType = NULL;
2568 std::map<int, wxString> *LanguageListAltID = NULL;
2569 std::map<int, wxString> *LanguageListPID = NULL;
2570 std::map<int, wxString> *LanguageListTokens = NULL;
2571 std::map<int, int> *LanguageListPref = NULL;
2575 LanguageList = &GeneralLanguageList;
2576 LanguageListType = &GeneralLanguageListType;
2577 LanguageListAltID = &GeneralLanguageListAltID;
2578 LanguageListPID = &GeneralLanguageListPID;
2579 LanguageListTokens = &GeneralLanguageListTokens;
2580 LanguageListPref = &GeneralLanguageListPref;
2583 LanguageList = &HomeLanguageList;
2584 LanguageListType = &HomeLanguageListType;
2585 LanguageListAltID = &HomeLanguageListAltID;
2586 LanguageListPID = &HomeLanguageListPID;
2587 LanguageListTokens = &HomeLanguageListTokens;
2588 LanguageListPref = &HomeLanguageListPref;
2591 LanguageList = &BusinessLanguageList;
2592 LanguageListType = &BusinessLanguageListType;
2593 LanguageListAltID = &BusinessLanguageListAltID;
2594 LanguageListPID = &BusinessLanguageListPID;
2595 LanguageListTokens = &BusinessLanguageListTokens;
2596 LanguageListPref = &BusinessLanguageListPref;
2602 std::map<int,int>::iterator SLiter;
2603 wxString PropertyData;
2604 wxString PropertyName;
2605 wxString PropertyValue;
2606 wxString PropertyTokens;
2607 bool FirstToken = TRUE;
2609 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2610 intiter != SplitPoints.end(); ++intiter){
2612 SLiter = SplitLength.find(intiter->first);
2614 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2616 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2617 PropertyName = PropertyElement.GetNextToken();
2618 PropertyValue = PropertyElement.GetNextToken();
2620 intPrevValue = intiter->second;
2622 CaptureString(&PropertyValue, FALSE);
2624 // Process properties.
2626 if (PropertyName == wxT("ALTID")){
2628 LanguageListAltID->erase(*LanguageCount);
2629 LanguageListAltID->insert(std::make_pair(*LanguageCount, PropertyValue));
2631 } else if (PropertyName == wxT("PID")){
2633 LanguageListPID->erase(*LanguageCount);
2634 LanguageListPID->insert(std::make_pair(*LanguageCount, PropertyValue));
2636 } else if (PropertyName == wxT("PREF")){
2638 ProcessIntegerValue(LanguageListPref, &PropertyValue, LanguageCount);
2642 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2644 if (FirstToken == TRUE){
2646 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2651 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2661 LanguageList->insert(std::make_pair(*LanguageCount, PropertySeg2));
2663 // Add the name token data.
2665 if (!PropertyTokens.IsEmpty()){
2667 LanguageListTokens->insert(std::make_pair(*LanguageCount, PropertyTokens));
2673 void ContactDataObject::ProcessGeographic(wxString PropertySeg1, wxString PropertySeg2, int *GeographicCount){
2675 std::map<int, int> SplitPoints;
2676 std::map<int, int> SplitLength;
2678 int intPrevValue = 5;
2681 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2685 PropertyType PropType = PROPERTY_NONE;
2687 // Look for type before continuing.
2689 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2691 std::map<int, wxString> *GeopositionList = NULL;
2692 std::map<int, wxString> *GeopositionListType = NULL;
2693 std::map<int, wxString> *GeopositionListAltID = NULL;
2694 std::map<int, wxString> *GeopositionListPID = NULL;
2695 std::map<int, wxString> *GeopositionListTokens = NULL;
2696 std::map<int, wxString> *GeopositionListMediatype = NULL;
2697 std::map<int, int> *GeopositionListPref = NULL;
2701 GeopositionList = &GeneralGeographyList;
2702 GeopositionListType = &GeneralGeographyListType;
2703 GeopositionListAltID = &GeneralGeographyListAltID;
2704 GeopositionListPID = &GeneralGeographyListPID;
2705 GeopositionListTokens = &GeneralGeographyListTokens;
2706 GeopositionListMediatype = &GeneralGeographyListMediatype;
2707 GeopositionListPref = &GeneralGeographyListPref;
2710 GeopositionList = &HomeGeographyList;
2711 GeopositionListType = &HomeGeographyListType;
2712 GeopositionListAltID = &HomeGeographyListAltID;
2713 GeopositionListPID = &HomeGeographyListPID;
2714 GeopositionListTokens = &HomeGeographyListTokens;
2715 GeopositionListMediatype = &HomeGeographyListMediatype;
2716 GeopositionListPref = &HomeGeographyListPref;
2719 GeopositionList = &BusinessGeographyList;
2720 GeopositionListType = &BusinessGeographyListType;
2721 GeopositionListAltID = &BusinessGeographyListAltID;
2722 GeopositionListPID = &BusinessGeographyListPID;
2723 GeopositionListTokens = &BusinessGeographyListTokens;
2724 GeopositionListMediatype = &BusinessGeographyListMediatype;
2725 GeopositionListPref = &BusinessGeographyListPref;
2731 std::map<int,int>::iterator SLiter;
2732 wxString PropertyData;
2733 wxString PropertyName;
2734 wxString PropertyValue;
2735 wxString PropertyTokens;
2736 bool FirstToken = TRUE;
2738 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2739 intiter != SplitPoints.end(); ++intiter){
2741 SLiter = SplitLength.find(intiter->first);
2743 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2745 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2746 PropertyName = PropertyElement.GetNextToken();
2747 PropertyValue = PropertyElement.GetNextToken();
2749 intPrevValue = intiter->second;
2751 CaptureString(&PropertyValue, FALSE);
2753 // Process properties.
2755 if (PropertyName == wxT("ALTID")){
2757 GeopositionListAltID->erase(*GeographicCount);
2758 GeopositionListAltID->insert(std::make_pair(*GeographicCount, PropertyValue));
2760 } else if (PropertyName == wxT("PID")){
2762 GeopositionListPID->erase(*GeographicCount);
2763 GeopositionListPID->insert(std::make_pair(*GeographicCount, PropertyValue));
2765 } else if (PropertyName == wxT("MEDIATYPE")){
2767 GeopositionListMediatype->erase(*GeographicCount);
2768 GeopositionListMediatype->insert(std::make_pair(*GeographicCount, PropertyValue));
2770 } else if (PropertyName == wxT("PREF")){
2772 ProcessIntegerValue(GeopositionListPref, &PropertyValue, GeographicCount);
2776 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2778 if (FirstToken == TRUE){
2780 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2785 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2795 GeopositionList->insert(std::make_pair(*GeographicCount, PropertySeg2));
2797 // Add the name token data.
2799 if (!PropertyTokens.IsEmpty()){
2801 GeopositionListTokens->insert(std::make_pair(*GeographicCount, PropertyTokens));
2807 void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertySeg2, int *RelatedCount){
2809 size_t intPropertyLen = PropertySeg1.Len();
2810 std::map<int, int> SplitPoints;
2811 std::map<int, int> SplitLength;
2812 std::map<int, int>::iterator SLiter;
2813 wxString PropertyData;
2814 wxString PropertyName;
2815 wxString PropertyValue;
2816 wxString PropertyTokens;
2817 wxString RelatedType;
2818 wxString RelatedTypeOriginal;
2819 wxString RelatedName;
2820 bool FirstToken = TRUE;
2821 int intSplitsFound = 0;
2822 int intSplitSize = 0;
2823 int intPrevValue = 9;
2827 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2831 // Look for type before continuing.
2833 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2834 intiter != SplitPoints.end(); ++intiter){
2836 SLiter = SplitLength.find(intiter->first);
2838 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2840 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2841 PropertyName = PropertyElement.GetNextToken();
2842 PropertyValue = PropertyElement.GetNextToken();
2844 intPrevValue = intiter->second;
2848 RelatedTypeOriginal = PropertyValue;
2850 if (PropertyName == wxT("TYPE")){
2852 if (PropertyValue == wxT("contact")){
2854 RelatedType = _("Contact");
2856 } else if (PropertyValue == wxT("acquaintance")){
2858 RelatedType = _("Acquaintance");
2860 } else if (PropertyValue == wxT("friend")){
2862 RelatedType = _("Friend");
2864 } else if (PropertyValue == wxT("met")){
2866 RelatedType = _("Met");
2868 } else if (PropertyValue == wxT("co-worker")){
2870 RelatedType = _("Co-worker");
2872 } else if (PropertyValue == wxT("colleague")){
2874 RelatedType = _("Colleague");
2876 } else if (PropertyValue == wxT("co-resident")){
2878 RelatedType = _("Co-resident");
2880 } else if (PropertyValue == wxT("neighbor")){
2882 RelatedType = _("Neighbour");
2884 } else if (PropertyValue == wxT("child")){
2886 RelatedType = _("Child");
2888 } else if (PropertyValue == wxT("parent")){
2890 RelatedType = _("Parent");
2892 } else if (PropertyValue == wxT("sibling")){
2894 RelatedType = _("Sibling");
2896 } else if (PropertyValue == wxT("spouse")){
2898 RelatedType = _("Spouse");
2900 } else if (PropertyValue == wxT("kin")){
2902 RelatedType = _("Kin");
2904 } else if (PropertyValue == wxT("muse")){
2906 RelatedType = _("Muse");
2908 } else if (PropertyValue == wxT("crush")){
2910 RelatedType = _("Crush");
2912 } else if (PropertyValue == wxT("date")){
2914 RelatedType = _("Date");
2916 } else if (PropertyValue == wxT("sweetheart")){
2918 RelatedType = _("Sweetheart");
2920 } else if (PropertyValue == wxT("me")){
2922 RelatedType = _("Me");
2924 } else if (PropertyValue == wxT("agent")){
2926 RelatedType = _("Agent");
2928 } else if (PropertyValue == wxT("emergency")){
2930 RelatedType = _("Emergency");
2934 RelatedType = PropertyValue;
2944 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2945 intiter != SplitPoints.end(); ++intiter){
2947 SLiter = SplitLength.find(intiter->first);
2949 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2951 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2952 PropertyName = PropertyElement.GetNextToken();
2953 PropertyValue = PropertyElement.GetNextToken();
2955 intPrevValue = intiter->second;
2957 // Process properties.
2959 size_t intPropertyValueLen = PropertyValue.Len();
2961 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2963 PropertyValue.Trim();
2964 PropertyValue.RemoveLast();
2968 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2970 PropertyValue.Remove(0, 1);
2974 CaptureString(&PropertyValue, FALSE);
2976 if (PropertyName == wxT("ALTID")){
2978 GeneralRelatedListAltID.erase(*RelatedCount);
2979 GeneralRelatedListAltID.insert(std::make_pair(*RelatedCount, PropertyValue));
2981 } else if (PropertyName == wxT("PID")){
2983 GeneralRelatedListPID.erase(*RelatedCount);
2984 GeneralRelatedListPID.insert(std::make_pair(*RelatedCount, PropertyValue));
2986 } else if (PropertyName == wxT("PREF")){
2988 int PriorityNumber = 0;
2989 bool ValidNumber = TRUE;
2992 PriorityNumber = std::stoi(PropertyValue.ToStdString());
2995 catch(std::invalid_argument &e){
2996 ValidNumber = FALSE;
2999 if (ValidNumber == TRUE){
3001 GeneralRelatedListPref.erase(*RelatedCount);
3002 GeneralRelatedListPref.insert(std::make_pair(*RelatedCount, PriorityNumber));
3006 } else if (PropertyName == wxT("LANGUAGE")){
3008 ProcessIntegerValue(&GeneralRelatedListPref, &PropertyValue, RelatedCount);
3010 } else if (PropertyName != wxT("TYPE")) {
3012 // Something else we don't know about so append
3013 // to the tokens variable.
3015 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3017 if (FirstToken == TRUE){
3019 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3024 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3034 // Add the data to the General/Home/Work address variables.
3036 GeneralRelatedList.erase(*RelatedCount);
3037 GeneralRelatedListRelType.erase(*RelatedCount);
3038 GeneralRelatedListType.erase(*RelatedCount);
3039 GeneralRelatedListTokens.erase(*RelatedCount);
3040 GeneralRelatedList.insert(std::make_pair(*RelatedCount, PropertySeg2));
3041 GeneralRelatedListRelType.insert(std::make_pair(*RelatedCount, RelatedType));
3042 GeneralRelatedListType.insert(std::make_pair(*RelatedCount, RelatedType));
3043 GeneralRelatedListTokens.insert(std::make_pair(*RelatedCount, PropertyTokens));
3047 void ContactDataObject::ProcessURL(wxString PropertySeg1, wxString PropertySeg2, int *URLCount){
3049 std::map<int, int> SplitPoints;
3050 std::map<int, int> SplitLength;
3051 std::map<int, int>::iterator SLiter;
3052 wxString PropertyData;
3053 wxString PropertyName;
3054 wxString PropertyValue;
3055 wxString PropertyTokens;
3056 bool FirstToken = TRUE;
3057 int intPrevValue = 5;
3062 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3066 PropertyType PropType = PROPERTY_NONE;
3068 // Look for type before continuing.
3070 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3072 // Setup the pointers.
3074 std::map<int, wxString> *WebsiteList = NULL;
3075 std::map<int, wxString> *WebsiteListAltID = NULL;
3076 std::map<int, wxString> *WebsiteListPID = NULL;
3077 std::map<int, wxString> *WebsiteListType = NULL;
3078 std::map<int, wxString> *WebsiteListTokens = NULL;
3079 std::map<int, wxString> *WebsiteListMediatype = NULL;
3080 std::map<int, int> *WebsiteListPref = NULL;
3082 // Setup blank lines for later on.
3086 WebsiteList = &GeneralWebsiteList;
3087 WebsiteListType = &GeneralWebsiteListType;
3088 WebsiteListAltID = &GeneralWebsiteListAltID;
3089 WebsiteListPID = &GeneralWebsiteListPID;
3090 WebsiteListTokens = &GeneralWebsiteListTokens;
3091 WebsiteListMediatype = &GeneralWebsiteListMediatype;
3092 WebsiteListPref = &GeneralWebsiteListPref;
3095 WebsiteList = &HomeWebsiteList;
3096 WebsiteListType = &HomeWebsiteListType;
3097 WebsiteListAltID = &HomeWebsiteListAltID;
3098 WebsiteListPID = &HomeWebsiteListPID;
3099 WebsiteListTokens = &HomeWebsiteListTokens;
3100 WebsiteListMediatype = &HomeWebsiteListMediatype;
3101 WebsiteListPref = &HomeWebsiteListPref;
3104 WebsiteList = &BusinessWebsiteList;
3105 WebsiteListType = &BusinessWebsiteListType;
3106 WebsiteListAltID = &BusinessWebsiteListAltID;
3107 WebsiteListPID = &BusinessWebsiteListPID;
3108 WebsiteListTokens = &BusinessWebsiteListTokens;
3109 WebsiteListMediatype = &BusinessWebsiteListMediatype;
3110 WebsiteListPref = &BusinessWebsiteListPref;
3116 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3117 intiter != SplitPoints.end(); ++intiter){
3119 SLiter = SplitLength.find(intiter->first);
3121 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3123 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3124 PropertyName = PropertyElement.GetNextToken();
3125 PropertyValue = PropertyElement.GetNextToken();
3127 intPrevValue = intiter->second;
3129 // Process properties.
3131 size_t intPropertyValueLen = PropertyValue.Len();
3133 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3135 PropertyValue.Trim();
3136 PropertyValue.RemoveLast();
3140 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3142 PropertyValue.Remove(0, 1);
3146 CaptureString(&PropertyValue, FALSE);
3148 if (PropertyName == wxT("ALTID")){
3150 WebsiteListAltID->erase(*URLCount);
3151 WebsiteListAltID->insert(std::make_pair(*URLCount, PropertyValue));
3153 } else if (PropertyName == wxT("PID")){
3155 WebsiteListPID->erase(*URLCount);
3156 WebsiteListPID->insert(std::make_pair(*URLCount, PropertyValue));
3158 } else if (PropertyName == wxT("PREF")){
3160 ProcessIntegerValue(WebsiteListPref, &PropertyValue, URLCount);
3162 } else if (PropertyName == wxT("MEDIATYPE")){
3164 WebsiteListMediatype->erase(*URLCount);
3165 WebsiteListMediatype->insert(std::make_pair(*URLCount, PropertyValue));
3169 // Something else we don't know about so append
3170 // to the tokens variable.
3172 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3174 if (FirstToken == TRUE){
3176 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3181 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3191 // Add the data to the General/Home/Work address variables.
3193 CaptureString(&PropertySeg2, FALSE);
3195 WebsiteList->insert(std::make_pair(*URLCount, PropertySeg2));
3197 if (!PropertyTokens.IsEmpty()){
3199 WebsiteListTokens->insert(std::make_pair(*URLCount, PropertyTokens));
3205 void ContactDataObject::ProcessTitle(wxString PropertySeg1, wxString PropertySeg2, int *TitleCount){
3207 std::map<int, int> SplitPoints;
3208 std::map<int, int> SplitLength;
3209 std::map<int, int>::iterator SLiter;
3210 wxString PropertyData;
3211 wxString PropertyName;
3212 wxString PropertyValue;
3213 wxString PropertyTokens;
3214 bool FirstToken = TRUE;
3215 int intPrevValue = 7;
3220 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3224 PropertyType PropType = PROPERTY_NONE;
3226 // Look for type before continuing.
3228 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3230 // Setup the pointers.
3232 std::map<int, wxString> *TitleList = NULL;
3233 std::map<int, wxString> *TitleListAltID = NULL;
3234 std::map<int, wxString> *TitleListPID = NULL;
3235 std::map<int, wxString> *TitleListType = NULL;
3236 std::map<int, wxString> *TitleListTokens = NULL;
3237 std::map<int, wxString> *TitleListLanguage = NULL;
3238 std::map<int, int> *TitleListPref = NULL;
3240 // Setup blank lines for later on.
3244 TitleList = &GeneralTitleList;
3245 TitleListType = &GeneralTitleListType;
3246 TitleListAltID = &GeneralTitleListAltID;
3247 TitleListPID = &GeneralTitleListPID;
3248 TitleListTokens = &GeneralTitleListTokens;
3249 TitleListLanguage = &GeneralTitleListLanguage;
3250 TitleListPref = &GeneralTitleListPref;
3253 TitleList = &HomeTitleList;
3254 TitleListType = &HomeTitleListType;
3255 TitleListAltID = &HomeTitleListAltID;
3256 TitleListPID = &HomeTitleListPID;
3257 TitleListTokens = &HomeTitleListTokens;
3258 TitleListLanguage = &HomeTitleListLanguage;
3259 TitleListPref = &HomeTitleListPref;
3262 TitleList = &BusinessTitleList;
3263 TitleListType = &BusinessTitleListType;
3264 TitleListAltID = &BusinessTitleListAltID;
3265 TitleListPID = &BusinessTitleListPID;
3266 TitleListTokens = &BusinessTitleListTokens;
3267 TitleListLanguage = &BusinessTitleListLanguage;
3268 TitleListPref = &BusinessTitleListPref;
3274 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3275 intiter != SplitPoints.end(); ++intiter){
3277 SLiter = SplitLength.find(intiter->first);
3279 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3281 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3282 PropertyName = PropertyElement.GetNextToken();
3283 PropertyValue = PropertyElement.GetNextToken();
3285 intPrevValue = intiter->second;
3287 // Process properties.
3289 size_t intPropertyValueLen = PropertyValue.Len();
3291 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3293 PropertyValue.Trim();
3294 PropertyValue.RemoveLast();
3298 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3300 PropertyValue.Remove(0, 1);
3304 CaptureString(&PropertyValue, FALSE);
3306 if (PropertyName == wxT("ALTID")){
3308 TitleListAltID->erase(*TitleCount);
3309 TitleListAltID->insert(std::make_pair(*TitleCount, PropertyValue));
3311 } else if (PropertyName == wxT("PID")){
3313 TitleListPID->erase(*TitleCount);
3314 TitleListPID->insert(std::make_pair(*TitleCount, PropertyValue));
3316 } else if (PropertyName == wxT("PREF")){
3318 ProcessIntegerValue(TitleListPref, &PropertyValue, TitleCount);
3320 } else if (PropertyName == wxT("LANGUAGE")){
3322 TitleListLanguage->erase(*TitleCount);
3323 TitleListLanguage->insert(std::make_pair(*TitleCount, PropertyValue));
3327 // Something else we don't know about so append
3328 // to the tokens variable.
3330 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3332 if (FirstToken == TRUE){
3334 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3339 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3349 // Add the data to the General/Home/Work address variables.
3351 CaptureString(&PropertySeg2, FALSE);
3353 TitleList->insert(std::make_pair(*TitleCount, PropertySeg2));
3355 if (!PropertyTokens.IsEmpty()){
3357 TitleListTokens->insert(std::make_pair(*TitleCount, PropertyTokens));
3363 void ContactDataObject::ProcessRole(wxString PropertySeg1, wxString PropertySeg2, int *RoleCount){
3365 std::map<int, int> SplitPoints;
3366 std::map<int, int> SplitLength;
3367 std::map<int, int>::iterator SLiter;
3368 wxString PropertyData;
3369 wxString PropertyName;
3370 wxString PropertyValue;
3371 wxString PropertyTokens;
3372 bool FirstToken = TRUE;
3373 int intPrevValue = 6;
3378 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3382 PropertyType PropType = PROPERTY_NONE;
3384 // Look for type before continuing.
3386 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3388 // Setup the pointers.
3390 std::map<int, wxString> *RoleList = NULL;
3391 std::map<int, wxString> *RoleListAltID = NULL;
3392 std::map<int, wxString> *RoleListPID = NULL;
3393 std::map<int, wxString> *RoleListType = NULL;
3394 std::map<int, wxString> *RoleListTokens = NULL;
3395 std::map<int, wxString> *RoleListLanguage = NULL;
3396 std::map<int, int> *RoleListPref = NULL;
3398 // Setup blank lines for later on.
3402 RoleList = &GeneralRoleList;
3403 RoleListType = &GeneralRoleListType;
3404 RoleListAltID = &GeneralRoleListAltID;
3405 RoleListPID = &GeneralRoleListPID;
3406 RoleListTokens = &GeneralRoleListTokens;
3407 RoleListLanguage = &GeneralRoleListLanguage;
3408 RoleListPref = &GeneralRoleListPref;
3411 RoleList = &HomeRoleList;
3412 RoleListType = &HomeRoleListType;
3413 RoleListAltID = &HomeRoleListAltID;
3414 RoleListPID = &HomeRoleListPID;
3415 RoleListTokens = &HomeRoleListTokens;
3416 RoleListLanguage = &HomeRoleListLanguage;
3417 RoleListPref = &HomeRoleListPref;
3420 RoleList = &BusinessRoleList;
3421 RoleListType = &BusinessRoleListType;
3422 RoleListAltID = &BusinessRoleListAltID;
3423 RoleListPID = &BusinessRoleListPID;
3424 RoleListTokens = &BusinessRoleListTokens;
3425 RoleListLanguage = &BusinessRoleListLanguage;
3426 RoleListPref = &BusinessRoleListPref;
3432 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3433 intiter != SplitPoints.end(); ++intiter){
3435 SLiter = SplitLength.find(intiter->first);
3437 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3439 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3440 PropertyName = PropertyElement.GetNextToken();
3441 PropertyValue = PropertyElement.GetNextToken();
3443 intPrevValue = intiter->second;
3445 // Process properties.
3447 size_t intPropertyValueLen = PropertyValue.Len();
3449 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3451 PropertyValue.Trim();
3452 PropertyValue.RemoveLast();
3456 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3458 PropertyValue.Remove(0, 1);
3462 CaptureString(&PropertyValue, FALSE);
3464 if (PropertyName == wxT("ALTID")){
3466 RoleListAltID->erase(*RoleCount);
3467 RoleListAltID->insert(std::make_pair(*RoleCount, PropertyValue));
3469 } else if (PropertyName == wxT("PID")){
3471 RoleListPID->erase(*RoleCount);
3472 RoleListPID->insert(std::make_pair(*RoleCount, PropertyValue));
3474 } else if (PropertyName == wxT("PREF")){
3476 ProcessIntegerValue(RoleListPref, &PropertyValue, RoleCount);
3478 } else if (PropertyName == wxT("LANGUAGE")){
3480 RoleListLanguage->erase(*RoleCount);
3481 RoleListLanguage->insert(std::make_pair(*RoleCount, PropertyValue));
3485 // Something else we don't know about so append
3486 // to the tokens variable.
3488 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3490 if (FirstToken == TRUE){
3492 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3497 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3507 // Add the data to the General/Home/Work address variables.
3509 CaptureString(&PropertySeg2, FALSE);
3511 RoleList->insert(std::make_pair(*RoleCount, PropertySeg2));
3513 if (!PropertyTokens.IsEmpty()){
3515 RoleListTokens->insert(std::make_pair(*RoleCount, PropertyTokens));
3521 void ContactDataObject::ProcessOrganisation(wxString PropertySeg1, wxString PropertySeg2, int *OrganisationCount){
3523 std::map<int, int> SplitPoints;
3524 std::map<int, int> SplitLength;
3525 std::map<int, int>::iterator SLiter;
3526 wxString PropertyData;
3527 wxString PropertyName;
3528 wxString PropertyValue;
3529 wxString PropertyTokens;
3530 bool FirstToken = TRUE;
3531 int intPrevValue = 5;
3536 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3540 PropertyType PropType = PROPERTY_NONE;
3542 // Look for type before continuing.
3544 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3546 // Setup the pointers.
3548 std::map<int, wxString> *OrganisationsList = NULL;
3549 std::map<int, wxString> *OrganisationsListAltID = NULL;
3550 std::map<int, wxString> *OrganisationsListPID = NULL;
3551 std::map<int, wxString> *OrganisationsListType = NULL;
3552 std::map<int, wxString> *OrganisationsListTokens = NULL;
3553 std::map<int, wxString> *OrganisationsListLanguage = NULL;
3554 std::map<int, wxString> *OrganisationsListSortAs = NULL;
3555 std::map<int, int> *OrganisationsListPref = NULL;
3557 // Setup blank lines for later on.
3561 OrganisationsList = &GeneralOrganisationsList;
3562 OrganisationsListType = &GeneralOrganisationsListType;
3563 OrganisationsListAltID = &GeneralOrganisationsListAltID;
3564 OrganisationsListPID = &GeneralOrganisationsListPID;
3565 OrganisationsListTokens = &GeneralOrganisationsListTokens;
3566 OrganisationsListLanguage = &GeneralOrganisationsListLanguage;
3567 OrganisationsListSortAs = &GeneralOrganisationsListSortAs;
3568 OrganisationsListPref = &GeneralOrganisationsListPref;
3571 OrganisationsList = &HomeOrganisationsList;
3572 OrganisationsListType = &HomeOrganisationsListType;
3573 OrganisationsListAltID = &HomeOrganisationsListAltID;
3574 OrganisationsListPID = &HomeOrganisationsListPID;
3575 OrganisationsListTokens = &HomeOrganisationsListTokens;
3576 OrganisationsListLanguage = &HomeOrganisationsListLanguage;
3577 OrganisationsListSortAs = &HomeOrganisationsListSortAs;
3578 OrganisationsListPref = &HomeOrganisationsListPref;
3581 OrganisationsList = &BusinessOrganisationsList;
3582 OrganisationsListType = &BusinessOrganisationsListType;
3583 OrganisationsListAltID = &BusinessOrganisationsListAltID;
3584 OrganisationsListPID = &BusinessOrganisationsListPID;
3585 OrganisationsListTokens = &BusinessOrganisationsListTokens;
3586 OrganisationsListLanguage = &BusinessOrganisationsListLanguage;
3587 OrganisationsListSortAs = &BusinessOrganisationsListSortAs;
3588 OrganisationsListPref = &BusinessOrganisationsListPref;
3594 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3595 intiter != SplitPoints.end(); ++intiter){
3597 SLiter = SplitLength.find(intiter->first);
3599 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3601 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3602 PropertyName = PropertyElement.GetNextToken();
3603 PropertyValue = PropertyElement.GetNextToken();
3605 intPrevValue = intiter->second;
3607 // Process properties.
3609 size_t intPropertyValueLen = PropertyValue.Len();
3611 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3613 PropertyValue.Trim();
3614 PropertyValue.RemoveLast();
3618 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3620 PropertyValue.Remove(0, 1);
3624 CaptureString(&PropertyValue, FALSE);
3626 if (PropertyName == wxT("ALTID")){
3628 OrganisationsListAltID->erase(*OrganisationCount);
3629 OrganisationsListAltID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3631 } else if (PropertyName == wxT("PID")){
3633 OrganisationsListPID->erase(*OrganisationCount);
3634 OrganisationsListPID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3636 } else if (PropertyName == wxT("SORT-AS")){
3638 OrganisationsListSortAs->erase(*OrganisationCount);
3639 OrganisationsListSortAs->insert(std::make_pair(*OrganisationCount, PropertyValue));
3641 } else if (PropertyName == wxT("PREF")){
3643 ProcessIntegerValue(OrganisationsListPref, &PropertyValue, OrganisationCount);
3645 } else if (PropertyName == wxT("LANGUAGE")){
3647 OrganisationsListLanguage->erase(*OrganisationCount);
3648 OrganisationsListLanguage->insert(std::make_pair(*OrganisationCount, PropertyValue));
3652 // Something else we don't know about so append
3653 // to the tokens variable.
3655 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3657 if (FirstToken == TRUE){
3659 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3664 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3674 // Add the data to the General/Home/Work address variables.
3676 CaptureString(&PropertySeg2, FALSE);
3678 OrganisationsList->insert(std::make_pair(*OrganisationCount, PropertySeg2));
3680 if (!PropertyTokens.IsEmpty()){
3682 OrganisationsListTokens->insert(std::make_pair(*OrganisationCount, PropertyTokens));
3688 void ContactDataObject::ProcessNote(wxString PropertySeg1, wxString PropertySeg2, int *NoteCount){
3690 std::map<int, int> SplitPoints;
3691 std::map<int, int> SplitLength;
3692 std::map<int, int>::iterator SLiter;
3693 wxString PropertyData;
3694 wxString PropertyName;
3695 wxString PropertyValue;
3696 wxString PropertyTokens;
3697 bool FirstToken = TRUE;
3698 int intPrevValue = 6;
3703 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3707 PropertyType PropType = PROPERTY_NONE;
3709 // Look for type before continuing.
3711 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3713 // Setup the pointers.
3715 std::map<int, wxString> *NoteList = NULL;
3716 std::map<int, wxString> *NoteListAltID = NULL;
3717 std::map<int, wxString> *NoteListPID = NULL;
3718 std::map<int, wxString> *NoteListType = NULL;
3719 std::map<int, wxString> *NoteListTokens = NULL;
3720 std::map<int, wxString> *NoteListLanguage = NULL;
3721 std::map<int, int> *NoteListPref = NULL;
3723 // Setup blank lines for later on.
3727 NoteList = &GeneralNoteList;
3728 NoteListType = &GeneralNoteListType;
3729 NoteListAltID = &GeneralNoteListAltID;
3730 NoteListPID = &GeneralNoteListPID;
3731 NoteListTokens = &GeneralNoteListTokens;
3732 NoteListLanguage = &GeneralNoteListLanguage;
3733 NoteListPref = &GeneralNoteListPref;
3736 NoteList = &HomeNoteList;
3737 NoteListType = &HomeNoteListType;
3738 NoteListAltID = &HomeNoteListAltID;
3739 NoteListPID = &HomeNoteListPID;
3740 NoteListTokens = &HomeNoteListTokens;
3741 NoteListLanguage = &HomeNoteListLanguage;
3742 NoteListPref = &HomeNoteListPref;
3745 NoteList = &BusinessNoteList;
3746 NoteListType = &BusinessNoteListType;
3747 NoteListAltID = &BusinessNoteListAltID;
3748 NoteListPID = &BusinessNoteListPID;
3749 NoteListTokens = &BusinessNoteListTokens;
3750 NoteListLanguage = &BusinessNoteListLanguage;
3751 NoteListPref = &BusinessNoteListPref;
3757 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3758 intiter != SplitPoints.end(); ++intiter){
3760 SLiter = SplitLength.find(intiter->first);
3762 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3764 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3765 PropertyName = PropertyElement.GetNextToken();
3766 PropertyValue = PropertyElement.GetNextToken();
3768 intPrevValue = intiter->second;
3770 // Process properties.
3772 size_t intPropertyValueLen = PropertyValue.Len();
3774 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3776 PropertyValue.Trim();
3777 PropertyValue.RemoveLast();
3781 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3783 PropertyValue.Remove(0, 1);
3787 CaptureString(&PropertyValue, FALSE);
3789 if (PropertyName == wxT("ALTID")){
3791 NoteListAltID->erase(*NoteCount);
3792 NoteListAltID->insert(std::make_pair(*NoteCount, PropertyValue));
3794 } else if (PropertyName == wxT("PID")){
3796 NoteListPID->erase(*NoteCount);
3797 NoteListPID->insert(std::make_pair(*NoteCount, PropertyValue));
3799 } else if (PropertyName == wxT("PREF")){
3801 ProcessIntegerValue(NoteListPref, &PropertyValue, NoteCount);
3803 } else if (PropertyName == wxT("LANGUAGE")){
3805 NoteListLanguage->erase(*NoteCount);
3806 NoteListLanguage->insert(std::make_pair(*NoteCount, PropertyValue));
3810 // Something else we don't know about so append
3811 // to the tokens variable.
3813 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3815 if (FirstToken == TRUE){
3817 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3822 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3832 // Add the data to the General/Home/Work address variables.
3834 CaptureString(&PropertySeg2, FALSE);
3836 NoteList->insert(std::make_pair(*NoteCount, PropertySeg2));
3838 if (!PropertyTokens.IsEmpty()){
3840 NoteListTokens->insert(std::make_pair(*NoteCount, PropertyTokens));
3846 void ContactDataObject::ProcessCategory(wxString PropertySeg1, wxString PropertySeg2, int *CategoryCount){
3848 std::map<int, int> SplitPoints;
3849 std::map<int, int> SplitLength;
3850 std::map<int, int>::iterator SLiter;
3851 wxString PropertyData;
3852 wxString PropertyName;
3853 wxString PropertyValue;
3854 wxString PropertyTokens;
3855 bool FirstToken = TRUE;
3856 int intPrevValue = 12;
3861 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3865 PropertyType PropType = PROPERTY_NONE;
3867 // Look for type before continuing.
3869 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3871 // Setup blank lines for later on.
3877 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
3880 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
3886 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3887 intiter != SplitPoints.end(); ++intiter){
3889 SLiter = SplitLength.find(intiter->first);
3891 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3893 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3894 PropertyName = PropertyElement.GetNextToken();
3895 PropertyValue = PropertyElement.GetNextToken();
3897 intPrevValue = intiter->second;
3899 // Process properties.
3901 size_t intPropertyValueLen = PropertyValue.Len();
3903 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3905 PropertyValue.Trim();
3906 PropertyValue.RemoveLast();
3910 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3912 PropertyValue.Remove(0, 1);
3916 CaptureString(&PropertyValue, FALSE);
3918 if (PropertyName == wxT("ALTID")){
3920 CategoriesListAltID.erase(*CategoryCount);
3921 CategoriesListAltID.insert(std::make_pair(*CategoryCount, PropertyValue));
3923 } else if (PropertyName == wxT("PID")){
3925 CategoriesListPID.erase(*CategoryCount);
3926 CategoriesListPID.insert(std::make_pair(*CategoryCount, PropertyValue));
3928 } else if (PropertyName == wxT("PREF")){
3930 ProcessIntegerValue(&CategoriesListPref, &PropertyValue, CategoryCount);
3932 } else if (PropertyName == wxT("LANGUAGE")){
3934 CategoriesListLanguage.erase(*CategoryCount);
3935 CategoriesListLanguage.insert(std::make_pair(*CategoryCount, PropertyValue));
3939 // Something else we don't know about so append
3940 // to the tokens variable.
3942 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3944 if (FirstToken == TRUE){
3946 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3951 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3961 // Deal with multiple categories.
3963 int intOrigCatCount = *CategoryCount;
3964 bool FirstCategoryProcessed = TRUE;
3965 bool AfterFirstToken = FALSE;
3966 int intSplitSize = 0;
3967 int intSplitsFound = 0;
3968 int intSplitSeek = 0;
3969 int intPropertyLen = PropertySeg2.Len();
3971 SplitPoints.clear();
3972 SplitLength.clear();
3975 for (int i = 0; i <= intPropertyLen; i++){
3977 if (intSplitSize == 0 && PropertySeg2.Mid(i, 1) == wxT(" ")){
3985 if (PropertySeg2.Mid(i, 1) == wxT(",") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
3987 if (AfterFirstToken == TRUE){
3989 SplitPoints.insert(std::make_pair(intSplitsFound, (i - intSplitSize + 1)));
3990 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
3994 SplitPoints.insert(std::make_pair(intSplitsFound, 0));
3995 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
3996 AfterFirstToken = TRUE;
4008 if (SplitPoints.size() > 0){
4010 SplitPoints.insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
4011 SplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
4015 if (SplitPoints.size() == 0){
4017 CategoriesList.insert(std::make_pair(*CategoryCount, PropertySeg2));
4019 if (!PropertyTokens.IsEmpty()){
4021 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4027 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4028 intiter != SplitPoints.end(); ++intiter){
4030 SLiter = SplitLength.find(intiter->first);
4032 intPrevValue = intiter->second;
4034 PropertyData = PropertySeg2.Mid(intPrevValue, (SLiter->second + 1));
4036 // Add the data to the General/Home/Work address variables.
4038 // Trim any whitespace from the start and end.
4040 PropertyData = PropertyData.Trim(FALSE);
4041 PropertyData = PropertyData.Trim(TRUE);
4043 CaptureString(&PropertyData, FALSE);
4045 if (FirstCategoryProcessed == TRUE){
4047 FirstCategoryProcessed = FALSE;
4049 CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4051 if (!PropertyTokens.IsEmpty()){
4053 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4063 CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4065 if (!PropertyTokens.IsEmpty()){
4067 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4073 // Copy the properties to each of the categories (if it exists).
4075 if (!PropertyTokens.IsEmpty()){
4077 CategoriesListTokens.insert(std::make_pair(*CategoryCount, CategoriesListTokens.find(intOrigCatCount)->second));
4081 // Check if ALTID was used.
4083 if (CategoriesListAltID.find(intOrigCatCount) != CategoriesListAltID.end()){
4085 CategoriesListAltID.insert(std::make_pair(*CategoryCount, CategoriesListAltID.find(intOrigCatCount)->second));
4089 // Check if PID was used.
4091 if (CategoriesListPID.find(intOrigCatCount) != CategoriesListPID.end()){
4093 CategoriesListPID.insert(std::make_pair(*CategoryCount, CategoriesListPID.find(intOrigCatCount)->second));
4097 // Check if PREF was used.
4099 if (CategoriesListPref.find(intOrigCatCount) != CategoriesListPref.end()){
4101 CategoriesListPref.insert(std::make_pair(*CategoryCount, CategoriesListPref.find(intOrigCatCount)->second));
4105 // Check if LANGUAGE was used.
4107 if (CategoriesListLanguage.find(intOrigCatCount) != CategoriesListLanguage.end()){
4109 CategoriesListLanguage.insert(std::make_pair(*CategoryCount, CategoriesListLanguage.find(intOrigCatCount)->second));
4113 // Check if TYPE was used.
4119 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
4122 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
4130 void ContactDataObject::ProcessPhoto(wxString PropertySeg1, wxString PropertySeg2, int *PhotoCount){
4132 size_t intPropertyLen = PropertySeg1.Len();
4133 std::map<int, int> SplitPoints;
4134 std::map<int, int> SplitLength;
4135 std::map<int, int>::iterator SLiter;
4136 wxString PropertyData;
4137 wxString PropertyName;
4138 wxString PropertyValue;
4139 wxString PropertyTokens;
4140 bool FirstToken = TRUE;
4141 int intSplitsFound = 0;
4142 int intSplitSize = 0;
4143 int intPrevValue = 7;
4147 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4151 PropertyType PropType = PROPERTY_NONE;
4153 // Look for type before continuing.
4155 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4159 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4160 intiter != SplitPoints.end(); ++intiter){
4162 SLiter = SplitLength.find(intiter->first);
4164 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4166 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4167 PropertyName = PropertyElement.GetNextToken();
4168 PropertyValue = PropertyElement.GetNextToken();
4170 intPrevValue = intiter->second;
4172 // Process properties.
4174 size_t intPropertyValueLen = PropertyValue.Len();
4176 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4178 PropertyValue.Trim();
4179 PropertyValue.RemoveLast();
4183 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4185 PropertyValue.Remove(0, 1);
4189 CaptureString(&PropertyValue, FALSE);
4191 if (PropertyName == wxT("ALTID")){
4193 PicturesListAltID.erase(*PhotoCount);
4194 PicturesListAltID.insert(std::make_pair(*PhotoCount, PropertyValue));
4196 } else if (PropertyName == wxT("PID")){
4198 PicturesListPID.erase(*PhotoCount);
4199 PicturesListPID.insert(std::make_pair(*PhotoCount, PropertyValue));
4201 } else if (PropertyName == wxT("PREF")){
4203 ProcessIntegerValue(&PicturesListPref, &PropertyValue, PhotoCount);
4205 } else if (PropertyName == wxT("MEDIATYPE")){
4207 PicturesListMediatype.erase(*PhotoCount);
4208 PicturesListMediatype.insert(std::make_pair(*PhotoCount, PropertyValue));
4212 // Something else we don't know about so append
4213 // to the tokens variable.
4215 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4217 if (FirstToken == TRUE){
4219 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4224 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4234 intPropertyLen = PropertySeg2.Len();
4235 SplitPoints.clear();
4236 SplitLength.clear();
4241 CaptureString(&PropertySeg2, FALSE);
4243 for (int i = 0; i <= intPropertyLen; i++){
4247 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4250 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4252 if (intSplitsFound == 6){
4254 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4259 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4269 wxString wxSPhotoURI;
4270 wxString wxSPhotoMIME;
4271 wxString wxSPhotoEncoding;
4272 wxString wxSPhotoData;
4273 std::string base64enc;
4275 if (intSplitsFound == 0){
4279 std::map<int, int>::iterator striter;
4281 striter = SplitLength.find(1);
4283 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4285 while (wSTDataType.HasMoreTokens() == TRUE){
4287 wxSPhotoURI = wSTDataType.GetNextToken();
4288 wxSPhotoMIME = wSTDataType.GetNextToken();
4293 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
4295 while (wSTDataInfo.HasMoreTokens() == TRUE){
4297 wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4298 wxSPhotoData = wSTDataInfo.GetNextToken();
4299 base64enc = wxSPhotoData.mb_str();
4306 // Add the data to the General/Home/Work address variables.
4308 PicturesList.insert(std::make_pair(*PhotoCount, base64enc));
4309 PicturesListPictureType.insert(std::make_pair(*PhotoCount, wxSPhotoMIME));
4310 PicturesListPicEncType.insert(std::make_pair(*PhotoCount, wxSPhotoEncoding));
4316 PicturesListType.insert(std::make_pair(*PhotoCount, "home"));
4319 PicturesListType.insert(std::make_pair(*PhotoCount, "work"));
4323 if (!PropertyTokens.IsEmpty()){
4325 PicturesListTokens.insert(std::make_pair(*PhotoCount, PropertyTokens));
4331 void ContactDataObject::ProcessLogo(wxString PropertySeg1, wxString PropertySeg2, int *LogoCount){
4333 size_t intPropertyLen = PropertySeg1.Len();
4334 std::map<int, int> SplitPoints;
4335 std::map<int, int> SplitLength;
4336 std::map<int, int>::iterator SLiter;
4337 wxString PropertyData;
4338 wxString PropertyName;
4339 wxString PropertyValue;
4340 wxString PropertyTokens;
4341 bool FirstToken = TRUE;
4342 int intSplitsFound = 0;
4343 int intSplitSize = 0;
4344 int intPrevValue = 6;
4348 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4352 PropertyType PropType = PROPERTY_NONE;
4354 // Look for type before continuing.
4356 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4360 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4361 intiter != SplitPoints.end(); ++intiter){
4363 SLiter = SplitLength.find(intiter->first);
4365 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4367 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4368 PropertyName = PropertyElement.GetNextToken();
4369 PropertyValue = PropertyElement.GetNextToken();
4371 intPrevValue = intiter->second;
4373 // Process properties.
4375 size_t intPropertyValueLen = PropertyValue.Len();
4377 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4379 PropertyValue.Trim();
4380 PropertyValue.RemoveLast();
4384 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4386 PropertyValue.Remove(0, 1);
4390 CaptureString(&PropertyValue, FALSE);
4392 if (PropertyName == wxT("ALTID")){
4394 LogosListAltID.erase(*LogoCount);
4395 LogosListAltID.insert(std::make_pair(*LogoCount, PropertyValue));
4397 } else if (PropertyName == wxT("PID")){
4399 LogosListPID.erase(*LogoCount);
4400 LogosListPID.insert(std::make_pair(*LogoCount, PropertyValue));
4402 } else if (PropertyName == wxT("PREF")){
4404 ProcessIntegerValue(&LogosListPref, &PropertyValue, LogoCount);
4406 } else if (PropertyName == wxT("MEDIATYPE")){
4408 LogosListMediatype.erase(*LogoCount);
4409 LogosListMediatype.insert(std::make_pair(*LogoCount, PropertyValue));
4413 // Something else we don't know about so append
4414 // to the tokens variable.
4416 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4418 if (FirstToken == TRUE){
4420 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4425 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4435 intPropertyLen = PropertySeg2.Len();
4436 SplitPoints.clear();
4437 SplitLength.clear();
4442 CaptureString(&PropertySeg2, FALSE);
4444 for (int i = 0; i <= intPropertyLen; i++){
4448 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4451 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4453 if (intSplitsFound == 6){
4455 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4460 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4470 wxString wxSPhotoURI;
4471 wxString wxSPhotoMIME;
4472 wxString wxSPhotoEncoding;
4473 wxString wxSPhotoData;
4474 std::string base64enc;
4476 if (intSplitsFound == 0){
4480 std::map<int, int>::iterator striter;
4482 striter = SplitLength.find(1);
4484 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4486 while (wSTDataType.HasMoreTokens() == TRUE){
4488 wxSPhotoURI = wSTDataType.GetNextToken();
4489 wxSPhotoMIME = wSTDataType.GetNextToken();
4494 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
4496 while (wSTDataInfo.HasMoreTokens() == TRUE){
4498 wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4499 wxSPhotoData = wSTDataInfo.GetNextToken();
4500 base64enc = wxSPhotoData.mb_str();
4507 // Add the data to the General/Home/Work address variables.
4509 LogosList.insert(std::make_pair(*LogoCount, base64enc));
4510 LogosListPictureType.insert(std::make_pair(*LogoCount, wxSPhotoMIME));
4511 LogosListPicEncType.insert(std::make_pair(*LogoCount, wxSPhotoEncoding));
4517 LogosListType.insert(std::make_pair(*LogoCount, "home"));
4520 LogosListType.insert(std::make_pair(*LogoCount, "work"));
4524 if (!PropertyTokens.IsEmpty()){
4526 LogosListTokens.insert(std::make_pair(*LogoCount, PropertyTokens));
4532 void ContactDataObject::ProcessSound(wxString PropertySeg1, wxString PropertySeg2, int *SoundCount){
4534 size_t intPropertyLen = PropertySeg1.Len();
4535 std::map<int, int> SplitPoints;
4536 std::map<int, int> SplitLength;
4537 std::map<int, int>::iterator SLiter;
4538 wxString PropertyData;
4539 wxString PropertyName;
4540 wxString PropertyValue;
4541 wxString PropertyTokens;
4542 bool FirstToken = TRUE;
4543 int intSplitsFound = 0;
4544 int intSplitSize = 0;
4545 int intPrevValue = 7;
4549 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4553 PropertyType PropType = PROPERTY_NONE;
4555 // Look for type before continuing.
4557 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4561 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4562 intiter != SplitPoints.end(); ++intiter){
4564 SLiter = SplitLength.find(intiter->first);
4566 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4568 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4569 PropertyName = PropertyElement.GetNextToken();
4570 PropertyValue = PropertyElement.GetNextToken();
4572 intPrevValue = intiter->second;
4574 // Process properties.
4576 size_t intPropertyValueLen = PropertyValue.Len();
4578 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4580 PropertyValue.Trim();
4581 PropertyValue.RemoveLast();
4585 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4587 PropertyValue.Remove(0, 1);
4591 CaptureString(&PropertyValue, FALSE);
4593 if (PropertyName == wxT("ALTID")){
4595 SoundsListAltID.erase(*SoundCount);
4596 SoundsListAltID.insert(std::make_pair(*SoundCount, PropertyValue));
4598 } else if (PropertyName == wxT("PID")){
4600 SoundsListPID.erase(*SoundCount);
4601 SoundsListPID.insert(std::make_pair(*SoundCount, PropertyValue));
4603 } else if (PropertyName == wxT("PREF")){
4605 ProcessIntegerValue(&SoundsListPref, &PropertyValue, SoundCount);
4607 } else if (PropertyName == wxT("MEDIATYPE")){
4609 SoundsListMediatype.erase(*SoundCount);
4610 SoundsListMediatype.insert(std::make_pair(*SoundCount, PropertyValue));
4612 } else if (PropertyName == wxT("LANGUAGE")){
4614 SoundsListLanguage.erase(*SoundCount);
4615 SoundsListLanguage.insert(std::make_pair(*SoundCount, PropertyValue));
4619 // Something else we don't know about so append
4620 // to the tokens variable.
4622 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4624 if (FirstToken == TRUE){
4626 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4631 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4641 intPropertyLen = PropertySeg2.Len();
4642 SplitPoints.clear();
4643 SplitLength.clear();
4648 CaptureString(&PropertySeg2, FALSE);
4650 for (int i = 0; i <= intPropertyLen; i++){
4654 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4657 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4659 if (intSplitsFound == 6){
4661 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4666 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4676 wxString wxSSoundURI;
4677 wxString wxSSoundMIME;
4678 wxString wxSSoundEncoding;
4679 wxString wxSSoundData;
4680 std::string base64enc;
4682 if (intSplitsFound == 0){
4686 std::map<int, int>::iterator striter;
4688 striter = SplitLength.find(1);
4690 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4692 while (wSTDataType.HasMoreTokens() == TRUE){
4694 wxSSoundURI = wSTDataType.GetNextToken();
4695 wxSSoundMIME = wSTDataType.GetNextToken();
4700 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
4702 while (wSTDataInfo.HasMoreTokens() == TRUE){
4704 wxSSoundEncoding = wSTDataInfo.GetNextToken();
4705 wxSSoundData = wSTDataInfo.GetNextToken();
4706 base64enc = wxSSoundData.mb_str();
4713 // Add the data to the General/Home/Work address variables.
4719 SoundsListType.insert(std::make_pair(*SoundCount, "home"));
4722 SoundsListType.insert(std::make_pair(*SoundCount, "work"));
4726 SoundsList.insert(std::make_pair(*SoundCount, base64enc));
4727 SoundsListAudioEncType.insert(std::make_pair(*SoundCount, wxSSoundEncoding));
4728 SoundsListAudioType.insert(std::make_pair(*SoundCount, wxSSoundMIME));
4730 if (!PropertyTokens.IsEmpty()){
4732 SoundsListTokens.insert(std::make_pair(*SoundCount, PropertyTokens));
4738 void ContactDataObject::ProcessCalendarURI(wxString PropertySeg1, wxString PropertySeg2, int *CalURICount){
4740 size_t intPropertyLen = PropertySeg1.Len();
4741 std::map<int, int> SplitPoints;
4742 std::map<int, int> SplitLength;
4743 std::map<int, int>::iterator SLiter;
4744 wxString PropertyData;
4745 wxString PropertyName;
4746 wxString PropertyValue;
4747 wxString PropertyTokens;
4748 bool FirstToken = TRUE;
4749 int intSplitsFound = 0;
4750 int intSplitSize = 0;
4751 int intPrevValue = 8;
4755 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4759 PropertyType PropType = PROPERTY_NONE;
4761 // Look for type before continuing.
4763 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4767 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4768 intiter != SplitPoints.end(); ++intiter){
4770 SLiter = SplitLength.find(intiter->first);
4772 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4774 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4775 PropertyName = PropertyElement.GetNextToken();
4776 PropertyValue = PropertyElement.GetNextToken();
4778 intPrevValue = intiter->second;
4780 // Process properties.
4782 size_t intPropertyValueLen = PropertyValue.Len();
4784 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4786 PropertyValue.Trim();
4787 PropertyValue.RemoveLast();
4791 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4793 PropertyValue.Remove(0, 1);
4797 CaptureString(&PropertyValue, FALSE);
4799 if (PropertyName == wxT("ALTID")){
4801 CalendarListAltID.erase(*CalURICount);
4802 CalendarListAltID.insert(std::make_pair(*CalURICount, PropertyValue));
4804 } else if (PropertyName == wxT("PID")){
4806 CalendarListPID.erase(*CalURICount);
4807 CalendarListPID.insert(std::make_pair(*CalURICount, PropertyValue));
4809 } else if (PropertyName == wxT("PREF")){
4811 ProcessIntegerValue(&CalendarListPref, &PropertyValue, CalURICount);
4813 } else if (PropertyName == wxT("MEDIATYPE")){
4815 CalendarListMediatype.erase(*CalURICount);
4816 CalendarListMediatype.insert(std::make_pair(*CalURICount, PropertyValue));
4820 // Something else we don't know about so append
4821 // to the tokens variable.
4823 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4825 if (FirstToken == TRUE){
4827 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4832 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4842 intPropertyLen = PropertySeg2.Len();
4843 SplitPoints.clear();
4844 SplitLength.clear();
4849 CaptureString(&PropertySeg2, FALSE);
4851 // Add the data to the General/Home/Work address variables.
4857 CalendarListType.insert(std::make_pair(*CalURICount, "home"));
4860 CalendarListType.insert(std::make_pair(*CalURICount, "work"));
4864 CalendarList.insert(std::make_pair(*CalURICount, PropertySeg2));
4866 if (!PropertyTokens.IsEmpty()){
4868 CalendarListTokens.insert(std::make_pair(*CalURICount, PropertyTokens));
4874 void ContactDataObject::ProcessCalendarAddressURI(wxString PropertySeg1, wxString PropertySeg2, int *CalAdrURICount){
4876 size_t intPropertyLen = PropertySeg1.Len();
4877 std::map<int, int> SplitPoints;
4878 std::map<int, int> SplitLength;
4879 std::map<int, int>::iterator SLiter;
4880 wxString PropertyData;
4881 wxString PropertyName;
4882 wxString PropertyValue;
4883 wxString PropertyTokens;
4884 bool FirstToken = TRUE;
4885 int intSplitsFound = 0;
4886 int intSplitSize = 0;
4887 int intPrevValue = 8;
4891 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4895 PropertyType PropType = PROPERTY_NONE;
4897 // Look for type before continuing.
4899 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4903 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4904 intiter != SplitPoints.end(); ++intiter){
4906 SLiter = SplitLength.find(intiter->first);
4908 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4910 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4911 PropertyName = PropertyElement.GetNextToken();
4912 PropertyValue = PropertyElement.GetNextToken();
4914 intPrevValue = intiter->second;
4916 // Process properties.
4918 size_t intPropertyValueLen = PropertyValue.Len();
4920 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4922 PropertyValue.Trim();
4923 PropertyValue.RemoveLast();
4927 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4929 PropertyValue.Remove(0, 1);
4933 CaptureString(&PropertyValue, FALSE);
4935 if (PropertyName == wxT("ALTID")){
4937 CalendarRequestListAltID.erase(*CalAdrURICount);
4938 CalendarRequestListAltID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
4940 } else if (PropertyName == wxT("PID")){
4942 CalendarRequestListPID.erase(*CalAdrURICount);
4943 CalendarRequestListPID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
4945 } else if (PropertyName == wxT("PREF")){
4947 ProcessIntegerValue(&CalendarRequestListPref, &PropertyValue, CalAdrURICount);
4949 } else if (PropertyName == wxT("MEDIATYPE")){
4951 CalendarRequestListMediatype.erase(*CalAdrURICount);
4952 CalendarRequestListMediatype.insert(std::make_pair(*CalAdrURICount, PropertyValue));
4956 // Something else we don't know about so append
4957 // to the tokens variable.
4959 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4961 if (FirstToken == TRUE){
4963 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4968 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4978 intPropertyLen = PropertySeg2.Len();
4979 SplitPoints.clear();
4980 SplitLength.clear();
4985 CaptureString(&PropertySeg2, FALSE);
4987 // Add the data to the General/Home/Work address variables.
4993 CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "home"));
4996 CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "work"));
5000 CalendarRequestList.insert(std::make_pair(*CalAdrURICount, PropertySeg2));
5002 if (!PropertyTokens.IsEmpty()){
5004 CalendarRequestListTokens.insert(std::make_pair(*CalAdrURICount, PropertyTokens));
5010 void ContactDataObject::ProcessCalendarFreeBusy(wxString PropertySeg1, wxString PropertySeg2, int *FreeBusyAddressCount){
5012 size_t intPropertyLen = PropertySeg1.Len();
5013 std::map<int, int> SplitPoints;
5014 std::map<int, int> SplitLength;
5015 std::map<int, int>::iterator SLiter;
5016 wxString PropertyData;
5017 wxString PropertyName;
5018 wxString PropertyValue;
5019 wxString PropertyTokens;
5020 bool FirstToken = TRUE;
5021 int intSplitsFound = 0;
5022 int intSplitSize = 0;
5023 int intPrevValue = 7;
5027 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5031 PropertyType PropType = PROPERTY_NONE;
5033 // Look for type before continuing.
5035 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5039 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
5040 intiter != SplitPoints.end(); ++intiter){
5042 SLiter = SplitLength.find(intiter->first);
5044 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5046 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5047 PropertyName = PropertyElement.GetNextToken();
5048 PropertyValue = PropertyElement.GetNextToken();
5050 intPrevValue = intiter->second;
5052 // Process properties.
5054 size_t intPropertyValueLen = PropertyValue.Len();
5056 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5058 PropertyValue.Trim();
5059 PropertyValue.RemoveLast();
5063 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5065 PropertyValue.Remove(0, 1);
5069 CaptureString(&PropertyValue, FALSE);
5071 if (PropertyName == wxT("ALTID")){
5073 FreeBusyListAltID.erase(*FreeBusyAddressCount);
5074 FreeBusyListAltID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5076 } else if (PropertyName == wxT("PID")){
5078 FreeBusyListPID.erase(*FreeBusyAddressCount);
5079 FreeBusyListPID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5081 } else if (PropertyName == wxT("PREF")){
5083 ProcessIntegerValue(&FreeBusyListPref, &PropertyValue, FreeBusyAddressCount);
5085 } else if (PropertyName == wxT("MEDIATYPE")){
5087 FreeBusyListMediatype.erase(*FreeBusyAddressCount);
5088 FreeBusyListMediatype.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5092 // Something else we don't know about so append
5093 // to the tokens variable.
5095 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5097 if (FirstToken == TRUE){
5099 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5104 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5114 intPropertyLen = PropertySeg2.Len();
5115 SplitPoints.clear();
5116 SplitLength.clear();
5121 CaptureString(&PropertySeg2, FALSE);
5123 // Add the data to the General/Home/Work address variables.
5129 FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "home"));
5132 FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "work"));
5136 FreeBusyList.insert(std::make_pair(*FreeBusyAddressCount, PropertySeg2));
5138 if (!PropertyTokens.IsEmpty()){
5140 FreeBusyListTokens.insert(std::make_pair(*FreeBusyAddressCount, PropertyTokens));
5146 void ContactDataObject::ProcessKey(wxString PropertySeg1, wxString PropertySeg2, int *KeyCount){
5148 size_t intPropertyLen = PropertySeg1.Len();
5149 std::map<int, int> SplitPoints;
5150 std::map<int, int> SplitLength;
5151 std::map<int, int>::iterator SLiter;
5152 wxString PropertyData;
5153 wxString PropertyName;
5154 wxString PropertyValue;
5155 wxString PropertyTokens;
5156 bool FirstToken = TRUE;
5157 int intSplitsFound = 0;
5158 int intSplitSize = 0;
5159 int intPrevValue = 5;
5164 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5168 PropertyType PropType = PROPERTY_NONE;
5170 // Look for type before continuing.
5172 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5176 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
5177 intiter != SplitPoints.end(); ++intiter){
5179 SLiter = SplitLength.find(intiter->first);
5181 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5183 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5184 PropertyName = PropertyElement.GetNextToken();
5185 PropertyValue = PropertyElement.GetNextToken();
5187 intPrevValue = intiter->second;
5189 // Process properties.
5191 size_t intPropertyValueLen = PropertyValue.Len();
5193 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5195 PropertyValue.Trim();
5196 PropertyValue.RemoveLast();
5200 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5202 PropertyValue.Remove(0, 1);
5206 if (PropertyName == wxT("ALTID")){
5208 KeyListAltID.erase(*KeyCount);
5209 KeyListAltID.insert(std::make_pair(*KeyCount, PropertyValue));
5211 } else if (PropertyName == wxT("PID")){
5213 KeyListPID.erase(*KeyCount);
5214 KeyListPID.insert(std::make_pair(*KeyCount, PropertyValue));
5216 } else if (PropertyName == wxT("PREF")){
5218 ProcessIntegerValue(&KeyListPref, &PropertyValue, KeyCount);
5222 // Something else we don't know about so append
5223 // to the tokens variable.
5225 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5227 if (FirstToken == TRUE){
5229 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5234 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5244 intPropertyLen = PropertySeg2.Len();
5245 SplitPoints.clear();
5246 SplitLength.clear();
5251 for (int i = 0; i <= intPropertyLen; i++){
5255 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
5258 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
5260 if (intSplitsFound == 6){
5262 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5267 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5278 wxString wxSKeyMIME;
5279 wxString wxSKeyEncoding;
5280 wxString wxSKeyData;
5281 std::string base64enc;
5283 if (intSplitsFound == 0){
5287 std::map<int, int>::iterator striter;
5289 striter = SplitLength.find(1);
5291 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
5293 while (wSTDataType.HasMoreTokens() == TRUE){
5295 wxSKeyURI = wSTDataType.GetNextToken();
5296 wxSKeyMIME = wSTDataType.GetNextToken();
5301 if (wxSKeyURI == wxT("data")){
5303 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
5305 while (wSTDataInfo.HasMoreTokens() == TRUE){
5307 wxSKeyEncoding = wSTDataInfo.GetNextToken();
5308 wxSKeyData = wSTDataInfo.GetNextToken();
5317 // Add the data to the General/Home/Work address variables.
5319 if (wxSKeyURI == wxT("data")){
5321 KeyListDataEncType.erase(*KeyCount);
5322 KeyListKeyType.erase(*KeyCount);
5323 KeyListDataEncType.insert(std::make_pair(*KeyCount, wxSKeyEncoding));
5324 KeyListKeyType.insert(std::make_pair(*KeyCount, TRUE));
5326 KeyList.erase(*KeyCount);
5327 KeyList.insert(std::make_pair(*KeyCount, wxSKeyData));
5331 KeyList.erase(*KeyCount);
5332 KeyList.insert(std::make_pair(*KeyCount, PropertySeg2));
5336 KeyListDataType.insert(std::make_pair(*KeyCount, wxSKeyMIME));
5342 KeyListType.insert(std::make_pair(*KeyCount, wxT("home")));
5345 KeyListType.insert(std::make_pair(*KeyCount, wxT("work")));
5349 if (!PropertyTokens.IsEmpty()){
5351 KeyListTokens.insert(std::make_pair(*KeyCount, PropertyTokens));
5357 void ContactDataObject::ProcessVendor(wxString PropertySeg1, wxString PropertySeg2, int *VendorCount){
5359 // Split the Vendor three ways.
5361 wxStringTokenizer wSTVendorDetails(PropertySeg1, wxT("-"));
5364 wxString wxSVNDPropName;
5367 while (wSTVendorDetails.HasMoreTokens() == TRUE){
5369 wSTVendorDetails.GetNextToken();
5370 wxSVNDID = wSTVendorDetails.GetNextToken();
5371 wxSVNDPropName = wSTVendorDetails.GetNextToken();
5376 if (!wxSVNDID.IsEmpty() && !wxSVNDPropName.IsEmpty()){
5378 // Add the data to the vendor variables.
5380 VendorList.erase(*VendorCount);
5381 VendorListPEN.erase(*VendorCount);
5382 VendorListElement.erase(*VendorCount);
5384 VendorList.insert(std::make_pair(*VendorCount, PropertySeg2));
5385 VendorListPEN.insert(std::make_pair(*VendorCount, wxSVNDID));
5386 VendorListElement.insert(std::make_pair(*VendorCount, wxSVNDPropName));
5392 void ProcessStringValue(wxString *PropertyName,
5393 wxString PropertyNameMatch,
5394 std::map<int,wxString> *MapPtr,
5395 wxString *PropertyValue,
5397 bool *PropertyMatched){
5399 if (*PropertyName == PropertyNameMatch){
5400 MapPtr->erase(*ItemCount);
5401 MapPtr->insert(std::make_pair(*ItemCount, *PropertyValue));
5402 *PropertyMatched = TRUE;
5407 void ProcessIntegerValue(wxString *PropertyName,
5408 wxString PropertyNameMatch,
5409 std::map<int,int> *PrefPtr,
5410 wxString *PropertyValue,
5412 bool *PropertyMatched){
5414 if (*PropertyName == PropertyNameMatch){
5415 *PropertyMatched = TRUE;
5420 int PriorityNumber = 0;
5421 bool ValidNumber = TRUE;
5424 PriorityNumber = std::stoi(PropertyValue->ToStdString());
5427 catch(std::invalid_argument &e){
5428 ValidNumber = FALSE;
5431 if (ValidNumber == TRUE){
5433 PrefPtr->erase(*ItemCount);
5434 PrefPtr->insert(std::make_pair(*ItemCount, PriorityNumber));
5440 void ProcessIntegerValue(std::map<int,int> *PrefPtr,
5441 wxString *PropertyValue,
5444 int PriorityNumber = 0;
5445 bool ValidNumber = TRUE;
5448 PriorityNumber = std::stoi(PropertyValue->ToStdString());
5451 catch(std::invalid_argument &e){
5452 ValidNumber = FALSE;
5455 if (ValidNumber == TRUE){
5457 PrefPtr->erase(*ItemCount);
5458 PrefPtr->insert(std::make_pair(*ItemCount, PriorityNumber));
5464 void SplitValues(wxString *PropertyLine,
5465 std::map<int,int> *SplitPoints,
5466 std::map<int,int> *SplitLength,
5469 size_t intPropertyLen = PropertyLine->Len();
5470 int intSplitsFound = 0;
5471 int intSplitSize = 0;
5472 int intSplitSeek = 0;
5474 for (int i = intSize; i <= intPropertyLen; i++){
5478 if (PropertyLine->Mid(i, 1) == wxT(";") &&
5479 PropertyLine->Mid((i - 1), 1) != wxT("\\")){
5481 if (intSplitsFound == 0){
5483 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
5487 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5491 SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
5501 if (intSplitsFound == 0){
5503 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
5504 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5508 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
5509 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5515 void CheckType(wxString *PropertySeg1,
5516 std::map<int,int> *SplitPoints,
5517 std::map<int,int> *SplitLength,
5519 PropertyType *PropType){
5521 wxString PropertyData;
5522 wxString PropertyName;
5523 wxString PropertyValue;
5524 std::map<int,int>::iterator SLiter;
5526 for (std::map<int, int>::iterator intiter = SplitPoints->begin();
5527 intiter != SplitPoints->end(); ++intiter){
5529 SLiter = SplitLength->find(intiter->first);
5531 PropertyData = PropertySeg1->Mid(*intPrevValue, (SLiter->second));
5533 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5534 PropertyName = PropertyElement.GetNextToken();
5535 PropertyValue = PropertyElement.GetNextToken();
5537 *intPrevValue = intiter->second;
5539 if (PropertyName == wxT("TYPE")){
5541 if (PropertyValue == wxT("work")){
5543 *PropType = PROPERTY_WORK;
5545 } else if (PropertyValue == wxT("home")){
5547 *PropType = PROPERTY_HOME;
5551 *PropType = PROPERTY_NONE;