Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
getcontactinfo.cpp: Fix issue with using wxTransparentColour
[xestiaab/.git] / source / common / getcontactinfo.cpp
index dfd357f..a07ec4a 100644 (file)
@@ -24,8 +24,6 @@
 #include <wx/fs_mem.h>
 #include <wx/mstream.h>
 #include <wx/filesys.h>
-#include <wx/datetime.h>
-//#include <b64/decode.h>
 #include <string>
 
 #include "getcontactinfo.h"
 #include "../vcard/vcard34conv.h"
 
 void LoadContactData(vCard *vCardObj, wxHtmlWindow *HTMLObj, wxString SID, 
-       wxString OldSID, std::map<wxString, wxString> *MemoryFSList){
+       wxString OldSID, std::map<wxString, wxString> *MemoryFSList, wxColour backgroundColour){
+
+       // Load the vCard contact data into the wxHTMLWindow given.
 
        // Show message to user that the contact information is loading.
 
        HTMLObj->SetBorders(0);
+       HTMLObj->SetBackgroundColour(wxColour(160,160,160,0));
                
        wxString PageData;
        
        wxFileSystem::AddHandler(new wxMemoryFSHandler);
-       //wxMemoryFSHandler::AddFile();
        
        PageData.append(wxT("<html>"));
        PageData.append(wxT("<head>"));
@@ -94,7 +94,6 @@ void LoadContactData(vCard *vCardObj, wxHtmlWindow *HTMLObj, wxString SID,
        // MAke sure new session ID doesn't conflict with existing
        // data. If there is a match, generate a new one and check again.
        
-       bool SIDMatch = FALSE;
        wxString SIDTemp;
        
        for (std::map<wxString, wxString>::iterator striter = MemoryFSList->begin();
@@ -143,6 +142,7 @@ void LoadContactData(vCard *vCardObj, wxHtmlWindow *HTMLObj, wxString SID,
        
        if (FNList.PropCount > 0){
                FNList.PropValues[0].Trim();
+        CaptureString(&FNList.PropValues[0], false);
                PageData.append(FNList.PropValues[0]);
        }
        
@@ -193,28 +193,6 @@ void LoadContactData(vCard *vCardObj, wxHtmlWindow *HTMLObj, wxString SID,
        ArrayvCardOutData ContactData = vCardObj->GetByPartial(wxT("PHOTO"));
        
        if (ContactData.PropCount > 0){
-
-               // Split the data.
-
-               
-               
-               /*std::map<int,int> SplitPts;
-               std::map<int,int> SplitLen;
-               std::map<wxString,wxString> SplitData;
-               int intSize = 0;
-               
-               SplitPropertyData(&ContactData.PropData[0], 
-                       &SplitPts, 
-                       &SplitLen, 
-                       0,
-                       &SplitData);
-               
-               for (std::map<wxString, wxString>::iterator striter = SplitData.begin();
-               striter != SplitData.end(); striter++){
-               
-                       raise(SIGABRT);
-               
-               }*/
                
                // Look for the X-ABCROP-RECTANGLE.
                
@@ -264,9 +242,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());
@@ -296,23 +271,6 @@ void LoadContactData(vCard *vCardObj, wxHtmlWindow *HTMLObj, wxString SID,
                                        } else {
                                        
                                        }
-                                       
-                                       /*int PointX = PointXBase;
-                                       int PointY = PointYBase;
-                                       int PointW = PointWBase;
-                                       int PointH = PointHBase;*/
-
-                                       // Bottom Left Method
-                                       
-                                       /*int PointX = wxAtoi(PhotoRectData.GetNextToken());
-                                       int PointY = photo.GetHeight() - wxAtoi(PhotoRectData.GetNextToken()) - 340;
-                                       int PointW = wxAtoi(PhotoRectData.GetNextToken());
-                                       int PointH = wxAtoi(PhotoRectData.GetNextToken());*/
-                                       
-                                       // Bottom Right Method
-                                       
-                                       /*int PointXRemain = photo.GetWidth() - PointX - 140;
-                                       int PointYRemain = photo.GetHeight() - PointY - 140;*/
                                                                                
                                        PhotoRectPoints.SetX(PointX);
                                        PhotoRectPoints.SetY(PointY);
@@ -510,12 +468,7 @@ void LoadContactData(vCard *vCardObj, wxHtmlWindow *HTMLObj, wxString SID,
        
        }
        
-       bool MultiLogoIcon = FALSE;
-       bool MultiPhotoIcon = FALSE;
-       bool SoundIcon = FALSE;
-       bool KeyIcon = FALSE;
-       bool VendorIcon = FALSE;
-       bool XTokenIcon = FALSE;
+       // TODO: Setup the second table.
        
        // Process Birthday
        
@@ -523,7 +476,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;
@@ -535,10 +492,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;
                
@@ -548,7 +554,13 @@ void LoadContactData(vCard *vCardObj, wxHtmlWindow *HTMLObj, wxString SID,
                
        }
        
-       PageData.append("<table CELLPADDING=4 style=\"{width: 100%;}\"><tr><td>");
+       if (backgroundColour != wxTransparentColour){
+               PageData.append("<table CELLPADDING=4 style=\"{background-color: ");
+               PageData.append(backgroundColour.GetAsString(wxC2S_CSS_SYNTAX));
+               PageData.append("; width: 100%;}\"><tr><td>");          
+       } else {
+               PageData.append("<table CELLPADDING=4 style=\"{width: 100%;}\"><tr><td>");
+       }
        
        if (DataDisplay == TRUE){
        
@@ -577,12 +589,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;
                
@@ -716,7 +776,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;
                                
@@ -727,7 +786,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){
@@ -737,7 +795,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){
@@ -747,10 +804,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){
                                
@@ -759,10 +813,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){
                                
@@ -771,13 +822,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));
                                
                                }
                        
@@ -1657,6 +1706,8 @@ void SplitPropertyData(wxString *PropertyLine,
        int intSize,
        std::map<wxString,wxString> *SplitData){
        
+       // Split the property data into SplitData.
+       
        wxString DataStr;
        wxStringTokenizer PropertyElement;
        wxString PropertyName;
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy