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