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