~ubuntu-branches/ubuntu/oneiric/apparmor/oneiric-security

« back to all changes in this revision

Viewing changes to deprecated/management/profile-editor/src/SearchAllProfiles.h

  • Committer: Bazaar Package Importer
  • Author(s): Kees Cook
  • Date: 2011-04-27 10:38:07 UTC
  • mfrom: (5.1.118 natty)
  • Revision ID: james.westby@ubuntu.com-20110427103807-ym3rhwys6o84ith0
Tags: 2.6.1-2
debian/copyright: clarify for some full organization names.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef _SEARCHALLPROFILESDIALOG_H_
 
2
#define _SEARCHALLPROFILESDIALOG_H_
 
3
 
 
4
 
 
5
class wxFlexGridSizer;
 
6
class wxStdDialogButtonSizer;
 
7
 
 
8
/**
 
9
 * A "Search All Profiles" dialog
 
10
 */
 
11
class SearchAllProfilesDialog: public wxDialog
 
12
{    
 
13
    DECLARE_DYNAMIC_CLASS(SearchAllProfilesDialog)
 
14
    DECLARE_EVENT_TABLE()
 
15
 
 
16
public:
 
17
        SearchAllProfilesDialog();
 
18
        SearchAllProfilesDialog(wxWindow* parent, 
 
19
                                wxWindowID id = wxID_ANY, 
 
20
                                const wxString& caption = _("Search All Profiles"), 
 
21
                                const wxPoint& pos = wxDefaultPosition, 
 
22
                                const wxSize& size = wxSize(400, 300), 
 
23
                                long style = wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX);
 
24
        
 
25
        /// Creation
 
26
        bool Create(wxWindow* parent, 
 
27
                        wxWindowID id = wxID_ANY, 
 
28
                        const wxString& caption = _("Search All Profiles"), 
 
29
                        const wxPoint& pos = wxDefaultPosition, 
 
30
                        const wxSize& size = wxSize(400, 300), 
 
31
                        long style = wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxCLOSE_BOX );
 
32
        void CreateControls();
 
33
        void OnSearch(wxCommandEvent& event);
 
34
        void OnListBoxDClick (wxCommandEvent& event);
 
35
        void DoSearch(const wxString& searchString);
 
36
 
 
37
 
 
38
        void SetProfileDirectory (const wxString& dir) { mProfileDirectory = dir; }
 
39
        void SetEditorExecutable (const wxString& exec) { mEditorExecutable = exec; }
 
40
        void SetSearchText (const wxString& searchString) { mpSearchPhraseTextCtrl->SetValue(searchString); }
 
41
 
 
42
private:
 
43
        wxFlexGridSizer*        mpSearchPhraseSizer;
 
44
        wxStaticText*           mpSearchStaticText;
 
45
        wxTextCtrl*             mpSearchPhraseTextCtrl;
 
46
        wxButton*               mpSearchButton;
 
47
        wxListBox*              mpSearchResultsListBox;
 
48
        wxStdDialogButtonSizer* mpOKButtonSizer;
 
49
        wxString                mProfileDirectory;
 
50
        wxString                mEditorExecutable;
 
51
        wxString                mSearchedPhrase;
 
52
};
 
53
 
 
54
/**
 
55
 * The "Search All" traverser
 
56
 */
 
57
class SearchAllProfilesTraverser : public wxDirTraverser
 
58
{
 
59
        public:
 
60
                SearchAllProfilesTraverser (const wxString& search, wxListBox *rBox) 
 
61
                                                        : searchString(search),
 
62
                                                          resultsBox(rBox) {}
 
63
                virtual wxDirTraverseResult OnFile(const wxString& filename)
 
64
                {
 
65
                        if (!tmpFile.Open(filename))
 
66
                                return wxDIR_CONTINUE;
 
67
 
 
68
                        if (!tmpFile.ReadAll(&tmpString))
 
69
                                return wxDIR_CONTINUE;
 
70
 
 
71
                        if (tmpString.Find(searchString) != -1)
 
72
                                resultsBox->Append(filename);
 
73
                        tmpFile.Close();
 
74
                        return wxDIR_CONTINUE;
 
75
                }
 
76
 
 
77
                 virtual wxDirTraverseResult OnDir(const wxString& dirname)
 
78
                {
 
79
                        return wxDIR_CONTINUE;
 
80
                }
 
81
        private:
 
82
                wxString searchString;
 
83
                wxListBox *resultsBox;
 
84
                wxString tmpString;
 
85
                wxFFile tmpFile;
 
86
                
 
87
};
 
88
 
 
89
enum
 
90
{
 
91
        ID_SEARCH_ALL_PROFILES_BUTTON = 15599,
 
92
        ID_SEARCH_ALL_PROFILES_LIST_BOX
 
93
};
 
94
 
 
95
#endif