1 // This file is part of BOINC. 2 // http://boinc.berkeley.edu 3 // Copyright (C) 2008 University of California 4 // 5 // BOINC is free software; you can redistribute it and/or modify it 6 // under the terms of the GNU Lesser General Public License 7 // as published by the Free Software Foundation, 8 // either version 3 of the License, or (at your option) any later version. 9 // 10 // BOINC is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 // See the GNU Lesser General Public License for more details. 14 // 15 // You should have received a copy of the GNU Lesser General Public License 16 // along with BOINC. If not, see <http://www.gnu.org/licenses/>. 17 18 #ifndef BOINC_BOINCBASEFRAME_H 19 #define BOINC_BOINCBASEFRAME_H 20 21 #if defined(__GNUG__) && !defined(__APPLE__) 22 #pragma interface "BOINCBaseFrame.cpp" 23 #endif 24 25 26 class CFrameEvent; 27 class CFrameAlertEvent; 28 class CBOINCDialUpManager; 29 30 enum FrameAlertEventType { 31 AlertNormal = 0, 32 AlertProcessResponse 33 }; 34 35 36 class CBOINCBaseFrame : public wxFrame { 37 38 DECLARE_DYNAMIC_CLASS( CBOINCBaseFrame ) 39 40 public: 41 42 CBOINCBaseFrame(); 43 CBOINCBaseFrame( 44 wxWindow *parent, 45 const wxWindowID id, 46 const wxString& title, 47 const wxPoint& pos, 48 const wxSize& size, 49 const long style 50 ); 51 52 ~CBOINCBaseFrame(); 53 54 void OnPeriodicRPC( wxTimerEvent& event ); 55 void OnDocumentPoll( wxTimerEvent& event ); 56 void OnAlertPoll( wxTimerEvent& event ); 57 virtual void OnRefreshView( CFrameEvent& event ); 58 59 void OnInitialized( CFrameEvent& event ); 60 61 virtual void OnAlert( CFrameAlertEvent& event ); 62 virtual void OnActivate( wxActivateEvent& event ); 63 virtual void OnClose( wxCloseEvent& event ); 64 virtual void OnCloseWindow( wxCommandEvent& event ); 65 virtual void OnExit( wxCommandEvent& event ); 66 67 int GetCurrentViewPage(); GetDialupConnectionName()68 wxString GetDialupConnectionName() { return m_strNetworkDialupConnectionName; } SetDialupConnectionName(wxString val)69 void SetDialupConnectionName(wxString val) { m_strNetworkDialupConnectionName = val; } GetDialupManager()70 CBOINCDialUpManager* GetDialupManager() { return m_pDialupManager; } GetReminderFrequency()71 int GetReminderFrequency() { return m_iReminderFrequency; } SetReminderFrequency(int val)72 void SetReminderFrequency(int val) { m_iReminderFrequency = val; } 73 74 void FireInitialize(); 75 void FireRefreshView(); 76 void FireConnect(); 77 void FireReloadSkin(); 78 void FireNotification(); 79 80 bool SelectComputer(wxString& hostName, int& portNum, wxString& password, bool required = false); 81 void ShowConnectionBadPasswordAlert( bool bUsedDefaultPassword, int iReadGUIRPCAuthFailure ); 82 void ShowConnectionFailedAlert(); 83 void ShowDaemonStartFailedAlert(); 84 void ShowNotCurrentlyConnectedAlert(); 85 86 virtual void StartTimers(); 87 virtual void StopTimers(); 88 virtual void UpdateRefreshTimerInterval(); 89 90 void ShowAlert( 91 const wxString title, 92 const wxString message, 93 const int style, 94 const bool notification_only = false, 95 const FrameAlertEventType alert_event_type = AlertNormal 96 ); 97 98 bool Show( bool bShow = true ); 99 100 virtual bool RestoreState(); 101 virtual bool SaveState(); 102 103 protected: 104 105 CBOINCDialUpManager* m_pDialupManager; 106 107 wxTimer* m_pDocumentPollTimer; 108 wxTimer* m_pAlertPollTimer; 109 wxTimer* m_pPeriodicRPCTimer; 110 111 int m_iReminderFrequency; 112 int m_iFrameRefreshRate; 113 114 wxString m_strNetworkDialupConnectionName; 115 116 wxArrayString m_aSelectedComputerMRU; 117 118 bool m_bShowConnectionFailedAlert; 119 120 virtual int _GetCurrentViewPage(); 121 122 wxPoint m_ptFramePos; 123 124 125 DECLARE_EVENT_TABLE() 126 }; 127 128 129 class CFrameEvent : public wxEvent 130 { 131 public: CFrameEvent(wxEventType evtType,CBOINCBaseFrame * frame)132 CFrameEvent(wxEventType evtType, CBOINCBaseFrame *frame) 133 : wxEvent(-1, evtType) 134 { 135 SetEventObject(frame); 136 } 137 CFrameEvent(wxEventType evtType,CBOINCBaseFrame * frame,wxString message)138 CFrameEvent(wxEventType evtType, CBOINCBaseFrame *frame, wxString message) 139 : wxEvent(-1, evtType), m_message(message) 140 { 141 SetEventObject(frame); 142 } 143 Clone()144 virtual wxEvent *Clone() const { return new CFrameEvent(*this); } 145 146 wxString m_message; 147 }; 148 149 150 class CFrameAlertEvent : public wxEvent 151 { 152 public: CFrameAlertEvent(wxEventType evtType,CBOINCBaseFrame * frame,wxString title,wxString message,int style,bool notification_only,FrameAlertEventType alert_event_type)153 CFrameAlertEvent(wxEventType evtType, CBOINCBaseFrame *frame, wxString title, wxString message, int style, bool notification_only, FrameAlertEventType alert_event_type) 154 : wxEvent(-1, evtType), m_title(title), m_message(message), m_style(style), m_notification_only(notification_only), m_alert_event_type(alert_event_type) 155 { 156 SetEventObject(frame); 157 } 158 CFrameAlertEvent(wxEventType evtType,CBOINCBaseFrame * frame,wxString title,wxString message,int style,bool notification_only)159 CFrameAlertEvent(wxEventType evtType, CBOINCBaseFrame *frame, wxString title, wxString message, int style, bool notification_only) 160 : wxEvent(-1, evtType), m_title(title), m_message(message), m_style(style), m_notification_only(notification_only) 161 { 162 SetEventObject(frame); 163 m_alert_event_type = AlertNormal; 164 } 165 CFrameAlertEvent(const CFrameAlertEvent & event)166 CFrameAlertEvent(const CFrameAlertEvent& event) 167 : wxEvent(event) 168 { 169 m_title = event.m_title; 170 m_message = event.m_message; 171 m_style = event.m_style; 172 m_notification_only = event.m_notification_only; 173 m_alert_event_type = event.m_alert_event_type; 174 } 175 Clone()176 virtual wxEvent *Clone() const { return new CFrameAlertEvent(*this); } 177 virtual void ProcessResponse(const int response) const; 178 179 wxString m_title; 180 wxString m_message; 181 int m_style; 182 bool m_notification_only; 183 FrameAlertEventType m_alert_event_type; 184 }; 185 186 187 BEGIN_DECLARE_EVENT_TYPES() 188 DECLARE_EVENT_TYPE( wxEVT_FRAME_ALERT, 10000 ) 189 DECLARE_EVENT_TYPE( wxEVT_FRAME_CONNECT, 10001 ) 190 DECLARE_EVENT_TYPE( wxEVT_FRAME_INITIALIZED, 10004 ) 191 DECLARE_EVENT_TYPE( wxEVT_FRAME_REFRESHVIEW, 10005 ) 192 DECLARE_EVENT_TYPE( wxEVT_FRAME_UPDATESTATUS, 10006 ) 193 DECLARE_EVENT_TYPE( wxEVT_FRAME_RELOADSKIN, 10007 ) 194 DECLARE_EVENT_TYPE( wxEVT_FRAME_NOTIFICATION, 10007 ) 195 END_DECLARE_EVENT_TYPES() 196 197 #define EVT_FRAME_ALERT(fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_FRAME_ALERT, -1, -1, (wxObjectEventFunction) (wxEventFunction) &fn, NULL), 198 #define EVT_FRAME_CONNECT(fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_FRAME_CONNECT, -1, -1, (wxObjectEventFunction) (wxEventFunction) &fn, NULL), 199 #define EVT_FRAME_INITIALIZED(fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_FRAME_INITIALIZED, -1, -1, (wxObjectEventFunction) (wxEventFunction) &fn, NULL), 200 #define EVT_FRAME_REFRESH(fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_FRAME_REFRESHVIEW, -1, -1, (wxObjectEventFunction) (wxEventFunction) &fn, NULL), 201 #define EVT_FRAME_UPDATESTATUS(fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_FRAME_UPDATESTATUS, -1, -1, (wxObjectEventFunction) (wxEventFunction) &fn, NULL), 202 #define EVT_FRAME_RELOADSKIN(fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_FRAME_RELOADSKIN, -1, -1, (wxObjectEventFunction) (wxEventFunction) &fn, NULL), 203 #define EVT_FRAME_NOTIFICATION(fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_FRAME_NOTIFICATION, -1, -1, (wxObjectEventFunction) (wxEventFunction) &fn, NULL), 204 205 #endif 206