X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Fvcard%2Fvcard34conv.cpp;h=9137a58eac5f06bcbe16032cf49de91411c2b71e;hb=134b7476fefe9440a5120b15e3d913afc9c48f04;hp=103d7ae9be768c299b5a401aaf221e0ef00dc06b;hpb=fb95962b20989702f8d689875a977d150c087660;p=xestiaab%2F.git
diff --git a/source/vcard/vcard34conv.cpp b/source/vcard/vcard34conv.cpp
index 103d7ae..9137a58 100644
--- a/source/vcard/vcard34conv.cpp
+++ b/source/vcard/vcard34conv.cpp
@@ -1,3 +1,21 @@
+// vcard34conv.cpp - vCard34Conv Object
+//
+// (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"
@@ -15,11 +33,15 @@
// RFC 6350 specification.
vCard34Conv::vCard34Conv(){
- vCardBegin = FALSE;
- vCardEnd = FALSE;
- vCardFN = FALSE;
- vCardVersion = 0.0;
- SettingCount = 0;
+
+ // Setup the vCard34Conv object.
+
+ vCardBegin = FALSE;
+ vCardEnd = FALSE;
+ vCardFN = FALSE;
+ vCardVersion = 0.0;
+ SettingCount = 0;
+
}
void vCard34Conv::ConvertV4PropertyProc(wxString *wxSPropertyName,
@@ -30,9 +52,11 @@ void vCard34Conv::ConvertV4PropertyProc(wxString *wxSPropertyName,
std::map *PropertyLockMap,
bool ProcessItemData, bool *VCardV3Value, bool *XVCardV4Value){
+ // Convert and format data to vCard 4.0 specifications.
+
wxString wxSProperty;
wxString wxSPropertySeg1Chopped;
- size_t intPropertyLen;
+ size_t intPropertyLen;
if (ProcessItemData == TRUE){
@@ -137,31 +161,43 @@ void vCard34Conv::ConvertV4PropertyProc(wxString *wxSPropertyName,
intPrevValue = intiter->second;
if (PropertyName == wxT("type") && PropertyValue == wxT("INTERNET")){
+
continue;
+
}
if (PropertyName == wxT("type") && PropertyValue == wxT("pref")){
if (ProcessItemData == FALSE){
+
PropertyName = wxT("PREF");
PropertyValue = wxT("50");
+
} else {
+
continue;
+
}
}
if (PropertyName == wxT("type") && (PropertyValue == wxT("HOME") || PropertyValue == wxT("home"))){
+
PropertyValue = wxT("home");
+
}
if (PropertyName == wxT("type") && (PropertyValue == wxT("WORK") || PropertyValue == wxT("work"))){
+
PropertyValue = wxT("work");
+
}
if (PropertyName == wxT("type") && (PropertyValue == wxT("OTHER") || PropertyValue == wxT("other"))){
+
PropertyName = wxT("X-TYPE");
PropertyValue = wxT("other");
+
}
// Process properties.
@@ -270,25 +306,35 @@ void vCard34Conv::ConvertV4PropertyProc(wxString *wxSPropertyName,
if (PropertyName == wxT("type") && PropertyValue == wxT("pref")){
if (ProcessItemData == FALSE){
+
PropertyName = wxT("PREF");
PropertyValue = wxT("50");
+
} else {
+
continue;
+
}
}
if (PropertyName == wxT("type") && (PropertyValue == wxT("HOME") || PropertyValue == wxT("home"))){
+
PropertyValue = wxT("home");
+
}
if (PropertyName == wxT("type") && (PropertyValue == wxT("WORK") || PropertyValue == wxT("work"))){
+
PropertyValue = wxT("work");
+
}
if (PropertyName == wxT("type") && (PropertyValue == wxT("OTHER") || PropertyValue == wxT("other"))){
+
PropertyName = wxT("X-TYPE");
PropertyValue = wxT("other");
+
}
// Process properties.
@@ -395,20 +441,28 @@ void vCard34Conv::ConvertV4PropertyProc(wxString *wxSPropertyName,
intPrevValue = intiter->second;
if (PropertyName == wxT("type") && PropertyValue == wxT("pref")){
+
continue;
+
}
if (PropertyName == wxT("type") && (PropertyValue == wxT("HOME") || PropertyValue == wxT("home"))){
+
PropertyValue = wxT("home");
+
}
if (PropertyName == wxT("type") && (PropertyValue == wxT("WORK") || PropertyValue == wxT("work"))){
+
PropertyValue = wxT("work");
+
}
if (PropertyName == wxT("type") && (PropertyValue == wxT("OTHER") || PropertyValue == wxT("other"))){
+
PropertyName = wxT("X-TYPE");
PropertyValue = wxT("other");
+
}
// Process properties.
@@ -537,24 +591,34 @@ void vCard34Conv::ConvertV4PropertyProc(wxString *wxSPropertyName,
intPrevValue = intiter->second;
if (PropertyName == wxT("type") && PropertyValue == wxT("pref")){
+
continue;
+
}
if (PropertyName == wxT("X-SERVICE-TYPE")){
+
continue;
+
}
if (PropertyName == wxT("type") && (PropertyValue == wxT("HOME") || PropertyValue == wxT("home"))){
+
PropertyValue = wxT("home");
+
}
if (PropertyName == wxT("type") && (PropertyValue == wxT("WORK") || PropertyValue == wxT("work"))){
+
PropertyValue = wxT("work");
+
}
if (PropertyName == wxT("type") && (PropertyValue == wxT("OTHER") || PropertyValue == wxT("other"))){
+
PropertyName = wxT("X-TYPE");
PropertyValue = wxT("other");
+
}
// Process properties.
@@ -663,22 +727,30 @@ void vCard34Conv::ConvertV4PropertyProc(wxString *wxSPropertyName,
intPrevValue = intiter->second;
if (PropertyName == wxT("type") && PropertyValue == wxT("pref")){
+
continue;
+
}
if (PropertyName == wxT("type") && (PropertyValue == wxT("HOME") || PropertyValue == wxT("home"))){
+
TelType.insert(std::make_pair(wxT("home"), wxT("home")));
continue;
+
}
if (PropertyName == wxT("type") && (PropertyValue == wxT("WORK") || PropertyValue == wxT("work"))){
+
TelType.insert(std::make_pair(wxT("work"), wxT("work")));
continue;
+
}
if (PropertyName == wxT("type") && (PropertyValue == wxT("OTHER") || PropertyValue == wxT("other"))){
+
PropertyName = wxT("X-TYPE");
PropertyValue = wxT("other");
+
}
// Process the telephone type options.
@@ -686,53 +758,68 @@ void vCard34Conv::ConvertV4PropertyProc(wxString *wxSPropertyName,
// text
if (PropertyName == wxT("type") && (PropertyValue == wxT("TEXT") || PropertyValue == wxT("text"))){
+
TelType.insert(std::make_pair(wxT("text"), wxT("text")));
continue;
+
}
// voice
if (PropertyName == wxT("type") && (PropertyValue == wxT("VOICE") || PropertyValue == wxT("voice"))){
+
TelType.insert(std::make_pair(wxT("voice"), wxT("voice")));
continue;
+
}
// fax
if (PropertyName == wxT("type") && (PropertyValue == wxT("FAX") || PropertyValue == wxT("fax"))){
+
TelType.insert(std::make_pair(wxT("fax"), wxT("fax")));
continue;
+
}
// cell
if (PropertyName == wxT("type") && (PropertyValue == wxT("CELL") || PropertyValue == wxT("cell"))){
+
TelType.insert(std::make_pair(wxT("cell"), wxT("cell")));
continue;
+
}
// video
if (PropertyName == wxT("type") && (PropertyValue == wxT("VIDEO") || PropertyValue == wxT("video"))){
+
TelType.insert(std::make_pair(wxT("video"), wxT("video")));
continue;
+
}
// pager
if (PropertyName == wxT("type") && (PropertyValue == wxT("PAGER") || PropertyValue == wxT("pager"))){
+
TelType.insert(std::make_pair(wxT("pager"), wxT("pager")));
continue;
+
}
// textphone
if (PropertyName == wxT("type") && (PropertyValue == wxT("TEXTPHONE") || PropertyValue == wxT("textphone"))){
+
TelType.insert(std::make_pair(wxT("textphone"), wxT("textphone")));
continue;
+
}
if (PropertyName == wxT("type") && PropertyValue.Find(wxT(",")) != wxNOT_FOUND){
+
wxStringTokenizer TypeSplit(PropertyValue, wxT(","));
wxString TypeSplitData;
while (TypeSplit.HasMoreTokens()){
@@ -898,7 +985,9 @@ void vCard34Conv::ConvertV4PropertyProc(wxString *wxSPropertyName,
intPrevValue = intiter->second;
if (PropertyName == wxT("type") && PropertyValue == wxT("pref")){
+
continue;
+
}
// Process properties.
@@ -1005,20 +1094,28 @@ void vCard34Conv::ConvertV4PropertyProc(wxString *wxSPropertyName,
intPrevValue = intiter->second;
if (PropertyName == wxT("type") && PropertyValue == wxT("pref")){
+
continue;
+
}
if (PropertyName == wxT("type") && (PropertyValue == wxT("HOME") || PropertyValue == wxT("home"))){
+
PropertyValue = wxT("home");
+
}
if (PropertyName == wxT("type") && (PropertyValue == wxT("WORK") || PropertyValue == wxT("work"))){
+
PropertyValue = wxT("work");
+
}
if (PropertyName == wxT("type") && (PropertyValue == wxT("OTHER") || PropertyValue == wxT("other"))){
+
PropertyName = wxT("X-TYPE");
PropertyValue = wxT("other");
+
}
// Process properties.
@@ -1275,7 +1372,7 @@ void vCard34Conv::ConvertV4PropertyProc(wxString *wxSPropertyName,
wxString PropertyValue;
wxString PropertyTokens;
bool FirstToken = TRUE;
- int intPrevValue = 3;
+ int intPrevValue = 3;
wxSPropertyDataOut->Append(*wxSPropertySeg2Ptr);
*wxSPropertyDataNameOut = wxT("N");
@@ -2717,7 +2814,7 @@ void vCard34Conv::ConvertV4PropertyProc(wxString *wxSPropertyName,
wxString PropertyName;
wxString PropertyValue;
wxString PropertyTokens;
- bool FirstToken = TRUE;
+ bool FirstToken = TRUE;
int intPrevValue = 12;
if (ProcessItemData == TRUE){
@@ -5860,7 +5957,9 @@ void vCard34Conv::ConvertV4PropertyProc(wxString *wxSPropertyName,
void vCard34Conv::ProcessCaptureStringsProc(wxString *strCapture){
- CaptureString(strCapture, FALSE);
+ // Process code for capturing the strings.
+
+ CaptureString(strCapture, FALSE);
}
@@ -5869,6 +5968,8 @@ void vCard34Conv::SplitValues(wxString *PropertyLine,
std::map *SplitLength,
int intSize){
+ // Split the values as required.
+
size_t intPropertyLen = PropertyLine->Len();
int intSplitsFound = 0;
int intSplitSize = 0;
@@ -5881,21 +5982,21 @@ void vCard34Conv::SplitValues(wxString *PropertyLine,
if (PropertyLine->Mid(i, 1) == wxT(";") &&
PropertyLine->Mid((i - 1), 1) != wxT("\\")){
- if (intSplitsFound == 0){
+ if (intSplitsFound == 0){
- SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
+ SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
- } else {
+ } else {
- SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
+ SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
- }
+ }
- SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
+ SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
- intSplitsFound++;
- intSplitSeek = i;
- intSplitSize = 0;
+ intSplitsFound++;
+ intSplitSeek = i;
+ intSplitSize = 0;
}
@@ -5921,6 +6022,9 @@ void vCard34Conv::SplitValuesData(wxString *PropertyLine,
int intSize,
std::map *SplitData){
+
+ // Split the data values as required.
+
wxString DataStr;
wxStringTokenizer PropertyElement;
wxString PropertyName;
@@ -5937,7 +6041,7 @@ void vCard34Conv::SplitValuesData(wxString *PropertyLine,
if (PropertyLine->Mid(i, 1) == wxT(";") &&
PropertyLine->Mid((i - 1), 1) != wxT("\\")){
- if (intSplitsFound == 0){
+ if (intSplitsFound == 0){
DataStr = PropertyLine->Mid(intSplitSeek, (intSplitSize));
SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
@@ -5949,24 +6053,24 @@ void vCard34Conv::SplitValuesData(wxString *PropertyLine,
}
- SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
+ SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
- intSplitsFound++;
- intSplitSeek = (i + 1);
- intSplitSize = 0;
+ intSplitsFound++;
+ intSplitSeek = (i + 1);
+ intSplitSize = 0;
- if (!DataStr.IsEmpty()){
+ if (!DataStr.IsEmpty()){
- PropertyElement.SetString(DataStr, wxT("="));
- PropertyName = PropertyElement.GetNextToken();
- PropertyValue = PropertyElement.GetNextToken();
- SplitData->insert(std::make_pair(PropertyName, PropertyValue));
+ PropertyElement.SetString(DataStr, wxT("="));
+ PropertyName = PropertyElement.GetNextToken();
+ PropertyValue = PropertyElement.GetNextToken();
+ SplitData->insert(std::make_pair(PropertyName, PropertyValue));
- }
+ }
- DataStr.clear();
- PropertyName.clear();
- PropertyValue.clear();
+ DataStr.clear();
+ PropertyName.clear();
+ PropertyValue.clear();
}