Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added copyright and license header to the C++ source and header files in the contacte...
[xestiaab/.git] / source / frmSearch.cpp
index 50d8b5c..0a1e4ca 100644 (file)
@@ -1,5 +1,24 @@
+// frmSearch.cpp - Search form.
+//
+// (c) 2012-2015 Xestia Software Development.
+//
+// This file is part of Xestia Address Book.
+//
+// Xestia Address Book is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by the
+// Free Software Foundation, version 3 of the license.
+//
+// Xestia Address Book is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with Xestia Address Book. If not, see <http://www.gnu.org/licenses/>
+
 #include "frmSearch.h"
 #include "frmMain.h"
+#include "frmContact.h"
 #include "search/XABSearchPanel.h"
 #include "search/frmSearchAccounts.h"
 #include "common/preferences.h"
@@ -7,9 +26,7 @@
 #include "vcard/vcard.h"
 
 #include <thread>
-/*#include <boost/filesystem.hpp>
-#include <boost/filesystem/fstream.hpp>
-#include <boost/filesystem/path.hpp>*/
+#include <wx/fs_mem.h>
 #include <wx/tokenzr.h>
 #include <wx/dir.h>
 
@@ -21,6 +38,9 @@ DEFINE_EVENT_TYPE(SE_SBUPDATE);
 DEFINE_EVENT_TYPE(SE_SEARCHFINISHED);
 DEFINE_EVENT_TYPE(SE_UPDATERESULT);
 DEFINE_EVENT_TYPE(SE_DELETERESULT);
+DEFINE_EVENT_TYPE(SE_OPENCONTACT);
+DEFINE_EVENT_TYPE(SE_EDITCONTACT);
+DEFINE_EVENT_TYPE(SE_REVEALCONTACT);
 
 BEGIN_EVENT_TABLE(frmSearch, wxFrame)
   EVT_COMMAND(wxID_ANY, SE_ADDSEARCHSETTING, frmSearch::AddSearchSetting)
@@ -31,10 +51,11 @@ BEGIN_EVENT_TABLE(frmSearch, wxFrame)
   EVT_COMMAND(wxID_ANY, SE_SEARCHFINISHED, frmSearch::SearchFinished)
   EVT_COMMAND(wxID_ANY, SE_UPDATERESULT, frmSearch::UpdateResult)
   EVT_COMMAND(wxID_ANY, SE_DELETERESULT, frmSearch::DeleteResult)
+  EVT_COMMAND(wxID_ANY, SE_OPENCONTACT, frmSearch::OpenContact)
+  EVT_COMMAND(wxID_ANY, SE_EDITCONTACT, frmSearch::EditContact)
+  EVT_COMMAND(wxID_ANY, SE_REVEALCONTACT, frmSearch::RevealContact)
 END_EVENT_TABLE()
 
-//namespace boostfs = boost::filesystem;
-
 frmSearch::frmSearch( wxWindow* parent )
 :
 frmSearchADT( parent )
