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