// vcard34conv-v3conv.cpp - vCard34Conv Object vCard3 conversion subroutines.
//
// (c) 2012-2015 Xestia Software Development.
//
// This file is part of Xestia Address Book.
//
// Xestia Address Book is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by the
// Free Software Foundation, version 3 of the license.
//
// Xestia Address Book is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with Xestia Address Book. If not, see
#include "vcard34conv.h"
#include "vcard.h"
#include "../version.h"
#include "../common/textprocessing.h"
#include
#include
#include
#include
bool vCard34Conv::ConvertToV3(wxString Filename, wxString *wxSData){
wxString V3Data;
wxString V4Data;
// Load the contact into the contact editor.
wxFFile ContactFile;
wxString wxSContactString;
wxString ContactLine;
vCard ContactData;
vCard ContactDatav3;
//wxSContactFilename = Filename;
// Check if we are using wxWidgets version 2.8 or less and
// execute the required command accordingly.
#if wxABI_VERSION < 20900
ContactFile.Open(Filename.c_str(), wxT("r"));
#else
ContactFile.Open(Filename, wxT("r"));
#endif
if (ContactFile.IsOpened() == FALSE){
return FALSE;
}
ContactFile.ReadAll(&wxSContactString, wxConvAuto());
// Split the lines.
std::map ContactFileLines;
std::map::iterator striter;
wxStringTokenizer wSTContactFileLines(wxSContactString, wxT("\r\n"));
int ContactLineSeek = 0;
while (wSTContactFileLines.HasMoreTokens() == TRUE){
ContactLine = wSTContactFileLines.GetNextToken();
ContactFileLines.insert(std::make_pair(ContactLineSeek, ContactLine));
ContactLineSeek++;
}
// Get the line.
bool QuoteMode = FALSE;
bool PropertyFind = TRUE;
bool HasExtraNicknames = FALSE;
bool IgnoreGender = FALSE;
bool ExtraLineSeek = TRUE;
bool BirthdayProcessed = FALSE;
bool AnniversaryProcessed = FALSE;
bool FNProcessed = FALSE;
bool GenderProcessed = FALSE;
bool NameProcessed = FALSE;
bool KindProcessed = FALSE;
bool FNFirst = FALSE;
bool NicknameFirst = FALSE;
bool TitleFirst = FALSE;
bool OrganisationFirst = FALSE;
bool NoteFirst = FALSE;
bool PhotoFirst = FALSE;
bool LogoFirst = FALSE;
int intExtraNickname = 0;
wxString wxSProperty;
wxString wxSPropertySeg1;
wxString wxSPropertySeg2;
wxString wxSPropertyNextLine;
size_t ContactLineLen = 0;
int QuoteBreakPoint = 0;
int FNCount = 0;
int NameCount = 0;
int NicknameCount = 0;
int ADRCount = 0;
int EmailCount = 0;
int IMPPCount = 0;
int TelCount = 0;
int LangCount = 0;
int TZCount = 0;
int GeoCount = 0;
int URLCount = 0;
int RelatedCount = 0;
int TitleCount = 0;
int RoleCount = 0;
int OrgCount = 0;
int NoteCount = 0;
int CategoryCount = 0;
int PhotoCount = 0;
int LogoCount = 0;
int SoundCount = 0;
int CalAdrCount = 0;
int CalReqAdrCount = 0;
int FreeBusyCount = 0;
int KeyCount = 0;
int VendorCount = 0;
int XTokenCount = 0;
int ItemSeek = 1;
//int intValueSeek = 1;
wxString strVer;
// Setup the version string.
strVer.Append(wxT("-//Xestia//Address Book Version "));
strVer.Append(wxT(XSDAB_VERSION));
strVer.Append(wxT("//KW"));
ContactDatav3.AddRaw(wxT("BEGIN"), wxT("VCARD"));
ContactDatav3.AddRaw(wxT("VERSION"), wxT("3.0"));
ContactDatav3.AddRaw(wxT("PRODID"), strVer);
for (std::map::iterator iter = ContactFileLines.begin();
iter != ContactFileLines.end(); ++iter){
// Find the colon which splits the start bit from the data part.
ContactLine = iter->second;
while (ExtraLineSeek == TRUE){
// Check if there is extra data on the next line
// (indicated by space or tab at the start) and add data.
iter++;
if (iter == ContactFileLines.end()){
iter--;
break;
}
wxSPropertyNextLine = iter->second;
if (wxSPropertyNextLine.Mid(0, 1) == wxT(" ") || wxSPropertyNextLine.Mid(0, 1) == wxT("\t")){
wxSPropertyNextLine.Remove(0, 1);
//wxSPropertyNextLine.Trim(FALSE);
//ContactLine.Trim();
ContactLine.Append(wxSPropertyNextLine);
} else {
iter--;
ExtraLineSeek = FALSE;
}
}
ContactLineLen = ContactLine.Len();
// Make sure we are not in quotation mode.
// Make sure colon does not have \ or \\ before it.
wxSProperty.Clear();
for (int i = 0; i <= ContactLineLen; i++){
if ((ContactLine.Mid(i, 1) == wxT(";") || ContactLine.Mid(i, 1) == wxT(":")) && PropertyFind == TRUE){
PropertyFind = FALSE;
} else if (PropertyFind == TRUE){
wxSProperty.Append(ContactLine.Mid(i, 1));
}
if (ContactLine.Mid(i, 1) == wxT("\"")){
if (QuoteMode == TRUE){
QuoteMode = FALSE;
} else {
QuoteMode = TRUE;
}
}
if (ContactLine.Mid(i, 1) == wxT(":") && ContactLine.Mid((i - 1), 1) != wxT("\\") && QuoteMode == FALSE){
QuoteBreakPoint = i;
break;
}
}
// Split that line at the point into two variables (ignore the colon).
wxSPropertySeg1 = ContactLine.Mid(0, QuoteBreakPoint);
wxSPropertySeg2 = ContactLine.Mid((QuoteBreakPoint + 1));
// Add the data into the contact editor depending on what it is.
if (wxSProperty == wxT("FN")){
std::map SplitPoints;
std::map SplitLength;
std::map::iterator SLiter;
wxString PropertyData;
wxString PropertyName;
wxString PropertyValue;
wxString PropertyTokens;
int intPrevValue = 4;
//SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
intPrevValue = 3;
if (FNFirst == FALSE){
ContactDatav3.AddRaw(wxT("FN"), wxSPropertySeg2);
if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
} else {
ContactDatav3.AddRaw(wxT("X-VCARD4-FN;X-FIRST=TRUE;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
}
FNFirst = TRUE;
} else {
if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
ContactDatav3.AddRaw(wxT("X-VCARD4-FN"), wxSPropertySeg2);
} else {
ContactDatav3.AddRaw(wxT("X-VCARD4-FN;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))),
wxSPropertySeg2);
}
}
} else if (wxSProperty == wxT("N") && NameProcessed == FALSE){
std::map SplitPoints;
std::map SplitLength;
std::map::iterator SLiter;
wxString PropertyData;
wxString PropertyName;
wxString PropertyValue;
wxString PropertyTokens;
int intPrevValue = 3;
intPrevValue = 2;
ContactDatav3.AddRaw(wxT("N"), wxSPropertySeg2);
if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
} else {
ContactDatav3.AddRaw(wxT("X-VCARD4-N;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxT(""));
}
NameProcessed = TRUE;
} else if (wxSProperty == wxT("KIND") && KindProcessed == FALSE){
// Process Data.
std::map SplitPoints;
std::map SplitLength;
std::map::iterator SLiter;
wxString PropertyData;
wxString PropertyName;
wxString PropertyValue;
wxString PropertyTokens;
int intPrevValue = 5;
intPrevValue = 4;
ContactDatav3.AddRaw(wxT("X-ADDRESSBOOKSERVER-KIND"), wxSPropertySeg2);
KindProcessed = TRUE;
} else if (wxSProperty == wxT("MEMBER")){
// Process Data.
std::map SplitPoints;
std::map SplitLength;
std::map::iterator SLiter;
wxString PropertyData;
wxString PropertyName;
wxString PropertyValue;
wxString PropertyTokens;
int intPrevValue = 7;
intPrevValue = 6;
ContactDatav3.AddRaw(wxT("X-ADDRESSBOOKSERVER-MEMBER"), wxSPropertySeg2);
} else if (wxSProperty == wxT("NICKNAME")){
std::map SplitPoints;
std::map SplitLength;
std::map::iterator SLiter;
wxString PropertyData;
wxString PropertyName;
wxString PropertyValue;
wxString PropertyTokens;
int intPrevValue = 10;
intPrevValue = 9;
if (NicknameFirst == FALSE){
ContactDatav3.AddRaw(wxT("NICKNAME"), wxSPropertySeg2);
if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
} else {
ContactDatav3.AddRaw(wxT("X-VCARD4-NICKNAME;X-FIRST=TRUE;")
+ ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxT(""));
}
NicknameFirst = TRUE;
ItemSeek++;
} else {
if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
ContactDatav3.AddRaw(wxT("X-VCARD4-NICKNAME"), wxSPropertySeg2);
} else {
ContactDatav3.AddRaw(wxT("X-VCARD4-NICKNAME;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))) + wxT(":"),
wxSPropertySeg2);
}
}
} else if (wxSProperty == wxT("GENDER") && GenderProcessed == FALSE){
// Do PID/ALTID/LANG things.
std::map SplitPoints;
std::map SplitLength;
std::map::iterator SLiter;
wxString PropertyData;
wxString PropertyName;
wxString PropertyValue;
wxString PropertyTokens;
int intPrevValue = 8;
intPrevValue = 7;
if (wxSPropertySeg2.Mid(1, 1) == wxT(";")){
if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
ContactDatav3.AddRaw(wxT("X-VCARD4-GENDER;X-GENDERTEXT=\"") + wxSPropertySeg2.Mid(2) + wxT("\""), wxSPropertySeg2.Mid(0, 1));
} else {
ContactDatav3.AddRaw(wxT("X-VCARD4-GENDER;X-GENDERTEXT=\"") + wxSPropertySeg2.Mid(2) + wxT("\";")
+ ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))),
wxSPropertySeg2.Mid(0, 1));
}
} else {
if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
ContactDatav3.AddRaw(wxT("X-VCARD4-GENDER"), wxSPropertySeg2);
} else {
ContactDatav3.AddRaw(wxT("X-VCARD4-GENDER;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
}
}
GenderProcessed = TRUE;
} else if (wxSProperty == wxT("BDAY") && BirthdayProcessed == FALSE){
// Process date. Preserve the remainder in the string.
std::map SplitPoints;
std::map SplitLength;
std::map::iterator SLiter;
wxString PropertyData;
wxString PropertyName;
wxString PropertyValue;
wxString PropertyTokens;
bool NoYear = FALSE;
int intPrevValue = 6;
wxString strResults;
intPrevValue = 5;
// Look for type before continuing.
if (wxSPropertySeg2.Mid(0, 2) == wxT("--")){
strResults.Append(wxT("1604-"));
NoYear = TRUE;
strResults.Append(wxSPropertySeg2.Mid(2, 2) + wxT("-"));
strResults.Append(wxSPropertySeg2.Mid(4, 2));
} else {
strResults.Append(wxSPropertySeg2.Mid(0, 4) + wxT("-"));
strResults.Append(wxSPropertySeg2.Mid(4, 2) + wxT("-"));
strResults.Append(wxSPropertySeg2.Mid(6, 2));
}
if (NoYear == TRUE){
ContactDatav3.AddRaw(wxT("BDAY;X-APPLE-OMIT-YEAR=1604"), strResults);
if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
ContactDatav3.AddRaw(wxT("X-VCARD4-BDAY"), wxSPropertySeg2);
} else {
ContactDatav3.AddRaw(wxT("X-VCARD4-BDAY;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
}
} else {
ContactDatav3.AddRaw(wxT("BDAY"), strResults);
if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
ContactDatav3.AddRaw(wxT("X-VCARD4-BDAY"), wxSPropertySeg2);
} else {
ContactDatav3.AddRaw(wxT("X-VCARD4-BDAY;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
}
}
BirthdayProcessed = TRUE;
} else if (wxSProperty == wxT("ANNIVERSARY") && AnniversaryProcessed == FALSE){
// Process date. Preserve the remainder in the string.
std::map SplitPoints;
std::map SplitLength;
std::map::iterator SLiter;
wxString PropertyData;
wxString PropertyName;
wxString PropertyValue;
wxString PropertyTokens;
int intPrevValue = 13;
wxString strResults;
bool NoYear = FALSE;
intPrevValue = 12;
// Look for type before continuing.
if (wxSPropertySeg2.Mid(0, 2) == wxT("--")){
strResults.Append(wxT("1604-"));
NoYear = TRUE;
strResults.Append(wxSPropertySeg2.Mid(2, 2) + wxT("-"));
strResults.Append(wxSPropertySeg2.Mid(4, 2));
} else {
strResults.Append(wxSPropertySeg2.Mid(0, 4) + wxT("-"));
strResults.Append(wxSPropertySeg2.Mid(4, 2) + wxT("-"));
strResults.Append(wxSPropertySeg2.Mid(6, 2));
}
if (NoYear == TRUE){
ContactDatav3.AddRaw(wxT("ANNIVERSARY;X-APPLE-OMIT-YEAR=1604"), strResults);
if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
ContactDatav3.AddRaw(wxT("X-VCARD4-ANNIVERSARY"), wxSPropertySeg2);
} else {
ContactDatav3.AddRaw(wxT("X-VCARD4-ANNIVERSARY;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
}
} else {
ContactDatav3.AddRaw(wxT("ANNIVERSARY"), strResults);
if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
ContactDatav3.AddRaw(wxT("X-VCARD4-ANNIVERSARY"), wxSPropertySeg2);
} else {
ContactDatav3.AddRaw(wxT("X-VCARD4-ANNIVERSARY;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
}
}
AnniversaryProcessed = TRUE;
} else if (wxSProperty == wxT("TZ")){
std::map SplitPoints;
std::map SplitLength;
std::map::iterator SLiter;
wxString PropertyData;
wxString PropertyName;
wxString PropertyValue;
wxString PropertyTokens;
int intPrevValue = 4;
intPrevValue = 3;
// Look for type before continuing.
if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
ContactDatav3.AddRaw(wxT("X-VCARD4-TZ"), wxSPropertySeg2);
} else {
ContactDatav3.AddRaw(wxT("X-VCARD4-TZ;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
}
} else if (wxSProperty == wxT("ADR")){
std::map SplitPoints;
std::map SplitLength;
std::map::iterator SLiter;
wxString PropertyData;
wxString PropertyName;
wxString PropertyValue;
wxString PropertyTokens;
wxString AddressLabel;
wxString AddressLang;
wxString AddressAltID;
wxString AddressPID;
wxString AddressTokens;
wxString AddressGeo;
wxString AddressTimezone;
wxString AddressType;
wxString AddressMediatype;
wxString AddressPOBox;
wxString AddressExtended;
wxString AddressStreet;
wxString AddressLocality;
wxString AddressCity;
wxString AddressRegion;
wxString AddressPostalCode;
wxString AddressCountry;
int intPrevValue = 5;
intPrevValue = 4;
// TODO: Check in value for X-ABLabel and use it if it is there.
if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".ADR"), wxSPropertySeg2);
ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), _("Address"));
ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-ADR"), wxSPropertySeg2);
} else {
ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".ADR"), wxSPropertySeg2);
ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), _("Address"));
ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-ADR;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
}
ItemSeek++;
} else if (wxSProperty == wxT("EMAIL")){
// TODO: Continue from here! See ADR for good example (Replace initer with intPrevValue).
// Remove inserted comma for Extra Tokens in frmContactEditor.cpp
std::map SplitPoints;
std::map SplitLength;
std::map::iterator SLiter;
std::map::iterator SPoint;
wxString PropertyData;
wxString PropertyName;
wxString PropertyValue;
wxString PropertyTokens;
wxString AddressLabel;
wxString AddressLang;
wxString AddressAltID;
wxString AddressPID;
wxString AddressTokens;
wxString AddressGeo;
wxString AddressTimezone;
wxString AddressType;
wxString AddressMediatype;
wxString AddressPOBox;
wxString AddressExtended;
wxString AddressStreet;
wxString AddressLocality;
wxString AddressCity;
wxString AddressRegion;
wxString AddressPostalCode;
wxString AddressCountry;
int intPrevValue = 7;
intPrevValue = 6;
// TODO: Check in value for X-ABLabel and use it if it is there.
if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".EMAIL"), wxSPropertySeg2);
ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), _("E-mail Address"));
ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-EMAIL"), wxSPropertySeg2);
} else {
ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".EMAIL"), wxSPropertySeg2);
ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), _("E-mail Address"));
ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-EMAIL;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
}
ItemSeek++;
} else if (wxSProperty == wxT("IMPP")){
std::map SplitPoints;
std::map SplitLength;
std::map::iterator SLiter;
std::map::iterator SPoint;
wxString PropertyData;
wxString PropertyName;
wxString PropertyValue;
wxString PropertyTokens;
wxString IMPPType;
wxString IMPPAddress;
int intPrevValue = 6;
SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
intPrevValue = 5;
// TODO: Check in value for X-ABLabel and use it if it is there.
if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".IMPP"), wxSPropertySeg2);
ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), _("Instant Message"));
ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-IMPP"), wxSPropertySeg2);
} else {
ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".IMPP"), wxSPropertySeg2);
ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), _("Instant Message"));
ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-IMPP;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
}
ItemSeek++;
} else if (wxSProperty == wxT("TEL")){
// Check TEL and make sure it is functioning properly.
std::map SplitPoints;
std::map SplitLength;
std::map TypeSplitPoints;
std::map TypeSplitLength;
std::map::iterator SLiter;
std::map::iterator SPoint;
std::map::iterator TSLiter;
std::map::iterator TSPoint;
wxString PropertyData;
wxString PropertyName;
wxString PropertyValue;
wxString PropertyTokens;
wxString TelType;
wxString TelNumber;
wxString TelTypeUI;
wxString TelTypeDetail;
wxString TelTypeOut;
wxString FinalFriendlyString;
int intSplitsFound = 0;
int intSplitSize = 0;
int intPrevValue = 5;
int intType = 0;
int intSplitPoint = 0;
intPrevValue = 4;
SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
// Look for type before continuing.
for (std::map::iterator intiter = SplitPoints.begin();
intiter != SplitPoints.end(); ++intiter){
SLiter = SplitLength.find(intiter->first);
PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second));
wxStringTokenizer PropertyElement (PropertyData, wxT("="));
PropertyName = PropertyElement.GetNextToken();
PropertyValue = PropertyElement.GetNextToken();
intPrevValue = intiter->second;
if (PropertyName == wxT("TYPE")){
// Process each value in type and translate each
// part.
// Strip out the quotes if they are there.
size_t intPropertyValueLen = PropertyValue.Len();
if (PropertyValue.Mid((intPropertyValueLen - 1), 1) == wxT("\"")){
PropertyValue.Trim();
PropertyValue.RemoveLast();
}
if (PropertyValue.Mid(0, 1) == wxT("\"")){
PropertyValue.Remove(0, 1);
}
TelTypeDetail = PropertyValue;
intSplitSize = 0;
intSplitsFound = 0;
intSplitPoint = 0;
for (int i = 0; i <= intPropertyValueLen; i++){
intSplitSize++;
if (PropertyValue.Mid(i, 1) == wxT(",") && PropertyValue.Mid((i - 1), 1) != wxT("\\")){
if (intSplitsFound == 0){
TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
TypeSplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
} else {
TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
}
intSplitsFound++;
i++;
intSplitPoint = i;
intSplitSize = 0;
}
}
TypeSplitPoints.insert(std::make_pair(intSplitsFound, intSplitPoint));
TypeSplitLength.insert(std::make_pair(intSplitsFound, intSplitSize));
int intTypeSeek = 0;
for (std::map::iterator typeiter = TypeSplitPoints.begin();
typeiter != TypeSplitPoints.end(); ++typeiter){
wxString TypePropertyName;
TSLiter = TypeSplitLength.find(typeiter->first);
TypePropertyName = PropertyValue.Mid(typeiter->second, TSLiter->second);
if (intTypeSeek == 0){
} else {
TelTypeUI.Append(wxT(","));
}
if (TypePropertyName == wxT("home")){
intType = 1;
} else if (TypePropertyName == wxT("work")){
intType = 2;
}
if (TypePropertyName == wxT("text")){
if (!FinalFriendlyString.IsEmpty()){ FinalFriendlyString.Append(_(", Text")); } else { FinalFriendlyString.Append(_("Text")); }
TelTypeOut.Append(wxT(";"));
TelTypeOut.Append(wxT("type=TEXT"));
} else if (TypePropertyName == wxT("voice")){
if (!FinalFriendlyString.IsEmpty()){ FinalFriendlyString.Append(_(", Voice")); } else { FinalFriendlyString.Append(_("Voice")); }
TelTypeOut.Append(wxT(";"));
TelTypeOut.Append(wxT("type=VOICE"));
intTypeSeek++;
} else if (TypePropertyName == wxT("fax")){
if (!FinalFriendlyString.IsEmpty()){ FinalFriendlyString.Append(_(", Fax")); } else { FinalFriendlyString.Append(_("Fax")); }
TelTypeOut.Append(wxT(";"));
TelTypeOut.Append(wxT("type=FAX"));
intTypeSeek++;
} else if (TypePropertyName == wxT("cell")){
if (!FinalFriendlyString.IsEmpty()){ FinalFriendlyString.Append(_(", Mobile")); } else { FinalFriendlyString.Append(_("Mobile")); }
TelTypeOut.Append(wxT(";"));
TelTypeOut.Append(wxT("type=CELL"));
intTypeSeek++;
} else if (TypePropertyName == wxT("video")){
if (!FinalFriendlyString.IsEmpty()){ FinalFriendlyString.Append(_(", Video")); } else { FinalFriendlyString.Append(_("Video")); }
TelTypeOut.Append(wxT(";"));
TelTypeOut.Append(wxT("type=VIDEO"));
intTypeSeek++;
} else if (TypePropertyName == wxT("pager")){
if (!FinalFriendlyString.IsEmpty()){ FinalFriendlyString.Append(_(", Pager")); } else { FinalFriendlyString.Append(_("Pager")); }
TelTypeOut.Append(wxT(";"));
TelTypeOut.Append(wxT("type=PAGER"));
intTypeSeek++;
} else if (TypePropertyName == wxT("textphone")){
//if (!TelTypeOut.IsEmpty()){ TelTypeOut.Append(wxT(";")); }
if (!FinalFriendlyString.IsEmpty()){ FinalFriendlyString.Append(_(", Textphone")); } else { FinalFriendlyString.Append(_("Textphone")); }
TelTypeOut.Append(wxT(";"));
TelTypeOut.Append(wxT("type=TEXTPHONE"));
intTypeSeek++;
}
}
}
}
wxString FinalTel;
// Remove 'tel:' if it is being used.
if (wxSPropertySeg2.Mid(0, 4) == wxT("tel:")){
FinalTel = wxSPropertySeg2.Mid(4);
} else {
FinalTel = wxSPropertySeg2;
}
if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".TEL") + TelTypeOut, FinalTel);
ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), FinalFriendlyString);
ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-TEL"), wxSPropertySeg2);
} else {
ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".TEL") + TelTypeOut, FinalTel);
ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), FinalFriendlyString);
ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-TEL;") + wxSPropertySeg1.Mid(4), wxSPropertySeg2);
}
ItemSeek++;
} else if (wxSProperty == wxT("LANG")){
std::map SplitPoints;
std::map SplitLength;
std::map::iterator SLiter;
wxString PropertyData;
wxString PropertyName;
wxString PropertyValue;
wxString PropertyTokens;
int intPrevValue = 6;
intPrevValue = 5;
if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
ContactDatav3.AddRaw(wxT("X-VCARD4-LANG"), wxSPropertySeg2);
} else {
ContactDatav3.AddRaw(wxT("X-VCARD4-LANG;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
}
} else if (wxSProperty == wxT("GEO")){
std::map SplitPoints;
std::map SplitLength;
std::map::iterator SLiter;
wxString PropertyData;
wxString PropertyName;
wxString PropertyValue;
wxString PropertyTokens;
wxString GeoType;
wxString GeoData;
int intPrevValue = 5;
intPrevValue = 4;
SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
wxString strFinalGeoValue;
wxString strFinalType;
if (wxSPropertySeg2.Mid(0, 3) == wxT("geo")){
strFinalGeoValue = wxSPropertySeg2.Mid(5);
strFinalType = wxT("geo");
} else {
wxStringTokenizer wSTSplit(wxSPropertySeg2, wxT(":"));
strFinalType = wSTSplit.GetNextToken();
strFinalGeoValue = wSTSplit.GetNextToken();
}
if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
ContactDatav3.AddRaw(wxT("X-VCARD4-GEO;X-GEOTYPE=") + strFinalType, wxSPropertySeg2);
} else {
ContactDatav3.AddRaw(wxT("X-VCARD4-GEO;X-GEOTYPE=") + strFinalType + wxT(";") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
}
} else if (wxSProperty == wxT("RELATED")){
std::map SplitPoints;
std::map SplitLength;
std::map::iterator SLiter;
wxString PropertyData;
wxString PropertyName;
wxString PropertyValue;
wxString PropertyTokens;
wxString RelatedType;
wxString RelatedTypeOriginal;
wxString RelatedName;
bool FirstToken = TRUE;
int intPrevValue = 9;
intPrevValue = 8;
SplitValues(&wxSPropertySeg1, &SplitPoints, &SplitLength, intPrevValue);
wxString strDetail;
for (std::map::iterator intiter = SplitPoints.begin();
intiter != SplitPoints.end(); ++intiter){
SLiter = SplitLength.find(intiter->first);
PropertyData = wxSPropertySeg1.Mid(intPrevValue, (SLiter->second - 1));
wxStringTokenizer PropertyElement (PropertyData, wxT("="));
PropertyName = PropertyElement.GetNextToken();
PropertyValue = PropertyElement.GetNextToken();
if (PropertyName == wxT("TYPE") && FirstToken == TRUE){
if (PropertyValue == wxT("contact")){
strDetail = _("Contact");
} else if (PropertyValue == wxT("acquaintance")){
strDetail = _("Acquaintance");
} else if (PropertyValue == wxT("friend")){
strDetail = _("Friend");
} else if (PropertyValue == wxT("met")){
strDetail = _("Met");
} else if (PropertyValue == wxT("co-worker")){
strDetail = _("Co-worker");
} else if (PropertyValue == wxT("colleague")){
strDetail = _("Colleague");
} else if (PropertyValue == wxT("co-resident")){
strDetail = _("Co-resident");
} else if (PropertyValue == wxT("neighbor")){
strDetail = _("Neighbour");
} else if (PropertyValue == wxT("child")){
strDetail = _("Child");
} else if (PropertyValue == wxT("parent")){
strDetail = _("Parent");
} else if (PropertyValue == wxT("sibling")){
strDetail = _("Sibling");
} else if (PropertyValue == wxT("spouse")){
strDetail = _("Spouse");
} else if (PropertyValue == wxT("kin")){
strDetail = _("Kin");
} else if (PropertyValue == wxT("muse")){
strDetail = _("Muse");
} else if (PropertyValue == wxT("crush")){
strDetail = _("Crush");
} else if (PropertyValue == wxT("date")){
strDetail = _("Date");
} else if (PropertyValue == wxT("sweetheart")){
strDetail = _("Sweetheart");
} else if (PropertyValue == wxT("me")){
strDetail = _("Me");
} else if (PropertyValue == wxT("agent")){
strDetail = _("Agent");
} else if (PropertyValue == wxT("emergency")){
strDetail = _("Emergency");
} else {
strDetail = PropertyValue;
}
FirstToken = FALSE;
}
}
if (strDetail.IsEmpty()){
strDetail = _("Relation");
}
if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABRELATEDNAMES"), wxSPropertySeg2);
ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), strDetail);
ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-RELATED"), wxSPropertySeg2);
} else {
ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABRELATEDNAMES"), wxSPropertySeg2);
ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), strDetail);
ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-RELATED;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
}
ItemSeek++;
} else if (wxSProperty == wxT("URL")){
std::map SplitPoints;
std::map SplitLength;
std::map::iterator SLiter;
wxString PropertyData;
wxString PropertyName;
wxString PropertyValue;
wxString PropertyTokens;
int intPrevValue = 5;
intPrevValue = 4;
// Todo: Check for X-ABLabel.
if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".URL"), wxSPropertySeg2);
ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), _("URL"));
ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-URL"), wxSPropertySeg2);
} else {
ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".URL"), wxSPropertySeg2);
ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-ABLabel"), _("URL"));
ContactDatav3.AddRaw(wxT("item") + wxString::Format(wxT("%i"), ItemSeek) + wxT(".X-VCARD4-URL;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
}
ItemSeek++;
} else if (wxSProperty == wxT("TITLE")) {
std::map SplitPoints;
std::map SplitLength;
std::map::iterator SLiter;
wxString PropertyData;
wxString PropertyName;
wxString PropertyValue;
wxString PropertyTokens;
int intPrevValue = 7;
intPrevValue = 6;
// Look for type before continuing.
if (TitleFirst == FALSE){
ContactDatav3.AddRaw(wxT("TITLE"), wxSPropertySeg2);
if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
} else {
ContactDatav3.AddRaw(wxT("X-VCARD4-TITLE;X-FIRST=TRUE;")
+ ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxT(""));
}
TitleFirst = TRUE;
ItemSeek++;
} else {
if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
ContactDatav3.AddRaw(wxT("X-VCARD4-TITLE"), wxSPropertySeg2);
} else {
ContactDatav3.AddRaw(wxT("X-VCARD4-TITLE;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))) + wxT(":"),
wxSPropertySeg2);
}
}
} else if (wxSProperty == wxT("ROLE")) {
std::map SplitPoints;
std::map SplitLength;
std::map::iterator SLiter;
wxString PropertyData;
wxString PropertyName;
wxString PropertyValue;
wxString PropertyTokens;
int intPrevValue = 6;
intPrevValue = 5;
if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
ContactDatav3.AddRaw(wxT("X-VCARD4-ROLE"), wxSPropertySeg2);
} else {
ContactDatav3.AddRaw(wxT("X-VCARD4-ROLE;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
}
} else if (wxSProperty == wxT("ORG")) {
std::map SplitPoints;
std::map SplitLength;
std::map::iterator SLiter;
wxString PropertyData;
wxString PropertyName;
wxString PropertyValue;
wxString PropertyTokens;
int intPrevValue = 5;
intPrevValue = 4;
if (OrganisationFirst == FALSE){
ContactDatav3.AddRaw(wxT("ORG"), wxSPropertySeg2);
if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
} else {
ContactDatav3.AddRaw(wxT("X-VCARD4-ORG;X-FIRST=TRUE;")
+ ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxT(""));
}
OrganisationFirst = TRUE;
ItemSeek++;
} else {
if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
ContactDatav3.AddRaw(wxT("X-VCARD4-ORG"), wxSPropertySeg2);
} else {
ContactDatav3.AddRaw(wxT("X-VCARD4-ORG;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))) + wxT(":"),
wxSPropertySeg2);
}
}
} else if (wxSProperty == wxT("NOTE")) {
std::map SplitPoints;
std::map SplitLength;
std::map::iterator SLiter;
wxString PropertyData;
wxString PropertyName;
wxString PropertyValue;
wxString PropertyTokens;
int intPrevValue = 6;
intPrevValue = 5;
if (NoteFirst == FALSE){
ContactDatav3.AddRaw(wxT("NOTE"), wxSPropertySeg2);
if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
} else {
ContactDatav3.AddRaw(wxT("X-VCARD4-NOTE;X-FIRST=TRUE;")
+ ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxT(""));
}
NoteFirst = TRUE;
ItemSeek++;
} else {
if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
ContactDatav3.AddRaw(wxT("X-VCARD4-NOTE"), wxSPropertySeg2);
} else {
ContactDatav3.AddRaw(wxT("X-VCARD4-NOTE;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))) + wxT(":"),
wxSPropertySeg2);
}
}
} else if (wxSProperty == wxT("CATEGORIES")) {
std::map SplitPoints;
std::map SplitLength;
std::map::iterator SLiter;
wxString PropertyData;
wxString PropertyName;
wxString PropertyValue;
wxString PropertyTokens;
wxString PropertyType;
int intPrevValue = 12;
intPrevValue = 11;
if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
ContactDatav3.AddRaw(wxT("X-VCARD4-CATEGORIES"), wxSPropertySeg2);
} else {
ContactDatav3.AddRaw(wxT("X-VCARD4-CATEGORIES;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
}
} else if (wxSProperty == wxT("PHOTO")) {
size_t intPropertyLen = wxSPropertySeg1.Len();
std::map SplitPoints;
std::map SplitLength;
std::map::iterator SLiter;
wxString PropertyData;
wxString PropertyName;
wxString PropertyValue;
wxString PropertyTokens;
int intSplitsFound = 0;
int intSplitSize = 0;
int intPrevValue = 7;
intPropertyLen = wxSPropertySeg2.Len();
SplitPoints.clear();
SplitLength.clear();
intSplitsFound = 0;
intSplitSize = 0;
CaptureString(&wxSPropertySeg2, FALSE);
for (int i = 0; i <= intPropertyLen; i++){
intSplitSize++;
if (wxSPropertySeg2.Mid(i, 1) == wxT(";")){
intSplitsFound++;
SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
if (intSplitsFound == 6){
SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
break;
} else {
SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
}
intSplitSize = 0;
}
}
wxString wxSPhotoURI;
wxString wxSPhotoMIME;
wxString wxSPhotoEncoding;
wxString wxSPhotoData;
std::string base64enc;
if (intSplitsFound == 0){
} else {
std::map::iterator striter;
striter = SplitLength.find(1);
wxStringTokenizer wSTDataType(wxSPropertySeg2.Mid(0, striter->second), wxT(":"));
while (wSTDataType.HasMoreTokens() == TRUE){
wxSPhotoURI = wSTDataType.GetNextToken();
wxSPhotoMIME = wSTDataType.GetNextToken();
break;
}
wxStringTokenizer wSTDataInfo(wxSPropertySeg2.Mid((striter->second + 1)), wxT(","));
while (wSTDataInfo.HasMoreTokens() == TRUE){
wxSPhotoEncoding = wSTDataInfo.GetNextToken();
wxSPhotoData = wSTDataInfo.GetNextToken();
base64enc = wxSPhotoData.mb_str();
break;
}
}
if (PhotoFirst == FALSE){
bool PhotoKeepData = FALSE;
wxString wxSPhotoMIMEF;
if (wxSPhotoMIME == wxT("image/png")){
wxSPhotoMIMEF = wxT("PNG");
} else if (wxSPhotoMIME == wxT("image/jpeg")){
wxSPhotoMIMEF = wxT("JPEG");
} else if (wxSPhotoMIME == wxT("image/gif")){
wxSPhotoMIMEF = wxT("GIF");
} else if (wxSPhotoMIME == wxT("image/bmp")){
wxSPhotoMIMEF = wxT("BMP");
} else {
wxSPhotoMIMEF = wxT("UNKNOWN");
PhotoKeepData = TRUE;
}
ContactDatav3.AddRaw(wxT("PHOTO;ENCODING=b;TYPE=") + wxSPhotoMIMEF, wxSPhotoData);
if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
} else {
if (PhotoKeepData == TRUE){
ContactDatav3.AddRaw(wxT("X-VCARD4-PHOTO;X-FIRST=TRUE;")
+ ContactLine.Mid((intPrevValue - 1), ((QuoteBreakPoint + 1) - (intPrevValue))), wxSPropertySeg2);
} else {
ContactDatav3.AddRaw(wxT("X-VCARD4-PHOTO;X-FIRST=TRUE;")
+ ContactLine.Mid((intPrevValue - 1), ((QuoteBreakPoint + 1) - (intPrevValue))), wxT(""));
}
}
PhotoFirst = TRUE;
ItemSeek++;
} else {
if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
ContactDatav3.AddRaw(wxT("X-VCARD4-PHOTO"), wxSPropertySeg2);
} else {
ContactDatav3.AddRaw(wxT("X-VCARD4-PHOTO;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))) + wxT(":"),
wxSPropertySeg2);
}
}
} else if (wxSProperty == wxT("LOGO")) {
std::map SplitPoints;
std::map SplitLength;
std::map::iterator SLiter;
wxString PropertyData;
wxString PropertyName;
wxString PropertyValue;
wxString PropertyTokens;
int intPrevValue = 6;
intPrevValue = 5;
if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
ContactDatav3.AddRaw(wxT("X-VCARD4-LOGO"), wxSPropertySeg2);
} else {
ContactDatav3.AddRaw(wxT("X-VCARD4-LOGO;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
}
} else if (wxSProperty == wxT("SOUND")) {
std::map SplitPoints;
std::map SplitLength;
std::map::iterator SLiter;
wxString PropertyData;
wxString PropertyName;
wxString PropertyValue;
wxString PropertyTokens;
int intPrevValue = 7;
intPrevValue = 6;
if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
ContactDatav3.AddRaw(wxT("X-VCARD4-SOUND"), wxSPropertySeg2);
} else {
ContactDatav3.AddRaw(wxT("X-VCARD4-SOUND;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
}
} else if (wxSProperty == wxT("CALURI")){
std::map SplitPoints;
std::map SplitLength;
std::map::iterator SLiter;
wxString PropertyData;
wxString PropertyName;
wxString PropertyValue;
wxString PropertyTokens;
int intPrevValue = 8;
intPrevValue = 7;
if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
ContactDatav3.AddRaw(wxT("X-VCARD4-CALURI"), wxSPropertySeg2);
} else {
ContactDatav3.AddRaw(wxT("X-VCARD4-CALURI;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
}
} else if (wxSProperty == wxT("CALADRURI")){
std::map SplitPoints;
std::map SplitLength;
std::map::iterator SLiter;
wxString PropertyData;
wxString PropertyName;
wxString PropertyValue;
wxString PropertyTokens;
int intPrevValue = 11;
intPrevValue = 10;
if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
ContactDatav3.AddRaw(wxT("X-VCARD4-CALADRURI"), wxSPropertySeg2);
} else {
ContactDatav3.AddRaw(wxT("X-VCARD4-CALADRURI;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
}
} else if (wxSProperty == wxT("FBURL")){
std::map SplitPoints;
std::map SplitLength;
std::map::iterator SLiter;
wxString PropertyData;
wxString PropertyName;
wxString PropertyValue;
wxString PropertyTokens;
int intPrevValue = 7;
intPrevValue = 6;
if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
ContactDatav3.AddRaw(wxT("X-VCARD4-FBURL"), wxSPropertySeg2);
} else {
ContactDatav3.AddRaw(wxT("X-VCARD4-FBURL;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
}
} else if (wxSProperty == wxT("KEY")){
std::map SplitPoints;
std::map SplitLength;
std::map::iterator SLiter;
wxString PropertyData;
wxString PropertyName;
wxString PropertyValue;
wxString PropertyTokens;
int intPrevValue = 5;
intPrevValue = 4;
if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
ContactDatav3.AddRaw(wxT("X-VCARD4-KEY"), wxSPropertySeg2);
} else {
ContactDatav3.AddRaw(wxT("X-VCARD4-KEY;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
}
} else if (wxSProperty == wxT("UID")){
ContactDatav3.AddRaw(wxT("UID"), wxSPropertySeg2);
} else if (wxSProperty.Mid(0, 3) == wxT("VND")){
// Split the Vendor three ways.
wxStringTokenizer wSTVendorDetails(wxSPropertySeg1, wxT("-"));
wxString wxSVNDID;
wxString wxSVNDPropName;
size_t intPrevValue = (wxSProperty.Len() + 1);
while (wSTVendorDetails.HasMoreTokens() == TRUE){
wSTVendorDetails.GetNextToken();
wxSVNDID = wSTVendorDetails.GetNextToken();
wxSVNDPropName = wSTVendorDetails.GetNextToken();
break;
}
if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
ContactDatav3.AddRaw(wxT("X-VCARD4-") + wxSProperty, wxSPropertySeg2);
} else {
ContactDatav3.AddRaw(wxT("X-VCARD4-") + wxSProperty + wxT(";") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
}
} else if (wxSProperty.Mid(0, 2) == wxT("X-")){
size_t intPrevValue = (wxSProperty.Len() + 1);
if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
ContactDatav3.AddRaw(wxSProperty, wxSPropertySeg2);
} else {
ContactDatav3.AddRaw(wxSProperty + wxT(";") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
}
} else if (wxSProperty.Mid(0, 12) == wxT("CLIENTPIDMAP")){
// Process the Client PID maps.
int intPrevValue = 14;
intPrevValue = ;
if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
ContactDatav3.AddRaw(wxT("X-VCARD4-CLIENTPIDMAP"), wxSPropertySeg2);
} else {
ContactDatav3.AddRaw(wxT("X-VCARD4-CLIENTPIDMAP;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
}
} else if (wxSProperty.Mid(0, 3) == wxT("XML")){
// Process the XML values.
int intPrevValue = 14;
intPrevValue = ;
if (((QuoteBreakPoint + 1) - intPrevValue) <= 0){
ContactDatav3.AddRaw(wxT("X-VCARD4-XML"), wxSPropertySeg2);
} else {
ContactDatav3.AddRaw(wxT("X-VCARD4-XML;") + ContactLine.Mid(intPrevValue, ((QuoteBreakPoint + 1) - (intPrevValue + 1))), wxSPropertySeg2);
}
}
// Reset the variables.
QuoteMode = FALSE;
PropertyFind = TRUE;
ExtraLineSeek = TRUE;
ContactLineLen = 0;
QuoteBreakPoint = 0;
ContactLine.Clear();
wxSProperty.Clear();
}
ContactDatav3.AddRaw(wxT("END"), wxT("VCARD"));
*wxSData = ContactDatav3.WriteString();
return TRUE;
}