From 8586a29ba7c4a3e79bb64ed915e1bfbb44d49540 Mon Sep 17 00:00:00 2001 From: Steve Brokenshire Date: Mon, 6 Mar 2017 11:00:23 +0000 Subject: [PATCH] getcontactinfo: Removed unused code and process dates Removed commented out code and process dates for the birthday and anniversary. --- source/common/getcontactinfo.cpp | 155 ++++++++++++++++++++++--------- source/common/getcontactinfo.h | 1 + 2 files changed, 110 insertions(+), 46 deletions(-) diff --git a/source/common/getcontactinfo.cpp b/source/common/getcontactinfo.cpp index 2941aba..b997279 100644 --- a/source/common/getcontactinfo.cpp +++ b/source/common/getcontactinfo.cpp @@ -24,8 +24,6 @@ #include #include #include -#include -//#include #include #include "getcontactinfo.h" @@ -194,28 +192,6 @@ void LoadContactData(vCard *vCardObj, wxHtmlWindow *HTMLObj, wxString SID, ArrayvCardOutData ContactData = vCardObj->GetByPartial(wxT("PHOTO")); if (ContactData.PropCount > 0){ - - // Split the data. - - - - /*std::map SplitPts; - std::map SplitLen; - std::map SplitData; - int intSize = 0; - - SplitPropertyData(&ContactData.PropData[0], - &SplitPts, - &SplitLen, - 0, - &SplitData); - - for (std::map::iterator striter = SplitData.begin(); - striter != SplitData.end(); striter++){ - - raise(SIGABRT); - - }*/ // Look for the X-ABCROP-RECTANGLE. @@ -265,9 +241,6 @@ void LoadContactData(vCard *vCardObj, wxHtmlWindow *HTMLObj, wxString SID, PhotoRectData.GetNextToken(); - //PhotoRectPoints.SetX(wxAtoi(PhotoRectData.GetNextToken())); - //PhotoRectPoints.SetY(wxAtoi(PhotoRectData.GetNextToken()) - 100); - int PointXBase = wxAtoi(PhotoRectData.GetNextToken()); int PointYBase = wxAtoi(PhotoRectData.GetNextToken()); int PointWBase = wxAtoi(PhotoRectData.GetNextToken()); @@ -500,7 +473,11 @@ void LoadContactData(vCard *vCardObj, wxHtmlWindow *HTMLObj, wxString SID, DataDisplay = FALSE; DataLines.clear(); - + wxDateTime DateFormat; + long MonthValue = 0; + long DayValue = 0; + long YearValue = 0; + if (ContactData.PropCount > 0){ wxString BDayLine; @@ -512,10 +489,59 @@ void LoadContactData(vCard *vCardObj, wxHtmlWindow *HTMLObj, wxString SID, BDayLine = ContactData.PropValues[i]; BDayLine.Trim(); - CaptureString(&BDayLine, FALSE); - ConvertToHTML(&BDayLine); + + if (BDayLine.Mid(0,4) == wxT("1604")){ + + BDayLine = BDayLine.Mid(4,4); + + BDayLine.Mid(0,2).ToLong(&MonthValue); + BDayLine.Mid(2,2).ToLong(&DayValue); + + MonthValue--; + + DateFormat.Set((wxDateTime::wxDateTime_t)(int)DayValue, (wxDateTime::Month)(MonthValue), 0, 0, 0, 0, 0); + + } else if (BDayLine.Mid(0,2) == wxT("--")){ + + BDayLine = BDayLine.Mid(2,4); + + BDayLine.Mid(0,2).ToLong(&MonthValue); + BDayLine.Mid(2,2).ToLong(&DayValue); + + MonthValue--; + + DateFormat.Set((wxDateTime::wxDateTime_t)(int)DayValue, (wxDateTime::Month)(MonthValue), 0, 0, 0, 0, 0); + + } else { + + + BDayLine.Mid(0,4).ToLong(&YearValue); + BDayLine.Mid(4,2).ToLong(&MonthValue); + BDayLine.Mid(6,2).ToLong(&DayValue); + + MonthValue--; + + DateFormat.Set((wxDateTime::wxDateTime_t)(int)DayValue, (wxDateTime::Month)(MonthValue), YearValue, 0, 0, 0, 0); + + } + + wxString BDayOutput; + + BDayOutput.append(wxString::Format(wxT("%02i"), (int)DayValue)); + BDayOutput.append(wxT("/")); + BDayOutput.append(wxString::Format(wxT("%02i"), (int)(MonthValue + 1))); + + if (DateFormat.GetYear() != 0){ + + BDayOutput.append(wxT("/")); + BDayOutput.append(wxString::Format(wxT("%04i"), (int)YearValue)); + + } + + CaptureString(&BDayOutput, FALSE); + ConvertToHTML(&BDayOutput); - DataLines.append(BDayLine); + DataLines.append(BDayOutput); break; @@ -554,12 +580,60 @@ void LoadContactData(vCard *vCardObj, wxHtmlWindow *HTMLObj, wxString SID, // Grab the first anniversary only. AnniLine = ContactData.PropValues[i]; - AnniLine.Trim(); - CaptureString(&AnniLine, FALSE); - ConvertToHTML(&AnniLine); + + if (AnniLine.Mid(0,4) == wxT("1604")){ + + AnniLine = AnniLine.Mid(4,4); + + AnniLine.Mid(0,2).ToLong(&MonthValue); + AnniLine.Mid(2,2).ToLong(&DayValue); + + MonthValue--; + + DateFormat.Set((wxDateTime::wxDateTime_t)(int)DayValue, (wxDateTime::Month)(MonthValue), 0, 0, 0, 0, 0); + + } else if (AnniLine.Mid(0,2) == wxT("--")){ + + AnniLine = AnniLine.Mid(2,4); + + AnniLine.Mid(0,2).ToLong(&MonthValue); + AnniLine.Mid(2,2).ToLong(&DayValue); + + MonthValue--; + + DateFormat.Set((wxDateTime::wxDateTime_t)(int)DayValue, (wxDateTime::Month)(MonthValue), 0, 0, 0, 0, 0); + + } else { + + + AnniLine.Mid(0,4).ToLong(&YearValue); + AnniLine.Mid(4,2).ToLong(&MonthValue); + AnniLine.Mid(6,2).ToLong(&DayValue); + + MonthValue--; + + DateFormat.Set((wxDateTime::wxDateTime_t)(int)DayValue, (wxDateTime::Month)(MonthValue), YearValue, 0, 0, 0, 0); + + } + + wxString AnniDayOutput; + + AnniDayOutput.append(wxString::Format(wxT("%02i"), (int)DayValue)); + AnniDayOutput.append(wxT("/")); + AnniDayOutput.append(wxString::Format(wxT("%02i"), (int)(MonthValue + 1))); + + if (DateFormat.GetYear() != 0){ + + AnniDayOutput.append(wxT("/")); + AnniDayOutput.append(wxString::Format(wxT("%04i"), (int)YearValue)); + + } + + CaptureString(&AnniDayOutput, FALSE); + ConvertToHTML(&AnniDayOutput); - DataLines.append(AnniLine); + DataLines.append(AnniDayOutput); break; @@ -693,7 +767,6 @@ void LoadContactData(vCard *vCardObj, wxHtmlWindow *HTMLObj, wxString SID, SLiter = SplitLength.find(1); - //txtSurname->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(0, SLiter->second), TRUE)); AddressPOBox = AddressLine.Mid(0, SLiter->second); intPrevValue = intiter->second; @@ -704,7 +777,6 @@ void LoadContactData(vCard *vCardObj, wxHtmlWindow *HTMLObj, wxString SID, SLiter = SplitLength.find(2); AddressExtended = AddressLine.Mid(intPrevValue, SLiter->second); - //txtForename->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE)); intPrevValue = intiter->second; } else if (intiter->first == 3){ @@ -714,7 +786,6 @@ void LoadContactData(vCard *vCardObj, wxHtmlWindow *HTMLObj, wxString SID, SLiter = SplitLength.find(3); AddressStreet = AddressLine.Mid(intPrevValue, SLiter->second); - //txtOtherNames->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE)); intPrevValue = intiter->second; } else if (intiter->first == 4){ @@ -724,10 +795,7 @@ void LoadContactData(vCard *vCardObj, wxHtmlWindow *HTMLObj, wxString SID, SLiter = SplitLength.find(4); AddressLocality = AddressLine.Mid(intPrevValue, SLiter->second); - //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE)); intPrevValue = intiter->second; - - //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, wxSTRING_MAXLEN), TRUE)); } else if (intiter->first == 5){ @@ -736,10 +804,7 @@ void LoadContactData(vCard *vCardObj, wxHtmlWindow *HTMLObj, wxString SID, SLiter = SplitLength.find(5); AddressRegion = AddressLine.Mid(intPrevValue, SLiter->second); - //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE)); intPrevValue = intiter->second; - - //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, wxSTRING_MAXLEN), TRUE)); } else if (intiter->first == 6){ @@ -748,13 +813,11 @@ void LoadContactData(vCard *vCardObj, wxHtmlWindow *HTMLObj, wxString SID, SLiter = SplitLength.find(6); AddressPostalCode = AddressLine.Mid(intPrevValue, SLiter->second); - //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE)); intPrevValue = intiter->second; // Deal with country. AddressCountry = AddressLine.Mid(intPrevValue); - //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, wxSTRING_MAXLEN), TRUE)); } diff --git a/source/common/getcontactinfo.h b/source/common/getcontactinfo.h index 1642817..416f7f9 100644 --- a/source/common/getcontactinfo.h +++ b/source/common/getcontactinfo.h @@ -20,6 +20,7 @@ #include #include #include +#include #include "../vcard/vcard.h" #ifndef GETCONTACTINFO_H -- 2.39.5