X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Fcontacteditor%2FfrmContactEditor-Save.cpp;h=766241800ba09a8cdf5ec0f1b08335be932d8aaa;hb=4f4ef609869729894a13a7e37b6aa5ea0ddaa32b;hp=f366f70df2cf054e9c3c5f4b8f400815795d109e;hpb=d01fbb460cbece5de883964f5824457e3c50f11d;p=xestiaab%2F.git diff --git a/source/contacteditor/frmContactEditor-Save.cpp b/source/contacteditor/frmContactEditor-Save.cpp index f366f70..7662418 100644 --- a/source/contacteditor/frmContactEditor-Save.cpp +++ b/source/contacteditor/frmContactEditor-Save.cpp @@ -173,6 +173,87 @@ void frmContactEditor::SaveContact( wxCommandEvent& event ) ContactData.Add(wxT("PRODID"), strValue, FALSE); + // Process the REV property. + + wxDateTime DateTimeSave; + DateTimeSave = DateTimeSave.SetToCurrent(); + wxString DateTimeSaveValue; + + DateTimeSaveValue += wxString::Format("%04i", DateTimeSave.GetYear()); + DateTimeSaveValue += wxString::Format("%02i", (DateTimeSave.GetMonth() + 1)); + DateTimeSaveValue += wxString::Format("%02i", DateTimeSave.GetDay()); + DateTimeSaveValue += "T"; + DateTimeSaveValue += wxString::Format("%02i", DateTimeSave.GetHour()); + DateTimeSaveValue += wxString::Format("%02i", DateTimeSave.GetMinute()); + DateTimeSaveValue += wxString::Format("%02i", DateTimeSave.GetSecond()); + + if (!ContactEditorData.RevisionTokens.IsEmpty()){ + ContactData.AddRaw("REV;" + ContactEditorData.RevisionTokens, DateTimeSaveValue); + } else { + ContactData.AddRaw("REV", DateTimeSaveValue); + } + // Process the XML properties. + + for (std::map::iterator iter = ContactEditorData.XMLList.begin(); + iter != ContactEditorData.XMLList.end(); ++iter){ + + wxString strOrigValue; + + strOrigValue = ContactEditorData.XMLList.find(iter->first)->second; + + ResetUnusedString(&strOrigValue); + + ProcessSaveData(wxT("XML"), &strValue2, &boolValue2, &boolValue, + &iter, &strOrigValue, &ContactData, + wxT("ALTID"), &ContactEditorData.XMLListAltID ); + + ResetSaveProcessData(); + + } + + // Process the CLIENTPIDMAP properties. + + for (std::map::iterator iter = ContactEditorData.ClientPIDList.begin(); + iter != ContactEditorData.ClientPIDList.end(); ++iter){ + + wxString strOrigValue; + + strOrigValue = ContactEditorData.ClientPIDList.find(iter->first)->second; + + ResetUnusedString(&strOrigValue); + + ProcessSaveData(wxT("CLIENTPIDMAP"), &strValue2, &boolValue2, &boolValue, + &iter, &strOrigValue, &ContactData, + wxT(""), &ContactEditorData.ClientPIDListTokens ); + + ResetSaveProcessData(); + + } + + // Process the SOURCE properties. + + for (std::map::iterator iter = ContactEditorData.SourceList.begin(); + iter != ContactEditorData.SourceList.end(); ++iter){ + + wxString strOrigValue; + + strOrigValue = ContactEditorData.SourceList.find(iter->first)->second; + + ResetUnusedString(&strOrigValue); + + ProcessSaveData(wxT("SOURCE"), &strValue2, &boolValue2, &boolValue, + &iter, &strOrigValue, &ContactData, + wxT("ALTID"), &ContactEditorData.SourceListAltID, + wxT("PID"), &ContactEditorData.SourceListPID, + wxT("TYPE"), &ContactEditorData.SourceListType, + wxT("PREF"), &ContactEditorData.SourceListPref, + wxT("MEDIATYPE"), &ContactEditorData.SourceListMediatype, + wxT(""), &ContactEditorData.SourceListTokens ); + + ResetSaveProcessData(); + + } + // Setup the name. strValue.Clear(); @@ -306,91 +387,89 @@ void frmContactEditor::SaveContact( wxCommandEvent& event ) } - strValue.Clear(); - strValue2.Clear(); - strValue3.Clear(); + ResetSaveProcessData(); - boolValue = FALSE; - boolValue2 = FALSE; - intValue2 = 0; - intValue = 0; + // Build the values for the BDAY property. + + // ALTID + + if (!ContactEditorData.BirthdayAltID.IsEmpty()){ - // Process Label. + wxString DataValue; + DataValue = ContactEditorData.BirthdayAltID; - strValue3 = ContactEditorData.BirthdayAltID; + EscapeString(&DataValue, FALSE); + + strValue3.Append("ALTID="); + strValue3.Append(DataValue); + + boolValue2 = TRUE; - if (!strValue3.IsEmpty()){ - - strValue3.Trim(); - strValue3.Trim(); - boolValue2 = TRUE; - strValue2.Append(wxT("ALTID=\"") + strValue3 + wxT("\"")); - - boolValue = TRUE; - } - //strValue3 = ContactData.Convert(GeneralAddressList, FALSE); - //strValue2 = + // CALSCALE. - // Process Language. + if (!ContactEditorData.BirthdayCalScale.IsEmpty()){ - strValue3 = ContactEditorData.BirthdayCalScale; + wxString DataValue; + DataValue = ContactEditorData.BirthdayCalScale; - if (!strValue3.IsEmpty()){ - - strValue3.Trim(); - strValue3.Trim(); - - if (boolValue2 == TRUE){ - - strValue2.Append(wxT(";")); - - } else { - - boolValue2 = TRUE; - - } - - strValue2.Append(wxT("CALSCALE=") + strValue3); - - boolValue = TRUE; - - } + EscapeString(&DataValue, FALSE); - // Process Tokens. + if (boolValue2 == TRUE){ + + strValue3.Append(";"); + + } + + strValue3.Append("CALSCALE="); + strValue3.Append(DataValue); + + boolValue2 = TRUE; - strValue2 = ContactEditorData.BirthdayTokens; + } - // Get the birthday and write it. + // Extra tokens. - ResetSaveProcessData(); + if (!ContactEditorData.BirthdayTokens.IsEmpty()){ + + wxString DataValue; + DataValue = ContactEditorData.BirthdayTokens; + + EscapeString(&DataValue, FALSE); + + if (boolValue2 == TRUE){ + + strValue3.Append(";"); + + } + + strValue3.Append(DataValue); + } + + // Write the BDAY property. + if (!txtBirthday->IsEmpty()){ - - strValue = txtBirthday->GetValue(); - - if (!strValue.IsEmpty() || !strValue2.IsEmpty()){ - - if (!strValue2.IsEmpty()){ - - EscapeString(&strValue2, FALSE); - EscapeString(&strValue, FALSE); - - ContactData.AddRaw(wxT("BDAY;VALUE=text;") + strValue2 + wxT(";"), strValue); - - } else { - - EscapeString(&strValue, FALSE); - - ContactData.AddRaw(wxT("BDAY;VALUE=text"), strValue); - - } - - } - + + if (!txtBirthday->GetValue().IsEmpty()){ + + strValue = txtBirthday->GetValue(); + + if (!strValue3.IsEmpty()){ + + ContactData.AddRaw("BDAY;VALUE=text;" + strValue3, strValue); + + } else { + + ContactData.AddRaw("BDAY;VALUE=text", strValue); + + } + + } + } else { - + // Deal with date. // Get Day, Month & Year. @@ -478,14 +557,14 @@ void frmContactEditor::SaveContact( wxCommandEvent& event ) } - if (!FinalBirthdayString.IsEmpty() || !strValue2.IsEmpty()){ + if (!FinalBirthdayString.IsEmpty() || !strValue3.IsEmpty()){ - if (!strValue2.IsEmpty()){ + if (!strValue3.IsEmpty()){ EscapeString(&strValue2, FALSE); EscapeString(&strValue, FALSE); - ContactData.AddRaw(wxT("BDAY") + strValue2 + wxT(";"), FinalBirthdayString); + ContactData.AddRaw(wxT("BDAY;") + strValue3, FinalBirthdayString); } else { @@ -498,85 +577,92 @@ void frmContactEditor::SaveContact( wxCommandEvent& event ) } } - + } ResetSaveProcessData(); - // Process Label. + // Build the values for the ANNIVERSARY property. + + // ALTID + + if (!ContactEditorData.AnniversaryAltID.IsEmpty()){ - strValue3 = ContactEditorData.AnniversaryAltID; + wxString DataValue; + DataValue = ContactEditorData.AnniversaryAltID; + + EscapeString(&DataValue, FALSE); + + strValue3.Append("ALTID="); + strValue3.Append(DataValue); + + boolValue2 = TRUE; - if (!strValue3.IsEmpty()){ - - strValue3.Trim(); - strValue3.Trim(); - boolValue2 = TRUE; - strValue2.Append(wxT("ALTID=\"") + strValue3 + wxT("\"")); - - boolValue = TRUE; - } - //strValue3 = ContactData.Convert(GeneralAddressList, FALSE); - //strValue2 = + // CALSCALE. - // Process Language. + if (!ContactEditorData.AnniversaryCalScale.IsEmpty()){ - strValue3 = ContactEditorData.AnniversaryCalScale; + wxString DataValue; + DataValue = ContactEditorData.AnniversaryCalScale; + + EscapeString(&DataValue, FALSE); + + if (boolValue2 == TRUE){ + + strValue3.Append(";"); + + } + + strValue3.Append("CALSCALE="); + strValue3.Append(DataValue); + + boolValue2 = TRUE; - if (!strValue3.IsEmpty()){ - - strValue3.Trim(); - strValue3.Trim(); - - if (boolValue2 == TRUE){ - - strValue2.Append(wxT(";")); - - } else { - - boolValue2 = TRUE; - - } - - strValue2.Append(wxT("CALSCALE=") + strValue3); - - boolValue = TRUE; - } - // Process Tokens. + // Extra tokens. - strValue2 = ContactEditorData.AnniversaryTokens; + if (!ContactEditorData.AnniversaryTokens.IsEmpty()){ - // Deal with ANNIVERSARY. + wxString DataValue; + DataValue = ContactEditorData.AnniversaryTokens; + + EscapeString(&DataValue, FALSE); + + if (boolValue2 == TRUE){ + + strValue3.Append(";"); + + } + + strValue3.Append(DataValue); + + } + + // Write the ANNIVERSARY property. if (!txtAnniversary->IsEmpty()){ - - strValue = txtAnniversary->GetValue(); - - if (!strValue.IsEmpty() || !strValue2.IsEmpty()){ - - if (!strValue2.IsEmpty()){ - - EscapeString(&strValue2, FALSE); - EscapeString(&strValue, FALSE); - - ContactData.AddRaw(wxT("ANNIVERSARY;VALUE=text;") + strValue2 + wxT(";"), strValue); - - } else { - - EscapeString(&strValue, FALSE); - - ContactData.AddRaw(wxT("ANNIVERSARY;VALUE=text"), strValue); - - } - - } - + + if (!txtAnniversary->GetValue().IsEmpty()){ + + strValue = txtAnniversary->GetValue(); + + if (!strValue3.IsEmpty()){ + + ContactData.AddRaw("ANNIVERSARY;VALUE=text;" + strValue3, strValue); + + } else { + + ContactData.AddRaw("ANNIVERSARY;VALUE=text", strValue); + + } + + } + } else { - + // Look for T and replace data before this. // Get Day, Month & Year. @@ -664,14 +750,14 @@ void frmContactEditor::SaveContact( wxCommandEvent& event ) } - if (!FinalAnniversaryString.IsEmpty() || !strValue2.IsEmpty()){ + if (!FinalAnniversaryString.IsEmpty() || !strValue3.IsEmpty()){ - if (!strValue2.IsEmpty()){ + if (!strValue3.IsEmpty()){ EscapeString(&strValue2, FALSE); EscapeString(&strValue, FALSE); - ContactData.AddRaw(wxT("ANNIVERSARY") + strValue2 + wxT(";"), FinalAnniversaryString); + ContactData.AddRaw(wxT("ANNIVERSARY;") + strValue3, FinalAnniversaryString); } else { @@ -684,14 +770,13 @@ void frmContactEditor::SaveContact( wxCommandEvent& event ) } } - - } + } + // Setup the addresses (General, Home, Business). - //intValue = GeneralAddressList.size(); ResetSaveProcessData(); - + for (std::map::iterator iter = ContactEditorData.GeneralAddressList.begin(); iter != ContactEditorData.GeneralAddressList.end(); ++iter){ @@ -1016,10 +1101,28 @@ void frmContactEditor::SaveContact( wxCommandEvent& event ) intValue2 = iter->first; + wxString strIMFinalValue = iter->second; + + ProcessCaptureStrings(&strIMFinalValue); + + if (ContactEditorData.GeneralIMListTypeInfo.find(iter->first) != + ContactEditorData.GeneralIMListTypeInfo.end()){ + + std::map::iterator DataTypeIter = ContactEditorData.GeneralIMListTypeInfo.find(iter->first); + + strIMFinalValue.insert(0, ":"); + strIMFinalValue.insert(0, DataTypeIter->second); + + } else { + + strIMFinalValue.insert(0, "none:"); + + } + // Process Alternative ID. ProcessSaveData(wxT("IMPP"), &strValue2, &boolValue2, &boolValue, - &iter, &ContactEditorData.GeneralIMList, &ContactData, + &iter, &strIMFinalValue, &ContactData, wxT("ALTID"), &ContactEditorData.GeneralIMListAltID, wxT("PID"), &ContactEditorData.GeneralIMListPID, wxT("MEDIATYPE"), &ContactEditorData.GeneralIMListMediatype, @@ -1035,6 +1138,24 @@ void frmContactEditor::SaveContact( wxCommandEvent& event ) for (std::map::iterator iter = ContactEditorData.HomeIMList.begin(); iter != ContactEditorData.HomeIMList.end(); ++iter){ + wxString strIMFinalValue = iter->second; + + ProcessCaptureStrings(&strIMFinalValue); + + if (ContactEditorData.HomeIMListTypeInfo.find(iter->first) != + ContactEditorData.HomeIMListTypeInfo.end()){ + + std::map::iterator DataTypeIter = ContactEditorData.HomeIMListTypeInfo.find(iter->first); + + strIMFinalValue.insert(0, ":"); + strIMFinalValue.insert(0, DataTypeIter->second); + + } else { + + strIMFinalValue.insert(0, "none:"); + + } + ProcessSaveData(wxT("IMPP;TYPE=home"), &strValue2, &boolValue2, &boolValue, &iter, &ContactEditorData.HomeIMList, &ContactData, wxT("ALTID"), &ContactEditorData.HomeIMListAltID, @@ -1052,6 +1173,24 @@ void frmContactEditor::SaveContact( wxCommandEvent& event ) for (std::map::iterator iter = ContactEditorData.BusinessIMList.begin(); iter != ContactEditorData.BusinessIMList.end(); ++iter){ + wxString strIMFinalValue = iter->second; + + ProcessCaptureStrings(&strIMFinalValue); + + if (ContactEditorData.BusinessIMListTypeInfo.find(iter->first) != + ContactEditorData.BusinessIMListTypeInfo.end()){ + + std::map::iterator DataTypeIter = ContactEditorData.BusinessIMListTypeInfo.find(iter->first); + + strIMFinalValue.insert(0, ":"); + strIMFinalValue.insert(0, DataTypeIter->second); + + } else { + + strIMFinalValue.insert(0, "none:"); + + } + ProcessSaveData(wxT("IMPP;TYPE=work"), &strValue2, &boolValue2, &boolValue, &iter, &ContactEditorData.BusinessIMList, &ContactData, wxT("ALTID"), &ContactEditorData.BusinessIMListAltID, @@ -1070,11 +1209,11 @@ void frmContactEditor::SaveContact( wxCommandEvent& event ) iter != ContactEditorData.GeneralTelephoneList.end(); ++iter){ wxString strAddressFinalValue = iter->second; + int DataID = iter->first; ProcessCaptureStrings(&strAddressFinalValue); - if (ContactEditorData.GeneralTelephoneListDataType.find(iter->first) != - ContactEditorData.GeneralTelephoneListDataType.end()){ + if (MapDataExists(&DataID, &ContactEditorData.GeneralTelephoneListDataType)){ std::map::iterator DataTypeIter = ContactEditorData.GeneralTelephoneListDataType.find(iter->first); @@ -1087,11 +1226,19 @@ void frmContactEditor::SaveContact( wxCommandEvent& event ) } + wxString strAddressTypeInfo; + + if (MapDataExists(&DataID, &ContactEditorData.GeneralTelephoneListTypeInfo)){ + + strAddressTypeInfo = ContactEditorData.GeneralTelephoneListTypeInfo.find(iter->first)->second; + + } + ProcessSaveData(wxT("TEL"), &strValue2, &boolValue2, &boolValue, &iter, &strAddressFinalValue, &ContactData, wxT("ALTID"), &ContactEditorData.GeneralTelephoneListAltID, wxT("PID"), &ContactEditorData.GeneralTelephoneListPID, - wxT("TYPE"), &ContactEditorData.GeneralTelephoneListType, + wxT("TYPE"), &ContactEditorData.GeneralTelephoneListTypeInfo, wxT("PREF"), &ContactEditorData.GeneralTelephoneListPref, wxT(""), &ContactEditorData.GeneralTelephoneListTokens ); @@ -1121,12 +1268,12 @@ void frmContactEditor::SaveContact( wxCommandEvent& event ) strAddressFinalValue.insert(0, "tel:"); } - + ProcessSaveData(wxT("TEL"), &strValue2, &boolValue2, &boolValue, &iter, &strAddressFinalValue, &ContactData, wxT("ALTID"), &ContactEditorData.HomeTelephoneListAltID, wxT("PID"), &ContactEditorData.HomeTelephoneListPID, - wxT("TYPE"), &ContactEditorData.HomeTelephoneListType, + wxT("TYPE"), &ContactEditorData.HomeTelephoneListTypeInfo, wxT("PREF"), &ContactEditorData.HomeTelephoneListPref, wxT(""), &ContactEditorData.HomeTelephoneListTokens ); @@ -1156,12 +1303,12 @@ void frmContactEditor::SaveContact( wxCommandEvent& event ) strAddressFinalValue.insert(0, "tel:"); } - + ProcessSaveData(wxT("TEL"), &strValue2, &boolValue2, &boolValue, &iter, &strAddressFinalValue, &ContactData, wxT("ALTID"), &ContactEditorData.BusinessTelephoneListAltID, wxT("PID"), &ContactEditorData.BusinessTelephoneListPID, - wxT("TYPE"), &ContactEditorData.BusinessTelephoneListType, + wxT("TYPE"), &ContactEditorData.BusinessTelephoneListTypeInfo, wxT("PREF"), &ContactEditorData.BusinessTelephoneListPref, wxT(""), &ContactEditorData.BusinessTelephoneListTokens ); @@ -1275,14 +1422,26 @@ void frmContactEditor::SaveContact( wxCommandEvent& event ) for (std::map::iterator iter = ContactEditorData.GeneralGeographyList.begin(); iter != ContactEditorData.GeneralGeographyList.end(); ++iter){ - wxString strAddressFinalValue = iter->second; + wxString strGeoFinalValue = iter->second; - ProcessCaptureStrings(&strAddressFinalValue); + ProcessCaptureStrings(&strGeoFinalValue); - strAddressFinalValue.insert(0, wxT("geo:")); + if (ContactEditorData.GeneralGeographyListDataType.find(iter->first) != + ContactEditorData.GeneralGeographyListDataType.end()){ + + std::map::iterator DataTypeIter = ContactEditorData.GeneralGeographyListDataType.find(iter->first); + + strGeoFinalValue.insert(0, ":"); + strGeoFinalValue.insert(0, DataTypeIter->second); + + } else { + + strGeoFinalValue.insert(0, "geo:"); + + } ProcessSaveData(wxT("GEO"), &strValue2, &boolValue2, &boolValue, - &iter, &strAddressFinalValue, &ContactData, + &iter, &strGeoFinalValue, &ContactData, wxT("ALTID"), &ContactEditorData.GeneralGeographyListAltID, wxT("PID"), &ContactEditorData.GeneralGeographyListPID, wxT("MEDIATYPE"), &ContactEditorData.GeneralGeographyListMediatype, @@ -1298,14 +1457,26 @@ void frmContactEditor::SaveContact( wxCommandEvent& event ) for (std::map::iterator iter = ContactEditorData.HomeGeographyList.begin(); iter != ContactEditorData.HomeGeographyList.end(); ++iter){ - wxString strAddressFinalValue = iter->second; + wxString strGeoFinalValue = iter->second; - ProcessCaptureStrings(&strAddressFinalValue); + ProcessCaptureStrings(&strGeoFinalValue); - strAddressFinalValue.insert(0, wxT("geo:")); + if (ContactEditorData.HomeGeographyListDataType.find(iter->first) != + ContactEditorData.HomeGeographyListDataType.end()){ + + std::map::iterator DataTypeIter = ContactEditorData.HomeGeographyListDataType.find(iter->first); + + strGeoFinalValue.insert(0, ":"); + strGeoFinalValue.insert(0, DataTypeIter->second); + + } else { + + strGeoFinalValue.insert(0, "geo:"); + + } ProcessSaveData(wxT("GEO;TYPE=home"), &strValue2, &boolValue2, &boolValue, - &iter, &ContactEditorData.HomeGeographyList, &ContactData, + &iter, &strGeoFinalValue, &ContactData, wxT("ALTID"), &ContactEditorData.HomeGeographyListAltID, wxT("PID"), &ContactEditorData.HomeGeographyListPID, wxT("MEDIATYPE"), &ContactEditorData.HomeGeographyListMediatype, @@ -1321,14 +1492,26 @@ void frmContactEditor::SaveContact( wxCommandEvent& event ) for (std::map::iterator iter = ContactEditorData.BusinessGeographyList.begin(); iter != ContactEditorData.BusinessGeographyList.end(); ++iter){ - wxString strAddressFinalValue = iter->second; + wxString strGeoFinalValue = iter->second; - ProcessCaptureStrings(&strAddressFinalValue); + ProcessCaptureStrings(&strGeoFinalValue); - strAddressFinalValue.insert(0, wxT("geo:")); + if (ContactEditorData.BusinessGeographyListDataType.find(iter->first) != + ContactEditorData.BusinessGeographyListDataType.end()){ + + std::map::iterator DataTypeIter = ContactEditorData.BusinessGeographyListDataType.find(iter->first); + + strGeoFinalValue.insert(0, ":"); + strGeoFinalValue.insert(0, DataTypeIter->second); + + } else { + + strGeoFinalValue.insert(0, "geo:"); + + } ProcessSaveData(wxT("GEO;TYPE=work"), &strValue2, &boolValue2, &boolValue, - &iter, &ContactEditorData.BusinessGeographyList, &ContactData, + &iter, &strGeoFinalValue, &ContactData, wxT("ALTID"), &ContactEditorData.BusinessGeographyListAltID, wxT("PID"), &ContactEditorData.BusinessGeographyListPID, wxT("MEDIATYPE"), &ContactEditorData.BusinessGeographyListMediatype, @@ -1783,23 +1966,17 @@ void frmContactEditor::SaveContact( wxCommandEvent& event ) wxString strValueData; strValueData = iter->second; - //strValueData.insert(0, wxT("data:") + striter->second + wxT(";") + enciter->second + wxT(",")); - strValueData.insert(0, wxT("data:") + striter->second + wxT(";base64,")); - - - // Add to the vCard. - - if (boolValue == TRUE){ - - ContactData.AddRaw(wxT("KEY;") + strValue2, strValueData); - - } else { - - ContactData.Add(wxT("KEY"), strValueData, TRUE); - - } + strValueData.insert(0, wxT("data:") + striter->second + wxT(";base64,")); + + ProcessSaveData(wxT("KEY"), &strValue2, &boolValue2, &boolValue, + &iter, &strValueData, &ContactData, + wxT("ALTID"), &ContactEditorData.KeyListAltID, + wxT("PID"), &ContactEditorData.KeyListPID, + wxT("TYPE"), &ContactEditorData.KeyListType, + wxT("PREF"), &ContactEditorData.KeyListPref, + wxT(""), &ContactEditorData.KeyListTokens ); - ResetSaveProcessData(); + ResetSaveProcessData(); }