linuxdcpp-team team mailing list archive
-
linuxdcpp-team team
-
Mailing list archive
-
Message #06274
[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 3131: plugin SDK: add stubs for missing interfaces
------------------------------------------------------------
revno: 3131
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Sun 2012-11-11 17:57:44 +0100
message:
plugin SDK: add stubs for missing interfaces
added:
pluginsdk/cpp/pluginsdk/Connections.cpp
pluginsdk/cpp/pluginsdk/Connections.h
pluginsdk/cpp/pluginsdk/Hubs.cpp
pluginsdk/cpp/pluginsdk/Hubs.h
pluginsdk/cpp/pluginsdk/Queue.cpp
pluginsdk/cpp/pluginsdk/Queue.h
pluginsdk/cpp/pluginsdk/Tagger.cpp
pluginsdk/cpp/pluginsdk/Tagger.h
modified:
plugins/Dev/Plugin.cpp
plugins/Dev/Plugin.h
plugins/Dev/pluginsdk.cpp
--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk
Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'plugins/Dev/Plugin.cpp'
--- plugins/Dev/Plugin.cpp 2012-11-11 16:28:14 +0000
+++ plugins/Dev/Plugin.cpp 2012-11-11 16:57:44 +0000
@@ -22,6 +22,7 @@
#include <pluginsdk/Config.h>
#include <pluginsdk/Core.h>
#include <pluginsdk/Hooks.h>
+#include <pluginsdk/Hubs.h>
#include <pluginsdk/Logger.h>
#include <pluginsdk/UI.h>
#include <pluginsdk/Util.h>
@@ -29,12 +30,11 @@
using dcapi::Config;
using dcapi::Core;
using dcapi::Hooks;
+using dcapi::Hubs;
using dcapi::Logger;
using dcapi::UI;
using dcapi::Util;
-Plugin* Plugin::instance = nullptr;
-
Plugin::Plugin() {
}
@@ -46,15 +46,15 @@
}
}
+Plugin* instance;
+
Bool DCAPI Plugin::main(PluginState state, DCCorePtr core, dcptr_t) {
switch(state) {
case ON_INSTALL:
case ON_LOAD:
{
- Bool res = True;
instance = new Plugin();
- instance->onLoad(core, (state == ON_INSTALL), res);
- return res;
+ return instance->onLoad(core, state == ON_INSTALL) ? True : False;
}
case ON_UNINSTALL:
@@ -108,13 +108,10 @@
UI::addCommand(commandName, [this] { onSwitched(); });
}
-void Plugin::onLoad(DCCorePtr core, bool install, Bool& loadRes) {
- hubs = reinterpret_cast<DCHubPtr>(core->query_interface(DCINTF_DCPP_HUBS, DCINTF_DCPP_HUBS_VER));
-
+bool Plugin::onLoad(DCCorePtr core, bool install) {
Core::init(core);
- if(!Config::init() || !Hooks::init() || !Logger::init() || !UI::init() || !Util::init() || !hubs) {
- loadRes = False;
- return;
+ if(!Config::init() || !Hooks::init() || !Hubs::init() || !Logger::init() || !UI::init() || !Util::init()) {
+ return false;
}
if(install) {
@@ -128,6 +125,8 @@
} else {
refreshSwitchCommand();
}
+
+ return true;
}
void Plugin::onSwitched() {
@@ -160,13 +159,13 @@
bool Plugin::onChatCommand(HubDataPtr hub, CommandDataPtr cmd) {
if(stricmp(cmd->command, "help") == 0) {
- hubs->local_message(hub, "/raw <message>", MSG_SYSTEM);
+ Hubs::handle()->local_message(hub, "/raw <message>", MSG_SYSTEM);
} else if(stricmp(cmd->command, "raw") == 0) {
if(strlen(cmd->params) == 0) {
- hubs->local_message(hub, "Specify a message to send", MSG_SYSTEM);
+ Hubs::handle()->local_message(hub, "Specify a message to send", MSG_SYSTEM);
} else {
- hubs->send_protocol_cmd(hub, cmd->params);
+ Hubs::handle()->send_protocol_cmd(hub, cmd->params);
}
}
=== modified file 'plugins/Dev/Plugin.h'
--- plugins/Dev/Plugin.h 2012-11-11 16:16:24 +0000
+++ plugins/Dev/Plugin.h 2012-11-11 16:57:44 +0000
@@ -42,7 +42,7 @@
void refreshSwitchCommand();
- void onLoad(DCCorePtr core, bool install, Bool& loadRes);
+ bool onLoad(DCCorePtr core, bool install);
void onSwitched();
bool onHubDataIn(HubDataPtr hHub, char* message);
bool onHubDataOut(HubDataPtr hHub, char* message);
@@ -50,13 +50,9 @@
bool onClientDataOut(ConnectionDataPtr hConn, char* message);
bool onChatCommand(HubDataPtr hub, CommandDataPtr cmd);
- DCHubPtr hubs;
-
Dialog dialog;
string commandName;
-
- static Plugin* instance;
};
#endif
=== modified file 'plugins/Dev/pluginsdk.cpp'
--- plugins/Dev/pluginsdk.cpp 2012-11-11 16:16:24 +0000
+++ plugins/Dev/pluginsdk.cpp 2012-11-11 16:57:44 +0000
@@ -6,6 +6,7 @@
#include <pluginsdk/Core.cpp>
#include <pluginsdk/Config.cpp>
#include <pluginsdk/Hooks.cpp>
+#include <pluginsdk/Hubs.cpp>
#include <pluginsdk/Logger.cpp>
#include <pluginsdk/UI.cpp>
#include <pluginsdk/Util.cpp>
=== added file 'pluginsdk/cpp/pluginsdk/Connections.cpp'
--- pluginsdk/cpp/pluginsdk/Connections.cpp 1970-01-01 00:00:00 +0000
+++ pluginsdk/cpp/pluginsdk/Connections.cpp 2012-11-11 16:57:44 +0000
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2012 Jacek Sieka, arnetheduck on gmail point com
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+/* Helpers around the DCConnection interface. */
+
+#include "Connections.h"
+
+#include "Core.h"
+
+namespace dcapi {
+
+DCConnectionPtr Connections::connections;
+
+bool Connections::init() {
+ if(!Core::handle()) { return false; }
+ init(reinterpret_cast<DCConnectionPtr>(Core::handle()->query_interface(DCINTF_DCPP_CONNECTIONS, DCINTF_DCPP_CONNECTIONS_VER)));
+ return connections;
+}
+void Connections::init(DCConnectionPtr coreConnections) { connections = coreConnections; }
+DCConnectionPtr Connections::handle() { return connections; }
+
+} // namespace dcapi
=== added file 'pluginsdk/cpp/pluginsdk/Connections.h'
--- pluginsdk/cpp/pluginsdk/Connections.h 1970-01-01 00:00:00 +0000
+++ pluginsdk/cpp/pluginsdk/Connections.h 2012-11-11 16:57:44 +0000
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2012 Jacek Sieka, arnetheduck on gmail point com
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+/* Helpers around the DCConnection interface. */
+
+#ifndef PLUGINSDK_CONNECTIONS_H
+#define PLUGINSDK_CONNECTIONS_H
+
+#include <cstdint>
+
+#include <pluginsdk/PluginDefs.h>
+
+namespace dcapi {
+
+class Connections
+{
+public:
+ static bool init();
+ static void init(DCConnectionPtr coreConnections);
+ static DCConnectionPtr handle();
+
+private:
+ static DCConnectionPtr connections;
+};
+
+} // namespace dcapi
+
+#endif
=== added file 'pluginsdk/cpp/pluginsdk/Hubs.cpp'
--- pluginsdk/cpp/pluginsdk/Hubs.cpp 1970-01-01 00:00:00 +0000
+++ pluginsdk/cpp/pluginsdk/Hubs.cpp 2012-11-11 16:57:44 +0000
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2012 Jacek Sieka, arnetheduck on gmail point com
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+/* Helpers around the DCHub interface. */
+
+#include "Hubs.h"
+
+#include "Core.h"
+
+namespace dcapi {
+
+DCHubPtr Hubs::hubs;
+
+bool Hubs::init() {
+ if(!Core::handle()) { return false; }
+ init(reinterpret_cast<DCHubPtr>(Core::handle()->query_interface(DCINTF_DCPP_HUBS, DCINTF_DCPP_HUBS_VER)));
+ return hubs;
+}
+void Hubs::init(DCHubPtr coreHub) { hubs = coreHub; }
+DCHubPtr Hubs::handle() { return hubs; }
+
+} // namespace dcapi
=== added file 'pluginsdk/cpp/pluginsdk/Hubs.h'
--- pluginsdk/cpp/pluginsdk/Hubs.h 1970-01-01 00:00:00 +0000
+++ pluginsdk/cpp/pluginsdk/Hubs.h 2012-11-11 16:57:44 +0000
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2012 Jacek Sieka, arnetheduck on gmail point com
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+/* Helpers around the DCHub interface. */
+
+#ifndef PLUGINSDK_HUBS_H
+#define PLUGINSDK_HUBS_H
+
+#include <cstdint>
+
+#include <pluginsdk/PluginDefs.h>
+
+namespace dcapi {
+
+class Hubs
+{
+public:
+ static bool init();
+ static void init(DCHubPtr coreHubs);
+ static DCHubPtr handle();
+
+private:
+ static DCHubPtr hubs;
+};
+
+} // namespace dcapi
+
+#endif
=== added file 'pluginsdk/cpp/pluginsdk/Queue.cpp'
--- pluginsdk/cpp/pluginsdk/Queue.cpp 1970-01-01 00:00:00 +0000
+++ pluginsdk/cpp/pluginsdk/Queue.cpp 2012-11-11 16:57:44 +0000
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2012 Jacek Sieka, arnetheduck on gmail point com
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+/* Helpers around the DCQueue interface. */
+
+#include "Queue.h"
+
+#include "Core.h"
+
+namespace dcapi {
+
+DCQueuePtr Queue::queue;
+
+bool Queue::init() {
+ if(!Core::handle()) { return false; }
+ init(reinterpret_cast<DCQueuePtr>(Core::handle()->query_interface(DCINTF_QUEUE, DCINTF_QUEUE_VER)));
+ return queue;
+}
+void Queue::init(DCQueuePtr coreQueue) { queue = coreQueue; }
+DCQueuePtr Queue::handle() { return queue; }
+
+} // namespace dcapi
=== added file 'pluginsdk/cpp/pluginsdk/Queue.h'
--- pluginsdk/cpp/pluginsdk/Queue.h 1970-01-01 00:00:00 +0000
+++ pluginsdk/cpp/pluginsdk/Queue.h 2012-11-11 16:57:44 +0000
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2012 Jacek Sieka, arnetheduck on gmail point com
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+/* Helpers around the DCQueue interface. */
+
+#ifndef PLUGINSDK_QUEUE_H
+#define PLUGINSDK_QUEUE_H
+
+#include <cstdint>
+
+#include <pluginsdk/PluginDefs.h>
+
+namespace dcapi {
+
+class Queue
+{
+public:
+ static bool init();
+ static void init(DCQueuePtr coreQueue);
+ static DCQueuePtr handle();
+
+private:
+ static DCQueuePtr queue;
+};
+
+} // namespace dcapi
+
+#endif
=== added file 'pluginsdk/cpp/pluginsdk/Tagger.cpp'
--- pluginsdk/cpp/pluginsdk/Tagger.cpp 1970-01-01 00:00:00 +0000
+++ pluginsdk/cpp/pluginsdk/Tagger.cpp 2012-11-11 16:57:44 +0000
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2012 Jacek Sieka, arnetheduck on gmail point com
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+/* Helpers around the DCTagger interface. */
+
+#include "Tagger.h"
+
+#include "Core.h"
+
+namespace dcapi {
+
+DCTaggerPtr Tagger::tagger;
+
+bool Tagger::init() {
+ if(!Core::handle()) { return false; }
+ init(reinterpret_cast<DCTaggerPtr>(Core::handle()->query_interface(DCINTF_DCPP_TAGGER, DCINTF_DCPP_TAGGER_VER)));
+ return tagger;
+}
+void Tagger::init(DCTaggerPtr coreTagger) { tagger = coreTagger; }
+DCTaggerPtr Tagger::handle() { return tagger; }
+
+} // namespace dcapi
=== added file 'pluginsdk/cpp/pluginsdk/Tagger.h'
--- pluginsdk/cpp/pluginsdk/Tagger.h 1970-01-01 00:00:00 +0000
+++ pluginsdk/cpp/pluginsdk/Tagger.h 2012-11-11 16:57:44 +0000
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2012 Jacek Sieka, arnetheduck on gmail point com
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+/* Helpers around the DCTagger interface. */
+
+#ifndef PLUGINSDK_TAGGER_H
+#define PLUGINSDK_TAGGER_H
+
+#include <cstdint>
+
+#include <pluginsdk/PluginDefs.h>
+
+namespace dcapi {
+
+class Tagger
+{
+public:
+ static bool init();
+ static void init(DCTaggerPtr coreTagger);
+ static DCTaggerPtr handle();
+
+private:
+ static DCTaggerPtr tagger;
+};
+
+} // namespace dcapi
+
+#endif