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;
735 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
736 intiter != SplitPoints.end(); ++intiter){
738 SLiter = SplitLength.find(intiter->first);
740 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
742 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
743 PropertyName = PropertyElement.GetNextToken();
744 PropertyValue = PropertyElement.GetNextToken();
746 intPrevValue = intiter->second;
748 CaptureString(&PropertyValue, FALSE);
750 if (PropertyName == wxT("ALTID")){
752 GroupsListAltID.erase(*GroupCount);
753 GroupsListAltID.insert(std::make_pair(*GroupCount, PropertyValue));
755 } else if (PropertyName == wxT("PID")){
757 GroupsListPID.erase(*GroupCount);
758 GroupsListPID.insert(std::make_pair(*GroupCount, PropertyValue));
760 } else if (PropertyName == wxT("PREF")){
762 ProcessIntegerValue(&GroupsListPref, &PropertyValue, GroupCount);
764 } else if (PropertyName == wxT("MEDIATYPE")){
766 GroupsListMediaType.erase(*GroupCount);
767 GroupsListMediaType.insert(std::make_pair(*GroupCount, PropertyValue));
769 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
771 if (FirstToken == TRUE){
773 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
778 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
786 GroupsList.insert(std::make_pair(*GroupCount, PropertySeg2));
788 if (!PropertyTokens.IsEmpty()){
790 GroupsListTokens.insert(std::make_pair(*GroupCount, PropertyTokens));
797 void ContactDataObject::ProcessFN(wxString PropertySeg1, wxString PropertySeg2, int *FNCount){
799 std::map<int, int> SplitPoints;
800 std::map<int, int> SplitLength;
802 int intPrevValue = 4;
806 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
810 wxString PropertyName;
811 wxString PropertyValue;
812 wxString PropertyData;
813 wxString PropertyTokens;
814 std::map<int,int>::iterator SLiter;
815 bool FirstToken = TRUE;
817 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
818 intiter != SplitPoints.end(); ++intiter){
820 SLiter = SplitLength.find(intiter->first);
822 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
824 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
825 PropertyName = PropertyElement.GetNextToken();
826 PropertyValue = PropertyElement.GetNextToken();
828 intPrevValue = intiter->second;
830 CaptureString(&PropertyValue, FALSE);
832 if (PropertyName == wxT("TYPE")){
834 if (!PropertyValue.IsEmpty() || PropertyValue == wxT("home") ||
835 PropertyValue == wxT("work") ){
837 FullNamesListType.erase(*FNCount);
838 FullNamesListType.insert(std::make_pair(*FNCount, PropertyValue));
842 } else if (PropertyName == wxT("LANGUAGE")){
844 FullNamesListLanguage.erase(*FNCount);
845 FullNamesListLanguage.insert(std::make_pair(*FNCount, PropertyValue));
847 } else if (PropertyName == wxT("ALTID")){
849 FullNamesListAltID.erase(*FNCount);
850 FullNamesListAltID.insert(std::make_pair(*FNCount, PropertyValue));
852 } else if (PropertyName == wxT("PID")){
854 FullNamesListPID.erase(*FNCount);
855 FullNamesListPID.insert(std::make_pair(*FNCount, PropertyValue));
857 } else if (PropertyName == wxT("PREF")){
859 ProcessIntegerValue(&FullNamesListPref, &PropertyValue, FNCount);
861 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
863 if (FirstToken == TRUE){
865 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
870 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
878 FullNamesList.insert(std::make_pair(*FNCount, PropertySeg2));
880 if (!PropertyTokens.IsEmpty()){
882 FullNamesListTokens.insert(std::make_pair(*FNCount, PropertyTokens));
888 void ContactDataObject::ProcessN(wxString PropertySeg1, wxString PropertySeg2){
890 std::map<int, int> SplitPoints;
891 std::map<int, int> SplitLength;
893 int intPrevValue = 3;
897 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
901 wxString PropertyName;
902 wxString PropertyValue;
903 wxString PropertyData;
904 wxString PropertyTokens;
905 std::map<int,int>::iterator SLiter;
906 bool FirstToken = TRUE;
908 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
909 intiter != SplitPoints.end(); ++intiter){
911 SLiter = SplitLength.find(intiter->first);
913 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
915 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
916 PropertyName = PropertyElement.GetNextToken();
917 PropertyValue = PropertyElement.GetNextToken();
919 intPrevValue = intiter->second;
921 CaptureString(&PropertyValue, FALSE);
923 if (PropertyName == wxT("ALTID")){
925 NameAltID = PropertyValue;
927 } else if (PropertyName == wxT("LANGUAGE")){
929 NameLanguage = PropertyValue;
931 } else if (PropertyName == wxT("SORT-AS")){
933 if (PropertyValue.Left(1) == wxT("\"") && PropertyValue.Right(1) == wxT("\"") &&
934 PropertyValue.Len() >= 3){
935 NameDisplayAs = PropertyValue.Mid(1, (PropertyValue.Len() - 2));
938 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
940 if (FirstToken == TRUE){
942 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
947 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
955 // Split the name data.
957 int intSplitSeek = 0;
958 int intSplitsFound = 0;
959 int intSplitSize = 0;
960 int intPropertyLen = PropertySeg2.Len();
962 std::map<int,wxString> NameValues;
965 for (int i = 0; i <= intPropertyLen; i++){
967 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
969 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, intSplitSize)));
974 if (intSplitsFound == 4){
976 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, wxString::npos)));
990 // Split the data into several parts.
992 for (std::map<int, wxString>::iterator iter = NameValues.begin();
993 iter != NameValues.end(); ++iter){
995 if (iter->first == 1){
997 // Deal with family name.
999 NameSurname = iter->second;
1001 } else if (iter->first == 2){
1003 // Deal with given names.
1005 NameForename = iter->second;
1007 } else if (iter->first == 3){
1009 // Deal with additional names.
1011 NameOtherNames = iter->second;
1013 } else if (iter->first == 4){
1015 // Deal with honorifix prefixes and suffixes.
1017 NameTitle = iter->second;
1021 if (iter == NameValues.end()){
1027 NameSuffix = iter->second;
1033 // Add the name token data.
1035 if (!PropertyTokens.IsEmpty()){
1037 NameTokens = PropertyTokens;
1043 void ContactDataObject::ProcessClientPIDMap(wxString PropertySeg1, wxString PropertySeg2, int *ClientPIDCount){
1045 size_t intPropertyLen = PropertySeg1.Len();
1046 std::map<int, int> SplitPoints;
1047 std::map<int, int> SplitLength;
1048 std::map<int, int>::iterator SLiter;
1049 wxString PropertyData;
1050 wxString PropertyName;
1051 wxString PropertyValue;
1052 wxString PropertyTokens;
1053 bool FirstToken = TRUE;
1054 int intSplitsFound = 0;
1055 int intSplitSize = 0;
1056 int intPrevValue = 14;
1060 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1064 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1065 intiter != SplitPoints.end(); ++intiter){
1067 SLiter = SplitLength.find(intiter->first);
1069 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1071 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1072 PropertyName = PropertyElement.GetNextToken();
1073 PropertyValue = PropertyElement.GetNextToken();
1075 intPrevValue = intiter->second;
1077 // Process properties.
1079 size_t intPropertyValueLen = PropertyValue.Len();
1081 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
1083 PropertyValue.Trim();
1084 PropertyValue.RemoveLast();
1088 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1090 PropertyValue.Remove(0, 1);
1094 CaptureString(&PropertyValue, FALSE);
1096 if (PropertyName.IsEmpty() || PropertyName.IsEmpty()){
1102 if (FirstToken == TRUE){
1104 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1109 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1115 CaptureString(&PropertySeg2, FALSE);
1117 ClientPIDList.insert(std::make_pair(*ClientPIDCount, PropertySeg2));
1119 if (!PropertyTokens.IsEmpty()){
1121 ClientPIDListTokens.insert(std::make_pair(*ClientPIDCount, PropertyTokens));
1127 void ContactDataObject::ProcessNickname(wxString PropertySeg1, wxString PropertySeg2, int *NicknameCount){
1129 std::map<int, int> SplitPoints;
1130 std::map<int, int> SplitLength;
1132 int intPrevValue = 10;
1135 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1139 PropertyType PropType = PROPERTY_NONE;
1141 // Look for type before continuing.
1143 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1147 std::map<int, wxString> *NicknamesList = NULL;
1148 std::map<int, wxString> *NicknamesListType = NULL;
1149 std::map<int, wxString> *NicknamesListLanguage = NULL;
1150 std::map<int, wxString> *NicknamesListAltID = NULL;
1151 std::map<int, wxString> *NicknamesListPID = NULL;
1152 std::map<int, wxString> *NicknamesListTokens = NULL;
1153 std::map<int, int> *NicknamesListPref = NULL;
1157 NicknamesList = &GeneralNicknamesList;
1158 NicknamesListType = &GeneralNicknamesListType;
1159 NicknamesListLanguage = &GeneralNicknamesListLanguage;
1160 NicknamesListAltID = &GeneralNicknamesListAltID;
1161 NicknamesListPID = &GeneralNicknamesListPID;
1162 NicknamesListTokens = &GeneralNicknamesListTokens;
1163 NicknamesListPref = &GeneralNicknamesListPref;
1166 NicknamesList = &HomeNicknamesList;
1167 NicknamesListType = &HomeNicknamesListType;
1168 NicknamesListLanguage = &HomeNicknamesListLanguage;
1169 NicknamesListAltID = &HomeNicknamesListAltID;
1170 NicknamesListPID = &HomeNicknamesListPID;
1171 NicknamesListTokens = &HomeNicknamesListTokens;
1172 NicknamesListPref = &HomeNicknamesListPref;
1175 NicknamesList = &BusinessNicknamesList;
1176 NicknamesListType = &BusinessNicknamesListType;
1177 NicknamesListLanguage = &BusinessNicknamesListLanguage;
1178 NicknamesListAltID = &BusinessNicknamesListAltID;
1179 NicknamesListPID = &BusinessNicknamesListPID;
1180 NicknamesListTokens = &BusinessNicknamesListTokens;
1181 NicknamesListPref = &BusinessNicknamesListPref;
1185 std::map<int, int>::iterator SLiter;
1186 wxString PropertyData;
1187 wxString PropertyName;
1188 wxString PropertyValue;
1189 wxString PropertyTokens;
1190 bool FirstToken = TRUE;
1192 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1193 intiter != SplitPoints.end(); ++intiter){
1195 SLiter = SplitLength.find(intiter->first);
1197 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1199 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1200 PropertyName = PropertyElement.GetNextToken();
1201 PropertyValue = PropertyElement.GetNextToken();
1203 intPrevValue = intiter->second;
1205 CaptureString(&PropertyValue, FALSE);
1207 if (PropertyName == wxT("ALTID")){
1209 NicknamesListAltID->erase(*NicknameCount);
1210 NicknamesListAltID->insert(std::make_pair(*NicknameCount, PropertyValue));
1212 } else if (PropertyName == wxT("PID")){
1214 NicknamesListPID->erase(*NicknameCount);
1215 NicknamesListPID->insert(std::make_pair(*NicknameCount, PropertyValue));
1217 } else if (PropertyName == wxT("PREF")){
1219 ProcessIntegerValue(NicknamesListPref, &PropertyValue, NicknameCount);
1221 } else if (PropertyName == wxT("LANGUAGE")){
1223 NicknamesListLanguage->erase(*NicknameCount);
1224 NicknamesListLanguage->insert(std::make_pair(*NicknameCount, PropertyValue));
1228 // Something else we don't know about so append
1229 // to the tokens variable.
1231 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1233 if (FirstToken == TRUE){
1235 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1240 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1250 NicknamesList->insert(std::make_pair(*NicknameCount, PropertySeg2));
1252 // Add the name token data.
1254 if (!PropertyTokens.IsEmpty()){
1256 NicknamesListTokens->insert(std::make_pair(*NicknameCount, PropertyTokens));
1262 void ContactDataObject::ProcessGender(wxString PropertySeg1, wxString PropertySeg2){
1264 std::map<int, int> SplitPoints;
1265 std::map<int, int> SplitLength;
1266 std::map<int, int>::iterator SLiter;
1267 wxString PropertyData;
1268 wxString PropertyName;
1269 wxString PropertyValue;
1270 wxString PropertyTokens;
1271 bool FirstToken = TRUE;
1272 int intPrevValue = 8;
1274 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1278 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1279 intiter != SplitPoints.end(); ++intiter){
1281 SLiter = SplitLength.find(intiter->first);
1283 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1285 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1286 PropertyName = PropertyElement.GetNextToken();
1287 PropertyValue = PropertyElement.GetNextToken();
1289 intPrevValue = intiter->second;
1291 // Process properties.
1293 size_t intPropertyValueLen = PropertyValue.Len();
1295 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
1297 PropertyValue.Trim();
1298 PropertyValue.RemoveLast();
1302 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1304 PropertyValue.Remove(0, 1);
1308 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1310 if (FirstToken == TRUE){
1312 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1317 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1325 wxStringTokenizer GenderData (PropertySeg2, wxT(";"));
1327 wxString GenderComponent;
1329 if (GenderData.CountTokens() >= 2){
1331 Gender = GenderData.GetNextToken();
1332 GenderDetails = GenderData.GetString();
1334 CaptureString(&GenderDetails, FALSE);
1338 Gender = GenderData.GetNextToken();
1342 if (!PropertyTokens.IsEmpty()){
1344 GenderTokens = PropertyTokens;
1350 void ContactDataObject::ProcessBirthday(wxString PropertySeg1, wxString PropertySeg2){
1352 // Process date. Preserve the remainder in the string.
1354 std::map<int, int> SplitPoints;
1355 std::map<int, int> SplitLength;
1356 std::map<int, int>::iterator SLiter;
1357 wxString PropertyData;
1358 wxString PropertyName;
1359 wxString PropertyValue;
1360 wxString PropertyTokens;
1361 bool BirthdayText = FALSE;
1362 int intPrevValue = 6;
1364 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1368 // Look for type before continuing.
1370 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1371 intiter != SplitPoints.end(); ++intiter){
1373 SLiter = SplitLength.find(intiter->first);
1375 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1377 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1378 PropertyName = PropertyElement.GetNextToken();
1379 PropertyValue = PropertyElement.GetNextToken();
1381 intPrevValue = intiter->second;
1383 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && BirthdayText == FALSE){
1385 CaptureString(&PropertySeg2, FALSE);
1386 Birthday = PropertySeg2;
1387 BirthdayText = TRUE;
1393 // Setup blank lines for later on.
1396 bool FirstToken = TRUE;
1398 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1399 intiter != SplitPoints.end(); ++intiter){
1401 SLiter = SplitLength.find(intiter->first);
1403 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1405 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1406 PropertyName = PropertyElement.GetNextToken();
1407 PropertyValue = PropertyElement.GetNextToken();
1409 intPrevValue = intiter->second;
1411 // Process properties.
1413 CaptureString(&PropertyValue, FALSE);
1415 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1417 PropertyValue.Trim();
1418 PropertyValue.RemoveLast();
1422 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1424 PropertyValue.Remove(0, 1);
1428 if (PropertyName == wxT("ALTID")){
1430 BirthdayAltID = PropertyValue;
1432 } else if (PropertyName == wxT("CALSCALE")){
1434 BirthdayCalScale = PropertyValue;
1436 } else if (PropertyName != wxT("VALUE")) {
1438 // Something else we don't know about so append
1439 // to the tokens variable.
1441 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1443 if (FirstToken == TRUE){
1445 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1450 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1460 // Add the data to the variables and form.
1462 if (BirthdayText == FALSE){
1464 Birthday = PropertySeg2;
1468 if (!PropertyTokens.IsEmpty()){
1470 BirthdayTokens = PropertyTokens;
1476 void ContactDataObject::ProcessAnniversary(wxString PropertySeg1, wxString PropertySeg2){
1478 // Process date. Preserve the remainder in the string.
1480 std::map<int, int> SplitPoints;
1481 std::map<int, int> SplitLength;
1482 std::map<int, int>::iterator SLiter;
1483 wxString PropertyData;
1484 wxString PropertyName;
1485 wxString PropertyValue;
1486 wxString PropertyTokens;
1487 bool AnniversaryText = FALSE;
1488 int intPrevValue = 13;
1490 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1494 // Look for type before continuing.
1496 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1497 intiter != SplitPoints.end(); ++intiter){
1499 SLiter = SplitLength.find(intiter->first);
1501 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1503 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1504 PropertyName = PropertyElement.GetNextToken();
1505 PropertyValue = PropertyElement.GetNextToken();
1507 intPrevValue = intiter->second;
1509 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && AnniversaryText == FALSE){
1511 CaptureString(&PropertySeg2, FALSE);
1512 Anniversary = PropertySeg2;
1513 AnniversaryText = TRUE;
1519 // Setup blank lines for later on.
1522 bool FirstToken = TRUE;
1524 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1525 intiter != SplitPoints.end(); ++intiter){
1527 SLiter = SplitLength.find(intiter->first);
1529 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1531 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1532 PropertyName = PropertyElement.GetNextToken();
1533 PropertyValue = PropertyElement.GetNextToken();
1535 intPrevValue = intiter->second;
1537 // Process properties.
1539 CaptureString(&PropertyValue, FALSE);
1541 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1543 PropertyValue.Trim();
1544 PropertyValue.RemoveLast();
1548 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1550 PropertyValue.Remove(0, 1);
1554 if (PropertyName == wxT("ALTID")){
1556 AnniversaryAltID = PropertyValue;
1558 } else if (PropertyName == wxT("CALSCALE")){
1560 AnniversaryCalScale = PropertyValue;
1562 } else if (PropertyName != wxT("VALUE")) {
1564 // Something else we don't know about so append
1565 // to the tokens variable.
1567 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
1569 if (FirstToken == TRUE){
1571 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1576 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1586 // Add the data to the variables and form.
1588 if (AnniversaryText == FALSE){
1590 Anniversary = PropertySeg2;
1594 if (!PropertyTokens.IsEmpty()){
1596 AnniversaryTokens = PropertyTokens;
1602 void ContactDataObject::ProcessTimeZone(wxString PropertySeg1, wxString PropertySeg2, int *TimeZoneCount){
1604 std::map<int, int> SplitPoints;
1605 std::map<int, int> SplitLength;
1607 int intPrevValue = 4;
1610 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1614 PropertyType PropType = PROPERTY_NONE;
1616 // Look for type before continuing.
1618 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1622 std::map<int, wxString> *TZList = NULL;
1623 std::map<int, wxString> *TZListType = NULL;
1624 std::map<int, wxString> *TZListMediatype = NULL;
1625 std::map<int, wxString> *TZListAltID = NULL;
1626 std::map<int, wxString> *TZListPID = NULL;
1627 std::map<int, wxString> *TZListTokens = NULL;
1628 std::map<int, int> *TZListPref = NULL;
1632 TZList = &GeneralTZList;
1633 TZListType = &GeneralTZListType;
1634 TZListMediatype = &GeneralTZListMediatype;
1635 TZListAltID = &GeneralTZListAltID;
1636 TZListPID = &GeneralTZListPID;
1637 TZListTokens = &GeneralTZListTokens;
1638 TZListPref = &GeneralTZListPref;
1641 TZList = &HomeTZList;
1642 TZListType = &HomeTZListType;
1643 TZListMediatype = &HomeTZListMediatype;
1644 TZListAltID = &HomeTZListAltID;
1645 TZListPID = &HomeTZListPID;
1646 TZListTokens = &HomeTZListTokens;
1647 TZListPref = &HomeTZListPref;
1650 TZList = &BusinessTZList;
1651 TZListType = &BusinessTZListType;
1652 TZListMediatype = &BusinessTZListMediatype;
1653 TZListAltID = &BusinessTZListAltID;
1654 TZListPID = &BusinessTZListPID;
1655 TZListTokens = &BusinessTZListTokens;
1656 TZListPref = &BusinessTZListPref;
1660 std::map<int, int>::iterator SLiter;
1661 wxString PropertyData;
1662 wxString PropertyName;
1663 wxString PropertyValue;
1664 wxString PropertyTokens;
1665 bool FirstToken = TRUE;
1667 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1668 intiter != SplitPoints.end(); ++intiter){
1670 SLiter = SplitLength.find(intiter->first);
1672 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1674 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1675 PropertyName = PropertyElement.GetNextToken();
1676 PropertyValue = PropertyElement.GetNextToken();
1678 intPrevValue = intiter->second;
1680 CaptureString(&PropertyValue, FALSE);
1682 if (PropertyName == wxT("ALTID")){
1684 TZListAltID->erase(*TimeZoneCount);
1685 TZListAltID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1687 } else if (PropertyName == wxT("PID")){
1689 TZListPID->erase(*TimeZoneCount);
1690 TZListPID->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1692 } else if (PropertyName == wxT("PREF")){
1694 ProcessIntegerValue(TZListPref, &PropertyValue, TimeZoneCount);
1696 } else if (PropertyName == wxT("MEDIATYPE")){
1698 TZListMediatype->erase(*TimeZoneCount);
1699 TZListMediatype->insert(std::make_pair(*TimeZoneCount, PropertyValue));
1703 // Something else we don't know about so append
1704 // to the tokens variable.
1706 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1708 if (FirstToken == TRUE){
1710 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1715 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1725 TZList->insert(std::make_pair(*TimeZoneCount, PropertySeg2));
1727 // Add the name token data.
1729 if (!PropertyTokens.IsEmpty()){
1731 TZListTokens->insert(std::make_pair(*TimeZoneCount, PropertyTokens));
1738 void ContactDataObject::ProcessAddress(wxString PropertySeg1, wxString PropertySeg2, int *AddressCount){
1740 size_t intPropertyLen = PropertySeg1.Len();
1741 std::map<int, int> SplitPoints;
1742 std::map<int, int> SplitLength;
1743 std::map<int, int>::iterator SLiter;
1744 wxString PropertyData;
1745 wxString PropertyName;
1746 wxString PropertyValue;
1747 wxString PropertyTokens;
1748 wxString AddressLabel;
1749 wxString AddressLang;
1750 wxString AddressAltID;
1751 wxString AddressPID;
1752 wxString AddressTokens;
1753 wxString AddressGeo;
1754 wxString AddressTimezone;
1755 wxString AddressType;
1756 wxString AddressMediatype;
1757 wxString AddressPOBox;
1758 wxString AddressExtended;
1759 wxString AddressStreet;
1760 wxString AddressLocality;
1761 wxString AddressCity;
1762 wxString AddressRegion;
1763 wxString AddressPostalCode;
1764 wxString AddressCountry;
1765 bool FirstToken = TRUE;
1766 int intSplitsFound = 0;
1767 int intSplitSize = 0;
1768 int intPrevValue = 5;
1773 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1777 PropertyType PropType = PROPERTY_NONE;
1779 // Look for type before continuing.
1781 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1785 std::map<int, wxString> *AddressList = NULL;
1786 std::map<int, wxString> *AddressListTown = NULL;
1787 std::map<int, wxString> *AddressListCounty = NULL;
1788 std::map<int, wxString> *AddressListPostCode = NULL;
1789 std::map<int, wxString> *AddressListCountry = NULL;
1790 std::map<int, wxString> *AddressListLabel = NULL;
1791 std::map<int, wxString> *AddressListLang = NULL;
1792 std::map<int, wxString> *AddressListAltID = NULL;
1793 std::map<int, wxString> *AddressListPID = NULL;
1794 std::map<int, wxString> *AddressListTokens = NULL;
1795 std::map<int, wxString> *AddressListGeo = NULL;
1796 std::map<int, wxString> *AddressListTimezone = NULL;
1797 std::map<int, wxString> *AddressListType = NULL;
1798 std::map<int, wxString> *AddressListMediatype = NULL;
1799 std::map<int, int> *AddressListPref = NULL;
1803 AddressList = &GeneralAddressList;
1804 AddressListTown = &GeneralAddressListTown;
1805 AddressListCounty = &GeneralAddressListCounty;
1806 AddressListPostCode = &GeneralAddressListPostCode;
1807 AddressListCountry = &GeneralAddressListCountry;
1808 AddressListLabel = &GeneralAddressListLabel;
1809 AddressListLang = &GeneralAddressListLang;
1810 AddressListAltID = &GeneralAddressListAltID;
1811 AddressListPID = &GeneralAddressListPID;
1812 AddressListTokens = &GeneralAddressListTokens;
1813 AddressListGeo = &GeneralAddressListGeo;
1814 AddressListTimezone = &GeneralAddressListTimezone;
1815 AddressListType = &GeneralAddressListType;
1816 AddressListMediatype = &GeneralAddressListMediatype;
1817 AddressListPref = &GeneralAddressListPref;
1820 AddressList = &HomeAddressList;
1821 AddressListTown = &HomeAddressListTown;
1822 AddressListCounty = &HomeAddressListCounty;
1823 AddressListPostCode = &HomeAddressListPostCode;
1824 AddressListCountry = &HomeAddressListCountry;
1825 AddressListLabel = &HomeAddressListLabel;
1826 AddressListLang = &HomeAddressListLang;
1827 AddressListAltID = &HomeAddressListAltID;
1828 AddressListPID = &HomeAddressListPID;
1829 AddressListTokens = &HomeAddressListTokens;
1830 AddressListGeo = &HomeAddressListGeo;
1831 AddressListTimezone = &HomeAddressListTimezone;
1832 AddressListType = &HomeAddressListType;
1833 AddressListMediatype = &HomeAddressListMediatype;
1834 AddressListPref = &HomeAddressListPref;
1837 AddressList = &BusinessAddressList;
1838 AddressListTown = &BusinessAddressListTown;
1839 AddressListCounty = &BusinessAddressListCounty;
1840 AddressListPostCode = &BusinessAddressListPostCode;
1841 AddressListCountry = &BusinessAddressListCountry;
1842 AddressListLabel = &BusinessAddressListLabel;
1843 AddressListLang = &BusinessAddressListLang;
1844 AddressListAltID = &BusinessAddressListAltID;
1845 AddressListPID = &BusinessAddressListPID;
1846 AddressListTokens = &BusinessAddressListTokens;
1847 AddressListGeo = &BusinessAddressListGeo;
1848 AddressListTimezone = &BusinessAddressListTimezone;
1849 AddressListType = &BusinessAddressListType;
1850 AddressListMediatype = &BusinessAddressListMediatype;
1851 AddressListPref = &BusinessAddressListPref;
1857 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1858 intiter != SplitPoints.end(); ++intiter){
1860 SLiter = SplitLength.find(intiter->first);
1862 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1864 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1865 PropertyName = PropertyElement.GetNextToken();
1866 PropertyValue = PropertyElement.GetNextToken();
1868 intPrevValue = intiter->second;
1870 CaptureString(&PropertyValue, FALSE);
1872 // Process properties.
1874 if (PropertyName == wxT("LABEL")){
1876 AddressListLabel->erase(*AddressCount);
1877 AddressListLabel->insert(std::make_pair(*AddressCount, PropertyValue));
1879 } else if (PropertyName == wxT("LANGUAGE")){
1881 AddressListLang->erase(*AddressCount);
1882 AddressListLang->insert(std::make_pair(*AddressCount, PropertyValue));
1884 } else if (PropertyName == wxT("ALTID")){
1886 AddressListAltID->erase(*AddressCount);
1887 AddressListAltID->insert(std::make_pair(*AddressCount, PropertyValue));
1889 } else if (PropertyName == wxT("PID")){
1891 AddressListPID->erase(*AddressCount);
1892 AddressListPID->insert(std::make_pair(*AddressCount, PropertyValue));
1894 } else if (PropertyName == wxT("GEO")){
1896 AddressListGeo->erase(*AddressCount);
1897 AddressListGeo->insert(std::make_pair(*AddressCount, PropertyValue));
1899 } else if (PropertyName == wxT("TZ")){
1901 AddressListTimezone->erase(*AddressCount);
1902 AddressListTimezone->insert(std::make_pair(*AddressCount, PropertyValue));
1904 } else if (PropertyName == wxT("MEDIATYPE")){
1906 AddressListMediatype->erase(*AddressCount);
1907 AddressListMediatype->insert(std::make_pair(*AddressCount, PropertyValue));
1909 } else if (PropertyName == wxT("PREF")){
1911 ProcessIntegerValue(AddressListPref, &PropertyValue, AddressCount);
1915 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1917 if (FirstToken == TRUE){
1919 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
1924 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
1934 // Split the address.
1936 //std::map<int, int>::iterator SLiter;
1937 intPropertyLen = PropertySeg2.Len();
1938 SplitPoints.clear();
1939 SplitLength.clear();
1944 for (int i = 0; i <= intPropertyLen; i++){
1948 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
1951 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
1953 if (intSplitsFound == 6){
1955 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1960 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1970 // Split the data into several parts.
1972 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1973 intiter != SplitPoints.end(); ++intiter){
1975 if (intiter->first == 1){
1977 // Deal with PO Box.
1979 SLiter = SplitLength.find(1);
1981 //txtSurname->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(0, SLiter->second), TRUE));
1982 AddressPOBox = PropertySeg2.Mid(0, SLiter->second);
1983 intPrevValue = intiter->second;
1985 } else if (intiter->first == 2){
1987 // Deal with extended address.
1989 SLiter = SplitLength.find(2);
1991 AddressExtended = PropertySeg2.Mid(intPrevValue, SLiter->second);
1992 //txtForename->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
1993 intPrevValue = intiter->second;
1995 } else if (intiter->first == 3){
1997 // Deal with street address.
1999 SLiter = SplitLength.find(3);
2001 AddressStreet = PropertySeg2.Mid(intPrevValue, SLiter->second);
2002 //txtOtherNames->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2003 intPrevValue = intiter->second;
2005 } else if (intiter->first == 4){
2007 // Deal with locality
2009 SLiter = SplitLength.find(4);
2011 AddressLocality = PropertySeg2.Mid(intPrevValue, SLiter->second);
2012 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2013 intPrevValue = intiter->second;
2015 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
2017 } else if (intiter->first == 5){
2019 // Deal with region.
2021 SLiter = SplitLength.find(5);
2023 AddressRegion = PropertySeg2.Mid(intPrevValue, SLiter->second);
2024 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2025 intPrevValue = intiter->second;
2027 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
2029 } else if (intiter->first == 6){
2031 // Deal with post code.
2033 SLiter = SplitLength.find(6);
2035 AddressPostalCode = PropertySeg2.Mid(intPrevValue, SLiter->second);
2036 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
2037 intPrevValue = intiter->second;
2039 // Deal with country.
2041 AddressCountry = PropertySeg2.Mid(intPrevValue, wxString::npos);
2042 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue), TRUE));
2050 // Add the data to the General/Home/Work address variables.
2052 CaptureString(&AddressStreet, FALSE);
2053 CaptureString(&AddressLocality, FALSE);
2054 CaptureString(&AddressRegion, FALSE);
2055 CaptureString(&AddressPostalCode, FALSE);
2056 CaptureString(&AddressCountry, FALSE);
2058 if (!PropertyTokens.IsEmpty()){
2060 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
2064 AddressListCountry->insert(std::make_pair(*AddressCount, AddressCountry));
2065 AddressList->insert(std::make_pair(*AddressCount, AddressStreet));
2066 AddressListTown->insert(std::make_pair(*AddressCount, AddressLocality));
2067 AddressListCounty->insert(std::make_pair(*AddressCount, AddressRegion));
2068 AddressListPostCode->insert(std::make_pair(*AddressCount, AddressPostalCode));
2072 AddressListType->insert(std::make_pair(*AddressCount, wxT("")));
2075 AddressListType->insert(std::make_pair(*AddressCount, wxT("home")));
2078 AddressListType->insert(std::make_pair(*AddressCount, wxT("work")));
2082 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
2086 void ContactDataObject::ProcessEmail(wxString PropertySeg1, wxString PropertySeg2, int *EmailCount){
2088 std::map<int, int> SplitPoints;
2089 std::map<int, int> SplitLength;
2091 int intPrevValue = 7;
2094 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2098 PropertyType PropType = PROPERTY_NONE;
2100 // Look for type before continuing.
2102 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2104 std::map<int, wxString> *EmailList = NULL;
2105 std::map<int, wxString> *EmailListType = NULL;
2106 std::map<int, wxString> *EmailListAltID = NULL;
2107 std::map<int, wxString> *EmailListPID = NULL;
2108 std::map<int, wxString> *EmailListTokens = NULL;
2109 std::map<int, int> *EmailListPref = NULL;
2113 EmailList = &GeneralEmailList;
2114 EmailListType = &GeneralEmailListType;
2115 EmailListAltID = &GeneralEmailListAltID;
2116 EmailListPID = &GeneralEmailListPID;
2117 EmailListTokens = &GeneralEmailListTokens;
2118 EmailListPref = &GeneralEmailListPref;
2121 EmailList = &HomeEmailList;
2122 EmailListType = &HomeEmailListType;
2123 EmailListAltID = &HomeEmailListAltID;
2124 EmailListPID = &HomeEmailListPID;
2125 EmailListTokens = &HomeEmailListTokens;
2126 EmailListPref = &HomeEmailListPref;
2129 EmailList = &BusinessEmailList;
2130 EmailListType = &BusinessEmailListType;
2131 EmailListAltID = &BusinessEmailListAltID;
2132 EmailListPID = &BusinessEmailListPID;
2133 EmailListTokens = &BusinessEmailListTokens;
2134 EmailListPref = &BusinessEmailListPref;
2140 std::map<int,int>::iterator SLiter;
2141 wxString PropertyData;
2142 wxString PropertyName;
2143 wxString PropertyValue;
2144 wxString PropertyTokens;
2145 bool FirstToken = TRUE;
2147 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2148 intiter != SplitPoints.end(); ++intiter){
2150 SLiter = SplitLength.find(intiter->first);
2152 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2154 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2155 PropertyName = PropertyElement.GetNextToken();
2156 PropertyValue = PropertyElement.GetNextToken();
2158 intPrevValue = intiter->second;
2160 CaptureString(&PropertyValue, FALSE);
2162 // Process properties.
2164 if (PropertyName == wxT("ALTID")){
2166 EmailListAltID->erase(*EmailCount);
2167 EmailListAltID->insert(std::make_pair(*EmailCount, PropertyValue));
2169 } else if (PropertyName == wxT("PID")){
2171 EmailListPID->erase(*EmailCount);
2172 EmailListPID->insert(std::make_pair(*EmailCount, PropertyValue));
2174 } else if (PropertyName == wxT("PREF")){
2176 ProcessIntegerValue(EmailListPref, &PropertyValue, EmailCount);
2180 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2182 if (FirstToken == TRUE){
2184 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2189 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2199 EmailList->insert(std::make_pair(*EmailCount, PropertySeg2));
2201 // Add the name token data.
2203 if (!PropertyTokens.IsEmpty()){
2205 EmailListTokens->insert(std::make_pair(*EmailCount, PropertyTokens));
2212 void ContactDataObject::ProcessIM(wxString PropertySeg1, wxString PropertySeg2, int *IMCount){
2214 std::map<int, int> SplitPoints;
2215 std::map<int, int> SplitLength;
2217 int intPrevValue = 6;
2220 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2224 PropertyType PropType = PROPERTY_NONE;
2226 // Look for type before continuing.
2228 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2230 std::map<int, wxString> *IMList = NULL;
2231 std::map<int, wxString> *IMListType = NULL;
2232 std::map<int, wxString> *IMListAltID = NULL;
2233 std::map<int, wxString> *IMListPID = NULL;
2234 std::map<int, wxString> *IMListTokens = NULL;
2235 std::map<int, wxString> *IMListMediatype = NULL;
2236 std::map<int, int> *IMListPref = NULL;
2240 IMList = &GeneralIMList;
2241 IMListType = &GeneralIMListType;
2242 IMListAltID = &GeneralIMListAltID;
2243 IMListPID = &GeneralIMListPID;
2244 IMListTokens = &GeneralIMListTokens;
2245 IMListMediatype = &GeneralIMListMediatype;
2246 IMListPref = &GeneralIMListPref;
2249 IMList = &HomeIMList;
2250 IMListType = &HomeIMListType;
2251 IMListAltID = &HomeIMListAltID;
2252 IMListPID = &HomeIMListPID;
2253 IMListTokens = &HomeIMListTokens;
2254 IMListMediatype = &HomeIMListMediatype;
2255 IMListPref = &HomeIMListPref;
2258 IMList = &BusinessIMList;
2259 IMListType = &BusinessIMListType;
2260 IMListAltID = &BusinessIMListAltID;
2261 IMListPID = &BusinessIMListPID;
2262 IMListTokens = &BusinessIMListTokens;
2263 IMListMediatype = &BusinessIMListMediatype;
2264 IMListPref = &BusinessIMListPref;
2270 std::map<int,int>::iterator SLiter;
2271 wxString PropertyData;
2272 wxString PropertyName;
2273 wxString PropertyValue;
2274 wxString PropertyTokens;
2275 bool FirstToken = TRUE;
2277 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2278 intiter != SplitPoints.end(); ++intiter){
2280 SLiter = SplitLength.find(intiter->first);
2282 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2284 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2285 PropertyName = PropertyElement.GetNextToken();
2286 PropertyValue = PropertyElement.GetNextToken();
2288 intPrevValue = intiter->second;
2290 CaptureString(&PropertyValue, FALSE);
2292 // Process properties.
2294 if (PropertyName == wxT("ALTID")){
2296 IMListAltID->erase(*IMCount);
2297 IMListAltID->insert(std::make_pair(*IMCount, PropertyValue));
2299 } else if (PropertyName == wxT("PID")){
2301 IMListPID->erase(*IMCount);
2302 IMListPID->insert(std::make_pair(*IMCount, PropertyValue));
2304 } else if (PropertyName == wxT("MEDIATYPE")){
2306 IMListMediatype->erase(*IMCount);
2307 IMListMediatype->insert(std::make_pair(*IMCount, PropertyValue));
2309 } else if (PropertyName == wxT("PREF")){
2311 ProcessIntegerValue(IMListPref, &PropertyValue, IMCount);
2315 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2317 if (FirstToken == TRUE){
2319 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2324 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2334 IMList->insert(std::make_pair(*IMCount, PropertySeg2));
2336 // Add the name token data.
2338 if (!PropertyTokens.IsEmpty()){
2340 IMListTokens->insert(std::make_pair(*IMCount, PropertyTokens));
2346 void ContactDataObject::ProcessTelephone(wxString PropertySeg1, wxString PropertySeg2, int *TelephoneCount){
2348 std::map<int, int> SplitPoints;
2349 std::map<int, int> SplitLength;
2350 std::map<int, int>::iterator SLiter;
2354 PropertyType PropType = PROPERTY_NONE;
2356 // Look for type before continuing.
2359 wxString TelTypeDetail;
2360 wxString PropertyData;
2361 wxString PropertyName;
2362 wxString PropertyValue;
2363 wxString PropertyTokens;
2365 std::map<int,int> TypeSplitPoints;
2366 std::map<int,int> TypeSplitLength;
2367 std::map<int,int>::iterator TSLiter;
2369 int intSplitSize = 0;
2370 int intSplitsFound = 0;
2371 int intSplitPoint = 0;
2373 int intPrevValue = 5;
2375 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2379 // Look for type before continuing.
2381 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2382 intiter != SplitPoints.end(); ++intiter){
2384 SLiter = SplitLength.find(intiter->first);
2386 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2388 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2389 PropertyName = PropertyElement.GetNextToken();
2390 PropertyValue = PropertyElement.GetNextToken();
2392 intPrevValue = intiter->second;
2394 if (PropertyName == wxT("TYPE")){
2396 // Process each value in type and translate each
2399 // Strip out the quotes if they are there.
2401 size_t intPropertyValueLen = PropertyValue.Len();
2403 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2405 PropertyValue.Trim();
2406 PropertyValue.RemoveLast();
2410 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2412 PropertyValue.Remove(0, 1);
2416 TelTypeDetail = PropertyValue;
2422 for (int i = 0; i <= intPropertyValueLen; i++){
2426 if (PropertyValue.Mid(i, 1) == wxT(",") && PropertyValue.Mid((i - 1), 1) != wxT("\\")){
2428 if (intSplitsFound == 0){
2430 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2431 TypeSplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2435 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2436 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2449 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2450 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2452 int intTypeSeek = 0;
2454 for (std::map<int, int>::iterator typeiter = TypeSplitPoints.begin();
2455 typeiter != TypeSplitPoints.end(); ++typeiter){
2457 wxString TypePropertyName;
2459 TSLiter = TypeSplitLength.find(typeiter->first);
2461 TypePropertyName = PropertyValue.Mid(typeiter->second, TSLiter->second);
2463 if (intTypeSeek == 0){
2468 TelTypeUI.Append(wxT(","));
2472 if (TypePropertyName == wxT("home")){
2474 PropType = PROPERTY_HOME;
2476 } else if (TypePropertyName == wxT("work")){
2478 PropType = PROPERTY_WORK;
2483 if (TypePropertyName == wxT("text")){
2485 TelTypeUI.Append(_("text"));
2488 } else if (TypePropertyName == wxT("voice")){
2490 TelTypeUI.Append(_("voice"));
2493 } else if (TypePropertyName == wxT("fax")){
2495 TelTypeUI.Append(_("fax"));
2498 } else if (TypePropertyName == wxT("cell")){
2500 TelTypeUI.Append(_("mobile"));
2503 } else if (TypePropertyName == wxT("video")){
2505 TelTypeUI.Append(_("video"));
2508 } else if (TypePropertyName == wxT("pager")){
2510 TelTypeUI.Append(_("pager"));
2513 } else if (TypePropertyName == wxT("textphone")){
2515 TelTypeUI.Append(_("textphone"));
2526 std::map<int, wxString> *TelephoneList = NULL;
2527 std::map<int, wxString> *TelephoneListType = NULL;
2528 std::map<int, wxString> *TelephoneListAltID = NULL;
2529 std::map<int, wxString> *TelephoneListPID = NULL;
2530 std::map<int, wxString> *TelephoneListTokens = NULL;
2531 std::map<int, wxString> *TelephoneListTypeInfo = NULL;
2532 std::map<int, int> *TelephoneListPref = NULL;
2536 TelephoneList = &GeneralTelephoneList;
2537 TelephoneListType = &GeneralTelephoneListType;
2538 TelephoneListAltID = &GeneralTelephoneListAltID;
2539 TelephoneListPID = &GeneralTelephoneListPID;
2540 TelephoneListTokens = &GeneralTelephoneListTokens;
2541 TelephoneListTypeInfo = &GeneralTelephoneListTypeInfo;
2542 TelephoneListPref = &GeneralTelephoneListPref;
2545 TelephoneList = &HomeTelephoneList;
2546 TelephoneListType = &HomeTelephoneListType;
2547 TelephoneListAltID = &HomeTelephoneListAltID;
2548 TelephoneListPID = &HomeTelephoneListPID;
2549 TelephoneListTokens = &HomeTelephoneListTokens;
2550 TelephoneListTypeInfo = &HomeTelephoneListTypeInfo;
2551 TelephoneListPref = &HomeTelephoneListPref;
2554 TelephoneList = &BusinessTelephoneList;
2555 TelephoneListType = &BusinessTelephoneListType;
2556 TelephoneListAltID = &BusinessTelephoneListAltID;
2557 TelephoneListPID = &BusinessTelephoneListPID;
2558 TelephoneListTokens = &BusinessTelephoneListTokens;
2559 TelephoneListTypeInfo = &BusinessTelephoneListTypeInfo;
2560 TelephoneListPref = &BusinessTelephoneListPref;
2564 // Process the properties.
2566 bool FirstToken = TRUE;
2569 SplitPoints.clear();
2570 SplitLength.clear();
2572 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2576 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2577 intiter != SplitPoints.end(); ++intiter){
2579 SLiter = SplitLength.find(intiter->first);
2581 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2583 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2584 PropertyName = PropertyElement.GetNextToken();
2585 PropertyValue = PropertyElement.GetNextToken();
2587 intPrevValue = intiter->second;
2589 CaptureString(&PropertyValue, FALSE);
2591 // Process properties.
2593 if (PropertyName == wxT("ALTID")){
2595 TelephoneListAltID->erase(*TelephoneCount);
2596 TelephoneListAltID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2598 } else if (PropertyName == wxT("PID")){
2600 TelephoneListPID->erase(*TelephoneCount);
2601 TelephoneListPID->insert(std::make_pair(*TelephoneCount, PropertyValue));
2603 } else if (PropertyName == wxT("PREF")){
2605 ProcessIntegerValue(TelephoneListPref, &PropertyValue, TelephoneCount);
2609 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2611 if (FirstToken == TRUE){
2613 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2618 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2628 TelephoneList->insert(std::make_pair(*TelephoneCount, PropertySeg2));
2629 TelephoneListTypeInfo->insert(std::make_pair(*TelephoneCount, TelTypeUI));
2631 // Add the name token data.
2633 if (!PropertyTokens.IsEmpty()){
2635 TelephoneListTokens->insert(std::make_pair(*TelephoneCount, PropertyTokens));
2641 void ContactDataObject::ProcessLanguage(wxString PropertySeg1, wxString PropertySeg2, int *LanguageCount){
2643 std::map<int, int> SplitPoints;
2644 std::map<int, int> SplitLength;
2646 int intPrevValue = 6;
2649 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2653 PropertyType PropType = PROPERTY_NONE;
2655 // Look for type before continuing.
2657 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2659 std::map<int, wxString> *LanguageList = NULL;
2660 std::map<int, wxString> *LanguageListType = NULL;
2661 std::map<int, wxString> *LanguageListAltID = NULL;
2662 std::map<int, wxString> *LanguageListPID = NULL;
2663 std::map<int, wxString> *LanguageListTokens = NULL;
2664 std::map<int, int> *LanguageListPref = NULL;
2668 LanguageList = &GeneralLanguageList;
2669 LanguageListType = &GeneralLanguageListType;
2670 LanguageListAltID = &GeneralLanguageListAltID;
2671 LanguageListPID = &GeneralLanguageListPID;
2672 LanguageListTokens = &GeneralLanguageListTokens;
2673 LanguageListPref = &GeneralLanguageListPref;
2676 LanguageList = &HomeLanguageList;
2677 LanguageListType = &HomeLanguageListType;
2678 LanguageListAltID = &HomeLanguageListAltID;
2679 LanguageListPID = &HomeLanguageListPID;
2680 LanguageListTokens = &HomeLanguageListTokens;
2681 LanguageListPref = &HomeLanguageListPref;
2684 LanguageList = &BusinessLanguageList;
2685 LanguageListType = &BusinessLanguageListType;
2686 LanguageListAltID = &BusinessLanguageListAltID;
2687 LanguageListPID = &BusinessLanguageListPID;
2688 LanguageListTokens = &BusinessLanguageListTokens;
2689 LanguageListPref = &BusinessLanguageListPref;
2695 std::map<int,int>::iterator SLiter;
2696 wxString PropertyData;
2697 wxString PropertyName;
2698 wxString PropertyValue;
2699 wxString PropertyTokens;
2700 bool FirstToken = TRUE;
2702 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2703 intiter != SplitPoints.end(); ++intiter){
2705 SLiter = SplitLength.find(intiter->first);
2707 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2709 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2710 PropertyName = PropertyElement.GetNextToken();
2711 PropertyValue = PropertyElement.GetNextToken();
2713 intPrevValue = intiter->second;
2715 CaptureString(&PropertyValue, FALSE);
2717 // Process properties.
2719 if (PropertyName == wxT("ALTID")){
2721 LanguageListAltID->erase(*LanguageCount);
2722 LanguageListAltID->insert(std::make_pair(*LanguageCount, PropertyValue));
2724 } else if (PropertyName == wxT("PID")){
2726 LanguageListPID->erase(*LanguageCount);
2727 LanguageListPID->insert(std::make_pair(*LanguageCount, PropertyValue));
2729 } else if (PropertyName == wxT("PREF")){
2731 ProcessIntegerValue(LanguageListPref, &PropertyValue, LanguageCount);
2735 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2737 if (FirstToken == TRUE){
2739 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2744 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2754 LanguageList->insert(std::make_pair(*LanguageCount, PropertySeg2));
2756 // Add the name token data.
2758 if (!PropertyTokens.IsEmpty()){
2760 LanguageListTokens->insert(std::make_pair(*LanguageCount, PropertyTokens));
2766 void ContactDataObject::ProcessGeographic(wxString PropertySeg1, wxString PropertySeg2, int *GeographicCount){
2768 std::map<int, int> SplitPoints;
2769 std::map<int, int> SplitLength;
2771 int intPrevValue = 5;
2774 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2778 PropertyType PropType = PROPERTY_NONE;
2780 // Look for type before continuing.
2782 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2784 std::map<int, wxString> *GeopositionList = NULL;
2785 std::map<int, wxString> *GeopositionListType = NULL;
2786 std::map<int, wxString> *GeopositionListAltID = NULL;
2787 std::map<int, wxString> *GeopositionListPID = NULL;
2788 std::map<int, wxString> *GeopositionListTokens = NULL;
2789 std::map<int, wxString> *GeopositionListMediatype = NULL;
2790 std::map<int, int> *GeopositionListPref = NULL;
2794 GeopositionList = &GeneralGeographyList;
2795 GeopositionListType = &GeneralGeographyListType;
2796 GeopositionListAltID = &GeneralGeographyListAltID;
2797 GeopositionListPID = &GeneralGeographyListPID;
2798 GeopositionListTokens = &GeneralGeographyListTokens;
2799 GeopositionListMediatype = &GeneralGeographyListMediatype;
2800 GeopositionListPref = &GeneralGeographyListPref;
2803 GeopositionList = &HomeGeographyList;
2804 GeopositionListType = &HomeGeographyListType;
2805 GeopositionListAltID = &HomeGeographyListAltID;
2806 GeopositionListPID = &HomeGeographyListPID;
2807 GeopositionListTokens = &HomeGeographyListTokens;
2808 GeopositionListMediatype = &HomeGeographyListMediatype;
2809 GeopositionListPref = &HomeGeographyListPref;
2812 GeopositionList = &BusinessGeographyList;
2813 GeopositionListType = &BusinessGeographyListType;
2814 GeopositionListAltID = &BusinessGeographyListAltID;
2815 GeopositionListPID = &BusinessGeographyListPID;
2816 GeopositionListTokens = &BusinessGeographyListTokens;
2817 GeopositionListMediatype = &BusinessGeographyListMediatype;
2818 GeopositionListPref = &BusinessGeographyListPref;
2824 std::map<int,int>::iterator SLiter;
2825 wxString PropertyData;
2826 wxString PropertyName;
2827 wxString PropertyValue;
2828 wxString PropertyTokens;
2829 bool FirstToken = TRUE;
2831 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2832 intiter != SplitPoints.end(); ++intiter){
2834 SLiter = SplitLength.find(intiter->first);
2836 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2838 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2839 PropertyName = PropertyElement.GetNextToken();
2840 PropertyValue = PropertyElement.GetNextToken();
2842 intPrevValue = intiter->second;
2844 CaptureString(&PropertyValue, FALSE);
2846 // Process properties.
2848 if (PropertyName == wxT("ALTID")){
2850 GeopositionListAltID->erase(*GeographicCount);
2851 GeopositionListAltID->insert(std::make_pair(*GeographicCount, PropertyValue));
2853 } else if (PropertyName == wxT("PID")){
2855 GeopositionListPID->erase(*GeographicCount);
2856 GeopositionListPID->insert(std::make_pair(*GeographicCount, PropertyValue));
2858 } else if (PropertyName == wxT("MEDIATYPE")){
2860 GeopositionListMediatype->erase(*GeographicCount);
2861 GeopositionListMediatype->insert(std::make_pair(*GeographicCount, PropertyValue));
2863 } else if (PropertyName == wxT("PREF")){
2865 ProcessIntegerValue(GeopositionListPref, &PropertyValue, GeographicCount);
2869 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
2871 if (FirstToken == TRUE){
2873 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
2878 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
2888 GeopositionList->insert(std::make_pair(*GeographicCount, PropertySeg2));
2890 // Add the name token data.
2892 if (!PropertyTokens.IsEmpty()){
2894 GeopositionListTokens->insert(std::make_pair(*GeographicCount, PropertyTokens));
2900 void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertySeg2, int *RelatedCount){
2902 size_t intPropertyLen = PropertySeg1.Len();
2903 std::map<int, int> SplitPoints;
2904 std::map<int, int> SplitLength;
2905 std::map<int, int>::iterator SLiter;
2906 wxString PropertyData;
2907 wxString PropertyName;
2908 wxString PropertyValue;
2909 wxString PropertyTokens;
2910 wxString RelatedType;
2911 wxString RelatedTypeOriginal;
2912 wxString RelatedName;
2913 bool FirstToken = TRUE;
2914 int intSplitsFound = 0;
2915 int intSplitSize = 0;
2916 int intPrevValue = 9;
2920 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2924 // Look for type before continuing.
2926 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2927 intiter != SplitPoints.end(); ++intiter){
2929 SLiter = SplitLength.find(intiter->first);
2931 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2933 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
2934 PropertyName = PropertyElement.GetNextToken();
2935 PropertyValue = PropertyElement.GetNextToken();
2937 intPrevValue = intiter->second;
2941 RelatedTypeOriginal = PropertyValue;
2943 if (PropertyName == wxT("TYPE")){
2945 if (PropertyValue == wxT("contact")){
2947 RelatedType = _("Contact");
2949 } else if (PropertyValue == wxT("acquaintance")){
2951 RelatedType = _("Acquaintance");
2953 } else if (PropertyValue == wxT("friend")){
2955 RelatedType = _("Friend");
2957 } else if (PropertyValue == wxT("met")){
2959 RelatedType = _("Met");
2961 } else if (PropertyValue == wxT("co-worker")){
2963 RelatedType = _("Co-worker");
2965 } else if (PropertyValue == wxT("colleague")){
2967 RelatedType = _("Colleague");
2969 } else if (PropertyValue == wxT("co-resident")){
2971 RelatedType = _("Co-resident");
2973 } else if (PropertyValue == wxT("neighbor")){
2975 RelatedType = _("Neighbour");
2977 } else if (PropertyValue == wxT("child")){
2979 RelatedType = _("Child");
2981 } else if (PropertyValue == wxT("parent")){
2983 RelatedType = _("Parent");
2985 } else if (PropertyValue == wxT("sibling")){
2987 RelatedType = _("Sibling");
2989 } else if (PropertyValue == wxT("spouse")){
2991 RelatedType = _("Spouse");
2993 } else if (PropertyValue == wxT("kin")){
2995 RelatedType = _("Kin");
2997 } else if (PropertyValue == wxT("muse")){
2999 RelatedType = _("Muse");
3001 } else if (PropertyValue == wxT("crush")){
3003 RelatedType = _("Crush");
3005 } else if (PropertyValue == wxT("date")){
3007 RelatedType = _("Date");
3009 } else if (PropertyValue == wxT("sweetheart")){
3011 RelatedType = _("Sweetheart");
3013 } else if (PropertyValue == wxT("me")){
3015 RelatedType = _("Me");
3017 } else if (PropertyValue == wxT("agent")){
3019 RelatedType = _("Agent");
3021 } else if (PropertyValue == wxT("emergency")){
3023 RelatedType = _("Emergency");
3027 RelatedType = PropertyValue;
3037 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3038 intiter != SplitPoints.end(); ++intiter){
3040 SLiter = SplitLength.find(intiter->first);
3042 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3044 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3045 PropertyName = PropertyElement.GetNextToken();
3046 PropertyValue = PropertyElement.GetNextToken();
3048 intPrevValue = intiter->second;
3050 // Process properties.
3052 size_t intPropertyValueLen = PropertyValue.Len();
3054 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3056 PropertyValue.Trim();
3057 PropertyValue.RemoveLast();
3061 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3063 PropertyValue.Remove(0, 1);
3067 CaptureString(&PropertyValue, FALSE);
3069 if (PropertyName == wxT("ALTID")){
3071 GeneralRelatedListAltID.erase(*RelatedCount);
3072 GeneralRelatedListAltID.insert(std::make_pair(*RelatedCount, PropertyValue));
3074 } else if (PropertyName == wxT("PID")){
3076 GeneralRelatedListPID.erase(*RelatedCount);
3077 GeneralRelatedListPID.insert(std::make_pair(*RelatedCount, PropertyValue));
3079 } else if (PropertyName == wxT("PREF")){
3081 int PriorityNumber = 0;
3082 bool ValidNumber = TRUE;
3085 PriorityNumber = std::stoi(PropertyValue.ToStdString());
3088 catch(std::invalid_argument &e){
3089 ValidNumber = FALSE;
3092 if (ValidNumber == TRUE){
3094 GeneralRelatedListPref.erase(*RelatedCount);
3095 GeneralRelatedListPref.insert(std::make_pair(*RelatedCount, PriorityNumber));
3099 } else if (PropertyName == wxT("LANGUAGE")){
3101 ProcessIntegerValue(&GeneralRelatedListPref, &PropertyValue, RelatedCount);
3103 } else if (PropertyName != wxT("TYPE")) {
3105 // Something else we don't know about so append
3106 // to the tokens variable.
3108 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3110 if (FirstToken == TRUE){
3112 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3117 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3127 // Add the data to the General/Home/Work address variables.
3129 GeneralRelatedList.erase(*RelatedCount);
3130 GeneralRelatedListRelType.erase(*RelatedCount);
3131 GeneralRelatedListType.erase(*RelatedCount);
3132 GeneralRelatedListTokens.erase(*RelatedCount);
3133 GeneralRelatedList.insert(std::make_pair(*RelatedCount, PropertySeg2));
3134 GeneralRelatedListRelType.insert(std::make_pair(*RelatedCount, RelatedType));
3135 GeneralRelatedListType.insert(std::make_pair(*RelatedCount, RelatedType));
3136 GeneralRelatedListTokens.insert(std::make_pair(*RelatedCount, PropertyTokens));
3140 void ContactDataObject::ProcessURL(wxString PropertySeg1, wxString PropertySeg2, int *URLCount){
3142 std::map<int, int> SplitPoints;
3143 std::map<int, int> SplitLength;
3144 std::map<int, int>::iterator SLiter;
3145 wxString PropertyData;
3146 wxString PropertyName;
3147 wxString PropertyValue;
3148 wxString PropertyTokens;
3149 bool FirstToken = TRUE;
3150 int intPrevValue = 5;
3155 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3159 PropertyType PropType = PROPERTY_NONE;
3161 // Look for type before continuing.
3163 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3165 // Setup the pointers.
3167 std::map<int, wxString> *WebsiteList = NULL;
3168 std::map<int, wxString> *WebsiteListAltID = NULL;
3169 std::map<int, wxString> *WebsiteListPID = NULL;
3170 std::map<int, wxString> *WebsiteListType = NULL;
3171 std::map<int, wxString> *WebsiteListTokens = NULL;
3172 std::map<int, wxString> *WebsiteListMediatype = NULL;
3173 std::map<int, int> *WebsiteListPref = NULL;
3175 // Setup blank lines for later on.
3179 WebsiteList = &GeneralWebsiteList;
3180 WebsiteListType = &GeneralWebsiteListType;
3181 WebsiteListAltID = &GeneralWebsiteListAltID;
3182 WebsiteListPID = &GeneralWebsiteListPID;
3183 WebsiteListTokens = &GeneralWebsiteListTokens;
3184 WebsiteListMediatype = &GeneralWebsiteListMediatype;
3185 WebsiteListPref = &GeneralWebsiteListPref;
3188 WebsiteList = &HomeWebsiteList;
3189 WebsiteListType = &HomeWebsiteListType;
3190 WebsiteListAltID = &HomeWebsiteListAltID;
3191 WebsiteListPID = &HomeWebsiteListPID;
3192 WebsiteListTokens = &HomeWebsiteListTokens;
3193 WebsiteListMediatype = &HomeWebsiteListMediatype;
3194 WebsiteListPref = &HomeWebsiteListPref;
3197 WebsiteList = &BusinessWebsiteList;
3198 WebsiteListType = &BusinessWebsiteListType;
3199 WebsiteListAltID = &BusinessWebsiteListAltID;
3200 WebsiteListPID = &BusinessWebsiteListPID;
3201 WebsiteListTokens = &BusinessWebsiteListTokens;
3202 WebsiteListMediatype = &BusinessWebsiteListMediatype;
3203 WebsiteListPref = &BusinessWebsiteListPref;
3209 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3210 intiter != SplitPoints.end(); ++intiter){
3212 SLiter = SplitLength.find(intiter->first);
3214 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3216 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3217 PropertyName = PropertyElement.GetNextToken();
3218 PropertyValue = PropertyElement.GetNextToken();
3220 intPrevValue = intiter->second;
3222 // Process properties.
3224 size_t intPropertyValueLen = PropertyValue.Len();
3226 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3228 PropertyValue.Trim();
3229 PropertyValue.RemoveLast();
3233 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3235 PropertyValue.Remove(0, 1);
3239 CaptureString(&PropertyValue, FALSE);
3241 if (PropertyName == wxT("ALTID")){
3243 WebsiteListAltID->erase(*URLCount);
3244 WebsiteListAltID->insert(std::make_pair(*URLCount, PropertyValue));
3246 } else if (PropertyName == wxT("PID")){
3248 WebsiteListPID->erase(*URLCount);
3249 WebsiteListPID->insert(std::make_pair(*URLCount, PropertyValue));
3251 } else if (PropertyName == wxT("PREF")){
3253 ProcessIntegerValue(WebsiteListPref, &PropertyValue, URLCount);
3255 } else if (PropertyName == wxT("MEDIATYPE")){
3257 WebsiteListMediatype->erase(*URLCount);
3258 WebsiteListMediatype->insert(std::make_pair(*URLCount, PropertyValue));
3262 // Something else we don't know about so append
3263 // to the tokens variable.
3265 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3267 if (FirstToken == TRUE){
3269 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3274 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3284 // Add the data to the General/Home/Work address variables.
3286 CaptureString(&PropertySeg2, FALSE);
3288 WebsiteList->insert(std::make_pair(*URLCount, PropertySeg2));
3290 if (!PropertyTokens.IsEmpty()){
3292 WebsiteListTokens->insert(std::make_pair(*URLCount, PropertyTokens));
3298 void ContactDataObject::ProcessTitle(wxString PropertySeg1, wxString PropertySeg2, int *TitleCount){
3300 std::map<int, int> SplitPoints;
3301 std::map<int, int> SplitLength;
3302 std::map<int, int>::iterator SLiter;
3303 wxString PropertyData;
3304 wxString PropertyName;
3305 wxString PropertyValue;
3306 wxString PropertyTokens;
3307 bool FirstToken = TRUE;
3308 int intPrevValue = 7;
3313 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3317 PropertyType PropType = PROPERTY_NONE;
3319 // Look for type before continuing.
3321 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3323 // Setup the pointers.
3325 std::map<int, wxString> *TitleList = NULL;
3326 std::map<int, wxString> *TitleListAltID = NULL;
3327 std::map<int, wxString> *TitleListPID = NULL;
3328 std::map<int, wxString> *TitleListType = NULL;
3329 std::map<int, wxString> *TitleListTokens = NULL;
3330 std::map<int, wxString> *TitleListLanguage = NULL;
3331 std::map<int, int> *TitleListPref = NULL;
3333 // Setup blank lines for later on.
3337 TitleList = &GeneralTitleList;
3338 TitleListType = &GeneralTitleListType;
3339 TitleListAltID = &GeneralTitleListAltID;
3340 TitleListPID = &GeneralTitleListPID;
3341 TitleListTokens = &GeneralTitleListTokens;
3342 TitleListLanguage = &GeneralTitleListLanguage;
3343 TitleListPref = &GeneralTitleListPref;
3346 TitleList = &HomeTitleList;
3347 TitleListType = &HomeTitleListType;
3348 TitleListAltID = &HomeTitleListAltID;
3349 TitleListPID = &HomeTitleListPID;
3350 TitleListTokens = &HomeTitleListTokens;
3351 TitleListLanguage = &HomeTitleListLanguage;
3352 TitleListPref = &HomeTitleListPref;
3355 TitleList = &BusinessTitleList;
3356 TitleListType = &BusinessTitleListType;
3357 TitleListAltID = &BusinessTitleListAltID;
3358 TitleListPID = &BusinessTitleListPID;
3359 TitleListTokens = &BusinessTitleListTokens;
3360 TitleListLanguage = &BusinessTitleListLanguage;
3361 TitleListPref = &BusinessTitleListPref;
3367 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3368 intiter != SplitPoints.end(); ++intiter){
3370 SLiter = SplitLength.find(intiter->first);
3372 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3374 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3375 PropertyName = PropertyElement.GetNextToken();
3376 PropertyValue = PropertyElement.GetNextToken();
3378 intPrevValue = intiter->second;
3380 // Process properties.
3382 size_t intPropertyValueLen = PropertyValue.Len();
3384 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3386 PropertyValue.Trim();
3387 PropertyValue.RemoveLast();
3391 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3393 PropertyValue.Remove(0, 1);
3397 CaptureString(&PropertyValue, FALSE);
3399 if (PropertyName == wxT("ALTID")){
3401 TitleListAltID->erase(*TitleCount);
3402 TitleListAltID->insert(std::make_pair(*TitleCount, PropertyValue));
3404 } else if (PropertyName == wxT("PID")){
3406 TitleListPID->erase(*TitleCount);
3407 TitleListPID->insert(std::make_pair(*TitleCount, PropertyValue));
3409 } else if (PropertyName == wxT("PREF")){
3411 ProcessIntegerValue(TitleListPref, &PropertyValue, TitleCount);
3413 } else if (PropertyName == wxT("LANGUAGE")){
3415 TitleListLanguage->erase(*TitleCount);
3416 TitleListLanguage->insert(std::make_pair(*TitleCount, PropertyValue));
3420 // Something else we don't know about so append
3421 // to the tokens variable.
3423 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3425 if (FirstToken == TRUE){
3427 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3432 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3442 // Add the data to the General/Home/Work address variables.
3444 CaptureString(&PropertySeg2, FALSE);
3446 TitleList->insert(std::make_pair(*TitleCount, PropertySeg2));
3448 if (!PropertyTokens.IsEmpty()){
3450 TitleListTokens->insert(std::make_pair(*TitleCount, PropertyTokens));
3456 void ContactDataObject::ProcessRole(wxString PropertySeg1, wxString PropertySeg2, int *RoleCount){
3458 std::map<int, int> SplitPoints;
3459 std::map<int, int> SplitLength;
3460 std::map<int, int>::iterator SLiter;
3461 wxString PropertyData;
3462 wxString PropertyName;
3463 wxString PropertyValue;
3464 wxString PropertyTokens;
3465 bool FirstToken = TRUE;
3466 int intPrevValue = 6;
3471 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3475 PropertyType PropType = PROPERTY_NONE;
3477 // Look for type before continuing.
3479 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3481 // Setup the pointers.
3483 std::map<int, wxString> *RoleList = NULL;
3484 std::map<int, wxString> *RoleListAltID = NULL;
3485 std::map<int, wxString> *RoleListPID = NULL;
3486 std::map<int, wxString> *RoleListType = NULL;
3487 std::map<int, wxString> *RoleListTokens = NULL;
3488 std::map<int, wxString> *RoleListLanguage = NULL;
3489 std::map<int, int> *RoleListPref = NULL;
3491 // Setup blank lines for later on.
3495 RoleList = &GeneralRoleList;
3496 RoleListType = &GeneralRoleListType;
3497 RoleListAltID = &GeneralRoleListAltID;
3498 RoleListPID = &GeneralRoleListPID;
3499 RoleListTokens = &GeneralRoleListTokens;
3500 RoleListLanguage = &GeneralRoleListLanguage;
3501 RoleListPref = &GeneralRoleListPref;
3504 RoleList = &HomeRoleList;
3505 RoleListType = &HomeRoleListType;
3506 RoleListAltID = &HomeRoleListAltID;
3507 RoleListPID = &HomeRoleListPID;
3508 RoleListTokens = &HomeRoleListTokens;
3509 RoleListLanguage = &HomeRoleListLanguage;
3510 RoleListPref = &HomeRoleListPref;
3513 RoleList = &BusinessRoleList;
3514 RoleListType = &BusinessRoleListType;
3515 RoleListAltID = &BusinessRoleListAltID;
3516 RoleListPID = &BusinessRoleListPID;
3517 RoleListTokens = &BusinessRoleListTokens;
3518 RoleListLanguage = &BusinessRoleListLanguage;
3519 RoleListPref = &BusinessRoleListPref;
3525 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3526 intiter != SplitPoints.end(); ++intiter){
3528 SLiter = SplitLength.find(intiter->first);
3530 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3532 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3533 PropertyName = PropertyElement.GetNextToken();
3534 PropertyValue = PropertyElement.GetNextToken();
3536 intPrevValue = intiter->second;
3538 // Process properties.
3540 size_t intPropertyValueLen = PropertyValue.Len();
3542 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3544 PropertyValue.Trim();
3545 PropertyValue.RemoveLast();
3549 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3551 PropertyValue.Remove(0, 1);
3555 CaptureString(&PropertyValue, FALSE);
3557 if (PropertyName == wxT("ALTID")){
3559 RoleListAltID->erase(*RoleCount);
3560 RoleListAltID->insert(std::make_pair(*RoleCount, PropertyValue));
3562 } else if (PropertyName == wxT("PID")){
3564 RoleListPID->erase(*RoleCount);
3565 RoleListPID->insert(std::make_pair(*RoleCount, PropertyValue));
3567 } else if (PropertyName == wxT("PREF")){
3569 ProcessIntegerValue(RoleListPref, &PropertyValue, RoleCount);
3571 } else if (PropertyName == wxT("LANGUAGE")){
3573 RoleListLanguage->erase(*RoleCount);
3574 RoleListLanguage->insert(std::make_pair(*RoleCount, PropertyValue));
3578 // Something else we don't know about so append
3579 // to the tokens variable.
3581 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3583 if (FirstToken == TRUE){
3585 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3590 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3600 // Add the data to the General/Home/Work address variables.
3602 CaptureString(&PropertySeg2, FALSE);
3604 RoleList->insert(std::make_pair(*RoleCount, PropertySeg2));
3606 if (!PropertyTokens.IsEmpty()){
3608 RoleListTokens->insert(std::make_pair(*RoleCount, PropertyTokens));
3614 void ContactDataObject::ProcessOrganisation(wxString PropertySeg1, wxString PropertySeg2, int *OrganisationCount){
3616 std::map<int, int> SplitPoints;
3617 std::map<int, int> SplitLength;
3618 std::map<int, int>::iterator SLiter;
3619 wxString PropertyData;
3620 wxString PropertyName;
3621 wxString PropertyValue;
3622 wxString PropertyTokens;
3623 bool FirstToken = TRUE;
3624 int intPrevValue = 5;
3629 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3633 PropertyType PropType = PROPERTY_NONE;
3635 // Look for type before continuing.
3637 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3639 // Setup the pointers.
3641 std::map<int, wxString> *OrganisationsList = NULL;
3642 std::map<int, wxString> *OrganisationsListAltID = NULL;
3643 std::map<int, wxString> *OrganisationsListPID = NULL;
3644 std::map<int, wxString> *OrganisationsListType = NULL;
3645 std::map<int, wxString> *OrganisationsListTokens = NULL;
3646 std::map<int, wxString> *OrganisationsListLanguage = NULL;
3647 std::map<int, wxString> *OrganisationsListSortAs = NULL;
3648 std::map<int, int> *OrganisationsListPref = NULL;
3650 // Setup blank lines for later on.
3654 OrganisationsList = &GeneralOrganisationsList;
3655 OrganisationsListType = &GeneralOrganisationsListType;
3656 OrganisationsListAltID = &GeneralOrganisationsListAltID;
3657 OrganisationsListPID = &GeneralOrganisationsListPID;
3658 OrganisationsListTokens = &GeneralOrganisationsListTokens;
3659 OrganisationsListLanguage = &GeneralOrganisationsListLanguage;
3660 OrganisationsListSortAs = &GeneralOrganisationsListSortAs;
3661 OrganisationsListPref = &GeneralOrganisationsListPref;
3664 OrganisationsList = &HomeOrganisationsList;
3665 OrganisationsListType = &HomeOrganisationsListType;
3666 OrganisationsListAltID = &HomeOrganisationsListAltID;
3667 OrganisationsListPID = &HomeOrganisationsListPID;
3668 OrganisationsListTokens = &HomeOrganisationsListTokens;
3669 OrganisationsListLanguage = &HomeOrganisationsListLanguage;
3670 OrganisationsListSortAs = &HomeOrganisationsListSortAs;
3671 OrganisationsListPref = &HomeOrganisationsListPref;
3674 OrganisationsList = &BusinessOrganisationsList;
3675 OrganisationsListType = &BusinessOrganisationsListType;
3676 OrganisationsListAltID = &BusinessOrganisationsListAltID;
3677 OrganisationsListPID = &BusinessOrganisationsListPID;
3678 OrganisationsListTokens = &BusinessOrganisationsListTokens;
3679 OrganisationsListLanguage = &BusinessOrganisationsListLanguage;
3680 OrganisationsListSortAs = &BusinessOrganisationsListSortAs;
3681 OrganisationsListPref = &BusinessOrganisationsListPref;
3687 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3688 intiter != SplitPoints.end(); ++intiter){
3690 SLiter = SplitLength.find(intiter->first);
3692 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3694 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3695 PropertyName = PropertyElement.GetNextToken();
3696 PropertyValue = PropertyElement.GetNextToken();
3698 intPrevValue = intiter->second;
3700 // Process properties.
3702 size_t intPropertyValueLen = PropertyValue.Len();
3704 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3706 PropertyValue.Trim();
3707 PropertyValue.RemoveLast();
3711 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3713 PropertyValue.Remove(0, 1);
3717 CaptureString(&PropertyValue, FALSE);
3719 if (PropertyName == wxT("ALTID")){
3721 OrganisationsListAltID->erase(*OrganisationCount);
3722 OrganisationsListAltID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3724 } else if (PropertyName == wxT("PID")){
3726 OrganisationsListPID->erase(*OrganisationCount);
3727 OrganisationsListPID->insert(std::make_pair(*OrganisationCount, PropertyValue));
3729 } else if (PropertyName == wxT("SORT-AS")){
3731 OrganisationsListSortAs->erase(*OrganisationCount);
3732 OrganisationsListSortAs->insert(std::make_pair(*OrganisationCount, PropertyValue));
3734 } else if (PropertyName == wxT("PREF")){
3736 ProcessIntegerValue(OrganisationsListPref, &PropertyValue, OrganisationCount);
3738 } else if (PropertyName == wxT("LANGUAGE")){
3740 OrganisationsListLanguage->erase(*OrganisationCount);
3741 OrganisationsListLanguage->insert(std::make_pair(*OrganisationCount, PropertyValue));
3745 // Something else we don't know about so append
3746 // to the tokens variable.
3748 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3750 if (FirstToken == TRUE){
3752 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3757 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3767 // Add the data to the General/Home/Work address variables.
3769 CaptureString(&PropertySeg2, FALSE);
3771 OrganisationsList->insert(std::make_pair(*OrganisationCount, PropertySeg2));
3773 if (!PropertyTokens.IsEmpty()){
3775 OrganisationsListTokens->insert(std::make_pair(*OrganisationCount, PropertyTokens));
3781 void ContactDataObject::ProcessNote(wxString PropertySeg1, wxString PropertySeg2, int *NoteCount){
3783 std::map<int, int> SplitPoints;
3784 std::map<int, int> SplitLength;
3785 std::map<int, int>::iterator SLiter;
3786 wxString PropertyData;
3787 wxString PropertyName;
3788 wxString PropertyValue;
3789 wxString PropertyTokens;
3790 bool FirstToken = TRUE;
3791 int intPrevValue = 6;
3796 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3800 PropertyType PropType = PROPERTY_NONE;
3802 // Look for type before continuing.
3804 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3806 // Setup the pointers.
3808 std::map<int, wxString> *NoteList = NULL;
3809 std::map<int, wxString> *NoteListAltID = NULL;
3810 std::map<int, wxString> *NoteListPID = NULL;
3811 std::map<int, wxString> *NoteListType = NULL;
3812 std::map<int, wxString> *NoteListTokens = NULL;
3813 std::map<int, wxString> *NoteListLanguage = NULL;
3814 std::map<int, int> *NoteListPref = NULL;
3816 // Setup blank lines for later on.
3820 NoteList = &GeneralNoteList;
3821 NoteListType = &GeneralNoteListType;
3822 NoteListAltID = &GeneralNoteListAltID;
3823 NoteListPID = &GeneralNoteListPID;
3824 NoteListTokens = &GeneralNoteListTokens;
3825 NoteListLanguage = &GeneralNoteListLanguage;
3826 NoteListPref = &GeneralNoteListPref;
3829 NoteList = &HomeNoteList;
3830 NoteListType = &HomeNoteListType;
3831 NoteListAltID = &HomeNoteListAltID;
3832 NoteListPID = &HomeNoteListPID;
3833 NoteListTokens = &HomeNoteListTokens;
3834 NoteListLanguage = &HomeNoteListLanguage;
3835 NoteListPref = &HomeNoteListPref;
3838 NoteList = &BusinessNoteList;
3839 NoteListType = &BusinessNoteListType;
3840 NoteListAltID = &BusinessNoteListAltID;
3841 NoteListPID = &BusinessNoteListPID;
3842 NoteListTokens = &BusinessNoteListTokens;
3843 NoteListLanguage = &BusinessNoteListLanguage;
3844 NoteListPref = &BusinessNoteListPref;
3850 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3851 intiter != SplitPoints.end(); ++intiter){
3853 SLiter = SplitLength.find(intiter->first);
3855 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3857 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3858 PropertyName = PropertyElement.GetNextToken();
3859 PropertyValue = PropertyElement.GetNextToken();
3861 intPrevValue = intiter->second;
3863 // Process properties.
3865 size_t intPropertyValueLen = PropertyValue.Len();
3867 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3869 PropertyValue.Trim();
3870 PropertyValue.RemoveLast();
3874 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3876 PropertyValue.Remove(0, 1);
3880 CaptureString(&PropertyValue, FALSE);
3882 if (PropertyName == wxT("ALTID")){
3884 NoteListAltID->erase(*NoteCount);
3885 NoteListAltID->insert(std::make_pair(*NoteCount, PropertyValue));
3887 } else if (PropertyName == wxT("PID")){
3889 NoteListPID->erase(*NoteCount);
3890 NoteListPID->insert(std::make_pair(*NoteCount, PropertyValue));
3892 } else if (PropertyName == wxT("PREF")){
3894 ProcessIntegerValue(NoteListPref, &PropertyValue, NoteCount);
3896 } else if (PropertyName == wxT("LANGUAGE")){
3898 NoteListLanguage->erase(*NoteCount);
3899 NoteListLanguage->insert(std::make_pair(*NoteCount, PropertyValue));
3903 // Something else we don't know about so append
3904 // to the tokens variable.
3906 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
3908 if (FirstToken == TRUE){
3910 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
3915 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
3925 // Add the data to the General/Home/Work address variables.
3927 CaptureString(&PropertySeg2, FALSE);
3929 NoteList->insert(std::make_pair(*NoteCount, PropertySeg2));
3931 if (!PropertyTokens.IsEmpty()){
3933 NoteListTokens->insert(std::make_pair(*NoteCount, PropertyTokens));
3939 void ContactDataObject::ProcessCategory(wxString PropertySeg1, wxString PropertySeg2, int *CategoryCount){
3941 std::map<int, int> SplitPoints;
3942 std::map<int, int> SplitLength;
3943 std::map<int, int>::iterator SLiter;
3944 wxString PropertyData;
3945 wxString PropertyName;
3946 wxString PropertyValue;
3947 wxString PropertyTokens;
3948 bool FirstToken = TRUE;
3949 int intPrevValue = 12;
3954 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3958 PropertyType PropType = PROPERTY_NONE;
3960 // Look for type before continuing.
3962 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3964 // Setup blank lines for later on.
3970 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
3973 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
3979 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3980 intiter != SplitPoints.end(); ++intiter){
3982 SLiter = SplitLength.find(intiter->first);
3984 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3986 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
3987 PropertyName = PropertyElement.GetNextToken();
3988 PropertyValue = PropertyElement.GetNextToken();
3990 intPrevValue = intiter->second;
3992 // Process properties.
3994 size_t intPropertyValueLen = PropertyValue.Len();
3996 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3998 PropertyValue.Trim();
3999 PropertyValue.RemoveLast();
4003 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4005 PropertyValue.Remove(0, 1);
4009 CaptureString(&PropertyValue, FALSE);
4011 if (PropertyName == wxT("ALTID")){
4013 CategoriesListAltID.erase(*CategoryCount);
4014 CategoriesListAltID.insert(std::make_pair(*CategoryCount, PropertyValue));
4016 } else if (PropertyName == wxT("PID")){
4018 CategoriesListPID.erase(*CategoryCount);
4019 CategoriesListPID.insert(std::make_pair(*CategoryCount, PropertyValue));
4021 } else if (PropertyName == wxT("PREF")){
4023 ProcessIntegerValue(&CategoriesListPref, &PropertyValue, CategoryCount);
4025 } else if (PropertyName == wxT("LANGUAGE")){
4027 CategoriesListLanguage.erase(*CategoryCount);
4028 CategoriesListLanguage.insert(std::make_pair(*CategoryCount, PropertyValue));
4032 // Something else we don't know about so append
4033 // to the tokens variable.
4035 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4037 if (FirstToken == TRUE){
4039 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4044 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4054 // Deal with multiple categories.
4056 int intOrigCatCount = *CategoryCount;
4057 bool FirstCategoryProcessed = TRUE;
4058 bool AfterFirstToken = FALSE;
4059 int intSplitSize = 0;
4060 int intSplitsFound = 0;
4061 int intSplitSeek = 0;
4062 int intPropertyLen = PropertySeg2.Len();
4064 SplitPoints.clear();
4065 SplitLength.clear();
4068 for (int i = 0; i <= intPropertyLen; i++){
4070 if (intSplitSize == 0 && PropertySeg2.Mid(i, 1) == wxT(" ")){
4078 if (PropertySeg2.Mid(i, 1) == wxT(",") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
4080 if (AfterFirstToken == TRUE){
4082 SplitPoints.insert(std::make_pair(intSplitsFound, (i - intSplitSize + 1)));
4083 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
4087 SplitPoints.insert(std::make_pair(intSplitsFound, 0));
4088 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
4089 AfterFirstToken = TRUE;
4101 if (SplitPoints.size() > 0){
4103 SplitPoints.insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
4104 SplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
4108 if (SplitPoints.size() == 0){
4110 CategoriesList.insert(std::make_pair(*CategoryCount, PropertySeg2));
4112 if (!PropertyTokens.IsEmpty()){
4114 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4120 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4121 intiter != SplitPoints.end(); ++intiter){
4123 SLiter = SplitLength.find(intiter->first);
4125 intPrevValue = intiter->second;
4127 PropertyData = PropertySeg2.Mid(intPrevValue, (SLiter->second + 1));
4129 // Add the data to the General/Home/Work address variables.
4131 // Trim any whitespace from the start and end.
4133 PropertyData = PropertyData.Trim(FALSE);
4134 PropertyData = PropertyData.Trim(TRUE);
4136 CaptureString(&PropertyData, FALSE);
4138 if (FirstCategoryProcessed == TRUE){
4140 FirstCategoryProcessed = FALSE;
4142 CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4144 if (!PropertyTokens.IsEmpty()){
4146 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4156 CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
4158 if (!PropertyTokens.IsEmpty()){
4160 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
4166 // Copy the properties to each of the categories (if it exists).
4168 if (!PropertyTokens.IsEmpty()){
4170 CategoriesListTokens.insert(std::make_pair(*CategoryCount, CategoriesListTokens.find(intOrigCatCount)->second));
4174 // Check if ALTID was used.
4176 if (CategoriesListAltID.find(intOrigCatCount) != CategoriesListAltID.end()){
4178 CategoriesListAltID.insert(std::make_pair(*CategoryCount, CategoriesListAltID.find(intOrigCatCount)->second));
4182 // Check if PID was used.
4184 if (CategoriesListPID.find(intOrigCatCount) != CategoriesListPID.end()){
4186 CategoriesListPID.insert(std::make_pair(*CategoryCount, CategoriesListPID.find(intOrigCatCount)->second));
4190 // Check if PREF was used.
4192 if (CategoriesListPref.find(intOrigCatCount) != CategoriesListPref.end()){
4194 CategoriesListPref.insert(std::make_pair(*CategoryCount, CategoriesListPref.find(intOrigCatCount)->second));
4198 // Check if LANGUAGE was used.
4200 if (CategoriesListLanguage.find(intOrigCatCount) != CategoriesListLanguage.end()){
4202 CategoriesListLanguage.insert(std::make_pair(*CategoryCount, CategoriesListLanguage.find(intOrigCatCount)->second));
4206 // Check if TYPE was used.
4212 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
4215 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
4223 void ContactDataObject::ProcessPhoto(wxString PropertySeg1, wxString PropertySeg2, int *PhotoCount){
4225 size_t intPropertyLen = PropertySeg1.Len();
4226 std::map<int, int> SplitPoints;
4227 std::map<int, int> SplitLength;
4228 std::map<int, int>::iterator SLiter;
4229 wxString PropertyData;
4230 wxString PropertyName;
4231 wxString PropertyValue;
4232 wxString PropertyTokens;
4233 bool FirstToken = TRUE;
4234 int intSplitsFound = 0;
4235 int intSplitSize = 0;
4236 int intPrevValue = 7;
4240 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4244 PropertyType PropType = PROPERTY_NONE;
4246 // Look for type before continuing.
4248 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4252 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4253 intiter != SplitPoints.end(); ++intiter){
4255 SLiter = SplitLength.find(intiter->first);
4257 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4259 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4260 PropertyName = PropertyElement.GetNextToken();
4261 PropertyValue = PropertyElement.GetNextToken();
4263 intPrevValue = intiter->second;
4265 // Process properties.
4267 size_t intPropertyValueLen = PropertyValue.Len();
4269 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4271 PropertyValue.Trim();
4272 PropertyValue.RemoveLast();
4276 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4278 PropertyValue.Remove(0, 1);
4282 CaptureString(&PropertyValue, FALSE);
4284 if (PropertyName == wxT("ALTID")){
4286 PicturesListAltID.erase(*PhotoCount);
4287 PicturesListAltID.insert(std::make_pair(*PhotoCount, PropertyValue));
4289 } else if (PropertyName == wxT("PID")){
4291 PicturesListPID.erase(*PhotoCount);
4292 PicturesListPID.insert(std::make_pair(*PhotoCount, PropertyValue));
4294 } else if (PropertyName == wxT("PREF")){
4296 ProcessIntegerValue(&PicturesListPref, &PropertyValue, PhotoCount);
4298 } else if (PropertyName == wxT("MEDIATYPE")){
4300 PicturesListMediatype.erase(*PhotoCount);
4301 PicturesListMediatype.insert(std::make_pair(*PhotoCount, PropertyValue));
4305 // Something else we don't know about so append
4306 // to the tokens variable.
4308 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4310 if (FirstToken == TRUE){
4312 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4317 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4327 intPropertyLen = PropertySeg2.Len();
4328 SplitPoints.clear();
4329 SplitLength.clear();
4334 CaptureString(&PropertySeg2, FALSE);
4336 for (int i = 0; i <= intPropertyLen; i++){
4340 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4343 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4345 if (intSplitsFound == 6){
4347 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4352 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4362 wxString wxSPhotoURI;
4363 wxString wxSPhotoMIME;
4364 wxString wxSPhotoEncoding;
4365 wxString wxSPhotoData;
4366 std::string base64enc;
4368 if (intSplitsFound == 0){
4372 std::map<int, int>::iterator striter;
4374 striter = SplitLength.find(1);
4376 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4378 while (wSTDataType.HasMoreTokens() == TRUE){
4380 wxSPhotoURI = wSTDataType.GetNextToken();
4381 wxSPhotoMIME = wSTDataType.GetNextToken();
4386 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
4388 while (wSTDataInfo.HasMoreTokens() == TRUE){
4390 wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4391 wxSPhotoData = wSTDataInfo.GetNextToken();
4392 base64enc = wxSPhotoData.mb_str();
4399 // Add the data to the General/Home/Work address variables.
4401 PicturesList.insert(std::make_pair(*PhotoCount, base64enc));
4402 PicturesListPictureType.insert(std::make_pair(*PhotoCount, wxSPhotoMIME));
4403 PicturesListPicEncType.insert(std::make_pair(*PhotoCount, wxSPhotoEncoding));
4409 PicturesListType.insert(std::make_pair(*PhotoCount, "home"));
4412 PicturesListType.insert(std::make_pair(*PhotoCount, "work"));
4416 if (!PropertyTokens.IsEmpty()){
4418 PicturesListTokens.insert(std::make_pair(*PhotoCount, PropertyTokens));
4424 void ContactDataObject::ProcessLogo(wxString PropertySeg1, wxString PropertySeg2, int *LogoCount){
4426 size_t intPropertyLen = PropertySeg1.Len();
4427 std::map<int, int> SplitPoints;
4428 std::map<int, int> SplitLength;
4429 std::map<int, int>::iterator SLiter;
4430 wxString PropertyData;
4431 wxString PropertyName;
4432 wxString PropertyValue;
4433 wxString PropertyTokens;
4434 bool FirstToken = TRUE;
4435 int intSplitsFound = 0;
4436 int intSplitSize = 0;
4437 int intPrevValue = 6;
4441 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4445 PropertyType PropType = PROPERTY_NONE;
4447 // Look for type before continuing.
4449 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4453 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4454 intiter != SplitPoints.end(); ++intiter){
4456 SLiter = SplitLength.find(intiter->first);
4458 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4460 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4461 PropertyName = PropertyElement.GetNextToken();
4462 PropertyValue = PropertyElement.GetNextToken();
4464 intPrevValue = intiter->second;
4466 // Process properties.
4468 size_t intPropertyValueLen = PropertyValue.Len();
4470 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4472 PropertyValue.Trim();
4473 PropertyValue.RemoveLast();
4477 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4479 PropertyValue.Remove(0, 1);
4483 CaptureString(&PropertyValue, FALSE);
4485 if (PropertyName == wxT("ALTID")){
4487 LogosListAltID.erase(*LogoCount);
4488 LogosListAltID.insert(std::make_pair(*LogoCount, PropertyValue));
4490 } else if (PropertyName == wxT("PID")){
4492 LogosListPID.erase(*LogoCount);
4493 LogosListPID.insert(std::make_pair(*LogoCount, PropertyValue));
4495 } else if (PropertyName == wxT("PREF")){
4497 ProcessIntegerValue(&LogosListPref, &PropertyValue, LogoCount);
4499 } else if (PropertyName == wxT("MEDIATYPE")){
4501 LogosListMediatype.erase(*LogoCount);
4502 LogosListMediatype.insert(std::make_pair(*LogoCount, PropertyValue));
4506 // Something else we don't know about so append
4507 // to the tokens variable.
4509 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4511 if (FirstToken == TRUE){
4513 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4518 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4528 intPropertyLen = PropertySeg2.Len();
4529 SplitPoints.clear();
4530 SplitLength.clear();
4535 CaptureString(&PropertySeg2, FALSE);
4537 for (int i = 0; i <= intPropertyLen; i++){
4541 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4544 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4546 if (intSplitsFound == 6){
4548 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4553 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4563 wxString wxSPhotoURI;
4564 wxString wxSPhotoMIME;
4565 wxString wxSPhotoEncoding;
4566 wxString wxSPhotoData;
4567 std::string base64enc;
4569 if (intSplitsFound == 0){
4573 std::map<int, int>::iterator striter;
4575 striter = SplitLength.find(1);
4577 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4579 while (wSTDataType.HasMoreTokens() == TRUE){
4581 wxSPhotoURI = wSTDataType.GetNextToken();
4582 wxSPhotoMIME = wSTDataType.GetNextToken();
4587 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
4589 while (wSTDataInfo.HasMoreTokens() == TRUE){
4591 wxSPhotoEncoding = wSTDataInfo.GetNextToken();
4592 wxSPhotoData = wSTDataInfo.GetNextToken();
4593 base64enc = wxSPhotoData.mb_str();
4600 // Add the data to the General/Home/Work address variables.
4602 LogosList.insert(std::make_pair(*LogoCount, base64enc));
4603 LogosListPictureType.insert(std::make_pair(*LogoCount, wxSPhotoMIME));
4604 LogosListPicEncType.insert(std::make_pair(*LogoCount, wxSPhotoEncoding));
4610 LogosListType.insert(std::make_pair(*LogoCount, "home"));
4613 LogosListType.insert(std::make_pair(*LogoCount, "work"));
4617 if (!PropertyTokens.IsEmpty()){
4619 LogosListTokens.insert(std::make_pair(*LogoCount, PropertyTokens));
4625 void ContactDataObject::ProcessSound(wxString PropertySeg1, wxString PropertySeg2, int *SoundCount){
4627 size_t intPropertyLen = PropertySeg1.Len();
4628 std::map<int, int> SplitPoints;
4629 std::map<int, int> SplitLength;
4630 std::map<int, int>::iterator SLiter;
4631 wxString PropertyData;
4632 wxString PropertyName;
4633 wxString PropertyValue;
4634 wxString PropertyTokens;
4635 bool FirstToken = TRUE;
4636 int intSplitsFound = 0;
4637 int intSplitSize = 0;
4638 int intPrevValue = 7;
4642 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4646 PropertyType PropType = PROPERTY_NONE;
4648 // Look for type before continuing.
4650 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4654 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4655 intiter != SplitPoints.end(); ++intiter){
4657 SLiter = SplitLength.find(intiter->first);
4659 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4661 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4662 PropertyName = PropertyElement.GetNextToken();
4663 PropertyValue = PropertyElement.GetNextToken();
4665 intPrevValue = intiter->second;
4667 // Process properties.
4669 size_t intPropertyValueLen = PropertyValue.Len();
4671 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4673 PropertyValue.Trim();
4674 PropertyValue.RemoveLast();
4678 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4680 PropertyValue.Remove(0, 1);
4684 CaptureString(&PropertyValue, FALSE);
4686 if (PropertyName == wxT("ALTID")){
4688 SoundsListAltID.erase(*SoundCount);
4689 SoundsListAltID.insert(std::make_pair(*SoundCount, PropertyValue));
4691 } else if (PropertyName == wxT("PID")){
4693 SoundsListPID.erase(*SoundCount);
4694 SoundsListPID.insert(std::make_pair(*SoundCount, PropertyValue));
4696 } else if (PropertyName == wxT("PREF")){
4698 ProcessIntegerValue(&SoundsListPref, &PropertyValue, SoundCount);
4700 } else if (PropertyName == wxT("MEDIATYPE")){
4702 SoundsListMediatype.erase(*SoundCount);
4703 SoundsListMediatype.insert(std::make_pair(*SoundCount, PropertyValue));
4705 } else if (PropertyName == wxT("LANGUAGE")){
4707 SoundsListLanguage.erase(*SoundCount);
4708 SoundsListLanguage.insert(std::make_pair(*SoundCount, PropertyValue));
4712 // Something else we don't know about so append
4713 // to the tokens variable.
4715 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4717 if (FirstToken == TRUE){
4719 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4724 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4734 intPropertyLen = PropertySeg2.Len();
4735 SplitPoints.clear();
4736 SplitLength.clear();
4741 CaptureString(&PropertySeg2, FALSE);
4743 for (int i = 0; i <= intPropertyLen; i++){
4747 if (PropertySeg2.Mid(i, 1) == wxT(";")){
4750 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4752 if (intSplitsFound == 6){
4754 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4759 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4769 wxString wxSSoundURI;
4770 wxString wxSSoundMIME;
4771 wxString wxSSoundEncoding;
4772 wxString wxSSoundData;
4773 std::string base64enc;
4775 if (intSplitsFound == 0){
4779 std::map<int, int>::iterator striter;
4781 striter = SplitLength.find(1);
4783 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4785 while (wSTDataType.HasMoreTokens() == TRUE){
4787 wxSSoundURI = wSTDataType.GetNextToken();
4788 wxSSoundMIME = wSTDataType.GetNextToken();
4793 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
4795 while (wSTDataInfo.HasMoreTokens() == TRUE){
4797 wxSSoundEncoding = wSTDataInfo.GetNextToken();
4798 wxSSoundData = wSTDataInfo.GetNextToken();
4799 base64enc = wxSSoundData.mb_str();
4806 // Add the data to the General/Home/Work address variables.
4812 SoundsListType.insert(std::make_pair(*SoundCount, "home"));
4815 SoundsListType.insert(std::make_pair(*SoundCount, "work"));
4819 SoundsList.insert(std::make_pair(*SoundCount, base64enc));
4820 SoundsListAudioEncType.insert(std::make_pair(*SoundCount, wxSSoundEncoding));
4821 SoundsListAudioType.insert(std::make_pair(*SoundCount, wxSSoundMIME));
4823 if (!PropertyTokens.IsEmpty()){
4825 SoundsListTokens.insert(std::make_pair(*SoundCount, PropertyTokens));
4831 void ContactDataObject::ProcessCalendarURI(wxString PropertySeg1, wxString PropertySeg2, int *CalURICount){
4833 size_t intPropertyLen = PropertySeg1.Len();
4834 std::map<int, int> SplitPoints;
4835 std::map<int, int> SplitLength;
4836 std::map<int, int>::iterator SLiter;
4837 wxString PropertyData;
4838 wxString PropertyName;
4839 wxString PropertyValue;
4840 wxString PropertyTokens;
4841 bool FirstToken = TRUE;
4842 int intSplitsFound = 0;
4843 int intSplitSize = 0;
4844 int intPrevValue = 8;
4848 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4852 PropertyType PropType = PROPERTY_NONE;
4854 // Look for type before continuing.
4856 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4860 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4861 intiter != SplitPoints.end(); ++intiter){
4863 SLiter = SplitLength.find(intiter->first);
4865 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4867 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
4868 PropertyName = PropertyElement.GetNextToken();
4869 PropertyValue = PropertyElement.GetNextToken();
4871 intPrevValue = intiter->second;
4873 // Process properties.
4875 size_t intPropertyValueLen = PropertyValue.Len();
4877 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4879 PropertyValue.Trim();
4880 PropertyValue.RemoveLast();
4884 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4886 PropertyValue.Remove(0, 1);
4890 CaptureString(&PropertyValue, FALSE);
4892 if (PropertyName == wxT("ALTID")){
4894 CalendarListAltID.erase(*CalURICount);
4895 CalendarListAltID.insert(std::make_pair(*CalURICount, PropertyValue));
4897 } else if (PropertyName == wxT("PID")){
4899 CalendarListPID.erase(*CalURICount);
4900 CalendarListPID.insert(std::make_pair(*CalURICount, PropertyValue));
4902 } else if (PropertyName == wxT("PREF")){
4904 ProcessIntegerValue(&CalendarListPref, &PropertyValue, CalURICount);
4906 } else if (PropertyName == wxT("MEDIATYPE")){
4908 CalendarListMediatype.erase(*CalURICount);
4909 CalendarListMediatype.insert(std::make_pair(*CalURICount, PropertyValue));
4913 // Something else we don't know about so append
4914 // to the tokens variable.
4916 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
4918 if (FirstToken == TRUE){
4920 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
4925 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
4935 intPropertyLen = PropertySeg2.Len();
4936 SplitPoints.clear();
4937 SplitLength.clear();
4942 CaptureString(&PropertySeg2, FALSE);
4944 // Add the data to the General/Home/Work address variables.
4950 CalendarListType.insert(std::make_pair(*CalURICount, "home"));
4953 CalendarListType.insert(std::make_pair(*CalURICount, "work"));
4957 CalendarList.insert(std::make_pair(*CalURICount, PropertySeg2));
4959 if (!PropertyTokens.IsEmpty()){
4961 CalendarListTokens.insert(std::make_pair(*CalURICount, PropertyTokens));
4967 void ContactDataObject::ProcessCalendarAddressURI(wxString PropertySeg1, wxString PropertySeg2, int *CalAdrURICount){
4969 size_t intPropertyLen = PropertySeg1.Len();
4970 std::map<int, int> SplitPoints;
4971 std::map<int, int> SplitLength;
4972 std::map<int, int>::iterator SLiter;
4973 wxString PropertyData;
4974 wxString PropertyName;
4975 wxString PropertyValue;
4976 wxString PropertyTokens;
4977 bool FirstToken = TRUE;
4978 int intSplitsFound = 0;
4979 int intSplitSize = 0;
4980 int intPrevValue = 8;
4984 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4988 PropertyType PropType = PROPERTY_NONE;
4990 // Look for type before continuing.
4992 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4996 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4997 intiter != SplitPoints.end(); ++intiter){
4999 SLiter = SplitLength.find(intiter->first);
5001 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5003 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5004 PropertyName = PropertyElement.GetNextToken();
5005 PropertyValue = PropertyElement.GetNextToken();
5007 intPrevValue = intiter->second;
5009 // Process properties.
5011 size_t intPropertyValueLen = PropertyValue.Len();
5013 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5015 PropertyValue.Trim();
5016 PropertyValue.RemoveLast();
5020 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5022 PropertyValue.Remove(0, 1);
5026 CaptureString(&PropertyValue, FALSE);
5028 if (PropertyName == wxT("ALTID")){
5030 CalendarRequestListAltID.erase(*CalAdrURICount);
5031 CalendarRequestListAltID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5033 } else if (PropertyName == wxT("PID")){
5035 CalendarRequestListPID.erase(*CalAdrURICount);
5036 CalendarRequestListPID.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5038 } else if (PropertyName == wxT("PREF")){
5040 ProcessIntegerValue(&CalendarRequestListPref, &PropertyValue, CalAdrURICount);
5042 } else if (PropertyName == wxT("MEDIATYPE")){
5044 CalendarRequestListMediatype.erase(*CalAdrURICount);
5045 CalendarRequestListMediatype.insert(std::make_pair(*CalAdrURICount, PropertyValue));
5049 // Something else we don't know about so append
5050 // to the tokens variable.
5052 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5054 if (FirstToken == TRUE){
5056 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5061 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5071 intPropertyLen = PropertySeg2.Len();
5072 SplitPoints.clear();
5073 SplitLength.clear();
5078 CaptureString(&PropertySeg2, FALSE);
5080 // Add the data to the General/Home/Work address variables.
5086 CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "home"));
5089 CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "work"));
5093 CalendarRequestList.insert(std::make_pair(*CalAdrURICount, PropertySeg2));
5095 if (!PropertyTokens.IsEmpty()){
5097 CalendarRequestListTokens.insert(std::make_pair(*CalAdrURICount, PropertyTokens));
5103 void ContactDataObject::ProcessCalendarFreeBusy(wxString PropertySeg1, wxString PropertySeg2, int *FreeBusyAddressCount){
5105 size_t intPropertyLen = PropertySeg1.Len();
5106 std::map<int, int> SplitPoints;
5107 std::map<int, int> SplitLength;
5108 std::map<int, int>::iterator SLiter;
5109 wxString PropertyData;
5110 wxString PropertyName;
5111 wxString PropertyValue;
5112 wxString PropertyTokens;
5113 bool FirstToken = TRUE;
5114 int intSplitsFound = 0;
5115 int intSplitSize = 0;
5116 int intPrevValue = 7;
5120 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5124 PropertyType PropType = PROPERTY_NONE;
5126 // Look for type before continuing.
5128 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5132 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
5133 intiter != SplitPoints.end(); ++intiter){
5135 SLiter = SplitLength.find(intiter->first);
5137 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5139 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5140 PropertyName = PropertyElement.GetNextToken();
5141 PropertyValue = PropertyElement.GetNextToken();
5143 intPrevValue = intiter->second;
5145 // Process properties.
5147 size_t intPropertyValueLen = PropertyValue.Len();
5149 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5151 PropertyValue.Trim();
5152 PropertyValue.RemoveLast();
5156 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5158 PropertyValue.Remove(0, 1);
5162 CaptureString(&PropertyValue, FALSE);
5164 if (PropertyName == wxT("ALTID")){
5166 FreeBusyListAltID.erase(*FreeBusyAddressCount);
5167 FreeBusyListAltID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5169 } else if (PropertyName == wxT("PID")){
5171 FreeBusyListPID.erase(*FreeBusyAddressCount);
5172 FreeBusyListPID.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5174 } else if (PropertyName == wxT("PREF")){
5176 ProcessIntegerValue(&FreeBusyListPref, &PropertyValue, FreeBusyAddressCount);
5178 } else if (PropertyName == wxT("MEDIATYPE")){
5180 FreeBusyListMediatype.erase(*FreeBusyAddressCount);
5181 FreeBusyListMediatype.insert(std::make_pair(*FreeBusyAddressCount, PropertyValue));
5185 // Something else we don't know about so append
5186 // to the tokens variable.
5188 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5190 if (FirstToken == TRUE){
5192 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5197 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5207 intPropertyLen = PropertySeg2.Len();
5208 SplitPoints.clear();
5209 SplitLength.clear();
5214 CaptureString(&PropertySeg2, FALSE);
5216 // Add the data to the General/Home/Work address variables.
5222 FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "home"));
5225 FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "work"));
5229 FreeBusyList.insert(std::make_pair(*FreeBusyAddressCount, PropertySeg2));
5231 if (!PropertyTokens.IsEmpty()){
5233 FreeBusyListTokens.insert(std::make_pair(*FreeBusyAddressCount, PropertyTokens));
5239 void ContactDataObject::ProcessKey(wxString PropertySeg1, wxString PropertySeg2, int *KeyCount){
5241 size_t intPropertyLen = PropertySeg1.Len();
5242 std::map<int, int> SplitPoints;
5243 std::map<int, int> SplitLength;
5244 std::map<int, int>::iterator SLiter;
5245 wxString PropertyData;
5246 wxString PropertyName;
5247 wxString PropertyValue;
5248 wxString PropertyTokens;
5249 bool FirstToken = TRUE;
5250 int intSplitsFound = 0;
5251 int intSplitSize = 0;
5252 int intPrevValue = 5;
5257 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
5261 PropertyType PropType = PROPERTY_NONE;
5263 // Look for type before continuing.
5265 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
5269 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
5270 intiter != SplitPoints.end(); ++intiter){
5272 SLiter = SplitLength.find(intiter->first);
5274 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
5276 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5277 PropertyName = PropertyElement.GetNextToken();
5278 PropertyValue = PropertyElement.GetNextToken();
5280 intPrevValue = intiter->second;
5282 // Process properties.
5284 size_t intPropertyValueLen = PropertyValue.Len();
5286 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
5288 PropertyValue.Trim();
5289 PropertyValue.RemoveLast();
5293 if (PropertyValue.Mid(0, 1) == wxT("\"")){
5295 PropertyValue.Remove(0, 1);
5299 if (PropertyName == wxT("ALTID")){
5301 KeyListAltID.erase(*KeyCount);
5302 KeyListAltID.insert(std::make_pair(*KeyCount, PropertyValue));
5304 } else if (PropertyName == wxT("PID")){
5306 KeyListPID.erase(*KeyCount);
5307 KeyListPID.insert(std::make_pair(*KeyCount, PropertyValue));
5309 } else if (PropertyName == wxT("PREF")){
5311 ProcessIntegerValue(&KeyListPref, &PropertyValue, KeyCount);
5315 // Something else we don't know about so append
5316 // to the tokens variable.
5318 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
5320 if (FirstToken == TRUE){
5322 PropertyTokens.Append(PropertyName + wxT("=") + PropertyValue);
5327 PropertyTokens.Append(wxT(";") + PropertyName + wxT("=") + PropertyValue);
5337 intPropertyLen = PropertySeg2.Len();
5338 SplitPoints.clear();
5339 SplitLength.clear();
5344 for (int i = 0; i <= intPropertyLen; i++){
5348 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
5351 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
5353 if (intSplitsFound == 6){
5355 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5360 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5371 wxString wxSKeyMIME;
5372 wxString wxSKeyEncoding;
5373 wxString wxSKeyData;
5374 std::string base64enc;
5376 if (intSplitsFound == 0){
5380 std::map<int, int>::iterator striter;
5382 striter = SplitLength.find(1);
5384 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
5386 while (wSTDataType.HasMoreTokens() == TRUE){
5388 wxSKeyURI = wSTDataType.GetNextToken();
5389 wxSKeyMIME = wSTDataType.GetNextToken();
5394 if (wxSKeyURI == wxT("data")){
5396 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
5398 while (wSTDataInfo.HasMoreTokens() == TRUE){
5400 wxSKeyEncoding = wSTDataInfo.GetNextToken();
5401 wxSKeyData = wSTDataInfo.GetNextToken();
5410 // Add the data to the General/Home/Work address variables.
5412 if (wxSKeyURI == wxT("data")){
5414 KeyListDataEncType.erase(*KeyCount);
5415 KeyListKeyType.erase(*KeyCount);
5416 KeyListDataEncType.insert(std::make_pair(*KeyCount, wxSKeyEncoding));
5417 KeyListKeyType.insert(std::make_pair(*KeyCount, TRUE));
5419 KeyList.erase(*KeyCount);
5420 KeyList.insert(std::make_pair(*KeyCount, wxSKeyData));
5424 KeyList.erase(*KeyCount);
5425 KeyList.insert(std::make_pair(*KeyCount, PropertySeg2));
5429 KeyListDataType.insert(std::make_pair(*KeyCount, wxSKeyMIME));
5435 KeyListType.insert(std::make_pair(*KeyCount, wxT("home")));
5438 KeyListType.insert(std::make_pair(*KeyCount, wxT("work")));
5442 if (!PropertyTokens.IsEmpty()){
5444 KeyListTokens.insert(std::make_pair(*KeyCount, PropertyTokens));
5450 void ContactDataObject::ProcessVendor(wxString PropertySeg1, wxString PropertySeg2, int *VendorCount){
5452 // Split the Vendor three ways.
5454 wxStringTokenizer wSTVendorDetails(PropertySeg1, wxT("-"));
5457 wxString wxSVNDPropName;
5460 while (wSTVendorDetails.HasMoreTokens() == TRUE){
5462 wSTVendorDetails.GetNextToken();
5463 wxSVNDID = wSTVendorDetails.GetNextToken();
5464 wxSVNDPropName = wSTVendorDetails.GetNextToken();
5469 if (!wxSVNDID.IsEmpty() && !wxSVNDPropName.IsEmpty()){
5471 // Add the data to the vendor variables.
5473 VendorList.erase(*VendorCount);
5474 VendorListPEN.erase(*VendorCount);
5475 VendorListElement.erase(*VendorCount);
5477 VendorList.insert(std::make_pair(*VendorCount, PropertySeg2));
5478 VendorListPEN.insert(std::make_pair(*VendorCount, wxSVNDID));
5479 VendorListElement.insert(std::make_pair(*VendorCount, wxSVNDPropName));
5485 void ProcessStringValue(wxString *PropertyName,
5486 wxString PropertyNameMatch,
5487 std::map<int,wxString> *MapPtr,
5488 wxString *PropertyValue,
5490 bool *PropertyMatched){
5492 if (*PropertyName == PropertyNameMatch){
5493 MapPtr->erase(*ItemCount);
5494 MapPtr->insert(std::make_pair(*ItemCount, *PropertyValue));
5495 *PropertyMatched = TRUE;
5500 void ProcessIntegerValue(wxString *PropertyName,
5501 wxString PropertyNameMatch,
5502 std::map<int,int> *PrefPtr,
5503 wxString *PropertyValue,
5505 bool *PropertyMatched){
5507 if (*PropertyName == PropertyNameMatch){
5508 *PropertyMatched = TRUE;
5513 int PriorityNumber = 0;
5514 bool ValidNumber = TRUE;
5517 PriorityNumber = std::stoi(PropertyValue->ToStdString());
5520 catch(std::invalid_argument &e){
5521 ValidNumber = FALSE;
5524 if (ValidNumber == TRUE){
5526 PrefPtr->erase(*ItemCount);
5527 PrefPtr->insert(std::make_pair(*ItemCount, PriorityNumber));
5533 void ProcessIntegerValue(std::map<int,int> *PrefPtr,
5534 wxString *PropertyValue,
5537 int PriorityNumber = 0;
5538 bool ValidNumber = TRUE;
5541 PriorityNumber = std::stoi(PropertyValue->ToStdString());
5544 catch(std::invalid_argument &e){
5545 ValidNumber = FALSE;
5548 if (ValidNumber == TRUE){
5550 PrefPtr->erase(*ItemCount);
5551 PrefPtr->insert(std::make_pair(*ItemCount, PriorityNumber));
5557 void SplitValues(wxString *PropertyLine,
5558 std::map<int,int> *SplitPoints,
5559 std::map<int,int> *SplitLength,
5562 size_t intPropertyLen = PropertyLine->Len();
5563 int intSplitsFound = 0;
5564 int intSplitSize = 0;
5565 int intSplitSeek = 0;
5567 for (int i = intSize; i <= intPropertyLen; i++){
5571 if (PropertyLine->Mid(i, 1) == wxT(";") &&
5572 PropertyLine->Mid((i - 1), 1) != wxT("\\")){
5574 if (intSplitsFound == 0){
5576 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
5580 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
5584 SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
5594 if (intSplitsFound == 0){
5596 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
5597 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5601 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
5602 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
5608 void CheckType(wxString *PropertySeg1,
5609 std::map<int,int> *SplitPoints,
5610 std::map<int,int> *SplitLength,
5612 PropertyType *PropType){
5614 wxString PropertyData;
5615 wxString PropertyName;
5616 wxString PropertyValue;
5617 std::map<int,int>::iterator SLiter;
5619 for (std::map<int, int>::iterator intiter = SplitPoints->begin();
5620 intiter != SplitPoints->end(); ++intiter){
5622 SLiter = SplitLength->find(intiter->first);
5624 PropertyData = PropertySeg1->Mid(*intPrevValue, (SLiter->second));
5626 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
5627 PropertyName = PropertyElement.GetNextToken();
5628 PropertyValue = PropertyElement.GetNextToken();
5630 *intPrevValue = intiter->second;
5632 if (PropertyName == wxT("TYPE")){
5634 if (PropertyValue == wxT("work")){
5636 *PropType = PROPERTY_WORK;
5638 } else if (PropertyValue == wxT("home")){
5640 *PropType = PROPERTY_HOME;
5644 *PropType = PROPERTY_NONE;