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);
487 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
488 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
489 intPrevValue = intiter->second;
491 // Process properties.
493 size_t intPropertyValueLen = PropertyValue.Len();
495 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
497 PropertyValue.Trim();
498 PropertyValue.RemoveLast();
502 if (PropertyValue.Mid(0, 1) == wxT("\"")){
504 PropertyValue.Remove(0, 1);
508 CaptureString(&PropertyValue, FALSE);
510 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
514 CaptureString(&PropertySeg2, FALSE);
516 Revision = PropertySeg2;
518 if (!PropertyTokens.IsEmpty()){
520 RevisionTokens = PropertyTokens;
527 void ContactDataObject::ProcessSource(wxString PropertySeg1, wxString PropertySeg2, int *SourceCount){
529 size_t intPropertyLen = PropertySeg1.Len();
530 std::map<int, int> SplitPoints;
531 std::map<int, int> SplitLength;
532 std::map<int, int>::iterator SLiter;
533 wxString PropertyData;
534 wxString PropertyName;
535 wxString PropertyValue;
536 wxString PropertyTokens;
537 bool FirstToken = TRUE;
538 bool PropertyMatched = FALSE;
539 int intSplitsFound = 0;
540 int intSplitSize = 0;
541 int intPrevValue = 8;
545 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
549 PropertyType PropType = PROPERTY_NONE;
551 // Look for type before continuing.
553 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
557 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
558 intiter != SplitPoints.end(); ++intiter){
560 SLiter = SplitLength.find(intiter->first);
562 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
564 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
566 intPrevValue = intiter->second;
568 // Process properties.
570 size_t intPropertyValueLen = PropertyValue.Len();
572 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
574 PropertyValue.Trim();
575 PropertyValue.RemoveLast();
579 if (PropertyValue.Mid(0, 1) == wxT("\"")){
581 PropertyValue.Remove(0, 1);
585 CaptureString(&PropertyValue, FALSE);
587 ProcessStringValue(&PropertyName, "ALTID", &SourceListAltID, &PropertyValue, SourceCount, &PropertyMatched);
588 ProcessStringValue(&PropertyName, "PID", &SourceListPID, &PropertyValue, SourceCount, &PropertyMatched);
589 ProcessStringValue(&PropertyName, "MEDIATYPE", &SourceListMediatype, &PropertyValue, SourceCount, &PropertyMatched);
590 ProcessIntegerValue(&PropertyName, "PREF", &SourceListPref, &PropertyValue, SourceCount, &PropertyMatched);
592 if (PropertyMatched == TRUE){
594 PropertyMatched = FALSE;
599 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
603 intPropertyLen = PropertySeg2.Len();
610 CaptureString(&PropertySeg2, FALSE);
612 // Add the data to the General/Home/Work address variables.
618 SourceListType.insert(std::make_pair(*SourceCount, "home"));
621 SourceListType.insert(std::make_pair(*SourceCount, "work"));
625 SourceList.insert(std::make_pair(*SourceCount, PropertySeg2));
627 if (!PropertyTokens.IsEmpty()){
629 SourceListTokens.insert(std::make_pair(*SourceCount, PropertyTokens));
635 void ContactDataObject::ProcessXML(wxString PropertySeg1, wxString PropertySeg2, int *XMLCount){
637 std::map<int, int> SplitPoints;
638 std::map<int, int> SplitLength;
640 int intPrevValue = 5;
644 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
648 wxString PropertyName;
649 wxString PropertyValue;
650 wxString PropertyData;
651 wxString PropertyTokens;
652 std::map<int,int>::iterator SLiter;
653 bool FirstToken = TRUE;
654 bool PropertyMatched = FALSE;
656 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
657 intiter != SplitPoints.end(); ++intiter){
659 SLiter = SplitLength.find(intiter->first);
660 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
661 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
662 intPrevValue = intiter->second;
664 CaptureString(&PropertyValue, FALSE);
666 ProcessStringValue(&PropertyName, "ALTID", &XMLListAltID, &PropertyValue, XMLCount, &PropertyMatched);
668 if (PropertyMatched == TRUE){
670 PropertyMatched = FALSE;
677 XMLList.insert(std::make_pair(*XMLCount, PropertySeg2));
681 void ContactDataObject::ProcessMember(wxString PropertySeg1, wxString PropertySeg2, int *GroupCount){
683 std::map<int, int> SplitPoints;
684 std::map<int, int> SplitLength;
686 int intPrevValue = 8;
690 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
694 wxString PropertyName;
695 wxString PropertyValue;
696 wxString PropertyData;
697 wxString PropertyTokens;
698 std::map<int,int>::iterator SLiter;
699 bool FirstToken = TRUE;
700 bool PropertyMatched = FALSE;
702 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
703 intiter != SplitPoints.end(); ++intiter){
705 SLiter = SplitLength.find(intiter->first);
706 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
707 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
708 intPrevValue = intiter->second;
710 CaptureString(&PropertyValue, FALSE);
712 ProcessStringValue(&PropertyName, "ALTID", &GroupsListAltID, &PropertyValue, GroupCount, &PropertyMatched);
713 ProcessStringValue(&PropertyName, "PID", &GroupsListPID, &PropertyValue, GroupCount, &PropertyMatched);
714 ProcessStringValue(&PropertyName, "MEDIATYPE", &GroupsListMediaType, &PropertyValue, GroupCount, &PropertyMatched);
715 ProcessIntegerValue(&PropertyName, "PREF", &GroupsListPref, &PropertyValue, GroupCount, &PropertyMatched);
717 if (PropertyMatched == TRUE){
719 PropertyMatched = FALSE;
724 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
728 GroupsList.insert(std::make_pair(*GroupCount, PropertySeg2));
730 if (!PropertyTokens.IsEmpty()){
732 GroupsListTokens.insert(std::make_pair(*GroupCount, PropertyTokens));
739 void ContactDataObject::ProcessFN(wxString PropertySeg1, wxString PropertySeg2, int *FNCount){
741 std::map<int, int> SplitPoints;
742 std::map<int, int> SplitLength;
744 int intPrevValue = 4;
748 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
752 wxString PropertyName;
753 wxString PropertyValue;
754 wxString PropertyData;
755 wxString PropertyTokens;
756 std::map<int,int>::iterator SLiter;
757 bool FirstToken = TRUE;
758 bool PropertyMatched = FALSE;
760 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
761 intiter != SplitPoints.end(); ++intiter){
763 SLiter = SplitLength.find(intiter->first);
764 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
765 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
766 intPrevValue = intiter->second;
768 CaptureString(&PropertyValue, FALSE);
770 if (PropertyName == wxT("TYPE")){
772 if (!PropertyValue.IsEmpty() || PropertyValue == wxT("home") ||
773 PropertyValue == wxT("work") ){
775 FullNamesListType.erase(*FNCount);
776 FullNamesListType.insert(std::make_pair(*FNCount, PropertyValue));
780 PropertyMatched = TRUE;
784 ProcessStringValue(&PropertyName, "ALTID", &FullNamesListAltID, &PropertyValue, FNCount, &PropertyMatched);
785 ProcessStringValue(&PropertyName, "PID", &FullNamesListPID, &PropertyValue, FNCount, &PropertyMatched);
786 ProcessStringValue(&PropertyName, "LANGUAGE", &FullNamesListLanguage, &PropertyValue, FNCount, &PropertyMatched);
787 ProcessIntegerValue(&PropertyName, "PREF", &FullNamesListPref, &PropertyValue, FNCount, &PropertyMatched);
789 if (PropertyMatched == TRUE){
791 PropertyMatched = FALSE;
796 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
800 FullNamesList.insert(std::make_pair(*FNCount, PropertySeg2));
802 if (!PropertyTokens.IsEmpty()){
804 FullNamesListTokens.insert(std::make_pair(*FNCount, PropertyTokens));
810 void ContactDataObject::ProcessN(wxString PropertySeg1, wxString PropertySeg2){
812 std::map<int, int> SplitPoints;
813 std::map<int, int> SplitLength;
815 int intPrevValue = 3;
819 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
823 wxString PropertyName;
824 wxString PropertyValue;
825 wxString PropertyData;
826 wxString PropertyTokens;
827 std::map<int,int>::iterator SLiter;
828 bool FirstToken = TRUE;
830 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
831 intiter != SplitPoints.end(); ++intiter){
833 SLiter = SplitLength.find(intiter->first);
834 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
835 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
836 intPrevValue = intiter->second;
838 CaptureString(&PropertyValue, FALSE);
840 if (PropertyName == wxT("ALTID")){
842 NameAltID = PropertyValue;
844 } else if (PropertyName == wxT("LANGUAGE")){
846 NameLanguage = PropertyValue;
848 } else if (PropertyName == wxT("SORT-AS")){
850 if (PropertyValue.Left(1) == wxT("\"") && PropertyValue.Right(1) == wxT("\"") &&
851 PropertyValue.Len() >= 3){
852 NameDisplayAs = PropertyValue.Mid(1, (PropertyValue.Len() - 2));
855 } else if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty()){
857 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
863 // Split the name data.
865 int intSplitSeek = 0;
866 int intSplitsFound = 0;
867 int intSplitSize = 0;
868 int intPropertyLen = PropertySeg2.Len();
870 std::map<int,wxString> NameValues;
873 for (int i = 0; i <= intPropertyLen; i++){
875 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
877 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, intSplitSize)));
882 if (intSplitsFound == 4){
884 NameValues.insert(std::make_pair(++intSplitsFound, PropertySeg2.Mid(intSplitSeek, wxString::npos)));
898 // Split the data into several parts.
900 for (std::map<int, wxString>::iterator iter = NameValues.begin();
901 iter != NameValues.end(); ++iter){
903 if (iter->first == 1){
905 // Deal with family name.
907 NameSurname = iter->second;
909 } else if (iter->first == 2){
911 // Deal with given names.
913 NameForename = iter->second;
915 } else if (iter->first == 3){
917 // Deal with additional names.
919 NameOtherNames = iter->second;
921 } else if (iter->first == 4){
923 // Deal with honorifix prefixes and suffixes.
925 NameTitle = iter->second;
929 if (iter == NameValues.end()){
935 NameSuffix = iter->second;
941 // Add the name token data.
943 if (!PropertyTokens.IsEmpty()){
945 NameTokens = PropertyTokens;
951 void ContactDataObject::ProcessClientPIDMap(wxString PropertySeg1, wxString PropertySeg2, int *ClientPIDCount){
953 size_t intPropertyLen = PropertySeg1.Len();
954 std::map<int, int> SplitPoints;
955 std::map<int, int> SplitLength;
956 std::map<int, int>::iterator SLiter;
957 wxString PropertyData;
958 wxString PropertyName;
959 wxString PropertyValue;
960 wxString PropertyTokens;
961 bool FirstToken = TRUE;
962 int intSplitsFound = 0;
963 int intSplitSize = 0;
964 int intPrevValue = 14;
968 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
972 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
973 intiter != SplitPoints.end(); ++intiter){
975 SLiter = SplitLength.find(intiter->first);
976 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
977 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
978 intPrevValue = intiter->second;
980 // Process properties.
982 CaptureString(&PropertyValue, FALSE);
984 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
988 CaptureString(&PropertySeg2, FALSE);
990 ClientPIDList.insert(std::make_pair(*ClientPIDCount, PropertySeg2));
992 if (!PropertyTokens.IsEmpty()){
994 ClientPIDListTokens.insert(std::make_pair(*ClientPIDCount, PropertyTokens));
1000 void ContactDataObject::ProcessNickname(wxString PropertySeg1, wxString PropertySeg2, int *NicknameCount){
1002 std::map<int, int> SplitPoints;
1003 std::map<int, int> SplitLength;
1005 int intPrevValue = 10;
1008 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1012 PropertyType PropType = PROPERTY_NONE;
1014 // Look for type before continuing.
1016 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1020 std::map<int, wxString> *NicknamesList = NULL;
1021 std::map<int, wxString> *NicknamesListType = NULL;
1022 std::map<int, wxString> *NicknamesListLanguage = NULL;
1023 std::map<int, wxString> *NicknamesListAltID = NULL;
1024 std::map<int, wxString> *NicknamesListPID = NULL;
1025 std::map<int, wxString> *NicknamesListTokens = NULL;
1026 std::map<int, int> *NicknamesListPref = NULL;
1030 NicknamesList = &GeneralNicknamesList;
1031 NicknamesListType = &GeneralNicknamesListType;
1032 NicknamesListLanguage = &GeneralNicknamesListLanguage;
1033 NicknamesListAltID = &GeneralNicknamesListAltID;
1034 NicknamesListPID = &GeneralNicknamesListPID;
1035 NicknamesListTokens = &GeneralNicknamesListTokens;
1036 NicknamesListPref = &GeneralNicknamesListPref;
1039 NicknamesList = &HomeNicknamesList;
1040 NicknamesListType = &HomeNicknamesListType;
1041 NicknamesListLanguage = &HomeNicknamesListLanguage;
1042 NicknamesListAltID = &HomeNicknamesListAltID;
1043 NicknamesListPID = &HomeNicknamesListPID;
1044 NicknamesListTokens = &HomeNicknamesListTokens;
1045 NicknamesListPref = &HomeNicknamesListPref;
1048 NicknamesList = &BusinessNicknamesList;
1049 NicknamesListType = &BusinessNicknamesListType;
1050 NicknamesListLanguage = &BusinessNicknamesListLanguage;
1051 NicknamesListAltID = &BusinessNicknamesListAltID;
1052 NicknamesListPID = &BusinessNicknamesListPID;
1053 NicknamesListTokens = &BusinessNicknamesListTokens;
1054 NicknamesListPref = &BusinessNicknamesListPref;
1058 std::map<int, int>::iterator SLiter;
1059 wxString PropertyData;
1060 wxString PropertyName;
1061 wxString PropertyValue;
1062 wxString PropertyTokens;
1063 bool FirstToken = TRUE;
1064 bool PropertyMatched = FALSE;
1066 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1067 intiter != SplitPoints.end(); ++intiter){
1069 SLiter = SplitLength.find(intiter->first);
1070 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1071 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
1072 intPrevValue = intiter->second;
1074 CaptureString(&PropertyValue, FALSE);
1076 ProcessStringValue(&PropertyName, "ALTID", NicknamesListAltID, &PropertyValue, NicknameCount, &PropertyMatched);
1077 ProcessStringValue(&PropertyName, "PID", NicknamesListPID, &PropertyValue, NicknameCount, &PropertyMatched);
1078 ProcessStringValue(&PropertyName, "LANGUAGE", NicknamesListLanguage, &PropertyValue, NicknameCount, &PropertyMatched);
1079 ProcessIntegerValue(&PropertyName, "PREF", NicknamesListPref, &PropertyValue, NicknameCount, &PropertyMatched);
1081 if (PropertyMatched == TRUE){
1083 PropertyMatched = FALSE;
1088 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
1092 NicknamesList->insert(std::make_pair(*NicknameCount, PropertySeg2));
1094 // Add the name token data.
1096 if (!PropertyTokens.IsEmpty()){
1098 NicknamesListTokens->insert(std::make_pair(*NicknameCount, PropertyTokens));
1104 void ContactDataObject::ProcessGender(wxString PropertySeg1, wxString PropertySeg2){
1106 std::map<int, int> SplitPoints;
1107 std::map<int, int> SplitLength;
1108 std::map<int, int>::iterator SLiter;
1109 wxString PropertyData;
1110 wxString PropertyName;
1111 wxString PropertyValue;
1112 wxString PropertyTokens;
1113 bool FirstToken = TRUE;
1114 int intPrevValue = 8;
1116 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1120 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1121 intiter != SplitPoints.end(); ++intiter){
1123 SLiter = SplitLength.find(intiter->first);
1124 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1125 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
1126 intPrevValue = intiter->second;
1128 // Process properties.
1130 size_t intPropertyValueLen = PropertyValue.Len();
1132 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
1134 PropertyValue.Trim();
1135 PropertyValue.RemoveLast();
1139 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1141 PropertyValue.Remove(0, 1);
1145 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
1149 wxStringTokenizer GenderData (PropertySeg2, wxT(";"));
1151 wxString GenderComponent;
1153 if (GenderData.CountTokens() >= 2){
1155 Gender = GenderData.GetNextToken();
1156 GenderDetails = GenderData.GetString();
1158 CaptureString(&GenderDetails, FALSE);
1162 Gender = GenderData.GetNextToken();
1166 if (!PropertyTokens.IsEmpty()){
1168 GenderTokens = PropertyTokens;
1174 void ContactDataObject::ProcessBirthday(wxString PropertySeg1, wxString PropertySeg2){
1176 // Process date. Preserve the remainder in the string.
1178 std::map<int, int> SplitPoints;
1179 std::map<int, int> SplitLength;
1180 std::map<int, int>::iterator SLiter;
1181 wxString PropertyData;
1182 wxString PropertyName;
1183 wxString PropertyValue;
1184 wxString PropertyTokens;
1185 bool BirthdayText = FALSE;
1186 int intPrevValue = 6;
1188 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1192 // Look for type before continuing.
1194 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1195 intiter != SplitPoints.end(); ++intiter){
1197 SLiter = SplitLength.find(intiter->first);
1198 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1199 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
1200 intPrevValue = intiter->second;
1202 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && BirthdayText == FALSE){
1204 CaptureString(&PropertySeg2, FALSE);
1205 Birthday = PropertySeg2;
1206 BirthdayText = TRUE;
1212 // Setup blank lines for later on.
1215 bool FirstToken = TRUE;
1217 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1218 intiter != SplitPoints.end(); ++intiter){
1220 SLiter = SplitLength.find(intiter->first);
1221 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1222 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
1223 intPrevValue = intiter->second;
1225 // Process properties.
1227 CaptureString(&PropertyValue, FALSE);
1229 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1231 PropertyValue.Trim();
1232 PropertyValue.RemoveLast();
1236 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1238 PropertyValue.Remove(0, 1);
1242 if (PropertyName == wxT("ALTID")){
1244 BirthdayAltID = PropertyValue;
1246 } else if (PropertyName == wxT("CALSCALE")){
1248 BirthdayCalScale = PropertyValue;
1250 } else if (PropertyName != wxT("VALUE")) {
1252 // Something else we don't know about so append
1253 // to the tokens variable.
1255 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
1261 // Add the data to the variables and form.
1263 if (BirthdayText == FALSE){
1265 Birthday = PropertySeg2;
1269 if (!PropertyTokens.IsEmpty()){
1271 BirthdayTokens = PropertyTokens;
1277 void ContactDataObject::ProcessAnniversary(wxString PropertySeg1, wxString PropertySeg2){
1279 // Process date. Preserve the remainder in the string.
1281 std::map<int, int> SplitPoints;
1282 std::map<int, int> SplitLength;
1283 std::map<int, int>::iterator SLiter;
1284 wxString PropertyData;
1285 wxString PropertyName;
1286 wxString PropertyValue;
1287 wxString PropertyTokens;
1288 bool AnniversaryText = FALSE;
1289 int intPrevValue = 13;
1291 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1295 // Look for type before continuing.
1297 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1298 intiter != SplitPoints.end(); ++intiter){
1300 SLiter = SplitLength.find(intiter->first);
1301 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1302 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
1303 intPrevValue = intiter->second;
1305 if (PropertyName == wxT("VALUE") && PropertyValue == wxT("text") && AnniversaryText == FALSE){
1307 CaptureString(&PropertySeg2, FALSE);
1308 Anniversary = PropertySeg2;
1309 AnniversaryText = TRUE;
1315 // Setup blank lines for later on.
1318 bool FirstToken = TRUE;
1320 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1321 intiter != SplitPoints.end(); ++intiter){
1323 SLiter = SplitLength.find(intiter->first);
1324 PropertyData = PropertySeg1.Mid(intPrevValue, SLiter->second);
1325 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
1326 intPrevValue = intiter->second;
1328 // Process properties.
1330 CaptureString(&PropertyValue, FALSE);
1332 if (PropertyValue.Mid((PropertyValue.Len() - 1), 1) == wxT("\"")){
1334 PropertyValue.Trim();
1335 PropertyValue.RemoveLast();
1339 if (PropertyValue.Mid(0, 1) == wxT("\"")){
1341 PropertyValue.Remove(0, 1);
1345 if (PropertyName == wxT("ALTID")){
1347 AnniversaryAltID = PropertyValue;
1349 } else if (PropertyName == wxT("CALSCALE")){
1351 AnniversaryCalScale = PropertyValue;
1353 } else if (PropertyName != wxT("VALUE")) {
1355 // Something else we don't know about so append
1356 // to the tokens variable.
1358 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
1364 // Add the data to the variables and form.
1366 if (AnniversaryText == FALSE){
1368 Anniversary = PropertySeg2;
1372 if (!PropertyTokens.IsEmpty()){
1374 AnniversaryTokens = PropertyTokens;
1380 void ContactDataObject::ProcessTimeZone(wxString PropertySeg1, wxString PropertySeg2, int *TimeZoneCount){
1382 std::map<int, int> SplitPoints;
1383 std::map<int, int> SplitLength;
1385 int intPrevValue = 4;
1388 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1392 PropertyType PropType = PROPERTY_NONE;
1394 // Look for type before continuing.
1396 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1400 std::map<int, wxString> *TZList = NULL;
1401 std::map<int, wxString> *TZListType = NULL;
1402 std::map<int, wxString> *TZListMediatype = NULL;
1403 std::map<int, wxString> *TZListAltID = NULL;
1404 std::map<int, wxString> *TZListPID = NULL;
1405 std::map<int, wxString> *TZListTokens = NULL;
1406 std::map<int, int> *TZListPref = NULL;
1410 TZList = &GeneralTZList;
1411 TZListType = &GeneralTZListType;
1412 TZListMediatype = &GeneralTZListMediatype;
1413 TZListAltID = &GeneralTZListAltID;
1414 TZListPID = &GeneralTZListPID;
1415 TZListTokens = &GeneralTZListTokens;
1416 TZListPref = &GeneralTZListPref;
1419 TZList = &HomeTZList;
1420 TZListType = &HomeTZListType;
1421 TZListMediatype = &HomeTZListMediatype;
1422 TZListAltID = &HomeTZListAltID;
1423 TZListPID = &HomeTZListPID;
1424 TZListTokens = &HomeTZListTokens;
1425 TZListPref = &HomeTZListPref;
1428 TZList = &BusinessTZList;
1429 TZListType = &BusinessTZListType;
1430 TZListMediatype = &BusinessTZListMediatype;
1431 TZListAltID = &BusinessTZListAltID;
1432 TZListPID = &BusinessTZListPID;
1433 TZListTokens = &BusinessTZListTokens;
1434 TZListPref = &BusinessTZListPref;
1438 std::map<int, int>::iterator SLiter;
1439 wxString PropertyData;
1440 wxString PropertyName;
1441 wxString PropertyValue;
1442 wxString PropertyTokens;
1443 bool FirstToken = TRUE;
1444 bool PropertyMatched = FALSE;
1446 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1447 intiter != SplitPoints.end(); ++intiter){
1449 SLiter = SplitLength.find(intiter->first);
1450 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1451 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
1452 intPrevValue = intiter->second;
1454 CaptureString(&PropertyValue, FALSE);
1456 ProcessStringValue(&PropertyName, "ALTID", TZListAltID, &PropertyValue, TimeZoneCount, &PropertyMatched);
1457 ProcessStringValue(&PropertyName, "PID", TZListPID, &PropertyValue, TimeZoneCount, &PropertyMatched);
1458 ProcessStringValue(&PropertyName, "MEDIATYPE", TZListMediatype, &PropertyValue, TimeZoneCount, &PropertyMatched);
1459 ProcessIntegerValue(&PropertyName, "PREF", TZListPref, &PropertyValue, TimeZoneCount, &PropertyMatched);
1461 if (PropertyMatched == TRUE){
1463 PropertyMatched = FALSE;
1468 if (!PropertyName.IsEmpty() && !PropertyValue.IsEmpty() && PropertyName != wxT("TYPE")){
1470 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
1476 TZList->insert(std::make_pair(*TimeZoneCount, PropertySeg2));
1478 // Add the name token data.
1480 if (!PropertyTokens.IsEmpty()){
1482 TZListTokens->insert(std::make_pair(*TimeZoneCount, PropertyTokens));
1489 void ContactDataObject::ProcessAddress(wxString PropertySeg1, wxString PropertySeg2, int *AddressCount){
1491 size_t intPropertyLen = PropertySeg1.Len();
1492 std::map<int, int> SplitPoints;
1493 std::map<int, int> SplitLength;
1494 std::map<int, int>::iterator SLiter;
1495 wxString PropertyData;
1496 wxString PropertyName;
1497 wxString PropertyValue;
1498 wxString PropertyTokens;
1499 wxString AddressLabel;
1500 wxString AddressLang;
1501 wxString AddressAltID;
1502 wxString AddressPID;
1503 wxString AddressTokens;
1504 wxString AddressGeo;
1505 wxString AddressTimezone;
1506 wxString AddressType;
1507 wxString AddressMediatype;
1508 wxString AddressPOBox;
1509 wxString AddressExtended;
1510 wxString AddressStreet;
1511 wxString AddressLocality;
1512 wxString AddressCity;
1513 wxString AddressRegion;
1514 wxString AddressPostalCode;
1515 wxString AddressCountry;
1516 bool FirstToken = TRUE;
1517 int intSplitsFound = 0;
1518 int intSplitSize = 0;
1519 int intPrevValue = 5;
1523 bool PropertyMatched = FALSE;
1525 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1529 PropertyType PropType = PROPERTY_NONE;
1531 // Look for type before continuing.
1533 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1537 std::map<int, wxString> *AddressList = NULL;
1538 std::map<int, wxString> *AddressListTown = NULL;
1539 std::map<int, wxString> *AddressListCounty = NULL;
1540 std::map<int, wxString> *AddressListPostCode = NULL;
1541 std::map<int, wxString> *AddressListCountry = NULL;
1542 std::map<int, wxString> *AddressListLabel = NULL;
1543 std::map<int, wxString> *AddressListLang = NULL;
1544 std::map<int, wxString> *AddressListAltID = NULL;
1545 std::map<int, wxString> *AddressListPID = NULL;
1546 std::map<int, wxString> *AddressListTokens = NULL;
1547 std::map<int, wxString> *AddressListGeo = NULL;
1548 std::map<int, wxString> *AddressListTimezone = NULL;
1549 std::map<int, wxString> *AddressListType = NULL;
1550 std::map<int, wxString> *AddressListMediatype = NULL;
1551 std::map<int, int> *AddressListPref = NULL;
1555 AddressList = &GeneralAddressList;
1556 AddressListTown = &GeneralAddressListTown;
1557 AddressListCounty = &GeneralAddressListCounty;
1558 AddressListPostCode = &GeneralAddressListPostCode;
1559 AddressListCountry = &GeneralAddressListCountry;
1560 AddressListLabel = &GeneralAddressListLabel;
1561 AddressListLang = &GeneralAddressListLang;
1562 AddressListAltID = &GeneralAddressListAltID;
1563 AddressListPID = &GeneralAddressListPID;
1564 AddressListTokens = &GeneralAddressListTokens;
1565 AddressListGeo = &GeneralAddressListGeo;
1566 AddressListTimezone = &GeneralAddressListTimezone;
1567 AddressListType = &GeneralAddressListType;
1568 AddressListMediatype = &GeneralAddressListMediatype;
1569 AddressListPref = &GeneralAddressListPref;
1572 AddressList = &HomeAddressList;
1573 AddressListTown = &HomeAddressListTown;
1574 AddressListCounty = &HomeAddressListCounty;
1575 AddressListPostCode = &HomeAddressListPostCode;
1576 AddressListCountry = &HomeAddressListCountry;
1577 AddressListLabel = &HomeAddressListLabel;
1578 AddressListLang = &HomeAddressListLang;
1579 AddressListAltID = &HomeAddressListAltID;
1580 AddressListPID = &HomeAddressListPID;
1581 AddressListTokens = &HomeAddressListTokens;
1582 AddressListGeo = &HomeAddressListGeo;
1583 AddressListTimezone = &HomeAddressListTimezone;
1584 AddressListType = &HomeAddressListType;
1585 AddressListMediatype = &HomeAddressListMediatype;
1586 AddressListPref = &HomeAddressListPref;
1589 AddressList = &BusinessAddressList;
1590 AddressListTown = &BusinessAddressListTown;
1591 AddressListCounty = &BusinessAddressListCounty;
1592 AddressListPostCode = &BusinessAddressListPostCode;
1593 AddressListCountry = &BusinessAddressListCountry;
1594 AddressListLabel = &BusinessAddressListLabel;
1595 AddressListLang = &BusinessAddressListLang;
1596 AddressListAltID = &BusinessAddressListAltID;
1597 AddressListPID = &BusinessAddressListPID;
1598 AddressListTokens = &BusinessAddressListTokens;
1599 AddressListGeo = &BusinessAddressListGeo;
1600 AddressListTimezone = &BusinessAddressListTimezone;
1601 AddressListType = &BusinessAddressListType;
1602 AddressListMediatype = &BusinessAddressListMediatype;
1603 AddressListPref = &BusinessAddressListPref;
1609 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1610 intiter != SplitPoints.end(); ++intiter){
1612 SLiter = SplitLength.find(intiter->first);
1613 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1614 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
1615 intPrevValue = intiter->second;
1617 CaptureString(&PropertyValue, FALSE);
1619 // Process properties.
1621 ProcessStringValue(&PropertyName, "LABEL", AddressListLabel, &PropertyValue, AddressCount, &PropertyMatched);
1622 ProcessStringValue(&PropertyName, "LANGUAGE", AddressListLang, &PropertyValue, AddressCount, &PropertyMatched);
1623 ProcessStringValue(&PropertyName, "ALTID", AddressListAltID, &PropertyValue, AddressCount, &PropertyMatched);
1624 ProcessStringValue(&PropertyName, "PID", AddressListPID, &PropertyValue, AddressCount, &PropertyMatched);
1625 ProcessStringValue(&PropertyName, "GEO", AddressListGeo, &PropertyValue, AddressCount, &PropertyMatched);
1626 ProcessStringValue(&PropertyName, "TZ", AddressListTimezone, &PropertyValue, AddressCount, &PropertyMatched);
1627 ProcessStringValue(&PropertyName, "MEDIATYPE", AddressListMediatype, &PropertyValue, AddressCount, &PropertyMatched);
1628 ProcessIntegerValue(&PropertyName, "PREF", AddressListPref, &PropertyValue, AddressCount, &PropertyMatched);
1630 if (PropertyMatched == TRUE){
1632 PropertyMatched = FALSE;
1637 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
1641 // Split the address.
1643 //std::map<int, int>::iterator SLiter;
1644 intPropertyLen = PropertySeg2.Len();
1645 SplitPoints.clear();
1646 SplitLength.clear();
1651 for (int i = 0; i <= intPropertyLen; i++){
1655 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
1658 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
1660 if (intSplitsFound == 6){
1662 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1667 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1677 // Split the data into several parts.
1679 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1680 intiter != SplitPoints.end(); ++intiter){
1682 if (intiter->first == 1){
1684 // Deal with PO Box.
1686 SLiter = SplitLength.find(1);
1688 AddressPOBox = PropertySeg2.Mid(0, SLiter->second);
1689 intPrevValue = intiter->second;
1691 } else if (intiter->first == 2){
1693 // Deal with extended address.
1695 SLiter = SplitLength.find(2);
1697 AddressExtended = PropertySeg2.Mid(intPrevValue, SLiter->second);
1698 intPrevValue = intiter->second;
1700 } else if (intiter->first == 3){
1702 // Deal with street address.
1704 SLiter = SplitLength.find(3);
1706 AddressStreet = PropertySeg2.Mid(intPrevValue, SLiter->second);
1707 intPrevValue = intiter->second;
1709 } else if (intiter->first == 4){
1711 // Deal with locality
1713 SLiter = SplitLength.find(4);
1715 AddressLocality = PropertySeg2.Mid(intPrevValue, SLiter->second);
1716 intPrevValue = intiter->second;
1718 } else if (intiter->first == 5){
1720 // Deal with region.
1722 SLiter = SplitLength.find(5);
1724 AddressRegion = PropertySeg2.Mid(intPrevValue, SLiter->second);
1725 intPrevValue = intiter->second;
1728 } else if (intiter->first == 6){
1730 // Deal with post code.
1732 SLiter = SplitLength.find(6);
1734 AddressPostalCode = PropertySeg2.Mid(intPrevValue, SLiter->second);
1735 intPrevValue = intiter->second;
1737 // Deal with country.
1739 AddressCountry = PropertySeg2.Mid(intPrevValue, wxString::npos);
1747 // Add the data to the General/Home/Work address variables.
1749 CaptureString(&AddressStreet, FALSE);
1750 CaptureString(&AddressLocality, FALSE);
1751 CaptureString(&AddressRegion, FALSE);
1752 CaptureString(&AddressPostalCode, FALSE);
1753 CaptureString(&AddressCountry, FALSE);
1755 if (!PropertyTokens.IsEmpty()){
1757 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
1761 AddressListCountry->insert(std::make_pair(*AddressCount, AddressCountry));
1762 AddressList->insert(std::make_pair(*AddressCount, AddressStreet));
1763 AddressListTown->insert(std::make_pair(*AddressCount, AddressLocality));
1764 AddressListCounty->insert(std::make_pair(*AddressCount, AddressRegion));
1765 AddressListPostCode->insert(std::make_pair(*AddressCount, AddressPostalCode));
1769 AddressListType->insert(std::make_pair(*AddressCount, wxT("")));
1772 AddressListType->insert(std::make_pair(*AddressCount, wxT("home")));
1775 AddressListType->insert(std::make_pair(*AddressCount, wxT("work")));
1779 AddressListTokens->insert(std::make_pair(*AddressCount, PropertyTokens));
1783 void ContactDataObject::ProcessEmail(wxString PropertySeg1, wxString PropertySeg2, int *EmailCount){
1785 std::map<int, int> SplitPoints;
1786 std::map<int, int> SplitLength;
1788 int intPrevValue = 7;
1791 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1795 PropertyType PropType = PROPERTY_NONE;
1797 // Look for type before continuing.
1799 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1801 std::map<int, wxString> *EmailList = NULL;
1802 std::map<int, wxString> *EmailListType = NULL;
1803 std::map<int, wxString> *EmailListAltID = NULL;
1804 std::map<int, wxString> *EmailListPID = NULL;
1805 std::map<int, wxString> *EmailListTokens = NULL;
1806 std::map<int, int> *EmailListPref = NULL;
1810 EmailList = &GeneralEmailList;
1811 EmailListType = &GeneralEmailListType;
1812 EmailListAltID = &GeneralEmailListAltID;
1813 EmailListPID = &GeneralEmailListPID;
1814 EmailListTokens = &GeneralEmailListTokens;
1815 EmailListPref = &GeneralEmailListPref;
1818 EmailList = &HomeEmailList;
1819 EmailListType = &HomeEmailListType;
1820 EmailListAltID = &HomeEmailListAltID;
1821 EmailListPID = &HomeEmailListPID;
1822 EmailListTokens = &HomeEmailListTokens;
1823 EmailListPref = &HomeEmailListPref;
1826 EmailList = &BusinessEmailList;
1827 EmailListType = &BusinessEmailListType;
1828 EmailListAltID = &BusinessEmailListAltID;
1829 EmailListPID = &BusinessEmailListPID;
1830 EmailListTokens = &BusinessEmailListTokens;
1831 EmailListPref = &BusinessEmailListPref;
1837 std::map<int,int>::iterator SLiter;
1838 wxString PropertyData;
1839 wxString PropertyName;
1840 wxString PropertyValue;
1841 wxString PropertyTokens;
1842 bool FirstToken = TRUE;
1843 bool PropertyMatched = FALSE;
1845 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1846 intiter != SplitPoints.end(); ++intiter){
1848 SLiter = SplitLength.find(intiter->first);
1849 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1850 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
1851 intPrevValue = intiter->second;
1853 CaptureString(&PropertyValue, FALSE);
1855 // Process properties.
1857 ProcessStringValue(&PropertyName, "ALTID", EmailListAltID, &PropertyValue, EmailCount, &PropertyMatched);
1858 ProcessStringValue(&PropertyName, "PID", EmailListPID, &PropertyValue, EmailCount, &PropertyMatched);
1859 ProcessIntegerValue(&PropertyName, "PREF", EmailListPref, &PropertyValue, EmailCount, &PropertyMatched);
1861 if (PropertyMatched == TRUE){
1863 PropertyMatched = FALSE;
1868 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
1872 EmailList->insert(std::make_pair(*EmailCount, PropertySeg2));
1874 // Add the name token data.
1876 if (!PropertyTokens.IsEmpty()){
1878 EmailListTokens->insert(std::make_pair(*EmailCount, PropertyTokens));
1885 void ContactDataObject::ProcessIM(wxString PropertySeg1, wxString PropertySeg2, int *IMCount){
1887 std::map<int, int> SplitPoints;
1888 std::map<int, int> SplitLength;
1890 int intPrevValue = 6;
1893 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1897 PropertyType PropType = PROPERTY_NONE;
1899 // Look for type before continuing.
1901 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
1903 std::map<int, wxString> *IMList = NULL;
1904 std::map<int, wxString> *IMListType = NULL;
1905 std::map<int, wxString> *IMListAltID = NULL;
1906 std::map<int, wxString> *IMListPID = NULL;
1907 std::map<int, wxString> *IMListTokens = NULL;
1908 std::map<int, wxString> *IMListMediatype = NULL;
1909 std::map<int, int> *IMListPref = NULL;
1913 IMList = &GeneralIMList;
1914 IMListType = &GeneralIMListType;
1915 IMListAltID = &GeneralIMListAltID;
1916 IMListPID = &GeneralIMListPID;
1917 IMListTokens = &GeneralIMListTokens;
1918 IMListMediatype = &GeneralIMListMediatype;
1919 IMListPref = &GeneralIMListPref;
1922 IMList = &HomeIMList;
1923 IMListType = &HomeIMListType;
1924 IMListAltID = &HomeIMListAltID;
1925 IMListPID = &HomeIMListPID;
1926 IMListTokens = &HomeIMListTokens;
1927 IMListMediatype = &HomeIMListMediatype;
1928 IMListPref = &HomeIMListPref;
1931 IMList = &BusinessIMList;
1932 IMListType = &BusinessIMListType;
1933 IMListAltID = &BusinessIMListAltID;
1934 IMListPID = &BusinessIMListPID;
1935 IMListTokens = &BusinessIMListTokens;
1936 IMListMediatype = &BusinessIMListMediatype;
1937 IMListPref = &BusinessIMListPref;
1943 std::map<int,int>::iterator SLiter;
1944 wxString PropertyData;
1945 wxString PropertyName;
1946 wxString PropertyValue;
1947 wxString PropertyTokens;
1948 bool FirstToken = TRUE;
1949 bool PropertyMatched = FALSE;
1951 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1952 intiter != SplitPoints.end(); ++intiter){
1954 SLiter = SplitLength.find(intiter->first);
1955 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
1956 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
1957 intPrevValue = intiter->second;
1959 CaptureString(&PropertyValue, FALSE);
1961 ProcessStringValue(&PropertyName, "ALTID", IMListAltID, &PropertyValue, IMCount, &PropertyMatched);
1962 ProcessStringValue(&PropertyName, "PID", IMListPID, &PropertyValue, IMCount, &PropertyMatched);
1963 ProcessStringValue(&PropertyName, "MEDIATYPE", IMListMediatype, &PropertyValue, IMCount, &PropertyMatched);
1964 ProcessIntegerValue(&PropertyName, "PREF", IMListPref, &PropertyValue, IMCount, &PropertyMatched);
1966 // Process properties.
1968 if (PropertyMatched == TRUE){
1970 PropertyMatched = FALSE;
1975 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
1979 IMList->insert(std::make_pair(*IMCount, PropertySeg2));
1981 // Add the name token data.
1983 if (!PropertyTokens.IsEmpty()){
1985 IMListTokens->insert(std::make_pair(*IMCount, PropertyTokens));
1991 void ContactDataObject::ProcessTelephone(wxString PropertySeg1, wxString PropertySeg2, int *TelephoneCount){
1993 std::map<int, int> SplitPoints;
1994 std::map<int, int> SplitLength;
1995 std::map<int, int>::iterator SLiter;
1999 PropertyType PropType = PROPERTY_NONE;
2001 // Look for type before continuing.
2004 wxString TelTypeDetail;
2005 wxString PropertyData;
2006 wxString PropertyName;
2007 wxString PropertyValue;
2008 wxString PropertyTokens;
2010 std::map<int,int> TypeSplitPoints;
2011 std::map<int,int> TypeSplitLength;
2012 std::map<int,int>::iterator TSLiter;
2014 int intSplitSize = 0;
2015 int intSplitsFound = 0;
2016 int intSplitPoint = 0;
2018 int intPrevValue = 5;
2020 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2024 // Look for type before continuing.
2026 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2027 intiter != SplitPoints.end(); ++intiter){
2029 SLiter = SplitLength.find(intiter->first);
2030 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2031 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
2032 intPrevValue = intiter->second;
2034 if (PropertyName == wxT("TYPE")){
2036 // Process each value in type and translate each
2039 // Strip out the quotes if they are there.
2041 size_t intPropertyValueLen = PropertyValue.Len();
2043 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2045 PropertyValue.Trim();
2046 PropertyValue.RemoveLast();
2050 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2052 PropertyValue.Remove(0, 1);
2056 TelTypeDetail = PropertyValue;
2062 for (int i = 0; i <= intPropertyValueLen; i++){
2066 if (PropertyValue.Mid(i, 1) == wxT(",") && PropertyValue.Mid((i - 1), 1) != wxT("\\")){
2068 if (intSplitsFound == 0){
2070 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2071 TypeSplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
2075 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2076 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2089 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
2090 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
2092 int intTypeSeek = 0;
2094 for (std::map<int, int>::iterator typeiter = TypeSplitPoints.begin();
2095 typeiter != TypeSplitPoints.end(); ++typeiter){
2097 wxString TypePropertyName;
2099 TSLiter = TypeSplitLength.find(typeiter->first);
2101 TypePropertyName = PropertyValue.Mid(typeiter->second, TSLiter->second);
2103 if (intTypeSeek == 0){
2108 TelTypeUI.Append(wxT(","));
2112 if (TypePropertyName == wxT("home")){
2114 PropType = PROPERTY_HOME;
2116 } else if (TypePropertyName == wxT("work")){
2118 PropType = PROPERTY_WORK;
2123 if (TypePropertyName == wxT("text")){
2125 TelTypeUI.Append(_("text"));
2128 } else if (TypePropertyName == wxT("voice")){
2130 TelTypeUI.Append(_("voice"));
2133 } else if (TypePropertyName == wxT("fax")){
2135 TelTypeUI.Append(_("fax"));
2138 } else if (TypePropertyName == wxT("cell")){
2140 TelTypeUI.Append(_("mobile"));
2143 } else if (TypePropertyName == wxT("video")){
2145 TelTypeUI.Append(_("video"));
2148 } else if (TypePropertyName == wxT("pager")){
2150 TelTypeUI.Append(_("pager"));
2153 } else if (TypePropertyName == wxT("textphone")){
2155 TelTypeUI.Append(_("textphone"));
2166 std::map<int, wxString> *TelephoneList = NULL;
2167 std::map<int, wxString> *TelephoneListType = NULL;
2168 std::map<int, wxString> *TelephoneListAltID = NULL;
2169 std::map<int, wxString> *TelephoneListPID = NULL;
2170 std::map<int, wxString> *TelephoneListTokens = NULL;
2171 std::map<int, wxString> *TelephoneListTypeInfo = NULL;
2172 std::map<int, int> *TelephoneListPref = NULL;
2176 TelephoneList = &GeneralTelephoneList;
2177 TelephoneListType = &GeneralTelephoneListType;
2178 TelephoneListAltID = &GeneralTelephoneListAltID;
2179 TelephoneListPID = &GeneralTelephoneListPID;
2180 TelephoneListTokens = &GeneralTelephoneListTokens;
2181 TelephoneListTypeInfo = &GeneralTelephoneListTypeInfo;
2182 TelephoneListPref = &GeneralTelephoneListPref;
2185 TelephoneList = &HomeTelephoneList;
2186 TelephoneListType = &HomeTelephoneListType;
2187 TelephoneListAltID = &HomeTelephoneListAltID;
2188 TelephoneListPID = &HomeTelephoneListPID;
2189 TelephoneListTokens = &HomeTelephoneListTokens;
2190 TelephoneListTypeInfo = &HomeTelephoneListTypeInfo;
2191 TelephoneListPref = &HomeTelephoneListPref;
2194 TelephoneList = &BusinessTelephoneList;
2195 TelephoneListType = &BusinessTelephoneListType;
2196 TelephoneListAltID = &BusinessTelephoneListAltID;
2197 TelephoneListPID = &BusinessTelephoneListPID;
2198 TelephoneListTokens = &BusinessTelephoneListTokens;
2199 TelephoneListTypeInfo = &BusinessTelephoneListTypeInfo;
2200 TelephoneListPref = &BusinessTelephoneListPref;
2204 // Process the properties.
2206 bool FirstToken = TRUE;
2209 SplitPoints.clear();
2210 SplitLength.clear();
2212 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2216 bool PropertyMatched = FALSE;
2218 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2219 intiter != SplitPoints.end(); ++intiter){
2221 SLiter = SplitLength.find(intiter->first);
2222 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2223 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
2224 intPrevValue = intiter->second;
2226 CaptureString(&PropertyValue, FALSE);
2228 // Process properties.
2230 ProcessStringValue(&PropertyName, "ALTID", TelephoneListAltID, &PropertyValue, TelephoneCount, &PropertyMatched);
2231 ProcessStringValue(&PropertyName, "PID", TelephoneListPID, &PropertyValue, TelephoneCount, &PropertyMatched);
2232 ProcessIntegerValue(&PropertyName, "PREF", TelephoneListPref, &PropertyValue, TelephoneCount, &PropertyMatched);
2234 if (PropertyMatched == TRUE){
2236 PropertyMatched = FALSE;
2241 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
2245 TelephoneList->insert(std::make_pair(*TelephoneCount, PropertySeg2));
2246 TelephoneListTypeInfo->insert(std::make_pair(*TelephoneCount, TelTypeUI));
2248 // Add the name token data.
2250 if (!PropertyTokens.IsEmpty()){
2252 TelephoneListTokens->insert(std::make_pair(*TelephoneCount, PropertyTokens));
2258 void ContactDataObject::ProcessLanguage(wxString PropertySeg1, wxString PropertySeg2, int *LanguageCount){
2260 std::map<int, int> SplitPoints;
2261 std::map<int, int> SplitLength;
2263 int intPrevValue = 6;
2266 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2270 PropertyType PropType = PROPERTY_NONE;
2272 // Look for type before continuing.
2274 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2276 std::map<int, wxString> *LanguageList = NULL;
2277 std::map<int, wxString> *LanguageListType = NULL;
2278 std::map<int, wxString> *LanguageListAltID = NULL;
2279 std::map<int, wxString> *LanguageListPID = NULL;
2280 std::map<int, wxString> *LanguageListTokens = NULL;
2281 std::map<int, int> *LanguageListPref = NULL;
2285 LanguageList = &GeneralLanguageList;
2286 LanguageListType = &GeneralLanguageListType;
2287 LanguageListAltID = &GeneralLanguageListAltID;
2288 LanguageListPID = &GeneralLanguageListPID;
2289 LanguageListTokens = &GeneralLanguageListTokens;
2290 LanguageListPref = &GeneralLanguageListPref;
2293 LanguageList = &HomeLanguageList;
2294 LanguageListType = &HomeLanguageListType;
2295 LanguageListAltID = &HomeLanguageListAltID;
2296 LanguageListPID = &HomeLanguageListPID;
2297 LanguageListTokens = &HomeLanguageListTokens;
2298 LanguageListPref = &HomeLanguageListPref;
2301 LanguageList = &BusinessLanguageList;
2302 LanguageListType = &BusinessLanguageListType;
2303 LanguageListAltID = &BusinessLanguageListAltID;
2304 LanguageListPID = &BusinessLanguageListPID;
2305 LanguageListTokens = &BusinessLanguageListTokens;
2306 LanguageListPref = &BusinessLanguageListPref;
2312 std::map<int,int>::iterator SLiter;
2313 wxString PropertyData;
2314 wxString PropertyName;
2315 wxString PropertyValue;
2316 wxString PropertyTokens;
2317 bool FirstToken = TRUE;
2318 bool PropertyMatched = FALSE;
2320 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2321 intiter != SplitPoints.end(); ++intiter){
2323 SLiter = SplitLength.find(intiter->first);
2324 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2325 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
2326 intPrevValue = intiter->second;
2328 CaptureString(&PropertyValue, FALSE);
2330 // Process properties.
2332 ProcessStringValue(&PropertyName, "ALTID", LanguageListAltID, &PropertyValue, LanguageCount, &PropertyMatched);
2333 ProcessStringValue(&PropertyName, "PID", LanguageListPID, &PropertyValue, LanguageCount, &PropertyMatched);
2334 ProcessIntegerValue(&PropertyName, "PREF", LanguageListPref, &PropertyValue, LanguageCount, &PropertyMatched);
2336 if (PropertyMatched == TRUE){
2338 PropertyMatched = FALSE;
2343 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
2347 LanguageList->insert(std::make_pair(*LanguageCount, PropertySeg2));
2349 // Add the name token data.
2351 if (!PropertyTokens.IsEmpty()){
2353 LanguageListTokens->insert(std::make_pair(*LanguageCount, PropertyTokens));
2359 void ContactDataObject::ProcessGeographic(wxString PropertySeg1, wxString PropertySeg2, int *GeographicCount){
2361 std::map<int, int> SplitPoints;
2362 std::map<int, int> SplitLength;
2364 int intPrevValue = 5;
2367 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2371 PropertyType PropType = PROPERTY_NONE;
2373 // Look for type before continuing.
2375 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2377 std::map<int, wxString> *GeopositionList = NULL;
2378 std::map<int, wxString> *GeopositionListType = NULL;
2379 std::map<int, wxString> *GeopositionListAltID = NULL;
2380 std::map<int, wxString> *GeopositionListPID = NULL;
2381 std::map<int, wxString> *GeopositionListTokens = NULL;
2382 std::map<int, wxString> *GeopositionListMediatype = NULL;
2383 std::map<int, int> *GeopositionListPref = NULL;
2387 GeopositionList = &GeneralGeographyList;
2388 GeopositionListType = &GeneralGeographyListType;
2389 GeopositionListAltID = &GeneralGeographyListAltID;
2390 GeopositionListPID = &GeneralGeographyListPID;
2391 GeopositionListTokens = &GeneralGeographyListTokens;
2392 GeopositionListMediatype = &GeneralGeographyListMediatype;
2393 GeopositionListPref = &GeneralGeographyListPref;
2396 GeopositionList = &HomeGeographyList;
2397 GeopositionListType = &HomeGeographyListType;
2398 GeopositionListAltID = &HomeGeographyListAltID;
2399 GeopositionListPID = &HomeGeographyListPID;
2400 GeopositionListTokens = &HomeGeographyListTokens;
2401 GeopositionListMediatype = &HomeGeographyListMediatype;
2402 GeopositionListPref = &HomeGeographyListPref;
2405 GeopositionList = &BusinessGeographyList;
2406 GeopositionListType = &BusinessGeographyListType;
2407 GeopositionListAltID = &BusinessGeographyListAltID;
2408 GeopositionListPID = &BusinessGeographyListPID;
2409 GeopositionListTokens = &BusinessGeographyListTokens;
2410 GeopositionListMediatype = &BusinessGeographyListMediatype;
2411 GeopositionListPref = &BusinessGeographyListPref;
2417 std::map<int,int>::iterator SLiter;
2418 wxString PropertyData;
2419 wxString PropertyName;
2420 wxString PropertyValue;
2421 wxString PropertyTokens;
2422 bool FirstToken = TRUE;
2423 bool PropertyMatched = FALSE;
2425 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2426 intiter != SplitPoints.end(); ++intiter){
2428 SLiter = SplitLength.find(intiter->first);
2429 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2430 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
2431 intPrevValue = intiter->second;
2433 CaptureString(&PropertyValue, FALSE);
2435 // Process properties.
2437 ProcessStringValue(&PropertyName, "ALTID", GeopositionListAltID, &PropertyValue, GeographicCount, &PropertyMatched);
2438 ProcessStringValue(&PropertyName, "PID", GeopositionListPID, &PropertyValue, GeographicCount, &PropertyMatched);
2439 ProcessStringValue(&PropertyName, "MEDIATYPE", GeopositionListMediatype, &PropertyValue, GeographicCount, &PropertyMatched);
2440 ProcessIntegerValue(&PropertyName, "PREF", GeopositionListPref, &PropertyValue, GeographicCount, &PropertyMatched);
2442 if (PropertyMatched == TRUE){
2444 PropertyMatched = FALSE;
2449 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
2453 GeopositionList->insert(std::make_pair(*GeographicCount, PropertySeg2));
2455 // Add the name token data.
2457 if (!PropertyTokens.IsEmpty()){
2459 GeopositionListTokens->insert(std::make_pair(*GeographicCount, PropertyTokens));
2465 void ContactDataObject::ProcessRelated(wxString PropertySeg1, wxString PropertySeg2, int *RelatedCount){
2467 size_t intPropertyLen = PropertySeg1.Len();
2468 std::map<int, int> SplitPoints;
2469 std::map<int, int> SplitLength;
2470 std::map<int, int>::iterator SLiter;
2471 wxString PropertyData;
2472 wxString PropertyName;
2473 wxString PropertyValue;
2474 wxString PropertyTokens;
2475 wxString RelatedType;
2476 wxString RelatedTypeOriginal;
2477 wxString RelatedName;
2478 bool FirstToken = TRUE;
2479 int intSplitsFound = 0;
2480 int intSplitSize = 0;
2481 int intPrevValue = 9;
2485 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2489 // Look for type before continuing.
2491 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2492 intiter != SplitPoints.end(); ++intiter){
2494 SLiter = SplitLength.find(intiter->first);
2495 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2496 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
2497 intPrevValue = intiter->second;
2501 RelatedTypeOriginal = PropertyValue;
2503 if (PropertyName == wxT("TYPE")){
2505 if (PropertyValue == wxT("contact")){
2507 RelatedType = _("Contact");
2509 } else if (PropertyValue == wxT("acquaintance")){
2511 RelatedType = _("Acquaintance");
2513 } else if (PropertyValue == wxT("friend")){
2515 RelatedType = _("Friend");
2517 } else if (PropertyValue == wxT("met")){
2519 RelatedType = _("Met");
2521 } else if (PropertyValue == wxT("co-worker")){
2523 RelatedType = _("Co-worker");
2525 } else if (PropertyValue == wxT("colleague")){
2527 RelatedType = _("Colleague");
2529 } else if (PropertyValue == wxT("co-resident")){
2531 RelatedType = _("Co-resident");
2533 } else if (PropertyValue == wxT("neighbor")){
2535 RelatedType = _("Neighbour");
2537 } else if (PropertyValue == wxT("child")){
2539 RelatedType = _("Child");
2541 } else if (PropertyValue == wxT("parent")){
2543 RelatedType = _("Parent");
2545 } else if (PropertyValue == wxT("sibling")){
2547 RelatedType = _("Sibling");
2549 } else if (PropertyValue == wxT("spouse")){
2551 RelatedType = _("Spouse");
2553 } else if (PropertyValue == wxT("kin")){
2555 RelatedType = _("Kin");
2557 } else if (PropertyValue == wxT("muse")){
2559 RelatedType = _("Muse");
2561 } else if (PropertyValue == wxT("crush")){
2563 RelatedType = _("Crush");
2565 } else if (PropertyValue == wxT("date")){
2567 RelatedType = _("Date");
2569 } else if (PropertyValue == wxT("sweetheart")){
2571 RelatedType = _("Sweetheart");
2573 } else if (PropertyValue == wxT("me")){
2575 RelatedType = _("Me");
2577 } else if (PropertyValue == wxT("agent")){
2579 RelatedType = _("Agent");
2581 } else if (PropertyValue == wxT("emergency")){
2583 RelatedType = _("Emergency");
2587 RelatedType = PropertyValue;
2597 bool PropertyMatched = FALSE;
2599 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2600 intiter != SplitPoints.end(); ++intiter){
2602 SLiter = SplitLength.find(intiter->first);
2603 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2604 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
2605 intPrevValue = intiter->second;
2607 // Process properties.
2609 size_t intPropertyValueLen = PropertyValue.Len();
2611 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2613 PropertyValue.Trim();
2614 PropertyValue.RemoveLast();
2618 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2620 PropertyValue.Remove(0, 1);
2624 CaptureString(&PropertyValue, FALSE);
2626 ProcessStringValue(&PropertyName, "ALTID", &GeneralRelatedListAltID, &PropertyValue, RelatedCount, &PropertyMatched);
2627 ProcessStringValue(&PropertyName, "PID", &GeneralRelatedListPID, &PropertyValue, RelatedCount, &PropertyMatched);
2628 ProcessStringValue(&PropertyName, "LANGUAGE", &GeneralRelatedListLanguage, &PropertyValue, RelatedCount, &PropertyMatched);
2629 ProcessIntegerValue(&PropertyName, "PREF", &GeneralRelatedListPref, &PropertyValue, RelatedCount, &PropertyMatched);
2631 if (PropertyMatched == TRUE){
2633 PropertyMatched = FALSE;
2638 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
2642 // Add the data to the General/Home/Work address variables.
2644 GeneralRelatedList.erase(*RelatedCount);
2645 GeneralRelatedListRelType.erase(*RelatedCount);
2646 GeneralRelatedListType.erase(*RelatedCount);
2647 GeneralRelatedListTokens.erase(*RelatedCount);
2648 GeneralRelatedList.insert(std::make_pair(*RelatedCount, PropertySeg2));
2649 GeneralRelatedListRelType.insert(std::make_pair(*RelatedCount, RelatedType));
2650 GeneralRelatedListType.insert(std::make_pair(*RelatedCount, RelatedType));
2651 GeneralRelatedListTokens.insert(std::make_pair(*RelatedCount, PropertyTokens));
2655 void ContactDataObject::ProcessURL(wxString PropertySeg1, wxString PropertySeg2, int *URLCount){
2657 std::map<int, int> SplitPoints;
2658 std::map<int, int> SplitLength;
2659 std::map<int, int>::iterator SLiter;
2660 wxString PropertyData;
2661 wxString PropertyName;
2662 wxString PropertyValue;
2663 wxString PropertyTokens;
2664 bool FirstToken = TRUE;
2665 int intPrevValue = 5;
2670 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2674 PropertyType PropType = PROPERTY_NONE;
2676 // Look for type before continuing.
2678 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2680 // Setup the pointers.
2682 std::map<int, wxString> *WebsiteList = NULL;
2683 std::map<int, wxString> *WebsiteListAltID = NULL;
2684 std::map<int, wxString> *WebsiteListPID = NULL;
2685 std::map<int, wxString> *WebsiteListType = NULL;
2686 std::map<int, wxString> *WebsiteListTokens = NULL;
2687 std::map<int, wxString> *WebsiteListMediatype = NULL;
2688 std::map<int, int> *WebsiteListPref = NULL;
2690 // Setup blank lines for later on.
2694 WebsiteList = &GeneralWebsiteList;
2695 WebsiteListType = &GeneralWebsiteListType;
2696 WebsiteListAltID = &GeneralWebsiteListAltID;
2697 WebsiteListPID = &GeneralWebsiteListPID;
2698 WebsiteListTokens = &GeneralWebsiteListTokens;
2699 WebsiteListMediatype = &GeneralWebsiteListMediatype;
2700 WebsiteListPref = &GeneralWebsiteListPref;
2703 WebsiteList = &HomeWebsiteList;
2704 WebsiteListType = &HomeWebsiteListType;
2705 WebsiteListAltID = &HomeWebsiteListAltID;
2706 WebsiteListPID = &HomeWebsiteListPID;
2707 WebsiteListTokens = &HomeWebsiteListTokens;
2708 WebsiteListMediatype = &HomeWebsiteListMediatype;
2709 WebsiteListPref = &HomeWebsiteListPref;
2712 WebsiteList = &BusinessWebsiteList;
2713 WebsiteListType = &BusinessWebsiteListType;
2714 WebsiteListAltID = &BusinessWebsiteListAltID;
2715 WebsiteListPID = &BusinessWebsiteListPID;
2716 WebsiteListTokens = &BusinessWebsiteListTokens;
2717 WebsiteListMediatype = &BusinessWebsiteListMediatype;
2718 WebsiteListPref = &BusinessWebsiteListPref;
2723 bool PropertyMatched = FALSE;
2725 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2726 intiter != SplitPoints.end(); ++intiter){
2728 SLiter = SplitLength.find(intiter->first);
2729 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2730 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
2731 intPrevValue = intiter->second;
2733 // Process properties.
2735 size_t intPropertyValueLen = PropertyValue.Len();
2737 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2739 PropertyValue.Trim();
2740 PropertyValue.RemoveLast();
2744 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2746 PropertyValue.Remove(0, 1);
2750 CaptureString(&PropertyValue, FALSE);
2752 ProcessStringValue(&PropertyName, "ALTID", WebsiteListAltID, &PropertyValue, URLCount, &PropertyMatched);
2753 ProcessStringValue(&PropertyName, "PID", WebsiteListPID, &PropertyValue, URLCount, &PropertyMatched);
2754 ProcessStringValue(&PropertyName, "MEDIATYPE", WebsiteListMediatype, &PropertyValue, URLCount, &PropertyMatched);
2755 ProcessIntegerValue(&PropertyName, "PREF", WebsiteListPref, &PropertyValue, URLCount, &PropertyMatched);
2757 if (PropertyMatched == TRUE){
2759 PropertyMatched = FALSE;
2764 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
2768 // Add the data to the General/Home/Work address variables.
2770 CaptureString(&PropertySeg2, FALSE);
2772 WebsiteList->insert(std::make_pair(*URLCount, PropertySeg2));
2774 if (!PropertyTokens.IsEmpty()){
2776 WebsiteListTokens->insert(std::make_pair(*URLCount, PropertyTokens));
2782 void ContactDataObject::ProcessTitle(wxString PropertySeg1, wxString PropertySeg2, int *TitleCount){
2784 std::map<int, int> SplitPoints;
2785 std::map<int, int> SplitLength;
2786 std::map<int, int>::iterator SLiter;
2787 wxString PropertyData;
2788 wxString PropertyName;
2789 wxString PropertyValue;
2790 wxString PropertyTokens;
2791 bool FirstToken = TRUE;
2792 int intPrevValue = 7;
2797 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2801 PropertyType PropType = PROPERTY_NONE;
2803 // Look for type before continuing.
2805 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2807 // Setup the pointers.
2809 std::map<int, wxString> *TitleList = NULL;
2810 std::map<int, wxString> *TitleListAltID = NULL;
2811 std::map<int, wxString> *TitleListPID = NULL;
2812 std::map<int, wxString> *TitleListType = NULL;
2813 std::map<int, wxString> *TitleListTokens = NULL;
2814 std::map<int, wxString> *TitleListLanguage = NULL;
2815 std::map<int, int> *TitleListPref = NULL;
2817 // Setup blank lines for later on.
2821 TitleList = &GeneralTitleList;
2822 TitleListType = &GeneralTitleListType;
2823 TitleListAltID = &GeneralTitleListAltID;
2824 TitleListPID = &GeneralTitleListPID;
2825 TitleListTokens = &GeneralTitleListTokens;
2826 TitleListLanguage = &GeneralTitleListLanguage;
2827 TitleListPref = &GeneralTitleListPref;
2830 TitleList = &HomeTitleList;
2831 TitleListType = &HomeTitleListType;
2832 TitleListAltID = &HomeTitleListAltID;
2833 TitleListPID = &HomeTitleListPID;
2834 TitleListTokens = &HomeTitleListTokens;
2835 TitleListLanguage = &HomeTitleListLanguage;
2836 TitleListPref = &HomeTitleListPref;
2839 TitleList = &BusinessTitleList;
2840 TitleListType = &BusinessTitleListType;
2841 TitleListAltID = &BusinessTitleListAltID;
2842 TitleListPID = &BusinessTitleListPID;
2843 TitleListTokens = &BusinessTitleListTokens;
2844 TitleListLanguage = &BusinessTitleListLanguage;
2845 TitleListPref = &BusinessTitleListPref;
2850 bool PropertyMatched = FALSE;
2852 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2853 intiter != SplitPoints.end(); ++intiter){
2855 SLiter = SplitLength.find(intiter->first);
2856 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2857 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
2858 intPrevValue = intiter->second;
2860 // Process properties.
2862 size_t intPropertyValueLen = PropertyValue.Len();
2864 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2866 PropertyValue.Trim();
2867 PropertyValue.RemoveLast();
2871 if (PropertyValue.Mid(0, 1) == wxT("\"")){
2873 PropertyValue.Remove(0, 1);
2877 CaptureString(&PropertyValue, FALSE);
2879 ProcessStringValue(&PropertyName, "ALTID", TitleListAltID, &PropertyValue, TitleCount, &PropertyMatched);
2880 ProcessStringValue(&PropertyName, "PID", TitleListPID, &PropertyValue, TitleCount, &PropertyMatched);
2881 ProcessStringValue(&PropertyName, "LANGUAGE", TitleListLanguage, &PropertyValue, TitleCount, &PropertyMatched);
2882 ProcessIntegerValue(&PropertyName, "PREF", TitleListPref, &PropertyValue, TitleCount, &PropertyMatched);
2884 if (PropertyMatched == TRUE){
2886 PropertyMatched = FALSE;
2891 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
2895 // Add the data to the General/Home/Work address variables.
2897 CaptureString(&PropertySeg2, FALSE);
2899 TitleList->insert(std::make_pair(*TitleCount, PropertySeg2));
2901 if (!PropertyTokens.IsEmpty()){
2903 TitleListTokens->insert(std::make_pair(*TitleCount, PropertyTokens));
2909 void ContactDataObject::ProcessRole(wxString PropertySeg1, wxString PropertySeg2, int *RoleCount){
2911 std::map<int, int> SplitPoints;
2912 std::map<int, int> SplitLength;
2913 std::map<int, int>::iterator SLiter;
2914 wxString PropertyData;
2915 wxString PropertyName;
2916 wxString PropertyValue;
2917 wxString PropertyTokens;
2918 bool FirstToken = TRUE;
2919 int intPrevValue = 6;
2924 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
2928 PropertyType PropType = PROPERTY_NONE;
2930 // Look for type before continuing.
2932 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
2934 // Setup the pointers.
2936 std::map<int, wxString> *RoleList = NULL;
2937 std::map<int, wxString> *RoleListAltID = NULL;
2938 std::map<int, wxString> *RoleListPID = NULL;
2939 std::map<int, wxString> *RoleListType = NULL;
2940 std::map<int, wxString> *RoleListTokens = NULL;
2941 std::map<int, wxString> *RoleListLanguage = NULL;
2942 std::map<int, int> *RoleListPref = NULL;
2944 // Setup blank lines for later on.
2948 RoleList = &GeneralRoleList;
2949 RoleListType = &GeneralRoleListType;
2950 RoleListAltID = &GeneralRoleListAltID;
2951 RoleListPID = &GeneralRoleListPID;
2952 RoleListTokens = &GeneralRoleListTokens;
2953 RoleListLanguage = &GeneralRoleListLanguage;
2954 RoleListPref = &GeneralRoleListPref;
2957 RoleList = &HomeRoleList;
2958 RoleListType = &HomeRoleListType;
2959 RoleListAltID = &HomeRoleListAltID;
2960 RoleListPID = &HomeRoleListPID;
2961 RoleListTokens = &HomeRoleListTokens;
2962 RoleListLanguage = &HomeRoleListLanguage;
2963 RoleListPref = &HomeRoleListPref;
2966 RoleList = &BusinessRoleList;
2967 RoleListType = &BusinessRoleListType;
2968 RoleListAltID = &BusinessRoleListAltID;
2969 RoleListPID = &BusinessRoleListPID;
2970 RoleListTokens = &BusinessRoleListTokens;
2971 RoleListLanguage = &BusinessRoleListLanguage;
2972 RoleListPref = &BusinessRoleListPref;
2977 bool PropertyMatched = FALSE;
2979 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
2980 intiter != SplitPoints.end(); ++intiter){
2982 SLiter = SplitLength.find(intiter->first);
2983 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
2984 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
2985 intPrevValue = intiter->second;
2987 // Process properties.
2989 size_t intPropertyValueLen = PropertyValue.Len();
2991 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
2993 PropertyValue.Trim();
2994 PropertyValue.RemoveLast();
2998 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3000 PropertyValue.Remove(0, 1);
3004 CaptureString(&PropertyValue, FALSE);
3006 ProcessStringValue(&PropertyName, "ALTID", RoleListAltID, &PropertyValue, RoleCount, &PropertyMatched);
3007 ProcessStringValue(&PropertyName, "PID", RoleListPID, &PropertyValue, RoleCount, &PropertyMatched);
3008 ProcessStringValue(&PropertyName, "LANGUAGE", RoleListLanguage, &PropertyValue, RoleCount, &PropertyMatched);
3009 ProcessIntegerValue(&PropertyName, "PREF", RoleListPref, &PropertyValue, RoleCount, &PropertyMatched);
3011 if (PropertyMatched == TRUE){
3013 PropertyMatched = FALSE;
3018 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
3022 // Add the data to the General/Home/Work address variables.
3024 CaptureString(&PropertySeg2, FALSE);
3026 RoleList->insert(std::make_pair(*RoleCount, PropertySeg2));
3028 if (!PropertyTokens.IsEmpty()){
3030 RoleListTokens->insert(std::make_pair(*RoleCount, PropertyTokens));
3036 void ContactDataObject::ProcessOrganisation(wxString PropertySeg1, wxString PropertySeg2, int *OrganisationCount){
3038 std::map<int, int> SplitPoints;
3039 std::map<int, int> SplitLength;
3040 std::map<int, int>::iterator SLiter;
3041 wxString PropertyData;
3042 wxString PropertyName;
3043 wxString PropertyValue;
3044 wxString PropertyTokens;
3045 bool FirstToken = TRUE;
3046 int intPrevValue = 5;
3051 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3055 PropertyType PropType = PROPERTY_NONE;
3057 // Look for type before continuing.
3059 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3061 // Setup the pointers.
3063 std::map<int, wxString> *OrganisationsList = NULL;
3064 std::map<int, wxString> *OrganisationsListAltID = NULL;
3065 std::map<int, wxString> *OrganisationsListPID = NULL;
3066 std::map<int, wxString> *OrganisationsListType = NULL;
3067 std::map<int, wxString> *OrganisationsListTokens = NULL;
3068 std::map<int, wxString> *OrganisationsListLanguage = NULL;
3069 std::map<int, wxString> *OrganisationsListSortAs = NULL;
3070 std::map<int, int> *OrganisationsListPref = NULL;
3072 // Setup blank lines for later on.
3076 OrganisationsList = &GeneralOrganisationsList;
3077 OrganisationsListType = &GeneralOrganisationsListType;
3078 OrganisationsListAltID = &GeneralOrganisationsListAltID;
3079 OrganisationsListPID = &GeneralOrganisationsListPID;
3080 OrganisationsListTokens = &GeneralOrganisationsListTokens;
3081 OrganisationsListLanguage = &GeneralOrganisationsListLanguage;
3082 OrganisationsListSortAs = &GeneralOrganisationsListSortAs;
3083 OrganisationsListPref = &GeneralOrganisationsListPref;
3086 OrganisationsList = &HomeOrganisationsList;
3087 OrganisationsListType = &HomeOrganisationsListType;
3088 OrganisationsListAltID = &HomeOrganisationsListAltID;
3089 OrganisationsListPID = &HomeOrganisationsListPID;
3090 OrganisationsListTokens = &HomeOrganisationsListTokens;
3091 OrganisationsListLanguage = &HomeOrganisationsListLanguage;
3092 OrganisationsListSortAs = &HomeOrganisationsListSortAs;
3093 OrganisationsListPref = &HomeOrganisationsListPref;
3096 OrganisationsList = &BusinessOrganisationsList;
3097 OrganisationsListType = &BusinessOrganisationsListType;
3098 OrganisationsListAltID = &BusinessOrganisationsListAltID;
3099 OrganisationsListPID = &BusinessOrganisationsListPID;
3100 OrganisationsListTokens = &BusinessOrganisationsListTokens;
3101 OrganisationsListLanguage = &BusinessOrganisationsListLanguage;
3102 OrganisationsListSortAs = &BusinessOrganisationsListSortAs;
3103 OrganisationsListPref = &BusinessOrganisationsListPref;
3108 bool PropertyMatched = FALSE;
3110 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3111 intiter != SplitPoints.end(); ++intiter){
3113 SLiter = SplitLength.find(intiter->first);
3114 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3115 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
3116 intPrevValue = intiter->second;
3118 // Process properties.
3120 size_t intPropertyValueLen = PropertyValue.Len();
3122 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3124 PropertyValue.Trim();
3125 PropertyValue.RemoveLast();
3129 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3131 PropertyValue.Remove(0, 1);
3135 CaptureString(&PropertyValue, FALSE);
3137 ProcessStringValue(&PropertyName, "ALTID", OrganisationsListAltID, &PropertyValue, OrganisationCount, &PropertyMatched);
3138 ProcessStringValue(&PropertyName, "PID", OrganisationsListPID, &PropertyValue, OrganisationCount, &PropertyMatched);
3139 ProcessStringValue(&PropertyName, "LANGUAGE", OrganisationsListLanguage, &PropertyValue, OrganisationCount, &PropertyMatched);
3140 ProcessStringValue(&PropertyName, "SORT-AS", OrganisationsListSortAs, &PropertyValue, OrganisationCount, &PropertyMatched);
3141 ProcessIntegerValue(&PropertyName, "PREF", OrganisationsListPref, &PropertyValue, OrganisationCount, &PropertyMatched);
3143 if (PropertyMatched == TRUE){
3145 PropertyMatched = FALSE;
3150 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
3154 // Add the data to the General/Home/Work address variables.
3156 CaptureString(&PropertySeg2, FALSE);
3158 OrganisationsList->insert(std::make_pair(*OrganisationCount, PropertySeg2));
3160 if (!PropertyTokens.IsEmpty()){
3162 OrganisationsListTokens->insert(std::make_pair(*OrganisationCount, PropertyTokens));
3168 void ContactDataObject::ProcessNote(wxString PropertySeg1, wxString PropertySeg2, int *NoteCount){
3170 std::map<int, int> SplitPoints;
3171 std::map<int, int> SplitLength;
3172 std::map<int, int>::iterator SLiter;
3173 wxString PropertyData;
3174 wxString PropertyName;
3175 wxString PropertyValue;
3176 wxString PropertyTokens;
3177 bool FirstToken = TRUE;
3178 int intPrevValue = 6;
3183 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3187 PropertyType PropType = PROPERTY_NONE;
3189 // Look for type before continuing.
3191 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3193 // Setup the pointers.
3195 std::map<int, wxString> *NoteList = NULL;
3196 std::map<int, wxString> *NoteListAltID = NULL;
3197 std::map<int, wxString> *NoteListPID = NULL;
3198 std::map<int, wxString> *NoteListType = NULL;
3199 std::map<int, wxString> *NoteListTokens = NULL;
3200 std::map<int, wxString> *NoteListLanguage = NULL;
3201 std::map<int, int> *NoteListPref = NULL;
3203 // Setup blank lines for later on.
3207 NoteList = &GeneralNoteList;
3208 NoteListType = &GeneralNoteListType;
3209 NoteListAltID = &GeneralNoteListAltID;
3210 NoteListPID = &GeneralNoteListPID;
3211 NoteListTokens = &GeneralNoteListTokens;
3212 NoteListLanguage = &GeneralNoteListLanguage;
3213 NoteListPref = &GeneralNoteListPref;
3216 NoteList = &HomeNoteList;
3217 NoteListType = &HomeNoteListType;
3218 NoteListAltID = &HomeNoteListAltID;
3219 NoteListPID = &HomeNoteListPID;
3220 NoteListTokens = &HomeNoteListTokens;
3221 NoteListLanguage = &HomeNoteListLanguage;
3222 NoteListPref = &HomeNoteListPref;
3225 NoteList = &BusinessNoteList;
3226 NoteListType = &BusinessNoteListType;
3227 NoteListAltID = &BusinessNoteListAltID;
3228 NoteListPID = &BusinessNoteListPID;
3229 NoteListTokens = &BusinessNoteListTokens;
3230 NoteListLanguage = &BusinessNoteListLanguage;
3231 NoteListPref = &BusinessNoteListPref;
3236 bool PropertyMatched = FALSE;
3238 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3239 intiter != SplitPoints.end(); ++intiter){
3241 SLiter = SplitLength.find(intiter->first);
3242 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3243 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
3244 intPrevValue = intiter->second;
3246 // Process properties.
3248 size_t intPropertyValueLen = PropertyValue.Len();
3250 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3252 PropertyValue.Trim();
3253 PropertyValue.RemoveLast();
3257 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3259 PropertyValue.Remove(0, 1);
3263 CaptureString(&PropertyValue, FALSE);
3265 ProcessStringValue(&PropertyName, "ALTID", NoteListAltID, &PropertyValue, NoteCount, &PropertyMatched);
3266 ProcessStringValue(&PropertyName, "PID", NoteListPID, &PropertyValue, NoteCount, &PropertyMatched);
3267 ProcessStringValue(&PropertyName, "LANGUAGE", NoteListLanguage, &PropertyValue, NoteCount, &PropertyMatched);
3268 ProcessIntegerValue(&PropertyName, "PREF", NoteListPref, &PropertyValue, NoteCount, &PropertyMatched);
3270 if (PropertyMatched == TRUE){
3272 PropertyMatched = FALSE;
3277 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
3281 // Add the data to the General/Home/Work address variables.
3283 CaptureString(&PropertySeg2, FALSE);
3285 NoteList->insert(std::make_pair(*NoteCount, PropertySeg2));
3287 if (!PropertyTokens.IsEmpty()){
3289 NoteListTokens->insert(std::make_pair(*NoteCount, PropertyTokens));
3295 void ContactDataObject::ProcessCategory(wxString PropertySeg1, wxString PropertySeg2, int *CategoryCount){
3297 std::map<int, int> SplitPoints;
3298 std::map<int, int> SplitLength;
3299 std::map<int, int>::iterator SLiter;
3300 wxString PropertyData;
3301 wxString PropertyName;
3302 wxString PropertyValue;
3303 wxString PropertyTokens;
3304 bool FirstToken = TRUE;
3305 int intPrevValue = 12;
3310 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3314 PropertyType PropType = PROPERTY_NONE;
3316 // Look for type before continuing.
3318 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3320 // Setup blank lines for later on.
3326 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
3329 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
3334 bool PropertyMatched = FALSE;
3336 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3337 intiter != SplitPoints.end(); ++intiter){
3339 SLiter = SplitLength.find(intiter->first);
3340 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3341 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
3342 intPrevValue = intiter->second;
3344 // Process properties.
3346 size_t intPropertyValueLen = PropertyValue.Len();
3348 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3350 PropertyValue.Trim();
3351 PropertyValue.RemoveLast();
3355 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3357 PropertyValue.Remove(0, 1);
3361 CaptureString(&PropertyValue, FALSE);
3363 ProcessStringValue(&PropertyName, "ALTID", &CategoriesListAltID, &PropertyValue, CategoryCount, &PropertyMatched);
3364 ProcessStringValue(&PropertyName, "PID", &CategoriesListPID, &PropertyValue, CategoryCount, &PropertyMatched);
3365 ProcessStringValue(&PropertyName, "LANGUAGE", &CategoriesListLanguage, &PropertyValue, CategoryCount, &PropertyMatched);
3366 ProcessIntegerValue(&PropertyName, "PREF", &CategoriesListPref, &PropertyValue, CategoryCount, &PropertyMatched);
3368 if (PropertyMatched == TRUE){
3370 PropertyMatched = FALSE;
3375 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
3379 // Deal with multiple categories.
3381 int intOrigCatCount = *CategoryCount;
3382 bool FirstCategoryProcessed = TRUE;
3383 bool AfterFirstToken = FALSE;
3384 int intSplitSize = 0;
3385 int intSplitsFound = 0;
3386 int intSplitSeek = 0;
3387 int intPropertyLen = PropertySeg2.Len();
3389 SplitPoints.clear();
3390 SplitLength.clear();
3393 for (int i = 0; i <= intPropertyLen; i++){
3395 if (intSplitSize == 0 && PropertySeg2.Mid(i, 1) == wxT(" ")){
3403 if (PropertySeg2.Mid(i, 1) == wxT(",") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
3405 if (AfterFirstToken == TRUE){
3407 SplitPoints.insert(std::make_pair(intSplitsFound, (i - intSplitSize + 1)));
3408 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
3412 SplitPoints.insert(std::make_pair(intSplitsFound, 0));
3413 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 2)));
3414 AfterFirstToken = TRUE;
3426 if (SplitPoints.size() > 0){
3428 SplitPoints.insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
3429 SplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
3433 if (SplitPoints.size() == 0){
3435 CategoriesList.insert(std::make_pair(*CategoryCount, PropertySeg2));
3437 if (!PropertyTokens.IsEmpty()){
3439 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
3445 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3446 intiter != SplitPoints.end(); ++intiter){
3448 SLiter = SplitLength.find(intiter->first);
3450 intPrevValue = intiter->second;
3452 PropertyData = PropertySeg2.Mid(intPrevValue, (SLiter->second + 1));
3454 // Add the data to the General/Home/Work address variables.
3456 // Trim any whitespace from the start and end.
3458 PropertyData = PropertyData.Trim(FALSE);
3459 PropertyData = PropertyData.Trim(TRUE);
3461 CaptureString(&PropertyData, FALSE);
3463 if (FirstCategoryProcessed == TRUE){
3465 FirstCategoryProcessed = FALSE;
3467 CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
3469 if (!PropertyTokens.IsEmpty()){
3471 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
3481 CategoriesList.insert(std::make_pair(*CategoryCount, PropertyData));
3483 if (!PropertyTokens.IsEmpty()){
3485 CategoriesListTokens.insert(std::make_pair(*CategoryCount, PropertyTokens));
3491 // Copy the properties to each of the categories (if it exists).
3493 if (!PropertyTokens.IsEmpty()){
3495 CategoriesListTokens.insert(std::make_pair(*CategoryCount, CategoriesListTokens.find(intOrigCatCount)->second));
3499 // Check if ALTID was used.
3501 if (CategoriesListAltID.find(intOrigCatCount) != CategoriesListAltID.end()){
3503 CategoriesListAltID.insert(std::make_pair(*CategoryCount, CategoriesListAltID.find(intOrigCatCount)->second));
3507 // Check if PID was used.
3509 if (CategoriesListPID.find(intOrigCatCount) != CategoriesListPID.end()){
3511 CategoriesListPID.insert(std::make_pair(*CategoryCount, CategoriesListPID.find(intOrigCatCount)->second));
3515 // Check if PREF was used.
3517 if (CategoriesListPref.find(intOrigCatCount) != CategoriesListPref.end()){
3519 CategoriesListPref.insert(std::make_pair(*CategoryCount, CategoriesListPref.find(intOrigCatCount)->second));
3523 // Check if LANGUAGE was used.
3525 if (CategoriesListLanguage.find(intOrigCatCount) != CategoriesListLanguage.end()){
3527 CategoriesListLanguage.insert(std::make_pair(*CategoryCount, CategoriesListLanguage.find(intOrigCatCount)->second));
3531 // Check if TYPE was used.
3537 CategoriesListType.insert(std::make_pair(*CategoryCount, "home"));
3540 CategoriesListType.insert(std::make_pair(*CategoryCount, "work"));
3548 void ContactDataObject::ProcessPhoto(wxString PropertySeg1, wxString PropertySeg2, int *PhotoCount){
3550 size_t intPropertyLen = PropertySeg1.Len();
3551 std::map<int, int> SplitPoints;
3552 std::map<int, int> SplitLength;
3553 std::map<int, int>::iterator SLiter;
3554 wxString PropertyData;
3555 wxString PropertyName;
3556 wxString PropertyValue;
3557 wxString PropertyTokens;
3558 bool FirstToken = TRUE;
3559 int intSplitsFound = 0;
3560 int intSplitSize = 0;
3561 int intPrevValue = 7;
3565 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3569 PropertyType PropType = PROPERTY_NONE;
3571 // Look for type before continuing.
3573 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3576 bool PropertyMatched = FALSE;
3578 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3579 intiter != SplitPoints.end(); ++intiter){
3581 SLiter = SplitLength.find(intiter->first);
3582 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3583 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
3584 intPrevValue = intiter->second;
3586 // Process properties.
3588 size_t intPropertyValueLen = PropertyValue.Len();
3590 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3592 PropertyValue.Trim();
3593 PropertyValue.RemoveLast();
3597 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3599 PropertyValue.Remove(0, 1);
3603 CaptureString(&PropertyValue, FALSE);
3605 ProcessStringValue(&PropertyName, "ALTID", &PicturesListAltID, &PropertyValue, PhotoCount, &PropertyMatched);
3606 ProcessStringValue(&PropertyName, "PID", &PicturesListPID, &PropertyValue, PhotoCount, &PropertyMatched);
3607 ProcessStringValue(&PropertyName, "MEDIATYPE", &PicturesListMediatype, &PropertyValue, PhotoCount, &PropertyMatched);
3608 ProcessIntegerValue(&PropertyName, "PREF", &PicturesListPref, &PropertyValue, PhotoCount, &PropertyMatched);
3610 if (PropertyMatched == TRUE){
3612 PropertyMatched = FALSE;
3617 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
3621 intPropertyLen = PropertySeg2.Len();
3622 SplitPoints.clear();
3623 SplitLength.clear();
3628 CaptureString(&PropertySeg2, FALSE);
3630 for (int i = 0; i <= intPropertyLen; i++){
3634 if (PropertySeg2.Mid(i, 1) == wxT(";")){
3637 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
3639 if (intSplitsFound == 6){
3641 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
3646 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
3656 wxString wxSPhotoURI;
3657 wxString wxSPhotoMIME;
3658 wxString wxSPhotoEncoding;
3659 wxString wxSPhotoData;
3660 std::string base64enc;
3662 if (intSplitsFound == 0){
3666 std::map<int, int>::iterator striter;
3668 striter = SplitLength.find(1);
3670 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
3672 while (wSTDataType.HasMoreTokens() == TRUE){
3674 wxSPhotoURI = wSTDataType.GetNextToken();
3675 wxSPhotoMIME = wSTDataType.GetNextToken();
3680 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
3682 while (wSTDataInfo.HasMoreTokens() == TRUE){
3684 wxSPhotoEncoding = wSTDataInfo.GetNextToken();
3685 wxSPhotoData = wSTDataInfo.GetNextToken();
3686 base64enc = wxSPhotoData.mb_str();
3693 // Add the data to the General/Home/Work address variables.
3695 PicturesList.insert(std::make_pair(*PhotoCount, base64enc));
3696 PicturesListPictureType.insert(std::make_pair(*PhotoCount, wxSPhotoMIME));
3697 PicturesListPicEncType.insert(std::make_pair(*PhotoCount, wxSPhotoEncoding));
3703 PicturesListType.insert(std::make_pair(*PhotoCount, "home"));
3706 PicturesListType.insert(std::make_pair(*PhotoCount, "work"));
3710 if (!PropertyTokens.IsEmpty()){
3712 PicturesListTokens.insert(std::make_pair(*PhotoCount, PropertyTokens));
3718 void ContactDataObject::ProcessLogo(wxString PropertySeg1, wxString PropertySeg2, int *LogoCount){
3720 size_t intPropertyLen = PropertySeg1.Len();
3721 std::map<int, int> SplitPoints;
3722 std::map<int, int> SplitLength;
3723 std::map<int, int>::iterator SLiter;
3724 wxString PropertyData;
3725 wxString PropertyName;
3726 wxString PropertyValue;
3727 wxString PropertyTokens;
3728 bool FirstToken = TRUE;
3729 int intSplitsFound = 0;
3730 int intSplitSize = 0;
3731 int intPrevValue = 6;
3735 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3739 PropertyType PropType = PROPERTY_NONE;
3741 // Look for type before continuing.
3743 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3746 bool PropertyMatched = FALSE;
3748 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3749 intiter != SplitPoints.end(); ++intiter){
3751 SLiter = SplitLength.find(intiter->first);
3752 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3753 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
3754 intPrevValue = intiter->second;
3756 // Process properties.
3758 size_t intPropertyValueLen = PropertyValue.Len();
3760 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3762 PropertyValue.Trim();
3763 PropertyValue.RemoveLast();
3767 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3769 PropertyValue.Remove(0, 1);
3773 CaptureString(&PropertyValue, FALSE);
3775 ProcessStringValue(&PropertyName, "ALTID", &LogosListAltID, &PropertyValue, LogoCount, &PropertyMatched);
3776 ProcessStringValue(&PropertyName, "PID", &LogosListPID, &PropertyValue, LogoCount, &PropertyMatched);
3777 ProcessStringValue(&PropertyName, "MEDIATYPE", &LogosListMediatype, &PropertyValue, LogoCount, &PropertyMatched);
3778 ProcessIntegerValue(&PropertyName, "PREF", &LogosListPref, &PropertyValue, LogoCount, &PropertyMatched);
3780 if (PropertyMatched == TRUE){
3782 PropertyMatched = FALSE;
3787 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
3791 intPropertyLen = PropertySeg2.Len();
3792 SplitPoints.clear();
3793 SplitLength.clear();
3798 CaptureString(&PropertySeg2, FALSE);
3800 for (int i = 0; i <= intPropertyLen; i++){
3804 if (PropertySeg2.Mid(i, 1) == wxT(";")){
3807 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
3809 if (intSplitsFound == 6){
3811 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
3816 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
3826 wxString wxSPhotoURI;
3827 wxString wxSPhotoMIME;
3828 wxString wxSPhotoEncoding;
3829 wxString wxSPhotoData;
3830 std::string base64enc;
3832 if (intSplitsFound == 0){
3836 std::map<int, int>::iterator striter;
3838 striter = SplitLength.find(1);
3840 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
3842 while (wSTDataType.HasMoreTokens() == TRUE){
3844 wxSPhotoURI = wSTDataType.GetNextToken();
3845 wxSPhotoMIME = wSTDataType.GetNextToken();
3850 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
3852 while (wSTDataInfo.HasMoreTokens() == TRUE){
3854 wxSPhotoEncoding = wSTDataInfo.GetNextToken();
3855 wxSPhotoData = wSTDataInfo.GetNextToken();
3856 base64enc = wxSPhotoData.mb_str();
3863 // Add the data to the General/Home/Work address variables.
3865 LogosList.insert(std::make_pair(*LogoCount, base64enc));
3866 LogosListPictureType.insert(std::make_pair(*LogoCount, wxSPhotoMIME));
3867 LogosListPicEncType.insert(std::make_pair(*LogoCount, wxSPhotoEncoding));
3873 LogosListType.insert(std::make_pair(*LogoCount, "home"));
3876 LogosListType.insert(std::make_pair(*LogoCount, "work"));
3880 if (!PropertyTokens.IsEmpty()){
3882 LogosListTokens.insert(std::make_pair(*LogoCount, PropertyTokens));
3888 void ContactDataObject::ProcessSound(wxString PropertySeg1, wxString PropertySeg2, int *SoundCount){
3890 size_t intPropertyLen = PropertySeg1.Len();
3891 std::map<int, int> SplitPoints;
3892 std::map<int, int> SplitLength;
3893 std::map<int, int>::iterator SLiter;
3894 wxString PropertyData;
3895 wxString PropertyName;
3896 wxString PropertyValue;
3897 wxString PropertyTokens;
3898 bool FirstToken = TRUE;
3899 int intSplitsFound = 0;
3900 int intSplitSize = 0;
3901 int intPrevValue = 7;
3905 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
3909 PropertyType PropType = PROPERTY_NONE;
3911 // Look for type before continuing.
3913 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
3916 bool PropertyMatched = FALSE;
3918 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
3919 intiter != SplitPoints.end(); ++intiter){
3921 SLiter = SplitLength.find(intiter->first);
3922 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
3923 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
3924 intPrevValue = intiter->second;
3926 // Process properties.
3928 size_t intPropertyValueLen = PropertyValue.Len();
3930 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
3932 PropertyValue.Trim();
3933 PropertyValue.RemoveLast();
3937 if (PropertyValue.Mid(0, 1) == wxT("\"")){
3939 PropertyValue.Remove(0, 1);
3943 CaptureString(&PropertyValue, FALSE);
3945 ProcessStringValue(&PropertyName, "ALTID", &SoundsListAltID, &PropertyValue, SoundCount, &PropertyMatched);
3946 ProcessStringValue(&PropertyName, "PID", &SoundsListPID, &PropertyValue, SoundCount, &PropertyMatched);
3947 ProcessStringValue(&PropertyName, "MEDIATYPE", &SoundsListMediatype, &PropertyValue, SoundCount, &PropertyMatched);
3948 ProcessStringValue(&PropertyName, "LANGUAGE", &SoundsListLanguage, &PropertyValue, SoundCount, &PropertyMatched);
3949 ProcessIntegerValue(&PropertyName, "PREF", &SoundsListPref, &PropertyValue, SoundCount, &PropertyMatched);
3951 if (PropertyMatched == TRUE){
3953 PropertyMatched = FALSE;
3958 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
3962 intPropertyLen = PropertySeg2.Len();
3963 SplitPoints.clear();
3964 SplitLength.clear();
3969 CaptureString(&PropertySeg2, FALSE);
3971 for (int i = 0; i <= intPropertyLen; i++){
3975 if (PropertySeg2.Mid(i, 1) == wxT(";")){
3978 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
3980 if (intSplitsFound == 6){
3982 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
3987 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
3997 wxString wxSSoundURI;
3998 wxString wxSSoundMIME;
3999 wxString wxSSoundEncoding;
4000 wxString wxSSoundData;
4001 std::string base64enc;
4003 if (intSplitsFound == 0){
4007 std::map<int, int>::iterator striter;
4009 striter = SplitLength.find(1);
4011 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4013 while (wSTDataType.HasMoreTokens() == TRUE){
4015 wxSSoundURI = wSTDataType.GetNextToken();
4016 wxSSoundMIME = wSTDataType.GetNextToken();
4021 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
4023 while (wSTDataInfo.HasMoreTokens() == TRUE){
4025 wxSSoundEncoding = wSTDataInfo.GetNextToken();
4026 wxSSoundData = wSTDataInfo.GetNextToken();
4027 base64enc = wxSSoundData.mb_str();
4034 // Add the data to the General/Home/Work address variables.
4040 SoundsListType.insert(std::make_pair(*SoundCount, "home"));
4043 SoundsListType.insert(std::make_pair(*SoundCount, "work"));
4047 SoundsList.insert(std::make_pair(*SoundCount, base64enc));
4048 SoundsListAudioEncType.insert(std::make_pair(*SoundCount, wxSSoundEncoding));
4049 SoundsListAudioType.insert(std::make_pair(*SoundCount, wxSSoundMIME));
4051 if (!PropertyTokens.IsEmpty()){
4053 SoundsListTokens.insert(std::make_pair(*SoundCount, PropertyTokens));
4059 void ContactDataObject::ProcessCalendarURI(wxString PropertySeg1, wxString PropertySeg2, int *CalURICount){
4061 size_t intPropertyLen = PropertySeg1.Len();
4062 std::map<int, int> SplitPoints;
4063 std::map<int, int> SplitLength;
4064 std::map<int, int>::iterator SLiter;
4065 wxString PropertyData;
4066 wxString PropertyName;
4067 wxString PropertyValue;
4068 wxString PropertyTokens;
4069 bool FirstToken = TRUE;
4070 int intSplitsFound = 0;
4071 int intSplitSize = 0;
4072 int intPrevValue = 8;
4076 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4080 PropertyType PropType = PROPERTY_NONE;
4082 // Look for type before continuing.
4084 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4087 bool PropertyMatched = FALSE;
4089 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4090 intiter != SplitPoints.end(); ++intiter){
4092 SLiter = SplitLength.find(intiter->first);
4093 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4094 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
4095 intPrevValue = intiter->second;
4097 // Process properties.
4099 size_t intPropertyValueLen = PropertyValue.Len();
4101 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4103 PropertyValue.Trim();
4104 PropertyValue.RemoveLast();
4108 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4110 PropertyValue.Remove(0, 1);
4114 CaptureString(&PropertyValue, FALSE);
4116 ProcessStringValue(&PropertyName, "ALTID", &CalendarListAltID, &PropertyValue, CalURICount, &PropertyMatched);
4117 ProcessStringValue(&PropertyName, "PID", &CalendarListPID, &PropertyValue, CalURICount, &PropertyMatched);
4118 ProcessStringValue(&PropertyName, "MEDIATYPE", &CalendarListMediatype, &PropertyValue, CalURICount, &PropertyMatched);
4119 ProcessIntegerValue(&PropertyName, "PREF", &CalendarListPref, &PropertyValue, CalURICount, &PropertyMatched);
4121 if (PropertyMatched == TRUE){
4123 PropertyMatched = FALSE;
4128 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
4132 intPropertyLen = PropertySeg2.Len();
4133 SplitPoints.clear();
4134 SplitLength.clear();
4139 CaptureString(&PropertySeg2, FALSE);
4141 // Add the data to the General/Home/Work address variables.
4147 CalendarListType.insert(std::make_pair(*CalURICount, "home"));
4150 CalendarListType.insert(std::make_pair(*CalURICount, "work"));
4154 CalendarList.insert(std::make_pair(*CalURICount, PropertySeg2));
4156 if (!PropertyTokens.IsEmpty()){
4158 CalendarListTokens.insert(std::make_pair(*CalURICount, PropertyTokens));
4164 void ContactDataObject::ProcessCalendarAddressURI(wxString PropertySeg1, wxString PropertySeg2, int *CalAdrURICount){
4166 size_t intPropertyLen = PropertySeg1.Len();
4167 std::map<int, int> SplitPoints;
4168 std::map<int, int> SplitLength;
4169 std::map<int, int>::iterator SLiter;
4170 wxString PropertyData;
4171 wxString PropertyName;
4172 wxString PropertyValue;
4173 wxString PropertyTokens;
4174 bool FirstToken = TRUE;
4175 int intSplitsFound = 0;
4176 int intSplitSize = 0;
4177 int intPrevValue = 8;
4181 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4185 PropertyType PropType = PROPERTY_NONE;
4187 // Look for type before continuing.
4189 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4192 bool PropertyMatched = FALSE;
4194 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4195 intiter != SplitPoints.end(); ++intiter){
4197 SLiter = SplitLength.find(intiter->first);
4198 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4199 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
4200 intPrevValue = intiter->second;
4202 // Process properties.
4204 size_t intPropertyValueLen = PropertyValue.Len();
4206 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4208 PropertyValue.Trim();
4209 PropertyValue.RemoveLast();
4213 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4215 PropertyValue.Remove(0, 1);
4219 CaptureString(&PropertyValue, FALSE);
4221 ProcessStringValue(&PropertyName, "ALTID", &CalendarRequestListAltID, &PropertyValue, CalAdrURICount, &PropertyMatched);
4222 ProcessStringValue(&PropertyName, "PID", &CalendarRequestListPID, &PropertyValue, CalAdrURICount, &PropertyMatched);
4223 ProcessStringValue(&PropertyName, "MEDIATYPE", &CalendarRequestListMediatype, &PropertyValue, CalAdrURICount, &PropertyMatched);
4224 ProcessIntegerValue(&PropertyName, "PREF", &CalendarRequestListPref, &PropertyValue, CalAdrURICount, &PropertyMatched);
4226 if (PropertyMatched == TRUE){
4228 PropertyMatched = FALSE;
4233 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
4237 intPropertyLen = PropertySeg2.Len();
4238 SplitPoints.clear();
4239 SplitLength.clear();
4244 CaptureString(&PropertySeg2, FALSE);
4246 // Add the data to the General/Home/Work address variables.
4252 CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "home"));
4255 CalendarRequestListType.insert(std::make_pair(*CalAdrURICount, "work"));
4259 CalendarRequestList.insert(std::make_pair(*CalAdrURICount, PropertySeg2));
4261 if (!PropertyTokens.IsEmpty()){
4263 CalendarRequestListTokens.insert(std::make_pair(*CalAdrURICount, PropertyTokens));
4269 void ContactDataObject::ProcessCalendarFreeBusy(wxString PropertySeg1, wxString PropertySeg2, int *FreeBusyAddressCount){
4271 size_t intPropertyLen = PropertySeg1.Len();
4272 std::map<int, int> SplitPoints;
4273 std::map<int, int> SplitLength;
4274 std::map<int, int>::iterator SLiter;
4275 wxString PropertyData;
4276 wxString PropertyName;
4277 wxString PropertyValue;
4278 wxString PropertyTokens;
4279 bool FirstToken = TRUE;
4280 int intSplitsFound = 0;
4281 int intSplitSize = 0;
4282 int intPrevValue = 7;
4286 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4290 PropertyType PropType = PROPERTY_NONE;
4292 // Look for type before continuing.
4294 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4297 bool PropertyMatched = FALSE;
4299 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4300 intiter != SplitPoints.end(); ++intiter){
4302 SLiter = SplitLength.find(intiter->first);
4303 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4304 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
4305 intPrevValue = intiter->second;
4307 // Process properties.
4309 size_t intPropertyValueLen = PropertyValue.Len();
4311 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4313 PropertyValue.Trim();
4314 PropertyValue.RemoveLast();
4318 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4320 PropertyValue.Remove(0, 1);
4324 CaptureString(&PropertyValue, FALSE);
4326 ProcessStringValue(&PropertyName, "ALTID", &FreeBusyListAltID, &PropertyValue, FreeBusyAddressCount, &PropertyMatched);
4327 ProcessStringValue(&PropertyName, "PID", &FreeBusyListPID, &PropertyValue, FreeBusyAddressCount, &PropertyMatched);
4328 ProcessStringValue(&PropertyName, "MEDIATYPE", &FreeBusyListMediatype, &PropertyValue, FreeBusyAddressCount, &PropertyMatched);
4329 ProcessIntegerValue(&PropertyName, "PREF", &FreeBusyListPref, &PropertyValue, FreeBusyAddressCount, &PropertyMatched);
4331 if (PropertyMatched == TRUE){
4333 PropertyMatched = FALSE;
4338 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
4342 intPropertyLen = PropertySeg2.Len();
4343 SplitPoints.clear();
4344 SplitLength.clear();
4349 CaptureString(&PropertySeg2, FALSE);
4351 // Add the data to the General/Home/Work address variables.
4357 FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "home"));
4360 FreeBusyListType.insert(std::make_pair(*FreeBusyAddressCount, "work"));
4364 FreeBusyList.insert(std::make_pair(*FreeBusyAddressCount, PropertySeg2));
4366 if (!PropertyTokens.IsEmpty()){
4368 FreeBusyListTokens.insert(std::make_pair(*FreeBusyAddressCount, PropertyTokens));
4374 void ContactDataObject::ProcessKey(wxString PropertySeg1, wxString PropertySeg2, int *KeyCount){
4376 size_t intPropertyLen = PropertySeg1.Len();
4377 std::map<int, int> SplitPoints;
4378 std::map<int, int> SplitLength;
4379 std::map<int, int>::iterator SLiter;
4380 wxString PropertyData;
4381 wxString PropertyName;
4382 wxString PropertyValue;
4383 wxString PropertyTokens;
4384 bool FirstToken = TRUE;
4385 int intSplitsFound = 0;
4386 int intSplitSize = 0;
4387 int intPrevValue = 5;
4392 SplitValues(&PropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
4396 PropertyType PropType = PROPERTY_NONE;
4398 // Look for type before continuing.
4400 CheckType(&PropertySeg1, &SplitPoints, &SplitLength, &intPrevValue, &PropType);
4403 bool PropertyMatched = FALSE;
4405 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
4406 intiter != SplitPoints.end(); ++intiter){
4408 SLiter = SplitLength.find(intiter->first);
4409 PropertyData = PropertySeg1.Mid(intPrevValue, (SLiter->second));
4410 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
4411 intPrevValue = intiter->second;
4413 // Process properties.
4415 size_t intPropertyValueLen = PropertyValue.Len();
4417 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
4419 PropertyValue.Trim();
4420 PropertyValue.RemoveLast();
4424 if (PropertyValue.Mid(0, 1) == wxT("\"")){
4426 PropertyValue.Remove(0, 1);
4430 ProcessStringValue(&PropertyName, "ALTID", &KeyListAltID, &PropertyValue, KeyCount, &PropertyMatched);
4431 ProcessStringValue(&PropertyName, "PID", &KeyListPID, &PropertyValue, KeyCount, &PropertyMatched);
4432 ProcessIntegerValue(&PropertyName, "PREF", &KeyListPref, &PropertyValue, KeyCount, &PropertyMatched);
4434 if (PropertyMatched == TRUE){
4436 PropertyMatched = FALSE;
4441 ProcessTokens(&PropertyName, &PropertyValue, &PropertyTokens, &FirstToken);
4445 intPropertyLen = PropertySeg2.Len();
4446 SplitPoints.clear();
4447 SplitLength.clear();
4452 for (int i = 0; i <= intPropertyLen; i++){
4456 if (PropertySeg2.Mid(i, 1) == wxT(";") && PropertySeg2.Mid((i - 1), 1) != wxT("\\")){
4459 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
4461 if (intSplitsFound == 6){
4463 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4468 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4479 wxString wxSKeyMIME;
4480 wxString wxSKeyEncoding;
4481 wxString wxSKeyData;
4482 std::string base64enc;
4484 if (intSplitsFound == 0){
4488 std::map<int, int>::iterator striter;
4490 striter = SplitLength.find(1);
4492 wxStringTokenizer wSTDataType(PropertySeg2.Mid(0, striter->second), wxT(":"));
4494 while (wSTDataType.HasMoreTokens() == TRUE){
4496 wxSKeyURI = wSTDataType.GetNextToken();
4497 wxSKeyMIME = wSTDataType.GetNextToken();
4502 if (wxSKeyURI == wxT("data")){
4504 wxStringTokenizer wSTDataInfo(PropertySeg2.Mid((striter->second + 1)), wxT(","));
4506 while (wSTDataInfo.HasMoreTokens() == TRUE){
4508 wxSKeyEncoding = wSTDataInfo.GetNextToken();
4509 wxSKeyData = wSTDataInfo.GetNextToken();
4518 // Add the data to the General/Home/Work address variables.
4520 if (wxSKeyURI == wxT("data")){
4522 KeyListDataEncType.erase(*KeyCount);
4523 KeyListKeyType.erase(*KeyCount);
4524 KeyListDataEncType.insert(std::make_pair(*KeyCount, wxSKeyEncoding));
4525 KeyListKeyType.insert(std::make_pair(*KeyCount, TRUE));
4527 KeyList.erase(*KeyCount);
4528 KeyList.insert(std::make_pair(*KeyCount, wxSKeyData));
4532 KeyList.erase(*KeyCount);
4533 KeyList.insert(std::make_pair(*KeyCount, PropertySeg2));
4537 KeyListDataType.insert(std::make_pair(*KeyCount, wxSKeyMIME));
4543 KeyListType.insert(std::make_pair(*KeyCount, wxT("home")));
4546 KeyListType.insert(std::make_pair(*KeyCount, wxT("work")));
4550 if (!PropertyTokens.IsEmpty()){
4552 KeyListTokens.insert(std::make_pair(*KeyCount, PropertyTokens));
4558 void ContactDataObject::ProcessVendor(wxString PropertySeg1, wxString PropertySeg2, int *VendorCount){
4560 // Split the Vendor three ways.
4562 wxStringTokenizer wSTVendorDetails(PropertySeg1, wxT("-"));
4565 wxString wxSVNDPropName;
4568 while (wSTVendorDetails.HasMoreTokens() == TRUE){
4570 wSTVendorDetails.GetNextToken();
4571 wxSVNDID = wSTVendorDetails.GetNextToken();
4572 wxSVNDPropName = wSTVendorDetails.GetNextToken();
4577 if (!wxSVNDID.IsEmpty() && !wxSVNDPropName.IsEmpty()){
4579 // Add the data to the vendor variables.
4581 VendorList.erase(*VendorCount);
4582 VendorListPEN.erase(*VendorCount);
4583 VendorListElement.erase(*VendorCount);
4585 VendorList.insert(std::make_pair(*VendorCount, PropertySeg2));
4586 VendorListPEN.insert(std::make_pair(*VendorCount, wxSVNDID));
4587 VendorListElement.insert(std::make_pair(*VendorCount, wxSVNDPropName));
4593 void ProcessNameValue(wxString *PropertyData,
4594 wxString *PropertyName,
4595 wxString *PropertyValue){
4597 wxStringTokenizer PropertyElement (*PropertyData, wxT("="));
4598 *PropertyName = PropertyElement.GetNextToken();
4599 *PropertyValue = PropertyElement.GetNextToken();
4603 void ProcessTokens(wxString *PropertyName,
4604 wxString *PropertyValue,
4605 wxString *PropertyTokens,
4608 if (!PropertyName->IsEmpty() && !PropertyValue->IsEmpty() && *PropertyName != wxT("TYPE")){
4610 if (*FirstToken == TRUE){
4612 PropertyTokens->Append(*PropertyName + wxT("=") + *PropertyValue);
4613 *FirstToken = FALSE;
4617 PropertyTokens->Append(wxT(";") + *PropertyName + wxT("=") + *PropertyValue);
4625 void ProcessStringValue(wxString *PropertyName,
4626 wxString PropertyNameMatch,
4627 std::map<int,wxString> *MapPtr,
4628 wxString *PropertyValue,
4630 bool *PropertyMatched){
4632 if (*PropertyName == PropertyNameMatch){
4633 MapPtr->erase(*ItemCount);
4634 MapPtr->insert(std::make_pair(*ItemCount, *PropertyValue));
4635 *PropertyMatched = TRUE;
4640 void ProcessIntegerValue(wxString *PropertyName,
4641 wxString PropertyNameMatch,
4642 std::map<int,int> *PrefPtr,
4643 wxString *PropertyValue,
4645 bool *PropertyMatched){
4647 if (*PropertyName == PropertyNameMatch){
4648 *PropertyMatched = TRUE;
4653 int PriorityNumber = 0;
4654 bool ValidNumber = TRUE;
4657 PriorityNumber = std::stoi(PropertyValue->ToStdString());
4660 catch(std::invalid_argument &e){
4661 ValidNumber = FALSE;
4664 if (ValidNumber == TRUE){
4666 PrefPtr->erase(*ItemCount);
4667 PrefPtr->insert(std::make_pair(*ItemCount, PriorityNumber));
4673 void SplitValues(wxString *PropertyLine,
4674 std::map<int,int> *SplitPoints,
4675 std::map<int,int> *SplitLength,
4678 size_t intPropertyLen = PropertyLine->Len();
4679 int intSplitsFound = 0;
4680 int intSplitSize = 0;
4681 int intSplitSeek = 0;
4683 for (int i = intSize; i <= intPropertyLen; i++){
4687 if (PropertyLine->Mid(i, 1) == wxT(";") &&
4688 PropertyLine->Mid((i - 1), 1) != wxT("\\")){
4690 if (intSplitsFound == 0){
4692 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
4696 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
4700 SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
4710 if (intSplitsFound == 0){
4712 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
4713 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
4717 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
4718 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
4724 void CheckType(wxString *PropertySeg1,
4725 std::map<int,int> *SplitPoints,
4726 std::map<int,int> *SplitLength,
4728 PropertyType *PropType){
4730 wxString PropertyData;
4731 wxString PropertyName;
4732 wxString PropertyValue;
4733 std::map<int,int>::iterator SLiter;
4735 for (std::map<int, int>::iterator intiter = SplitPoints->begin();
4736 intiter != SplitPoints->end(); ++intiter){
4738 SLiter = SplitLength->find(intiter->first);
4739 PropertyData = PropertySeg1->Mid(*intPrevValue, (SLiter->second));
4740 ProcessNameValue(&PropertyData, &PropertyName, &PropertyValue);
4741 *intPrevValue = intiter->second;
4743 if (PropertyName == wxT("TYPE")){
4745 if (PropertyValue == wxT("work")){
4747 *PropType = PROPERTY_WORK;
4749 } else if (PropertyValue == wxT("home")){
4751 *PropType = PROPERTY_HOME;
4755 *PropType = PROPERTY_NONE;