linuxdcpp-team team mailing list archive
-
linuxdcpp-team team
-
Mailing list archive
-
Message #06288
[Branch ~dcplusplus-team/dcpp-plugin-sdk-cpp/TestPlugin] Rev 2: init from lp:dcplusplus/plugins/Test
------------------------------------------------------------
revno: 2
committer: poy <poy@xxxxxxxxxx>
branch nick: TestPlugin
timestamp: Thu 2012-11-15 20:10:34 +0100
message:
init from lp:dcplusplus/plugins/Test
modified:
src/Plugin.cpp
src/Plugin.h
src/resource.rc
src/version.h
--
lp:~dcplusplus-team/dcpp-plugin-sdk-cpp/TestPlugin
https://code.launchpad.net/~dcplusplus-team/dcpp-plugin-sdk-cpp/TestPlugin
Your team Dcplusplus-team is subscribed to branch lp:~dcplusplus-team/dcpp-plugin-sdk-cpp/TestPlugin.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcpp-plugin-sdk-cpp/TestPlugin/+edit-subscription
=== modified file 'src/Plugin.cpp'
--- src/Plugin.cpp 2012-11-15 18:17:16 +0000
+++ src/Plugin.cpp 2012-11-15 19:10:34 +0000
@@ -25,6 +25,8 @@
#include <pluginsdk/Core.h>
#include <pluginsdk/Hooks.h>
#include <pluginsdk/Logger.h>
+#include <pluginsdk/Tagger.h>
+#include <pluginsdk/UI.h>
#include <pluginsdk/Util.h>
/* Plugin SDK helpers are in the "dcapi" namespace; ease their calling. */
@@ -32,6 +34,8 @@
using dcapi::Core;
using dcapi::Hooks;
using dcapi::Logger;
+using dcapi::Tagger;
+using dcapi::UI;
using dcapi::Util;
Plugin::Plugin() {
@@ -71,15 +75,42 @@
/* Initialization phase. Initiate additional interfaces that you may have included from the
plugin SDK. */
Core::init(core);
- if(!Config::init(PLUGIN_GUID) || !Hooks::init() || !Logger::init() || !Util::init()) {
+ if(!Config::init(PLUGIN_GUID) || !Hooks::init() || !Logger::init() || !Tagger::init() || !UI::init() || !Util::init()) {
return false;
}
if(install) {
// This only executes when the plugin has been installed for the first time.
+ Logger::log("The test plugin has been installed.");
}
// Start the plugin logic here; add hooks with functions from the Hooks interface.
+ Logger::log("Test plugin loaded, watch out!");
+
+ Hooks::Timer::onSecond([this](uint64_t tick, bool&) { return onSecond(tick); });
+ Hooks::UI::onChatTags([this](UserDataPtr, TagDataPtr tags, bool&) { return onUiChatTags(tags); });
return true;
}
+
+bool Plugin::onSecond(uint64_t tick) {
+ static uint64_t prevTick = 0;
+ if(tick - prevTick >= 10*1000) {
+ prevTick = tick;
+ UI::handle()->play_sound("Media\\tada.wav");
+ }
+ return false;
+}
+
+bool Plugin::onUiChatTags(TagDataPtr tags) {
+ // look for the pattern and make it bold.
+ const string pattern = "ABC DEF";
+
+ string text(tags->text);
+ size_t start, end = 0;
+ while((start = text.find(pattern, end)) != string::npos) {
+ end = start + pattern.size();
+ Tagger::handle()->add_tag(tags, start, end, "b", "");
+ }
+ return false;
+}
=== modified file 'src/Plugin.h'
--- src/Plugin.h 2012-11-15 18:17:16 +0000
+++ src/Plugin.h 2012-11-15 19:10:34 +0000
@@ -31,6 +31,8 @@
~Plugin();
bool onLoad(DCCorePtr core, bool install);
+ bool onSecond(uint64_t tick);
+ bool onUiChatTags(TagDataPtr tags);
};
#endif
=== modified file 'src/resource.rc'
--- src/resource.rc 2012-11-15 18:17:16 +0000
+++ src/resource.rc 2012-11-15 19:10:34 +0000
@@ -67,13 +67,13 @@
BEGIN
BLOCK "080004b0"
BEGIN
- VALUE "Comments", "..."
- VALUE "FileDescription", "..."
+ VALUE "Comments", "http://dcplusplus.sourceforge.net";
+ VALUE "FileDescription", "Test plugin for DC++"
VALUE "FileVersion", "1, 0, 0, 0"
- VALUE "InternalName", "..."
- VALUE "LegalCopyright", "..."
- VALUE "OriginalFilename", "..."
- VALUE "ProductName", "..."
+ VALUE "InternalName", "TestPlugin"
+ VALUE "LegalCopyright", "Copyright (C) 2012 Jacek Sieka"
+ VALUE "OriginalFilename", "TestPlugin.dll"
+ VALUE "ProductName", "Test plugin for DC++"
VALUE "ProductVersion", "1, 0, 0, 0"
END
END
=== modified file 'src/version.h'
--- src/version.h 2012-11-15 18:17:16 +0000
+++ src/version.h 2012-11-15 19:10:34 +0000
@@ -18,27 +18,25 @@
/* Information about the plugin - fill this out! Don't forget to edit the resource file as well. */
-#error Version information not set! Remove this error once you have filled version.h and the resource file.
-
#ifndef PLUGIN_VERSION_H
#define PLUGIN_VERSION_H
/* UUID/GUID for this plugin project */
-#define PLUGIN_GUID "..."
+#define PLUGIN_GUID "{a6150201-b8f6-4ec7-b851-e9fb1b2807dc}"
/* Name of the plugin */
-#define PLUGIN_NAME "..."
+#define PLUGIN_NAME "Test plugin"
/* Author of the plugin */
-#define PLUGIN_AUTHOR "..."
+#define PLUGIN_AUTHOR "DC++"
/* Short description of the plugin */
-#define PLUGIN_DESC "..."
+#define PLUGIN_DESC "Test plugin to play around with the plugin API"
/* Version of the plugin (note: not API version) */
#define PLUGIN_VERSION 1.0
/* Plugin website, set to "N/A" if none */
-#define PLUGIN_WEB "N/A"
+#define PLUGIN_WEB "http://dcplusplus.sourceforge.net/";
#endif