📄 ecspecialtags.h
字号:
//// This file is part of the aMule Project.//// Copyright (c) 2004-2008 aMule Team ( admin@amule.org / http://www.amule.org )//// Any parts of this program derived from the xMule, lMule or eMule project,// or contributed by third-party developers are copyrighted by their// respective authors.//// This program 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 2 of the License, or// (at your option) any later version.//// This program 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 this program; if not, write to the Free Software// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA//#ifndef ECSPECIALTAGS_H#define ECSPECIALTAGS_H//#warning Kry - Preferences packet derived from packet, and that's ok, but shouldn't be here because this is a tag file and forces a stupid include#include "ECPacket.h" // Needed for CECPacket#include "../../../NetworkFunctions.h" // Needed for IsLowID#include <map>/* * Specific tags for specific requests * * \note EC remote end does not need to create these packets, * only using the getter functions. * * Regarding this, those classes are removed from remote build, * that have only a constructor. */class CServer;class CKnownFile;class CPartFile;class CSearchFile;class CUpDownClient;/* * EC tags encoder. Idea: if for an object <X>, client <Z> tag <Y> have value equal to previous * request, skip this tag. */class CValueMap { /* * Tag -> LastValue map. Hold last value that transmitted to remote side */ std::map<ec_tagname_t, uint8> m_map_uint8; std::map<ec_tagname_t, uint16> m_map_uint16; std::map<ec_tagname_t, uint32> m_map_uint32; std::map<ec_tagname_t, uint64> m_map_uint64; std::map<ec_tagname_t, CMD4Hash> m_map_md4; std::map<ec_tagname_t, wxString> m_map_string; template <class T> void CreateTagT(ec_tagname_t tagname, T value, std::map<ec_tagname_t, T> &map, CECTag *parent) { if ( (map.count(tagname) == 0) || (map[tagname] != value) ) { parent->AddTag(CECTag(tagname, value)); map[tagname] = value; } } public: CValueMap() { } CValueMap(const CValueMap &valuemap) { m_map_uint8 = valuemap.m_map_uint8; m_map_uint16 = valuemap.m_map_uint16; m_map_uint32 = valuemap.m_map_uint32; m_map_uint64 = valuemap.m_map_uint64; m_map_md4 = valuemap.m_map_md4; m_map_string = valuemap.m_map_string; } ~CValueMap() { } void CreateTag(ec_tagname_t tagname, uint8 value, CECTag *parent) { CreateTagT<uint8>(tagname, value, m_map_uint8, parent); } void CreateTag(ec_tagname_t tagname, uint16 value, CECTag *parent) { CreateTagT<uint16>(tagname, value, m_map_uint16, parent); } void CreateTag(ec_tagname_t tagname, uint32 value, CECTag *parent) { CreateTagT<uint32>(tagname, value, m_map_uint32, parent); } void CreateTag(ec_tagname_t tagname, uint64 value, CECTag *parent) { CreateTagT<uint64>(tagname, value, m_map_uint64, parent); } void CreateTag(ec_tagname_t tagname, CMD4Hash value, CECTag *parent) { CreateTagT<CMD4Hash>(tagname, value, m_map_md4, parent); } void CreateTag(ec_tagname_t tagname, wxString value, CECTag *parent) { CreateTagT<wxString>(tagname, value, m_map_string, parent); }};class CEC_Category_Tag : public CECTag { public: CEC_Category_Tag(uint32 cat_index, EC_DETAIL_LEVEL detail_level = EC_DETAIL_FULL); // for create-upate commands CEC_Category_Tag(uint32 cat_index, wxString name, wxString path, wxString comment, uint32 color, uint8 prio); void Apply(); void Create(); wxString Name() { return GetTagByNameSafe(EC_TAG_CATEGORY_TITLE)->GetStringData(); } wxString Path() { return GetTagByNameSafe(EC_TAG_CATEGORY_PATH)->GetStringData(); } wxString Comment() { return GetTagByNameSafe(EC_TAG_CATEGORY_COMMENT)->GetStringData(); } uint8 Prio() { return GetTagByNameSafe(EC_TAG_CATEGORY_PRIO)->GetInt(); } uint32 Color() { return GetTagByNameSafe(EC_TAG_CATEGORY_COLOR)->GetInt(); } };class CEC_Prefs_Packet : public CECPacket { public: CEC_Prefs_Packet(uint32 selection, EC_DETAIL_LEVEL prefs_detail = EC_DETAIL_FULL, EC_DETAIL_LEVEL cat_details = EC_DETAIL_FULL); void Apply();};class CEC_Server_Tag : public CECTag { public: CEC_Server_Tag(const CServer *, EC_DETAIL_LEVEL); wxString ServerName() { return GetTagByNameSafe(EC_TAG_SERVER_NAME)->GetStringData(); } wxString ServerDesc() { return GetTagByNameSafe(EC_TAG_SERVER_DESC)->GetStringData(); } uint8 GetPrio() { return GetTagByNameSafe(EC_TAG_SERVER_PRIO)->GetInt(); } bool GetStatic() { return (GetTagByNameSafe(EC_TAG_SERVER_STATIC)->GetInt() == 1); } uint32 GetPing() { return GetTagByNameSafe(EC_TAG_SERVER_PING)->GetInt(); } uint8 GetFailed() { return GetTagByNameSafe(EC_TAG_SERVER_FAILED)->GetInt(); } uint32 GetFiles() { return GetTagByNameSafe(EC_TAG_SERVER_FILES)->GetInt(); } uint32 GetUsers() { return GetTagByNameSafe(EC_TAG_SERVER_USERS)->GetInt(); } uint32 GetMaxUsers() { return GetTagByNameSafe(EC_TAG_SERVER_USERS_MAX)->GetInt(); } // we're not using incremental update on server list, // but template code needs it uint32 ID() { return 0; }};class CEC_ConnState_Tag : public CECTag { public: CEC_ConnState_Tag(EC_DETAIL_LEVEL); uint32 GetEd2kId() { return GetTagByNameSafe(EC_TAG_ED2K_ID)->GetInt(); } uint32 GetClientId() { return GetTagByNameSafe(EC_TAG_CLIENT_ID)->GetInt(); } bool HasLowID() { return GetEd2kId() < HIGHEST_LOWID_ED2K_KAD; } bool IsConnected() const { return IsConnectedED2K() || IsConnectedKademlia(); } bool IsConnectedED2K() const { return (GetInt() & 0x01) != 0; } bool IsConnectingED2K() const { return (GetInt() & 0x02) != 0; } bool IsConnectedKademlia() const { return (GetInt() & 0x04) != 0; } bool IsKadFirewalled() const { return (GetInt() & 0x08) != 0; } bool IsKadRunning() const { return (GetInt() & 0x10) != 0; }};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -