Skip to content
Snippets Groups Projects
Commit e1ab7d8a authored by Kartic Krishnamurthy's avatar Kartic Krishnamurthy
Browse files
NOTE: r63705 is *not* the earliest rev# for dpo-3-bug-fix.
parent 7964c6f7
No related branches found
No related tags found
No related merge requests found
...@@ -243,7 +243,6 @@ ...@@ -243,7 +243,6 @@
<key>trusted-sender</key> <key>trusted-sender</key>
<boolean>false</boolean> <boolean>false</boolean>
</map> </map>
<!-- Simulator to simulator unreliable messages --> <!-- Simulator to simulator unreliable messages -->
<key>EdgeDataPacket</key> <key>EdgeDataPacket</key>
<map> <map>
...@@ -324,6 +323,38 @@ ...@@ -324,6 +323,38 @@
<key>trusted-sender</key> <key>trusted-sender</key>
<boolean>true</boolean> <boolean>true</boolean>
</map> </map>
<key>avatarnotesrequest</key>
<map>
<key>service_name</key><string>avatar-notes</string>
<key>builder</key>
<string>template</string>
<key>trusted-sender</key>
<boolean>false</boolean>
</map>
<key>avatarclassifiedsrequest</key>
<map>
<key>service_name</key><string>avatar-classifieds</string>
<key>builder</key>
<string>template</string>
<key>trusted-sender</key>
<boolean>false</boolean>
</map>
<key>avatarpickrequest</key>
<map>
<key>service_name</key><string>avatar-pick</string>
<key>builder</key>
<string>template</string>
<key>trusted-sender</key>
<boolean>false</boolean>
</map>
<key>pickinforequest</key>
<map>
<key>service_name</key><string>pick-info</string>
<key>builder</key>
<string>template</string>
<key>trusted-sender</key>
<boolean>false</boolean>
</map>
</map> </map>
<key>capBans</key> <key>capBans</key>
<map> <map>
......
...@@ -275,9 +275,10 @@ LLURI LLURI::buildHTTP(const std::string& prefix, ...@@ -275,9 +275,10 @@ LLURI LLURI::buildHTTP(const std::string& prefix,
const LLSD& query) const LLSD& query)
{ {
LLURI uri = buildHTTP(prefix, path); LLURI uri = buildHTTP(prefix, path);
uri.mEscapedQuery = mapToQueryString(query);
// break out and escape each query component // break out and escape each query component
uri.mEscapedOpaque += "?" + uri.mEscapedQuery ; uri.mEscapedQuery = mapToQueryString(query);
uri.mEscapedOpaque += uri.mEscapedQuery ;
uri.mEscapedQuery.erase(0,1); // trim the leading '?'
return uri; return uri;
} }
...@@ -581,20 +582,30 @@ LLSD LLURI::queryMap(std::string escaped_query_string) ...@@ -581,20 +582,30 @@ LLSD LLURI::queryMap(std::string escaped_query_string)
std::string LLURI::mapToQueryString(const LLSD& queryMap) std::string LLURI::mapToQueryString(const LLSD& queryMap)
{ {
std::string query_string; std::string query_string;
if (queryMap.isMap()) if (queryMap.isMap())
{ {
for (LLSD::map_const_iterator iter = queryMap.beginMap(); bool first_element = true;
iter != queryMap.endMap(); LLSD::map_const_iterator iter = queryMap.beginMap();
iter++) LLSD::map_const_iterator end = queryMap.endMap();
std::ostringstream ostr;
for (; iter != end; ++iter)
{ {
query_string += escapeQueryVariable(iter->first) + if(first_element)
(iter->second.isUndefined() ? "" : "=" + escapeQueryValue(iter->second.asString())) + "&" ; {
ostr << "?";
first_element = false;
}
else
{
ostr << "&";
}
ostr << escapeQueryVariable(iter->first);
if(iter->second.isDefined())
{
ostr << "=" << escapeQueryValue(iter->second.asString());
}
} }
//if (queryMap.size() > 0) query_string = ostr.str();
//{
// query_string += "?" + query_string ;
//}
} }
return query_string; return query_string;
} }
...@@ -38,34 +38,42 @@ class LLURI ...@@ -38,34 +38,42 @@ class LLURI
// construct from escaped string, as would be transmitted on the net // construct from escaped string, as would be transmitted on the net
~LLURI(); ~LLURI();
static LLURI buildHTTP(const std::string& prefix, static LLURI buildHTTP(
const LLSD& path); const std::string& prefix,
static LLURI buildHTTP(const std::string& prefix, const LLSD& path);
const LLSD& path,
const LLSD& query);
// prefix is either a full URL prefix of the form "http://example.com:8080",
// or it can be simply a host and optional port like "example.com" or
// "example.com:8080", in these cases, the "http://" will be added
static LLURI buildHTTP(const std::string& host, static LLURI buildHTTP(
const U32& port, const std::string& prefix,
const LLSD& path); const LLSD& path,
static LLURI buildHTTP(const std::string& host, const LLSD& query);
const U32& port, ///< prefix is either a full URL prefix of the form
const LLSD& path, /// "http://example.com:8080", or it can be simply a host and
const LLSD& query); /// optional port like "example.com" or "example.com:8080", in
std::string asString() const; /// these cases, the "http://" will be added
// the whole URI, escaped as needed
static LLURI buildHTTP(
const std::string& host,
const U32& port,
const LLSD& path);
static LLURI buildHTTP(
const std::string& host,
const U32& port,
const LLSD& path,
const LLSD& query);
std::string asString() const;
///< the whole URI, escaped as needed
// Parts of a URI /** @name Parts of a URI */
// These functions return parts of the decoded URI. The returned //@{
// strings are un-escaped as needed // These functions return parts of the decoded URI. The returned
// strings are un-escaped as needed
// for all schemes // for all schemes
std::string scheme() const; // ex.: "http", note lack of colon std::string scheme() const; ///< ex.: "http", note lack of colon
std::string opaque() const; // everything after the colon std::string opaque() const; ///< everything after the colon
// for schemes that follow path like syntax (http, https, ftp) // for schemes that follow path like syntax (http, https, ftp)
std::string authority() const; // ex.: "host.com:80" std::string authority() const; // ex.: "host.com:80"
...@@ -81,27 +89,34 @@ class LLURI ...@@ -81,27 +89,34 @@ class LLURI
const std::string& escapedQuery() const { return mEscapedQuery; } const std::string& escapedQuery() const { return mEscapedQuery; }
LLSD queryMap() const; // above decoded into a map LLSD queryMap() const; // above decoded into a map
static LLSD queryMap(std::string escaped_query_string); static LLSD queryMap(std::string escaped_query_string);
static std::string mapToQueryString(const LLSD& queryMap);
// Escaping Utilities /**
// Escape a string by urlencoding all the characters that aren't in the allowed string. * @brief given a name value map, return a serialized query string.
static std::string escape(const std::string& str); *
static std::string escape(const std::string& str, const std::string & allowed);
static std::string unescape(const std::string& str); * @param query_map a map of name value. every value must be
* representable as a string.
* @return Returns an url query string of '?n1=v1&n2=v2&...'
*/
static std::string mapToQueryString(const LLSD& query_map);
// Functions for building specific URIs for web services /** @name Escaping Utilities */
// *NOTE: DEPRECATED. use the service builder instead. //@{
//static LLURI buildBulkAgentNamesURI(LLApp* app); // Escape a string by urlencoding all the characters that aren't
//static LLURI buildAgentSessionURI(const LLUUID& agent_id, LLApp* app); // in the allowed string.
//static LLURI buildAgentLoginInfoURI(const LLUUID& agent_id, const std::string& dataserver); static std::string escape(const std::string& str);
//static LLURI buildAgentNameURI(const LLUUID& agent_id, LLApp* app); static std::string escape(
const std::string& str,
const std::string & allowed);
static std::string unescape(const std::string& str);
//@}
private: private:
std::string mScheme; std::string mScheme;
std::string mEscapedOpaque; std::string mEscapedOpaque;
std::string mEscapedAuthority; std::string mEscapedAuthority;
std::string mEscapedPath; std::string mEscapedPath;
std::string mEscapedQuery; std::string mEscapedQuery;
}; };
#endif // LL_LLURI_H #endif // LL_LLURI_H
...@@ -232,6 +232,7 @@ static void request( ...@@ -232,6 +232,7 @@ static void request(
LLURLRequest::ERequestAction method, LLURLRequest::ERequestAction method,
Injector* body_injector, Injector* body_injector,
LLHTTPClient::ResponderPtr responder, LLHTTPClient::ResponderPtr responder,
const LLSD& headers,
const F32 timeout=HTTP_REQUEST_EXPIRY_SECS) const F32 timeout=HTTP_REQUEST_EXPIRY_SECS)
{ {
if (!LLHTTPClient::hasPump()) if (!LLHTTPClient::hasPump())
...@@ -243,6 +244,19 @@ static void request( ...@@ -243,6 +244,19 @@ static void request(
LLURLRequest *req = new LLURLRequest(method, url); LLURLRequest *req = new LLURLRequest(method, url);
req->requestEncoding(""); req->requestEncoding("");
if (headers.isMap())
{
LLSD::map_const_iterator iter = headers.beginMap();
LLSD::map_const_iterator end = headers.endMap();
for (; iter != end; ++iter)
{
std::ostringstream header;
header << iter->first << ": " << iter->second.asString() ;
req->addHeader(header.str().c_str());
}
}
if (!gCABundle.empty()) if (!gCABundle.empty())
{ {
req->checkRootCertificate(true, gCABundle.c_str()); req->checkRootCertificate(true, gCABundle.c_str());
...@@ -267,17 +281,37 @@ static void request( ...@@ -267,17 +281,37 @@ static void request(
theClientPump->addChain(chain, timeout); theClientPump->addChain(chain, timeout);
} }
static void request(
const std::string& url,
LLURLRequest::ERequestAction method,
Injector* body_injector,
LLHTTPClient::ResponderPtr responder,
const F32 timeout=HTTP_REQUEST_EXPIRY_SECS)
{
request(url, method, body_injector, responder, LLSD(), timeout);
}
void LLHTTPClient::get(const std::string& url, ResponderPtr responder, const LLSD& headers, const F32 timeout)
{
request(url, LLURLRequest::HTTP_GET, NULL, responder, headers, timeout);
}
void LLHTTPClient::get(const std::string& url, ResponderPtr responder, const F32 timeout) void LLHTTPClient::get(const std::string& url, ResponderPtr responder, const F32 timeout)
{ {
request(url, LLURLRequest::HTTP_GET, NULL, responder, timeout); get(url, responder, LLSD(), timeout);
} }
void LLHTTPClient::get(const std::string& url, const LLSD& query, ResponderPtr responder, const F32 timeout) void LLHTTPClient::get(const std::string& url, const LLSD& query, ResponderPtr responder, const LLSD& headers, const F32 timeout)
{ {
LLURI uri; LLURI uri;
uri = LLURI::buildHTTP(url, LLSD::emptyArray(), query); uri = LLURI::buildHTTP(url, LLSD::emptyArray(), query);
get(uri.asString(), responder, timeout); get(uri.asString(), responder, headers, timeout);
}
void LLHTTPClient::get(const std::string& url, const LLSD& query, ResponderPtr responder, const F32 timeout)
{
get(url, query, responder, LLSD(), timeout);
} }
// A simple class for managing data returned from a curl http request. // A simple class for managing data returned from a curl http request.
......
...@@ -59,7 +59,9 @@ class LLHTTPClient ...@@ -59,7 +59,9 @@ class LLHTTPClient
typedef boost::intrusive_ptr<Responder> ResponderPtr; typedef boost::intrusive_ptr<Responder> ResponderPtr;
static void get(const std::string& url, ResponderPtr, const F32 timeout=HTTP_REQUEST_EXPIRY_SECS); static void get(const std::string& url, ResponderPtr, const F32 timeout=HTTP_REQUEST_EXPIRY_SECS);
static void get(const std::string& url, ResponderPtr, const LLSD& headers, const F32 timeout=HTTP_REQUEST_EXPIRY_SECS);
static void get(const std::string& url, const LLSD& query, ResponderPtr, const F32 timeout=HTTP_REQUEST_EXPIRY_SECS); static void get(const std::string& url, const LLSD& query, ResponderPtr, const F32 timeout=HTTP_REQUEST_EXPIRY_SECS);
static void get(const std::string& url, const LLSD& query, ResponderPtr, const LLSD& headers, const F32 timeout=HTTP_REQUEST_EXPIRY_SECS);
static void put(const std::string& url, const LLSD& body, ResponderPtr, const F32 timeout=HTTP_REQUEST_EXPIRY_SECS); static void put(const std::string& url, const LLSD& body, ResponderPtr, const F32 timeout=HTTP_REQUEST_EXPIRY_SECS);
///< non-blocking ///< non-blocking
static void post(const std::string& url, const LLSD& body, ResponderPtr, const F32 timeout=HTTP_REQUEST_EXPIRY_SECS); static void post(const std::string& url, const LLSD& body, ResponderPtr, const F32 timeout=HTTP_REQUEST_EXPIRY_SECS);
......
...@@ -232,3 +232,19 @@ bool LLMessageConfig::isCapBanned(const std::string& cap_name) ...@@ -232,3 +232,19 @@ bool LLMessageConfig::isCapBanned(const std::string& cap_name)
{ {
return LLMessageConfigFile::instance().isCapBanned(cap_name); return LLMessageConfigFile::instance().isCapBanned(cap_name);
} }
// return the web-service path to use for a given
// message. This entry *should* match the entry
// in simulator.xml!
LLSD LLMessageConfig::getConfigForMessage(const std::string& msg_name)
{
if (sServerName.empty())
{
llerrs << "LLMessageConfig::isMessageTrusted(name) before"
<< " LLMessageConfig::initClass()" << llendl;
}
LLMessageConfigFile& file = LLMessageConfigFile::instance();
// LLSD for the CamelCase message name
LLSD config = file.mMessages[msg_name];
return config;
}
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#define LL_MESSAGECONFIG_H #define LL_MESSAGECONFIG_H
#include <string> #include <string>
#include "llsd.h"
class LLSD; class LLSD;
...@@ -30,5 +31,6 @@ class LLMessageConfig ...@@ -30,5 +31,6 @@ class LLMessageConfig
static SenderTrust getSenderTrustedness(const std::string& msg_name); static SenderTrust getSenderTrustedness(const std::string& msg_name);
static bool isValidMessage(const std::string& msg_name); static bool isValidMessage(const std::string& msg_name);
static bool isCapBanned(const std::string& cap_name); static bool isCapBanned(const std::string& cap_name);
static LLSD getConfigForMessage(const std::string& msg_name);
}; };
#endif // LL_MESSAGECONFIG_H #endif // LL_MESSAGECONFIG_H
...@@ -89,7 +89,7 @@ std::string LLServiceBuilder::buildServiceURI( ...@@ -89,7 +89,7 @@ std::string LLServiceBuilder::buildServiceURI(
const LLSD& option_map) const LLSD& option_map)
{ {
std::string service_url = buildServiceURI(service_name); std::string service_url = buildServiceURI(service_name);
// Find the Service Name // Find the Service Name
if(!service_url.empty() && option_map.isMap()) if(!service_url.empty() && option_map.isMap())
{ {
...@@ -108,6 +108,23 @@ std::string LLServiceBuilder::buildServiceURI( ...@@ -108,6 +108,23 @@ std::string LLServiceBuilder::buildServiceURI(
find_pos, find_pos,
variable_name.length(), variable_name.length(),
(*option_itr).second.asString()); (*option_itr).second.asString());
continue;
}
variable_name.assign("{%");
variable_name.append((*option_itr).first);
variable_name.append("}");
find_pos = service_url.find(variable_name);
if(find_pos != std::string::npos)
{
std::string query_str = LLURI::mapToQueryString(
(*option_itr).second);
if(!query_str.empty())
{
service_url.replace(
find_pos,
variable_name.length(),
query_str);
}
} }
} }
} }
......
...@@ -71,6 +71,7 @@ BOOL LLPanelAvatar::sAllowFirstLife = FALSE; ...@@ -71,6 +71,7 @@ BOOL LLPanelAvatar::sAllowFirstLife = FALSE;
// RN: move these to lldbstrings.h // RN: move these to lldbstrings.h
static const S32 DB_USER_FAVORITES_STR_LEN = 254; static const S32 DB_USER_FAVORITES_STR_LEN = 254;
const char LOADING_MSG[] = "Loading...";
static const char IM_DISABLED_TOOLTIP[] = "Instant Message (IM).\nDisabled because you do not have their card."; static const char IM_DISABLED_TOOLTIP[] = "Instant Message (IM).\nDisabled because you do not have their card.";
static const char IM_ENABLED_TOOLTIP[] = "Instant Message (IM)"; static const char IM_ENABLED_TOOLTIP[] = "Instant Message (IM)";
static const S32 LEFT = HPAD; static const S32 LEFT = HPAD;
...@@ -810,7 +811,7 @@ void LLPanelAvatarNotes::refresh() ...@@ -810,7 +811,7 @@ void LLPanelAvatarNotes::refresh()
void LLPanelAvatarNotes::clearControls() void LLPanelAvatarNotes::clearControls()
{ {
childSetText("notes edit", "Loading..."); childSetText("notes edit", LOADING_MSG);
childSetEnabled("notes edit", false); childSetEnabled("notes edit", false);
} }
...@@ -1251,6 +1252,8 @@ LLPanelAvatar::LLPanelAvatar( ...@@ -1251,6 +1252,8 @@ LLPanelAvatar::LLPanelAvatar(
mAvatarID( LLUUID::null ), // mAvatarID is set with 'setAvatar' or 'setAvatarID' mAvatarID( LLUUID::null ), // mAvatarID is set with 'setAvatar' or 'setAvatarID'
mHaveProperties(FALSE), mHaveProperties(FALSE),
mHaveStatistics(FALSE), mHaveStatistics(FALSE),
mHaveNotes(false),
mLastNotes(),
mAllowEdit(allow_edit) mAllowEdit(allow_edit)
{ {
...@@ -1440,6 +1443,8 @@ void LLPanelAvatar::setAvatarID(const LLUUID &avatar_id, const LLString &name, ...@@ -1440,6 +1443,8 @@ void LLPanelAvatar::setAvatarID(const LLUUID &avatar_id, const LLString &name,
mPanelNotes->clearControls(); mPanelNotes->clearControls();
mPanelNotes->setDataRequested(false); mPanelNotes->setDataRequested(false);
mHaveNotes = false;
mLastNotes.clear();
// Request just the first two pages of data. The picks, // Request just the first two pages of data. The picks,
// classifieds, and notes will be requested when that panel // classifieds, and notes will be requested when that panel
...@@ -1451,8 +1456,8 @@ void LLPanelAvatar::setAvatarID(const LLUUID &avatar_id, const LLString &name, ...@@ -1451,8 +1456,8 @@ void LLPanelAvatar::setAvatarID(const LLUUID &avatar_id, const LLString &name,
if (mAllowEdit) if (mAllowEdit)
{ {
// OK button disabled until properties data arrives // OK button disabled until properties data arrives
childSetVisible("OK",TRUE); childSetVisible("OK", true);
childSetEnabled("OK",TRUE); childSetEnabled("OK", false);
childSetVisible("Cancel",TRUE); childSetVisible("Cancel",TRUE);
childSetEnabled("Cancel",TRUE); childSetEnabled("Cancel",TRUE);
} }
...@@ -1747,7 +1752,19 @@ void LLPanelAvatar::sendAvatarPropertiesRequest() ...@@ -1747,7 +1752,19 @@ void LLPanelAvatar::sendAvatarPropertiesRequest()
void LLPanelAvatar::sendAvatarNotesUpdate() void LLPanelAvatar::sendAvatarNotesUpdate()
{ {
std::string notes = mPanelNotes->childGetValue("notes edit").asString(); std::string notes = mPanelNotes->childGetValue("notes edit").asString();
if (!mHaveNotes
&& (notes.empty() || notes == LOADING_MSG))
{
// no notes from server and no user updates
return;
}
if (notes == mLastNotes)
{
// Avatar notes unchanged
return;
}
LLMessageSystem *msg = gMessageSystem; LLMessageSystem *msg = gMessageSystem;
msg->newMessage("AvatarNotesUpdate"); msg->newMessage("AvatarNotesUpdate");
...@@ -2155,6 +2172,8 @@ void LLPanelAvatar::processAvatarNotesReply(LLMessageSystem *msg, void**) ...@@ -2155,6 +2172,8 @@ void LLPanelAvatar::processAvatarNotesReply(LLMessageSystem *msg, void**)
msg->getString("Data", "Notes", DB_USER_NOTE_SIZE, text); msg->getString("Data", "Notes", DB_USER_NOTE_SIZE, text);
self->childSetValue("notes edit", text); self->childSetValue("notes edit", text);
self->childSetEnabled("notes edit", true); self->childSetEnabled("notes edit", true);
self->mHaveNotes = true;
self->mLastNotes = text;
} }
} }
......
...@@ -303,16 +303,15 @@ class LLPanelAvatar : public LLPanel ...@@ -303,16 +303,15 @@ class LLPanelAvatar : public LLPanel
static void onClickCSR( void *userdata); static void onClickCSR( void *userdata);
static void onClickMute( void *userdata); static void onClickMute( void *userdata);
private:
void enableOKIfReady();
static void finishKick(S32 option, const LLString& text, void* userdata); static void finishKick(S32 option, const LLString& text, void* userdata);
static void finishFreeze(S32 option, const LLString& text, void* userdata); static void finishFreeze(S32 option, const LLString& text, void* userdata);
static void finishUnfreeze(S32 option, const LLString& text, void* userdata); static void finishUnfreeze(S32 option, const LLString& text, void* userdata);
static void showProfileCallback(S32 option, void *userdata); static void showProfileCallback(S32 option, void *userdata);
// Teen users are not allowed to see or enter data into the first life page,
// or their own about/interests text entry fields.
static BOOL sAllowFirstLife;
static void* createPanelAvatar(void* data); static void* createPanelAvatar(void* data);
static void* createFloaterAvatarInfo(void* data); static void* createFloaterAvatarInfo(void* data);
static void* createPanelAvatarSecondLife(void* data); static void* createPanelAvatarSecondLife(void* data);
...@@ -333,13 +332,20 @@ class LLPanelAvatar : public LLPanel ...@@ -333,13 +332,20 @@ class LLPanelAvatar : public LLPanel
LLPanelAvatarWeb* mPanelWeb; LLPanelAvatarWeb* mPanelWeb;
LLDropTarget* mDropTarget; LLDropTarget* mDropTarget;
// Teen users are not allowed to see or enter data into the first life page,
// or their own about/interests text entry fields.
static BOOL sAllowFirstLife;
protected: private:
void enableOKIfReady();
LLUUID mAvatarID; // for which avatar is this window? LLUUID mAvatarID; // for which avatar is this window?
BOOL mIsFriend; // Are we friends? BOOL mIsFriend; // Are we friends?
BOOL mHaveProperties; BOOL mHaveProperties;
BOOL mHaveStatistics; BOOL mHaveStatistics;
// only update note if data received from database and
// note is changed from database version
bool mHaveNotes;
std::string mLastNotes;
LLTabContainerCommon* mTab; LLTabContainerCommon* mTab;
BOOL mAllowEdit; BOOL mAllowEdit;
......
...@@ -72,5 +72,22 @@ namespace tut ...@@ -72,5 +72,22 @@ namespace tut
std::string test_url = mServiceBuilder.buildServiceURI("ServiceBuilderTest", data_map); std::string test_url = mServiceBuilder.buildServiceURI("ServiceBuilderTest", data_map);
ensure_equals("Replacement URL Creation for Non-existant Service", test_url , "/agent/{$agent-id}/name"); ensure_equals("Replacement URL Creation for Non-existant Service", test_url , "/agent/{$agent-id}/name");
} }
template<> template<>
void ServiceBuilderTestObject::test<5>()
{
LLSD test_block;
test_block["service-builder"] = "/proc/{$proc}{%params}";
mServiceBuilder.createServiceDefinition("ServiceBuilderTest", test_block["service-builder"]);
LLSD data_map;
data_map["proc"] = "do/something/useful";
data_map["params"]["estate_id"] = 1;
data_map["params"]["query"] = "public";
std::string test_url = mServiceBuilder.buildServiceURI("ServiceBuilderTest", data_map);
ensure_equals(
"two part URL Creation",
test_url ,
"/proc/do/something/useful?estate_id=1&query=public");
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment