linuxdcpp-team team mailing list archive
-
linuxdcpp-team team
-
Mailing list archive
-
Message #06392
[Branch ~dcplusplus-team/dcpp-plugin-sdk-cpp/DevPlugin] Rev 11: show user info in the Peer column
Merge authors:
poy (poy)
------------------------------------------------------------
revno: 11 [merge]
committer: poy <poy@xxxxxxxxxx>
branch nick: DevPlugin
timestamp: Thu 2012-12-27 22:14:43 +0100
message:
show user info in the Peer column
modified:
pluginsdk/PluginDefs.h
src/Plugin.cpp
--
lp:~dcplusplus-team/dcpp-plugin-sdk-cpp/DevPlugin
https://code.launchpad.net/~dcplusplus-team/dcpp-plugin-sdk-cpp/DevPlugin
Your team Dcplusplus-team is subscribed to branch lp:~dcplusplus-team/dcpp-plugin-sdk-cpp/DevPlugin.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcpp-plugin-sdk-cpp/DevPlugin/+edit-subscription
=== modified file 'pluginsdk/PluginDefs.h'
--- pluginsdk/PluginDefs.h 2012-11-15 18:17:16 +0000
+++ pluginsdk/PluginDefs.h 2012-12-27 21:13:45 +0000
@@ -65,7 +65,7 @@
/* Optional interfaces */
#define DCINTF_DCPP_CONNECTIONS "dcpp.network.DCConnection" /* Peer connections */
-#define DCINTF_DCPP_CONNECTIONS_VER 1
+#define DCINTF_DCPP_CONNECTIONS_VER 2
#define DCINTF_DCPP_HUBS "dcpp.network.DCHub" /* Hubs */
#define DCINTF_DCPP_HUBS_VER 1
@@ -357,6 +357,9 @@
void (DCAPI *send_udp_data) (const char* ip, uint32_t port, dcptr_t data, size_t n);
void (DCAPI *send_protocol_cmd) (ConnectionDataPtr hConn, const char* cmd);
void (DCAPI *terminate_conn) (ConnectionDataPtr hConn, Bool graceless);
+
+ /* Version 2 functions */
+ UserDataPtr (DCAPI *get_user) (ConnectionDataPtr hConn);
} DCConnection, *DCConnectionPtr;
/* Hubs */
=== modified file 'src/Plugin.cpp'
--- src/Plugin.cpp 2012-12-27 13:57:18 +0000
+++ src/Plugin.cpp 2012-12-27 21:14:43 +0000
@@ -22,6 +22,7 @@
/* Include plugin SDK helpers. There are more interfaces available that can be included in the same
fashion (check the pluginsdk directory). */
#include <pluginsdk/Config.h>
+#include <pluginsdk/Connections.h>
#include <pluginsdk/Core.h>
#include <pluginsdk/Hooks.h>
#include <pluginsdk/Hubs.h>
@@ -31,6 +32,7 @@
/* Plugin SDK helpers are in the "dcapi" namespace; ease their calling. */
using dcapi::Config;
+using dcapi::Connections;
using dcapi::Core;
using dcapi::Hooks;
using dcapi::Hubs;
@@ -115,7 +117,7 @@
/* Initialization phase. Initiate additional interfaces that you may have included from the
plugin SDK. */
Core::init(core);
- if(!Config::init(PLUGIN_GUID) || !Hooks::init() || !Hubs::init() || !Logger::init() || !UI::init() || !Util::init()) {
+ if(!Config::init(PLUGIN_GUID) || !Connections::init() || !Hooks::init() || !Hubs::init() || !Logger::init() || !UI::init() || !Util::init()) {
return false;
}
@@ -145,22 +147,29 @@
}
bool Plugin::onHubDataIn(HubDataPtr hHub, char* message) {
- gui.write(true, false, hHub->ip, hHub->port, "Hub " + string(hHub->url), message);
+ gui.write(true, false, hHub->ip, hHub->port, "Hub <" + string(hHub->url) + ">", message);
return false;
}
bool Plugin::onHubDataOut(HubDataPtr hHub, char* message) {
- gui.write(true, true, hHub->ip, hHub->port, "Hub " + string(hHub->url), message);
+ gui.write(true, true, hHub->ip, hHub->port, "Hub <" + string(hHub->url) + ">", message);
return false;
}
+namespace { string userInfo(ConnectionDataPtr hConn) {
+ auto user = Connections::handle()->get_user(hConn);
+ string ret = user ? string(user->nick) + " <" + string(user->hubHint) + ">" : "[unknown]";
+ if(user) { Hubs::handle()->release_user(user); }
+ return ret;
+} }
+
bool Plugin::onClientDataIn(ConnectionDataPtr hConn, char* message) {
- gui.write(false, false, hConn->ip, hConn->port, "User" /** @todo get user's nick */, message);
+ gui.write(false, false, hConn->ip, hConn->port, "User " + userInfo(hConn), message);
return false;
}
bool Plugin::onClientDataOut(ConnectionDataPtr hConn, char* message) {
- gui.write(false, true, hConn->ip, hConn->port, "User" /** @todo get user's nick */, message);
+ gui.write(false, true, hConn->ip, hConn->port, "User " + userInfo(hConn), message);
return false;
}