5 #include <wx/tokenzr.h>
7 #include <wx/mstream.h>
8 #include <wx/filesys.h>
9 #include <wx/datetime.h>
10 //#include <b64/decode.h>
13 #include "getcontactinfo.h"
15 #include "textprocessing.h"
16 #include "../vcard/vcard34conv.h"
18 void LoadContactData(vCard *vCardObj, wxHtmlWindow *HTMLObj, wxString SID,
19 wxString OldSID, std::map<wxString, wxString> *MemoryFSList){
21 // Show message to user that the contact information is loading.
25 wxFileSystem::AddHandler(new wxMemoryFSHandler);
26 //wxMemoryFSHandler::AddFile();
28 PageData.append(wxT("<html>"));
29 PageData.append(wxT("<head>"));
30 PageData.append(wxT("<title>Page Loading</title>"));
31 PageData.append(wxT("</head>"));
32 PageData.append(wxT("<body>"));
33 PageData.append(wxT("<h2>"));
34 PageData.append(_("Loading contact information..."));
35 PageData.append(wxT("</h2>"));
36 PageData.append(wxT("</body>"));
37 PageData.append(wxT("</html>"));
39 HTMLObj->SetPage(PageData);
43 // Delete the information from the old session.
45 if (!OldSID.IsEmpty()){
47 if (MemoryFSList->find(OldSID) == MemoryFSList->end()){
52 std::map<wxString, wxString>::iterator striter;
54 for (striter = MemoryFSList->begin(); striter != MemoryFSList->end(); striter++){
56 if (OldSID == striter->second){
58 // Delete the references from the wxMemoryFSHandler
59 // and the entry from the map.
61 wxMemoryFSHandler::RemoveFile(striter->first);
68 MemoryFSList->erase(striter);
74 // MAke sure new session ID doesn't conflict with existing
75 // data. If there is a match, generate a new one and check again.
77 bool SIDMatch = FALSE;
80 for (std::map<wxString, wxString>::iterator striter = MemoryFSList->begin();
81 striter != MemoryFSList->end(); striter++){
83 SIDTemp = striter->second;
87 // Generate a new random number.
89 SID = wxString::Format(wxT("%i"), rand() % 32768);
91 // Rewind the seek process back to the start.
93 striter = MemoryFSList->begin();
101 // Setup the HTML document.
103 PageData.append(wxT("<html>"));
104 PageData.append(wxT("<head>"));
105 PageData.append(wxT("<title>Contact Information</title>"));
106 PageData.append(wxT("</head>"));
107 PageData.append(wxT("<body>"));
109 // Process the data in the vCard object.
113 PageData.append(wxT("<table>"));
114 PageData.append(wxT("<tr>"));
115 PageData.append(wxT("<td>"));
116 PageData.append(wxT("<h2>"));
117 PageData.append(vCardObj->Get(wxT("FN")));
118 PageData.append(wxT("</h2>"));
119 PageData.append(wxT("</td>"));
120 PageData.append(wxT("<td>"));
122 // Define common variables for ADR.
124 std::map<int,int> SplitPoints;
125 std::map<int,int> SplitLength;
126 std::map<int,int>::iterator SLiter;
133 wxString AddressPOBox;
134 wxString AddressStreet;
135 wxString AddressLocality;
136 wxString AddressRegion;
137 wxString AddressPostalCode;
138 wxString AddressCountry;
139 wxString AddressExtended;
141 wxString FinalAddressLine;
142 bool AddressFirst = TRUE;
144 // Define common variables for PHOTO and LOGO.
146 std::string PhotoDataBin;
147 std::string PhotoDataIn;
148 wxString PhotoSplitData;
149 wxString PhotoMIMEType;
150 wxString PhotoEncType;
151 wxString PhotoEncData;
152 bool LoadPicture = FALSE;
153 bool DataDisplay = FALSE;
154 bool RectData = FALSE;
155 wxRect PhotoRectPoints;
156 wxString SIDFilename;
162 ArrayvCardOutData ContactData = vCardObj->GetByPartial(wxT("PHOTO"));
164 if (ContactData.PropCount > 0){
170 /*std::map<int,int> SplitPts;
171 std::map<int,int> SplitLen;
172 std::map<wxString,wxString> SplitData;
175 SplitPropertyData(&ContactData.PropData[0],
181 for (std::map<wxString, wxString>::iterator striter = SplitData.begin();
182 striter != SplitData.end(); striter++){
188 // Look for the X-ABCROP-RECTANGLE.
190 wxStringTokenizer PhotoSplit(ContactData.PropData[0], wxT(":"));
191 wxString PhotoPropertyDataString = PhotoSplit.GetNextToken();
192 wxStringTokenizer PhotoPropertyData(PhotoPropertyDataString, wxT(";"));
193 wxString PropertyLineData;
194 wxString PropertyName;
195 wxString PropertyValue;
197 wxStringTokenizer DataSplit(ContactData.PropValues[0], wxT(";"));
198 PhotoSplitData = DataSplit.GetNextToken();
199 wxStringTokenizer MIMESplit(PhotoSplitData, wxT(":"));
200 MIMESplit.GetNextToken();
201 PhotoMIMEType = MIMESplit.GetNextToken();
202 PhotoSplitData = DataSplit.GetNextToken();
203 wxStringTokenizer EncSplit(PhotoSplitData, wxT(","));
204 PhotoEncType = EncSplit.GetNextToken();
205 PhotoEncData = EncSplit.GetNextToken();
207 // Convert the picture data from base64 to binary.
209 PhotoDataIn = std::string(PhotoEncData.mb_str());
210 PhotoDataBin = base64_decode(PhotoDataIn);
211 wxMemoryInputStream istream(PhotoDataBin.c_str(), (size_t)PhotoDataBin.size());
214 if (!photo.LoadFile(istream, wxBITMAP_TYPE_ANY)){
216 // Photo failed to load so do nothing.
222 while (PhotoPropertyData.HasMoreTokens()){
224 PropertyLineData = PhotoPropertyData.GetNextToken();
226 wxStringTokenizer PhotoPropPair(PropertyLineData, wxT("="));
227 wxString PhotoPropName = PhotoPropPair.GetNextToken();
228 wxString PhotoPropValue = PhotoPropPair.GetNextToken();
230 if (PhotoPropName == wxT("X-ABCROP-RECTANGLE")){
232 wxStringTokenizer PhotoRectData(PhotoPropValue, wxT("&"));
234 PhotoRectData.GetNextToken();
236 //PhotoRectPoints.SetX(wxAtoi(PhotoRectData.GetNextToken()));
237 //PhotoRectPoints.SetY(wxAtoi(PhotoRectData.GetNextToken()) - 100);
239 int PointXBase = wxAtoi(PhotoRectData.GetNextToken());
240 int PointYBase = wxAtoi(PhotoRectData.GetNextToken());
241 int PointWBase = wxAtoi(PhotoRectData.GetNextToken());
242 int PointHBase = wxAtoi(PhotoRectData.GetNextToken());
244 int PointX = PointXBase;
245 int PointY = PointYBase;
246 int PointW = PointWBase;
247 int PointH = PointHBase;
251 if (PointYBase > PointHBase){
253 PointX = photo.GetWidth() - PointXBase - 140;
254 PointY = photo.GetHeight() - PointYBase - 140;
258 } else if (PointXBase > PointWBase){
260 PointX = photo.GetWidth() - PointXBase;
261 PointY = PointYBase - 50;
269 /*int PointX = PointXBase;
270 int PointY = PointYBase;
271 int PointW = PointWBase;
272 int PointH = PointHBase;*/
274 // Bottom Left Method
276 /*int PointX = wxAtoi(PhotoRectData.GetNextToken());
277 int PointY = photo.GetHeight() - wxAtoi(PhotoRectData.GetNextToken()) - 340;
278 int PointW = wxAtoi(PhotoRectData.GetNextToken());
279 int PointH = wxAtoi(PhotoRectData.GetNextToken());*/
281 // Bottom Right Method
283 /*int PointXRemain = photo.GetWidth() - PointX - 140;
284 int PointYRemain = photo.GetHeight() - PointY - 140;*/
286 PhotoRectPoints.SetX(PointX);
287 PhotoRectPoints.SetY(PointY);
288 PhotoRectPoints.SetWidth(PointW);
289 PhotoRectPoints.SetHeight(PointH);
298 // Resize the picture to 125x125.
300 // Add to the wxMemnoryFSHandler.
302 SIDFilename = SID + wxT("-photo");
304 if (RectData == TRUE){
306 wxImage rectphoto = photo.GetSubImage(PhotoRectPoints);
307 rectphoto = rectphoto.Scale(75, 75, wxIMAGE_QUALITY_HIGH);
308 wxMemoryFSHandler::AddFile(SIDFilename, rectphoto, wxBITMAP_TYPE_PNG);
312 photo = photo.Scale(50, 50, wxIMAGE_QUALITY_HIGH);
313 wxMemoryFSHandler::AddFile(SIDFilename, photo, wxBITMAP_TYPE_PNG);
317 // Add the filename to the MemoryFSList map.
319 MemoryFSList->insert(std::make_pair(SIDFilename, SID));
325 if (LoadPicture == TRUE){
327 PageData.append(wxT("<img src=\"memory:") + SIDFilename + wxT("\">"));
335 ContactData = vCardObj->GetByPartial(wxT("LOGO"));
337 if (ContactData.PropCount > 0){
341 wxStringTokenizer DataSplit(ContactData.PropValues[0], wxT(";"));
342 PhotoSplitData = DataSplit.GetNextToken();
343 wxStringTokenizer MIMESplit(PhotoSplitData, wxT(":"));
344 MIMESplit.GetNextToken();
345 PhotoMIMEType = MIMESplit.GetNextToken();
346 PhotoSplitData = DataSplit.GetNextToken();
347 wxStringTokenizer EncSplit(PhotoSplitData, wxT(","));
348 PhotoEncType = EncSplit.GetNextToken();
349 PhotoEncData = EncSplit.GetNextToken();
351 // Convert the picture data from base64 to binary.
353 PhotoDataIn = std::string(PhotoEncData.mb_str());
354 PhotoDataBin = base64_decode(PhotoDataIn);
355 wxMemoryInputStream istream(PhotoDataBin.c_str(), (size_t)PhotoDataBin.size());
358 if (!photo.LoadFile(istream, wxBITMAP_TYPE_ANY)){
360 // Photo failed to load so do nothing.
368 photo = photo.Scale(50, 50, wxIMAGE_QUALITY_HIGH);
370 // Resize the picture to 125x125.
372 // Add to the wxMemnoryFSHandler.
374 SIDFilename = SID + wxT("-logo");
376 wxMemoryFSHandler::AddFile(SIDFilename, photo, wxBITMAP_TYPE_PNG);
378 // Add the filename to the MemoryFSList map.
380 MemoryFSList->insert(std::make_pair(SIDFilename, SID));
386 if (LoadPicture == TRUE){
388 PageData.append(wxT("<img src=\"memory:") + SIDFilename + wxT("\">"));
392 PageData.append(wxT("</td>"));
393 PageData.append(wxT("</tr>"));
394 PageData.append(wxT("</table>"));
396 // Process LOGO, PHOTO, SOUND, KEY, VND-* and X-*
397 // lines and display icons for each accordingly.
399 ContactData = vCardObj->GetByPartial(wxT("PHOTO"));
401 bool AddBreak = FALSE;
403 if (ContactData.PropCount > 1){
405 PageData.append(wxT("<img src=\"memory:cipto.png\" alt=\""));
406 PageData.append(_("This contact has multiple photos."));
407 PageData.append(wxT("\">"));
412 ContactData = vCardObj->GetByPartial(wxT("LOGO"));
414 if (ContactData.PropCount > 1){
416 PageData.append(wxT("<img src=\"memory:cilog.png\" alt=\""));
417 PageData.append(_("This contact has multiple logos."));
418 PageData.append(wxT("\">"));
423 ContactData = vCardObj->GetByPartial(wxT("SOUND"));
425 if (ContactData.PropCount >= 1){
427 PageData.append(wxT("<img src=\"memory:cisnd.png\" alt=\""));
428 PageData.append(_("This contact has audio information."));
429 PageData.append(wxT("\">"));
434 ContactData = vCardObj->GetByPartial(wxT("KEY"));
436 if (ContactData.PropCount >= 1){
438 PageData.append(wxT("<img src=\"memory:cikey.png\" alt=\""));
439 PageData.append(_("This contact has crytographic keys."));
440 PageData.append(wxT("\">"));
445 ContactData = vCardObj->GetByPartial(wxT("VND-"));
447 if (ContactData.PropCount >= 1){
449 PageData.append(wxT("<img src=\"memory:civen.png\" alt=\""));
450 PageData.append(_("This contact has vendor-specific information."));
451 PageData.append(wxT("\">"));
456 ContactData = vCardObj->GetByPartial(wxT("X-"));
458 if (ContactData.PropCount >= 1){
460 PageData.append(wxT("<img src=\"memory:ciext.png\" alt=\""));
461 PageData.append(_("This contact has extended information."));
462 PageData.append(wxT("\">"));
467 if (AddBreak == TRUE){
469 PageData.append(wxT("<br><br>"));
473 bool MultiLogoIcon = FALSE;
474 bool MultiPhotoIcon = FALSE;
475 bool SoundIcon = FALSE;
476 bool KeyIcon = FALSE;
477 bool VendorIcon = FALSE;
478 bool XTokenIcon = FALSE;
482 ContactData = vCardObj->GetByPartial(wxT("BDAY"));
487 if (ContactData.PropCount > 0){
491 for (int i = 0; i < ContactData.PropCount; i++){
493 // Grab the first birthday only.
495 BDayLine = ContactData.PropValues[i];
498 CaptureString(&BDayLine, FALSE);
499 ConvertToHTML(&BDayLine);
501 DataLines.append(BDayLine);
511 if (DataDisplay == TRUE){
514 PageData.append(wxT("<b>"));
515 PageData.append(_("Birthday:"));
516 PageData.append(wxT("</b> "));
517 PageData.append(DataLines);
518 PageData.append(wxT("<br>"));
522 // Process Anniversary
524 ContactData = vCardObj->GetByPartial(wxT("ANNIVERSARY"));
529 if (ContactData.PropCount > 0){
533 for (int i = 0; i < ContactData.PropCount; i++){
535 // Grab the first anniversary only.
537 AnniLine = ContactData.PropValues[i];
540 CaptureString(&AnniLine, FALSE);
541 ConvertToHTML(&AnniLine);
543 DataLines.append(AnniLine);
553 if (DataDisplay == TRUE){
556 PageData.append(wxT("<b>"));
557 PageData.append(_("Anniversary:"));
558 PageData.append(wxT("</b> "));
559 PageData.append(DataLines);
560 PageData.append(wxT("<br>"));
566 ContactData = vCardObj->GetByPartial(wxT("NICKNAME"));
571 if (ContactData.PropCount > 0){
573 wxString NicknameLine;
575 for (int i = 0; i < ContactData.PropCount; i++){
577 NicknameLine = ContactData.PropValues[i];
580 CaptureString(&NicknameLine, FALSE);
581 ConvertToHTML(&NicknameLine);
583 DataLines.append(wxT("<tr><td><b>"));
584 DataLines.append(_("Nickname:"));
585 DataLines.append(wxT(" </b></td><td>"));
586 DataLines.append(NicknameLine);
587 DataLines.append(wxT("</td></tr>"));
595 if (DataDisplay == TRUE){
598 PageData.append(wxT("<h4>"));
599 PageData.append(_("Nicknames"));
600 PageData.append(wxT("</h4>"));
601 PageData.append(wxT("<br>"));
602 PageData.append(wxT("<table>"));
603 PageData.append(DataLines);
604 PageData.append(wxT("</table>"));
610 ContactData = vCardObj->GetByPartial(wxT("ADR"));
615 if (ContactData.PropCount > 0){
617 wxString AddressLine;
619 for (int i = 0; i < ContactData.PropCount; i++){
621 AddressLine = ContactData.PropValues[i];
623 intPropertyLen = AddressLine.Len();
630 AddressPOBox.clear();
631 AddressStreet.clear();
632 AddressLocality.clear();
633 AddressRegion.clear();
634 AddressPostalCode.clear();
635 AddressCountry.clear();
636 AddressExtended.clear();
637 FinalAddressLine.clear();
640 for (int i = 0; i <= intPropertyLen; i++){
644 if (AddressLine.Mid(i, 1) == wxT(";") && AddressLine.Mid((i - 1), 1) != wxT("\\")){
647 SplitPoints.insert(std::make_pair(intSplitsFound, (i + 1)));
649 if (intSplitsFound == 6){
651 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
656 SplitLength.insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
666 // Split the data into several parts.
668 for (std::map<int, int>::iterator intiter = SplitPoints.begin();
669 intiter != SplitPoints.end(); ++intiter){
671 if (intiter->first == 1){
675 SLiter = SplitLength.find(1);
677 //txtSurname->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(0, SLiter->second), TRUE));
678 AddressPOBox = AddressLine.Mid(0, SLiter->second);
679 intPrevValue = intiter->second;
681 } else if (intiter->first == 2){
683 // Deal with extended address.
685 SLiter = SplitLength.find(2);
687 AddressExtended = AddressLine.Mid(intPrevValue, SLiter->second);
688 //txtForename->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
689 intPrevValue = intiter->second;
691 } else if (intiter->first == 3){
693 // Deal with street address.
695 SLiter = SplitLength.find(3);
697 AddressStreet = AddressLine.Mid(intPrevValue, SLiter->second);
698 //txtOtherNames->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
699 intPrevValue = intiter->second;
701 } else if (intiter->first == 4){
703 // Deal with locality
705 SLiter = SplitLength.find(4);
707 AddressLocality = AddressLine.Mid(intPrevValue, SLiter->second);
708 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
709 intPrevValue = intiter->second;
711 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, wxSTRING_MAXLEN), TRUE));
713 } else if (intiter->first == 5){
717 SLiter = SplitLength.find(5);
719 AddressRegion = AddressLine.Mid(intPrevValue, SLiter->second);
720 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
721 intPrevValue = intiter->second;
723 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, wxSTRING_MAXLEN), TRUE));
725 } else if (intiter->first == 6){
727 // Deal with post code.
729 SLiter = SplitLength.find(6);
731 AddressPostalCode = AddressLine.Mid(intPrevValue, SLiter->second);
732 //txtTitle->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, SLiter->second), TRUE));
733 intPrevValue = intiter->second;
735 // Deal with country.
737 AddressCountry = AddressLine.Mid(intPrevValue);
738 //txtSuffix->SetValue(ContactData.Convert(wxSPropertySeg2.Mid(intPrevValue, wxSTRING_MAXLEN), TRUE));
744 if (!AddressStreet.IsEmpty()){
746 AddressStreet.Trim();
747 ConvertToHTML(&AddressStreet);
749 FinalAddressLine.append(AddressStreet);
750 AddressFirst = FALSE;
754 if (!AddressLocality.IsEmpty()){
756 AddressLocality.Trim();
757 ConvertToHTML(&AddressLocality);
759 if (AddressFirst == FALSE){
761 FinalAddressLine.append(wxT(",<br>"));
762 FinalAddressLine.append(AddressLocality);
766 FinalAddressLine.append(AddressLocality);
767 AddressFirst = FALSE;
773 if (!AddressRegion.IsEmpty()){
775 AddressRegion.Trim();
776 ConvertToHTML(&AddressRegion);
778 if (AddressFirst == FALSE){
780 FinalAddressLine.append(wxT(",<br>"));
781 FinalAddressLine.append(AddressRegion);
785 FinalAddressLine.append(AddressRegion);
786 AddressFirst = FALSE;
792 if (!AddressPostalCode.IsEmpty()){
794 AddressPostalCode.Trim();
795 ConvertToHTML(&AddressPostalCode);
797 if (AddressFirst == FALSE){
799 FinalAddressLine.append(wxT(",<br>"));
800 FinalAddressLine.append(AddressPostalCode);
804 FinalAddressLine.append(AddressPostalCode);
805 AddressFirst = FALSE;
811 if (!AddressCountry.IsEmpty()){
813 AddressCountry.Trim();
814 ConvertToHTML(&AddressCountry);
816 if (AddressFirst == FALSE){
818 FinalAddressLine.append(wxT(",<br>"));
819 FinalAddressLine.append(AddressCountry);
823 FinalAddressLine.append(AddressCountry);
824 AddressFirst = FALSE;
830 CaptureString(&FinalAddressLine, FALSE);
832 DataLines.append(wxT("<tr><td><b>"));
833 DataLines.append(_("Address:"));
834 DataLines.append(wxT(" </b></td><td>"));
835 DataLines.append(FinalAddressLine);
836 DataLines.append(wxT("</td></tr>"));
844 if (DataDisplay == TRUE){
847 PageData.append(wxT("<h4>"));
848 PageData.append(_("Addresses"));
849 PageData.append(wxT("</h4>"));
850 PageData.append(wxT("<br>"));
851 PageData.append(wxT("<table>"));
852 PageData.append(DataLines);
853 PageData.append(wxT("</table>"));
859 ContactData = vCardObj->GetByPartial(wxT("EMAIL"));
864 if (ContactData.PropCount > 0){
868 for (int i = 0; i < ContactData.PropCount; i++){
870 EmailLine = ContactData.PropValues[i];
873 CaptureString(&EmailLine, FALSE);
874 ConvertToHTML(&EmailLine);
876 DataLines.append(wxT("<tr><td><b>"));
877 DataLines.append(_("E-mail Address:"));
878 DataLines.append(wxT(" </b></td><td>"));
879 DataLines.append(EmailLine);
880 DataLines.append(wxT("</td></tr>"));
888 if (DataDisplay == TRUE){
891 PageData.append(wxT("<h4>"));
892 PageData.append(_("Email Addresses"));
893 PageData.append(wxT("</h4>"));
894 PageData.append(wxT("<br>"));
895 PageData.append(wxT("<table>"));
896 PageData.append(DataLines);
897 PageData.append(wxT("</table>"));
903 ContactData = vCardObj->GetByPartial(wxT("TEL"));
908 if (ContactData.PropCount > 0){
912 for (int i = 0; i < ContactData.PropCount; i++){
914 TelLine = ContactData.PropValues[i];
916 wxStringTokenizer TelSplit(TelLine, wxT(":"));
918 TelLine = TelSplit.GetNextToken();
920 if (TelSplit.HasMoreTokens()){
922 TelLine = TelSplit.GetNextToken();
927 CaptureString(&TelLine, FALSE);
928 ConvertToHTML(&TelLine);
930 DataLines.append(wxT("<tr><td><b>"));
931 DataLines.append(_("Telephone:"));
932 DataLines.append(wxT(" </b></td><td>"));
933 DataLines.append(TelLine);
934 DataLines.append(wxT("</td></tr>"));
942 if (DataDisplay == TRUE){
945 PageData.append(wxT("<h4>"));
946 PageData.append(_("Telephones"));
947 PageData.append(wxT("</h4>"));
948 PageData.append(wxT("<br>"));
949 PageData.append(wxT("<table>"));
950 PageData.append(DataLines);
951 PageData.append(wxT("</table>"));
957 ContactData = vCardObj->GetByPartial(wxT("IMPP"));
962 if (ContactData.PropCount > 0){
965 wxString IMTypeFriendly;
968 for (int i = 0; i < ContactData.PropCount; i++){
970 IMLine = ContactData.PropValues[i];
972 wxStringTokenizer IMSplit(IMLine, wxT(":"));
974 IMType = IMSplit.GetNextToken();
975 IMLine = IMSplit.GetNextToken();
977 // Process skype, gg, icq, yahoo etc into
978 // something meaningful.
980 if (IMType == wxT("aim")){
984 IMTypeFriendly = _("AIM");
986 } else if (IMType == wxT("xmpp")){
990 IMTypeFriendly = _("XMPP");
992 } else if (IMType == wxT("icq")){
996 IMTypeFriendly = _("ICQ");
998 } else if (IMType == wxT("skype")){
1002 IMTypeFriendly = _("Skype");
1004 } else if (IMType == wxT("gg")){
1008 IMTypeFriendly = _("Gadu-Gadu");
1010 } else if (IMType == wxT("yahoo")){
1014 IMTypeFriendly = _("Yahoo");
1018 // Other. Use IM type that was split.
1020 IMTypeFriendly = IMType;
1025 CaptureString(&IMLine, FALSE);
1026 ConvertToHTML(&IMLine);
1028 DataLines.append(wxT("<tr><td><b>"));
1029 DataLines.append(_("IM Address"));
1030 DataLines.append(_(" ("));
1031 DataLines.append(IMTypeFriendly);
1032 DataLines.append(_("):"));
1033 DataLines.append(wxT(" </b></td><td>"));
1034 DataLines.append(IMLine);
1035 DataLines.append(wxT("</td></tr>"));
1037 IMTypeFriendly.clear();
1047 if (DataDisplay == TRUE){
1050 PageData.append(wxT("<h4>"));
1051 PageData.append(_("Instant Messaging Addresses"));
1052 PageData.append(wxT("</h4>"));
1053 PageData.append(wxT("<br>"));
1054 PageData.append(wxT("<table>"));
1055 PageData.append(DataLines);
1056 PageData.append(wxT("</table>"));
1062 ContactData = vCardObj->GetByPartial(wxT("URL"));
1064 DataDisplay = FALSE;
1067 if (ContactData.PropCount > 0){
1071 for (int i = 0; i < ContactData.PropCount; i++){
1073 URLLine = ContactData.PropValues[i];
1076 CaptureString(&URLLine, FALSE);
1077 ConvertToHTML(&URLLine);
1079 DataLines.append(wxT("<tr><td><b>"));
1080 DataLines.append(_("Website:"));
1081 DataLines.append(wxT(" </b></td><td>"));
1082 DataLines.append(URLLine);
1083 DataLines.append(wxT("</td></tr>"));
1091 if (DataDisplay == TRUE){
1094 PageData.append(wxT("<h4>"));
1095 PageData.append(_("Website Addresses"));
1096 PageData.append(wxT("</h4>"));
1097 PageData.append(wxT("<br>"));
1098 PageData.append(wxT("<table>"));
1099 PageData.append(DataLines);
1100 PageData.append(wxT("</table>"));
1106 ContactData = vCardObj->GetByPartial(wxT("LANG"));
1108 DataDisplay = FALSE;
1111 if (ContactData.PropCount > 0){
1113 wxString NicknameLine;
1115 for (int i = 0; i < ContactData.PropCount; i++){
1117 NicknameLine = ContactData.PropValues[i];
1119 NicknameLine.Trim();
1120 CaptureString(&NicknameLine, FALSE);
1121 ConvertToHTML(&NicknameLine);
1123 DataLines.append(wxT("<tr><td><b>"));
1124 DataLines.append(_("Language:"));
1125 DataLines.append(wxT(" </b></td><td>"));
1126 DataLines.append(NicknameLine);
1127 DataLines.append(wxT("</td></tr>"));
1135 if (DataDisplay == TRUE){
1138 PageData.append(wxT("<h4>"));
1139 PageData.append(_("Languages"));
1140 PageData.append(wxT("</h4>"));
1141 PageData.append(wxT("<br>"));
1142 PageData.append(wxT("<table>"));
1143 PageData.append(DataLines);
1144 PageData.append(wxT("</table>"));
1150 ContactData = vCardObj->GetByPartial(wxT("TZ"));
1152 DataDisplay = FALSE;
1155 if (ContactData.PropCount > 0){
1157 wxString NicknameLine;
1159 for (int i = 0; i < ContactData.PropCount; i++){
1161 NicknameLine = ContactData.PropValues[i];
1163 NicknameLine.Trim();
1164 CaptureString(&NicknameLine, FALSE);
1165 ConvertToHTML(&NicknameLine);
1167 DataLines.append(wxT("<tr><td><b>"));
1168 DataLines.append(_("Timezone:"));
1169 DataLines.append(wxT(" </b></td><td>"));
1170 DataLines.append(NicknameLine);
1171 DataLines.append(wxT("</td></tr>"));
1179 if (DataDisplay == TRUE){
1182 PageData.append(wxT("<h4>"));
1183 PageData.append(_("Timezones"));
1184 PageData.append(wxT("</h4>"));
1185 PageData.append(wxT("<br>"));
1186 PageData.append(wxT("<table>"));
1187 PageData.append(DataLines);
1188 PageData.append(wxT("</table>"));
1194 ContactData = vCardObj->GetByPartial(wxT("GEO"));
1196 DataDisplay = FALSE;
1199 if (ContactData.PropCount > 0){
1203 for (int i = 0; i < ContactData.PropCount; i++){
1205 GeoLine = ContactData.PropValues[i];
1207 wxStringTokenizer GeoSplit(GeoLine, wxT(":"));
1209 GeoLine = GeoSplit.GetNextToken();
1211 if (GeoSplit.HasMoreTokens()){
1213 GeoLine = GeoSplit.GetNextToken();
1218 CaptureString(&GeoLine, FALSE);
1219 ConvertToHTML(&GeoLine);
1221 DataLines.append(wxT("<tr><td><b>"));
1222 DataLines.append(_("Geoposition:"));
1223 DataLines.append(wxT(" </b></td><td>"));
1224 DataLines.append(GeoLine);
1225 DataLines.append(wxT("</td></tr>"));
1233 if (DataDisplay == TRUE){
1236 PageData.append(wxT("<h4>"));
1237 PageData.append(_("Geopositioning"));
1238 PageData.append(wxT("</h4>"));
1239 PageData.append(wxT("<br>"));
1240 PageData.append(wxT("<table>"));
1241 PageData.append(DataLines);
1242 PageData.append(wxT("</table>"));
1248 ContactData = vCardObj->GetByPartial(wxT("TITLE"));
1250 DataDisplay = FALSE;
1253 if (ContactData.PropCount > 0){
1257 for (int i = 0; i < ContactData.PropCount; i++){
1259 TitleLine = ContactData.PropValues[i];
1262 CaptureString(&TitleLine, FALSE);
1263 ConvertToHTML(&TitleLine);
1265 DataLines.append(wxT("<tr><td><b>"));
1266 DataLines.append(_("Title:"));
1267 DataLines.append(wxT(" </b></td><td>"));
1268 DataLines.append(TitleLine);
1269 DataLines.append(wxT("</td></tr>"));
1277 if (DataDisplay == TRUE){
1280 PageData.append(wxT("<h4>"));
1281 PageData.append(_("Titles"));
1282 PageData.append(wxT("</h4>"));
1283 PageData.append(wxT("<br>"));
1284 PageData.append(wxT("<table>"));
1285 PageData.append(DataLines);
1286 PageData.append(wxT("</table>"));
1292 ContactData = vCardObj->GetByPartial(wxT("ROLE"));
1294 DataDisplay = FALSE;
1297 if (ContactData.PropCount > 0){
1301 for (int i = 0; i < ContactData.PropCount; i++){
1303 RoleLine = ContactData.PropValues[i];
1306 CaptureString(&RoleLine, FALSE);
1307 ConvertToHTML(&RoleLine);
1309 DataLines.append(wxT("<tr><td><b>"));
1310 DataLines.append(_("Role:"));
1311 DataLines.append(wxT(" </b></td><td>"));
1312 DataLines.append(RoleLine);
1313 DataLines.append(wxT("</td></tr>"));
1321 if (DataDisplay == TRUE){
1324 PageData.append(wxT("<h4>"));
1325 PageData.append(_("Roles"));
1326 PageData.append(wxT("</h4>"));
1327 PageData.append(wxT("<br>"));
1328 PageData.append(wxT("<table>"));
1329 PageData.append(DataLines);
1330 PageData.append(wxT("</table>"));
1336 ContactData = vCardObj->GetByPartial(wxT("ORG"));
1338 DataDisplay = FALSE;
1341 if (ContactData.PropCount > 0){
1345 for (int i = 0; i < ContactData.PropCount; i++){
1347 OrgLine = ContactData.PropValues[i];
1350 CaptureString(&OrgLine, FALSE);
1351 ConvertToHTML(&OrgLine);
1353 DataLines.append(wxT("<tr><td><b>"));
1354 DataLines.append(_("Organisation:"));
1355 DataLines.append(wxT(" </b></td><td>"));
1356 DataLines.append(OrgLine);
1357 DataLines.append(wxT("</td></tr>"));
1365 if (DataDisplay == TRUE){
1368 PageData.append(wxT("<h4>"));
1369 PageData.append(_("Organisations"));
1370 PageData.append(wxT("</h4>"));
1371 PageData.append(wxT("<br>"));
1372 PageData.append(wxT("<table>"));
1373 PageData.append(DataLines);
1374 PageData.append(wxT("</table>"));
1380 ContactData = vCardObj->GetByPartial(wxT("CATEGORIES"));
1382 DataDisplay = FALSE;
1385 if (ContactData.PropCount > 0){
1389 for (int i = 0; i < ContactData.PropCount; i++){
1391 CatLine = ContactData.PropValues[i];
1394 CaptureString(&CatLine, FALSE);
1395 ConvertToHTML(&CatLine);
1397 DataLines.append(wxT("<tr><td><b>"));
1398 DataLines.append(_("Category:"));
1399 DataLines.append(wxT(" </b></td><td>"));
1400 DataLines.append(CatLine);
1401 DataLines.append(wxT("</td></tr>"));
1409 if (DataDisplay == TRUE){
1412 PageData.append(wxT("<h4>"));
1413 PageData.append(_("Categories"));
1414 PageData.append(wxT("</h4>"));
1415 PageData.append(wxT("<br>"));
1416 PageData.append(wxT("<table>"));
1417 PageData.append(DataLines);
1418 PageData.append(wxT("</table>"));
1426 // Calendar Addresses
1428 ContactData = vCardObj->GetByPartial(wxT("CALURI"));
1430 DataDisplay = FALSE;
1433 if (ContactData.PropCount > 0){
1435 wxString CalURILine;
1437 for (int i = 0; i < ContactData.PropCount; i++){
1439 CalURILine = ContactData.PropValues[i];
1442 CaptureString(&CalURILine, FALSE);
1443 ConvertToHTML(&CalURILine);
1445 DataLines.append(wxT("<tr><td><b>"));
1446 DataLines.append(_("Calendar Address:"));
1447 DataLines.append(wxT(" </b></td><td>"));
1448 DataLines.append(CalURILine);
1449 DataLines.append(wxT("</td></tr>"));
1457 if (DataDisplay == TRUE){
1460 PageData.append(wxT("<h4>"));
1461 PageData.append(_("Calendar Addresses"));
1462 PageData.append(wxT("</h4>"));
1463 PageData.append(wxT("<br>"));
1464 PageData.append(wxT("<table>"));
1465 PageData.append(DataLines);
1466 PageData.append(wxT("</table>"));
1470 // Calendar Request Addresses
1472 ContactData = vCardObj->GetByPartial(wxT("CALADRURI"));
1474 DataDisplay = FALSE;
1477 if (ContactData.PropCount > 0){
1479 wxString CalAdrURILine;
1481 for (int i = 0; i < ContactData.PropCount; i++){
1483 CalAdrURILine = ContactData.PropValues[i];
1485 CalAdrURILine.Trim();
1486 CaptureString(&CalAdrURILine, FALSE);
1487 ConvertToHTML(&CalAdrURILine);
1489 DataLines.append(wxT("<tr><td><b>"));
1490 DataLines.append(_("Calendar Request Address:"));
1491 DataLines.append(wxT(" </b></td><td>"));
1492 DataLines.append(CalAdrURILine);
1493 DataLines.append(wxT("</td></tr>"));
1501 if (DataDisplay == TRUE){
1504 PageData.append(wxT("<h4>"));
1505 PageData.append(_("Calendar Request Addresses"));
1506 PageData.append(wxT("</h4>"));
1507 PageData.append(wxT("<br>"));
1508 PageData.append(wxT("<table>"));
1509 PageData.append(DataLines);
1510 PageData.append(wxT("</table>"));
1514 // Free/Busy Addresses
1516 ContactData = vCardObj->GetByPartial(wxT("FBURL"));
1518 DataDisplay = FALSE;
1521 if (ContactData.PropCount > 0){
1525 for (int i = 0; i < ContactData.PropCount; i++){
1527 FBURLLine = ContactData.PropValues[i];
1530 CaptureString(&FBURLLine, FALSE);
1531 ConvertToHTML(&FBURLLine);
1533 DataLines.append(wxT("<tr><td><b>"));
1534 DataLines.append(_("Free/Busy Address:"));
1535 DataLines.append(wxT(" </b></td><td>"));
1536 DataLines.append(FBURLLine);
1537 DataLines.append(wxT("</td></tr>"));
1545 if (DataDisplay == TRUE){
1548 PageData.append(wxT("<h4>"));
1549 PageData.append(_("Free/Busy Addresses"));
1550 PageData.append(wxT("</h4>"));
1551 PageData.append(wxT("<br>"));
1552 PageData.append(wxT("<table>"));
1553 PageData.append(DataLines);
1554 PageData.append(wxT("</table>"));
1560 ContactData = vCardObj->GetByPartial(wxT("NOTE"));
1562 DataDisplay = FALSE;
1565 if (ContactData.PropCount > 0){
1569 for (int i = 0; i < ContactData.PropCount; i++){
1571 NoteLine = ContactData.PropValues[i];
1574 CaptureString(&NoteLine, FALSE);
1575 ConvertToHTML(&NoteLine);
1577 DataLines.append(wxT("<tr><td><b>"));
1578 DataLines.append(_("Note:"));
1579 DataLines.append(wxT(" </b></td><td>"));
1580 DataLines.append(NoteLine);
1581 DataLines.append(wxT("</td></tr>"));
1589 if (DataDisplay == TRUE){
1591 PageData.append(wxT("<h4>"));
1592 PageData.append(_("Notes"));
1593 PageData.append(wxT("</h4>"));
1594 PageData.append(wxT("<br>"));
1595 PageData.append(wxT("<table>"));
1596 PageData.append(DataLines);
1597 PageData.append(wxT("</table>"));
1601 // Display the HTML document on the screen.
1603 PageData.append(wxT("</body>"));
1604 PageData.append(wxT("</html>"));
1606 HTMLObj->SetPage(PageData);
1610 void SplitPropertyData(wxString *PropertyLine,
1611 std::map<int,int> *SplitPoints,
1612 std::map<int,int> *SplitLength,
1614 std::map<wxString,wxString> *SplitData){
1617 wxStringTokenizer PropertyElement;
1618 wxString PropertyName;
1619 wxString PropertyValue;
1620 int intPropertyLen = PropertyLine->Len();
1621 int intSplitsFound = 0;
1622 int intSplitSize = 0;
1623 int intSplitSeek = (intSize - 1);
1625 for (int i = intSize; i <= intPropertyLen; i++){
1629 if (PropertyLine->Mid(i, 1) == wxT(";") &&
1630 PropertyLine->Mid((i - 1), 1) != wxT("\\")){
1632 if (intSplitsFound == 0){
1634 DataStr = PropertyLine->Mid(intSplitSeek, (intSplitSize));
1635 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize)));
1639 DataStr = PropertyLine->Mid(intSplitSeek, (intSplitSize - 1));
1640 SplitLength->insert(std::make_pair(intSplitsFound, (intSplitSize - 1)));
1644 SplitPoints->insert(std::make_pair(intSplitsFound, (i + 1)));
1647 intSplitSeek = (i + 1);
1650 if (!DataStr.IsEmpty()){
1652 PropertyElement.SetString(DataStr, wxT("="));
1653 PropertyName = PropertyElement.GetNextToken();
1654 PropertyValue = PropertyElement.GetNextToken();
1655 SplitData->insert(std::make_pair(PropertyName, PropertyValue));
1660 PropertyName.clear();
1661 PropertyValue.clear();
1667 if (intSplitsFound == 0){
1669 DataStr = PropertyLine->Mid(intSplitSeek, (intSplitSize));
1671 SplitPoints->insert(std::make_pair(intSplitsFound, (8 + 1)));
1672 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
1676 DataStr = PropertyLine->Mid(intSplitSeek, (intSplitSize - 1));
1678 SplitPoints->insert(std::make_pair(intSplitsFound, (intSplitSeek + 1)));
1679 SplitLength->insert(std::make_pair(intSplitsFound, intSplitSize));
1683 if (!DataStr.IsEmpty()){
1685 PropertyElement.SetString(DataStr, wxT("="));
1686 PropertyName = PropertyElement.GetNextToken();
1687 PropertyValue = PropertyElement.GetNextToken();
1688 SplitData->insert(std::make_pair(PropertyName, PropertyValue));