KVIrc 5.2.6
Developer APIs
libkvitorrent.cpp File Reference
#include "TorrentInterface.h"
#include "KTorrentDbusInterface.h"
#include "StatusBarApplet.h"
#include "KviModule.h"
#include "KviOptions.h"
#include "KviMainWindow.h"
#include "KviLocale.h"
#include "kvi_out.h"

Macros

#define TC_KVS_COMMAND(__name)
 
#define TC_KVS_COMMAND_ERROR
 
#define TC_KVS_FAIL_ON_NO_INTERFACE
 
#define TC_KVS_FLOATRET_FUNCTION(__name, __ifacecommand)
 
#define TC_KVS_FUNCTION(__name)
 
#define TC_KVS_INT_COMMAND(__name, __ifacecommand, __argname)
 
#define TC_KVS_INT_INT_STRING_COMMAND(__name, __ifacecommand, __argname1, __argname2, __argname3)
 
#define TC_KVS_INTRET_FUNCTION(__name, __ifacecommand)
 
#define TC_KVS_INTRET_INT_FUNCTION(__name, __ifacecommand, __argname)
 
#define TC_KVS_INTRET_INT_INT_FUNCTION(__name, __ifacecommand, __argname1, __argname2)
 
#define TC_KVS_REGCMD(__name, __stringname)
 
#define TC_KVS_REGFNC(__name, __stringname)
 
#define TC_KVS_SIMPLE_COMMAND(__name, __ifacecommand)
 
#define TC_KVS_STRINGRET_FUNCTION(__name, __ifacecommand)
 
#define TC_KVS_STRINGRET_INT_FUNCTION(__name, __ifacecommand, __argname)
 
#define TC_KVS_STRINGRET_INT_INT_FUNCTION(__name, __ifacecommand, __argname1, __argname2)
 

Functions

static TorrentInterfaceauto_detect_torrent_client (KviWindow *pOut=nullptr)
 
 TC_KVS_COMMAND (detect)
 
 TC_KVS_COMMAND (setClient)
 
 TC_KVS_FUNCTION (client)
 
 TC_KVS_FUNCTION (clientList)
 
static bool torrent_module_can_unload (KviModule *)
 
static bool torrent_module_cleanup (KviModule *)
 
static bool torrent_module_ctrl (KviModule *, const char *, void *)
 
static bool torrent_module_init (KviModule *m)
 

Variables

static KviPointerList< TorrentInterfaceDescriptor > * g_pDescriptorList = nullptr
 

Macro Definition Documentation

◆ TC_KVS_COMMAND

#define TC_KVS_COMMAND ( __name)
Value:
static bool torrent_kvs_cmd_##__name(KviKvsModuleCommandCall * c)
Definition KviKvsModuleInterface.h:69

Referenced by TC_KVS_COMMAND().

◆ TC_KVS_COMMAND_ERROR

#define TC_KVS_COMMAND_ERROR
Value:
if(!c->hasSwitch('q', "quiet")) \
{ \
c->warning(__tr2qs_ctx("The selected torrent client interface failed to execute the requested function", "torrent")); \
QString tmp = __tr2qs_ctx("Last interface error: ", "torrent"); \
c->warning(tmp); \
}
#define __tr2qs_ctx(text, context)
Definition KviLocale.h:223
QString lastError()
Definition TorrentInterface.h:95
static TorrentInterface * selected()
Definition TorrentInterface.h:98

◆ TC_KVS_FAIL_ON_NO_INTERFACE

#define TC_KVS_FAIL_ON_NO_INTERFACE
Value:
{ \
c->warning(__tr2qs_ctx("No torrent client interface selected. Try /torrent.detect", "torrent")); \
return true; \
}

◆ TC_KVS_FLOATRET_FUNCTION

#define TC_KVS_FLOATRET_FUNCTION ( __name,
__ifacecommand )
Value:
TC_KVS_FUNCTION(__name) \
{ \
TC_KVS_FAIL_ON_NO_INTERFACE \
kvs_real_t ret = TorrentInterface::selected()->__ifacecommand(); \
c->returnValue()->setReal(ret); \
return true; \
}
#define TC_KVS_FUNCTION(__name)
Definition libkvitorrent.cpp:94

◆ TC_KVS_FUNCTION

