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