1 #include "vcard34conv.h"
3 #include "../version.h"
4 #include "../common/textprocessing.h"
7 #include <wx/tokenzr.h>
8 #include <wx/datetime.h>
11 bool vCard34Conv::ConvertToV3(wxString Filename, wxString *wxSData){
16 // Load the contact into the contact editor.
19 wxString wxSContactString;
25 //wxSContactFilename = Filename;
27 // Check if we are using wxWidgets version 2.8 or less and
28 // execute the required command accordingly.
30 #if wxABI_VERSION < 20900
31 ContactFile.Open(Filename.c_str(), wxT("r"));
33 ContactFile.Open(Filename, wxT("r"));
36 if (ContactFile.IsOpened() == FALSE){
42 ContactFile.ReadAll(&wxSContactString, wxConvAuto());
46 std::map<int, wxString> ContactFileLines;
47 std::map<int, wxString>::iterator striter;
49 wxStringTokenizer wSTContactFileLines(wxSContactString, wxT("\r\n"));
51 int ContactLineSeek = 0;
53 while (wSTContactFileLines.HasMoreTokens() == TRUE){
55 ContactLine = wSTContactFileLines.GetNextToken();
56 ContactFileLines.insert(std::make_pair(ContactLineSeek, ContactLine));
63 bool QuoteMode = FALSE;
64 bool PropertyFind = TRUE;
65 bool HasExtraNicknames = FALSE;
66 bool IgnoreGender = FALSE;
67 bool ExtraLineSeek = TRUE;
68 bool BirthdayProcessed = FALSE;
69 bool AnniversaryProcessed = FALSE;
70 bool FNProcessed = FALSE;
71 bool GenderProcessed = FALSE;
72 bool NameProcessed = FALSE;
73 bool KindProcessed = FALSE;
75 bool NicknameFirst = FALSE;
76 bool TitleFirst = FALSE;
77 bool OrganisationFirst = FALSE;
78 bool NoteFirst = FALSE;
79 bool PhotoFirst = FALSE;
80 bool LogoFirst = FALSE;
81 int intExtraNickname = 0;
83 wxString wxSPropertySeg1;
84 wxString wxSPropertySeg2;
85 wxString wxSPropertyNextLine;
86 size_t ContactLineLen = 0;
87 int QuoteBreakPoint = 0;
90 int NicknameCount = 0;
104 int CategoryCount = 0;
109 int CalReqAdrCount = 0;
110 int FreeBusyCount = 0;
115 //int intValueSeek = 1;
119 // Setup the version string.
121 strVer.Append(wxT("-//Xestia//Address Book Version "));
122 strVer.Append(wxT(XSDAB_VERSION));
123 strVer.Append(wxT("//KW"));
125 ContactDatav3.AddRaw(wxT("BEGIN"), wxT("VCARD"));
126 ContactDatav3.AddRaw(wxT("VERSION"), wxT("3.0"));
127 ContactDatav3.AddRaw(wxT("PRODID"), strVer);
129 for (std::map<int,wxString>::iterator iter = ContactFileLines.begin();
130 iter != ContactFileLines.end(); ++iter){
132 // Find the colon which splits the start bit from the data part.
134 ContactLine = iter->second;
136 while (ExtraLineSeek == TRUE){
138 // Check if there is extra data on the next line
139 // (indicated by space or tab at the start) and add data.
143 if (iter == ContactFileLines.end()){
150 wxSPropertyNextLine = iter->second;
153 if (wxSPropertyNextLine.Mid(0, 1) == wxT(" ") || wxSPropertyNextLine.Mid(0, 1) == wxT("\t")){
155 wxSPropertyNextLine.Remove(0, 1);
156 //wxSPropertyNextLine.Trim(FALSE);
157 //ContactLine.Trim();
158 ContactLine.Append(wxSPropertyNextLine);
163 ExtraLineSeek = FALSE;
169 ContactLineLen = ContactLine.Len();
171 // Make sure we are not in quotation mode.
172 // Make sure colon does not have \ or \\ before it.
176 for (int i = 0; i <= ContactLineLen; i++){
178 if ((ContactLine.Mid(i, 1) == wxT(";") || ContactLine.Mid(i, 1) == wxT(":")) && PropertyFind == TRUE){
180 PropertyFind = FALSE;
182 } else if (PropertyFind == TRUE){
184 wxSProperty.Append(ContactLine.Mid(i, 1));
188 if (ContactLine.Mid(i, 1) == wxT("\"")){
190 if (QuoteMode == TRUE){
202 if (ContactLine.Mid(i, 1) == wxT(":") && ContactLine.Mid((i - 1), 1) != wxT("\\") && QuoteMode == FALSE){
211 // Split that line at the point into two variables (ignore the colon).
213 wxSPropertySeg1 = ContactLine.Mid(0, QuoteBreakPoint);
214 wxSPropertySeg2 = ContactLine.Mid((QuoteBreakPoint + 1));
216 // Add the data into the contact editor depending on what it is.
218 if (wxSProperty == wxT("FN")){
220 std::map<int, int> SplitPoints;
221 std::map<int, int> SplitLength;
222 std::map<int, int>::iterator SLiter;
223 wxString PropertyData;
224 wxString PropertyName;
225 wxString PropertyValue;
226 wxString PropertyTokens;
227 int intPrevValue = 4;
229 //SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
233 if (FNFirst == FALSE){
235 ContactDatav3.AddRaw(wxT("FN"), wxSPropertySeg2);
237 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
241 ContactDatav3.AddRaw(wxT("X-VCARD4-FN;X-FIRST=TRUE;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
248 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
250 ContactDatav3.AddRaw(wxT("X-VCARD4-FN"), wxSPropertySeg2);
254 ContactDatav3.AddRaw(wxT("X-VCARD4-FN;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))),
261 } else if (wxSProperty == wxT("N") && NameProcessed == FALSE){
263 std::map<int, int> SplitPoints;
264 std::map<int, int> SplitLength;
265 std::map<int, int>::iterator SLiter;
266 wxString PropertyData;
267 wxString PropertyName;
268 wxString PropertyValue;
269 wxString PropertyTokens;
270 int intPrevValue = 3;
274 ContactDatav3.AddRaw(wxT("N"), wxSPropertySeg2);
276 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
282 ContactDatav3.AddRaw(wxT("X-VCARD4-N;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxT(""));
286 NameProcessed = TRUE;
288 } else if (wxSProperty == wxT("KIND") && KindProcessed == FALSE){
292 std::map<int, int> SplitPoints;
293 std::map<int, int> SplitLength;
294 std::map<int, int>::iterator SLiter;
295 wxString PropertyData;
296 wxString PropertyName;
297 wxString PropertyValue;
298 wxString PropertyTokens;
299 int intPrevValue = 5;
303 ContactDatav3.AddRaw(wxT("X-ADDRESSBOOKSERVER-KIND"), wxSPropertySeg2);
305 KindProcessed = TRUE;
307 } else if (wxSProperty == wxT("MEMBER")){
311 std::map<int, int> SplitPoints;
312 std::map<int, int> SplitLength;
313 std::map<int, int>::iterator SLiter;
314 wxString PropertyData;
315 wxString PropertyName;
316 wxString PropertyValue;
317 wxString PropertyTokens;
318 int intPrevValue = 7;
322 ContactDatav3.AddRaw(wxT("X-ADDRESSBOOKSERVER-MEMBER"), wxSPropertySeg2);
324 } else if (wxSProperty == wxT("NICKNAME")){
326 std::map<int, int> SplitPoints;
327 std::map<int, int> SplitLength;
328 std::map<int, int>::iterator SLiter;
329 wxString PropertyData;
330 wxString PropertyName;
331 wxString PropertyValue;
332 wxString PropertyTokens;
333 int intPrevValue = 10;
337 if (NicknameFirst == FALSE){
339 ContactDatav3.AddRaw(wxT("NICKNAME"), wxSPropertySeg2);
341 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
345 ContactDatav3.AddRaw(wxT("X-VCARD4-NICKNAME;X-FIRST=TRUE;")
346 + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxT(""));
349 NicknameFirst = TRUE;
354 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
356 ContactDatav3.AddRaw(wxT("X-VCARD4-NICKNAME"), wxSPropertySeg2);
360 ContactDatav3.AddRaw(wxT("X-VCARD4-NICKNAME;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))) + wxT(":"),
368 } else if (wxSProperty == wxT("GENDER") && GenderProcessed == FALSE){
370 // Do PID/ALTID/LANG things.
372 std::map<int, int> SplitPoints;
373 std::map<int, int> SplitLength;
374 std::map<int, int>::iterator SLiter;
375 wxString PropertyData;
376 wxString PropertyName;
377 wxString PropertyValue;
378 wxString PropertyTokens;
379 int intPrevValue = 8;
384 if (wxSPropertySeg2.Mid(1, 1) == wxT(";")){
386 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
388 ContactDatav3.AddRaw(wxT("X-VCARD4-GENDER;X-GENDERTEXT=\"") + wxSPropertySeg2.Mid(2) + wxT("\""), wxSPropertySeg2.Mid(0, 1));
392 ContactDatav3.AddRaw(wxT("X-VCARD4-GENDER;X-GENDERTEXT=\"") + wxSPropertySeg2.Mid(2) + wxT("\";")
393 + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))),
394 wxSPropertySeg2.Mid(0, 1));
400 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
402 ContactDatav3.AddRaw(wxT("X-VCARD4-GENDER"), wxSPropertySeg2);
406 ContactDatav3.AddRaw(wxT("X-VCARD4-GENDER;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
412 GenderProcessed = TRUE;
414 } else if (wxSProperty == wxT("BDAY") && BirthdayProcessed == FALSE){
416 // Process date. Preserve the remainder in the string.
418 std::map<int, int> SplitPoints;
419 std::map<int, int> SplitLength;
420 std::map<int, int>::iterator SLiter;
421 wxString PropertyData;
422 wxString PropertyName;
423 wxString PropertyValue;
424 wxString PropertyTokens;
426 int intPrevValue = 6;
432 // Look for type before continuing.
434 if (wxSPropertySeg2.Mid(0, 2) == wxT("--")){
436 strResults.Append(wxT("1604-"));
439 strResults.Append(wxSPropertySeg2.Mid(2, 2) + wxT("-"));
440 strResults.Append(wxSPropertySeg2.Mid(4, 2));
444 strResults.Append(wxSPropertySeg2.Mid(0, 4) + wxT("-"));
445 strResults.Append(wxSPropertySeg2.Mid(4, 2) + wxT("-"));
446 strResults.Append(wxSPropertySeg2.Mid(6, 2));
454 ContactDatav3.AddRaw(wxT("BDAY;X-APPLE-OMIT-YEAR=1604"), strResults);
456 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
458 ContactDatav3.AddRaw(wxT("X-VCARD4-BDAY"), wxSPropertySeg2);
462 ContactDatav3.AddRaw(wxT("X-VCARD4-BDAY;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
468 ContactDatav3.AddRaw(wxT("BDAY"), strResults);
470 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
472 ContactDatav3.AddRaw(wxT("X-VCARD4-BDAY"), wxSPropertySeg2);
476 ContactDatav3.AddRaw(wxT("X-VCARD4-BDAY;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
482 BirthdayProcessed = TRUE;
484 } else if (wxSProperty == wxT("ANNIVERSARY") && AnniversaryProcessed == FALSE){
486 // Process date. Preserve the remainder in the string.
488 std::map<int, int> SplitPoints;
489 std::map<int, int> SplitLength;
490 std::map<int, int>::iterator SLiter;
491 wxString PropertyData;
492 wxString PropertyName;
493 wxString PropertyValue;
494 wxString PropertyTokens;
495 int intPrevValue = 13;
502 // Look for type before continuing.
504 if (wxSPropertySeg2.Mid(0, 2) == wxT("--")){
506 strResults.Append(wxT("1604-"));
509 strResults.Append(wxSPropertySeg2.Mid(2, 2) + wxT("-"));
510 strResults.Append(wxSPropertySeg2.Mid(4, 2));
514 strResults.Append(wxSPropertySeg2.Mid(0, 4) + wxT("-"));
515 strResults.Append(wxSPropertySeg2.Mid(4, 2) + wxT("-"));
516 strResults.Append(wxSPropertySeg2.Mid(6, 2));
522 ContactDatav3.AddRaw(wxT("ANNIVERSARY;X-APPLE-OMIT-YEAR=1604"), strResults);
524 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
526 ContactDatav3.AddRaw(wxT("X-VCARD4-ANNIVERSARY"), wxSPropertySeg2);
530 ContactDatav3.AddRaw(wxT("X-VCARD4-ANNIVERSARY;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
536 ContactDatav3.AddRaw(wxT("ANNIVERSARY"), strResults);
538 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
540 ContactDatav3.AddRaw(wxT("X-VCARD4-ANNIVERSARY"), wxSPropertySeg2);
544 ContactDatav3.AddRaw(wxT("X-VCARD4-ANNIVERSARY;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
550 AnniversaryProcessed = TRUE;
552 } else if (wxSProperty == wxT("TZ")){
554 std::map<int, int> SplitPoints;
555 std::map<int, int> SplitLength;
556 std::map<int, int>::iterator SLiter;
557 wxString PropertyData;
558 wxString PropertyName;
559 wxString PropertyValue;
560 wxString PropertyTokens;
561 int intPrevValue = 4;
565 // Look for type before continuing.
567 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
569 ContactDatav3.AddRaw(wxT("X-VCARD4-TZ"), wxSPropertySeg2);
573 ContactDatav3.AddRaw(wxT("X-VCARD4-TZ;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
577 } else if (wxSProperty == wxT("ADR")){
579 std::map<int, int> SplitPoints;
580 std::map<int, int> SplitLength;
581 std::map<int, int>::iterator SLiter;
582 wxString PropertyData;
583 wxString PropertyName;
584 wxString PropertyValue;
585 wxString PropertyTokens;
586 wxString AddressLabel;
587 wxString AddressLang;
588 wxString AddressAltID;
590 wxString AddressTokens;
592 wxString AddressTimezone;
593 wxString AddressType;
594 wxString AddressMediatype;
595 wxString AddressPOBox;
596 wxString AddressExtended;
597 wxString AddressStreet;
598 wxString AddressLocality;
599 wxString AddressCity;
600 wxString AddressRegion;
601 wxString AddressPostalCode;
602 wxString AddressCountry;
603 int intPrevValue = 5;
607 // TODO: Check in value for X-ABLabel and use it if it is there.
609 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
611 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".ADR"), wxSPropertySeg2);
612 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), _("Address"));
613 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-ADR"), wxSPropertySeg2);
617 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".ADR"), wxSPropertySeg2);
618 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), _("Address"));
619 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-ADR;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
625 } else if (wxSProperty == wxT("EMAIL")){
627 // TODO: Continue from here! See ADR for good example (Replace initer with intPrevValue).
628 // Remove inserted comma for Extra Tokens in frmContactEditor.cpp
630 std::map<int, int> SplitPoints;
631 std::map<int, int> SplitLength;
632 std::map<int, int>::iterator SLiter;
633 std::map<int, int>::iterator SPoint;
634 wxString PropertyData;
635 wxString PropertyName;
636 wxString PropertyValue;
637 wxString PropertyTokens;
638 wxString AddressLabel;
639 wxString AddressLang;
640 wxString AddressAltID;
642 wxString AddressTokens;
644 wxString AddressTimezone;
645 wxString AddressType;
646 wxString AddressMediatype;
647 wxString AddressPOBox;
648 wxString AddressExtended;
649 wxString AddressStreet;
650 wxString AddressLocality;
651 wxString AddressCity;
652 wxString AddressRegion;
653 wxString AddressPostalCode;
654 wxString AddressCountry;
655 int intPrevValue = 7;
659 // TODO: Check in value for X-ABLabel and use it if it is there.
661 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
663 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".EMAIL"), wxSPropertySeg2);
664 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), _("E-mail Address"));
665 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-EMAIL"), wxSPropertySeg2);
669 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".EMAIL"), wxSPropertySeg2);
670 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), _("E-mail Address"));
671 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-EMAIL;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
677 } else if (wxSProperty == wxT("IMPP")){
679 std::map<int, int> SplitPoints;
680 std::map<int, int> SplitLength;
681 std::map<int, int>::iterator SLiter;
682 std::map<int, int>::iterator SPoint;
683 wxString PropertyData;
684 wxString PropertyName;
685 wxString PropertyValue;
686 wxString PropertyTokens;
688 wxString IMPPAddress;
689 int intPrevValue = 6;
691 SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
695 // TODO: Check in value for X-ABLabel and use it if it is there.
697 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
699 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".IMPP"), wxSPropertySeg2);
700 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), _("Instant Message"));
701 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-IMPP"), wxSPropertySeg2);
705 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".IMPP"), wxSPropertySeg2);
706 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), _("Instant Message"));
707 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-IMPP;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
713 } else if (wxSProperty == wxT("TEL")){
715 // Check TEL and make sure it is functioning properly.
717 std::map<int, int> SplitPoints;
718 std::map<int, int> SplitLength;
719 std::map<int, int> TypeSplitPoints;
720 std::map<int, int> TypeSplitLength;
721 std::map<int, int>::iterator SLiter;
722 std::map<int, int>::iterator SPoint;
723 std::map<int, int>::iterator TSLiter;
724 std::map<int, int>::iterator TSPoint;
725 wxString PropertyData;
726 wxString PropertyName;
727 wxString PropertyValue;
728 wxString PropertyTokens;
732 wxString TelTypeDetail;
734 wxString FinalFriendlyString;
735 int intSplitsFound = 0;
736 int intSplitSize = 0;
737 int intPrevValue = 5;
739 int intSplitPoint = 0;
743 SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
745 // Look for type before continuing.
747 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
748 intiter != SplitPoints.end(); ++intiter){
750 SLiter = SplitLength.find(intiter->first);
752 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
754 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
755 PropertyName = PropertyElement.GetNextToken();
756 PropertyValue = PropertyElement.GetNextToken();
758 intPrevValue = intiter->second;
760 if (PropertyName == wxT("TYPE")){
762 // Process each value in type and translate each
765 // Strip out the quotes if they are there.
767 size_t intPropertyValueLen = PropertyValue.Len();
769 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
771 PropertyValue.Trim();
772 PropertyValue.RemoveLast();
776 if (PropertyValue.Mid(0, 1) == wxT("\"")){
778 PropertyValue.Remove(0, 1);
782 TelTypeDetail = PropertyValue;
788 for (int i = 0; i <= intPropertyValueLen; i++){
792 if (PropertyValue.Mid(i, 1) == wxT(",") && PropertyValue.Mid((i - 1), 1) != wxT("\\")){
794 if (intSplitsFound == 0){
796 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
797 TypeSplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
801 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
802 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
815 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
816 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
820 for (std::map<int, int>::iterator typeiter = TypeSplitPoints.begin();
821 typeiter != TypeSplitPoints.end(); ++typeiter){
823 wxString TypePropertyName;
825 TSLiter = TypeSplitLength.find(typeiter->first);
827 TypePropertyName = PropertyValue.Mid(typeiter->second, TSLiter->second);
829 if (intTypeSeek == 0){
834 TelTypeUI.Append(wxT(","));
838 if (TypePropertyName == wxT("home")){
842 } else if (TypePropertyName == wxT("work")){
848 if (TypePropertyName == wxT("text")){
850 if (!FinalFriendlyString.IsEmpty()){ FinalFriendlyString.Append(_(", Text")); } else { FinalFriendlyString.Append(_("Text")); }
852 TelTypeOut.Append(wxT(";"));
853 TelTypeOut.Append(wxT("type=TEXT"));
855 } else if (TypePropertyName == wxT("voice")){
857 if (!FinalFriendlyString.IsEmpty()){ FinalFriendlyString.Append(_(", Voice")); } else { FinalFriendlyString.Append(_("Voice")); }
859 TelTypeOut.Append(wxT(";"));
860 TelTypeOut.Append(wxT("type=VOICE"));
864 } else if (TypePropertyName == wxT("fax")){
866 if (!FinalFriendlyString.IsEmpty()){ FinalFriendlyString.Append(_(", Fax")); } else { FinalFriendlyString.Append(_("Fax")); }
868 TelTypeOut.Append(wxT(";"));
869 TelTypeOut.Append(wxT("type=FAX"));
872 } else if (TypePropertyName == wxT("cell")){
874 if (!FinalFriendlyString.IsEmpty()){ FinalFriendlyString.Append(_(", Mobile")); } else { FinalFriendlyString.Append(_("Mobile")); }
876 TelTypeOut.Append(wxT(";"));
877 TelTypeOut.Append(wxT("type=CELL"));
880 } else if (TypePropertyName == wxT("video")){
882 if (!FinalFriendlyString.IsEmpty()){ FinalFriendlyString.Append(_(", Video")); } else { FinalFriendlyString.Append(_("Video")); }
884 TelTypeOut.Append(wxT(";"));
885 TelTypeOut.Append(wxT("type=VIDEO"));
888 } else if (TypePropertyName == wxT("pager")){
890 if (!FinalFriendlyString.IsEmpty()){ FinalFriendlyString.Append(_(", Pager")); } else { FinalFriendlyString.Append(_("Pager")); }
892 TelTypeOut.Append(wxT(";"));
893 TelTypeOut.Append(wxT("type=PAGER"));
896 } else if (TypePropertyName == wxT("textphone")){
898 //if (!TelTypeOut.IsEmpty()){ TelTypeOut.Append(wxT(";")); }
900 if (!FinalFriendlyString.IsEmpty()){ FinalFriendlyString.Append(_(", Textphone")); } else { FinalFriendlyString.Append(_("Textphone")); }
902 TelTypeOut.Append(wxT(";"));
903 TelTypeOut.Append(wxT("type=TEXTPHONE"));
920 // Remove 'tel:' if it is being used.
922 if (wxSPropertySeg2.Mid(0, 4) == wxT("tel:")){
924 FinalTel = wxSPropertySeg2.Mid(4);
928 FinalTel = wxSPropertySeg2;
932 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
934 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".TEL") + TelTypeOut, FinalTel);
935 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), FinalFriendlyString);
936 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-TEL"), wxSPropertySeg2);
940 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".TEL") + TelTypeOut, FinalTel);
941 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), FinalFriendlyString);
942 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-TEL;") + wxSPropertySeg1.Mid(4), wxSPropertySeg2);
948 } else if (wxSProperty == wxT("LANG")){
950 std::map<int, int> SplitPoints;
951 std::map<int, int> SplitLength;
952 std::map<int, int>::iterator SLiter;
953 wxString PropertyData;
954 wxString PropertyName;
955 wxString PropertyValue;
956 wxString PropertyTokens;
957 int intPrevValue = 6;
961 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
963 ContactDatav3.AddRaw(wxT("X-VCARD4-LANG"), wxSPropertySeg2);
967 ContactDatav3.AddRaw(wxT("X-VCARD4-LANG;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
971 } else if (wxSProperty == wxT("GEO")){
973 std::map<int, int> SplitPoints;
974 std::map<int, int> SplitLength;
975 std::map<int, int>::iterator SLiter;
976 wxString PropertyData;
977 wxString PropertyName;
978 wxString PropertyValue;
979 wxString PropertyTokens;
982 int intPrevValue = 5;
986 SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
988 wxString strFinalGeoValue;
989 wxString strFinalType;
991 if (wxSPropertySeg2.Mid(0, 3) == wxT("geo")){
993 strFinalGeoValue = wxSPropertySeg2.Mid(5);
994 strFinalType = wxT("geo");
998 wxStringTokenizer wSTSplit(wxSPropertySeg2, wxT(":"));
999 strFinalType = wSTSplit.GetNextToken();
1000 strFinalGeoValue = wSTSplit.GetNextToken();
1004 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1006 ContactDatav3.AddRaw(wxT("X-VCARD4-GEO;X-GEOTYPE=") + strFinalType, wxSPropertySeg2);
1010 ContactDatav3.AddRaw(wxT("X-VCARD4-GEO;X-GEOTYPE=") + strFinalType + wxT(";") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
1014 } else if (wxSProperty == wxT("RELATED")){
1016 std::map<int, int> SplitPoints;
1017 std::map<int, int> SplitLength;
1018 std::map<int, int>::iterator SLiter;
1019 wxString PropertyData;
1020 wxString PropertyName;
1021 wxString PropertyValue;
1022 wxString PropertyTokens;
1023 wxString RelatedType;
1024 wxString RelatedTypeOriginal;
1025 wxString RelatedName;
1026 bool FirstToken = TRUE;
1027 int intPrevValue = 9;
1031 SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1035 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1036 intiter != SplitPoints.end(); ++intiter){
1038 SLiter = SplitLength.find(intiter->first);
1040 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second - 1));
1042 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1043 PropertyName = PropertyElement.GetNextToken();
1044 PropertyValue = PropertyElement.GetNextToken();
1046 if (PropertyName == wxT("TYPE") && FirstToken == TRUE){
1048 if (PropertyValue == wxT("contact")){
1050 strDetail = _("Contact");
1052 } else if (PropertyValue == wxT("acquaintance")){
1054 strDetail = _("Acquaintance");
1056 } else if (PropertyValue == wxT("friend")){
1058 strDetail = _("Friend");
1060 } else if (PropertyValue == wxT("met")){
1062 strDetail = _("Met");
1064 } else if (PropertyValue == wxT("co-worker")){
1066 strDetail = _("Co-worker");
1068 } else if (PropertyValue == wxT("colleague")){
1070 strDetail = _("Colleague");
1072 } else if (PropertyValue == wxT("co-resident")){
1074 strDetail = _("Co-resident");
1076 } else if (PropertyValue == wxT("neighbor")){
1078 strDetail = _("Neighbour");
1080 } else if (PropertyValue == wxT("child")){
1082 strDetail = _("Child");
1084 } else if (PropertyValue == wxT("parent")){
1086 strDetail = _("Parent");
1088 } else if (PropertyValue == wxT("sibling")){
1090 strDetail = _("Sibling");
1092 } else if (PropertyValue == wxT("spouse")){
1094 strDetail = _("Spouse");
1096 } else if (PropertyValue == wxT("kin")){
1098 strDetail = _("Kin");
1100 } else if (PropertyValue == wxT("muse")){
1102 strDetail = _("Muse");
1104 } else if (PropertyValue == wxT("crush")){
1106 strDetail = _("Crush");
1108 } else if (PropertyValue == wxT("date")){
1110 strDetail = _("Date");
1112 } else if (PropertyValue == wxT("sweetheart")){
1114 strDetail = _("Sweetheart");
1116 } else if (PropertyValue == wxT("me")){
1118 strDetail = _("Me");
1120 } else if (PropertyValue == wxT("agent")){
1122 strDetail = _("Agent");
1124 } else if (PropertyValue == wxT("emergency")){
1126 strDetail = _("Emergency");
1130 strDetail = PropertyValue;
1140 if (strDetail.IsEmpty()){
1142 strDetail = _("Relation");
1146 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1148 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABRELATEDNAMES"), wxSPropertySeg2);
1149 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), strDetail);
1150 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-RELATED"), wxSPropertySeg2);
1154 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABRELATEDNAMES"), wxSPropertySeg2);
1155 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), strDetail);
1156 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-RELATED;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
1162 } else if (wxSProperty == wxT("URL")){
1164 std::map<int, int> SplitPoints;
1165 std::map<int, int> SplitLength;
1166 std::map<int, int>::iterator SLiter;
1167 wxString PropertyData;
1168 wxString PropertyName;
1169 wxString PropertyValue;
1170 wxString PropertyTokens;
1171 int intPrevValue = 5;
1175 // Todo: Check for X-ABLabel.
1177 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1179 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".URL"), wxSPropertySeg2);
1180 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), _("URL"));
1181 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-URL"), wxSPropertySeg2);
1185 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".URL"), wxSPropertySeg2);
1186 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), _("URL"));
1187 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-URL;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
1193 } else if (wxSProperty == wxT("TITLE")) {
1195 std::map<int, int> SplitPoints;
1196 std::map<int, int> SplitLength;
1197 std::map<int, int>::iterator SLiter;
1198 wxString PropertyData;
1199 wxString PropertyName;
1200 wxString PropertyValue;
1201 wxString PropertyTokens;
1202 int intPrevValue = 7;
1206 // Look for type before continuing.
1208 if (TitleFirst == FALSE){
1210 ContactDatav3.AddRaw(wxT("TITLE"), wxSPropertySeg2);
1212 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1216 ContactDatav3.AddRaw(wxT("X-VCARD4-TITLE;X-FIRST=TRUE;")
1217 + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxT(""));
1225 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1227 ContactDatav3.AddRaw(wxT("X-VCARD4-TITLE"), wxSPropertySeg2);
1231 ContactDatav3.AddRaw(wxT("X-VCARD4-TITLE;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))) + wxT(":"),
1238 } else if (wxSProperty == wxT("ROLE")) {
1240 std::map<int, int> SplitPoints;
1241 std::map<int, int> SplitLength;
1242 std::map<int, int>::iterator SLiter;
1243 wxString PropertyData;
1244 wxString PropertyName;
1245 wxString PropertyValue;
1246 wxString PropertyTokens;
1247 int intPrevValue = 6;
1251 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1253 ContactDatav3.AddRaw(wxT("X-VCARD4-ROLE"), wxSPropertySeg2);
1257 ContactDatav3.AddRaw(wxT("X-VCARD4-ROLE;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
1261 } else if (wxSProperty == wxT("ORG")) {
1263 std::map<int, int> SplitPoints;
1264 std::map<int, int> SplitLength;
1265 std::map<int, int>::iterator SLiter;
1266 wxString PropertyData;
1267 wxString PropertyName;
1268 wxString PropertyValue;
1269 wxString PropertyTokens;
1270 int intPrevValue = 5;
1274 if (OrganisationFirst == FALSE){
1276 ContactDatav3.AddRaw(wxT("ORG"), wxSPropertySeg2);
1278 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1282 ContactDatav3.AddRaw(wxT("X-VCARD4-ORG;X-FIRST=TRUE;")
1283 + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxT(""));
1286 OrganisationFirst = TRUE;
1291 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1293 ContactDatav3.AddRaw(wxT("X-VCARD4-ORG"), wxSPropertySeg2);
1297 ContactDatav3.AddRaw(wxT("X-VCARD4-ORG;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))) + wxT(":"),
1304 } else if (wxSProperty == wxT("NOTE")) {
1306 std::map<int, int> SplitPoints;
1307 std::map<int, int> SplitLength;
1308 std::map<int, int>::iterator SLiter;
1309 wxString PropertyData;
1310 wxString PropertyName;
1311 wxString PropertyValue;
1312 wxString PropertyTokens;
1313 int intPrevValue = 6;
1317 if (NoteFirst == FALSE){
1319 ContactDatav3.AddRaw(wxT("NOTE"), wxSPropertySeg2);
1321 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1325 ContactDatav3.AddRaw(wxT("X-VCARD4-NOTE;X-FIRST=TRUE;")
1326 + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxT(""));
1334 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1336 ContactDatav3.AddRaw(wxT("X-VCARD4-NOTE"), wxSPropertySeg2);
1340 ContactDatav3.AddRaw(wxT("X-VCARD4-NOTE;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))) + wxT(":"),
1347 } else if (wxSProperty == wxT("CATEGORIES")) {
1349 std::map<int, int> SplitPoints;
1350 std::map<int, int> SplitLength;
1351 std::map<int, int>::iterator SLiter;
1352 wxString PropertyData;
1353 wxString PropertyName;
1354 wxString PropertyValue;
1355 wxString PropertyTokens;
1356 wxString PropertyType;
1357 int intPrevValue = 12;
1361 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1363 ContactDatav3.AddRaw(wxT("X-VCARD4-CATEGORIES"), wxSPropertySeg2);
1367 ContactDatav3.AddRaw(wxT("X-VCARD4-CATEGORIES;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
1371 } else if (wxSProperty == wxT("PHOTO")) {
1373 size_t intPropertyLen = wxSPropertySeg1.Len();
1374 std::map<int, int> SplitPoints;
1375 std::map<int, int> SplitLength;
1376 std::map<int, int>::iterator SLiter;
1377 wxString PropertyData;
1378 wxString PropertyName;
1379 wxString PropertyValue;
1380 wxString PropertyTokens;
1381 int intSplitsFound = 0;
1382 int intSplitSize = 0;
1383 int intPrevValue = 7;
1385 intPropertyLen = wxSPropertySeg2.Len();
1386 SplitPoints.clear();
1387 SplitLength.clear();
1391 CaptureString(&wxSPropertySeg2, FALSE);
1393 for (int i = 0; i <= intPropertyLen; i++){
1397 if (wxSPropertySeg2.Mid(i, 1) == wxT(";")){
1400 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
1402 if (intSplitsFound == 6){
1404 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1409 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1419 wxString wxSPhotoURI;
1420 wxString wxSPhotoMIME;
1421 wxString wxSPhotoEncoding;
1422 wxString wxSPhotoData;
1423 std::string base64enc;
1425 if (intSplitsFound == 0){
1429 std::map<int, int>::iterator striter;
1431 striter = SplitLength.find(1);
1433 wxStringTokenizer wSTDataType(wxSPropertySeg2.Mid(0, striter->second), wxT(":"));
1435 while (wSTDataType.HasMoreTokens() == TRUE){
1437 wxSPhotoURI = wSTDataType.GetNextToken();
1438 wxSPhotoMIME = wSTDataType.GetNextToken();
1443 wxStringTokenizer wSTDataInfo(wxSPropertySeg2.Mid((striter->second + 1)), wxT(","));
1445 while (wSTDataInfo.HasMoreTokens() == TRUE){
1447 wxSPhotoEncoding = wSTDataInfo.GetNextToken();
1448 wxSPhotoData = wSTDataInfo.GetNextToken();
1449 base64enc = wxSPhotoData.mb_str();
1457 if (PhotoFirst == FALSE){
1459 bool PhotoKeepData = FALSE;
1461 wxString wxSPhotoMIMEF;
1463 if (wxSPhotoMIME == wxT("image/png")){
1464 wxSPhotoMIMEF = wxT("PNG");
1465 } else if (wxSPhotoMIME == wxT("image/jpeg")){
1466 wxSPhotoMIMEF = wxT("JPEG");
1467 } else if (wxSPhotoMIME == wxT("image/gif")){
1468 wxSPhotoMIMEF = wxT("GIF");
1469 } else if (wxSPhotoMIME == wxT("image/bmp")){
1470 wxSPhotoMIMEF = wxT("BMP");
1472 wxSPhotoMIMEF = wxT("UNKNOWN");
1473 PhotoKeepData = TRUE;
1476 ContactDatav3.AddRaw(wxT("PHOTO;ENCODING=b;TYPE=") + wxSPhotoMIMEF, wxSPhotoData);
1478 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1482 if (PhotoKeepData == TRUE){
1484 ContactDatav3.AddRaw(wxT("X-VCARD4-PHOTO;X-FIRST=TRUE;")
1485 + ContactLine.Mid((intPrevValue - 1), ((QuoteBreakPoint + 1) - (intPrevValue))), wxSPropertySeg2);
1489 ContactDatav3.AddRaw(wxT("X-VCARD4-PHOTO;X-FIRST=TRUE;")
1490 + ContactLine.Mid((intPrevValue - 1), ((QuoteBreakPoint + 1) - (intPrevValue))), wxT(""));
1500 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1502 ContactDatav3.AddRaw(wxT("X-VCARD4-PHOTO"), wxSPropertySeg2);
1506 ContactDatav3.AddRaw(wxT("X-VCARD4-PHOTO;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))) + wxT(":"),
1512 } else if (wxSProperty == wxT("LOGO")) {
1514 std::map<int, int> SplitPoints;
1515 std::map<int, int> SplitLength;
1516 std::map<int, int>::iterator SLiter;
1517 wxString PropertyData;
1518 wxString PropertyName;
1519 wxString PropertyValue;
1520 wxString PropertyTokens;
1521 int intPrevValue = 6;
1525 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1527 ContactDatav3.AddRaw(wxT("X-VCARD4-LOGO"), wxSPropertySeg2);
1531 ContactDatav3.AddRaw(wxT("X-VCARD4-LOGO;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
1535 } else if (wxSProperty == wxT("SOUND")) {
1537 std::map<int, int> SplitPoints;
1538 std::map<int, int> SplitLength;
1539 std::map<int, int>::iterator SLiter;
1540 wxString PropertyData;
1541 wxString PropertyName;
1542 wxString PropertyValue;
1543 wxString PropertyTokens;
1544 int intPrevValue = 7;
1548 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1550 ContactDatav3.AddRaw(wxT("X-VCARD4-SOUND"), wxSPropertySeg2);
1554 ContactDatav3.AddRaw(wxT("X-VCARD4-SOUND;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
1558 } else if (wxSProperty == wxT("CALURI")){
1560 std::map<int, int> SplitPoints;
1561 std::map<int, int> SplitLength;
1562 std::map<int, int>::iterator SLiter;
1563 wxString PropertyData;
1564 wxString PropertyName;
1565 wxString PropertyValue;
1566 wxString PropertyTokens;
1567 int intPrevValue = 8;
1571 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1573 ContactDatav3.AddRaw(wxT("X-VCARD4-CALURI"), wxSPropertySeg2);
1577 ContactDatav3.AddRaw(wxT("X-VCARD4-CALURI;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
1581 } else if (wxSProperty == wxT("CALADRURI")){
1583 std::map<int, int> SplitPoints;
1584 std::map<int, int> SplitLength;
1585 std::map<int, int>::iterator SLiter;
1586 wxString PropertyData;
1587 wxString PropertyName;
1588 wxString PropertyValue;
1589 wxString PropertyTokens;
1590 int intPrevValue = 11;
1594 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1596 ContactDatav3.AddRaw(wxT("X-VCARD4-CALADRURI"), wxSPropertySeg2);
1600 ContactDatav3.AddRaw(wxT("X-VCARD4-CALADRURI;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
1604 } else if (wxSProperty == wxT("FBURL")){
1606 std::map<int, int> SplitPoints;
1607 std::map<int, int> SplitLength;
1608 std::map<int, int>::iterator SLiter;
1609 wxString PropertyData;
1610 wxString PropertyName;
1611 wxString PropertyValue;
1612 wxString PropertyTokens;
1613 int intPrevValue = 7;
1617 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1619 ContactDatav3.AddRaw(wxT("X-VCARD4-FBURL"), wxSPropertySeg2);
1623 ContactDatav3.AddRaw(wxT("X-VCARD4-FBURL;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
1627 } else if (wxSProperty == wxT("KEY")){
1629 std::map<int, int> SplitPoints;
1630 std::map<int, int> SplitLength;
1631 std::map<int, int>::iterator SLiter;
1632 wxString PropertyData;
1633 wxString PropertyName;
1634 wxString PropertyValue;
1635 wxString PropertyTokens;
1636 int intPrevValue = 5;
1640 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1642 ContactDatav3.AddRaw(wxT("X-VCARD4-KEY"), wxSPropertySeg2);
1646 ContactDatav3.AddRaw(wxT("X-VCARD4-KEY;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
1650 } else if (wxSProperty == wxT("UID")){
1652 ContactDatav3.AddRaw(wxT("UID"), wxSPropertySeg2);
1654 } else if (wxSProperty.Mid(0, 3) == wxT("VND")){
1656 // Split the Vendor three ways.
1658 wxStringTokenizer wSTVendorDetails(wxSPropertySeg1, wxT("-"));
1661 wxString wxSVNDPropName;
1663 size_t intPrevValue = (wxSProperty.Len() + 1);
1665 while (wSTVendorDetails.HasMoreTokens() == TRUE){
1667 wSTVendorDetails.GetNextToken();
1668 wxSVNDID = wSTVendorDetails.GetNextToken();
1669 wxSVNDPropName = wSTVendorDetails.GetNextToken();
1674 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1676 ContactDatav3.AddRaw(wxT("X-VCARD4-") + wxSProperty, wxSPropertySeg2);
1680 ContactDatav3.AddRaw(wxT("X-VCARD4-") + wxSProperty + wxT(";") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
1684 } else if (wxSProperty.Mid(0, 2) == wxT("X-")){
1686 size_t intPrevValue = (wxSProperty.Len() + 1);
1688 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1690 ContactDatav3.AddRaw(wxSProperty, wxSPropertySeg2);
1694 ContactDatav3.AddRaw(wxSProperty + wxT(";") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
1700 // Reset the variables.
1703 PropertyFind = TRUE;
1704 ExtraLineSeek = TRUE;
1706 QuoteBreakPoint = 0;
1707 ContactLine.Clear();
1708 wxSProperty.Clear();
1712 ContactDatav3.AddRaw(wxT("END"), wxT("VCARD"));
1713 *wxSData = ContactDatav3.WriteString();