00001 00032 #ifndef LL_LLAPPVIEWER_H 00033 #define LL_LLAPPVIEWER_H 00034 00035 class LLTextureCache; 00036 class LLWorkerThread; 00037 class LLTextureFetch; 00038 class LLWatchdogTimeout; 00039 class LLCommandLineParser; 00040 00041 class LLAppViewer : public LLApp 00042 { 00043 public: 00044 LLAppViewer(); 00045 virtual ~LLAppViewer(); 00046 00053 static LLAppViewer* instance() {return sInstance; } 00054 00055 // 00056 // Main application logic 00057 // 00058 virtual bool init(); // Override to do application initialization 00059 virtual bool cleanup(); // Override to do application cleanup 00060 virtual bool mainLoop(); // Override for the application main loop. Needs to at least gracefully notice the QUITTING state and exit. 00061 00062 // Application control 00063 void forceQuit(); // Puts the viewer into 'shutting down without error' mode. 00064 void requestQuit(); // Request a quit. A kinder, gentler quit. 00065 void userQuit(); // The users asks to quit. Confirm, then requestQuit() 00066 void earlyExit(const LLString& msg); // Display an error dialog and forcibly quit. 00067 void forceExit(S32 arg); // exit() immediately (after some cleanup). 00068 void abortQuit(); // Called to abort a quit request. 00069 00070 bool quitRequested() { return mQuitRequested; } 00071 bool logoutRequestSent() { return mLogoutRequestSent; } 00072 00073 void closeDebug(); 00074 00075 const LLOSInfo& getOSInfo() const { return mSysOSInfo; } 00076 00077 // Report true if under the control of a debugger. A null-op default. 00078 virtual bool beingDebugged() { return false; } 00079 00080 S32 getCrashBehavior() const { return mCrashBehavior; } 00081 void setCrashBehavior(S32 cb); 00082 virtual void handleCrashReporting() = 0; // What to do with crash report? 00083 virtual void handleSyncCrashTrace() = 0; // any low-level crash-prep that has to happen in the context of the crashing thread before the crash report is delivered. 00084 static void handleViewerCrash(); // Hey! The viewer crashed. Do this, soon. 00085 static void handleSyncViewerCrash(); // Hey! The viewer crashed. Do this right NOW in the context of the crashing thread. 00086 00087 // Thread accessors 00088 static LLTextureCache* getTextureCache() { return sTextureCache; } 00089 static LLWorkerThread* getImageDecodeThread() { return sImageDecodeThread; } 00090 static LLTextureFetch* getTextureFetch() { return sTextureFetch; } 00091 00092 const std::string& getSerialNumber() { return mSerialNumber; } 00093 00094 bool getPurgeCache() const { return mPurgeCache; } 00095 00096 const LLString& getSecondLifeTitle() const; // The Second Life title. 00097 const LLString& getWindowTitle() const; // The window display name. 00098 00099 // Helpers for URIs 00100 void addLoginURI(const std::string& uri); 00101 void setHelperURI(const std::string& uri); 00102 const std::vector<std::string>& getLoginURIs() const; 00103 const std::string& getHelperURI() const; 00104 void resetURIs() const; 00105 00106 void forceDisconnect(const LLString& msg); // Force disconnection, with a message to the user. 00107 void badNetworkHandler(); // Cause a crash state due to bad network packet. 00108 00109 bool hasSavedFinalSnapshot() { return mSavedFinalSnapshot; } 00110 void saveFinalSnapshot(); 00111 00112 void loadNameCache(); 00113 void saveNameCache(); 00114 00115 bool isInProductionGrid(); 00116 00117 void removeMarkerFile(bool leave_logout_marker = false); 00118 00119 // LLAppViewer testing helpers. 00120 // *NOTE: These will potentially crash the viewer. Only for debugging. 00121 virtual void forceErrorLLError(); 00122 virtual void forceErrorBreakpoint(); 00123 virtual void forceErrorBadMemoryAccess(); 00124 virtual void forceErrorInifiniteLoop(); 00125 virtual void forceErrorSoftwareException(); 00126 00127 // *NOTE: There are currently 3 settings files: 00128 // "Global", "PerAccount" and "CrashSettings" 00129 // The list is found in app_settings/settings_files.xml 00130 // but since they are used explicitly in code, 00131 // the follow consts should also do the trick. 00132 static const std::string sGlobalSettingsName; 00133 static const std::string sPerAccountSettingsName; 00134 static const std::string sCrashSettingsName; 00135 00136 void loadSettingsFromDirectory(ELLPath path_index); 00137 00138 std::string getSettingsFileName(const std::string& file); 00139 00140 // For thread debugging. 00141 // llstartup needs to control this. 00142 // llworld, send_agent_pause() also controls this. 00143 void startMainloopTimeout(F32 secs = -1.0f); 00144 void stopMainloopTimeout(); 00145 00146 protected: 00147 virtual bool initWindow(); // Initialize the viewer's window. 00148 virtual bool initLogging(); // Initialize log files, logging system, return false on failure. 00149 virtual void initConsole() {}; // Initialize OS level debugging console. 00150 virtual bool initHardwareTest() { return true; } // A false result indicates the app should quit. 00151 00152 virtual bool initParseCommandLine(LLCommandLineParser& clp) 00153 { return true; } // Allow platforms to specify the command line args. 00154 00155 virtual std::string generateSerialNumber() = 0; // Platforms specific classes generate this. 00156 00157 00158 private: 00159 00160 bool initThreads(); // Initialize viewer threads, return false on failure. 00161 bool initConfiguration(); // Initialize settings from the command line/config file. 00162 00163 bool initCache(); // Initialize local client cache. 00164 void purgeCache(); // Clear the local cache. 00165 00166 void cleanupSavedSettings(); // Sets some config data to current or default values during cleanup. 00167 void removeCacheFiles(const char *filemask); // Deletes cached files the match the given wildcard. 00168 00169 void writeSystemInfo(); // Write system info to "debug_info.log" 00170 00171 bool anotherInstanceRunning(); 00172 void initMarkerFile(); 00173 00174 void idle(); 00175 void idleShutdown(); 00176 void idleNetwork(); 00177 00178 void sendLogoutRequest(); 00179 void disconnectViewer(); 00180 00181 // *FIX: the app viewer class should be some sort of singleton, no? 00182 // Perhaps its child class is the singleton and this should be an abstract base. 00183 static LLAppViewer* sInstance; 00184 00185 bool mSecondInstance; // Is this a second instance of the app? 00186 00187 LLString mMarkerFileName; 00188 apr_file_t* mMarkerFile; // A file created to indicate the app is running. 00189 00190 LLString mLogoutMarkerFileName; 00191 apr_file_t* mLogoutMarkerFile; // A file created to indicate the app is running. 00192 00193 00194 LLOSInfo mSysOSInfo; 00195 S32 mCrashBehavior; 00196 bool mReportedCrash; 00197 00198 // Thread objects. 00199 static LLTextureCache* sTextureCache; 00200 static LLWorkerThread* sImageDecodeThread; 00201 static LLTextureFetch* sTextureFetch; 00202 00203 S32 mNumSessions; 00204 00205 std::string mSerialNumber; 00206 bool mPurgeCache; 00207 bool mPurgeOnExit; 00208 00209 bool mSavedFinalSnapshot; 00210 00211 bool mQuitRequested; // User wants to quit, may have modified documents open. 00212 bool mLogoutRequestSent; // Disconnect message sent to simulator, no longer safe to send messages to the sim. 00213 S32 mYieldTime; 00214 LLSD mSettingsFileList; 00215 00216 LLWatchdogTimeout* mMainloopTimeout; 00217 }; 00218 00219 // consts from viewer.h 00220 const S32 AGENT_UPDATES_PER_SECOND = 10; 00221 00222 // Globals with external linkage. From viewer.h 00223 // *NOTE:Mani - These will be removed as the Viewer App Cleanup project continues. 00224 // 00225 // "// llstartup" indicates that llstartup is the only client for this global. 00226 00227 extern BOOL gHandleKeysAsync; // gSavedSettings used by llviewerdisplay.cpp & llviewermenu.cpp 00228 extern LLString gDisabledMessage; // llstartup 00229 extern BOOL gHideLinks; // used by llpanellogin, lllfloaterbuycurrency, llstartup 00230 extern LLSD gDebugInfo; 00231 00232 extern BOOL gAllowIdleAFK; 00233 extern BOOL gAllowTapTapHoldRun; 00234 extern BOOL gShowObjectUpdates; 00235 00236 extern BOOL gAcceptTOS; 00237 extern BOOL gAcceptCriticalMessage; 00238 00239 00240 typedef enum 00241 { 00242 LAST_EXEC_NORMAL = 0, 00243 LAST_EXEC_FROZE, 00244 LAST_EXEC_LLERROR_CRASH, 00245 LAST_EXEC_OTHER_CRASH, 00246 LAST_EXEC_LOGOUT_FROZE, 00247 LAST_EXEC_LOGOUT_CRASH 00248 } eLastExecEvent; 00249 00250 extern eLastExecEvent gLastExecEvent; // llstartup 00251 00252 extern U32 gFrameCount; 00253 extern U32 gForegroundFrameCount; 00254 00255 extern LLPumpIO* gServicePump; 00256 00257 // Is the Pacific time zone (aka server time zone) 00258 // currently in daylight savings time? 00259 extern BOOL gPacificDaylightTime; 00260 00261 extern U64 gFrameTime; // The timestamp of the most-recently-processed frame 00262 extern F32 gFrameTimeSeconds; // Loses msec precision after ~4.5 hours... 00263 extern F32 gFrameIntervalSeconds; // Elapsed time between current and previous gFrameTimeSeconds 00264 extern F32 gFPSClamped; // Frames per second, smoothed, weighted toward last frame 00265 extern F32 gFrameDTClamped; 00266 extern U64 gStartTime; 00267 00268 extern LLTimer gRenderStartTime; 00269 extern LLFrameTimer gForegroundTime; 00270 00271 extern F32 gLogoutMaxTime; 00272 extern LLTimer gLogoutTimer; 00273 00274 extern F32 gSimLastTime; 00275 extern F32 gSimFrames; 00276 00277 extern LLUUID gInventoryLibraryOwner; 00278 extern LLUUID gInventoryLibraryRoot; 00279 00280 extern BOOL gDisconnected; 00281 00282 // Map scale in pixels per region 00283 extern F32 gMapScale; 00284 extern F32 gMiniMapScale; 00285 00286 extern LLFrameTimer gRestoreGLTimer; 00287 extern BOOL gRestoreGL; 00288 extern BOOL gUseWireframe; 00289 00290 // VFS globals - gVFS is for general use 00291 // gStaticVFS is read-only and is shipped w/ the viewer 00292 // it has pre-cache data like the UI .TGAs 00293 extern LLVFS *gStaticVFS; 00294 00295 extern LLMemoryInfo gSysMemory; 00296 00297 extern LLString gLastVersionChannel; 00298 00299 extern LLVector3 gWindVec; 00300 extern LLVector3 gRelativeWindVec; 00301 extern U32 gPacketsIn; 00302 extern BOOL gPrintMessagesThisFrame; 00303 00304 extern LLUUID gSunTextureID; 00305 extern LLUUID gMoonTextureID; 00306 00307 extern BOOL gRandomizeFramerate; 00308 extern BOOL gPeriodicSlowFrame; 00309 00310 #endif // LL_LLAPPVIEWER_H