/* * MCUPnP.h * * mcupnp library Interface. * Manage UPnP MediaSerer:1 devices. * * Created by Bruno Keymolen on 1/18/08. * * (C) Copyright, 2008 Bruno Keymolen. * * * Build on top of pupnp (http://pupnp.sourceforge.net/) * * This file is part of the mcupnp library. * * The mcupnp library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * The mcupnp 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with the mcupnp library. If not, see . * * Contact: bruno.keymolen@gmail.com */ #ifndef mcupnp_ #define mcupnp_ /* Export these Classes */ #pragma GCC visibility push(default) #include using namespace std; #define DevicetypeMediaServer "urn:schemas-upnp-org:device:MediaServer:1" /** * UPnP Devices, Containers and Items are organized in a "MCUPnPNode" tree. */ class MCUPnPNode{ public: /** * Get the parent node * Return : MCUPnPNode* ; a pointer to the parent node * NULL if there is no parent (the root node) */ virtual MCUPnPNode* getParent() = 0; /** * Get the number of childs for this node * Return : int ; the number of childs * 0 if the node has no childs */ virtual int getChildsCount() = 0; /** * Get an array containing the child nodes * Parameters : MCUPnPNode* ; a return array of child nodes * Return : int ; the number of childs */ virtual int getChilds(MCUPnPNode*** childs) = 0; /** * Get the name of the node * Return : const char* ; an NULL terminating string containing the node name */ virtual const char* getName() = 0; /** * Get the url of the node (if any) * Return : const char* ; an NULL terminating string containing the node url */ virtual const char* getUrl() = 0; /** * Check if this node is a container * Return : true if it is a container node * false if not */ virtual bool isContainer() = 0; /** * Get the unique node Key * Node key's are unique and are persistent between tree updates */ virtual unsigned char* getKey(int* len) = 0; /** * To be used with the observer methods * When a callback (ex: "MCUPnPTreeUpdate") is made, the Node can be flagged as deleted * the actual deletion from memory will happen after the callback returns. */ virtual bool isDeleted() = 0; /** * To be used with the observer methods * When a callback (ex: "MCUPnPTreeUpdate") is made, the Node will be flagged as new if it is added by the last update process * the flag will be resetted after the callback returns */ virtual bool isNew() = 0; }; /** * Callbacks signaling node tree (UPnP) updates */ class MCUPnPObserver{ public: /** * Fires when a change in the UPnP tree is made * MCUPnPNode* is a node tree containing the current UPnP state. * This tree stay's in memory until (and after) the next MCUPnPTreeUpdate event is processed. */ virtual void MCUPnPTreeUpdate(MCUPnPNode* root) = 0; }; /** * MCUPnP Main Interface */ class MCUPnP{ public: /** * Get an instance of the MCUPnP class (Singleton Implementation) */ static MCUPnP* Instance(); /** * Start the UPnP system */ virtual int start() = 0; virtual int stop() = 0; virtual void addObserver(MCUPnPObserver* obs) = 0; virtual void removeObserver(MCUPnPObserver* obs) = 0; virtual int searchNow() = 0; virtual MCUPnPNode* getFileTree() = 0; }; #pragma GCC visibility pop #endif //mcupnp_