aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Elvio Basello2008-04-08 01:40:28 +0000
committerGravatar Elvio Basello2008-04-08 01:40:28 +0000
commitd97e538eb31a558aa24fda748cc4bd1b6e0c82a0 (patch)
tree5a662afdff8d2627bc82e547d17633e6e46cc216
parentcode clean and fixes (diff)
downloadKVIrc-d97e538eb31a558aa24fda748cc4bd1b6e0c82a0.tar.gz
KVIrc-d97e538eb31a558aa24fda748cc4bd1b6e0c82a0.tar.bz2
KVIrc-d97e538eb31a558aa24fda748cc4bd1b6e0c82a0.zip
ported some modules
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@1423 17fca916-40b9-46aa-a4ea-0a15b648b75c
-rw-r--r--TODO-Qt411
-rw-r--r--src/modules/CMakeLists.txt7
-rw-r--r--src/modules/setup/libkvisetup.cpp2
-rw-r--r--src/modules/setup/setupwizard.cpp4
-rw-r--r--src/modules/setup/setupwizard.h9
-rw-r--r--src/modules/tmphighlight/libkvitmphighlight.cpp5
-rw-r--r--src/modules/toolbar/libkvitoolbar.cpp16
-rw-r--r--src/modules/toolbareditor/libkvitoolbareditor.cpp5
-rw-r--r--src/modules/toolbareditor/toolbareditor.cpp8
-rw-r--r--src/modules/toolbareditor/toolbareditor.h16
-rw-r--r--src/modules/torrent/libkvitorrent.cpp16
-rw-r--r--src/modules/torrent/tc_interface.cpp1
-rw-r--r--src/modules/torrent/tc_interface.h8
-rw-r--r--src/modules/torrent/tc_ktorrentdcopinterface.cpp896
-rw-r--r--src/modules/torrent/tc_ktorrentdcopinterface.h172
-rw-r--r--src/modules/torrent/tc_statusbarapplet.cpp42
-rw-r--r--src/modules/torrent/tc_statusbarapplet.h32
-rw-r--r--src/modules/url/libkviurl.cpp51
-rw-r--r--src/modules/url/libkviurl.h35
-rw-r--r--src/modules/window/libkviwindow.cpp11
-rw-r--r--src/modules/window/userwindow.cpp1
21 files changed, 659 insertions, 689 deletions
diff --git a/TODO-Qt4 b/TODO-Qt4
index dfbe692ae..241b8c9e4 100644
--- a/TODO-Qt4
+++ b/TODO-Qt4
@@ -82,16 +82,7 @@ src/modules
objects
options
reguser - q3support in dialog.*
-
- setup
-
theme
tip
-
- tmphighlight
- toolbar
- toolbareditor
- torrent
+ torrent - broken
trayicon
- url
- window \ No newline at end of file
diff --git a/src/modules/CMakeLists.txt b/src/modules/CMakeLists.txt
index 980ece711..6e0f5adc2 100644
--- a/src/modules/CMakeLists.txt
+++ b/src/modules/CMakeLists.txt
@@ -33,17 +33,18 @@ SUBDIRS(
objects options
popupeditor
raweditor regchan reguser rijndael
- setup sharedfile sharedfileswindow snd socketspy spaste str system
+ setup sharedfile sharedfileswindow snd
+ socketspy spaste str system
texticons term theme tip tmphighlight toolbar toolbareditor trayicon
url
window
# broken modules
- # notifier, options, torrent
+ # torrent
# modules to deprecate ?
# perl, perlcore
# forgotten ?
- # clock iograph
+ # language offer
)
diff --git a/src/modules/setup/libkvisetup.cpp b/src/modules/setup/libkvisetup.cpp
index 49d629eb3..e20cf4546 100644
--- a/src/modules/setup/libkvisetup.cpp
+++ b/src/modules/setup/libkvisetup.cpp
@@ -147,7 +147,7 @@ static bool setup_module_can_unload(KviModule *m)
}
KVIRC_MODULE(
- "Setup wizard",
+ "Setup Wizard",
"4.0.0",
"Szymon Stefanek <pragma at kvirc dot net>",
"First-time-run setup wizard",
diff --git a/src/modules/setup/setupwizard.cpp b/src/modules/setup/setupwizard.cpp
index 7a7bb87c6..d0c7d26aa 100644
--- a/src/modules/setup/setupwizard.cpp
+++ b/src/modules/setup/setupwizard.cpp
@@ -767,7 +767,6 @@ void KviSetupWizard::chooseIncomingPath()
}
}
-
void KviSetupWizard::makeLink()
{
#ifdef COMPILE_ON_WINDOWS
@@ -857,7 +856,7 @@ void KviSetupWizard::makeLink()
"Exec=kvirc -m %u\n" \
"Icon=kvirc\n" \
"MapNotify=true\n" \
- "Name=KVIrc 3\n" \
+ "Name=KVIrc 4\n" \
"Terminal=false\n" \
"Type=Application\n" \
"X-KDE-SubstituteUID=false\n";
@@ -1131,4 +1130,3 @@ void KviSetupWizard::accept()
#ifndef COMPILE_USE_STANDALONE_MOC_SOURCES
#include "setupwizard.moc"
#endif //!COMPILE_USE_STANDALONE_MOC_SOURCES
-
diff --git a/src/modules/setup/setupwizard.h b/src/modules/setup/setupwizard.h
index 526292e21..fbd6bc9b9 100644
--- a/src/modules/setup/setupwizard.h
+++ b/src/modules/setup/setupwizard.h
@@ -27,7 +27,6 @@
#include "kvi_settings.h"
#include "kvi_string.h"
#include "kvi_selectors.h"
-
#include <kvi_tal_wizard.h>
#include "kvi_tal_vbox.h"
#include "kvi_tal_hbox.h"
@@ -39,18 +38,12 @@
#include <QRadioButton>
#include <QComboBox>
#include <QCheckBox>
-/*
-#include <Q3ButtonGroup>
-#define KviTalVButtonGroup Q3VButtonGroup
-*/
-/* FIXME: Qt4 */
#include <QGroupBox>
#define KviTalVButtonGroup QGroupBox
-
-
class KviSetupWizard;
+
class KviSetupPage : public QWidget
{
Q_OBJECT
diff --git a/src/modules/tmphighlight/libkvitmphighlight.cpp b/src/modules/tmphighlight/libkvitmphighlight.cpp
index 9a2d39e68..9f4e2e1ee 100644
--- a/src/modules/tmphighlight/libkvitmphighlight.cpp
+++ b/src/modules/tmphighlight/libkvitmphighlight.cpp
@@ -22,7 +22,6 @@
#include "kvi_module.h"
-
#include "kvi_locale.h"
#include "kvi_channel.h"
@@ -49,7 +48,7 @@
// tmphighlight.add
//-------------------------------------------
static bool tmphighlight_kvs_cmd_add(KviKvsModuleCommandCall * c)
-{
+{
QString szNick;
KVSM_PARAMETERS_BEGIN(c)
@@ -164,7 +163,7 @@ static bool tmphighlight_module_can_unload(KviModule *m)
//-------------------------------------------------
KVIRC_MODULE(
"TmpHighlight", // module name
- "1.0.0", // module version
+ "4.0.0", // module version
" (C) 2002 Juanjo Alvarez (juanjux@yahoo.es)", // author & (C)
"Temporal Highlightining of channel users",
tmphighlight_module_init,
diff --git a/src/modules/toolbar/libkvitoolbar.cpp b/src/modules/toolbar/libkvitoolbar.cpp
index dba61ce2f..61dbe0948 100644
--- a/src/modules/toolbar/libkvitoolbar.cpp
+++ b/src/modules/toolbar/libkvitoolbar.cpp
@@ -23,9 +23,7 @@
//=============================================================================
#include "kvi_module.h"
-
#include "kvi_locale.h"
-
#include "kvi_window.h"
#include "kvi_app.h"
#include "kvi_error.h"
@@ -301,7 +299,7 @@ static bool toolbar_kvs_cmd_hide(KviKvsModuleCommandCall * c)
static bool toolbar_kvs_fnc_exists(KviKvsModuleFunctionCall * c)
-{
+{
QString szId;
KVSM_PARAMETERS_BEGIN(c)
KVSM_PARAMETER("id",KVS_PT_NONEMPTYSTRING,0,szId)
@@ -329,7 +327,7 @@ static bool toolbar_kvs_fnc_exists(KviKvsModuleFunctionCall * c)
*/
static bool toolbar_kvs_fnc_isVisible(KviKvsModuleFunctionCall * c)
-{
+{
QString szId;
KVSM_PARAMETERS_BEGIN(c)
KVSM_PARAMETER("id",KVS_PT_NONEMPTYSTRING,0,szId)
@@ -356,7 +354,7 @@ static bool toolbar_kvs_fnc_isVisible(KviKvsModuleFunctionCall * c)
*/
static bool toolbar_kvs_fnc_list(KviKvsModuleFunctionCall * c)
-{
+{
KviKvsArray * a = new KviKvsArray();
KviPointerHashTableIterator<QString,KviCustomToolBarDescriptor> it(*(KviCustomToolBarManager::instance()->descriptors()));
@@ -534,7 +532,7 @@ static bool toolbar_kvs_cmd_additem(KviKvsModuleCommandCall * c)
*/
static bool toolbar_kvs_fnc_items(KviKvsModuleFunctionCall * c)
-{
+{
QString szId;
KVSM_PARAMETERS_BEGIN(c)
KVSM_PARAMETER("id",KVS_PT_NONEMPTYSTRING,0,szId)
@@ -565,8 +563,6 @@ static bool toolbar_kvs_fnc_items(KviKvsModuleFunctionCall * c)
return true;
}
-
-
static bool toolbar_module_init(KviModule * m)
{
KVSM_REGISTER_SIMPLE_COMMAND(m,"create",toolbar_kvs_cmd_create)
@@ -591,8 +587,8 @@ static bool toolbar_module_cleanup(KviModule *m)
}
KVIRC_MODULE(
- "toolbar", // module name
- "1.0.0", // module version
+ "Toolbar", // module name
+ "4.0.0", // module version
"Copyright (C) 2002 Szymon Stefanek (pragma at kvirc dot net)", // author & (C)
"Interface to the scriptable toolbars",
toolbar_module_init,
diff --git a/src/modules/toolbareditor/libkvitoolbareditor.cpp b/src/modules/toolbareditor/libkvitoolbareditor.cpp
index a90b88c47..6cff8c06c 100644
--- a/src/modules/toolbareditor/libkvitoolbareditor.cpp
+++ b/src/modules/toolbareditor/libkvitoolbareditor.cpp
@@ -23,10 +23,9 @@
//=============================================================================
#include "toolbareditor.h"
-#include "kvi_module.h"
+#include "kvi_module.h"
#include "kvi_locale.h"
-
#include "kvi_frame.h"
#include "kvi_actionmanager.h"
#include "kvi_config.h"
@@ -86,7 +85,7 @@ static bool toolbareditor_module_cleanup(KviModule *m)
KVIRC_MODULE(
"ToolbarEditor", // module name
- "1.0.0", // module version
+ "4.0.0", // module version
"Copyright (C) 2002 Szymon Stefanek (pragma at kvirc dot net)", // author & (C)
"Editor for the scriptable toolbars",
toolbareditor_module_init,
diff --git a/src/modules/toolbareditor/toolbareditor.cpp b/src/modules/toolbareditor/toolbareditor.cpp
index e9b8bbf90..b2de12304 100644
--- a/src/modules/toolbareditor/toolbareditor.cpp
+++ b/src/modules/toolbareditor/toolbareditor.cpp
@@ -115,7 +115,6 @@ void KviTrashcanLabel::dragEnterEvent(QDragEnterEvent * e)
}
-
KviCustomToolBarPropertiesDialog::KviCustomToolBarPropertiesDialog(QWidget * p,const QString &szText,const QString &szId,const QString &szLabel,const QString &szIconId)
: QDialog(p)
{
@@ -187,8 +186,6 @@ KviCustomToolBarPropertiesDialog::KviCustomToolBarPropertiesDialog(QWidget * p,c
g->setRowStretch(0,1);
g->setColStretch(2,1);
-
-
}
KviCustomToolBarPropertiesDialog::~KviCustomToolBarPropertiesDialog()
@@ -223,7 +220,6 @@ void KviCustomToolBarPropertiesDialog::iconButtonClicked()
iconSelected(s);
}
-
void KviCustomToolBarPropertiesDialog::labelTextChanged(const QString &s)
{
if(m_szOriginalId.isEmpty())
@@ -233,7 +229,6 @@ void KviCustomToolBarPropertiesDialog::labelTextChanged(const QString &s)
}
}
-
void KviCustomToolBarPropertiesDialog::okClicked()
{
if(m_szLabel.isEmpty())
@@ -362,7 +357,6 @@ void KviCustomizeToolBarsDialog::showEvent(QShowEvent * e)
// move(x,y);
}
-
void KviCustomizeToolBarsDialog::deleteToolBar()
{
KviCustomToolBar * t = KviActionManager::currentToolBar();
@@ -451,7 +445,6 @@ void KviCustomizeToolBarsDialog::exportToolBar()
{
QMessageBox::warning(this,__tr2qs("Write Failed - KVIrc"),__tr2qs("Unable to write to the toolbar file."),__tr2qs("OK"));
}
-
}
void KviCustomizeToolBarsDialog::renameToolBar()
@@ -532,4 +525,3 @@ void KviCustomizeToolBarsDialog::closeEvent(QCloseEvent * e)
e->ignore();
delete this;
}
-
diff --git a/src/modules/toolbareditor/toolbareditor.h b/src/modules/toolbareditor/toolbareditor.h
index fe4623e96..c99354950 100644
--- a/src/modules/toolbareditor/toolbareditor.h
+++ b/src/modules/toolbareditor/toolbareditor.h
@@ -25,14 +25,19 @@
//=============================================================================
#include "kvi_settings.h"
-#include <qwidget.h>
-#include <qlabel.h>
-#include <qdialog.h>
-#include <qcolor.h>
+#include <QWidget>
+#include <QLabel>
+#include <QDialog>
+#include <QColor>
+
+class QTimer;
+class QLineEdit;
+class QPushButton;
class QPushButton;
class KviActionDrawer;
+
class KviCustomizeToolBarsDialog : public QDialog
{
Q_OBJECT
@@ -62,8 +67,6 @@ protected slots:
void currentToolBarChanged();
};
-class QLineEdit;
-class QPushButton;
class KviCustomToolBarPropertiesDialog : public QDialog
{
@@ -95,7 +98,6 @@ protected:
void iconSelected(const QString &szIconId);
};
-class QTimer;
class KviTrashcanLabel : public QLabel
{
diff --git a/src/modules/torrent/libkvitorrent.cpp b/src/modules/torrent/libkvitorrent.cpp
index 557cffd77..ce55147ac 100644
--- a/src/modules/torrent/libkvitorrent.cpp
+++ b/src/modules/torrent/libkvitorrent.cpp
@@ -22,18 +22,16 @@
//
//=============================================================================
-#include "kvi_module.h"
-#include "kvi_options.h"
-#include "kvi_frame.h"
-
#include "tc_interface.h"
#include "tc_ktorrentdcopinterface.h"
#include "tc_statusbarapplet.h"
+#include "kvi_module.h"
+#include "kvi_options.h"
+#include "kvi_frame.h"
#include "kvi_locale.h"
#include "kvi_out.h"
-
static KviPointerList<KviTorrentInterfaceDescriptor> * g_pDescriptorList = 0;
static KviTorrentInterface *auto_detect_torrent_client(KviWindow * pOut = 0)
@@ -870,7 +868,7 @@ static bool torrent_module_can_unload( KviModule * m )
static bool torrent_module_ctrl(KviModule * m,const char * operation,void * param)
{
- debug("torrent module ctrl");
+ qDebug("torrent module ctrl");
/* if(kvi_strEqualCI(operation,"getAvailableMediaPlayers"))
{
// we expect param to be a pointer to QStringList
@@ -890,11 +888,9 @@ static bool torrent_module_ctrl(KviModule * m,const char * operation,void * para
return false;
}
-
-
KVIRC_MODULE(
- "torrent",
- "1.0.0",
+ "Torrent",
+ "4.0.0",
"Copyright (C) 2007 Alexander Stillich (torque at pltn dot org)",
"Interface to various torrent clients",
torrent_module_init,
diff --git a/src/modules/torrent/tc_interface.cpp b/src/modules/torrent/tc_interface.cpp
index 1c960adf3..2379d3037 100644
--- a/src/modules/torrent/tc_interface.cpp
+++ b/src/modules/torrent/tc_interface.cpp
@@ -26,6 +26,7 @@
//=============================================================================
#include "tc_interface.h"
+
#include "kvi_locale.h"
KviTorrentInterface *KviTorrentInterface::m_selected = 0;
diff --git a/src/modules/torrent/tc_interface.h b/src/modules/torrent/tc_interface.h
index 537dd2c84..272ff07cf 100644
--- a/src/modules/torrent/tc_interface.h
+++ b/src/modules/torrent/tc_interface.h
@@ -30,13 +30,12 @@
#include "kvi_settings.h"
#include "kvi_qstring.h"
-#include <qobject.h>
+
+#include <QObject>
class KviTorrentInterface : public QObject
{
-
public:
-
KviTorrentInterface() {}
virtual ~KviTorrentInterface() {}
@@ -101,9 +100,7 @@ public:
static KviTorrentInterface *selected() { return m_selected; }
protected:
-
QString m_lastError;
-
static KviTorrentInterface *m_selected;
};
@@ -161,4 +158,3 @@ public:
}
#endif // _TC_INTERFACE_H_
-
diff --git a/src/modules/torrent/tc_ktorrentdcopinterface.cpp b/src/modules/torrent/tc_ktorrentdcopinterface.cpp
index fd845cb12..335bb71a2 100644
--- a/src/modules/torrent/tc_ktorrentdcopinterface.cpp
+++ b/src/modules/torrent/tc_ktorrentdcopinterface.cpp
@@ -2,7 +2,7 @@
//
// Common interface for BitTorrent clients.
//
-// File : torr_ktorrentdcopinterface.cpp
+// File : tc_ktorrentdcopinterface.cpp
// Creation date : Fri Jan 1 15:42:25 2007 GMT by Alexander Stillich
//
// This file is part of the KVirc irc client distribution
@@ -25,476 +25,472 @@
//
//=============================================================================
-#ifdef COMPILE_KDE_SUPPORT
-
-#include "kvi_app.h"
-
-
-#include "dcopclient.h" // <-- this include should be hidden in kvilib
-
#include "tc_ktorrentdcopinterface.h"
-
-#include "kvi_locale.h"
-#include <qtimer.h>
-
-TORR_IMPLEMENT_DESCRIPTOR(
- KviKTorrentDCOPInterface,
- "ktorrentdcop",
- __tr2qs_ctx(
- "An interface to KDE's excellent KTorrent client.\n" \
- "Download it from http://www.ktorrent.org\n",
- "torrent"
+#ifdef COMPILE_KDE_SUPPORT
+ #include "kvi_app.h"
+ #include "kvi_locale.h"
+
+ #include "dcopclient.h" // <-- this include should be hidden in kvilib
+
+ #include <QTimer>
+
+ TORR_IMPLEMENT_DESCRIPTOR(
+ KviKTorrentDCOPInterface,
+ "ktorrentdcop",
+ __tr2qs_ctx(
+ "An interface to KDE's excellent KTorrent client.\n" \
+ "Download it from http://www.ktorrent.org\n",
+ "torrent"
+ )
)
-)
-
-#define ERROR_MSG \
- QCString msg; \
- if (!findRunningApp(m_szAppId)) \
- msg = "KTorrent's isn't running!"; \
- else \
- msg = "Something's wrong here! KTorrent's DCOP interface has probably changed."; \
- m_lastError = __tr2qs_ctx(QString(msg), "torrent"); \
- debug("%s (%s:%d): %s", __PRETTY_FUNCTION__, __FILE__, __LINE__, (const char*)msg); \
-
-#define ERROR_MSG_RANGE(I, SIZE) \
- KviQString::sprintf(m_lastError, __tr2qs_ctx("Index out of range: %d [0-%d]!", "torrent"), I, (SIZE>0)?(SIZE-1):0); \
- debug("%s (%s:%d): Index out of range: %d [0-%d]!", __PRETTY_FUNCTION__ , __FILE__, __LINE__, I, (SIZE>0)?(SIZE-1):0);
-
-#define ERROR_RET_BOOL \
- { \
- ERROR_MSG \
- return false; \
+
+ #define ERROR_MSG \
+ QCString msg; \
+ if (!findRunningApp(m_szAppId)) \
+ msg = "KTorrent's isn't running!"; \
+ else \
+ msg = "Something's wrong here! KTorrent's DCOP interface has probably changed."; \
+ m_lastError = __tr2qs_ctx(QString(msg), "torrent"); \
+ debug("%s (%s:%d): %s", __PRETTY_FUNCTION__, __FILE__, __LINE__, (const char*)msg); \
+
+ #define ERROR_MSG_RANGE(I, SIZE) \
+ KviQString::sprintf(m_lastError, __tr2qs_ctx("Index out of range: %d [0-%d]!", "torrent"), I, (SIZE>0)?(SIZE-1):0); \
+ debug("%s (%s:%d): Index out of range: %d [0-%d]!", __PRETTY_FUNCTION__ , __FILE__, __LINE__, I, (SIZE>0)?(SIZE-1):0);
+
+ #define ERROR_RET_BOOL \
+ { \
+ ERROR_MSG \
+ return false; \
+ }
+
+ #define ERROR_RET_NUM \
+ { \
+ ERROR_MSG \
+ return -1; \
+ }
+
+ // TODO: unused?
+ #define ERROR_RET_STRING \
+ { \
+ ERROR_MSG \
+ return ""; \
+ }
+
+ #define ERROR_RET_VOID \
+ { \
+ ERROR_MSG \
+ return; \
+ }
+
+ #define CHECK_RANGE_BOOL(I, SIZE) \
+ if (I<0 || I>=SIZE) \
+ { \
+ ERROR_MSG_RANGE(I, SIZE) \
+ return false; \
+ }
+
+ #define CHECK_RANGE_INT(I, SIZE) \
+ if (I<0 || I>=SIZE) \
+ { \
+ ERROR_MSG_RANGE(I, SIZE) \
+ return -1; \
+ }
+
+ #define CHECK_RANGE_STRING(I, SIZE) \
+ if (I<0 || I>=SIZE) \
+ { \
+ ERROR_MSG_RANGE(I, SIZE) \
+ return ""; \
+ }
+
+ KviKTorrentDCOPInterface::KviKTorrentDCOPInterface()
+ : KviDCOPHelper(false, "ktorrent")
+ {
+ printf("KviKTorrentDCOPInterface\n");
+
+ QTimer *timer = new QTimer(this);
+ connect(timer, SIGNAL(timeout()), this, SLOT(slotTimer()));
+ timer->start(250, FALSE);
+
+ // make sure we have a list of files,
+ // otherwise functions dealing would
+ // fail if called the first time
+ slotTimer();
}
-
-#define ERROR_RET_NUM \
- { \
- ERROR_MSG \
- return -1; \
+
+ KviKTorrentDCOPInterface::~KviKTorrentDCOPInterface()
+ {
+ printf("~KviKTorrentDCOPInterface\n");
}
-
-// TODO: unused?
-#define ERROR_RET_STRING \
- { \
- ERROR_MSG \
- return ""; \
+
+ void KviKTorrentDCOPInterface::slotTimer()
+ {
+ if (!findRunningApp(m_szAppId))
+ return;
+
+ m_ti.clear();
+
+ KviValueList<int> ret;
+ if (!qvalueListIntRetIntDCOPCall("KTorrent", "getTorrentNumbers(int)", ret, 0))
+ ERROR_RET_VOID
+
+ for (int i=0; i<ret.size(); i++)
+ {
+ KviQCStringList info;
+ if (!qcstringListRetIntDCOPCall("KTorrent", "getTorrentInfo(int)", info, ret[i]))
+ ERROR_RET_VOID
+
+ if (info.size() == 0)
+ continue;
+
+ TorrentInfo item;
+ if (!makeTorrentInfo(item, info))
+ return;
+
+ item.num = ret[i];
+ m_ti.append(item);
+ }
+
+ qHeapSort(m_ti);
}
-
-#define ERROR_RET_VOID \
- { \
- ERROR_MSG \
- return; \
+
+ int KviKTorrentDCOPInterface::detect()
+ {
+ if (!findRunningApp(m_szAppId))
+ return 0;
+
+ return 100;
}
-
-#define CHECK_RANGE_BOOL(I, SIZE) \
- if (I<0 || I>=SIZE) \
- { \
- ERROR_MSG_RANGE(I, SIZE) \
- return false; \
+
+ bool makeSize(float &sz, const QString &s, const QString &u)
+ {
+ bool ok;
+ sz = s.toFloat(&ok);
+ if (!ok)
+ return false;
+
+ if (u == "B")
+ ;
+ else
+ if (u == "KB")
+ sz = sz * 1024.0;
+ else
+ if (u == "MB")
+ sz = sz * 1024.0 * 1024.0;
+ else
+ if (u == "GB")
+ sz = sz * 1024.0 * 1024.0 * 1024.0;
+ else
+ return false;
+
+ return true;
}
-
-#define CHECK_RANGE_INT(I, SIZE) \
- if (I<0 || I>=SIZE) \
- { \
- ERROR_MSG_RANGE(I, SIZE) \
- return -1; \
+
+ bool KviKTorrentDCOPInterface::start(int i)
+ {
+ CHECK_RANGE_BOOL(i, m_ti.size())
+
+ debug("starting %s [%d]", (const char*)m_ti[i].name, m_ti[i].num);
+ if (!voidRetIntDCOPCall("KTorrent", "start(int)", m_ti[i].num))
+ ERROR_RET_BOOL
+
+ return true;
}
-
-#define CHECK_RANGE_STRING(I, SIZE) \
- if (I<0 || I>=SIZE) \
- { \
- ERROR_MSG_RANGE(I, SIZE) \
- return ""; \
+
+ bool KviKTorrentDCOPInterface::stop(int i)
+ {
+ CHECK_RANGE_BOOL(i, m_ti.size())
+
+ debug("stopping %s [%d]", (const char*)m_ti[i].name, m_ti[i].num);
+ if (!voidRetIntBoolDCOPCall("KTorrent", "stop(int, bool)", m_ti[i].num, true))
+ ERROR_RET_BOOL
+
+ return true;
}
-
-KviKTorrentDCOPInterface::KviKTorrentDCOPInterface()
- : KviDCOPHelper(false, "ktorrent")
-{
- printf("KviKTorrentDCOPInterface\n");
-
- QTimer *timer = new QTimer(this);
- connect(timer, SIGNAL(timeout()), this, SLOT(slotTimer()));
- timer->start(250, FALSE);
-
- // make sure we have a list of files,
- // otherwise functions dealing would
- // fail if called the first time
- slotTimer();
-}
-
-KviKTorrentDCOPInterface::~KviKTorrentDCOPInterface()
-{
- printf("~KviKTorrentDCOPInterface\n");
-}
-
-void KviKTorrentDCOPInterface::slotTimer()
-{
- if (!findRunningApp(m_szAppId))
- return;
-
- m_ti.clear();
-
- KviValueList<int> ret;
- if (!qvalueListIntRetIntDCOPCall("KTorrent", "getTorrentNumbers(int)", ret, 0))
- ERROR_RET_VOID
-
- for (int i=0; i<ret.size(); i++)
+
+ bool KviKTorrentDCOPInterface::announce(int i)
{
- KviQCStringList info;
- if (!qcstringListRetIntDCOPCall("KTorrent", "getTorrentInfo(int)", info, ret[i]))
- ERROR_RET_VOID
-
- if (info.size() == 0)
- continue;
-
- TorrentInfo item;
- if (!makeTorrentInfo(item, info))
- return;
-
- item.num = ret[i];
- m_ti.append(item);
+ CHECK_RANGE_BOOL(i, m_ti.size())
+
+ debug("announcing %s [%d]", (const char*)m_ti[i].name, m_ti[i].num);
+ if (!voidRetIntDCOPCall("KTorrent", "announce(int)", m_ti[i].num))
+ ERROR_RET_BOOL
+ return true;
}
-
- qHeapSort(m_ti);
-}
-
-int KviKTorrentDCOPInterface::detect()
-{
- if (!findRunningApp(m_szAppId))
- return 0;
-
- return 100;
-}
-
-bool makeSize(float &sz, const QString &s, const QString &u)
-{
- bool ok;
- sz = s.toFloat(&ok);
- if (!ok)
- return false;
-
- if (u == "B")
- ;
- else
- if (u == "KB")
- sz = sz * 1024.0;
- else
- if (u == "MB")
- sz = sz * 1024.0 * 1024.0;
- else
- if (u == "GB")
- sz = sz * 1024.0 * 1024.0 * 1024.0;
- else
- return false;
-
- return true;
-}
-
-bool KviKTorrentDCOPInterface::start(int i)
-{
- CHECK_RANGE_BOOL(i, m_ti.size())
-
- debug("starting %s [%d]", (const char*)m_ti[i].name, m_ti[i].num);
- if (!voidRetIntDCOPCall("KTorrent", "start(int)", m_ti[i].num))
- ERROR_RET_BOOL
-
- return true;
-}
-
-bool KviKTorrentDCOPInterface::stop(int i)
-{
- CHECK_RANGE_BOOL(i, m_ti.size())
-
- debug("stopping %s [%d]", (const char*)m_ti[i].name, m_ti[i].num);
- if (!voidRetIntBoolDCOPCall("KTorrent", "stop(int, bool)", m_ti[i].num, true))
- ERROR_RET_BOOL
-
- return true;
-}
-
-bool KviKTorrentDCOPInterface::announce(int i)
-{
- CHECK_RANGE_BOOL(i, m_ti.size())
-
- debug("announcing %s [%d]", (const char*)m_ti[i].name, m_ti[i].num);
- if (!voidRetIntDCOPCall("KTorrent", "announce(int)", m_ti[i].num))
- ERROR_RET_BOOL
- return true;
-}
-
-QString KviKTorrentDCOPInterface::state(int i)
-{
- CHECK_RANGE_STRING(i, m_ti.size())
-
- return m_ti[i].state;
-}
-
-QString KviKTorrentDCOPInterface::name(int i)
-{
- CHECK_RANGE_STRING(i, m_ti.size())
- return m_ti[i].name;
-}
-
-int KviKTorrentDCOPInterface::fileCount(int i)
-{
- CHECK_RANGE_INT(i, m_ti.size())
-
- int ret;
- if (!intRetIntDCOPCall("KTorrent", "getFileCount(int)", ret, m_ti[i].num))
- ERROR_RET_NUM
-
- return ret;
-}
-
-QString KviKTorrentDCOPInterface::fileName(int i, int file)
-{
- CHECK_RANGE_STRING(i, m_ti.size())
-
- QCStringList ret;
- if (!qcstringListRetIntDCOPCall("KTorrent", "getFileNames(int)", ret, m_ti[i].num))
- ERROR_RET_STRING
-
- CHECK_RANGE_STRING(file, ret.size())
-
- return ret[file];
-}
-
-QString KviKTorrentDCOPInterface::filePriority(int i, int file)
-{
- CHECK_RANGE_STRING(i, m_ti.size())
-
- QValueList<int> ret;
- if (!qvalueListIntRetIntDCOPCall("KTorrent", "getFilePriorities(int)",ret, m_ti[i].num))
+ QString KviKTorrentDCOPInterface::state(int i)
+ {
+ CHECK_RANGE_STRING(i, m_ti.size())
+
+ return m_ti[i].state;
+ }
+
+ QString KviKTorrentDCOPInterface::name(int i)
+ {
+ CHECK_RANGE_STRING(i, m_ti.size())
+
+ return m_ti[i].name;
+ }
+
+ int KviKTorrentDCOPInterface::fileCount(int i)
+ {
+ CHECK_RANGE_INT(i, m_ti.size())
+
+ int ret;
+ if (!intRetIntDCOPCall("KTorrent", "getFileCount(int)", ret, m_ti[i].num))
+ ERROR_RET_NUM
+
+ return ret;
+ }
+
+ QString KviKTorrentDCOPInterface::fileName(int i, int file)
+ {
+ CHECK_RANGE_STRING(i, m_ti.size())
+
+ QCStringList ret;
+ if (!qcstringListRetIntDCOPCall("KTorrent", "getFileNames(int)", ret, m_ti[i].num))
+ ERROR_RET_STRING
+
+ CHECK_RANGE_STRING(file, ret.size())
+
+ return ret[file];
+ }
+
+ QString KviKTorrentDCOPInterface::filePriority(int i, int file)
+ {
+ CHECK_RANGE_STRING(i, m_ti.size())
+
+ QValueList<int> ret;
+ if (!qvalueListIntRetIntDCOPCall("KTorrent", "getFilePriorities(int)",ret, m_ti[i].num))
+ ERROR_RET_STRING
+
+ CHECK_RANGE_STRING(file, ret.size())
+
+ debug("prio: %d", ret[file]);
+ switch (ret[file])
+ {
+ case 1: return "low";
+ case 2: return "normal";
+ case 3: return "high";
+ }
+
ERROR_RET_STRING
-
- CHECK_RANGE_STRING(file, ret.size())
-
- debug("prio: %d", ret[file]);
- switch (ret[file])
+ }
+
+ bool KviKTorrentDCOPInterface::setFilePriority(int i, int file, const QString &prio)
{
- case 1: return "low";
- case 2: return "normal";
- case 3: return "high";
+ CHECK_RANGE_BOOL(i, m_ti.size())
+
+ int prion;
+ if (prio == "low")
+ prion = 1;
+ else
+ if (prio == "normal")
+ prion = 2;
+ else
+ if (prio == "high")
+ prion = 1;
+ else
+ ERROR_RET_BOOL
+
+ if (!voidRetIntIntIntDCOPCall("KTorrent", "setFilePriority(int,int,int)", m_ti[i].num, file, prion))
+ ERROR_RET_BOOL
+
+ return true;
}
-
- ERROR_RET_STRING
-}
-
-bool KviKTorrentDCOPInterface::setFilePriority(int i, int file, const QString &prio)
-{
- CHECK_RANGE_BOOL(i, m_ti.size())
-
- int prion;
- if (prio == "low")
- prion = 1;
- else
- if (prio == "normal")
- prion = 2;
- else
- if (prio == "high")
- prion = 1;
- else
- ERROR_RET_BOOL
-
- if (!voidRetIntIntIntDCOPCall("KTorrent", "setFilePriority(int,int,int)", m_ti[i].num, file, prion))
- ERROR_RET_BOOL
-
- return true;
-}
-
-bool KviKTorrentDCOPInterface::startAll()
-{
- if (!voidRetIntDCOPCall("KTorrent", "startAll(int)", 3))
- ERROR_RET_BOOL
-
- return true;
-}
-
-bool KviKTorrentDCOPInterface::stopAll()
-{
- if (!voidRetIntDCOPCall("KTorrent", "stopAll(int)", 3))
- ERROR_RET_BOOL
-
- return true;
-}
-
-int KviKTorrentDCOPInterface::count()
-{
- return m_ti.size();
-}
-
-float KviKTorrentDCOPInterface::speedUp()
-{
- KviQCStringList ret;
- if (!qcstringListRetVoidDCOPCall("KTorrent", "getInfo()", ret))
- ERROR_RET_NUM
-
- QStringList tmp = QStringList::split(" ", ret[2]);
- if (tmp.size() != 8)
- ERROR_RET_NUM
-
- bool ok;
- float f = tmp[6].toFloat(&ok);
- if (!ok)
- ERROR_RET_NUM
-
- return f;
-}
-
-float KviKTorrentDCOPInterface::speedDown()
-{
- KviQCStringList ret;
- if (!qcstringListRetVoidDCOPCall("KTorrent", "getInfo()", ret))
- ERROR_RET_NUM
-
- QStringList tmp = QStringList::split(" ", ret[2]);
- if (tmp.size() != 8)
- ERROR_RET_NUM
-
- bool ok;
- float f = tmp[2].toFloat(&ok);
- if (!ok)
- ERROR_RET_NUM
-
- return f;
-}
-
-float KviKTorrentDCOPInterface::trafficUp()
-{
- KviQCStringList ret;
- if (!qcstringListRetVoidDCOPCall("KTorrent", "getInfo()", ret))
- ERROR_RET_NUM
-
- QStringList tmp = QStringList::split(" ", ret[1]);
- if (tmp.size() != 8)
- ERROR_RET_NUM
-
- float f;
- if (!makeSize(f, tmp[6], tmp[7]))
- ERROR_RET_NUM
-
- return f;
-}
-
-float KviKTorrentDCOPInterface::trafficDown()
-{
- KviQCStringList ret;
- if (!qcstringListRetVoidDCOPCall("KTorrent", "getInfo()", ret))
- ERROR_RET_NUM
-
- QStringList tmp = QStringList::split(" ", ret[1]);
- if (tmp.size() != 8)
- ERROR_RET_NUM
-
- float f;
- if (!makeSize(f, tmp[2], tmp[3]))
- ERROR_RET_NUM
-
- return f;
-}
-
-bool KviKTorrentDCOPInterface::makeTorrentInfo(TorrentInfo &ti, const KviQCStringList &ret)
-{
- if (ret.size() != 10)
- ERROR_RET_BOOL
-
- ti.name = ret[0];
- if (ret[1] == "Seeding")
- ti.state = "Seeding";
- else
- if (ret[1] == "Stalled")
- ti.state = "Stalled";
- else
- if (ret[1] == "Downloading")
- ti.state = "Downloading";
- else
- ti.state = "Stopped";
-
-
- QStringList tmp;
- tmp = QStringList::split(" ", ret[2]);
- if (tmp.size()!=2 || !makeSize(ti.trafficDown, tmp[0], tmp[1]))
- ERROR_RET_BOOL
-
- tmp = QStringList::split(" ", ret[3]);
- if (tmp.size()!=2 || !makeSize(ti.size, tmp[0], tmp[1]))
- ERROR_RET_BOOL
-
- tmp = QStringList::split(" ", ret[4]);
- if (tmp.size()!=2 || !makeSize(ti.trafficUp, tmp[0], tmp[1]))
- ERROR_RET_BOOL
-
-
- bool ok;
- tmp = QStringList::split(" ", ret[5]);
- if (tmp.size()!=2)
- ERROR_RET_BOOL
- ti.speedDown = tmp[0].toFloat(&ok);
- if (!ok)
- ERROR_RET_BOOL
-
- tmp = QStringList::split(" ", ret[6]);
- if (tmp.size()!=2)
- ERROR_RET_BOOL
- ti.speedUp = tmp[0].toFloat(&ok);
- if (!ok)
- ERROR_RET_BOOL
-
- // torrent name, status, downloaded, size, uploaded, down spd, up spd, none, peers, % complete
- ti.peers = ret[8].toInt(&ok);
- if (!ok)
- ERROR_RET_BOOL
-
- tmp = QStringList::split(" ", ret[9]);
- if (tmp.size()!=2)
- ERROR_RET_BOOL
- ti.percent = tmp[0].toFloat(&ok);
- if (!ok)
- ERROR_RET_BOOL
-
- return true;
-}
-
-int KviKTorrentDCOPInterface::maxUploadSpeed()
-{
- int ret;
- if (!intRetVoidDCOPCall("KTorrent", "maxUploadRate()", ret))
+ bool KviKTorrentDCOPInterface::startAll()
{
- ERROR_MSG
- return -1;
+ if (!voidRetIntDCOPCall("KTorrent", "startAll(int)", 3))
+ ERROR_RET_BOOL
+
+ return true;
}
- return ret;
-}
-
-int KviKTorrentDCOPInterface::maxDownloadSpeed()
-{
- int ret;
- if (!intRetVoidDCOPCall("KTorrent", "maxDownloadRate()", ret))
+
+ bool KviKTorrentDCOPInterface::stopAll()
{
- ERROR_MSG
- return -1;
+ if (!voidRetIntDCOPCall("KTorrent", "stopAll(int)", 3))
+ ERROR_RET_BOOL
+
+ return true;
}
- return ret;
-}
-
-bool KviKTorrentDCOPInterface::setMaxUploadSpeed(int kbytes_per_sec)
-{
- if (!voidRetIntDCOPCall("KTorrent", "setMaxUploadSpeed(int)", kbytes_per_sec))
- ERROR_RET_BOOL
- return true;
-}
-
-bool KviKTorrentDCOPInterface::setMaxDownloadSpeed(int kbytes_per_sec)
-{
- if (!voidRetIntDCOPCall("KTorrent", "setMaxDownloadSpeed(int)", kbytes_per_sec))
- ERROR_RET_BOOL
- return true;
-}
-
-
-#include "tc_ktorrentdcopinterface.moc"
+
+ int KviKTorrentDCOPInterface::count()
+ {
+ return m_ti.size();
+ }
+
+ float KviKTorrentDCOPInterface::speedUp()
+ {
+ KviQCStringList ret;
+ if (!qcstringListRetVoidDCOPCall("KTorrent", "getInfo()", ret))
+ ERROR_RET_NUM
+
+ QStringList tmp = QStringList::split(" ", ret[2]);
+ if (tmp.size() != 8)
+ ERROR_RET_NUM
+
+ bool ok;
+ float f = tmp[6].toFloat(&ok);
+ if (!ok)
+ ERROR_RET_NUM
+
+ return f;
+ }
+
+ float KviKTorrentDCOPInterface::speedDown()
+ {
+ KviQCStringList ret;
+ if (!qcstringListRetVoidDCOPCall("KTorrent", "getInfo()", ret))
+ ERROR_RET_NUM
+
+ QStringList tmp = QStringList::split(" ", ret[2]);
+ if (tmp.size() != 8)
+ ERROR_RET_NUM
+
+ bool ok;
+ float f = tmp[2].toFloat(&ok);
+ if (!ok)
+ ERROR_RET_NUM
+
+ return f;
+ }
+
+ float KviKTorrentDCOPInterface::trafficUp()
+ {
+ KviQCStringList ret;
+ if (!qcstringListRetVoidDCOPCall("KTorrent", "getInfo()", ret))
+ ERROR_RET_NUM
+
+ QStringList tmp = QStringList::split(" ", ret[1]);
+ if (tmp.size() != 8)
+ ERROR_RET_NUM
+
+ float f;
+ if (!makeSize(f, tmp[6], tmp[7]))
+ ERROR_RET_NUM
+
+ return f;
+ }
+
+ float KviKTorrentDCOPInterface::trafficDown()
+ {
+ KviQCStringList ret;
+ if (!qcstringListRetVoidDCOPCall("KTorrent", "getInfo()", ret))
+ ERROR_RET_NUM
+
+ QStringList tmp = QStringList::split(" ", ret[1]);
+ if (tmp.size() != 8)
+ ERROR_RET_NUM
+
+ float f;
+ if (!makeSize(f, tmp[2], tmp[3]))
+ ERROR_RET_NUM
+
+ return f;
+ }
+
+ bool KviKTorrentDCOPInterface::makeTorrentInfo(TorrentInfo &ti, const KviQCStringList &ret)
+ {
+ if (ret.size() != 10)
+ ERROR_RET_BOOL
+
+ ti.name = ret[0];
+ if (ret[1] == "Seeding")
+ ti.state = "Seeding";
+ else
+ if (ret[1] == "Stalled")
+ ti.state = "Stalled";
+ else
+ if (ret[1] == "Downloading")
+ ti.state = "Downloading";
+ else
+ ti.state = "Stopped";
+
+
+ QStringList tmp;
+ tmp = QStringList::split(" ", ret[2]);
+ if (tmp.size()!=2 || !makeSize(ti.trafficDown, tmp[0], tmp[1]))
+ ERROR_RET_BOOL
+
+ tmp = QStringList::split(" ", ret[3]);
+ if (tmp.size()!=2 || !makeSize(ti.size, tmp[0], tmp[1]))
+ ERROR_RET_BOOL
+
+ tmp = QStringList::split(" ", ret[4]);
+ if (tmp.size()!=2 || !makeSize(ti.trafficUp, tmp[0], tmp[1]))
+ ERROR_RET_BOOL
+
+
+ bool ok;
+ tmp = QStringList::split(" ", ret[5]);
+ if (tmp.size()!=2)
+ ERROR_RET_BOOL
+ ti.speedDown = tmp[0].toFloat(&ok);
+ if (!ok)
+ ERROR_RET_BOOL
+
+ tmp = QStringList::split(" ", ret[6]);
+ if (tmp.size()!=2)
+ ERROR_RET_BOOL
+ ti.speedUp = tmp[0].toFloat(&ok);
+ if (!ok)
+ ERROR_RET_BOOL
+
+
+ // torrent name, status, downloaded, size, uploaded, down spd, up spd, none, peers, % complete
+ ti.peers = ret[8].toInt(&ok);
+ if (!ok)
+ ERROR_RET_BOOL
+
+ tmp = QStringList::split(" ", ret[9]);
+ if (tmp.size()!=2)
+ ERROR_RET_BOOL
+ ti.percent = tmp[0].toFloat(&ok);
+ if (!ok)
+ ERROR_RET_BOOL
+
+ return true;
+ }
+
+ int KviKTorrentDCOPInterface::maxUploadSpeed()
+ {
+ int ret;
+ if (!intRetVoidDCOPCall("KTorrent", "maxUploadRate()", ret))
+ {
+ ERROR_MSG
+ return -1;
+ }
+ return ret;
+ }
+
+ int KviKTorrentDCOPInterface::maxDownloadSpeed()
+ {
+ int ret;
+ if (!intRetVoidDCOPCall("KTorrent", "maxDownloadRate()", ret))
+ {
+ ERROR_MSG
+ return -1;
+ }
+ return ret;
+ }
+
+ bool KviKTorrentDCOPInterface::setMaxUploadSpeed(int kbytes_per_sec)
+ {
+ if (!voidRetIntDCOPCall("KTorrent", "setMaxUploadSpeed(int)", kbytes_per_sec))
+ ERROR_RET_BOOL
+ return true;
+ }
+
+ bool KviKTorrentDCOPInterface::setMaxDownloadSpeed(int kbytes_per_sec)
+ {
+ if (!voidRetIntDCOPCall("KTorrent", "setMaxDownloadSpeed(int)", kbytes_per_sec))
+ ERROR_RET_BOOL
+ return true;
+ }
+
+ #include "tc_ktorrentdcopinterface.moc"
#endif // COMPILE_KDE_SUPPORT
diff --git a/src/modules/torrent/tc_ktorrentdcopinterface.h b/src/modules/torrent/tc_ktorrentdcopinterface.h
index 7ebc729e5..7b348f092 100644
--- a/src/modules/torrent/tc_ktorrentdcopinterface.h
+++ b/src/modules/torrent/tc_ktorrentdcopinterface.h
@@ -5,7 +5,7 @@
//
// DCOP interface for KTorrent client.
//
-// File : torr_ktorrentdcopinterface.h
+// File : tc_ktorrentdcopinterface.h
// Creation date : Fri Jan 1 15:42:25 2007 GMT by Alexander Stillich
//
// This file is part of the KVirc irc client distribution
@@ -32,99 +32,87 @@
#include "tc_interface.h"
#ifdef COMPILE_KDE_SUPPORT
-
-#include <kvi_dcophelper.h>
-
-// DCOP interface to KTorrent. this has 'DCOP' in its name
-// because in kde4 there will be a D-BUS interface.
-class KviKTorrentDCOPInterface : public KviTorrentInterface,
- private KviDCOPHelper
-{
- Q_OBJECT
-
-public:
-
- KviKTorrentDCOPInterface();
- virtual ~KviKTorrentDCOPInterface();
-
- virtual int detect();
-
- virtual int count();
-
- virtual bool start(int i);
- virtual bool stop(int i);
- virtual bool announce(int i);
- virtual QString state(int i);
- virtual QString name(int i);
-
- virtual int fileCount(int i);
- virtual QString fileName(int i, int file);
- virtual QString filePriority(int i, int file);
- virtual bool setFilePriority(int i, int file, const QString &prio);
-
- virtual bool startAll();
- virtual bool stopAll();
-
- virtual int maxUploadSpeed();
- virtual int maxDownloadSpeed();
-
- virtual bool setMaxUploadSpeed(int kbytes_per_sec);
- virtual bool setMaxDownloadSpeed(int kbytes_per_sec);
-
- virtual float speedUp();
- virtual float speedDown();
-
- virtual float trafficUp();
- virtual float trafficDown();
-
-private slots:
-
- // polls client and extracts information.
- // this is done because the order of torrents returned changes
- // each time a torrent's state changes.
- // we want to present a consistent list (in terms of indices) to
- // the user, so we extract the info and sort it by name.
- // otherwise the user would have a hard time figuring out what's
- // going on. we could sort each time a function working with
- // torrents is called, but this would be horribly slow ...
- void slotTimer();
-
-private:
-
- struct TorrentInfo
+ #include <kvi_dcophelper.h>
+
+ // DCOP interface to KTorrent. this has 'DCOP' in its name
+ // because in kde4 there will be a D-BUS interface.
+ class KviKTorrentDCOPInterface : public KviTorrentInterface,
+ private KviDCOPHelper
{
- // internal number
- int num;
- // name displayed in ktorrent
- QString name;
- // state of torrent
- QString state;
- // bytes
- float size;
- // bytes
- float trafficUp;
- // bytes
- float trafficDown;
- // KB/s
- float speedUp;
- // KB/s
- float speedDown;
- // percent complete
- float percent;
- // number of peers
- int peers;
-
- bool operator<(const TorrentInfo &ti) { return name < ti.name; }
+ Q_OBJECT
+
+ public:
+ KviKTorrentDCOPInterface();
+ virtual ~KviKTorrentDCOPInterface();
+ virtual int detect();
+ virtual int count();
+ virtual bool start(int i);
+ virtual bool stop(int i);
+ virtual bool announce(int i);
+ virtual QString state(int i);
+ virtual QString name(int i);
+ virtual int fileCount(int i);
+ virtual QString fileName(int i, int file);
+ virtual QString filePriority(int i, int file);
+ virtual bool setFilePriority(int i, int file, const QString &prio);
+
+ virtual bool startAll();
+ virtual bool stopAll();
+
+ virtual int maxUploadSpeed();
+ virtual int maxDownloadSpeed();
+
+ virtual bool setMaxUploadSpeed(int kbytes_per_sec);
+ virtual bool setMaxDownloadSpeed(int kbytes_per_sec);
+
+ virtual float speedUp();
+ virtual float speedDown();
+
+ virtual float trafficUp();
+ virtual float trafficDown();
+ private slots:
+ // polls client and extracts information.
+ // this is done because the order of torrents returned changes
+ // each time a torrent's state changes.
+ // we want to present a consistent list (in terms of indices) to
+ // the user, so we extract the info and sort it by name.
+ // otherwise the user would have a hard time figuring out what's
+ // going on. we could sort each time a function working with
+ // torrents is called, but this would be horribly slow ...
+ void slotTimer();
+ private:
+ struct TorrentInfo
+ {
+ // internal number
+ int num;
+ // name displayed in ktorrent
+ QString name;
+ // state of torrent
+ QString state;
+ // bytes
+ float size;
+ // bytes
+ float trafficUp;
+ // bytes
+ float trafficDown;
+ // KB/s
+ float speedUp;
+ // KB/s
+ float speedDown;
+ // percent complete
+ float percent;
+ // number of peers
+ int peers;
+ bool operator<(const TorrentInfo &ti) { return name < ti.name; }
+ };
+
+ QValueList<TorrentInfo> m_ti;
+
+ private:
+ bool makeTorrentInfo(TorrentInfo &ti, const KviQCStringList &ret);
};
-
- QValueList<TorrentInfo> m_ti;
-
-private:
-
- bool makeTorrentInfo(TorrentInfo &ti, const KviQCStringList &ret);
-};
-
-TORR_DECLARE_DESCRIPTOR(KviKTorrentDCOPInterface)
+
+ TORR_DECLARE_DESCRIPTOR(KviKTorrentDCOPInterface)
#endif // COMPILE_KDE_SUPPORT
diff --git a/src/modules/torrent/tc_statusbarapplet.cpp b/src/modules/torrent/tc_statusbarapplet.cpp
index 5d23a299d..9f67139c2 100644
--- a/src/modules/torrent/tc_statusbarapplet.cpp
+++ b/src/modules/torrent/tc_statusbarapplet.cpp
@@ -1,9 +1,38 @@
-#include "qtimer.h"
-#include "kvi_locale.h"
-#include "kvi_iconmanager.h"
+//=============================================================================
+//
+// DCOP interface for KTorrent client.
+//
+// File : tc_statusbarapplet.cpp
+// Creation date : Fri Jan 1 15:42:25 2007 GMT by Alexander Stillich
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 2001-2005 Szymon Stefanek (pragma at kvirc dot net)
+// Copyright (C) 2007 Alexander Stillich (torque at pltn dot org)
+//
+// 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 opinion) 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.
+//
+//=============================================================================
+
#include "tc_interface.h"
#include "tc_statusbarapplet.h"
+#include "kvi_locale.h"
+#include "kvi_iconmanager.h"
+
+#include "QTimer"
+
KviTorrentStatusBarApplet::KviTorrentStatusBarApplet(KviStatusBar *parent, KviStatusBarAppletDescriptor *desc)
: KviStatusBarApplet(parent, desc)
{
@@ -21,7 +50,7 @@ KviTorrentStatusBarApplet::~KviTorrentStatusBarApplet()
static KviStatusBarApplet *CreateTorrentClientApplet(KviStatusBar *bar, KviStatusBarAppletDescriptor *desc)
{
- debug("CreateTorrentClientApplet");
+ qDebug("CreateTorrentClientApplet");
return new KviTorrentStatusBarApplet(bar, desc);
}
@@ -58,12 +87,9 @@ void KviTorrentStatusBarApplet::update()
.arg(formatSize(KviTorrentInterface::selected()->trafficDown()));
setText(msg);
-
- } else
- {
+ } else {
setText(__tr2qs_ctx("No client selected!", "torrent"));
}
}
#include "tc_statusbarapplet.moc"
-
diff --git a/src/modules/torrent/tc_statusbarapplet.h b/src/modules/torrent/tc_statusbarapplet.h
index 03dd6d0df..960f79fc9 100644
--- a/src/modules/torrent/tc_statusbarapplet.h
+++ b/src/modules/torrent/tc_statusbarapplet.h
@@ -1,5 +1,31 @@
#ifndef _TC_STATUSBARAPPLET_H_
#define _TC_STATUSBARAPPLET_H_
+//=============================================================================
+//
+// DCOP interface for KTorrent client.
+//
+// File : tc_statusbarapplet.h
+// Creation date : Fri Jan 1 15:42:25 2007 GMT by Alexander Stillich
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 2001-2005 Szymon Stefanek (pragma at kvirc dot net)
+// Copyright (C) 2007 Alexander Stillich (torque at pltn dot org)
+//
+// 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 opinion) 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.
+//
+//=============================================================================
#include "kvi_statusbar.h"
#include "kvi_statusbarapplet.h"
@@ -9,18 +35,12 @@
class KviTorrentStatusBarApplet : public KviStatusBarApplet
{
Q_OBJECT
-
public:
-
KviTorrentStatusBarApplet(KviStatusBar *parent, KviStatusBarAppletDescriptor *desc);
virtual ~KviTorrentStatusBarApplet();
-
static void selfRegister(KviStatusBar *bar);
-
private slots:
-
void update();
-
};
#endif // _TC_STATUSBARAPPLET_H_
diff --git a/src/modules/url/libkviurl.cpp b/src/modules/url/libkviurl.cpp
index 9003ed49f..087b794e2 100644
--- a/src/modules/url/libkviurl.cpp
+++ b/src/modules/url/libkviurl.cpp
@@ -17,31 +17,28 @@
// Inc. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
+#include "libkviurl.h"
+#include "icons.h"
+
#include "kvi_styled_controls.h"
#include "kvi_module.h"
-#include "libkviurl.h"
#include "kvi_app.h"
#include "kvi_frame.h"
-#include "kvi_kvs_eventmanager.h"
-#include "kvi_tal_popupmenu.h"
-
#include "kvi_menubar.h"
#include "kvi_internalcmd.h"
#include "kvi_iconmanager.h"
#include "kvi_action.h"
#include "kvi_actionmanager.h"
#include "kvi_taskbar.h"
-#include "icons.h"
#include "kvi_pointerlist.h"
-#include <qfiledialog.h>
-#include <qmessagebox.h>
-#include <qcursor.h>
-#include <qdatetime.h>
+#include "kvi_kvs_eventmanager.h"
+#include "kvi_tal_popupmenu.h"
-#ifdef COMPILE_USE_QT4
- #include <q3textstream.h>
- #include <QTextStream>
-#endif
+#include <QFileDialog>
+#include <QMessageBox>
+#include <QCursor>
+#include <QDateTime>
+#include <QTextStream>
static QPixmap * g_pUrlIconPixmap = 0;
static KviUrlAction * g_pUrlAction = 0;
@@ -148,11 +145,7 @@ UrlDialog::UrlDialog(KviPointerList<KviUrl> *g_pList)
connect(m_pUrlList,SIGNAL(rightButtonPressed(KviTalListViewItem *, const QPoint &, int)),SLOT(popup(KviTalListViewItem *, const QPoint &, int)));
// setFocusHandlerNoChildren(m_pUrlList);
-#ifdef COMPILE_USE_QT4
m_pUrlList->setFocusPolicy(Qt::StrongFocus);
-#else
- m_pUrlList->setFocusPolicy(QWidget::StrongFocus);
-#endif
m_pUrlList->setFocus();
}
@@ -530,12 +523,8 @@ void loadUrlList()
QFile file;
file.setName(QString::fromUtf8(urllist.ptr()));
if (!file.open(IO_ReadOnly))return;
-#ifdef COMPILE_USE_QT4
- Q3TextStream stream(&file);
-#else
- QTextStream stream(&file);
-#endif
+ QTextStream stream(&file);
g_pList->clear();
@@ -545,7 +534,7 @@ void loadUrlList()
KviUrl *tmp;
int i=0;
int num = stream.readLine().toInt();
- while ((!stream.eof()) && (i<num)){
+ while ((!stream.atEnd()) && (i<num)){
tmp = new KviUrl();
tmp->url = stream.readLine();
tmp->window = stream.readLine();
@@ -594,16 +583,14 @@ void loadBanList()
QFile file;
file.setName(QString::fromUtf8(banlist.ptr()));
if (!file.open(IO_ReadOnly))return;
-#ifdef COMPILE_USE_QT4
- Q3TextStream stream(&file);
-#else
+
QTextStream stream(&file);
-#endif
+
g_pBanList->clear();
int i=0;
int num = stream.readLine().toInt();
- while ((!stream.eof()) && (i<num)){
+ while ((!stream.atEnd()) && (i<num)){
KviStr *tmp = new KviStr(stream.readLine());
g_pBanList->append(tmp);
i++;
@@ -643,7 +630,6 @@ static bool url_kvs_cmd_list(KviKvsModuleCommandCall * c)
return true;
}
-
UrlDlgList *findFrame()
{
UrlDlgList *tmpitem = g_pUrlDlgList->first();
@@ -696,7 +682,7 @@ bool urllist()
<blockquote>if the word "ftp" is inserted in the ban list and if in a window there is an output like "ftp.kvirc.net",
the url will not be catched.</blockquote></I>
<HR>
- */
+*/
static bool url_kvs_cmd_config(KviKvsModuleCommandCall * c)
{
@@ -898,8 +884,8 @@ void url_module_config()
KVIRC_MODULE(
"URL",
- "1.0.0" ,
- "Copyright (C) 2002 Andrea Parrella <yap@yapsoft.it>" ,
+ "4.0.0" ,
+ "Copyright (C) 2002 Andrea Parrella <yap@yapsoft.it>",
"url list module for KVIrc",
url_module_init,
url_module_can_unload,
@@ -910,4 +896,3 @@ KVIRC_MODULE(
#ifndef COMPILE_USE_STANDALONE_MOC_SOURCES
#include "libkviurl.moc"
#endif //!COMPILE_USE_STANDALONE_MOC_SOURCES
-
diff --git a/src/modules/url/libkviurl.h b/src/modules/url/libkviurl.h
index e6fe3b75f..9b36d9d27 100644
--- a/src/modules/url/libkviurl.h
+++ b/src/modules/url/libkviurl.h
@@ -20,25 +20,6 @@
// Inc. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
-
-#include <qdialog.h>
-#include <qlayout.h>
-#include "kvi_tal_listview.h"
-#include <qstring.h>
-#include <qpushbutton.h>
-#include <qfile.h>
-#ifdef COMPILE_USE_QT4
- #include <q3textstream.h>
-#else
- #include <qtextstream.h>
-#endif
-#include <qcheckbox.h>
-#include "kvi_tal_listbox.h"
-#include <qmenubar.h>
-#include <qinputdialog.h>
-#include <qtoolbutton.h>
-#include <qiconset.h>
-
#include "kvi_locale.h"
#include "kvi_config.h"
#include "kvi_irctoolbar.h"
@@ -46,8 +27,21 @@
#include "kvi_tal_menubar.h"
#include "kvi_mextoolbar.h"
#include "kvi_styled_controls.h"
+#include "kvi_kvs_action.h"
+#include "kvi_tal_listview.h"
+#include "kvi_tal_listbox.h"
-#include <qpixmap.h>
+#include <QDialog>
+#include <QLayout>
+#include <QString>
+#include <QPushButton>
+#include <QFile>
+#include <QCheckBox>
+#include <QMenuBar>
+#include <QInputDialog>
+#include <QToolButton>
+#include <QIconSet>
+#include <QPixmap>
typedef struct _KviUrl
{
@@ -124,7 +118,6 @@ protected slots:
void discardbtn();
};
-#include "kvi_kvs_action.h"
class KviUrlAction : public KviKvsAction
{
diff --git a/src/modules/window/libkviwindow.cpp b/src/modules/window/libkviwindow.cpp
index bf51ecc93..5e6b9a42b 100644
--- a/src/modules/window/libkviwindow.cpp
+++ b/src/modules/window/libkviwindow.cpp
@@ -22,8 +22,9 @@
//
//=================================================================================
-#include "kvi_module.h"
+#include "userwindow.h"
+#include "kvi_module.h"
#include "kvi_console.h"
#include "kvi_options.h"
#include "kvi_ircsocket.h"
@@ -37,12 +38,10 @@
#include "kvi_modulemanager.h"
#include "kvi_memmove.h"
#include "kvi_malloc.h"
-
#include "kvi_channel.h"
-#include "userwindow.h"
-
#include "kvi_pointerhashtable.h"
-#include <qtimer.h>
+
+#include <QTimer>
#ifdef COMPILE_CRYPT_SUPPORT
@@ -1537,7 +1536,7 @@ static bool window_module_can_unload(KviModule *m)
KVIRC_MODULE(
"Window", // module name
- "1.0.0", // module version
+ "4.0.0", // module version
"Copyright (C) 2001-2004 Szymon Stefanek (pragma at kvirc dot net)", // author & (C)
"KVIrc window management functions",
window_module_init,
diff --git a/src/modules/window/userwindow.cpp b/src/modules/window/userwindow.cpp
index d022b040f..cc9187a83 100644
--- a/src/modules/window/userwindow.cpp
+++ b/src/modules/window/userwindow.cpp
@@ -104,4 +104,3 @@ void KviUserWindow::setCaptionStrings(const QString &szPlainText,const QString &
if(m_szHtmlInactiveCaption.isEmpty())m_szHtmlInactiveCaption = szPlainText;
updateCaption();
}
-