214 lines
6.4 KiB
C++
214 lines
6.4 KiB
C++
/**
|
|
* @file fslslbridge.h
|
|
* @brief FSLSLBridge header
|
|
*
|
|
* $LicenseInfo:firstyear=2011&license=fsviewerlgpl$
|
|
* Phoenix Firestorm Viewer Source Code
|
|
* Copyright (C) 2011, The Phoenix Firestorm Project, 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
|
|
*
|
|
* The Phoenix Firestorm Project, Inc., 1831 Oakwood Drive, Fairmont, Minnesota 56031-3225 USA
|
|
* http://www.firestormviewer.org
|
|
* $/LicenseInfo$
|
|
*/
|
|
|
|
#ifndef FS_LSLBRIDGE_H
|
|
#define FS_LSLBRIDGE_H
|
|
|
|
#include "llhttpclient.h"
|
|
#include "llinventorymodel.h"
|
|
#include "llviewerinventory.h"
|
|
#include "llinventoryobserver.h"
|
|
#include "lleventtimer.h"
|
|
|
|
class FSLSLBridgeRequestResponder;
|
|
|
|
//
|
|
//-TT Client LSL Bridge File
|
|
//
|
|
|
|
const std::string LIB_ROCK_NAME = "Rock - medium, round";
|
|
const std::string FS_BRIDGE_NAME = "#Firestorm LSL Bridge v";
|
|
const U8 FS_BRIDGE_POINT = 31;
|
|
const std::string FS_BRIDGE_ATTACHMENT_POINT_NAME = "Center 2";
|
|
|
|
class FSLSLBridge : public LLSingleton<FSLSLBridge>, public LLHTTPClient::Responder, public LLVOInventoryListener
|
|
{
|
|
friend class FSLSLBridgeScriptCallback;
|
|
friend class FSLSLBridgeRezCallback;
|
|
friend class FSLSLBridgeInventoryObserver;
|
|
friend class FSLSLBridgeInventoryPreCreationCleanupObserver;
|
|
friend class FSLSLBridgeCleanupTimer;
|
|
friend class FSLSLBridgeReAttachTimer;
|
|
friend class FSLSLBridgeStartCreationTimer;
|
|
|
|
public:
|
|
FSLSLBridge();
|
|
~FSLSLBridge();
|
|
|
|
bool lslToViewer(const std::string& message, const LLUUID& fromID, const LLUUID& ownerID);
|
|
bool viewerToLSL(const std::string& message, FSLSLBridgeRequestResponder* responder = NULL);
|
|
|
|
bool updateBoolSettingValue(const std::string& msgVal);
|
|
bool updateBoolSettingValue(const std::string& msgVal, bool contentVal);
|
|
void updateIntegrations();
|
|
|
|
void initBridge();
|
|
void recreateBridge();
|
|
void processAttach(LLViewerObject* object, const LLViewerJointAttachment* attachment);
|
|
void processDetach(LLViewerObject* object, const LLViewerJointAttachment* attachment);
|
|
|
|
bool getBridgeCreating() { return mBridgeCreating; };
|
|
void setBridgeCreating(bool status) { mBridgeCreating = status; };
|
|
|
|
void setBridge(LLViewerInventoryItem* item) { mpBridge = item; };
|
|
LLViewerInventoryItem* getBridge() { return mpBridge; };
|
|
bool canUseBridge();
|
|
bool isBridgeValid() const { return NULL != mpBridge; }
|
|
|
|
void checkBridgeScriptName(const std::string& fileName);
|
|
std::string currentFullName() { return mCurrentFullName; }
|
|
|
|
LLUUID getBridgeFolder() { return mBridgeFolderID; }
|
|
LLUUID getAttachedID() { return mBridgeUUID; }
|
|
|
|
bool canDetach(const LLUUID& item_id);
|
|
|
|
// from LLVOInventoryListener
|
|
virtual void inventoryChanged(LLViewerObject* object,
|
|
LLInventoryObject::object_list_t* inventory,
|
|
S32 serial_num,
|
|
void* user_data);
|
|
|
|
private:
|
|
std::string mCurrentURL;
|
|
bool mBridgeCreating;
|
|
bool mAllowDetach;
|
|
bool mFinishCreation;
|
|
|
|
LLViewerInventoryItem* mpBridge;
|
|
std::string mCurrentFullName;
|
|
LLUUID mScriptItemID; //internal script ID
|
|
LLUUID mBridgeFolderID;
|
|
LLUUID mBridgeContainerFolderID;
|
|
LLUUID mBridgeUUID;
|
|
|
|
bool mIsFirstCallDone; //initialization conversation
|
|
|
|
uuid_vec_t mAllowedDetachables;
|
|
|
|
protected:
|
|
LLViewerInventoryItem* findInvObject(const std::string& obj_name, const LLUUID& catID, LLAssetType::EType type);
|
|
LLUUID findFSCategory();
|
|
LLUUID findFSBridgeContainerCategory();
|
|
|
|
bool isItemAttached(const LLUUID& iID);
|
|
void createNewBridge();
|
|
void create_script_inner(LLViewerObject* object);
|
|
bool isOldBridgeVersion(LLInventoryItem* item);
|
|
void cleanUpBridgeFolder();
|
|
void cleanUpBridgeFolder(const std::string& nameToCleanUp);
|
|
void setupBridgePrim(LLViewerObject* object);
|
|
void cleanUpBridge();
|
|
void startCreation();
|
|
void finishBridge();
|
|
void cleanUpOldVersions();
|
|
void detachOtherBridges();
|
|
void configureBridgePrim(LLViewerObject* object);
|
|
void cleanUpPreCreation();
|
|
void finishCleanUpPreCreation();
|
|
};
|
|
|
|
|
|
class FSLSLBridgeRezCallback : public LLInventoryCallback
|
|
{
|
|
public:
|
|
FSLSLBridgeRezCallback();
|
|
void fire(const LLUUID& inv_item);
|
|
|
|
protected:
|
|
~FSLSLBridgeRezCallback();
|
|
};
|
|
|
|
class FSLSLBridgeScriptCallback : public LLInventoryCallback
|
|
{
|
|
public:
|
|
FSLSLBridgeScriptCallback();
|
|
void fire(const LLUUID& inv_item);
|
|
std::string prepUploadFile();
|
|
|
|
protected:
|
|
~FSLSLBridgeScriptCallback();
|
|
};
|
|
|
|
class FSLSLBridgeInventoryObserver : public LLInventoryFetchDescendentsObserver
|
|
{
|
|
public:
|
|
FSLSLBridgeInventoryObserver(const LLUUID& cat_id = LLUUID::null):LLInventoryFetchDescendentsObserver(cat_id) {}
|
|
FSLSLBridgeInventoryObserver(const uuid_vec_t& cat_ids):LLInventoryFetchDescendentsObserver(cat_ids) {}
|
|
/*virtual*/ void done() { gInventory.removeObserver(this); FSLSLBridge::instance().startCreation(); delete this; }
|
|
|
|
protected:
|
|
~FSLSLBridgeInventoryObserver() {}
|
|
|
|
};
|
|
|
|
class FSLSLBridgeInventoryPreCreationCleanupObserver : public LLInventoryFetchDescendentsObserver
|
|
{
|
|
public:
|
|
FSLSLBridgeInventoryPreCreationCleanupObserver(const LLUUID& cat_id = LLUUID::null):LLInventoryFetchDescendentsObserver(cat_id) {}
|
|
/*virtual*/ void done() { gInventory.removeObserver(this); FSLSLBridge::instance().cleanUpPreCreation(); delete this; }
|
|
|
|
protected:
|
|
~FSLSLBridgeInventoryPreCreationCleanupObserver() {}
|
|
|
|
};
|
|
|
|
|
|
class FSLSLBridgeCleanupTimer : public LLEventTimer
|
|
{
|
|
public:
|
|
FSLSLBridgeCleanupTimer(F32 period) : LLEventTimer(period) {}
|
|
BOOL tick();
|
|
void startTimer() { mEventTimer.start(); }
|
|
void stopTimer() { mEventTimer.stop(); }
|
|
};
|
|
|
|
class FSLSLBridgeReAttachTimer : public LLEventTimer
|
|
{
|
|
public:
|
|
FSLSLBridgeReAttachTimer(const LLUUID& bridge_uuid) :
|
|
LLEventTimer(5.f),
|
|
mBridgeUUID(bridge_uuid)
|
|
{}
|
|
BOOL tick();
|
|
|
|
protected:
|
|
LLUUID mBridgeUUID;
|
|
};
|
|
|
|
class FSLSLBridgeStartCreationTimer : public LLEventTimer
|
|
{
|
|
public:
|
|
FSLSLBridgeStartCreationTimer() : LLEventTimer(5.f) {}
|
|
BOOL tick()
|
|
{
|
|
FSLSLBridge::instance().finishCleanUpPreCreation();
|
|
return TRUE;
|
|
}
|
|
};
|
|
#endif // FS_LSLBRIDGE_H
|