#define TC_KVS_FUNCTION ( __name)
Value:
static bool torrent_kvs_fnc_##__name(KviKvsModuleFunctionCall * c)
Definition KviKvsModuleInterface.h:112

◆ TC_KVS_INT_COMMAND

#define TC_KVS_INT_COMMAND ( __name,
__ifacecommand,
__argname )
Value:
TC_KVS_COMMAND(__name) \
{ \
kvs_int_t arg; \
KVSM_PARAMETERS_BEGIN(c) \
KVSM_PARAMETER(__argname, KVS_PT_INT, 0, arg) \
KVSM_PARAMETERS_END(c) \
\
TC_KVS_FAIL_ON_NO_INTERFACE \
\
if(!TorrentInterface::selected()->__ifacecommand(arg)) \
{ \
} \
return true; \
}
@ KVS_PT_INT
Definition KviKvsParameterProcessor.h:50
kvi_i64_t kvs_int_t
Definition KviKvsTypes.h:33
#define TC_KVS_COMMAND_ERROR
Definition libkvitorrent.cpp:96
#define TC_KVS_COMMAND(__name)
Definition libkvitorrent.cpp:93

◆ TC_KVS_INT_INT_STRING_COMMAND

#define TC_KVS_INT_INT_STRING_COMMAND ( __name,
__ifacecommand,
__argname1,
__argname2,
__argname3 )
Value:
TC_KVS_COMMAND(__name) \
{ \
kvs_int_t arg1; \
kvs_int_t arg2; \
QString arg3; \
KVSM_PARAMETERS_BEGIN(c) \
KVSM_PARAMETER(__argname1, KVS_PT_INT, 0, arg1) \
KVSM_PARAMETER(__argname2, KVS_PT_INT, 0, arg2) \
KVSM_PARAMETER(__argname3, KVS_PT_STRING, 0, arg3) \
KVSM_PARAMETERS_END(c) \
\
TC_KVS_FAIL_ON_NO_INTERFACE \
\
if(!TorrentInterface::selected()->__ifacecommand(arg1, arg2, arg3)) \
{ \
} \
return true; \
}
@ KVS_PT_STRING
Definition KviKvsParameterProcessor.h:42

◆ TC_KVS_INTRET_FUNCTION

#define TC_KVS_INTRET_FUNCTION ( __name,
__ifacecommand )
Value:
TC_KVS_FUNCTION(__name) \
{ \
TC_KVS_FAIL_ON_NO_INTERFACE \
kvs_int_t ret = TorrentInterface::selected()->__ifacecommand(); \
c->returnValue()->setInteger(ret); \
return true; \
}

◆ TC_KVS_INTRET_INT_FUNCTION

#define TC_KVS_INTRET_INT_FUNCTION ( __name,
__ifacecommand,
__argname )
Value:
TC_KVS_FUNCTION(__name) \
{ \
kvs_int_t arg; \
KVSM_PARAMETERS_BEGIN(c) \
KVSM_PARAMETER(__argname, KVS_PT_INT, 0, arg) \
KVSM_PARAMETERS_END(c) \
TC_KVS_FAIL_ON_NO_INTERFACE \
kvs_int_t ret = TorrentInterface::selected()->__ifacecommand(arg); \
c->returnValue()->setInteger(ret); \
return true; \
}

◆ TC_KVS_INTRET_INT_INT_FUNCTION

#define TC_KVS_INTRET_INT_INT_FUNCTION ( __name,
__ifacecommand,
__argname1,
__argname2 )
Value:
TC_KVS_FUNCTION(__name) \
{ \
kvs_int_t arg1; \
kvs_int_t arg2; \
KVSM_PARAMETERS_BEGIN(c) \
KVSM_PARAMETER(__argname1, KVS_PT_INT, 0, arg1) \
KVSM_PARAMETER(__argname2, KVS_PT_INT, 0, arg2) \
KVSM_PARAMETERS_END(c) \
TC_KVS_FAIL_ON_NO_INTERFACE \
kvs_int_t ret = TorrentInterface::selected()->__ifacecommand(arg1, arg2); \
c->returnValue()->setInteger(ret); \
return true; \
}

◆ TC_KVS_REGCMD

