From 7f0664ff82650a52dd9ea83987deabb23036a7eb Mon Sep 17 00:00:00 2001 From: Siana Gearz Date: Sat, 3 Nov 2012 14:13:13 +0100 Subject: [PATCH] Bringing back message logger --- indra/llmessage/CMakeLists.txt | 11 +- indra/llmessage/llcircuit.cpp | 11 + indra/llmessage/llcircuit.h | 4 + indra/llmessage/lldatapacker.h | 6 +- indra/llmessage/llpacketring.cpp | 10 +- indra/llmessage/llregionpresenceverifier.cpp | 153 ------------ indra/llmessage/llregionpresenceverifier.h | 98 -------- indra/llmessage/llservice.cpp | 111 --------- indra/llmessage/llservice.h | 185 --------------- indra/llmessage/llservicebuilder.cpp | 236 ------------------- indra/llmessage/llservicebuilder.h | 104 -------- indra/llmessage/lltemplatemessagereader.cpp | 35 +-- indra/llmessage/lltemplatemessagereader.h | 8 +- indra/llmessage/message.cpp | 4 +- indra/llmessage/message.h | 4 +- indra/newview/CMakeLists.txt | 2 + indra/newview/llviewermenu.cpp | 10 +- indra/newview/llviewerprecompiledheaders.h | 1 - 18 files changed, 69 insertions(+), 924 deletions(-) delete mode 100644 indra/llmessage/llregionpresenceverifier.cpp delete mode 100644 indra/llmessage/llregionpresenceverifier.h delete mode 100644 indra/llmessage/llservice.cpp delete mode 100644 indra/llmessage/llservice.h delete mode 100644 indra/llmessage/llservicebuilder.cpp delete mode 100644 indra/llmessage/llservicebuilder.h diff --git a/indra/llmessage/CMakeLists.txt b/indra/llmessage/CMakeLists.txt index aac669137..f084200f6 100644 --- a/indra/llmessage/CMakeLists.txt +++ b/indra/llmessage/CMakeLists.txt @@ -49,6 +49,7 @@ set(llmessage_SOURCE_FILES llmail.cpp llmessagebuilder.cpp llmessageconfig.cpp + llmessagelog.cpp llmessagereader.cpp llmessagetemplate.cpp llmessagetemplateparser.cpp @@ -62,14 +63,11 @@ set(llmessage_SOURCE_FILES llpartdata.cpp llproxy.cpp llpumpio.cpp - llregionpresenceverifier.cpp llsdappservices.cpp llsdhttpserver.cpp llsdmessage.cpp llsdmessagebuilder.cpp llsdmessagereader.cpp - llservicebuilder.cpp - llservice.cpp llstoredmessage.cpp lltemplatemessagebuilder.cpp lltemplatemessagedispatcher.cpp @@ -94,7 +92,6 @@ set(llmessage_SOURCE_FILES message_prehash.cpp message_string_table.cpp net.cpp - partsyspacket.cpp patch_code.cpp patch_dct.cpp patch_idct.cpp @@ -145,6 +142,7 @@ set(llmessage_HEADER_FILES llmail.h llmessagebuilder.h llmessageconfig.h + llmessagelog.h llmessagereader.h llmessagetemplate.h llmessagetemplateparser.h @@ -162,14 +160,11 @@ set(llmessage_HEADER_FILES llqueryflags.h llregionflags.h llregionhandle.h - llregionpresenceverifier.h llsdappservices.h llsdhttpserver.h llsdmessage.h llsdmessagebuilder.h llsdmessagereader.h - llservice.h - llservicebuilder.h llstoredmessage.h lltaskname.h llteleportflags.h @@ -197,7 +192,6 @@ set(llmessage_HEADER_FILES message.h message_prehash.h net.h - partsyspacket.h patch_code.h patch_dct.h sound_ids.h @@ -232,7 +226,6 @@ if (LL_TESTS) llnamevalue.cpp lltrustedmessageservice.cpp lltemplatemessagedispatcher.cpp - llregionpresenceverifier.cpp ) LL_ADD_PROJECT_UNIT_TESTS(llmessage "${llmessage_TEST_SOURCE_FILES}") diff --git a/indra/llmessage/llcircuit.cpp b/indra/llmessage/llcircuit.cpp index 56249db41..2ae76ab5e 100644 --- a/indra/llmessage/llcircuit.cpp +++ b/indra/llmessage/llcircuit.cpp @@ -1229,6 +1229,17 @@ void LLCircuit::getCircuitRange( first = mCircuitData.upper_bound(key); } +// +std::vector LLCircuit::getCircuitDataList() +{ + std::vector list; + circuit_data_map::iterator end = mCircuitData.end(); + for(circuit_data_map::iterator iter = mCircuitData.begin(); iter != end; ++iter) + list.push_back((*iter).second); + return list; +} +// + TPACKETID LLCircuitData::nextPacketOutID() { mPacketsOut++; diff --git a/indra/llmessage/llcircuit.h b/indra/llmessage/llcircuit.h index d1c400c6a..cd7576efa 100644 --- a/indra/llmessage/llcircuit.h +++ b/indra/llmessage/llcircuit.h @@ -328,6 +328,10 @@ public: circuit_data_map::iterator& first, circuit_data_map::iterator& end); + // + std::vector getCircuitDataList(); + // + // Lists that optimize how many circuits we need to traverse a frame // HACK - this should become protected eventually, but stupid !@$@# message system/circuit classes are jumbling things up. circuit_data_map mUnackedCircuitMap; // Map of circuits with unacked data diff --git a/indra/llmessage/lldatapacker.h b/indra/llmessage/lldatapacker.h index b0a638c16..2b6e57484 100644 --- a/indra/llmessage/lldatapacker.h +++ b/indra/llmessage/lldatapacker.h @@ -173,10 +173,12 @@ public: void freeBuffer() { delete [] mBufferp; mBufferp = mCurBufferp = NULL; mBufferSize = 0; mWriteEnabled = FALSE; } void assignBuffer(U8 *bufferp, S32 size) { - if(mBufferp && mBufferp != bufferp) + //No no no no no! This breaks the paradigm of callers handling buffer allocation/deallocation + //Also, buffers can be on stack! Calling delete[] on such a buffer would be VERY bad. + /*if(mBufferp && mBufferp != bufferp) { freeBuffer() ; - } + }*/ mBufferp = bufferp; mCurBufferp = bufferp; mBufferSize = size; diff --git a/indra/llmessage/llpacketring.cpp b/indra/llmessage/llpacketring.cpp index fc6e9c519..d52a9435c 100644 --- a/indra/llmessage/llpacketring.cpp +++ b/indra/llmessage/llpacketring.cpp @@ -44,6 +44,10 @@ #include "timing.h" #include "u64.h" +// +#include "llmessagelog.h" +// + /////////////////////////////////////////////////////////// LLPacketRing::LLPacketRing () : mUseInThrottle(FALSE), @@ -272,7 +276,11 @@ S32 LLPacketRing::receivePacket (S32 socket, char *datap) } BOOL LLPacketRing::sendPacket(int h_socket, char * send_buffer, S32 buf_size, LLHost host) -{ +{ + // + LLMessageLog::log(LLHost(16777343, gMessageSystem->getListenPort()), host, (U8*)send_buffer, buf_size); + // + BOOL status = TRUE; if (!mUseOutThrottle) { diff --git a/indra/llmessage/llregionpresenceverifier.cpp b/indra/llmessage/llregionpresenceverifier.cpp deleted file mode 100644 index 01d78ed3e..000000000 --- a/indra/llmessage/llregionpresenceverifier.cpp +++ /dev/null @@ -1,153 +0,0 @@ -/** - * @file llregionpresenceverifier.cpp - * @brief - * - * $LicenseInfo:firstyear=2008&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#include "linden_common.h" - -#include "llregionpresenceverifier.h" -#include "llhttpclientinterface.h" -#include -#include "net.h" -#include "message.h" - -//namespace boost -//{ - void intrusive_ptr_add_ref(LLRegionPresenceVerifier::Response* p) - { - ++p->mReferenceCount; - } - - void intrusive_ptr_release(LLRegionPresenceVerifier::Response* p) - { - if(p && 0 == --p->mReferenceCount) - { - delete p; - } - } -//}; - -LLRegionPresenceVerifier::Response::~Response() -{ -} - -LLRegionPresenceVerifier::RegionResponder::RegionResponder(const std::string& - uri, - ResponsePtr data, - S32 retry_count) : - mUri(uri), - mSharedData(data), - mRetryCount(retry_count) -{ -} - -//virtual -LLRegionPresenceVerifier::RegionResponder::~RegionResponder() -{ -} - -void LLRegionPresenceVerifier::RegionResponder::result(const LLSD& content) -{ - std::string host = content["private_host"].asString(); - U32 port = content["private_port"].asInteger(); - LLHost destination(host, port); - LLUUID id = content["region_id"]; - - lldebugs << "Verifying " << destination.getString() << " is region " << id << llendl; - - std::stringstream uri; - uri << "http://" << destination.getString() << "/state/basic/"; - mSharedData->getHttpClient().get( - uri.str(), - new VerifiedDestinationResponder(mUri, mSharedData, content, mRetryCount)); -} - -void LLRegionPresenceVerifier::RegionResponder::error(U32 status, - const std::string& reason) -{ - // TODO: babbage: distinguish between region presence service and - // region verification errors? - mSharedData->onRegionVerificationFailed(); -} - -LLRegionPresenceVerifier::VerifiedDestinationResponder::VerifiedDestinationResponder(const std::string& uri, ResponsePtr data, const LLSD& content, - S32 retry_count): - mUri(uri), - mSharedData(data), - mContent(content), - mRetryCount(retry_count) -{ -} - -//virtual -LLRegionPresenceVerifier::VerifiedDestinationResponder::~VerifiedDestinationResponder() -{ -} - -void LLRegionPresenceVerifier::VerifiedDestinationResponder::result(const LLSD& content) -{ - LLUUID actual_region_id = content["region_id"]; - LLUUID expected_region_id = mContent["region_id"]; - - lldebugs << "Actual region: " << content << llendl; - lldebugs << "Expected region: " << mContent << llendl; - - if (mSharedData->checkValidity(content) && - (actual_region_id == expected_region_id)) - { - mSharedData->onRegionVerified(mContent); - } - else if (mRetryCount > 0) - { - retry(); - } - else - { - llwarns << "Simulator verification failed. Region: " << mUri << llendl; - mSharedData->onRegionVerificationFailed(); - } -} - -void LLRegionPresenceVerifier::VerifiedDestinationResponder::retry() -{ - LLSD headers; - headers["Cache-Control"] = "no-cache, max-age=0"; - llinfos << "Requesting region information, get uncached for region " - << mUri << llendl; - --mRetryCount; - mSharedData->getHttpClient().get(mUri, new RegionResponder(mUri, mSharedData, mRetryCount), headers); -} - -void LLRegionPresenceVerifier::VerifiedDestinationResponder::error(U32 status, const std::string& reason) -{ - if(mRetryCount > 0) - { - retry(); - } - else - { - llwarns << "Failed to contact simulator for verification. Region: " << mUri << llendl; - mSharedData->onRegionVerificationFailed(); - } -} diff --git a/indra/llmessage/llregionpresenceverifier.h b/indra/llmessage/llregionpresenceverifier.h deleted file mode 100644 index 9b45e78b5..000000000 --- a/indra/llmessage/llregionpresenceverifier.h +++ /dev/null @@ -1,98 +0,0 @@ -/** - * @file llregionpresenceverifier.cpp - * @brief - * - * $LicenseInfo:firstyear=2008&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -/* Macro Definitions */ -#ifndef LL_LLREGIONPRESENCEVERIFIER_H -#define LL_LLREGIONPRESENCEVERIFIER_H - -#include "llhttpclient.h" -#include -#include "llsd.h" -#include - -class LLHTTPClientInterface; - -class LLRegionPresenceVerifier -{ -public: - class Response - { - public: - virtual ~Response() = 0; - - virtual bool checkValidity(const LLSD& content) const = 0; - virtual void onRegionVerified(const LLSD& region_details) = 0; - virtual void onRegionVerificationFailed() = 0; - - virtual LLHTTPClientInterface& getHttpClient() = 0; - - public: /* but not really -- don't touch this */ - U32 mReferenceCount; - }; - - typedef boost::intrusive_ptr ResponsePtr; - - class RegionResponder : public LLHTTPClient::Responder - { - public: - RegionResponder(const std::string& uri, ResponsePtr data, - S32 retry_count); - virtual ~RegionResponder(); - virtual void result(const LLSD& content); - virtual void error(U32 status, const std::string& reason); - - private: - ResponsePtr mSharedData; - std::string mUri; - S32 mRetryCount; - }; - - class VerifiedDestinationResponder : public LLHTTPClient::Responder - { - public: - VerifiedDestinationResponder(const std::string& uri, ResponsePtr data, - const LLSD& content, S32 retry_count); - virtual ~VerifiedDestinationResponder(); - virtual void result(const LLSD& content); - - virtual void error(U32 status, const std::string& reason); - - private: - void retry(); - ResponsePtr mSharedData; - LLSD mContent; - std::string mUri; - S32 mRetryCount; - }; -}; - -//namespace boost -//{ - void intrusive_ptr_add_ref(LLRegionPresenceVerifier::Response* p); - void intrusive_ptr_release(LLRegionPresenceVerifier::Response* p); -//}; - -#endif //LL_LLREGIONPRESENCEVERIFIER_H diff --git a/indra/llmessage/llservice.cpp b/indra/llmessage/llservice.cpp deleted file mode 100644 index dbec92c22..000000000 --- a/indra/llmessage/llservice.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/** - * @file llservice.cpp - * @author Phoenix - * @date 2005-04-20 - * - * $LicenseInfo:firstyear=2005&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#include "linden_common.h" -#include "llservice.h" - -LLService::creators_t LLService::sCreatorFunctors; - -LLService::LLService() -{ -} - -LLService::~LLService() -{ -} - -// static -bool LLService::registerCreator(const std::string& name, creator_t fn) -{ - llinfos << "LLService::registerCreator(" << name << ")" << llendl; - if(name.empty()) - { - return false; - } - - creators_t::value_type vt(name, fn); - std::pair rv = sCreatorFunctors.insert(vt); - return rv.second; - - // alternately... - //std::string name_str(name); - //sCreatorFunctors[name_str] = fn; -} - -// static -LLIOPipe* LLService::activate( - const std::string& name, - LLPumpIO::chain_t& chain, - LLSD context) -{ - if(name.empty()) - { - llinfos << "LLService::activate - no service specified." << llendl; - return NULL; - } - creators_t::iterator it = sCreatorFunctors.find(name); - LLIOPipe* rv = NULL; - if(it != sCreatorFunctors.end()) - { - if((*it).second->build(chain, context)) - { - rv = chain[0].get(); - } - else - { - // empty out the chain, because failed service creation - // should just discard this stuff. - llwarns << "LLService::activate - unable to build chain: " << name - << llendl; - chain.clear(); - } - } - else - { - llwarns << "LLService::activate - unable find factory: " << name - << llendl; - } - return rv; -} - -// static -bool LLService::discard(const std::string& name) -{ - if(name.empty()) - { - return false; - } - creators_t::iterator it = sCreatorFunctors.find(name); - if(it != sCreatorFunctors.end()) - { - //(*it).second->discard(); - sCreatorFunctors.erase(it); - return true; - } - return false; -} - diff --git a/indra/llmessage/llservice.h b/indra/llmessage/llservice.h deleted file mode 100644 index 9c09aeb44..000000000 --- a/indra/llmessage/llservice.h +++ /dev/null @@ -1,185 +0,0 @@ -/** - * @file llservice.h - * @author Phoenix - * @date 2004-11-21 - * @brief Declaration file for LLService and related classes. - * - * $LicenseInfo:firstyear=2004&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#ifndef LL_LLSERVICE_H -#define LL_LLSERVICE_H - -#include -#include -//#include -//#include - -//#include "llframetimer.h" -#include "lliopipe.h" -#include "llchainio.h" - -#if 0 -class LLServiceCreator; -/** - * intrusive pointer support - */ -namespace boost -{ - void intrusive_ptr_add_ref(LLServiceCreator* p); - void intrusive_ptr_release(LLServiceCreator* p); -}; -#endif - -/** - * @class LLServiceCreator - * @brief This class is an abstract base class for classes which create - * new LLService instances. - * - * Derive classes from this class which appropriately implement the - * operator() and destructor. - * @see LLService - */ -#if 0 -class LLServiceCreator -{ -public: - typedef boost::intrusive_ptr service_t; - virtual ~LLServiceCreator() {} - virtual service_t activate() = 0; - virtual void discard() = 0; - -protected: - LLServiceCreator() : mReferenceCount(0) - { - } - -private: - friend void boost::intrusive_ptr_add_ref(LLServiceCreator* p); - friend void boost::intrusive_ptr_release(LLServiceCreator* p); - U32 mReferenceCount; -}; -#endif - -#if 0 -namespace boost -{ - inline void intrusive_ptr_add_ref(LLServiceCreator* p) - { - ++p->mReferenceCount; - } - inline void intrusive_ptr_release(LLServiceCreator* p) - { - if(p && 0 == --p->mReferenceCount) - { - delete p; - } - } -}; -#endif - -/** - * @class LLService - * @brief This class is the base class for the service classes. - * @see LLIOPipe - * - * The services map a string to a chain factory with a known interface - * at the front of the chain. So, to activate a service, call - * activate() with the name of the service needed which - * will call the associated factory, and return a pointer to the - * known interface. - * NOTE: If you are implementing a service factory, it is - * vitally important that the service pipe is at the front of the - * chain. - */ -class LLService : public LLIOPipe -{ -public: - //typedef boost::intrusive_ptr creator_t; - //typedef boost::intrusive_ptr service_t; - typedef boost::shared_ptr creator_t; - - /** - * @brief This method is used to register a protocol name with a - * a functor that creates the service. - * - * THOROUGH_DESCRIPTION - * @param aParameter A brief description of aParameter. - * @return Returns true if a service was successfully registered. - */ - static bool registerCreator(const std::string& name, creator_t fn); - - /** - * @brief This method connects to a service by name. - * - * @param name The name of the service to connect to. - * @param chain The constructed chain including the service instance. - * @param context Context for the activation. - * @return An instance of the service for use or NULL on failure. - */ - static LLIOPipe* activate( - const std::string& name, - LLPumpIO::chain_t& chain, - LLSD context); - - /** - * @brief - * - * @param name The name of the service to discard. - * @return true if service creator was found and discarded. - */ - static bool discard(const std::string& name); - -protected: - // The creation factory static data. - typedef std::map creators_t; - static creators_t sCreatorFunctors; - -protected: - // construction & destruction. since this class is an abstract - // base class, it is up to Service implementations to actually - // deal with construction and not a public method. How that - // construction takes place will be handled by the service - // creators. - LLService(); - virtual ~LLService(); - -protected: - // This frame timer records how long this service has - // existed. Useful for derived services to give themselves a - // lifetime and expiration. - // *NOTE: Phoenix - This functionaity has been moved to the - // pump. 2005-12-13 - //LLFrameTimer mTimer; - - // Since services are designed in an 'ask now, respond later' - // idiom which probably crosses thread boundaries, almost all - // services will need a handle to a response pipe. It will usually - // be the job of the service author to derive a useful - // implementation of response, and up to the service subscriber to - // further derive that class to do something useful when the - // response comes in. - LLIOPipe::ptr_t mResponse; -}; - - -#endif // LL_LLSERVICE_H diff --git a/indra/llmessage/llservicebuilder.cpp b/indra/llmessage/llservicebuilder.cpp deleted file mode 100644 index b9aef3d0b..000000000 --- a/indra/llmessage/llservicebuilder.cpp +++ /dev/null @@ -1,236 +0,0 @@ -/** - * @file llservicebuilder.cpp - * @brief Implementation of the LLServiceBuilder class. - * - * $LicenseInfo:firstyear=2007&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ - -#include "linden_common.h" -#include "llapp.h" -#include "llfile.h" -#include "llservicebuilder.h" -#include "llsd.h" -#include "llsdserialize.h" - -void LLServiceBuilder::loadServiceDefinitionsFromFile( - const std::string& service_filename) -{ - llifstream service_file(service_filename, std::ios::binary); - if(service_file.is_open()) - { - LLSD service_data; - LLSDSerialize::fromXMLDocument(service_data, service_file); - service_file.close(); - // Load service - LLSD service_map = service_data["services"]; - for(LLSD::array_iterator array_itr = service_map.beginArray(); - array_itr != service_map.endArray(); - ++array_itr) - { - LLSD service_llsd = (*array_itr)["service-builder"]; - std::string service_name = (*array_itr)["name"].asString(); - createServiceDefinition(service_name, service_llsd); - } - llinfos << "loaded config file: " << service_filename << llendl; - } - else - { - llwarns << "unable to find config file: " << service_filename << llendl; - } -} - -void LLServiceBuilder::createServiceDefinition( - const std::string& service_name, - LLSD& service_llsd) -{ - if(service_llsd.isString()) - { - mServiceMap[ service_name ] = service_llsd.asString(); - } - else if(service_llsd.isMap()) - { - for(LLSD::map_iterator map_itr = service_llsd.beginMap(); - map_itr != service_llsd.endMap(); - ++map_itr) - { - std::string compound_builder_name = service_name; - compound_builder_name.append("-"); - compound_builder_name.append((*map_itr).first); - mServiceMap[ compound_builder_name ] = (*map_itr).second.asString(); - } - } -} - -static -bool starts_with(const std::string& text, const char* prefix) -{ - return text.substr(0, strlen(prefix)) == prefix; -} - -// TODO: Build a real services.xml for windows development. -// and remove the base_url logic below. -std::string LLServiceBuilder::buildServiceURI(const std::string& service_name) const -{ - std::ostringstream service_url; - // Find the service builder - std::map::const_iterator it = - mServiceMap.find(service_name); - if(it != mServiceMap.end()) - { - // construct the service builder url - LLApp* app = LLApp::instance(); - if(app) - { - // We define a base-url for some development configurations - // In production neither of these are defined and all services have full urls - LLSD base_url; - - if (starts_with(service_name,"cap")) - { - base_url = app->getOption("cap-base-url"); - } - - if (base_url.asString().empty()) - { - base_url = app->getOption("services-base-url"); - } - service_url << base_url.asString(); - } - service_url << it->second; - } - else - { - llwarns << "Cannot find service " << service_name << llendl; - } - return service_url.str(); -} - -std::string LLServiceBuilder::buildServiceURI( - const std::string& service_name, - const LLSD& option_map) const -{ - return russ_format(buildServiceURI(service_name), option_map); -} - -std::string russ_format(const std::string& format_str, const LLSD& context) -{ - std::string service_url(format_str); - if(!service_url.empty() && context.isMap()) - { - // throw in a ridiculously large limiter to make sure we don't - // loop forever with bad input. - int iterations = 100; - bool keep_looping = true; - while(keep_looping) - { - if(0 == --iterations) - { - keep_looping = false; - } - - int depth = 0; - int deepest = 0; - bool find_match = false; - std::string::iterator iter(service_url.begin()); - std::string::iterator end(service_url.end()); - std::string::iterator deepest_node(service_url.end()); - std::string::iterator deepest_node_end(service_url.end()); - // parse out the variables to replace by going through {}s - // one at a time, starting with the "deepest" in series - // {{}}, and otherwise replacing right-to-left - for(; iter != end; ++iter) - { - switch(*iter) - { - case '{': - ++depth; - if(depth > deepest) - { - deepest = depth; - deepest_node = iter; - find_match = true; - } - break; - case '}': - --depth; - if(find_match) - { - deepest_node_end = iter; - find_match = false; - } - break; - default: - break; - } - } - if((deepest_node == end) || (deepest_node_end == end)) - { - break; - } - //replace the variable we found in the {} above. - // *NOTE: since the c++ implementation only understands - // params and straight string substitution, so it's a - // known distance of 2 to skip the directive. - std::string key(deepest_node + 2, deepest_node_end); - LLSD value = context[key]; - switch(*(deepest_node + 1)) - { - case '$': - if(value.isDefined()) - { - service_url.replace( - deepest_node, - deepest_node_end + 1, - value.asString()); - } - else - { - llwarns << "Unknown key: " << key << " in option map: " - << LLSDOStreamer(context) - << llendl; - keep_looping = false; - } - break; - case '%': - { - std::string query_str = LLURI::mapToQueryString(value); - service_url.replace( - deepest_node, - deepest_node_end + 1, - query_str); - } - break; - default: - llinfos << "Unknown directive: " << *(deepest_node + 1) - << llendl; - keep_looping = false; - break; - } - } - } - if (service_url.find('{') != std::string::npos) - { - llwarns << "Constructed a likely bogus service URL: " << service_url - << llendl; - } - return service_url; -} diff --git a/indra/llmessage/llservicebuilder.h b/indra/llmessage/llservicebuilder.h deleted file mode 100644 index 968995edf..000000000 --- a/indra/llmessage/llservicebuilder.h +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @file llservicebuilder.h -* @brief Declaration of the LLServiceBuilder class. -* -* $LicenseInfo:firstyear=2007&license=viewerlgpl$ -* Second Life Viewer Source Code -* Copyright (C) 2010, Linden Research, Inc. -* -* This library is free software; you can redistribute it and/or -* modify it under the terms of the GNU Lesser General Public -* License as published by the Free Software Foundation; -* version 2.1 of the License only. -* -* This library is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public -* License along with this library; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -* -* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA -* $/LicenseInfo$ -*/ - -#ifndef LLSERVICEBUILDER_H -#define LLSERVICEBUILDER_H - -#include -#include -#include "llerror.h" - -class LLSD; - -/** - * @brief Format format string according to rules for RUSS. - * - * This function appears alongside the service builder since the - * algorithm was originally implemented there. This can eventually be - * moved when someone wants to take the time. - * @see https://osiris.lindenlab.com/mediawiki/index.php/Recursive_URL_Substitution_Syntax - * @param format_str The input string to format. - * @param context A map used for string substitutions. - * @return Returns the formatted string. If no match is found for a - * substitution target, the braces remain intact. - */ -std::string russ_format(const std::string& format_str, const LLSD& context); - -/** - * @class LLServiceBuilder - * @brief This class builds urls for us to use when making web service calls. - */ -class LLServiceBuilder -{ - LOG_CLASS(LLServiceBuilder); -public: - LLServiceBuilder(void) {} - ~LLServiceBuilder(void) {} - - /** - * @brief Initialize this object with the service definitions. - * - * @param service_filename The services definition files -- services.xml. - */ - void loadServiceDefinitionsFromFile(const std::string& service_filename); - - /** - * @brief Build a service url if the url needs no construction parameters. - * - * @param service_name The name of the service you want to call. - */ - std::string buildServiceURI(const std::string& service_name) const; - - /** - * @brief Build a service url if the url with construction parameters. - * - * The parameter substitution supports string substituition from RUSS: - * [[Recursive_URL_Substitution_Syntax]] - * @param service_name The name of the service you want to call. - * @param option_map The parameters in a map of name:value for the service. - */ - std::string buildServiceURI( - const std::string& service_name, - const LLSD& option_map) const; - -public: - /** - * @brief Helper method which builds construction state for a service - * - * This method should probably be protected, but we need to test this - * method. - */ - void createServiceDefinition( - const std::string& service_name, - LLSD& service_url); - -protected: - std::map mServiceMap; -}; - - - -#endif diff --git a/indra/llmessage/lltemplatemessagereader.cpp b/indra/llmessage/lltemplatemessagereader.cpp index ab91f74ab..bfce2ea29 100644 --- a/indra/llmessage/lltemplatemessagereader.cpp +++ b/indra/llmessage/lltemplatemessagereader.cpp @@ -443,7 +443,7 @@ S32 LLTemplateMessageReader::getMessageSize() const // Returns template for the message contained in buffer BOOL LLTemplateMessageReader::decodeTemplate( const U8* buffer, S32 buffer_size, // inputs - LLMessageTemplate** msg_template ) // outputs + LLMessageTemplate** msg_template, bool custom ) // outputs { const U8* header = buffer + LL_PACKET_ID_SIZE; @@ -485,8 +485,9 @@ BOOL LLTemplateMessageReader::decodeTemplate( } else // bogus packet received (too short) { - llwarns << "Packet with unusable length received (too short): " - << buffer_size << llendl; + if(!custom) + llwarns << "Packet with unusable length received (too short): " + << buffer_size << llendl; return(FALSE); } @@ -497,9 +498,11 @@ BOOL LLTemplateMessageReader::decodeTemplate( } else { - llwarns << "Message #" << std::hex << num << std::dec - << " received but not registered!" << llendl; - gMessageSystem->callExceptionFunc(MX_UNREGISTERED_MESSAGE); + if(!custom) { + llwarns << "Message #" << std::hex << num << std::dec + << " received but not registered!" << llendl; + gMessageSystem->callExceptionFunc(MX_UNREGISTERED_MESSAGE); + } return(FALSE); } @@ -528,7 +531,7 @@ void LLTemplateMessageReader::logRanOffEndOfPacket( const LLHost& host, const S3 static LLFastTimer::DeclareTimer FTM_PROCESS_MESSAGES("Process Messages"); // decode a given message -BOOL LLTemplateMessageReader::decodeData(const U8* buffer, const LLHost& sender ) +BOOL LLTemplateMessageReader::decodeData(const U8* buffer, const LLHost& sender, bool custom) { llassert( mReceiveSize >= 0 ); llassert( mCurrentRMessageTemplate); @@ -586,7 +589,8 @@ BOOL LLTemplateMessageReader::decodeData(const U8* buffer, const LLHost& sender } else { - llerrs << "Unknown block type" << llendl; + if(!custom) + llerrs << "Unknown block type" << llendl; return FALSE; } @@ -632,7 +636,8 @@ BOOL LLTemplateMessageReader::decodeData(const U8* buffer, const LLHost& sender if ((decode_pos + data_size) > mReceiveSize) { - logRanOffEndOfPacket(sender, decode_pos, data_size); + if (!custom) + logRanOffEndOfPacket(sender, decode_pos, data_size); // default to 0 length variable blocks tsize = 0; @@ -668,7 +673,8 @@ BOOL LLTemplateMessageReader::decodeData(const U8* buffer, const LLHost& sender // so, copy data pointer and set data size to fixed size if ((decode_pos + mvci.getSize()) > mReceiveSize) { - logRanOffEndOfPacket(sender, decode_pos, mvci.getSize()); + if(!custom) + logRanOffEndOfPacket(sender, decode_pos, mvci.getSize()); // default to 0s. U32 size = mvci.getSize(); @@ -696,6 +702,7 @@ BOOL LLTemplateMessageReader::decodeData(const U8* buffer, const LLHost& sender return FALSE; } + if(!custom) { static LLTimer decode_timer; @@ -751,11 +758,11 @@ BOOL LLTemplateMessageReader::decodeData(const U8* buffer, const LLHost& sender BOOL LLTemplateMessageReader::validateMessage(const U8* buffer, S32 buffer_size, const LLHost& sender, - bool trusted) + bool trusted, bool custom) { mReceiveSize = buffer_size; - BOOL valid = decodeTemplate(buffer, buffer_size, &mCurrentRMessageTemplate ); - if(valid) + BOOL valid = decodeTemplate(buffer, buffer_size, &mCurrentRMessageTemplate, custom); + if(valid && !custom) { mCurrentRMessageTemplate->mReceiveCount++; //lldebugs << "MessageRecvd:" @@ -787,7 +794,7 @@ BOOL LLTemplateMessageReader::validateMessage(const U8* buffer, BOOL LLTemplateMessageReader::readMessage(const U8* buffer, const LLHost& sender) { - return decodeData(buffer, sender); + return decodeData(buffer, sender, false); } //virtual diff --git a/indra/llmessage/lltemplatemessagereader.h b/indra/llmessage/lltemplatemessagereader.h index fcf8f92fa..e096d4775 100644 --- a/indra/llmessage/lltemplatemessagereader.h +++ b/indra/llmessage/lltemplatemessagereader.h @@ -99,7 +99,7 @@ public: virtual void copyToBuilder(LLMessageBuilder&) const; BOOL validateMessage(const U8* buffer, S32 buffer_size, - const LLHost& sender, bool trusted = false); + const LLHost& sender, bool trusted = false, bool custom = false); BOOL readMessage(const U8* buffer, const LLHost& sender); bool isTrusted() const; @@ -112,16 +112,18 @@ private: S32 size = 0, S32 blocknum = 0, S32 max_size = S32_MAX); BOOL decodeTemplate(const U8* buffer, S32 buffer_size, // inputs - LLMessageTemplate** msg_template ); // outputs + LLMessageTemplate** msg_template, // outputs + bool custom = false); void logRanOffEndOfPacket( const LLHost& host, const S32 where, const S32 wanted ); - BOOL decodeData(const U8* buffer, const LLHost& sender ); + BOOL decodeData(const U8* buffer, const LLHost& sender, bool custom); S32 mReceiveSize; LLMessageTemplate* mCurrentRMessageTemplate; LLMsgData* mCurrentRMessageData; message_template_number_map_t& mMessageNumbers; + friend class LLFloaterMessageLogItem; }; #endif // LL_LLTEMPLATEMESSAGEREADER_H diff --git a/indra/llmessage/message.cpp b/indra/llmessage/message.cpp index 1fe40f6bc..7f6d9e378 100644 --- a/indra/llmessage/message.cpp +++ b/indra/llmessage/message.cpp @@ -552,11 +552,11 @@ BOOL LLMessageSystem::checkMessages( S64 frame_count ) S32 true_rcv_size = 0; U8* buffer = mTrueReceiveBuffer; - + mTrueReceiveSize = mPacketRing->receivePacket(mSocket, (char *)mTrueReceiveBuffer); // If you want to dump all received packets into SecondLife.log, uncomment this //dumpPacketToLog(); - + receive_size = mTrueReceiveSize; mLastSender = mPacketRing->getLastSender(); mLastReceivingIF = mPacketRing->getLastReceivingInterface(); diff --git a/indra/llmessage/message.h b/indra/llmessage/message.h index dee687d47..fff0c6f85 100644 --- a/indra/llmessage/message.h +++ b/indra/llmessage/message.h @@ -233,6 +233,8 @@ class LLMessageSystem : public LLMessageSenderInterface private: message_template_name_map_t mMessageTemplates; message_template_number_map_t mMessageNumbers; + friend class LLFloaterMessageLogItem; + friend class LLFloaterMessageLog; public: S32 mSystemVersionMajor; @@ -341,7 +343,7 @@ public: bool addCircuitCode(U32 code, const LLUUID& session_id); BOOL poll(F32 seconds); // Number of seconds that we want to block waiting for data, returns if data was received - BOOL checkMessages( S64 frame_count = 0 ); + BOOL checkMessages(S64 frame_count = 0); void processAcks(); BOOL isMessageFast(const char *msg); diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index b380af7d2..97b9429b4 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -217,6 +217,7 @@ set(viewer_SOURCE_FILES llfloatermap.cpp llfloatermediabrowser.cpp llfloatermemleak.cpp + llfloatermessagelog.cpp llfloatermodeluploadbase.cpp llfloatermute.cpp llfloaternamedesc.cpp @@ -719,6 +720,7 @@ set(viewer_HEADER_FILES llfloatermap.h llfloatermediabrowser.h llfloatermemleak.h + llfloatermessagelog.h llfloatermodeluploadbase.h llfloatermute.h llfloaternamedesc.h diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index a0f2064ca..8963af86c 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -249,6 +249,7 @@ #include "hgfloatertexteditor.h" #include "llfloatervfs.h" #include "llfloatervfsexplorer.h" +#include "llfloatermessagelog.h" #include "shfloatermediaticker.h" #include "llpacketring.h" // @@ -489,7 +490,7 @@ void handle_force_ground_sit(void*); void handle_phantom_avatar(void*); void handle_hide_typing_notification(void*); void handle_close_all_notifications(void*); -//void handle_open_message_log(void*); +void handle_open_message_log(void*); void handle_edit_ao(void*); void handle_local_assets(void*); void handle_vfs_explorer(void*); @@ -818,7 +819,6 @@ void init_menus() (void*)"ReSit")); menu->addSeparator(); menu->addChild(new LLMenuItemCallGL( "Object Area Search", &handle_area_search, NULL)); - //menu->addChild(new LLMenuItemCallGL( "Message Log", &handle_open_message_log, NULL)); menu->addChild(new LLMenuItemCallGL( "Sound Explorer", &handle_sounds_explorer, NULL)); @@ -1089,6 +1089,8 @@ void init_client_menu(LLMenuGL* menu) sub = new LLMenuGL("Network"); sub->setCanTearOff(TRUE); + sub->addChild(new LLMenuItemCallGL( "Message Log", &handle_open_message_log, NULL)); + sub->addChild(new LLMenuItemCallGL("Enable Message Log", &handle_viewer_enable_message_log, NULL)); sub->addChild(new LLMenuItemCallGL("Disable Message Log", @@ -3657,10 +3659,10 @@ void process_grant_godlike_powers(LLMessageSystem* msg, void**) // -/*void handle_open_message_log(void*) +void handle_open_message_log(void*) { LLFloaterMessageLog::show(); -}*/ +} void handle_edit_ao(void*) { diff --git a/indra/newview/llviewerprecompiledheaders.h b/indra/newview/llviewerprecompiledheaders.h index 3b8444b54..c95d11314 100644 --- a/indra/newview/llviewerprecompiledheaders.h +++ b/indra/newview/llviewerprecompiledheaders.h @@ -175,7 +175,6 @@ #include "message_prehash.h" #include "net.h" //#include "network.h" -#include "partsyspacket.h" #include "patch_code.h" #include "patch_dct.h" #include "sound_ids.h"