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 // Check if we are using wxWidgets version 2.8 or less and
44 // execute the required command accordingly.
46 #if wxABI_VERSION < 20900
47 ContactFile.Open(Filename.c_str(), wxT("r"));
49 ContactFile.Open(Filename, wxT("r"));
52 if (ContactFile.IsOpened() == FALSE){
58 ContactFile.ReadAll(&wxSContactString, wxConvAuto());
62 std::map<int, wxString> ContactFileLines;
63 std::map<int, wxString>::iterator striter;
65 wxStringTokenizer wSTContactFileLines(wxSContactString, wxT("\r\n"));
67 int ContactLineSeek = 0;
69 while (wSTContactFileLines.HasMoreTokens() == TRUE){
71 ContactLine = wSTContactFileLines.GetNextToken();
72 ContactFileLines.insert(std::make_pair(ContactLineSeek, ContactLine));
79 bool QuoteMode = FALSE;
80 bool PropertyFind = TRUE;
81 bool ExtraLineSeek = TRUE;
82 bool BirthdayProcessed = FALSE;
83 bool AnniversaryProcessed = FALSE;
84 bool GenderProcessed = FALSE;
85 bool NameProcessed = FALSE;
86 bool KindProcessed = FALSE;
88 bool NicknameFirst = FALSE;
89 bool TitleFirst = FALSE;
90 bool OrganisationFirst = FALSE;
91 bool NoteFirst = FALSE;
92 bool PhotoFirst = FALSE;
94 wxString wxSPropertySeg1;
95 wxString wxSPropertySeg2;
96 wxString wxSPropertyNextLine;
97 size_t ContactLineLen = 0;
98 int QuoteBreakPoint = 0;
103 // Setup the version string.
105 strVer.Append(wxT("-//Xestia//Address Book Version "));
106 strVer.Append(wxT(XSDAB_VERSION));
107 strVer.Append(wxT("//KW"));
109 ContactDatav3.AddRaw(wxT("BEGIN"), wxT("VCARD"));
110 ContactDatav3.AddRaw(wxT("VERSION"), wxT("3.0"));
111 ContactDatav3.AddRaw(wxT("PRODID"), strVer);
113 for (std::map<int,wxString>::iterator iter = ContactFileLines.begin();
114 iter != ContactFileLines.end(); ++iter){
116 // Find the colon which splits the start bit from the data part.
118 ContactLine = iter->second;
120 while (ExtraLineSeek == TRUE){
122 // Check if there is extra data on the next line
123 // (indicated by space or tab at the start) and add data.
127 if (iter == ContactFileLines.end()){
134 wxSPropertyNextLine = iter->second;
137 if (wxSPropertyNextLine.Mid(0, 1) == wxT(" ") || wxSPropertyNextLine.Mid(0, 1) == wxT("\t")){
139 wxSPropertyNextLine.Remove(0, 1);
140 ContactLine.Append(wxSPropertyNextLine);
145 ExtraLineSeek = FALSE;
151 ContactLineLen = ContactLine.Len();
153 // Make sure we are not in quotation mode.
154 // Make sure colon does not have \ or \\ before it.
158 for (int i = 0; i <= ContactLineLen; i++){
160 if ((ContactLine.Mid(i, 1) == wxT(";") || ContactLine.Mid(i, 1) == wxT(":")) && PropertyFind == TRUE){
162 PropertyFind = FALSE;
164 } else if (PropertyFind == TRUE){
166 wxSProperty.Append(ContactLine.Mid(i, 1));
170 if (ContactLine.Mid(i, 1) == wxT("\"")){
172 if (QuoteMode == TRUE){
184 if (ContactLine.Mid(i, 1) == wxT(":") && ContactLine.Mid((i - 1), 1) != wxT("\\") && QuoteMode == FALSE){
193 // Split that line at the point into two variables (ignore the colon).
195 wxSPropertySeg1 = ContactLine.Mid(0, QuoteBreakPoint);
196 wxSPropertySeg2 = ContactLine.Mid((QuoteBreakPoint + 1));
198 // Add the data into the contact editor depending on what it is.
200 if (wxSProperty == wxT("FN")){
202 std::map<int, int> SplitPoints;
203 std::map<int, int> SplitLength;
204 std::map<int, int>::iterator SLiter;
205 wxString PropertyData;
206 wxString PropertyName;
207 wxString PropertyValue;
208 wxString PropertyTokens;
209 int intPrevValue = 4;
213 if (FNFirst == FALSE){
215 ContactDatav3.AddRaw(wxT("FN"), wxSPropertySeg2);
217 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
221 ContactDatav3.AddRaw(wxT("X-VCARD4-FN;X-FIRST=TRUE;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
228 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
230 ContactDatav3.AddRaw(wxT("X-VCARD4-FN"), wxSPropertySeg2);
234 ContactDatav3.AddRaw(wxT("X-VCARD4-FN;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))),
241 } else if (wxSProperty == wxT("N") && NameProcessed == FALSE){
243 std::map<int, int> SplitPoints;
244 std::map<int, int> SplitLength;
245 std::map<int, int>::iterator SLiter;
246 wxString PropertyData;
247 wxString PropertyName;
248 wxString PropertyValue;
249 wxString PropertyTokens;
250 int intPrevValue = 3;
254 ContactDatav3.AddRaw(wxT("N"), wxSPropertySeg2);
256 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
262 ContactDatav3.AddRaw(wxT("X-VCARD4-N;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxT(""));
266 NameProcessed = TRUE;
268 } else if (wxSProperty == wxT("KIND") && KindProcessed == FALSE){
272 std::map<int, int> SplitPoints;
273 std::map<int, int> SplitLength;
274 std::map<int, int>::iterator SLiter;
275 wxString PropertyData;
276 wxString PropertyName;
277 wxString PropertyValue;
278 wxString PropertyTokens;
280 ContactDatav3.AddRaw(wxT("X-ADDRESSBOOKSERVER-KIND"), wxSPropertySeg2);
282 KindProcessed = TRUE;
284 } else if (wxSProperty == wxT("MEMBER")){
288 std::map<int, int> SplitPoints;
289 std::map<int, int> SplitLength;
290 std::map<int, int>::iterator SLiter;
291 wxString PropertyData;
292 wxString PropertyName;
293 wxString PropertyValue;
294 wxString PropertyTokens;
296 ContactDatav3.AddRaw(wxT("X-ADDRESSBOOKSERVER-MEMBER"), wxSPropertySeg2);
298 } else if (wxSProperty == wxT("NICKNAME")){
300 std::map<int, int> SplitPoints;
301 std::map<int, int> SplitLength;
302 std::map<int, int>::iterator SLiter;
303 wxString PropertyData;
304 wxString PropertyName;
305 wxString PropertyValue;
306 wxString PropertyTokens;
307 int intPrevValue = 10;
311 if (NicknameFirst == FALSE){
313 ContactDatav3.AddRaw(wxT("NICKNAME"), wxSPropertySeg2);
315 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
319 ContactDatav3.AddRaw(wxT("X-VCARD4-NICKNAME;X-FIRST=TRUE;")
320 + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxT(""));
323 NicknameFirst = TRUE;
328 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
330 ContactDatav3.AddRaw(wxT("X-VCARD4-NICKNAME"), wxSPropertySeg2);
334 ContactDatav3.AddRaw(wxT("X-VCARD4-NICKNAME;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))) + wxT(":"),
342 } else if (wxSProperty == wxT("GENDER") && GenderProcessed == FALSE){
344 // Do PID/ALTID/LANG things.
346 std::map<int, int> SplitPoints;
347 std::map<int, int> SplitLength;
348 std::map<int, int>::iterator SLiter;
349 wxString PropertyData;
350 wxString PropertyName;
351 wxString PropertyValue;
352 wxString PropertyTokens;
353 int intPrevValue = 8;
358 if (wxSPropertySeg2.Mid(1, 1) == wxT(";")){
360 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
362 ContactDatav3.AddRaw(wxT("X-VCARD4-GENDER;X-GENDERTEXT=\"") + wxSPropertySeg2.Mid(2) + wxT("\""), wxSPropertySeg2.Mid(0, 1));
366 ContactDatav3.AddRaw(wxT("X-VCARD4-GENDER;X-GENDERTEXT=\"") + wxSPropertySeg2.Mid(2) + wxT("\";")
367 + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))),
368 wxSPropertySeg2.Mid(0, 1));
374 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
376 ContactDatav3.AddRaw(wxT("X-VCARD4-GENDER"), wxSPropertySeg2);
380 ContactDatav3.AddRaw(wxT("X-VCARD4-GENDER;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
386 GenderProcessed = TRUE;
388 } else if (wxSProperty == wxT("BDAY") && BirthdayProcessed == FALSE){
390 // Process date. Preserve the remainder in the string.
392 std::map<int, int> SplitPoints;
393 std::map<int, int> SplitLength;
394 std::map<int, int>::iterator SLiter;
395 wxString PropertyData;
396 wxString PropertyName;
397 wxString PropertyValue;
398 wxString PropertyTokens;
400 int intPrevValue = 6;
406 // Look for type before continuing.
408 if (wxSPropertySeg2.Mid(0, 2) == wxT("--")){
410 strResults.Append(wxT("1604-"));
413 strResults.Append(wxSPropertySeg2.Mid(2, 2) + wxT("-"));
414 strResults.Append(wxSPropertySeg2.Mid(4, 2));
418 strResults.Append(wxSPropertySeg2.Mid(0, 4) + wxT("-"));
419 strResults.Append(wxSPropertySeg2.Mid(4, 2) + wxT("-"));
420 strResults.Append(wxSPropertySeg2.Mid(6, 2));
428 ContactDatav3.AddRaw(wxT("BDAY;X-APPLE-OMIT-YEAR=1604"), strResults);
430 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
432 ContactDatav3.AddRaw(wxT("X-VCARD4-BDAY"), wxSPropertySeg2);
436 ContactDatav3.AddRaw(wxT("X-VCARD4-BDAY;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
442 ContactDatav3.AddRaw(wxT("BDAY"), strResults);
444 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
446 ContactDatav3.AddRaw(wxT("X-VCARD4-BDAY"), wxSPropertySeg2);
450 ContactDatav3.AddRaw(wxT("X-VCARD4-BDAY;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
456 BirthdayProcessed = TRUE;
458 } else if (wxSProperty == wxT("ANNIVERSARY") && AnniversaryProcessed == FALSE){
460 // Process date. Preserve the remainder in the string.
462 std::map<int, int> SplitPoints;
463 std::map<int, int> SplitLength;
464 std::map<int, int>::iterator SLiter;
465 wxString PropertyData;
466 wxString PropertyName;
467 wxString PropertyValue;
468 wxString PropertyTokens;
469 int intPrevValue = 13;
476 // Look for type before continuing.
478 if (wxSPropertySeg2.Mid(0, 2) == wxT("--")){
480 strResults.Append(wxT("1604-"));
483 strResults.Append(wxSPropertySeg2.Mid(2, 2) + wxT("-"));
484 strResults.Append(wxSPropertySeg2.Mid(4, 2));
488 strResults.Append(wxSPropertySeg2.Mid(0, 4) + wxT("-"));
489 strResults.Append(wxSPropertySeg2.Mid(4, 2) + wxT("-"));
490 strResults.Append(wxSPropertySeg2.Mid(6, 2));
496 ContactDatav3.AddRaw(wxT("ANNIVERSARY;X-APPLE-OMIT-YEAR=1604"), strResults);
498 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
500 ContactDatav3.AddRaw(wxT("X-VCARD4-ANNIVERSARY"), wxSPropertySeg2);
504 ContactDatav3.AddRaw(wxT("X-VCARD4-ANNIVERSARY;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
510 ContactDatav3.AddRaw(wxT("ANNIVERSARY"), strResults);
512 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
514 ContactDatav3.AddRaw(wxT("X-VCARD4-ANNIVERSARY"), wxSPropertySeg2);
518 ContactDatav3.AddRaw(wxT("X-VCARD4-ANNIVERSARY;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
524 AnniversaryProcessed = TRUE;
526 } else if (wxSProperty == wxT("TZ")){
528 std::map<int, int> SplitPoints;
529 std::map<int, int> SplitLength;
530 std::map<int, int>::iterator SLiter;
531 wxString PropertyData;
532 wxString PropertyName;
533 wxString PropertyValue;
534 wxString PropertyTokens;
535 int intPrevValue = 4;
539 // Look for type before continuing.
541 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
543 ContactDatav3.AddRaw(wxT("X-VCARD4-TZ"), wxSPropertySeg2);
547 ContactDatav3.AddRaw(wxT("X-VCARD4-TZ;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
551 } else if (wxSProperty == wxT("ADR")){
553 std::map<int, int> SplitPoints;
554 std::map<int, int> SplitLength;
555 std::map<int, int>::iterator SLiter;
556 wxString PropertyData;
557 wxString PropertyName;
558 wxString PropertyValue;
559 wxString PropertyTokens;
560 wxString AddressLabel;
561 wxString AddressLang;
562 wxString AddressAltID;
564 wxString AddressTokens;
566 wxString AddressTimezone;
567 wxString AddressType;
568 wxString AddressMediatype;
569 wxString AddressPOBox;
570 wxString AddressExtended;
571 wxString AddressStreet;
572 wxString AddressLocality;
573 wxString AddressCity;
574 wxString AddressRegion;
575 wxString AddressPostalCode;
576 wxString AddressCountry;
577 int intPrevValue = 5;
581 // TODO: Check in value for X-ABLabel and use it if it is there.
583 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
585 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".ADR"), wxSPropertySeg2);
586 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), _("Address"));
587 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-ADR"), wxSPropertySeg2);
591 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".ADR"), wxSPropertySeg2);
592 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), _("Address"));
593 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-ADR;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
599 } else if (wxSProperty == wxT("EMAIL")){
601 // TODO: Continue from here! See ADR for good example (Replace initer with intPrevValue).
602 // Remove inserted comma for Extra Tokens in frmContactEditor.cpp
604 std::map<int, int> SplitPoints;
605 std::map<int, int> SplitLength;
606 std::map<int, int>::iterator SLiter;
607 std::map<int, int>::iterator SPoint;
608 wxString PropertyData;
609 wxString PropertyName;
610 wxString PropertyValue;
611 wxString PropertyTokens;
612 wxString AddressLabel;
613 wxString AddressLang;
614 wxString AddressAltID;
616 wxString AddressTokens;
618 wxString AddressTimezone;
619 wxString AddressType;
620 wxString AddressMediatype;
621 wxString AddressPOBox;
622 wxString AddressExtended;
623 wxString AddressStreet;
624 wxString AddressLocality;
625 wxString AddressCity;
626 wxString AddressRegion;
627 wxString AddressPostalCode;
628 wxString AddressCountry;
629 int intPrevValue = 7;
633 // TODO: Check in value for X-ABLabel and use it if it is there.
635 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
637 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".EMAIL"), wxSPropertySeg2);
638 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), _("E-mail Address"));
639 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-EMAIL"), wxSPropertySeg2);
643 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".EMAIL"), wxSPropertySeg2);
644 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), _("E-mail Address"));
645 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-EMAIL;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
651 } else if (wxSProperty == wxT("IMPP")){
653 std::map<int, int> SplitPoints;
654 std::map<int, int> SplitLength;
655 std::map<int, int>::iterator SLiter;
656 std::map<int, int>::iterator SPoint;
657 wxString PropertyData;
658 wxString PropertyName;
659 wxString PropertyValue;
660 wxString PropertyTokens;
662 wxString IMPPAddress;
663 int intPrevValue = 6;
665 SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
669 // TODO: Check in value for X-ABLabel and use it if it is there.
671 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
673 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".IMPP"), wxSPropertySeg2);
674 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), _("Instant Message"));
675 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-IMPP"), wxSPropertySeg2);
679 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".IMPP"), wxSPropertySeg2);
680 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), _("Instant Message"));
681 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-IMPP;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
687 } else if (wxSProperty == wxT("TEL")){
689 // Check TEL and make sure it is functioning properly.
691 std::map<int, int> SplitPoints;
692 std::map<int, int> SplitLength;
693 std::map<int, int> TypeSplitPoints;
694 std::map<int, int> TypeSplitLength;
695 std::map<int, int>::iterator SLiter;
696 std::map<int, int>::iterator SPoint;
697 std::map<int, int>::iterator TSLiter;
698 std::map<int, int>::iterator TSPoint;
699 wxString PropertyData;
700 wxString PropertyName;
701 wxString PropertyValue;
702 wxString PropertyTokens;
706 wxString TelTypeDetail;
708 wxString FinalFriendlyString;
709 int intSplitsFound = 0;
710 int intSplitSize = 0;
711 int intPrevValue = 5;
712 int intSplitPoint = 0;
716 SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
718 // Look for type before continuing.
720 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
721 intiter != SplitPoints.end(); ++intiter){
723 SLiter = SplitLength.find(intiter->first);
725 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
727 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
728 PropertyName = PropertyElement.GetNextToken();
729 PropertyValue = PropertyElement.GetNextToken();
731 intPrevValue = intiter->second;
733 if (PropertyName == wxT("TYPE")){
735 // Process each value in type and translate each
738 // Strip out the quotes if they are there.
740 size_t intPropertyValueLen = PropertyValue.Len();
742 if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
744 PropertyValue.Trim();
745 PropertyValue.RemoveLast();
749 if (PropertyValue.Mid(0, 1) == wxT("\"")){
751 PropertyValue.Remove(0, 1);
755 TelTypeDetail = PropertyValue;
761 for (int i = 0; i <= intPropertyValueLen; i++){
765 if (PropertyValue.Mid(i, 1) == wxT(",") && PropertyValue.Mid((i - 1), 1) != wxT("\\")){
767 if (intSplitsFound == 0){
769 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
770 TypeSplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
774 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
775 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
788 TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
789 TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
793 for (std::map<int, int>::iterator typeiter = TypeSplitPoints.begin();
794 typeiter != TypeSplitPoints.end(); ++typeiter){
796 wxString TypePropertyName;
798 TSLiter = TypeSplitLength.find(typeiter->first);
800 TypePropertyName = PropertyValue.Mid(typeiter->second, TSLiter->second);
802 if (intTypeSeek == 0){
807 TelTypeUI.Append(wxT(","));
811 if (TypePropertyName == wxT("text")){
813 if (!FinalFriendlyString.IsEmpty()){ FinalFriendlyString.Append(_(", Text")); } else { FinalFriendlyString.Append(_("Text")); }
815 TelTypeOut.Append(wxT(";"));
816 TelTypeOut.Append(wxT("type=TEXT"));
818 } else if (TypePropertyName == wxT("voice")){
820 if (!FinalFriendlyString.IsEmpty()){ FinalFriendlyString.Append(_(", Voice")); } else { FinalFriendlyString.Append(_("Voice")); }
822 TelTypeOut.Append(wxT(";"));
823 TelTypeOut.Append(wxT("type=VOICE"));
827 } else if (TypePropertyName == wxT("fax")){
829 if (!FinalFriendlyString.IsEmpty()){ FinalFriendlyString.Append(_(", Fax")); } else { FinalFriendlyString.Append(_("Fax")); }
831 TelTypeOut.Append(wxT(";"));
832 TelTypeOut.Append(wxT("type=FAX"));
835 } else if (TypePropertyName == wxT("cell")){
837 if (!FinalFriendlyString.IsEmpty()){ FinalFriendlyString.Append(_(", Mobile")); } else { FinalFriendlyString.Append(_("Mobile")); }
839 TelTypeOut.Append(wxT(";"));
840 TelTypeOut.Append(wxT("type=CELL"));
843 } else if (TypePropertyName == wxT("video")){
845 if (!FinalFriendlyString.IsEmpty()){ FinalFriendlyString.Append(_(", Video")); } else { FinalFriendlyString.Append(_("Video")); }
847 TelTypeOut.Append(wxT(";"));
848 TelTypeOut.Append(wxT("type=VIDEO"));
851 } else if (TypePropertyName == wxT("pager")){
853 if (!FinalFriendlyString.IsEmpty()){ FinalFriendlyString.Append(_(", Pager")); } else { FinalFriendlyString.Append(_("Pager")); }
855 TelTypeOut.Append(wxT(";"));
856 TelTypeOut.Append(wxT("type=PAGER"));
859 } else if (TypePropertyName == wxT("textphone")){
861 if (!FinalFriendlyString.IsEmpty()){ FinalFriendlyString.Append(_(", Textphone")); } else { FinalFriendlyString.Append(_("Textphone")); }
863 TelTypeOut.Append(wxT(";"));
864 TelTypeOut.Append(wxT("type=TEXTPHONE"));
881 // Remove 'tel:' if it is being used.
883 if (wxSPropertySeg2.Mid(0, 4) == wxT("tel:")){
885 FinalTel = wxSPropertySeg2.Mid(4);
889 FinalTel = wxSPropertySeg2;
893 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
895 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".TEL") + TelTypeOut, FinalTel);
896 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), FinalFriendlyString);
897 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-TEL"), wxSPropertySeg2);
901 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".TEL") + TelTypeOut, FinalTel);
902 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), FinalFriendlyString);
903 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-TEL;") + wxSPropertySeg1.Mid(4), wxSPropertySeg2);
909 } else if (wxSProperty == wxT("LANG")){
911 std::map<int, int> SplitPoints;
912 std::map<int, int> SplitLength;
913 std::map<int, int>::iterator SLiter;
914 wxString PropertyData;
915 wxString PropertyName;
916 wxString PropertyValue;
917 wxString PropertyTokens;
918 int intPrevValue = 6;
922 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
924 ContactDatav3.AddRaw(wxT("X-VCARD4-LANG"), wxSPropertySeg2);
928 ContactDatav3.AddRaw(wxT("X-VCARD4-LANG;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
932 } else if (wxSProperty == wxT("GEO")){
934 std::map<int, int> SplitPoints;
935 std::map<int, int> SplitLength;
936 std::map<int, int>::iterator SLiter;
937 wxString PropertyData;
938 wxString PropertyName;
939 wxString PropertyValue;
940 wxString PropertyTokens;
943 int intPrevValue = 5;
947 SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
949 wxString strFinalGeoValue;
950 wxString strFinalType;
952 if (wxSPropertySeg2.Mid(0, 3) == wxT("geo")){
954 strFinalGeoValue = wxSPropertySeg2.Mid(5);
955 strFinalType = wxT("geo");
959 wxStringTokenizer wSTSplit(wxSPropertySeg2, wxT(":"));
960 strFinalType = wSTSplit.GetNextToken();
961 strFinalGeoValue = wSTSplit.GetNextToken();
965 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
967 ContactDatav3.AddRaw(wxT("X-VCARD4-GEO;X-GEOTYPE=") + strFinalType, wxSPropertySeg2);
971 ContactDatav3.AddRaw(wxT("X-VCARD4-GEO;X-GEOTYPE=") + strFinalType + wxT(";") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
975 } else if (wxSProperty == wxT("RELATED")){
977 std::map<int, int> SplitPoints;
978 std::map<int, int> SplitLength;
979 std::map<int, int>::iterator SLiter;
980 wxString PropertyData;
981 wxString PropertyName;
982 wxString PropertyValue;
983 wxString PropertyTokens;
984 wxString RelatedType;
985 wxString RelatedTypeOriginal;
986 wxString RelatedName;
987 bool FirstToken = TRUE;
988 int intPrevValue = 9;
992 SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
996 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
997 intiter != SplitPoints.end(); ++intiter){
999 SLiter = SplitLength.find(intiter->first);
1001 PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second - 1));
1003 wxStringTokenizer PropertyElement (PropertyData, wxT("="));
1004 PropertyName = PropertyElement.GetNextToken();
1005 PropertyValue = PropertyElement.GetNextToken();
1007 if (PropertyName == wxT("TYPE") && FirstToken == TRUE){
1009 if (PropertyValue == wxT("contact")){
1011 strDetail = _("Contact");
1013 } else if (PropertyValue == wxT("acquaintance")){
1015 strDetail = _("Acquaintance");
1017 } else if (PropertyValue == wxT("friend")){
1019 strDetail = _("Friend");
1021 } else if (PropertyValue == wxT("met")){
1023 strDetail = _("Met");
1025 } else if (PropertyValue == wxT("co-worker")){
1027 strDetail = _("Co-worker");
1029 } else if (PropertyValue == wxT("colleague")){
1031 strDetail = _("Colleague");
1033 } else if (PropertyValue == wxT("co-resident")){
1035 strDetail = _("Co-resident");
1037 } else if (PropertyValue == wxT("neighbor")){
1039 strDetail = _("Neighbour");
1041 } else if (PropertyValue == wxT("child")){
1043 strDetail = _("Child");
1045 } else if (PropertyValue == wxT("parent")){
1047 strDetail = _("Parent");
1049 } else if (PropertyValue == wxT("sibling")){
1051 strDetail = _("Sibling");
1053 } else if (PropertyValue == wxT("spouse")){
1055 strDetail = _("Spouse");
1057 } else if (PropertyValue == wxT("kin")){
1059 strDetail = _("Kin");
1061 } else if (PropertyValue == wxT("muse")){
1063 strDetail = _("Muse");
1065 } else if (PropertyValue == wxT("crush")){
1067 strDetail = _("Crush");
1069 } else if (PropertyValue == wxT("date")){
1071 strDetail = _("Date");
1073 } else if (PropertyValue == wxT("sweetheart")){
1075 strDetail = _("Sweetheart");
1077 } else if (PropertyValue == wxT("me")){
1079 strDetail = _("Me");
1081 } else if (PropertyValue == wxT("agent")){
1083 strDetail = _("Agent");
1085 } else if (PropertyValue == wxT("emergency")){
1087 strDetail = _("Emergency");
1091 strDetail = PropertyValue;
1101 if (strDetail.IsEmpty()){
1103 strDetail = _("Relation");
1107 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1109 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABRELATEDNAMES"), wxSPropertySeg2);
1110 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), strDetail);
1111 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-RELATED"), wxSPropertySeg2);
1115 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABRELATEDNAMES"), wxSPropertySeg2);
1116 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), strDetail);
1117 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-RELATED;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
1123 } else if (wxSProperty == wxT("URL")){
1125 std::map<int, int> SplitPoints;
1126 std::map<int, int> SplitLength;
1127 std::map<int, int>::iterator SLiter;
1128 wxString PropertyData;
1129 wxString PropertyName;
1130 wxString PropertyValue;
1131 wxString PropertyTokens;
1132 int intPrevValue = 5;
1136 // Todo: Check for X-ABLabel.
1138 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1140 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".URL"), wxSPropertySeg2);
1141 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), _("URL"));
1142 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-URL"), wxSPropertySeg2);
1146 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".URL"), wxSPropertySeg2);
1147 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), _("URL"));
1148 ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-URL;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
1154 } else if (wxSProperty == wxT("TITLE")) {
1156 std::map<int, int> SplitPoints;
1157 std::map<int, int> SplitLength;
1158 std::map<int, int>::iterator SLiter;
1159 wxString PropertyData;
1160 wxString PropertyName;
1161 wxString PropertyValue;
1162 wxString PropertyTokens;
1163 int intPrevValue = 7;
1167 // Look for type before continuing.
1169 if (TitleFirst == FALSE){
1171 ContactDatav3.AddRaw(wxT("TITLE"), wxSPropertySeg2);
1173 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1177 ContactDatav3.AddRaw(wxT("X-VCARD4-TITLE;X-FIRST=TRUE;")
1178 + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxT(""));
1186 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1188 ContactDatav3.AddRaw(wxT("X-VCARD4-TITLE"), wxSPropertySeg2);
1192 ContactDatav3.AddRaw(wxT("X-VCARD4-TITLE;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))) + wxT(":"),
1199 } else if (wxSProperty == wxT("ROLE")) {
1201 std::map<int, int> SplitPoints;
1202 std::map<int, int> SplitLength;
1203 std::map<int, int>::iterator SLiter;
1204 wxString PropertyData;
1205 wxString PropertyName;
1206 wxString PropertyValue;
1207 wxString PropertyTokens;
1208 int intPrevValue = 6;
1212 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1214 ContactDatav3.AddRaw(wxT("X-VCARD4-ROLE"), wxSPropertySeg2);
1218 ContactDatav3.AddRaw(wxT("X-VCARD4-ROLE;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
1222 } else if (wxSProperty == wxT("ORG")) {
1224 std::map<int, int> SplitPoints;
1225 std::map<int, int> SplitLength;
1226 std::map<int, int>::iterator SLiter;
1227 wxString PropertyData;
1228 wxString PropertyName;
1229 wxString PropertyValue;
1230 wxString PropertyTokens;
1231 int intPrevValue = 5;
1235 if (OrganisationFirst == FALSE){
1237 ContactDatav3.AddRaw(wxT("ORG"), wxSPropertySeg2);
1239 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1243 ContactDatav3.AddRaw(wxT("X-VCARD4-ORG;X-FIRST=TRUE;")
1244 + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxT(""));
1247 OrganisationFirst = TRUE;
1252 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1254 ContactDatav3.AddRaw(wxT("X-VCARD4-ORG"), wxSPropertySeg2);
1258 ContactDatav3.AddRaw(wxT("X-VCARD4-ORG;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))) + wxT(":"),
1265 } else if (wxSProperty == wxT("NOTE")) {
1267 std::map<int, int> SplitPoints;
1268 std::map<int, int> SplitLength;
1269 std::map<int, int>::iterator SLiter;
1270 wxString PropertyData;
1271 wxString PropertyName;
1272 wxString PropertyValue;
1273 wxString PropertyTokens;
1274 int intPrevValue = 6;
1278 if (NoteFirst == FALSE){
1280 ContactDatav3.AddRaw(wxT("NOTE"), wxSPropertySeg2);
1282 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1286 ContactDatav3.AddRaw(wxT("X-VCARD4-NOTE;X-FIRST=TRUE;")
1287 + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxT(""));
1295 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1297 ContactDatav3.AddRaw(wxT("X-VCARD4-NOTE"), wxSPropertySeg2);
1301 ContactDatav3.AddRaw(wxT("X-VCARD4-NOTE;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))) + wxT(":"),
1308 } else if (wxSProperty == wxT("CATEGORIES")) {
1310 std::map<int, int> SplitPoints;
1311 std::map<int, int> SplitLength;
1312 std::map<int, int>::iterator SLiter;
1313 wxString PropertyData;
1314 wxString PropertyName;
1315 wxString PropertyValue;
1316 wxString PropertyTokens;
1317 wxString PropertyType;
1318 int intPrevValue = 12;
1322 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1324 ContactDatav3.AddRaw(wxT("X-VCARD4-CATEGORIES"), wxSPropertySeg2);
1328 ContactDatav3.AddRaw(wxT("X-VCARD4-CATEGORIES;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
1332 } else if (wxSProperty == wxT("PHOTO")) {
1334 size_t intPropertyLen = wxSPropertySeg1.Len();
1335 std::map<int, int> SplitPoints;
1336 std::map<int, int> SplitLength;
1337 std::map<int, int>::iterator SLiter;
1338 wxString PropertyData;
1339 wxString PropertyName;
1340 wxString PropertyValue;
1341 wxString PropertyTokens;
1342 int intSplitsFound = 0;
1343 int intSplitSize = 0;
1344 int intPrevValue = 7;
1346 intPropertyLen = wxSPropertySeg2.Len();
1347 SplitPoints.clear();
1348 SplitLength.clear();
1352 CaptureString(&wxSPropertySeg2, FALSE);
1354 for (int i = 0; i <= intPropertyLen; i++){
1358 if (wxSPropertySeg2.Mid(i, 1) == wxT(";")){
1361 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
1363 if (intSplitsFound == 6){
1365 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1370 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1380 wxString wxSPhotoURI;
1381 wxString wxSPhotoMIME;
1382 wxString wxSPhotoEncoding;
1383 wxString wxSPhotoData;
1384 std::string base64enc;
1386 if (intSplitsFound == 0){
1390 std::map<int, int>::iterator striter;
1392 striter = SplitLength.find(1);
1394 wxStringTokenizer wSTDataType(wxSPropertySeg2.Mid(0, striter->second), wxT(":"));
1396 while (wSTDataType.HasMoreTokens() == TRUE){
1398 wxSPhotoURI = wSTDataType.GetNextToken();
1399 wxSPhotoMIME = wSTDataType.GetNextToken();
1404 wxStringTokenizer wSTDataInfo(wxSPropertySeg2.Mid((striter->second + 1)), wxT(","));
1406 while (wSTDataInfo.HasMoreTokens() == TRUE){
1408 wxSPhotoEncoding = wSTDataInfo.GetNextToken();
1409 wxSPhotoData = wSTDataInfo.GetNextToken();
1410 base64enc = wxSPhotoData.mb_str();
1418 if (PhotoFirst == FALSE){
1420 bool PhotoKeepData = FALSE;
1422 wxString wxSPhotoMIMEF;
1424 if (wxSPhotoMIME == wxT("image/png")){
1425 wxSPhotoMIMEF = wxT("PNG");
1426 } else if (wxSPhotoMIME == wxT("image/jpeg")){
1427 wxSPhotoMIMEF = wxT("JPEG");
1428 } else if (wxSPhotoMIME == wxT("image/gif")){
1429 wxSPhotoMIMEF = wxT("GIF");
1430 } else if (wxSPhotoMIME == wxT("image/bmp")){
1431 wxSPhotoMIMEF = wxT("BMP");
1433 wxSPhotoMIMEF = wxT("UNKNOWN");
1434 PhotoKeepData = TRUE;
1437 ContactDatav3.AddRaw(wxT("PHOTO;ENCODING=b;TYPE=") + wxSPhotoMIMEF, wxSPhotoData);
1439 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1443 if (PhotoKeepData == TRUE){
1445 ContactDatav3.AddRaw(wxT("X-VCARD4-PHOTO;X-FIRST=TRUE;")
1446 + ContactLine.Mid((intPrevValue - 1), ((QuoteBreakPoint + 1) - (intPrevValue))), wxSPropertySeg2);
1450 ContactDatav3.AddRaw(wxT("X-VCARD4-PHOTO;X-FIRST=TRUE;")
1451 + ContactLine.Mid((intPrevValue - 1), ((QuoteBreakPoint + 1) - (intPrevValue))), wxT(""));
1461 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1463 ContactDatav3.AddRaw(wxT("X-VCARD4-PHOTO"), wxSPropertySeg2);
1467 ContactDatav3.AddRaw(wxT("X-VCARD4-PHOTO;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))) + wxT(":"),
1473 } else if (wxSProperty == wxT("LOGO")) {
1475 std::map<int, int> SplitPoints;
1476 std::map<int, int> SplitLength;
1477 std::map<int, int>::iterator SLiter;
1478 wxString PropertyData;
1479 wxString PropertyName;
1480 wxString PropertyValue;
1481 wxString PropertyTokens;
1482 int intPrevValue = 6;
1486 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1488 ContactDatav3.AddRaw(wxT("X-VCARD4-LOGO"), wxSPropertySeg2);
1492 ContactDatav3.AddRaw(wxT("X-VCARD4-LOGO;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
1496 } else if (wxSProperty == wxT("SOUND")) {
1498 std::map<int, int> SplitPoints;
1499 std::map<int, int> SplitLength;
1500 std::map<int, int>::iterator SLiter;
1501 wxString PropertyData;
1502 wxString PropertyName;
1503 wxString PropertyValue;
1504 wxString PropertyTokens;
1505 int intPrevValue = 7;
1509 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1511 ContactDatav3.AddRaw(wxT("X-VCARD4-SOUND"), wxSPropertySeg2);
1515 ContactDatav3.AddRaw(wxT("X-VCARD4-SOUND;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
1519 } else if (wxSProperty == wxT("CALURI")){
1521 std::map<int, int> SplitPoints;
1522 std::map<int, int> SplitLength;
1523 std::map<int, int>::iterator SLiter;
1524 wxString PropertyData;
1525 wxString PropertyName;
1526 wxString PropertyValue;
1527 wxString PropertyTokens;
1528 int intPrevValue = 8;
1532 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1534 ContactDatav3.AddRaw(wxT("X-VCARD4-CALURI"), wxSPropertySeg2);
1538 ContactDatav3.AddRaw(wxT("X-VCARD4-CALURI;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
1542 } else if (wxSProperty == wxT("CALADRURI")){
1544 std::map<int, int> SplitPoints;
1545 std::map<int, int> SplitLength;
1546 std::map<int, int>::iterator SLiter;
1547 wxString PropertyData;
1548 wxString PropertyName;
1549 wxString PropertyValue;
1550 wxString PropertyTokens;
1551 int intPrevValue = 11;
1555 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1557 ContactDatav3.AddRaw(wxT("X-VCARD4-CALADRURI"), wxSPropertySeg2);
1561 ContactDatav3.AddRaw(wxT("X-VCARD4-CALADRURI;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
1565 } else if (wxSProperty == wxT("FBURL")){
1567 std::map<int, int> SplitPoints;
1568 std::map<int, int> SplitLength;
1569 std::map<int, int>::iterator SLiter;
1570 wxString PropertyData;
1571 wxString PropertyName;
1572 wxString PropertyValue;
1573 wxString PropertyTokens;
1574 int intPrevValue = 7;
1578 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1580 ContactDatav3.AddRaw(wxT("X-VCARD4-FBURL"), wxSPropertySeg2);
1584 ContactDatav3.AddRaw(wxT("X-VCARD4-FBURL;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
1588 } else if (wxSProperty == wxT("KEY")){
1590 std::map<int, int> SplitPoints;
1591 std::map<int, int> SplitLength;
1592 std::map<int, int>::iterator SLiter;
1593 wxString PropertyData;
1594 wxString PropertyName;
1595 wxString PropertyValue;
1596 wxString PropertyTokens;
1597 int intPrevValue = 5;
1601 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1603 ContactDatav3.AddRaw(wxT("X-VCARD4-KEY"), wxSPropertySeg2);
1607 ContactDatav3.AddRaw(wxT("X-VCARD4-KEY;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
1611 } else if (wxSProperty == wxT("UID")){
1613 ContactDatav3.AddRaw(wxT("UID"), wxSPropertySeg2);
1615 } else if (wxSProperty.Mid(0, 3) == wxT("VND")){
1617 // Split the Vendor three ways.
1619 wxStringTokenizer wSTVendorDetails(wxSPropertySeg1, wxT("-"));
1622 wxString wxSVNDPropName;
1624 size_t intPrevValue = (wxSProperty.Len() + 1);
1626 while (wSTVendorDetails.HasMoreTokens() == TRUE){
1628 wSTVendorDetails.GetNextToken();
1629 wxSVNDID = wSTVendorDetails.GetNextToken();
1630 wxSVNDPropName = wSTVendorDetails.GetNextToken();
1635 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1637 ContactDatav3.AddRaw(wxT("X-VCARD4-") + wxSProperty, wxSPropertySeg2);
1641 ContactDatav3.AddRaw(wxT("X-VCARD4-") + wxSProperty + wxT(";") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
1645 } else if (wxSProperty.Mid(0, 2) == wxT("X-")){
1647 size_t intPrevValue = (wxSProperty.Len() + 1);
1649 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1651 ContactDatav3.AddRaw(wxSProperty, wxSPropertySeg2);
1655 ContactDatav3.AddRaw(wxSProperty + wxT(";") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
1659 } else if (wxSProperty.Mid(0, 12) == wxT("CLIENTPIDMAP")){
1661 // Process the Client PID maps.
1663 int intPrevValue = 14;
1667 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1669 ContactDatav3.AddRaw(wxT("X-VCARD4-CLIENTPIDMAP"), wxSPropertySeg2);
1673 ContactDatav3.AddRaw(wxT("X-VCARD4-CLIENTPIDMAP;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
1677 } else if (wxSProperty.Mid(0, 3) == wxT("XML")){
1679 // Process the XML values.
1681 int intPrevValue = 5;
1685 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1687 ContactDatav3.AddRaw(wxT("X-VCARD4-XML"), wxSPropertySeg2);
1691 ContactDatav3.AddRaw(wxT("X-VCARD4-XML;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
1695 } else if (wxSProperty.Mid(0, 6) == wxT("SOURCE")){
1697 // Process the source links.
1699 int intPrevValue = 8;
1703 if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
1705 ContactDatav3.AddRaw(wxT("X-VCARD4-SOURCE"), wxSPropertySeg2);
1709 ContactDatav3.AddRaw(wxT("X-VCARD4-SOURCE;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
1715 // Reset the variables.
1718 PropertyFind = TRUE;
1719 ExtraLineSeek = TRUE;
1721 QuoteBreakPoint = 0;
1722 ContactLine.Clear();
1723 wxSProperty.Clear();
1727 ContactDatav3.AddRaw(wxT("END"), wxT("VCARD"));
1728 *wxSData = ContactDatav3.WriteString();