X-Git-Url: http://Server1/repobrowser/?p=xestiaab%2F.git;a=blobdiff_plain;f=source%2Fvcard%2Fvcard.cpp;h=fb34ab4bab8439c9e9aaee0e49873e6acd6ee354;hp=a25f2dca113a084cf164df92ab68007b7d3dec10;hb=2031be04c0036b44c40c473a07fdd31e898b2a11;hpb=e683ccaef66d6f0e695c7b2fc1b4b930e9497e8f diff --git a/source/vcard/vcard.cpp b/source/vcard/vcard.cpp index a25f2dc..fb34ab4 100644 --- a/source/vcard/vcard.cpp +++ b/source/vcard/vcard.cpp @@ -27,6 +27,8 @@ vCard::vCard(){ + // Setup the vCard object. + vCardBegin = FALSE; vCardEnd = FALSE; vCardFN = FALSE; @@ -37,6 +39,8 @@ vCard::vCard(){ void vCard::Add(wxString SettingName, wxString SettingValue, bool ReplaceMode){ + // Add data to vCard object. + // Check for backslashes used for commas, newlines and // backslashes used for values. @@ -101,6 +105,8 @@ void vCard::Add(wxString SettingName, wxString SettingValue, bool ReplaceMode){ void vCard::AddRaw(wxString SettingName, wxString SettingValue){ + // Add data to the vCard in raw mode. + // Check data to make sure that it meets the required // vCard 4.0 specifications. @@ -145,10 +151,12 @@ void vCard::AddRaw(wxString SettingName, wxString SettingValue){ wxString vCard::Get(wxString SettingName){ + // Get values from the vCard object. + wxString SettingValue; // Look for the setting name. - + for (int i = 0; i < SettingCount; i++){ if (SettingNames[i] == SettingName){ @@ -177,9 +185,20 @@ wxString vCard::Get(wxString SettingName){ vCardName vCard::GetName(){ + // Get the name from the vCard object. + vCardName NameData; ArrayvCardOutData NameArray = this->GetByPartial(wxT("N")); //wxString NameDataGet = NameArray.PropValues[0]; + + if (NameArray.PropValues.Count() == 0) + { + // Use FN if there is no N values set. + wxString fullName = this->Get(wxT("FN")); + NameData.Forename = fullName; + return NameData; + } + wxString NameDataGet = NameArray.PropValues[0]; std::map SplitPoints; std::map SplitLength; @@ -188,7 +207,6 @@ vCardName vCard::GetName(){ // Process the name data to get the required information. int intPropertyLen = NameDataGet.Len(); - int intSplitSeek = 0; int intSplitsFound = 0; int intSplitSize = 0; int intPrevValue = 0; @@ -270,6 +288,8 @@ vCardName vCard::GetName(){ ArrayvCardOutData vCard::GetByPartial(wxString SettingName){ + // Get data from the vCard object based on a partial match. + ArrayvCardOutData vCardOutData; wxArrayString SettingList; wxString SettingValueCurrent; @@ -346,6 +366,8 @@ ArrayvCardOutData vCard::GetByPartial(wxString SettingName){ wxString vCard::GetById(int id){ + // Get data from the vCard object based on ID. + // Unimplemented. return wxT(""); @@ -353,6 +375,8 @@ wxString vCard::GetById(int id){ int vCard::WriteFile(wxString WriteFilename){ + // Write the vCard to a file using the WriteFilename given. + // Open the file and begin writing data into the file. wxString SettingName; @@ -372,10 +396,8 @@ int vCard::WriteFile(wxString WriteFilename){ 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. @@ -389,7 +411,6 @@ int vCard::WriteFile(wxString WriteFilename){ intSeek = intSeek + 3; SettingLineLen = SettingLineLen + 3; intLineSeek = 0; - intPrevLine = intSeek; FirstLine = FALSE; } @@ -398,26 +419,6 @@ int vCard::WriteFile(wxString WriteFilename){ intLineSeek++; } - - /* - - for (int x = 0; x < intTimes; x++){ - - if (x == 0){ - SettingLine.insert((intDivider - 1), wxT("\r\n ")); - } else if (x == intTimes){ - - } else { - if (x < intDivider){ - SettingLine.insert((intDivider * (x+1)) + (x * 3), wxT("\r\n ")); - } - } - - intTimes = floor(SettingLine.Len() / intDivider); - - } - - */ ContactFile.Write(SettingLine); @@ -431,14 +432,16 @@ int vCard::WriteFile(wxString WriteFilename){ int vCard::LoadFile(wxString LoadFilename){ + // Load data from a file using the LoadFilename given. + wxFFile ContactFile; wxString wxSContactString; 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")); @@ -464,6 +467,8 @@ int vCard::LoadFile(wxString LoadFilename){ int vCard::LoadString(wxString ContactData){ + // Load data from a wxString. + ProcessString(&ContactData); return 0; @@ -472,6 +477,8 @@ int vCard::LoadString(wxString ContactData){ void vCard::ProcessString(wxString *ContactDataInc){ + // Process data from a wxString pointer. + // Split the vCards (if there are more than one vCard in the file). wxString ContactLine; @@ -489,7 +496,6 @@ void vCard::ProcessString(wxString *ContactDataInc){ wxString wxSPropertySeg2; bool FoundBegin = FALSE; - bool FoundEnd = FALSE; bool FirstContact = TRUE; wxString FirstContactData; wxString ContactData; @@ -673,6 +679,8 @@ void vCard::ProcessString(wxString *ContactDataInc){ wxString vCard::WriteString(){ + // Write the vCard file into a wxString. + // Open the file and begin writing data into the file. wxString SettingName; @@ -688,10 +696,8 @@ wxString vCard::WriteString(){ 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. @@ -705,7 +711,6 @@ wxString vCard::WriteString(){ intSeek = intSeek + 3; SettingLineLen = SettingLineLen + 3; intLineSeek = 0; - intPrevLine = intSeek; FirstLine = FALSE; } @@ -769,12 +774,16 @@ wxString vCard::Convert(wxString SettingValue, bool ReplaceMode){ wxString vCard::GetFilename(){ + // Get the filename associated with the vCard object. + return vCardFilename; } std::map* vCard::GetAllCards(){ + // Get all of vCards within the vCard object. + return &Cards; } \ No newline at end of file