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