[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [vidalia/alpha] Add sleep to the plugin engine
commit 41d32ca0135e88e45b4faecc3a2715bc08c1fe7d
Author: Tomás Touceda <chiiph@xxxxxxxxxxxxxx>
Date: Fri Sep 16 10:44:40 2011 -0300
Add sleep to the plugin engine
Also, make sleep work on Windows when waiting for port.conf
---
src/vidalia/MainWindow.cpp | 5 +++++
src/vidalia/plugin/PluginEngine.cpp | 18 ++++++++++++++++++
src/vidalia/plugin/PluginEngine.h | 1 +
3 files changed, 24 insertions(+), 0 deletions(-)
diff --git a/src/vidalia/MainWindow.cpp b/src/vidalia/MainWindow.cpp
index e20bb08..88cb300 100644
--- a/src/vidalia/MainWindow.cpp
+++ b/src/vidalia/MainWindow.cpp
@@ -121,6 +121,7 @@ MainWindow::MainWindow()
updateTorStatus(Stopped);
#if defined(Q_WS_MAC)
+ VidaliaSettings settings;
/* Display OSX dock icon if icon preference is not set to "Tray Only" */
if (settings.getIconPref() != VidaliaSettings::Tray) {
ProcessSerialNumber psn = { 0, kCurrentProcess };
@@ -661,7 +662,11 @@ MainWindow::started()
while((!file.open(QIODevice::ReadOnly | QIODevice::Text)) and
(tries++ < maxtries)) {
vWarn(QString("This is try number: %1.").arg(tries));
+#if defined(Q_WS_WIN)
+ Sleep(1000);
+#else
sleep(1);
+#endif
}
if(tries >= maxtries) {
diff --git a/src/vidalia/plugin/PluginEngine.cpp b/src/vidalia/plugin/PluginEngine.cpp
index 41f9712..b3c35c1 100644
--- a/src/vidalia/plugin/PluginEngine.cpp
+++ b/src/vidalia/plugin/PluginEngine.cpp
@@ -36,6 +36,7 @@ PluginEngine::PluginEngine(QObject *parent)
globalObject().setProperty("importExtension", newFunction(importExtension));
globalObject().setProperty("vdebug", newFunction(vdebug));
globalObject().setProperty("findWidget", newFunction(findWidget));
+ globalObject().setProperty("sleep", newFunction(sleep));
VidaliaSettings settings;
globalObject().setProperty("pluginPath", QScriptValue(settings.pluginPath()));
@@ -201,3 +202,20 @@ PluginEngine::findWidget(QScriptContext *context, QScriptEngine *engine)
return ret;
}
+
+QScriptValue
+PluginEngine::sleep(QScriptContext *context, QScriptEngine *engine)
+{
+ if(context->argumentCount() != 1)
+ return context->throwError(QString("sleep must be called with 1 parameter."));
+
+ int s = context->argument(1).toInt32();
+
+#if defined(Q_WS_WIN)
+ Sleep(s*1000);
+#else
+ !::sleep(s);
+#endif
+
+ return engine->nullValue();
+}
diff --git a/src/vidalia/plugin/PluginEngine.h b/src/vidalia/plugin/PluginEngine.h
index 2251e6c..c13e1cd 100644
--- a/src/vidalia/plugin/PluginEngine.h
+++ b/src/vidalia/plugin/PluginEngine.h
@@ -51,6 +51,7 @@ class PluginEngine : public QScriptEngine {
// static QScriptValue includeScript(QScriptContext *context, QScriptEngine *engine);
static QScriptValue vdebug(QScriptContext *context, QScriptEngine *engine);
static QScriptValue findWidget(QScriptContext *context, QScriptEngine *engine);
+ static QScriptValue sleep(QScriptContext *context, QScriptEngine *engine);
void loadAllPlugins();
void tryLoadPlugin(QDir path);
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits