Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Removed comments from ShowContactInfo 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 vcardfilenamewxs;
647     wxString vCardFilename;
648     wxString vCardFilenameFull;
649     wxString vCardDataString;
650     wxStringTokenizer vcardfileline;
651     wxString lwxs;
652     wxString setname, setvalue;
653     //vCardNames = new std::map<wxString, wxString, std::greater<wxString>>;
654     std::multimap<wxString, wxString, std::greater<wxString>> vCardNamesAsc;
655     std::multimap<wxString, wxString, std::less<wxString>> vCardNamesDsc;
656     long ContactIndex = 1;
657     long ContactSeekPoint = 0;
658     
659     wxDir vcardaccdir(AccountDirFinal);
660     
661     // Get the wxTreeItemId and image icon and compare it to the list.
662     
663     if (ActiveItemIcon == AccountGrpID){
664         
665         // It's a group so load the file containing the group and
666         // get the members of the group.
667         
668         vCard Group;
669         wxString UIDCode;
670         
671         std::multimap<wxTreeItemId, int>::iterator AGTiter = AccountGroupTreeId.find(ActiveItemId);
672         std::multimap<int, wxString>::iterator AGFiter = AccountGroupFilename.find(AGTiter->second);
673         //std::multimap<wxTreeItemId, int>::iterator AGFiter = AccountGroupTreeId.find(ActiveItemId);
674         
675         Group.LoadFile(AGFiter->second);
676         
677         ArrayvCardOutData vCardMember = Group.GetByPartial(wxT("MEMBER"));
678         
679         for (int i = 0; i < vCardMember.PropCount; i++){
680             
681             vCardMember.PropValues[i].Trim();
682             if (vCardMember.PropValues[i].Left(9) == wxT("urn:uuid:")){
683                 
684                 wxString NewPropValue;
685                 NewPropValue = vCardMember.PropValues[i].Mid(9, wxString::npos);
686                 vCardMember.PropValues[i] = NewPropValue;
687                 
688             }
689             
690             
691         }
692         
693         bool ProcFiles = vcardaccdir.GetFirst(&vCardFilename, wxEmptyString, wxDIR_FILES);
694         while(ProcFiles){
695             
696             if (vCardFilename.Right(4) == wxT(".vcf") ||
697                 vCardFilename.Right(4) == wxT(".VCF") ||
698                 vCardFilename.Right(5) == wxT(".vcard") ||
699                 vCardFilename.Right(5) == wxT(".VCARD")){
700                 
701                 vCard Person;
702                 bool FoundMember = FALSE;
703                 
704                 vCardFilenameFull.Append(AccountDirFinal);
705                 vCardFilenameFull.Append(wxT("/"));
706                 vCardFilenameFull.Append(vCardFilename);
707                 
708                 Person.LoadFile(vCardFilenameFull);
709                 
710                 UIDCode = Person.Get(wxT("UID"));
711                 
712                 for (int i = 0; i < vCardMember.PropCount; i++){
713                     
714                     if (vCardMember.PropValues[i] == UIDCode){
715                         
716                         FoundMember = TRUE;
717                         
718                     }
719                     
720                 }
721                 
722                 if (FoundMember == FALSE){
723                     
724                     vCardFilename.Clear();
725                     vCardFilenameFull.Clear();
726                     vCardDataString.Clear();
727                     ProcFiles = vcardaccdir.GetNext(&vCardFilename);
728                     continue;
729                     
730                 }
731                 
732                 if (Person.MeetBaseSpecification()){
733                     
734                     if (SortMode == 1){
735                         
736                         // Split the name into sections.
737                         
738                         vCardDataString = Person.Get(wxT("N"));
739                         
740                         vCardName NameData = Person.GetName();
741                         
742                         vCardDataString = NameData.Forename + wxT(" ") + NameData.Surname;
743                         
744                     } else if (SortMode == 2){
745                         
746                         // Split the name into sections.
747                         
748                         vCardName NameData = Person.GetName();
749                         
750                         vCardDataString = NameData.Surname + wxT(", ") + NameData.Forename;
751                         
752                     } else if (SortMode == 3){
753                         
754                         // Check and make sure that the top most nickname is used.
755                         
756                         vCardDataString = Person.Get(wxT("NICKNAME"));
757                         
758                         if (vCardDataString.IsEmpty()){
759                             
760                             vCardDataString = wxT("(no nickname)");
761                             
762                         }
763                         
764                     } else if (SortMode == 4){
765                         
766                         vCardDataString = Person.Get(wxT("FN"));
767                         
768                     }
769                     
770                     if (AscendingMode == TRUE){
771                         vCardNamesAsc.insert(std::make_pair(vCardDataString, vCardFilenameFull));
772                     } else {
773                         vCardNamesDsc.insert(std::make_pair(vCardDataString, vCardFilenameFull));
774                     }
775                     
776                 } else {
777                     
778                 }
779                 
780             }
781             
782             vCardFilename.Clear();
783             vCardFilenameFull.Clear();
784             vCardDataString.Clear();
785             ProcFiles = vcardaccdir.GetNext(&vCardFilename);
786         }
787         
788     } else {
789         
790         bool ProcFiles = vcardaccdir.GetFirst(&vCardFilename, wxEmptyString, wxDIR_FILES);
791         while(ProcFiles){
792             
793             if (vCardFilename.Right(4) == wxT(".vcf") ||
794                 vCardFilename.Right(4) == wxT(".VCF") ||
795                 vCardFilename.Right(5) == wxT(".vcard") ||
796                 vCardFilename.Right(5) == wxT(".VCARD")){
797                 
798                 vCard Person;
799                 
800                 vCardFilenameFull.Append(AccountDirFinal);
801                 vCardFilenameFull.Append(vCardFilename);
802                 
803                 Person.LoadFile(vCardFilenameFull);
804                 
805                 if (Person.MeetBaseSpecification()){
806                     
807                     if (SortMode == 1){
808                         
809                         // Split the name into sections.
810                         
811                         vCardDataString = Person.Get(wxT("N"));
812                         
813                         vCardName NameData = Person.GetName();
814                         
815                         vCardDataString = NameData.Forename + wxT(" ") + NameData.Surname;
816                         
817                     } else if (SortMode == 2){
818                         
819                         // Split the name into sections.
820                         
821                         vCardName NameData = Person.GetName();
822                         
823                         vCardDataString = NameData.Surname + wxT(", ") + NameData.Forename;
824                         
825                     } else if (SortMode == 3){
826                         
827                         // Check and make sure that the top most nickname is used.
828                         
829                         vCardDataString = Person.Get(wxT("NICKNAME"));
830                         
831                         if (vCardDataString.IsEmpty()){
832                             
833                             vCardDataString = wxT("(no nickname)");
834                             
835                         }
836                         
837                     } else if (SortMode == 4){
838                         
839                         vCardDataString = Person.Get(wxT("FN"));
840                         
841                     }
842                     
843                     if (AscendingMode == TRUE){
844                         vCardNamesAsc.insert(std::make_pair(vCardDataString, vCardFilenameFull));
845                     } else {
846                         vCardNamesDsc.insert(std::make_pair(vCardDataString, vCardFilenameFull));
847                     }
848                     
849                 } else {
850                     
851                 }
852                 
853             }
854             
855             vCardFilename.Clear();
856             vCardFilenameFull.Clear();
857             vCardDataString.Clear();
858             ProcFiles = vcardaccdir.GetNext(&vCardFilename);
859         }
860         
861     }
862     
863     // Sort the data.
864     
865     // Insert the data into the control.
866     
867     if (AscendingMode == TRUE){
868         for (std::map<wxString, wxString>::iterator iter = vCardNamesAsc.begin();
869              iter != vCardNamesAsc.end(); ++iter){
870             
871             wxListItem ContactInfo;
872             
873             ContactInfo.SetId(0);
874             ContactInfo.SetText(_("Mooo"));
875             ContactInfo.SetData(ContactSeekPoint);
876             ContactIndex = lstContacts->InsertItem(ContactInfo);
877             
878             lstContacts->SetItem(ContactIndex, 0, iter->first);
879             ContactsFileIndex.Insert(iter->second, ContactSeekPoint);
880             ContactSeekPoint++;
881             
882         }
883         
884     } else {
885         
886         for (std::map<wxString, wxString>::iterator iter = vCardNamesDsc.begin();
887              iter != vCardNamesDsc.end(); ++iter){
888             
889             wxListItem ContactInfo;
890             
891             ContactInfo.SetId(0);
892             ContactInfo.SetText(_("Mooo"));
893             ContactInfo.SetData(ContactSeekPoint);
894             ContactIndex = lstContacts->InsertItem(ContactInfo);
895             
896             lstContacts->SetItem(ContactIndex, 0, iter->first);
897             ContactsFileIndex.Insert(iter->second, ContactSeekPoint);
898             ContactSeekPoint++;
899             
900         }
901         
902     }
903     
906 void frmMain::ShowContactInfo( wxListEvent& event )
908     
909     long intSelected = -1;
910     long ContactSeekNum = -1;
911     
912     // Check if several contacts have been selected.
913     
914     int ContactTotal = 0;
915     
916     for (;;){
917         
918         intSelected = lstContacts->GetNextItem(intSelected,
919                                                wxLIST_NEXT_ALL,
920                                                wxLIST_STATE_SELECTED);
921         
922         if (intSelected == -1){
923             
924             break;
925             
926         }
927         
928         ContactTotal++;
929         
930     }
931     
932     if (ContactTotal == 0){
933         htmContactData->SetPage(wxT(""));
934         return;
935     }
936     
937     if (ContactTotal > 1){
938         
939         htmContactData->SetPage(wxString::Format(wxT("%i contacts selected."), ContactTotal));
940         ActiveFilename.Clear();
941         return;
942         
943     }
944     
945     intSelected = lstContacts->GetNextItem(intSelected,
946                                            wxLIST_NEXT_ALL,
947                                            wxLIST_STATE_SELECTED);
948     
949     ContactSeekNum = lstContacts->GetItemData(intSelected);
950     
951     wxFFile ContactFile;
952     wxString wxSContactString;
953     wxString ContactLine;
954     vCard Person;
955     
956     size_t ContactLineLen;
957     bool ExtraLineSeek = FALSE;
958     int QuoteBreakPoint = 0;
959     
960     bool PropertyFind = FALSE;
961     bool QuoteMode = FALSE;
962     
963     wxString wxSPropertyNextLine;
964     wxString wxSProperty;
965     wxString wxSPropertySeg1;
966     wxString wxSPropertySeg2;
967     
968     // Check if we are using wxWidgets version 2.8 or less and
969     // execute the required command accordingly.
970     
971 #if wxABI_VERSION < 20900
972     ContactFile.Open(ContactsFileIndex[ContactSeekNum].c_str(), wxT("r"));
973 #else
974     ContactFile.Open(ContactsFileIndex[ContactSeekNum], wxT("r"));
975 #endif
976     
977     if (ContactFile.IsOpened() == FALSE){
978         
979         return;
980         
981     }
982     
983     ContactFile.ReadAll(&wxSContactString, wxConvAuto());
984     
985     // Split the lines.
986     
987     std::map<int, wxString> ContactFileLines;
988     std::map<int, wxString>::iterator striter;
989     
990     wxStringTokenizer wSTContactFileLines(wxSContactString, wxT("\r\n"));
991     
992     int ContactLineSeek = 0;
993     
994     while (wSTContactFileLines.HasMoreTokens() == TRUE){
995         
996         ContactLine = wSTContactFileLines.GetNextToken();
997         ContactFileLines.insert(std::make_pair(ContactLineSeek, ContactLine));
998         ContactLineSeek++;
999         
1000     }
1001     
1002     if (ContactSeekNum < 0){
1003         return;
1004     }
1005     
1006     for (std::map<int, wxString>::iterator iter = ContactFileLines.begin();
1007          iter != ContactFileLines.end(); ++iter){
1008         
1009         // Find the colon which splits the start bit from the data part.
1010         
1011         ContactLine = iter->second;
1012         
1013         while (ExtraLineSeek == TRUE){
1014             
1015             // Check if there is extra data on the next line
1016             // (indicated by space or tab at the start) and add data.
1017             
1018             iter++;
1019             
1020             if (iter == ContactFileLines.end()){
1021                 
1022                 iter--;
1023                 break;
1024                 
1025             }
1026             
1027             wxSPropertyNextLine = iter->second;
1028             
1029             
1030             if (wxSPropertyNextLine.Mid(0, 1) == wxT(" ") || wxSPropertyNextLine.Mid(0, 1) == wxT("\t")){
1031                 
1032                 wxSPropertyNextLine.Remove(0, 1);
1033                 ContactLine.Append(wxSPropertyNextLine);
1034                 
1035             } else {
1036                 
1037                 iter--;
1038                 ExtraLineSeek = FALSE;
1039                 
1040             }
1041             
1042         }
1043         
1044         ContactLineLen = ContactLine.Len();
1045         
1046         // Make sure we are not in quotation mode.
1047         // Make sure colon does not have \ or \\ before it.
1048         
1049         for (int i = 0; i <= ContactLineLen; i++){
1050             
1051             if ((ContactLine.Mid(i, 1) == wxT(";") || ContactLine.Mid(i, 1) == wxT(":")) && PropertyFind == TRUE){
1052                 
1053                 PropertyFind = FALSE;
1054                 
1055             } else if (PropertyFind == TRUE){
1056                 
1057                 wxSProperty.Append(ContactLine.Mid(i, 1));
1058                 
1059             }
1060             
1061             if (ContactLine.Mid(i, 1) == wxT("\"")){
1062                 
1063                 if (QuoteMode == TRUE){
1064                     
1065                     QuoteMode = FALSE;
1066                     
1067                 } else {
1068                     
1069                     QuoteMode = TRUE;
1070                     
1071                 }
1072                 
1073             }
1074             
1075             if (ContactLine.Mid(i, 1) == wxT(":") && ContactLine.Mid((i - 1), 1) != wxT("\\") && QuoteMode == FALSE){
1076                 
1077                 QuoteBreakPoint = i;
1078                 break;
1079                 
1080             }
1081             
1082         }
1083         
1084         // Split that line at the point into two variables (ignore the colon).
1085         
1086         wxSPropertySeg1 = ContactLine.Mid(0, QuoteBreakPoint);
1087         wxSPropertySeg2 = ContactLine.Mid((QuoteBreakPoint + 1));
1088         
1089         // Insert both into the vCard data file.
1090         
1091         Person.AddRaw(wxSPropertySeg1, wxSPropertySeg2);
1092         
1093         QuoteMode = FALSE;
1094         PropertyFind = TRUE;
1095         ExtraLineSeek = TRUE;
1096         ContactLineLen = 0;
1097         QuoteBreakPoint = 0;
1098         ContactLine.Clear();
1099         wxSProperty.Clear();
1100         
1101     }
1102     
1103     OldSessionID = SessionID;
1104     SessionID = wxString::Format(wxT("%i"), rand() % 32768);
1105     LoadContactData(&Person, htmContactData, SessionID, OldSessionID, &MemoryFileList);
1106     ActiveFilename = ContactsFileIndex[ContactSeekNum];
1107     
1110 void frmMain::ShowContactEditorNew( wxCommandEvent& event )
1112     
1113     // Check if there is an account selected and if not
1114     // return immediately.
1115     
1116     if (ActiveAccount.IsEmpty()){
1117         
1118         return;
1119         
1120     }
1121     
1122     // Add Pointer to SetupPointers for the ETagDB.
1123     
1124     wxMemoryInputStream istream(bigimgs_contactpersonicon48_png, sizeof(bigimgs_contactpersonicon48_png));
1125     wxImage bigimgs_contactpersonicon48i(istream, wxBITMAP_TYPE_PNG);
1126     wxBitmap contacticonbmp(bigimgs_contactpersonicon48i, -1);
1127     wxIcon contacticon;
1128     contacticon.CopyFromBitmap(contacticonbmp);
1129     
1130     frmContactEditor *ContactEditor = new frmContactEditor( this );
1131     
1132     WindowMenuItemID++;
1133     
1134     ContactEditor->SetUID(WindowMenuItemID);
1135     
1136     WindowData *WData = new WindowData;
1137     
1138     WData->DataType = 1;
1139     WData->WindowPointer = (void*)ContactEditor;
1140     WData->WindowID = WindowMenuItemID;
1141     
1142     wxCommandEvent addevent(WINDOW_ADD);
1143     addevent.SetClientData(WData);
1144     wxPostEvent(this, addevent);
1145     
1146     frmActivityMgr *frameActMgr = static_cast<frmActivityMgr*>(ActMgrPtr);
1147     ContactEditor->SetupHeaders();
1148     ContactEditor->SetupContact(ActiveAccount);
1149     ContactEditor->SetIcon(contacticon);
1150     ContactEditor->SetupPointers(frameActMgr, &ETagProcTimer, this);
1151     ContactEditor->Show(true);
1152     
1155 void frmMain::ShowContactEditorEdit( wxCommandEvent& event )
1157     
1158     // Check if there is an account selected and if not
1159     // return immediately.
1160     
1161     int DataCheck = event.GetInt();
1162     
1163     if (ActiveAccount.IsEmpty() && DataCheck == 0){
1164         
1165         return;
1166         
1167     }
1168     
1169     wxMemoryInputStream istream(bigimgs_contactpersonicon48_png, sizeof(bigimgs_contactpersonicon48_png));
1170     wxImage bigimgs_contactpersonicon48i(istream, wxBITMAP_TYPE_PNG);
1171     wxBitmap contacticonbmp(bigimgs_contactpersonicon48i, -1);
1172     wxIcon contacticon;
1173     contacticon.CopyFromBitmap(contacticonbmp);
1174     
1175     // Check if a contact has been selected.
1176     
1177     long intSelected = -1;
1178     long intContactSeekNum = -1;
1179         
1180     intSelected = lstContacts->GetNextItem(intSelected,
1181                                            wxLIST_NEXT_ALL,
1182                                            wxLIST_STATE_SELECTED);
1183     
1184     if (intSelected == -1){
1185         return;
1186     }
1187     
1188     intContactSeekNum = lstContacts->GetItemData(intSelected);
1189     
1190     // Get the filename of the selected contact.
1191     
1192     frmActivityMgr *frameActMgr = static_cast<frmActivityMgr*>(ActMgrPtr);
1193     frmContactEditor *ContactEditor = new frmContactEditor( this );
1194     
1195     WindowMenuItemID++;
1196     
1197     ContactEditor->SetUID(WindowMenuItemID);
1198     
1199     WindowData *WData = new WindowData;
1200     
1201     WData->DataType = 1;
1202     WData->WindowPointer = (void*)ContactEditor;
1203     WData->WindowID = WindowMenuItemID;
1204     
1205     wxCommandEvent addevent(WINDOW_ADD);
1206     addevent.SetClientData(WData);
1207     wxPostEvent(this, addevent);
1208     
1209     ContactEditor->SetupPointers(frameActMgr, &ETagProcTimer, this);
1210     ContactEditor->SetupHeaders();
1211     
1212     // Check if pointer is NULL (not from the search forms) or not.
1213     
1214     if (DataCheck == 0){
1215         
1216         ContactEditor->LoadContact(ContactsFileIndex[intContactSeekNum]);
1217         ContactEditor->SetupContact(ActiveAccount);
1218         
1219     } else {
1220         
1221         UCNotif *uc = (UCNotif*)event.GetClientData();
1222         
1223         if (!uc){
1224             
1225             ContactEditor->SetupContact(ActiveAccount);
1226             ContactEditor->LoadContact(ContactsFileIndex[intContactSeekNum]);
1227             
1228         } else {
1229             
1230             ContactEditor->SetupContact(uc->ContactAccount);
1231             ContactEditor->LoadContact(uc->ContactFilename);
1232             
1233             delete uc;
1234             uc = NULL;
1235             
1236             
1237         }
1238         
1239     }
1240     
1241     ContactEditor->SetIcon(contacticon);
1242     ContactEditor->Show(true);
1243     
1246 void frmMain::RefreshAddressBook( wxCommandEvent& event ){
1247    
1248     // Check if ActiveAccount is empty. If not then check if
1249     // account type is not local otherwise continue.
1250     
1251     if (!ActiveAccount.IsEmpty()){
1252    
1253         if (ActiveAccountType != wxT("Local")){
1254         
1255                 // Account type is not local.
1256         
1257                 frmActivityMgr *frameActMgr = static_cast<frmActivityMgr*>(ActMgrPtr);
1258                 frameActMgr->AddTask(3, wxT(""), ActiveAccount,
1259                                      wxT(""), wxT(""), wxT(""), wxT(""));
1260         
1261         } else {
1262         
1263                 wxMessageBox(_("The refresh address book command is not supported with this type of account."), wxT("Not supported for this type of account"));
1264         
1265         }
1266         
1267     }
1268     
1271 void frmMain::OpenContactInfoList( wxListEvent& event )
1273     
1274     wxStringTokenizer vcardfileline;
1275     std::string l;
1276     wxString lwxs;
1277     wxString setname, setvalue;
1278     vCard Person;
1279     wxString nextchar;
1280     
1281     long intSelected = -1;
1282     long intContactSeekNum = -1;
1283     
1284     intSelected = lstContacts->GetNextItem(intSelected,
1285                                            wxLIST_NEXT_ALL,
1286                                            wxLIST_STATE_SELECTED);
1287     
1288     intContactSeekNum = lstContacts->GetItemData(intSelected);
1289     
1290     if (intContactSeekNum == -1){
1291         return;
1292     }
1293     
1294     Person.LoadFile(ContactsFileIndex[intContactSeekNum]);
1295     
1296     wxMemoryInputStream istream(bigimgs_contactpersonicon48_png, sizeof(bigimgs_contactpersonicon48_png));
1297     wxImage bigimgs_contactpersonicon48i(istream, wxBITMAP_TYPE_PNG);
1298     wxBitmap contacticonbmp(bigimgs_contactpersonicon48i, -1);
1299     wxIcon contacticon;
1300     contacticon.CopyFromBitmap(contacticonbmp);
1301     
1302     frmContact *Contact = new frmContact( this );
1303     
1304     // Add to window list.
1305     
1306     WindowMenuItemID++;
1307     
1308     Contact->SetUID(WindowMenuItemID);
1309     
1310     WindowData *WData = new WindowData;
1311     
1312     WData->DataType = 0;
1313     WData->WindowPointer = (void*)Contact;
1314     WData->WindowID = WindowMenuItemID;
1315     
1316     wxCommandEvent addevent(WINDOW_ADD);
1317     addevent.SetClientData(WData);
1318     wxPostEvent(this, addevent);
1319     
1320     Contact->SetupPointers(&MemoryFileList);
1321     Contact->SetupContactData(&Person);
1322     
1323     Contact->SetIcon(contacticon);
1324     Contact->Show(true);
1325     
1328 void frmMain::OpenContactInfoList( wxCommandEvent& event ){
1330         wxListEvent pevent;
1331         OpenContactInfoList(pevent);
1335 void frmMain::OpenContactInfo( wxCommandEvent& event )
1337     
1338     UCNotif *uc = (UCNotif*)event.GetClientData();
1339     
1340     wxStringTokenizer vcardfileline;
1341     std::string l;
1342     wxString lwxs;
1343     wxString setname, setvalue;
1344     vCard Person;
1345     wxString nextchar;
1346     
1347     Person.LoadFile(uc->ContactFilename);
1348     
1349     wxMemoryInputStream istream(bigimgs_contactpersonicon48_png, sizeof(bigimgs_contactpersonicon48_png));
1350     wxImage bigimgs_contactpersonicon48i(istream, wxBITMAP_TYPE_PNG);
1351     wxBitmap contacticonbmp(bigimgs_contactpersonicon48i, -1);
1352     wxIcon contacticon;
1353     contacticon.CopyFromBitmap(contacticonbmp);
1354     
1355     frmContact *Contact = new frmContact( this );
1356     
1357     // Add to window list.
1358     
1359     WindowMenuItemID++;
1360     
1361     Contact->SetUID(WindowMenuItemID);
1362     
1363     WindowData *WData = new WindowData;
1364     
1365     WData->DataType = 0;
1366     WData->WindowPointer = (void*)Contact;
1367     WData->WindowID = WindowMenuItemID;
1368     
1369     wxCommandEvent addevent(WINDOW_ADD);
1370     addevent.SetClientData(WData);
1371     wxPostEvent(this, addevent);
1372     
1373     Contact->SetupPointers(&MemoryFileList);
1374     Contact->SetupContactData(&Person);
1375     
1376     Contact->SetIcon(contacticon);
1377     Contact->Show(true);
1378     
1382 void frmMain::LoadPreferences( wxActivateEvent& event)
1384     this->LoadPreferences();
1387 void frmMain::LoadPreferences(){
1388     
1389     // Load the preferences.
1390     
1391     wxString preffilename = GetUserPrefDir();
1392     
1393     XABPreferences preferences(preffilename);
1394     
1395     // Setup the main window position (if needed).
1396     
1397     bool SaveWindowPos = preferences.GetBoolData(wxT("SaveWindowPosition"));
1398     bool HideLocalABs = preferences.GetBoolData(wxT("HideLocalAddressBooks"));
1399     
1400     if (SaveWindowPos == TRUE){
1401         
1402         this->SetSize(preferences.GetMainWindowData());
1403         
1404     }
1405     
1406     treAccounts->DeleteAllItems();
1407     
1408     wxTreeItemId RootNode = treAccounts->AddRoot(wxT("Root Item"), AccountNoneID);
1409     
1410     // Stop all account timers and remove the accounts.
1411     
1412     for (std::map<wxString, wxAccountSyncTimer*>::iterator iter = AccountSyncTimers.begin();
1413          iter != AccountSyncTimers.end(); iter++){
1414         
1415         wxAccountSyncTimer *AccTmrPtr = iter->second;
1416         AccTmrPtr->Stop();
1417         
1418         delete AccTmrPtr;
1419         AccTmrPtr = NULL;
1420         
1421     }
1422     
1423     AccountSyncTimers.clear();
1424     
1425     wxString AccDir;
1426     wxString AccDirFull;
1427     wxString AccDirFullSfx;
1428     wxString AccName;
1429     wxString AccDirFinal;
1430     AccountAccDirList.clear();
1431     AccountGroupList.clear();
1432     AccountGroupFilename.clear();
1433     AccountGroupTreeId.clear();
1434     wxTreeItemId AccountTreeId;
1435     wxTreeItemId GroupTreeId;
1436     int intGroupID = 0;
1437     
1438     for (int i = 0; i < preferences.accounts.GetCount(); i++){
1439         
1440         if ((preferences.accounts.GetAccountType(i) == wxT("Local") ||
1441              preferences.accounts.GetAccountType(i) == wxT("local")) && HideLocalABs == TRUE){
1442             
1443             continue;
1444             
1445         }
1446         
1447         if (preferences.accounts.GetAccountDirectory(i).IsEmpty()){
1448             
1449             continue;
1450             
1451         }
1452         
1453         AccDir = preferences.accounts.GetAccountDirectory(i);
1454         AccDirFull = preferences.accounts.GetAccountDirectory(i);
1455         AccDirFull.Trim();
1456         AccDirFull.Append(wxT("."));
1457         AccDirFullSfx.Append(preferences.accounts.GetAccountType(i));
1458         AccDirFullSfx.LowerCase();
1459         AccDirFullSfx.Trim();
1460         AccDirFull.Append(AccDirFullSfx);
1461         AccName = preferences.accounts.GetAccountName(i);
1462         AccName.Trim();
1463         AccountAccDirList.insert(std::make_pair(i, AccDirFull));
1464         
1465         if (preferences.accounts.GetAccountType(i) == wxT("CardDAV") ||
1466             preferences.accounts.GetAccountType(i) == wxT("carddav")){
1467             
1468             // TODO: Check if the directory exists before doing anything.
1469             
1470             
1471             
1472             // Add a new timer using the existing account details.
1473             
1474             wxAccountSyncTimer *ActTmrPtr = new wxAccountSyncTimer;
1475             
1476             ActTmrPtr->SetupData(AccDirFull, AccName);
1477             ActTmrPtr->SetupPointers(this, ActMgrPtr, ETagProcTimer.GetPointer(AccDirFull));
1478             ActTmrPtr->Start((int)(preferences.accounts.GetAccountRefresh(i) * 1000));
1479             ActTmrPtr->SetOwner(this);
1480             ActTmrPtr->Notify();
1481             
1482             // Add the timer to the list of timers.
1483             
1484             AccountSyncTimers.insert(std::make_pair(AccDirFull, ActTmrPtr));
1485             
1486             AccountTreeId = treAccounts->AppendItem(RootNode, preferences.accounts.GetAccountName(i), AccountNetID, -1);
1487             
1488         } else {
1489             
1490             AccountTreeId = treAccounts->AppendItem(RootNode, preferences.accounts.GetAccountName(i), AccountID, -1);
1491             
1492         }
1493         
1494         // Go through the account directory and find contact files with
1495         // 'KIND:group' set and add them to the list of groups for the account.
1496         
1497         AccDirFinal = GetAccountDir(AccDirFull, FALSE);
1498         
1499         wxDir vcardaccdir(AccDirFinal);
1500         
1501         wxString vCardFilename;
1502         wxString vCardDataString;
1503         wxString vCardFilenameFull;
1505         bool ProcFiles = vcardaccdir.GetFirst(&vCardFilename, wxEmptyString, wxDIR_FILES);
1506         while(ProcFiles){
1507             
1508             if (vCardFilename.Right(4) == wxT(".vcf") ||
1509                 vCardFilename.Right(4) == wxT(".VCF") ||
1510                 vCardFilename.Right(5) == wxT(".vcard") ||
1511                 vCardFilename.Right(5) == wxT(".VCARD")){
1512                 
1513                 vCard Person;
1514                 
1515                 vCardFilenameFull.Append(AccDirFinal);
1516                 vCardFilenameFull.Append(wxT("/"));
1517                 vCardFilenameFull.Append(vCardFilename);
1518                 
1519                 Person.LoadFile(vCardFilenameFull);
1520                 
1521                 if (Person.MeetBaseSpecification()){
1522                     
1523                     vCardDataString = Person.Get(wxT("KIND"));
1524                     
1525                     if (vCardDataString == wxT("group")){
1526                         
1527                         // The vCard kind is a group. Add to the account's group list.
1528                         
1529                         GroupTreeId = treAccounts->AppendItem(AccountTreeId, Person.Get(wxT("FN")), AccountGrpID, -1);
1530                         treAccounts->SetItemHasChildren(AccountTreeId, TRUE);
1531                         AccountGroupList.insert(std::make_pair(intGroupID, i));
1532                         AccountGroupFilename.insert(std::make_pair(intGroupID, vCardFilenameFull));
1533                         AccountGroupTreeId.insert(std::make_pair(GroupTreeId, intGroupID));
1534                         
1535                     }
1536                     
1537                     intGroupID++;
1538                     
1539                 } else {
1540                     
1541                 }
1542                 
1543             }
1544             
1545             vCardFilename.Clear();
1546             vCardFilenameFull.Clear();
1547             vCardDataString.Clear();
1548             ProcFiles = vcardaccdir.GetNext(&vCardFilename);
1549             
1550         }
1551         
1552         // Clearup for next account.
1553         
1554         AccDir.clear();
1555         AccDirFull.clear();
1556         AccDirFullSfx.clear();
1557         AccDirFinal.clear();
1558         AccName.clear();
1559         
1560     }
1561     
1562     // Load the account settings as they are needed for connecting
1563     // to the servers.
1564     
1565     prefaccounts = preferences.accounts;
1566     
1569 void frmMain::ConflictResolution(wxCommandEvent& event){
1570     
1571     frmConflictResolution *frameCR = new frmConflictResolution ( this );
1572     vCardConflictObj *vCardConfObj = (vCardConflictObj*)event.GetClientData();
1573     vCard *ClientDataPtr = vCardConfObj->vCardLocalData;
1574     vCard *ServerDataPtr = vCardConfObj->vCardServerData;
1575     frameCR->LoadData(ClientDataPtr, ServerDataPtr, &MemoryFileList);
1576     frameCR->ShowModal();
1577     
1578     int FinalConflictResult = frameCR->GetResult();
1579     
1580     wxCommandEvent event2(ACTMGR_RESUMEPROC);
1581     event2.SetClientData(vCardConfObj->QRNotifData);
1582     event2.SetInt(FinalConflictResult);
1583     
1584     delete frameCR;
1585     frameCR = NULL;
1586     
1587     frmActivityMgr *frameActMgr = static_cast<frmActivityMgr*>(ActMgrPtr);
1588     wxPostEvent(frameActMgr, event2);
1589     
1592 void frmMain::UpdateContactList(wxCommandEvent& event){
1593     
1594     UCNotif *ucd = (UCNotif*)event.GetClientData();
1595     
1596     // Check if the active account is being displayed in the
1597     // main window. If not, skip and delete the data.
1598     
1599     long longSelected = -1;
1600     int intSelectedData = 0;
1601     
1602     if (ActiveAccount == ucd->ContactAccount){
1603         
1604         // Look at the list of contacts and if it matches the
1605         // filename then update the name.
1606         
1607         for (;;){
1608             
1609             longSelected = lstContacts->GetNextItem(longSelected,
1610                                                     wxLIST_NEXT_ALL,
1611                                                     wxLIST_STATE_DONTCARE);
1612             
1613             if (longSelected == -1){
1614                 
1615                 break;
1616                 
1617             }
1618             
1619             intSelectedData = (int)lstContacts->GetItemData(longSelected);
1620             
1621             if (ucd->ContactFilename == ContactsFileIndex[intSelectedData]){
1622                 
1623                 // Work out which sorting mode we are in.
1624                 
1625                 if (SortMode == 1){
1626                     
1627                     // First Name, Last Name.
1628                     
1629                     lstContacts->SetItem(longSelected, 0, ucd->ContactNameArray.Forename + wxT(" ") + ucd->ContactNameArray.Surname);
1630                     
1631                 } else if (SortMode == 2){
1632                     
1633                     // Last Name, First Name.
1634                     
1635                     lstContacts->SetItem(longSelected, 0, ucd->ContactNameArray.Surname + wxT(", ") + ucd->ContactNameArray.Forename);
1636                     
1637                 } else if (SortMode == 3){
1638                     
1639                     // Nickname.
1640                     
1641                     lstContacts->SetItem(longSelected, 0, ucd->ContactNickname);
1642                     
1643                 } else if (SortMode == 4){
1644                     
1645                     // Display As.
1646                     
1647                     lstContacts->SetItem(longSelected, 0, ucd->ContactName);
1648                     
1649                 }
1650                 
1651                 
1652             }
1653             
1654             // If the filename is the one loaded into the
1655             // browser control, then update this too.
1656             
1657             if (ActiveFilename == ContactsFileIndex[intSelectedData]){
1658                 
1659                 wxListEvent nullevent;
1660                 ShowContactInfo(nullevent);
1661                 
1662             }
1663             
1664         }
1665         
1666     }
1667     
1668     for (std::map<int, void*>::iterator WindowIter = WindowListPointers.begin();
1669          WindowIter != WindowListPointers.end(); WindowIter++){
1670         
1671         if (WindowListType[WindowIter->first] != 0){
1672             
1673             continue;
1674             
1675         }
1676         
1677         frmContact *frmContactPtr = static_cast<frmContact*>(WindowIter->second);
1678         
1679         if (frmContactPtr->GetFilename() == ucd->ContactFilename){
1680             
1681             vCard UpdatedPerson;
1682             UpdatedPerson.LoadFile(ucd->ContactFilename);
1683             frmContactPtr->SetupContactData(&UpdatedPerson);
1684             
1685         }
1686         
1687     }
1688     
1689     // Send message to search window controller subroutine and
1690     // pass that notification onto the search windows.
1691     
1692     // Setup the new pointer to use the existing UCNotif without
1693     // deleting it.
1694     
1695     UCNotif *ucd2 = ucd;
1696     
1697     wxCommandEvent sup(SE_UPDATECONTACTNOTIF);
1698     sup.SetClientData(ucd2);
1699     wxPostEvent(this, sup);
1700     
1701     // Clear up the unused pointer.
1702     
1703     ucd = NULL;
1704     
1707 void frmMain::UpdateAccountList(wxCommandEvent& event){
1708     
1711 void frmMain::SetupPointers(void *ActMgrPtrInc){
1712     
1713     ActMgrPtr = ActMgrPtrInc;
1714     
1717 void frmMain::SetupForm(){
1718     
1719     frmActivityMgr *frameActMgr = static_cast<frmActivityMgr*>(ActMgrPtr);
1720     frameActMgr->SetupPointers(&ETagProcTimer, this);
1721     
1722     // Setup the contact information icons for later.
1723     
1724     wxFileSystem::AddHandler(new wxMemoryFSHandler);
1725     wxImage ciicon_png;
1726     //wxBitmap ciicon;
1727     
1728     wxMemoryInputStream ciptostream(icons_cipto_png, sizeof(icons_cipto_png));
1729     ciicon_png.LoadFile(ciptostream, wxBITMAP_TYPE_PNG);
1730     wxMemoryFSHandler::AddFile(wxT("cipto.png"), ciicon_png, wxBITMAP_TYPE_PNG);
1731     
1732     wxMemoryInputStream cilogstream(icons_cilog_png, sizeof(icons_cilog_png));
1733     ciicon_png.LoadFile(cilogstream, wxBITMAP_TYPE_PNG);
1734     wxMemoryFSHandler::AddFile(wxT("cilog.png"), ciicon_png, wxBITMAP_TYPE_PNG);
1735     
1736     wxMemoryInputStream cisndstream(icons_cisnd_png, sizeof(icons_cisnd_png));
1737     ciicon_png.LoadFile(cisndstream, wxBITMAP_TYPE_PNG);
1738     wxMemoryFSHandler::AddFile(wxT("cisnd.png"), ciicon_png, wxBITMAP_TYPE_PNG);
1739     
1740     wxMemoryInputStream cikeystream(icons_cikey_png, sizeof(icons_cikey_png));
1741     ciicon_png.LoadFile(cikeystream, wxBITMAP_TYPE_PNG);
1742     wxMemoryFSHandler::AddFile(wxT("cikey.png"), ciicon_png, wxBITMAP_TYPE_PNG);
1743     
1744     wxMemoryInputStream civenstream(icons_civen_png, sizeof(icons_civen_png));
1745     ciicon_png.LoadFile(civenstream, wxBITMAP_TYPE_PNG);
1746     wxMemoryFSHandler::AddFile(wxT("civen.png"), ciicon_png, wxBITMAP_TYPE_PNG);
1747     
1748     wxMemoryInputStream ciextstream(icons_ciext_png, sizeof(icons_ciext_png));
1749     ciicon_png.LoadFile(ciextstream, wxBITMAP_TYPE_PNG);
1750     wxMemoryFSHandler::AddFile(wxT("ciext.png"), ciicon_png, wxBITMAP_TYPE_PNG);
1751     
1752     LoadPreferences();
1753     
1756 void frmMain::UpdateSearchContactLists(wxCommandEvent& event){
1757     
1758     // Go through each of the search windows and
1759     // send the required notification to update the
1760     // contact information.
1761     
1762     // Get the event notification data.
1763     
1764     UCNotif *ucd = (UCNotif*)event.GetClientData();
1765     
1766     // Process each search window giving the new details.
1767     
1768     for (std::map<void*,wxString>::iterator switer = SearchWindowList.begin();
1769          switer != SearchWindowList.end(); switer++){
1770         
1771         // Duplicate the event notification data.
1772         
1773         UCNotif *ucd2 = new UCNotif;
1774         
1775         ucd2->ContactAccount = ucd->ContactAccount;
1776         ucd2->ContactFilename = ucd->ContactFilename;
1777         ucd2->ContactName = ucd->ContactName;
1778         ucd2->ContactNickname = ucd->ContactNickname;
1779         ucd2->ContactNameArray = ucd->ContactNameArray;
1780         
1781         // Pass the data to the search window for processing.
1782         
1783         frmSearch *frameSCH = static_cast<frmSearch*>(switer->first);
1784         wxCommandEvent schupdate(SE_UPDATERESULT);
1785         schupdate.SetClientData(ucd2);
1786         wxPostEvent(frameSCH, schupdate);
1787         
1788         // Clear up the pointer prior to variable deletion.
1789         
1790         frameSCH = NULL;
1791         
1792     }
1793     
1794     delete ucd;
1795     ucd = NULL;
1796     
1799 void frmMain::OpenFindContactsWindow(wxCommandEvent& event){
1800     
1801     WindowMenuItemID++;
1802     
1803     frmSearch *frameSCH = new frmSearch ( this );
1804     frameSCH->SetUID(WindowMenuItemID);
1805     frameSCH->Show(true);
1806     
1807     WindowData *WData = new WindowData;
1808     
1809     WData->DataType = 2;
1810     WData->WindowPointer = (void*)frameSCH;
1811     WData->WindowID = WindowMenuItemID;
1812     
1813     wxCommandEvent addevent(WINDOW_ADD);
1814     addevent.SetClientData(WData);
1815     wxPostEvent(this, addevent);
1816     
1817     // Add pointer to the list of open search windows.
1818     
1819     SearchWindowList.insert(std::make_pair(frameSCH, wxT("Search")));
1820     
1821     WData = NULL;
1822     
1825 void frmMain::RemoveContactsWindowPointer(wxCommandEvent& event){
1826     
1827     void *frameSCH = (void*)event.GetClientData();
1828     
1829     SearchWindowList.erase(frameSCH);
1830     
1831     frameSCH = NULL;
1832     
1835 void frmMain::RemoveContactEditorWindowPointer(wxCommandEvent& event){
1836     
1837     void *frameSCH = (void*)event.GetClientData();
1838     
1839     SearchWindowList.erase(frameSCH);
1840     
1841     frameSCH = NULL;
1842     
1845 void frmMain::RevealContact(wxCommandEvent& event){
1846     
1847     UCNotif *uc = (UCNotif*)event.GetClientData();
1848     
1849     // Switch the account to the one passed.
1850     
1851     wxTreeItemIdValue cookie;
1852     wxTreeItemId next = treAccounts->GetRootItem();
1853     wxTreeItemId nextChild;
1854     
1855     for (int i = 0; i < prefaccounts.GetCount(); i++){
1856         
1857         if (!nextChild){
1858             nextChild = treAccounts->GetFirstChild(next, cookie);
1859         } else {
1860             nextChild = treAccounts->GetNextSibling(nextChild);
1861         }
1862         
1863         //AccountName = treAccounts->GetItemText(nextChild);
1864         
1865         if (uc->ContactAccount == AccountAccDirList[i]){
1866             
1867             //AccControl->();
1868             treAccounts->SelectItem(nextChild, TRUE);
1869             AccCtrl->SetText(treAccounts->GetItemText(nextChild));
1870             
1871         }
1872         
1873     }
1874     
1875     // Switch the contact to the one passed.
1876     
1877     long longSelected = -1;
1878     int intSelectedData = 0;
1879     
1880     for (;;){
1881         
1882         longSelected = lstContacts->GetNextItem(longSelected,
1883                                                 wxLIST_NEXT_ALL,
1884                                                 wxLIST_STATE_DONTCARE);
1885         
1886         if (longSelected == -1){
1887             
1888             break;
1889             
1890         }
1891         
1892         intSelectedData = (int)lstContacts->GetItemData(longSelected);
1893         
1894         // Compare the filename with the one received.
1895         // If they match then select it.
1896         
1897         if (ContactsFileIndex[intSelectedData] == uc->ContactFilename){
1898             
1899             // Select.
1900             
1901             lstContacts->SetItemState(longSelected, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
1902             lstContacts->EnsureVisible(longSelected);
1903             
1904         } else {
1905         
1906             lstContacts->SetItemState(longSelected, 0, wxLIST_STATE_SELECTED);
1907         
1908         }
1909         
1910     }
1911     
1914 void frmMain::DeleteContact(wxCommandEvent& event){
1915     
1916     // Check if a contact is selected.
1917     
1918     long intSelected = -1;
1919     long intContactSeekNum = -1;
1920     wxString wxSContactName;
1921     
1922     intSelected = lstContacts->GetNextItem(intSelected,
1923                                            wxLIST_NEXT_ALL,
1924                                            wxLIST_STATE_SELECTED);
1925     
1926     if (intSelected == -1){
1927         return;
1928     }
1929     
1930     frmActivityMgr *frameActMgr = static_cast<frmActivityMgr*>(ActMgrPtr);
1931     
1932     // Get the item data of the contact.
1933     
1934     intContactSeekNum = lstContacts->GetItemData(intSelected);
1935     
1936     // Get the name of the contact.
1937     
1938     wxSContactName = lstContacts->GetItemText(intSelected);
1939     
1940     // Display a message confirming if the contact should
1941     // be deleted.
1942     
1943     int QuestionResponse;
1944     
1945     QuestionResponse = wxMessageBox(_("Are you sure you want to delete this contact?"), _("Delete contact"), wxYES_NO, this);
1946     
1947     if (QuestionResponse == wxNO){
1948         
1949         // Exit the subroutine
1950         
1951         return;
1952         
1953     }
1954     
1955     // Delete the contact.
1956     
1957     if (!wxRemoveFile(ContactsFileIndex[intContactSeekNum])){
1958         
1959         wxMessageBox(_("Unable to delete the contact."), _("Cannot delete contact"), wxOK, this);
1960         return;
1961         
1962     }
1963     
1964     // Remove the contact from the list.
1965     
1966     lstContacts->DeleteItem(intSelected);
1967     
1968     // Update the search windows, removing the deleted
1969     // contact.
1970     
1971     UCNotif *ucd = new UCNotif;
1972     
1973     ucd->ContactAccount = ActiveAccount;
1974     ucd->ContactFilename = ContactsFileIndex[intContactSeekNum];
1975     
1976     for (std::map<void*,wxString>::iterator switer = SearchWindowList.begin();
1977          switer != SearchWindowList.end(); switer++){
1978         
1979         // Duplicate the event notification data.
1980         
1981         UCNotif *ucd2 = new UCNotif;
1982         
1983         ucd2->ContactAccount = ucd->ContactAccount;
1984         ucd2->ContactFilename = ucd->ContactFilename;
1985         
1986         // Pass the data to the search window for processing.
1987         
1988         frmSearch *frameSCH = static_cast<frmSearch*>(switer->first);
1989         wxCommandEvent schdelete(SE_DELETERESULT);
1990         schdelete.SetClientData(ucd2);
1991         wxPostEvent(frameSCH, schdelete);
1992         
1993         // Clear up the pointer prior to variable deletion.
1994         
1995         frameSCH = NULL;
1996         ucd2 = NULL;
1997         
1998     }
1999     
2000     // Clear the wxHTMLWindow.
2001     
2002     wxString EmptyPage = wxT("");
2003     
2004     htmContactData->SetPage(EmptyPage);
2005     
2006     wxStringTokenizer wSTFilename(ContactsFileIndex[intContactSeekNum], wxT("/"));
2007     
2008     wxString wxSplitFilename;
2009     wxString wxSDataURL;
2010     
2011     while(wSTFilename.HasMoreTokens()){
2012         
2013         wxSplitFilename = wSTFilename.GetNextToken();
2014         
2015     }
2016     
2017     if (ActiveAccountType == wxT("CardDAV") || ActiveAccountType == wxT("carddav")){
2018         
2019         // Update the ETagDB and mark it as deleted.
2020         
2021         ETagDB *ETagDBPtr = ETagProcTimer.GetPointer(ActiveAccount);
2022         
2023         ETagDBPtr->UpdateETag(wxSplitFilename, wxT("DELETED"));
2024         
2025         // Get the Data URL.
2026         
2027         wxTreeItemIdValue cookie;
2028         wxTreeItemId next = treAccounts->GetRootItem();
2029         
2030         wxTreeItemId selectedChild = treAccounts->GetSelection();
2031         wxTreeItemId nextChild;
2032         
2033         for (int i = 0; i < prefaccounts.GetCount(); i++){
2034             
2035             if (!nextChild){
2036                 nextChild = treAccounts->GetFirstChild(next, cookie);
2037             }
2038             else {
2039                 nextChild = treAccounts->GetNextSibling(nextChild);
2040             }
2041             
2042             if (nextChild == selectedChild){
2043                 wxSDataURL = prefaccounts.GetAccountDirPrefix(i) + wxT("/") + wxSplitFilename;
2044                 
2045             }
2046             
2047         }
2048         
2049         // Add task to the activity monitor to delete the contact.
2050         
2051         frameActMgr->AddTask(2, wxSContactName, ActiveAccount, wxSDataURL, wxSplitFilename, ContactsFileIndex[intContactSeekNum], wxT(""));
2052         
2053     }
2054     
2055     // Clear the variable. Don't delete as it will mess things up.
2056     
2057     ContactsFileIndex[intContactSeekNum] = wxT("");
2058     
2059     delete ucd;
2060     ucd = NULL;
2061     
2064 void frmMain::EmptyServerDialog(wxCommandEvent& event){
2065     
2066     QRNotif *qrn = (QRNotif *)event.GetClientData();
2067     
2068     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);
2069     
2070     if (QResponse == wxNO){
2071         
2072         return;
2073     
2074     }
2075     
2076     wxCommandEvent event2(ACTMGR_RESUMEPROC);
2077     event2.SetInt(*qrn->QResponse);
2078     event2.SetClientData(qrn->PausePtr);
2079     
2080     frmActivityMgr *frameActMgr = static_cast<frmActivityMgr*>(ActMgrPtr);
2081     
2082     wxPostEvent(frameActMgr, event2);
2083     
2086 void frmMain::DeleteContactSync(wxString &Account, wxString &Filename){
2087     
2088     // Remove the contact from the window after syncronising.
2089     
2090     // Check which account is currently active in the window.
2091     // If it is different from the one passed to this subroutine then
2092     // exit from the subroutine.
2093     
2094     if (Account != ActiveAccount){
2095         return;
2096     }
2097     
2098     long longSelected = -1;
2099     int intSelectedData = 0;
2100     
2101     for (;;){
2102         
2103         longSelected = lstContacts->GetNextItem(longSelected,
2104                                                 wxLIST_NEXT_ALL,
2105                                                 wxLIST_STATE_DONTCARE);
2106         
2107         if (longSelected == -1){
2108             
2109             break;
2110             
2111         }
2112         
2113         intSelectedData = (int)lstContacts->GetItemData(longSelected);
2114         
2115         // Compare the filename with the one received.
2116         // If they match then select it.
2117         
2118         if (ContactsFileIndex[intSelectedData] == Filename){
2119             
2120             // Remove the contact from the window.
2121             
2122             lstContacts->DeleteItem(intSelectedData);
2123             
2124             // Check if contact is the selected contact in the HTML window and
2125             // if it is then clear the window.
2126             
2127             if (ActiveFilename == Filename){
2128                 
2129                 wxString EmptyPage = wxT("");
2130                 htmContactData->SetPage(EmptyPage);
2131                 
2132             }
2133             
2134             break;
2135             
2136         }
2137         
2138     }
2139     
2144 void frmMain::SortFNLN( wxCommandEvent& event ) {
2145     
2146     wxTreeEvent NullEvent;
2147     SortMode = 1;
2148     LoadContactList(NullEvent);
2149     
2152 void frmMain::SortLNFN( wxCommandEvent& event ) {
2153     
2154     wxTreeEvent NullEvent;
2155     SortMode = 2;
2156     LoadContactList(NullEvent);
2157     
2160 void frmMain::SortNickname( wxCommandEvent& event ) {
2161     
2162     wxTreeEvent NullEvent;
2163     SortMode = 3;
2164     LoadContactList(NullEvent);
2165     
2168 void frmMain::SortDisplayAs( wxCommandEvent& event ) {
2169     
2170     wxTreeEvent NullEvent;
2171     SortMode = 4;
2172     LoadContactList(NullEvent);
2173     
2176 void frmMain::SortAscending( wxCommandEvent& event ) {
2177     
2178     wxTreeEvent NullEvent;
2179     AscendingMode = TRUE;
2180     LoadContactList(NullEvent);
2181     
2184 void frmMain::SortDescending( wxCommandEvent& event ) {
2185     
2186     wxTreeEvent NullEvent;
2187     AscendingMode = FALSE;
2188     LoadContactList(NullEvent);
2189     
2192 void frmMain::ToggleStatusBar( wxCommandEvent& event ) {
2193     
2194     if (stbBottom->IsShown() == TRUE){
2195         
2196         stbBottom->Hide();
2197         
2198     } else {
2199         
2200         stbBottom->Show();
2201         
2202     }
2203     
2204     this->Layout();
2205     
2208 void frmMain::ActivityIconStart( wxCommandEvent& event ){
2209     
2210     // Display the activity icon.
2211     
2212     imgActivityStatus->SetBitmap(*imgActIcon1);
2213     ActivityIconStatus = 0;
2214     
2217 void frmMain::ActivityIconShuffle( wxCommandEvent& event ){
2218     
2219     switch (ActivityIconStatus){
2220             
2221         case 0:
2222             imgActivityStatus->SetBitmap(*imgActIcon1);
2223             ActivityIconStatus = 1;
2224             break;
2225         case 1:
2226             imgActivityStatus->SetBitmap(*imgActIcon2);
2227             ActivityIconStatus = 2;
2228             break;
2229         case 2:
2230             imgActivityStatus->SetBitmap(*imgActIcon3);
2231             ActivityIconStatus = 3;
2232             break;
2233         case 3:
2234             imgActivityStatus->SetBitmap(*imgActIcon4);
2235             ActivityIconStatus = 0;
2236             break;
2237         default:
2238             ActivityIconStatus = 0;
2239             
2240     }
2241     
2244 void frmMain::ActivityIconStop( wxCommandEvent& event ){
2245     
2246     // Display the sleep icon.
2247     
2248     imgActivityStatus->SetBitmap(*imgActIconSleep);
2249     
2252 void frmMain::UpdateSBIconPlacement( wxSizeEvent& event ){
2253     
2254     if (imgConnStatus == 0 || imgSSLStatus == 0 || imgActivityStatus == 0){
2255         
2256         return;
2257         
2258     }
2259     
2260     wxRect rectOnline;
2261     wxRect rectSSL;
2262     wxRect rectActivity;
2263     stbBottom->GetFieldRect(1, rectOnline);
2264     stbBottom->GetFieldRect(2, rectSSL);
2265     stbBottom->GetFieldRect(3, rectActivity);
2266     
2267     imgConnStatus->Move(rectOnline.GetX(),rectOnline.GetY());
2268     imgSSLStatus->Move(rectSSL.GetX(),rectSSL.GetY());
2269     imgActivityStatus->Move(rectActivity.GetX(),rectActivity.GetY());
2270     
2273 XABViewMode frmMain::GetViewMode(){
2274     
2275     XABViewMode xvm;
2276     
2277     xvm.SortMode = SortMode;
2278     xvm.AscendingMode = AscendingMode;
2279     
2280     return xvm;
2281     
2284 void frmMain::WindowAdd( wxCommandEvent &event ){
2285     
2286     WindowData *WData = (WindowData*)event.GetClientData();
2287     
2288     size_t pos;
2289     
2290     if (WData->DataType == 0){
2291         
2292         // Contact Window
2293         
2294         int intID = mnuContactWindows->GetId();
2295         
2296         mnuWindow->FindChildItem(intID, &pos);
2297         wxMenuItem *mnuNewItem = new wxMenuItem(NULL, WData->WindowID, wxT("Contact Window #") + wxString::Format(wxT("%i"), WData->WindowID), wxEmptyString, wxITEM_NORMAL, NULL);
2298         mnuNewItem->SetId(WData->WindowID);
2299         WindowListPointersMenu.insert(std::make_pair(WData->WindowID, mnuNewItem));
2300         WindowListPointers.insert(std::make_pair(WData->WindowID, WData->WindowPointer));
2301         WindowListType.insert(std::make_pair(WData->WindowID, 0));
2302         mnuWindow->Insert((pos + 1), mnuNewItem);
2303         this->Connect(mnuNewItem->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(frmMain::ShowContactWindow));
2304         
2305     } else if (WData->DataType == 1){
2306         
2307         // Contact Editor Window
2308         
2309         int intID = mnuContactEditorWindows->GetId();
2310         
2311         mnuWindow->FindChildItem(intID, &pos);
2312         wxMenuItem *mnuNewItem = new wxMenuItem(NULL, WData->WindowID, wxT("Contact Editor Window #") + wxString::Format(wxT("%i"), WData->WindowID), wxEmptyString, wxITEM_NORMAL, NULL);
2313         mnuNewItem->SetId(WData->WindowID);
2314         WindowListPointersMenu.insert(std::make_pair(WData->WindowID, mnuNewItem));
2315         WindowListPointers.insert(std::make_pair(WData->WindowID, WData->WindowPointer));
2316         WindowListType.insert(std::make_pair(WData->WindowID, 1));
2317         mnuWindow->Insert((pos + 1), mnuNewItem);
2318         this->Connect(mnuNewItem->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(frmMain::ShowContactEditorWindow));
2319         
2320     } else if (WData->DataType == 2){
2321         
2322         // Search Window
2323         
2324         int intID = mnuSearchWindows->GetId();
2325         
2326         mnuWindow->FindChildItem(intID, &pos);
2327         wxMenuItem *mnuNewItem = new wxMenuItem(NULL, WData->WindowID, wxT("Search Window #") + wxString::Format(wxT("%i"), WData->WindowID), wxEmptyString, wxITEM_NORMAL, NULL);
2328         mnuNewItem->SetId(WData->WindowID);
2329         WindowListPointersMenu.insert(std::make_pair(WData->WindowID, mnuNewItem));
2330         WindowListPointers.insert(std::make_pair(WData->WindowID, WData->WindowPointer));
2331         WindowListType.insert(std::make_pair(WData->WindowID, 2));
2332         mnuWindow->Insert((pos + 1), mnuNewItem);
2333         this->Connect(mnuNewItem->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(frmMain::ShowSearchWindow));
2334         
2335     }
2336     
2337     delete WData;
2338     WData = NULL;
2339     
2342 void frmMain::WindowEdit( wxCommandEvent &event ){
2343     
2344     WindowData *WData = (WindowData*)event.GetClientData();
2345     
2346     if (WData->DataType == 0){
2347         
2348         // Get the window title and use that.
2349         
2350         frmContact *frmContactPtr = static_cast<frmContact*>(WData->WindowPointer);
2351         
2352         wxString WindowTitle = frmContactPtr->GetTitle();
2353         
2354         std::map<int, wxMenuItem*>::iterator MenuIter = WindowListPointersMenu.find(WData->WindowID);
2355         
2356         MenuIter->second->SetItemLabel(WindowTitle);
2357                 
2358     } else if (WData->DataType == 1){
2359         
2360         // Get the window title and use that.
2361         
2362         frmContactEditor *frmCEPtr = static_cast<frmContactEditor*>(WData->WindowPointer);
2363         
2364         wxString WindowTitle = frmCEPtr->GetTitle();
2365         
2366         std::map<int, wxMenuItem*>::iterator MenuIter = WindowListPointersMenu.find(WData->WindowID);
2367         
2368         if (WindowTitle.IsEmpty()){
2369             
2370             MenuIter->second->SetItemLabel(_("Unnamed Contact"));
2371             
2372         } else {
2373             
2374             MenuIter->second->SetItemLabel(WindowTitle);
2375             
2376         }
2377         
2378     }
2379     
2380     delete WData;
2381     WData = NULL;
2382     
2385 void frmMain::WindowDelete( wxCommandEvent &event ){
2386     
2387     WindowData *WData = (WindowData*)event.GetClientData();
2388     
2389     std::map<int, wxMenuItem*>::iterator MenuIter = WindowListPointersMenu.find(WData->WindowID);
2390     
2391     mnuWindow->Remove(MenuIter->second);
2392     
2393     delete MenuIter->second;
2394     MenuIter->second = NULL;
2395     
2396     WindowListPointersMenu.erase(WData->WindowID);
2397     WindowListPointers.erase(WData->WindowID);
2398     WindowListType.erase(WData->WindowID);
2399     
2400     delete WData;
2401     WData = NULL;
2402     
2405 void frmMain::ShowContactWindow( wxCommandEvent &event ){
2406     
2407     std::map<int, void*>::iterator WindowIter = WindowListPointers.find(event.GetId());
2408     
2409     frmContact *frmContactPtr = static_cast<frmContact*>(WindowIter->second);
2410     
2411     frmContactPtr->Show();
2412     frmContactPtr->Raise();
2413     
2416 void frmMain::ShowContactEditorWindow( wxCommandEvent &event ){
2417     
2418     std::map<int, void*>::iterator WindowIter = WindowListPointers.find(event.GetId());
2419     
2420     frmContactEditor *frmCEPtr = static_cast<frmContactEditor*>(WindowIter->second);
2421     
2422     frmCEPtr->Show();
2423     frmCEPtr->Raise();
2424     
2427 void frmMain::ShowSearchWindow( wxCommandEvent &event ){
2428     
2429     // Look through the Search Window List Pointers, grab the
2430     // window point and show the window.
2431     
2432     std::map<int, void*>::iterator WindowIter = WindowListPointers.find(event.GetId());
2433     
2434     frmSearch *frmSearchPtr = static_cast<frmSearch*>(WindowIter->second);
2435     
2436     frmSearchPtr->Show();
2437     frmSearchPtr->Raise();
2438     
2441 void frmMain::ToggleConnectionStatus( wxCommandEvent &event ){
2442     
2443     frmActivityMgr *frameActMgr = static_cast<frmActivityMgr*>(ActMgrPtr);
2444     wxCommandEvent toggconn(ACTMGR_TOGGLECONN);
2445     wxPostEvent(frameActMgr, toggconn);
2446     
2449 void frmMain::ShowSSLCertificates( wxCommandEvent &event ){
2450     
2451     // Check the account type before continuing.
2452     
2453     wxString SeekAccount;
2454     wxString AccTypeLower;
2455     wxString AccType;
2456     bool AccountSSL;
2457     std::map<int, SSLCertCollection>::iterator SSLColIter;
2458     
2459     for (int i = 0; i < prefaccounts.GetCount(); i++){
2460         
2461         SeekAccount.Append(prefaccounts.GetAccountDirectory(i));
2462         AccType.Append(prefaccounts.GetAccountType(i));
2463         AccountSSL = prefaccounts.GetAccountSSL(i);
2464         AccTypeLower = AccType.MakeLower();
2465         SeekAccount.Append(wxT("."));
2466         SeekAccount.Append(AccTypeLower);
2467         
2468         if (SeekAccount == ActiveAccount){
2469             
2470             if (AccTypeLower == wxT("local")){
2471                 
2472                 return;
2473                 
2474             }
2475             
2476             if (AccountSSL == false){
2477                 
2478                 return;
2479                 
2480             }
2481             
2482             SSLColIter = AccountSSLData.find(i);
2483             
2484             SSLCertCollection SSLCertInfo = SSLColIter->second;
2485             
2486             frmSSLCertificate *frameSSLCert = new frmSSLCertificate ( this );
2487             frameSSLCert->StartCertFrom(0);
2488             frameSSLCert->SetupCerts(SSLCertInfo);
2489             frameSSLCert->ShowModal();
2490             
2491             delete frameSSLCert;
2492             frameSSLCert = NULL;
2493             
2494         }
2495         
2496         SeekAccount.Clear();
2497         AccTypeLower.Clear();
2498         AccType.clear();
2499         
2500     }
2501     
2504 void frmMain::ShowSSLInfo( wxCommandEvent &event ){
2505     
2506     // Check the account type before continuing.
2507     
2510 void frmMain::HideSSLInfo( wxCommandEvent &event ){
2511     
2512     // Check the account type before continuing.
2513     
2516 void frmMain::UpdateConnectionStatus( wxCommandEvent &event ){
2517     
2518     if (event.GetInt() == 0){
2519         
2520         imgConnStatus->SetBitmap(*imgOnline);
2521         
2522     } else {
2523         
2524         imgConnStatus->SetBitmap(*imgOffline);
2525         
2526     }   
2527     
2530 void frmMain::SetupSSLStatus( int AccountID ){
2531     
2532     // Check if account ID given is
2533     // the active account and if not, do nothing.
2534     
2535     wxString AccType;
2536     wxString AccTypeLower;
2537     
2538     AccType = prefaccounts.GetAccountType(AccountID);
2539     AccTypeLower = AccType.MakeLower();
2540     
2541     wxString AccountIDName = prefaccounts.GetAccountDirectory(AccountID) + wxT(".") +
2542                                 AccTypeLower;
2543     
2544     if (AccountIDName != ActiveAccount){
2545         
2546         return;
2547         
2548     }
2549     
2550     // Check if the account has SSL enabled.
2551     
2552     bool SSLInUse = prefaccounts.GetAccountSSL(AccountID);
2553     
2554     if (SSLInUse == FALSE){
2555         
2556         SSLToolTip->SetTip(wxT("SSL is not enabled for this account"));
2557         imgSSLStatus->SetBitmap(*imgNoSSL);
2558         
2559     } else {
2560         
2561         // Get the SSL Collection Data.
2562         
2563         std::map<int,int>::iterator SSLResultIter = AccountSSLResult.find(AccountID);
2564         
2565         if (SSLResultIter->second == 1){
2566             
2567             imgSSLStatus->SetBitmap(*imgSSLWarning);
2568             SSLToolTip->SetTip(wxT("Invalid certificate(s) received for '") + 
2569                                prefaccounts.GetAccountName(AccountID) +
2570                                wxT("' (Connection denied by user)\n\nDouble click for more information."));
2571             
2572             
2573         } else if (SSLResultIter->second == 0){
2574             
2575             imgSSLStatus->SetBitmap(*imgSSL);
2576             SSLToolTip->SetTip(wxT("Account '") + 
2577                                prefaccounts.GetAccountName(AccountID) +
2578                                wxT("' secured using SSL\n\nDouble click for more information."));
2579             
2580         }
2581         
2582     }
2583     
2586 void frmMain::InvalidSSLCertificate( wxCommandEvent &event ){
2587     
2588     frmInvalidSSLCertificate *frameISC = new frmInvalidSSLCertificate ( this );
2589     SSLInvalidCertNotifObj *SSLICNObj = (SSLInvalidCertNotifObj*)event.GetClientData();
2590     SSLCertCollection SSLCCData = SSLICNObj->CertCollection;
2591     wxString AccountName = SSLICNObj->AccountName;
2592     frameISC->LoadData(SSLCCData, AccountName);
2593     frameISC->ShowModal();
2594     
2595     int FinalConflictResult = frameISC->GetResult();
2596     
2597     wxCommandEvent event2(ACTMGR_RESUMEPROC);
2598     event2.SetClientData(SSLICNObj->QRNotifData);
2599     event2.SetInt(FinalConflictResult);
2600     
2601     delete frameISC;
2602     frameISC = NULL;
2603     
2604     frmActivityMgr *frameActMgr = static_cast<frmActivityMgr*>(ActMgrPtr);      
2605     wxPostEvent(frameActMgr, event2);
2608 void frmMain::PauseAllTimers(){
2609     
2610     for (std::map<wxString, wxAccountSyncTimer*>::iterator ASTiter = AccountSyncTimers.begin(); 
2611          ASTiter != AccountSyncTimers.end(); ASTiter++){
2612         
2613         ASTiter->second->Stop();
2614         
2615     }
2616     
2619 void frmMain::ResumeAllTimers(){
2620     
2621     for (std::map<wxString, wxAccountSyncTimer*>::iterator ASTiter = AccountSyncTimers.begin(); 
2622          ASTiter != AccountSyncTimers.end(); ASTiter++){
2623         
2624         ASTiter->second->Start();
2625         
2626     }
2627     
2630 void frmMain::UpdateSSLAccountStatus(int AccountID, int SSLStatus, SSLCertCollection SSLCertInc){
2631     
2632     // Delete existing data.
2633     
2634     AccountSSLData.erase(AccountID);
2635     AccountSSLResult.erase(AccountID);
2636     
2637     // Insert new data.
2638     
2639     AccountSSLData.insert(std::make_pair(AccountID, SSLCertInc));
2640     AccountSSLResult.insert(std::make_pair(AccountID, SSLStatus));
2641     
2644 void frmMain::CheckUpdates( wxCommandEvent& event ){
2645     
2646     frmUpdate *frameUpdate = new frmUpdate ( this );
2647     frameUpdate->FetchData();
2648     frameUpdate->ShowModal();
2649     
2652 void frmMain::OpenImportDialog( wxCommandEvent& event ){
2653     
2654     // Run the import contacts system.
2655     
2656     ImportRun(this);
2657     
2660 void frmMain::OpenExportDialog( wxCommandEvent& event ){
2661     
2662     // Check if an account and at least one contact is selected
2663     // before continuing.
2664     
2665     wxArrayString ArrData;
2666     
2667     if (ActiveAccount.IsEmpty()){
2668         
2669         return;
2670         
2671     }
2672     
2673     int ContactSelected = 0;
2674     int ContactsCollected = 0;
2675     long longSelected = -1;
2676     
2677     for (;;){
2678         
2679         longSelected = lstContacts->GetNextItem(longSelected, 
2680                                                 wxLIST_NEXT_ALL,
2681                                                 wxLIST_STATE_SELECTED);
2682         
2683         if (longSelected == -1){
2684             
2685             break;
2686             
2687         }
2688         
2689         int FileID = (int)lstContacts->GetItemData(longSelected);
2690         
2691         ArrData.Insert(ContactsFileIndex[FileID],
2692                        ContactsCollected, 1);
2693         
2694         ContactSelected++;
2695         
2696     }
2697     
2698     if (ContactSelected == 0){
2699         
2700         return;
2701         
2702     }
2703     
2704     // Run the export contacts system.
2705     
2706     ExportRun(this, &ArrData);
2707     
2710 void frmMain::GetListControl(wxListCtrl *lstContactsPtr, 
2711                              wxArrayString *ContactsFileIndexPtr){
2712     
2713     lstContactsPtr = lstContacts;
2714     ContactsFileIndexPtr = &ContactsFileIndex;
2715     
2718 void frmMain::GetSelectedList( wxCommandEvent& event ){
2719     
2720     // Get the array of contact filenames. 
2721     
2722     wxArrayString *ArrData = (wxArrayString*)event.GetClientData();
2723     
2724     // Process them into an array of files.     
2725     
2726     long longSelected = -1;
2727     int ContactsCollected = 0;
2728     wxString ContactFilename;
2729     
2730     for (;;){
2731         
2732         longSelected = lstContacts->GetNextItem(longSelected, 
2733                                                 wxLIST_NEXT_ALL,
2734                                                 wxLIST_STATE_SELECTED);
2735         
2736         if (longSelected == -1){
2737             
2738             break;
2739             
2740         }
2741         
2742         // Get the file information and add to the list.
2743         
2744         int FileID = (int)lstContacts->GetItemData(longSelected);
2745         
2746         ArrData->Insert(ContactsFileIndex[FileID],
2747                         ContactsCollected, 1);
2748         
2749         ContactsCollected++;
2750         ContactFilename.Clear();        
2751         
2752     }
2753     
2754     event.SetInt(1);
2755     
2758 void frmMain::SyncAccount( wxCommandEvent& event ){
2759     
2760     wxString AccNameInc = event.GetString();
2761     
2762     frmActivityMgr *frameActMgr = static_cast<frmActivityMgr*>(ActMgrPtr);
2763     frameActMgr->AddTask(3, wxT(""), AccNameInc, 
2764                          wxT(""), wxT(""), wxT(""), wxT(""));
2765     
2768 void frmMain::ShowHelp( wxCommandEvent& event ){
2769     
2770     // Based on the operating system, work out where 
2771     // the documentation should be.
2772     
2773     //#ifdef __APPLE__
2774     
2775 #if defined(__HAIKU__)
2776     
2777 #elif defined(__WIN32__)
2778     
2779     
2780     
2781 #else
2782     
2783     if (wxFileExists("/usr/share/doc/xestiaab/index.html")){
2784         
2785         wxLaunchDefaultBrowser(wxT("file:///usr/share/doc/xestiaab/index.html"));
2786         return;
2787         
2788 #if XSDAB_RELEASE == 0
2789         
2790     } else if (wxFileExists("/usr/local/share/doc/xestiaab/index.html")){
2791         
2792         wxLaunchDefaultBrowser(wxT("file:///usr/local/share/doc/xestiaab/index.html"));
2793         return;
2794         
2795 #endif 
2796         
2797     }
2798     
2799 #endif
2800     
2801 #if XSDAB_RELEASE == 0
2802     
2803     wxMessageBox(_("The help documentation is not available.\n\nYou can view the documentation that came with your source package."), _("Help documentation missing!"));
2804     
2805 #else
2806     
2807     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!"));
2808     
2809 #endif
2810     
2813 void frmMain::ShowImportResults( wxCommandEvent &event ){
2815         std::map<int,wxString> *ResultData = (std::map<int,wxString>*)event.GetClientData();
2817         frmImportResults *frmIR = new frmImportResults(this);
2818         frmIR->LoadData(ResultData, event.GetInt(), (int)event.GetExtraLong());
2819         frmIR->ShowModal();
2820                 
2821         delete frmIR;
2822         frmIR = NULL;
2823         
2824         delete ResultData;
2825         ResultData = NULL;
2829 void frmMain::ReloadContactList( wxCommandEvent &event ){
2831         // Check if the account name given is the current
2832         // account selected.
2834         if (ActiveAccount == event.GetString()){
2835         
2836                 wxTreeEvent NullEvent;
2837                 LoadContactList(NullEvent);
2838         
2839         }
2843 void frmMain::ShowContactMenu( wxMouseEvent& event ){
2845         bool EnableRefresh = FALSE;
2847         if (!ActiveAccount.IsEmpty()){
2849                 EnableRefresh = TRUE;
2850         
2851         }
2853         ContactMenu->SetupPointers(this, lstContacts, EnableRefresh);
2855         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