Changeset 2942
- Timestamp:
- 04/26/06 21:01:22 (3 years ago)
- Files:
-
- hydranode/hnbase/fwd.h (modified) (1 diff)
- hydranode/hnbase/object.cpp (modified) (5 diffs)
- hydranode/hnbase/object.h (modified) (2 diffs)
- hydranode/hncgcomm/cgcomm.cpp (modified) (3 diffs)
- hydranode/hncgcomm/cgcomm.h (modified) (3 diffs)
- hydranode/hncgcomm/fwd.h (modified) (2 diffs)
- hydranode/hncore/cgcomm/opcodes.h (modified) (2 diffs)
- hydranode/hncore/cgcomm/sub_modules.cpp (modified) (3 diffs)
- hydranode/hncore/cgcomm/sub_modules.h (modified) (1 diff)
- hydranode/hncore/ed2k/ed2k.cpp (modified) (1 diff)
- hydranode/hncore/ed2k/ed2k.h (modified) (1 diff)
- hydranode/hncore/ed2k/server.cpp (modified) (1 diff)
- hydranode/hncore/ed2k/server.h (modified) (1 diff)
- hydranode/hncore/ed2k/serverlist.cpp (modified) (2 diffs)
- hydranode/hncore/ed2k/serverlist.h (modified) (1 diff)
- hydranode/hncore/fileslist.cpp (modified) (1 diff)
- hydranode/hncore/fileslist.h (modified) (1 diff)
- hydranode/hngui/Jamfile (modified) (1 diff)
- hydranode/hngui/home_homeactions.ui (modified) (1 diff)
- hydranode/hngui/hometabs.cpp (modified) (4 diffs)
- hydranode/hngui/hometabs.h (modified) (4 diffs)
- hydranode/hngui/myhydra.cpp (modified) (7 diffs)
- hydranode/hngui/myhydra.h (modified) (2 diffs)
- hydranode/hngui/plugins (added)
- hydranode/hngui/plugins/donkeypage.cpp (added)
- hydranode/hngui/plugins/donkeypage.h (added)
- hydranode/hngui/plugins/donkeypage_ui.ui (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
hydranode/hnbase/fwd.h
r2637 r2942 35 35 class UDPSocket; 36 36 class IPV4Address; 37 class Object; 37 38 template<typename Impl, typename _ImplPtr> class Scheduler; 38 39 template<typename T> class Range; hydranode/hnbase/object.cpp
r2652 r2942 87 87 return m_name; 88 88 } 89 /*virtual*/ uint 8_t Object::getDataCount() const {90 return 0; 91 } 92 /*virtual*/ std::string Object::getData(uint 8_t) const {89 /*virtual*/ uint32_t Object::getDataCount() const { 90 return 0; 91 } 92 /*virtual*/ std::string Object::getData(uint32_t) const { 93 93 logTrace( 94 94 TRACE_OBJECT, … … 97 97 return std::string(); 98 98 } 99 /*virtual*/ std::string Object::getFieldName(uint 8_t) const {99 /*virtual*/ std::string Object::getFieldName(uint32_t) const { 100 100 logTrace( 101 101 TRACE_OBJECT, … … 105 105 return std::string(); 106 106 } 107 DataType Object::getFieldType(uint 8_t) const { return ODT_UNKNOWN; }107 DataType Object::getFieldType(uint32_t) const { return ODT_UNKNOWN; } 108 108 void Object::getValueChoices(std::vector<std::string>*) const {} 109 /*virtual*/ uint 8_t Object::getOperCount() const {110 return 0; 111 } 112 /*virtual*/ Object::Operation Object::getOper(uint 8_t) const {109 /*virtual*/ uint32_t Object::getOperCount() const { 110 return 0; 111 } 112 /*virtual*/ Object::Operation Object::getOper(uint32_t) const { 113 113 logTrace(TRACE_OBJECT, 114 114 boost::format("%s: Object does not have operations.") % m_name … … 126 126 ); 127 127 } 128 /*virtual*/ void Object::setData(uint 8_t, const std::string&) {128 /*virtual*/ void Object::setData(uint32_t, const std::string&) { 129 129 logTrace( 130 130 TRACE_OBJECT, … … 218 218 m_children = 0; 219 219 } 220 notify(child->m_id, OBJ_REMOVED); 220 221 // Virtual function call 221 222 onChildRemoved(child->m_id); hydranode/hnbase/object.h
r2652 r2942 128 128 OBJ_MODIFIED = 0x01, //!< This object's data has been modified 129 129 OBJ_ADDED, //!< An object has been added to this container 130 OBJ_REMOVED, //!< An object has been removed from th sicontainer130 OBJ_REMOVED, //!< An object has been removed from this container 131 131 OBJ_DESTROY //!< This object has been destroyed 132 132 }; … … 180 180 //@{ 181 181 //! Retrieve the number of data fields within this object 182 virtual uint 8_t getDataCount() const;182 virtual uint32_t getDataCount() const; 183 183 //! Retrieve the data at specific field 184 virtual std::string getData(uint 8_t num) const;184 virtual std::string getData(uint32_t num) const; 185 185 //! Retrieve the data field name 186 virtual std::string getFieldName(uint 8_t num) const;186 virtual std::string getFieldName(uint32_t num) const; 187 187 //! Retrieve the data type of the field 188 virtual DataType getFieldType(uint 8_t num) const;188 virtual DataType getFieldType(uint32_t num) const; 189 189 //! Fill the passed vector with possible values for this field. 190 190 //! Generally used in conjuction with FieldType OFT_CHOICE 191 191 virtual void getValueChoices(std::vector<std::string> *cont) const; 192 192 //! Retrieve the number of operations for this object 193 virtual uint 8_t getOperCount() const;193 virtual uint32_t getOperCount() const; 194 194 //! Retrieve a specific operation description 195 virtual Operation getOper(uint 8_t n) const;195 virtual Operation getOper(uint32_t n) const; 196 196 //! Perform an operation with this object 197 197 virtual void doOper(const Operation &oper); 198 198 //! Modify the data at specific field 199 virtual void setData(uint 8_t num, const std::string &data);199 virtual void setData(uint32_t num, const std::string &data); 200 200 //@} 201 201 hydranode/hncgcomm/cgcomm.cpp
r2938 r2942 903 903 } 904 904 905 Object::Object(Modules *parent) : m_parentList(parent), m_id() {} 906 907 void 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 914 void Object::setData(uint8_t num, const std::string &newValue) { 915 m_parentList->setObjectData(shared_from_this(), num, newValue); 916 } 917 918 void 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 925 void 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 939 void 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 905 948 Modules::Modules(Main *parent) : SubSysBase(parent, SUB_MODULES) {} 906 949 … … 941 984 break; 942 985 } 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 1052 ObjectPtr 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; 944 1073 } 945 1074 … … 988 1117 void Modules::getList() { 989 1118 std::ostringstream tmp; 1119 Utils::putVal<uint8_t>(tmp, OC_LIST); 1120 sendPacket(tmp.str()); 1121 } 1122 1123 void 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 1131 void Modules::getObject(ModulePtr mod, const std::string &name, bool recurse) { 1132 std::ostringstream tmp; 990 1133 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 1141 void Modules::monitorObject(ObjectPtr obj, uint32_t interval) { 995 1142 std::ostringstream tmp; 996 1143 Utils::putVal<uint8_t>(tmp, OC_MONITOR); 1144 Utils::putVal<uint32_t>(tmp, obj->getId()); 997 1145 Utils::putVal<uint32_t>(tmp, interval); 998 1146 sendPacket(tmp.str()); 999 1147 } 1000 1148 1149 void 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 1170 void 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 1001 1180 } // end namespace Engine hydranode/hncgcomm/cgcomm.h
r2938 r2942 488 488 }; 489 489 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 490 537 class DLLEXPORT Modules : public SubSysBase { 491 538 public: 492 539 Modules(Main *parent); 540 541 // modules specific 493 542 void getList(); 494 543 void monitor(uint32_t interval); … … 501 550 typedef std::map<uint32_t, ModulePtr>::const_iterator CIter; 502 551 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; 505 610 protected: 506 611 virtual void handle(std::istream &i); … … 508 613 std::map<uint32_t, ModulePtr> m_list; 509 614 615 std::map<uint32_t, ObjectPtr> m_objects; 616 510 617 ModulePtr readModule(std::istream &i); 618 ObjectPtr readObject(std::istream &i); 511 619 }; 512 620 hydranode/hncgcomm/fwd.h
r2895 r2942 38 38 class Module; 39 39 class Modules; 40 class Object; 40 41 41 42 typedef boost::shared_ptr<SearchResult> SearchResultPtr; … … 43 44 typedef boost::shared_ptr<SharedFile> SharedFilePtr; 44 45 typedef boost::shared_ptr<Module> ModulePtr; 46 typedef boost::shared_ptr<Object> ObjectPtr; 45 47 46 48 enum FileType { hydranode/hncore/cgcomm/opcodes.h
r2911 r2942 62 62 OC_LINKS = 0x18, //!< Get/Send human-readable links (http, ed2k etc) 63 63 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 65 71 }; 66 72 … … 167 173 168 174 enum { 169 OP_SHAREDFILE = 0x90 175 OP_SHAREDFILE = 0x90, 176 OC_OBJECT = 0x91, 177 OC_OBJLIST = 0x92 170 178 }; 171 179 hydranode/hncore/cgcomm/sub_modules.cpp
r2862 r2942 40 40 uint8_t oc = Utils::getVal<uint8_t>(i); 41 41 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; 44 47 default: break; 45 48 } … … 72 75 73 76 void Modules::monitor(std::istream &i) { 77 uint32_t id = Utils::getVal<uint32_t>(i); 74 78 uint32_t timer = Utils::getVal<uint32_t>(i); 75 if (!m_monitorTimer && timer ) {79 if (!m_monitorTimer && timer && id) { 76 80 Utils::timedCallback( 77 81 boost::bind(&Modules::sendList, this, OC_UPDATE), timer 78 82 ); 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 } 79 92 } 80 93 m_monitorTimer = timer; … … 120 133 } 121 134 122 123 } 124 } 135 void 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 165 uint32_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 190 void 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 218 void 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 231 void 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 240 void 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 33 33 virtual void handle(std::istream &i); 34 34 private: 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 35 45 void sendList(uint8_t oc = OC_LIST); 36 void monitor(std::istream &i);37 46 void onLoaded(ModuleBase *mod); 38 47 void onUnloaded(ModuleBase *mod); hydranode/hncore/ed2k/ed2k.cpp
r2875 r2942 402 402 } 403 403 404 uint 8_t ED2K::getOperCount() const {404 uint32_t ED2K::getOperCount() const { 405 405 return ServerList::instance().getOperCount(); 406 406 } 407 Object::Operation ED2K::getOper(uint 8_t n) const {407 Object::Operation ED2K::getOper(uint32_t n) const { 408 408 return ServerList::instance().getOper(n); 409 409 } hydranode/hncore/ed2k/ed2k.h
r2875 r2942 109 109 */ 110 110 //@{ 111 virtual uint 8_t getOperCount() const;112 virtual Object::Operation getOper(uint 8_t n) const;111 virtual uint32_t getOperCount() const; 112 virtual Object::Operation getOper(uint32_t n) const; 113 113 virtual void doOper(const Object::Operation &op); 114 114 //@} hydranode/hncore/ed2k/server.cpp
r2757 r2942 245 245 MSVC_ONLY(;) 246 246 247 uint32_t Server::getDataCount() const { return 17; } 248 249 std::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 273 std::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 247 296 } // namespace Detail 248 297 } // end namespace Donkey hydranode/hncore/ed2k/server.h
r2798 r2942 123 123 void setCurrentSearch(SearchPtr p) { m_globSearch = p; } 124 124 //@} 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; 125 129 private: 126 130 friend class ::Donkey::ServerList; hydranode/hncore/ed2k/serverlist.cpp
r2903 r2942 1188 1188 } 1189 1189 1190 uint 8_t ServerList::getOperCount() const {1190 uint32_t ServerList::getOperCount() const { 1191 1191 #ifndef NDEBUG 1192 1192 return 5; … … 1196 1196 } 1197 1197 1198 Object::Operation ServerList::getOper(uint 8_t n) const {1198 Object::Operation ServerList::getOper(uint32_t n) const { 1199 1199 if (n == 0) { 1200 1200 Operation op("connect", true); hydranode/hncore/ed2k/serverlist.h
r2892 r2942 308 308 //! @name Various operations 309 309 //@{ 310 virtual uint 8_t getOperCount() const;311 virtual Object::Operation getOper(uint 8_t n) const;310 virtual uint32_t getOperCount() const; 311 virtual Object::Operation getOper(uint32_t n) const; 312 312 virtual void doOper(const Object::Operation &op); 313 313 //@} hydranode/hncore/fileslist.cpp
r2821 r2942 388 388 389 389 // Customization virtual functions 390 uint 8_t FilesList::getOperCount() const {390 uint32_t FilesList::getOperCount() const { 391 391 return 1; 392 392 } 393 393 394 Object::Operation FilesList::getOper(uint 8_t n) const {394 Object::Operation FilesList::getOper(uint32_t n) const { 395 395 switch (n) { 396 396 case 0: { hydranode/hncore/fileslist.h
r2816 r2942 313 313 //! @name Make operations/data available for Object hierarcy 314 314 //@{ 315 virtual uint 8_t getOperCount() const;316 virtual Object::Operation getOper(uint 8_t n) const;315 virtual uint32_t getOperCount() const; 316 virtual Object::Operation getOper(uint32_t n) const; 317 317 virtual void doOper(const Operation &oper); 318 318 //@} hydranode/hngui/Jamfile
r2939 r2942 37 37 /qt4//QtGui /qt4//QtNetwork /qt4//QtXml 38 38 ../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 39 42 : <include>. 40 43 &
