Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added copyright and licence header to C++ files and headers for the common directory.
[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         // Show message to user that the contact information is loading.
41         wxString PageData;
42         
43         wxFileSystem::AddHandler(new wxMemoryFSHandler);
44         //wxMemoryFSHandler::AddFile();
45         
46         PageData.append(wxT("<html>"));
47         PageData.append(wxT("<head>"));
48         PageData.append(wxT("<title>Page Loading</title>"));    
49         PageData.append(wxT("</head>"));
50         PageData.append(wxT("<body>"));
51         PageData.append(wxT("<h2>"));
52         PageData.append(_("Loading contact information..."));
53         PageData.append(wxT("</h2>"));
54         PageData.append(wxT("</body>"));
55         PageData.append(wxT("</html>"));
57         HTMLObj->SetPage(PageData);
58         
59         PageData.clear();
60         
61         // Delete the information from the old session.
62         
63         if (!OldSID.IsEmpty()){
64         
65                 if (MemoryFSList->find(OldSID) == MemoryFSList->end()){
68                 } else {
70                         std::map<wxString, wxString>::iterator striter;
72                         for (striter = MemoryFSList->begin(); striter != MemoryFSList->end(); striter++){
74                                 if (OldSID == striter->second){
76                                         // Delete the references from the wxMemoryFSHandler
77                                         // and the entry from the map.
79                                         wxMemoryFSHandler::RemoveFile(striter->first);
80                                         break;
82                                 }
84                         }
86                         MemoryFSList->erase(striter);
88                 }
89         
90         }
91         
92         // MAke sure new session ID doesn't conflict with existing
93         // data. If there is a match, generate a new one and check again.
94         
95         bool SIDMatch = FALSE;
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         PageData.append(wxT("<body>"));
127         // Process the data in the vCard object.
128         
129         // Name (Display As)
130         
131         PageData.append(wxT("<table>"));
132         PageData.append(wxT("<tr>"));
133         PageData.append(wxT("<td>"));
134         PageData.append(wxT("<h2>"));
135         PageData.append(vCardObj->Get(wxT("FN")));
136         PageData.append(wxT("</h2>"));
137         PageData.append(wxT("</td>"));
138         PageData.append(wxT("<td>"));
139         
140         // Define common variables for ADR.
141         
142         std::map<int,int> SplitPoints;
143         std::map<int,int> SplitLength;
144         std::map<int,int>::iterator SLiter;
145         
146         int intPropertyLen;
147         int intSplitsFound;
148         int intSplitSize;
149         int intPrevValue;
150         
151         wxString AddressPOBox;
152         wxString AddressStreet;
153         wxString AddressLocality;
154         wxString AddressRegion;
155         wxString AddressPostalCode;
156         wxString AddressCountry;
157         wxString AddressExtended;
158         
159         wxString FinalAddressLine;
160         bool AddressFirst = TRUE;
161         
162         // Define common variables for PHOTO and LOGO.
163         
164         std::string PhotoDataBin;
165         std::string PhotoDataIn;
166         wxString PhotoSplitData;
167         wxString PhotoMIMEType;
168         wxString PhotoEncType;
169         wxString PhotoEncData;
170         bool LoadPicture = FALSE;
171         bool DataDisplay = FALSE;
172         bool RectData = FALSE;
173         wxRect PhotoRectPoints;
174         wxString SIDFilename;
175         wxString OutData;
176         wxString DataLines;
177         
178         // Picture
179         
180         ArrayvCardOutData ContactData = vCardObj->GetByPartial(wxT("PHOTO"));
181         
182         if (ContactData.PropCount > 0){
184                 // Split the data.
186                 
187                 
188                 /*std::map<int,int> SplitPts;
189                 std::map<int,int> SplitLen;
190                 std::map<wxString,wxString> SplitData;
191                 int intSize = 0;
192                 
193                 SplitPropertyData(&ContactData.PropData[0], 
194                         &SplitPts, 
195                         &SplitLen, 
196                         0,
197                         &SplitData);
198                 
199                 for (std::map<wxString, wxString>::iterator striter = SplitData.begin();
200                 striter != SplitData.end(); striter++){
201                 
202                         raise(SIGABRT);
203                 
204                 }*/
205                 
206                 // Look for the X-ABCROP-RECTANGLE.
207                 
208                 wxStringTokenizer PhotoSplit(ContactData.PropData[0], wxT(":"));
209                 wxString PhotoPropertyDataString = PhotoSplit.GetNextToken();
210                 wxStringTokenizer PhotoPropertyData(PhotoPropertyDataString, wxT(";"));
211                 wxString PropertyLineData;
212                 wxString PropertyName;
213                 wxString PropertyValue;
214                 
215                 wxStringTokenizer DataSplit(ContactData.PropValues[0], wxT(";"));
216                 PhotoSplitData = DataSplit.GetNextToken();
217                 wxStringTokenizer MIMESplit(PhotoSplitData, wxT(":"));
218                 MIMESplit.GetNextToken();
219                 PhotoMIMEType = MIMESplit.GetNextToken();
220                 PhotoSplitData = DataSplit.GetNextToken();
221                 wxStringTokenizer EncSplit(PhotoSplitData, wxT(","));
222                 PhotoEncType = EncSplit.GetNextToken();
223                 PhotoEncData = EncSplit.GetNextToken();
224                 
225                 // Convert the picture data from base64 to binary.
226         
227                 PhotoDataIn = std::string(PhotoEncData.mb_str());
228                 PhotoDataBin = base64_decode(PhotoDataIn);
229                 wxMemoryInputStream istream(PhotoDataBin.c_str(), (size_t)PhotoDataBin.size());
230                 wxImage photo;
232                 if (!photo.LoadFile(istream, wxBITMAP_TYPE_ANY)){
233     
234                         // Photo failed to load so do nothing.
235     
236                         LoadPicture = FALSE;
238                 } else {
239                 
240                         while (PhotoPropertyData.HasMoreTokens()){
241                 
242                                 PropertyLineData = PhotoPropertyData.GetNextToken();
243                         
244                                 wxStringTokenizer PhotoPropPair(PropertyLineData, wxT("="));
245                                 wxString PhotoPropName = PhotoPropPair.GetNextToken();
246                                 wxString PhotoPropValue = PhotoPropPair.GetNextToken();
247                 
248                                 if (PhotoPropName == wxT("X-ABCROP-RECTANGLE")){
249                         
250                                         wxStringTokenizer PhotoRectData(PhotoPropValue, wxT("&"));
251                                 
252                                         PhotoRectData.GetNextToken();
254                                         //PhotoRectPoints.SetX(wxAtoi(PhotoRectData.GetNextToken()));
255                                         //PhotoRectPoints.SetY(wxAtoi(PhotoRectData.GetNextToken()) - 100);
257                                         int PointXBase = wxAtoi(PhotoRectData.GetNextToken());
258                                         int PointYBase = wxAtoi(PhotoRectData.GetNextToken());
259                                         int PointWBase = wxAtoi(PhotoRectData.GetNextToken());
260                                         int PointHBase = wxAtoi(PhotoRectData.GetNextToken());
262                                         int PointX = PointXBase;
263                                         int PointY = PointYBase;
264                                         int PointW = PointWBase;
265                                         int PointH = PointHBase;
267                                         // Top Right Method
269                                         if (PointYBase > PointHBase){
271                                                 PointX = photo.GetWidth() - PointXBase - 140;
272                                                 PointY = photo.GetHeight() - PointYBase - 140;
273                                                 PointW = PointWBase;
274                                                 PointH = PointHBase;
276                                         } else if (PointXBase > PointWBase){
277                                         
278                                                 PointX = photo.GetWidth() - PointXBase;
279                                                 PointY = PointYBase - 50;
280                                                 PointW = PointWBase;
281                                                 PointH = PointHBase;
282                                         
283                                         } else {
284                                         
285                                         }
286                                         
287                                         /*int PointX = PointXBase;
288                                         int PointY = PointYBase;
289                                         int PointW = PointWBase;
290                                         int PointH = PointHBase;*/
292                                         // Bottom Left Method
293                                         
294                                         /*int PointX = wxAtoi(PhotoRectData.GetNextToken());
295                                         int PointY = photo.GetHeight() - wxAtoi(PhotoRectData.GetNextToken()) - 340;
296                                         int PointW = wxAtoi(PhotoRectData.GetNextToken());
297                                         int PointH = wxAtoi(PhotoRectData.GetNextToken());*/
298                                         
299                                         // Bottom Right Method
300                                         
301                                         /*int PointXRemain = photo.GetWidth() - PointX - 140;
302                                         int PointYRemain = photo.GetHeight() - PointY - 140;*/
303                                                                                 
304                                         PhotoRectPoints.SetX(PointX);
305                                         PhotoRectPoints.SetY(PointY);
306                                         PhotoRectPoints.SetWidth(PointW);
307                                         PhotoRectPoints.SetHeight(PointH);
308                                         RectData = TRUE;
309                         
310                                 }
311                 
312                         }
313                 
314                         LoadPicture = TRUE;
315                 
316                         // Resize the picture to 125x125.
317                         
318                         // Add to the wxMemnoryFSHandler.
319                         
320                         SIDFilename = SID + wxT("-photo");
321                         
322                         if (RectData == TRUE){
323                                 
324                                 wxImage rectphoto = photo.GetSubImage(PhotoRectPoints);
325                                 rectphoto = rectphoto.Scale(75, 75, wxIMAGE_QUALITY_HIGH);
326                                 wxMemoryFSHandler::AddFile(SIDFilename, rectphoto, wxBITMAP_TYPE_PNG);
327                         
328                         } else {
329                         
330                                 photo = photo.Scale(50, 50, wxIMAGE_QUALITY_HIGH);
331                                 wxMemoryFSHandler::AddFile(SIDFilename, photo, wxBITMAP_TYPE_PNG);
332                         
333                         }
334                         
335                         // Add the filename to the MemoryFSList map.
337                         MemoryFSList->insert(std::make_pair(SIDFilename, SID));
338                 
339                 }
340         
341         }
342         
343         if (LoadPicture == TRUE){
345                 PageData.append(wxT("<img src=\"memory:") + SIDFilename + wxT("\">"));
346         
347         }
348         
349         LoadPicture = FALSE;
350         
351         // Logo
352         
353         ContactData = vCardObj->GetByPartial(wxT("LOGO"));
354         
355         if (ContactData.PropCount > 0){
357                 // Split the data.
358         
359                 wxStringTokenizer DataSplit(ContactData.PropValues[0], wxT(";"));
360                 PhotoSplitData = DataSplit.GetNextToken();
361                 wxStringTokenizer MIMESplit(PhotoSplitData, wxT(":"));
362                 MIMESplit.GetNextToken();
363                 PhotoMIMEType = MIMESplit.GetNextToken();
364                 PhotoSplitData = DataSplit.GetNextToken();
365                 wxStringTokenizer EncSplit(PhotoSplitData, wxT(","));
366                 PhotoEncType = EncSplit.GetNextToken();
367                 PhotoEncData = EncSplit.GetNextToken();
368                 
369                 // Convert the picture data from base64 to binary.
370         
371                 PhotoDataIn = std::string(PhotoEncData.mb_str());
372                 PhotoDataBin = base64_decode(PhotoDataIn);
373                 wxMemoryInputStream istream(PhotoDataBin.c_str(), (size_t)PhotoDataBin.size());
374                 wxImage photo;
376                 if (!photo.LoadFile(istream, wxBITMAP_TYPE_ANY)){
377     
378                         // Photo failed to load so do nothing.
379     
380                         LoadPicture = FALSE;
382                 } else {
383                 
384                         LoadPicture = TRUE;
385                 
386                         photo = photo.Scale(50, 50, wxIMAGE_QUALITY_HIGH);
388                         // Resize the picture to 125x125.
389                         
390                         // Add to the wxMemnoryFSHandler.
391                         
392                         SIDFilename = SID + wxT("-logo");
393                         
394                         wxMemoryFSHandler::AddFile(SIDFilename, photo, wxBITMAP_TYPE_PNG);
395                         
396                         // Add the filename to the MemoryFSList map.
397                         
398                         MemoryFSList->insert(std::make_pair(SIDFilename, SID));
399                 
400                 }
401         
402         }
403         
404         if (LoadPicture == TRUE){
406                 PageData.append(wxT("<img src=\"memory:") + SIDFilename + wxT("\">"));
407         
408         }       
410         PageData.append(wxT("</td>"));
411         PageData.append(wxT("</tr>"));
412         PageData.append(wxT("</table>"));
413         
414         // Process LOGO, PHOTO, SOUND, KEY, VND-* and X-*
415         // lines and display icons for each accordingly.
417         ContactData = vCardObj->GetByPartial(wxT("PHOTO"));
418         
419         bool AddBreak = FALSE;
420         
421         if (ContactData.PropCount > 1){
422         
423                 PageData.append(wxT("<img src=\"memory:cipto.png\" alt=\""));
424                 PageData.append(_("This contact has multiple photos."));
425                 PageData.append(wxT("\">"));
426                 AddBreak = TRUE;
427         
428         }
429         
430         ContactData = vCardObj->GetByPartial(wxT("LOGO"));
431         
432         if (ContactData.PropCount > 1){
433         
434                 PageData.append(wxT("<img src=\"memory:cilog.png\" alt=\""));
435                 PageData.append(_("This contact has multiple logos."));
436                 PageData.append(wxT("\">"));
437                 AddBreak = TRUE;
438         
439         }
440         
441         ContactData = vCardObj->GetByPartial(wxT("SOUND"));
442         
443         if (ContactData.PropCount >= 1){
444         
445                 PageData.append(wxT("<img src=\"memory:cisnd.png\" alt=\""));
446                 PageData.append(_("This contact has audio information."));
447                 PageData.append(wxT("\">"));
448                 AddBreak = TRUE;
449         
450         }
451         
452         ContactData = vCardObj->GetByPartial(wxT("KEY"));
454         if (ContactData.PropCount >= 1){
455         
456                 PageData.append(wxT("<img src=\"memory:cikey.png\" alt=\""));
457                 PageData.append(_("This contact has crytographic keys."));
458                 PageData.append(wxT("\">"));
459                 AddBreak = TRUE;
460         
461         }
462         
463         ContactData = vCardObj->GetByPartial(wxT("VND-"));
464         
465         if (ContactData.PropCount >= 1){
466         
467                 PageData.append(wxT("<img src=\"memory:civen.png\" alt=\""));
468                 PageData.append(_("This contact has vendor-specific information."));
469                 PageData.append(wxT("\">"));
470                 AddBreak = TRUE;
471         
472         }
473         
474         ContactData = vCardObj->GetByPartial(wxT("X-"));
475         
476         if (ContactData.PropCount >= 1){
477         
478                 PageData.append(wxT("<img src=\"memory:ciext.png\" alt=\""));
479                 PageData.append(_("This contact has extended information."));
480                 PageData.append(wxT("\">"));
481                 AddBreak = TRUE;
483         }
484         
485         if (AddBreak == TRUE){
486         
487                 PageData.append(wxT("<br><br>"));
488         
489         }
490         
491         bool MultiLogoIcon = FALSE;
492         bool MultiPhotoIcon = FALSE;
493         bool SoundIcon = FALSE;
494         bool KeyIcon = FALSE;
495         bool VendorIcon = FALSE;
496         bool XTokenIcon = FALSE;
497         
498         // Process Birthday
499         
500         ContactData = vCardObj->GetByPartial(wxT("BDAY"));
502         DataDisplay = FALSE;
503         DataLines.clear();
505         if (ContactData.PropCount > 0){
506         
507                 wxString BDayLine;
508                 
509                 for (int i = 0; i < ContactData.PropCount; i++){
511                         // Grab the first birthday only.
513                         BDayLine = ContactData.PropValues[i];
514                 
515                         BDayLine.Trim();
516                         CaptureString(&BDayLine, FALSE);
517                         ConvertToHTML(&BDayLine);
518                 
519                         DataLines.append(BDayLine);
521                         break;
522                 
523                 }
524                 
525                 DataDisplay = TRUE;
526                 
527         }
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(wxT("</body>"));
1622         PageData.append(wxT("</html>"));
1624         HTMLObj->SetPage(PageData);
1628 void SplitPropertyData(wxString *PropertyLine, 
1629         std::map<int,int> *SplitPoints, 
1630         std::map<int,int> *SplitLength, 
1631         int intSize,
1632         std::map<wxString,wxString> *SplitData){
1633         
1634         wxString DataStr;
1635         wxStringTokenizer PropertyElement;
1636         wxString PropertyName;
1637         wxString PropertyValue;
1638         int intPropertyLen = PropertyLine->Len();               
1639         int intSplitsFound = 0;
1640         int intSplitSize = 0;
1641         int intSplitSeek = (intSize - 1);
1642         
1643         for (int i = intSize; i <= intPropertyLen; i++){
1645                 intSplitSize++;
1646         
1647                 if (PropertyLine->Mid(i, 1) == wxT(";") &&
1648                     PropertyLine->Mid((i - 1), 1) != wxT("\\")){
1649            
1650                     if (intSplitsFound == 0){
1651             
1652                         DataStr = PropertyLine->Mid(intSplitSeek, (intSplitSize));
1653                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
1654           
1655                     } else {
1656            
1657                         DataStr = PropertyLine->Mid(intSplitSeek, (intSplitSize - 1));
1658                         SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1659                     
1660                     }
1661                     
1662                     SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
1663             
1664                     intSplitsFound++;
1665                     intSplitSeek = (i + 1);
1666                     intSplitSize = 0;
1667                     
1668                     if (!DataStr.IsEmpty()){
1669                     
1670                         PropertyElement.SetString(DataStr, wxT("="));
1671                         PropertyName = PropertyElement.GetNextToken();
1672                         PropertyValue = PropertyElement.GetNextToken();
1673                         SplitData->insert(std::make_pair(PropertyName, PropertyValue));
1674                     
1675                     }
1676                     
1677                     DataStr.clear();
1678                     PropertyName.clear();
1679                     PropertyValue.clear();
1680             
1681                 }
1683         }
1685         if (intSplitsFound == 0){
1687                 DataStr = PropertyLine->Mid(intSplitSeek, (intSplitSize));
1689                 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
1690                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
1692         } else {
1694                 DataStr = PropertyLine->Mid(intSplitSeek, (intSplitSize - 1));
1696                 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
1697                 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
1699         }
1701         if (!DataStr.IsEmpty()){
1702                 
1703                 PropertyElement.SetString(DataStr, wxT("="));
1704                 PropertyName = PropertyElement.GetNextToken();
1705                 PropertyValue = PropertyElement.GetNextToken();
1706                 SplitData->insert(std::make_pair(PropertyName, PropertyValue));         
1707                 
1708         }
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