Merge authors: poy (poy) ------------------------------------------------------------ revno: 12 [merge] committer: poy <p...@123gen.com> branch nick: ScriptPlugin timestamp: Thu 2013-04-25 19:56:49 +0200 message: merge added: doc/Plugin format (dcext).txt modified: pluginsdk/Config.cpp pluginsdk/Config.h pluginsdk/PluginDefs.h pluginsdk/UI.cpp pluginsdk/UI.h
-- lp:~dcplusplus-team/dcpp-plugin-sdk-cpp/ScriptPlugin https://code.launchpad.net/~dcplusplus-team/dcpp-plugin-sdk-cpp/ScriptPlugin Your team Dcplusplus-team is subscribed to branch lp:~dcplusplus-team/dcpp-plugin-sdk-cpp/ScriptPlugin. To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcpp-plugin-sdk-cpp/ScriptPlugin/+edit-subscription
=== added file 'doc/Plugin format (dcext).txt' --- doc/Plugin format (dcext).txt 1970-01-01 00:00:00 +0000 +++ doc/Plugin format (dcext).txt 2013-04-23 18:12:02 +0000 @@ -0,0 +1,70 @@ +This document describes the way DC plugins are packaged and distributed. + +More resources: +- C SDK: <https://launchpad.net/dcpp-plugin-sdk-c>. +- C++ SDK: <https://launchpad.net/dcpp-plugin-sdk-cpp>. +- Implementation details: dcpp/Plugin* files. + +Alternative names for a DC plugin: DC extension, DC++ plugin, DC++ extension - stemming from the +host-agnostic design of the DC plugin API. + +A DC plugin is, at the very least, a shared extension (.so Linux file, .dll Windows file) that +defines a "pluginInit" function and handles basic events from the plugin API (ON_INSTALL, ON_LOAD, +etc). It can then subscribe to interfaces such as DCHooks to catch more events. + +Shared extensions are fine for testing but impractical to distribute and to have users install. +Therefore, a DC plugin is preferably packaged as a .dcext file. + +A .dcext file is an archive. Currently, it is required to be a tar file, either uncompressed or +compressed with bzip2 or gzip. This may be expanded in the future if needed. + +That archive must contain an XML file named "info.xml" at its root, whose contents shall validate +against the schemas/dcext.xsd schema. + +Description of the XML tags: + +- "dcext" (compulsory): Root tag. + +- "UUID" (compulsory): UUID to uniquely identify this plugin. +- "Name" (compulsory): Friendly name of the plugin. +- "Version" (compulsory): Version of the plugin; used for updates. +- "ApiVersion" (compulsory): Plugin API version the plugin has been built with. + +- "Author" (optional): Author of the plugin. +- "Description" (optional): Short description of the plugin. +- "Website" (optional): Plugin website. + +- "Plugin" (compulsory): Location of the loadable shared extension within the archive. The required + "Platform" attribute of this tag must be a value from the "Platform codes" list below. Multiple + "Plugin" tags may be provided for different platforms. +- "Files" (optional): Additional files required by the plugin, each within a "File" tag. "File" + tags may contain an optional "Platform" attribute which must be a value from the "Platform + codes" list below; in its absence, files are assumed to be platform-independant by default. + +Platform codes: +- elf-x64: ELF format, x64 architecture. +- elf-x86: ELF format, x86 architecture. +- pe-x64: PE format, x64 architecture. +- pe-x86: PE format, x86 architecture. + +Example info.xml: + +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<dcext> + <UUID>{f62ed829-def5-4332-a0d7-84d2ec692006}</UUID> + <Name>Test plugin</Name> + <Version>2.3</Version> + <ApiVersion>6</ApiVersion> + <Author>Test team</Author> + <Description>Plugin to do X</Description> + <Website>http://example.com</Website> + <Plugin Platform="elf-x64">x64/TestPlugin.so</Plugin> + <Plugin Platform="elf-x86">x86/TestPlugin.so</Plugin> + <Plugin Platform="pe-x64">x64/TestPlugin.dll</Plugin> + <Plugin Platform="pe-x86">x86/TestPlugin.dll</Plugin> + <Files> + <File>icons/TestPlugin.ico</File> + <File>fonts/cool.font</File> + <File Platform="elf-x64">FasterHash.so</File> + </Files> +</dcext> === modified file 'pluginsdk/Config.cpp' --- pluginsdk/Config.cpp 2013-01-18 21:37:14 +0000 +++ pluginsdk/Config.cpp 2013-04-23 18:12:02 +0000 @@ -51,4 +51,11 @@ string Config::getPath(PathType type) { return config->get_path(type); } +string Config::getInstallPath() { + auto cfg = config->get_install_path(guid.c_str()); + string ret(cfg->value); + config->release(reinterpret_cast<ConfigValuePtr>(cfg)); + return ret; +} + } // namespace dcapi === modified file 'pluginsdk/Config.h' --- pluginsdk/Config.h 2013-01-18 21:37:14 +0000 +++ pluginsdk/Config.h 2013-04-23 18:12:02 +0000 @@ -52,6 +52,8 @@ static string getPath(PathType type); + static string getInstallPath(); + private: template<typename ConfigT, typename ValueT> static void setConfig(const char* name, ConfigType type, ValueT value); template<typename ConfigT, typename RetT> static RetT getConfig(const char* name, ConfigType type); === modified file 'pluginsdk/PluginDefs.h' --- pluginsdk/PluginDefs.h 2013-03-03 19:21:04 +0000 +++ pluginsdk/PluginDefs.h 2013-04-23 18:12:02 +0000 @@ -32,7 +32,7 @@ #endif /* Version of the plugin api (must change if old plugins simply can't be seen as viably working) */ -#define DCAPI_CORE_VER 6 +#define DCAPI_CORE_VER 7 #ifdef _WIN32 # define DCAPI __stdcall @@ -58,7 +58,7 @@ /* Recommended interfaces */ #define DCINTF_CONFIG "generic.plugins.DCConfig" /* Config management */ -#define DCINTF_CONFIG_VER 1 +#define DCINTF_CONFIG_VER 2 #define DCINTF_LOGGING "generic.plugins.DCLog" /* Logging functions */ #define DCINTF_LOGGING_VER 1 @@ -74,10 +74,10 @@ #define DCINTF_DCPP_QUEUE_VER 2 #define DCINTF_DCPP_UTILS "dcpp.utils.DCUtils" /* Utility and convenience functions */ -#define DCINTF_DCPP_UTILS_VER 2 +#define DCINTF_DCPP_UTILS_VER 1 #define DCINTF_DCPP_TAGGER "dcpp.xml.DCTagger" /* Manipulation of an XML tagger */ -#define DCINTF_DCPP_TAGGER_VER 2 +#define DCINTF_DCPP_TAGGER_VER 1 #define DCINTF_DCPP_UI "dcpp.ui.DCUI" /* User interface */ #define DCINTF_DCPP_UI_VER 1 @@ -336,6 +336,9 @@ ConfigValuePtr (DCAPI *copy) (const ConfigValuePtr val); void (DCAPI *release) (ConfigValuePtr val); + + /* Version 2 functions */ + ConfigStrPtr (DCAPI *get_install_path) (const char* guid); } DCConfig, *DCConfigPtr; /* Logging functions */ @@ -426,10 +429,9 @@ /* Tagger API version */ uint32_t apiVersion; + const char* (DCAPI *get_text) (TagDataPtr hTags); + void (DCAPI *add_tag) (TagDataPtr hTags, size_t start, size_t end, const char* id, const char* attributes); - - /* Version 2 functions */ - const char* (DCAPI *get_text) (TagDataPtr hTags); void (DCAPI *replace_text) (TagDataPtr hTags, size_t start, size_t end, const char* replacement); } DCTagger, *DCTaggerPtr; @@ -440,7 +442,10 @@ /* User interface API version */ uint32_t apiVersion; - void (DCAPI *add_command) (const char* name, DCCommandFunc command); + /* Add a command identified by "name". + "icon" is optional; it is the path to an icon file used to illustrate the command. */ + void (DCAPI *add_command) (const char* name, DCCommandFunc command, const char* icon); + /* Remove a command previously added with add_command. */ void (DCAPI *remove_command) (const char* name); void (DCAPI *play_sound) (const char* path); === modified file 'pluginsdk/UI.cpp' --- pluginsdk/UI.cpp 2013-01-18 21:37:14 +0000 +++ pluginsdk/UI.cpp 2013-04-23 18:12:02 +0000 @@ -25,7 +25,7 @@ namespace dcapi { DCUIPtr UI::ui; -unordered_map<string, UI::Command> UI::commands; +unordered_map<string, pair<UI::Command, string>> UI::commands; bool UI::init() { if(!Core::handle()) { return false; } @@ -35,8 +35,9 @@ void UI::init(DCUIPtr coreUI) { ui = coreUI; } DCUIPtr UI::handle() { return ui; } -void UI::addCommand(string name, Command command) { - ui->add_command(commands.insert(std::make_pair(move(name), command)).first->first.c_str(), commandCallback); +void UI::addCommand(string name, Command command, string icon) { + const auto& iter = commands.insert(std::make_pair(move(name), std::make_pair(command, move(icon)))).first; + ui->add_command(iter->first.c_str(), commandCallback, iter->second.second.c_str()); } void UI::removeCommand(const string& name) { @@ -45,7 +46,7 @@ } void DCAPI UI::commandCallback(const char* name) { - commands[name](); + commands[name].first(); } } // namespace dcapi === modified file 'pluginsdk/UI.h' --- pluginsdk/UI.h 2013-01-18 21:37:14 +0000 +++ pluginsdk/UI.h 2013-04-23 18:12:02 +0000 @@ -30,6 +30,7 @@ namespace dcapi { using std::function; +using std::pair; using std::string; using std::unordered_map; @@ -41,7 +42,7 @@ static DCUIPtr handle(); typedef function<void ()> Command; - static void addCommand(string name, Command command); + static void addCommand(string name, Command command, string icon); static void removeCommand(const string& name); private: @@ -49,7 +50,7 @@ static DCUIPtr ui; - static unordered_map<string, Command> commands; + static unordered_map<string, pair<UI::Command, string>> commands; }; } // namespace dcapi
_______________________________________________ Mailing list: https://launchpad.net/~linuxdcpp-team Post to : linuxdcpp-team@lists.launchpad.net Unsubscribe : https://launchpad.net/~linuxdcpp-team More help : https://help.launchpad.net/ListHelp