Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Removed comments from LoadContactList in frmMain
[xestiaab/.git] / source / frmMain.cpp
1 // frmMain.cpp - Main window form.
2 //
3 // (c) 2012-2015 Xestia Software Development.
4 //
5 // This file is part of Xestia Address Book.
6 //
7 // Xestia Address Book is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by the
9 // Free Software Foundation, version 3 of the license.
10 //
11 // Xestia Address Book is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License along
17 // with Xestia Address Book. If not, see <http://www.gnu.org/licenses/>
19 #include <iostream>
20 #include <algorithm>
21 #include <vector>
22 #include <thread>
24 #include <wx/wx.h>
25 #include <wx/tokenzr.h>
26 #include <wx/icon.h>
27 #include <wx/mstream.h>
28 #include <wx/fs_mem.h>
29 #include <wx/ffile.h>
30 #include <wx/filesys.h>
31 #include <wx/dir.h>
32 #include <wx/stdpaths.h>
33 #include <wx/fileconf.h>
34 #include <wx/gdicmn.h>
36 // Include the forms.
38 #include "frmMain.h"
39 #include "frmAbout.h"
40 #include "frmPreferences.h"
41 #include "frmNewAccount.h"
42 #include "actmgr/frmActivityMgr.h"
43 #include "frmContact.h"
44 #include "frmConflictResolution.h"
45 #include "frmInvalidSSLCertificate.h"
46 #include "search/frmSearch.h"
47 #include "frmSSLCertificate.h"
48 #include "frmUpdate.h"
49 #include "import/frmImportResults.h"
50 #include "bitmaps.h"
52 #include "common/preferences.h"
53 #include "common/getcontactinfo.h"
54 #include "common/events.h"
55 #include "common/dirs.h"
56 #include "vcard/vcard.h"
57 #include "carddav/carddav.h"
58 #include "contacteditor/frmContactEditor.h"
59 #include "import/import.h"
60 #include "export/export.h"
61 #include "widgets/XABContactMenu.h"
62 #include "widgets/XABAccountView.h"
64 #include "version.h"
66 //extern const wxEventType MyHaremEvent = wxNewEventType();
68 //#define CE_UPDATECONTACTLIST 7700
69 //#define CE_UPDATEACCOUNTLIST 7701
71 DEFINE_EVENT_TYPE(CE_UPDATECONTACTLIST);
72 DEFINE_EVENT_TYPE(CE_UPDATEACCOUNTLIST);
73 DEFINE_EVENT_TYPE(SE_UPDATECONTACTNOTIF);
74 DEFINE_EVENT_TYPE(CE_OPENCONTACT);
75 DEFINE_EVENT_TYPE(CE_OPENCONTACTLIST);
76 DEFINE_EVENT_TYPE(CE_NEWCONTACT);
77 DEFINE_EVENT_TYPE(CE_EDITCONTACT);
78 DEFINE_EVENT_TYPE(CE_DELETECONTACT);
79 DEFINE_EVENT_TYPE(CE_REVEALCONTACT);
80 DEFINE_EVENT_TYPE(CE_REMOVECONTACT);
81 DEFINE_EVENT_TYPE(CE_REMOVESEARCH);
82 DEFINE_EVENT_TYPE(SYNC_EMPTYSERVER);
83 DEFINE_EVENT_TYPE(ACTMGR_START);
84 DEFINE_EVENT_TYPE(ACTMGR_SHUFFLE);
85 DEFINE_EVENT_TYPE(ACTMGR_STOP);
86 DEFINE_EVENT_TYPE(WINDOW_ADD);
87 DEFINE_EVENT_TYPE(WINDOW_EDIT);
88 DEFINE_EVENT_TYPE(WINDOW_CLOSE);
89 DEFINE_EVENT_TYPE(CONNSTAT_UPDATE);
90 DEFINE_EVENT_TYPE(INVALIDSSLCERT);
91 DEFINE_EVENT_TYPE(GETSELECTEDLIST);
92 DEFINE_EVENT_TYPE(SYNCACCOUNT);
93 DEFINE_EVENT_TYPE(IMPORT_RESULTSSHOW);
94 DEFINE_EVENT_TYPE(RELOADCONTACTLIST);
95 DEFINE_EVENT_TYPE(REFRESHADDRESSBOOK);
97 BEGIN_EVENT_TABLE(frmMain, wxFrame)
98 EVT_COMMAND(wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, frmMain::ConflictResolution)
99 EVT_COMMAND(wxID_ANY, CE_UPDATECONTACTLIST, frmMain::UpdateContactList)
100 EVT_COMMAND(wxID_ANY, CE_UPDATEACCOUNTLIST, frmMain::UpdateAccountList)
101 EVT_COMMAND(wxID_ANY, SE_UPDATECONTACTNOTIF, frmMain::UpdateSearchContactLists)
102 EVT_COMMAND(wxID_ANY, CE_OPENCONTACT, frmMain::OpenContactInfo)
103 EVT_COMMAND(wxID_ANY, CE_OPENCONTACTLIST, frmMain::OpenContactInfoList)
104 EVT_COMMAND(wxID_ANY, CE_NEWCONTACT, frmMain::ShowContactEditorNew)
105 EVT_COMMAND(wxID_ANY, CE_EDITCONTACT, frmMain::ShowContactEditorEdit)
106 EVT_COMMAND(wxID_ANY, CE_DELETECONTACT, frmMain::DeleteContact)
107 EVT_COMMAND(wxID_ANY, CE_REVEALCONTACT, frmMain::RevealContact)
108 EVT_COMMAND(wxID_ANY, CE_REMOVESEARCH, frmMain::RemoveContactsWindowPointer)
109 EVT_COMMAND(wxID_ANY, SYNC_EMPTYSERVER, frmMain::EmptyServerDialog)
110 EVT_COMMAND(wxID_ANY, ACTMGR_START, frmMain::ActivityIconStart)
111 EVT_COMMAND(wxID_ANY, ACTMGR_SHUFFLE, frmMain::ActivityIconShuffle)
112 EVT_COMMAND(wxID_ANY, ACTMGR_STOP, frmMain::ActivityIconStop)
113 EVT_COMMAND(wxID_ANY, WINDOW_ADD, frmMain::WindowAdd)
114 EVT_COMMAND(wxID_ANY, WINDOW_EDIT, frmMain::WindowEdit)
115 EVT_COMMAND(wxID_ANY, WINDOW_CLOSE, frmMain::WindowDelete)
116 EVT_COMMAND(wxID_ANY, CONNSTAT_UPDATE, frmMain::UpdateConnectionStatus)
117 EVT_COMMAND(wxID_ANY, INVALIDSSLCERT, frmMain::InvalidSSLCertificate)
118 EVT_COMMAND(wxID_ANY, GETSELECTEDLIST, frmMain::GetSelectedList)
119 EVT_COMMAND(wxID_ANY, SYNCACCOUNT, frmMain::SyncAccount)
120 EVT_COMMAND(wxID_ANY, IMPORT_RESULTSSHOW, frmMain::ShowImportResults)
121 EVT_COMMAND(wxID_ANY, RELOADCONTACTLIST, frmMain::ReloadContactList)
122 EVT_COMMAND(wxID_ANY, REFRESHADDRESSBOOK, frmMain::RefreshAddressBook)
123 END_EVENT_TABLE()
125 frmMain::frmMain( wxWindow* parent )
127 frmMainADT( parent )
129     
130     // Setup the account icons.
131     
132     wxMemoryInputStream astream(icons_accinet_png, sizeof(icons_accinet_png));
133     wxMemoryInputStream bstream(icons_acclocal_png, sizeof(icons_acclocal_png));
134     wxMemoryInputStream cstream(icons_accgroup_png, sizeof(icons_accgroup_png));
135     wxMemoryInputStream dstream(icons_accnone_png, sizeof(icons_accnone_png));
136     
137     wxImage icons_accinet_png(astream, wxBITMAP_TYPE_PNG);
138     wxBitmap AccInet(icons_accinet_png, -1);
139     wxIcon wxIAccInet;
140     wxIAccInet.CopyFromBitmap(AccInet);
141     
142     wxImage icons_acclocal_png(bstream, wxBITMAP_TYPE_PNG);
143     wxBitmap AccNIcon(icons_acclocal_png, -1);
144     wxIcon wxIAccNIcon;
145     wxIAccNIcon.CopyFromBitmap(AccNIcon);
146     
147     wxImage icons_accgroup_png(cstream, wxBITMAP_TYPE_PNG);
148     wxBitmap AccGrp(icons_accgroup_png, -1);
149     wxIcon wxIAccGrp;
150     wxIAccGrp.CopyFromBitmap(AccGrp);
151     
152     wxImage icons_accnone_png(dstream, wxBITMAP_TYPE_PNG);
153     wxBitmap AccNone(icons_accnone_png, -1);
154     wxIcon wxIAccNone;
155     wxIAccNone.CopyFromBitmap(AccNone);
156     
157     AccountID = AccImgList->Add(wxIAccNIcon);
158     AccountNetID = AccImgList->Add(wxIAccInet);
159     AccountGrpID = AccImgList->Add(wxIAccGrp);
160     AccountNoneID = AccImgList->Add(wxIAccNone);
161     
162     bmpIcon->SetIcon(AccImgList->GetIcon(AccountNoneID));
163     
164     // Setup the status bar icons.
165     
166     // SSL icons.
167     
168     wxMemoryInputStream sslstream(icons_ssl_png, sizeof(icons_ssl_png));
169     wxMemoryInputStream sslwarningstream(icons_sslwarning_png, sizeof(icons_sslwarning_png));
170     wxMemoryInputStream nosslstream(icons_nossl_png, sizeof(icons_nossl_png));
171     
172     wxImage icons_ssl_png(sslstream, wxBITMAP_TYPE_PNG);
173     imgSSL = new wxBitmap(icons_ssl_png, -1);
174     
175     wxImage icons_sslwarning_png(sslwarningstream, wxBITMAP_TYPE_PNG);
176     imgSSLWarning = new wxBitmap(icons_sslwarning_png, -1);
177     
178     wxImage icons_nossl_png(nosslstream, wxBITMAP_TYPE_PNG);
179     imgNoSSL = new wxBitmap(icons_nossl_png, -1);
180     
181     // Activity Icon.
182     
183     wxMemoryInputStream act1(icons_act1_png, sizeof(icons_act1_png));
184     wxMemoryInputStream act2(icons_act2_png, sizeof(icons_act2_png));
185     wxMemoryInputStream act3(icons_act3_png, sizeof(icons_act3_png));
186     wxMemoryInputStream act4(icons_act4_png, sizeof(icons_act4_png));
187     wxMemoryInputStream actsleep(icons_actsleep_png, sizeof(icons_actsleep_png));
188     
189     wxImage icons_actsleep_png(actsleep, wxBITMAP_TYPE_PNG);
190     imgActIconSleep = new wxBitmap (icons_actsleep_png, -1);
191     
192     wxImage icons_act1_png(act1, wxBITMAP_TYPE_PNG);
193     imgActIcon1 = new wxBitmap (icons_act1_png, -1);
194     wxIcon wxIAct1icon;
195     wxIAct1icon.CopyFromBitmap(*imgActIcon1);
196     
197     wxImage icons_act2_png(act2, wxBITMAP_TYPE_PNG);
198     imgActIcon2 = new wxBitmap (icons_act2_png, -1);
199     wxIcon wxIAct2icon;
200     wxIAct2icon.CopyFromBitmap(*imgActIcon2);
201     
202     wxImage icons_act3_png(act3, wxBITMAP_TYPE_PNG);
203     imgActIcon3 = new wxBitmap (icons_act3_png, -1);
204     wxIcon wxIAct3icon;
205     wxIAct3icon.CopyFromBitmap(*imgActIcon3);
206     
207     wxImage icons_act4_png(act4, wxBITMAP_TYPE_PNG);
208     imgActIcon4 = new wxBitmap (icons_act4_png, -1);
209     wxIcon wxIAct4icon;
210     wxIAct4icon.CopyFromBitmap(*imgActIcon4);
211     
212     // Online/Offline icons.
213     
214     wxMemoryInputStream onlinestream(icons_online_png, sizeof(icons_online_png));
215     wxMemoryInputStream offlinestream(icons_offline_png, sizeof(icons_offline_png));
216     
217     wxImage icons_online_png(onlinestream, wxBITMAP_TYPE_PNG);
218     imgOnline = new wxBitmap(icons_online_png, -1);
219     
220     wxImage icons_offline_png(offlinestream, wxBITMAP_TYPE_PNG);
221     imgOffline = new wxBitmap(icons_offline_png, -1);
222     
223     // Setup the account view.
224     
225     AccCtrl->SetPopupControl(treAccounts);
226     AccCtrl->SetPopupMaxHeight(175);
227     AccCtrl->SetPopupMinWidth(250);
228     treAccounts->AssignImageList(AccImgList);
229     //bmpIcon->Hide();
230     
231     /*wxStaticBitmap* BeepBoop = new wxStaticBitmap(AccCtrl, wxID_ANY, wxNullBitmap, wxPoint(AccTextCtrlSize.GetX() + 3, AccTextCtrlSize.GetY() + 2), wxDefaultSize, 0);
232      
233      icons_accgroup_png.SetMask(new wxMask(icons_accgroup_png, wxSystemSettings::GetColour(wxSYS_COLOUR_BACKGROUND)));
234      
235      BeepBoop->SetBackgroundColour(AccCtrl->GetBackgroundColour());
236      BeepBoop->SetBitmap(icons_accgroup_png);*/
237     
238     //szrContactList->Insert(0, XABV2, 1, wxEXPAND | wxALL, 0);
239     
240     /*AccControl->UseAltPopupWindow();
241      AccControl->SetPopupControl(treAccounts);
242      AccControl->SetPopupMaxHeight(175);
243      
244      treAccounts->AssignImageList(AccImgList);
245      szrContactList->Insert(0, AccControl, 1, wxEXPAND|wxALL, 0);
246      szrAccList->Add(AccIcon, 0, wxLEFT|wxTOP|wxEXPAND, 3);
247      
248      */
249     
250     //szrContactList->Layout();
251     //szrContactList->RecalcSizes();
252     
253     wxListItem ColumnData;
254     ColumnData.SetId(0);
255     ColumnData.SetText(wxT("Name0"));
256     ColumnData.SetWidth(320);
257     lstContacts->InsertColumn(0, ColumnData);
258     
259     //Connect(wxID_ANY, ContactConflictCmdEnv,
260     //  ContactConflictEventHandler(frmMain::ConflictResolution), NULL, this);
261     
262     //Connect(wxID_ANY, MyFooCommandEvent,
263     //  MyFooEventHandler(frmMain::DoSomething), NULL, this);
264     
265     //Bind(ContactConflictCmdEnv, ContactConflictEventHandler(frmMain::ConflictResolution), this, wxID_ANY);
266     
267     treAccounts->Connect(wxEVT_LEFT_DCLICK, wxTreeEventHandler(frmMain::LoadContactList), NULL, this);
268     treAccounts->Connect(wxEVT_TREE_SEL_CHANGED, wxTreeEventHandler(frmMain::LoadContactList), NULL, this);
269     
270 #if defined(__HAIKU__)
271     
272 #elif defined(__WIN32__)
273     
274     int stbBottomData [4] = { -1, 8, 8, 8 };
275     
276 #else
277     
278     int stbBottomData [4] = { -1, 20, 20, 20 };
279     
280 #endif
281     
282     stbBottom->SetFieldsCount(4, stbBottomData);
283     stbBottom->SetMinHeight(16);
284     
285     wxRect rectOnline;
286     wxRect rectSSL;
287     wxRect rectActivity;
288     stbBottom->GetFieldRect(1, rectOnline);
289     stbBottom->GetFieldRect(2, rectSSL);
290     stbBottom->GetFieldRect(3, rectActivity);
291     
292     SSLToolTip = new wxToolTip(wxT(""));
293     
294     imgConnStatus = new wxStaticBitmap(stbBottom, wxID_ANY, wxNullBitmap, wxPoint((rectOnline.GetX()),(rectOnline.GetY())), wxDefaultSize, 0 );
295     imgConnStatus->SetBitmap(*imgOnline);
296     imgConnStatus->Connect( wxEVT_LEFT_DCLICK, wxCommandEventHandler( frmMain::ToggleConnectionStatus ), NULL, this );
297     
298     imgSSLStatus = new wxStaticBitmap(stbBottom, wxID_ANY, wxNullBitmap, wxPoint((rectSSL.GetX()),(rectSSL.GetY())), wxDefaultSize, 0 );
299     imgSSLStatus->SetBitmap(*imgNoSSL);
300     imgSSLStatus->SetToolTip(SSLToolTip);
301     imgSSLStatus->Connect( wxEVT_LEFT_DCLICK, wxCommandEventHandler( frmMain::ShowSSLCertificates ), NULL, this );
302     
303     imgActivityStatus = new wxStaticBitmap(stbBottom, wxID_ANY, wxNullBitmap, wxPoint((rectActivity.GetX()),(rectActivity.GetY())), wxDefaultSize, 0);
304     imgActivityStatus->SetBitmap(*imgActIconSleep);
305     imgActivityStatus->Connect( wxEVT_LEFT_DCLICK, wxCommandEventHandler( frmMain::ShowActivityWindow ), NULL, this );
306     
307     // Setup the window menu.
308     
309     // By default should be:
310     
311     // Contact windows:
312     // (none)
313     // (horizontal line)
314     // Contact editor windows:
315     // (none)
316     // (horizontal line)
317     // Search windows:
318     // (none)
319     
320     mnuContactWindows = new wxMenuItem( mnuManage, wxID_ANY, wxString( _("Contact windows:") ), wxEmptyString, wxITEM_NORMAL );
321     mnuWindow->Append( mnuContactWindows );
322     
323     mnuWindow->AppendSeparator();
324     
325     mnuContactEditorWindows = new wxMenuItem( mnuManage, wxID_ANY, wxString( _("Contact editor windows:") ), wxEmptyString, wxITEM_NORMAL );
326     mnuWindow->Append( mnuContactEditorWindows );
327     
328     mnuWindow->AppendSeparator();
329     
330     mnuSearchWindows = new wxMenuItem( mnuManage, wxID_ANY, wxString( wxT("Search windows:") ), wxEmptyString, wxITEM_NORMAL );
331     mnuWindow->Append( mnuSearchWindows );
332     
333 #if defined(__WIN32__)
334     
335     wxFont fontstyle;
336     fontstyle.Bold();
337     
338     mnuContactWindows->SetFont(fontstyle);
339     mnuContactEditorWindows->SetFont(fontstyle);
340     mnuSearchWindows->SetFont(fontstyle);
341     
342 #else
343     
344     mnuContactWindows->Enable(FALSE);
345     mnuContactEditorWindows->Enable(FALSE);
346     mnuSearchWindows->Enable(FALSE);
347     
348 #endif
349     
350     // Hide unimplemented functions.
351     
352     mnuMain->Remove(3);
353     
356 void frmMain::QuitApp( wxCloseEvent& event )
359     QuitApp();
363 void frmMain::QuitApp( wxCommandEvent& event )
365     
366     QuitApp();
367     
370 void frmMain::QuitApp()
372     //-------------------------------------------------------------------
373     // frmMain::QuitApp: Quits the application by simply closing this
374     // window which causes the exit as frmMain is the main window.
375     //
376     // wxCommandEvent   Accepts a referenced event command.
377     //-------------------------------------------------------------------
378  
379      //-------------------------------------------------------------------
380     // frmMain::QuitApp: Quits the application by simply closing this
381     // window which causes the exit as frmMain is the main window.
382     //
383     // wxCommandEvent   Accepts a referenced event command.
384     //-------------------------------------------------------------------
385     
386     //Go through the windows and close each one (be it search
387     //or contact editor). Abort if user wants to cancel.
388     
389     // Close the contact editor windows.
390     
391     // Close the contact windows.
392     
393     // Close the search windows.
394     
395     // Write out the ETag databases.
396     
397     // Save Preferences: Save the window position if that option is enabled.
398     
399     wxString SetFilename = GetUserPrefDir();
400     
401 #if defined(__HAIKU__)
402     
403     
404     
405 #elif defined(__WIN32__)
406     
407     SetFilename.Append(wxT("settings"));
408     
409 #else
410     
411     // *nix OSes
412     
413     SetFilename.Append(wxT("settings"));
414     
415 #endif
416     
417     wxFileConfig *cfgfile = new wxFileConfig("", "", SetFilename);
418     
419     bool SaveWindowPos = FALSE;
420     wxString SaveWindowInc;
421     cfgfile->Read(wxT("SaveWindowPosition"), &SaveWindowInc);
422     
423     if (SaveWindowInc == wxT("true")){
424         
425         SaveWindowPos = TRUE;
426         
427     }
428     
429     if (SaveWindowPos == TRUE){
430         
431         wxRect frmMainPos = this->GetRect();
432         
433         cfgfile->Write(wxT("WindowPositionX"), frmMainPos.GetX());
434         cfgfile->Write(wxT("WindowPositionY"), frmMainPos.GetY());
435         cfgfile->Write(wxT("WindowPositionHeight"), frmMainPos.GetHeight());
436         cfgfile->Write(wxT("WindowPositionWidth"), frmMainPos.GetWidth());
437         
438         
439     }
440     
441     delete cfgfile;
442     cfgfile = NULL;
443     
444     //Everything closed... exit.
445     
446     std::exit(0);
447     
448     Close();
449     
452 void frmMain::ShowActivityWindow( wxCommandEvent& event )
454     
455     frmActivityMgr *frameActMgr = static_cast<frmActivityMgr*>(ActMgrPtr);
456     frameActMgr->OpenWindow();
457     frameActMgr->Show();
458     
461 void frmMain::ShowAboutWindow( wxCommandEvent& event )
463     //-------------------------------------------------------------------
464     // frmMain::ShowAboutWindow: Shows the About window as a modal
465     // dialog and then cleans up when finished.
466     //
467     // wxCommandEvent   Accepts a referenced event command.
468     //-------------------------------------------------------------------
469     
470     frmAbout *frameAbout = new frmAbout ( this );
471     frameAbout->SetupAboutWindow();
472     frameAbout->ShowModal();
473     delete frameAbout;
474     frameAbout = NULL;
475     
478 void frmMain::OpenPreferences( wxCommandEvent& event)
480     //-------------------------------------------------------------------
481     // frmMain::ShowAboutWindow: Opens the Preferences window as a modal
482     // dialog and then cleans up when finished.
483     //
484     // wxCommandEvent   Accepts a referenced event command.
485     //-------------------------------------------------------------------
486     
487     ReloadAccounts = FALSE;
488     
489     frmPreferences *framePreferences = new frmPreferences ( this );
490     framePreferences->SetupPointers(&ReloadAccounts);
491     framePreferences->ShowModal();
492     delete framePreferences;
493     framePreferences = NULL;
494     
495     if (ReloadAccounts == TRUE){
496         
497         // Reload the accounts as a change has been made within
498         // the application.
499         
500         this->LoadPreferences();
501         
502     }
503     
506 void frmMain::OpenNewABDialog( wxCommandEvent& event)
508     //-------------------------------------------------------------------
509     // frmMain::ShowAboutWindow: Opens the Preferences window as a modal
510     // dialog and then cleans up when finished.
511     //
512     // wxCommandEvent   Accepts a referenced event command.
513     //-------------------------------------------------------------------
514     
515     ReloadAccounts = FALSE;
516     
517     frmNewAccount *frameNewAccount = new frmNewAccount ( this );
518     frameNewAccount->SetupPointers(&ReloadAccounts);
519     frameNewAccount->ShowModal();
520     delete frameNewAccount;
521     frameNewAccount = NULL;
522     
523     if (ReloadAccounts == TRUE){
524         
525         // Reload the accounts as a change has been made within
526         // the application.
527         
528         this->LoadPreferences();
529         
530     }
531     
534 void frmMain::LoadContactList( wxTreeEvent& event )
536     
537     // Clear all existing variables.
538     
539     lstContacts->DeleteAllItems();
540     
541     treAccounts->SetAccount();
542     
543     wxTreeItemIdValue cookie;
544     wxTreeItemId next = treAccounts->GetRootItem();
545     wxString AccountName;
546     wxString AccountDir, AccountType, AccountDirFinal, AccountTypeFinal;
547     wxString AccountDirCmb;
548     long selectedaccount = 0;
549     
550     wxTreeItemId selectedChild = treAccounts->GetSelection();
551     wxTreeItemId nextChild;
552     
553     wxTreeItemId ActiveItemId = treAccounts->GetFocusedItem();
554     int ActiveItemIcon = treAccounts->GetItemImage(ActiveItemId, wxTreeItemIcon_Normal);
555     
556     int SCImg = treAccounts->GetItemImage(selectedChild);
557     int AccountIndex = 0;
558     
559     bmpIcon->SetIcon(AccImgList->GetIcon(SCImg));
560     
561     for (int i = 0; i < prefaccounts.GetCount(); i++){
562         
563         if (ActiveItemIcon == 2){
564             
565             std::multimap<wxTreeItemId, int>::iterator AGTiter = AccountGroupTreeId.find(ActiveItemId);
566             std::multimap<int, int>::iterator AGLiter = AccountGroupList.find(AGTiter->second);
567             int ActiveAccountG = AGLiter->second;
568             
569             if (i == ActiveAccountG){
570                 
571                 AccountDir.Append(prefaccounts.GetAccountDirectory(i));
572                 AccountType.Append(prefaccounts.GetAccountType(i));
573                 
574                 AccountDir.Trim();
575                 AccountType.Trim();
576                 
577                 if (AccountType == wxT("CardDAV")){
578                     AccountTypeFinal.Append(wxT("carddav"));
579                 }
580                 else if (AccountType == wxT("Local")){
581                     imgSSLStatus->SetBitmap(*imgOffline);
582                     SSLToolTip->SetTip(wxT("SSL status is not applicable for this account"));
583                     AccountTypeFinal.Append(wxT("local"));
584                 }
585                 
586                 AccountIndex = i;
587                 break;
588                 
589             }
590             
591         }
592         
593         if (!nextChild){
594             nextChild = treAccounts->GetFirstChild(next, cookie);
595         }
596         else {
597             nextChild = treAccounts->GetNextSibling(nextChild);
598         }
599         
600         AccountName = treAccounts->GetItemText(nextChild);
601         
602         if (nextChild == selectedChild){
603             AccountDir.Append(prefaccounts.GetAccountDirectory(i));
604             AccountType.Append(prefaccounts.GetAccountType(i));
605             
606             AccountDir.Trim();
607             AccountType.Trim();
608             
609             if (AccountType == wxT("CardDAV")){
610                 AccountTypeFinal.Append(wxT("carddav"));
611             }
612             else if (AccountType == wxT("Local")){
613                 SSLToolTip->SetTip(wxT("SSL status is not applicable for this account"));
614                 AccountTypeFinal.Append(wxT("local"));
615             }
616             
617             AccountIndex = i;
618             
619         }
620         
621     }
622     
623     if (selectedaccount >= prefaccounts.GetCount()){
624         
625         // The account selected isn't there so return.
626         
627         RevealWait = FALSE;
628         
629         return;
630         
631     }
632     
633     // Open the directory and get the list of .vcf files
634     // in that directory.
635     
636     ActiveAccount = AccountDir + wxT(".") + AccountTypeFinal;
637     ActiveAccountType = AccountType;
638     
639     SetupSSLStatus(AccountIndex);
640     
641     AccountDirFinal.Clear();
642     AccountDirFinal = GetAccountDir(AccountDir + wxT(".") + AccountTypeFinal, FALSE);
643     
644     ContactsFileIndex.Clear();
645     
646     wxString vCardFilename;
647     wxString vCardFilenameFull;
648     wxString vCardDataString;
649     wxStringTokenizer vcardfileline;
650     wxString lwxs;
651     wxString setname, setvalue;
652     std::multimap<wxString, wxString, std::greater<wxString>> vCardNamesAsc;
653     std::multimap<wxString, wxString, std::less<wxString>> vCardNamesDsc;
654     long ContactIndex = 1;
655     long ContactSeekPoint = 0;
656     
657     wxDir vcardaccdir(AccountDirFinal);
658     
659     // Get the wxTreeItemId and image icon and compare it to the list.
660     
661     if (ActiveItemIcon == AccountGrpID){
662         
663         // It's a group so load the file containing the group and
664         // get the members of the group.
665         
666         vCard Group;
667         wxString UIDCode;
668         
669         std::multimap<wxTreeItemId, int>::iterator AGTiter = AccountGroupTreeId.find(ActiveItemId);
670         std::multimap<int, wxString>::iterator AGFiter = AccountGroupFilename.find(AGTiter->second);
671        
672         Group.LoadFile(AGFiter->second);
673         
674         ArrayvCardOutData vCardMember = Group.GetByPartial(wxT("MEMBER"));
675         
676         for (int i = 0; i < vCardMember.PropCount; i++){
677             
678             vCardMember.PropValues[i].Trim();
679             if (vCardMember.PropValues[i].Left(9) == wxT("urn:uuid:")){
680                 
681                 wxString NewPropValue;
682                 NewPropValue = vCardMember.PropValues[i].Mid(9, wxString::npos);
683                 vCardMember.PropValues[i] = NewPropValue;
684                 
685             }
686             
687             
688         }
689         
690         bool ProcFiles = vcardaccdir.GetFirst(&vCardFilename, wxEmptyString, wxDIR_FILES);
691         while(ProcFiles){
692             
693             if (vCardFilename.Right(4) == wxT(".vcf") ||
694                 vCardFilename.Right(4) == wxT(".VCF") ||
695                 vCardFilename.Right(5) == wxT(".vcard") ||
696                 vCardFilename.Right(5) == wxT(".VCARD")){
697                 
698                 vCard Person;
699                 bool FoundMember = FALSE;
700                 
701                 vCardFilenameFull.Append(AccountDirFinal);
702                 vCardFilenameFull.Append(wxT("/"));
703                 vCardFilenameFull.Append(vCardFilename);
704                 
705                 Person.LoadFile(vCardFilenameFull);
706                 
707                 UIDCode = Person.Get(wxT("UID"));
708                 
709                 for (int i = 0; i < vCardMember.PropCount; i++){
710                     
711                     if (vCardMember.PropValues[i] == UIDCode){
712                         
713                         FoundMember = TRUE;
714                         
715                     }
716                     
717                 }
718                 
719                 if (FoundMember == FALSE){
720                     
721                     vCardFilename.Clear();
722                     vCardFilenameFull.Clear();
723                     vCardDataString.Clear();
724                     ProcFiles = vcardaccdir.GetNext(&vCardFilename);
725                     continue;
726                     
727                 }
728                 
729                 if (Person.MeetBaseSpecification()){
730                     
731                     if (SortMode == 1){
732                         
733                         // Split the name into sections.
734                         
735                         vCardDataString = Person.Get(wxT("N"));
736                         
737                         vCardName NameData = Person.GetName();
738                         
739                         vCardDataString = NameData.Forename + wxT(" ") + NameData.Surname;
740                         
741                     } else if (SortMode == 2){
742                         
743                         // Split the name into sections.
744                         
745                         vCardName NameData = Person.GetName();
746                         
747                         vCardDataString = NameData.Surname + wxT(", ") + NameData.Forename;
748                         
749                     } else if (SortMode == 3){
750                         
751                         // Check and make sure that the top most nickname is used.
752                         
753                         vCardDataString = Person.Get(wxT("NICKNAME"));
754                         
755                         if (vCardDataString.IsEmpty()){
756                             
757                             vCardDataString = wxT("(no nickname)");
758                             
759                         }
760                         
761                     } else if (SortMode == 4){
762                         
763                         vCardDataString = Person.Get(wxT("FN"));
764                         
765                     }
766                     
767                     if (AscendingMode == TRUE){
768                         vCardNamesAsc.insert(std::make_pair(vCardDataString, vCardFilenameFull));
769                     } else {
770                         vCardNamesDsc.insert(std::make_pair(vCardDataString, vCardFilenameFull));
771                     }
772                     
773                 } else {
774                     
775                 }
776                 
777             }
778             
779             vCardFilename.Clear();
780             vCardFilenameFull.Clear();
781             vCardDataString.Clear();
782             ProcFiles = vcardaccdir.GetNext(&vCardFilename);
783         }
784         
785     } else {
786         
787         bool ProcFiles = vcardaccdir.GetFirst(&vCardFilename, wxEmptyString, wxDIR_FILES);
788         while(ProcFiles){
789             
790             if (vCardFilename.Right(4) == wxT(".vcf") ||
791                 vCardFilename.Right(4) == wxT(".VCF") ||
792                 vCardFilename.Right(5) == wxT(".vcard") ||
793                 vCardFilename.Right(5) == wxT(".VCARD")){
794                 
795                 vCard Person;
796                 
797                 vCardFilenameFull.Append(AccountDirFinal);
798                 vCardFilenameFull.Append(vCardFilename);
799                 
800                 Person.LoadFile(vCardFilenameFull);
801                 
802                 if (Person.MeetBaseSpecification()){
803                     
804                     if (SortMode == 1){
805                         
806                         // Split the name into sections.
807                         
808                         vCardDataString = Person.Get(wxT("N"));
809                         
810                         vCardName NameData = Person.GetName();
811                         
812                         vCardDataString = NameData.Forename + wxT(" ") + NameData.Surname;
813                         
814                     } else if (SortMode == 2){
815                         
816                         // Split the name into sections.
817                         
818                         vCardName NameData = Person.GetName();
819                         
820                         vCardDataString = NameData.Surname + wxT(", ") + NameData.Forename;
821                         
822                     } else if (SortMode == 3){
823                         
824                         // Check and make sure that the top most nickname is used.
825                         
826                         vCardDataString = Person.Get(wxT("NICKNAME"));
827                         
828                         if (vCardDataString.IsEmpty()){
829                             
830                             vCardDataString = wxT("(no nickname)");
831                             
832                         }
833                         
834                     } else if (SortMode == 4){
835                         
836                         vCardDataString = Person.Get(wxT("FN"));
837                         
838                     }
839                     
840                     if (AscendingMode == TRUE){
841                         vCardNamesAsc.insert(std::make_pair(vCardDataString, vCardFilenameFull));
842                     } else {
843                         vCardNamesDsc.insert(std::make_pair(vCardDataString, vCardFilenameFull));
844                     }
845                     
846                 } else {
847                     
848                 }
849                 
850             }
851             
852             vCardFilename.Clear();
853             vCardFilenameFull.Clear();
854             vCardDataString.Clear();
855             ProcFiles = vcardaccdir.GetNext(&vCardFilename);
856         }
857         
858     }
859     
860     // Sort the data.
861     
862     // Insert the data into the control.
863     
864     if (AscendingMode == TRUE){
865         for (std::map<wxString, wxString>::iterator iter = vCardNamesAsc.begin();
866              iter != vCardNamesAsc.end(); ++iter){
867             
868             wxListItem ContactInfo;
869             
870             ContactInfo.SetId(0);
871             ContactInfo.SetText(_("Mooo"));
872             ContactInfo.SetData(ContactSeekPoint);
873             ContactIndex = lstContacts->InsertItem(ContactInfo);
874             
875             lstContacts->SetItem(ContactIndex, 0, iter->first);
876             ContactsFileIndex.Insert(iter->second, ContactSeekPoint);
877             ContactSeekPoint++;
878             
879         }
880         
881     } else {
882         
883         for (std::map<wxString, wxString>::iterator iter = vCardNamesDsc.begin();
884              iter != vCardNamesDsc.end(); ++iter){
885             
886             wxListItem ContactInfo;
887             
888             ContactInfo.SetId(0);
889             ContactInfo.SetText(_("Mooo"));
890             ContactInfo.SetData(ContactSeekPoint);
891             ContactIndex = lstContacts->InsertItem(ContactInfo);
892             
893             lstContacts->SetItem(ContactIndex, 0, iter->first);
894             ContactsFileIndex.Insert(iter->second, ContactSeekPoint);
895             ContactSeekPoint++;
896             
897         }
898         
899     }
900     
903 void frmMain::ShowContactInfo( wxListEvent& event )
905     
906     long intSelected = -1;
907     long ContactSeekNum = -1;
908     
909     // Check if several contacts have been selected.
910     
911     int ContactTotal = 0;
912     
913     for (;;){
914         
915         intSelected = lstContacts->GetNextItem(intSelected,
916                                                wxLIST_NEXT_ALL,
917                                                wxLIST_STATE_SELECTED);
918         
919         if (intSelected == -1){
920             
921             break;
922             
923         }
924         
925         ContactTotal++;
926         
927     }
928     
929     if (ContactTotal == 0){
930         htmContactData->SetPage(wxT(""));
931         return;
932     }
933     
934     if (ContactTotal > 1){
935         
936         htmContactData->SetPage(wxString::Format(wxT("%i contacts selected."), ContactTotal));
937         ActiveFilename.Clear();
938         return;
939         
940     }
941     
942     intSelected = lstContacts->GetNextItem(intSelected,
943                                            wxLIST_NEXT_ALL,
944                                            wxLIST_STATE_SELECTED);
945     
946     ContactSeekNum = lstContacts->GetItemData(intSelected);
947     
948     wxFFile ContactFile;
949     wxString wxSContactString;
950     wxString ContactLine;
951     vCard Person;
952     
953     size_t ContactLineLen;
954     bool ExtraLineSeek = FALSE;
955     int QuoteBreakPoint = 0;
956     
957     bool PropertyFind = FALSE;
958     bool QuoteMode = FALSE;
959     
960     wxString wxSPropertyNextLine;
961     wxString wxSProperty;
962     wxString wxSPropertySeg1;
963     wxString wxSPropertySeg2;
964     
965     // Check if we are using wxWidgets version 2.8 or less and
966     // execute the required command accordingly.
967     
968 #if wxABI_VERSION < 20900
969     ContactFile.Open(ContactsFileIndex[ContactSeekNum].c_str(), wxT("r"));
970 #else
971     ContactFile.Open(ContactsFileIndex[ContactSeekNum], wxT("r"));
972 #endif
973     
974     if (ContactFile.IsOpened() == FALSE){
975         
976         return;
977         
978     }
979     
980     ContactFile.ReadAll(&wxSContactString, wxConvAuto());
981     
982     // Split the lines.
983     
984     std::map<int, wxString> ContactFileLines;
985     std::map<int, wxString>::iterator striter;
986     
987     wxStringTokenizer wSTContactFileLines(wxSContactString, wxT("\r\n"));
988     
989     int ContactLineSeek = 0;
990     
991     while (wSTContactFileLines.HasMoreTokens() == TRUE){
992         
993         ContactLine = wSTContactFileLines.GetNextToken();
994         ContactFileLines.insert(std::make_pair(ContactLineSeek, ContactLine));
995         ContactLineSeek++;
996         
997     }
998     
999     if (ContactSeekNum < 0){
1000         return;
1001     }
1002     
1003     for (std::map<int, wxString>::iterator iter = ContactFileLines.begin();
1004          iter != ContactFileLines.end(); ++iter){
1005         
1006         // Find the colon which splits the start bit from the data part.
1007         
1008         ContactLine = iter->second;
1009         
1010         while (ExtraLineSeek == TRUE){
1011             
1012             // Check if there is extra data on the next line
1013             // (indicated by space or tab at the start) and add data.
1014             
1015             iter++;
1016             
1017             if (iter == ContactFileLines.end()){
1018                 
1019                 iter--;
1020                 break;
1021                 
1022             }
1023             
1024             wxSPropertyNextLine = iter->second;
1025             
1026             
1027             if (wxSPropertyNextLine.Mid(0, 1) == wxT(" ") || wxSPropertyNextLine.Mid(0, 1) == wxT("\t")){
1028                 
1029                 wxSPropertyNextLine.Remove(0, 1);
1030                 ContactLine.Append(wxSPropertyNextLine);
1031                 
1032             } else {
1033                 
1034                 iter--;
1035                 ExtraLineSeek = FALSE;
1036                 
1037             }
1038             
1039         }
1040         
1041         ContactLineLen = ContactLine.Len();
1042         
1043         // Make sure we are not in quotation mode.
1044         // Make sure colon does not have \ or \\ before it.
1045         
1046         for (int i = 0; i <= ContactLineLen; i++){
1047             
1048             if ((ContactLine.Mid(i, 1) == wxT(";") || ContactLine.Mid(i, 1) == wxT(":")) && PropertyFind == TRUE){
1049                 
1050                 PropertyFind = FALSE;
1051                 
1052             } else if (PropertyFind == TRUE){
1053                 
1054                 wxSProperty.Append(ContactLine.Mid(i, 1));
1055                 
1056             }
1057             
1058             if (ContactLine.Mid(i, 1) == wxT("\"")){
1059                 
1060                 if (QuoteMode == TRUE){
1061                     
1062                     QuoteMode = FALSE;
1063                     
1064                 } else {
1065                     
1066                     QuoteMode = TRUE;
1067                     
1068                 }
1069                 
1070             }
1071             
1072             if (ContactLine.Mid(i, 1) == wxT(":") && ContactLine.Mid((i - 1), 1) != wxT("\\") && QuoteMode == FALSE){
1073                 
1074                 QuoteBreakPoint = i;
1075                 break;
1076                 
1077             }
1078             
1079         }
1080         
1081         // Split that line at the point into two variables (ignore the colon).
1082         
1083         wxSPropertySeg1 = ContactLine.Mid(0, QuoteBreakPoint);
1084         wxSPropertySeg2 = ContactLine.Mid((QuoteBreakPoint + 1));
1085         
1086         // Insert both into the vCard data file.
1087         
1088         Person.AddRaw(wxSPropertySeg1, wxSPropertySeg2);
1089         
1090         QuoteMode = FALSE;
1091         PropertyFind = TRUE;
1092         ExtraLineSeek = TRUE;
1093         ContactLineLen = 0;
1094         QuoteBreakPoint = 0;
1095         ContactLine.Clear();
1096         wxSProperty.Clear();
1097         
1098     }
1099     
1100     OldSessionID = SessionID;
1101     SessionID = wxString::Format(wxT("%i"), rand() % 32768);
1102     LoadContactData(&Person, htmContactData, SessionID, OldSessionID, &MemoryFileList);
1103     ActiveFilename = ContactsFileIndex[ContactSeekNum];
1104     
1107 void frmMain::ShowContactEditorNew( wxCommandEvent& event )
1109     
1110     // Check if there is an account selected and if not
1111     // return immediately.
1112     
1113     if (ActiveAccount.IsEmpty()){
1114         
1115         return;
1116         
1117     }
1118     
1119     // Add Pointer to SetupPointers for the ETagDB.
1120     
1121     wxMemoryInputStream istream(bigimgs_contactpersonicon48_png, sizeof(bigimgs_contactpersonicon48_png));
1122     wxImage bigimgs_contactpersonicon48i(istream, wxBITMAP_TYPE_PNG);
1123     wxBitmap contacticonbmp(bigimgs_contactpersonicon48i, -1);
1124     wxIcon contacticon;
1125     contacticon.CopyFromBitmap(contacticonbmp);
1126     
1127     frmContactEditor *ContactEditor = new frmContactEditor( this );
1128     
1129     WindowMenuItemID++;
1130     
1131     ContactEditor->SetUID(WindowMenuItemID);
1132     
1133     WindowData *WData = new WindowData;
1134     
1135     WData->DataType = 1;
1136     WData->WindowPointer = (void*)ContactEditor;
1137     WData->WindowID = WindowMenuItemID;
1138     
1139     wxCommandEvent addevent(WINDOW_ADD);
1140     addevent.SetClientData(WData);
1141     wxPostEvent(this, addevent);
1142     
1143     frmActivityMgr *frameActMgr = static_cast<frmActivityMgr*>(ActMgrPtr);
1144     ContactEditor->SetupHeaders();
1145     ContactEditor->SetupContact(ActiveAccount);
1146     ContactEditor->SetIcon(contacticon);
1147     ContactEditor->SetupPointers(frameActMgr, &ETagProcTimer, this);
1148     ContactEditor->Show(true);
1149     
1152 void frmMain::ShowContactEditorEdit( wxCommandEvent& event )
1154     
1155     // Check if there is an account selected and if not
1156     // return immediately.
1157     
1158     int DataCheck = event.GetInt();
1159     
1160     if (ActiveAccount.IsEmpty() && DataCheck == 0){
1161         
1162         return;
1163         
1164     }
1165     
1166     wxMemoryInputStream istream(bigimgs_contactpersonicon48_png, sizeof(bigimgs_contactpersonicon48_png));
1167     wxImage bigimgs_contactpersonicon48i(istream, wxBITMAP_TYPE_PNG);
1168     wxBitmap contacticonbmp(bigimgs_contactpersonicon48i, -1);
1169     wxIcon contacticon;
1170     contacticon.CopyFromBitmap(contacticonbmp);
1171     
1172     // Check if a contact has been selected.
1173     
1174     long intSelected = -1;
1175     long intContactSeekNum = -1;
1176         
1177     intSelected = lstContacts->GetNextItem(intSelected,
1178                                            wxLIST_NEXT_ALL,
1179                                            wxLIST_STATE_SELECTED);
1180     
1181     if (intSelected == -1){
1182         return;
1183     }
1184     
1185     intContactSeekNum = lstContacts->GetItemData(intSelected);
1186     
1187     // Get the filename of the selected contact.
1188     
1189     frmActivityMgr *frameActMgr = static_cast<frmActivityMgr*>(ActMgrPtr);
1190     frmContactEditor *ContactEditor = new frmContactEditor( this );
1191     
1192     WindowMenuItemID++;
1193     
1194     ContactEditor->SetUID(WindowMenuItemID);
1195     
1196     WindowData *WData = new WindowData;
1197     
1198     WData->DataType = 1;
1199     WData->WindowPointer = (void*)ContactEditor;
1200     WData->WindowID = WindowMenuItemID;
1201     
1202     wxCommandEvent addevent(WINDOW_ADD);
1203     addevent.SetClientData(WData);
1204     wxPostEvent(this, addevent);
1205     
1206     ContactEditor->SetupPointers(frameActMgr, &ETagProcTimer, this);
1207     ContactEditor->SetupHeaders();
1208     
1209     // Check if pointer is NULL (not from the search forms) or not.
1210     
1211     if (DataCheck == 0){
1212         
1213         ContactEditor->LoadContact(ContactsFileIndex[intContactSeekNum]);
1214         ContactEditor->SetupContact(ActiveAccount);
1215         
1216     } else {
1217         
1218         UCNotif *uc = (UCNotif*)event.GetClientData();
1219         
1220         if (!uc){
1221             
1222             ContactEditor->SetupContact(ActiveAccount);
1223             ContactEditor->LoadContact(ContactsFileIndex[intContactSeekNum]);
1224             
1225         } else {
1226             
1227             ContactEditor->SetupContact(uc->ContactAccount);
1228             ContactEditor->LoadContact(uc->ContactFilename);
1229             
1230             delete uc;
1231             uc = NULL;
1232             
1233             
1234         }
1235         
1236     }
1237     
1238     ContactEditor->SetIcon(contacticon);
1239     ContactEditor->Show(true);
1240     
1243 void frmMain::RefreshAddressBook( wxCommandEvent& event ){
1244    
1245     // Check if ActiveAccount is empty. If not then check if
1246     // account type is not local otherwise continue.
1247     
1248     if (!ActiveAccount.IsEmpty()){
1249    
1250         if (ActiveAccountType != wxT("Local")){
1251         
1252                 // Account type is not local.
1253         
1254                 frmActivityMgr *frameActMgr = static_cast<frmActivityMgr*>(ActMgrPtr);
1255                 frameActMgr->AddTask(3, wxT(""), ActiveAccount,
1256                                      wxT(""), wxT(""), wxT(""), wxT(""));
1257         
1258         } else {
1259         
1260                 wxMessageBox(_("The refresh address book command is not supported with this type of account."), wxT("Not supported for this type of account"));
1261         
1262         }
1263         
1264     }
1265     
1268 void frmMain::OpenContactInfoList( wxListEvent& event )
1270     
1271     wxStringTokenizer vcardfileline;
1272     std::string l;
1273     wxString lwxs;
1274     wxString setname, setvalue;
1275     vCard Person;
1276     wxString nextchar;
1277     
1278     long intSelected = -1;
1279     long intContactSeekNum = -1;
1280     
1281     intSelected = lstContacts->GetNextItem(intSelected,
1282                                            wxLIST_NEXT_ALL,
1283                                            wxLIST_STATE_SELECTED);
1284     
1285     intContactSeekNum = lstContacts->GetItemData(intSelected);
1286     
1287     if (intContactSeekNum == -1){
1288         return;
1289     }
1290     
1291     Person.LoadFile(ContactsFileIndex[intContactSeekNum]);
1292     
1293     wxMemoryInputStream istream(bigimgs_contactpersonicon48_png, sizeof(bigimgs_contactpersonicon48_png));
1294     wxImage bigimgs_contactpersonicon48i(istream, wxBITMAP_TYPE_PNG);
1295     wxBitmap contacticonbmp(bigimgs_contactpersonicon48i, -1);
1296     wxIcon contacticon;
1297     contacticon.CopyFromBitmap(contacticonbmp);
1298     
1299     frmContact *Contact = new frmContact( this );
1300     
1301     // Add to window list.
1302     
1303     WindowMenuItemID++;
1304     
1305     Contact->SetUID(WindowMenuItemID);
1306     
1307     WindowData *WData = new WindowData;
1308     
1309     WData->DataType = 0;
1310     WData->WindowPointer = (void*)Contact;
1311     WData->WindowID = WindowMenuItemID;
1312     
1313     wxCommandEvent addevent(WINDOW_ADD);
1314     addevent.SetClientData(WData);
1315     wxPostEvent(this, addevent);
1316     
1317     Contact->SetupPointers(&MemoryFileList);
1318     Contact->SetupContactData(&Person);
1319     
1320     Contact->SetIcon(contacticon);
1321     Contact->Show(true);
1322     
1325 void frmMain::OpenContactInfoList( wxCommandEvent& event ){
1327         wxListEvent pevent;
1328         OpenContactInfoList(pevent);
1332 void frmMain::OpenContactInfo( wxCommandEvent& event )
1334     
1335     UCNotif *uc = (UCNotif*)event.GetClientData();
1336     
1337     wxStringTokenizer vcardfileline;
1338     std::string l;
1339     wxString lwxs;
1340     wxString setname, setvalue;
1341     vCard Person;
1342     wxString nextchar;
1343     
1344     Person.LoadFile(uc->ContactFilename);
1345     
1346     wxMemoryInputStream istream(bigimgs_contactpersonicon48_png, sizeof(bigimgs_contactpersonicon48_png));
1347     wxImage bigimgs_contactpersonicon48i(istream, wxBITMAP_TYPE_PNG);
1348     wxBitmap contacticonbmp(bigimgs_contactpersonicon48i, -1);
1349     wxIcon contacticon;
1350     contacticon.CopyFromBitmap(contacticonbmp);
1351     
1352     frmContact *Contact = new frmContact( this );
1353     
1354     // Add to window list.
1355     
1356     WindowMenuItemID++;
1357     
1358     Contact->SetUID(WindowMenuItemID);
1359     
1360     WindowData *WData = new WindowData;
1361     
1362     WData->DataType = 0;
1363     WData->WindowPointer = (void*)Contact;
1364     WData->WindowID = WindowMenuItemID;
1365     
1366     wxCommandEvent addevent(WINDOW_ADD);
1367     addevent.SetClientData(WData);
1368     wxPostEvent(this, addevent);
1369     
1370     Contact->SetupPointers(&MemoryFileList);
1371     Contact->SetupContactData(&Person);
1372     
1373     Contact->SetIcon(contacticon);
1374     Contact->Show(true);
1375     
1379 void frmMain::LoadPreferences( wxActivateEvent& event)
1381     this->LoadPreferences();
1384 void frmMain::LoadPreferences(){
1385     
1386     // Load the preferences.
1387     
1388     wxString preffilename = GetUserPrefDir();
1389     
1390     XABPreferences preferences(preffilename);
1391     
1392     // Setup the main window position (if needed).
1393     
1394     bool SaveWindowPos = preferences.GetBoolData(wxT("SaveWindowPosition"));
1395     bool HideLocalABs = preferences.GetBoolData(wxT("HideLocalAddressBooks"));
1396     
1397     if (SaveWindowPos == TRUE){
1398         
1399         this->SetSize(preferences.GetMainWindowData());
1400         
1401     }
1402     
1403     treAccounts->DeleteAllItems();
1404     
1405     wxTreeItemId RootNode = treAccounts->AddRoot(wxT("Root Item"), AccountNoneID);
1406     
1407     // Stop all account timers and remove the accounts.
1408     
1409     for (std::map<wxString, wxAccountSyncTimer*>::iterator iter = AccountSyncTimers.begin();
1410          iter != AccountSyncTimers.end(); iter++){
1411         
1412         wxAccountSyncTimer *AccTmrPtr = iter->second;
1413         AccTmrPtr->Stop();
1414         
1415         delete AccTmrPtr;
1416         AccTmrPtr = NULL;
1417         
1418     }
1419     
1420     AccountSyncTimers.clear();
1421     
1422     wxString AccDir;
1423     wxString AccDirFull;
1424     wxString AccDirFullSfx;
1425     wxString AccName;
1426     wxString AccDirFinal;
1427     AccountAccDirList.clear();
1428     AccountGroupList.clear();
1429     AccountGroupFilename.clear();
1430     AccountGroupTreeId.clear();
1431     wxTreeItemId AccountTreeId;
1432     wxTreeItemId GroupTreeId;
1433     int intGroupID = 0;
1434     
1435     for (int i = 0; i < preferences.accounts.GetCount(); i++){
1436         
1437         if ((preferences.accounts.GetAccountType(i) == wxT("Local") ||
1438              preferences.accounts.GetAccountType(i) == wxT("local")) && HideLocalABs == TRUE){
1439             
1440             continue;
1441             
1442         }
1443         
1444         if (preferences.accounts.GetAccountDirectory(i).IsEmpty()){
1445             
1446             continue;
1447             
1448         }
1449         
1450         AccDir = preferences.accounts.GetAccountDirectory(i);
1451         AccDirFull = preferences.accounts.GetAccountDirectory(i);
1452         AccDirFull.Trim();
1453         AccDirFull.Append(wxT("."));
1454         AccDirFullSfx.Append(preferences.accounts.GetAccountType(i));
1455         AccDirFullSfx.LowerCase();
1456         AccDirFullSfx.Trim();
1457         AccDirFull.Append(AccDirFullSfx);
1458         AccName = preferences.accounts.GetAccountName(i);
1459         AccName.Trim();
1460         AccountAccDirList.insert(std::make_pair(i, AccDirFull));
1461         
1462         if (preferences.accounts.GetAccountType(i) == wxT("CardDAV") ||
1463             preferences.accounts.GetAccountType(i) == wxT("carddav")){
1464             
1465             // TODO: Check if the directory exists before doing anything.
1466             
1467             
1468             
1469             // Add a new timer using the existing account details.
1470             
1471             wxAccountSyncTimer *ActTmrPtr = new wxAccountSyncTimer;
1472             
1473             ActTmrPtr->SetupData(AccDirFull, AccName);
1474             ActTmrPtr->SetupPointers(this, ActMgrPtr, ETagProcTimer.GetPointer(AccDirFull));
1475             ActTmrPtr->Start((int)(preferences.accounts.GetAccountRefresh(i) * 1000));
1476             ActTmrPtr->SetOwner(this);
1477             ActTmrPtr->Notify();
1478             
1479             // Add the timer to the list of timers.
1480             
1481             AccountSyncTimers.insert(std::make_pair(AccDirFull, ActTmrPtr));
1482             
1483             AccountTreeId = treAccounts->AppendItem(RootNode, preferences.accounts.GetAccountName(i), AccountNetID, -1);
1484             
1485         } else {
1486             
1487             AccountTreeId = treAccounts->AppendItem(RootNode, preferences.accounts.GetAccountName(i), AccountID, -1);
1488             
1489         }
1490         
1491         // Go through the account directory and find contact files with
1492         // 'KIND:group' set and add them to the list of groups for the account.
1493         
1494         AccDirFinal = GetAccountDir(AccDirFull, FALSE);
1495         
1496         wxDir vcardaccdir(AccDirFinal);
1497         
1498         wxString vCardFilename;
1499         wxString vCardDataString;
1500         wxString vCardFilenameFull;
1502         bool ProcFiles = vcardaccdir.GetFirst(&vCardFilename, wxEmptyString, wxDIR_FILES);
1503         while(ProcFiles){
1504             
1505             if (vCardFilename.Right(4) == wxT(".vcf") ||
1506                 vCardFilename.Right(4) == wxT(".VCF") ||
1507                 vCardFilename.Right(5) == wxT(".vcard") ||
1508                 vCardFilename.Right(5) == wxT(".VCARD")){
1509                 
1510                 vCard Person;
1511                 
1512                 vCardFilenameFull.Append(AccDirFinal);
1513                 vCardFilenameFull.Append(wxT("/"));
1514                 vCardFilenameFull.Append(vCardFilename);
1515                 
1516                 Person.LoadFile(vCardFilenameFull);
1517                 
1518                 if (Person.MeetBaseSpecification()){
1519                     
1520                     vCardDataString = Person.Get(wxT("KIND"));
1521                     
1522                     if (vCardDataString == wxT("group")){
1523                         
1524                         // The vCard kind is a group. Add to the account's group list.
1525                         
1526                         GroupTreeId = treAccounts->AppendItem(AccountTreeId, Person.Get(wxT("FN")), AccountGrpID, -1);
1527                         treAccounts->SetItemHasChildren(AccountTreeId, TRUE);
1528                         AccountGroupList.insert(std::make_pair(intGroupID, i));
1529                         AccountGroupFilename.insert(std::make_pair(intGroupID, vCardFilenameFull));
1530                         AccountGroupTreeId.insert(std::make_pair(GroupTreeId, intGroupID));
1531                         
1532                     }
1533                     
1534                     intGroupID++;
1535                     
1536                 } else {
1537                     
1538                 }
1539                 
1540             }
1541             
1542             vCardFilename.Clear();
1543             vCardFilenameFull.Clear();
1544             vCardDataString.Clear();
1545             ProcFiles = vcardaccdir.GetNext(&vCardFilename);
1546             
1547         }
1548         
1549         // Clearup for next account.
1550         
1551         AccDir.clear();
1552         AccDirFull.clear();
1553         AccDirFullSfx.clear();
1554         AccDirFinal.clear();
1555         AccName.clear();
1556         
1557     }
1558     
1559     // Load the account settings as they are needed for connecting
1560     // to the servers.
1561     
1562     prefaccounts = preferences.accounts;
1563     
1566 void frmMain::ConflictResolution(wxCommandEvent& event){
1567     
1568     frmConflictResolution *frameCR = new frmConflictResolution ( this );
1569     vCardConflictObj *vCardConfObj = (vCardConflictObj*)event.GetClientData();
1570     vCard *ClientDataPtr = vCardConfObj->vCardLocalData;
1571     vCard *ServerDataPtr = vCardConfObj->vCardServerData;
1572     frameCR->LoadData(ClientDataPtr, ServerDataPtr, &MemoryFileList);
1573     frameCR->ShowModal();
1574     
1575     int FinalConflictResult = frameCR->GetResult();
1576     
1577     wxCommandEvent event2(ACTMGR_RESUMEPROC);
1578     event2.SetClientData(vCardConfObj->QRNotifData);
1579     event2.SetInt(FinalConflictResult);
1580     
1581     delete frameCR;
1582     frameCR = NULL;
1583     
1584     frmActivityMgr *frameActMgr = static_cast<frmActivityMgr*>(ActMgrPtr);
1585     wxPostEvent(frameActMgr, event2);
1586     
1589 void frmMain::UpdateContactList(wxCommandEvent& event){
1590     
1591     UCNotif *ucd = (UCNotif*)event.GetClientData();
1592     
1593     // Check if the active account is being displayed in the
1594     // main window. If not, skip and delete the data.
1595     
1596     long longSelected = -1;
1597     int intSelectedData = 0;
1598     
1599     if (ActiveAccount == ucd->ContactAccount){
1600         
1601         // Look at the list of contacts and if it matches the
1602         // filename then update the name.
1603         
1604         for (;;){
1605             
1606             longSelected = lstContacts->GetNextItem(longSelected,
1607                                                     wxLIST_NEXT_ALL,
1608                                                     wxLIST_STATE_DONTCARE);
1609             
1610             if (longSelected == -1){
1611                 
1612                 break;
1613                 
1614             }
1615             
1616             intSelectedData = (int)lstContacts->GetItemData(longSelected);
1617             
1618             if (ucd->ContactFilename == ContactsFileIndex[intSelectedData]){
1619                 
1620                 // Work out which sorting mode we are in.
1621                 
1622                 if (SortMode == 1){
1623                     
1624                     // First Name, Last Name.
1625                     
1626                     lstContacts->SetItem(longSelected, 0, ucd->ContactNameArray.Forename + wxT(" ") + ucd->ContactNameArray.Surname);
1627                     
1628                 } else if (SortMode == 2){
1629                     
1630                     // Last Name, First Name.
1631                     
1632                     lstContacts->SetItem(longSelected, 0, ucd->ContactNameArray.Surname + wxT(", ") + ucd->ContactNameArray.Forename);
1633                     
1634                 } else if (SortMode == 3){
1635                     
1636                     // Nickname.
1637                     
1638                     lstContacts->SetItem(longSelected, 0, ucd->ContactNickname);
1639                     
1640                 } else if (SortMode == 4){
1641                     
1642                     // Display As.
1643                     
1644                     lstContacts->SetItem(longSelected, 0, ucd->ContactName);
1645                     
1646                 }
1647                 
1648                 
1649             }
1650             
1651             // If the filename is the one loaded into the
1652             // browser control, then update this too.
1653             
1654             if (ActiveFilename == ContactsFileIndex[intSelectedData]){
1655                 
1656                 wxListEvent nullevent;
1657                 ShowContactInfo(nullevent);
1658                 
1659             }
1660             
1661         }
1662         
1663     }
1664     
1665     for (std::map<int, void*>::iterator WindowIter = WindowListPointers.begin();
1666          WindowIter != WindowListPointers.end(); WindowIter++){
1667         
1668         if (WindowListType[WindowIter->first] != 0){
1669             
1670             continue;
1671             
1672         }
1673         
1674         frmContact *frmContactPtr = static_cast<frmContact*>(WindowIter->second);
1675         
1676         if (frmContactPtr->GetFilename() == ucd->ContactFilename){
1677             
1678             vCard UpdatedPerson;
1679             UpdatedPerson.LoadFile(ucd->ContactFilename);
1680             frmContactPtr->SetupContactData(&UpdatedPerson);
1681             
1682         }
1683         
1684     }
1685     
1686     // Send message to search window controller subroutine and
1687     // pass that notification onto the search windows.
1688     
1689     // Setup the new pointer to use the existing UCNotif without
1690     // deleting it.
1691     
1692     UCNotif *ucd2 = ucd;
1693     
1694     wxCommandEvent sup(SE_UPDATECONTACTNOTIF);
1695     sup.SetClientData(ucd2);
1696     wxPostEvent(this, sup);
1697     
1698     // Clear up the unused pointer.
1699     
1700     ucd = NULL;
1701     
1704 void frmMain::UpdateAccountList(wxCommandEvent& event){
1705     
1708 void frmMain::SetupPointers(void *ActMgrPtrInc){
1709     
1710     ActMgrPtr = ActMgrPtrInc;
1711     
1714 void frmMain::SetupForm(){
1715     
1716     frmActivityMgr *frameActMgr = static_cast<frmActivityMgr*>(ActMgrPtr);
1717     frameActMgr->SetupPointers(&ETagProcTimer, this);
1718     
1719     // Setup the contact information icons for later.
1720     
1721     wxFileSystem::AddHandler(new wxMemoryFSHandler);
1722     wxImage ciicon_png;
1723     //wxBitmap ciicon;
1724     
1725     wxMemoryInputStream ciptostream(icons_cipto_png, sizeof(icons_cipto_png));
1726     ciicon_png.LoadFile(ciptostream, wxBITMAP_TYPE_PNG);
1727     wxMemoryFSHandler::AddFile(wxT("cipto.png"), ciicon_png, wxBITMAP_TYPE_PNG);
1728     
1729     wxMemoryInputStream cilogstream(icons_cilog_png, sizeof(icons_cilog_png));
1730     ciicon_png.LoadFile(cilogstream, wxBITMAP_TYPE_PNG);
1731     wxMemoryFSHandler::AddFile(wxT("cilog.png"), ciicon_png, wxBITMAP_TYPE_PNG);
1732     
1733     wxMemoryInputStream cisndstream(icons_cisnd_png, sizeof(icons_cisnd_png));
1734     ciicon_png.LoadFile(cisndstream, wxBITMAP_TYPE_PNG);
1735     wxMemoryFSHandler::AddFile(wxT("cisnd.png"), ciicon_png, wxBITMAP_TYPE_PNG);
1736     
1737     wxMemoryInputStream cikeystream(icons_cikey_png, sizeof(icons_cikey_png));
1738     ciicon_png.LoadFile(cikeystream, wxBITMAP_TYPE_PNG);
1739     wxMemoryFSHandler::AddFile(wxT("cikey.png"), ciicon_png, wxBITMAP_TYPE_PNG);
1740     
1741     wxMemoryInputStream civenstream(icons_civen_png, sizeof(icons_civen_png));
1742     ciicon_png.LoadFile(civenstream, wxBITMAP_TYPE_PNG);
1743     wxMemoryFSHandler::AddFile(wxT("civen.png"), ciicon_png, wxBITMAP_TYPE_PNG);
1744     
1745     wxMemoryInputStream ciextstream(icons_ciext_png, sizeof(icons_ciext_png));
1746     ciicon_png.LoadFile(ciextstream, wxBITMAP_TYPE_PNG);
1747     wxMemoryFSHandler::AddFile(wxT("ciext.png"), ciicon_png, wxBITMAP_TYPE_PNG);
1748     
1749     LoadPreferences();
1750     
1753 void frmMain::UpdateSearchContactLists(wxCommandEvent& event){
1754     
1755     // Go through each of the search windows and
1756     // send the required notification to update the
1757     // contact information.
1758     
1759     // Get the event notification data.
1760     
1761     UCNotif *ucd = (UCNotif*)event.GetClientData();
1762     
1763     // Process each search window giving the new details.
1764     
1765     for (std::map<void*,wxString>::iterator switer = SearchWindowList.begin();
1766          switer != SearchWindowList.end(); switer++){
1767         
1768         // Duplicate the event notification data.
1769         
1770         UCNotif *ucd2 = new UCNotif;
1771         
1772         ucd2->ContactAccount = ucd->ContactAccount;
1773         ucd2->ContactFilename = ucd->ContactFilename;
1774         ucd2->ContactName = ucd->ContactName;
1775         ucd2->ContactNickname = ucd->ContactNickname;
1776         ucd2->ContactNameArray = ucd->ContactNameArray;
1777         
1778         // Pass the data to the search window for processing.
1779         
1780         frmSearch *frameSCH = static_cast<frmSearch*>(switer->first);
1781         wxCommandEvent schupdate(SE_UPDATERESULT);
1782         schupdate.SetClientData(ucd2);
1783         wxPostEvent(frameSCH, schupdate);
1784         
1785         // Clear up the pointer prior to variable deletion.
1786         
1787         frameSCH = NULL;
1788         
1789     }
1790     
1791     delete ucd;
1792     ucd = NULL;
1793     
1796 void frmMain::OpenFindContactsWindow(wxCommandEvent& event){
1797     
1798     WindowMenuItemID++;
1799     
1800     frmSearch *frameSCH = new frmSearch ( this );
1801     frameSCH->SetUID(WindowMenuItemID);
1802     frameSCH->Show(true);
1803     
1804     WindowData *WData = new WindowData;
1805     
1806     WData->DataType = 2;
1807     WData->WindowPointer = (void*)frameSCH;
1808     WData->WindowID = WindowMenuItemID;
1809     
1810     wxCommandEvent addevent(WINDOW_ADD);
1811     addevent.SetClientData(WData);
1812     wxPostEvent(this, addevent);
1813     
1814     // Add pointer to the list of open search windows.
1815     
1816     SearchWindowList.insert(std::make_pair(frameSCH, wxT("Search")));
1817     
1818     WData = NULL;
1819     
1822 void frmMain::RemoveContactsWindowPointer(wxCommandEvent& event){
1823     
1824     void *frameSCH = (void*)event.GetClientData();
1825     
1826     SearchWindowList.erase(frameSCH);
1827     
1828     frameSCH = NULL;
1829     
1832 void frmMain::RemoveContactEditorWindowPointer(wxCommandEvent& event){
1833     
1834     void *frameSCH = (void*)event.GetClientData();
1835     
1836     SearchWindowList.erase(frameSCH);
1837     
1838     frameSCH = NULL;
1839     
1842 void frmMain::RevealContact(wxCommandEvent& event){
1843     
1844     UCNotif *uc = (UCNotif*)event.GetClientData();
1845     
1846     // Switch the account to the one passed.
1847     
1848     wxTreeItemIdValue cookie;
1849     wxTreeItemId next = treAccounts->GetRootItem();
1850     wxTreeItemId nextChild;
1851     
1852     for (int i = 0; i < prefaccounts.GetCount(); i++){
1853         
1854         if (!nextChild){
1855             nextChild = treAccounts->GetFirstChild(next, cookie);
1856         } else {
1857             nextChild = treAccounts->GetNextSibling(nextChild);
1858         }
1859         
1860         //AccountName = treAccounts->GetItemText(nextChild);
1861         
1862         if (uc->ContactAccount == AccountAccDirList[i]){
1863             
1864             //AccControl->();
1865             treAccounts->SelectItem(nextChild, TRUE);
1866             AccCtrl->SetText(treAccounts->GetItemText(nextChild));
1867             
1868         }
1869         
1870     }
1871     
1872     // Switch the contact to the one passed.
1873     
1874     long longSelected = -1;
1875     int intSelectedData = 0;
1876     
1877     for (;;){
1878         
1879         longSelected = lstContacts->GetNextItem(longSelected,
1880                                                 wxLIST_NEXT_ALL,
1881                                                 wxLIST_STATE_DONTCARE);
1882         
1883         if (longSelected == -1){
1884             
1885             break;
1886             
1887         }
1888         
1889         intSelectedData = (int)lstContacts->GetItemData(longSelected);
1890         
1891         // Compare the filename with the one received.
1892         // If they match then select it.
1893         
1894         if (ContactsFileIndex[intSelectedData] == uc->ContactFilename){
1895             
1896             // Select.
1897             
1898             lstContacts->SetItemState(longSelected, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
1899             lstContacts->EnsureVisible(longSelected);
1900             
1901         } else {
1902         
1903             lstContacts->SetItemState(longSelected, 0, wxLIST_STATE_SELECTED);
1904         
1905         }
1906         
1907     }
1908     
1911 void frmMain::DeleteContact(wxCommandEvent& event){
1912     
1913     // Check if a contact is selected.
1914     
1915     long intSelected = -1;
1916     long intContactSeekNum = -1;
1917     wxString wxSContactName;
1918     
1919     intSelected = lstContacts->GetNextItem(intSelected,
1920                                            wxLIST_NEXT_ALL,
1921                                            wxLIST_STATE_SELECTED);
1922     
1923     if (intSelected == -1){
1924         return;
1925     }
1926     
1927     frmActivityMgr *frameActMgr = static_cast<frmActivityMgr*>(ActMgrPtr);
1928     
1929     // Get the item data of the contact.
1930     
1931     intContactSeekNum = lstContacts->GetItemData(intSelected);
1932     
1933     // Get the name of the contact.
1934     
1935     wxSContactName = lstContacts->GetItemText(intSelected);
1936     
1937     // Display a message confirming if the contact should
1938     // be deleted.
1939     
1940     int QuestionResponse;
1941     
1942     QuestionResponse = wxMessageBox(_("Are you sure you want to delete this contact?"), _("Delete contact"), wxYES_NO, this);
1943     
1944     if (QuestionResponse == wxNO){
1945         
1946         // Exit the subroutine
1947         
1948         return;
1949         
1950     }
1951     
1952     // Delete the contact.
1953     
1954     if (!wxRemoveFile(ContactsFileIndex[intContactSeekNum])){
1955         
1956         wxMessageBox(_("Unable to delete the contact."), _("Cannot delete contact"), wxOK, this);
1957         return;
1958         
1959     }
1960     
1961     // Remove the contact from the list.
1962     
1963     lstContacts->DeleteItem(intSelected);
1964     
1965     // Update the search windows, removing the deleted
1966     // contact.
1967     
1968     UCNotif *ucd = new UCNotif;
1969     
1970     ucd->ContactAccount = ActiveAccount;
1971     ucd->ContactFilename = ContactsFileIndex[intContactSeekNum];
1972     
1973     for (std::map<void*,wxString>::iterator switer = SearchWindowList.begin();
1974          switer != SearchWindowList.end(); switer++){
1975         
1976         // Duplicate the event notification data.
1977         
1978         UCNotif *ucd2 = new UCNotif;
1979         
1980         ucd2->ContactAccount = ucd->ContactAccount;
1981         ucd2->ContactFilename = ucd->ContactFilename;
1982         
1983         // Pass the data to the search window for processing.
1984         
1985         frmSearch *frameSCH = static_cast<frmSearch*>(switer->first);
1986         wxCommandEvent schdelete(SE_DELETERESULT);
1987         schdelete.SetClientData(ucd2);
1988         wxPostEvent(frameSCH, schdelete);
1989         
1990         // Clear up the pointer prior to variable deletion.
1991         
1992         frameSCH = NULL;
1993         ucd2 = NULL;
1994         
1995     }
1996     
1997     // Clear the wxHTMLWindow.
1998     
1999     wxString EmptyPage = wxT("");
2000     
2001     htmContactData->SetPage(EmptyPage);
2002     
2003     wxStringTokenizer wSTFilename(ContactsFileIndex[intContactSeekNum], wxT("/"));
2004     
2005     wxString wxSplitFilename;
2006     wxString wxSDataURL;
2007     
2008     while(wSTFilename.HasMoreTokens()){
2009         
2010         wxSplitFilename = wSTFilename.GetNextToken();
2011         
2012     }
2013     
2014     if (ActiveAccountType == wxT("CardDAV") || ActiveAccountType == wxT("carddav")){
2015         
2016         // Update the ETagDB and mark it as deleted.
2017         
2018         ETagDB *ETagDBPtr = ETagProcTimer.GetPointer(ActiveAccount);
2019         
2020         ETagDBPtr->UpdateETag(wxSplitFilename, wxT("DELETED"));
2021         
2022         // Get the Data URL.
2023         
2024         wxTreeItemIdValue cookie;
2025         wxTreeItemId next = treAccounts->GetRootItem();
2026         
2027         wxTreeItemId selectedChild = treAccounts->GetSelection();
2028         wxTreeItemId nextChild;
2029         
2030         for (int i = 0; i < prefaccounts.GetCount(); i++){
2031             
2032             if (!nextChild){
2033                 nextChild = treAccounts->GetFirstChild(next, cookie);
2034             }
2035             else {
2036                 nextChild = treAccounts->GetNextSibling(nextChild);
2037             }
2038             
2039             if (nextChild == selectedChild){
2040                 wxSDataURL = prefaccounts.GetAccountDirPrefix(i) + wxT("/") + wxSplitFilename;
2041                 
2042             }
2043             
2044         }
2045         
2046         // Add task to the activity monitor to delete the contact.
2047         
2048         frameActMgr->AddTask(2, wxSContactName, ActiveAccount, wxSDataURL, wxSplitFilename, ContactsFileIndex[intContactSeekNum], wxT(""));
2049         
2050     }
2051     
2052     // Clear the variable. Don't delete as it will mess things up.
2053     
2054     ContactsFileIndex[intContactSeekNum] = wxT("");
2055     
2056     delete ucd;
2057     ucd = NULL;
2058     
2061 void frmMain::EmptyServerDialog(wxCommandEvent& event){
2062     
2063     QRNotif *qrn = (QRNotif *)event.GetClientData();
2064     
2065     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);
2066     
2067     if (QResponse == wxNO){
2068         
2069         return;
2070     
2071     }
2072     
2073     wxCommandEvent event2(ACTMGR_RESUMEPROC);
2074     event2.SetInt(*qrn->QResponse);
2075     event2.SetClientData(qrn->PausePtr);
2076     
2077     frmActivityMgr *frameActMgr = static_cast<frmActivityMgr*>(ActMgrPtr);
2078     
2079     wxPostEvent(frameActMgr, event2);
2080     
2083 void frmMain::DeleteContactSync(wxString &Account, wxString &Filename){
2084     
2085     // Remove the contact from the window after syncronising.
2086     
2087     // Check which account is currently active in the window.
2088     // If it is different from the one passed to this subroutine then
2089     // exit from the subroutine.
2090     
2091     if (Account != ActiveAccount){
2092         return;
2093     }
2094     
2095     long longSelected = -1;
2096     int intSelectedData = 0;
2097     
2098     for (;;){
2099         
2100         longSelected = lstContacts->GetNextItem(longSelected,
2101                                                 wxLIST_NEXT_ALL,
2102                                                 wxLIST_STATE_DONTCARE);
2103         
2104         if (longSelected == -1){
2105             
2106             break;
2107             
2108         }
2109         
2110         intSelectedData = (int)lstContacts->GetItemData(longSelected);
2111         
2112         // Compare the filename with the one received.
2113         // If they match then select it.
2114         
2115         if (ContactsFileIndex[intSelectedData] == Filename){
2116             
2117             // Remove the contact from the window.
2118             
2119             lstContacts->DeleteItem(intSelectedData);
2120             
2121             // Check if contact is the selected contact in the HTML window and
2122             // if it is then clear the window.
2123             
2124             if (ActiveFilename == Filename){
2125                 
2126                 wxString EmptyPage = wxT("");
2127                 htmContactData->SetPage(EmptyPage);
2128                 
2129             }
2130             
2131             break;
2132             
2133         }
2134         
2135     }
2136     
2141 void frmMain::SortFNLN( wxCommandEvent& event ) {
2142     
2143     wxTreeEvent NullEvent;
2144     SortMode = 1;
2145     LoadContactList(NullEvent);
2146     
2149 void frmMain::SortLNFN( wxCommandEvent& event ) {
2150     
2151     wxTreeEvent NullEvent;
2152     SortMode = 2;
2153     LoadContactList(NullEvent);
2154     
2157 void frmMain::SortNickname( wxCommandEvent& event ) {
2158     
2159     wxTreeEvent NullEvent;
2160     SortMode = 3;
2161     LoadContactList(NullEvent);
2162     
2165 void frmMain::SortDisplayAs( wxCommandEvent& event ) {
2166     
2167     wxTreeEvent NullEvent;
2168     SortMode = 4;
2169     LoadContactList(NullEvent);
2170     
2173 void frmMain::SortAscending( wxCommandEvent& event ) {
2174     
2175     wxTreeEvent NullEvent;
2176     AscendingMode = TRUE;
2177     LoadContactList(NullEvent);
2178     
2181 void frmMain::SortDescending( wxCommandEvent& event ) {
2182     
2183     wxTreeEvent NullEvent;
2184     AscendingMode = FALSE;
2185     LoadContactList(NullEvent);
2186     
2189 void frmMain::ToggleStatusBar( wxCommandEvent& event ) {
2190     
2191     if (stbBottom->IsShown() == TRUE){
2192         
2193         stbBottom->Hide();
2194         
2195     } else {
2196         
2197         stbBottom->Show();
2198         
2199     }
2200     
2201     this->Layout();
2202     
2205 void frmMain::ActivityIconStart( wxCommandEvent& event ){
2206     
2207     // Display the activity icon.
2208     
2209     imgActivityStatus->SetBitmap(*imgActIcon1);
2210     ActivityIconStatus = 0;
2211     
2214 void frmMain::ActivityIconShuffle( wxCommandEvent& event ){
2215     
2216     switch (ActivityIconStatus){
2217             
2218         case 0:
2219             imgActivityStatus->SetBitmap(*imgActIcon1);
2220             ActivityIconStatus = 1;
2221             break;
2222         case 1:
2223             imgActivityStatus->SetBitmap(*imgActIcon2);
2224             ActivityIconStatus = 2;
2225             break;
2226         case 2:
2227             imgActivityStatus->SetBitmap(*imgActIcon3);
2228             ActivityIconStatus = 3;
2229             break;
2230         case 3:
2231             imgActivityStatus->SetBitmap(*imgActIcon4);
2232             ActivityIconStatus = 0;
2233             break;
2234         default:
2235             ActivityIconStatus = 0;
2236             
2237     }
2238     
2241 void frmMain::ActivityIconStop( wxCommandEvent& event ){
2242     
2243     // Display the sleep icon.
2244     
2245     imgActivityStatus->SetBitmap(*imgActIconSleep);
2246     
2249 void frmMain::UpdateSBIconPlacement( wxSizeEvent& event ){
2250     
2251     if (imgConnStatus == 0 || imgSSLStatus == 0 || imgActivityStatus == 0){
2252         
2253         return;
2254         
2255     }
2256     
2257     wxRect rectOnline;
2258     wxRect rectSSL;
2259     wxRect rectActivity;
2260     stbBottom->GetFieldRect(1, rectOnline);
2261     stbBottom->GetFieldRect(2, rectSSL);
2262     stbBottom->GetFieldRect(3, rectActivity);
2263     
2264     imgConnStatus->Move(rectOnline.GetX(),rectOnline.GetY());
2265     imgSSLStatus->Move(rectSSL.GetX(),rectSSL.GetY());
2266     imgActivityStatus->Move(rectActivity.GetX(),rectActivity.GetY());
2267     
2270 XABViewMode frmMain::GetViewMode(){
2271     
2272     XABViewMode xvm;
2273     
2274     xvm.SortMode = SortMode;
2275     xvm.AscendingMode = AscendingMode;
2276     
2277     return xvm;
2278     
2281 void frmMain::WindowAdd( wxCommandEvent &event ){
2282     
2283     WindowData *WData = (WindowData*)event.GetClientData();
2284     
2285     size_t pos;
2286     
2287     if (WData->DataType == 0){
2288         
2289         // Contact Window
2290         
2291         int intID = mnuContactWindows->GetId();
2292         
2293         mnuWindow->FindChildItem(intID, &pos);
2294         wxMenuItem *mnuNewItem = new wxMenuItem(NULL, WData->WindowID, wxT("Contact Window #") + wxString::Format(wxT("%i"), WData->WindowID), wxEmptyString, wxITEM_NORMAL, NULL);
2295         mnuNewItem->SetId(WData->WindowID);
2296         WindowListPointersMenu.insert(std::make_pair(WData->WindowID, mnuNewItem));
2297         WindowListPointers.insert(std::make_pair(WData->WindowID, WData->WindowPointer));
2298         WindowListType.insert(std::make_pair(WData->WindowID, 0));
2299         mnuWindow->Insert((pos + 1), mnuNewItem);
2300         this->Connect(mnuNewItem->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(frmMain::ShowContactWindow));
2301         
2302     } else if (WData->DataType == 1){
2303         
2304         // Contact Editor Window
2305         
2306         int intID = mnuContactEditorWindows->GetId();
2307         
2308         mnuWindow->FindChildItem(intID, &pos);
2309         wxMenuItem *mnuNewItem = new wxMenuItem(NULL, WData->WindowID, wxT("Contact Editor Window #") + wxString::Format(wxT("%i"), WData->WindowID), wxEmptyString, wxITEM_NORMAL, NULL);
2310         mnuNewItem->SetId(WData->WindowID);
2311         WindowListPointersMenu.insert(std::make_pair(WData->WindowID, mnuNewItem));
2312         WindowListPointers.insert(std::make_pair(WData->WindowID, WData->WindowPointer));
2313         WindowListType.insert(std::make_pair(WData->WindowID, 1));
2314         mnuWindow->Insert((pos + 1), mnuNewItem);
2315         this->Connect(mnuNewItem->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(frmMain::ShowContactEditorWindow));
2316         
2317     } else if (WData->DataType == 2){
2318         
2319         // Search Window
2320         
2321         int intID = mnuSearchWindows->GetId();
2322         
2323         mnuWindow->FindChildItem(intID, &pos);
2324         wxMenuItem *mnuNewItem = new wxMenuItem(NULL, WData->WindowID, wxT("Search Window #") + wxString::Format(wxT("%i"), WData->WindowID), wxEmptyString, wxITEM_NORMAL, NULL);
2325         mnuNewItem->SetId(WData->WindowID);
2326         WindowListPointersMenu.insert(std::make_pair(WData->WindowID, mnuNewItem));
2327         WindowListPointers.insert(std::make_pair(WData->WindowID, WData->WindowPointer));
2328         WindowListType.insert(std::make_pair(WData->WindowID, 2));
2329         mnuWindow->Insert((pos + 1), mnuNewItem);
2330         this->Connect(mnuNewItem->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(frmMain::ShowSearchWindow));
2331         
2332     }
2333     
2334     delete WData;
2335     WData = NULL;
2336     
2339 void frmMain::WindowEdit( wxCommandEvent &event ){
2340     
2341     WindowData *WData = (WindowData*)event.GetClientData();
2342     
2343     if (WData->DataType == 0){
2344         
2345         // Get the window title and use that.
2346         
2347         frmContact *frmContactPtr = static_cast<frmContact*>(WData->WindowPointer);
2348         
2349         wxString WindowTitle = frmContactPtr->GetTitle();
2350         
2351         std::map<int, wxMenuItem*>::iterator MenuIter = WindowListPointersMenu.find(WData->WindowID);
2352         
2353         MenuIter->second->SetItemLabel(WindowTitle);
2354                 
2355     } else if (WData->DataType == 1){
2356         
2357         // Get the window title and use that.
2358         
2359         frmContactEditor *frmCEPtr = static_cast<frmContactEditor*>(WData->WindowPointer);
2360         
2361         wxString WindowTitle = frmCEPtr->GetTitle();
2362         
2363         std::map<int, wxMenuItem*>::iterator MenuIter = WindowListPointersMenu.find(WData->WindowID);
2364         
2365         if (WindowTitle.IsEmpty()){
2366             
2367             MenuIter->second->SetItemLabel(_("Unnamed Contact"));
2368             
2369         } else {
2370             
2371             MenuIter->second->SetItemLabel(WindowTitle);
2372             
2373         }
2374         
2375     }
2376     
2377     delete WData;
2378     WData = NULL;
2379     
2382 void frmMain::WindowDelete( wxCommandEvent &event ){
2383     
2384     WindowData *WData = (WindowData*)event.GetClientData();
2385     
2386     std::map<int, wxMenuItem*>::iterator MenuIter = WindowListPointersMenu.find(WData->WindowID);
2387     
2388     mnuWindow->Remove(MenuIter->second);
2389     
2390     delete MenuIter->second;
2391     MenuIter->second = NULL;
2392     
2393     WindowListPointersMenu.erase(WData->WindowID);
2394     WindowListPointers.erase(WData->WindowID);
2395     WindowListType.erase(WData->WindowID);
2396     
2397     delete WData;
2398     WData = NULL;
2399     
2402 void frmMain::ShowContactWindow( wxCommandEvent &event ){
2403     
2404     std::map<int, void*>::iterator WindowIter = WindowListPointers.find(event.GetId());
2405     
2406     frmContact *frmContactPtr = static_cast<frmContact*>(WindowIter->second);
2407     
2408     frmContactPtr->Show();
2409     frmContactPtr->Raise();
2410     
2413 void frmMain::ShowContactEditorWindow( wxCommandEvent &event ){
2414     
2415     std::map<int, void*>::iterator WindowIter = WindowListPointers.find(event.GetId());
2416     
2417     frmContactEditor *frmCEPtr = static_cast<frmContactEditor*>(WindowIter->second);
2418     
2419     frmCEPtr->Show();
2420     frmCEPtr->Raise();
2421     
2424 void frmMain::ShowSearchWindow( wxCommandEvent &event ){
2425     
2426     // Look through the Search Window List Pointers, grab the
2427     // window point and show the window.
2428     
2429     std::map<int, void*>::iterator WindowIter = WindowListPointers.find(event.GetId());
2430     
2431     frmSearch *frmSearchPtr = static_cast<frmSearch*>(WindowIter->second);
2432     
2433     frmSearchPtr->Show();
2434     frmSearchPtr->Raise();
2435     
2438 void frmMain::ToggleConnectionStatus( wxCommandEvent &event ){
2439     
2440     frmActivityMgr *frameActMgr = static_cast<frmActivityMgr*>(ActMgrPtr);
2441     wxCommandEvent toggconn(ACTMGR_TOGGLECONN);
2442     wxPostEvent(frameActMgr, toggconn);
2443     
2446 void frmMain::ShowSSLCertificates( wxCommandEvent &event ){
2447     
2448     // Check the account type before continuing.
2449     
2450     wxString SeekAccount;
2451     wxString AccTypeLower;
2452     wxString AccType;
2453     bool AccountSSL;
2454     std::map<int, SSLCertCollection>::iterator SSLColIter;
2455     
2456     for (int i = 0; i < prefaccounts.GetCount(); i++){
2457         
2458         SeekAccount.Append(prefaccounts.GetAccountDirectory(i));
2459         AccType.Append(prefaccounts.GetAccountType(i));
2460         AccountSSL = prefaccounts.GetAccountSSL(i);
2461         AccTypeLower = AccType.MakeLower();
2462         SeekAccount.Append(wxT("."));
2463         SeekAccount.Append(AccTypeLower);
2464         
2465         if (SeekAccount == ActiveAccount){
2466             
2467             if (AccTypeLower == wxT("local")){
2468                 
2469                 return;
2470                 
2471             }
2472             
2473             if (AccountSSL == false){
2474                 
2475                 return;
2476                 
2477             }
2478             
2479             SSLColIter = AccountSSLData.find(i);
2480             
2481             SSLCertCollection SSLCertInfo = SSLColIter->second;
2482             
2483             frmSSLCertificate *frameSSLCert = new frmSSLCertificate ( this );
2484             frameSSLCert->StartCertFrom(0);
2485             frameSSLCert->SetupCerts(SSLCertInfo);
2486             frameSSLCert->ShowModal();
2487             
2488             delete frameSSLCert;
2489             frameSSLCert = NULL;
2490             
2491         }
2492         
2493         SeekAccount.Clear();
2494         AccTypeLower.Clear();
2495         AccType.clear();
2496         
2497     }
2498     
2501 void frmMain::ShowSSLInfo( wxCommandEvent &event ){
2502     
2503     // Check the account type before continuing.
2504     
2507 void frmMain::HideSSLInfo( wxCommandEvent &event ){
2508     
2509     // Check the account type before continuing.
2510     
2513 void frmMain::UpdateConnectionStatus( wxCommandEvent &event ){
2514     
2515     if (event.GetInt() == 0){
2516         
2517         imgConnStatus->SetBitmap(*imgOnline);
2518         
2519     } else {
2520         
2521         imgConnStatus->SetBitmap(*imgOffline);
2522         
2523     }   
2524     
2527 void frmMain::SetupSSLStatus( int AccountID ){
2528     
2529     // Check if account ID given is
2530     // the active account and if not, do nothing.
2531     
2532     wxString AccType;
2533     wxString AccTypeLower;
2534     
2535     AccType = prefaccounts.GetAccountType(AccountID);
2536     AccTypeLower = AccType.MakeLower();
2537     
2538     wxString AccountIDName = prefaccounts.GetAccountDirectory(AccountID) + wxT(".") +
2539                                 AccTypeLower;
2540     
2541     if (AccountIDName != ActiveAccount){
2542         
2543         return;
2544         
2545     }
2546     
2547     // Check if the account has SSL enabled.
2548     
2549     bool SSLInUse = prefaccounts.GetAccountSSL(AccountID);
2550     
2551     if (SSLInUse == FALSE){
2552         
2553         SSLToolTip->SetTip(wxT("SSL is not enabled for this account"));
2554         imgSSLStatus->SetBitmap(*imgNoSSL);
2555         
2556     } else {
2557         
2558         // Get the SSL Collection Data.
2559         
2560         std::map<int,int>::iterator SSLResultIter = AccountSSLResult.find(AccountID);
2561         
2562         if (SSLResultIter->second == 1){
2563             
2564             imgSSLStatus->SetBitmap(*imgSSLWarning);
2565             SSLToolTip->SetTip(wxT("Invalid certificate(s) received for '") + 
2566                                prefaccounts.GetAccountName(AccountID) +
2567                                wxT("' (Connection denied by user)\n\nDouble click for more information."));
2568             
2569             
2570         } else if (SSLResultIter->second == 0){
2571             
2572             imgSSLStatus->SetBitmap(*imgSSL);
2573             SSLToolTip->SetTip(wxT("Account '") + 
2574                                prefaccounts.GetAccountName(AccountID) +
2575                                wxT("' secured using SSL\n\nDouble click for more information."));
2576             
2577         }
2578         
2579     }
2580     
2583 void frmMain::InvalidSSLCertificate( wxCommandEvent &event ){
2584     
2585     frmInvalidSSLCertificate *frameISC = new frmInvalidSSLCertificate ( this );
2586     SSLInvalidCertNotifObj *SSLICNObj = (SSLInvalidCertNotifObj*)event.GetClientData();
2587     SSLCertCollection SSLCCData = SSLICNObj->CertCollection;
2588     wxString AccountName = SSLICNObj->AccountName;
2589     frameISC->LoadData(SSLCCData, AccountName);
2590     frameISC->ShowModal();
2591     
2592     int FinalConflictResult = frameISC->GetResult();
2593     
2594     wxCommandEvent event2(ACTMGR_RESUMEPROC);
2595     event2.SetClientData(SSLICNObj->QRNotifData);
2596     event2.SetInt(FinalConflictResult);
2597     
2598     delete frameISC;
2599     frameISC = NULL;
2600     
2601     frmActivityMgr *frameActMgr = static_cast<frmActivityMgr*>(ActMgrPtr);      
2602     wxPostEvent(frameActMgr, event2);
2605 void frmMain::PauseAllTimers(){
2606     
2607     for (std::map<wxString, wxAccountSyncTimer*>::iterator ASTiter = AccountSyncTimers.begin(); 
2608          ASTiter != AccountSyncTimers.end(); ASTiter++){
2609         
2610         ASTiter->second->Stop();
2611         
2612     }
2613     
2616 void frmMain::ResumeAllTimers(){
2617     
2618     for (std::map<wxString, wxAccountSyncTimer*>::iterator ASTiter = AccountSyncTimers.begin(); 
2619          ASTiter != AccountSyncTimers.end(); ASTiter++){
2620         
2621         ASTiter->second->Start();
2622         
2623     }
2624     
2627 void frmMain::UpdateSSLAccountStatus(int AccountID, int SSLStatus, SSLCertCollection SSLCertInc){
2628     
2629     // Delete existing data.
2630     
2631     AccountSSLData.erase(AccountID);
2632     AccountSSLResult.erase(AccountID);
2633     
2634     // Insert new data.
2635     
2636     AccountSSLData.insert(std::make_pair(AccountID, SSLCertInc));
2637     AccountSSLResult.insert(std::make_pair(AccountID, SSLStatus));
2638     
2641 void frmMain::CheckUpdates( wxCommandEvent& event ){
2642     
2643     frmUpdate *frameUpdate = new frmUpdate ( this );
2644     frameUpdate->FetchData();
2645     frameUpdate->ShowModal();
2646     
2649 void frmMain::OpenImportDialog( wxCommandEvent& event ){
2650     
2651     // Run the import contacts system.
2652     
2653     ImportRun(this);
2654     
2657 void frmMain::OpenExportDialog( wxCommandEvent& event ){
2658     
2659     // Check if an account and at least one contact is selected
2660     // before continuing.
2661     
2662     wxArrayString ArrData;
2663     
2664     if (ActiveAccount.IsEmpty()){
2665         
2666         return;
2667         
2668     }
2669     
2670     int ContactSelected = 0;
2671     int ContactsCollected = 0;
2672     long longSelected = -1;
2673     
2674     for (;;){
2675         
2676         longSelected = lstContacts->GetNextItem(longSelected, 
2677                                                 wxLIST_NEXT_ALL,
2678                                                 wxLIST_STATE_SELECTED);
2679         
2680         if (longSelected == -1){
2681             
2682             break;
2683             
2684         }
2685         
2686         int FileID = (int)lstContacts->GetItemData(longSelected);
2687         
2688         ArrData.Insert(ContactsFileIndex[FileID],
2689                        ContactsCollected, 1);
2690         
2691         ContactSelected++;
2692         
2693     }
2694     
2695     if (ContactSelected == 0){
2696         
2697         return;
2698         
2699     }
2700     
2701     // Run the export contacts system.
2702     
2703     ExportRun(this, &ArrData);
2704     
2707 void frmMain::GetListControl(wxListCtrl *lstContactsPtr, 
2708                              wxArrayString *ContactsFileIndexPtr){
2709     
2710     lstContactsPtr = lstContacts;
2711     ContactsFileIndexPtr = &ContactsFileIndex;
2712     
2715 void frmMain::GetSelectedList( wxCommandEvent& event ){
2716     
2717     // Get the array of contact filenames. 
2718     
2719     wxArrayString *ArrData = (wxArrayString*)event.GetClientData();
2720     
2721     // Process them into an array of files.     
2722     
2723     long longSelected = -1;
2724     int ContactsCollected = 0;
2725     wxString ContactFilename;
2726     
2727     for (;;){
2728         
2729         longSelected = lstContacts->GetNextItem(longSelected, 
2730                                                 wxLIST_NEXT_ALL,
2731                                                 wxLIST_STATE_SELECTED);
2732         
2733         if (longSelected == -1){
2734             
2735             break;
2736             
2737         }
2738         
2739         // Get the file information and add to the list.
2740         
2741         int FileID = (int)lstContacts->GetItemData(longSelected);
2742         
2743         ArrData->Insert(ContactsFileIndex[FileID],
2744                         ContactsCollected, 1);
2745         
2746         ContactsCollected++;
2747         ContactFilename.Clear();        
2748         
2749     }
2750     
2751     event.SetInt(1);
2752     
2755 void frmMain::SyncAccount( wxCommandEvent& event ){
2756     
2757     wxString AccNameInc = event.GetString();
2758     
2759     frmActivityMgr *frameActMgr = static_cast<frmActivityMgr*>(ActMgrPtr);
2760     frameActMgr->AddTask(3, wxT(""), AccNameInc, 
2761                          wxT(""), wxT(""), wxT(""), wxT(""));
2762     
2765 void frmMain::ShowHelp( wxCommandEvent& event ){
2766     
2767     // Based on the operating system, work out where 
2768     // the documentation should be.
2769     
2770     //#ifdef __APPLE__
2771     
2772 #if defined(__HAIKU__)
2773     
2774 #elif defined(__WIN32__)
2775     
2776     
2777     
2778 #else
2779     
2780     if (wxFileExists("/usr/share/doc/xestiaab/index.html")){
2781         
2782         wxLaunchDefaultBrowser(wxT("file:///usr/share/doc/xestiaab/index.html"));
2783         return;
2784         
2785 #if XSDAB_RELEASE == 0
2786         
2787     } else if (wxFileExists("/usr/local/share/doc/xestiaab/index.html")){
2788         
2789         wxLaunchDefaultBrowser(wxT("file:///usr/local/share/doc/xestiaab/index.html"));
2790         return;
2791         
2792 #endif 
2793         
2794     }
2795     
2796 #endif
2797     
2798 #if XSDAB_RELEASE == 0
2799     
2800     wxMessageBox(_("The help documentation is not available.\n\nYou can view the documentation that came with your source package."), _("Help documentation missing!"));
2801     
2802 #else
2803     
2804     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!"));
2805     
2806 #endif
2807     
2810 void frmMain::ShowImportResults( wxCommandEvent &event ){
2812         std::map<int,wxString> *ResultData = (std::map<int,wxString>*)event.GetClientData();
2814         frmImportResults *frmIR = new frmImportResults(this);
2815         frmIR->LoadData(ResultData, event.GetInt(), (int)event.GetExtraLong());
2816         frmIR->ShowModal();
2817                 
2818         delete frmIR;
2819         frmIR = NULL;
2820         
2821         delete ResultData;
2822         ResultData = NULL;
2826 void frmMain::ReloadContactList( wxCommandEvent &event ){
2828         // Check if the account name given is the current
2829         // account selected.
2831         if (ActiveAccount == event.GetString()){
2832         
2833                 wxTreeEvent NullEvent;
2834                 LoadContactList(NullEvent);
2835         
2836         }
2840 void frmMain::ShowContactMenu( wxMouseEvent& event ){
2842         bool EnableRefresh = FALSE;
2844         if (!ActiveAccount.IsEmpty()){
2846                 EnableRefresh = TRUE;
2847         
2848         }
2850         ContactMenu->SetupPointers(this, lstContacts, EnableRefresh);
2852         this->PopupMenu(ContactMenu->MenuPointer(), wxDefaultPosition);
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