Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
6c56df3b616e16a0d2c006b4b85727a156758072
[xestiaab/.git] / source / common / getcontactinfo.cpp
1 #include <iostream>
2 #include <map>
3 #include <utility>
4 #include <wx/wx.h>
5 #include <wx/tokenzr.h>
6 #include <wx/fs_mem.h>
7 #include <wx/mstream.h>
8 #include <wx/filesys.h>
9 #include <wx/datetime.h>
10 //#include <b64/decode.h>
11 #include <string>
13 #include "getcontactinfo.h"
14 #include "base64.h"
15 #include "textprocessing.h"
16 #include "../vcard/vcard34conv.h"
18 void LoadContactData(vCard *vCardObj, wxHtmlWindow *HTMLObj, wxString SID, 
19         wxString OldSID, std::map<wxString, wxString> *MemoryFSList){
21         // Show message to user that the contact information is loading.
23         wxString PageData;
24         
25         wxFileSystem::AddHandler(new wxMemoryFSHandler);
26         //wxMemoryFSHandler::AddFile();
27         
28         PageData.append(wxT("<html>"));
29         PageData.append(wxT("<head>"));
30         PageData.append(wxT("<title>Page Loading</title>"));    
31         PageData.append(wxT("</head>"));
32         PageData.append(wxT("<body>"));
33         PageData.append(wxT("<h2>"));
34         PageData.append(_("Loading contact information..."));
35         PageData.append(wxT("</h2>"));
36         PageData.append(wxT("</body>"));
37         PageData.append(wxT("</html>"));
39         HTMLObj->SetPage(PageData);
40         
41         PageData.clear();
42         
43         // Delete the information from the old session.
44         
45         if (!OldSID.IsEmpty()){
46         
47                 if (MemoryFSList->find(OldSID) == MemoryFSList->end()){
50                 } else {
52                         std::map<wxString, wxString>::iterator striter;
54                         for (striter = MemoryFSList->begin(); striter != MemoryFSList->end(); striter++){
56                                 if (OldSID == striter->second){
58                                         // Delete the references from the wxMemoryFSHandler
59                                         // and the entry from the map.
61                                         wxMemoryFSHandler::RemoveFile(striter->first);
62                                         break;
64                                 }
66                         }
68                         MemoryFSList->erase(striter);
70                 }
71         
72         }
73         
74         // MAke sure new session ID doesn't conflict with existing
75         // data. If there is a match, generate a new one and check again.
76         
77         bool SIDMatch = FALSE;
78         wxString SIDTemp;
79         
80         for (std::map<wxString, wxString>::iterator striter = MemoryFSList->begin();
81                 striter != MemoryFSList->end(); striter++){
82         
83                 SIDTemp = striter->second;
84                 
85                 if (SID == SIDTemp){
86                 
87                         // Generate a new random number.
88                         
89                         SID = wxString::Format(wxT("%i"), rand() % 32768);
90                         
91                         // Rewind the seek process back to the start.
92                         
93                         striter = MemoryFSList->begin();
94                 
95                 }
96                                 
97         }
98         
99         SIDTemp.clear();
101         // Setup the HTML document.
103         PageData.append(wxT("<html>"));
104         PageData.append(wxT("<head>"));
105         PageData.append(wxT("<title>Contact Information</title>"));     
106         PageData.append(wxT("</head>"));
107         PageData.append(wxT("<body>"));
109         // Process the data in the vCard object.
110         
111         // Name (Display As)
112         
113         PageData.append(wxT("<table>"));
114         PageData.append(wxT("<tr>"));
115         PageData.append(wxT("<td>"));
116         PageData.append(wxT("<h2>"));
117         PageData.append(vCardObj->Get(wxT("FN")));
118         PageData.append(wxT("</h2>"));
119         PageData.append(wxT("</td>"));
120         PageData.append(wxT("<td>"));
121         
122         // Define common variables for ADR.
123         
124         std::map<int,int> SplitPoints;
125         std::map<int,int> SplitLength;
126         std::map<int,int>::iterator SLiter;
127         
128         int intPropertyLen;
129         int intSplitsFound;
130         int intSplitSize;
131         int intPrevValue;
132         
133         wxString AddressPOBox;
134         wxString AddressStreet;
135         wxString AddressLocality;
136         wxString AddressRegion;
137         wxString AddressPostalCode;
138         wxString AddressCountry;
139         wxString AddressExtended;
140         
141         wxString FinalAddressLine;
142         bool AddressFirst = TRUE;
143         
144         // Define common variables for PHOTO and LOGO.
145         
146         std::string PhotoDataBin;
147         std::string PhotoDataIn;
148         wxString PhotoSplitData;
149         wxString PhotoMIMEType;
150         wxString PhotoEncType;
151         wxString PhotoEncData;
152         bool LoadPicture = FALSE;
153         bool DataDisplay = FALSE;
154         bool RectData = FALSE;
155         wxRect PhotoRectPoints;
156         wxString SIDFilename;
157         wxString OutData;
158         wxString DataLines;
159         
160         // Picture
161         
162         ArrayvCardOutData ContactData = vCardObj->GetByPartial(wxT("PHOTO"));
163         
164         if (ContactData.PropCount > 0){
166                 // Split the data.
168                 
169                 
170                 /*std::map<int,int> SplitPts;
171                 std::map<int,int> SplitLen;
172                 std::map<wxString,wxString> SplitData;
173                 int intSize = 0;
174                 
175                 SplitPropertyData(&ContactData.PropData[0], 
176                         &SplitPts, 
177                         &SplitLen, 
178                         0,
179                         &SplitData);
180                 
181                 for (std::map<wxString, wxString>::iterator striter = SplitData.begin();
182                 striter != SplitData.end(); striter++){
183                 
184                         raise(SIGABRT);
185                 
186                 }*/
187                 
188                 // Look for the X-ABCROP-RECTANGLE.
189                 
190                 wxStringTokenizer PhotoSplit(ContactData.PropData[0], wxT(":"));
191                 wxString PhotoPropertyDataString = PhotoSplit.GetNextToken();
192                 wxStringTokenizer PhotoPropertyData(PhotoPropertyDataString, wxT(";"));
193                 wxString PropertyLineData;
194                 wxString PropertyName;
195                 wxString PropertyValue;
196                 
197                 wxStringTokenizer DataSplit(ContactData.PropValues[0], wxT(";"));
198                 PhotoSplitData = DataSplit.GetNextToken();
199                 wxStringTokenizer MIMESplit(PhotoSplitData, wxT(":"));
200                 MIMESplit.GetNextToken();
201                 PhotoMIMEType = MIMESplit.GetNextToken();
202                 PhotoSplitData = DataSplit.GetNextToken();
203                 wxStringTokenizer EncSplit(PhotoSplitData, wxT(","));
204                 PhotoEncType = EncSplit.GetNextToken();
205                 PhotoEncData = EncSplit.GetNextToken();
206                 
207                 // Convert the picture data from base64 to binary.
208         
209                 PhotoDataIn = std::string(PhotoEncData.mb_str());
210                 PhotoDataBin = base64_decode(PhotoDataIn);
211                 wxMemoryInputStream istream(PhotoDataBin.c_str(), (size_t)PhotoDataBin.size());
212                 wxImage photo;
214                 if (!photo.LoadFile(istream, wxBITMAP_TYPE_ANY)){
215     
216                         // Photo failed to load so do nothing.
217     
218                         LoadPicture = FALSE;
220                 } else {
221                 
222                         while (PhotoPropertyData.HasMoreTokens()){
223                 
224                                 PropertyLineData = PhotoPropertyData.GetNextToken();
225                         
226                                 wxStringTokenizer PhotoPropPair(PropertyLineData, wxT("="));
227                                 wxString PhotoPropName = PhotoPropPair.GetNextToken();
228                                 wxString PhotoPropValue = PhotoPropPair.GetNextToken();
229                 
230                                 if (PhotoPropName == wxT("X-ABCROP-RECTANGLE")){
231                         
232                                         wxStringTokenizer PhotoRectData(PhotoPropValue, wxT("&"));
233                                 
234                                         PhotoRectData.GetNextToken();
236                                         //PhotoRectPoints.SetX(wxAtoi(PhotoRectData.GetNextToken()));
237                                         //PhotoRectPoints.SetY(wxAtoi(PhotoRectData.GetNextToken()) - 100);
239                                         int PointXBase = wxAtoi(PhotoRectData.GetNextToken());
240                                         int PointYBase = wxAtoi(PhotoRectData.GetNextToken());
241                                         int PointWBase = wxAtoi(PhotoRectData.GetNextToken());
242                                         int PointHBase = wxAtoi(PhotoRectData.GetNextToken());
244                                         int PointX = PointXBase;
245                                         int PointY = PointYBase;
246                                         int PointW = PointWBase;
247                                         int PointH = PointHBase;
249                                         // Top Right Method
251                                         if (PointYBase > PointHBase){
253                                                 PointX = photo.GetWidth() - PointXBase - 140;
254                                                 PointY = photo.GetHeight() - PointYBase - 140;
255                                                 PointW = PointWBase;
256                                                 PointH = PointHBase;
258                                         } else if (PointXBase > PointWBase){
259                                         
260                                                 PointX = photo.GetWidth() - PointXBase;
261                                                 PointY = PointYBase - 50;
262                                                 PointW = PointWBase;
263                                                 PointH = PointHBase;
264                                         
265                                         } else {
266                                         
267                                         }
268                                         
269                                         /*int PointX = PointXBase;
270                                         int PointY = PointYBase;
271                                         int PointW = PointWBase;
272                                         int PointH = PointHBase;*/
274                                         // Bottom Left Method
275                                         
276                                         /*int PointX = wxAtoi(PhotoRectData.GetNextToken());
277                                         int PointY = photo.GetHeight() - wxAtoi(PhotoRectData.GetNextToken()) - 340;
278                                         int PointW = wxAtoi(PhotoRectData.GetNextToken());
279                                         int PointH = wxAtoi(PhotoRectData.GetNextToken());*/
280                                         
281                                         // Bottom Right Method
282                                         
283                                         /*int PointXRemain = photo.GetWidth() - PointX - 140;
284                                         int PointYRemain = photo.GetHeight() - PointY - 140;*/
285                                                                                 
286                                         PhotoRectPoints.SetX(PointX);
287                                         PhotoRectPoints.SetY(PointY);
288                                         PhotoRectPoints.SetWidth(PointW);
289                                         PhotoRectPoints.SetHeight(PointH);
290                                         RectData = TRUE;
291                         
292                                 }
293                 
294                         }
295                 
296                         LoadPicture = TRUE;
297                 
298                         // Resize the picture to 125x125.
299                         
300                         // Add to the wxMemnoryFSHandler.
301                         
302                         SIDFilename = SID + wxT("-photo");
303                         
304                         if (RectData == TRUE){
305                                 
306                                 wxImage rectphoto = photo.GetSubImage(PhotoRectPoints);
307                                 rectphoto = rectphoto.Scale(75, 75, wxIMAGE_QUALITY_HIGH);
308                                 wxMemoryFSHandler::AddFile(SIDFilename, rectphoto, wxBITMAP_TYPE_PNG);
309                         
310                         } else {
311                         
312                                 photo = photo.Scale(50, 50, wxIMAGE_QUALITY_HIGH);
313                                 wxMemoryFSHandler::AddFile(SIDFilename, photo, wxBITMAP_TYPE_PNG);
314                         
315                         }
316                         
317                         // Add the filename to the MemoryFSList map.
319                         MemoryFSList->insert(std::make_pair(SIDFilename, SID));
320                 
321                 }
322         
323         }
324         
325         if (LoadPicture == TRUE){
327                 PageData.append(wxT("<img src=\"memory:") + SIDFilename + wxT("\">"));
328         
329         }
330         
331         LoadPicture = FALSE;
332         
333         // Logo
334         
335         ContactData = vCardObj->GetByPartial(wxT("LOGO"));
336         
337         if (ContactData.PropCount > 0){
339                 // Split the data.
340         
341                 wxStringTokenizer DataSplit(ContactData.PropValues[0], wxT(";"));
342                 PhotoSplitData = DataSplit.GetNextToken();
343                 wxStringTokenizer MIMESplit(PhotoSplitData, wxT(":"));
344                 MIMESplit.GetNextToken();
345                 PhotoMIMEType = MIMESplit.GetNextToken();
346                 PhotoSplitData = DataSplit.GetNextToken();
347                 wxStringTokenizer EncSplit(PhotoSplitData, wxT(","));
348                 PhotoEncType = EncSplit.GetNextToken();
349                 PhotoEncData = EncSplit.GetNextToken();
350                 
351                 // Convert the picture data from base64 to binary.
352         
353                 PhotoDataIn = std::string(PhotoEncData.mb_str());
354                 PhotoDataBin = base64_decode(PhotoDataIn);
355                 wxMemoryInputStream istream(PhotoDataBin.c_str(), (size_t)PhotoDataBin.size());
356                 wxImage photo;
358                 if (!photo.LoadFile(istream, wxBITMAP_TYPE_ANY)){
359     
360                         // Photo failed to load so do nothing.
361     
362                         LoadPicture = FALSE;
364                 } else {
365                 
366                         LoadPicture = TRUE;
367                 
368                         photo = photo.Scale(50, 50, wxIMAGE_QUALITY_HIGH);
370                         // Resize the picture to 125x125.
371                         
372                         // Add to the wxMemnoryFSHandler.
373                         
374                         SIDFilename = SID + wxT("-logo");
375                         
376                         wxMemoryFSHandler::AddFile(SIDFilename, photo, wxBITMAP_TYPE_PNG);
377                         
378                         // Add the filename to the MemoryFSList map.
379                         
380                         MemoryFSList->insert(std::make_pair(SIDFilename, SID));
381                 
382                 }
383         
384         }
385         
386         if (LoadPicture == TRUE){
388                 PageData.append(wxT("<img src=\"memory:") + SIDFilename + wxT("\">"));
389         
390         }       
392         PageData.append(wxT("</td>"));
393         PageData.append(wxT("</tr>"));
394         PageData.append(wxT("</table>"));
395         
396         // Process LOGO, PHOTO, SOUND, KEY, VND-* and X-*
397         // lines and display icons for each accordingly.
399         ContactData = vCardObj->GetByPartial(wxT("PHOTO"));
400         
401         bool AddBreak = FALSE;
402         
403         if (ContactData.PropCount > 1){
404         
405                 PageData.append(wxT("<img src=\"memory:cipto.png\" alt=\""));
406                 PageData.append(_("This contact has multiple photos."));
407                 PageData.append(wxT("\">"));
408                 AddBreak = TRUE;
409         
410         }
411         
412         ContactData = vCardObj->GetByPartial(wxT("LOGO"));
413         
414         if (ContactData.PropCount > 1){
415         
416                 PageData.append(wxT("<img src=\"memory:cilog.png\" alt=\""));
417                 PageData.append(_("This contact has multiple logos."));
418                 PageData.append(wxT("\">"));
419                 AddBreak = TRUE;
420         
421         }
422         
423         ContactData = vCardObj->GetByPartial(wxT("SOUND"));
424         
425         if (ContactData.PropCount >= 1){
426         
427                 PageData.append(wxT("<img src=\"memory:cisnd.png\" alt=\""));
428                 PageData.append(_("This contact has audio information."));
429                 PageData.append(wxT("\">"));
430                 AddBreak = TRUE;
431         
432         }
433         
434         ContactData = vCardObj->GetByPartial(wxT("KEY"));
436         if (ContactData.PropCount >= 1){
437         
438                 PageData.append(wxT("<img src=\"memory:cikey.png\" alt=\""));
439                 PageData.append(_("This contact has crytographic keys."));
440                 PageData.append(wxT("\">"));
441                 AddBreak = TRUE;
442         
443         }
444         
445         ContactData = vCardObj->GetByPartial(wxT("VND-"));
446         
447         if (ContactData.PropCount >= 1){
448         
449                 PageData.append(wxT("<img src=\"memory:civen.png\" alt=\""));
450                 PageData.append(_("This contact has vendor-specific information."));
451                 PageData.append(wxT("\">"));
452                 AddBreak = TRUE;
453         
454         }
455         
456         ContactData = vCardObj->GetByPartial(wxT("X-"));
457         
458         if (ContactData.PropCount >= 1){
459         
460                 PageData.append(wxT("<img src=\"memory:ciext.png\" alt=\""));
461                 PageData.append(_("This contact has extended information."));
462                 PageData.append(wxT("\">"));
463                 AddBreak = TRUE;
465         }
466         
467         if (AddBreak == TRUE){
468         
469                 PageData.append(wxT("<br><br>"));
470         
471         }
472         
473         bool MultiLogoIcon = FALSE;
474         bool MultiPhotoIcon = FALSE;
475         bool SoundIcon = FALSE;
476         bool KeyIcon = FALSE;
477         bool VendorIcon = FALSE;
478         bool XTokenIcon = FALSE;
479         
480         // Process Birthday
481         
482         ContactData = vCardObj->GetByPartial(wxT("BDAY"));
484         DataDisplay = FALSE;
485         DataLines.clear();
487         if (ContactData.PropCount > 0){
488         
489                 wxString BDayLine;
490                 
491                 for (int i = 0; i < ContactData.PropCount; i++){
493                         // Grab the first birthday only.
495                         BDayLine = ContactData.PropValues[i];
496                 
497                         BDayLine.Trim();
498                         CaptureString(&BDayLine, FALSE);
499                         ConvertToHTML(&BDayLine);
500                 
501                         DataLines.append(BDayLine);
503                         break;
504                 
505                 }
506                 
507                 DataDisplay = TRUE;
508                 
509         }
510         
511         if (DataDisplay == TRUE){
512         
513                 DataLines.Trim();
514                 PageData.append(wxT("<b>"));
515                 PageData.append(_("Birthday:"));
516                 PageData.append(wxT("</b> "));
517                 PageData.append(DataLines);
518                 PageData.append(wxT("<br>"));
519         
520         }
521         
522         // Process Anniversary
523         
524         ContactData = vCardObj->GetByPartial(wxT("ANNIVERSARY"));
526         DataDisplay = FALSE;
527         DataLines.clear();
529         if (ContactData.PropCount > 0){
530         
531                 wxString AnniLine;
532                 
533                 for (int i = 0; i < ContactData.PropCount; i++){
535                         // Grab the first anniversary only.
537                         AnniLine = ContactData.PropValues[i];
538                 
539                         AnniLine.Trim();
540                         CaptureString(&AnniLine, FALSE);
541                         ConvertToHTML(&AnniLine);
542                 
543                         DataLines.append(AnniLine);
545                         break;
546                 
547                 }
548                 
549                 DataDisplay = TRUE;
550                 
551         }
552         
553         if (DataDisplay == TRUE){
554         
555                 DataLines.Trim();
556                 PageData.append(wxT("<b>"));
557                 PageData.append(_("Anniversary:"));
558                 PageData.append(wxT("</b> "));
559                 PageData.append(DataLines);
560                 PageData.append(wxT("<br>"));
561         
562         }
563         
564         // Nickname
565         
566         ContactData = vCardObj->GetByPartial(wxT("NICKNAME"));
568         DataDisplay = FALSE;
569         DataLines.clear();
571         if (ContactData.PropCount > 0){
572         
573                 wxString NicknameLine;
574                 
575                 for (int i = 0; i < ContactData.PropCount; i++){
577                         NicknameLine = ContactData.PropValues[i];
578                 
579                         NicknameLine.Trim();
580                         CaptureString(&NicknameLine, FALSE);
581                         ConvertToHTML(&NicknameLine);
582                 
583                         DataLines.append(wxT("<tr><td><b>"));
584                         DataLines.append(_("Nickname:"));
585                         DataLines.append(wxT(" </b></td><td>"));
586                         DataLines.append(NicknameLine);
587                         DataLines.append(wxT("</td></tr>"));
588                 
589                 }
590                 
591                 DataDisplay = TRUE;
592                 
593         }
594         
595         if (DataDisplay == TRUE){
597                 DataLines.Trim();
598                 PageData.append(wxT("<h4>"));
599                 PageData.append(_("Nicknames"));
600                 PageData.append(wxT("</h4>"));
601                 PageData.append(wxT("<br>"));
602                 PageData.append(wxT("<table>"));
603                 PageData.append(DataLines);
604                 PageData.append(wxT("</table>"));
605         
606         }
607         
608         // Address
609         
610         ContactData = vCardObj->GetByPartial(wxT("ADR"));
611         
612         DataDisplay = FALSE;
613         DataLines.clear();
614                 
615         if (ContactData.PropCount > 0){
616         
617                 wxString AddressLine;
618         
619                 for (int i = 0; i < ContactData.PropCount; i++){
620                         
621                         AddressLine = ContactData.PropValues[i];
622                         
623                         intPropertyLen = AddressLine.Len();
624                         SplitPoints.clear();
625                         SplitLength.clear();
626                         intSplitsFound = 0;
627                         intSplitSize = 0;
628                         intPrevValue = 0;
629                         
630                         AddressPOBox.clear();
631                         AddressStreet.clear();
632                         AddressLocality.clear();
633                         AddressRegion.clear();
634                         AddressPostalCode.clear();
635                         AddressCountry.clear();
636                         AddressExtended.clear();
637                         FinalAddressLine.clear();
638                         AddressFirst = TRUE;
639                         
640                         for (int i = 0; i <= intPropertyLen; i++){
641                 
642                                 intSplitSize++;
643                         
644                                 if (AddressLine.Mid(i, 1) == wxT(";") && AddressLine.Mid((i - 1), 1) != wxT("\\")){
645                         
646                                         intSplitsFound++;
647                                         SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
648                                         
649                                         if (intSplitsFound == 6){ 
650                                         
651                                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
652                                                 break; 
653                                                 
654                                         } else {
655                                         
656                                                 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
657                                         
658                                         }
659                                         
660                                         intSplitSize = 0;                                       
661                         
662                                 }
663                 
664                         }
665                         
666                         // Split the data into several parts.                   
667                         
668                         for (std::map<int, int>::iterator intiter = SplitPoints.begin(); 
669                         intiter != SplitPoints.end(); ++intiter){
670                         
671                                 if (intiter->first == 1){
672                                 
673                                         // Deal with PO Box.
674                                         
675                                         SLiter = SplitLength.find(1);
676                                                                                 
677                                         //txtSurname->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(0, SLiter->second), TRUE));
678                                         AddressPOBox = AddressLine.Mid(0, SLiter->second);
679                                         intPrevValue = intiter->second;
680                                 
681                                 } else if (intiter->first == 2){
682                                 
683                                         // Deal with extended address.
684                                         
685                                         SLiter = SplitLength.find(2);
686                                         
687                                         AddressExtended = AddressLine.Mid(intPrevValue, SLiter->second);
688                                         //txtForename->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
689                                         intPrevValue = intiter->second;
690                                 
691                                 } else if (intiter->first == 3){
692                                 
693                                         // Deal with street address.
694                                         
695                                         SLiter = SplitLength.find(3);
696                                                                                 
697                                         AddressStreet = AddressLine.Mid(intPrevValue, SLiter->second);
698                                         //txtOtherNames->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
699                                         intPrevValue = intiter->second;
700                                 
701                                 } else if (intiter->first == 4){
702                                 
703                                         // Deal with locality
705                                         SLiter = SplitLength.find(4);
706                                         
707                                         AddressLocality = AddressLine.Mid(intPrevValue, SLiter->second);
708                                         //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
709                                         intPrevValue = intiter->second;
710                                         
711                                         //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, wxSTRING_MAXLEN), TRUE));
712                                 
713                                 } else if (intiter->first == 5){
714                                 
715                                         // Deal with region.
717                                         SLiter = SplitLength.find(5);
718                                         
719                                         AddressRegion = AddressLine.Mid(intPrevValue, SLiter->second);
720                                         //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
721                                         intPrevValue = intiter->second;
722                                         
723                                         //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, wxSTRING_MAXLEN), TRUE));
724                                 
725                                 } else if (intiter->first == 6){
726                                 
727                                         // Deal with post code.
729                                         SLiter = SplitLength.find(6);
730                                         
731                                         AddressPostalCode = AddressLine.Mid(intPrevValue, SLiter->second);
732                                         //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
733                                         intPrevValue = intiter->second;
734                                         
735                                         // Deal with country.
736                                         
737                                         AddressCountry = AddressLine.Mid(intPrevValue);
738                                         //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, wxSTRING_MAXLEN), TRUE));
739                                 
740                                 }
741                         
742                         }
743                         
744                         if (!AddressStreet.IsEmpty()){
745                         
746                                 AddressStreet.Trim();
747                                 ConvertToHTML(&AddressStreet);
748                         
749                                 FinalAddressLine.append(AddressStreet);
750                                 AddressFirst = FALSE;
751                         
752                         }
753                         
754                         if (!AddressLocality.IsEmpty()){
755                         
756                                 AddressLocality.Trim();
757                                 ConvertToHTML(&AddressLocality);
758                         
759                                 if (AddressFirst == FALSE){
760                                 
761                                         FinalAddressLine.append(wxT(",<br>"));
762                                         FinalAddressLine.append(AddressLocality);
764                                 } else {
765                                 
766                                         FinalAddressLine.append(AddressLocality);
767                                         AddressFirst = FALSE;
768                                 
769                                 }
770                         
771                         }
772                         
773                         if (!AddressRegion.IsEmpty()){
774                         
775                                 AddressRegion.Trim();
776                                 ConvertToHTML(&AddressRegion);
777                         
778                                 if (AddressFirst == FALSE){
779                                 
780                                         FinalAddressLine.append(wxT(",<br>"));
781                                         FinalAddressLine.append(AddressRegion);
783                                 } else {
784                                 
785                                         FinalAddressLine.append(AddressRegion);
786                                         AddressFirst = FALSE;
787                                 
788                                 }
789                         
790                         }
791                         
792                         if (!AddressPostalCode.IsEmpty()){
793                         
794                                 AddressPostalCode.Trim();
795                                 ConvertToHTML(&AddressPostalCode);
796                         
797                                 if (AddressFirst == FALSE){
798                                 
799                                         FinalAddressLine.append(wxT(",<br>"));
800                                         FinalAddressLine.append(AddressPostalCode);
802                                 } else {
803                                 
804                                         FinalAddressLine.append(AddressPostalCode);
805                                         AddressFirst = FALSE;
806                                 
807                                 }
808                         
809                         }
810                         
811                         if (!AddressCountry.IsEmpty()){
812                         
813                                 AddressCountry.Trim();
814                                 ConvertToHTML(&AddressCountry);
815                         
816                                 if (AddressFirst == FALSE){
817                                 
818                                         FinalAddressLine.append(wxT(",<br>"));
819                                         FinalAddressLine.append(AddressCountry);
821                                 } else {
822                                 
823                                         FinalAddressLine.append(AddressCountry);
824                                         AddressFirst = FALSE;
825                                 
826                                 }
827                         
828                         }
829                         
830                         CaptureString(&FinalAddressLine, FALSE);
831                         
832                         DataLines.append(wxT("<tr><td><b>"));
833                         DataLines.append(_("Address:"));
834                         DataLines.append(wxT(" </b></td><td>"));
835                         DataLines.append(FinalAddressLine);
836                         DataLines.append(wxT("</td></tr>"));
837                         
838                 }
839         
840                 DataDisplay = TRUE;
841         
842         }
843         
844         if (DataDisplay == TRUE){
845         
846                 DataLines.Trim();
847                 PageData.append(wxT("<h4>"));
848                 PageData.append(_("Addresses"));
849                 PageData.append(wxT("</h4>"));
850                 PageData.append(wxT("<br>"));
851                 PageData.append(wxT("<table>"));
852                 PageData.append(DataLines);
853                 PageData.append(wxT("</table>"));
854         
855         }
857         // Email
858         
859         ContactData = vCardObj->GetByPartial(wxT("EMAIL"));
861         DataDisplay = FALSE;
862         DataLines.clear();
864         if (ContactData.PropCount > 0){
865         
866                 wxString EmailLine;
867                 
868                 for (int i = 0; i < ContactData.PropCount; i++){
870                         EmailLine = ContactData.PropValues[i];
871                 
872                         EmailLine.Trim();
873                         CaptureString(&EmailLine, FALSE);
874                         ConvertToHTML(&EmailLine);
875                 
876                         DataLines.append(wxT("<tr><td><b>"));
877                         DataLines.append(_("E-mail Address:"));
878                         DataLines.append(wxT(" </b></td><td>"));
879                         DataLines.append(EmailLine);
880                         DataLines.append(wxT("</td></tr>"));
881                 
882                 }
883                 
884                 DataDisplay = TRUE;
885                 
886         }
887         
888         if (DataDisplay == TRUE){
890                 DataLines.Trim();
891                 PageData.append(wxT("<h4>"));
892                 PageData.append(_("Email 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         }
900         
901         // Telephone
903         ContactData = vCardObj->GetByPartial(wxT("TEL"));
905         DataDisplay = FALSE;
906         DataLines.clear();
908         if (ContactData.PropCount > 0){
909         
910                 wxString TelLine;
911                 
912                 for (int i = 0; i < ContactData.PropCount; i++){
914                         TelLine = ContactData.PropValues[i];
915                 
916                         wxStringTokenizer TelSplit(TelLine, wxT(":"));
917                         
918                         TelLine = TelSplit.GetNextToken();
919                         
920                         if (TelSplit.HasMoreTokens()){
921                         
922                                 TelLine = TelSplit.GetNextToken();
923                         
924                         }
925                 
926                         TelLine.Trim();
927                         CaptureString(&TelLine, FALSE);
928                         ConvertToHTML(&TelLine);
929                         
930                         DataLines.append(wxT("<tr><td><b>"));
931                         DataLines.append(_("Telephone:"));
932                         DataLines.append(wxT(" </b></td><td>"));
933                         DataLines.append(TelLine);
934                         DataLines.append(wxT("</td></tr>"));
935                 
936                 }
937                 
938                 DataDisplay = TRUE;
939                 
940         }
941         
942         if (DataDisplay == TRUE){
944                 DataLines.Trim();
945                 PageData.append(wxT("<h4>"));
946                 PageData.append(_("Telephones"));
947                 PageData.append(wxT("</h4>"));
948                 PageData.append(wxT("<br>"));
949                 PageData.append(wxT("<table>"));
950                 PageData.append(DataLines);
951                 PageData.append(wxT("</table>"));
952         
953         }
954         
955         // Instant Messaging
957         ContactData = vCardObj->GetByPartial(wxT("IMPP"));
959         DataDisplay = FALSE;
960         DataLines.clear();
962         if (ContactData.PropCount > 0){
963         
964                 wxString IMLine;
965                 wxString IMTypeFriendly;
966                 wxString IMType;
967                 
968                 for (int i = 0; i < ContactData.PropCount; i++){
970                         IMLine = ContactData.PropValues[i];
971                 
972                         wxStringTokenizer IMSplit(IMLine, wxT(":"));
973                         
974                         IMType = IMSplit.GetNextToken();
975                         IMLine = IMSplit.GetNextToken();
976                 
977                         // Process skype, gg, icq, yahoo etc into
978                         // something meaningful.
979                 
980                         if (IMType == wxT("aim")){
981                         
982                                 // AIM
983                         
984                                 IMTypeFriendly = _("AIM");
985                         
986                         } else if (IMType == wxT("xmpp")){
987                         
988                                 // XMPP
989                                 
990                                 IMTypeFriendly = _("XMPP");
991                         
992                         } else if (IMType == wxT("icq")){
993                         
994                                 // ICQ
995                                 
996                                 IMTypeFriendly = _("ICQ");
997                         
998                         } else if (IMType == wxT("skype")){
999                         
1000                                 // Skype
1001                         
1002                                 IMTypeFriendly = _("Skype");
1003                         
1004                         } else if (IMType == wxT("gg")){
1005                         
1006                                 // Gadu-Gadu
1007                         
1008                                 IMTypeFriendly = _("Gadu-Gadu");
1009                         
1010                         } else if (IMType == wxT("yahoo")){
1011                         
1012                                 // Yahoo
1013                                 
1014                                 IMTypeFriendly = _("Yahoo");
1015                         
1016                         } else {
1017                         
1018                                 // Other. Use IM type that was split.
1019                                 
1020                                 IMTypeFriendly = IMType;
1021                         
1022                         }
1023                 
1024                         IMLine.Trim();
1025                         CaptureString(&IMLine, FALSE);
1026                         ConvertToHTML(&IMLine);
1027                 
1028                         DataLines.append(wxT("<tr><td><b>"));
1029                         DataLines.append(_("IM Address"));
1030                         DataLines.append(_(" ("));
1031                         DataLines.append(IMTypeFriendly);
1032                         DataLines.append(_("):"));
1033                         DataLines.append(wxT(" </b></td><td>"));
1034                         DataLines.append(IMLine);
1035                         DataLines.append(wxT("</td></tr>"));
1036                 
1037                         IMTypeFriendly.clear();
1038                         IMType.clear();
1039                         IMLine.clear();
1040                 
1041                 }
1042                 
1043                 DataDisplay = TRUE;
1044                 
1045         }
1046         
1047         if (DataDisplay == TRUE){
1048         
1049                 DataLines.Trim();
1050                 PageData.append(wxT("<h4>"));
1051                 PageData.append(_("Instant Messaging Addresses"));
1052                 PageData.append(wxT("</h4>"));
1053                 PageData.append(wxT("<br>"));
1054                 PageData.append(wxT("<table>"));
1055                 PageData.append(DataLines);
1056                 PageData.append(wxT("</table>"));
1057         
1058         }
1059         
1060         // URL
1062         ContactData = vCardObj->GetByPartial(wxT("URL"));
1064         DataDisplay = FALSE;
1065         DataLines.clear();
1067         if (ContactData.PropCount > 0){
1068         
1069                 wxString URLLine;
1070                 
1071                 for (int i = 0; i < ContactData.PropCount; i++){
1073                         URLLine = ContactData.PropValues[i];
1074                 
1075                         URLLine.Trim();
1076                         CaptureString(&URLLine, FALSE);
1077                         ConvertToHTML(&URLLine);
1078                 
1079                         DataLines.append(wxT("<tr><td><b>"));
1080                         DataLines.append(_("Website:"));
1081                         DataLines.append(wxT(" </b></td><td>"));
1082                         DataLines.append(URLLine);
1083                         DataLines.append(wxT("</td></tr>"));
1084                 
1085                 }
1086                 
1087                 DataDisplay = TRUE;
1088                 
1089         }
1090         
1091         if (DataDisplay == TRUE){
1093                 DataLines.Trim();
1094                 PageData.append(wxT("<h4>"));
1095                 PageData.append(_("Website 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         // Languages
1105         
1106         ContactData = vCardObj->GetByPartial(wxT("LANG"));
1108         DataDisplay = FALSE;
1109         DataLines.clear();
1111         if (ContactData.PropCount > 0){
1112         
1113                 wxString NicknameLine;
1114                 
1115                 for (int i = 0; i < ContactData.PropCount; i++){
1117                         NicknameLine = ContactData.PropValues[i];
1118                 
1119                         NicknameLine.Trim();
1120                         CaptureString(&NicknameLine, FALSE);
1121                         ConvertToHTML(&NicknameLine);
1122                 
1123                         DataLines.append(wxT("<tr><td><b>"));
1124                         DataLines.append(_("Language:"));
1125                         DataLines.append(wxT(" </b></td><td>"));
1126                         DataLines.append(NicknameLine);
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(_("Languages"));
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         // Timezones
1149         
1150         ContactData = vCardObj->GetByPartial(wxT("TZ"));
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(_("Timezone:"));
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(_("Timezones"));
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         }
1192         // Geopositioning
1193         
1194         ContactData = vCardObj->GetByPartial(wxT("GEO"));
1196         DataDisplay = FALSE;
1197         DataLines.clear();
1199         if (ContactData.PropCount > 0){
1200         
1201                 wxString GeoLine;
1202                 
1203                 for (int i = 0; i < ContactData.PropCount; i++){
1205                         GeoLine = ContactData.PropValues[i];
1206                 
1207                         wxStringTokenizer GeoSplit(GeoLine, wxT(":"));
1208                         
1209                         GeoLine = GeoSplit.GetNextToken();
1210                         
1211                         if (GeoSplit.HasMoreTokens()){
1212                         
1213                                 GeoLine = GeoSplit.GetNextToken();
1214                         
1215                         }
1216                 
1217                         GeoLine.Trim();
1218                         CaptureString(&GeoLine, FALSE);
1219                         ConvertToHTML(&GeoLine);
1220                 
1221                         DataLines.append(wxT("<tr><td><b>"));
1222                         DataLines.append(_("Geoposition:"));
1223                         DataLines.append(wxT(" </b></td><td>"));
1224                         DataLines.append(GeoLine);
1225                         DataLines.append(wxT("</td></tr>"));
1226                 
1227                 }
1228                 
1229                 DataDisplay = TRUE;
1230                 
1231         }
1232         
1233         if (DataDisplay == TRUE){
1235                 DataLines.Trim();
1236                 PageData.append(wxT("<h4>"));
1237                 PageData.append(_("Geopositioning"));
1238                 PageData.append(wxT("</h4>"));
1239                 PageData.append(wxT("<br>"));
1240                 PageData.append(wxT("<table>"));
1241                 PageData.append(DataLines);
1242                 PageData.append(wxT("</table>"));
1243         
1244         }
1245         
1246         // Titles
1247         
1248         ContactData = vCardObj->GetByPartial(wxT("TITLE"));
1250         DataDisplay = FALSE;
1251         DataLines.clear();
1253         if (ContactData.PropCount > 0){
1254         
1255                 wxString TitleLine;
1256                 
1257                 for (int i = 0; i < ContactData.PropCount; i++){
1259                         TitleLine = ContactData.PropValues[i];
1260                 
1261                         TitleLine.Trim();
1262                         CaptureString(&TitleLine, FALSE);
1263                         ConvertToHTML(&TitleLine);
1264                 
1265                         DataLines.append(wxT("<tr><td><b>"));
1266                         DataLines.append(_("Title:"));
1267                         DataLines.append(wxT(" </b></td><td>"));
1268                         DataLines.append(TitleLine);
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(_("Titles"));
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         // Roles
1291         
1292         ContactData = vCardObj->GetByPartial(wxT("ROLE"));
1294         DataDisplay = FALSE;
1295         DataLines.clear();
1297         if (ContactData.PropCount > 0){
1298         
1299                 wxString RoleLine;
1300                 
1301                 for (int i = 0; i < ContactData.PropCount; i++){
1303                         RoleLine = ContactData.PropValues[i];
1304                 
1305                         RoleLine.Trim();
1306                         CaptureString(&RoleLine, FALSE);
1307                         ConvertToHTML(&RoleLine);
1308                 
1309                         DataLines.append(wxT("<tr><td><b>"));
1310                         DataLines.append(_("Role:"));
1311                         DataLines.append(wxT(" </b></td><td>"));
1312                         DataLines.append(RoleLine);
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(_("Roles"));
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         // Organisations
1335         
1336         ContactData = vCardObj->GetByPartial(wxT("ORG"));
1338         DataDisplay = FALSE;
1339         DataLines.clear();
1341         if (ContactData.PropCount > 0){
1342         
1343                 wxString OrgLine;
1344                 
1345                 for (int i = 0; i < ContactData.PropCount; i++){
1347                         OrgLine = ContactData.PropValues[i];
1348                 
1349                         OrgLine.Trim();
1350                         CaptureString(&OrgLine, FALSE);
1351                         ConvertToHTML(&OrgLine);
1352                 
1353                         DataLines.append(wxT("<tr><td><b>"));
1354                         DataLines.append(_("Organisation:"));
1355                         DataLines.append(wxT(" </b></td><td>"));
1356                         DataLines.append(OrgLine);
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(_("Organisations"));
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         // Categories
1379         
1380         ContactData = vCardObj->GetByPartial(wxT("CATEGORIES"));
1382         DataDisplay = FALSE;
1383         DataLines.clear();
1385         if (ContactData.PropCount > 0){
1386         
1387                 wxString CatLine;
1388                 
1389                 for (int i = 0; i < ContactData.PropCount; i++){
1391                         CatLine = ContactData.PropValues[i];
1392                 
1393                         CatLine.Trim();
1394                         CaptureString(&CatLine, FALSE);
1395                         ConvertToHTML(&CatLine);
1396                 
1397                         DataLines.append(wxT("<tr><td><b>"));
1398                         DataLines.append(_("Category:"));
1399                         DataLines.append(wxT(" </b></td><td>"));
1400                         DataLines.append(CatLine);
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(_("Categories"));
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         // Groups
1423         
1425         
1426         // Calendar Addresses
1427         
1428         ContactData = vCardObj->GetByPartial(wxT("CALURI"));
1430         DataDisplay = FALSE;
1431         DataLines.clear();
1433         if (ContactData.PropCount > 0){
1434         
1435                 wxString CalURILine;
1436                 
1437                 for (int i = 0; i < ContactData.PropCount; i++){
1439                         CalURILine = ContactData.PropValues[i];
1440                 
1441                         CalURILine.Trim();
1442                         CaptureString(&CalURILine, FALSE);
1443                         ConvertToHTML(&CalURILine);
1444                 
1445                         DataLines.append(wxT("<tr><td><b>"));
1446                         DataLines.append(_("Calendar Address:"));
1447                         DataLines.append(wxT(" </b></td><td>"));
1448                         DataLines.append(CalURILine);
1449                         DataLines.append(wxT("</td></tr>"));
1450                 
1451                 }
1452                 
1453                 DataDisplay = TRUE;
1454                 
1455         }
1456         
1457         if (DataDisplay == TRUE){
1459                 DataLines.Trim();
1460                 PageData.append(wxT("<h4>"));
1461                 PageData.append(_("Calendar Addresses"));
1462                 PageData.append(wxT("</h4>"));
1463                 PageData.append(wxT("<br>"));
1464                 PageData.append(wxT("<table>"));
1465                 PageData.append(DataLines);
1466                 PageData.append(wxT("</table>"));
1467         
1468         }
1469         
1470         // Calendar Request Addresses
1472         ContactData = vCardObj->GetByPartial(wxT("CALADRURI"));
1474         DataDisplay = FALSE;
1475         DataLines.clear();
1477         if (ContactData.PropCount > 0){
1478         
1479                 wxString CalAdrURILine;
1480                 
1481                 for (int i = 0; i < ContactData.PropCount; i++){
1483                         CalAdrURILine = ContactData.PropValues[i];
1484                 
1485                         CalAdrURILine.Trim();
1486                         CaptureString(&CalAdrURILine, FALSE);
1487                         ConvertToHTML(&CalAdrURILine);
1488                 
1489                         DataLines.append(wxT("<tr><td><b>"));
1490                         DataLines.append(_("Calendar Request Address:"));
1491                         DataLines.append(wxT(" </b></td><td>"));
1492                         DataLines.append(CalAdrURILine);
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 Request 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         }
1514         // Free/Busy Addresses
1515         
1516         ContactData = vCardObj->GetByPartial(wxT("FBURL"));
1518         DataDisplay = FALSE;
1519         DataLines.clear();
1521         if (ContactData.PropCount > 0){
1522         
1523                 wxString FBURLLine;
1524                 
1525                 for (int i = 0; i < ContactData.PropCount; i++){
1527                         FBURLLine = ContactData.PropValues[i];
1528                 
1529                         FBURLLine.Trim();
1530                         CaptureString(&FBURLLine, FALSE);
1531                         ConvertToHTML(&FBURLLine);
1532                 
1533                         DataLines.append(wxT("<tr><td><b>"));
1534                         DataLines.append(_("Free/Busy Address:"));
1535                         DataLines.append(wxT(" </b></td><td>"));
1536                         DataLines.append(FBURLLine);
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(_("Free/Busy 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         }
1557         
1558         // Notes
1559         
1560         ContactData = vCardObj->GetByPartial(wxT("NOTE"));
1562         DataDisplay = FALSE;
1563         DataLines.clear();
1565         if (ContactData.PropCount > 0){
1566         
1567                 wxString NoteLine;
1568                 
1569                 for (int i = 0; i < ContactData.PropCount; i++){
1571                         NoteLine = ContactData.PropValues[i];
1572                 
1573                         NoteLine.Trim();
1574                         CaptureString(&NoteLine, FALSE);
1575                         ConvertToHTML(&NoteLine);
1576                 
1577                         DataLines.append(wxT("<tr><td><b>"));
1578                         DataLines.append(_("Note:"));
1579                         DataLines.append(wxT(" </b></td><td>"));
1580                         DataLines.append(NoteLine);
1581                         DataLines.append(wxT("</td></tr>"));
1582                 
1583                 }
1584                 
1585                 DataDisplay = TRUE;
1586                 
1587         }
1588         
1589         if (DataDisplay == TRUE){
1590         
1591                 PageData.append(wxT("<h4>"));
1592                 PageData.append(_("Notes"));
1593                 PageData.append(wxT("</h4>"));
1594                 PageData.append(wxT("<br>"));
1595                 PageData.append(wxT("<table>"));
1596                 PageData.append(DataLines);
1597                 PageData.append(wxT("</table>"));
1598         
1599         }
1601         // Display the HTML document on the screen.
1603         PageData.append(wxT("</body>"));
1604         PageData.append(wxT("</html>"));
1606         HTMLObj->SetPage(PageData);
1610 void SplitPropertyData(wxString *PropertyLine, 
1611         std::map<int,int> *SplitPoints, 
1612         std::map<int,int> *SplitLength, 
1613         int intSize,
1614         std::map<wxString,wxString> *SplitData){
1615         
1616         wxString DataStr;
1617         wxStringTokenizer PropertyElement;
1618         wxString PropertyName;
1619         wxString PropertyValue;
1620         int intPropertyLen = PropertyLine->Len();               
1621         int intSplitsFound = 0;
1622         int intSplitSize = 0;
1623         int intSplitSeek = (intSize - 1);
1624         
1625         for (int i = intSize; i <= intPropertyLen; i++){
1627                 intSplitSize++;
1628         
1629                 if (PropertyLine->Mid(i, 1) == wxT(";") &&
1630                     PropertyLine->Mid((i - 1), 1) != wxT("\\")){
1631            
1632                     if (intSplitsFound == 0){
1633             
1634                         DataStr = PropertyLine->Mid(intSplitSeek, (intSplitSize));
1635                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
1636           
1637                     } else {
1638            
1639                         DataStr = PropertyLine->Mid(intSplitSeek, (intSplitSize - 1));
1640                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1641                     
1642                     }
1643                     
1644                     SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
1645             
1646                     intSplitsFound++;
1647                     intSplitSeek = (i + 1);
1648                     intSplitSize = 0;
1649                     
1650                     if (!DataStr.IsEmpty()){
1651                     
1652                         PropertyElement.SetString(DataStr, wxT("="));
1653                         PropertyName = PropertyElement.GetNextToken();
1654                         PropertyValue = PropertyElement.GetNextToken();
1655                         SplitData->insert(std::make_pair(PropertyName, PropertyValue));
1656                     
1657                     }
1658                     
1659                     DataStr.clear();
1660                     PropertyName.clear();
1661                     PropertyValue.clear();
1662             
1663                 }
1665         }
1667         if (intSplitsFound == 0){
1669                 DataStr = PropertyLine->Mid(intSplitSeek, (intSplitSize));
1671                 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
1672                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
1674         } else {
1676                 DataStr = PropertyLine->Mid(intSplitSeek, (intSplitSize - 1));
1678                 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
1679                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
1681         }
1683         if (!DataStr.IsEmpty()){
1684                 
1685                 PropertyElement.SetString(DataStr, wxT("="));
1686                 PropertyName = PropertyElement.GetNextToken();
1687                 PropertyValue = PropertyElement.GetNextToken();
1688                 SplitData->insert(std::make_pair(PropertyName, PropertyValue));         
1689                 
1690         }
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