Changeset 2942

Show
Ignore:
Timestamp:
04/26/06 21:01:22 (3 years ago)
Author:
madcat
Message:

Experimental support for passing Object's through cgcomm.
Experimental support for server list in user interface.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • hydranode/hnbase/fwd.h

    r2637 r2942  
    3535class UDPSocket; 
    3636class IPV4Address; 
     37class Object; 
    3738template<typename Impl, typename _ImplPtr> class Scheduler; 
    3839template<typename T> class Range; 
  • hydranode/hnbase/object.cpp

    r2652 r2942  
    8787        return m_name; 
    8888} 
    89 /*virtual*/ uint8_t Object::getDataCount() const { 
    90         return 0; 
    91 } 
    92 /*virtual*/ std::string Object::getData(uint8_t) const { 
     89/*virtual*/ uint32_t Object::getDataCount() const { 
     90        return 0; 
     91} 
     92/*virtual*/ std::string Object::getData(uint32_t) const { 
    9393        logTrace( 
    9494                TRACE_OBJECT, 
     
    9797        return std::string(); 
    9898} 
    99 /*virtual*/ std::string Object::getFieldName(uint8_t) const { 
     99/*virtual*/ std::string Object::getFieldName(uint32_t) const { 
    100100        logTrace( 
    101101                TRACE_OBJECT, 
     
    105105        return std::string(); 
    106106} 
    107 DataType Object::getFieldType(uint8_t) const { return ODT_UNKNOWN; } 
     107DataType Object::getFieldType(uint32_t) const { return ODT_UNKNOWN; } 
    108108void Object::getValueChoices(std::vector<std::string>*) const {} 
    109 /*virtual*/ uint8_t Object::getOperCount() const { 
    110         return 0; 
    111 } 
    112 /*virtual*/ Object::Operation Object::getOper(uint8_t) const { 
     109/*virtual*/ uint32_t Object::getOperCount() const { 
     110        return 0; 
     111} 
     112/*virtual*/ Object::Operation Object::getOper(uint32_t) const { 
    113113        logTrace(TRACE_OBJECT, 
    114114                boost::format("%s: Object does not have operations.") % m_name 
     
    126126        ); 
    127127} 
    128 /*virtual*/ void Object::setData(uint8_t, const std::string&) { 
     128/*virtual*/ void Object::setData(uint32_t, const std::string&) { 
    129129        logTrace( 
    130130                TRACE_OBJECT, 
     
    218218                m_children = 0; 
    219219        } 
     220        notify(child->m_id, OBJ_REMOVED); 
    220221        // Virtual function call 
    221222        onChildRemoved(child->m_id); 
  • hydranode/hnbase/object.h

    r2652 r2942  
    128128        OBJ_MODIFIED = 0x01, //!< This object's data has been modified 
    129129        OBJ_ADDED,           //!< An object has been added to this container 
    130         OBJ_REMOVED,         //!< An object has been removed from thsi container 
     130        OBJ_REMOVED,         //!< An object has been removed from this container 
    131131        OBJ_DESTROY          //!< This object has been destroyed 
    132132}; 
     
    180180        //@{ 
    181181        //! Retrieve the number of data fields within this object 
    182         virtual uint8_t getDataCount() const; 
     182        virtual uint32_t getDataCount() const; 
    183183        //! Retrieve the data at specific field 
    184         virtual std::string getData(uint8_t num) const; 
     184        virtual std::string getData(uint32_t num) const; 
    185185        //! Retrieve the data field name 
    186         virtual std::string getFieldName(uint8_t num) const; 
     186        virtual std::string getFieldName(uint32_t num) const; 
    187187        //! Retrieve the data type of the field 
    188         virtual DataType getFieldType(uint8_t num) const; 
     188        virtual DataType getFieldType(uint32_t num) const; 
    189189        //! Fill the passed vector with possible values for this field. 
    190190        //! Generally used in conjuction with FieldType OFT_CHOICE 
    191191        virtual void getValueChoices(std::vector<std::string> *cont) const; 
    192192        //! Retrieve the number of operations for this object 
    193         virtual uint8_t getOperCount() const; 
     193        virtual uint32_t getOperCount() const; 
    194194        //! Retrieve a specific operation description 
    195         virtual Operation getOper(uint8_t n) const; 
     195        virtual Operation getOper(uint32_t n) const; 
    196196        //! Perform an operation with this object 
    197197        virtual void doOper(const Operation &oper); 
    198198        //! Modify the data at specific field 
    199         virtual void setData(uint8_t num, const std::string &data); 
     199        virtual void setData(uint32_t num, const std::string &data); 
    200200        //@} 
    201201 
  • hydranode/hncgcomm/cgcomm.cpp

    r2938 r2942  
    903903} 
    904904 
     905Object::Object(Modules *parent) : m_parentList(parent), m_id() {} 
     906 
     907void Object::doOper( 
     908        const std::string &opName, 
     909        const std::map<std::string, std::string> &args 
     910) { 
     911        m_parentList->doObjectOper(shared_from_this(), opName, args); 
     912} 
     913 
     914void Object::setData(uint8_t num, const std::string &newValue) { 
     915        m_parentList->setObjectData(shared_from_this(), num, newValue); 
     916} 
     917 
     918void Object::update(ObjectPtr obj) { 
     919        m_data     = obj->m_data; 
     920        m_childIds = obj->m_childIds; 
     921        m_name     = obj->m_name; 
     922        m_id       = obj->m_id; 
     923} 
     924 
     925void Object::findChildren() { 
     926        m_children.clear(); 
     927        std::set<uint32_t>::iterator i = m_childIds.begin(); 
     928        while (i != m_childIds.end()) { 
     929                ObjectPtr tmp = m_parentList->findObject(*i); 
     930                if (tmp) { 
     931                        m_children[*i] = tmp; 
     932                        tmp->m_parent = shared_from_this(); 
     933                        tmp->findChildren(); 
     934                } 
     935                ++i; 
     936        } 
     937} 
     938 
     939void Object::destroy() { 
     940        for (CIter i = begin(); i != end(); ++i) { 
     941                i->second->destroy(); 
     942                m_children.erase(i->second->getId()); 
     943                m_childIds.erase(i->second->getId()); 
     944        } 
     945        onDestroyed(shared_from_this()); 
     946} 
     947 
    905948Modules::Modules(Main *parent) : SubSysBase(parent, SUB_MODULES) {} 
    906949 
     
    941984                        break; 
    942985                } 
    943         } 
     986                case OC_NOTFOUND: { 
     987                        uint32_t id = Utils::getVal<uint32_t>(i); 
     988                        logDebug(boost::format("Object not found: %d") % id); 
     989                        break; 
     990                } 
     991                case OC_OBJLIST: { 
     992                        uint32_t cnt = Utils::getVal<uint32_t>(i); 
     993                        ObjectPtr lastObject = ObjectPtr(); 
     994                        while (i && cnt--) { 
     995                                ObjectPtr obj = readObject(i); 
     996                                ObjectPtr found = findObject(obj->getId()); 
     997                                if (found) { 
     998                                        found->update(obj); 
     999                                        obj = found; 
     1000                                } else { 
     1001                                        m_objects[obj->getId()] = obj; 
     1002                                } 
     1003                                lastObject = obj; 
     1004                        } 
     1005                        lastObject->findChildren(); 
     1006                        receivedObject(lastObject); 
     1007                        break; 
     1008                } 
     1009                case OC_CADDED: { 
     1010                        uint32_t id = Utils::getVal<uint32_t>(i); 
     1011                        ObjectPtr child = readObject(i); 
     1012                        ObjectPtr found = findObject(child->getId()); 
     1013                        if (found) { 
     1014                                found->update(child); 
     1015                                child = found; 
     1016                        } else { 
     1017                                m_objects[child->getId()] = child; 
     1018                        } 
     1019                        ObjectPtr parent = findObject(id); 
     1020                        if (parent) { 
     1021                                parent->m_childIds.insert(id); 
     1022                                parent->m_children[id] = child; 
     1023                                parent->childAdded(parent, child); 
     1024                                child->m_parent = parent; 
     1025                        } 
     1026                        break; 
     1027                } 
     1028                case OC_CREMOVED: { 
     1029                        uint32_t id = Utils::getVal<uint32_t>(i); 
     1030                        uint32_t cid = Utils::getVal<uint32_t>(i); 
     1031                        ObjectPtr parent = findObject(id); 
     1032                        ObjectPtr child = findObject(cid); 
     1033                        if (parent && child) { 
     1034                                parent->m_childIds.erase(cid); 
     1035                                parent->m_children.erase(cid); 
     1036                                parent->childRemoved(parent, child); 
     1037                        } 
     1038                        break; 
     1039                } 
     1040                case OC_DESTROY: { 
     1041                        uint32_t id = Utils::getVal<uint32_t>(i); 
     1042                        ObjectPtr obj = findObject(id); 
     1043                        if (obj) { 
     1044                                obj->destroy(); 
     1045                                m_objects.erase(id); 
     1046                        } 
     1047                        break; 
     1048                } 
     1049        } 
     1050
     1051 
     1052ObjectPtr Modules::readObject(std::istream &i) { 
     1053        if (Utils::getVal<uint8_t>(i) != OC_OBJECT) { 
     1054                throw std::runtime_error("Invalid object."); 
     1055        } 
     1056 
     1057        ObjectPtr obj(new Object(this)); 
     1058        obj->m_id = Utils::getVal<uint32_t>(i); 
     1059        uint16_t nLen = Utils::getVal<uint16_t>(i); 
     1060        obj->m_name = Utils::getVal<std::string>(i, nLen); 
     1061        uint32_t dataCount = Utils::getVal<uint32_t>(i); 
     1062        while (i && dataCount--) { 
     1063                uint16_t dLen = Utils::getVal<uint16_t>(i); 
     1064                std::string data = Utils::getVal<std::string>(i, dLen); 
     1065                obj->m_data.push_back(data); 
     1066        } 
     1067        uint32_t childCount = Utils::getVal<uint32_t>(i); 
     1068        while (i && childCount--) { 
     1069                obj->m_childIds.insert(Utils::getVal<uint32_t>(i)); 
     1070        } 
     1071 
     1072        return obj; 
    9441073} 
    9451074 
     
    9881117void Modules::getList() { 
    9891118        std::ostringstream tmp; 
     1119        Utils::putVal<uint8_t>(tmp, OC_LIST); 
     1120        sendPacket(tmp.str()); 
     1121} 
     1122 
     1123void Modules::monitor(uint32_t interval) { 
     1124        std::ostringstream tmp; 
     1125        Utils::putVal<uint8_t>(tmp, OC_MONITOR); 
     1126        Utils::putVal<uint32_t>(tmp, 0); 
     1127        Utils::putVal<uint32_t>(tmp, interval); 
     1128        sendPacket(tmp.str()); 
     1129} 
     1130 
     1131void Modules::getObject(ModulePtr mod, const std::string &name, bool recurse) { 
     1132        std::ostringstream tmp; 
    9901133        Utils::putVal<uint8_t>(tmp, OC_GET); 
    991         sendPacket(tmp.str()); 
    992 
    993  
    994 void Modules::monitor(uint32_t interval) { 
     1134        Utils::putVal<uint32_t>(tmp, mod->getId()); 
     1135        Utils::putVal<uint16_t>(tmp, name.size()); 
     1136        Utils::putVal(tmp, name, name.size()); 
     1137        Utils::putVal<uint8_t>(tmp, recurse); 
     1138        sendPacket(tmp.str()); 
     1139
     1140 
     1141void Modules::monitorObject(ObjectPtr obj, uint32_t interval) { 
    9951142        std::ostringstream tmp; 
    9961143        Utils::putVal<uint8_t>(tmp, OC_MONITOR); 
     1144        Utils::putVal<uint32_t>(tmp, obj->getId()); 
    9971145        Utils::putVal<uint32_t>(tmp, interval); 
    9981146        sendPacket(tmp.str()); 
    9991147} 
    10001148 
     1149void Modules::doObjectOper( 
     1150        ObjectPtr obj, const std::string &opName, 
     1151        const std::map<std::string, std::string> &args 
     1152) { 
     1153        std::ostringstream tmp; 
     1154        Utils::putVal<uint8_t>(tmp, OC_DOOPER); 
     1155        Utils::putVal<uint32_t>(tmp, obj->getId()); 
     1156        Utils::putVal<uint16_t>(tmp, opName.size()); 
     1157        Utils::putVal(tmp, opName, opName.size()); 
     1158        Utils::putVal<uint16_t>(tmp, args.size()); 
     1159        std::map<std::string, std::string>::const_iterator i(args.begin()); 
     1160        while (i != args.end()) { 
     1161                Utils::putVal<uint16_t>(tmp, i->first.size()); 
     1162                Utils::putVal(tmp, i->first, i->first.size()); 
     1163                Utils::putVal<uint16_t>(tmp, i->second.size()); 
     1164                Utils::putVal(tmp, i->second, i->second.size()); 
     1165                ++i; 
     1166        } 
     1167        sendPacket(tmp.str()); 
     1168} 
     1169 
     1170void Modules::setObjectData(ObjectPtr obj, uint8_t dNum, const std::string &v) { 
     1171        std::ostringstream tmp; 
     1172        Utils::putVal<uint8_t>(tmp, OC_SET); 
     1173        Utils::putVal<uint32_t>(tmp, obj->getId()); 
     1174        Utils::putVal<uint8_t>(tmp, dNum); 
     1175        Utils::putVal<uint16_t>(tmp, v.size()); 
     1176        Utils::putVal(tmp, v, v.size()); 
     1177        sendPacket(tmp.str()); 
     1178} 
     1179 
    10011180} // end namespace Engine 
  • hydranode/hncgcomm/cgcomm.h

    r2938 r2942  
    488488        }; 
    489489 
     490        class DLLEXPORT Object : public boost::enable_shared_from_this<Object> { 
     491        public: 
     492                typedef std::vector<std::string>::const_iterator DIter; 
     493                typedef std::map<uint32_t, ObjectPtr>::const_iterator CIter; 
     494 
     495                std::string getName()   const { return m_name;   } 
     496                uint32_t    getId()     const { return m_id;     } 
     497                ObjectPtr   getParent() const { return m_parent; } 
     498 
     499                size_t      dataCount()       const { return m_data.size();  } 
     500                std::string getData(size_t n) const { return m_data.at(n);   } 
     501                DIter       dbegin()          const { return m_data.begin(); } 
     502                DIter       dend()            const { return m_data.end();   } 
     503 
     504                size_t childCount() const { return m_children.size();  } 
     505                CIter  begin()      const { return m_children.begin(); } 
     506                CIter  end()        const { return m_children.end();   } 
     507 
     508                void doOper( 
     509                        const std::string &opName, 
     510                        const std::map<std::string, std::string> &args 
     511                ); 
     512                void setData(uint8_t num, const std::string &newValue); 
     513 
     514                boost::signal<void (ObjectPtr, ObjectPtr)> childAdded; 
     515                boost::signal<void (ObjectPtr, ObjectPtr)> childRemoved; 
     516                boost::signal<void (ObjectPtr)> onDestroyed; 
     517        private: 
     518                friend class Modules; 
     519 
     520                ObjectPtr m_parent; 
     521                Modules *m_parentList; 
     522                std::vector<std::string> m_data; 
     523                std::map<uint32_t, ObjectPtr> m_children; 
     524                std::set<uint32_t> m_childIds; 
     525                std::string m_name; 
     526                uint32_t m_id; 
     527 
     528                void update(ObjectPtr obj); 
     529                void findChildren(); 
     530                void destroy(); 
     531 
     532                Object(Modules *parent); 
     533                Object(const Object&); 
     534                Object& operator=(const Object&); 
     535        }; 
     536 
    490537        class DLLEXPORT Modules : public SubSysBase { 
    491538        public: 
    492539                Modules(Main *parent); 
     540 
     541                // modules specific 
    493542                void getList(); 
    494543                void monitor(uint32_t interval); 
     
    501550                typedef std::map<uint32_t, ModulePtr>::const_iterator CIter; 
    502551 
    503                 CIter begin() const { return m_list.begin(); } 
    504                 CIter end() const { return m_list.end(); } 
     552                size_t count() const { return m_list.size();  } 
     553                CIter  begin() const { return m_list.begin(); } 
     554                CIter  end()   const { return m_list.end();   } 
     555 
     556                // Object tree specific 
     557 
     558                /** 
     559                 * Request an object to be sent 
     560                 * 
     561                 * @param mod        Module for which the object is child of 
     562                 * @param name       Name of the object to be sent 
     563                 * @param recurse    Whether to send the entire subtree 
     564                 */ 
     565                void getObject( 
     566                        ModulePtr mod, const std::string &name,  
     567                        bool recurse = true 
     568                ); 
     569                /** 
     570                 * Requests monitoring to be set up for the object 
     571                 * 
     572                 * @param obj       Object to be monitored 
     573                 * @param interval  Minimum update interval (ms) 
     574                 */ 
     575                void monitorObject(ObjectPtr obj, uint32_t interval); 
     576 
     577                void doObjectOper( 
     578                        ObjectPtr obj, const std::string &opName, 
     579                        const std::map<std::string, std::string> &args 
     580                ); 
     581                void setObjectData( 
     582                        ObjectPtr obj, uint8_t dNum, const std::string &newValue 
     583                ); 
     584 
     585                typedef std::map<uint32_t, ObjectPtr>::iterator OIter; 
     586                typedef std::map<uint32_t, ObjectPtr>::const_iterator OCIter; 
     587 
     588                ObjectPtr findObject(uint32_t id) const { 
     589                        OCIter i = m_objects.find(id); 
     590                        if (i != m_objects.end()) { 
     591                                return i->second; 
     592                        } else { 
     593                                return ObjectPtr(); 
     594                        } 
     595                } 
     596 
     597                /** 
     598                 * Emitted when an object is received from core. Note that when 
     599                 * receiving multiple objects in a tree, this is emitted only 
     600                 * for the top-most tree object, instead of for each subobject 
     601                 * of the tree. 
     602                 */ 
     603                boost::signal<void (ObjectPtr)> receivedObject; 
     604 
     605                /** 
     606                 * Signaled when an object has been updated. This is emitted 
     607                 * for each object that was updated. 
     608                 */ 
     609                boost::signal<void (ObjectPtr)> updatedObject; 
    505610        protected: 
    506611                virtual void handle(std::istream &i); 
     
    508613                std::map<uint32_t, ModulePtr> m_list; 
    509614 
     615                std::map<uint32_t, ObjectPtr> m_objects; 
     616 
    510617                ModulePtr readModule(std::istream &i); 
     618                ObjectPtr readObject(std::istream &i); 
    511619        }; 
    512620 
  • hydranode/hncgcomm/fwd.h

    r2895 r2942  
    3838        class Module; 
    3939        class Modules; 
     40        class Object; 
    4041 
    4142        typedef boost::shared_ptr<SearchResult> SearchResultPtr; 
     
    4344        typedef boost::shared_ptr<SharedFile>   SharedFilePtr; 
    4445        typedef boost::shared_ptr<Module>       ModulePtr; 
     46        typedef boost::shared_ptr<Object>       ObjectPtr; 
    4547 
    4648        enum FileType { 
  • hydranode/hncore/cgcomm/opcodes.h

    r2911 r2942  
    6262        OC_LINKS    = 0x18,  //!< Get/Send human-readable links (http, ed2k etc) 
    6363        OC_GETLINK  = 0x19,  //!< Start a download from a link 
    64         OC_GETFILE  = 0x1a   //!< Start a download from file contents 
     64        OC_GETFILE  = 0x1a,  //!< Start a download from file contents 
     65        OC_DOOPER   = 0x1b,  //!< Do an operation (on an object) 
     66        OC_NOTFOUND = 0x1c,  //!< The refered object was not found 
     67        OC_CADDED   = 0x1d,  //!< Child was added to an object 
     68        OC_CREMOVED = 0x1e,  //!< Child was removed from an object 
     69        OC_DESTROY  = 0x1f   //!< Object was destroyed 
     70 
    6571}; 
    6672 
     
    167173 
    168174enum { 
    169         OP_SHAREDFILE = 0x90 
     175        OP_SHAREDFILE = 0x90, 
     176        OC_OBJECT     = 0x91, 
     177        OC_OBJLIST    = 0x92 
    170178}; 
    171179 
  • hydranode/hncore/cgcomm/sub_modules.cpp

    r2862 r2942  
    4040        uint8_t oc = Utils::getVal<uint8_t>(i); 
    4141        switch (oc) { 
    42                 case OC_LIST: sendList(); break; 
    43                 case OC_MONITOR: monitor(i); break; 
     42                case OC_LIST:      sendList();   break; 
     43                case OC_MONITOR:   monitor(i);   break; 
     44                case OC_GET:       getObject(i); break; 
     45                case OC_SET:       setData(i);   break; 
     46                case OC_DOOPER:    doOper(i);    break; 
    4447                default: break; 
    4548        } 
     
    7275 
    7376void Modules::monitor(std::istream &i) { 
     77        uint32_t id = Utils::getVal<uint32_t>(i); 
    7478        uint32_t timer = Utils::getVal<uint32_t>(i); 
    75         if (!m_monitorTimer && timer) { 
     79        if (!m_monitorTimer && timer && id) { 
    7680                Utils::timedCallback( 
    7781                        boost::bind(&Modules::sendList, this, OC_UPDATE), timer 
    7882                ); 
     83        } else if (id) { 
     84                Object *obj = Object::findObject(id); 
     85                if (!obj) { 
     86                        sendNotFound(id); 
     87                } else { 
     88//                      obj->addHandler( 
     89//                              boost::bind(&Modules::objUpdated, this, _1) 
     90//                      ); 
     91                } 
    7992        } 
    8093        m_monitorTimer = timer; 
     
    120133} 
    121134 
    122  
    123 
    124 
     135void Modules::getObject(std::istream &i) { 
     136        uint32_t    id      = Utils::getVal<uint32_t>(i); 
     137        uint16_t    len     = Utils::getVal<uint16_t>(i); 
     138        std::string name    = Utils::getVal<std::string>(i, len); 
     139        bool        recurse = Utils::getVal<uint8_t>(i); 
     140 
     141        logDebug("Received request for object " + name); 
     142        Object *obj = Object::findObject(id); 
     143        if (!obj) { 
     144                sendNotFound(id); 
     145        } else { 
     146                for (Object::CIter i = obj->begin(); i != obj->end(); ++i) { 
     147                        if (i->second->getName() == name) { 
     148                                std::ostringstream tmp; 
     149                                uint32_t cnt = sendObject( 
     150                                        i->second, recurse, tmp 
     151                                ); 
     152                                std::ostringstream final; 
     153                                Utils::putVal<uint8_t>(final, OC_OBJLIST); 
     154                                Utils::putVal<uint32_t>(final, cnt); 
     155                                Utils::putVal<std::string>( 
     156                                        final, tmp.str(), tmp.str().size() 
     157                                ); 
     158                                sendPacket(final.str()); 
     159                                break; 
     160                        } 
     161                } 
     162        } 
     163
     164 
     165uint32_t Modules::sendObject(Object *obj, bool recurse, std::ostream &tmp) { 
     166        uint32_t cnt = 0; 
     167        if (recurse) { 
     168                for (Object::CIter i = obj->begin(); i != obj->end(); ++i) { 
     169                        cnt += sendObject(i->second, recurse, tmp); 
     170                } 
     171        } 
     172        Utils::putVal<uint8_t>(tmp, OC_OBJECT); 
     173        Utils::putVal<uint32_t>(tmp, obj->getId()); 
     174        Utils::putVal<uint16_t>(tmp, obj->getName().size()); 
     175        Utils::putVal<std::string>(tmp, obj->getName(), obj->getName().size()); 
     176        Utils::putVal<uint32_t>(tmp, obj->getDataCount()); 
     177        for (uint8_t i = 0; i < obj->getDataCount(); ++i) { 
     178                std::string data(obj->getData(i)); 
     179                Utils::putVal<uint16_t>(tmp, data.size()); 
     180                Utils::putVal<std::string>(tmp, data, data.size()); 
     181        } 
     182        Utils::putVal<uint32_t>(tmp, obj->getChildCount()); 
     183        for (Object::CIter i = obj->begin(); i != obj->end(); ++i) { 
     184                Utils::putVal<uint32_t>(tmp, i->second->getId()); 
     185        } 
     186 
     187        return ++cnt; 
     188
     189 
     190void Modules::doOper(std::istream &i) { 
     191        uint32_t id = Utils::getVal<uint32_t>(i); 
     192        Object *obj = Object::findObject(id); 
     193        if (!obj) { 
     194                sendNotFound(id); 
     195        } else { 
     196                uint16_t len = Utils::getVal<uint16_t>(i); 
     197                std::string opName = Utils::getVal<std::string>(i, len); 
     198                uint16_t argCount = Utils::getVal<uint16_t>(i); 
     199                std::vector<Object::Operation::Argument> args; 
     200                while (i && argCount--) { 
     201                        uint16_t nLen = Utils::getVal<uint16_t>(i); 
     202                        std::string argName =Utils::getVal<std::string>(i,nLen); 
     203                        uint16_t vLen = Utils::getVal<uint16_t>(i); 
     204                        std::string argVal =Utils::getVal<std::string>(i, vLen); 
     205                        args.push_back( 
     206                                Object::Operation::Argument(argName, argVal) 
     207                        ); 
     208                } 
     209                Object::Operation op(opName, args); 
     210                logDebug( 
     211                        "Performing operation " + opName  
     212                        + " on " + obj->getName() 
     213                ); 
     214                obj->doOper(op); 
     215        } 
     216
     217 
     218void Modules::setData(std::istream &i) { 
     219        uint32_t id = Utils::getVal<uint32_t>(i); 
     220        Object *obj = Object::findObject(id); 
     221        if (!obj) { 
     222                sendNotFound(id); 
     223        } else { 
     224                uint8_t dNum = Utils::getVal<uint8_t>(i); 
     225                uint16_t vLen = Utils::getVal<uint16_t>(i); 
     226                std::string value = Utils::getVal<std::string>(i, vLen); 
     227                obj->setData(dNum, value); 
     228        } 
     229
     230 
     231void Modules::sendNotFound(uint32_t id) { 
     232        logDebug(boost::format("Object id %d was not found.") % id); 
     233 
     234        std::ostringstream tmp; 
     235        Utils::putVal<uint8_t>(tmp, OC_NOTFOUND); 
     236        Utils::putVal<uint32_t>(tmp, id); 
     237        sendPacket(tmp.str()); 
     238
     239 
     240void Modules::objUpdated(Object *obj) { 
     241        m_dirty.insert(obj); 
     242
     243 
     244} // end namespace Subsystem 
     245} // end namespace CGComm 
  • hydranode/hncore/cgcomm/sub_modules.h

    r2862 r2942  
    3333        virtual void handle(std::istream &i); 
    3434private: 
     35        void getObject(std::istream &i); 
     36        void monitor(std::istream &i); 
     37        void doOper(std::istream &i); 
     38        void setData(std::istream &i); 
     39 
     40        uint32_t sendObject(Object *obj, bool recurse, std::ostream &tmp); 
     41        void sendNotFound(uint32_t id); 
     42        void objUpdated(Object *obj); 
     43        std::set<Object*> m_dirty; 
     44 
    3545        void sendList(uint8_t oc = OC_LIST); 
    36         void monitor(std::istream &i); 
    3746        void onLoaded(ModuleBase *mod); 
    3847        void onUnloaded(ModuleBase *mod); 
  • hydranode/hncore/ed2k/ed2k.cpp

    r2875 r2942  
    402402} 
    403403 
    404 uint8_t ED2K::getOperCount() const { 
     404uint32_t ED2K::getOperCount() const { 
    405405        return ServerList::instance().getOperCount(); 
    406406} 
    407 Object::Operation ED2K::getOper(uint8_t n) const { 
     407Object::Operation ED2K::getOper(uint32_t n) const { 
    408408        return ServerList::instance().getOper(n); 
    409409} 
  • hydranode/hncore/ed2k/ed2k.h

    r2875 r2942  
    109109         */ 
    110110        //@{ 
    111         virtual uint8_t getOperCount() const; 
    112         virtual Object::Operation getOper(uint8_t n) const; 
     111        virtual uint32_t getOperCount() const; 
     112        virtual Object::Operation getOper(uint32_t n) const; 
    113113        virtual void doOper(const Object::Operation &op); 
    114114        //@} 
  • hydranode/hncore/ed2k/server.cpp

    r2757 r2942  
    245245MSVC_ONLY(;) 
    246246 
     247uint32_t Server::getDataCount() const { return 17; } 
     248 
     249std::string Server::getData(uint32_t num) const { 
     250        using boost::lexical_cast; 
     251        switch (num) { 
     252                case  0: return m_name; 
     253                case  1: return m_addr.getStr(); 
     254                case  2: return m_desc; 
     255                case  3: return boost::lexical_cast<std::string>(m_users); 
     256                case  4: return boost::lexical_cast<std::string>(m_files); 
     257                case  5: return m_dynip; 
     258                case  6: return m_version; 
     259                case  7: return boost::lexical_cast<std::string>(m_failedCount); 
     260                case  8: return boost::lexical_cast<std::string>(m_preference); 
     261                case  9: return boost::lexical_cast<std::string>(m_ping); 
     262                case 10: return boost::lexical_cast<std::string>(m_lastPing); 
     263                case 11: return boost::lexical_cast<std::string>(m_maxUsers); 
     264                case 12: return boost::lexical_cast<std::string>(m_softLimit); 
     265                case 13: return boost::lexical_cast<std::string>(m_hardLimit); 
     266                case 14: return boost::lexical_cast<std::string>(m_udpFlags); 
     267                case 15: return boost::lexical_cast<std::string>(m_tcpFlags); 
     268                case 16: return boost::lexical_cast<std::string>(m_lowIdUsers); 
     269                default: return std::string(); 
     270        } 
     271} 
     272 
     273std::string Server::getFieldName(uint32_t num) const { 
     274        switch (num) { 
     275                case  0: return "Name"; 
     276                case  1: return "Address"; 
     277                case  2: return "Description"; 
     278                case  3: return "Users"; 
     279                case  4: return "Files"; 
     280                case  5: return "Dynamic IP"; 
     281                case  6: return "Version"; 
     282                case  7: return "Failed count"; 
     283                case  8: return "Preference"; 
     284                case  9: return "Ping"; 
     285                case 10: return "Last ping"; 
     286                case 11: return "Max users"; 
     287                case 12: return "Soft file limit"; 
     288                case 13: return "Hard file limit"; 
     289                case 14: return "UDP flags"; 
     290                case 15: return "TCP flags"; 
     291                case 16: return "Low ID users"; 
     292                default: return std::string(); 
     293        } 
     294} 
     295 
    247296} // namespace Detail 
    248297} // end namespace Donkey 
  • hydranode/hncore/ed2k/server.h

    r2798 r2942  
    123123        void setCurrentSearch(SearchPtr p)    { m_globSearch = p;      } 
    124124        //@} 
     125 
     126        virtual uint32_t getDataCount() const; 
     127        virtual std::string getData(uint32_t num) const; 
     128        virtual std::string getFieldName(uint32_t num) const; 
    125129private: 
    126130        friend class ::Donkey::ServerList; 
  • hydranode/hncore/ed2k/serverlist.cpp

    r2903 r2942  
    11881188} 
    11891189 
    1190 uint8_t ServerList::getOperCount() const {  
     1190uint32_t ServerList::getOperCount() const {  
    11911191#ifndef NDEBUG 
    11921192        return 5;  
     
    11961196} 
    11971197 
    1198 Object::Operation ServerList::getOper(uint8_t n) const { 
     1198Object::Operation ServerList::getOper(uint32_t n) const { 
    11991199        if (n == 0) { 
    12001200                Operation op("connect", true); 
  • hydranode/hncore/ed2k/serverlist.h

    r2892 r2942  
    308308        //! @name Various operations 
    309309        //@{ 
    310         virtual uint8_t getOperCount() const; 
    311         virtual Object::Operation getOper(uint8_t n) const; 
     310        virtual uint32_t getOperCount() const; 
     311        virtual Object::Operation getOper(uint32_t n) const; 
    312312        virtual void doOper(const Object::Operation &op); 
    313313        //@} 
  • hydranode/hncore/fileslist.cpp

    r2821 r2942  
    388388 
    389389// Customization virtual functions 
    390 uint8_t FilesList::getOperCount() const { 
     390uint32_t FilesList::getOperCount() const { 
    391391        return 1; 
    392392} 
    393393 
    394 Object::Operation FilesList::getOper(uint8_t n) const { 
     394Object::Operation FilesList::getOper(uint32_t n) const { 
    395395        switch (n) { 
    396396                case 0: { 
  • hydranode/hncore/fileslist.h

    r2816 r2942  
    313313        //! @name Make operations/data available for Object hierarcy 
    314314        //@{ 
    315         virtual uint8_t getOperCount() const; 
    316         virtual Object::Operation getOper(uint8_t n) const; 
     315        virtual uint32_t getOperCount() const; 
     316        virtual Object::Operation getOper(uint32_t n) const; 
    317317        virtual void doOper(const Operation &oper); 
    318318        //@} 
  • hydranode/hngui/Jamfile

    r2939 r2942  
    3737           /qt4//QtGui /qt4//QtNetwork /qt4//QtXml 
    3838          ../extra//boost_signals ../extra//boost_date_time 
     39         
     40        # plugins (built-in currently due to lack of support for plugin loading) 
     41          plugins/donkeypage.cpp plugins/donkeypage.h plugins/donkeypage_ui.ui 
    3942        : <include>.  
    4043  &