@@ -165,12 +186,8 @@ void frmSearch::SearchContactsThread(){
                // Get the list of contact files and process each
                // one of them.
                
-               wxString AccountDir = GetAccountDir(SAPiter->second, FALSE);
-               
-               //boostfs::path vcarddir(AccountDir.c_str());
-               //boostfs::directory_iterator dir_end;    
+               wxString AccountDir = GetAccountDir(SAPiter->second, FALSE);  
 
-               //boostfs::path vcardfilename;
                wxString vcardfilenamewxs;
                wxStringTokenizer vcardfileline;
                //std::string l;
@@ -181,15 +198,12 @@ void frmSearch::SearchContactsThread(){
                wxString vCardFilename;
                wxString vCardFilenameFull;
                
-               //if (boostfs::exists(vcarddir)){
                if (wxDirExists(AccountDir)){
                
                        wxDir vcardaccdir(AccountDir);
                
                        bool ProcFiles = vcardaccdir.GetFirst(&vCardFilename, wxEmptyString, wxDIR_FILES);
                        while(ProcFiles){
-                       //for (boostfs::directory_iterator vcarddir_iter(vcarddir);
-                       //     vcarddir_iter != dir_end ; ++vcarddir_iter){
 
                                if (StopMode == FALSE){
 
@@ -215,20 +229,8 @@ void frmSearch::SearchContactsThread(){
 
 
                                        Person.LoadFile(vCardFilenameFull);
-
-                                   /*if (boostfs::path(vcarddir_iter->path()).extension() == ".vcf" ||
-                                       boostfs::path(vcarddir_iter->path()).extension() == ".VCF" ||
-                                       boostfs::path(vcarddir_iter->path()).extension() == ".vcard" ||
-                                       boostfs::path(vcarddir_iter->path()).extension() == ".VCARD"){*/
                
                                        vcardfilenamewxs = vCardFilenameFull;
-               
-                                       /*vCard Person;
-                                       std::fstream vcardfile;
-
-                                       vcardfilename = boostfs::path(vcarddir_iter->path()).filename();
-                                       vcardfilenamewxs.Append(AccountDir);            
-                                       vcardfilenamewxs.Append(wxString::FromUTF8(vcardfilename.c_str()));         
            
                                        // Open the vCard file up and get the setting names and values from the
                                        // file.
@@ -1242,6 +1244,8 @@ void frmSearch::RemoveSearchSetting( wxCommandEvent& event )
 
 void frmSearch::ReloadAccountList( wxCommandEvent& event ){
 
+       // Currently unimplemented.
+
 }
 
 void frmSearch::AddResult( wxCommandEvent& event ){
@@ -1366,14 +1370,40 @@ void frmSearch::OpenContact( wxCommandEvent& event ){
 
        intContactSeekNum = lstResults->GetItemData(intSelected);
 
-       UCNotif *uc = new UCNotif;
+       if (SearchMode == TRUE){
+    
+               wxMessageBox(SearchResultFilename[intContactSeekNum]);
+    
+               vCard Person;
+    
+               Person.LoadFile(SearchResultFilename[intContactSeekNum]);
+    
+               wxMemoryInputStream istream(bigimgs_contactpersonicon48_png, sizeof(bigimgs_contactpersonicon48_png));
+               wxImage bigimgs_contactpersonicon48i(istream, wxBITMAP_TYPE_PNG);
+               wxBitmap contacticonbmp(bigimgs_contactpersonicon48i, -1);
+               wxIcon contacticon;
+               contacticon.CopyFromBitmap(contacticonbmp);
+    
+               frmContact *Contact = new frmContact( this );
+    
+               Contact->SetupPointers(&SearchModeMemoryFSPtr);
+               Contact->SetupContactData(&Person);
+    
+               Contact->SetIcon(contacticon);
+               Contact->Show(true);
 
-       uc->ContactAccount = SearchResultAccount[intContactSeekNum];
-       uc->ContactFilename = SearchResultFilename[intContactSeekNum];
+       } else {
+
+               UCNotif *uc = new UCNotif;
+
+               uc->ContactAccount = SearchResultAccount[intContactSeekNum];
+               uc->ContactFilename = SearchResultFilename[intContactSeekNum];
 
-       wxCommandEvent oc(CE_OPENCONTACT);
-       oc.SetClientData(uc);
-       wxPostEvent(this->GetParent(), oc);
+               wxCommandEvent oc(CE_OPENCONTACT);
+               oc.SetClientData(uc);
+               wxPostEvent(this->GetParent(), oc);
+
+       }
 
 }
 
@@ -1665,4 +1695,57 @@ void frmSearch::SetUID(int UID){
 
        SearchUID = UID;
 
+}
+
+void frmSearch::SetSearchMode(bool SearchModeIn){
+
+       SearchMode = SearchModeIn;
+
+       if (SearchMode == TRUE){
+       
+               mnuContactEdit->Enable(FALSE);
+               mnuContactReveal->Enable(FALSE);
+               
+               wxFileSystem::AddHandler(new wxMemoryFSHandler);
+               wxImage ciicon_png;
+
+               wxMemoryInputStream ciptostream(icons_cipto_png, sizeof(icons_cipto_png));
+               ciicon_png.LoadFile(ciptostream, wxBITMAP_TYPE_PNG);
+               wxMemoryFSHandler::AddFile(wxT("cipto.png"), ciicon_png, wxBITMAP_TYPE_PNG);
+
+               wxMemoryInputStream cilogstream(icons_cilog_png, sizeof(icons_cilog_png));
+               ciicon_png.LoadFile(cilogstream, wxBITMAP_TYPE_PNG);
+               wxMemoryFSHandler::AddFile(wxT("cilog.png"), ciicon_png, wxBITMAP_TYPE_PNG);
+
+               wxMemoryInputStream cisndstream(icons_cisnd_png, sizeof(icons_cisnd_png));
+               ciicon_png.LoadFile(cisndstream, wxBITMAP_TYPE_PNG);
+               wxMemoryFSHandler::AddFile(wxT("cisnd.png"), ciicon_png, wxBITMAP_TYPE_PNG);
+
+               wxMemoryInputStream cikeystream(icons_cikey_png, sizeof(icons_cikey_png));
+               ciicon_png.LoadFile(cikeystream, wxBITMAP_TYPE_PNG);
+               wxMemoryFSHandler::AddFile(wxT("cikey.png"), ciicon_png, wxBITMAP_TYPE_PNG);
+
+               wxMemoryInputStream civenstream(icons_civen_png, sizeof(icons_civen_png));
+               ciicon_png.LoadFile(civenstream, wxBITMAP_TYPE_PNG);
+               wxMemoryFSHandler::AddFile(wxT("civen.png"), ciicon_png, wxBITMAP_TYPE_PNG);
+
+               wxMemoryInputStream ciextstream(icons_ciext_png, sizeof(icons_ciext_png));
+               ciicon_png.LoadFile(ciextstream, wxBITMAP_TYPE_PNG);
+               wxMemoryFSHandler::AddFile(wxT("ciext.png"), ciicon_png, wxBITMAP_TYPE_PNG);
+       
+       } else {
+       
+               mnuContactEdit->Enable(TRUE);
+               mnuContactReveal->Enable(TRUE);
+       
+       }
+       
+}
+
+void frmSearch::ShowContactMenu( wxMouseEvent& event ){
+
+       ContactMenu->SetupPointers(this, lstResults);
+
+       PopupMenu(ContactMenu->MenuPointer(), wxDefaultPosition);
+
 }
\ No newline at end of file
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