PageRenderTime 163ms CodeModel.GetById 80ms app.highlight 9ms RepoModel.GetById 72ms 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
  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
 27#ifndef LL_LLLOGININSTANCE_H
 28#define LL_LLLOGININSTANCE_H
 29
 30#include "lleventdispatcher.h"
 31#include <boost/scoped_ptr.hpp>
 32#include <boost/function.hpp>
 33#include "llsecapi.h"
 34class LLLogin;
 35class LLEventStream;
 36class LLNotificationsInterface;
 37class LLUpdaterService;
 38
 39// This class hosts the login module and is used to 
 40// negotiate user authentication attempts.
 41class LLLoginInstance : public LLSingleton<LLLoginInstance>
 42{
 43public:
 44	class Disposable;
 45
 46	LLLoginInstance();
 47	~LLLoginInstance();
 48
 49	void connect(LLPointer<LLCredential> credentials); // Connect to the current grid choice.
 50	void connect(const std::string& uri, LLPointer<LLCredential> credentials);	// Connect to the given uri.
 51	void reconnect(); // reconnect using the current credentials.
 52	void disconnect();
 53
 54	bool authFailure() { return mAttemptComplete && mLoginState == "offline"; }
 55	bool authSuccess() { return mAttemptComplete && mLoginState == "online"; }
 56
 57	const std::string& getLoginState() { return mLoginState; }
 58	LLSD getResponse(const std::string& key) { return getResponse()[key]; }
 59	LLSD getResponse();
 60
 61	// Only valid when authSuccess == true.
 62	const F64 getLastTransferRateBPS() { return mTransferRate; }
 63
 64	// Whether to tell login to skip optional update request.
 65	// False by default.
 66	void setSkipOptionalUpdate(bool state) { mSkipOptionalUpdate = state; }
 67	void setSerialNumber(const std::string& sn) { mSerialNumber = sn; }
 68	void setLastExecEvent(int lee) { mLastExecEvent = lee; }
 69
 70	void setNotificationsInterface(LLNotificationsInterface* ni) { mNotifications = ni; }
 71
 72	typedef boost::function<void()> UpdaterLauncherCallback;
 73	void setUpdaterLauncher(const UpdaterLauncherCallback& ulc) { mUpdaterLauncher = ulc; }
 74
 75	void setUpdaterService(LLUpdaterService * updaterService) { mUpdaterService = updaterService; }
 76private:
 77	void constructAuthParams(LLPointer<LLCredential> user_credentials);
 78	void updateApp(bool mandatory, const std::string& message);
 79	bool updateDialogCallback(const LLSD& notification, const LLSD& response);
 80
 81	bool handleLoginEvent(const LLSD& event);
 82	void handleLoginFailure(const LLSD& event);
 83	void handleLoginSuccess(const LLSD& event);
 84	void handleDisconnect(const LLSD& event);
 85	void handleIndeterminate(const LLSD& event);
 86
 87	bool handleTOSResponse(bool v, const std::string& key);
 88
 89	void attemptComplete() { mAttemptComplete = true; } // In the future an event?
 90
 91	boost::scoped_ptr<LLLogin> mLoginModule;
 92	LLNotificationsInterface* mNotifications;
 93
 94	std::string mLoginState;
 95	LLSD mRequestData;
 96	LLSD mResponseData;
 97	bool mSkipOptionalUpdate;
 98	bool mAttemptComplete;
 99	F64 mTransferRate;
100	std::string mSerialNumber;
101	int mLastExecEvent;
102	UpdaterLauncherCallback mUpdaterLauncher;
103	LLEventDispatcher mDispatcher;
104	LLUpdaterService * mUpdaterService;	
105	boost::scoped_ptr<Disposable> mUpdateStateMachine;
106};
107
108#endif