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