Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Initial import of code already done for Xestia Address Book
[xestiaab/.git] / source / frmMain.cpp
1 #include <iostream>
2 #include <algorithm>
3 #include <vector>
4 #include <thread>
6 #include <wx/wx.h>
7 #include <wx/tokenzr.h>
8 #include <wx/icon.h>
9 #include <wx/mstream.h>
10 #include <wx/fs_mem.h>
11 #include <wx/ffile.h>
12 #include <wx/filesys.h>
13 #include <wx/dir.h>
14 #include <wx/stdpaths.h>
15 #include <wx/fileconf.h>
16 //#include <boost/filesystem/fstream.hpp>
18 // Include the forms.
20 #include "frmMain.h"
21 #include "frmAbout.h"
22 #include "frmPreferences.h"
23 #include "frmNewAccount.h"
24 #include "frmActivityMgr.h"
25 #include "frmContact.h"
26 #include "frmConflictResolution.h"
27 #include "frmInvalidSSLCertificate.h"
28 #include "frmSearch.h"
29 #include "frmSSLCertificate.h"
30 #include "frmUpdate.h"
31 #include "bitmaps.h"
33 #include "common/preferences.h"
34 #include "common/getcontactinfo.h"
35 #include "common/events.h"
36 #include "common/dirs.h"
37 #include "vcard/vcard.h"
38 #include "carddav/carddav.h"
39 #include "contacteditor/frmContactEditor.h"
40 #include "import/import.h"
41 #include "export/export.h"
42 #include "widgets/XABAccountView2.h"
44 #include "version.h"
46 //extern const wxEventType MyHaremEvent = wxNewEventType();
48 //#define CE_UPDATECONTACTLIST 7700
49 //#define CE_UPDATEACCOUNTLIST 7701
51 DEFINE_EVENT_TYPE(CE_UPDATECONTACTLIST);
52 DEFINE_EVENT_TYPE(CE_UPDATEACCOUNTLIST);
53 DEFINE_EVENT_TYPE(SE_UPDATECONTACTNOTIF);
54 DEFINE_EVENT_TYPE(CE_OPENCONTACT);
55 DEFINE_EVENT_TYPE(CE_EDITCONTACT);
56 DEFINE_EVENT_TYPE(CE_REVEALCONTACT);
57 DEFINE_EVENT_TYPE(CE_REMOVECONTACT);
58 DEFINE_EVENT_TYPE(CE_REMOVESEARCH);
59 DEFINE_EVENT_TYPE(SYNC_EMPTYSERVER);
60 DEFINE_EVENT_TYPE(ACTMGR_START);
61 DEFINE_EVENT_TYPE(ACTMGR_SHUFFLE);
62 DEFINE_EVENT_TYPE(ACTMGR_STOP);
63 DEFINE_EVENT_TYPE(WINDOW_ADD);
64 DEFINE_EVENT_TYPE(WINDOW_EDIT);
65 //DEFINE_EVENT_TYPE(WINDOW_DELETE);
66 DEFINE_EVENT_TYPE(WINDOW_CLOSE);
67 DEFINE_EVENT_TYPE(CONNSTAT_UPDATE);
68 DEFINE_EVENT_TYPE(INVALIDSSLCERT);
69 DEFINE_EVENT_TYPE(GETSELECTEDLIST);
70 DEFINE_EVENT_TYPE(SYNCACCOUNT);
72 BEGIN_EVENT_TABLE(frmMain, wxFrame)
73   EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, frmMain::ConflictResolution)
74   EVT_COMMAND(wxID_ANY, CE_UPDATECONTACTLIST, frmMain::UpdateContactList)
75   EVT_COMMAND(wxID_ANY, CE_UPDATEACCOUNTLIST, frmMain::UpdateAccountList)
76   EVT_COMMAND(wxID_ANY, SE_UPDATECONTACTNOTIF, frmMain::UpdateSearchContactLists)
77   EVT_COMMAND(wxID_ANY, CE_OPENCONTACT, frmMain::OpenContactInfo)
78   EVT_COMMAND(wxID_ANY, CE_EDITCONTACT, frmMain::ShowContactEditorEdit)
79   EVT_COMMAND(wxID_ANY, CE_REVEALCONTACT, frmMain::RevealContact)
80   EVT_COMMAND(wxID_ANY, CE_REMOVESEARCH, frmMain::RemoveContactsWindowPointer)
81   EVT_COMMAND(wxID_ANY, SYNC_EMPTYSERVER, frmMain::EmptyServerDialog)
82   EVT_COMMAND(wxID_ANY, ACTMGR_START, frmMain::ActivityIconStart)
83   EVT_COMMAND(wxID_ANY, ACTMGR_SHUFFLE, frmMain::ActivityIconShuffle)
84   EVT_COMMAND(wxID_ANY, ACTMGR_STOP, frmMain::ActivityIconStop)
85   EVT_COMMAND(wxID_ANY, WINDOW_ADD, frmMain::WindowAdd)
86   EVT_COMMAND(wxID_ANY, WINDOW_EDIT, frmMain::WindowEdit)
87   EVT_COMMAND(wxID_ANY, WINDOW_CLOSE, frmMain::WindowDelete)
88   EVT_COMMAND(wxID_ANY, CONNSTAT_UPDATE, frmMain::UpdateConnectionStatus)
89   EVT_COMMAND(wxID_ANY, INVALIDSSLCERT, frmMain::InvalidSSLCertificate)
90   EVT_COMMAND(wxID_ANY, GETSELECTEDLIST, frmMain::GetSelectedList)
91   EVT_COMMAND(wxID_ANY, SYNCACCOUNT, frmMain::SyncAccount)
92 END_EVENT_TABLE()
94 frmMain::frmMain( wxWindow* parent )
95 :
96 frmMainADT( parent )
97 {
99         // Setup the account icons.
101         wxMemoryInputStream astream(icons_accinet_png, sizeof(icons_accinet_png));
102         wxMemoryInputStream bstream(icons_acclocal_png, sizeof(icons_acclocal_png));
103         wxMemoryInputStream cstream(icons_accgroup_png, sizeof(icons_accgroup_png));
104         wxMemoryInputStream dstream(icons_accnone_png, sizeof(icons_accnone_png));
106         wxImage icons_accinet_png(astream, wxBITMAP_TYPE_PNG);
107         wxBitmap AccInet(icons_accinet_png, -1);
108         wxIcon wxIAccInet;
109         wxIAccInet.CopyFromBitmap(AccInet);
111         wxImage icons_acclocal_png(bstream, wxBITMAP_TYPE_PNG);
112         wxBitmap AccNIcon(icons_acclocal_png, -1);
113         wxIcon wxIAccNIcon;
114         wxIAccNIcon.CopyFromBitmap(AccNIcon);
116         wxImage icons_accgroup_png(cstream, wxBITMAP_TYPE_PNG);
117         wxBitmap AccGrp(icons_accgroup_png, -1);
118         wxIcon wxIAccGrp;
119         wxIAccGrp.CopyFromBitmap(AccGrp);
120         
121         wxImage icons_accnone_png(dstream, wxBITMAP_TYPE_PNG);
122         wxBitmap AccNone(icons_accnone_png, -1);
123         wxIcon wxIAccNone;
124         wxIAccNone.CopyFromBitmap(AccNone);
126         AccountID = AccImgList->Add(wxIAccNIcon);
127         AccountNetID = AccImgList->Add(wxIAccInet);
128         AccountGrpID = AccImgList->Add(wxIAccGrp);
129         AccountNoneID = AccImgList->Add(wxIAccNone);
131         bmpIcon->SetIcon(AccImgList->GetIcon(AccountNoneID));
133         // Setup the status bar icons.
134         
135         // SSL icons.
136         
137         wxMemoryInputStream sslstream(icons_ssl_png, sizeof(icons_ssl_png));
138         wxMemoryInputStream sslwarningstream(icons_sslwarning_png, sizeof(icons_sslwarning_png));
139         wxMemoryInputStream nosslstream(icons_nossl_png, sizeof(icons_nossl_png));
141         wxImage icons_ssl_png(sslstream, wxBITMAP_TYPE_PNG);
142         imgSSL = new wxBitmap(icons_ssl_png, -1);
144         wxImage icons_sslwarning_png(sslwarningstream, wxBITMAP_TYPE_PNG);
145         imgSSLWarning = new wxBitmap(icons_sslwarning_png, -1);
147         wxImage icons_nossl_png(nosslstream, wxBITMAP_TYPE_PNG);
148         imgNoSSL = new wxBitmap(icons_nossl_png, -1);
150         // Activity Icon.
152         wxMemoryInputStream act1(icons_act1_png, sizeof(icons_act1_png));
153         wxMemoryInputStream act2(icons_act2_png, sizeof(icons_act2_png));
154         wxMemoryInputStream act3(icons_act3_png, sizeof(icons_act3_png));
155         wxMemoryInputStream act4(icons_act4_png, sizeof(icons_act4_png));
156         wxMemoryInputStream actsleep(icons_actsleep_png, sizeof(icons_actsleep_png));
158         wxImage icons_actsleep_png(actsleep, wxBITMAP_TYPE_PNG);
159         imgActIconSleep = new wxBitmap (icons_actsleep_png, -1);
161         wxImage icons_act1_png(act1, wxBITMAP_TYPE_PNG);
162         imgActIcon1 = new wxBitmap (icons_act1_png, -1);
163         wxIcon wxIAct1icon;
164         wxIAct1icon.CopyFromBitmap(*imgActIcon1);
165         
166         wxImage icons_act2_png(act2, wxBITMAP_TYPE_PNG);
167         imgActIcon2 = new wxBitmap (icons_act2_png, -1);
168         wxIcon wxIAct2icon;
169         wxIAct2icon.CopyFromBitmap(*imgActIcon2);
170         
171         wxImage icons_act3_png(act3, wxBITMAP_TYPE_PNG);
172         imgActIcon3 = new wxBitmap (icons_act3_png, -1);
173         wxIcon wxIAct3icon;
174         wxIAct3icon.CopyFromBitmap(*imgActIcon3);
175                 
176         wxImage icons_act4_png(act4, wxBITMAP_TYPE_PNG);
177         imgActIcon4 = new wxBitmap (icons_act4_png, -1);
178         wxIcon wxIAct4icon;
179         wxIAct4icon.CopyFromBitmap(*imgActIcon4);
181         // Online/Offline icons.
183         wxMemoryInputStream onlinestream(icons_online_png, sizeof(icons_online_png));
184         wxMemoryInputStream offlinestream(icons_offline_png, sizeof(icons_offline_png));
186         wxImage icons_online_png(onlinestream, wxBITMAP_TYPE_PNG);
187         imgOnline = new wxBitmap(icons_online_png, -1);
189         wxImage icons_offline_png(offlinestream, wxBITMAP_TYPE_PNG);
190         imgOffline = new wxBitmap(icons_offline_png, -1);
192         // Setup the account view.
193         
194         AccCtrl->SetPopupControl(treAccounts);
195         AccCtrl->SetPopupMaxHeight(175);
196         AccCtrl->SetPopupMinWidth(250);
197         treAccounts->AssignImageList(AccImgList);
198         //bmpIcon->Hide();
199         wxRect AccTextCtrlSize = AccCtrl->GetTextRect();
201         /*wxStaticBitmap* BeepBoop = new wxStaticBitmap(AccCtrl, wxID_ANY, wxNullBitmap, wxPoint(AccTextCtrlSize.GetX() + 3, AccTextCtrlSize.GetY() + 2), wxDefaultSize, 0);
203         icons_accgroup_png.SetMask(new wxMask(icons_accgroup_png, wxSystemSettings::GetColour(wxSYS_COLOUR_BACKGROUND)));
205         BeepBoop->SetBackgroundColour(AccCtrl->GetBackgroundColour());
206         BeepBoop->SetBitmap(icons_accgroup_png);*/
208         //szrContactList->Insert(0, XABV2, 1, wxEXPAND | wxALL, 0);
210         /*AccControl->UseAltPopupWindow();
211         AccControl->SetPopupControl(treAccounts);
212         AccControl->SetPopupMaxHeight(175);
214         treAccounts->AssignImageList(AccImgList);
215         szrContactList->Insert(0, AccControl, 1, wxEXPAND|wxALL, 0);
216         szrAccList->Add(AccIcon, 0, wxLEFT|wxTOP|wxEXPAND, 3);
218         */
220         //szrContactList->Layout();
221         //szrContactList->RecalcSizes();
223         wxListItem ColumnData;
224         ColumnData.SetId(0);
225         ColumnData.SetText(wxT("Name0"));
226         ColumnData.SetWidth(320);
227         lstContacts->InsertColumn(0, ColumnData);
228         
229         //Connect(wxID_ANY, ContactConflictCmdEnv,
230         //      ContactConflictEventHandler(frmMain::ConflictResolution), NULL, this);
232         //Connect(wxID_ANY, MyFooCommandEvent,
233         //      MyFooEventHandler(frmMain::DoSomething), NULL, this);
235         //Bind(ContactConflictCmdEnv, ContactConflictEventHandler(frmMain::ConflictResolution), this, wxID_ANY);
237         treAccounts->Connect(wxEVT_LEFT_DCLICK, wxTreeEventHandler(frmMain::LoadContactList), NULL, this);
238         treAccounts->Connect(wxEVT_TREE_SEL_CHANGED, wxTreeEventHandler(frmMain::LoadContactList), NULL, this);
240 #if defined(__HAIKU__)
242 #elif defined(__WIN32__)
244         int stbBottomData [4] = { -1, 8, 8, 8 };
246 #else
248         int stbBottomData [4] = { -1, 20, 20, 20 };
249         
250 #endif
252         stbBottom->SetFieldsCount(4, stbBottomData);
253         stbBottom->SetMinHeight(16);
254         
255         wxRect rectOnline;
256         wxRect rectSSL;
257         wxRect rectActivity;
258         stbBottom->GetFieldRect(1, rectOnline);
259         stbBottom->GetFieldRect(2, rectSSL);
260         stbBottom->GetFieldRect(3, rectActivity);
262         SSLToolTip = new wxToolTip(wxT(""));
263         
264         imgConnStatus = new wxStaticBitmap(stbBottom, wxID_ANY, wxNullBitmap, wxPoint((rectOnline.GetX()),(rectOnline.GetY())), wxDefaultSize, 0 );
265         imgConnStatus->SetBitmap(*imgOnline);
266         imgConnStatus->Connect( wxEVT_LEFT_DCLICK, wxCommandEventHandler( frmMain::ToggleConnectionStatus ), NULL, this );
267         
268         imgSSLStatus = new wxStaticBitmap(stbBottom, wxID_ANY, wxNullBitmap, wxPoint((rectSSL.GetX()),(rectSSL.GetY())), wxDefaultSize, 0 );
269         imgSSLStatus->SetBitmap(*imgNoSSL);
270         imgSSLStatus->SetToolTip(SSLToolTip);
271         imgSSLStatus->Connect( wxEVT_LEFT_DCLICK, wxCommandEventHandler( frmMain::ShowSSLCertificates ), NULL, this );
273         imgActivityStatus = new wxStaticBitmap(stbBottom, wxID_ANY, wxNullBitmap, wxPoint((rectActivity.GetX()),(rectActivity.GetY())), wxDefaultSize, 0);
274         imgActivityStatus->SetBitmap(*imgActIconSleep);
275         imgActivityStatus->Connect( wxEVT_LEFT_DCLICK, wxCommandEventHandler( frmMain::ShowActivityWindow ), NULL, this );
277         // Setup the window menu.
278         
279         // By default should be:
280         
281         // Contact windows:
282         // (none)
283         // (horizontal line)
284         // Contact editor windows:
285         // (none)
286         // (horizontal line)
287         // Search windows:
288         // (none)
289         
290         mnuContactWindows = new wxMenuItem( mnuManage, wxID_ANY, wxString( _("Contact windows:") ), wxEmptyString, wxITEM_NORMAL );
291         mnuWindow->Append( mnuContactWindows );
293         mnuWindow->AppendSeparator();
295         mnuContactEditorWindows = new wxMenuItem( mnuManage, wxID_ANY, wxString( _("Contact editor windows:") ), wxEmptyString, wxITEM_NORMAL );
296         mnuWindow->Append( mnuContactEditorWindows );
298         mnuWindow->AppendSeparator();
300         mnuSearchWindows = new wxMenuItem( mnuManage, wxID_ANY, wxString( wxT("Search windows:") ), wxEmptyString, wxITEM_NORMAL );
301         mnuWindow->Append( mnuSearchWindows );
302         
303 #if defined(__WIN32__)
304         
305         wxFont fontstyle;
306         fontstyle.Bold();
308         mnuContactWindows->SetFont(fontstyle);
309         mnuContactEditorWindows->SetFont(fontstyle);
310         mnuSearchWindows->SetFont(fontstyle);
312 #else
314         mnuContactWindows->Enable(FALSE);
315         mnuContactEditorWindows->Enable(FALSE);
316         mnuSearchWindows->Enable(FALSE);
318 #endif
320         // Hide unimplemented functions.
321         
322         mnuMain->Remove(3);
323         
326 void frmMain::QuitApp( wxCommandEvent& event )
328 //-------------------------------------------------------------------
329 // frmMain::QuitApp: Quits the application by simply closing this
330 // window which causes the exit as frmMain is the main window.
331 //
332 // wxCommandEvent       Accepts a referenced event command.
333 //-------------------------------------------------------------------
335         //Go through the windows and close each one (be it search
336         //or contact editor). Abort if user wants to cancel.
338         // Close the contact editor windows.
339         
340         // Close the contact windows.
341         
342         // Close the search windows.
344         // Write out the ETag databases.
346         // Save Preferences: Save the window position if that option is enabled.
347     
348         wxString SetFilename = GetUserPrefDir();
350 #if defined(__HAIKU__)
351     
354 #elif defined(__WIN32__)
356         SetFilename.Append(wxT("settings"));
358 #else
359     
360         // *nix OSes
362         SetFilename.Append(wxT("settings"));
364 #endif
366         wxFileConfig *cfgfile = new wxFileConfig("", "", SetFilename);
367         
368         bool SaveWindowPos = FALSE;
369         wxString SaveWindowInc;
370         cfgfile->Read(wxT("SaveWindowPosition"), &SaveWindowInc);
371         
372         if (SaveWindowInc == wxT("true")){
373         
374                 SaveWindowPos = TRUE;
375         
376         }
377         
378         if (SaveWindowPos == TRUE){
379         
380                 wxRect frmMainPos = this->GetRect();
381         
382                 cfgfile->Write(wxT("WindowPositionX"), frmMainPos.GetX());
383                 cfgfile->Write(wxT("WindowPositionY"), frmMainPos.GetY());
384                 cfgfile->Write(wxT("WindowPositionHeight"), frmMainPos.GetHeight());
385                 cfgfile->Write(wxT("WindowPositionWidth"), frmMainPos.GetWidth());
387         
388         }
389         
390         delete cfgfile;
391         cfgfile = NULL;
392         
393         //Everything closed... exit.
394     
395         std::exit(0);
396     
399 void frmMain::QuitApp()
401 //-------------------------------------------------------------------
402 // frmMain::QuitApp: Quits the application by simply closing this
403 // window which causes the exit as frmMain is the main window.
404 //
405 // wxCommandEvent       Accepts a referenced event command.
406 //-------------------------------------------------------------------
408     Close(this);
411 void frmMain::ShowActivityWindow( wxCommandEvent& event )
414     frmActivityMgr *frameActMgr = static_cast<frmActivityMgr*>(ActMgrPtr);
415     frameActMgr->OpenWindow();
416     frameActMgr->Show();
420 void frmMain::ShowAboutWindow( wxCommandEvent& event )
422 //-------------------------------------------------------------------
423 // frmMain::ShowAboutWindow: Shows the About window as a modal
424 // dialog and then cleans up when finished.
425 //
426 // wxCommandEvent       Accepts a referenced event command.
427 //-------------------------------------------------------------------
428   
429     frmAbout *frameAbout = new frmAbout ( this );
430     frameAbout->SetupAboutWindow();
431     frameAbout->ShowModal();
432     delete frameAbout;
433     frameAbout = NULL;
434     
437 void frmMain::OpenPreferences( wxCommandEvent& event)
439 //-------------------------------------------------------------------
440 // frmMain::ShowAboutWindow: Opens the Preferences window as a modal
441 // dialog and then cleans up when finished.
442 //
443 // wxCommandEvent       Accepts a referenced event command.
444 //-------------------------------------------------------------------
446     ReloadAccounts = FALSE;
448     frmPreferences *framePreferences = new frmPreferences ( this );
449     framePreferences->SetupPointers(&ReloadAccounts);
450     framePreferences->ShowModal();
451     delete framePreferences;
452     framePreferences = NULL;
453     
454     if (ReloadAccounts == TRUE){
455     
456         // Reload the accounts as a change has been made within
457         // the application.
458         
459         this->LoadPreferences();
460     
461     }
462     
465 void frmMain::OpenNewABDialog( wxCommandEvent& event)
467 //-------------------------------------------------------------------
468 // frmMain::ShowAboutWindow: Opens the Preferences window as a modal
469 // dialog and then cleans up when finished.
470 //
471 // wxCommandEvent       Accepts a referenced event command.
472 //-------------------------------------------------------------------
474     ReloadAccounts = FALSE;
476     frmNewAccount *frameNewAccount = new frmNewAccount ( this );
477     frameNewAccount->SetupPointers(&ReloadAccounts);
478     frameNewAccount->ShowModal();
479     delete frameNewAccount;
480     frameNewAccount = NULL;
481     
482     if (ReloadAccounts == TRUE){
483     
484         // Reload the accounts as a change has been made within
485         // the application.
486         
487                 this->LoadPreferences();
488     
489     }
490     
493 void frmMain::LoadContactList( wxTreeEvent& event )
496     // Clear all existing variables.
498     lstContacts->DeleteAllItems();
500         treAccounts->SetAccount();
502     wxTreeItemIdValue cookie;
503     wxTreeItemId next = treAccounts->GetRootItem();
504     wxString AccountName;
505     wxString AccountDir, AccountType, AccountDirFinal, AccountTypeFinal;
506     wxString AccountDirCmb;
507     long selectedaccount = 0;
509     wxTreeItemId selectedChild = treAccounts->GetSelection();
510     wxTreeItemId nextChild;
511     
512     wxTreeItemId ActiveItemId = treAccounts->GetFocusedItem();
513     int ActiveItemIcon = treAccounts->GetItemImage(ActiveItemId, wxTreeItemIcon_Normal);
514     
515     int SCImg = treAccounts->GetItemImage(selectedChild);
516     int AccountIndex = 0;
518     bmpIcon->SetIcon(AccImgList->GetIcon(SCImg));
520         for (int i = 0; i < prefaccounts.GetCount(); i++){
522                 if (ActiveItemIcon == 2){
524                         std::multimap<wxTreeItemId, int>::iterator AGTiter = AccountGroupTreeId.find(ActiveItemId);
525                         std::multimap<int, wxString>::iterator AGFiter = AccountGroupFilename.find(AGTiter->second);
526                         std::multimap<int, int>::iterator AGLiter = AccountGroupList.find(AGTiter->second);
527                         int ActiveAccountG = AGLiter->second;
529                         if (i == ActiveAccountG){
531                                 AccountDir.Append(prefaccounts.GetAccountDirectory(i));
532                                 AccountType.Append(prefaccounts.GetAccountType(i));
534                                 AccountDir.Trim();
535                                 AccountType.Trim();
537                                 if (AccountType == wxT("CardDAV")){
538                                         AccountTypeFinal.Append(wxT("carddav"));
539                                 }
540                                 else if (AccountType == wxT("Local")){
541                                         imgSSLStatus->SetBitmap(*imgOffline);
542                                         SSLToolTip->SetTip(wxT("SSL status is not applicable for this account"));
543                                         AccountTypeFinal.Append(wxT("local"));
544                                 }
546                                 AccountIndex = i;
547                                 break;
549                         }
551                 }
553                 if (!nextChild){
554                         nextChild = treAccounts->GetFirstChild(next, cookie);
555                 }
556                 else {
557                         nextChild = treAccounts->GetNextSibling(nextChild);
558                 }
560                 AccountName = treAccounts->GetItemText(nextChild);
562                 if (nextChild == selectedChild){
563                         AccountDir.Append(prefaccounts.GetAccountDirectory(i));
564                         AccountType.Append(prefaccounts.GetAccountType(i));
566                         AccountDir.Trim();
567                         AccountType.Trim();
569                         if (AccountType == wxT("CardDAV")){
570                                 AccountTypeFinal.Append(wxT("carddav"));
571                         }
572                         else if (AccountType == wxT("Local")){
573                                 SSLToolTip->SetTip(wxT("SSL status is not applicable for this account"));
574                                 AccountTypeFinal.Append(wxT("local"));
575                         }
577                         AccountIndex = i;
579                 }
581         }
582         
583         if (selectedaccount >= prefaccounts.GetCount()){
585                 // The account selected isn't there so return.
587                 RevealWait = FALSE;
589                 return;
591         }
592     
593     // Open the directory and get the list of .vcf files
594     // in that directory.
596     ActiveAccount = AccountDir + wxT(".") + AccountTypeFinal;
597         ActiveAccountType = AccountType;
599     SetupSSLStatus(AccountIndex);
601         AccountDirFinal.Clear();
602         AccountDirFinal = GetAccountDir(AccountDir + wxT(".") + AccountTypeFinal, FALSE);
603     
604     ContactsFileIndex.Clear();
605     
606     //wxString vcardfilenamewxs;
607     wxString vCardFilename;
608     wxString vCardFilenameFull;
609     wxString vCardDataString;
610     wxStringTokenizer vcardfileline;
611     wxString lwxs;
612     wxString setname, setvalue;
613     //vCardNames = new std::map<wxString, wxString, std::greater<wxString>>;
614     std::multimap<wxString, wxString, std::greater<wxString>> vCardNamesAsc;
615     std::multimap<wxString, wxString, std::less<wxString>> vCardNamesDsc;
616     long ContactIndex = 1;
617     long ContactSeekPoint = 0;
618     
619     wxDir vcardaccdir(AccountDirFinal);
620     
621     // Get the wxTreeItemId and image icon and compare it to the list. 
623     if (ActiveItemIcon == AccountGrpID){
625             // It's a group so load the file containing the group and 
626             // get the members of the group.
627             
628             vCard Group;
629             wxString UIDCode;
630             
631             std::multimap<wxTreeItemId, int>::iterator AGTiter = AccountGroupTreeId.find(ActiveItemId);
632             std::multimap<int, wxString>::iterator AGFiter = AccountGroupFilename.find(AGTiter->second);
633             //std::multimap<wxTreeItemId, int>::iterator AGFiter = AccountGroupTreeId.find(ActiveItemId);
634             
635             Group.LoadFile(AGFiter->second);
636             
637             ArrayvCardOutData vCardMember = Group.GetByPartial(wxT("MEMBER"));
638             
639             for (int i = 0; i < vCardMember.PropCount; i++){
640                 
641                 vCardMember.PropValues[i].Trim();
642                 if (vCardMember.PropValues[i].Left(9) == wxT("urn:uuid:")){
643                 
644                     wxString NewPropValue;
645                     NewPropValue = vCardMember.PropValues[i].Mid(9, wxString::npos);
646                     vCardMember.PropValues[i] = NewPropValue;
647                 
648                 }
649                 
650                 
651             }
652             
653             bool ProcFiles = vcardaccdir.GetFirst(&vCardFilename, wxEmptyString, wxDIR_FILES);
654             while(ProcFiles){
655     
656                 if (vCardFilename.Right(4) == wxT(".vcf") || 
657                     vCardFilename.Right(4) == wxT(".VCF") || 
658                     vCardFilename.Right(5) == wxT(".vcard") || 
659                     vCardFilename.Right(5) == wxT(".VCARD")){
660         
661                         vCard Person;
662                         bool FoundMember = FALSE;
663                 
664                         vCardFilenameFull.Append(AccountDirFinal);
665                         vCardFilenameFull.Append(wxT("/"));
666                         vCardFilenameFull.Append(vCardFilename);
667                 
668                         Person.LoadFile(vCardFilenameFull);
669                 
670                         UIDCode = Person.Get(wxT("UID"));
671                 
672                         for (int i = 0; i < vCardMember.PropCount; i++){
673                         
674                                 if (vCardMember.PropValues[i] == UIDCode){
675                                 
676                                         FoundMember = TRUE;
677                                 
678                                 }
679                         
680                         }
681                         
682                         if (FoundMember == FALSE){
684                                 vCardFilename.Clear();
685                                 vCardFilenameFull.Clear();
686                                 vCardDataString.Clear();
687                                 ProcFiles = vcardaccdir.GetNext(&vCardFilename);
688                                 continue;
689                         
690                         }
691                 
692                         if (Person.MeetBaseSpecification()){
693         
694                             if (SortMode == 1){
696                                 // Split the name into sections.
697                         
698                                 vCardDataString = Person.Get(wxT("N"));
700                                 vCardName NameData = Person.GetName();
701                     
702                                 vCardDataString = NameData.Forename + wxT(" ") + NameData.Surname;
703                     
704                             } else if (SortMode == 2){
705                     
706                                 // Split the name into sections.
707                     
708                                 vCardName NameData = Person.GetName();    
709                     
710                                 vCardDataString = NameData.Surname + wxT(", ") + NameData.Forename;
711                     
712                             } else if (SortMode == 3){
713                     
714                                 // Check and make sure that the top most nickname is used.
715                     
716                                 vCardDataString = Person.Get(wxT("NICKNAME"));
717                     
718                                 if (vCardDataString.IsEmpty()){
719                         
720                                         vCardDataString = wxT("(no nickname)");
721                         
722                                 }
723                     
724                             } else if (SortMode == 4){
725                     
726                                 vCardDataString = Person.Get(wxT("FN"));
727                     
728                             }
729         
730                             if (AscendingMode == TRUE){
731                                 vCardNamesAsc.insert(std::make_pair(vCardDataString, vCardFilenameFull));
732                             } else {
733                                 vCardNamesDsc.insert(std::make_pair(vCardDataString, vCardFilenameFull));
734                             }
735                 
736                         } else {
737         
738                         }
739         
740                 }
741         
742                 vCardFilename.Clear();
743                 vCardFilenameFull.Clear();
744                 vCardDataString.Clear();
745                 ProcFiles = vcardaccdir.GetNext(&vCardFilename);
746             }
747     
748     } else {
749     
750             bool ProcFiles = vcardaccdir.GetFirst(&vCardFilename, wxEmptyString, wxDIR_FILES);
751             while(ProcFiles){
752     
753                 if (vCardFilename.Right(4) == wxT(".vcf") || 
754                     vCardFilename.Right(4) == wxT(".VCF") || 
755                     vCardFilename.Right(5) == wxT(".vcard") || 
756                     vCardFilename.Right(5) == wxT(".VCARD")){
757         
758                         vCard Person;
759                 
760                         vCardFilenameFull.Append(AccountDirFinal);
761                         vCardFilenameFull.Append(wxT("/"));
762                         vCardFilenameFull.Append(vCardFilename);
763                 
764                         Person.LoadFile(vCardFilenameFull);
765                 
766                         if (Person.MeetBaseSpecification()){
767         
768                             if (SortMode == 1){
770                                 // Split the name into sections.
771                         
772                                 vCardDataString = Person.Get(wxT("N"));
774                                 vCardName NameData = Person.GetName();
775                     
776                                 vCardDataString = NameData.Forename + wxT(" ") + NameData.Surname;
777                     
778                             } else if (SortMode == 2){
779                     
780                                 // Split the name into sections.
781                     
782                                 vCardName NameData = Person.GetName();    
783                     
784                                 vCardDataString = NameData.Surname + wxT(", ") + NameData.Forename;
785                     
786                             } else if (SortMode == 3){
787                     
788                                 // Check and make sure that the top most nickname is used.
789                     
790                                 vCardDataString = Person.Get(wxT("NICKNAME"));
791                     
792                                 if (vCardDataString.IsEmpty()){
793                         
794                                         vCardDataString = wxT("(no nickname)");
795                         
796                                 }
797                     
798                             } else if (SortMode == 4){
799                     
800                                 vCardDataString = Person.Get(wxT("FN"));
801                     
802                             }
803         
804                             if (AscendingMode == TRUE){
805                                 vCardNamesAsc.insert(std::make_pair(vCardDataString, vCardFilenameFull));
806                             } else {
807                                 vCardNamesDsc.insert(std::make_pair(vCardDataString, vCardFilenameFull));
808                             }
809                 
810                         } else {
811                         
812                         }
813         
814                 }
815         
816                 vCardFilename.Clear();
817                 vCardFilenameFull.Clear();
818                 vCardDataString.Clear();
819                 ProcFiles = vcardaccdir.GetNext(&vCardFilename);
820             }
821     
822     }
823     
824     // Sort the data.
826     // Insert the data into the control.
828         if (AscendingMode == TRUE){
829                 for (std::map<wxString, wxString>::iterator iter = vCardNamesAsc.begin();
830                         iter != vCardNamesAsc.end(); ++iter){
832                         wxListItem ContactInfo;
834                         ContactInfo.SetId(0);
835                         ContactInfo.SetText(_("Mooo"));
836                         ContactInfo.SetData(ContactSeekPoint);
837                         ContactIndex = lstContacts->InsertItem(ContactInfo);
839                         lstContacts->SetItem(ContactIndex, 0, iter->first);
840                         ContactsFileIndex.Insert(iter->second, ContactSeekPoint);
841                         ContactSeekPoint++;
843                 }
845         } else {
847                 for (std::map<wxString, wxString>::iterator iter = vCardNamesDsc.begin();
848                         iter != vCardNamesDsc.end(); ++iter){
850                         wxListItem ContactInfo;
852                         ContactInfo.SetId(0);
853                         ContactInfo.SetText(_("Mooo"));
854                         ContactInfo.SetData(ContactSeekPoint);
855                         ContactIndex = lstContacts->InsertItem(ContactInfo);
857                         lstContacts->SetItem(ContactIndex, 0, iter->first);
858                         ContactsFileIndex.Insert(iter->second, ContactSeekPoint);
859                         ContactSeekPoint++;
861                 }
863         }
867 void frmMain::ShowContactInfo( wxListEvent& event )
870     long intSelected = -1;
871     int intSelectedData = 0;
872     long ContactSeekNum = -1;
873     
874 //    intSelected = lstContacts->GetSelection();
875     
876     // Check if several contacts have been selected.
877     
878     int ContactTotal = 0;
879     
880         for (;;){
882                 intSelected = lstContacts->GetNextItem(intSelected,
883                         wxLIST_NEXT_ALL,
884                         wxLIST_STATE_SELECTED);
886                 if (intSelected == -1){
888                         break;
890                 }
892                 ContactTotal++;
894         }
895     
896     if (ContactTotal == 0){
897                 htmContactData->SetPage(wxT(""));
898                 return;
899     }
900     
901     if (ContactTotal > 1){
902     
903                 htmContactData->SetPage(wxString::Format(wxT("%i contacts selected."), ContactTotal));
904                 ActiveFilename.Clear();
905                 return;
906     
907     }
908     
909     intSelected = lstContacts->GetNextItem(intSelected, 
910         wxLIST_NEXT_ALL,
911         wxLIST_STATE_SELECTED);
912         
913     ContactSeekNum = lstContacts->GetItemData(intSelected);
914     
915     wxFFile ContactFile;
916     wxString wxSContactString;
917     wxString ContactLine;
918     vCard Person;
919     
920     int ContactLineLen;
921     bool ExtraLineSeek = FALSE;
922     int QuoteBreakPoint;
923     
924     bool PropertyFind = FALSE;
925     bool QuoteMode = FALSE;
926     
927     wxString wxSPropertyNextLine;
928     wxString wxSProperty;
929     wxString wxSPropertySeg1;
930     wxString wxSPropertySeg2;
931         
932     // Check if we are using wxWidgets version 2.8 or less and
933     // execute the required command accordingly.
934         
935 #if wxABI_VERSION < 20900
936     ContactFile.Open(ContactsFileIndex[ContactSeekNum].c_str(), wxT("r"));
937 #else
938     ContactFile.Open(ContactsFileIndex[ContactSeekNum], wxT("r"));
939 #endif  
940         
941     if (ContactFile.IsOpened() == FALSE){
942         
943                 return;
944         
945     }
946         
947     ContactFile.ReadAll(&wxSContactString, wxConvAuto());
948         
949     // Split the lines.
950         
951     std::map<int, wxString> ContactFileLines;
952     std::map<int, wxString>::iterator striter;
953         
954     wxStringTokenizer wSTContactFileLines(wxSContactString, wxT("\r\n"));
956     int ContactLineSeek = 0;
958     while (wSTContactFileLines.HasMoreTokens() == TRUE){
960                 ContactLine = wSTContactFileLines.GetNextToken();
961                 ContactFileLines.insert(std::make_pair(ContactLineSeek, ContactLine));
962                 ContactLineSeek++;              
963         
964     }
965     
966     if (ContactSeekNum < 0){
967                 return;
968     }
969     
970         for (std::map<int, wxString>::iterator iter = ContactFileLines.begin();
971                 iter != ContactFileLines.end(); ++iter){
973                 // Find the colon which splits the start bit from the data part.
975                 ContactLine = iter->second;
977                 while (ExtraLineSeek == TRUE){
979                         // Check if there is extra data on the next line 
980                         // (indicated by space or tab at the start) and add data.
982                         iter++;
984                         if (iter == ContactFileLines.end()){
986                                 iter--;
987                                 break;
989                         }
991                         wxSPropertyNextLine = iter->second;
994                         if (wxSPropertyNextLine.Mid(0, 1) == wxT(" ") || wxSPropertyNextLine.Mid(0, 1) == wxT("\t")){
996                                 wxSPropertyNextLine.Remove(0, 1);
997                                 //wxSPropertyNextLine.Trim(FALSE);
998                                 //ContactLine.Trim();
999                                 ContactLine.Append(wxSPropertyNextLine);
1001                         } else {
1003                                 iter--;
1004                                 ExtraLineSeek = FALSE;
1006                         }
1008                 }
1010                 ContactLineLen = ContactLine.Len();
1012                 // Make sure we are not in quotation mode.
1013                 // Make sure colon does not have \ or \\ before it.
1015                 for (int i = 0; i <= ContactLineLen; i++){
1017                         if ((ContactLine.Mid(i, 1) == wxT(";") || ContactLine.Mid(i, 1) == wxT(":")) && PropertyFind == TRUE){
1019                                 PropertyFind = FALSE;
1021                         } else if (PropertyFind == TRUE){
1023                                 wxSProperty.Append(ContactLine.Mid(i, 1));
1025                         }
1027                         if (ContactLine.Mid(i, 1) == wxT("\"")){
1029                                 if (QuoteMode == TRUE){
1031                                         QuoteMode = FALSE;
1033                                 } else {
1035                                         QuoteMode = TRUE;
1037                                 }
1039                         }
1041                         if (ContactLine.Mid(i, 1) == wxT(":") && ContactLine.Mid((i - 1), 1) != wxT("\\") && QuoteMode == FALSE){
1043                                 QuoteBreakPoint = i;
1044                                 break;
1046                         }
1048                 }
1050                 // Split that line at the point into two variables (ignore the colon).
1052                 wxSPropertySeg1 = ContactLine.Mid(0, QuoteBreakPoint);
1053                 wxSPropertySeg2 = ContactLine.Mid((QuoteBreakPoint + 1));
1055                 // Insert both into the vCard data file.
1057                 Person.AddRaw(wxSPropertySeg1, wxSPropertySeg2);
1059                 QuoteMode = FALSE;
1060                 PropertyFind = TRUE;
1061                 ExtraLineSeek = TRUE;
1062                 ContactLineLen = 0;
1063                 QuoteBreakPoint = 0;
1064                 ContactLine.Clear();
1065                 wxSProperty.Clear();
1067         }
1068     
1069     OldSessionID = SessionID;
1070     SessionID = wxString::Format(wxT("%i"), rand() % 32768);
1071     LoadContactData(&Person, htmContactData, SessionID, OldSessionID, &MemoryFileList);
1072     ActiveFilename = ContactsFileIndex[ContactSeekNum];
1073     
1076 void frmMain::ShowContactEditorNew( wxCommandEvent& event )
1079     // Check if there is an account selected and if not
1080     // return immediately.
1081     
1082     if (ActiveAccount.IsEmpty()){
1083     
1084         return;
1085     
1086     }
1088     // Add Pointer to SetupPointers for the ETagDB.
1090     wxMemoryInputStream istream(bigimgs_contactpersonicon48_png, sizeof(bigimgs_contactpersonicon48_png));
1091     wxImage bigimgs_contactpersonicon48i(istream, wxBITMAP_TYPE_PNG);
1092     wxBitmap contacticonbmp(bigimgs_contactpersonicon48i, -1);    
1093     wxIcon contacticon;
1094     contacticon.CopyFromBitmap(contacticonbmp); 
1096     frmContactEditor *ContactEditor = new frmContactEditor( this );
1097     
1098     WindowMenuItemID++;
1100     ContactEditor->SetUID(WindowMenuItemID);
1102     WindowData *WData = new WindowData;
1104     WData->DataType = 1;
1105     WData->WindowPointer = (void*)ContactEditor;
1106     WData->WindowID = WindowMenuItemID;
1108     wxCommandEvent addevent(WINDOW_ADD);
1109     addevent.SetClientData(WData);
1110     wxPostEvent(this, addevent);
1111     
1112     frmActivityMgr *frameActMgr = static_cast<frmActivityMgr*>(ActMgrPtr);
1113     ContactEditor->SetupHeaders();
1114     ContactEditor->SetupContact(ActiveAccount);
1115     ContactEditor->SetIcon(contacticon);
1116     ContactEditor->SetupPointers(frameActMgr, &ETagProcTimer, this);
1117     ContactEditor->Show(true);
1118     
1121 void frmMain::ShowContactEditorEdit( wxCommandEvent& event )
1124     // Check if there is an account selected and if not
1125     // return immediately.
1126     
1127     int DataCheck = event.GetInt();
1128         
1129     if (ActiveAccount.IsEmpty() && DataCheck == 0){
1130     
1131         return;
1132     
1133     }
1134     
1135     wxMemoryInputStream istream(bigimgs_contactpersonicon48_png, sizeof(bigimgs_contactpersonicon48_png));
1136     wxImage bigimgs_contactpersonicon48i(istream, wxBITMAP_TYPE_PNG);
1137     wxBitmap contacticonbmp(bigimgs_contactpersonicon48i, -1);
1138     wxIcon contacticon;
1139     contacticon.CopyFromBitmap(contacticonbmp); 
1141     // Check if a contact has been selected.
1142     
1143     long intSelected = -1;
1144     int intSelectedData = 0;
1145     long intContactSeekNum = -1;
1146     
1147 //    intSelected = lstContacts->GetSelection();
1148     
1149     intSelected = lstContacts->GetNextItem(intSelected, 
1150         wxLIST_NEXT_ALL,
1151         wxLIST_STATE_SELECTED);
1152         
1153     if (intSelected == -1){
1154         return;
1155     }
1156     
1157     intContactSeekNum = lstContacts->GetItemData(intSelected);
1159     // Get the filename of the selected contact.
1161     frmActivityMgr *frameActMgr = static_cast<frmActivityMgr*>(ActMgrPtr);
1162     frmContactEditor *ContactEditor = new frmContactEditor( this );
1163     
1164     WindowMenuItemID++;
1165     
1166     ContactEditor->SetUID(WindowMenuItemID);
1168     WindowData *WData = new WindowData;
1170     WData->DataType = 1;
1171     WData->WindowPointer = (void*)ContactEditor;
1172     WData->WindowID = WindowMenuItemID;
1174     wxCommandEvent addevent(WINDOW_ADD);
1175     addevent.SetClientData(WData);
1176     wxPostEvent(this, addevent);
1177     
1178     ContactEditor->SetupPointers(frameActMgr, &ETagProcTimer, this);
1179     ContactEditor->SetupHeaders();
1180     
1181     // Check if pointer is NULL (not from the search forms) or not.
1182     
1183     if (DataCheck == 0){
1184       
1185         ContactEditor->LoadContact(ContactsFileIndex[intContactSeekNum]);
1186         ContactEditor->SetupContact(ActiveAccount);
1187     
1188     } else {
1189         
1190         UCNotif *uc = (UCNotif*)event.GetClientData();
1191         
1192         if (!uc){
1194                 ContactEditor->SetupContact(ActiveAccount);
1195                 ContactEditor->LoadContact(ContactsFileIndex[intContactSeekNum]);
1196                         
1197         } else {
1198     
1199                 ContactEditor->SetupContact(uc->ContactAccount);
1200                 ContactEditor->LoadContact(uc->ContactFilename);
1201                 
1202                 delete uc;
1203                 uc = NULL;
1205     
1206         }
1207     
1208     }
1209         
1210     ContactEditor->SetIcon(contacticon);
1211     ContactEditor->Show(true);
1215 void frmMain::RefreshAddressBook( wxCommandEvent& event ){
1217         // TODO: Check Account Type.
1219         if (!ActiveAccount.IsEmpty()){
1221                 frmActivityMgr *frameActMgr = static_cast<frmActivityMgr*>(ActMgrPtr);
1222                 frameActMgr->AddTask(3, wxT(""), ActiveAccount,
1223                         wxT(""), wxT(""), wxT(""), wxT(""));
1225         }
1229 void frmMain::OpenContactInfo( wxListEvent& event )
1232     wxStringTokenizer vcardfileline;
1233     std::string l;
1234     wxString lwxs;
1235     wxString setname, setvalue;
1236     vCard Person;
1237     wxString nextchar;
1238     
1239     long intSelected = -1;
1240     int intSelectedData = 0;
1241     long intContactSeekNum = -1;
1242     
1243     intSelected = lstContacts->GetNextItem(intSelected, 
1244         wxLIST_NEXT_ALL,
1245         wxLIST_STATE_SELECTED);
1246         
1247     intContactSeekNum = lstContacts->GetItemData(intSelected);
1248     
1249     if (intContactSeekNum == -1){
1250         return;
1251     }
1252     
1253     Person.LoadFile(ContactsFileIndex[intContactSeekNum]);
1255     wxMemoryInputStream istream(bigimgs_contactpersonicon48_png, sizeof(bigimgs_contactpersonicon48_png));
1256     wxImage bigimgs_contactpersonicon48i(istream, wxBITMAP_TYPE_PNG);
1257     wxBitmap contacticonbmp(bigimgs_contactpersonicon48i, -1);    
1258     wxIcon contacticon;
1259     contacticon.CopyFromBitmap(contacticonbmp);
1261     frmContact *Contact = new frmContact( this );
1262     
1263     // Add to window list.
1265     WindowMenuItemID++;
1267     Contact->SetUID(WindowMenuItemID);
1269     WindowData *WData = new WindowData;
1271     WData->DataType = 0;
1272     WData->WindowPointer = (void*)Contact;
1273     WData->WindowID = WindowMenuItemID;
1275     wxCommandEvent addevent(WINDOW_ADD);
1276     addevent.SetClientData(WData);
1277     wxPostEvent(this, addevent);
1278     
1279     Contact->SetupPointers(&MemoryFileList);
1280     Contact->SetupContactData(&Person);
1281     
1282     Contact->SetIcon(contacticon);
1283     Contact->Show(true);
1287 void frmMain::OpenContactInfo( wxCommandEvent& event )
1289     
1290     UCNotif *uc = (UCNotif*)event.GetClientData();
1291     
1292     wxStringTokenizer vcardfileline;
1293     std::string l;
1294     wxString lwxs;
1295     wxString setname, setvalue;
1296     vCard Person;
1297     wxString nextchar;
1298     //std::fstream vcardfile;    
1300     long intSelected = -1;
1301     int intSelectedData = 0;
1302     long intContactSeekNum = -1;
1303     
1304     Person.LoadFile(uc->ContactFilename);
1306     wxMemoryInputStream istream(bigimgs_contactpersonicon48_png, sizeof(bigimgs_contactpersonicon48_png));
1307     wxImage bigimgs_contactpersonicon48i(istream, wxBITMAP_TYPE_PNG);
1308     wxBitmap contacticonbmp(bigimgs_contactpersonicon48i, -1);    
1309     wxIcon contacticon;
1310     contacticon.CopyFromBitmap(contacticonbmp);
1312     frmContact *Contact = new frmContact( this );
1313     
1314     // Add to window list.
1316     WindowMenuItemID++;
1318     Contact->SetUID(WindowMenuItemID);
1320     WindowData *WData = new WindowData;
1322     WData->DataType = 0;
1323     WData->WindowPointer = (void*)Contact;
1324     WData->WindowID = WindowMenuItemID;
1326     wxCommandEvent addevent(WINDOW_ADD);
1327     addevent.SetClientData(WData);
1328     wxPostEvent(this, addevent);
1329     
1330     Contact->SetupPointers(&MemoryFileList);
1331     Contact->SetupContactData(&Person);
1332     
1333     Contact->SetIcon(contacticon);
1334     Contact->Show(true);
1335     
1339 void frmMain::LoadPreferences( wxActivateEvent& event)
1341     this->LoadPreferences();
1344 void frmMain::LoadPreferences(){
1345     
1346     // Load the preferences.
1347     
1348     wxString preffilename = GetUserPrefDir();
1349     
1350     XABPreferences preferences(preffilename);
1352     // Setup the main window position (if needed).
1353     
1354     bool SaveWindowPos = preferences.GetBoolData(wxT("SaveWindowPosition"));
1355     bool HideLocalABs = preferences.GetBoolData(wxT("HideLocalAddressBooks"));
1356     
1357     if (SaveWindowPos == TRUE){
1358          
1359                 this->SetSize(preferences.GetMainWindowData());
1360     
1361     }
1362     
1363     treAccounts->DeleteAllItems();
1364     
1365     wxTreeItemId RootNode = treAccounts->AddRoot(wxT("Root Item"));
1367     // Stop all account timers and remove the accounts.
1368         
1369         for (std::map<wxString, wxAccountSyncTimer*>::iterator iter = AccountSyncTimers.begin();
1370                 iter != AccountSyncTimers.end(); iter++){
1372                 wxAccountSyncTimer *AccTmrPtr = iter->second;
1373                 AccTmrPtr->Stop();
1375                 delete AccTmrPtr;
1376                 AccTmrPtr = NULL;
1378         }
1380         AccountSyncTimers.clear();
1382     /*    
1383     for (int i = (preferences.accounts.GetCount() - 1); i > 0; --i){
1384         treAccounts->AppendItem(RootNode, preferences.accounts.GetAccountName(i));
1385     }
1386     */
1388     wxString AccDir;
1389     wxString AccDirFull;
1390     wxString AccDirFullSfx;
1391     wxString AccName;
1392     wxString AccDirFinal;
1393     AccountAccDirList.clear();
1394     AccountGroupList.clear();
1395     AccountGroupFilename.clear();
1396     AccountGroupTreeId.clear();
1397     wxTreeItemId AccountTreeId;
1398     wxTreeItemId GroupTreeId;
1399     int intGroupID = 0;
1401     for (int i = 0; i < preferences.accounts.GetCount(); i++){
1402     
1403         if ((preferences.accounts.GetAccountType(i) == wxT("Local") || 
1404                 preferences.accounts.GetAccountType(i) == wxT("local")) && HideLocalABs == TRUE){
1405                 
1406                 continue;
1407                 
1408         }
1409     
1410         AccDir = preferences.accounts.GetAccountDirectory(i);
1411         AccDirFull = preferences.accounts.GetAccountDirectory(i);
1412         AccDirFull.Trim();
1413         AccDirFull.Append(wxT("."));
1414         AccDirFullSfx.Append(preferences.accounts.GetAccountType(i));
1415         AccDirFullSfx.LowerCase();
1416         AccDirFullSfx.Trim();
1417         AccDirFull.Append(AccDirFullSfx);
1418         AccName = preferences.accounts.GetAccountName(i);
1419         AccName.Trim();
1420         AccountAccDirList.insert(std::make_pair(i, AccDirFull));
1421         
1422         if (preferences.accounts.GetAccountType(i) == wxT("CardDAV") ||
1423         preferences.accounts.GetAccountType(i) == wxT("carddav")){
1424         
1425                 // Add a new timer using the existing account details.
1426         
1427                 wxAccountSyncTimer *ActTmrPtr = new wxAccountSyncTimer;
1428         
1429                 ActTmrPtr->SetupData(AccDirFull, AccName);
1430                 ActTmrPtr->SetupPointers(this, ActMgrPtr, ETagProcTimer.GetPointer(AccDirFull));
1431                 ActTmrPtr->Start(preferences.accounts.GetAccountRefresh(i) * 1000);
1432                 ActTmrPtr->SetOwner(this);
1433                 ActTmrPtr->Notify();
1434         
1435                 // Add the timer to the list of timers.
1436         
1437                 AccountSyncTimers.insert(std::make_pair(AccDirFull, ActTmrPtr));
1438         
1439                 AccountTreeId = treAccounts->AppendItem(RootNode, preferences.accounts.GetAccountName(i), AccountNetID, -1);
1440         
1441         } else {
1442                         
1443                 AccountTreeId = treAccounts->AppendItem(RootNode, preferences.accounts.GetAccountName(i), AccountID, -1);
1444         
1445         }
1446         
1447         // Go through the account directory and find contact files with
1448         // 'KIND:group' set and add them to the list of groups for the account.
1449         
1450         AccDirFinal = GetAccountDir(AccDirFull, FALSE);
1451         
1452         wxDir vcardaccdir(AccDirFinal);
1453     
1454         wxString vCardFilename;
1455         wxString vCardDataString;
1456         wxString vCardFilenameFull;
1457         //bool ProcFiles = FALSE;
1458         
1459         bool ProcFiles = vcardaccdir.GetFirst(&vCardFilename, wxEmptyString, wxDIR_FILES);
1460         while(ProcFiles){
1462         if (vCardFilename.Right(4) == wxT(".vcf") || 
1463             vCardFilename.Right(4) == wxT(".VCF") || 
1464             vCardFilename.Right(5) == wxT(".vcard") || 
1465             vCardFilename.Right(5) == wxT(".VCARD")){
1467                 vCard Person;
1468         
1469                 vCardFilenameFull.Append(AccDirFinal);
1470                 vCardFilenameFull.Append(wxT("/"));
1471                 vCardFilenameFull.Append(vCardFilename);
1472         
1473                 Person.LoadFile(vCardFilenameFull);
1474         
1475                 if (Person.MeetBaseSpecification()){
1477                     vCardDataString = Person.Get(wxT("KIND"));
1479                     if (vCardDataString == wxT("group")){
1480                     
1481                         // The vCard kind is a group. Add to the account's group list.
1482                         
1483                                 GroupTreeId = treAccounts->AppendItem(AccountTreeId, Person.Get(wxT("FN")), AccountGrpID, -1);
1484                                 treAccounts->SetItemHasChildren(AccountTreeId, TRUE);
1485                                 AccountGroupList.insert(std::make_pair(intGroupID, i));
1486                                 AccountGroupFilename.insert(std::make_pair(intGroupID, vCardFilenameFull));
1487                                 AccountGroupTreeId.insert(std::make_pair(GroupTreeId, intGroupID));
1488                     
1489                     }
1491                     /*if (SortMode == 1){
1493                         // Split the name into sections.
1495                         vCardName NameData = Person.GetName();
1496             
1497                         vCardDataString = NameData.Forename + wxT(" ") + NameData.Surname;
1498             
1499                     } else if (SortMode == 2){
1500             
1501                         // Split the name into sections.
1502             
1503                         vCardName NameData = Person.GetName();    
1504             
1505                         vCardDataString = NameData.Surname + wxT(", ") + NameData.Forename;
1506             
1507                     } else if (SortMode == 3){
1508             
1509                         // Check and make sure that the top most nickname is used.
1510             
1511                         vCardDataString = Person.Get(wxT("NICKNAME"));
1512             
1513                         if (vCardDataString.IsEmpty()){
1514                 
1515                                 vCardDataString = wxT("(no nickname)");
1516                 
1517                         }
1518             
1519                     } else if (SortMode == 4){
1520             
1521                         vCardDataString = Person.Get(wxT("FN"));
1522             
1523                     }
1525                     if (AscendingMode == TRUE){
1526                         vCardNamesAsc.insert(std::make_pair(vCardDataString, vCardFilenameFull));
1527                     } else {
1528                         vCardNamesDsc.insert(std::make_pair(vCardDataString, vCardFilenameFull));
1529                     }*/
1530                     
1531                     intGroupID++;
1532         
1533                 } else {
1534         
1535                 }
1537         }
1539             vCardFilename.Clear();
1540             vCardFilenameFull.Clear();
1541             vCardDataString.Clear();
1542             ProcFiles = vcardaccdir.GetNext(&vCardFilename);
1543             
1544         }
1545         
1546         // Clearup for next account.
1547         
1548         AccDir.clear();
1549         AccDirFull.clear();
1550         AccDirFullSfx.clear();
1551         AccDirFinal.clear();
1552         AccName.clear();
1553         
1554     }
1555     
1556     // Load the account settings as they are needed for connecting
1557     // to the servers.
1558     
1559     prefaccounts = preferences.accounts;
1563 void frmMain::ConflictResolution(wxCommandEvent& event){
1565         frmConflictResolution *frameCR = new frmConflictResolution ( this );
1566         vCardConflictObj *vCardConfObj = (vCardConflictObj*)event.GetClientData();
1567         vCard *ClientDataPtr = vCardConfObj->vCardLocalData;
1568         vCard *ServerDataPtr = vCardConfObj->vCardServerData;
1569         //vCard *ServerDataPtr = vCardConfObj->vCardServerData;
1570         //wxString Moo = ClientDataPtr->WriteString();
1571         //vCard *ServerDataPtr = vCardConfObj->vCardServerData;
1572         frameCR->LoadData(ClientDataPtr, ServerDataPtr, &MemoryFileList);
1573         //frameCR->LoadData(vCardConfObj->vCardLocalData, vCardConfObj->vCardServerData, &MemoryFileList);
1574         frameCR->ShowModal();
1575         
1576         int FinalConflictResult = frameCR->GetResult();
1577         
1578         wxCommandEvent event2(ACTMGR_RESUMEPROC);
1579         event2.SetClientData(vCardConfObj->QRNotifData);
1580         event2.SetInt(FinalConflictResult);
1581         
1582         delete frameCR;
1583         frameCR = NULL;
1585         frmActivityMgr *frameActMgr = static_cast<frmActivityMgr*>(ActMgrPtr);  
1586         wxPostEvent(frameActMgr, event2);
1587         
1590 void frmMain::UpdateContactList(wxCommandEvent& event){
1592         UCNotif *ucd = (UCNotif*)event.GetClientData();
1594         // Check if the active account is being displayed in the
1595         // main window. If not, skip and delete the data.
1596         
1597         long longSelected = -1;
1598         int intSelectedData = 0;
1599         
1600         if (ActiveAccount == ucd->ContactAccount){
1601         
1602                 // Look at the list of contacts and if it matches the
1603                 // filename then update the name.
1604                 
1605                 for (;;){
1607                         longSelected = lstContacts->GetNextItem(longSelected, 
1608                                 wxLIST_NEXT_ALL,
1609                                 wxLIST_STATE_DONTCARE);
1610                         
1611                         if (longSelected == -1){
1612                         
1613                                 break;
1614                         
1615                         }
1616                                 
1617                         intSelectedData = lstContacts->GetItemData(longSelected);
1618                         
1619                         if (ucd->ContactFilename == ContactsFileIndex[intSelectedData]){
1620                         
1621                                 // Work out which sorting mode we are in.
1623                                 if (SortMode == 1){
1625                                         // First Name, Last Name.
1627                                         lstContacts->SetItem(longSelected, 0, ucd->ContactNameArray.Forename + wxT(" ") + ucd->ContactNameArray.Surname);
1629                                 } else if (SortMode == 2){
1631                                         // Last Name, First Name.
1633                                         lstContacts->SetItem(longSelected, 0, ucd->ContactNameArray.Surname + wxT(", ") + ucd->ContactNameArray.Forename);
1635                                 } else if (SortMode == 3){
1637                                         // Nickname.
1639                                         lstContacts->SetItem(longSelected, 0, ucd->ContactNickname);
1641                                 } else if (SortMode == 4){
1642                                         
1643                                         // Display As.
1645                                         lstContacts->SetItem(longSelected, 0, ucd->ContactName);
1647                                 }
1649                         
1650                         }
1651         
1652                         // If the filename is the one loaded into the 
1653                         // browser control, then update this too.
1654                 
1655                         if (ActiveFilename == ContactsFileIndex[intSelectedData]){
1656                         
1657                                 wxListEvent nullevent;
1658                                 ShowContactInfo(nullevent);
1659                         
1660                         }
1661                 
1662                 }
1663         
1664         }
1665         
1666         for (std::map<int, void*>::iterator WindowIter = WindowListPointers.begin();
1667                 WindowIter != WindowListPointers.end(); WindowIter++){
1668                                 
1669                 if (WindowListType[WindowIter->first] != 0){
1670                 
1671                         continue;
1672                 
1673                 }
1674                 
1675                 frmContact *frmContactPtr = static_cast<frmContact*>(WindowIter->second);
1676                 
1677                 if (frmContactPtr->GetFilename() == ucd->ContactFilename){
1678                 
1679                         vCard UpdatedPerson;
1680                         UpdatedPerson.LoadFile(ucd->ContactFilename);
1681                         frmContactPtr->SetupContactData(&UpdatedPerson);
1682                 
1683                 }
1684                 
1685         }
1687         // Send message to search window controller subroutine and 
1688         // pass that notification onto the search windows.
1689         
1690         // Setup the new pointer to use the existing UCNotif without
1691         // deleting it.
1692         
1693         UCNotif *ucd2 = ucd;
1694         
1695         wxCommandEvent sup(SE_UPDATECONTACTNOTIF);
1696         sup.SetClientData(ucd2);
1697         wxPostEvent(this, sup);
1699         // Clear up the unused pointer.
1700         
1701         ucd = NULL;
1705 void frmMain::UpdateAccountList(wxCommandEvent& event){
1709 void frmMain::SetupPointers(void *ActMgrPtrInc){
1711         ActMgrPtr = ActMgrPtrInc;
1715 void frmMain::SetupForm(){
1717         frmActivityMgr *frameActMgr = static_cast<frmActivityMgr*>(ActMgrPtr);
1718         frameActMgr->SetupPointers(&ETagProcTimer, this);
1719         
1720         // Setup the contact information icons for later.
1721         
1722         wxFileSystem::AddHandler(new wxMemoryFSHandler);
1723         wxImage ciicon_png;
1724         //wxBitmap ciicon;
1725         
1726         wxMemoryInputStream ciptostream(icons_cipto_png, sizeof(icons_cipto_png));
1727         ciicon_png.LoadFile(ciptostream, wxBITMAP_TYPE_PNG);
1728         wxMemoryFSHandler::AddFile(wxT("cipto.png"), ciicon_png, wxBITMAP_TYPE_PNG);
1729         
1730         wxMemoryInputStream cilogstream(icons_cilog_png, sizeof(icons_cilog_png));
1731         ciicon_png.LoadFile(cilogstream, wxBITMAP_TYPE_PNG);
1732         wxMemoryFSHandler::AddFile(wxT("cilog.png"), ciicon_png, wxBITMAP_TYPE_PNG);
1733         
1734         wxMemoryInputStream cisndstream(icons_cisnd_png, sizeof(icons_cisnd_png));
1735         ciicon_png.LoadFile(cisndstream, wxBITMAP_TYPE_PNG);
1736         wxMemoryFSHandler::AddFile(wxT("cisnd.png"), ciicon_png, wxBITMAP_TYPE_PNG);
1737         
1738         wxMemoryInputStream cikeystream(icons_cikey_png, sizeof(icons_cikey_png));
1739         ciicon_png.LoadFile(cikeystream, wxBITMAP_TYPE_PNG);
1740         wxMemoryFSHandler::AddFile(wxT("cikey.png"), ciicon_png, wxBITMAP_TYPE_PNG);
1741         
1742         wxMemoryInputStream civenstream(icons_civen_png, sizeof(icons_civen_png));
1743         ciicon_png.LoadFile(civenstream, wxBITMAP_TYPE_PNG);
1744         wxMemoryFSHandler::AddFile(wxT("civen.png"), ciicon_png, wxBITMAP_TYPE_PNG);
1745         
1746         wxMemoryInputStream ciextstream(icons_ciext_png, sizeof(icons_ciext_png));
1747         ciicon_png.LoadFile(ciextstream, wxBITMAP_TYPE_PNG);
1748         wxMemoryFSHandler::AddFile(wxT("ciext.png"), ciicon_png, wxBITMAP_TYPE_PNG);
1750         LoadPreferences();
1754 void frmMain::UpdateSearchContactLists(wxCommandEvent& event){
1756         // Go through each of the search windows and 
1757         // send the required notification to update the
1758         // contact information.
1759         
1760         // Get the event notification data.
1761         
1762         UCNotif *ucd = (UCNotif*)event.GetClientData();
1763         
1764         // Process each search window giving the new details.
1765                 
1766         for (std::map<void*,wxString>::iterator switer = SearchWindowList.begin(); 
1767         switer != SearchWindowList.end(); switer++){
1768         
1769                 // Duplicate the event notification data.
1770                 
1771                 UCNotif *ucd2 = new UCNotif;
1772                 
1773                 ucd2->ContactAccount = ucd->ContactAccount;
1774                 ucd2->ContactFilename = ucd->ContactFilename;
1775                 ucd2->ContactName = ucd->ContactName;
1776                 ucd2->ContactNickname = ucd->ContactNickname;
1777                 ucd2->ContactNameArray = ucd->ContactNameArray;
1778                 
1779                 // Pass the data to the search window for processing.
1780         
1781                 frmSearch *frameSCH = static_cast<frmSearch*>(switer->first);
1782                 wxCommandEvent schupdate(SE_UPDATERESULT);
1783                 schupdate.SetClientData(ucd2);
1784                 wxPostEvent(frameSCH, schupdate);
1785                 
1786                 // Clear up the pointer prior to variable deletion.
1787                 
1788                 frameSCH = NULL;
1789         
1790         }
1791         
1792         delete ucd;
1793         ucd = NULL;
1797 void frmMain::OpenFindContactsWindow(wxCommandEvent& event){
1799         WindowMenuItemID++;
1801         frmSearch *frameSCH = new frmSearch ( this );
1802         frameSCH->SetUID(WindowMenuItemID);
1803         frameSCH->Show(true);
1804         
1805         WindowData *WData = new WindowData;
1807         WData->DataType = 2;
1808         WData->WindowPointer = (void*)frameSCH;
1809         WData->WindowID = WindowMenuItemID;
1811         wxCommandEvent addevent(WINDOW_ADD);
1812         addevent.SetClientData(WData);
1813         wxPostEvent(this, addevent);
1814         
1815         // Add pointer to the list of open search windows.
1816         
1817         SearchWindowList.insert(std::make_pair(frameSCH, wxT("Search")));
1818         
1819         WData = NULL;
1823 void frmMain::RemoveContactsWindowPointer(wxCommandEvent& event){
1825         //frmSearch *frameSCH = static_cast<frmSearch*>(ActMgrPtr);
1826         void *frameSCH = (void*)event.GetClientData();
1828         SearchWindowList.erase(frameSCH);
1829         
1830         frameSCH = NULL;
1834 void frmMain::RemoveContactEditorWindowPointer(wxCommandEvent& event){
1836         void *frameSCH = (void*)event.GetClientData();
1838         SearchWindowList.erase(frameSCH);
1839         
1840         frameSCH = NULL;
1844 void frmMain::UpdateWindowList(wxCommandEvent& event){
1846         // Update the Window List.
1847         
1848         // Delete the existing items in the window menu.
1850         // Get the list of contacts.
1851         
1852         // Insert a separator.
1853         
1854         // Get the list of search windows.
1858 void frmMain::RevealContact(wxCommandEvent& event){
1860         UCNotif *uc = (UCNotif*)event.GetClientData();
1861         
1862         // Switch the account to the one passed.
1864         wxTreeItemIdValue cookie;
1865         wxTreeItemId next = treAccounts->GetRootItem();
1866         wxTreeItemId nextChild;
1867         
1868         for (int i = 0; i < prefaccounts.GetCount(); i++){
1869       
1870                 if (!nextChild){
1871                     nextChild = treAccounts->GetFirstChild(next, cookie);
1872                 } else {
1873                     nextChild = treAccounts->GetNextSibling(nextChild);
1874                 }
1875         
1876                 //AccountName = treAccounts->GetItemText(nextChild);            
1877         
1878                 if (uc->ContactAccount == AccountAccDirList[i]){
1880                         //AccControl->();               
1881                         treAccounts->SelectItem(nextChild, TRUE);
1882                         AccCtrl->SetText(treAccounts->GetItemText(nextChild));
1883                 
1884                 }
1885         
1886         }
1887         
1888         // Switch the contact to the one passed.
1890         long longSelected = -1;
1891         int intSelectedData = 0;
1893         for (;;){
1894         
1895                 longSelected = lstContacts->GetNextItem(longSelected, 
1896                         wxLIST_NEXT_ALL,
1897                         wxLIST_STATE_DONTCARE);
1898                         
1899                 if (longSelected == -1){
1900                         
1901                         break;
1902                         
1903                 }
1904                                 
1905                 intSelectedData = lstContacts->GetItemData(longSelected);
1906                 
1907                 // Compare the filename with the one received.
1908                 // If they match then select it.
1909         
1910                 if (ContactsFileIndex[intSelectedData] == uc->ContactFilename){
1911                 
1912                         // Select.
1913                 
1914                         lstContacts->SetItemState(longSelected, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
1915                         lstContacts->EnsureVisible(longSelected);
1916                 
1917                         break;
1918                 
1919                 }
1921         }
1925 void frmMain::DeleteContact(wxCommandEvent& event){
1927         // Check if a contact is selected.
1929         long intSelected = -1;
1930         int intSelectedData = 0;
1931         long intContactSeekNum = -1;
1932         wxString wxSContactName;
1933         
1934         intSelected = lstContacts->GetNextItem(intSelected, 
1935         wxLIST_NEXT_ALL,
1936         wxLIST_STATE_SELECTED); 
1938         if (intSelected == -1){
1939                 return;
1940         }
1942         frmActivityMgr *frameActMgr = static_cast<frmActivityMgr*>(ActMgrPtr);
1944         // Get the item data of the contact.
1946         intContactSeekNum = lstContacts->GetItemData(intSelected);
1948         // Get the name of the contact.
1949         
1950         wxSContactName = lstContacts->GetItemText(intSelected);
1952         // Display a message confirming if the contact should
1953         // be deleted.
1954         
1955         int QuestionResponse;
1957         QuestionResponse = wxMessageBox(_("Are you sure you want to delete this contact?"), _("Delete contact"), wxYES_NO, this);
1959         if (QuestionResponse == wxNO){
1961                 // Exit the subroutine
1963                 return;
1965         }
1966         
1967         // Delete the contact.
1969         if (!wxRemoveFile(ContactsFileIndex[intContactSeekNum])){
1970         
1971                 wxMessageBox(_("Unable to delete the contact."), _("Cannot delete contact"), wxOK, this);
1972                 return;
1973         
1974         }
1976         // Remove the contact from the list.
1978         lstContacts->DeleteItem(intSelected);
1979         
1980         // Update the search windows, removing the deleted
1981         // contact.
1982         
1983         UCNotif *ucd = new UCNotif;
1984                 
1985         ucd->ContactAccount = ActiveAccount;
1986         ucd->ContactFilename = ContactsFileIndex[intContactSeekNum];
1987         
1988         for (std::map<void*,wxString>::iterator switer = SearchWindowList.begin(); 
1989         switer != SearchWindowList.end(); switer++){
1990         
1991                 // Duplicate the event notification data.
1992         
1993                 UCNotif *ucd2 = new UCNotif;
1995                 ucd2->ContactAccount = ucd->ContactAccount;
1996                 ucd2->ContactFilename = ucd->ContactFilename;
1997                 
1998                 // Pass the data to the search window for processing.
1999         
2000                 frmSearch *frameSCH = static_cast<frmSearch*>(switer->first);
2001                 wxCommandEvent schdelete(SE_DELETERESULT);
2002                 schdelete.SetClientData(ucd2);
2003                 wxPostEvent(frameSCH, schdelete);
2004                 
2005                 // Clear up the pointer prior to variable deletion.
2006                 
2007                 frameSCH = NULL;
2008                 ucd2 = NULL;
2009         
2010         }
2011         
2012         // Clear the wxHTMLWindow.
2013         
2014         wxString EmptyPage = wxT("");
2015         
2016         htmContactData->SetPage(EmptyPage);
2017         
2018         wxStringTokenizer wSTFilename(ContactsFileIndex[intContactSeekNum], wxT("/"));
2019         
2020         wxString wxSplitFilename;
2021         wxString wxSDataURL;
2022     
2023         while(wSTFilename.HasMoreTokens()){
2024     
2025                 wxSplitFilename = wSTFilename.GetNextToken();
2026     
2027         }
2029         if (ActiveAccountType == wxT("CardDAV") || ActiveAccountType == wxT("carddav")){
2031                 // Update the ETagDB and mark it as deleted.
2033                 ETagDB *ETagDBPtr = ETagProcTimer.GetPointer(ActiveAccount);
2035                 ETagDBPtr->UpdateETag(wxSplitFilename, wxT("DELETED"));
2037                 // Get the Data URL.
2039                 wxTreeItemIdValue cookie;
2040                 wxTreeItemId next = treAccounts->GetRootItem();
2042                 wxTreeItemId selectedChild = treAccounts->GetSelection();
2043                 wxTreeItemId nextChild;
2045                 for (int i = 0; i < prefaccounts.GetCount(); i++){
2047                         if (!nextChild){
2048                                 nextChild = treAccounts->GetFirstChild(next, cookie);
2049                         }
2050                         else {
2051                                 nextChild = treAccounts->GetNextSibling(nextChild);
2052                         }
2054                         if (nextChild == selectedChild){
2055                                 wxSDataURL = prefaccounts.GetAccountDirPrefix(i) + wxT("/") + wxSplitFilename;
2057                         }
2059                 }
2061                 // Add task to the activity monitor to delete the contact.
2063                 frameActMgr->AddTask(2, wxSContactName, ActiveAccount, wxSDataURL, wxSplitFilename, ContactsFileIndex[intContactSeekNum], wxT(""));
2065         }
2066         
2067         // Clear the variable. Don't delete as it will mess things up.
2068         
2069         ContactsFileIndex[intContactSeekNum] = wxT("");
2070         
2071         delete ucd;
2072         ucd = NULL;
2076 void frmMain::EmptyServerDialog(wxCommandEvent& event){
2078         QRNotif *qrn = (QRNotif *)event.GetClientData();                
2080         int QResponse = wxMessageBox(_("The list of contacts on the server is empty. Upload all locally stored contacts for this account now?"), _("No contacts on server"), wxYES_NO, this);
2082         wxCommandEvent event2(ACTMGR_RESUMEPROC);
2083         event2.SetInt(*qrn->QResponse);
2084         event2.SetClientData(qrn->PausePtr);
2086         frmActivityMgr *frameActMgr = static_cast<frmActivityMgr*>(ActMgrPtr);
2088         wxPostEvent(frameActMgr, event2);
2092 void frmMain::DeleteContactSync(wxString &Account, wxString &Filename){
2094         // Remove the contact from the window after syncronising.
2096         // Check which account is currently active in the window.
2097         // If it is different from the one passed to this subroutine then
2098         // exit from the subroutine.
2099         
2100         if (Account != ActiveAccount){
2101                 return;
2102         }
2103         
2104         long longSelected = -1;
2105         int intSelectedData = 0;
2107         for (;;){
2108         
2109                 longSelected = lstContacts->GetNextItem(longSelected, 
2110                         wxLIST_NEXT_ALL,
2111                         wxLIST_STATE_DONTCARE);
2112                         
2113                 if (longSelected == -1){
2114                         
2115                         break;
2116                         
2117                 }
2118                                 
2119                 intSelectedData = lstContacts->GetItemData(longSelected);
2120                 
2121                 // Compare the filename with the one received.
2122                 // If they match then select it.
2123         
2124                 if (ContactsFileIndex[intSelectedData] == Filename){
2125                 
2126                         // Remove the contact from the window.
2127                 
2128                         lstContacts->DeleteItem(intSelectedData);
2129                 
2130                         // Check if contact is the selected contact in the HTML window and
2131                         // if it is then clear the window.
2132                 
2133                         if (ActiveFilename == Filename){
2134                         
2135                                 wxString EmptyPage = wxT("");
2136                                 htmContactData->SetPage(EmptyPage);
2137                         
2138                         }
2139                 
2140                         break;
2141                 
2142                 }
2144         }       
2150 void frmMain::SortFNLN( wxCommandEvent& event ) {
2152         wxTreeEvent NullEvent;
2153         SortMode = 1;
2154         LoadContactList(NullEvent);
2158 void frmMain::SortLNFN( wxCommandEvent& event ) {
2160         wxTreeEvent NullEvent;
2161         SortMode = 2;
2162         LoadContactList(NullEvent);
2166 void frmMain::SortNickname( wxCommandEvent& event ) {
2168         wxTreeEvent NullEvent;
2169         SortMode = 3;
2170         LoadContactList(NullEvent);
2174 void frmMain::SortDisplayAs( wxCommandEvent& event ) {
2176         wxTreeEvent NullEvent;
2177         SortMode = 4;
2178         LoadContactList(NullEvent);
2182 void frmMain::SortAscending( wxCommandEvent& event ) {
2184         wxTreeEvent NullEvent;
2185         AscendingMode = TRUE;
2186         LoadContactList(NullEvent);
2190 void frmMain::SortDescending( wxCommandEvent& event ) {
2192         wxTreeEvent NullEvent;
2193         AscendingMode = FALSE;
2194         LoadContactList(NullEvent);
2196
2198 void frmMain::ToggleStatusBar( wxCommandEvent& event ) {
2200         if (stbBottom->IsShown() == TRUE){
2201         
2202                 stbBottom->Hide();
2203         
2204         } else {
2205         
2206                 stbBottom->Show();
2207         
2208         }
2210         this->Layout();
2214 void frmMain::ActivityIconStart( wxCommandEvent& event ){
2216         // Display the activity icon.
2218         imgActivityStatus->SetBitmap(*imgActIcon1);
2219         ActivityIconStatus = 0;
2223 void frmMain::ActivityIconShuffle( wxCommandEvent& event ){
2225         switch (ActivityIconStatus){
2226         
2227                 case 0:
2228                         imgActivityStatus->SetBitmap(*imgActIcon1);
2229                         ActivityIconStatus = 1;
2230                         break;
2231                 case 1:
2232                         imgActivityStatus->SetBitmap(*imgActIcon2);
2233                         ActivityIconStatus = 2;
2234                         break;
2235                 case 2:
2236                         imgActivityStatus->SetBitmap(*imgActIcon3);
2237                         ActivityIconStatus = 3;
2238                         break;
2239                 case 3:
2240                         imgActivityStatus->SetBitmap(*imgActIcon4);
2241                         ActivityIconStatus = 0;
2242                         break;
2243                 default:
2244                         ActivityIconStatus = 0;
2245         
2246         }
2250 void frmMain::ActivityIconStop( wxCommandEvent& event ){
2252         // Display the sleep icon.
2254         imgActivityStatus->SetBitmap(*imgActIconSleep);
2258 void frmMain::UpdateSBIconPlacement( wxSizeEvent& event ){
2260         if (imgConnStatus == 0 || imgSSLStatus == 0 || imgActivityStatus == 0){
2261         
2262                 return;
2263         
2264         }
2266         wxRect rectOnline;
2267         wxRect rectSSL;
2268         wxRect rectActivity;
2269         stbBottom->GetFieldRect(1, rectOnline);
2270         stbBottom->GetFieldRect(2, rectSSL);
2271         stbBottom->GetFieldRect(3, rectActivity);
2273         imgConnStatus->Move(rectOnline.GetX(),rectOnline.GetY());
2274         imgSSLStatus->Move(rectSSL.GetX(),rectSSL.GetY());
2275         imgActivityStatus->Move(rectActivity.GetX(),rectActivity.GetY());
2279 XABViewMode frmMain::GetViewMode(){
2281         XABViewMode xvm;
2282         
2283         xvm.SortMode = SortMode;
2284         xvm.AscendingMode = AscendingMode;
2285         
2286         return xvm;
2287         
2290 void frmMain::WindowAdd( wxCommandEvent &event ){
2292         WindowData *WData = (WindowData*)event.GetClientData();
2294         size_t pos;
2295         
2296         if (WData->DataType == 0){
2297         
2298                 // Contact Window
2300                 int intID = mnuContactWindows->GetId();
2302                 mnuWindow->FindChildItem(intID, &pos);
2303                 wxMenuItem *mnuNewItem = new wxMenuItem(NULL, WData->WindowID, wxT("Contact Window #") + wxString::Format(wxT("%i"), WData->WindowID), wxEmptyString, wxITEM_NORMAL, NULL);
2304                 mnuNewItem->SetId(WData->WindowID);
2305                 WindowListPointersMenu.insert(std::make_pair(WData->WindowID, mnuNewItem));
2306                 WindowListPointers.insert(std::make_pair(WData->WindowID, WData->WindowPointer));
2307                 WindowListType.insert(std::make_pair(WData->WindowID, 0));
2308                 mnuWindow->Insert((pos + 1), mnuNewItem);
2309                 this->Connect(mnuNewItem->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(frmMain::ShowContactWindow));
2310         
2311         } else if (WData->DataType == 1){
2312         
2313                 // Contact Editor Window
2315                 int intID = mnuContactEditorWindows->GetId();
2317                 mnuWindow->FindChildItem(intID, &pos);
2318                 wxMenuItem *mnuNewItem = new wxMenuItem(NULL, WData->WindowID, wxT("Contact Editor Window #") + wxString::Format(wxT("%i"), WData->WindowID), wxEmptyString, wxITEM_NORMAL, NULL);
2319                 mnuNewItem->SetId(WData->WindowID);
2320                 WindowListPointersMenu.insert(std::make_pair(WData->WindowID, mnuNewItem));
2321                 WindowListPointers.insert(std::make_pair(WData->WindowID, WData->WindowPointer));
2322                 WindowListType.insert(std::make_pair(WData->WindowID, 1));
2323                 mnuWindow->Insert((pos + 1), mnuNewItem);
2324                 this->Connect(mnuNewItem->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(frmMain::ShowContactEditorWindow));
2325         
2326         } else if (WData->DataType == 2){
2327                 
2328                 // Search Window
2329         
2330                 int intID = mnuSearchWindows->GetId();
2331                 
2332                 mnuWindow->FindChildItem(intID, &pos);
2333                 wxMenuItem *mnuNewItem = new wxMenuItem(NULL, WData->WindowID, wxT("Search Window #") + wxString::Format(wxT("%i"), WData->WindowID), wxEmptyString, wxITEM_NORMAL, NULL);
2334                 mnuNewItem->SetId(WData->WindowID);
2335                 WindowListPointersMenu.insert(std::make_pair(WData->WindowID, mnuNewItem));
2336                 WindowListPointers.insert(std::make_pair(WData->WindowID, WData->WindowPointer));
2337                 WindowListType.insert(std::make_pair(WData->WindowID, 2));
2338                 mnuWindow->Insert((pos + 1), mnuNewItem);
2339                 this->Connect(mnuNewItem->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(frmMain::ShowSearchWindow));
2340         
2341         }
2342         
2343         delete WData;
2344         WData = NULL;
2348 void frmMain::WindowEdit( wxCommandEvent &event ){
2350         WindowData *WData = (WindowData*)event.GetClientData();
2352         if (WData->DataType == 0){
2353         
2354                 // Contact Window
2356                 int intID = mnuContactWindows->GetId();
2358                 // Get the window title and use that.
2360                 frmContact *frmContactPtr = static_cast<frmContact*>(WData->WindowPointer);
2362                 wxString WindowTitle = frmContactPtr->GetTitle();
2364                 std::map<int, wxMenuItem*>::iterator MenuIter = WindowListPointersMenu.find(WData->WindowID);
2365                 
2366                 MenuIter->second->SetItemLabel(WindowTitle);
2368                 //mnuWindow->FindChildItem(intID, &pos);
2369                 //wxMenuItem *mnuNewItem = new wxMenuItem(NULL, WData->WindowID, WindowTitle, WData->WindowID), wxEmptyString, wxITEM_NORMAL, NULL);
2370                 //mnuNewItem->SetId(WData->WindowID);
2371                 //ContactWindowListPointersMenu.insert(std::make_pair(WData->WindowID, mnuNewItem));
2372                 //ContactWindowListPointers.insert(std::make_pair(WData->WindowID, WData->WindowPointer));
2373                 //mnuWindow->Insert((pos + 1), mnuNewItem);
2374                 //this->Connect(mnuNewItem->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(frmMain::ShowContactWindow));
2375         
2376         } else if (WData->DataType == 1){
2377         
2378                 // Contact Editor Window
2380                 int intID = mnuContactEditorWindows->GetId();
2382                 // Get the window title and use that.
2384                 frmContactEditor *frmCEPtr = static_cast<frmContactEditor*>(WData->WindowPointer);
2386                 wxString WindowTitle = frmCEPtr->GetTitle();
2388                 std::map<int, wxMenuItem*>::iterator MenuIter = WindowListPointersMenu.find(WData->WindowID);
2389                 
2390                 if (WindowTitle.IsEmpty()){
2392                         MenuIter->second->SetItemLabel(_("Unnamed Contact"));
2394                 } else {
2396                         MenuIter->second->SetItemLabel(WindowTitle);
2398                 }
2400                 //mnuWindow->FindChildItem(intID, &pos);
2401                 //wxMenuItem *mnuNewItem = new wxMenuItem(NULL, WData->WindowID, WindowTitle, WData->WindowID), wxEmptyString, wxITEM_NORMAL, NULL);
2402                 //mnuNewItem->SetId(WData->WindowID);
2403                 //ContactEditorWindowListPointersMenu.insert(std::make_pair(WData->WindowID, mnuNewItem));
2404                 //ContactEditorWindowListPointers.insert(std::make_pair(WData->WindowID, WData->WindowPointer));
2405                 //mnuWindow->Insert((pos + 1), mnuNewItem);
2406                 //this->Connect(mnuNewItem->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(frmMain::ShowContactEditorWindow));
2407         
2408         }
2410         delete WData;
2411         WData = NULL;
2412         
2415 void frmMain::WindowDelete( wxCommandEvent &event ){
2417         WindowData *WData = (WindowData*)event.GetClientData();
2418         
2419         std::map<int, wxMenuItem*>::iterator MenuIter = WindowListPointersMenu.find(WData->WindowID);
2421         mnuWindow->Remove(MenuIter->second);
2423         delete MenuIter->second;
2424         MenuIter->second = NULL;
2425         
2426         WindowListPointersMenu.erase(WData->WindowID);
2427         WindowListPointers.erase(WData->WindowID);
2428         WindowListType.erase(WData->WindowID);
2430         delete WData;
2431         WData = NULL;
2435 void frmMain::ShowContactWindow( wxCommandEvent &event ){
2437         std::map<int, void*>::iterator WindowIter = WindowListPointers.find(event.GetId());
2439         frmContact *frmContactPtr = static_cast<frmContact*>(WindowIter->second);
2440         
2441         frmContactPtr->Show();
2442         frmContactPtr->Raise();
2446 void frmMain::ShowContactEditorWindow( wxCommandEvent &event ){
2448         std::map<int, void*>::iterator WindowIter = WindowListPointers.find(event.GetId());
2450         frmContactEditor *frmCEPtr = static_cast<frmContactEditor*>(WindowIter->second);
2451         
2452         frmCEPtr->Show();
2453         frmCEPtr->Raise();
2457 void frmMain::ShowSearchWindow( wxCommandEvent &event ){
2459         // Look through the Search Window List Pointers, grab the
2460         // window point and show the window.
2462         std::map<int, void*>::iterator WindowIter = WindowListPointers.find(event.GetId());
2464         frmSearch *frmSearchPtr = static_cast<frmSearch*>(WindowIter->second);
2465         
2466         frmSearchPtr->Show();
2467         frmSearchPtr->Raise();
2471 void frmMain::ToggleConnectionStatus( wxCommandEvent &event ){
2473         frmActivityMgr *frameActMgr = static_cast<frmActivityMgr*>(ActMgrPtr);
2474         wxCommandEvent toggconn(ACTMGR_TOGGLECONN);
2475         wxPostEvent(frameActMgr, toggconn);
2479 void frmMain::ShowSSLCertificates( wxCommandEvent &event ){
2481         // Check the account type before continuing.
2482         
2483         wxString SeekAccount;
2484         wxString AccTypeLower;
2485         wxString AccType;
2486         std::map<int, SSLCertCollection>::iterator SSLColIter;
2487         
2488         for (int i = 0; i < prefaccounts.GetCount(); i++){
2490                 SeekAccount.Append(prefaccounts.GetAccountDirectory(i));
2491                 AccType.Append(prefaccounts.GetAccountType(i));
2492                 AccTypeLower = AccType.MakeLower();
2493                 SeekAccount.Append(wxT("."));
2494                 SeekAccount.Append(AccTypeLower);
2495                                 
2496                 if (SeekAccount == ActiveAccount){
2497                 
2498                         if (AccTypeLower == wxT("local")){
2499                         
2500                                 return;
2501                         
2502                         }
2503                         
2504                         SSLColIter = AccountSSLData.find(i);
2506                         SSLCertCollection SSLCertInfo = SSLColIter->second;
2507                         
2508                         frmSSLCertificate *frameSSLCert = new frmSSLCertificate ( this );
2509                         frameSSLCert->StartCertFrom(0);
2510                         frameSSLCert->SetupCerts(SSLCertInfo);
2511                         frameSSLCert->ShowModal();
2512                 
2513                         delete frameSSLCert;
2514                         frameSSLCert = NULL;
2515                 
2516                 }
2517                 
2518                 SeekAccount.Clear();
2519                 AccTypeLower.Clear();
2520                 AccType.clear();
2521                 
2522         }
2526 void frmMain::ShowSSLInfo( wxCommandEvent &event ){
2528         // Check the account type before continuing.
2532 void frmMain::HideSSLInfo( wxCommandEvent &event ){
2534         // Check the account type before continuing.
2538 void frmMain::UpdateConnectionStatus( wxCommandEvent &event ){
2540         if (event.GetInt() == 0){
2541         
2542                 imgConnStatus->SetBitmap(*imgOnline);
2543         
2544         } else {
2546                 imgConnStatus->SetBitmap(*imgOffline);
2547         
2548         }       
2552 void frmMain::SetupSSLStatus( int AccountID ){
2554         // Check if account ID given is
2555         // the active account and if not, do nothing.
2556         
2557         wxString AccType;
2558         wxString AccTypeLower;
2559         
2560         AccType = prefaccounts.GetAccountType(AccountID);
2561         AccTypeLower = AccType.MakeLower();
2562         
2563         wxString AccountIDName = prefaccounts.GetAccountDirectory(AccountID) + wxT(".") +
2564                                 AccTypeLower;
2566         if (AccountIDName != ActiveAccount){
2567         
2568                 return;
2569         
2570         }
2572         // Check if the account has SSL enabled.
2573         
2574         bool SSLInUse = prefaccounts.GetAccountSSL(AccountID);
2575         
2576         if (SSLInUse == FALSE){
2577         
2578                 SSLToolTip->SetTip(wxT("SSL is not enabled for this account"));
2579                 imgSSLStatus->SetBitmap(*imgNoSSL);
2580         
2581         } else {
2582         
2583                 // Get the SSL Collection Data.
2585                 std::map<int,int>::iterator SSLResultIter = AccountSSLResult.find(AccountID);
2587                 if (SSLResultIter->second == 1){
2588                 
2589                         imgSSLStatus->SetBitmap(*imgSSLWarning);
2590                         SSLToolTip->SetTip(wxT("Invalid certificate(s) received for '") + 
2591                                 prefaccounts.GetAccountName(AccountID) +
2592                                 wxT("' (Connection denied by user)\n\nDouble click for more information."));
2593                         
2594                 
2595                 } else if (SSLResultIter->second == 0){
2596                 
2597                         imgSSLStatus->SetBitmap(*imgSSL);
2598                         SSLToolTip->SetTip(wxT("Account '") + 
2599                                 prefaccounts.GetAccountName(AccountID) +
2600                                 wxT("' secured using SSL\n\nDouble click for more information."));
2601                 
2602                 }
2603         
2604         }
2608 void frmMain::InvalidSSLCertificate( wxCommandEvent &event ){
2610         frmInvalidSSLCertificate *frameISC = new frmInvalidSSLCertificate ( this );
2611         SSLInvalidCertNotifObj *SSLICNObj = (SSLInvalidCertNotifObj*)event.GetClientData();
2612         SSLCertCollection SSLCCData = SSLICNObj->CertCollection;
2613         wxString AccountName = SSLICNObj->AccountName;
2614         frameISC->LoadData(SSLCCData, AccountName);
2615         frameISC->ShowModal();
2616         
2617         int FinalConflictResult = frameISC->GetResult();
2618         
2619         wxCommandEvent event2(ACTMGR_RESUMEPROC);
2620         event2.SetClientData(SSLICNObj->QRNotifData);
2621         event2.SetInt(FinalConflictResult);
2622         
2623         delete frameISC;
2624         frameISC = NULL;
2626         frmActivityMgr *frameActMgr = static_cast<frmActivityMgr*>(ActMgrPtr);  
2627         wxPostEvent(frameActMgr, event2);
2630 void frmMain::PauseAllTimers(){
2632         for (std::map<wxString, wxAccountSyncTimer*>::iterator ASTiter = AccountSyncTimers.begin(); 
2633         ASTiter != AccountSyncTimers.end(); ASTiter++){
2634         
2635                 ASTiter->second->Stop();
2636         
2637         }
2641 void frmMain::ResumeAllTimers(){
2643         for (std::map<wxString, wxAccountSyncTimer*>::iterator ASTiter = AccountSyncTimers.begin(); 
2644         ASTiter != AccountSyncTimers.end(); ASTiter++){
2645         
2646                 ASTiter->second->Start();
2647         
2648         }
2652 void frmMain::UpdateSSLAccountStatus(int AccountID, int SSLStatus, SSLCertCollection SSLCertInc){
2654         // Delete existing data.
2656         AccountSSLData.erase(AccountID);
2657         AccountSSLResult.erase(AccountID);
2659         // Insert new data.
2660         
2661         AccountSSLData.insert(std::make_pair(AccountID, SSLCertInc));
2662         AccountSSLResult.insert(std::make_pair(AccountID, SSLStatus));
2666 void frmMain::CheckUpdates( wxCommandEvent& event ){
2668         frmUpdate *frameUpdate = new frmUpdate ( this );
2669         frameUpdate->FetchData();
2670         frameUpdate->ShowModal();
2674 void frmMain::OpenImportDialog( wxCommandEvent& event ){
2675         
2676         // Run the import contacts system.
2678         ImportRun(this);
2682 void frmMain::OpenExportDialog( wxCommandEvent& event ){
2684         // Check if an account and at least one contact is selected
2685         // before continuing.
2686         
2687         wxArrayString ArrData;
2688         
2689         if (ActiveAccount.IsEmpty()){
2690     
2691                 return;
2692     
2693         }
2694         
2695         int ContactSelected = 0;
2696         int ContactsCollected = 0;
2697         long longSelected = -1;
2698         
2699         for (;;){
2700                 
2701                 longSelected = lstContacts->GetNextItem(longSelected, 
2702                         wxLIST_NEXT_ALL,
2703                         wxLIST_STATE_SELECTED);
2704                         
2705                 if (longSelected == -1){
2706                 
2707                         break;
2708                         
2709                 }
2710                 
2711                 int FileID = lstContacts->GetItemData(longSelected);
2712                 
2713                 ArrData.Insert(ContactsFileIndex[FileID],
2714                         ContactsCollected, 1);
2715         
2716                 ContactSelected++;
2717                 
2718         }
2720         if (ContactSelected == 0){
2721         
2722                 return;
2723         
2724         }
2725         
2726         // Run the export contacts system.
2728         ExportRun(this, &ArrData);
2732 void frmMain::GetListControl(wxListCtrl *lstContactsPtr, 
2733         wxArrayString *ContactsFileIndexPtr){
2735         lstContactsPtr = lstContacts;
2736         ContactsFileIndexPtr = &ContactsFileIndex;
2737         
2740 void frmMain::GetSelectedList( wxCommandEvent& event ){
2742         // Get the array of contact filenames. 
2744         wxArrayString *ArrData = (wxArrayString*)event.GetClientData();
2745         
2746         // Process them into an array of files. 
2748         long longSelected = -1;
2749         int ContactsCollected = 0;
2750         wxString ContactFilename;
2752         for (;;){
2753                 
2754                 longSelected = lstContacts->GetNextItem(longSelected, 
2755                         wxLIST_NEXT_ALL,
2756                         wxLIST_STATE_SELECTED);
2757                 
2758                 if (longSelected == -1){
2759                 
2760                         break;
2761                         
2762                 }
2764                 // Get the file information and add to the list.
2765                 
2766                 int FileID = lstContacts->GetItemData(longSelected);
2767                 
2768                 ArrData->Insert(ContactsFileIndex[FileID],
2769                         ContactsCollected, 1);
2770                 
2771                 ContactsCollected++;
2772                 ContactFilename.Clear();        
2773                 
2774         }
2775         
2776         event.SetInt(1);
2780 void frmMain::SyncAccount( wxCommandEvent& event ){
2782         wxString *AccNameInc = (wxString*)event.GetClientData();
2784         frmActivityMgr *frameActMgr = static_cast<frmActivityMgr*>(ActMgrPtr);
2785         frameActMgr->AddTask(3, wxT(""), *AccNameInc, 
2786             wxT(""), wxT(""), wxT(""), wxT(""));
2790 void frmMain::ShowHelp( wxCommandEvent& event ){
2792         // Based on the operating system, work out where 
2793         // the documentation should be.
2795 //#ifdef __APPLE__
2797 #if defined(__HAIKU__)
2799 #elif defined(__WIN32__)
2803 #else
2805         if (wxFileExists("/usr/share/doc/xestiaab/index.html")){
2806         
2807                 wxLaunchDefaultBrowser(wxT("file:///usr/share/doc/xestiaab/index.html"));
2808                 return;
2810 #if XSDAB_RELEASE == 0
2812         } else if (wxFileExists("/usr/local/share/doc/xestiaab/index.html")){
2813         
2814                 wxLaunchDefaultBrowser(wxT("file:///usr/local/share/doc/xestiaab/index.html"));
2815                 return;
2817 #endif 
2819         }
2820         
2821 #endif
2822         
2823 #if XSDAB_RELEASE == 0
2825         wxMessageBox(_("The help documentation is not available.\n\nYou can view the documentation that came with your source package."), _("Help documentation missing!"));
2827 #else
2829         wxMessageBox(_("The help documentation is not available in the usual locations on the system. Please visit http://documentation.xestia.co.uk/xestiaab/ for documentation"), _("Help documentation missing!"));
2830         
2831 #endif
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