Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Capture full name string when processing it for display in the HTML widget.
[xestiaab/.git] / source / common / getcontactinfo.cpp
1 // getcontactinfo.cpp - Contact Information subroutines.
2 //
3 // (c) 2012-2015 Xestia Software Development.
4 //
5 // This file is part of Xestia Address Book.
6 //
7 // Xestia Address Book is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by the
9 // Free Software Foundation, version 3 of the license.
10 //
11 // Xestia Address Book is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License along
17 // with Xestia Address Book. If not, see <http://www.gnu.org/licenses/>
19 #include <iostream>
20 #include <map>
21 #include <utility>
22 #include <wx/wx.h>
23 #include <wx/tokenzr.h>
24 #include <wx/fs_mem.h>
25 #include <wx/mstream.h>
26 #include <wx/filesys.h>
27 #include <wx/datetime.h>
28 //#include <b64/decode.h>
29 #include <string>
31 #include "getcontactinfo.h"
32 #include "base64.h"
33 #include "textprocessing.h"
34 #include "../vcard/vcard34conv.h"
36 void LoadContactData(vCard *vCardObj, wxHtmlWindow *HTMLObj, wxString SID, 
37         wxString OldSID, std::map<wxString, wxString> *MemoryFSList){
39         // Load the vCard contact data into the wxHTMLWindow given.
41         // Show message to user that the contact information is loading.
43         HTMLObj->SetBorders(0);
44                 
45         wxString PageData;
46         
47         wxFileSystem::AddHandler(new wxMemoryFSHandler);
48         
49         PageData.append(wxT("<html>"));
50         PageData.append(wxT("<head>"));
51         PageData.append(wxT("<title>Page Loading</title>"));    
52         PageData.append(wxT("</head>"));
53         PageData.append(wxT("<body>"));
54         PageData.append(wxT("<h2>"));
55         PageData.append(_("Loading contact information..."));
56         PageData.append(wxT("</h2>"));
57         PageData.append(wxT("</body>"));
58         PageData.append(wxT("</html>"));
60         HTMLObj->SetPage(PageData);
61         
62         PageData.clear();
63         
64         // Delete the information from the old session.
65         
66         if (!OldSID.IsEmpty()){
67         
68                 if (MemoryFSList->find(OldSID) == MemoryFSList->end()){
71                 } else {
73                         std::map<wxString, wxString>::iterator striter;
75                         for (striter = MemoryFSList->begin(); striter != MemoryFSList->end(); striter++){
77                                 if (OldSID == striter->second){
79                                         // Delete the references from the wxMemoryFSHandler
80                                         // and the entry from the map.
82                                         wxMemoryFSHandler::RemoveFile(striter->first);
83                                         break;
85                                 }
87                         }
89                         MemoryFSList->erase(striter);
91                 }
92         
93         }
94         
95         // MAke sure new session ID doesn't conflict with existing
96         // data. If there is a match, generate a new one and check again.
97         
98         wxString SIDTemp;
99         
100         for (std::map<wxString, wxString>::iterator striter = MemoryFSList->begin();
101                 striter != MemoryFSList->end(); striter++){
102         
103                 SIDTemp = striter->second;
104                 
105                 if (SID == SIDTemp){
106                 
107                         // Generate a new random number.
108                         
109                         SID = wxString::Format(wxT("%i"), rand() % 32768);
110                         
111                         // Rewind the seek process back to the start.
112                         
113                         striter = MemoryFSList->begin();
114                 
115                 }
116                                 
117         }
118         
119         SIDTemp.clear();
121         // Setup the HTML document.
123         PageData.append(wxT("<html>"));
124         PageData.append(wxT("<head>"));
125         PageData.append(wxT("<title>Contact Information</title>"));     
126         PageData.append(wxT("</head>"));
127         
128         // Process the CSS section.
129         
130         PageData.append(wxT("<body>"));
132         // Process the data in the vCard object.
133         
134         // Name (Display As)
135         
136         ArrayvCardOutData FNList;
137         FNList = vCardObj->GetByPartial(wxT("FN"));
138         
139         PageData.append(wxT("<table style=\"background: #cccccc; width: 100%\">"));
140         PageData.append(wxT("<tr>"));
141         PageData.append(wxT("<td style=\"width:100%\">"));
142         PageData.append(wxT("<h2>"));
143         
144         if (FNList.PropCount > 0){
145                 FNList.PropValues[0].Trim();
146         CaptureString(&FNList.PropValues[0], false);
147                 PageData.append(FNList.PropValues[0]);
148         }
149         
150         PageData.append(wxT("</h2>"));
151         PageData.append(wxT("</td>"));
152         PageData.append(wxT("<td style=\"width: 200px;\">"));
153         
154         // Define common variables for ADR.
155         
156         std::map<int,int> SplitPoints;
157         std::map<int,int> SplitLength;
158         std::map<int,int>::iterator SLiter;
159         
160         int intPropertyLen;
161         int intSplitsFound;
162         int intSplitSize;
163         int intPrevValue;
164         
165         wxString AddressPOBox;
166         wxString AddressStreet;
167         wxString AddressLocality;
168         wxString AddressRegion;
169         wxString AddressPostalCode;
170         wxString AddressCountry;
171         wxString AddressExtended;
172         
173         wxString FinalAddressLine;
174         bool AddressFirst = TRUE;
175         
176         // Define common variables for PHOTO and LOGO.
177         
178         std::string PhotoDataBin;
179         std::string PhotoDataIn;
180         wxString PhotoSplitData;
181         wxString PhotoMIMEType;
182         wxString PhotoEncType;
183         wxString PhotoEncData;
184         bool LoadPicture = FALSE;
185         bool DataDisplay = FALSE;
186         bool RectData = FALSE;
187         wxRect PhotoRectPoints;
188         wxString SIDFilename;
189         wxString OutData;
190         wxString DataLines;
191         
192         // Picture
193         
194         ArrayvCardOutData ContactData = vCardObj->GetByPartial(wxT("PHOTO"));
195         
196         if (ContactData.PropCount > 0){
198                 // Split the data.
200                 
201                 
202                 /*std::map<int,int> SplitPts;
203                 std::map<int,int> SplitLen;
204                 std::map<wxString,wxString> SplitData;
205                 int intSize = 0;
206                 
207                 SplitPropertyData(&ContactData.PropData[0], 
208                         &SplitPts, 
209                         &SplitLen, 
210                         0,
211                         &SplitData);
212                 
213                 for (std::map<wxString, wxString>::iterator striter = SplitData.begin();
214                 striter != SplitData.end(); striter++){
215                 
216                         raise(SIGABRT);
217                 
218                 }*/
219                 
220                 // Look for the X-ABCROP-RECTANGLE.
221                 
222                 wxStringTokenizer PhotoSplit(ContactData.PropData[0], wxT(":"));
223                 wxString PhotoPropertyDataString = PhotoSplit.GetNextToken();
224                 wxStringTokenizer PhotoPropertyData(PhotoPropertyDataString, wxT(";"));
225                 wxString PropertyLineData;
226                 wxString PropertyName;
227                 wxString PropertyValue;
228                 
229                 wxStringTokenizer DataSplit(ContactData.PropValues[0], wxT(";"));
230                 PhotoSplitData = DataSplit.GetNextToken();
231                 wxStringTokenizer MIMESplit(PhotoSplitData, wxT(":"));
232                 MIMESplit.GetNextToken();
233                 PhotoMIMEType = MIMESplit.GetNextToken();
234                 PhotoSplitData = DataSplit.GetNextToken();
235                 wxStringTokenizer EncSplit(PhotoSplitData, wxT(","));
236                 PhotoEncType = EncSplit.GetNextToken();
237                 PhotoEncData = EncSplit.GetNextToken();
238                 
239                 // Convert the picture data from base64 to binary.
240         
241                 PhotoDataIn = std::string(PhotoEncData.mb_str());
242                 PhotoDataBin = base64_decode(PhotoDataIn);
243                 wxMemoryInputStream istream(PhotoDataBin.c_str(), (size_t)PhotoDataBin.size());
244                 wxImage photo;
246                 if (!photo.LoadFile(istream, wxBITMAP_TYPE_ANY)){
247     
248                         // Photo failed to load so do nothing.
249     
250                         LoadPicture = FALSE;
252                 } else {
253                 
254                         while (PhotoPropertyData.HasMoreTokens()){
255                 
256                                 PropertyLineData = PhotoPropertyData.GetNextToken();
257                         
258                                 wxStringTokenizer PhotoPropPair(PropertyLineData, wxT("="));
259                                 wxString PhotoPropName = PhotoPropPair.GetNextToken();
260                                 wxString PhotoPropValue = PhotoPropPair.GetNextToken();
261                 
262                                 if (PhotoPropName == wxT("X-ABCROP-RECTANGLE")){
263                         
264                                         wxStringTokenizer PhotoRectData(PhotoPropValue, wxT("&"));
265                                 
266                                         PhotoRectData.GetNextToken();
268                                         //PhotoRectPoints.SetX(wxAtoi(PhotoRectData.GetNextToken()));
269                                         //PhotoRectPoints.SetY(wxAtoi(PhotoRectData.GetNextToken()) - 100);
271                                         int PointXBase = wxAtoi(PhotoRectData.GetNextToken());
272                                         int PointYBase = wxAtoi(PhotoRectData.GetNextToken());
273                                         int PointWBase = wxAtoi(PhotoRectData.GetNextToken());
274                                         int PointHBase = wxAtoi(PhotoRectData.GetNextToken());
276                                         int PointX = PointXBase;
277                                         int PointY = PointYBase;
278                                         int PointW = PointWBase;
279                                         int PointH = PointHBase;
281                                         // Top Right Method
283                                         if (PointYBase > PointHBase){
285                                                 PointX = photo.GetWidth() - PointXBase - 140;
286                                                 PointY = photo.GetHeight() - PointYBase - 140;
287                                                 PointW = PointWBase;
288                                                 PointH = PointHBase;
290                                         } else if (PointXBase > PointWBase){
291                                         
292                                                 PointX = photo.GetWidth() - PointXBase;
293                                                 PointY = PointYBase - 50;
294                                                 PointW = PointWBase;
295                                                 PointH = PointHBase;
296                                         
297                                         } else {
298                                         
299                                         }
300                                                                                 
301                                         PhotoRectPoints.SetX(PointX);
302                                         PhotoRectPoints.SetY(PointY);
303                                         PhotoRectPoints.SetWidth(PointW);
304                                         PhotoRectPoints.SetHeight(PointH);
305                                         RectData = TRUE;
306                         
307                                 }
308                 
309                         }
310                 
311                         LoadPicture = TRUE;
312                 
313                         // Resize the picture to 125x125.
314                         
315                         // Add to the wxMemnoryFSHandler.
316                         
317                         SIDFilename = SID + wxT("-photo");
318                         
319                         if (RectData == TRUE){
320                                 
321                                 wxImage rectphoto = photo.GetSubImage(PhotoRectPoints);
322                                 rectphoto = rectphoto.Scale(75, 75, wxIMAGE_QUALITY_HIGH);
323                                 wxMemoryFSHandler::AddFile(SIDFilename, rectphoto, wxBITMAP_TYPE_PNG);
324                         
325                         } else {
326                         
327                                 photo = photo.Scale(50, 50, wxIMAGE_QUALITY_HIGH);
328                                 wxMemoryFSHandler::AddFile(SIDFilename, photo, wxBITMAP_TYPE_PNG);
329                         
330                         }
331                         
332                         // Add the filename to the MemoryFSList map.
334                         MemoryFSList->insert(std::make_pair(SIDFilename, SID));
335                 
336                 }
337         
338         }
339         
340         if (LoadPicture == TRUE){
342                 PageData.append(wxT("<img src=\"memory:") + SIDFilename + wxT("\">"));
343         
344         }
345         
346         LoadPicture = FALSE;
347         
348         // Logo
349         
350         ContactData = vCardObj->GetByPartial(wxT("LOGO"));
351         
352         if (ContactData.PropCount > 0){
354                 // Split the data.
355         
356                 wxStringTokenizer DataSplit(ContactData.PropValues[0], wxT(";"));
357                 PhotoSplitData = DataSplit.GetNextToken();
358                 wxStringTokenizer MIMESplit(PhotoSplitData, wxT(":"));
359                 MIMESplit.GetNextToken();
360                 PhotoMIMEType = MIMESplit.GetNextToken();
361                 PhotoSplitData = DataSplit.GetNextToken();
362                 wxStringTokenizer EncSplit(PhotoSplitData, wxT(","));
363                 PhotoEncType = EncSplit.GetNextToken();
364                 PhotoEncData = EncSplit.GetNextToken();
365                 
366                 // Convert the picture data from base64 to binary.
367         
368                 PhotoDataIn = std::string(PhotoEncData.mb_str());
369                 PhotoDataBin = base64_decode(PhotoDataIn);
370                 wxMemoryInputStream istream(PhotoDataBin.c_str(), (size_t)PhotoDataBin.size());
371                 wxImage photo;
373                 if (!photo.LoadFile(istream, wxBITMAP_TYPE_ANY)){
374     
375                         // Photo failed to load so do nothing.
376     
377                         LoadPicture = FALSE;
379                 } else {
380                 
381                         LoadPicture = TRUE;
382                 
383                         photo = photo.Scale(50, 50, wxIMAGE_QUALITY_HIGH);
385                         // Resize the picture to 125x125.
386                         
387                         // Add to the wxMemnoryFSHandler.
388                         
389                         SIDFilename = SID + wxT("-logo");
390                         
391                         wxMemoryFSHandler::AddFile(SIDFilename, photo, wxBITMAP_TYPE_PNG);
392                         
393                         // Add the filename to the MemoryFSList map.
394                         
395                         MemoryFSList->insert(std::make_pair(SIDFilename, SID));
396                 
397                 }
398         
399         }
400         
401         if (LoadPicture == TRUE){
403                 PageData.append(wxT("<img src=\"memory:") + SIDFilename + wxT("\">"));
404         
405         }       
407         PageData.append(wxT("</td>"));
408         PageData.append(wxT("</tr>"));
409         PageData.append(wxT("</table>"));
410         
411         // Process LOGO, PHOTO, SOUND, KEY, VND-* and X-*
412         // lines and display icons for each accordingly.
414         ContactData = vCardObj->GetByPartial(wxT("PHOTO"));
415         
416         bool AddBreak = FALSE;
417         wxString TypePageData;
418         
419         if (ContactData.PropCount > 1){
420         
421                 TypePageData.append(wxT("<img src=\"memory:cipto.png\" alt=\""));
422                 TypePageData.append(_("This contact has multiple photos."));
423                 TypePageData.append(wxT("\">"));
424                 AddBreak = TRUE;
425         
426         }
427         
428         ContactData = vCardObj->GetByPartial(wxT("LOGO"));
429         
430         if (ContactData.PropCount > 1){
431         
432                 TypePageData.append(wxT("<img src=\"memory:cilog.png\" alt=\""));
433                 TypePageData.append(_("This contact has multiple logos."));
434                 TypePageData.append(wxT("\">"));
435                 AddBreak = TRUE;
436         
437         }
438         
439         ContactData = vCardObj->GetByPartial(wxT("SOUND"));
440         
441         if (ContactData.PropCount >= 1){
442         
443                 TypePageData.append(wxT("<img src=\"memory:cisnd.png\" alt=\""));
444                 TypePageData.append(_("This contact has audio information."));
445                 TypePageData.append(wxT("\">"));
446                 AddBreak = TRUE;
447         
448         }
449         
450         ContactData = vCardObj->GetByPartial(wxT("KEY"));
452         if (ContactData.PropCount >= 1){
453         
454                 TypePageData.append(wxT("<img src=\"memory:cikey.png\" alt=\""));
455                 TypePageData.append(_("This contact has crytographic keys."));
456                 TypePageData.append(wxT("\">"));
457                 AddBreak = TRUE;
458         
459         }
460         
461         ContactData = vCardObj->GetByPartial(wxT("VND-"));
462         
463         if (ContactData.PropCount >= 1){
464         
465                 TypePageData.append(wxT("<img src=\"memory:civen.png\" alt=\""));
466                 TypePageData.append(_("This contact has vendor-specific information."));
467                 TypePageData.append(wxT("\">"));
468                 AddBreak = TRUE;
469         
470         }
471         
472         ContactData = vCardObj->GetByPartial(wxT("X-"));
473         
474         if (ContactData.PropCount >= 1){
475         
476                 TypePageData.append(wxT("<img src=\"memory:ciext.png\" alt=\""));
477                 TypePageData.append(_("This contact has extended information."));
478                 TypePageData.append(wxT("\">"));
479                 AddBreak = TRUE;
481         }
482         
483         if (!TypePageData.IsEmpty()){
484                 
485                 PageData.append("<table style=\"{background: #dddddd; width:100%}\"><tr><td>");
486                 PageData.append(TypePageData);
487                 PageData.append("</tr></td></table>");
488                 
489         }
490         
491         if (AddBreak == TRUE){
492         
493                 PageData.append(wxT("<br><br>"));
494         
495         }
496         
497         // Process Birthday
498         
499         ContactData = vCardObj->GetByPartial(wxT("BDAY"));
501         DataDisplay = FALSE;
502         DataLines.clear();
504         if (ContactData.PropCount > 0){
505         
506                 wxString BDayLine;
507                 
508                 for (int i = 0; i < ContactData.PropCount; i++){
510                         // Grab the first birthday only.
512                         BDayLine = ContactData.PropValues[i];
513                 
514                         BDayLine.Trim();
515                         CaptureString(&BDayLine, FALSE);
516                         ConvertToHTML(&BDayLine);
517                 
518                         DataLines.append(BDayLine);
520                         break;
521                 
522                 }
523                 
524                 DataDisplay = TRUE;
525                 
526         }
527         
528         PageData.append("<table CELLPADDING=4 style=\"{width: 100%;}\"><tr><td>");
529         
530         if (DataDisplay == TRUE){
531         
532                 DataLines.Trim();
533                 PageData.append(wxT("<b>"));
534                 PageData.append(_("Birthday:"));
535                 PageData.append(wxT("</b> "));
536                 PageData.append(DataLines);
537                 PageData.append(wxT("<br>"));
538         
539         }
540         
541         // Process Anniversary
542         
543         ContactData = vCardObj->GetByPartial(wxT("ANNIVERSARY"));
545         DataDisplay = FALSE;
546         DataLines.clear();
548         if (ContactData.PropCount > 0){
549         
550                 wxString AnniLine;
551                 
552                 for (int i = 0; i < ContactData.PropCount; i++){
554                         // Grab the first anniversary only.
556                         AnniLine = ContactData.PropValues[i];
557                 
558                         AnniLine.Trim();
559                         CaptureString(&AnniLine, FALSE);
560                         ConvertToHTML(&AnniLine);
561                 
562                         DataLines.append(AnniLine);
564                         break;
565                 
566                 }
567                 
568                 DataDisplay = TRUE;
569                 
570         }
571         
572         if (DataDisplay == TRUE){
573         
574                 DataLines.Trim();
575                 PageData.append(wxT("<b>"));
576                 PageData.append(_("Anniversary:"));
577                 PageData.append(wxT("</b> "));
578                 PageData.append(DataLines);
579                 PageData.append(wxT("<br>"));
580         
581         }
582         
583         // Nickname
584         
585         ContactData = vCardObj->GetByPartial(wxT("NICKNAME"));
587         DataDisplay = FALSE;
588         DataLines.clear();
590         if (ContactData.PropCount > 0){
591         
592                 wxString NicknameLine;
593                 
594                 for (int i = 0; i < ContactData.PropCount; i++){
596                         NicknameLine = ContactData.PropValues[i];
597                 
598                         NicknameLine.Trim();
599                         CaptureString(&NicknameLine, FALSE);
600                         ConvertToHTML(&NicknameLine);
601                 
602                         DataLines.append(wxT("<tr><td><b>"));
603                         DataLines.append(_("Nickname:"));
604                         DataLines.append(wxT(" </b></td><td>"));
605                         DataLines.append(NicknameLine);
606                         DataLines.append(wxT("</td></tr>"));
607                 
608                 }
609                 
610                 DataDisplay = TRUE;
611                 
612         }
613         
614         if (DataDisplay == TRUE){
616                 DataLines.Trim();
617                 PageData.append(wxT("<h4>"));
618                 PageData.append(_("Nicknames"));
619                 PageData.append(wxT("</h4>"));
620                 PageData.append(wxT("<br>"));
621                 PageData.append(wxT("<table>"));
622                 PageData.append(DataLines);
623                 PageData.append(wxT("</table>"));
624         
625         }
626         
627         // Address
628         
629         ContactData = vCardObj->GetByPartial(wxT("ADR"));
630         
631         DataDisplay = FALSE;
632         DataLines.clear();
633                 
634         if (ContactData.PropCount > 0){
635         
636                 wxString AddressLine;
637         
638                 for (int i = 0; i < ContactData.PropCount; i++){
639                         
640                         AddressLine = ContactData.PropValues[i];
641                         
642                         intPropertyLen = AddressLine.Len();
643                         SplitPoints.clear();
644                         SplitLength.clear();
645                         intSplitsFound = 0;
646                         intSplitSize = 0;
647                         intPrevValue = 0;
648                         
649                         AddressPOBox.clear();
650                         AddressStreet.clear();
651                         AddressLocality.clear();
652                         AddressRegion.clear();
653                         AddressPostalCode.clear();
654                         AddressCountry.clear();
655                         AddressExtended.clear();
656                         FinalAddressLine.clear();
657                         AddressFirst = TRUE;
658                         
659                         for (int i = 0; i <= intPropertyLen; i++){
660                 
661                                 intSplitSize++;
662                         
663                                 if (AddressLine.Mid(i, 1) == wxT(";") && AddressLine.Mid((i - 1), 1) != wxT("\\")){
664                         
665                                         intSplitsFound++;
666                                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
667                                         
668                                         if (intSplitsFound == 6){ 
669                                         
670                                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
671                                                 break; 
672                                                 
673                                         } else {
674                                         
675                                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
676                                         
677                                         }
678                                         
679                                         intSplitSize = 0;                                       
680                         
681                                 }
682                 
683                         }
684                         
685                         // Split the data into several parts.                   
686                         
687                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
688                         intiter != SplitPoints.end(); ++intiter){
689                         
690                                 if (intiter->first == 1){
691                                 
692                                         // Deal with PO Box.
693                                         
694                                         SLiter = SplitLength.find(1);
695                                                                                 
696                                         //txtSurname->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(0, SLiter->second), TRUE));
697                                         AddressPOBox = AddressLine.Mid(0, SLiter->second);
698                                         intPrevValue = intiter->second;
699                                 
700                                 } else if (intiter->first == 2){
701                                 
702                                         // Deal with extended address.
703                                         
704                                         SLiter = SplitLength.find(2);
705                                         
706                                         AddressExtended = AddressLine.Mid(intPrevValue, SLiter->second);
707                                         //txtForename->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
708                                         intPrevValue = intiter->second;
709                                 
710                                 } else if (intiter->first == 3){
711                                 
712                                         // Deal with street address.
713                                         
714                                         SLiter = SplitLength.find(3);
715                                                                                 
716                                         AddressStreet = AddressLine.Mid(intPrevValue, SLiter->second);
717                                         //txtOtherNames->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
718                                         intPrevValue = intiter->second;
719                                 
720                                 } else if (intiter->first == 4){
721                                 
722                                         // Deal with locality
724                                         SLiter = SplitLength.find(4);
725                                         
726                                         AddressLocality = AddressLine.Mid(intPrevValue, SLiter->second);
727                                         //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
728                                         intPrevValue = intiter->second;
729                                         
730                                         //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, wxSTRING_MAXLEN), TRUE));
731                                 
732                                 } else if (intiter->first == 5){
733                                 
734                                         // Deal with region.
736                                         SLiter = SplitLength.find(5);
737                                         
738                                         AddressRegion = AddressLine.Mid(intPrevValue, SLiter->second);
739                                         //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
740                                         intPrevValue = intiter->second;
741                                         
742                                         //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, wxSTRING_MAXLEN), TRUE));
743                                 
744                                 } else if (intiter->first == 6){
745                                 
746                                         // Deal with post code.
748                                         SLiter = SplitLength.find(6);
749                                         
750                                         AddressPostalCode = AddressLine.Mid(intPrevValue, SLiter->second);
751                                         //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
752                                         intPrevValue = intiter->second;
753                                         
754                                         // Deal with country.
755                                         
756                                         AddressCountry = AddressLine.Mid(intPrevValue);
757                                         //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, wxSTRING_MAXLEN), TRUE));
758                                 
759                                 }
760                         
761                         }
762                         
763                         if (!AddressStreet.IsEmpty()){
764                         
765                                 AddressStreet.Trim();
766                                 ConvertToHTML(&AddressStreet);
767                         
768                                 FinalAddressLine.append(AddressStreet);
769                                 AddressFirst = FALSE;
770                         
771                         }
772                         
773                         if (!AddressLocality.IsEmpty()){
774                         
775                                 AddressLocality.Trim();
776                                 ConvertToHTML(&AddressLocality);
777                         
778                                 if (AddressFirst == FALSE){
779                                 
780                                         FinalAddressLine.append(wxT(",<br>"));
781                                         FinalAddressLine.append(AddressLocality);
783                                 } else {
784                                 
785                                         FinalAddressLine.append(AddressLocality);
786                                         AddressFirst = FALSE;
787                                 
788                                 }
789                         
790                         }
791                         
792                         if (!AddressRegion.IsEmpty()){
793                         
794                                 AddressRegion.Trim();
795                                 ConvertToHTML(&AddressRegion);
796                         
797                                 if (AddressFirst == FALSE){
798                                 
799                                         FinalAddressLine.append(wxT(",<br>"));
800                                         FinalAddressLine.append(AddressRegion);
802                                 } else {
803                                 
804                                         FinalAddressLine.append(AddressRegion);
805                                         AddressFirst = FALSE;
806                                 
807                                 }
808                         
809                         }
810                         
811                         if (!AddressPostalCode.IsEmpty()){
812                         
813                                 AddressPostalCode.Trim();
814                                 ConvertToHTML(&AddressPostalCode);
815                         
816                                 if (AddressFirst == FALSE){
817                                 
818                                         FinalAddressLine.append(wxT(",<br>"));
819                                         FinalAddressLine.append(AddressPostalCode);
821                                 } else {
822                                 
823                                         FinalAddressLine.append(AddressPostalCode);
824                                         AddressFirst = FALSE;
825                                 
826                                 }
827                         
828                         }
829                         
830                         if (!AddressCountry.IsEmpty()){
831                         
832                                 AddressCountry.Trim();
833                                 ConvertToHTML(&AddressCountry);
834                         
835                                 if (AddressFirst == FALSE){
836                                 
837                                         FinalAddressLine.append(wxT(",<br>"));
838                                         FinalAddressLine.append(AddressCountry);
840                                 } else {
841                                 
842                                         FinalAddressLine.append(AddressCountry);
843                                         AddressFirst = FALSE;
844                                 
845                                 }
846                         
847                         }
848                         
849                         CaptureString(&FinalAddressLine, FALSE);
850                         
851                         DataLines.append(wxT("<tr><td><b>"));
852                         DataLines.append(_("Address:"));
853                         DataLines.append(wxT(" </b></td><td>"));
854                         DataLines.append(FinalAddressLine);
855                         DataLines.append(wxT("</td></tr>"));
856                         
857                 }
858         
859                 DataDisplay = TRUE;
860         
861         }
862         
863         if (DataDisplay == TRUE){
864         
865                 DataLines.Trim();
866                 PageData.append(wxT("<h4>"));
867                 PageData.append(_("Addresses"));
868                 PageData.append(wxT("</h4>"));
869                 PageData.append(wxT("<br>"));
870                 PageData.append(wxT("<table>"));
871                 PageData.append(DataLines);
872                 PageData.append(wxT("</table>"));
873         
874         }
876         // Email
877         
878         ContactData = vCardObj->GetByPartial(wxT("EMAIL"));
880         DataDisplay = FALSE;
881         DataLines.clear();
883         if (ContactData.PropCount > 0){
884         
885                 wxString EmailLine;
886                 
887                 for (int i = 0; i < ContactData.PropCount; i++){
889                         EmailLine = ContactData.PropValues[i];
890                 
891                         EmailLine.Trim();
892                         CaptureString(&EmailLine, FALSE);
893                         ConvertToHTML(&EmailLine);
894                 
895                         DataLines.append(wxT("<tr><td><b>"));
896                         DataLines.append(_("E-mail Address:"));
897                         DataLines.append(wxT(" </b></td><td>"));
898                         DataLines.append(EmailLine);
899                         DataLines.append(wxT("</td></tr>"));
900                 
901                 }
902                 
903                 DataDisplay = TRUE;
904                 
905         }
906         
907         if (DataDisplay == TRUE){
909                 DataLines.Trim();
910                 PageData.append(wxT("<h4>"));
911                 PageData.append(_("Email Addresses"));
912                 PageData.append(wxT("</h4>"));
913                 PageData.append(wxT("<br>"));
914                 PageData.append(wxT("<table>"));
915                 PageData.append(DataLines);
916                 PageData.append(wxT("</table>"));
917         
918         }
919         
920         // Telephone
922         ContactData = vCardObj->GetByPartial(wxT("TEL"));
924         DataDisplay = FALSE;
925         DataLines.clear();
927         if (ContactData.PropCount > 0){
928         
929                 wxString TelLine;
930                 
931                 for (int i = 0; i < ContactData.PropCount; i++){
933                         TelLine = ContactData.PropValues[i];
934                 
935                         wxStringTokenizer TelSplit(TelLine, wxT(":"));
936                         
937                         TelLine = TelSplit.GetNextToken();
938                         
939                         if (TelSplit.HasMoreTokens()){
940                         
941                                 TelLine = TelSplit.GetNextToken();
942                         
943                         }
944                 
945                         TelLine.Trim();
946                         CaptureString(&TelLine, FALSE);
947                         ConvertToHTML(&TelLine);
948                         
949                         DataLines.append(wxT("<tr><td><b>"));
950                         DataLines.append(_("Telephone:"));
951                         DataLines.append(wxT(" </b></td><td>"));
952                         DataLines.append(TelLine);
953                         DataLines.append(wxT("</td></tr>"));
954                 
955                 }
956                 
957                 DataDisplay = TRUE;
958                 
959         }
960         
961         if (DataDisplay == TRUE){
963                 DataLines.Trim();
964                 PageData.append(wxT("<h4>"));
965                 PageData.append(_("Telephones"));
966                 PageData.append(wxT("</h4>"));
967                 PageData.append(wxT("<br>"));
968                 PageData.append(wxT("<table>"));
969                 PageData.append(DataLines);
970                 PageData.append(wxT("</table>"));
971         
972         }
973         
974         // Instant Messaging
976         ContactData = vCardObj->GetByPartial(wxT("IMPP"));
978         DataDisplay = FALSE;
979         DataLines.clear();
981         if (ContactData.PropCount > 0){
982         
983                 wxString IMLine;
984                 wxString IMTypeFriendly;
985                 wxString IMType;
986                 
987                 for (int i = 0; i < ContactData.PropCount; i++){
989                         IMLine = ContactData.PropValues[i];
990                 
991                         wxStringTokenizer IMSplit(IMLine, wxT(":"));
992                         
993                         IMType = IMSplit.GetNextToken();
994                         IMLine = IMSplit.GetNextToken();
995                 
996                         // Process skype, gg, icq, yahoo etc into
997                         // something meaningful.
998                 
999                         if (IMType == wxT("aim")){
1000                         
1001                                 // AIM
1002                         
1003                                 IMTypeFriendly = _("AIM");
1004                         
1005                         } else if (IMType == wxT("xmpp")){
1006                         
1007                                 // XMPP
1008                                 
1009                                 IMTypeFriendly = _("XMPP");
1010                         
1011                         } else if (IMType == wxT("icq")){
1012                         
1013                                 // ICQ
1014                                 
1015                                 IMTypeFriendly = _("ICQ");
1016                         
1017                         } else if (IMType == wxT("skype")){
1018                         
1019                                 // Skype
1020                         
1021                                 IMTypeFriendly = _("Skype");
1022                         
1023                         } else if (IMType == wxT("gg")){
1024                         
1025                                 // Gadu-Gadu
1026                         
1027                                 IMTypeFriendly = _("Gadu-Gadu");
1028                         
1029                         } else if (IMType == wxT("yahoo")){
1030                         
1031                                 // Yahoo
1032                                 
1033                                 IMTypeFriendly = _("Yahoo");
1034                         
1035                         } else {
1036                         
1037                                 // Other. Use IM type that was split.
1038                                 
1039                                 IMTypeFriendly = IMType;
1040                         
1041                         }
1042                 
1043                         IMLine.Trim();
1044                         CaptureString(&IMLine, FALSE);
1045                         ConvertToHTML(&IMLine);
1046                 
1047                         DataLines.append(wxT("<tr><td><b>"));
1048                         DataLines.append(_("IM Address"));
1049                         DataLines.append(_(" ("));
1050                         DataLines.append(IMTypeFriendly);
1051                         DataLines.append(_("):"));
1052                         DataLines.append(wxT(" </b></td><td>"));
1053                         DataLines.append(IMLine);
1054                         DataLines.append(wxT("</td></tr>"));
1055                 
1056                         IMTypeFriendly.clear();
1057                         IMType.clear();
1058                         IMLine.clear();
1059                 
1060                 }
1061                 
1062                 DataDisplay = TRUE;
1063                 
1064         }
1065         
1066         if (DataDisplay == TRUE){
1067         
1068                 DataLines.Trim();
1069                 PageData.append(wxT("<h4>"));
1070                 PageData.append(_("Instant Messaging Addresses"));
1071                 PageData.append(wxT("</h4>"));
1072                 PageData.append(wxT("<br>"));
1073                 PageData.append(wxT("<table>"));
1074                 PageData.append(DataLines);
1075                 PageData.append(wxT("</table>"));
1076         
1077         }
1078         
1079         // URL
1081         ContactData = vCardObj->GetByPartial(wxT("URL"));
1083         DataDisplay = FALSE;
1084         DataLines.clear();
1086         if (ContactData.PropCount > 0){
1087         
1088                 wxString URLLine;
1089                 
1090                 for (int i = 0; i < ContactData.PropCount; i++){
1092                         URLLine = ContactData.PropValues[i];
1093                 
1094                         URLLine.Trim();
1095                         CaptureString(&URLLine, FALSE);
1096                         ConvertToHTML(&URLLine);
1097                 
1098                         DataLines.append(wxT("<tr><td><b>"));
1099                         DataLines.append(_("Website:"));
1100                         DataLines.append(wxT(" </b></td><td>"));
1101                         DataLines.append(URLLine);
1102                         DataLines.append(wxT("</td></tr>"));
1103                 
1104                 }
1105                 
1106                 DataDisplay = TRUE;
1107                 
1108         }
1109         
1110         if (DataDisplay == TRUE){
1112                 DataLines.Trim();
1113                 PageData.append(wxT("<h4>"));
1114                 PageData.append(_("Website Addresses"));
1115                 PageData.append(wxT("</h4>"));
1116                 PageData.append(wxT("<br>"));
1117                 PageData.append(wxT("<table>"));
1118                 PageData.append(DataLines);
1119                 PageData.append(wxT("</table>"));
1120         
1121         }
1122         
1123         // Languages
1124         
1125         ContactData = vCardObj->GetByPartial(wxT("LANG"));
1127         DataDisplay = FALSE;
1128         DataLines.clear();
1130         if (ContactData.PropCount > 0){
1131         
1132                 wxString NicknameLine;
1133                 
1134                 for (int i = 0; i < ContactData.PropCount; i++){
1136                         NicknameLine = ContactData.PropValues[i];
1137                 
1138                         NicknameLine.Trim();
1139                         CaptureString(&NicknameLine, FALSE);
1140                         ConvertToHTML(&NicknameLine);
1141                 
1142                         DataLines.append(wxT("<tr><td><b>"));
1143                         DataLines.append(_("Language:"));
1144                         DataLines.append(wxT(" </b></td><td>"));
1145                         DataLines.append(NicknameLine);
1146                         DataLines.append(wxT("</td></tr>"));
1147                 
1148                 }
1149                 
1150                 DataDisplay = TRUE;
1151                 
1152         }
1153         
1154         if (DataDisplay == TRUE){
1156                 DataLines.Trim();
1157                 PageData.append(wxT("<h4>"));
1158                 PageData.append(_("Languages"));
1159                 PageData.append(wxT("</h4>"));
1160                 PageData.append(wxT("<br>"));
1161                 PageData.append(wxT("<table>"));
1162                 PageData.append(DataLines);
1163                 PageData.append(wxT("</table>"));
1164         
1165         }
1166         
1167         // Timezones
1168         
1169         ContactData = vCardObj->GetByPartial(wxT("TZ"));
1171         DataDisplay = FALSE;
1172         DataLines.clear();
1174         if (ContactData.PropCount > 0){
1175         
1176                 wxString NicknameLine;
1177                 
1178                 for (int i = 0; i < ContactData.PropCount; i++){
1180                         NicknameLine = ContactData.PropValues[i];
1181                 
1182                         NicknameLine.Trim();
1183                         CaptureString(&NicknameLine, FALSE);
1184                         ConvertToHTML(&NicknameLine);
1185                 
1186                         DataLines.append(wxT("<tr><td><b>"));
1187                         DataLines.append(_("Timezone:"));
1188                         DataLines.append(wxT(" </b></td><td>"));
1189                         DataLines.append(NicknameLine);
1190                         DataLines.append(wxT("</td></tr>"));
1191                 
1192                 }
1193                 
1194                 DataDisplay = TRUE;
1195                 
1196         }
1197         
1198         if (DataDisplay == TRUE){
1200                 DataLines.Trim();
1201                 PageData.append(wxT("<h4>"));
1202                 PageData.append(_("Timezones"));
1203                 PageData.append(wxT("</h4>"));
1204                 PageData.append(wxT("<br>"));
1205                 PageData.append(wxT("<table>"));
1206                 PageData.append(DataLines);
1207                 PageData.append(wxT("</table>"));
1208         
1209         }
1211         // Geopositioning
1212         
1213         ContactData = vCardObj->GetByPartial(wxT("GEO"));
1215         DataDisplay = FALSE;
1216         DataLines.clear();
1218         if (ContactData.PropCount > 0){
1219         
1220                 wxString GeoLine;
1221                 
1222                 for (int i = 0; i < ContactData.PropCount; i++){
1224                         GeoLine = ContactData.PropValues[i];
1225                 
1226                         wxStringTokenizer GeoSplit(GeoLine, wxT(":"));
1227                         
1228                         GeoLine = GeoSplit.GetNextToken();
1229                         
1230                         if (GeoSplit.HasMoreTokens()){
1231                         
1232                                 GeoLine = GeoSplit.GetNextToken();
1233                         
1234                         }
1235                 
1236                         GeoLine.Trim();
1237                         CaptureString(&GeoLine, FALSE);
1238                         ConvertToHTML(&GeoLine);
1239                 
1240                         DataLines.append(wxT("<tr><td><b>"));
1241                         DataLines.append(_("Geoposition:"));
1242                         DataLines.append(wxT(" </b></td><td>"));
1243                         DataLines.append(GeoLine);
1244                         DataLines.append(wxT("</td></tr>"));
1245                 
1246                 }
1247                 
1248                 DataDisplay = TRUE;
1249                 
1250         }
1251         
1252         if (DataDisplay == TRUE){
1254                 DataLines.Trim();
1255                 PageData.append(wxT("<h4>"));
1256                 PageData.append(_("Geopositioning"));
1257                 PageData.append(wxT("</h4>"));
1258                 PageData.append(wxT("<br>"));
1259                 PageData.append(wxT("<table>"));
1260                 PageData.append(DataLines);
1261                 PageData.append(wxT("</table>"));
1262         
1263         }
1264         
1265         // Titles
1266         
1267         ContactData = vCardObj->GetByPartial(wxT("TITLE"));
1269         DataDisplay = FALSE;
1270         DataLines.clear();
1272         if (ContactData.PropCount > 0){
1273         
1274                 wxString TitleLine;
1275                 
1276                 for (int i = 0; i < ContactData.PropCount; i++){
1278                         TitleLine = ContactData.PropValues[i];
1279                 
1280                         TitleLine.Trim();
1281                         CaptureString(&TitleLine, FALSE);
1282                         ConvertToHTML(&TitleLine);
1283                 
1284                         DataLines.append(wxT("<tr><td><b>"));
1285                         DataLines.append(_("Title:"));
1286                         DataLines.append(wxT(" </b></td><td>"));
1287                         DataLines.append(TitleLine);
1288                         DataLines.append(wxT("</td></tr>"));
1289                 
1290                 }
1291                 
1292                 DataDisplay = TRUE;
1293                 
1294         }
1295         
1296         if (DataDisplay == TRUE){
1298                 DataLines.Trim();
1299                 PageData.append(wxT("<h4>"));
1300                 PageData.append(_("Titles"));
1301                 PageData.append(wxT("</h4>"));
1302                 PageData.append(wxT("<br>"));
1303                 PageData.append(wxT("<table>"));
1304                 PageData.append(DataLines);
1305                 PageData.append(wxT("</table>"));
1306         
1307         }
1308         
1309         // Roles
1310         
1311         ContactData = vCardObj->GetByPartial(wxT("ROLE"));
1313         DataDisplay = FALSE;
1314         DataLines.clear();
1316         if (ContactData.PropCount > 0){
1317         
1318                 wxString RoleLine;
1319                 
1320                 for (int i = 0; i < ContactData.PropCount; i++){
1322                         RoleLine = ContactData.PropValues[i];
1323                 
1324                         RoleLine.Trim();
1325                         CaptureString(&RoleLine, FALSE);
1326                         ConvertToHTML(&RoleLine);
1327                 
1328                         DataLines.append(wxT("<tr><td><b>"));
1329                         DataLines.append(_("Role:"));
1330                         DataLines.append(wxT(" </b></td><td>"));
1331                         DataLines.append(RoleLine);
1332                         DataLines.append(wxT("</td></tr>"));
1333                 
1334                 }
1335                 
1336                 DataDisplay = TRUE;
1337                 
1338         }
1339         
1340         if (DataDisplay == TRUE){
1342                 DataLines.Trim();
1343                 PageData.append(wxT("<h4>"));
1344                 PageData.append(_("Roles"));
1345                 PageData.append(wxT("</h4>"));
1346                 PageData.append(wxT("<br>"));
1347                 PageData.append(wxT("<table>"));
1348                 PageData.append(DataLines);
1349                 PageData.append(wxT("</table>"));
1350         
1351         }
1352         
1353         // Organisations
1354         
1355         ContactData = vCardObj->GetByPartial(wxT("ORG"));
1357         DataDisplay = FALSE;
1358         DataLines.clear();
1360         if (ContactData.PropCount > 0){
1361         
1362                 wxString OrgLine;
1363                 
1364                 for (int i = 0; i < ContactData.PropCount; i++){
1366                         OrgLine = ContactData.PropValues[i];
1367                 
1368                         OrgLine.Trim();
1369                         CaptureString(&OrgLine, FALSE);
1370                         ConvertToHTML(&OrgLine);
1371                 
1372                         DataLines.append(wxT("<tr><td><b>"));
1373                         DataLines.append(_("Organisation:"));
1374                         DataLines.append(wxT(" </b></td><td>"));
1375                         DataLines.append(OrgLine);
1376                         DataLines.append(wxT("</td></tr>"));
1377                 
1378                 }
1379                 
1380                 DataDisplay = TRUE;
1381                 
1382         }
1383         
1384         if (DataDisplay == TRUE){
1386                 DataLines.Trim();
1387                 PageData.append(wxT("<h4>"));
1388                 PageData.append(_("Organisations"));
1389                 PageData.append(wxT("</h4>"));
1390                 PageData.append(wxT("<br>"));
1391                 PageData.append(wxT("<table>"));
1392                 PageData.append(DataLines);
1393                 PageData.append(wxT("</table>"));
1394         
1395         }
1396         
1397         // Categories
1398         
1399         ContactData = vCardObj->GetByPartial(wxT("CATEGORIES"));
1401         DataDisplay = FALSE;
1402         DataLines.clear();
1404         if (ContactData.PropCount > 0){
1405         
1406                 wxString CatLine;
1407                 
1408                 for (int i = 0; i < ContactData.PropCount; i++){
1410                         CatLine = ContactData.PropValues[i];
1411                 
1412                         CatLine.Trim();
1413                         CaptureString(&CatLine, FALSE);
1414                         ConvertToHTML(&CatLine);
1415                 
1416                         DataLines.append(wxT("<tr><td><b>"));
1417                         DataLines.append(_("Category:"));
1418                         DataLines.append(wxT(" </b></td><td>"));
1419                         DataLines.append(CatLine);
1420                         DataLines.append(wxT("</td></tr>"));
1421                 
1422                 }
1423                 
1424                 DataDisplay = TRUE;
1425                 
1426         }
1427         
1428         if (DataDisplay == TRUE){
1430                 DataLines.Trim();
1431                 PageData.append(wxT("<h4>"));
1432                 PageData.append(_("Categories"));
1433                 PageData.append(wxT("</h4>"));
1434                 PageData.append(wxT("<br>"));
1435                 PageData.append(wxT("<table>"));
1436                 PageData.append(DataLines);
1437                 PageData.append(wxT("</table>"));
1438         
1439         }
1440         
1441         // Groups
1442         
1444         
1445         // Calendar Addresses
1446         
1447         ContactData = vCardObj->GetByPartial(wxT("CALURI"));
1449         DataDisplay = FALSE;
1450         DataLines.clear();
1452         if (ContactData.PropCount > 0){
1453         
1454                 wxString CalURILine;
1455                 
1456                 for (int i = 0; i < ContactData.PropCount; i++){
1458                         CalURILine = ContactData.PropValues[i];
1459                 
1460                         CalURILine.Trim();
1461                         CaptureString(&CalURILine, FALSE);
1462                         ConvertToHTML(&CalURILine);
1463                 
1464                         DataLines.append(wxT("<tr><td><b>"));
1465                         DataLines.append(_("Calendar Address:"));
1466                         DataLines.append(wxT(" </b></td><td>"));
1467                         DataLines.append(CalURILine);
1468                         DataLines.append(wxT("</td></tr>"));
1469                 
1470                 }
1471                 
1472                 DataDisplay = TRUE;
1473                 
1474         }
1475         
1476         if (DataDisplay == TRUE){
1478                 DataLines.Trim();
1479                 PageData.append(wxT("<h4>"));
1480                 PageData.append(_("Calendar Addresses"));
1481                 PageData.append(wxT("</h4>"));
1482                 PageData.append(wxT("<br>"));
1483                 PageData.append(wxT("<table>"));
1484                 PageData.append(DataLines);
1485                 PageData.append(wxT("</table>"));
1486         
1487         }
1488         
1489         // Calendar Request Addresses
1491         ContactData = vCardObj->GetByPartial(wxT("CALADRURI"));
1493         DataDisplay = FALSE;
1494         DataLines.clear();
1496         if (ContactData.PropCount > 0){
1497         
1498                 wxString CalAdrURILine;
1499                 
1500                 for (int i = 0; i < ContactData.PropCount; i++){
1502                         CalAdrURILine = ContactData.PropValues[i];
1503                 
1504                         CalAdrURILine.Trim();
1505                         CaptureString(&CalAdrURILine, FALSE);
1506                         ConvertToHTML(&CalAdrURILine);
1507                 
1508                         DataLines.append(wxT("<tr><td><b>"));
1509                         DataLines.append(_("Calendar Request Address:"));
1510                         DataLines.append(wxT(" </b></td><td>"));
1511                         DataLines.append(CalAdrURILine);
1512                         DataLines.append(wxT("</td></tr>"));
1513                 
1514                 }
1515                 
1516                 DataDisplay = TRUE;
1517                 
1518         }
1519         
1520         if (DataDisplay == TRUE){
1522                 DataLines.Trim();
1523                 PageData.append(wxT("<h4>"));
1524                 PageData.append(_("Calendar Request Addresses"));
1525                 PageData.append(wxT("</h4>"));
1526                 PageData.append(wxT("<br>"));
1527                 PageData.append(wxT("<table>"));
1528                 PageData.append(DataLines);
1529                 PageData.append(wxT("</table>"));
1530         
1531         }
1533         // Free/Busy Addresses
1534         
1535         ContactData = vCardObj->GetByPartial(wxT("FBURL"));
1537         DataDisplay = FALSE;
1538         DataLines.clear();
1540         if (ContactData.PropCount > 0){
1541         
1542                 wxString FBURLLine;
1543                 
1544                 for (int i = 0; i < ContactData.PropCount; i++){
1546                         FBURLLine = ContactData.PropValues[i];
1547                 
1548                         FBURLLine.Trim();
1549                         CaptureString(&FBURLLine, FALSE);
1550                         ConvertToHTML(&FBURLLine);
1551                 
1552                         DataLines.append(wxT("<tr><td><b>"));
1553                         DataLines.append(_("Free/Busy Address:"));
1554                         DataLines.append(wxT(" </b></td><td>"));
1555                         DataLines.append(FBURLLine);
1556                         DataLines.append(wxT("</td></tr>"));
1557                 
1558                 }
1559                 
1560                 DataDisplay = TRUE;
1561                 
1562         }
1563         
1564         if (DataDisplay == TRUE){
1566                 DataLines.Trim();
1567                 PageData.append(wxT("<h4>"));
1568                 PageData.append(_("Free/Busy Addresses"));
1569                 PageData.append(wxT("</h4>"));
1570                 PageData.append(wxT("<br>"));
1571                 PageData.append(wxT("<table>"));
1572                 PageData.append(DataLines);
1573                 PageData.append(wxT("</table>"));
1574         
1575         }
1576         
1577         // Notes
1578         
1579         ContactData = vCardObj->GetByPartial(wxT("NOTE"));
1581         DataDisplay = FALSE;
1582         DataLines.clear();
1584         if (ContactData.PropCount > 0){
1585         
1586                 wxString NoteLine;
1587                 
1588                 for (int i = 0; i < ContactData.PropCount; i++){
1590                         NoteLine = ContactData.PropValues[i];
1591                 
1592                         NoteLine.Trim();
1593                         CaptureString(&NoteLine, FALSE);
1594                         ConvertToHTML(&NoteLine);
1595                 
1596                         DataLines.append(wxT("<tr><td><b>"));
1597                         DataLines.append(_("Note:"));
1598                         DataLines.append(wxT(" </b></td><td>"));
1599                         DataLines.append(NoteLine);
1600                         DataLines.append(wxT("</td></tr>"));
1601                 
1602                 }
1603                 
1604                 DataDisplay = TRUE;
1605                 
1606         }
1607         
1608         if (DataDisplay == TRUE){
1609         
1610                 PageData.append(wxT("<h4>"));
1611                 PageData.append(_("Notes"));
1612                 PageData.append(wxT("</h4>"));
1613                 PageData.append(wxT("<br>"));
1614                 PageData.append(wxT("<table>"));
1615                 PageData.append(DataLines);
1616                 PageData.append(wxT("</table>"));
1617         
1618         }
1620         // Display the HTML document on the screen.
1622         PageData.append("</td></tr></table>");
1623         
1624         PageData.append(wxT("</body>"));
1625         PageData.append(wxT("</html>"));
1627         HTMLObj->SetPage(PageData);
1631 void SplitPropertyData(wxString *PropertyLine, 
1632         std::map<int,int> *SplitPoints, 
1633         std::map<int,int> *SplitLength, 
1634         int intSize,
1635         std::map<wxString,wxString> *SplitData){
1636         
1637         // Split the property data into SplitData.
1638         
1639         wxString DataStr;
1640         wxStringTokenizer PropertyElement;
1641         wxString PropertyName;
1642         wxString PropertyValue;
1643         int intPropertyLen = PropertyLine->Len();               
1644         int intSplitsFound = 0;
1645         int intSplitSize = 0;
1646         int intSplitSeek = (intSize - 1);
1647         
1648         for (int i = intSize; i <= intPropertyLen; i++){
1650                 intSplitSize++;
1651         
1652                 if (PropertyLine->Mid(i, 1) == wxT(";") &&
1653                     PropertyLine->Mid((i - 1), 1) != wxT("\\")){
1654            
1655                     if (intSplitsFound == 0){
1656             
1657                         DataStr = PropertyLine->Mid(intSplitSeek, (intSplitSize));
1658                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
1659           
1660                     } else {
1661            
1662                         DataStr = PropertyLine->Mid(intSplitSeek, (intSplitSize - 1));
1663                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1664                     
1665                     }
1666                     
1667                     SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
1668             
1669                     intSplitsFound++;
1670                     intSplitSeek = (i + 1);
1671                     intSplitSize = 0;
1672                     
1673                     if (!DataStr.IsEmpty()){
1674                     
1675                         PropertyElement.SetString(DataStr, wxT("="));
1676                         PropertyName = PropertyElement.GetNextToken();
1677                         PropertyValue = PropertyElement.GetNextToken();
1678                         SplitData->insert(std::make_pair(PropertyName, PropertyValue));
1679                     
1680                     }
1681                     
1682                     DataStr.clear();
1683                     PropertyName.clear();
1684                     PropertyValue.clear();
1685             
1686                 }
1688         }
1690         if (intSplitsFound == 0){
1692                 DataStr = PropertyLine->Mid(intSplitSeek, (intSplitSize));
1694                 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
1695                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
1697         } else {
1699                 DataStr = PropertyLine->Mid(intSplitSeek, (intSplitSize - 1));
1701                 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
1702                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
1704         }
1706         if (!DataStr.IsEmpty()){
1707                 
1708                 PropertyElement.SetString(DataStr, wxT("="));
1709                 PropertyName = PropertyElement.GetNextToken();
1710                 PropertyValue = PropertyElement.GetNextToken();
1711                 SplitData->insert(std::make_pair(PropertyName, PropertyValue));         
1712                 
1713         }
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