aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules/dcc/libkvidcc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/dcc/libkvidcc.cpp')
-rw-r--r--src/modules/dcc/libkvidcc.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/modules/dcc/libkvidcc.cpp b/src/modules/dcc/libkvidcc.cpp
index be15c526e..d38a98f1e 100644
--- a/src/modules/dcc/libkvidcc.cpp
+++ b/src/modules/dcc/libkvidcc.cpp
@@ -2539,6 +2539,47 @@ static bool dcc_kvs_fnc_averageSpeed(KviKvsModuleFunctionCall * c)
return true;
}
+/*
+ @doc: dcc.instantSpeed
+ @type:
+ function
+ @title:
+ Returns the instant speed of a DCC file transfer
+ @syntax:
+ $dcc.instantSpeed
+ $dcc.instantSpeed(<dcc_id>)
+ @description:
+ Returns the instant speed (in bytes/sec) of the specified DCC session.[br]
+ If <dcc_id> is omitted then the DCC Session associated
+ with the current window is assumed.[br]
+ If <dcc_id> is not a valid DCC session identifier (or it is omitted
+ and the current window has no associated DCC session) then
+ this function prints a warning and returns an empty string.[br]
+ If the DCC session does not refer to a file transfer then
+ this function returns [b]0[/b].[br]
+ See the [module:dcc]dcc module[/module] documentation for more information.[br]
+*/
+
+static bool dcc_kvs_fnc_instantSpeed(KviKvsModuleFunctionCall * c)
+{
+ kvs_uint_t uDccId;
+ KVSM_PARAMETERS_BEGIN(c)
+ KVSM_PARAMETER("dcc_id",KVS_PT_UINT,KVS_PF_OPTIONAL,uDccId)
+ KVSM_PARAMETERS_END(c)
+
+ DccDescriptor * dcc = dcc_kvs_find_dcc_descriptor(uDccId,c);
+
+ if(dcc)
+ {
+ if(dcc->transfer())
+ {
+ c->returnValue()->setInteger(dcc->transfer()->instantSpeed());
+ } else {
+ c->returnValue()->setInteger(0);
+ }
+ }
+ return true;
+}
/*
@@ -2907,6 +2948,7 @@ static bool dcc_module_init(KviModule * m)
KVSM_REGISTER_FUNCTION(m,"remoteFileName",dcc_kvs_fnc_remoteFileName);
KVSM_REGISTER_FUNCTION(m,"remoteFileSize",dcc_kvs_fnc_remoteFileSize);
KVSM_REGISTER_FUNCTION(m,"averageSpeed",dcc_kvs_fnc_averageSpeed);
+ KVSM_REGISTER_FUNCTION(m,"instantSpeed",dcc_kvs_fnc_instantSpeed);
KVSM_REGISTER_FUNCTION(m,"transferredBytes",dcc_kvs_fnc_transferredBytes);
KVSM_REGISTER_FUNCTION(m,"ircContext",dcc_kvs_fnc_ircContext);
KVSM_REGISTER_FUNCTION(m,"session",dcc_kvs_fnc_session);