summaryrefslogtreecommitdiff
path: root/indra/newview/llappviewer.h
blob: 9518636f87b1ba2b98b76ce79872792790ebf517 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
/** 
 * @file llappviewer.h
 * @brief The LLAppViewer class declaration
 *
 * $LicenseInfo:firstyear=2007&license=viewergpl$
 * 
 * Copyright (c) 2007, Linden Research, Inc.
 * 
 * Second Life Viewer Source Code
 * The source code in this file ("Source Code") is provided by Linden Lab
 * to you under the terms of the GNU General Public License, version 2.0
 * ("GPL"), unless you have obtained a separate licensing agreement
 * ("Other License"), formally executed by you and Linden Lab.  Terms of
 * the GPL can be found in doc/GPL-license.txt in this distribution, or
 * online at http://secondlife.com/developers/opensource/gplv2
 * 
 * There are special exceptions to the terms and conditions of the GPL as
 * it is applied to this Source Code. View the full text of the exception
 * in the file doc/FLOSS-exception.txt in this software distribution, or
 * online at http://secondlife.com/developers/opensource/flossexception
 * 
 * By copying, modifying or distributing this software, you acknowledge
 * that you have read and understood your obligations described above,
 * and agree to abide by those obligations.
 * 
 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
 * COMPLETENESS OR PERFORMANCE.
 * $/LicenseInfo$
 */

#ifndef LL_LLAPPVIEWER_H
#define LL_LLAPPVIEWER_H

class LLTextureCache;
class LLWorkerThread;
class LLTextureFetch;

class LLAppViewer : public LLApp
{
public:
	LLAppViewer();
	virtual ~LLAppViewer();

	// *NOTE:Mani - Don't use this!
	// Having 
	static LLAppViewer* instance() {return sInstance; } 

	//
	// Main application logic
	//
	virtual bool init();			// Override to do application initialization
	virtual bool cleanup();			// Override to do application cleanup
	virtual bool mainLoop(); // Override for the application main loop.  Needs to at least gracefully notice the QUITTING state and exit.

	// Application control
	void forceQuit(); // Puts the viewer into 'shutting down without error' mode.
	void requestQuit(); // Request a quit. A kinder, gentler quit.
	void userQuit(); // The users asks to quit. Confirm, then requestQuit()
    void earlyExit(const LLString& msg); // Display an error dialog and forcibly quit.
    void forceExit(S32 arg); // exit() immediately (after some cleanup).
    void abortQuit();  // Called to abort a quit request.

    bool quitRequested() { return mQuitRequested; }
    bool logoutRequestSent() { return mLogoutRequestSent; }

	// *FIX: This is meant to stay only until the command line issues are hashed out with repect to LLApp::parseCommandLine
	// This version stores the argc and argv for later usage, make sure the params passed in last as long as this class.
	bool tempStoreCommandOptions(int argc, char** argv);

	void closeDebug();

	const LLOSInfo& getOSInfo() const { return mSysOSInfo; }

	// Report true if under the control of a debugger. A null-op default.
	virtual bool beingDebugged() { return false; } 

	S32 getCrashBehavior() const { return mCrashBehavior; } 
	void setCrashBehavior(S32 cb);
	virtual void handleCrashReporting() = 0; // What to do with crash report?
	static void handleViewerCrash(); // Hey! The viewer crashed. Do this.

	// Thread accessors
	static LLTextureCache* getTextureCache() { return sTextureCache; }
	static LLWorkerThread* getImageDecodeThread() { return sImageDecodeThread; }
	static LLTextureFetch* getTextureFetch() { return sTextureFetch; }

	const std::string& getSerialNumber() { return mSerialNumber; }
	
	// *FIX:Mani purgeCache was made public for parse_args().
	// If that beast is gone, make it private.
	void purgeCache(); // Clear the local cache. 
	bool getPurgeCache() const { return mPurgeCache; }
	
	const LLString& getSecondLifeTitle() const; // The Second Life title.
	const LLString& getWindowTitle() const; // The window display name.

    // Helpers for URIs
    void addLoginURI(const std::string& uri);
    void setHelperURI(const std::string& uri);
    const std::vector<std::string>& getLoginURIs() const;
    const std::string& getHelperURI() const;
    void resetURIs() const;
    void setLoginPage(const std::string& login_page);
    const std::string& getLoginPage();

    void forceDisconnect(const LLString& msg); // Force disconnection, with a message to the user.
    void badNetworkHandler(); // Cause a crash state due to bad network packet.

	bool hasSavedFinalSnapshot() { return mSavedFinalSnapshot; }
	void saveFinalSnapshot(); 

    void loadNameCache();
    void saveNameCache();

    bool isInProductionGrid();

	void removeMarkerFile();
	
    // LLAppViewer testing helpers.
    // *NOTE: These will potentially crash the viewer. Only for debugging.
    virtual void forceErrorLLError();
    virtual void forceErrorBreakpoint();
    virtual void forceErrorBadMemoryAccess();
    virtual void forceErrorInifiniteLoop();
    virtual void forceErrorSoftwareException();

protected:
	virtual bool initWindow(); // Initialize the viewer's window.
	virtual bool initLogging(); // Initialize log files, logging system, return false on failure.
	virtual bool initHardwareTest() { return true; } // A false result indicates the app should quit.
	
	virtual std::string generateSerialNumber() = 0; // Platforms specific classes generate this.


private:

	bool initEarlyConfiguration(); // Initialize setting needed by crash reporting.
	bool initThreads(); // Initialize viewer threads, return false on failure.
	bool initConfiguration(); // Initialize settings from the command line/config file.

