/** * @file llfloaterproject.h * @brief LLFloaterChat class definition * * Copyright (c) 2002-2007, Linden Research, Inc. * * Second Life Viewer Source Code * The source code in this file ("Source Code") is provided by Linden Lab * to you under the terms of the GNU General Public License, version 2.0 * ("GPL"), unless you have obtained a separate licensing agreement * ("Other License"), formally executed by you and Linden Lab. Terms of * the GPL can be found in doc/GPL-license.txt in this distribution, or * online at http://secondlife.com/developers/opensource/gplv2 * * There are special exceptions to the terms and conditions of the GPL as * it is applied to this Source Code. View the full text of the exception * in the file doc/FLOSS-exception.txt in this software distribution, or * online at http://secondlife.com/developers/opensource/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, * and agree to abide by those obligations. * * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, * COMPLETENESS OR PERFORMANCE. */ #ifndef LL_LLFLOATERPROJECT_H #define LL_LLFLOATERPROJECT_H #define DG_INCLUDE_WHITEBOARD 1 #include "llfloater.h" #include "llfolderview.h" #include "llviewercommunication.h" /** * @brief Bridge for the tree nodes * This class defines the behavior of the nodes, and adds members for specific * information related to the content of the node */ class LLNetwork2080Bridge : public LLFolderViewEventListener { protected: U32 mID; LLUUID mUUID; LLString mName; S32 mSortOrder; LLInventoryItem* findItem() const; public: LLNetwork2080Bridge(const U32 id, const LLString& name) : mID(id), mName(name), mSortOrder(0) { // Generate a random ID if none is defined if ( 0 == mID ) { mUUID = getRandomID(); } else { mUUID = makeID(mID); } } /** * @brief ID of this node * This is the identifier assigned by the Netwok2080 backend * @returns ID */ S32 getID() const { return mID; } virtual ~LLNetwork2080Bridge( void ) {} virtual LLFontGL::StyleFlags getLabelStyle() const { return LLFontGL::NORMAL; } virtual LLString getLabelSuffix() const { return LLString::null; } virtual void showProperties() {} // LLFolderViewEventListener functionality virtual const LLString& getName() const { return mName; } virtual const LLString& getDisplayName() const { return mName; } virtual PermissionMask getPermissionMask() const { return PERM_NONE; } virtual const LLUUID& getUUID() const { return mUUID; } virtual U32 getCreationDate() const {return 0; } virtual LLViewerImage* getIcon() const { return NULL; } virtual void openItem(); virtual void previewItem(); virtual void selectItem() {} virtual BOOL isItemRenameable() const { return FALSE; } virtual BOOL renameItem(const LLString& new_name); virtual BOOL isItemMovable() { return FALSE; } virtual BOOL isItemRemovable() { return FALSE; } virtual BOOL removeItem(); virtual void removeBatch(LLDynamicArray& batch); virtual void move(LLFolderViewEventListener* parent_listener); virtual BOOL isItemCopyable() const { return FALSE; } virtual BOOL copyToClipboard() const { return FALSE; } virtual void cutToClipboard(); virtual BOOL isClipboardPasteable() const { return FALSE; } virtual void pasteFromClipboard(); virtual void buildContextMenu(LLMenuGL& menu, U32 flags); virtual void performAction(LLFolderView* folder, LLInventoryModel* model, LLString action); /** * @brief Whether the node is up to date * This indicates that the node (and its children) are fully loaded. * @note If FALSE, then hasChildren() determines whether the node is expandable. * If TRUE, then the presence of visible children in the tree determines whether the node * is expandable. * @returns Whether the node is up to date */ virtual BOOL isUpToDate() const { return TRUE; } /** * @brief Whether the node has children * Note that this also applies to children that aren't currently loaded. This returning TRUE * will result in an expandable node even if there's nothing in the tree under it yet. * * @note This value is only relevant if isUpToDate() is FALSE. In this case the value returned * by this function determines whether this node is expandable. * @returns Whether the node has children */ virtual BOOL hasChildren() const { return FALSE; } virtual LLInventoryType::EType getInventoryType() const { return LLInventoryType::IT_NONE; } // LLDragAndDropBridge functionality virtual BOOL startDrag(EDragAndDropType* type, LLUUID* id); virtual BOOL dragOrDrop(MASK mask, BOOL drop, EDragAndDropType cargo_type, void* cargo_data); /** * @brief Generates a random identifier and returns it * Used when we want to create a new item, but don't know what ID to give it * @returns Generated UUID */ static LLUUID getRandomID() { LLUUID ret; ret.generate(); return ret; } /** * @brief Generate an UUID based on a S32 to an UUID form * This is done to convert IDs sent by the server * This of course is affected by endianess, but it doesn't matter as this is for local use only. * @param id ID to generate UUID from * @returns Generated UUID */ static LLUUID makeID(S32 id) { LLUUID ret; ret.mData[0] = id & 0xFF; ret.mData[1] = (id >> 8) & 0xFF; ret.mData[2] = (id >> 16) & 0xFF; ret.mData[3] = (id >> 24) & 0xFF; return ret; } /** * @brief Get the URL to retrieve the children of this node * @returns URL */ virtual LLString getChildrenURL() const { return ""; } /** * @brief Get the URL to be loaded when this node is selected * @returns URL */ virtual LLString getURL() const { return ""; } /** * @brief Whether the queue buttons need to be enabled when this node is selected * @returns true if buttons need to be enabled */ virtual bool getQueueButtonsEnabled() const { return FALSE; } /** * @brief Sets the sort order * @param order Order */ void setSortOrder(S32 order) { mSortOrder = order; } /** * @brief Gets the sort order * @returns Sort order */ S32 getSortOrder() const { return mSortOrder; } }; /** * @brief Bridge for folders */ class LLNetwork2080FolderBridge : public LLNetwork2080Bridge { private: S32 mChildren; bool mLoaded; bool mLoading; public: LLNetwork2080FolderBridge(const U32 id, const LLString& name, S32 children): LLNetwork2080Bridge(id, name), mChildren(children), mLoaded(false), mLoading(false) {} virtual LLViewerImage* getIcon() const; virtual void openItem(); virtual LLString getChildrenURL() const; virtual BOOL hasChildren() const { return mChildren > 0; } virtual BOOL isUpToDate() const { return mLoaded; } bool isLoaded() const { return mLoaded; } bool isLoading() const { return mLoading && !mLoaded; } void setLoading(bool loading) { mLoading = loading; } void setLoaded(bool loaded) { mLoaded = loaded; if ( mLoaded ) mLoading = false; } }; /** * @brief Bridge for playable content */ class LLNetwork2080PlayableContentBridge : public LLNetwork2080Bridge { private: public: LLNetwork2080PlayableContentBridge(const S32 id, const LLString&name) : LLNetwork2080Bridge(id, name) {} virtual LLViewerImage* getIcon() const; virtual LLString getURL() const; virtual bool getQueueButtonsEnabled() const { return TRUE; } }; /** * @brief Bridge for pages */ class LLNetwork2080PageBridge : public LLNetwork2080Bridge { private: public: LLNetwork2080PageBridge(const S32 id, const LLString&name) : LLNetwork2080Bridge(id, name) {} virtual LLViewerImage* getIcon() const; virtual LLString getURL() const; }; /** * @brief Network2080 floater */ class LLFloaterNetwork2080 : public LLFloater { public: LLFloaterNetwork2080(); virtual ~LLFloaterNetwork2080(); static void toggle(void*); /** * @brief Hide when user closes the list. */ virtual void onClose(bool app_quitting) { setVisible(FALSE); } /** * @brief Adds an item to the tree * @param parent Parent ID for this item. 0 for root level. * @param id Idenitifer for this item * @param name Name that will appear in the list * @param has_children true if there are items under this one */ //void addCategoryChild(S32 parent, S32 id, const LLString &name, bool has_children = false); void addNode(S32 parent, LLNetwork2080Bridge *bridge); void show(); static void idle(void* user_data); /** * @brief Selection callback * @param items List of selected items * @param user_action Whether the user caused this callback to be called * @param data Pointer to floater */ static void selectionCallback(const std::deque< LLFolderViewItem * > &items, BOOL user_action, void *data); /** * @brief Idle function * This needs to be periodically called so that the tree redraws */ void doIdle (); /** * @brief Request list of root categories */ void requestRoot(); /** * @brief Request list of children of a cateogry * @param parent_id ID of the item whose children are being requested */ void requestChildren(S32 parent_id); /** * @brief Set the whiteboard text * @param text Text to set */ void setWhiteboardText(const LLString &text); /** * @brief Set the enabled/disabled status of the buttons on the whiteboard * @param status Whether the buttons are enabled */ void setQueueButtonsStatus(bool status); /** * @brief Builds a query URL * @param baseurl Base URL for the query * @param id Resource ID * @param Send avatar's key if true * @returns URL */ LLString buildURL(const LLString &baseurl, S32 id, bool send_key = false); /** * @brief Load the results for the query generated from the baseurl from the current selection * @param baseurl Base URL for the query */ void doSelectedPageCommand(const LLString &baseurl); static void onClickQueue(void *userdata); static void onClickExitQueue(void *userdata); static void onClickMyInfo(void *userdata); static void onClickNotecard(void *userdata); static void onClickQueueStatus(void *userdata); /** * @brief Comparator for tree nodes * Compares the nodes by getSortOrder() * * @param self LLInventorySort object that's being used internally by the tree. This contains the sort settings for the tree. * @param a Tree node * @param b Tree node * @returns Whether a > b */ static bool compare(LLInventorySort*self, LLFolderViewItem* a, LLFolderViewItem* b); static void viewerCommCallback(LLString& data, LLViewerCircuit& circuit, void* userdata); private: LLFolderView *mTree; LLFolderViewFolder *mRoot; LLScrollableContainerView* mScroller; LLTextEditor *mWhiteboard; LLString mPassword; // Web backend password S32 mSelectedID; // Current selection U32 mNodeCount; // For sort order }; extern LLFloaterNetwork2080* gFloaterProject; #endif