1 // This file is part of BOINC. 2 // http://boinc.berkeley.edu 3 // Copyright (C) 2016 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 19 /// 20 /// @defgroup BOINCMgr BOINC Manager 21 /// The BOINC Manager 22 /// @{ 23 24 #ifndef BOINC_BOINCGUIAPP_H 25 #define BOINC_BOINCGUIAPP_H 26 27 #if defined(__GNUG__) && !defined(__APPLE__) 28 #pragma interface "BOINCGUIApp.cpp" 29 #endif 30 31 /// 32 /// Which view is on display 33 /// 34 #define BOINC_ADVANCEDGUI 1 35 #define BOINC_SIMPLEGUI 2 36 37 38 class wxLogBOINC; 39 class CBOINCBaseFrame; 40 class CMainDocument; 41 class CTaskBarIcon; 42 class CSkinManager; 43 class CDlgEventLog; 44 class CRPCFinishedEvent; 45 46 #ifdef __WXMAC__ 47 OSErr QuitAppleEventHandler(const AppleEvent *appleEvt, AppleEvent* reply, UInt32 refcon); 48 #endif 49 50 class CBOINCGUIApp : public wxApp { 51 52 DECLARE_DYNAMIC_CLASS(CBOINCGUIApp) 53 54 protected: 55 int OnExit(); 56 #ifndef __WXMAC__ 57 void OnEndSession(wxCloseEvent& event); 58 #endif 59 60 void OnInitCmdLine(wxCmdLineParser &parser); 61 bool OnCmdLineParsed(wxCmdLineParser &parser); 62 63 bool DetectDuplicateInstance(); 64 void DetectExecutableName(); 65 void DetectRootDirectory(); 66 void DetectDataDirectory(); 67 68 void InitSupportedLanguages(); 69 70 int IdleTrackerAttach(); 71 int IdleTrackerDetach(); 72 73 wxConfig* m_pConfig; 74 wxLocale* m_pLocale; 75 wxLogBOINC* m_pLog; 76 wxSingleInstanceChecker* m_pInstanceChecker; 77 78 CSkinManager* m_pSkinManager; 79 CBOINCBaseFrame* m_pFrame; 80 CMainDocument* m_pDocument; 81 CTaskBarIcon* m_pTaskBarIcon; 82 CDlgEventLog* m_pEventLog; 83 bool m_bEventLogWasActive; 84 bool m_bProcessingActivateAppEvent; 85 #ifdef __WXMAC__ 86 CTaskBarIcon* m_pMacDockIcon; 87 #endif 88 wxString m_strBOINCMGRExecutableName; 89 wxString m_strBOINCMGRRootDirectory; 90 wxString m_strBOINCMGRDataDirectory; 91 wxString m_strHostNameArg; 92 wxString m_strPasswordArg; 93 wxString m_strBOINCArguments; 94 int m_iRPCPortArg; 95 96 bool m_bBOINCMGRAutoStarted; 97 int m_iBOINCMGRDisableAutoStart; 98 int m_iShutdownCoreClient; 99 int m_iDisplayExitDialog; 100 int m_iDisplayShutdownConnectedClientDialog; 101 102 bool m_bGUIVisible; 103 104 int m_iGUISelected; 105 bool m_bDebugSkins; 106 bool m_bMultipleInstancesOK; 107 bool m_bFilterEvents; 108 bool m_bAboutDialogIsOpen; 109 bool m_bRunDaemon; 110 bool m_bNeedRunDaemon; 111 112 // The last value defined in the wxLanguage enum is wxLANGUAGE_USER_DEFINED. 113 // defined in: wx/intl.h 114 wxArrayString m_astrLanguages; 115 wxString m_strISOLanguageCode; 116 117 int m_bSafeMessageBoxDisplayed; 118 119 public: 120 121 bool OnInit(); 122 void SaveState(); 123 GetLocale()124 wxLocale* GetLocale() { return m_pLocale; } GetSkinManager()125 CSkinManager* GetSkinManager() { return m_pSkinManager; } GetFrame()126 CBOINCBaseFrame* GetFrame() { return m_pFrame; } GetDocument()127 CMainDocument* GetDocument() { return m_pDocument; } GetExecutableName()128 wxString GetExecutableName() { return m_strBOINCMGRExecutableName; } GetRootDirectory()129 wxString GetRootDirectory() { return m_strBOINCMGRRootDirectory; } GetDataDirectory()130 wxString GetDataDirectory() { return m_strBOINCMGRDataDirectory; } GetClientHostNameArg()131 wxString GetClientHostNameArg() { return m_strHostNameArg; } GetClientPasswordArg()132 wxString GetClientPasswordArg() { return m_strPasswordArg; } GetArguments()133 wxString GetArguments() { return m_strBOINCArguments; } GetClientRPCPortArg()134 int GetClientRPCPortArg() { return m_iRPCPortArg; } GetEventLog()135 CDlgEventLog* GetEventLog() { return m_pEventLog; } GetTaskBarIcon()136 CTaskBarIcon* GetTaskBarIcon() { return m_pTaskBarIcon; } 137 IsAnotherInstanceRunning()138 bool IsAnotherInstanceRunning() { return m_pInstanceChecker->IsAnotherRunning(); } IsMgrMultipleInstance()139 bool IsMgrMultipleInstance() { return m_bMultipleInstancesOK; } 140 141 #ifdef __WXMAC__ 142 void OnFinishInit(); GetMacDockIcon()143 CTaskBarIcon* GetMacDockIcon() { return m_pMacDockIcon; } ShouldShutdownCoreClient()144 int ShouldShutdownCoreClient() { return true; } 145 #else ShouldShutdownCoreClient()146 int ShouldShutdownCoreClient() { return m_iShutdownCoreClient; } 147 #endif 148 GetBOINCMGRDisableAutoStart()149 int GetBOINCMGRDisableAutoStart() 150 { return m_iBOINCMGRDisableAutoStart; } SetBOINCMGRDisableAutoStart(int iDisableAutoStart)151 void SetBOINCMGRDisableAutoStart(int iDisableAutoStart) 152 { m_iBOINCMGRDisableAutoStart = iDisableAutoStart; } 153 GetBOINCMGRDisplayExitMessage()154 int GetBOINCMGRDisplayExitMessage() 155 { return m_iDisplayExitDialog; } SetBOINCMGRDisplayExitMessage(int iDisplayExitMessage)156 void SetBOINCMGRDisplayExitMessage(int iDisplayExitMessage) 157 { m_iDisplayExitDialog = iDisplayExitMessage; } 158 GetBOINCMGRDisplayShutdownConnectedClientMessage()159 int GetBOINCMGRDisplayShutdownConnectedClientMessage() 160 { return m_iDisplayShutdownConnectedClientDialog; } SetBOINCMGRDisplayShutdownConnectedClientMessage(int iDisplayShutdownConnectedClientDialog)161 void SetBOINCMGRDisplayShutdownConnectedClientMessage(int iDisplayShutdownConnectedClientDialog) 162 { m_iDisplayShutdownConnectedClientDialog = iDisplayShutdownConnectedClientDialog; } 163 GetRunDaemon()164 bool GetRunDaemon() 165 { return m_bRunDaemon; } SetRunDaemon(bool bRunDaemon)166 void SetRunDaemon(bool bRunDaemon) 167 { m_bRunDaemon = bRunDaemon; } 168 GetNeedRunDaemon()169 bool GetNeedRunDaemon() 170 { return m_bNeedRunDaemon; } 171 GetSupportedLanguages()172 wxArrayString& GetSupportedLanguages() { return m_astrLanguages; } GetISOLanguageCode()173 wxString GetISOLanguageCode() { return m_strISOLanguageCode; } SetISOLanguageCode(wxString strISOLanguageCode)174 void SetISOLanguageCode(wxString strISOLanguageCode) 175 { m_strISOLanguageCode = strISOLanguageCode; } 176 SetEventLogWasActive(bool wasActive)177 void SetEventLogWasActive(bool wasActive) { m_bEventLogWasActive = wasActive; } 178 void DisplayEventLog(bool bShowWindow = true); 179 void OnEventLogClose(); 180 181 void FireReloadSkin(); FrameClosed()182 void FrameClosed() { m_pFrame = NULL; } 183 184 int StartBOINCScreensaverTest(); 185 int StartBOINCDefaultScreensaverTest(); 186 187 bool SetActiveGUI(int iGUISelection, bool bShowWindow = true); 188 189 void OnActivateApp( wxActivateEvent& event ); 190 void OnRPCFinished( CRPCFinishedEvent& event ); 191 192 int ConfirmExit(); 193 194 int SafeMessageBox( 195 const wxString& message, 196 const wxString& caption = wxMessageBoxCaptionStr, 197 long style = wxOK | wxCENTRE, 198 wxWindow *parent = NULL, 199 int x = wxDefaultCoord, 200 int y = wxDefaultCoord 201 ); 202 203 bool IsApplicationVisible(); 204 void ShowApplication(bool bShow); 205 bool ShowInterface(); 206 bool ShowNotifications(); 207 208 bool IsModalDialogDisplayed(); IsSafeMesageBoxDisplayed()209 bool IsSafeMesageBoxDisplayed() { return (m_bSafeMessageBoxDisplayed != 0); }; 210 211 int FilterEvent(wxEvent &event); 212 213 214 int UpdateSystemIdleDetection(); 215 SetEventFiltering(bool set)216 void SetEventFiltering(bool set) { m_bFilterEvents = set; } 217 SetAboutDialogIsOpen(bool set)218 void SetAboutDialogIsOpen(bool set) { m_bAboutDialogIsOpen = set; } GetAboutDialogIsOpen()219 bool GetAboutDialogIsOpen() { return m_bAboutDialogIsOpen; } 220 221 #ifdef __WXMAC__ 222 // The following Cocoa routines are in CBOINCGUIApp.mm 223 // 224 bool WasFileModifiedBeforeSystemBoot(char * filePath); 225 void HideThisApp(void); 226 227 #if !wxCHECK_VERSION(3,0,1) 228 // This should be fixed after wxCocoa 3.0.0: 229 // http://trac.wxwidgets.org/ticket/16156 230 231 // Override standard wxCocoa wxApp::CallOnInit() to allow Manager 232 // to run properly when launched hidden on login via Login Item. 233 bool CallOnInit(); 234 #endif 235 236 void CheckPartialActivation(); 237 #endif 238 239 DECLARE_EVENT_TABLE() 240 }; 241 242 DECLARE_APP(CBOINCGUIApp) 243 244 245 #endif 246 247 /// @} 248