	bool initCache(); // Initialize local client cache.

	bool doConfigFromCommandLine(); // calls parse args.

	void cleanupSavedSettings(); // Sets some config data to current or default values during cleanup.
	void removeCacheFiles(const char *filemask); // Deletes cached files the match the given wildcard.

	void writeSystemInfo(); // Write system info to "debug_info.log"

	bool anotherInstanceRunning(); 
	void initMarkerFile(); 
    
    void idle(); 
    void idleShutdown();
    void idleNetwork();

    void sendLogoutRequest();
    void disconnectViewer();

	// *FIX: the app viewer class should be some sort of singleton, no?
	// Perhaps its child class is the singleton and this should be an abstract base.
	static LLAppViewer* sInstance; 

    bool mSecondInstance; // Is this a second instance of the app?

	LLString mMarkerFileName;
	apr_file_t* mMarkerFile; // A file created to indicate the app is running.

	LLOSInfo mSysOSInfo; 
	S32 mCrashBehavior;
	bool mReportedCrash;

	// Thread objects.
	static LLTextureCache* sTextureCache; 
	static LLWorkerThread* sImageDecodeThread; 
	static LLTextureFetch* sTextureFetch;

	S32 mNumSessions;

	std::string mSerialNumber;
	bool mPurgeCache;
    bool mPurgeOnExit;

	bool mSavedFinalSnapshot;

    bool mQuitRequested;				// User wants to quit, may have modified documents open.
    bool mLogoutRequestSent;			// Disconnect message sent to simulator, no longer safe to send messages to the sim.
};

// consts from viewer.h
const S32 AGENT_UPDATES_PER_SECOND  = 10;

// Globals with external linkage. From viewer.h
// *NOTE:Mani - These will be removed as the Viewer App Cleanup project continues.
//
// "// llstartup" indicates that llstartup is the only client for this global.

extern bool gVerifySSLCert; // parse_args setting used by llxmlrpctransaction.cpp
extern BOOL gHandleKeysAsync; // gSavedSettings used by llviewerdisplay.cpp & llviewermenu.cpp
extern BOOL gProbeHardware;
extern LLString gDisabledMessage; // llstartup
extern BOOL gHideLinks; // used by llpanellogin, lllfloaterbuycurrency, llstartup
extern LLSD gDebugInfo;

extern BOOL	gAllowIdleAFK;
extern F32 gAFKTimeout;
extern BOOL	gShowObjectUpdates;

extern BOOL gLogMessages; // llstartup 
extern std::string gChannelName;
extern BOOL gUseAudio; // llstartup

extern LLString gCmdLineFirstName; // llstartup
extern LLString gCmdLineLastName;
extern LLString gCmdLinePassword;

extern BOOL gAutoLogin; // llstartup
extern const char* DEFAULT_SETTINGS_FILE; // llstartup

extern BOOL gRequestInventoryLibrary; // llstartup
extern BOOL gGodConnect; // llstartup

extern BOOL gAcceptTOS;
extern BOOL gAcceptCriticalMessage;

extern LLUUID	gViewerDigest;  // MD5 digest of the viewer's executable file.

typedef enum 
{
	LAST_EXEC_NORMAL = 0,
	LAST_EXEC_FROZE,
	LAST_EXEC_LLERROR_CRASH,
	LAST_EXEC_OTHER_CRASH
} eLastExecEvent;

extern eLastExecEvent gLastExecEvent; // llstartup

extern U32 gFrameCount;
extern U32 gForegroundFrameCount;

extern LLPumpIO* gServicePump;

// Is the Pacific time zone (aka server time zone)
// currently in daylight savings time?
extern BOOL gPacificDaylightTime;

extern U64      gFrameTime;					// The timestamp of the most-recently-processed frame
extern F32		gFrameTimeSeconds;			// Loses msec precision after ~4.5 hours...
extern F32		gFrameIntervalSeconds;		// Elapsed time between current and previous gFrameTimeSeconds
extern F32		gFPSClamped;						// Frames per second, smoothed, weighted toward last frame
extern F32		gFrameDTClamped;
extern U64		gStartTime;

extern LLTimer gRenderStartTime;
extern LLFrameTimer gForegroundTime;

extern F32 gLogoutMaxTime;
extern LLTimer gLogoutTimer;

extern F32 gSimLastTime; 
extern F32 gSimFrames;

extern LLUUID gInventoryLibraryOwner;
extern LLUUID gInventoryLibraryRoot;

extern BOOL		gDisconnected;
extern BOOL		gDisableVoice;

// Map scale in pixels per region
extern F32 gMapScale;
extern F32 gMiniMapScale;

extern LLFrameTimer	gRestoreGLTimer;
extern BOOL			gRestoreGL;
extern BOOL		gUseWireframe;

extern F32 gMouseSensitivity;
extern BOOL gInvertMouse;

// VFS globals - gVFS is for general use
// gStaticVFS is read-only and is shipped w/ the viewer
// it has pre-cache data like the UI .TGAs
extern LLVFS	*gStaticVFS;

extern LLMemoryInfo gSysMemory;

extern bool gPreloadImages;
extern bool gPreloadSounds;

extern LLString gLastVersionChannel;

extern LLVector3 gWindVec;
extern LLVector3 gRelativeWindVec;
extern U32	gPacketsIn;
extern BOOL gPrintMessagesThisFrame;

extern LLUUID gSunTextureID;
extern LLUUID gMoonTextureID;

extern BOOL gUseConsole; 

extern BOOL gRandomizeFramerate;
extern BOOL gPeriodicSlowFrame;

extern BOOL gQAMode;
#endif // LL_LLAPPVIEWER_H