PageRenderTime 48ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/newview/llstartup.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 2004 lines | 1358 code | 273 blank | 373 comment | 210 complexity | 603f9e6c06d16124425fed069407d556 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llstartup.cpp
  3. * @brief startup routines.
  4. *
  5. * $LicenseInfo:firstyear=2004&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2010, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #include "llviewerprecompiledheaders.h"
  27. #include "llstartup.h"
  28. #if LL_WINDOWS
  29. # include <process.h> // _spawnl()
  30. #else
  31. # include <sys/stat.h> // mkdir()
  32. #endif
  33. #include "llviewermedia_streamingaudio.h"
  34. #include "llaudioengine.h"
  35. #ifdef LL_FMOD
  36. # include "llaudioengine_fmod.h"
  37. #endif
  38. #ifdef LL_OPENAL
  39. #include "llaudioengine_openal.h"
  40. #endif
  41. #include "llares.h"
  42. #include "llavatarnamecache.h"
  43. #include "lllandmark.h"
  44. #include "llcachename.h"
  45. #include "lldir.h"
  46. #include "llerrorcontrol.h"
  47. #include "llfloaterreg.h"
  48. #include "llfocusmgr.h"
  49. #include "llhttpsender.h"
  50. #include "llimfloater.h"
  51. #include "lllocationhistory.h"
  52. #include "llimageworker.h"
  53. #include "llloginflags.h"
  54. #include "llmd5.h"
  55. #include "llmemorystream.h"
  56. #include "llmessageconfig.h"
  57. #include "llmoveview.h"
  58. #include "llnearbychat.h"
  59. #include "llnotifications.h"
  60. #include "llnotificationsutil.h"
  61. #include "llteleporthistory.h"
  62. #include "llregionhandle.h"
  63. #include "llsd.h"
  64. #include "llsdserialize.h"
  65. #include "llsdutil_math.h"
  66. #include "llsecondlifeurls.h"
  67. #include "llstring.h"
  68. #include "lluserrelations.h"
  69. #include "llversioninfo.h"
  70. #include "llviewercontrol.h"
  71. #include "llviewerhelp.h"
  72. #include "llvfs.h"
  73. #include "llxorcipher.h" // saved password, MAC address
  74. #include "llwindow.h"
  75. #include "imageids.h"
  76. #include "message.h"
  77. #include "v3math.h"
  78. #include "llagent.h"
  79. #include "llagentcamera.h"
  80. #include "llagentpicksinfo.h"
  81. #include "llagentwearables.h"
  82. #include "llagentpilot.h"
  83. #include "llfloateravatarpicker.h"
  84. #include "llcallbacklist.h"
  85. #include "llcallingcard.h"
  86. #include "llconsole.h"
  87. #include "llcontainerview.h"
  88. #include "lldebugview.h"
  89. #include "lldrawable.h"
  90. #include "lleventnotifier.h"
  91. #include "llface.h"
  92. #include "llfeaturemanager.h"
  93. //#include "llfirstuse.h"
  94. #include "llfloaterhud.h"
  95. #include "llfloaterland.h"
  96. #include "llfloaterpreference.h"
  97. #include "llfloatertopobjects.h"
  98. #include "llfloaterworldmap.h"
  99. #include "llgesturemgr.h"
  100. #include "llgroupmgr.h"
  101. #include "llhudeffecttrail.h"
  102. #include "llhudmanager.h"
  103. #include "llhttpclient.h"
  104. #include "llimagebmp.h"
  105. #include "llinventorybridge.h"
  106. #include "llinventorymodel.h"
  107. #include "llinventorymodelbackgroundfetch.h"
  108. #include "llkeyboard.h"
  109. #include "llloginhandler.h" // gLoginHandler, SLURL support
  110. #include "lllogininstance.h" // Host the login module.
  111. #include "llpanellogin.h"
  112. #include "llmutelist.h"
  113. #include "llavatarpropertiesprocessor.h"
  114. #include "llpanelclassified.h"
  115. #include "llpanelpick.h"
  116. #include "llpanelgrouplandmoney.h"
  117. #include "llpanelgroupnotices.h"
  118. #include "llpreview.h"
  119. #include "llpreviewscript.h"
  120. #include "llproxy.h"
  121. #include "llproductinforequest.h"
  122. #include "llsecondlifeurls.h"
  123. #include "llselectmgr.h"
  124. #include "llsky.h"
  125. #include "llstatview.h"
  126. #include "llstatusbar.h" // sendMoneyBalanceRequest(), owns L$ balance
  127. #include "llsurface.h"
  128. #include "lltexturecache.h"
  129. #include "lltexturefetch.h"
  130. #include "lltoolmgr.h"
  131. #include "lltrans.h"
  132. #include "llui.h"
  133. #include "llurldispatcher.h"
  134. #include "llurlentry.h"
  135. #include "llslurl.h"
  136. #include "llurlhistory.h"
  137. #include "llurlwhitelist.h"
  138. #include "llvieweraudio.h"
  139. #include "llviewerassetstorage.h"
  140. #include "llviewercamera.h"
  141. #include "llviewerdisplay.h"
  142. #include "llviewergenericmessage.h"
  143. #include "llviewergesture.h"
  144. #include "llviewertexturelist.h"
  145. #include "llviewermedia.h"
  146. #include "llviewermenu.h"
  147. #include "llviewermessage.h"
  148. #include "llviewernetwork.h"
  149. #include "llviewerobjectlist.h"
  150. #include "llviewerparcelmedia.h"
  151. #include "llviewerparcelmgr.h"
  152. #include "llviewerregion.h"
  153. #include "llviewerstats.h"
  154. #include "llviewerthrottle.h"
  155. #include "llviewerwindow.h"
  156. #include "llvoavatar.h"
  157. #include "llvoavatarself.h"
  158. #include "llweb.h"
  159. #include "llworld.h"
  160. #include "llworldmapmessage.h"
  161. #include "llxfermanager.h"
  162. #include "pipeline.h"
  163. #include "llappviewer.h"
  164. #include "llfasttimerview.h"
  165. #include "llfloatermap.h"
  166. #include "llweb.h"
  167. #include "llvoiceclient.h"
  168. #include "llnamelistctrl.h"
  169. #include "llnamebox.h"
  170. #include "llnameeditor.h"
  171. #include "llpostprocess.h"
  172. #include "llwlparammanager.h"
  173. #include "llwaterparammanager.h"
  174. #include "llagentlanguage.h"
  175. #include "llwearable.h"
  176. #include "llinventorybridge.h"
  177. #include "llappearancemgr.h"
  178. #include "llavatariconctrl.h"
  179. #include "llvoicechannel.h"
  180. #include "lllogin.h"
  181. #include "llevents.h"
  182. #include "llstartuplistener.h"
  183. #include "lltoolbarview.h"
  184. #if LL_WINDOWS
  185. #include "lldxhardware.h"
  186. #endif
  187. //
  188. // exported globals
  189. //
  190. bool gAgentMovementCompleted = false;
  191. S32 gMaxAgentGroups;
  192. std::string SCREEN_HOME_FILENAME = "screen_home.bmp";
  193. std::string SCREEN_LAST_FILENAME = "screen_last.bmp";
  194. LLPointer<LLViewerTexture> gStartTexture;
  195. //
  196. // Imported globals
  197. //
  198. extern S32 gStartImageWidth;
  199. extern S32 gStartImageHeight;
  200. //
  201. // local globals
  202. //
  203. static bool gGotUseCircuitCodeAck = false;
  204. static std::string sInitialOutfit;
  205. static std::string sInitialOutfitGender; // "male" or "female"
  206. static boost::signals2::connection sWearablesLoadedCon;
  207. static bool gUseCircuitCallbackCalled = false;
  208. EStartupState LLStartUp::gStartupState = STATE_FIRST;
  209. LLSLURL LLStartUp::sStartSLURL;
  210. static LLPointer<LLCredential> gUserCredential;
  211. static std::string gDisplayName;
  212. static BOOL gRememberPassword = TRUE;
  213. static U64 gFirstSimHandle = 0;
  214. static LLHost gFirstSim;
  215. static std::string gFirstSimSeedCap;
  216. static LLVector3 gAgentStartLookAt(1.0f, 0.f, 0.f);
  217. static std::string gAgentStartLocation = "safe";
  218. static bool mLoginStatePastUI = false;
  219. boost::scoped_ptr<LLEventPump> LLStartUp::sStateWatcher(new LLEventStream("StartupState"));
  220. boost::scoped_ptr<LLStartupListener> LLStartUp::sListener(new LLStartupListener());
  221. //
  222. // local function declaration
  223. //
  224. void login_show();
  225. void login_callback(S32 option, void* userdata);
  226. void show_first_run_dialog();
  227. bool first_run_dialog_callback(const LLSD& notification, const LLSD& response);
  228. void set_startup_status(const F32 frac, const std::string& string, const std::string& msg);
  229. bool login_alert_status(const LLSD& notification, const LLSD& response);
  230. void login_packet_failed(void**, S32 result);
  231. void use_circuit_callback(void**, S32 result);
  232. void register_viewer_callbacks(LLMessageSystem* msg);
  233. void asset_callback_nothing(LLVFS*, const LLUUID&, LLAssetType::EType, void*, S32);
  234. bool callback_choose_gender(const LLSD& notification, const LLSD& response);
  235. void init_start_screen(S32 location_id);
  236. void release_start_screen();
  237. void reset_login();
  238. LLSD transform_cert_args(LLPointer<LLCertificate> cert);
  239. void general_cert_done(const LLSD& notification, const LLSD& response);
  240. void trust_cert_done(const LLSD& notification, const LLSD& response);
  241. void apply_udp_blacklist(const std::string& csv);
  242. bool process_login_success_response();
  243. void transition_back_to_login_panel(const std::string& emsg);
  244. void callback_cache_name(const LLUUID& id, const std::string& full_name, bool is_group)
  245. {
  246. LLNameBox::refreshAll(id, full_name, is_group);
  247. LLNameEditor::refreshAll(id, full_name, is_group);
  248. // TODO: Actually be intelligent about the refresh.
  249. // For now, just brute force refresh the dialogs.
  250. dialog_refresh_all();
  251. }
  252. //
  253. // exported functionality
  254. //
  255. //
  256. // local classes
  257. //
  258. namespace
  259. {
  260. class LLNullHTTPSender : public LLHTTPSender
  261. {
  262. virtual void send(const LLHost& host,
  263. const std::string& message, const LLSD& body,
  264. LLHTTPClient::ResponderPtr response) const
  265. {
  266. LL_WARNS("AppInit") << " attemped to send " << message << " to " << host
  267. << " with null sender" << LL_ENDL;
  268. }
  269. };
  270. }
  271. void update_texture_fetch()
  272. {
  273. LLAppViewer::getTextureCache()->update(1); // unpauses the texture cache thread
  274. LLAppViewer::getImageDecodeThread()->update(1); // unpauses the image thread
  275. LLAppViewer::getTextureFetch()->update(1); // unpauses the texture fetch thread
  276. gTextureList.updateImages(0.10f);
  277. }
  278. // Returns false to skip other idle processing. Should only return
  279. // true when all initialization done.
  280. bool idle_startup()
  281. {
  282. LLMemType mt1(LLMemType::MTYPE_STARTUP);
  283. const F32 PRECACHING_DELAY = gSavedSettings.getF32("PrecachingDelay");
  284. static LLTimer timeout;
  285. static S32 timeout_count = 0;
  286. static LLTimer login_time;
  287. // until this is encapsulated, this little hack for the
  288. // auth/transform loop will do.
  289. static F32 progress = 0.10f;
  290. static std::string auth_desc;
  291. static std::string auth_message;
  292. static LLVector3 initial_sun_direction(1.f, 0.f, 0.f);
  293. static LLVector3 agent_start_position_region(10.f, 10.f, 10.f); // default for when no space server
  294. // last location by default
  295. static S32 agent_location_id = START_LOCATION_ID_LAST;
  296. static S32 location_which = START_LOCATION_ID_LAST;
  297. static bool show_connect_box = true;
  298. //static bool stipend_since_login = false;
  299. // HACK: These are things from the main loop that usually aren't done
  300. // until initialization is complete, but need to be done here for things
  301. // to work.
  302. gIdleCallbacks.callFunctions();
  303. gViewerWindow->updateUI();
  304. LLMortician::updateClass();
  305. const std::string delims (" ");
  306. std::string system;
  307. int begIdx, endIdx;
  308. std::string osString = LLAppViewer::instance()->getOSInfo().getOSStringSimple();
  309. begIdx = osString.find_first_not_of (delims);
  310. endIdx = osString.find_first_of (delims, begIdx);
  311. system = osString.substr (begIdx, endIdx - begIdx);
  312. system += "Locale";
  313. LLStringUtil::setLocale (LLTrans::getString(system));
  314. //note: Removing this line will cause incorrect button size in the login screen. -- bao.
  315. gTextureList.updateImages(0.01f) ;
  316. if ( STATE_FIRST == LLStartUp::getStartupState() )
  317. {
  318. gViewerWindow->showCursor();
  319. gViewerWindow->getWindow()->setCursor(UI_CURSOR_WAIT);
  320. /////////////////////////////////////////////////
  321. //
  322. // Initialize stuff that doesn't need data from simulators
  323. //
  324. std::string lastGPU = gSavedSettings.getString("LastGPUString");
  325. std::string thisGPU = LLFeatureManager::getInstance()->getGPUString();
  326. if (LLFeatureManager::getInstance()->isSafe())
  327. {
  328. LLNotificationsUtil::add("DisplaySetToSafe");
  329. }
  330. else if ((gSavedSettings.getS32("LastFeatureVersion") < LLFeatureManager::getInstance()->getVersion()) &&
  331. (gSavedSettings.getS32("LastFeatureVersion") != 0))
  332. {
  333. LLNotificationsUtil::add("DisplaySetToRecommendedFeatureChange");
  334. }
  335. else if ( ! lastGPU.empty() && (lastGPU != thisGPU))
  336. {
  337. LLSD subs;
  338. subs["LAST_GPU"] = lastGPU;
  339. subs["THIS_GPU"] = thisGPU;
  340. LLNotificationsUtil::add("DisplaySetToRecommendedGPUChange", subs);
  341. }
  342. else if (!gViewerWindow->getInitAlert().empty())
  343. {
  344. LLNotificationsUtil::add(gViewerWindow->getInitAlert());
  345. }
  346. //-------------------------------------------------
  347. // Init the SOCKS 5 proxy if the user has configured
  348. // one. We need to do this early in case the user
  349. // is using SOCKS for HTTP so we get the login
  350. // screen and HTTP tables via SOCKS.
  351. //-------------------------------------------------
  352. LLStartUp::startLLProxy();
  353. gSavedSettings.setS32("LastFeatureVersion", LLFeatureManager::getInstance()->getVersion());
  354. gSavedSettings.setString("LastGPUString", thisGPU);
  355. // load dynamic GPU/feature tables from website (S3)
  356. LLFeatureManager::getInstance()->fetchHTTPTables();
  357. std::string xml_file = LLUI::locateSkin("xui_version.xml");
  358. LLXMLNodePtr root;
  359. bool xml_ok = false;
  360. if (LLXMLNode::parseFile(xml_file, root, NULL))
  361. {
  362. if( (root->hasName("xui_version") ) )
  363. {
  364. std::string value = root->getValue();
  365. F32 version = 0.0f;
  366. LLStringUtil::convertToF32(value, version);
  367. if (version >= 1.0f)
  368. {
  369. xml_ok = true;
  370. }
  371. }
  372. }
  373. if (!xml_ok)
  374. {
  375. // If XML is bad, there's a good possibility that notifications.xml is ALSO bad.
  376. // If that's so, then we'll get a fatal error on attempting to load it,
  377. // which will display a nontranslatable error message that says so.
  378. // Otherwise, we'll display a reasonable error message that IS translatable.
  379. LLAppViewer::instance()->earlyExit("BadInstallation");
  380. }
  381. //
  382. // Statistics stuff
  383. //
  384. // Load autopilot and stats stuff
  385. gAgentPilot.load();
  386. //gErrorStream.setTime(gSavedSettings.getBOOL("LogTimestamps"));
  387. // Load the throttle settings
  388. gViewerThrottle.load();
  389. if (ll_init_ares() == NULL || !gAres->isInitialized())
  390. {
  391. std::string diagnostic = "Could not start address resolution system";
  392. LL_WARNS("AppInit") << diagnostic << LL_ENDL;
  393. LLAppViewer::instance()->earlyExit("LoginFailedNoNetwork", LLSD().with("DIAGNOSTIC", diagnostic));
  394. }
  395. //
  396. // Initialize messaging system
  397. //
  398. LL_DEBUGS("AppInit") << "Initializing messaging system..." << LL_ENDL;
  399. std::string message_template_path = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS,"message_template.msg");
  400. LLFILE* found_template = NULL;
  401. found_template = LLFile::fopen(message_template_path, "r"); /* Flawfinder: ignore */
  402. #if LL_WINDOWS
  403. // On the windows dev builds, unpackaged, the message_template.msg
  404. // file will be located in:
  405. // build-vc**/newview/<config>/app_settings
  406. if (!found_template)
  407. {
  408. message_template_path = gDirUtilp->getExpandedFilename(LL_PATH_EXECUTABLE, "app_settings", "message_template.msg");
  409. found_template = LLFile::fopen(message_template_path.c_str(), "r"); /* Flawfinder: ignore */
  410. }
  411. #elif LL_DARWIN
  412. // On Mac dev builds, message_template.msg lives in:
  413. // indra/build-*/newview/<config>/Second Life/Contents/Resources/app_settings
  414. if (!found_template)
  415. {
  416. message_template_path =
  417. gDirUtilp->getExpandedFilename(LL_PATH_EXECUTABLE,
  418. "../Resources/app_settings",
  419. "message_template.msg");
  420. found_template = LLFile::fopen(message_template_path.c_str(), "r"); /* Flawfinder: ignore */
  421. }
  422. #endif
  423. if (found_template)
  424. {
  425. fclose(found_template);
  426. U32 port = gSavedSettings.getU32("UserConnectionPort");
  427. if ((NET_USE_OS_ASSIGNED_PORT == port) && // if nothing specified on command line (-port)
  428. (gSavedSettings.getBOOL("ConnectionPortEnabled")))
  429. {
  430. port = gSavedSettings.getU32("ConnectionPort");
  431. }
  432. LLHTTPSender::setDefaultSender(new LLNullHTTPSender());
  433. // TODO parameterize
  434. const F32 circuit_heartbeat_interval = 5;
  435. const F32 circuit_timeout = 100;
  436. const LLUseCircuitCodeResponder* responder = NULL;
  437. bool failure_is_fatal = true;
  438. if(!start_messaging_system(
  439. message_template_path,
  440. port,
  441. LLVersionInfo::getMajor(),
  442. LLVersionInfo::getMinor(),
  443. LLVersionInfo::getPatch(),
  444. FALSE,
  445. std::string(),
  446. responder,
  447. failure_is_fatal,
  448. circuit_heartbeat_interval,
  449. circuit_timeout))
  450. {
  451. std::string diagnostic = llformat(" Error: %d", gMessageSystem->getErrorCode());
  452. LL_WARNS("AppInit") << diagnostic << LL_ENDL;
  453. LLAppViewer::instance()->earlyExit("LoginFailedNoNetwork", LLSD().with("DIAGNOSTIC", diagnostic));
  454. }
  455. #if LL_WINDOWS
  456. // On the windows dev builds, unpackaged, the message.xml file will
  457. // be located in indra/build-vc**/newview/<config>/app_settings.
  458. std::string message_path = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS,"message.xml");
  459. if (!LLFile::isfile(message_path.c_str()))
  460. {
  461. LLMessageConfig::initClass("viewer", gDirUtilp->getExpandedFilename(LL_PATH_EXECUTABLE, "app_settings", ""));
  462. }
  463. else
  464. {
  465. LLMessageConfig::initClass("viewer", gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, ""));
  466. }
  467. #else
  468. LLMessageConfig::initClass("viewer", gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, ""));
  469. #endif
  470. }
  471. else
  472. {
  473. LLAppViewer::instance()->earlyExit("MessageTemplateNotFound", LLSD().with("PATH", message_template_path));
  474. }
  475. if(gMessageSystem && gMessageSystem->isOK())
  476. {
  477. // Initialize all of the callbacks in case of bad message
  478. // system data
  479. LLMessageSystem* msg = gMessageSystem;
  480. msg->setExceptionFunc(MX_UNREGISTERED_MESSAGE,
  481. invalid_message_callback,
  482. NULL);
  483. msg->setExceptionFunc(MX_PACKET_TOO_SHORT,
  484. invalid_message_callback,
  485. NULL);
  486. // running off end of a packet is now valid in the case
  487. // when a reader has a newer message template than
  488. // the sender
  489. /*msg->setExceptionFunc(MX_RAN_OFF_END_OF_PACKET,
  490. invalid_message_callback,
  491. NULL);*/
  492. msg->setExceptionFunc(MX_WROTE_PAST_BUFFER_SIZE,
  493. invalid_message_callback,
  494. NULL);
  495. if (gSavedSettings.getBOOL("LogMessages"))
  496. {
  497. LL_DEBUGS("AppInit") << "Message logging activated!" << LL_ENDL;
  498. msg->startLogging();
  499. }
  500. // start the xfer system. by default, choke the downloads
  501. // a lot...
  502. const S32 VIEWER_MAX_XFER = 3;
  503. start_xfer_manager(gVFS);
  504. gXferManager->setMaxIncomingXfers(VIEWER_MAX_XFER);
  505. F32 xfer_throttle_bps = gSavedSettings.getF32("XferThrottle");
  506. if (xfer_throttle_bps > 1.f)
  507. {
  508. gXferManager->setUseAckThrottling(TRUE);
  509. gXferManager->setAckThrottleBPS(xfer_throttle_bps);
  510. }
  511. gAssetStorage = new LLViewerAssetStorage(msg, gXferManager, gVFS, gStaticVFS);
  512. F32 dropPercent = gSavedSettings.getF32("PacketDropPercentage");
  513. msg->mPacketRing.setDropPercentage(dropPercent);
  514. F32 inBandwidth = gSavedSettings.getF32("InBandwidth");
  515. F32 outBandwidth = gSavedSettings.getF32("OutBandwidth");
  516. if (inBandwidth != 0.f)
  517. {
  518. LL_DEBUGS("AppInit") << "Setting packetring incoming bandwidth to " << inBandwidth << LL_ENDL;
  519. msg->mPacketRing.setUseInThrottle(TRUE);
  520. msg->mPacketRing.setInBandwidth(inBandwidth);
  521. }
  522. if (outBandwidth != 0.f)
  523. {
  524. LL_DEBUGS("AppInit") << "Setting packetring outgoing bandwidth to " << outBandwidth << LL_ENDL;
  525. msg->mPacketRing.setUseOutThrottle(TRUE);
  526. msg->mPacketRing.setOutBandwidth(outBandwidth);
  527. }
  528. }
  529. LL_INFOS("AppInit") << "Message System Initialized." << LL_ENDL;
  530. //-------------------------------------------------
  531. // Init audio, which may be needed for prefs dialog
  532. // or audio cues in connection UI.
  533. //-------------------------------------------------
  534. if (FALSE == gSavedSettings.getBOOL("NoAudio"))
  535. {
  536. gAudiop = NULL;
  537. #ifdef LL_OPENAL
  538. if (!gAudiop
  539. #if !LL_WINDOWS
  540. && NULL == getenv("LL_BAD_OPENAL_DRIVER")
  541. #endif // !LL_WINDOWS
  542. )
  543. {
  544. gAudiop = (LLAudioEngine *) new LLAudioEngine_OpenAL();
  545. }
  546. #endif
  547. #ifdef LL_FMOD
  548. if (!gAudiop
  549. #if !LL_WINDOWS
  550. && NULL == getenv("LL_BAD_FMOD_DRIVER")
  551. #endif // !LL_WINDOWS
  552. )
  553. {
  554. gAudiop = (LLAudioEngine *) new LLAudioEngine_FMOD();
  555. }
  556. #endif
  557. if (gAudiop)
  558. {
  559. #if LL_WINDOWS
  560. // FMOD on Windows needs the window handle to stop playing audio
  561. // when window is minimized. JC
  562. void* window_handle = (HWND)gViewerWindow->getPlatformWindow();
  563. #else
  564. void* window_handle = NULL;
  565. #endif
  566. bool init = gAudiop->init(kAUDIO_NUM_SOURCES, window_handle);
  567. if(init)
  568. {
  569. gAudiop->setMuted(TRUE);
  570. }
  571. else
  572. {
  573. LL_WARNS("AppInit") << "Unable to initialize audio engine" << LL_ENDL;
  574. delete gAudiop;
  575. gAudiop = NULL;
  576. }
  577. if (gAudiop)
  578. {
  579. // if the audio engine hasn't set up its own preferred handler for streaming audio then set up the generic streaming audio implementation which uses media plugins
  580. if (NULL == gAudiop->getStreamingAudioImpl())
  581. {
  582. LL_INFOS("AppInit") << "Using media plugins to render streaming audio" << LL_ENDL;
  583. gAudiop->setStreamingAudioImpl(new LLStreamingAudio_MediaPlugins());
  584. }
  585. }
  586. }
  587. }
  588. LL_INFOS("AppInit") << "Audio Engine Initialized." << LL_ENDL;
  589. if (LLTimer::knownBadTimer())
  590. {
  591. LL_WARNS("AppInit") << "Unreliable timers detected (may be bad PCI chipset)!!" << LL_ENDL;
  592. }
  593. //
  594. // Log on to system
  595. //
  596. if (gUserCredential.isNull())
  597. {
  598. gUserCredential = gLoginHandler.initializeLoginInfo();
  599. }
  600. // Previous initializeLoginInfo may have generated user credentials. Re-check them.
  601. if (gUserCredential.isNull())
  602. {
  603. show_connect_box = TRUE;
  604. }
  605. else if (gSavedSettings.getBOOL("AutoLogin"))
  606. {
  607. gRememberPassword = TRUE;
  608. gSavedSettings.setBOOL("RememberPassword", TRUE);
  609. show_connect_box = false;
  610. }
  611. else
  612. {
  613. gRememberPassword = gSavedSettings.getBOOL("RememberPassword");
  614. show_connect_box = TRUE;
  615. }
  616. // Go to the next startup state
  617. LLStartUp::setStartupState( STATE_BROWSER_INIT );
  618. return FALSE;
  619. }
  620. if (STATE_BROWSER_INIT == LLStartUp::getStartupState())
  621. {
  622. LL_DEBUGS("AppInit") << "STATE_BROWSER_INIT" << LL_ENDL;
  623. std::string msg = LLTrans::getString("LoginInitializingBrowser");
  624. set_startup_status(0.03f, msg.c_str(), gAgent.mMOTD.c_str());
  625. display_startup();
  626. // LLViewerMedia::initBrowser();
  627. LLStartUp::setStartupState( STATE_LOGIN_SHOW );
  628. return FALSE;
  629. }
  630. if (STATE_LOGIN_SHOW == LLStartUp::getStartupState())
  631. {
  632. LL_DEBUGS("AppInit") << "Initializing Window" << LL_ENDL;
  633. // if we've gone backwards in the login state machine, to this state where we show the UI
  634. // AND the debug setting to exit in this case is true, then go ahead and bail quickly
  635. if ( mLoginStatePastUI && gSavedSettings.getBOOL("QuitOnLoginActivated") )
  636. {
  637. // no requirement for notification here - just exit
  638. LLAppViewer::instance()->earlyExitNoNotify();
  639. }
  640. gViewerWindow->getWindow()->setCursor(UI_CURSOR_ARROW);
  641. timeout_count = 0;
  642. // Login screen needs menus for preferences, but we can enter
  643. // this startup phase more than once.
  644. if (gLoginMenuBarView == NULL)
  645. {
  646. display_startup();
  647. initialize_edit_menu();
  648. display_startup();
  649. init_menus();
  650. display_startup();
  651. }
  652. if (show_connect_box)
  653. {
  654. // Load all the name information out of the login view
  655. // NOTE: Hits "Attempted getFields with no login view shown" warning, since we don't
  656. // show the login view until login_show() is called below.
  657. if (gUserCredential.isNull())
  658. {
  659. display_startup();
  660. gUserCredential = gLoginHandler.initializeLoginInfo();
  661. display_startup();
  662. }
  663. if (gHeadlessClient)
  664. {
  665. LL_WARNS("AppInit") << "Waiting at connection box in headless client. Did you mean to add autologin params?" << LL_ENDL;
  666. }
  667. // Make sure the process dialog doesn't hide things
  668. display_startup();
  669. gViewerWindow->setShowProgress(FALSE);
  670. display_startup();
  671. // Show the login dialog
  672. login_show();
  673. display_startup();
  674. // connect dialog is already shown, so fill in the names
  675. if (gUserCredential.notNull())
  676. {
  677. LLPanelLogin::setFields( gUserCredential, gRememberPassword);
  678. }
  679. display_startup();
  680. LLPanelLogin::giveFocus();
  681. LLStartUp::setStartupState( STATE_LOGIN_WAIT ); // Wait for user input
  682. }
  683. else
  684. {
  685. // skip directly to message template verification
  686. LLStartUp::setStartupState( STATE_LOGIN_CLEANUP );
  687. }
  688. display_startup();
  689. gViewerWindow->setNormalControlsVisible( FALSE );
  690. display_startup();
  691. gLoginMenuBarView->setVisible( TRUE );
  692. display_startup();
  693. gLoginMenuBarView->setEnabled( TRUE );
  694. display_startup();
  695. show_debug_menus();
  696. display_startup();
  697. // Hide the splash screen
  698. LLSplashScreen::hide();
  699. display_startup();
  700. // Push our window frontmost
  701. gViewerWindow->getWindow()->show();
  702. display_startup();
  703. // DEV-16927. The following code removes errant keystrokes that happen while the window is being
  704. // first made visible.
  705. #ifdef _WIN32
  706. MSG msg;
  707. while( PeekMessage( &msg, /*All hWnds owned by this thread */ NULL, WM_KEYFIRST, WM_KEYLAST, PM_REMOVE ) )
  708. { }
  709. display_startup();
  710. #endif
  711. timeout.reset();
  712. return FALSE;
  713. }
  714. if (STATE_LOGIN_WAIT == LLStartUp::getStartupState())
  715. {
  716. // when we get to this state, we've already been past the login UI
  717. // (possiblely automatically) - flag this so we can test in the
  718. // STATE_LOGIN_SHOW state if we've gone backwards
  719. mLoginStatePastUI = true;
  720. // Don't do anything. Wait for the login view to call the login_callback,
  721. // which will push us to the next state.
  722. display_startup();
  723. // Sleep so we don't spin the CPU
  724. ms_sleep(1);
  725. return FALSE;
  726. }
  727. if (STATE_LOGIN_CLEANUP == LLStartUp::getStartupState())
  728. {
  729. // Post login screen, we should see if any settings have changed that may
  730. // require us to either start/stop or change the socks proxy. As various communications
  731. // past this point may require the proxy to be up.
  732. if (!LLStartUp::startLLProxy())
  733. {
  734. // Proxy start up failed, we should now bail the state machine
  735. // startLLProxy() will have reported an error to the user
  736. // already, so we just go back to the login screen. The user
  737. // could then change the preferences to fix the issue.
  738. LLStartUp::setStartupState(STATE_LOGIN_SHOW);
  739. return FALSE;
  740. }
  741. // reset the values that could have come in from a slurl
  742. // DEV-42215: Make sure they're not empty -- gUserCredential
  743. // might already have been set from gSavedSettings, and it's too bad
  744. // to overwrite valid values with empty strings.
  745. if (show_connect_box)
  746. {
  747. // TODO if not use viewer auth
  748. // Load all the name information out of the login view
  749. LLPanelLogin::getFields(gUserCredential, gRememberPassword);
  750. // end TODO
  751. // HACK: Try to make not jump on login
  752. gKeyboard->resetKeys();
  753. }
  754. // when we get to this state, we've already been past the login UI
  755. // (possiblely automatically) - flag this so we can test in the
  756. // STATE_LOGIN_SHOW state if we've gone backwards
  757. mLoginStatePastUI = true;
  758. // save the credentials
  759. std::string userid = "unknown";
  760. if(gUserCredential.notNull())
  761. {
  762. userid = gUserCredential->userID();
  763. gSecAPIHandler->saveCredential(gUserCredential, gRememberPassword);
  764. }
  765. gSavedSettings.setBOOL("RememberPassword", gRememberPassword);
  766. LL_INFOS("AppInit") << "Attempting login as: " << userid << LL_ENDL;
  767. gDebugInfo["LoginName"] = userid;
  768. // create necessary directories
  769. // *FIX: these mkdir's should error check
  770. gDirUtilp->setLindenUserDir(userid);
  771. LLFile::mkdir(gDirUtilp->getLindenUserDir());
  772. // Set PerAccountSettingsFile to the default value.
  773. std::string per_account_settings_file = LLAppViewer::instance()->getSettingsFilename("Default", "PerAccount");
  774. gSavedSettings.setString("PerAccountSettingsFile",
  775. gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT,
  776. LLAppViewer::instance()->getSettingsFilename("Default", "PerAccount")));
  777. // Note: can't store warnings files per account because some come up before login
  778. // Overwrite default user settings with user settings
  779. LLAppViewer::instance()->loadSettingsFromDirectory("Account");
  780. // Need to set the LastLogoff time here if we don't have one. LastLogoff is used for "Recent Items" calculation
  781. // and startup time is close enough if we don't have a real value.
  782. if (gSavedPerAccountSettings.getU32("LastLogoff") == 0)
  783. {
  784. gSavedPerAccountSettings.setU32("LastLogoff", time_corrected());
  785. }
  786. //Default the path if one isn't set.
  787. // *NOTE: unable to check variable differ from "InstantMessageLogPath" because it was
  788. // provided in pre 2.0 viewer. See EXT-6661
  789. if (gSavedPerAccountSettings.getString("InstantMessageLogPath").empty())
  790. {
  791. gDirUtilp->setChatLogsDir(gDirUtilp->getOSUserAppDir());
  792. gSavedPerAccountSettings.setString("InstantMessageLogPath", gDirUtilp->getChatLogsDir());
  793. }
  794. else
  795. {
  796. gDirUtilp->setChatLogsDir(gSavedPerAccountSettings.getString("InstantMessageLogPath"));
  797. }
  798. gDirUtilp->setPerAccountChatLogsDir(userid);
  799. LLFile::mkdir(gDirUtilp->getChatLogsDir());
  800. LLFile::mkdir(gDirUtilp->getPerAccountChatLogsDir());
  801. //good a place as any to create user windlight directories
  802. std::string user_windlight_path_name(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight", ""));
  803. LLFile::mkdir(user_windlight_path_name.c_str());
  804. std::string user_windlight_skies_path_name(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/skies", ""));
  805. LLFile::mkdir(user_windlight_skies_path_name.c_str());
  806. std::string user_windlight_water_path_name(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/water", ""));
  807. LLFile::mkdir(user_windlight_water_path_name.c_str());
  808. std::string user_windlight_days_path_name(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight/days", ""));
  809. LLFile::mkdir(user_windlight_days_path_name.c_str());
  810. if (show_connect_box)
  811. {
  812. LLSLURL slurl;
  813. //LLPanelLogin::closePanel();
  814. }
  815. // Load URL History File
  816. LLURLHistory::loadFile("url_history.xml");
  817. // Load location history
  818. LLLocationHistory::getInstance()->load();
  819. // Load Avatars icons cache
  820. LLAvatarIconIDCache::getInstance()->load();
  821. // Load media plugin cookies
  822. LLViewerMedia::loadCookieFile();
  823. //-------------------------------------------------
  824. // Handle startup progress screen
  825. //-------------------------------------------------
  826. // on startup the user can request to go to their home,
  827. // their last location, or some URL "-url //sim/x/y[/z]"
  828. // All accounts have both a home and a last location, and we don't support
  829. // more locations than that. Choose the appropriate one. JC
  830. switch (LLStartUp::getStartSLURL().getType())
  831. {
  832. case LLSLURL::LOCATION:
  833. agent_location_id = START_LOCATION_ID_URL;
  834. location_which = START_LOCATION_ID_LAST;
  835. break;
  836. case LLSLURL::LAST_LOCATION:
  837. agent_location_id = START_LOCATION_ID_LAST;
  838. location_which = START_LOCATION_ID_LAST;
  839. break;
  840. default:
  841. agent_location_id = START_LOCATION_ID_HOME;
  842. location_which = START_LOCATION_ID_HOME;
  843. break;
  844. }
  845. gViewerWindow->getWindow()->setCursor(UI_CURSOR_WAIT);
  846. init_start_screen(agent_location_id);
  847. // Display the startup progress bar.
  848. gViewerWindow->setShowProgress(TRUE);
  849. gViewerWindow->setProgressCancelButtonVisible(TRUE, LLTrans::getString("Quit"));
  850. gViewerWindow->revealIntroPanel();
  851. // Poke the VFS, which could potentially block for a while if
  852. // Windows XP is acting up
  853. set_startup_status(0.07f, LLTrans::getString("LoginVerifyingCache"), LLStringUtil::null);
  854. display_startup();
  855. gVFS->pokeFiles();
  856. LLStartUp::setStartupState( STATE_LOGIN_AUTH_INIT );
  857. return FALSE;
  858. }
  859. if(STATE_LOGIN_AUTH_INIT == LLStartUp::getStartupState())
  860. {
  861. gDebugInfo["GridName"] = LLGridManager::getInstance()->getGridLabel();
  862. // Update progress status and the display loop.
  863. auth_desc = LLTrans::getString("LoginInProgress");
  864. set_startup_status(progress, auth_desc, auth_message);
  865. progress += 0.02f;
  866. display_startup();
  867. // Setting initial values...
  868. LLLoginInstance* login = LLLoginInstance::getInstance();
  869. login->setNotificationsInterface(LLNotifications::getInstance());
  870. login->setSerialNumber(LLAppViewer::instance()->getSerialNumber());
  871. login->setLastExecEvent(gLastExecEvent);
  872. login->setUpdaterLauncher(boost::bind(&LLAppViewer::launchUpdater, LLAppViewer::instance()));
  873. // This call to LLLoginInstance::connect() starts the
  874. // authentication process.
  875. login->connect(gUserCredential);
  876. LLStartUp::setStartupState( STATE_LOGIN_CURL_UNSTUCK );
  877. return FALSE;
  878. }
  879. if(STATE_LOGIN_CURL_UNSTUCK == LLStartUp::getStartupState())
  880. {
  881. // If we get here we have gotten past the potential stall
  882. // in curl, so take "may appear frozen" out of progress bar. JC
  883. auth_desc = LLTrans::getString("LoginInProgressNoFrozen");
  884. set_startup_status(progress, auth_desc, auth_message);
  885. LLStartUp::setStartupState( STATE_LOGIN_PROCESS_RESPONSE );
  886. return FALSE;
  887. }
  888. if(STATE_LOGIN_PROCESS_RESPONSE == LLStartUp::getStartupState())
  889. {
  890. // Generic failure message
  891. std::ostringstream emsg;
  892. emsg << LLTrans::getString("LoginFailed") << "\n";
  893. if(LLLoginInstance::getInstance()->authFailure())
  894. {
  895. LL_INFOS("LLStartup") << "Login failed, LLLoginInstance::getResponse(): "
  896. << LLLoginInstance::getInstance()->getResponse() << LL_ENDL;
  897. LLSD response = LLLoginInstance::getInstance()->getResponse();
  898. // Still have error conditions that may need some
  899. // sort of handling - dig up specific message
  900. std::string reason_response = response["reason"];
  901. std::string message_response = response["message"];
  902. std::string message_id = response["message_id"];
  903. std::string message; // actual string to show the user
  904. if(!message_id.empty() && LLTrans::findString(message, message_id, response["message_args"]))
  905. {
  906. // message will be filled in with the template and arguments
  907. }
  908. else if(!message_response.empty())
  909. {
  910. // *HACK: "no_inventory_host" sent as the message itself.
  911. // Remove this clause when server is sending message_id as well.
  912. message = LLAgent::sTeleportErrorMessages[ message_response ];
  913. }
  914. if (message.empty())
  915. {
  916. // Fallback to server-supplied string; necessary since server
  917. // may add strings that this viewer is not yet aware of
  918. message = message_response;
  919. }
  920. emsg << message;
  921. if(reason_response == "key")
  922. {
  923. // Couldn't login because user/password is wrong
  924. // Clear the credential
  925. gUserCredential->clearAuthenticator();
  926. }
  927. if(reason_response == "update"
  928. || reason_response == "optional")
  929. {
  930. // In the case of a needed update, quit.
  931. // Its either downloading or declined.
  932. // If optional was skipped this case shouldn't
  933. // be reached.
  934. LLLoginInstance::getInstance()->disconnect();
  935. LLAppViewer::instance()->forceQuit();
  936. }
  937. else
  938. {
  939. if (reason_response != "tos")
  940. {
  941. // Don't pop up a notification in the TOS case because
  942. // LLFloaterTOS::onCancel() already scolded the user.
  943. std::string error_code;
  944. if(response.has("errorcode"))
  945. {
  946. error_code = response["errorcode"].asString();
  947. }
  948. if ((reason_response == "CURLError") &&
  949. (error_code == "SSL_CACERT" || error_code == "SSL_PEER_CERTIFICATE") &&
  950. response.has("certificate"))
  951. {
  952. // This was a certificate error, so grab the certificate
  953. // and throw up the appropriate dialog.
  954. LLPointer<LLCertificate> certificate = gSecAPIHandler->getCertificate(response["certificate"]);
  955. if(certificate)
  956. {
  957. LLSD args = transform_cert_args(certificate);
  958. if(error_code == "SSL_CACERT")
  959. {
  960. // if we are handling an untrusted CA, throw up the dialog
  961. // with the 'trust this CA' button.
  962. LLNotificationsUtil::add("TrustCertificateError", args, response,
  963. trust_cert_done);
  964. show_connect_box = true;
  965. }
  966. else
  967. {
  968. // the certificate exception returns a unique string for each type of exception.
  969. // we grab this string via the LLUserAuth object, and use that to grab the localized
  970. // string.
  971. args["REASON"] = LLTrans::getString(message_response);
  972. LLNotificationsUtil::add("GeneralCertificateError", args, response,
  973. general_cert_done);
  974. reset_login();
  975. gSavedSettings.setBOOL("AutoLogin", FALSE);
  976. show_connect_box = true;
  977. }
  978. }
  979. }
  980. else
  981. {
  982. // This wasn't a certificate error, so throw up the normal
  983. // notificatioin message.
  984. LLSD args;
  985. args["ERROR_MESSAGE"] = emsg.str();
  986. LL_INFOS("LLStartup") << "Notification: " << args << LL_ENDL;
  987. LLNotificationsUtil::add("ErrorMessage", args, LLSD(), login_alert_done);
  988. }
  989. }
  990. //setup map of datetime strings to codes and slt & local time offset from utc
  991. // *TODO: Does this need to be here?
  992. LLStringOps::setupDatetimeInfo (false);
  993. transition_back_to_login_panel(emsg.str());
  994. show_connect_box = true;
  995. }
  996. }
  997. else if(LLLoginInstance::getInstance()->authSuccess())
  998. {
  999. if(process_login_success_response())
  1000. {
  1001. // Pass the user information to the voice chat server interface.
  1002. LLVoiceClient::getInstance()->userAuthorized(gUserCredential->userID(), gAgentID);
  1003. // create the default proximal channel
  1004. LLVoiceChannel::initClass();
  1005. LLGridManager::getInstance()->setFavorite();
  1006. LLStartUp::setStartupState( STATE_WORLD_INIT);
  1007. }
  1008. else
  1009. {
  1010. LLSD args;
  1011. args["ERROR_MESSAGE"] = emsg.str();
  1012. LL_INFOS("LLStartup") << "Notification: " << args << LL_ENDL;
  1013. LLNotificationsUtil::add("ErrorMessage", args, LLSD(), login_alert_done);
  1014. transition_back_to_login_panel(emsg.str());
  1015. show_connect_box = true;
  1016. return FALSE;
  1017. }
  1018. }
  1019. return FALSE;
  1020. }
  1021. //---------------------------------------------------------------------
  1022. // World Init
  1023. //---------------------------------------------------------------------
  1024. if (STATE_WORLD_INIT == LLStartUp::getStartupState())
  1025. {
  1026. set_startup_status(0.30f, LLTrans::getString("LoginInitializingWorld"), gAgent.mMOTD);
  1027. display_startup();
  1028. // We should have an agent id by this point.
  1029. llassert(!(gAgentID == LLUUID::null));
  1030. // Finish agent initialization. (Requires gSavedSettings, builds camera)
  1031. gAgent.init();
  1032. display_startup();
  1033. gAgentCamera.init();
  1034. display_startup();
  1035. set_underclothes_menu_options();
  1036. display_startup();
  1037. // Since we connected, save off the settings so the user doesn't have to
  1038. // type the name/password again if we crash.
  1039. gSavedSettings.saveToFile(gSavedSettings.getString("ClientSettingsFile"), TRUE);
  1040. LLUIColorTable::instance().saveUserSettings();
  1041. display_startup();
  1042. //
  1043. // Initialize classes w/graphics stuff.
  1044. //
  1045. gTextureList.doPrefetchImages();
  1046. display_startup();
  1047. LLSurface::initClasses();
  1048. display_startup();
  1049. LLFace::initClass();
  1050. display_startup();
  1051. LLDrawable::initClass();
  1052. display_startup();
  1053. // init the shader managers
  1054. LLPostProcess::initClass();
  1055. display_startup();
  1056. LLViewerObject::initVOClasses();
  1057. display_startup();
  1058. // Initialize all our tools. Must be done after saved settings loaded.
  1059. // NOTE: This also is where gToolMgr used to be instantiated before being turned into a singleton.
  1060. LLToolMgr::getInstance()->initTools();
  1061. display_startup();
  1062. // Pre-load floaters, like the world map, that are slow to spawn
  1063. // due to XML complexity.
  1064. gViewerWindow->initWorldUI();
  1065. display_startup();
  1066. // This is where we used to initialize gWorldp. Original comment said:
  1067. // World initialization must be done after above window init
  1068. // User might have overridden far clip
  1069. LLWorld::getInstance()->setLandFarClip(gAgentCamera.mDrawDistance);
  1070. display_startup();
  1071. // Before we create the first region, we need to set the agent's mOriginGlobal
  1072. // This is necessary because creating objects before this is set will result in a
  1073. // bad mPositionAgent cache.
  1074. gAgent.initOriginGlobal(from_region_handle(gFirstSimHandle));
  1075. display_startup();
  1076. LLWorld::getInstance()->addRegion(gFirstSimHandle, gFirstSim);
  1077. display_startup();
  1078. LLViewerRegion *regionp = LLWorld::getInstance()->getRegionFromHandle(gFirstSimHandle);
  1079. LL_INFOS("AppInit") << "Adding initial simulator " << regionp->getOriginGlobal() << LL_ENDL;
  1080. regionp->setSeedCapability(gFirstSimSeedCap);
  1081. LL_DEBUGS("AppInit") << "Waiting for seed grant ...." << LL_ENDL;
  1082. display_startup();
  1083. // Set agent's initial region to be the one we just created.
  1084. gAgent.setRegion(regionp);
  1085. display_startup();
  1086. // Set agent's initial position, which will be read by LLVOAvatar when the avatar
  1087. // object is created. I think this must be done after setting the region. JC
  1088. gAgent.setPositionAgent(agent_start_position_region);
  1089. display_startup();
  1090. LLStartUp::setStartupState( STATE_MULTIMEDIA_INIT );
  1091. return FALSE;
  1092. }
  1093. //---------------------------------------------------------------------
  1094. // Load QuickTime/GStreamer and other multimedia engines, can be slow.
  1095. // Do it while we're waiting on the network for our seed capability. JC
  1096. //---------------------------------------------------------------------
  1097. if (STATE_MULTIMEDIA_INIT == LLStartUp::getStartupState())
  1098. {
  1099. LLStartUp::multimediaInit();
  1100. LLStartUp::setStartupState( STATE_FONT_INIT );
  1101. display_startup();
  1102. return FALSE;
  1103. }
  1104. // Loading fonts takes several seconds
  1105. if (STATE_FONT_INIT == LLStartUp::getStartupState())
  1106. {
  1107. LLStartUp::fontInit();
  1108. LLStartUp::setStartupState( STATE_SEED_GRANTED_WAIT );
  1109. display_startup();
  1110. return FALSE;
  1111. }
  1112. //---------------------------------------------------------------------
  1113. // Wait for Seed Cap Grant
  1114. //---------------------------------------------------------------------
  1115. if(STATE_SEED_GRANTED_WAIT == LLStartUp::getStartupState())
  1116. {
  1117. LLViewerRegion *regionp = LLWorld::getInstance()->getRegionFromHandle(gFirstSimHandle);
  1118. if (regionp->capabilitiesReceived())
  1119. {
  1120. LLStartUp::setStartupState( STATE_SEED_CAP_GRANTED );
  1121. }
  1122. else
  1123. {
  1124. U32 num_retries = regionp->getNumSeedCapRetries();
  1125. if (num_retries > 0)
  1126. {
  1127. LLStringUtil::format_map_t args;
  1128. args["[NUMBER]"] = llformat("%d", num_retries + 1);
  1129. set_startup_status(0.4f, LLTrans::getString("LoginRetrySeedCapGrant", args), gAgent.mMOTD);
  1130. }
  1131. else
  1132. {
  1133. set_startup_status(0.4f, LLTrans::getString("LoginRequestSeedCapGrant"), gAgent.mMOTD);
  1134. }
  1135. }
  1136. display_startup();
  1137. return FALSE;
  1138. }
  1139. //---------------------------------------------------------------------
  1140. // Seed Capability Granted
  1141. // no newMessage calls should happen before this point
  1142. //---------------------------------------------------------------------
  1143. if (STATE_SEED_CAP_GRANTED == LLStartUp::getStartupState())
  1144. {
  1145. display_startup();
  1146. update_texture_fetch();
  1147. display_startup();
  1148. if ( gViewerWindow != NULL)
  1149. { // This isn't the first logon attempt, so show the UI
  1150. gViewerWindow->setNormalControlsVisible( TRUE );
  1151. }
  1152. gLoginMenuBarView->setVisible( FALSE );
  1153. gLoginMenuBarView->setEnabled( FALSE );
  1154. display_startup();
  1155. // direct logging to the debug console's line buffer
  1156. LLError::logToFixedBuffer(gDebugView->mDebugConsolep);
  1157. display_startup();
  1158. // set initial visibility of debug console
  1159. gDebugView->mDebugConsolep->setVisible(gSavedSettings.getBOOL("ShowDebugConsole"));
  1160. display_startup();
  1161. //
  1162. // Set message handlers
  1163. //
  1164. LL_INFOS("AppInit") << "Initializing communications..." << LL_ENDL;
  1165. // register callbacks for messages. . . do this after initial handshake to make sure that we don't catch any unwanted
  1166. register_viewer_callbacks(gMessageSystem);
  1167. display_startup();
  1168. // Debugging info parameters
  1169. gMessageSystem->setMaxMessageTime( 0.5f ); // Spam if decoding all msgs takes more than 500 ms
  1170. display_startup();
  1171. #ifndef LL_RELEASE_FOR_DOWNLOAD
  1172. gMessageSystem->setTimeDecodes( TRUE ); // Time the decode of each msg
  1173. gMessageSystem->setTimeDecodesSpamThreshold( 0.05f ); // Spam if a single msg takes over 50ms to decode
  1174. #endif
  1175. display_startup();
  1176. gXferManager->registerCallbacks(gMessageSystem);
  1177. display_startup();
  1178. LLStartUp::initNameCache();
  1179. display_startup();
  1180. // update the voice settings *after* gCacheName initialization
  1181. // so that we can construct voice UI that relies on the name cache
  1182. LLVoiceClient::getInstance()->updateSettings();
  1183. display_startup();
  1184. //gCacheName is required for nearby chat history loading
  1185. //so I just moved nearby history loading a few states further
  1186. if (gSavedPerAccountSettings.getBOOL("LogShowHistory"))
  1187. {
  1188. LLNearbyChat* nearby_chat = LLNearbyChat::getInstance();
  1189. if (nearby_chat) nearby_chat->loadHistory();
  1190. }
  1191. display_startup();
  1192. // *Note: this is where gWorldMap used to be initialized.
  1193. // register null callbacks for audio until the audio system is initialized
  1194. gMessageSystem->setHandlerFuncFast(_PREHASH_SoundTrigger, null_message_callback, NULL);
  1195. gMessageSystem->setHandlerFuncFast(_PREHASH_AttachedSound, null_message_callback, NULL);
  1196. display_startup();
  1197. //reset statistics
  1198. LLViewerStats::getInstance()->resetStats();
  1199. display_startup();
  1200. //
  1201. // Set up region and surface defaults
  1202. //
  1203. // Sets up the parameters for the first simulator
  1204. LL_DEBUGS("AppInit") << "Initializing camera..." << LL_ENDL;
  1205. gFrameTime = totalTime();
  1206. F32 last_time = gFrameTimeSeconds;
  1207. gFrameTimeSeconds = (S64)(gFrameTime - gStartTime)/SEC_TO_MICROSEC;
  1208. gFrameIntervalSeconds = gFrameTimeSeconds - last_time;
  1209. if (gFrameIntervalSeconds < 0.f)
  1210. {
  1211. gFrameIntervalSeconds = 0.f;
  1212. }
  1213. // Make sure agent knows correct aspect ratio
  1214. // FOV limits depend upon aspect ratio so this needs to happen before initializing the FOV below
  1215. LLViewerCamera::getInstance()->setViewHeightInPixels(gViewerWindow->getWorldViewHeightRaw());
  1216. LLViewerCamera::getInstance()->setAspect(gViewerWindow->getWorldViewAspectRatio());
  1217. // Initialize FOV
  1218. LLViewerCamera::getInstance()->setDefaultFOV(gSavedSettings.getF32("CameraAngle"));
  1219. display_startup();
  1220. // Move agent to starting location. The position handed to us by
  1221. // the space server is in global coordinates, but the agent frame
  1222. // is in region local coordinates. Therefore, we need to adjust
  1223. // the coordinates handed to us to fit in the local region.
  1224. gAgent.setPositionAgent(agent_start_position_region);
  1225. gAgent.resetAxes(gAgentStartLookAt);
  1226. gAgentCamera.stopCameraAnimation();
  1227. gAgentCamera.resetCamera();
  1228. display_startup();
  1229. // Initialize global class data needed for surfaces (i.e. textures)
  1230. LL_DEBUGS("AppInit") << "Initializing sky..." << LL_ENDL;
  1231. // Initialize all of the viewer object classes for the first time (doing things like texture fetches.
  1232. LLGLState::checkStates();
  1233. LLGLState::checkTextureChannels();
  1234. gSky.init(initial_sun_direction);
  1235. LLGLState::checkStates();
  1236. LLGLState::checkTextureChannels();
  1237. display_startup();
  1238. LL_DEBUGS("AppInit") << "Decoding images..." << LL_ENDL;
  1239. // For all images pre-loaded into viewer cache, decode them.
  1240. // Need to do this AFTER we init the sky
  1241. const S32 DECODE_TIME_SEC = 2;
  1242. for (int i = 0; i < DECODE_TIME_SEC; i++)
  1243. {
  1244. F32 frac = (F32)i / (F32)DECODE_TIME_SEC;
  1245. set_startup_status(0.45f + frac*0.1f, LLTrans::getString("LoginDecodingImages"), gAgent.mMOTD);
  1246. display_startup();
  1247. gTextureList.decodeAllImages(1.f);
  1248. }
  1249. LLStartUp::setStartupState( STATE_WORLD_WAIT );
  1250. display_startup();
  1251. // JC - Do this as late as possible to increase likelihood Purify
  1252. // will run.
  1253. LLMessageSystem* msg = gMessageSystem;
  1254. if (!msg->mOurCircuitCode)
  1255. {
  1256. LL_WARNS("AppInit") << "Attempting to connect to simulator with a zero circuit code!" << LL_ENDL;
  1257. }
  1258. gUseCircuitCallbackCalled = false;
  1259. msg->enableCircuit(gFirstSim, TRUE);
  1260. // now, use the circuit info to tell simulator about us!
  1261. LL_INFOS("AppInit") << "viewer: UserLoginLocationReply() Enabling " << gFirstSim << " with code " << msg->mOurCircuitCode << LL_ENDL;
  1262. msg->newMessageFast(_PREHASH_UseCircuitCode);
  1263. msg->nextBlockFast(_PREHASH_CircuitCode);
  1264. msg->addU32Fast(_PREHASH_Code, msg->mOurCircuitCode);
  1265. msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
  1266. msg->addUUIDFast(_PREHASH_ID, gAgent.getID());
  1267. msg->sendReliable(
  1268. gFirstSim,
  1269. gSavedSettings.getS32("UseCircuitCodeMaxRetries"),
  1270. FALSE,
  1271. gSavedSettings.getF32("UseCircuitCodeTimeout"),
  1272. use_circuit_callback,
  1273. NULL);
  1274. timeout.reset();
  1275. display_startup();
  1276. return FALSE;
  1277. }
  1278. //---------------------------------------------------------------------
  1279. // Agent Send
  1280. //---------------------------------------------------------------------
  1281. if(STATE_WORLD_WAIT == LLStartUp::getStartupState())
  1282. {
  1283. LL_DEBUGS("AppInit") << "Waiting for simulator ack...." << LL_ENDL;
  1284. set_startup_status(0.59f, LLTrans::getString("LoginWaitingForRegionHandshake"), gAgent.mMOTD);
  1285. if(gGotUseCircuitCodeAck)
  1286. {
  1287. LLStartUp::setStartupState( STATE_AGENT_SEND );
  1288. }
  1289. LLMessageSystem* msg = gMessageSystem;
  1290. while (msg->checkAllMessages(gFrameCount, gServicePump))
  1291. {
  1292. display_startup();
  1293. }
  1294. msg->processAcks();
  1295. display_startup();
  1296. return FALSE;
  1297. }
  1298. //---------------------------------------------------------------------
  1299. // Agent Send
  1300. //---------------------------------------------------------------------
  1301. if (STATE_AGENT_SEND == LLStartUp::getStartupState())
  1302. {
  1303. LL_DEBUGS("AppInit") << "Connecting to region..." << LL_ENDL;
  1304. set_startup_status(0.60f, LLTrans::getString("LoginConnectingToRegion"), gAgent.mMOTD);
  1305. display_startup();
  1306. // register with the message system so it knows we're
  1307. // expecting this message
  1308. LLMessageSystem* msg = gMessageSystem;
  1309. msg->setHandlerFuncFast(
  1310. _PREHASH_AgentMovementComplete,
  1311. process_agent_movement_complete);
  1312. LLViewerRegion* regionp = gAgent.getRegion();
  1313. if(regionp)
  1314. {
  1315. send_complete_agent_movement(regionp->getHost());
  1316. gAssetStorage->setUpstream(regionp->getHost());
  1317. gCacheName->setUpstream(regionp->getHost());
  1318. msg->newMessageFast(_PREHASH_EconomyDataRequest);
  1319. gAgent.sendReliableMessage();
  1320. }
  1321. display_startup();
  1322. // Create login effect
  1323. // But not on first login, because you can't see your avatar then
  1324. if (!gAgent.isFirstLogin())
  1325. {
  1326. LLHUDEffectSpiral *effectp = (LLHUDEffectSpiral *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_POINT, TRUE);
  1327. effectp->setPositionGlobal(gAgent.getPositionGlobal());
  1328. effectp->setColor(LLColor4U(gAgent.getEffectColor()));
  1329. LLHUDManager::getInstance()->sendEffects();
  1330. }
  1331. LLStartUp::setStartupState( STATE_AGENT_WAIT ); // Go to STATE_AGENT_WAIT
  1332. timeout.reset();
  1333. display_startup();
  1334. return FALSE;
  1335. }
  1336. //---------------------------------------------------------------------
  1337. // Agent Wait
  1338. //---------------------------------------------------------------------
  1339. if (STATE_AGENT_WAIT == LLStartUp::getStartupState())
  1340. {
  1341. LLMessageSystem* msg = gMessageSystem;
  1342. while (msg->checkAllMessages(gFrameCount, gServicePump))
  1343. {
  1344. if (gAgentMovementCompleted)
  1345. {
  1346. // Sometimes we have more than one message in the
  1347. // queue. break out of this loop and continue
  1348. // processing. If we don't, then this could skip one
  1349. // or more login steps.
  1350. break;
  1351. }
  1352. else
  1353. {
  1354. LL_DEBUGS("AppInit") << "Awaiting AvatarInitComplete, got "
  1355. << msg->getMessageName() << LL_ENDL;
  1356. }
  1357. display_startup();
  1358. }
  1359. msg->processAcks();
  1360. display_startup();
  1361. if (gAgentMovementCompleted)
  1362. {
  1363. LLStartUp::setStartupState( STATE_INVENTORY_SEND );
  1364. }
  1365. display_startup();
  1366. return FALSE;
  1367. }
  1368. //---------------------------------------------------------------------
  1369. // Inventory Send
  1370. //---------------------------------------------------------------------
  1371. if (STATE_INVENTORY_SEND == LLStartUp::getStartupState())
  1372. {
  1373. display_startup();
  1374. // Inform simulator of our language preference
  1375. LLAgentLanguage::update();
  1376. display_startup();
  1377. // unpack thin inventory
  1378. LLSD response = LLLoginInstance::getInstance()->getResponse();
  1379. //bool dump_buffer = false;
  1380. LLSD inv_lib_root = response["inventory-lib-root"];
  1381. if(inv_lib_root.isDefined())
  1382. {
  1383. // should only be one
  1384. LLSD id = inv_lib_root[0]["folder_id"];
  1385. if(id.isDefined())
  1386. {
  1387. gInventory.setLibraryRootFolderID(id.asUUID());
  1388. }
  1389. }
  1390. display_startup();
  1391. LLSD inv_lib_owner = response["inventory-lib-owner"];
  1392. if(inv_lib_owner.isDefined())
  1393. {
  1394. // should only be one
  1395. LLSD id = inv_lib_owner[0]["agent_id"];
  1396. if(id.isDefined())
  1397. {
  1398. gInventory.setLibraryOwnerID( LLUUID(id.asUUID()));
  1399. }
  1400. }
  1401. display_startup();
  1402. LLSD inv_skel_lib = response["inventory-skel-lib"];
  1403. if(inv_skel_lib.isDefined() && gInventory.getLibraryOwnerID().notNull())
  1404. {
  1405. if(!gInventory.loadSkeleton(inv_skel_lib, gInventory.getLibraryOwnerID()))
  1406. {
  1407. LL_WARNS("AppInit") << "Problem loading inventory-skel-lib" << LL_ENDL;
  1408. }
  1409. }
  1410. display_startup();
  1411. LLSD inv_skeleton = response["inventory-skeleton"];
  1412. if(inv_skeleton.isDefined())
  1413. {
  1414. if(!gInventory.loadSkeleton(inv_skeleton, gAgent.getID()))
  1415. {
  1416. LL_WARNS("AppInit") << "Problem loading inventory-skel-targets" << LL_ENDL;
  1417. }
  1418. }
  1419. display_startup();
  1420. LLSD inv_basic = response["inventory-basic"];
  1421. if(inv_basic.isDefined())
  1422. {
  1423. llinfos << "Basic inventory root folder id is " << inv_basic["folder_id"] << llendl;
  1424. }
  1425. LLSD buddy_list = response["buddy-list"];
  1426. if(buddy_list.isDefined())
  1427. {
  1428. LLAvatarTracker::buddy_map_t list;
  1429. LLUUID agent_id;
  1430. S32 has_rights = 0, given_rights = 0;
  1431. for(LLSD::array_const_iterator it = buddy_list.beginArray(),
  1432. end = buddy_list.endArray(); it != end; ++it)
  1433. {
  1434. LLSD buddy_id = (*it)["buddy_id"];
  1435. if(buddy_id.isDefined())
  1436. {
  1437. agent_id = buddy_id.asUUID();
  1438. }
  1439. LLSD buddy_rights_has = (*it)["buddy_rights_has"];
  1440. if(buddy_rights_has.isDefined())
  1441. {
  1442. has_rights = buddy_rights_has.asInteger();
  1443. }
  1444. LLSD buddy_rights_given = (*it)["buddy_rights_given"];
  1445. if(buddy_rights_given.isDefined())
  1446. {
  1447. given_rights = buddy_rights_given.asInteger();
  1448. }
  1449. list[agent_id] = new LLRelationship(given_rights, has_rights, false);
  1450. }
  1451. LLAvatarTracker::instance().addBuddyList(list);
  1452. display_startup();
  1453. }
  1454. bool show_hud = false;
  1455. LLSD tutorial_setting = response["tutorial_setting"];
  1456. if(tutorial_setting.isDefined())
  1457. {
  1458. for(LLSD::array_const_iterator it = tutorial_setting.beginArray(),
  1459. end = tutorial_setting.endArray(); it != end; ++it)
  1460. {
  1461. LLSD tutorial_url = (*it)["tutorial_url"];
  1462. if(tutorial_url.isDefined())
  1463. {
  1464. // Tutorial floater will append language code
  1465. gSavedSettings.setString("TutorialURL", tutorial_url.asString());
  1466. }
  1467. // For Viewer 2.0 we are not using the web-based tutorial
  1468. // If we reverse that decision, put this code back and use
  1469. // login.cgi to send a different URL with content that matches
  1470. // the Viewer 2.0 UI.
  1471. //LLSD use_tutorial = (*it)["use_tutorial"];
  1472. //if(use_tutorial.asString() == "true")
  1473. //{
  1474. // show_hud = true;
  1475. //}
  1476. }
  1477. }
  1478. display_startup();
  1479. // Either we want to show tutorial because this is the first login
  1480. // to a Linden Help Island or the user quit with the tutorial
  1481. // visible. JC
  1482. if (show_hud || gSavedSettings.getBOOL("ShowTutorial"))
  1483. {
  1484. LLFloaterReg::showInstance("hud", LLSD(), FALSE);
  1485. }
  1486. display_startup();
  1487. LLSD event_notifications = response["event_notifications"];
  1488. if(event_notifications.isDefined())
  1489. {
  1490. gEventNotifier.load(event_notifications);
  1491. }
  1492. display_startup();
  1493. LLSD classified_categories = response["classified_categories"];
  1494. if(classified_categories.isDefined())
  1495. {
  1496. LLClassifiedInfo::loadCategories(classified_categories);
  1497. }
  1498. display_startup();
  1499. // This method MUST be called before gInventory.findCategoryUUIDForType because of
  1500. // gInventory.mIsAgentInvUsable is set to true in the gInventory.buildParentChildMap.
  1501. gInventory.buildParentChildMap();
  1502. display_startup();
  1503. //all categories loaded. lets create "My Favorites" category
  1504. gInventory.findCategoryUUIDForType(LLFolderType::FT_FAVORITE,true);
  1505. // set up callbacks
  1506. llinfos << "Registering Callbacks" << llendl;
  1507. LLMessageSystem* msg = gMessageSystem;
  1508. llinfos << " Inventory" << llendl;
  1509. LLInventoryModel::registerCallbacks(msg);
  1510. llinfos << " AvatarTracker" << llendl;
  1511. LLAvatarTracker::instance().registerCallbacks(msg);
  1512. llinfos << " Landmark" << llendl;
  1513. LLLandmark::registerCallbacks(msg);
  1514. display_startup();
  1515. // request mute list
  1516. llinfos << "Requesting Mute List" << llendl;
  1517. LLMuteList::getInstance()->requestFromServer(gAgent.getID());
  1518. display_startup();
  1519. // Get L$ and ownership credit information
  1520. llinfos << "Requesting Money Balance" << llendl;
  1521. LLStatusBar::sendMoneyBalanceRequest();
  1522. display_startup();
  1523. // request all group information
  1524. llinfos << "Requesting Agent Data" << llendl;
  1525. gAgent.sendAgentDataUpdateRequest();
  1526. display_startup();
  1527. // Create the inventory views
  1528. llinfos << "Creating Inventory Views" << llendl;
  1529. LLFloaterReg::getInstance("inventory");
  1530. display_startup();
  1531. LLStartUp::setStartupState( STATE_MISC );
  1532. display_startup();
  1533. return FALSE;
  1534. }
  1535. //---------------------------------------------------------------------
  1536. // Misc
  1537. //---------------------------------------------------------------------
  1538. if (STATE_MISC == LLStartUp::getStartupState())
  1539. {
  1540. // We have a region, and just did a big inventory download.
  1541. // We can estimate the user's connection speed, and set their
  1542. // max bandwidth accordingly. JC
  1543. if (gSavedSettings.getBOOL("FirstLoginThisInstall"))
  1544. {
  1545. // This is actually a pessimistic computation, because TCP may not have enough
  1546. // time to ramp up on the (small) default inventory file to truly measure max
  1547. // bandwidth. JC
  1548. F64 rate_bps = LLLoginInstance::getInstance()->getLastTransferRateBPS();
  1549. const F32 FAST_RATE_BPS = 600.f * 1024.f;
  1550. const F32 FASTER_RATE_BPS = 750.f * 1024.f;
  1551. F32 max_bandwidth = gViewerThrottle.getMaxBandwidth();
  1552. if (rate_bps > FASTER_RATE_BPS
  1553. && rate_bps > max_bandwidth)
  1554. {
  1555. LL_DEBUGS("AppInit") << "Fast network connection, increasing max bandwidth to "
  1556. << FASTER_RATE_BPS/1024.f
  1557. << " kbps" << LL_ENDL;
  1558. gViewerThrottle.setMaxBandwidth(FASTER_RATE_BPS / 1024.f);
  1559. }
  1560. else if (rate_bps > FAST_RATE_BPS
  1561. && rate_bps > max_bandwidth)
  1562. {
  1563. LL_DEBUGS("AppInit") << "Fast network connection, increasing max bandwidth to "
  1564. << FAST_RATE_BPS/1024.f
  1565. << " kbps" << LL_ENDL;
  1566. gViewerThrottle.setMaxBandwidth(FAST_RATE_BPS / 1024.f);
  1567. }
  1568. if (gSavedSettings.getBOOL("ShowHelpOnFirstLogin"))
  1569. {
  1570. gSavedSettings.setBOOL("HelpFloaterOpen", TRUE);
  1571. }
  1572. // Set the show start location to true, now that the user has logged
  1573. // on with this install.
  1574. gSavedSettings.setBOOL("ShowStartLocation", TRUE);
  1575. }
  1576. display_startup();
  1577. if (gSavedSettings.getBOOL("HelpFloaterOpen"))
  1578. {
  1579. // show default topic
  1580. LLViewerHelp::instance().showTopic("");
  1581. }
  1582. display_startup();
  1583. // We're successfully logged in.
  1584. gSavedSettings.setBOOL("FirstLoginThisInstall", FALSE);
  1585. LLFloaterReg::showInitialVisibleInstances();
  1586. display_startup();
  1587. // based on the comments, we've successfully logged in so we can delete the 'forced'
  1588. // URL that the updater set in settings.ini (in a mostly paranoid fashion)
  1589. std::string nextLoginLocation = gSavedSettings.getString( "NextLoginLocation" );
  1590. if ( nextLoginLocation.length() )
  1591. {
  1592. // clear it
  1593. gSavedSettings.setString( "NextLoginLocation", "" );
  1594. // and make sure it's saved
  1595. gSavedSettings.saveToFile( gSavedSettings.getString("ClientSettingsFile") , TRUE );
  1596. LLUIColorTable::instance().saveUserSettings();
  1597. };
  1598. display_startup();
  1599. // JC: Initializing audio requests many sounds for download.
  1600. init_audio();
  1601. display_startup();
  1602. // JC: Initialize "active" gestures. This may also trigger
  1603. // many gesture downloads, if this is the user's first
  1604. // time on this machine or -purge has been run.
  1605. LLSD gesture_options
  1606. = LLLoginInstance::getInstance()->getResponse("gestures");
  1607. if (gesture_options.isDefined())
  1608. {
  1609. LL_DEBUGS("AppInit") << "Gesture Manager loading " << gesture_options.size()
  1610. << LL_ENDL;
  1611. uuid_vec_t item_ids;
  1612. for(LLSD::array_const_iterator resp_it = gesture_options.beginArray(),
  1613. end = gesture_options.endArray(); resp_it != end; ++resp_it)
  1614. {
  1615. // If the id is not specifed in the LLSD,
  1616. // the LLSD operator[]() will return a null LLUUID.
  1617. LLUUID item_id = (*resp_it)["item_id"];
  1618. LLUUID asset_id = (*resp_it)["asset_id"];
  1619. if (item_id.notNull() && asset_id.notNull())
  1620. {
  1621. // Could schedule and delay these for later.
  1622. const BOOL no_inform_server = FALSE;
  1623. const BOOL no_deactivate_similar = FALSE;
  1624. LLGestureMgr::instance().activateGestureWithAsset(item_id, asset_id,
  1625. no_inform_server,
  1626. no_deactivate_similar);
  1627. // We need to fetch the inventory items for these gestures
  1628. // so we have the names to populate the UI.
  1629. item_ids.push_back(item_id);
  1630. }
  1631. }
  1632. // no need to add gesture to inventory observer, it's already made in constructor
  1633. LLGestureMgr::instance().setFetchIDs(item_ids);
  1634. LLGestureMgr::instance().startFetch();
  1635. }
  1636. gDisplaySwapBuffers = TRUE;
  1637. display_startup();
  1638. LLMessageSystem* msg = gMessageSystem;
  1639. msg->setHandlerFuncFast(_PREHASH_SoundTrigger, process_sound_trigger);
  1640. msg->setHandlerFuncFast(_PREHASH_PreloadSound, process_preload_sound);
  1641. msg->setHandlerFuncFast(_PREHASH_AttachedSound, process_attached_sound);
  1642. msg->setHandlerFuncFast(_PREHASH_AttachedSoundGainChange, process_attached_sound_gain_change);
  1643. LL_DEBUGS("AppInit") << "Initialization complete" << LL_ENDL;
  1644. gRenderStartTime.reset();
  1645. gForegroundTime.reset();
  1646. // HACK: Inform simulator of window size.
  1647. // Do this here so it's less likely to race with RegisterNewAgent.
  1648. // TODO: Put this into RegisterNewAgent
  1649. // JC - 7/20/2002
  1650. gViewerWindow->sendShapeToSim();
  1651. // The reason we show the alert is because we want to
  1652. // reduce confusion for when you log in and your provided
  1653. // location is not your expected location. So, if this is
  1654. // your first login, then you do not have an expectation,
  1655. // thus, do not show this alert.
  1656. if (!gAgent.isFirstLogin())
  1657. {
  1658. llinfos << "gAgentStartLocation : " << gAgentStartLocation << llendl;
  1659. LLSLURL start_slurl = LLStartUp::getStartSLURL();
  1660. if (((start_slurl.getType() == LLSLURL::LOCATION) && (gAgentStartLocation == "url")) ||
  1661. ((start_slurl.getType() == LLSLURL::LAST_LOCATION) && (gAgentStartLocation == "last")) ||
  1662. ((start_slurl.getType() == LLSLURL::HOME_LOCATION) && (gAgentStartLocation == "home")))
  1663. {
  1664. // Start location is OK
  1665. // Disabled code to restore camera location and focus if logging in to default location
  1666. static bool samename = false;
  1667. if (samename)
  1668. {
  1669. // restore old camera pos
  1670. gAgentCamera.setFocusOnAvatar(FALSE, FALSE);
  1671. gAgentCamera.setCameraPosAndFocusGlobal(gSavedSettings.getVector3d("CameraPosOnLogout"), gSavedSettings.getVector3d("FocusPosOnLogout"), LLUUID::null);
  1672. BOOL limit_hit = FALSE;
  1673. gAgentCamera.calcCameraPositionTargetGlobal(&limit_hit);
  1674. if (limit_hit)
  1675. {
  1676. gAgentCamera.setFocusOnAvatar(TRUE, FALSE);
  1677. }
  1678. gAgentCamera.stopCameraAnimation();
  1679. }
  1680. }
  1681. else
  1682. {
  1683. std::string msg;
  1684. switch(start_slurl.getType())
  1685. {
  1686. case LLSLURL::LOCATION:
  1687. {
  1688. msg = "AvatarMovedDesired";
  1689. break;
  1690. }
  1691. case LLSLURL::HOME_LOCATION:
  1692. {
  1693. msg = "AvatarMovedHome";
  1694. break;
  1695. }
  1696. default:
  1697. {
  1698. msg = "AvatarMovedLast";
  1699. }
  1700. }
  1701. LLNotificationsUtil::add(msg);
  1702. }
  1703. }
  1704. display_startup();
  1705. //DEV-17797. get null folder. Any items found here moved to Lost and Found
  1706. LLInventoryModelBackgroundFetch::instance().findLostItems();
  1707. display_startup();
  1708. LLStartUp::setStartupState( STATE_PRECACHE );
  1709. timeout.reset();
  1710. return FALSE;
  1711. }
  1712. if (STATE_PRECACHE == LLStartUp::getStartupState())
  1713. {
  1714. display_startup();
  1715. F32 timeout_frac = timeout.getElapsedTimeF32()/PRECACHING_DELAY;
  1716. // We now have an inventory skeleton, so if this is a user's first
  1717. // login, we can start setting up their clothing and avatar
  1718. // appearance. This helps to avoid the generic "Ruth" avatar in
  1719. // the orientation island tutorial experience. JC
  1720. if (gAgent.isFirstLogin()
  1721. && !sInitialOutfit.empty() // registration set up an outfit
  1722. && !sInitialOutfitGender.empty() // and a gender
  1723. && isAgentAvatarValid() // can't wear clothes without object
  1724. && !gAgent.isGenderChosen() ) // nothing already loading
  1725. {
  1726. // Start loading the wearables, textures, gestures
  1727. LLStartUp::loadInitialOutfit( sInitialOutfit, sInitialOutfitGender );
  1728. }
  1729. display_startup();
  1730. // wait precache-delay and for agent's avatar or a lot longer.
  1731. if(