// Save the updated contact data.
- vCard ContactData;
+ //vCard ContactData;
wxString FilenameFinal;
bool ReplaceContact = FALSE;
std::map<int,int>::iterator intiter;
std::map<int,wxString>::iterator striter;
- ContactData.Add(wxT("BEGIN"), wxT("VCARD"), FALSE);
+ // Set some values for saving.
+
+ ContactEditorData.NameForename = txtForename->GetValue();
+ ContactEditorData.NameSurname = txtSurname->GetValue();
+ ContactEditorData.NameOtherNames = txtOtherNames->GetValue();
+ ContactEditorData.NameTitle = txtTitle->GetValue();
+ ContactEditorData.NameSuffix = txtSuffix->GetValue();
+
+ ContactEditorData.GenderDetails = txtGenderDescription->GetValue();
+
+ // Process Birthday: Get Day, Month & Year.
+
+ wxDateTime BirthdayDate;
+ wxDateTime::Month BirthdayMonth;
+ int BirthdayDay;
+ int BirthdayYear;
+ wxString DataBeforeT;
+ wxString DataAfterT;
+ wxString FinalBirthdayString;
+ bool ProcessDataAfterT = FALSE;
+
+ BirthdayDate = dapBirthday->GetValue();
+
+ if (!txtBirthday->IsEmpty()){
+
+ // Birthday value is text so use this.
+
+ ContactEditorData.Birthday = txtBirthday->GetValue();
+
+ } else if (BirthdayDate.IsValid()){
+
+ BirthdayDay = BirthdayDate.GetDay();
+ BirthdayMonth = BirthdayDate.GetMonth();
+ BirthdayYear = BirthdayDate.GetYear();
+
+ // Look for T and replace data before this.
+
+ wxStringTokenizer wSTDate(ContactEditorData.Birthday, wxT("T"));
+
+ while (wSTDate.HasMoreTokens()){
+
+ if (ProcessDataAfterT == FALSE){
+
+ DataBeforeT = wSTDate.GetNextToken();
+ ProcessDataAfterT = TRUE;
+
+ } else {
+
+ DataAfterT = wSTDate.GetNextToken();
+ break;
+
+ }
+
+ }
+
+ // If there is not T then replace altogether.
+
+ wxString FinalBirthdayDay;
+ wxString FinalBirthdayMonth;
+ wxString FinalBirthdayYear;
+
+ if (BirthdayDay < 10){
+
+ FinalBirthdayDay = wxT("0") + wxString::Format(wxT("%i"), BirthdayDay);
+
+ } else {
+
+ FinalBirthdayDay = wxString::Format(wxT("%i"), BirthdayDay);
+
+ }
+
+ if (((int)BirthdayMonth + 1) < 10){
+
+ FinalBirthdayMonth = wxT("0") + wxString::Format(wxT("%i"), ((int)BirthdayMonth + 1));
+
+ } else {
+
+ FinalBirthdayMonth = wxString::Format(wxT("%i"), ((int)BirthdayMonth + 1));
+
+ }
+
+ if (BirthdayYear == 0){
+
+ FinalBirthdayYear = wxT("--");
+
+ } else {
+
+ FinalBirthdayYear = wxString::Format(wxT("%i"), BirthdayYear);
+
+ }
+
+ if (!DataAfterT.IsEmpty()){
+
+ FinalBirthdayString = FinalBirthdayYear + FinalBirthdayMonth + FinalBirthdayDay + wxT("T") + DataAfterT;
+
+ } else {
+
+ FinalBirthdayString = FinalBirthdayYear + FinalBirthdayMonth + FinalBirthdayDay;
+
+ }
+
+ if(!FinalBirthdayString.IsEmpty()){
+
+ ContactEditorData.Birthday = FinalBirthdayString;
+
+ }
+
+ }
+
+ // Process Anniversary: Get Day, Month & Year.
+
+ wxDateTime AnniversaryDate;
+ wxDateTime::Month AnniversaryMonth;
+ int AnniversaryDay;
+ int AnniversaryYear;
+ DataBeforeT = "";
+ DataAfterT = "";
+ wxString FinalAnniversaryString;
+ ProcessDataAfterT = FALSE;
+
+ AnniversaryDate = dapAnniversary->GetValue();
+
+ if (!txtAnniversary->IsEmpty()){
+
+ // Birthday value is text so use this.
+
+ ContactEditorData.Anniversary = txtAnniversary->GetValue();
+
+ } else if (AnniversaryDate.IsValid()){
+
+ AnniversaryDay = AnniversaryDate.GetDay();
+ AnniversaryMonth = AnniversaryDate.GetMonth();
+ AnniversaryYear = AnniversaryDate.GetYear();
+
+ // Look for T and replace data before this.
+
+ wxStringTokenizer wSTDate(ContactEditorData.Anniversary, wxT("T"));
+
+ while (wSTDate.HasMoreTokens()){
+
+ if (ProcessDataAfterT == FALSE){
+
+ DataBeforeT = wSTDate.GetNextToken();
+ ProcessDataAfterT = TRUE;
+
+ } else {
+
+ DataAfterT = wSTDate.GetNextToken();
+ break;
+
+ }
+
+ }
+
+ // If there is not T then replace altogether.
+
+ wxString FinalAnniversaryDay;
+ wxString FinalAnniversaryMonth;
+ wxString FinalAnniversaryYear;
+
+ if (AnniversaryDay < 10){
+
+ FinalAnniversaryDay = wxT("0") + wxString::Format(wxT("%i"), AnniversaryDay);
+
+ } else {
+
+ FinalAnniversaryDay = wxString::Format(wxT("%i"), AnniversaryDay);
+
+ }
+
+ if (((int)AnniversaryMonth + 1) < 10){
+
+ FinalAnniversaryMonth = wxT("0") + wxString::Format(wxT("%i"), ((int)AnniversaryMonth + 1));
+
+ } else {
+
+ FinalAnniversaryMonth = wxString::Format(wxT("%i"), ((int)AnniversaryMonth + 1));
+
+ }
+
+ if (AnniversaryYear == 0){
+
+ FinalAnniversaryYear = wxT("--");
+
+ } else {
+
+ FinalAnniversaryYear = wxString::Format(wxT("%i"), AnniversaryYear);
+
+ }
+
+ if (!DataAfterT.IsEmpty()){
+
+ FinalAnniversaryString = FinalAnniversaryYear + FinalAnniversaryMonth + FinalAnniversaryDay + wxT("T") + DataAfterT;
+
+ } else {
+
+ FinalAnniversaryString = FinalAnniversaryYear + FinalAnniversaryMonth + FinalAnniversaryDay;
+
+ }
+
+ if(!FinalAnniversaryString.IsEmpty()){
+
+ ContactEditorData.Birthday = FinalAnniversaryString;
+
+ }
+
+ }
+
+ // Process full name.
+
+ if (ContactEditorData.FullNamesList.size() > 0){
+
+ ContactEditorData.FullNamesList[0] = cmbDisplayAs->GetValue();
+
+ } else {
+
+ ContactEditorData.FullNamesList.insert(std::make_pair(0, cmbDisplayAs->GetValue()));
+ ContactEditorData.FullNamesListAltID.insert(std::make_pair(0, wxT("")));
+ ContactEditorData.FullNamesListPID.insert(std::make_pair(0, wxT("")));
+ ContactEditorData.FullNamesListType.insert(std::make_pair(0, wxT("")));
+ ContactEditorData.FullNamesListLanguage.insert(std::make_pair(0, wxT("")));
+ ContactEditorData.FullNamesListPref.insert(std::make_pair(0, 0));
+ ContactEditorData.FullNamesListTokens.insert(std::make_pair(0, wxT("")));
+
+ }
+
+ /*ContactData.Add(wxT("BEGIN"), wxT("VCARD"), FALSE);
ContactData.Add(wxT("VERSION"), wxT("4.0"), FALSE);
// Setup the version string.
// End the vCard File.
- ContactData.Add(wxT("END"), wxT("VCARD"), FALSE);
+ ContactData.Add(wxT("END"), wxT("VCARD"), FALSE);*/
FMTimer.Stop();
- ContactData.WriteFile(FilenameFinal);
+ ContactEditorData.SaveFile(FilenameFinal);
+ //ContactData.WriteFile(FilenameFinal);
vCard34Conv ConvFileFun;
// TODO: Workout nickname settings by priority and
// type.
+ vCardName NameData;
+
+ NameData.Forename = txtForename->GetValue();
+ NameData.Surname = txtSurname->GetValue();
+ NameData.OtherNames = txtOtherNames->GetValue();
+ NameData.Title = txtTitle->GetValue();
+ NameData.Suffix = txtSuffix->GetValue();
+
ucd->ContactAccount = wxSContactAccount;
ucd->ContactFilename = FilenameFinal;
ucd->ContactName = cmbDisplayAs->GetValue();
- ucd->ContactNameArray = ContactData.GetName();
+ ucd->ContactNameArray = NameData;
for (std::map<int,wxString>::iterator gniter = ContactEditorData.GeneralNicknamesList.begin();
gniter != ContactEditorData.GeneralNicknamesList.end(); gniter++){