#define TC_KVS_REGCMD ( __name,
__stringname )
Value:
KVSM_REGISTER_SIMPLE_COMMAND(m, __stringname, torrent_kvs_cmd_##__name)
#define KVSM_REGISTER_SIMPLE_COMMAND(_pModule, _szCmd, _procname)
Definition KviKvsModuleInterface.h:207
#define m
Definition detector.cpp:78

Referenced by torrent_module_init().

◆ TC_KVS_REGFNC

#define TC_KVS_REGFNC ( __name,
__stringname )
Value:
KVSM_REGISTER_FUNCTION(m, __stringname, torrent_kvs_fnc_##__name)
#define KVSM_REGISTER_FUNCTION(_pModule, _szFnc, _procname)
Definition KviKvsModuleInterface.h:219

Referenced by torrent_module_init().

◆ TC_KVS_SIMPLE_COMMAND

#define TC_KVS_SIMPLE_COMMAND ( __name,
__ifacecommand )
Value:
TC_KVS_COMMAND(__name) \
{ \
KVSM_PARAMETERS_BEGIN(c) \
KVSM_PARAMETERS_END(c) \
\
TC_KVS_FAIL_ON_NO_INTERFACE \
\
if(!TorrentInterface::selected()->__ifacecommand()) \
{ \
} \
return true; \
}

◆ TC_KVS_STRINGRET_FUNCTION

#define TC_KVS_STRINGRET_FUNCTION ( __name,
__ifacecommand )
Value:
TC_KVS_FUNCTION(__name) \
{ \
TC_KVS_FAIL_ON_NO_INTERFACE \
QString szRet = TorrentInterface::selected()->__ifacecommand(); \
c->returnValue()->setString(szRet); \
return true; \
}

◆ TC_KVS_STRINGRET_INT_FUNCTION

#define TC_KVS_STRINGRET_INT_FUNCTION ( __name,
__ifacecommand,
__argname )
Value:
TC_KVS_FUNCTION(__name) \
{ \
kvs_int_t arg; \
KVSM_PARAMETERS_BEGIN(c) \
KVSM_PARAMETER(__argname, KVS_PT_INT, 0, arg) \
KVSM_PARAMETERS_END(c) \
TC_KVS_FAIL_ON_NO_INTERFACE \
QString szRet = TorrentInterface::selected()->__ifacecommand(arg); \
c->returnValue()->setString(szRet); \
return true; \
}

◆ TC_KVS_STRINGRET_INT_INT_FUNCTION

#define TC_KVS_STRINGRET_INT_INT_FUNCTION ( __name,
__ifacecommand,
__argname1,
__argname2 )
Value:
TC_KVS_FUNCTION(__name) \
{ \
kvs_int_t arg1; \
kvs_int_t arg2; \
KVSM_PARAMETERS_BEGIN(c) \
KVSM_PARAMETER(__argname1, KVS_PT_INT, 0, arg1) \
KVSM_PARAMETER(__argname2, KVS_PT_INT, 0, arg2) \
KVSM_PARAMETERS_END(c) \
TC_KVS_FAIL_ON_NO_INTERFACE \
QString szRet = TorrentInterface::selected()->__ifacecommand(arg1, arg2); \
c->returnValue()->setString(szRet); \
return true; \
}

Function Documentation

◆ auto_detect_torrent_client()

◆ TC_KVS_COMMAND() [1/2]

TC_KVS_COMMAND ( detect )

◆ TC_KVS_COMMAND() [2/2]

◆ TC_KVS_FUNCTION() [1/2]

TC_KVS_FUNCTION ( client )

◆ TC_KVS_FUNCTION() [2/2]

TC_KVS_FUNCTION ( clientList )

References d, g_pDescriptorList, and pArray.

◆ torrent_module_can_unload()

static bool torrent_module_can_unload ( KviModule * )
static

◆ torrent_module_cleanup()

static bool torrent_module_cleanup ( KviModule * )
static

References g_pDescriptorList.

◆ torrent_module_ctrl()

static bool torrent_module_ctrl ( KviModule * ,
const char * ,
void *  )
static

◆ torrent_module_init()

Variable Documentation

◆ g_pDescriptorList

KviPointerList<TorrentInterfaceDescriptor>* g_pDescriptorList = nullptr
static