// RFC 6350 specification.
vCard::vCard(){
- vCardBegin = FALSE;
- vCardEnd = FALSE;
- vCardFN = FALSE;
- vCardVersion = 0.0;
- SettingCount = 0;
+
+ // Setup the vCard object.
+
+ vCardBegin = FALSE;
+ vCardEnd = FALSE;
+ vCardFN = FALSE;
+ vCardVersion = 0.0;
+ SettingCount = 0;
+
}
void vCard::Add(wxString SettingName, wxString SettingValue, bool ReplaceMode){
- // Check for backslashes used for commas, newlines and
- // backslashes used for values.
+ // Add data to vCard object.
+
+ // Check for backslashes used for commas, newlines and
+ // backslashes used for values.
- if (ReplaceMode == TRUE){
+ if (ReplaceMode == TRUE){
- SettingValue.Replace(wxT("\\n"), wxT("\n"));
- SettingValue.Replace(wxT("\\,"), wxT(","));
- SettingValue.Replace(wxT("\\:"), wxT(":"));
- SettingValue.Replace(wxT("\\\\"), wxT("\\"));
+ SettingValue.Replace(wxT("\\n"), wxT("\n"));
+ SettingValue.Replace(wxT("\\,"), wxT(","));
+ SettingValue.Replace(wxT("\\:"), wxT(":"));
+ SettingValue.Replace(wxT("\\\\"), wxT("\\"));
- } else {
+ } else {
- SettingValue.Replace(wxT("\\"), wxT("\\\\"));
- SettingValue.Replace(wxT("\n"), wxT("\\n"));
- SettingValue.Replace(wxT(","), wxT("\\,"));
- SettingValue.Replace(wxT(":"), wxT("\\:"));
- SettingValue = SettingValue + wxT("\n");
+ SettingValue.Replace(wxT("\\"), wxT("\\\\"));
+ SettingValue.Replace(wxT("\n"), wxT("\\n"));
+ SettingValue.Replace(wxT(","), wxT("\\,"));
+ SettingValue.Replace(wxT(":"), wxT("\\:"));
+ SettingValue = SettingValue + wxT("\n");
- }
+ }
- // Check data to make sure that it meets the required
- // vCard 4.0 specifications.
+ // Check data to make sure that it meets the required
+ // vCard 4.0 specifications.
if (SettingName == wxT("BEGIN") && SettingValue == wxT("VCARD")){
vCardBegin = TRUE;
vCardVersion = 2.0;
}
- SettingValue.Trim();
+ SettingValue.Trim();
- if (SettingValue.Right(2) != wxT("\r\n")){
+ if (SettingValue.Right(2) != wxT("\r\n")){
- SettingValue.Append(wxT("\r\n"));
+ SettingValue.Append(wxT("\r\n"));
- }
+ }
- SettingNames.Add(SettingName, 1);
- SettingValues.Add(SettingValue, 1);
+ SettingNames.Add(SettingName, 1);
+ SettingValues.Add(SettingValue, 1);
- ++SettingCount;
+ ++SettingCount;
+
}
void vCard::AddRaw(wxString SettingName, wxString SettingValue){
- // Check data to make sure that it meets the required
- // vCard 4.0 specifications.
-
- if (SettingName == wxT("BEGIN") && SettingValue == wxT("VCARD")){
- vCardBegin = TRUE;
- }
+ // Add data to the vCard in raw mode.
+
+ // Check data to make sure that it meets the required
+ // vCard 4.0 specifications.
+
+ if (SettingName == wxT("BEGIN") && SettingValue == wxT("VCARD")){
+ vCardBegin = TRUE;
+ }
- if (SettingName == wxT("END") && SettingValue == wxT("VCARD")){
- vCardEnd = TRUE;
- }
+ if (SettingName == wxT("END") && SettingValue == wxT("VCARD")){
+ vCardEnd = TRUE;
+ }
- if (SettingName.Mid(0,2) == wxT("FN")){
- vCardFN = TRUE;
- }
+ if (SettingName.Mid(0,2) == wxT("FN")){
+ vCardFN = TRUE;
+ }
- if (SettingName == wxT("VERSION") && SettingValue == wxT("4.0")){
- vCardVersion = 4.0;
- }
+ if (SettingName == wxT("VERSION") && SettingValue == wxT("4.0")){
+ vCardVersion = 4.0;
+ }
- if (SettingName == wxT("VERSION") && SettingValue == wxT("3.0")){
- vCardVersion = 3.0;
- }
+ if (SettingName == wxT("VERSION") && SettingValue == wxT("3.0")){
+ vCardVersion = 3.0;
+ }
- if (SettingName == wxT("VERSION") && SettingValue == wxT("3.0")){
- vCardVersion = 2.0;
- }
+ if (SettingName == wxT("VERSION") && SettingValue == wxT("3.0")){
+ vCardVersion = 2.0;
+ }
- SettingValue.Trim();
+ SettingValue.Trim();
- if (SettingValue.Right(2) != wxT("\r\n")){
+ if (SettingValue.Right(2) != wxT("\r\n")){
- SettingValue.Append(wxT("\r\n"));
+ SettingValue.Append(wxT("\r\n"));
- }
+ }
- SettingNames.Add(SettingName, 1);
- SettingValues.Add(SettingValue, 1);
+ SettingNames.Add(SettingName, 1);
+ SettingValues.Add(SettingValue, 1);
- ++SettingCount;
+ ++SettingCount;
+
}
wxString vCard::Get(wxString SettingName){
- wxString SettingValue;
-
- // Look for the setting name.
+ // Get values from the vCard object.
+
+ wxString SettingValue;
- for (int i = 0; i < SettingCount; i++){
+ // Look for the setting name.
+
+ for (int i = 0; i < SettingCount; i++){
- if (SettingNames[i] == SettingName){
+ if (SettingNames[i] == SettingName){
- SettingValue = SettingValues[i];
- SettingValue.Trim(TRUE);
+ SettingValue = SettingValues[i];
+ SettingValue.Trim(TRUE);
- while (SettingValues[(i + 1)].Mid(0, 1) == wxT(" ") || SettingValues[(i + 1)].Mid(0, 1) == wxT("\t")){
+ while (SettingValues[(i + 1)].Mid(0, 1) == wxT(" ") || SettingValues[(i + 1)].Mid(0, 1) == wxT("\t")){
- SettingValue.Trim();
- SettingValue.Append(SettingValues[(i + 1)]);
+ SettingValue.Trim();
+ SettingValue.Append(SettingValues[(i + 1)]);
- i++;
- }
+ i++;
+
+ }
- return SettingValue;
+ return SettingValue;
+
+ }
+
}
- }
return wxEmptyString;
vCardName vCard::GetName(){
+ // Get the name from the vCard object.
+
vCardName NameData;
ArrayvCardOutData NameArray = this->GetByPartial(wxT("N"));
//wxString NameDataGet = NameArray.PropValues[0];
ArrayvCardOutData vCard::GetByPartial(wxString SettingName){
- ArrayvCardOutData vCardOutData;
- wxArrayString SettingList;
- wxString SettingValueCurrent;
- wxString SettingValue;
- int SettingNameLen;
- int SettingNameSeek;
- bool FirstToken = TRUE;
+ // Get data from the vCard object based on a partial match.
+
+ ArrayvCardOutData vCardOutData;
+ wxArrayString SettingList;
+ wxString SettingValueCurrent;
+ wxString SettingValue;
+ int SettingNameLen;
+ int SettingNameSeek;
+ bool FirstToken = TRUE;
- SettingNameLen = SettingName.Len();
-
- for (int i = 0; i < SettingCount; i++){
+ SettingNameLen = SettingName.Len();
+
+ for (int i = 0; i < SettingCount; i++){
- if (SettingNames[i].Mid(0, SettingNameLen) == SettingName){
+ if (SettingNames[i].Mid(0, SettingNameLen) == SettingName){
- SettingValue = SettingValues[i];
- SettingNameSeek = i;
+ SettingValue = SettingValues[i];
+ SettingNameSeek = i;
- while (SettingValues[(i + 1)].Mid(0, 1) == wxT(" ") || SettingValues[(i + 1)].Mid(0, 1) == wxT("\t")){
+ while (SettingValues[(i + 1)].Mid(0, 1) == wxT(" ") || SettingValues[(i + 1)].Mid(0, 1) == wxT("\t")){
- if (FirstToken == TRUE){
+ if (FirstToken == TRUE){
- SettingValue.Trim(FALSE);
- SettingValue.Trim(TRUE);
- FirstToken = FALSE;
+ SettingValue.Trim(FALSE);
+ SettingValue.Trim(TRUE);
+ FirstToken = FALSE;
- }
+ }
- SettingValueCurrent = SettingValues[(i + 1)];
- SettingValueCurrent.Trim(FALSE);
- SettingValueCurrent.Trim(TRUE);
+ SettingValueCurrent = SettingValues[(i + 1)];
+ SettingValueCurrent.Trim(FALSE);
+ SettingValueCurrent.Trim(TRUE);
- SettingValue.Append(SettingValueCurrent);
+ SettingValue.Append(SettingValueCurrent);
- i++;
+ i++;
- }
+ }
- //SettingList.Add(SettingNames[SettingNameSeek] + wxT(":") + SettingValue);
- vCardOutData.PropData.Add(SettingNames[SettingNameSeek]);
- vCardOutData.PropValues.Add(SettingValue);
- vCardOutData.PropCount++;
+ //SettingList.Add(SettingNames[SettingNameSeek] + wxT(":") + SettingValue);
+ vCardOutData.PropData.Add(SettingNames[SettingNameSeek]);
+ vCardOutData.PropValues.Add(SettingValue);
+ vCardOutData.PropCount++;
+ }
}
- }
/*for (int i = 0; i < SettingCount; i++){
if (SettingNames[i].Mid(0, SettingNameLen) == SettingName){
}
}*/
- return vCardOutData;
+ return vCardOutData;
}
wxString vCard::GetById(int id){
+
+ // Get data from the vCard object based on ID.
+
// Unimplemented.
return wxT("");
+
}
int vCard::WriteFile(wxString WriteFilename){
- // Open the file and begin writing data into the file.
+ // Write the vCard to a file using the WriteFilename given.
+
+ // Open the file and begin writing data into the file.
- wxString SettingName;
- wxString SettingValue;
- wxString SettingLine;
+ wxString SettingName;
+ wxString SettingValue;
+ wxString SettingLine;
- SettingCount = SettingNames.GetCount();
+ SettingCount = SettingNames.GetCount();
- wxFile ContactFile;
- if (ContactFile.Create(WriteFilename, TRUE, wxS_DEFAULT) == FALSE){
- return 1;
- }
+ wxFile ContactFile;
+ if (ContactFile.Create(WriteFilename, TRUE, wxS_DEFAULT) == FALSE){
+ return 1;
+ }
- for (int i = 0; i < SettingCount; i++){
+ for (int i = 0; i < SettingCount; i++){
- SettingLine = SettingNames[i] + wxT(":") + SettingValues[i];
+ SettingLine = SettingNames[i] + wxT(":") + SettingValues[i];
- int SettingLineLen = SettingLine.Len();
- int intDivider = 74;
- int intTimes = floor((SettingLine.Len() / intDivider));
- int intSeek = 0;
- int intLineSeek = 0;
- int intPrevLine;
- bool FirstLine = TRUE;
+ int SettingLineLen = SettingLine.Len();
+ int intDivider = 74;
+ int intTimes = floor((SettingLine.Len() / intDivider));
+ int intSeek = 0;
+ int intLineSeek = 0;
+ int intPrevLine;
+ bool FirstLine = TRUE;
- // Remember to round down the calculation.
+ // Remember to round down the calculation.
- while (intSeek < SettingLineLen){
+ while (intSeek < SettingLineLen){
- if ((intLineSeek == intDivider && FirstLine == TRUE) ||
- (intLineSeek == (intDivider - 1) && FirstLine == FALSE)){
+ if ((intLineSeek == intDivider && FirstLine == TRUE) ||
+ (intLineSeek == (intDivider - 1) && FirstLine == FALSE)){
- SettingLine.insert(intSeek, wxT("\r\n "));
- intSeek = intSeek + 3;
- SettingLineLen = SettingLineLen + 3;
- intLineSeek = 0;
- intPrevLine = intSeek;
- FirstLine = FALSE;
+ SettingLine.insert(intSeek, wxT("\r\n "));
+ intSeek = intSeek + 3;
+ SettingLineLen = SettingLineLen + 3;
+ intLineSeek = 0;
+ intPrevLine = intSeek;
+ FirstLine = FALSE;
- }
+ }
- intSeek++;
- intLineSeek++;
+ intSeek++;
+ intLineSeek++;
- }
+ }
/*
*/
- ContactFile.Write(SettingLine);
+ ContactFile.Write(SettingLine);
- }
+ }
- ContactFile.Close();
+ ContactFile.Close();
- return 0;
+ return 0;
}
int vCard::LoadFile(wxString LoadFilename){
- wxFFile ContactFile;
+ // Load data from a file using the LoadFilename given.
+
+ wxFFile ContactFile;
- wxString wxSContactString;
+ wxString wxSContactString;
- vCardFilename = LoadFilename;
+ vCardFilename = LoadFilename;
- // Check if we are using wxWidgets version 2.8 or less and
- // execute the required command accordingly.
+ // Check if we are using wxWidgets version 2.8 or less and
+ // execute the required command accordingly.
#if wxABI_VERSION < 20900
- ContactFile.Open(LoadFilename.c_str(), wxT("r"));
+ ContactFile.Open(LoadFilename.c_str(), wxT("r"));
#else
- ContactFile.Open(LoadFilename, wxT("r"));
+ ContactFile.Open(LoadFilename, wxT("r"));
#endif
- if (ContactFile.IsOpened() == FALSE){
+ if (ContactFile.IsOpened() == FALSE){
return 1;
- }
+ }
- ContactFile.ReadAll(&wxSContactString, wxConvAuto());
+ ContactFile.ReadAll(&wxSContactString, wxConvAuto());
- ContactFile.Close();
+ ContactFile.Close();
- ProcessString(&wxSContactString);
+ ProcessString(&wxSContactString);
return 0;
int vCard::LoadString(wxString ContactData){
- ProcessString(&ContactData);
+ // Load data from a wxString.
+
+ ProcessString(&ContactData);
return 0;
void vCard::ProcessString(wxString *ContactDataInc){
- // Split the vCards (if there are more than one vCard in the file).
+ // Process data from a wxString pointer.
+
+ // Split the vCards (if there are more than one vCard in the file).
- wxString ContactLine;
+ wxString ContactLine;
- int ContactLineLen;
- bool ExtraLineSeek = FALSE;
- int QuoteBreakPoint = 0;
+ int ContactLineLen;
+ bool ExtraLineSeek = FALSE;
+ int QuoteBreakPoint = 0;
- bool PropertyFind = FALSE;
- bool QuoteMode = FALSE;
+ bool PropertyFind = FALSE;
+ bool QuoteMode = FALSE;
- wxString wxSPropertyNextLine;
- wxString wxSProperty;
- wxString wxSPropertySeg1;
- wxString wxSPropertySeg2;
+ wxString wxSPropertyNextLine;
+ wxString wxSProperty;
+ wxString wxSPropertySeg1;
+ wxString wxSPropertySeg2;
- bool FoundBegin = FALSE;
- bool FoundEnd = FALSE;
- bool FirstContact = TRUE;
- wxString FirstContactData;
- wxString ContactData;
- int ContactCount = 0;
+ bool FoundBegin = FALSE;
+ bool FoundEnd = FALSE;
+ bool FirstContact = TRUE;
+ wxString FirstContactData;
+ wxString ContactData;
+ int ContactCount = 0;
- wxStringTokenizer wSTContactFileLines(*ContactDataInc, wxT("\r\n"));
+ wxStringTokenizer wSTContactFileLines(*ContactDataInc, wxT("\r\n"));
- while(wSTContactFileLines.HasMoreTokens() == TRUE){
+ while(wSTContactFileLines.HasMoreTokens() == TRUE){
- ContactLine = wSTContactFileLines.GetNextToken();
+ ContactLine = wSTContactFileLines.GetNextToken();
- if (ContactLine == wxT("BEGIN:VCARD")){
+ if (ContactLine == wxT("BEGIN:VCARD")){
- if (FoundBegin == TRUE){
+ if (FoundBegin == TRUE){
- // No END:VCARD was found so discard current data.
+ // No END:VCARD was found so discard current data.
- ContactData.Clear();
+ ContactData.Clear();
- if (FirstContact == TRUE){
+ if (FirstContact == TRUE){
- FirstContactData.Clear();
+ FirstContactData.Clear();
- }
+ }
- }
+ }
- FoundBegin = TRUE;
+ FoundBegin = TRUE;
- FirstContactData.Append(ContactLine + wxT("\r\n"));
- ContactData.Append(ContactLine + wxT("\r\n"));
+ FirstContactData.Append(ContactLine + wxT("\r\n"));
+ ContactData.Append(ContactLine + wxT("\r\n"));
- } else if (ContactLine == wxT("END:VCARD") && FoundBegin == TRUE){
+ } else if (ContactLine == wxT("END:VCARD") && FoundBegin == TRUE){
- if (FirstContact == TRUE){
+ if (FirstContact == TRUE){
- FirstContact = FALSE;
- FirstContactData.Append(ContactLine + wxT("\r\n"));
+ FirstContact = FALSE;
+ FirstContactData.Append(ContactLine + wxT("\r\n"));
- }
+ }
- ContactData.Append(ContactLine + wxT("\r\n"));
+ ContactData.Append(ContactLine + wxT("\r\n"));
- Cards.insert(std::make_pair(ContactCount, ContactData));
+ Cards.insert(std::make_pair(ContactCount, ContactData));
- ContactCount++;
+ ContactCount++;
- } else if (FoundBegin == TRUE){
+ } else if (FoundBegin == TRUE){
- if (FirstContact == TRUE){
+ if (FirstContact == TRUE){
- FirstContactData.Append(ContactLine + wxT("\r\n"));
+ FirstContactData.Append(ContactLine + wxT("\r\n"));
- }
+ }
- ContactData.Append(ContactLine + wxT("\r\n"));
+ ContactData.Append(ContactLine + wxT("\r\n"));
- }
+ }
- }
+ }
- ContactLine.Clear();
+ ContactLine.Clear();
- // Split the lines.
+ // Split the lines.
- std::map<int, wxString> ContactFileLines;
- std::map<int, wxString>::iterator striter;
+ std::map<int, wxString> ContactFileLines;
+ std::map<int, wxString>::iterator striter;
- wxStringTokenizer wSTFirstContactLines(FirstContactData, wxT("\r\n"));
+ wxStringTokenizer wSTFirstContactLines(FirstContactData, wxT("\r\n"));
- int ContactLineSeek = 0;
+ int ContactLineSeek = 0;
- while (wSTFirstContactLines.HasMoreTokens() == TRUE){
+ while (wSTFirstContactLines.HasMoreTokens() == TRUE){
- ContactLine = wSTFirstContactLines.GetNextToken();
- ContactFileLines.insert(std::make_pair(ContactLineSeek, ContactLine));
- ContactLineSeek++;
+ ContactLine = wSTFirstContactLines.GetNextToken();
+ ContactFileLines.insert(std::make_pair(ContactLineSeek, ContactLine));
+ ContactLineSeek++;
- }
+ }
- for (std::map<int,wxString>::iterator iter = ContactFileLines.begin();
- iter != ContactFileLines.end(); ++iter){
+ for (std::map<int,wxString>::iterator iter = ContactFileLines.begin();
+ iter != ContactFileLines.end(); ++iter){
- // Find the colon which splits the start bit from the data part.
+ // Find the colon which splits the start bit from the data part.
- ContactLine = iter->second;
+ ContactLine = iter->second;
- while (ExtraLineSeek == TRUE){
+ while (ExtraLineSeek == TRUE){
- // Check if there is extra data on the next line
- // (indicated by space or tab at the start) and add data.
+ // Check if there is extra data on the next line
+ // (indicated by space or tab at the start) and add data.
- iter++;
+ iter++;
- if (iter == ContactFileLines.end()){
+ if (iter == ContactFileLines.end()){
- iter--;
- break;
+ iter--;
+ break;
- }
+ }
- wxSPropertyNextLine = iter->second;
+ 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);
- 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 {
+ } else {
- iter--;
- ExtraLineSeek = FALSE;
+ iter--;
+ ExtraLineSeek = FALSE;
- }
+ }
- }
+ }
- ContactLineLen = ContactLine.Len();
+ ContactLineLen = ContactLine.Len();
- // Make sure we are not in quotation mode.
- // Make sure colon does not have \ or \\ before it.
+ // Make sure we are not in quotation mode.
+ // Make sure colon does not have \ or \\ before it.
- for (int i = 0; i <= ContactLineLen; i++){
+ for (int i = 0; i <= ContactLineLen; i++){
- if ((ContactLine.Mid(i, 1) == wxT(";") || ContactLine.Mid(i, 1) == wxT(":")) && PropertyFind == TRUE){
+ if ((ContactLine.Mid(i, 1) == wxT(";") || ContactLine.Mid(i, 1) == wxT(":")) && PropertyFind == TRUE){
- PropertyFind = FALSE;
+ PropertyFind = FALSE;
- } else if (PropertyFind == TRUE){
+ } else if (PropertyFind == TRUE){
- wxSProperty.Append(ContactLine.Mid(i, 1));
+ wxSProperty.Append(ContactLine.Mid(i, 1));
- }
+ }
- if (ContactLine.Mid(i, 1) == wxT("\"")){
+ if (ContactLine.Mid(i, 1) == wxT("\"")){
- if (QuoteMode == TRUE){
+ if (QuoteMode == TRUE){
- QuoteMode = FALSE;
+ QuoteMode = FALSE;
- } else {
+ } else {
- QuoteMode = TRUE;
+ QuoteMode = TRUE;
- }
+ }
- }
+ }
- if (ContactLine.Mid(i, 1) == wxT(":") && ContactLine.Mid((i - 1), 1) != wxT("\\") && QuoteMode == FALSE){
+ if (ContactLine.Mid(i, 1) == wxT(":") && ContactLine.Mid((i - 1), 1) != wxT("\\") && QuoteMode == FALSE){
- QuoteBreakPoint = i;
- break;
+ QuoteBreakPoint = i;
+ break;
- }
+ }
- }
+ }
- // Split that line at the point into two variables (ignore the colon).
+ // Split that line at the point into two variables (ignore the colon).
- wxSPropertySeg1 = ContactLine.Mid(0, QuoteBreakPoint);
- wxSPropertySeg2 = ContactLine.Mid((QuoteBreakPoint + 1));
+ wxSPropertySeg1 = ContactLine.Mid(0, QuoteBreakPoint);
+ wxSPropertySeg2 = ContactLine.Mid((QuoteBreakPoint + 1));
- // Insert both into the vCard data file.
+ // Insert both into the vCard data file.
- AddRaw(wxSPropertySeg1, wxSPropertySeg2);
+ AddRaw(wxSPropertySeg1, wxSPropertySeg2);
- QuoteMode = FALSE;
- PropertyFind = TRUE;
- ExtraLineSeek = TRUE;
- ContactLineLen = 0;
- QuoteBreakPoint = 0;
- ContactLine.Clear();
- wxSProperty.Clear();
+ QuoteMode = FALSE;
+ PropertyFind = TRUE;
+ ExtraLineSeek = TRUE;
+ ContactLineLen = 0;
+ QuoteBreakPoint = 0;
+ ContactLine.Clear();
+ wxSProperty.Clear();
- }
+ }
}
wxString vCard::WriteString(){
- // Open the file and begin writing data into the file.
+ // Write the vCard file into a wxString.
+
+ // Open the file and begin writing data into the file.
- wxString SettingName;
- wxString SettingValue;
- wxString SettingLine;
- wxString SettingFinal;
+ wxString SettingName;
+ wxString SettingValue;
+ wxString SettingLine;
+ wxString SettingFinal;
- SettingCount = SettingNames.GetCount();
+ SettingCount = SettingNames.GetCount();
- for (int i = 0; i < SettingCount; i++){
+ for (int i = 0; i < SettingCount; i++){
- SettingLine = SettingNames[i] + wxT(":") + SettingValues[i];
+ SettingLine = SettingNames[i] + wxT(":") + SettingValues[i];
- int SettingLineLen = SettingLine.Len();
- int intDivider = 74;
- int intTimes = floor((SettingLine.Len() / intDivider));
- int intSeek = 0;
- int intLineSeek = 0;
- int intPrevLine;
- bool FirstLine = TRUE;
+ int SettingLineLen = SettingLine.Len();
+ int intDivider = 74;
+ int intTimes = floor((SettingLine.Len() / intDivider));
+ int intSeek = 0;
+ int intLineSeek = 0;
+ int intPrevLine;
+ bool FirstLine = TRUE;
- // Remember to round down the calculation.
+ // Remember to round down the calculation.
- while (intSeek < SettingLineLen){
+ while (intSeek < SettingLineLen){
- if ((intLineSeek == intDivider && FirstLine == TRUE) ||
- (intLineSeek == (intDivider - 1) && FirstLine == FALSE)){
+ if ((intLineSeek == intDivider && FirstLine == TRUE) ||
+ (intLineSeek == (intDivider - 1) && FirstLine == FALSE)){
- SettingLine.insert(intSeek, wxT("\r\n "));
- intSeek = intSeek + 3;
- SettingLineLen = SettingLineLen + 3;
- intLineSeek = 0;
- intPrevLine = intSeek;
- FirstLine = FALSE;
+ SettingLine.insert(intSeek, wxT("\r\n "));
+ intSeek = intSeek + 3;
+ SettingLineLen = SettingLineLen + 3;
+ intLineSeek = 0;
+ intPrevLine = intSeek;
+ FirstLine = FALSE;
- }
+ }
- intSeek++;
- intLineSeek++;
+ intSeek++;
+ intLineSeek++;
- }
+ }
- SettingFinal.Append(SettingLine);
+ SettingFinal.Append(SettingLine);
- }
+ }
- return SettingFinal;
+ return SettingFinal;
}
bool vCard::MeetBaseSpecification(){
- // Check and see if the vCard object meets the base specification
- // of vCard 4.0.
+
+ // Check and see if the vCard object meets the base specification
+ // of vCard 4.0.
- if (vCardBegin == TRUE && vCardEnd == TRUE && vCardFN == TRUE &&
- vCardVersion == 4.0){
- return TRUE;
- } else {
- return FALSE;
- }
+ if (vCardBegin == TRUE && vCardEnd == TRUE && vCardFN == TRUE &&
+ vCardVersion == 4.0){
+
+ return TRUE;
+
+ } else {
+
+ return FALSE;
+
+ }
}
wxString vCard::Convert(wxString SettingValue, bool ReplaceMode){
- // Check for backslashes used for commas, newlines and
- // backslashes used for values.
+ // Check for backslashes used for commas, newlines and
+ // backslashes used for values.
- if (ReplaceMode == TRUE){
+ if (ReplaceMode == TRUE){
- SettingValue.Replace(wxT("\\n"), wxT("\n"));
- SettingValue.Replace(wxT("\\,"), wxT(","));
- SettingValue.Replace(wxT("\\;"), wxT(";"));
- SettingValue.Replace(wxT("\\\\"), wxT("\\"));
+ SettingValue.Replace(wxT("\\n"), wxT("\n"));
+ SettingValue.Replace(wxT("\\,"), wxT(","));
+ SettingValue.Replace(wxT("\\;"), wxT(";"));
+ SettingValue.Replace(wxT("\\\\"), wxT("\\"));
- } else {
+ } else {
- SettingValue.Replace(wxT("\\"), wxT("\\\\"));
- SettingValue.Replace(wxT("\n"), wxT("\\n"));
- SettingValue.Replace(wxT(","), wxT("\\,"));
- SettingValue.Replace(wxT(";"), wxT("\\;"));
- SettingValue = SettingValue + wxT("\n");
+ SettingValue.Replace(wxT("\\"), wxT("\\\\"));
+ SettingValue.Replace(wxT("\n"), wxT("\\n"));
+ SettingValue.Replace(wxT(","), wxT("\\,"));
+ SettingValue.Replace(wxT(";"), wxT("\\;"));
+ SettingValue = SettingValue + wxT("\n");
- }
+ }
- return SettingValue;
+ return SettingValue;
}
wxString vCard::GetFilename(){
- return vCardFilename;
+ // Get the filename associated with the vCard object.
+
+ return vCardFilename;
}
std::map<int,wxString>* vCard::GetAllCards(){
- return &Cards;
+ // Get all of vCards within the vCard object.
+
+ return &Cards;
}
\ No newline at end of file
bool vCard34Conv::ConvertToV4(wxString *wxSData, vCard *vCardOut){
+ // Convert a vCard 3.0 format into the vCard 4.0 format.
+
std::map<int, wxString> ContactFileLines;
std::map<int, bool> ContactFileProcessed;
std::map<int, bool> ContactFileProcessedWorking;
vCardOut->AddRaw(wxT("VERSION"), wxT("4.0"));
vCardOut->AddRaw(wxT("PRODID"), strVer);
- // FN
- // NICKNAME
- // TITLE
- // ORG
- // NOTE
- // PHOTO
+ // FN
+ // NICKNAME
+ // TITLE
+ // ORG
+ // NOTE
+ // PHOTO
// Process the properties which have X-FIRST.
if (wxSPropertyNextLine.Mid(0, 1) == wxT(" ") || wxSPropertyNextLine.Mid(0, 1) == wxT("\t")){
wxSPropertyNextLine.Remove(0, 1);
- //wxSPropertyNextLine.Trim(FALSE);
- //ContactLine.Trim();
ContactLine.Append(wxSPropertyNextLine);
DataLineProcessOriginal.insert(std::make_pair(DataLineSeekOrig, iterboolsub->first));
DataLineSeekOrig++;
- //iterboolsub->second = TRUE;
-
+
} else {
ExtraLineSeek = FALSE;
for (std::map<int,wxString>::iterator itersub = ContactFileLines.begin();
itersub != ContactFileLines.end(); ++itersub){
- //DataLineProcess = DataLineProcessOriginal;
- //DataLineSeek = DataLineSeekOrig;
-
ContactLineSub = itersub->second;
ExtraLineSeekSub = TRUE;
iterboolsub = ContactFileProcessed.find(itersub->first);
- //std::map<int,bool>::iterator iterorig = ContactFileProcessed.find(itersub->first);
- //std::map<int,bool>::iterator itersuborig;
// Ignore certain variables as they are not needed.
continue;
}
-
- //std::map<int,wxString>::iterator itersub = iter;
DataLineProcess.insert(std::make_pair(DataLineSeek, itersub->first));
DataLineSeek++;
-
-
while (ExtraLineSeekSub == TRUE){
if (itersub == ContactFileLines.end()){
if (wxSPropertyNextLine.Mid(0, 1) == wxT(" ") || wxSPropertyNextLine.Mid(0, 1) == wxT("\t")){
wxSPropertyNextLine.Remove(0, 1);
- //wxSPropertyNextLine.Trim(FALSE);
- //ContactLine.Trim();
ContactLineSub.Append(wxSPropertyNextLine);
- //iterboolsub->second = TRUE;
DataLineProcess.insert(std::make_pair(DataLineSeek, itersub->first));
DataLineSeek++;
}
}
-
- /*while (ExtraLineSeekSub == TRUE && iterboolsub != ContactFileProcessedWorking.end()){
-
- // Check if there is extra data on the next line
- // (indicated by space or tab at the start) and add data.
-
- itersub++;
-
- iterboolsub = ContactFileProcessedWorking.find(itersub->first);
-
- if (iterboolsub->second == TRUE){
-
- continue;
-
- }
-
- if (itersub == ContactFileLines.end()){
-
- break;
-
- }
-
- wxSPropertyNextLine = itersub->second;
-
- if (wxSPropertyNextLine.Mid(0, 1) == wxT(" ") || wxSPropertyNextLine.Mid(0, 1) == wxT("\t")){
-
- wxSPropertyNextLine.Remove(0, 1);
- //wxSPropertyNextLine.Trim(FALSE);
- //ContactLine.Trim();
- ContactLineSub.Append(wxSPropertyNextLine);
- //iterboolsub->second = TRUE;
- DataLineProcess.insert(std::make_pair(DataLineSeek, itersub->first));
- DataLineSeek++;
-
- } else {
-
- itersub--;
- ExtraLineSeekSub = FALSE;
-
- }
-
- if (iterboolsub == ContactFileProcessedWorking.end()){
-
- break;
- ExtraLineSeekSub = FALSE;
-
- }
-
- }*/
ContactLineSubLen = ContactLineSub.Len();
PropertyFind = TRUE;
TempPropertyData.clear();
} else {
-
- wxT("PHOTODANCEMATCH!");
for (std::map<wxString, wxString>::iterator xfiter = TempPropertyData.begin();
xfiter != TempPropertyData.end(); ++xfiter){
wxSPropertyData.Clear();
wxSPropertyXVCard4Value.Clear();
wxSPropertyNameConv.Clear();
- //FinalPropertyData.clear();
- //FinalPropValue.clear();
PropertyData.clear();
PropertyLock.clear();
ContactLine.clear();
if (wxSPropertyNextLine.Mid(0, 1) == wxT(" ") || wxSPropertyNextLine.Mid(0, 1) == wxT("\t")){
wxSPropertyNextLine.Remove(0, 1);
- //wxSPropertyNextLine.Trim(FALSE);
- //ContactLine.Trim();
ContactLine.Append(wxSPropertyNextLine);
iterboolsub->second = TRUE;
wxSPropertyData.Clear();
wxSPropertyXVCard4Value.Clear();
wxSPropertyNameConv.Clear();
- //FinalPropertyData.clear();
- //FinalPropValue.clear();
PropertyData.clear();
PropertyLock.clear();
ContactLine.clear();
size_t ItemStringSeekLen = 0;
int ItemSeekSub = 0;
int ItemSeekSecSub = 0;
- //int intValueSeek = 1;
std::map<int, wxString> NumberedName;
std::map<int, wxString> NumberedData;
SeekItemData = FALSE;
std::map<wxString, void*> ItemMapIndex;
- //std::map<wxString, wxString> ItemNameIndex;
// Look for item in the initial line, process into a proper line then
// look for other lines with the same item association.
// Get Item data.
- //ContactLineSeekSub = ContactLineSeek;
std::map<int,wxString>::iterator itersub = iter;
while (ExtraLineSeek == TRUE){
if (wxSPropertyNextLine.Mid(0, 1) == wxT(" ") || wxSPropertyNextLine.Mid(0, 1) == wxT("\t")){
wxSPropertyNextLine.Remove(0, 1);
- //wxSPropertyNextLine.Trim(FALSE);
- //ContactLine.Trim();
ContactLine.Append(wxSPropertyNextLine);
iterboolsub->second = TRUE;
iterboolsub->second = TRUE;
}
-
- //ItemNameIndex.insert(std::make_pair(ItemStringSeek, ItemPropName));
+
ItemListData->insert(std::make_pair(ItemIndex, ContactLineSub));
ItemMapIndex.insert(std::make_pair(ItemStringSeek, ItemListData));
wxSPropertyData.Clear();
wxSPropertyXVCard4Value.Clear();
wxSPropertyNameConv.Clear();
- //FinalPropertyData.clear();
- //FinalPropValue.clear();
PropertyData.clear();
PropertyLock.clear();
ContactLine.clear();
wxSPropertyData.Clear();
wxSPropertyXVCard4Value.Clear();
wxSPropertyNameConv.Clear();
- //FinalPropertyData.clear();
- //FinalPropValue.clear();
PropertyData.clear();
PropertyLock.clear();
ContactLine.clear();
VCard3Value = FALSE;
TempData.clear();
- //PropertyData.clear();
- //PropertyLock.clear();
}