llstartup.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. /**
  2. * @file llstartup.h
  3. * @brief Startup routines and logic declaration - Purely static class.
  4. *
  5. * $LicenseInfo:firstyear=2004&license=viewergpl$
  6. *
  7. * Copyright (c) 2004-2009, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #ifndef LL_LLSTARTUP_H
  33. #define LL_LLSTARTUP_H
  34. #include "llerror.h"
  35. class LLMessageSystem;
  36. class LLSLURL;
  37. class LLViewerTexture;
  38. // Constants, variables and enumerations
  39. extern const std::string SCREEN_HOME_FILENAME;
  40. extern const std::string SCREEN_LAST_FILENAME;
  41. extern const std::string SCREEN_LAST_BETA_FILENAME;
  42. // Start location constants
  43. enum EStartLocation
  44. {
  45. START_LOCATION_ID_LAST,
  46. START_LOCATION_ID_HOME,
  47. START_LOCATION_ID_DIRECT,
  48. START_LOCATION_ID_PARCEL,
  49. START_LOCATION_ID_TELEHUB,
  50. START_LOCATION_ID_URL,
  51. START_LOCATION_ID_COUNT
  52. };
  53. typedef enum {
  54. STATE_FIRST, // Initial startup
  55. STATE_BROWSER_INIT, // Initialize web browser for login screen
  56. STATE_LOGIN_SHOW, // Show login screen
  57. STATE_TPV_FIRST_USE, // Show TPV agreement
  58. STATE_LOGIN_WAIT, // Wait for user input at login screen
  59. STATE_LOGIN_CLEANUP, // Get rid of login screen and start login
  60. STATE_UPDATE_CHECK, // Wait for user at a dialog box (updates, term-of-service, etc)
  61. STATE_LOGIN_AUTH_INIT, // Start login to SL servers
  62. STATE_XMLRPC_LOGIN, // XMLRPC login
  63. STATE_LOGIN_NO_DATA_YET, // Waiting for authentication replies to start
  64. STATE_LOGIN_DOWNLOADING, // Waiting for authentication replies to download
  65. STATE_LOGIN_PROCESS_RESPONSE, // Check authentication reply
  66. STATE_WORLD_INIT, // Start building the world
  67. STATE_MULTIMEDIA_INIT, // Init the rest of multimedia library
  68. STATE_SEED_GRANTED_WAIT, // Wait for seed cap grant
  69. STATE_SEED_CAP_GRANTED, // Have seed cap grant
  70. STATE_WORLD_WAIT, // Waiting for simulator
  71. STATE_AGENT_SEND, // Connect to a region
  72. STATE_AGENT_WAIT, // Wait for region
  73. STATE_INVENTORY_SEND, // Do inventory transfer
  74. STATE_MISC, // Do more things (set bandwidth, start audio, save location, etc)
  75. STATE_PRECACHE, // Wait a bit for textures to download
  76. STATE_WEARABLES_WAIT, // Wait for clothing to download
  77. STATE_CLEANUP, // Final cleanup
  78. STATE_STARTED // Up and running in-world
  79. } EStartupState;
  80. class LLStartUp
  81. {
  82. friend class LLLoginHandler;
  83. LLStartUp() = delete;
  84. ~LLStartUp() = delete;
  85. protected:
  86. LOG_CLASS(LLStartUp);
  87. // Get, base64-decode and decipher the user's password or MFA hash from
  88. // settings. Return the corresponding plain hash.
  89. static std::string getPasswordHashFromSettings();
  90. static std::string getMFAHashFromSettings();
  91. // Cipher, base64-encode and save in settings the user's password or MFA
  92. // hash for next login.
  93. static void savePasswordHashToSettings(std::string password);
  94. static void saveMFAHashToSettings(std::string mfa_hash);
  95. public:
  96. static bool idleStartup();
  97. // Always use this to set sStartupState so changes are logged
  98. static void setStartupState(EStartupState state);
  99. LL_INLINE static bool isLoggedIn()
  100. {
  101. return sStartupState == STATE_STARTED;
  102. }
  103. LL_INLINE static EStartupState getStartupState()
  104. {
  105. return sStartupState;
  106. }
  107. LL_INLINE static std::string getStartupStateString()
  108. {
  109. return startupStateToString(sStartupState);
  110. }
  111. // Initializes LLViewerMedia multimedia engine.
  112. static void multimediaInit();
  113. // outfit_folder_name can be a folder anywhere in your inventory,
  114. // but the name must be a case-sensitive exact match.
  115. // gender_name is either "male" or "female"
  116. static void loadInitialOutfit(const std::string& outfit_folder_name,
  117. const std::string& gender_name);
  118. static S32 setStartSLURL(const LLSLURL& slurl);
  119. LL_INLINE static LLSLURL& getStartSLURL() { return sStartSLURL; }
  120. // If we have a SLURL or sim string ("Ahern/123/45") that started the
  121. // viewer, dispatches it.
  122. static bool dispatchURL();
  123. // Initializes the SOCKS 5 proxy, if any
  124. static bool startLLProxy();
  125. static void refreshLoginPanel();
  126. static bool loginAlertDone(const LLSD&, const LLSD&);
  127. static void startAudioEngine();
  128. static void shutdownAudioEngine();
  129. private:
  130. static void resetLogin();
  131. static bool loginShow(bool update_servers);
  132. static void initStartScreen(S32 location_id);
  133. static void setStartupStatus(F32 frac, const std::string& string,
  134. const std::string& msg);
  135. static std::string startupStateToString(EStartupState state);
  136. static void updateTextureFetch();
  137. static void applyUdpBlacklist(const std::string& csv);
  138. static void loginCallback(S32 option, void*);
  139. static void useCircuitCallback(void**, S32 result);
  140. static bool loginAlertStatus(const LLSD&, const LLSD&);
  141. static bool callbackChooseGender(const LLSD& notification,
  142. const LLSD& response);
  143. static void callbackCacheName(const LLUUID& id,
  144. const std::string& fullname,
  145. bool is_group);
  146. static void registerViewerCallbacks(LLMessageSystem* msg);
  147. private:
  148. // Do not set directly, use LLStartup::setStartupState
  149. static EStartupState sStartupState;
  150. static std::string sInitialOutfit;
  151. static std::string sInitialOutfitGender; // "male" or "female"
  152. static LLSLURL sLoginSLURL;
  153. static LLSLURL sStartSLURL;
  154. };
  155. // Exported globals
  156. extern LLPointer<LLViewerTexture> gStartTexture;
  157. extern S32 gMaxAgentGroups;
  158. extern bool gAgentMovementCompleted;
  159. extern std::string gLoginFirstName;
  160. extern std::string gLoginLastName;
  161. #endif // LL_LLSTARTUP_H