PageRenderTime 94ms CodeModel.GetById 31ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/newview/lllogininstance.h

https://bitbucket.org/lindenlab/viewer-beta/
C Header | 108 lines | 60 code | 18 blank | 30 comment | 4 complexity | 011763ed9c42296798114e6d27db3eda MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file lllogininstance.h
  3. * @brief A host for the viewer's login connection.
  4. *
  5. * $LicenseInfo:firstyear=2009&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. #ifndef LL_LLLOGININSTANCE_H
  27. #define LL_LLLOGININSTANCE_H
  28. #include "lleventdispatcher.h"
  29. #include <boost/scoped_ptr.hpp>
  30. #include <boost/function.hpp>
  31. #include "llsecapi.h"
  32. class LLLogin;
  33. class LLEventStream;
  34. class LLNotificationsInterface;
  35. class LLUpdaterService;
  36. // This class hosts the login module and is used to
  37. // negotiate user authentication attempts.
  38. class LLLoginInstance : public LLSingleton<LLLoginInstance>
  39. {
  40. public:
  41. class Disposable;
  42. LLLoginInstance();
  43. ~LLLoginInstance();
  44. void connect(LLPointer<LLCredential> credentials); // Connect to the current grid choice.
  45. void connect(const std::string& uri, LLPointer<LLCredential> credentials); // Connect to the given uri.
  46. void reconnect(); // reconnect using the current credentials.
  47. void disconnect();
  48. bool authFailure() { return mAttemptComplete && mLoginState == "offline"; }
  49. bool authSuccess() { return mAttemptComplete && mLoginState == "online"; }
  50. const std::string& getLoginState() { return mLoginState; }
  51. LLSD getResponse(const std::string& key) { return getResponse()[key]; }
  52. LLSD getResponse();
  53. // Only valid when authSuccess == true.
  54. const F64 getLastTransferRateBPS() { return mTransferRate; }
  55. // Whether to tell login to skip optional update request.
  56. // False by default.
  57. void setSkipOptionalUpdate(bool state) { mSkipOptionalUpdate = state; }
  58. void setSerialNumber(const std::string& sn) { mSerialNumber = sn; }
  59. void setLastExecEvent(int lee) { mLastExecEvent = lee; }
  60. void setNotificationsInterface(LLNotificationsInterface* ni) { mNotifications = ni; }
  61. typedef boost::function<void()> UpdaterLauncherCallback;
  62. void setUpdaterLauncher(const UpdaterLauncherCallback& ulc) { mUpdaterLauncher = ulc; }
  63. void setUpdaterService(LLUpdaterService * updaterService) { mUpdaterService = updaterService; }
  64. private:
  65. void constructAuthParams(LLPointer<LLCredential> user_credentials);
  66. void updateApp(bool mandatory, const std::string& message);
  67. bool updateDialogCallback(const LLSD& notification, const LLSD& response);
  68. bool handleLoginEvent(const LLSD& event);
  69. void handleLoginFailure(const LLSD& event);
  70. void handleLoginSuccess(const LLSD& event);
  71. void handleDisconnect(const LLSD& event);
  72. void handleIndeterminate(const LLSD& event);
  73. bool handleTOSResponse(bool v, const std::string& key);
  74. void attemptComplete() { mAttemptComplete = true; } // In the future an event?
  75. boost::scoped_ptr<LLLogin> mLoginModule;
  76. LLNotificationsInterface* mNotifications;
  77. std::string mLoginState;
  78. LLSD mRequestData;
  79. LLSD mResponseData;
  80. bool mSkipOptionalUpdate;
  81. bool mAttemptComplete;
  82. F64 mTransferRate;
  83. std::string mSerialNumber;
  84. int mLastExecEvent;
  85. UpdaterLauncherCallback mUpdaterLauncher;
  86. LLEventDispatcher mDispatcher;
  87. LLUpdaterService * mUpdaterService;
  88. boost::scoped_ptr<Disposable> mUpdateStateMachine;
  89. };
  90. #endif