1 // vcard34conv-v3conv.cpp - vCard34Conv Object vCard3 conversion subroutines.
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 "vcard34conv.h"
21 #include "../version.h"
22 #include "../common/textprocessing.h"
25 #include <wx/tokenzr.h>
26 #include <wx/datetime.h>
29 bool vCard34Conv::ConvertToV3(wxString Filename, wxString *wxSData){
34 // Load the contact into the contact editor.
37 wxString wxSContactString;
43 //wxSContactFilename = Filename;
45 // Check if we are using wxWidgets version 2.8 or less and
46 // execute the required command accordingly.
48 #if wxABI_VERSION < 20900
49 ContactFile.Open(Filename.c_str(), wxT("r"));
51 ContactFile.Open(Filename, wxT("r"));
54 if (ContactFile.IsOpened() == FALSE){
60 ContactFile.ReadAll(&wxSContactString, wxConvAuto());
64 std::map<int, wxString> ContactFileLines;
65 std::map<int, wxString>::iterator striter;
67 wxStringTokenizer wSTContactFileLines(wxSContactString, wxT("\r\n"));
69 int ContactLineSeek = 0;
71 while (wSTContactFileLines.HasMoreTokens() == TRUE){
73 ContactLine = wSTContactFileLines.GetNextToken();
74 ContactFileLines.insert(std::make_pair(ContactLineSeek, ContactLine));
81 bool QuoteMode = FALSE;
82 bool PropertyFind = TRUE;
83 bool HasExtraNicknames = FALSE;
84 bool IgnoreGender = FALSE;
85 bool ExtraLineSeek = TRUE;
86 bool BirthdayProcessed = FALSE;
87 bool AnniversaryProcessed = FALSE;
88 bool FNProcessed = FALSE;
89 bool GenderProcessed = FALSE;
90 bool NameProcessed = FALSE;
91 bool KindProcessed = FALSE;
93 bool NicknameFirst = FALSE;
94 bool TitleFirst = FALSE;
95 bool OrganisationFirst = FALSE;
96 bool NoteFirst = FALSE;
97 bool PhotoFirst = FALSE;
98 bool LogoFirst = FALSE;
99 int intExtraNickname = 0;
100 wxString wxSProperty;
101 wxString wxSPropertySeg1;
102 wxString wxSPropertySeg2;
103 wxString wxSPropertyNextLine;
104 size_t ContactLineLen = 0;
105 int QuoteBreakPoint = 0;
108 int NicknameCount = 0;
117 int RelatedCount = 0;
122 int CategoryCount = 0;
127 int CalReqAdrCount = 0;
128 int FreeBusyCount = 0;
133 //int intValueSeek = 1;
137 // Setup the version string.
139 strVer.Append(wxT("-//Xestia//Address Book Version "));
140 strVer.Append(wxT(XSDAB_VERSION));
141 strVer.Append(wxT("//KW"));
143 ContactDatav3.AddRaw(wxT("BEGIN"), wxT("VCARD"));
144 ContactDatav3.AddRaw(wxT("VERSION"), wxT("3.0"));
145 ContactDatav3.AddRaw(wxT("PRODID"), strVer);
147 for (std::map<int,wxString>::iterator iter = ContactFileLines.begin();
148 iter != ContactFileLines.end(); ++iter){
150 // Find the colon which splits the start bit from the data part.
152 ContactLine = iter->second;
154 while (ExtraLineSeek == TRUE){
156 // Check if there is extra data on the next line
157 // (indicated by space or tab at the start) and add data.
161 if (iter == ContactFileLines.end()){
168 wxSPropertyNextLine = iter->second;
171 if (wxSPropertyNextLine.Mid(0, 1) == wxT(" ") || wxSPropertyNextLine.Mid(0, 1) == wxT("\t")){
173 wxSPropertyNextLine.Remove(0, 1);
174 //wxSPropertyNextLine.Trim(FALSE);
175 //ContactLine.Trim();
176 ContactLine.Append(wxSPropertyNextLine);
181 ExtraLineSeek = FALSE;
187 ContactLineLen = ContactLine.Len();
189 // Make sure we are not in quotation mode.
190 // Make sure colon does not have \ or \\ before it.
194 for (int i = 0; i <= ContactLineLen; i++){
196 if ((ContactLine.Mid(i, 1) == wxT(";") || ContactLine.Mid(i, 1) == wxT(":")) && PropertyFind == TRUE){
198 PropertyFind = FALSE;
200 } else if (PropertyFind == TRUE){
202 wxSProperty.Append(ContactLine.Mid(i, 1));
206 if (ContactLine.Mid(i, 1) == wxT("\"")){
208 if (QuoteMode == TRUE){
220 if (ContactLine.Mid(i, 1) == wxT(":") && ContactLine.Mid((i - 1), 1) != wxT("\\") && QuoteMode == FALSE){
229 // Split that line at the point into two variables (ignore the colon).
231 wxSPropertySeg1 = ContactLine.Mid(0, QuoteBreakPoint);
232 wxSPropertySeg2 = ContactLine.Mid((QuoteBreakPoint + 1));
234 // Add the data into the contact editor depending on what it is.
236 if (wxSProperty == wxT("FN")){
238 std::map<int, int> SplitPoints;
239 std::map<int, int> SplitLength;
240 std::map<int, int>::iterator SLiter;
241 wxString PropertyData;
242 wxString PropertyName;
243 wxString PropertyValue;
244 wxString PropertyTokens;
245 int intPrevValue = 4;
247 //SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
251 if (FNFirst == FALSE){
253 ContactDatav3.AddRaw(wxT("FN"), wxSPropertySeg2);
255 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
259 ContactDatav3.AddRaw(wxT("X-VCARD4-FN;X-FIRST=TRUE;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
266 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
268 ContactDatav3.AddRaw(wxT("X-VCARD4-FN"), wxSPropertySeg2);
272 ContactDatav3.AddRaw(wxT("X-VCARD4-FN;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))),
279 } else if (wxSProperty == wxT("N") && NameProcessed == FALSE){
281 std::map<int, int> SplitPoints;
282 std::map<int, int> SplitLength;
283 std::map<int, int>::iterator SLiter;
284 wxString PropertyData;
285 wxString PropertyName;
286 wxString PropertyValue;
287 wxString PropertyTokens;
288 int intPrevValue = 3;
292 ContactDatav3.AddRaw(wxT("N"), wxSPropertySeg2);
294 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
300 ContactDatav3.AddRaw(wxT("X-VCARD4-N;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxT(""));
304 NameProcessed = TRUE;
306 } else if (wxSProperty == wxT("KIND") && KindProcessed == FALSE){
310 std::map<int, int> SplitPoints;
311 std::map<int, int> SplitLength;
312 std::map<int, int>::iterator SLiter;
313 wxString PropertyData;
314 wxString PropertyName;
315 wxString PropertyValue;
316 wxString PropertyTokens;
317 int intPrevValue = 5;
321 ContactDatav3.AddRaw(wxT("X-ADDRESSBOOKSERVER-KIND"), wxSPropertySeg2);
323 KindProcessed = TRUE;
325 } else if (wxSProperty == wxT("MEMBER")){
329 std::map<int, int> SplitPoints;
330 std::map<int, int> SplitLength;
331 std::map<int, int>::iterator SLiter;
332 wxString PropertyData;
333 wxString PropertyName;
334 wxString PropertyValue;
335 wxString PropertyTokens;
336 int intPrevValue = 7;
340 ContactDatav3.AddRaw(wxT("X-ADDRESSBOOKSERVER-MEMBER"), wxSPropertySeg2);
342 } else if (wxSProperty == wxT("NICKNAME")){
344 std::map<int, int> SplitPoints;
345 std::map<int, int> SplitLength;
346 std::map<int, int>::iterator SLiter;
347 wxString PropertyData;
348 wxString PropertyName;
349 wxString PropertyValue;
350 wxString PropertyTokens;
351 int intPrevValue = 10;
355 if (NicknameFirst == FALSE){
357 ContactDatav3.AddRaw(wxT("NICKNAME"), wxSPropertySeg2);
359 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
363 ContactDatav3.AddRaw(wxT("X-VCARD4-NICKNAME;X-FIRST=TRUE;")
364 + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxT(""));
367 NicknameFirst = TRUE;
372 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
374 ContactDatav3.AddRaw(wxT("X-VCARD4-NICKNAME"), wxSPropertySeg2);
378 ContactDatav3.AddRaw(wxT("X-VCARD4-NICKNAME;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))) + wxT(":"),
386 } else if (wxSProperty == wxT("GENDER") && GenderProcessed == FALSE){
388 // Do PID/ALTID/LANG things.
390 std::map<int, int> SplitPoints;
391 std::map<int, int> SplitLength;
392 std::map<int, int>::iterator SLiter;
393 wxString PropertyData;
394 wxString PropertyName;
395 wxString PropertyValue;
396 wxString PropertyTokens;
397 int intPrevValue = 8;
402 if (wxSPropertySeg2.Mid(1, 1) == wxT(";")){
404 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
406 ContactDatav3.AddRaw(wxT("X-VCARD4-GENDER;X-GENDERTEXT=\"") + wxSPropertySeg2.Mid(2) + wxT("\""), wxSPropertySeg2.Mid(0, 1));
410 ContactDatav3.AddRaw(wxT("X-VCARD4-GENDER;X-GENDERTEXT=\"") + wxSPropertySeg2.Mid(2) + wxT("\";")
411 + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))),
412 wxSPropertySeg2.Mid(0, 1));
418 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
420 ContactDatav3.AddRaw(wxT("X-VCARD4-GENDER"), wxSPropertySeg2);
424 ContactDatav3.AddRaw(wxT("X-VCARD4-GENDER;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
430 GenderProcessed = TRUE;
432 } else if (wxSProperty == wxT("BDAY") && BirthdayProcessed == FALSE){
434 // Process date. Preserve the remainder in the string.
436 std::map<int, int> SplitPoints;
437 std::map<int, int> SplitLength;
438 std::map<int, int>::iterator SLiter;
439 wxString PropertyData;
440 wxString PropertyName;
441 wxString PropertyValue;
442 wxString PropertyTokens;
444 int intPrevValue = 6;
450 // Look for type before continuing.
452 if (wxSPropertySeg2.Mid(0, 2) == wxT("--")){
454 strResults.Append(wxT("1604-"));
457 strResults.Append(wxSPropertySeg2.Mid(2, 2) + wxT("-"));
458 strResults.Append(wxSPropertySeg2.Mid(4, 2));
462 strResults.Append(wxSPropertySeg2.Mid(0, 4) + wxT("-"));
463 strResults.Append(wxSPropertySeg2.Mid(4, 2) + wxT("-"));
464 strResults.Append(wxSPropertySeg2.Mid(6, 2));
472 ContactDatav3.AddRaw(wxT("BDAY;X-APPLE-OMIT-YEAR=1604"), strResults);
474 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
476 ContactDatav3.AddRaw(wxT("X-VCARD4-BDAY"), wxSPropertySeg2);
480 ContactDatav3.AddRaw(wxT("X-VCARD4-BDAY;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
486 ContactDatav3.AddRaw(wxT("BDAY"), strResults);
488 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
490 ContactDatav3.AddRaw(wxT("X-VCARD4-BDAY"), wxSPropertySeg2);
494 ContactDatav3.AddRaw(wxT("X-VCARD4-BDAY;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
500 BirthdayProcessed = TRUE;
502 } else if (wxSProperty == wxT("ANNIVERSARY") && AnniversaryProcessed == FALSE){
504 // Process date. Preserve the remainder in the string.
506 std::map<int, int> SplitPoints;
507 std::map<int, int> SplitLength;
508 std::map<int, int>::iterator SLiter;
509 wxString PropertyData;
510 wxString PropertyName;
511 wxString PropertyValue;
512 wxString PropertyTokens;
513 int intPrevValue = 13;
520 // Look for type before continuing.
522 if (wxSPropertySeg2.Mid(0, 2) == wxT("--")){
524 strResults.Append(wxT("1604-"));
527 strResults.Append(wxSPropertySeg2.Mid(2, 2) + wxT("-"));
528 strResults.Append(wxSPropertySeg2.Mid(4, 2));
532 strResults.Append(wxSPropertySeg2.Mid(0, 4) + wxT("-"));
533 strResults.Append(wxSPropertySeg2.Mid(4, 2) + wxT("-"));
534 strResults.Append(wxSPropertySeg2.Mid(6, 2));
540 ContactDatav3.AddRaw(wxT("ANNIVERSARY;X-APPLE-OMIT-YEAR=1604"), strResults);
542 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
544 ContactDatav3.AddRaw(wxT("X-VCARD4-ANNIVERSARY"), wxSPropertySeg2);
548 ContactDatav3.AddRaw(wxT("X-VCARD4-ANNIVERSARY;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
554 ContactDatav3.AddRaw(wxT("ANNIVERSARY"), strResults);
556 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
558 ContactDatav3.AddRaw(wxT("X-VCARD4-ANNIVERSARY"), wxSPropertySeg2);
562 ContactDatav3.AddRaw(wxT("X-VCARD4-ANNIVERSARY;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
568 AnniversaryProcessed = TRUE;
570 } else if (wxSProperty == wxT("TZ")){
572 std::map<int, int> SplitPoints;
573 std::map<int, int> SplitLength;
574 std::map<int, int>::iterator SLiter;
575 wxString PropertyData;
576 wxString PropertyName;
577 wxString PropertyValue;
578 wxString PropertyTokens;
579 int intPrevValue = 4;
583 // Look for type before continuing.
585 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
587 ContactDatav3.AddRaw(wxT("X-VCARD4-TZ"), wxSPropertySeg2);
591 ContactDatav3.AddRaw(wxT("X-VCARD4-TZ;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
595 } else if (wxSProperty == wxT("ADR")){
597 std::map<int, int> SplitPoints;
598 std::map<int, int> SplitLength;
599 std::map<int, int>::iterator SLiter;
600 wxString PropertyData;
601 wxString PropertyName;
602 wxString PropertyValue;
603 wxString PropertyTokens;
604 wxString AddressLabel;
605 wxString AddressLang;
606 wxString AddressAltID;
608 wxString AddressTokens;
610 wxString AddressTimezone;
611 wxString AddressType;
612 wxString AddressMediatype;
613 wxString AddressPOBox;
614 wxString AddressExtended;
615 wxString AddressStreet;
616 wxString AddressLocality;
617 wxString AddressCity;
618 wxString AddressRegion;
619 wxString AddressPostalCode;
620 wxString AddressCountry;
621 int intPrevValue = 5;
625 // TODO: Check in value for X-ABLabel and use it if it is there.
627 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
629 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".ADR"), wxSPropertySeg2);
630 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), _("Address"));
631 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-ADR"), wxSPropertySeg2);
635 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".ADR"), wxSPropertySeg2);
636 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), _("Address"));
637 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-ADR;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
643 } else if (wxSProperty == wxT("EMAIL")){
645 // TODO: Continue from here! See ADR for good example (Replace initer with intPrevValue).
646 // Remove inserted comma for Extra Tokens in frmContactEditor.cpp
648 std::map<int, int> SplitPoints;
649 std::map<int, int> SplitLength;
650 std::map<int, int>::iterator SLiter;
651 std::map<int, int>::iterator SPoint;
652 wxString PropertyData;
653 wxString PropertyName;
654 wxString PropertyValue;
655 wxString PropertyTokens;
656 wxString AddressLabel;
657 wxString AddressLang;
658 wxString AddressAltID;
660 wxString AddressTokens;
662 wxString AddressTimezone;
663 wxString AddressType;
664 wxString AddressMediatype;
665 wxString AddressPOBox;
666 wxString AddressExtended;
667 wxString AddressStreet;
668 wxString AddressLocality;
669 wxString AddressCity;
670 wxString AddressRegion;
671 wxString AddressPostalCode;
672 wxString AddressCountry;
673 int intPrevValue = 7;
677 // TODO: Check in value for X-ABLabel and use it if it is there.
679 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
681 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".EMAIL"), wxSPropertySeg2);
682 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), _("E-mail Address"));
683 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-EMAIL"), wxSPropertySeg2);
687 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".EMAIL"), wxSPropertySeg2);
688 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), _("E-mail Address"));
689 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-EMAIL;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
695 } else if (wxSProperty == wxT("IMPP")){
697 std::map<int, int> SplitPoints;
698 std::map<int, int> SplitLength;
699 std::map<int, int>::iterator SLiter;
700 std::map<int, int>::iterator SPoint;
701 wxString PropertyData;
702 wxString PropertyName;
703 wxString PropertyValue;
704 wxString PropertyTokens;
706 wxString IMPPAddress;
707 int intPrevValue = 6;
709 SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
713 // TODO: Check in value for X-ABLabel and use it if it is there.
715 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
717 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".IMPP"), wxSPropertySeg2);
718 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), _("Instant Message"));
719 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-IMPP"), wxSPropertySeg2);
723 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".IMPP"), wxSPropertySeg2);
724 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), _("Instant Message"));
725 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-IMPP;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
731 } else if (wxSProperty == wxT("TEL")){
733 // Check TEL and make sure it is functioning properly.
735 std::map<int, int> SplitPoints;
736 std::map<int, int> SplitLength;
737 std::map<int, int> TypeSplitPoints;
738 std::map<int, int> TypeSplitLength;
739 std::map<int, int>::iterator SLiter;
740 std::map<int, int>::iterator SPoint;
741 std::map<int, int>::iterator TSLiter;
742 std::map<int, int>::iterator TSPoint;
743 wxString PropertyData;
744 wxString PropertyName;
745 wxString PropertyValue;
746 wxString PropertyTokens;
750 wxString TelTypeDetail;
752 wxString FinalFriendlyString;
753 int intSplitsFound = 0;
754 int intSplitSize = 0;
755 int intPrevValue = 5;
757 int intSplitPoint = 0;
761 SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
763 // Look for type before continuing.
765 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
766 intiter != SplitPoints.end(); ++intiter){
768 SLiter = SplitLength.find(intiter->first);
770 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
772 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
773 PropertyName = PropertyElement.GetNextToken();
774 PropertyValue = PropertyElement.GetNextToken();
776 intPrevValue = intiter->second;
778 if (PropertyName == wxT("TYPE")){
780 // Process each value in type and translate each
783 // Strip out the quotes if they are there.
785 size_t intPropertyValueLen = PropertyValue.Len();
787 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
789 PropertyValue.Trim();
790 PropertyValue.RemoveLast();
794 if (PropertyValue.Mid(0, 1) == wxT("\"")){
796 PropertyValue.Remove(0, 1);
800 TelTypeDetail = PropertyValue;
806 for (int i = 0; i <= intPropertyValueLen; i++){
810 if (PropertyValue.Mid(i, 1) == wxT(",") && PropertyValue.Mid((i - 1), 1) != wxT("\\")){
812 if (intSplitsFound == 0){
814 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
815 TypeSplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
819 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
820 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
833 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
834 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
838 for (std::map<int, int>::iterator typeiter = TypeSplitPoints.begin();
839 typeiter != TypeSplitPoints.end(); ++typeiter){
841 wxString TypePropertyName;
843 TSLiter = TypeSplitLength.find(typeiter->first);
845 TypePropertyName = PropertyValue.Mid(typeiter->second, TSLiter->second);
847 if (intTypeSeek == 0){
852 TelTypeUI.Append(wxT(","));
856 if (TypePropertyName == wxT("home")){
860 } else if (TypePropertyName == wxT("work")){
866 if (TypePropertyName == wxT("text")){
868 if (!FinalFriendlyString.IsEmpty()){ FinalFriendlyString.Append(_(", Text")); } else { FinalFriendlyString.Append(_("Text")); }
870 TelTypeOut.Append(wxT(";"));
871 TelTypeOut.Append(wxT("type=TEXT"));
873 } else if (TypePropertyName == wxT("voice")){
875 if (!FinalFriendlyString.IsEmpty()){ FinalFriendlyString.Append(_(", Voice")); } else { FinalFriendlyString.Append(_("Voice")); }
877 TelTypeOut.Append(wxT(";"));
878 TelTypeOut.Append(wxT("type=VOICE"));
882 } else if (TypePropertyName == wxT("fax")){
884 if (!FinalFriendlyString.IsEmpty()){ FinalFriendlyString.Append(_(", Fax")); } else { FinalFriendlyString.Append(_("Fax")); }
886 TelTypeOut.Append(wxT(";"));
887 TelTypeOut.Append(wxT("type=FAX"));
890 } else if (TypePropertyName == wxT("cell")){
892 if (!FinalFriendlyString.IsEmpty()){ FinalFriendlyString.Append(_(", Mobile")); } else { FinalFriendlyString.Append(_("Mobile")); }
894 TelTypeOut.Append(wxT(";"));
895 TelTypeOut.Append(wxT("type=CELL"));
898 } else if (TypePropertyName == wxT("video")){
900 if (!FinalFriendlyString.IsEmpty()){ FinalFriendlyString.Append(_(", Video")); } else { FinalFriendlyString.Append(_("Video")); }
902 TelTypeOut.Append(wxT(";"));
903 TelTypeOut.Append(wxT("type=VIDEO"));
906 } else if (TypePropertyName == wxT("pager")){
908 if (!FinalFriendlyString.IsEmpty()){ FinalFriendlyString.Append(_(", Pager")); } else { FinalFriendlyString.Append(_("Pager")); }
910 TelTypeOut.Append(wxT(";"));
911 TelTypeOut.Append(wxT("type=PAGER"));
914 } else if (TypePropertyName == wxT("textphone")){
916 //if (!TelTypeOut.IsEmpty()){ TelTypeOut.Append(wxT(";")); }
918 if (!FinalFriendlyString.IsEmpty()){ FinalFriendlyString.Append(_(", Textphone")); } else { FinalFriendlyString.Append(_("Textphone")); }
920 TelTypeOut.Append(wxT(";"));
921 TelTypeOut.Append(wxT("type=TEXTPHONE"));
938 // Remove 'tel:' if it is being used.
940 if (wxSPropertySeg2.Mid(0, 4) == wxT("tel:")){
942 FinalTel = wxSPropertySeg2.Mid(4);
946 FinalTel = wxSPropertySeg2;
950 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
952 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".TEL") + TelTypeOut, FinalTel);
953 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), FinalFriendlyString);
954 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-TEL"), wxSPropertySeg2);
958 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".TEL") + TelTypeOut, FinalTel);
959 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), FinalFriendlyString);
960 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-TEL;") + wxSPropertySeg1.Mid(4), wxSPropertySeg2);
966 } else if (wxSProperty == wxT("LANG")){
968 std::map<int, int> SplitPoints;
969 std::map<int, int> SplitLength;
970 std::map<int, int>::iterator SLiter;
971 wxString PropertyData;
972 wxString PropertyName;
973 wxString PropertyValue;
974 wxString PropertyTokens;
975 int intPrevValue = 6;
979 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
981 ContactDatav3.AddRaw(wxT("X-VCARD4-LANG"), wxSPropertySeg2);
985 ContactDatav3.AddRaw(wxT("X-VCARD4-LANG;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
989 } else if (wxSProperty == wxT("GEO")){
991 std::map<int, int> SplitPoints;
992 std::map<int, int> SplitLength;
993 std::map<int, int>::iterator SLiter;
994 wxString PropertyData;
995 wxString PropertyName;
996 wxString PropertyValue;
997 wxString PropertyTokens;
1000 int intPrevValue = 5;
1004 SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1006 wxString strFinalGeoValue;
1007 wxString strFinalType;
1009 if (wxSPropertySeg2.Mid(0, 3) == wxT("geo")){
1011 strFinalGeoValue = wxSPropertySeg2.Mid(5);
1012 strFinalType = wxT("geo");
1016 wxStringTokenizer wSTSplit(wxSPropertySeg2, wxT(":"));
1017 strFinalType = wSTSplit.GetNextToken();
1018 strFinalGeoValue = wSTSplit.GetNextToken();
1022 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1024 ContactDatav3.AddRaw(wxT("X-VCARD4-GEO;X-GEOTYPE=") + strFinalType, wxSPropertySeg2);
1028 ContactDatav3.AddRaw(wxT("X-VCARD4-GEO;X-GEOTYPE=") + strFinalType + wxT(";") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
1032 } else if (wxSProperty == wxT("RELATED")){
1034 std::map<int, int> SplitPoints;
1035 std::map<int, int> SplitLength;
1036 std::map<int, int>::iterator SLiter;
1037 wxString PropertyData;
1038 wxString PropertyName;
1039 wxString PropertyValue;
1040 wxString PropertyTokens;
1041 wxString RelatedType;
1042 wxString RelatedTypeOriginal;
1043 wxString RelatedName;
1044 bool FirstToken = TRUE;
1045 int intPrevValue = 9;
1049 SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
1053 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
1054 intiter != SplitPoints.end(); ++intiter){
1056 SLiter = SplitLength.find(intiter->first);
1058 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second - 1));
1060 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1061 PropertyName = PropertyElement.GetNextToken();
1062 PropertyValue = PropertyElement.GetNextToken();
1064 if (PropertyName == wxT("TYPE") && FirstToken == TRUE){
1066 if (PropertyValue == wxT("contact")){
1068 strDetail = _("Contact");
1070 } else if (PropertyValue == wxT("acquaintance")){
1072 strDetail = _("Acquaintance");
1074 } else if (PropertyValue == wxT("friend")){
1076 strDetail = _("Friend");
1078 } else if (PropertyValue == wxT("met")){
1080 strDetail = _("Met");
1082 } else if (PropertyValue == wxT("co-worker")){
1084 strDetail = _("Co-worker");
1086 } else if (PropertyValue == wxT("colleague")){
1088 strDetail = _("Colleague");
1090 } else if (PropertyValue == wxT("co-resident")){
1092 strDetail = _("Co-resident");
1094 } else if (PropertyValue == wxT("neighbor")){
1096 strDetail = _("Neighbour");
1098 } else if (PropertyValue == wxT("child")){
1100 strDetail = _("Child");
1102 } else if (PropertyValue == wxT("parent")){
1104 strDetail = _("Parent");
1106 } else if (PropertyValue == wxT("sibling")){
1108 strDetail = _("Sibling");
1110 } else if (PropertyValue == wxT("spouse")){
1112 strDetail = _("Spouse");
1114 } else if (PropertyValue == wxT("kin")){
1116 strDetail = _("Kin");
1118 } else if (PropertyValue == wxT("muse")){
1120 strDetail = _("Muse");
1122 } else if (PropertyValue == wxT("crush")){
1124 strDetail = _("Crush");
1126 } else if (PropertyValue == wxT("date")){
1128 strDetail = _("Date");
1130 } else if (PropertyValue == wxT("sweetheart")){
1132 strDetail = _("Sweetheart");
1134 } else if (PropertyValue == wxT("me")){
1136 strDetail = _("Me");
1138 } else if (PropertyValue == wxT("agent")){
1140 strDetail = _("Agent");
1142 } else if (PropertyValue == wxT("emergency")){
1144 strDetail = _("Emergency");
1148 strDetail = PropertyValue;
1158 if (strDetail.IsEmpty()){
1160 strDetail = _("Relation");
1164 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1166 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABRELATEDNAMES"), wxSPropertySeg2);
1167 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), strDetail);
1168 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-RELATED"), wxSPropertySeg2);
1172 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABRELATEDNAMES"), wxSPropertySeg2);
1173 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), strDetail);
1174 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-RELATED;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
1180 } else if (wxSProperty == wxT("URL")){
1182 std::map<int, int> SplitPoints;
1183 std::map<int, int> SplitLength;
1184 std::map<int, int>::iterator SLiter;
1185 wxString PropertyData;
1186 wxString PropertyName;
1187 wxString PropertyValue;
1188 wxString PropertyTokens;
1189 int intPrevValue = 5;
1193 // Todo: Check for X-ABLabel.
1195 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1197 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".URL"), wxSPropertySeg2);
1198 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), _("URL"));
1199 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-URL"), wxSPropertySeg2);
1203 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".URL"), wxSPropertySeg2);
1204 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), _("URL"));
1205 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-URL;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
1211 } else if (wxSProperty == wxT("TITLE")) {
1213 std::map<int, int> SplitPoints;
1214 std::map<int, int> SplitLength;
1215 std::map<int, int>::iterator SLiter;
1216 wxString PropertyData;
1217 wxString PropertyName;
1218 wxString PropertyValue;
1219 wxString PropertyTokens;
1220 int intPrevValue = 7;
1224 // Look for type before continuing.
1226 if (TitleFirst == FALSE){
1228 ContactDatav3.AddRaw(wxT("TITLE"), wxSPropertySeg2);
1230 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1234 ContactDatav3.AddRaw(wxT("X-VCARD4-TITLE;X-FIRST=TRUE;")
1235 + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxT(""));
1243 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1245 ContactDatav3.AddRaw(wxT("X-VCARD4-TITLE"), wxSPropertySeg2);
1249 ContactDatav3.AddRaw(wxT("X-VCARD4-TITLE;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))) + wxT(":"),
1256 } else if (wxSProperty == wxT("ROLE")) {
1258 std::map<int, int> SplitPoints;
1259 std::map<int, int> SplitLength;
1260 std::map<int, int>::iterator SLiter;
1261 wxString PropertyData;
1262 wxString PropertyName;
1263 wxString PropertyValue;
1264 wxString PropertyTokens;
1265 int intPrevValue = 6;
1269 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1271 ContactDatav3.AddRaw(wxT("X-VCARD4-ROLE"), wxSPropertySeg2);
1275 ContactDatav3.AddRaw(wxT("X-VCARD4-ROLE;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
1279 } else if (wxSProperty == wxT("ORG")) {
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 int intPrevValue = 5;
1292 if (OrganisationFirst == FALSE){
1294 ContactDatav3.AddRaw(wxT("ORG"), wxSPropertySeg2);
1296 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1300 ContactDatav3.AddRaw(wxT("X-VCARD4-ORG;X-FIRST=TRUE;")
1301 + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxT(""));
1304 OrganisationFirst = TRUE;
1309 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1311 ContactDatav3.AddRaw(wxT("X-VCARD4-ORG"), wxSPropertySeg2);
1315 ContactDatav3.AddRaw(wxT("X-VCARD4-ORG;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))) + wxT(":"),
1322 } else if (wxSProperty == wxT("NOTE")) {
1324 std::map<int, int> SplitPoints;
1325 std::map<int, int> SplitLength;
1326 std::map<int, int>::iterator SLiter;
1327 wxString PropertyData;
1328 wxString PropertyName;
1329 wxString PropertyValue;
1330 wxString PropertyTokens;
1331 int intPrevValue = 6;
1335 if (NoteFirst == FALSE){
1337 ContactDatav3.AddRaw(wxT("NOTE"), wxSPropertySeg2);
1339 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1343 ContactDatav3.AddRaw(wxT("X-VCARD4-NOTE;X-FIRST=TRUE;")
1344 + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxT(""));
1352 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1354 ContactDatav3.AddRaw(wxT("X-VCARD4-NOTE"), wxSPropertySeg2);
1358 ContactDatav3.AddRaw(wxT("X-VCARD4-NOTE;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))) + wxT(":"),
1365 } else if (wxSProperty == wxT("CATEGORIES")) {
1367 std::map<int, int> SplitPoints;
1368 std::map<int, int> SplitLength;
1369 std::map<int, int>::iterator SLiter;
1370 wxString PropertyData;
1371 wxString PropertyName;
1372 wxString PropertyValue;
1373 wxString PropertyTokens;
1374 wxString PropertyType;
1375 int intPrevValue = 12;
1379 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1381 ContactDatav3.AddRaw(wxT("X-VCARD4-CATEGORIES"), wxSPropertySeg2);
1385 ContactDatav3.AddRaw(wxT("X-VCARD4-CATEGORIES;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
1389 } else if (wxSProperty == wxT("PHOTO")) {
1391 size_t intPropertyLen = wxSPropertySeg1.Len();
1392 std::map<int, int> SplitPoints;
1393 std::map<int, int> SplitLength;
1394 std::map<int, int>::iterator SLiter;
1395 wxString PropertyData;
1396 wxString PropertyName;
1397 wxString PropertyValue;
1398 wxString PropertyTokens;
1399 int intSplitsFound = 0;
1400 int intSplitSize = 0;
1401 int intPrevValue = 7;
1403 intPropertyLen = wxSPropertySeg2.Len();
1404 SplitPoints.clear();
1405 SplitLength.clear();
1409 CaptureString(&wxSPropertySeg2, FALSE);
1411 for (int i = 0; i <= intPropertyLen; i++){
1415 if (wxSPropertySeg2.Mid(i, 1) == wxT(";")){
1418 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
1420 if (intSplitsFound == 6){
1422 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1427 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1437 wxString wxSPhotoURI;
1438 wxString wxSPhotoMIME;
1439 wxString wxSPhotoEncoding;
1440 wxString wxSPhotoData;
1441 std::string base64enc;
1443 if (intSplitsFound == 0){
1447 std::map<int, int>::iterator striter;
1449 striter = SplitLength.find(1);
1451 wxStringTokenizer wSTDataType(wxSPropertySeg2.Mid(0, striter->second), wxT(":"));
1453 while (wSTDataType.HasMoreTokens() == TRUE){
1455 wxSPhotoURI = wSTDataType.GetNextToken();
1456 wxSPhotoMIME = wSTDataType.GetNextToken();
1461 wxStringTokenizer wSTDataInfo(wxSPropertySeg2.Mid((striter->second + 1)), wxT(","));
1463 while (wSTDataInfo.HasMoreTokens() == TRUE){
1465 wxSPhotoEncoding = wSTDataInfo.GetNextToken();
1466 wxSPhotoData = wSTDataInfo.GetNextToken();
1467 base64enc = wxSPhotoData.mb_str();
1475 if (PhotoFirst == FALSE){
1477 bool PhotoKeepData = FALSE;
1479 wxString wxSPhotoMIMEF;
1481 if (wxSPhotoMIME == wxT("image/png")){
1482 wxSPhotoMIMEF = wxT("PNG");
1483 } else if (wxSPhotoMIME == wxT("image/jpeg")){
1484 wxSPhotoMIMEF = wxT("JPEG");
1485 } else if (wxSPhotoMIME == wxT("image/gif")){
1486 wxSPhotoMIMEF = wxT("GIF");
1487 } else if (wxSPhotoMIME == wxT("image/bmp")){
1488 wxSPhotoMIMEF = wxT("BMP");
1490 wxSPhotoMIMEF = wxT("UNKNOWN");
1491 PhotoKeepData = TRUE;
1494 ContactDatav3.AddRaw(wxT("PHOTO;ENCODING=b;TYPE=") + wxSPhotoMIMEF, wxSPhotoData);
1496 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1500 if (PhotoKeepData == TRUE){
1502 ContactDatav3.AddRaw(wxT("X-VCARD4-PHOTO;X-FIRST=TRUE;")
1503 + ContactLine.Mid((intPrevValue - 1), ((QuoteBreakPoint + 1) - (intPrevValue))), wxSPropertySeg2);
1507 ContactDatav3.AddRaw(wxT("X-VCARD4-PHOTO;X-FIRST=TRUE;")
1508 + ContactLine.Mid((intPrevValue - 1), ((QuoteBreakPoint + 1) - (intPrevValue))), wxT(""));
1518 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1520 ContactDatav3.AddRaw(wxT("X-VCARD4-PHOTO"), wxSPropertySeg2);
1524 ContactDatav3.AddRaw(wxT("X-VCARD4-PHOTO;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))) + wxT(":"),
1530 } else if (wxSProperty == wxT("LOGO")) {
1532 std::map<int, int> SplitPoints;
1533 std::map<int, int> SplitLength;
1534 std::map<int, int>::iterator SLiter;
1535 wxString PropertyData;
1536 wxString PropertyName;
1537 wxString PropertyValue;
1538 wxString PropertyTokens;
1539 int intPrevValue = 6;
1543 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1545 ContactDatav3.AddRaw(wxT("X-VCARD4-LOGO"), wxSPropertySeg2);
1549 ContactDatav3.AddRaw(wxT("X-VCARD4-LOGO;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
1553 } else if (wxSProperty == wxT("SOUND")) {
1555 std::map<int, int> SplitPoints;
1556 std::map<int, int> SplitLength;
1557 std::map<int, int>::iterator SLiter;
1558 wxString PropertyData;
1559 wxString PropertyName;
1560 wxString PropertyValue;
1561 wxString PropertyTokens;
1562 int intPrevValue = 7;
1566 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1568 ContactDatav3.AddRaw(wxT("X-VCARD4-SOUND"), wxSPropertySeg2);
1572 ContactDatav3.AddRaw(wxT("X-VCARD4-SOUND;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
1576 } else if (wxSProperty == wxT("CALURI")){
1578 std::map<int, int> SplitPoints;
1579 std::map<int, int> SplitLength;
1580 std::map<int, int>::iterator SLiter;
1581 wxString PropertyData;
1582 wxString PropertyName;
1583 wxString PropertyValue;
1584 wxString PropertyTokens;
1585 int intPrevValue = 8;
1589 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1591 ContactDatav3.AddRaw(wxT("X-VCARD4-CALURI"), wxSPropertySeg2);
1595 ContactDatav3.AddRaw(wxT("X-VCARD4-CALURI;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
1599 } else if (wxSProperty == wxT("CALADRURI")){
1601 std::map<int, int> SplitPoints;
1602 std::map<int, int> SplitLength;
1603 std::map<int, int>::iterator SLiter;
1604 wxString PropertyData;
1605 wxString PropertyName;
1606 wxString PropertyValue;
1607 wxString PropertyTokens;
1608 int intPrevValue = 11;
1612 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1614 ContactDatav3.AddRaw(wxT("X-VCARD4-CALADRURI"), wxSPropertySeg2);
1618 ContactDatav3.AddRaw(wxT("X-VCARD4-CALADRURI;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
1622 } else if (wxSProperty == wxT("FBURL")){
1624 std::map<int, int> SplitPoints;
1625 std::map<int, int> SplitLength;
1626 std::map<int, int>::iterator SLiter;
1627 wxString PropertyData;
1628 wxString PropertyName;
1629 wxString PropertyValue;
1630 wxString PropertyTokens;
1631 int intPrevValue = 7;
1635 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1637 ContactDatav3.AddRaw(wxT("X-VCARD4-FBURL"), wxSPropertySeg2);
1641 ContactDatav3.AddRaw(wxT("X-VCARD4-FBURL;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
1645 } else if (wxSProperty == wxT("KEY")){
1647 std::map<int, int> SplitPoints;
1648 std::map<int, int> SplitLength;
1649 std::map<int, int>::iterator SLiter;
1650 wxString PropertyData;
1651 wxString PropertyName;
1652 wxString PropertyValue;
1653 wxString PropertyTokens;
1654 int intPrevValue = 5;
1658 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1660 ContactDatav3.AddRaw(wxT("X-VCARD4-KEY"), wxSPropertySeg2);
1664 ContactDatav3.AddRaw(wxT("X-VCARD4-KEY;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
1668 } else if (wxSProperty == wxT("UID")){
1670 ContactDatav3.AddRaw(wxT("UID"), wxSPropertySeg2);
1672 } else if (wxSProperty.Mid(0, 3) == wxT("VND")){
1674 // Split the Vendor three ways.
1676 wxStringTokenizer wSTVendorDetails(wxSPropertySeg1, wxT("-"));
1679 wxString wxSVNDPropName;
1681 size_t intPrevValue = (wxSProperty.Len() + 1);
1683 while (wSTVendorDetails.HasMoreTokens() == TRUE){
1685 wSTVendorDetails.GetNextToken();
1686 wxSVNDID = wSTVendorDetails.GetNextToken();
1687 wxSVNDPropName = wSTVendorDetails.GetNextToken();
1692 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1694 ContactDatav3.AddRaw(wxT("X-VCARD4-") + wxSProperty, wxSPropertySeg2);
1698 ContactDatav3.AddRaw(wxT("X-VCARD4-") + wxSProperty + wxT(";") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
1702 } else if (wxSProperty.Mid(0, 2) == wxT("X-")){
1704 size_t intPrevValue = (wxSProperty.Len() + 1);
1706 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1708 ContactDatav3.AddRaw(wxSProperty, wxSPropertySeg2);
1712 ContactDatav3.AddRaw(wxSProperty + wxT(";") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
1716 } else if (wxSProperty.Mid(0, 12) == wxT("CLIENTPIDMAP")){
1718 // Process the Client PID maps.
1720 int intPrevValue = 14;
1724 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1726 ContactDatav3.AddRaw(wxT("X-VCARD4-CLIENTPIDMAP"), wxSPropertySeg2);
1730 ContactDatav3.AddRaw(wxT("X-VCARD4-CLIENTPIDMAP;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
1734 } else if (wxSProperty.Mid(0, 3) == wxT("XML")){
1736 // Process the XML values.
1738 int intPrevValue = 5;
1742 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1744 ContactDatav3.AddRaw(wxT("X-VCARD4-XML"), wxSPropertySeg2);
1748 ContactDatav3.AddRaw(wxT("X-VCARD4-XML;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
1752 } else if (wxSProperty.Mid(0, 6) == wxT("SOURCE")){
1754 // Process the source links.
1756 int intPrevValue = 8;
1760 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1762 ContactDatav3.AddRaw(wxT("X-VCARD4-SOURCE"), wxSPropertySeg2);
1766 ContactDatav3.AddRaw(wxT("X-VCARD4-SOURCE;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
1772 // Reset the variables.
1775 PropertyFind = TRUE;
1776 ExtraLineSeek = TRUE;
1778 QuoteBreakPoint = 0;
1779 ContactLine.Clear();
1780 wxSProperty.Clear();
1784 ContactDatav3.AddRaw(wxT("END"), wxT("VCARD"));
1785 *wxSData = ContactDatav3.WriteString();