commit ccbc7388fb15d808e5c90aa9d30cd9af48b1f1cf Author: Tomas Touceda chiiph@torproject.org Date: Wed Jun 15 00:24:14 2011 -0300
First rusty working version of TorControlPrototype
It needs work mainly in all the types that aren't automatically cohersed to QVariant or something that javascript understands --- src/vidalia/CMakeLists.txt | 2 + src/vidalia/plugin/PluginEngine.cpp | 22 +- src/vidalia/plugin/PluginEngine.h | 3 +- .../plugin/prototypes/TorControlPrototype.cpp | 475 +++++++++----------- .../plugin/prototypes/TorControlPrototype.h | 49 +- 5 files changed, 256 insertions(+), 295 deletions(-)
diff --git a/src/vidalia/CMakeLists.txt b/src/vidalia/CMakeLists.txt index 380b9e8..f340b65 100644 --- a/src/vidalia/CMakeLists.txt +++ b/src/vidalia/CMakeLists.txt @@ -89,6 +89,7 @@ set(vidalia_SRCS ${vidalia_SRCS} plugin/DebugDialog.cpp plugin/prototypes/VidaliaTabPrototype.cpp plugin/prototypes/HelperProcessPrototype.cpp + plugin/prototypes/TorControlPrototype.cpp ) qt4_wrap_cpp(vidalia_SRCS plugin/PluginEngine.h @@ -96,6 +97,7 @@ qt4_wrap_cpp(vidalia_SRCS plugin/DebugDialog.h plugin/prototypes/VidaliaTabPrototype.h plugin/prototypes/HelperProcessPrototype.h + plugin/prototypes/TorControlPrototype.h )
## Configuration dialog sources diff --git a/src/vidalia/plugin/PluginEngine.cpp b/src/vidalia/plugin/PluginEngine.cpp index 3f99025..4d6d745 100644 --- a/src/vidalia/plugin/PluginEngine.cpp +++ b/src/vidalia/plugin/PluginEngine.cpp @@ -3,6 +3,8 @@ #include "PluginWrapper.h" #include "DebugDialog.h"
+#include "Vidalia.h" + PluginEngine::PluginEngine(QObject *parent) : QScriptEngine(parent) { @@ -10,10 +12,13 @@ PluginEngine::PluginEngine(QObject *parent) MAKE_CREATABLE(VidaliaTabPrototype) ADD_PROTOTYPE(HelperProcessPrototype) MAKE_CREATABLE(HelperProcessPrototype) -// ADD_PROTOTYPE(TorControlPrototype) + ADD_PROTOTYPE(TorControlPrototype) + + globalObject().setProperty("torControl", newQObject(Vidalia::torControl()));
globalObject().setProperty("include", newFunction(includeScript)); globalObject().setProperty("importExtension", newFunction(importExtension)); + globalObject().setProperty("vdebug", newFunction(vdebug));
VidaliaSettings settings; globalObject().setProperty("pluginPath", QScriptValue(settings.pluginPath())); @@ -163,3 +168,18 @@ PluginEngine::loadFile(QString fileName, QScriptEngine *engine) } return true; } + +QScriptValue +PluginEngine::vdebug(QScriptContext *context, QScriptEngine *engine) +{ + QString result; + for(int i = 0; i<context->argumentCount(); i++) { + if(i>0) + result.append(" "); + result.append(context->argument(i).toString()); + } + + qWarning() << result; + + return engine->undefinedValue(); +} diff --git a/src/vidalia/plugin/PluginEngine.h b/src/vidalia/plugin/PluginEngine.h index 5b4cc25..13890f6 100644 --- a/src/vidalia/plugin/PluginEngine.h +++ b/src/vidalia/plugin/PluginEngine.h @@ -6,7 +6,7 @@
#include "VidaliaTabPrototype.h" #include "HelperProcessPrototype.h" -//#include "TorControlPrototype.h" +#include "TorControlPrototype.h"
class PluginWrapper;
@@ -33,6 +33,7 @@ class PluginEngine : public QScriptEngine { static QScriptValue importExtension(QScriptContext *context, QScriptEngine *engine); static bool loadFile(QString fileName, QScriptEngine *engine); static QScriptValue includeScript(QScriptContext *context, QScriptEngine *engine); + static QScriptValue vdebug(QScriptContext *context, QScriptEngine *engine);
void loadAllPlugins(); void tryLoadPlugin(QDir path); diff --git a/src/vidalia/plugin/prototypes/TorControlPrototype.cpp b/src/vidalia/plugin/prototypes/TorControlPrototype.cpp index 972d100..56bccc0 100644 --- a/src/vidalia/plugin/prototypes/TorControlPrototype.cpp +++ b/src/vidalia/plugin/prototypes/TorControlPrototype.cpp @@ -1,5 +1,55 @@ #include "TorControlPrototype.h"
+#define GET_AND_CALL(type, func, res) \ + type obj = qscriptvalue_cast<type>(thisObject()); \ + if(obj) \ + res = obj->func; + +#define MERGE2(result, errmsg) \ + QVariant(QList<QVariant>() << result << errmsg); + +#define DEF_TYPE0(type, retType, func, call) \ +retType \ +type##Prototype::func \ +{ \ + type *obj = qscriptvalue_cast<type *>(thisObject()); \ + if(obj) \ + return obj->call; \ +} + +#define DEF_TYPE1(type, resType, func, call) \ +QVariant \ +type##Prototype::func \ +{ \ + resType res; \ + QString errmsg; \ +\ + type *obj = qscriptvalue_cast<type *>(thisObject()); \ + if(obj) \ + res = obj->call; \ + QList<QVariant> vals; \ + vals << res << QVariant(errmsg); \ +\ + return vals; \ +} + +#define DEF_TYPE2(type, resType, ansType, func, call) \ +QVariant \ +type##Prototype::func \ +{ \ + resType res; \ + ansType ans; \ + QString errmsg; \ +\ + type *obj = qscriptvalue_cast<type *>(thisObject()); \ + if(obj) \ + res = obj->call; \ + QList<QVariant> vals; \ + vals << QVariant(ans) << res << QVariant(errmsg); \ +\ + return vals; \ +} + TorControlPrototype::TorControlPrototype() : QObject(), QScriptable() {}
@@ -13,187 +63,120 @@ TorControlPrototype::name() { return QString("TorControl"); }
+DEF_TYPE0(TorControl, void, + start(const QString &tor, const QStringList &args), + start(tor, args))
-void -TorControlPrototype::start(const QString &tor, const QStringList &args) -{ - TorControl *obj = qscriptvalue_cast<TorControl *>(thisObject()); - - if(obj) - obj->start(tor, args); -} - -bool -TorControlPrototype::stop(QString *errmsg) -{ - TorControl *obj = qscriptvalue_cast<TorControl *>(thisObject()); - - if(obj) - return obj->stop(errmsg); -} +DEF_TYPE1(TorControl, bool, + stop(), + stop(&errmsg))
-bool -TorControlPrototype::isRunning() -{ - TorControl *obj = qscriptvalue_cast<TorControl *>(thisObject()); +DEF_TYPE0(TorControl, bool, + isRunning(), + isRunning())
- if(obj) - return obj->isRunning(); -} +DEF_TYPE0(TorControl, bool, + isVidaliaRunningTor(), + isVidaliaRunningTor())
-bool -TorControlPrototype::isVidaliaRunningTor() -{ - TorControl *obj = qscriptvalue_cast<TorControl *>(thisObject()); +DEF_TYPE0(TorControl, void, + closeTorStdout(), + closeTorStdout())
- if(obj) - return obj->isVidaliaRunningTor(); -} - -void -TorControlPrototype::closeTorStdout() -{ - TorControl *obj = qscriptvalue_cast<TorControl *>(thisObject()); - - if(obj) - obj->closeTorStdout(); -} - -void -TorControlPrototype::connect(const QHostAddress &address, quint16 port) -{ - TorControl *obj = qscriptvalue_cast<TorControl *>(thisObject()); - - if(obj) - obj->connect(address, port); -} - -void -TorControlPrototype::connect(const QString &path) -{ - TorControl *obj = qscriptvalue_cast<TorControl *>(thisObject()); - - if(obj) - obj->connect(path); -} - -void -TorControlPrototype::disconnect() -{ - TorControl *obj = qscriptvalue_cast<TorControl *>(thisObject()); - - if(obj) - obj->disconnect(); -} +DEF_TYPE0(TorControl, void, + connect(const QHostAddress &address, quint16 port), + connect(address, port))
-bool -TorControlPrototype::isConnected() -{ - TorControl *obj = qscriptvalue_cast<TorControl *>(thisObject()); +DEF_TYPE0(TorControl, void, + connect(const QString &path), + connect(path))
- if(obj) - return obj->isConnected(); -} +DEF_TYPE0(TorControl, void, + disconnect(), + disconnect())
-bool -TorControlPrototype::authenticate(const QByteArray cookie, QString *errmsg) -{ - TorControl *obj = qscriptvalue_cast<TorControl *>(thisObject()); +DEF_TYPE0(TorControl, bool, + isConnected(), + isConnected())
- if(obj) - return obj->authenticate(cookie, errmsg); -} +DEF_TYPE1(TorControl, bool, + authenticate(const QByteArray cookie), + authenticate(cookie, &errmsg))
-bool -TorControlPrototype::authenticate(const QString &password, QString *errmsg) -{ - TorControl *obj = qscriptvalue_cast<TorControl *>(thisObject()); +DEF_TYPE1(TorControl, bool, + authenticate(const QString &password), + authenticate(password, &errmsg))
- if(obj) - return obj->authenticate(password, errmsg); -} +// TODO: make a QVariant for this two +//QVariant +//TorControlPrototype::protocolInfo() +//{ +// ProtocolInfo info; +// QString errmsg;
-ProtocolInfo -TorControlPrototype::protocolInfo(QString *errmsg) -{ - TorControl *obj = qscriptvalue_cast<TorControl *>(thisObject()); +// GET_AND_CALL(TorControl *, protocolInfo(&errmsg), info)
- if(obj) - return obj->protocolInfo(errmsg); -} +// return MERGE2(info, errmsg); +//}
-BootstrapStatus -TorControlPrototype::bootstrapStatus(QString *errmsg) -{ - TorControl *obj = qscriptvalue_cast<TorControl *>(thisObject()); +//BootstrapStatus +//TorControlPrototype::bootstrapStatus(QString *errmsg) +//{ +// BootstrapStatus status; +// QString errmsg;
- if(obj) - return obj->bootstrapStatus(errmsg); -} +// GET_AND_CALL(TorControl *, protocolInfo(&errmsg), status)
-bool -TorControlPrototype::isCircuitEstablished() -{ - TorControl *obj = qscriptvalue_cast<TorControl *>(thisObject()); +// return MERGE2(status, errmsg); +//}
- if(obj) - return obj->isCircuitEstablished(); -} +DEF_TYPE0(TorControl, bool, + isCircuitEstablished(), + isCircuitEstablished())
-bool -TorControlPrototype::getInfo(QHash<QString,QString> &map, QString *errmsg) -{ - TorControl *obj = qscriptvalue_cast<TorControl *>(thisObject()); +DEF_TYPE1(TorControl, bool, + getInfo(QHash<QString,QString> &map), + getInfo(map, &errmsg))
- if(obj) - return obj->getInfo(map, errmsg); -} +// TODO: this one may be useless +//QVariant +//TorControlPrototype::getInfo(QString key) +//{ +// TorControl *obj = qscriptvalue_cast<TorControl *>(thisObject()); +// QString val, *errmsg = new QString(); +// bool res = false; +// QList<QVariant> vals;
-bool -TorControlPrototype::getInfo(QString key, QString &val, QString *errmsg) -{ - TorControl *obj = qscriptvalue_cast<TorControl *>(thisObject()); +// if(obj) +// res = obj->getInfo(key, val, errmsg);
- if(obj) - return obj->getInfo(key, val, errmsg); -} +// vals.append(QVariant(res)); +// vals.append(QVariant(val)); +// vals.append(QVariant(*errmsg));
-QVariantMap -TorControlPrototype::getInfo(const QStringList &keys, QString *errmsg) -{ - TorControl *obj = qscriptvalue_cast<TorControl *>(thisObject()); +// return QVariant(vals); +//}
- if(obj) - return obj->getInfo(keys, errmsg); -} +// TODO: There is no StringList, this may be useless +//DEF_TYPE1(TorControl, QVariantMap, +// getInfo(const QStringList &keys), +// getInfo(keys, &errmsg))
-QVariant -TorControlPrototype::getInfo(const QString &key, QString *errmsg) -{ - TorControl *obj = qscriptvalue_cast<TorControl *>(thisObject()); - - if(obj) - return obj->getInfo(key, errmsg); -} - -bool -TorControlPrototype::signal(TorSignal::Signal sig, QString *errmsg) -{ - TorControl *obj = qscriptvalue_cast<TorControl *>(thisObject()); - - if(obj) - return obj->signal(sig, errmsg); -} - -QHostAddress -TorControlPrototype::getSocksAddress(QString *errmsg) -{ - TorControl *obj = qscriptvalue_cast<TorControl *>(thisObject()); - - if(obj) - return obj->getSocksAddress(errmsg); -} +DEF_TYPE1(TorControl, QVariant, + getInfo(const QString &key), + getInfo(key, &errmsg)) + +DEF_TYPE1(TorControl, bool, + signal(TorSignal::Signal sig), + signal(sig, &errmsg)) + +// TODO: QVariant don't like QHostAddress +//DEF_TYPE1(TorControl, QHostAddress, +// getSocksAddress(), +// getSocksAddress(&errmsg))
+// TODO: make it a QVariant(QList<QVariant>() << QVariant(QString) << +// QVariant(QString) ... QStringList TorControlPrototype::getSocksAddressList(QString *errmsg) { @@ -203,87 +186,53 @@ TorControlPrototype::getSocksAddressList(QString *errmsg) return obj->getSocksAddressList(errmsg); }
-quint16 -TorControlPrototype::getSocksPort(QString *errmsg) -{ - TorControl *obj = qscriptvalue_cast<TorControl *>(thisObject()); - - if(obj) - return obj->getSocksPort(errmsg); -} +DEF_TYPE1(TorControl, quint16, + getSocksPort(), + getSocksPort(&errmsg))
+// TODO: same as getSocksAddressList but with quint16 QList<quint16> TorControlPrototype::getSocksPortList(QString *errmsg) { TorControl *obj = qscriptvalue_cast<TorControl *>(thisObject());
if(obj) - return obj->quint16> getSocksPortList(errmsg); + return obj->getSocksPortList(errmsg); }
-QString -TorControlPrototype::getTorVersionString() -{ - TorControl *obj = qscriptvalue_cast<TorControl *>(thisObject()); +DEF_TYPE0(TorControl, QString, + getTorVersionString(), + getTorVersionString())
- if(obj) - return obj->getTorVersionString(); -} +DEF_TYPE0(TorControl, quint32, + getTorVersion(), + getTorVersion())
-quint32 -TorControlPrototype::getTorVersion() -{ - TorControl *obj = qscriptvalue_cast<TorControl *>(thisObject()); +DEF_TYPE1(TorControl, bool, + setEvent(TorEvents::Event e, bool add, bool set), + setEvent(e, add, set, &errmsg))
- if(obj) - return obj->getTorVersion(); -} +DEF_TYPE1(TorControl, bool, + setEvents(), + setEvents(&errmsg))
-bool -TorControlPrototype::setEvent(TorEvents::Event e, bool add, bool set, QString *errmsg) -{ - TorControl *obj = qscriptvalue_cast<TorControl *>(thisObject()); +DEF_TYPE1(TorControl, bool, + setConf(QHash<QString,QString> map), + setConf(map, &errmsg))
- if(obj) - return obj->setEvent(e, add, set, errmsg); -} +DEF_TYPE1(TorControl, bool, + setConf(QString key, QString value), + setConf(key, value, &errmsg))
-bool -TorControlPrototype::setEvents(QString *errmsg) -{ - TorControl *obj = qscriptvalue_cast<TorControl *>(thisObject()); - - if(obj) - return obj->setEvents(errmsg); -} - -bool -TorControlPrototype::setConf(QHash<QString,QString> map, QString *errmsg) -{ - TorControl *obj = qscriptvalue_cast<TorControl *>(thisObject()); - - if(obj) - return obj->setConf(map, errmsg); -} - -bool -TorControlPrototype::setConf(QString key, QString value, QString *errmsg) -{ - TorControl *obj = qscriptvalue_cast<TorControl *>(thisObject()); - - if(obj) - returb obj->setConf(key, value, errmsg); -} - -bool -TorControlPrototype::setConf(QString keyAndValue, QString *errmsg) -{ - TorControl *obj = qscriptvalue_cast<TorControl *>(thisObject()); - - if(obj) - return obj->setConf(keyAndValue, errmsg); -} +DEF_TYPE1(TorControl, bool, + setConf(QString keyAndValue), + setConf(keyAndValue, &errmsg))
+// TODO: macros don't like template variables +// do this one by hand +//DEF_TYPE2(TorControl, bool, QHash<QString,QString>, +// getConf(QHash<QString,QString> &map), +// getConf(map, &errmsg)) bool TorControlPrototype::getConf(QHash<QString,QString> &map, QString *errmsg) { @@ -293,6 +242,7 @@ TorControlPrototype::getConf(QHash<QString,QString> &map, QString *errmsg) return obj->getConf(map, errmsg); }
+// TODO: this one too bool TorControlPrototype::getConf(QHash<QString,QStringList> &map, QString *errmsg) { @@ -302,15 +252,11 @@ TorControlPrototype::getConf(QHash<QString,QStringList> &map, QString *errmsg) return obj->getConf(map, errmsg); }
-bool -TorControlPrototype::getConf(QString key, QString &value, QString *errmsg) -{ - TorControl *obj = qscriptvalue_cast<TorControl *>(thisObject()); - - if(obj) - return obj->getConf(key, value, errmsg); -} +DEF_TYPE2(TorControl, bool, QString, + getConf(QString key), + getConf(key, ans, &errmsg))
+// TODO: same as the last one with StringList bool TorControlPrototype::getConf(QString key, QStringList &value, QString *errmsg) { @@ -320,6 +266,7 @@ TorControlPrototype::getConf(QString key, QStringList &value, QString *errmsg) return obj->getConf(key, value, errmsg); }
+// TODO: idem QVariantMap TorControlPrototype::getConf(const QStringList &keys, QString *errmsg) { @@ -329,33 +276,25 @@ TorControlPrototype::getConf(const QStringList &keys, QString *errmsg) return obj->getConf(keys, errmsg); }
-QVariant -TorControlPrototype::getConf(const QString &key, QString *errmsg) -{ - TorControl *obj = qscriptvalue_cast<TorControl *>(thisObject()); - - if(obj) - return obj->getConf(key, errmsg); -} - -QString -TorControlPrototype::getHiddenServiceConf(const QString &key, QString *errmsg) -{ - TorControl *obj = qscriptvalue_cast<TorControl *>(thisObject()); +// TODO: possibly useless +//QVariant +//TorControlPrototype::getConf(const QString &key, QString *errmsg) +//{ +// TorControl *obj = qscriptvalue_cast<TorControl *>(thisObject());
- if(obj) - return obj->getHiddenServiceConf(key, errmsg); -} +// if(obj) +// return obj->getConf(key, errmsg); +//}
-bool -TorControlPrototype::saveConf(QString *errmsg) -{ - TorControl *obj = qscriptvalue_cast<TorControl *>(thisObject()); +DEF_TYPE1(TorControl, QString, + getHiddenServiceConf(const QString &key), + getHiddenServiceConf(key, &errmsg))
- if(obj) - return obj->saveConf(errmsg); -} +DEF_TYPE1(TorControl, bool, + saveConf(), + saveConf(&errmsg))
+// TODO: another stringlist one bool TorControlPrototype::resetConf(QStringList keys, QString *errmsg) { @@ -365,15 +304,11 @@ TorControlPrototype::resetConf(QStringList keys, QString *errmsg) return obj->resetConf(keys, errmsg); }
-bool -TorControlPrototype::resetConf(QString key, QString *errmsg) -{ - TorControl *obj = qscriptvalue_cast<TorControl *>(thisObject()); - - if(obj) - return obj->resetConf(key, errmsg); -} +DEF_TYPE1(TorControl, bool, + resetConf(QString key), + resetConf(key, &errmsg))
+// TODO: you know QStringList TorControlPrototype::getRouterDescriptorText(const QString &id, QString *errmsg) { @@ -383,6 +318,7 @@ TorControlPrototype::getRouterDescriptorText(const QString &id, QString *errmsg) return obj->getRouterDescriptorText(id, errmsg); }
+// TODO: QVariantize RouterDescriptor RouterDescriptor TorControlPrototype::getRouterDescriptor(const QString &id, QString *errmsg) { @@ -392,6 +328,7 @@ TorControlPrototype::getRouterDescriptor(const QString &id, QString *errmsg) return obj->getRouterDescriptor(id, errmsg); }
+// TODO: QVariantize RouterStatus RouterStatus TorControlPrototype::getRouterStatus(const QString &id, QString *errmsg) { @@ -401,6 +338,7 @@ TorControlPrototype::getRouterStatus(const QString &id, QString *errmsg) return obj->getRouterStatus(id, errmsg); }
+// TODO: QVariantize NetworkStatus NetworkStatus TorControlPrototype::getNetworkStatus(QString *errmsg) { @@ -410,6 +348,7 @@ TorControlPrototype::getNetworkStatus(QString *errmsg) return obj->getNetworkStatus(errmsg); }
+// TODO: QVariantize DescriptorAnnotations DescriptorAnnotations TorControlPrototype::getDescriptorAnnotations(const QString &id, QString *errmsg) { @@ -419,6 +358,7 @@ TorControlPrototype::getDescriptorAnnotations(const QString &id, QString *errmsg return obj->getDescriptorAnnotations(id, errmsg); }
+// TODO: QVariantize CircuitList CircuitList TorControlPrototype::getCircuits(QString *errmsg) { @@ -428,6 +368,7 @@ TorControlPrototype::getCircuits(QString *errmsg) return obj->getCircuits(errmsg); }
+// TODO: QVariantize StreamList StreamList TorControlPrototype::getStreams(QString *errmsg) { @@ -437,6 +378,7 @@ TorControlPrototype::getStreams(QString *errmsg) return obj->getStreams(errmsg); }
+// TODO: QVariantize AddressMap AddressMap TorControlPrototype::getAddressMap(AddressMap::AddressMapType type, QString *errmsg) { @@ -446,15 +388,11 @@ TorControlPrototype::getAddressMap(AddressMap::AddressMapType type, QString *err return obj->getAddressMap(type, errmsg); }
-QString -TorControlPrototype::ipToCountry(const QHostAddress &ip, QString *errmsg) -{ - TorControl *obj = qscriptvalue_cast<TorControl *>(thisObject()); - - if(obj) - return obj->ipToCountry(ip, errmsg); -} +DEF_TYPE1(TorControl, QString, + ipToCountry(const QHostAddress &ip), + ipToCountry(ip, &errmsg))
+// TODO: migrate CircuitId bool TorControlPrototype::closeCircuit(const CircuitId &circId, bool ifUnused, QString *errmsg) { @@ -464,6 +402,7 @@ TorControlPrototype::closeCircuit(const CircuitId &circId, bool ifUnused, QStrin return obj->closeCircuit(circId, ifUnused, errmsg); }
+// TODO: migrate StreamId bool TorControlPrototype::closeStream(const StreamId &streamId, QString *errmsg) { diff --git a/src/vidalia/plugin/prototypes/TorControlPrototype.h b/src/vidalia/plugin/prototypes/TorControlPrototype.h index 196a378..8127c76 100644 --- a/src/vidalia/plugin/prototypes/TorControlPrototype.h +++ b/src/vidalia/plugin/prototypes/TorControlPrototype.h @@ -35,7 +35,7 @@ public: /** Start the Tor process */ Q_INVOKABLE void start(const QString &tor, const QStringList &args); /** Stop the Tor process */ - Q_INVOKABLE bool stop(QString *errmsg = 0); + Q_INVOKABLE QVariant stop(); /** Detect if the Tor process is running */ Q_INVOKABLE bool isRunning(); /** Detects if the Tor process is running under Vidalia. */ @@ -52,46 +52,46 @@ public: /** Check if we're connected to Tor's control socket */ Q_INVOKABLE bool isConnected(); /** Sends an authentication cookie to Tor. */ - Q_INVOKABLE bool authenticate(const QByteArray cookie, QString *errmsg = 0); + Q_INVOKABLE QVariant authenticate(const QByteArray cookie); /** Sends an authentication password to Tor. */ - Q_INVOKABLE bool authenticate(const QString &password = QString(), QString *errmsg = 0); + Q_INVOKABLE QVariant authenticate(const QString &password = QString());
/** Sends a PROTOCOLINFO command to Tor and parses the response. */ - Q_INVOKABLE ProtocolInfo protocolInfo(QString *errmsg = 0); +// Q_INVOKABLE QVariant protocolInfo();
/** Returns the Tor software's current bootstrap phase and status. */ - Q_INVOKABLE BootstrapStatus bootstrapStatus(QString *errmsg = 0); +// Q_INVOKABLE BootstrapStatus bootstrapStatus(QString *errmsg = 0);
/** Returns true if Tor either has an open circuit or (on Tor >= * 0.2.0.1-alpha) has previously decided it's able to establish a circuit. */ Q_INVOKABLE bool isCircuitEstablished();
/** Sends a GETINFO message to Tor based on the given keys */ - Q_INVOKABLE bool getInfo(QHash<QString,QString> &map, QString *errmsg = 0); + Q_INVOKABLE QVariant getInfo(QHash<QString,QString> &map); /** Sends a GETINFO message for a single info value to Tor */ - Q_INVOKABLE bool getInfo(QString key, QString &val, QString *errmsg = 0); +// Q_INVOKABLE QVariant getInfo(QString key);
/** Sends a GETINFO message to Tor using the given list of <b>keys</b> and * returns a QVariantMap containing the specified keys and their values as * returned by Tor. Returns a default constructed QVariantMap on failure. */ - Q_INVOKABLE QVariantMap getInfo(const QStringList &keys, QString *errmsg = 0); +// Q_INVOKABLE QVariantMap getInfo(const QStringList &keys, QString *errmsg = 0); /** Sends a GETINFO message to Tor with a single <b>key</b> and returns a * QVariant containing the value returned by Tor. Returns a default * constructed QVariant on failure. */ - Q_INVOKABLE QVariant getInfo(const QString &key, QString *errmsg = 0); + Q_INVOKABLE QVariant getInfo(const QString &key);
/** Sends a signal to Tor */ - Q_INVOKABLE bool signal(TorSignal::Signal sig, QString *errmsg = 0); + Q_INVOKABLE QVariant signal(TorSignal::Signal sig);
/** Returns an address on which Tor is listening for application * requests. If none are available, a null QHostAddress is returned. */ - Q_INVOKABLE QHostAddress getSocksAddress(QString *errmsg = 0); +// Q_INVOKABLE QVariant getSocksAddress(); /** Returns a (possibly empty) list of all currently configured * SocksListenAddress entries. */ Q_INVOKABLE QStringList getSocksAddressList(QString *errmsg = 0); /** Returns a valid SOCKS port for Tor, or 0 if Tor is not accepting * application requests. */ - Q_INVOKABLE quint16 getSocksPort(QString *errmsg = 0); + Q_INVOKABLE QVariant getSocksPort(); /** Returns a list of all currently configured SOCKS ports. If Tor is not * accepting any application connections, an empty list will be returned. */ Q_INVOKABLE QList<quint16> getSocksPortList(QString *errmsg = 0); @@ -104,24 +104,23 @@ public: /** Sets an event and its handler. If add is true, then the event is added, * otherwise it is removed. If set is true, then the given event will be * registered with Tor. */ - Q_INVOKABLE bool setEvent(TorEvents::Event e, bool add = true, bool set = true, - QString *errmsg = 0); + Q_INVOKABLE QVariant setEvent(TorEvents::Event e, bool add = true, bool set = true); /** Register events of interest with Tor */ - Q_INVOKABLE bool setEvents(QString *errmsg = 0); + Q_INVOKABLE QVariant setEvents();
/** Sets each configuration key in <b>map</b> to the value associated with its key. */ - Q_INVOKABLE bool setConf(QHash<QString,QString> map, QString *errmsg = 0); + Q_INVOKABLE QVariant setConf(QHash<QString,QString> map); /** Sets a single configuration key to the given value. */ - Q_INVOKABLE bool setConf(QString key, QString value, QString *errmsg = 0); + Q_INVOKABLE QVariant setConf(QString key, QString value); /** Sets a single configuration string that is formatted <key=escaped value>. */ - Q_INVOKABLE bool setConf(QString keyAndValue, QString *errmsg = 0); + Q_INVOKABLE QVariant setConf(QString keyAndValue); /** Gets values for a set of configuration keys, each of which has a single * value. */ - Q_INVOKABLE bool getConf(QHash<QString,QString> &map, QString *errmsg = 0); + Q_INVOKABLE bool getConf(QHash<QString,QString> &map, QString *errmsg); /** Gets a set of configuration keyvalues and stores them in <b>map</b>. */ Q_INVOKABLE bool getConf(QHash<QString,QStringList> &map, QString *errmsg = 0); /** Gets a single configuration value for <b>key</b>. */ - Q_INVOKABLE bool getConf(QString key, QString &value, QString *errmsg = 0); + Q_INVOKABLE QVariant getConf(QString key); /** Gets a list of configuration values for <b>key</b>. */ Q_INVOKABLE bool getConf(QString key, QStringList &value, QString *errmsg = 0);
@@ -132,17 +131,17 @@ public: /** Sends a GETCONF message to Tor with a single <b>key</b> and returns a * QVariant containing the value returned by Tor. Returns a default * constructed QVariant on failure. */ - Q_INVOKABLE QVariant getConf(const QString &key, QString *errmsg = 0); +// Q_INVOKABLE QVariant getConf(const QString &key, QString *errmsg = 0); /** Sends a GETCONF message to Tor with the single key and returns a QString * containing the value returned by Tor */ - Q_INVOKABLE QString getHiddenServiceConf(const QString &key, QString *errmsg = 0); + Q_INVOKABLE QVariant getHiddenServiceConf(const QString &key);
/** Asks Tor to save the current configuration to its torrc */ - Q_INVOKABLE bool saveConf(QString *errmsg = 0); + Q_INVOKABLE QVariant saveConf(); /** Tells Tor to reset the given configuration keys back to defaults. */ Q_INVOKABLE bool resetConf(QStringList keys, QString *errmsg = 0); /** Tells Tor to reset a configuration key back to its default value. */ - Q_INVOKABLE bool resetConf(QString key, QString *errmsg = 0); + Q_INVOKABLE QVariant resetConf(QString key);
/** Returns an unparsed router descriptor for the router whose fingerprint * matches <b>id</b>. The returned text can later be parsed by the @@ -183,7 +182,7 @@ public: * Returns a default-constructed QString on failure or if a country code * is not known for <b>ip</b>. On failure, <b>errmsg</b> will be set if * it's not NULL. */ - Q_INVOKABLE QString ipToCountry(const QHostAddress &ip, QString *errmsg = 0); + Q_INVOKABLE QVariant ipToCountry(const QHostAddress &ip);
public slots: /** Closes the circuit specified by <b>circId</b>. If <b>ifUnused</b> is