Add LL(URLDispatcher,CommandDispatcher,PanelLogin)Listener

LLURLDispatcherListener accepts requests for LLURLDispatcher.
LLCommandDispatcherListener accepts requests for LLCommandDispatcher.
LLPanelLoginListener accepts requests specifically for LLPanelLogin. Initially
it supports a simulated click to the "Log In" button.
meow-7.2.2
Nat Goodspeed 2009-12-10 22:30:57 -05:00
parent 99d757e041
commit 19122e164c
11 changed files with 254 additions and 2 deletions

View File

@ -104,6 +104,7 @@ set(viewer_SOURCE_FILES
llclassifiedstatsresponder.cpp
llcloud.cpp
llcolorswatch.cpp
llcommanddispatcherlistener.cpp
llcommandhandler.cpp
llcommandlineparser.cpp
llcompilequeue.cpp
@ -324,6 +325,7 @@ set(viewer_SOURCE_FILES
llpanellandmarks.cpp
llpanellandmedia.cpp
llpanellogin.cpp
llpanelloginlistener.cpp
llpanellookinfo.cpp
llpanelmaininventory.cpp
llpanelmediasettingsgeneral.cpp
@ -444,6 +446,7 @@ set(viewer_SOURCE_FILES
lluploaddialog.cpp
llurl.cpp
llurldispatcher.cpp
llurldispatcherlistener.cpp
llurlhistory.cpp
llurllineeditorctrl.cpp
llurlsimstring.cpp
@ -611,6 +614,7 @@ set(viewer_HEADER_FILES
llclassifiedstatsresponder.h
llcloud.h
llcolorswatch.h
llcommanddispatcherlistener.h
llcommandhandler.h
llcommandlineparser.h
llcompilequeue.h
@ -826,6 +830,7 @@ set(viewer_HEADER_FILES
llpanellandmarks.h
llpanellandmedia.h
llpanellogin.h
llpanelloginlistener.h
llpanellookinfo.h
llpanelmaininventory.h
llpanelmediasettingsgeneral.h
@ -950,6 +955,7 @@ set(viewer_HEADER_FILES
lluploaddialog.h
llurl.h
llurldispatcher.h
llurldispatcherlistener.h
llurlhistory.h
llurllineeditorctrl.h
llurlsimstring.h

View File

@ -0,0 +1,47 @@
/**
* @file llcommanddispatcherlistener.cpp
* @author Nat Goodspeed
* @date 2009-12-10
* @brief Implementation for llcommanddispatcherlistener.
*
* $LicenseInfo:firstyear=2009&license=viewergpl$
* Copyright (c) 2009, Linden Research, Inc.
* $/LicenseInfo$
*/
// Precompiled header
#include "llviewerprecompiledheaders.h"
// associated header
#include "llcommanddispatcherlistener.h"
// STL headers
// std headers
// external library headers
// other Linden headers
#include "llcommandhandler.h"
LLCommandDispatcherListener::LLCommandDispatcherListener(/* LLCommandDispatcher* instance */):
LLEventAPI("LLCommandDispatcher", "Access to LLCommandHandler commands") /* ,
mDispatcher(instance) */
{
add("dispatch",
"Execute a command registered as an LLCommandHandler,\n"
"passing any required parameters:\n"
"[\"cmd\"] string command name\n"
"[\"params\"] array of parameters, as if from components of URL path\n"
"[\"query\"] map of parameters, as if from ?key1=val&key2=val\n"
"[\"trusted\"] boolean indicating trusted browser [default true]",
&LLCommandDispatcherListener::dispatch);
}
void LLCommandDispatcherListener::dispatch(const LLSD& params) const
{
// For most purposes, we expect callers to want to be trusted.
bool trusted_browser = true;
if (params.has("trusted"))
{
// But for testing, allow a caller to specify untrusted.
trusted_browser = params["trusted"].asBoolean();
}
LLCommandDispatcher::dispatch(params["cmd"], params["params"], params["query"], NULL,
trusted_browser);
}

View File

@ -0,0 +1,30 @@
/**
* @file llcommanddispatcherlistener.h
* @author Nat Goodspeed
* @date 2009-12-10
* @brief LLEventAPI for LLCommandDispatcher
*
* $LicenseInfo:firstyear=2009&license=viewergpl$
* Copyright (c) 2009, Linden Research, Inc.
* $/LicenseInfo$
*/
#if ! defined(LL_LLCOMMANDDISPATCHERLISTENER_H)
#define LL_LLCOMMANDDISPATCHERLISTENER_H
#include "lleventapi.h"
class LLCommandDispatcher;
class LLSD;
class LLCommandDispatcherListener: public LLEventAPI
{
public:
LLCommandDispatcherListener(/* LLCommandDispatcher* instance */); // all static members
private:
void dispatch(const LLSD& params) const;
//LLCommandDispatcher* mDispatcher;
};
#endif /* ! defined(LL_LLCOMMANDDISPATCHERLISTENER_H) */

View File

@ -35,12 +35,15 @@
#include "llcommandhandler.h"
#include "llnotificationsutil.h"
#include "llcommanddispatcherlistener.h"
// system includes
#include <boost/tokenizer.hpp>
#define THROTTLE_PERIOD 15 // required secs between throttled commands
static LLCommandDispatcherListener sCommandDispatcherListener;
//---------------------------------------------------------------------------
// Underlying registry for command handlers, not directly accessible.
//---------------------------------------------------------------------------

View File

@ -73,6 +73,11 @@
#include "llfloatertos.h"
#include "lltrans.h"
#include "llglheaders.h"
#include "llpanelloginlistener.h"
#if LL_WINDOWS
#pragma warning(disable: 4355) // 'this' used in initializer list
#endif // LL_WINDOWS
#define USE_VIEWER_AUTH 0
@ -166,7 +171,8 @@ LLPanelLogin::LLPanelLogin(const LLRect &rect,
mLogoImage(),
mCallback(callback),
mCallbackData(cb_data),
mHtmlAvailable( TRUE )
mHtmlAvailable( TRUE ),
mListener(new LLPanelLoginListener(this))
{
setFocusRoot(TRUE);

View File

@ -36,10 +36,11 @@
#include "llpanel.h"
#include "llpointer.h" // LLPointer<>
#include "llmediactrl.h" // LLMediaCtrlObserver
#include <boost/scoped_ptr.hpp>
class LLLineEditor;
class LLUIImage;
class LLPanelLoginListener;
class LLPanelLogin:
public LLPanel,
@ -90,6 +91,7 @@ public:
/*virtual*/ void handleMediaEvent(LLPluginClassMedia* self, EMediaEvent event);
private:
friend class LLPanelLoginListener;
void reshapeBrowser();
static void onClickConnect(void*);
static void onClickNewAccount(void*);
@ -103,6 +105,7 @@ private:
private:
LLPointer<LLUIImage> mLogoImage;
boost::scoped_ptr<LLPanelLoginListener> mListener;
void (*mCallback)(S32 option, void *userdata);
void* mCallbackData;

View File

@ -0,0 +1,34 @@
/**
* @file llpanelloginlistener.cpp
* @author Nat Goodspeed
* @date 2009-12-10
* @brief Implementation for llpanelloginlistener.
*
* $LicenseInfo:firstyear=2009&license=viewergpl$
* Copyright (c) 2009, Linden Research, Inc.
* $/LicenseInfo$
*/
// Precompiled header
#include "llviewerprecompiledheaders.h"
// associated header
#include "llpanelloginlistener.h"
// STL headers
// std headers
// external library headers
// other Linden headers
#include "llpanellogin.h"
LLPanelLoginListener::LLPanelLoginListener(LLPanelLogin* instance):
LLEventAPI("LLPanelLogin", "Access to LLPanelLogin methods"),
mPanel(instance)
{
add("onClickConnect",
"Pretend user clicked the \"Log In\" button",
&LLPanelLoginListener::onClickConnect);
}
void LLPanelLoginListener::onClickConnect(const LLSD&) const
{
mPanel->onClickConnect(NULL);
}

View File

@ -0,0 +1,30 @@
/**
* @file llpanelloginlistener.h
* @author Nat Goodspeed
* @date 2009-12-10
* @brief LLEventAPI for LLPanelLogin
*
* $LicenseInfo:firstyear=2009&license=viewergpl$
* Copyright (c) 2009, Linden Research, Inc.
* $/LicenseInfo$
*/
#if ! defined(LL_LLPANELLOGINLISTENER_H)
#define LL_LLPANELLOGINLISTENER_H
#include "lleventapi.h"
class LLPanelLogin;
class LLSD;
class LLPanelLoginListener: public LLEventAPI
{
public:
LLPanelLoginListener(LLPanelLogin* instance);
private:
void onClickConnect(const LLSD&) const;
LLPanelLogin* mPanel;
};
#endif /* ! defined(LL_LLPANELLOGINLISTENER_H) */

View File

@ -47,11 +47,14 @@
#include "llurlsimstring.h"
#include "llweb.h"
#include "llworldmapmessage.h"
#include "llurldispatcherlistener.h"
// library includes
#include "llnotificationsutil.h"
#include "llsd.h"
static LLURLDispatcherListener sURLDispatcherListener;
class LLURLDispatcherImpl
{
public:

View File

@ -0,0 +1,58 @@
/**
* @file llurldispatcherlistener.cpp
* @author Nat Goodspeed
* @date 2009-12-10
* @brief Implementation for llurldispatcherlistener.
*
* $LicenseInfo:firstyear=2009&license=viewergpl$
* Copyright (c) 2009, Linden Research, Inc.
* $/LicenseInfo$
*/
// Precompiled header
#include "llviewerprecompiledheaders.h"
// associated header
#include "llurldispatcherlistener.h"
// STL headers
// std headers
// external library headers
// other Linden headers
#include "llurldispatcher.h"
LLURLDispatcherListener::LLURLDispatcherListener(/* LLURLDispatcher* instance */):
LLEventAPI("LLURLDispatcher", "Internal URL handling") /* ,
mDispatcher(instance) */
{
add("dispatch",
"At startup time or on clicks in internal web browsers,\n"
"teleport, open map, or run requested command.\n"
"[\"url\"] string url to dispatch\n"
"[\"trusted\"] boolean indicating trusted browser [default true]",
&LLURLDispatcherListener::dispatch);
add("dispatchRightClick", "Dispatch [\"url\"] as if from a right-click on a hot link.",
&LLURLDispatcherListener::dispatchRightClick);
add("dispatchFromTextEditor", "Dispatch [\"url\"] as if from an edit field.",
&LLURLDispatcherListener::dispatchFromTextEditor);
}
void LLURLDispatcherListener::dispatch(const LLSD& params) const
{
// For most purposes, we expect callers to want to be trusted.
bool trusted_browser = true;
if (params.has("trusted"))
{
// But for testing, allow a caller to specify untrusted.
trusted_browser = params["trusted"].asBoolean();
}
LLURLDispatcher::dispatch(params["url"], NULL, trusted_browser);
}
void LLURLDispatcherListener::dispatchRightClick(const LLSD& params) const
{
LLURLDispatcher::dispatchRightClick(params["url"]);
}
void LLURLDispatcherListener::dispatchFromTextEditor(const LLSD& params) const
{
LLURLDispatcher::dispatchFromTextEditor(params["url"]);
}

View File

@ -0,0 +1,32 @@
/**
* @file llurldispatcherlistener.h
* @author Nat Goodspeed
* @date 2009-12-10
* @brief LLEventAPI for LLURLDispatcher
*
* $LicenseInfo:firstyear=2009&license=viewergpl$
* Copyright (c) 2009, Linden Research, Inc.
* $/LicenseInfo$
*/
#if ! defined(LL_LLURLDISPATCHERLISTENER_H)
#define LL_LLURLDISPATCHERLISTENER_H
#include "lleventapi.h"
class LLURLDispatcher;
class LLSD;
class LLURLDispatcherListener: public LLEventAPI
{
public:
LLURLDispatcherListener(/* LLURLDispatcher* instance */); // all static members
private:
void dispatch(const LLSD& params) const;
void dispatchRightClick(const LLSD& params) const;
void dispatchFromTextEditor(const LLSD& params) const;
//LLURLDispatcher* mDispatcher;
};
#endif /* ! defined(LL_LLURLDISPATCHERLISTENER_H) */