tor-commits
Threads by month
- ----- 2026 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- 1 participants
- 216120 discussions
[translation/whisperback_completed] Update translations for whisperback_completed
by translation@torproject.org 25 Sep '12
by translation@torproject.org 25 Sep '12
25 Sep '12
commit 0182fce0e21d2058ac3f9f9b06735af9291362b5
Author: Translation commit bot <translation(a)torproject.org>
Date: Tue Sep 25 23:45:35 2012 +0000
Update translations for whisperback_completed
---
nl/nl.po | 21 ++++++++++++---------
1 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/nl/nl.po b/nl/nl.po
index c79a479..d88f1f2 100644
--- a/nl/nl.po
+++ b/nl/nl.po
@@ -3,20 +3,23 @@
# This file is distributed under the same license as the PACKAGE package.
#
# Translators:
+# <ayurveda63(a)gmail.com>, 2012.
# Shondoit Walker <shondoit+transifex(a)gmail.com>, 2012.
+# <therbom(a)gmail.com>, 2012.
+# <unknown365(a)hotmail.com>, 2012.
msgid ""
msgstr ""
"Project-Id-Version: The Tor Project\n"
"Report-Msgid-Bugs-To: https://trac.torproject.org/projects/tor\n"
"POT-Creation-Date: 2012-02-16 22:33+0100\n"
-"PO-Revision-Date: 2012-02-26 21:19+0000\n"
-"Last-Translator: Shondoit Walker <shondoit+transifex(a)gmail.com>\n"
+"PO-Revision-Date: 2012-09-25 23:18+0000\n"
+"Last-Translator: unknown365 <unknown365(a)hotmail.com>\n"
"Language-Team: LANGUAGE <LL(a)li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: nl\n"
-"Plural-Forms: nplurals=2; plural=(n != 1)\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#. XXX use a better exception
#: ../whisperBack/whisperback.py:63
@@ -157,8 +160,8 @@ msgid "Send feedback in an encrypted mail."
msgstr "Stuur feedback in een versleutelde mail."
#: ../whisperBack/gui.py:405
-msgid "Copyright © 2009-2011 Tails developpers (tails(a)boum.org)"
-msgstr "Copyright © 2009-2011 Tails ontwikkelaars (tails(a)boum.org)"
+msgid "Copyright © 2009-2012 Tails developpers (tails(a)boum.org)"
+msgstr "Copyright © 2009-2012 Tails-ontwikkelaars (tails(a)boum.org)"
#: ../whisperBack/gui.py:406
msgid "Tails developers <tails(a)boum.org>"
@@ -182,8 +185,8 @@ msgid "Bug description"
msgstr "Foutomschrijving"
#: ../data/whisperback.ui.h:3
-msgid "Copyright © 2009-2011 tails(a)boum.org"
-msgstr "Copyright © 2009-2011 tails(a)boum.org"
+msgid "Copyright © 2009-2012 tails(a)boum.org"
+msgstr "Copyright © 2009-2012 tails(a)boum.org"
#: ../data/whisperback.ui.h:4
msgid "Help"
@@ -214,7 +217,7 @@ msgstr "Technische details om bij te voegen"
#: ../data/whisperback.ui.h:12
msgid ""
"WhisperBack - Send feedback in an encrypted mail\n"
-"Copyright (C) 2009-2011 Tails developers <tails(a)boum.org>\n"
+"Copyright (C) 2009-2012 Tails developers <tails(a)boum.org>\n"
"\n"
"This program is free software; you can redistribute it and/or modify\n"
"it under the terms of the GNU General Public License as published by\n"
@@ -228,7 +231,7 @@ msgid ""
"\n"
"You should have received a copy of the GNU General Public License\n"
"along with this program. If not, see <http://www.gnu.org/licenses/>.\n"
-msgstr "WhisperBack - Verstuur feedback in een versleutelde mail\nCopyright (C) 2009-2011 Tails ontwikkelaars <tails(a)boum.org>\n\nDit programma is vrije software; je mag het verspreiden en/of het aanpassen onder de voorwaarden van de GNU General Public License zoals gepubliceerd door de Free Software Foundation; zij het versie 3 van de Licentie, of (naar eigen keuze) enige latere versie.\n\nDit programma is verspreid in de hoop dat het nuttig is, maar ZONDER ENIGE GARANTIE; zonder zelfs de impliciete garantie van\nVERKOOPBAARHEID of GESCHIKTHEID VOOR EEN BEPAALD DOEL. Zie de GNU General Public License voor meer details.\n\nJe zou een kopie ontvangen moeten hebben van de GNU General Public License samen met dit programma. Zo niet, zie <http://www.gnu.org/licenses/>.\n"
+msgstr "WhisperBack - Stuur terugkoppeling in een versleutelde email.\nCopyright (C) 2009-2012 Tails ontwikkelaars <tail(a)boum.org>\n\nDit programma is vrije programmatuur; u kan het verspreiden en/of aanpassen\nonder de voorwaarden van de GNU General Public License zoals gepubliceerd door\nThe Free Software Foundation; ofwel versie 3 van de Licentie, of (naar\nuw keuze) elke latere versie.\n\nDit programma wordt gedistribueerd in de hoop dat het nuttig zal zijn, maar\nZONDER ENIGE GARANTIE; zelfs zonder de impliciete garantie van\nVERKOOPBAARHEID of GESCHIKTHEID VOOR EEN BEPAALD DOEL. Zie de GNU\nGeneral Public License voor meer details.\n\nU heeft een kopie moeten ontvangen van de GNU General Public License samen met dit programma. Zo niet, zie <http://www.gnu.org/licenses/>.\n"
#: ../data/whisperback.ui.h:28
msgid "debugging info"
1
0
[translation/whisperback] Update translations for whisperback
by translation@torproject.org 25 Sep '12
by translation@torproject.org 25 Sep '12
25 Sep '12
commit 3f2f7dc81b823e2395b07b3e8be74d67120245a7
Author: Translation commit bot <translation(a)torproject.org>
Date: Tue Sep 25 23:45:33 2012 +0000
Update translations for whisperback
---
nl/nl.po | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/nl/nl.po b/nl/nl.po
index 0130e99..d88f1f2 100644
--- a/nl/nl.po
+++ b/nl/nl.po
@@ -6,13 +6,14 @@
# <ayurveda63(a)gmail.com>, 2012.
# Shondoit Walker <shondoit+transifex(a)gmail.com>, 2012.
# <therbom(a)gmail.com>, 2012.
+# <unknown365(a)hotmail.com>, 2012.
msgid ""
msgstr ""
"Project-Id-Version: The Tor Project\n"
"Report-Msgid-Bugs-To: https://trac.torproject.org/projects/tor\n"
"POT-Creation-Date: 2012-02-16 22:33+0100\n"
-"PO-Revision-Date: 2012-09-20 21:10+0000\n"
-"Last-Translator: therbom <therbom(a)gmail.com>\n"
+"PO-Revision-Date: 2012-09-25 23:18+0000\n"
+"Last-Translator: unknown365 <unknown365(a)hotmail.com>\n"
"Language-Team: LANGUAGE <LL(a)li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@@ -230,7 +231,7 @@ msgid ""
"\n"
"You should have received a copy of the GNU General Public License\n"
"along with this program. If not, see <http://www.gnu.org/licenses/>.\n"
-msgstr ""
+msgstr "WhisperBack - Stuur terugkoppeling in een versleutelde email.\nCopyright (C) 2009-2012 Tails ontwikkelaars <tail(a)boum.org>\n\nDit programma is vrije programmatuur; u kan het verspreiden en/of aanpassen\nonder de voorwaarden van de GNU General Public License zoals gepubliceerd door\nThe Free Software Foundation; ofwel versie 3 van de Licentie, of (naar\nuw keuze) elke latere versie.\n\nDit programma wordt gedistribueerd in de hoop dat het nuttig zal zijn, maar\nZONDER ENIGE GARANTIE; zelfs zonder de impliciete garantie van\nVERKOOPBAARHEID of GESCHIKTHEID VOOR EEN BEPAALD DOEL. Zie de GNU\nGeneral Public License voor meer details.\n\nU heeft een kopie moeten ontvangen van de GNU General Public License samen met dit programma. Zo niet, zie <http://www.gnu.org/licenses/>.\n"
#: ../data/whisperback.ui.h:28
msgid "debugging info"
1
0
commit 94cf0b247d4e4bb95cf3bd6398ae94060ac35844
Author: Sebastian Baginski <sebthestampede(a)gmail.com>
Date: Sat Sep 15 13:26:49 2012 +0200
test code for torrc classes
---
CMakeLists.txt | 3 +
changes/bug6128 | 2 +
src/CMakeLists.txt | 4 +-
src/tests/CMakeLists.txt | 332 ++++++++++++++++++++++++++
src/tests/TorrcTest.cpp | 589 ++++++++++++++++++++++++++++++++++++++++++++++
src/tests/Torrctest.h | 44 ++++
src/tests/testMain.cpp | 43 ++++
7 files changed, 1016 insertions(+), 1 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 021de50..08a70bc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -115,6 +115,9 @@ if (USE_GEOIP)
include(${CMAKE_SOURCE_DIR}/cmake/FindGeoIP.cmake)
endif(USE_GEOIP)
+## Optional include test sources
+option(BUILD_TESTS "Build test sources" OFF)
+
## Check for system header files
check_include_file("limits.h" HAVE_LIMITS_H)
check_include_file("sys/limits.h" HAVE_SYS_LIMITS_H)
diff --git a/changes/bug6128 b/changes/bug6128
new file mode 100644
index 0000000..f261f06
--- /dev/null
+++ b/changes/bug6128
@@ -0,0 +1,2 @@
+ Internal cleanups and improvements:
+ o Create test code for Vidalia torrc classes. Fixes ticket 6128.
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 4a25aac..fefa2c6 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -65,4 +65,6 @@ add_subdirectory(common)
add_subdirectory(tools)
add_subdirectory(torcontrol)
add_subdirectory(vidalia)
-
+if (BUILD_TESTS)
+ add_subdirectory(tests)
+endif (BUILD_TESTS)
diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt
new file mode 100644
index 0000000..1d0bf34
--- /dev/null
+++ b/src/tests/CMakeLists.txt
@@ -0,0 +1,332 @@
+##
+## $Id$
+##
+## This file is part of Vidalia, and is subject to the license terms in the
+## LICENSE file, found in the top level directory of this distribution. If
+## you did not receive the LICENSE file with this file, you may obtain it
+## from the Vidalia source package distributed by the Vidalia Project at
+## http://www.torproject.org/projects/vidalia.html. No part of Vidalia,
+## including this file, may be copied, modified, propagated, or distributed
+## except according to the terms described in the LICENSE file.
+##
+
+add_definitions( -DBUILD_TESTS )
+
+include_directories(
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/about
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/torrc
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/help/browser
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/log
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/prototypes
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/extensions
+)
+
+## About dialog sources
+set(vidalia_SRCS
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/about/AboutDialog.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/about/LicenseDialog.cpp
+)
+qt4_wrap_cpp(vidalia_SRCS
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/about/AboutDialog.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/about/LicenseDialog.h
+)
+
+## Plugin framework sources
+set(vidalia_SRCS ${vidalia_SRCS}
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/PluginEngine.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/PluginWrapper.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/DebugDialog.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/prototypes/HelperProcessPrototype.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/prototypes/TorrcPrototype.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/extensions/VidaliaExtensions.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/extensions/VidaliaExtensionsInit.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/extensions/qtscript_BootstrapStatus.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/extensions/qtscript_Circuit.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/extensions/qtscript_ControlCommand.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/extensions/qtscript_ControlConnection.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/extensions/qtscript_ControlMethod.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/extensions/qtscript_ControlReply.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/extensions/qtscript_ControlSocket.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/extensions/qtscript_ReplyLine.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/extensions/qtscript_RouterDescriptor.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/extensions/qtscript_RouterStatus.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/extensions/qtscript_SendCommandEvent.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/extensions/qtscript_Stream.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/extensions/qtscript_TorControl.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/extensions/qtscript_TorEvents.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/extensions/qtscript_TorProcess.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/extensions/qtscript_TorSignal.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/extensions/qtscript_VidaliaTab.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/extensions/qtscriptshell_ControlConnection.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/extensions/qtscriptshell_ControlMethod.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/extensions/qtscriptshell_ControlSocket.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/extensions/qtscriptshell_TorControl.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/extensions/qtscriptshell_TorEvents.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/extensions/qtscriptshell_TorProcess.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/extensions/qtscriptshell_TorSignal.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/extensions/qtscriptshell_VidaliaTab.cpp
+)
+qt4_wrap_cpp(vidalia_SRCS
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/PluginEngine.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/PluginWrapper.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/DebugDialog.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/prototypes/HelperProcessPrototype.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/prototypes/TorrcPrototype.h
+)
+
+## Configuration dialog sources
+set(vidalia_SRCS ${vidalia_SRCS}
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/AbstractTorSettings.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/AdvancedPage.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/AppearancePage.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/BridgeUsageDialog.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/ConfigDialog.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/ConfigPageStack.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/DomainValidator.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/ExitPolicy.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/GeneralPage.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/IpValidator.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/Local8BitStringValidator.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/NetworkPage.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/NetworkSettings.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/NicknameValidator.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/Policy.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/PortValidator.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/ServerPage.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/ServerSettings.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/TorrcDialog.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/TorSettings.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/VidaliaSettings.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/VSettings.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/torrc/TorrcParser.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/torrc/Torrc.cpp
+)
+qt4_wrap_cpp(vidalia_SRCS
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/AbstractTorSettings.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/AdvancedPage.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/AppearancePage.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/BridgeUsageDialog.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/ConfigDialog.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/ConfigPage.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/ConfigPageStack.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/DomainValidator.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/GeneralPage.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/Local8BitStringValidator.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/NetworkPage.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/NetworkSettings.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/NicknameValidator.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/PortValidator.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/ServerPage.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/ServerSettings.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/TorrcDialog.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/TorSettings.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/VidaliaSettings.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/VSettings.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/torrc/Torrc.h
+)
+if (USE_MINIUPNPC)
+ include_directories(${MINIUPNPC_INCLUDE_DIR})
+ set(vidalia_SRCS ${vidalia_SRCS}
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/UPNPControl.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/UPNPControlThread.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/UPNPTestDialog.cpp
+ )
+ qt4_wrap_cpp(vidalia_SRCS
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/UPNPControl.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/UPNPControlThread.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/UPNPTestDialog.h
+ )
+endif(USE_MINIUPNPC)
+
+## Main Vidalia sources (without main.cpp)
+set(vidalia_SRCS ${vidalia_SRCS}
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/Vidalia.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/LanguageSupport.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/VTabWidget.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/VAttachButton.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/MainWindow.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/VidaliaWindow.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/VMessageBox.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/ControlPasswordInputDialog.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/VidaliaTab.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/StatusTab.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/HelperProcess.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/FirstRunWizard.cpp
+)
+qt4_wrap_cpp(vidalia_SRCS
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/Vidalia.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/VTabWidget.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/VAttachButton.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/MainWindow.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/VidaliaWindow.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/VMessageBox.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/ControlPasswordInputDialog.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/VidaliaTab.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/StatusTab.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/HelperProcess.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/FirstRunWizard.h
+)
+
+if (USE_MINIUPNPC)
+ qt4_wrap_ui(vidalia_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/UPNPTestDialog.ui)
+endif(USE_MINIUPNPC)
+
+## Specify all the Qt Designer .ui files
+qt4_wrap_ui(vidalia_SRCS
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/ControlPasswordInputDialog.ui
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/StatusTab.ui
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/MainWindow.ui
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/about/AboutDialog.ui
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/about/LicenseDialog.ui
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/AdvancedPage.ui
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/AppearancePage.ui
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/BridgeUsageDialog.ui
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/ConfigDialog.ui
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/GeneralPage.ui
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/NetworkPage.ui
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/ServerPage.ui
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/config/TorrcDialog.ui
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/log/MessageLog.ui
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/help/browser/HelpBrowser.ui
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/NetViewer.ui
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/RouterInfoDialog.ui
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/plugin/DebugDialog.ui
+)
+
+## Add the resource files (icons, etc.)
+qt4_add_resources(vidalia_SRCS
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/res/vidalia.qrc
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/help/content/content.qrc
+ ${CMAKE_CURRENT_BINARY_DIR}/../vidalia/i18n/vidalia_i18n.qrc
+)
+
+## Network map sources
+set(vidalia_SRCS ${vidalia_SRCS}
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/CircuitItem.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/CircuitListWidget.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/CountryInfo.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/GeoIpRecord.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/GeoIpResolver.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/NetViewer.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/RouterDescriptorView.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/RouterInfoDialog.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/RouterListItem.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/RouterListWidget.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/StreamItem.cpp
+)
+qt4_wrap_cpp(vidalia_SRCS
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/CircuitListWidget.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/CountryInfo.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/GeoIpResolver.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/NetViewer.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/RouterDescriptorView.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/RouterInfoDialog.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/RouterListWidget.h
+)
+if (USE_MARBLE)
+ set(vidalia_SRCS ${vidalia_SRCS}
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/TorMapWidget.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/TorMapWidgetPopupMenu.cpp
+ )
+ qt4_wrap_cpp(vidalia_SRCS
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/TorMapWidget.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/TorMapWidgetPopupMenu.h
+ )
+else(USE_MARBLE)
+ set(vidalia_SRCS ${vidalia_SRCS}
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/TorMapImageView.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/ZImageView.cpp
+ )
+ qt4_wrap_cpp(vidalia_SRCS
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/TorMapImageView.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/ZImageView.h
+ )
+endif(USE_MARBLE)
+if (USE_GEOIP)
+ set(vidalia_SRCS ${vidalia_SRCS}
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/GeoIpDatabase.cpp
+ )
+ qt4_wrap_cpp(vidalia_SRCS
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/network/GeoIpDatabase.h
+ )
+endif(USE_GEOIP)
+
+## Help browser sources
+set(vidalia_SRCS ${vidalia_SRCS}
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/help/browser/HelpBrowser.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/help/browser/HelpTextBrowser.cpp
+)
+qt4_wrap_cpp(vidalia_SRCS
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/help/browser/HelpBrowser.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/help/browser/HelpTextBrowser.h
+)
+
+## Message log sources
+set(vidalia_SRCS ${vidalia_SRCS}
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/log/LogFile.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/log/LogHeaderView.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/log/LogMessageColumnDelegate.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/log/LogTreeItem.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/log/LogTreeWidget.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/log/MessageLog.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/log/StatusEventItem.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/log/StatusEventItemDelegate.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/log/StatusEventWidget.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/log/LogFilter.cpp
+)
+qt4_wrap_cpp(vidalia_SRCS
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/log/LogFile.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/log/LogHeaderView.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/log/LogTreeWidget.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/log/MessageLog.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/log/StatusEventItemDelegate.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/../vidalia/log/StatusEventWidget.h
+)
+
+
+## Bootstrap test sources
+set(vidalia_SRCS ${vidalia_SRCS}
+ testMain.cpp
+ TorrcTest.cpp
+)
+qt4_wrap_cpp(vidalia_SRCS
+ TorrcTest.h
+)
+
+set(test_BIN VidaliaTestSuite)
+
+add_executable(${test_BIN} ${vidalia_SRCS})
+target_link_libraries(${test_BIN}
+ ${QT_LIBRARIES}
+ ${QT_QTTEST_LIBRARY}
+ common
+ torcontrol
+)
+if (USE_MINIUPNPC)
+ target_link_libraries(${test_BIN} miniupnpc)
+endif(USE_MINIUPNPC)
+if (USE_BREAKPAD)
+ target_link_libraries(${test_BIN} ${BREAKPAD_LIBRARY})
+endif(USE_BREAKPAD)
+if (USE_MARBLE)
+ target_link_libraries(${test_BIN}
+ ${MARBLE_LIBRARIES}
+ ${QT_QTSVG_LIBRARY}
+ )
+endif(USE_MARBLE)
+if (USE_GEOIP)
+ target_link_libraries(${test_BIN} ${GEOIP_LIBRARIES})
+endif(USE_GEOIP)
+
+if (APPLE)
+ target_link_libraries(${test_BIN}
+ "-framework AppKit"
+ iconv
+ )
+endif(APPLE)
diff --git a/src/tests/TorrcTest.cpp b/src/tests/TorrcTest.cpp
new file mode 100644
index 0000000..1e2a026
--- /dev/null
+++ b/src/tests/TorrcTest.cpp
@@ -0,0 +1,589 @@
+/*
+** This file is part of Vidalia, and is subject to the license terms in the
+** LICENSE file, found in the top level directory of this distribution. If you
+** did not receive the LICENSE file with this file, you may obtain it from the
+** Vidalia source package distributed by the Vidalia Project at
+** http://www.torproject.org/projects/vidalia.html. No part of Vidalia,
+** including this file, may be copied, modified, propagated, or distributed
+** except according to the terms described in the LICENSE file.
+*/
+
+/*
+** \file TorrcTest.cpp
+** \brief test of torrc handling
+*/
+
+#include "TorrcTest.h"
+#include "TorrcParser.h"
+#include "Torrc.h"
+#include "Vidalia.h"
+#include "MainWindow.h"
+#include <QTimer>
+#include <QEventLoop>
+
+/** Constructor. */
+TorrcTestSuite::TorrcTestSuite(QObject *parent)
+ :QObject(parent)
+{
+
+}
+
+/** Destructor. */
+TorrcTestSuite::~TorrcTestSuite()
+{
+
+}
+
+/** Test TorrcLine class */
+void TorrcTestSuite::testTorrcLine()
+{
+ const int count = 100;
+
+ // test single lined values
+ for (int i=0 ; i<count ; ++i) {
+ const QString content = QString("test_content_%1").arg(i);
+ const QString comment = QString("test_comment_%1").arg(i);
+ TorrcLine tLine(content,comment);
+ QCOMPARE(content, tLine.content());
+ QCOMPARE(comment, tLine.comment());
+ QVERIFY(tLine.isMultilined() == false);
+ tLine.setComment(content);
+ tLine.setContent(comment);
+ QCOMPARE(comment, tLine.content());
+ QCOMPARE(content, tLine.comment());
+ QVERIFY(tLine.isMultilined() == false);
+ }
+
+ // test multilined TorrcLine
+ for (int i=0 ; i<count ; ++i) {
+ const QString content = QString("test\\multiline\\content\\%1\\").arg(i);
+ const QString comment = QString("test\\multiline\\comment\\%1\\").arg(i);
+ TorrcLine tLine(content,comment);
+ QCOMPARE(content, tLine.content());
+ QCOMPARE(comment, tLine.comment());
+ QVERIFY(tLine.isMultilined() == true);
+ tLine.setComment(content);
+ tLine.setContent(comment);
+ QCOMPARE(comment, tLine.content());
+ QCOMPARE(content, tLine.comment());
+ QVERIFY(tLine.isMultilined() == true);
+ }
+}
+
+/** Test parser class */
+void TorrcTestSuite::testTorrcParser()
+{
+ const QString testFilePath("vidalia_test_suite_torrc_file.txt");
+ QFile file(testFilePath);
+ if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
+ QVERIFY(false && "Cannot open test torrc file!");
+ const int optCount = 100;
+ QList< QPair<QString,QString> > testData;
+ // create test file
+ QString content;
+ for (int i=0 ; i<optCount ; ++i) {
+ const QString optName = QString("option_%1 value_%1").arg(i);
+ const QString optComt = QString("#comment_%1").arg(i);
+ content += optName + optComt;
+ testData.append( QPair<QString,QString>(optName,optComt) );
+ if (i<optCount-1)
+ content += "\n";
+ }
+ file.write(content.toAscii());
+ file.close();
+
+ TorrcParser parser;
+ QMap<QString, QPair<QString, TorOpt> > map;
+ QList<TorrcLine*> lines = parser.parse(testFilePath,map);
+ QVERIFY(lines.isEmpty() == false);
+ QCOMPARE(lines.count(), optCount);
+
+ for (int i=0 ; i<optCount ; ++i) {
+ TorrcLine * line = lines.at(i);
+ QVERIFY(line != NULL);
+ QCOMPARE(line->content(), testData[i].first);
+ QCOMPARE(line->comment(), testData[i].second);
+ }
+
+ // verify loaded values (all should be null)
+ QCOMPARE(map.count(), optCount);
+ foreach (QString key, map.keys()) {
+ QString value = map[key].first;
+ TorOpt opt = map[key].second;
+ QVERIFY(value.startsWith("value_"));
+ QVERIFY(opt.isNull());
+ }
+
+ qDeleteAll(lines);
+ QVERIFY( QFile::remove(testFilePath) );
+}
+
+QList<TorOpt> createTestOpts();
+QString createTestValue(TorOpt::OptType);
+QString defaultValue(const QString &);
+
+/** Test main Torrc class */
+void TorrcTestSuite::testTorrc()
+{
+ const QString testFilePath("vidalia_test_suite_torrc_file.txt");
+ QFile file(testFilePath);
+ if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
+ QVERIFY(false && "Cannot open test torrc file!");
+ QList<TorOpt> opts = createTestOpts();
+ QList< QPair<QString,QString> > testData;
+ foreach (const TorOpt &opt, opts) {
+ testData.append( QPair<QString,QString>(opt.name(),createTestValue(opt.type())) );
+ }
+ // create test file with real option names and values
+ QString content;
+ for (int i=0 ; i<testData.count() ; ++i) {
+ const QString optName = testData[i].first + " " + testData[i].second;
+ const QString optComt = QString("#comment_%1").arg(i);
+ content += optName + optComt;
+ if (i<testData.count()-1)
+ content += "\n";
+ }
+ file.write(content.toAscii());
+ file.close();
+
+ TorrcParser parser;
+ QMap<QString, QPair<QString, TorOpt> > map;
+ QList<TorrcLine*> lines = parser.parse(testFilePath,map);
+ QVERIFY(lines.isEmpty() == false);
+ QCOMPARE(lines.count(), testData.count());
+
+ for (int i=0 ; i<testData.count() ; ++i) {
+ TorrcLine * line = lines.at(i);
+ QVERIFY(line != NULL);
+ QCOMPARE(line->content(), QString(testData[i].first + " " + testData[i].second).trimmed());
+ QCOMPARE(line->comment(), QString("#comment_%1").arg(i));
+ }
+
+ // verify loaded values
+ foreach (QString key, map.keys()) {
+ QString value = map[key].first;
+ TorOpt opt = map[key].second;
+ QCOMPARE(value, createTestValue(opt.type()));
+ QVERIFY(opt.isNull() == false);
+ QVERIFY(testData.contains( QPair<QString,QString>(key,value) ));
+ }
+
+ qDeleteAll(lines);
+
+ // test torrc object
+ Torrc torrc(testFilePath);
+ QCOMPARE(torrc.getTorrcPath(), testFilePath);
+ for (int i=0 ; i<testData.count() ; ++i) {
+ // test the data in torrc file
+ QVERIFY(torrc.isValid(testData[i].first, testData[i].second));
+ QStringList values = torrc.value(testData[i].first);
+ if (testData[i].second.isEmpty()==false) {
+ QVERIFY(values.contains(testData[i].second));
+ }
+ // test if clearing a value works ok
+ torrc.clear(QStringList() << testData[i].first);
+ values = torrc.value(testData[i].first);
+ if (testData[i].second.isEmpty()==false) {
+ QVERIFY(values.contains(testData[i].second) == false);
+ }
+ }
+ QVERIFY(torrc.apply(Vidalia::torControl()));
+ // after applying changes, we test the file content
+ QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text));
+ content = file.readAll();
+ file.close();
+ for (int i=0 ; i<testData.count() ; ++i) {
+ QVERIFY(content.contains(testData[i].first) == false);
+ }
+ // test adding values to empty file
+ QVERIFY(QFile::remove(testFilePath));
+ QVERIFY(file.open(QIODevice::WriteOnly | QIODevice::Text));
+ file.write("");
+ file.close();
+ torrc.load(testFilePath);
+ int lastKeyPos = -1; // value for checking if <key, value> pairs are present in the file
+ for (int i=0 ; i<testData.count() ; ++i) {
+ torrc.setValue(testData[i].first,testData[i].second);
+ QVERIFY(torrc.apply(Vidalia::torControl()));
+ QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text));
+ content = file.readAll();
+ file.close();
+ // if value is default for given key, file should not contain the entry
+ if (testData[i].second == defaultValue(testData[i].first)) {
+ QVERIFY(content.contains(testData[i].first)==false);
+ } else {
+ // check if key is in the file, and the value follows
+ QVERIFY(content.contains(testData[i].first));
+ lastKeyPos = content.indexOf(testData[i].first,lastKeyPos+1);
+ int nlPos = content.indexOf("\n",lastKeyPos);
+ if (nlPos == -1)
+ nlPos = content.length();
+ const int valPos = content.indexOf(testData[i].second,lastKeyPos);
+ QVERIFY(valPos != -1);
+ QVERIFY(valPos < nlPos);
+ }
+ }
+ QVERIFY(QFile::remove(testFilePath));
+}
+
+inline bool
+compareValues(const QVariant& var, const QString& value){
+ bool ok = false;
+ const double r = value.toDouble(&ok);
+ if (ok)
+ return qFuzzyCompare(var.toDouble(),r);
+ else
+ return var.toString() == value;
+}
+
+void TorrcTestSuite::testRunningTor()
+{
+ MainWindow * mw = new MainWindow;
+ mw->show();
+ TorControl * torControl = Vidalia::torControl();
+ QVERIFY(torControl);
+
+ // start tor, make sure we wont wait forever
+ QEventLoop loop;
+ QTimer timeoutCheck;
+ timeoutCheck.setSingleShot(true);
+ timeoutCheck.setInterval(120*1000);
+ connect(&timeoutCheck, SIGNAL(timeout()), &loop, SLOT(quit()));
+ connect(torControl, SIGNAL(started()), &loop, SLOT(quit()));
+ QTimer::singleShot(0,mw,SLOT(start()));
+ timeoutCheck.start();
+ loop.exec();
+ qApp->processEvents();
+
+ if (timeoutCheck.isActive()) {
+ vWarn("Tor process started.");
+ QVERIFY(torControl->isConnected());
+ QVERIFY(torControl->isRunning());
+
+ // create test torrc file
+ const QString testFilePath("vidalia_test_suite_torrc_file.txt");
+ QFile file(testFilePath);
+ if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
+ QVERIFY(false && "Cannot open test torrc file!");
+
+ QHash<QString,QString> testData;
+ testData["AccountingMax"] = "0";
+ testData["AllowDotExit"] = "0";
+ testData["AllowInvalidNodes"] = "middle,rendezvous";
+ testData["AllowNonRFC953Hostnames"] = "0";
+ testData["AllowSingleHopCircuits"] = "0";
+ testData["BridgeRecordUsageByCountry"] = "0";
+ testData["CircuitIdleTimeout"] = "3600";
+ testData["CircuitPriorityHalflife"] = "-100.0";
+ testData["ControlPort"] = "9051";
+ testData["CookieAuthentication"] = "0";
+ testData["DataDirectory"] = "C:\\DifferentDataDirectory";
+ testData["PortForwarding"] = "0";
+ testData["ProtocolWarnings"] = "0";
+ testData["User"] = "userid";
+ // data directory should remain unchanged
+ const QString dataDir = torControl->getConf("DataDirectory").toString();
+
+ QString content;
+ foreach (QString key, testData) {
+ content += key + " " + testData[key] + "#comment\n";
+ }
+ file.write(content.toAscii());
+ file.close();
+ Torrc torrc(testFilePath);
+ QVERIFY( torrc.apply(torControl) );
+
+ // check values in running tor instance
+ foreach (QString key, testData) {
+ const QVariant val = torControl->getConf(key);
+ if (key == "DataDirectory"){
+ QCOMPARE(dataDir,val.toString());
+ } else
+ QVERIFY(compareValues(val,testData[key]));
+ }
+ // create new test data, different from current tor values
+ testData.remove("DataDirectory");
+ testData["AccountingMax"] = "1";
+ testData["AllowDotExit"] = "1";
+ testData["AllowInvalidNodes"] = "middle";
+ testData["AllowNonRFC953Hostnames"] = "1";
+ testData["AllowSingleHopCircuits"] = "1";
+ testData["BridgeRecordUsageByCountry"] = "1";
+ testData["CircuitIdleTimeout"] = "900";
+ testData["CircuitPriorityHalflife"] = "-150.0";
+ testData["ControlPort"] = "8974";
+ testData["CookieAuthentication"] = "1";
+ testData["PortForwarding"] = "1";
+ testData["ProtocolWarnings"] = "1";
+ testData["User"] = "u2id";
+
+ // check if values are applied ok
+ QVERIFY( torrc.apply(torControl) );
+ foreach (QString key, testData) {
+ const QVariant val = torControl->getConf(key);
+ QVERIFY(compareValues(val,testData[key]));
+ }
+ QVERIFY(QFile::remove(testFilePath));
+ } else {
+ QVERIFY(false && "Cannot start the tor process!");
+ }
+ mw->deleteLater();
+}
+
+QList<TorOpt>
+createTestOpts()
+{
+ QList<TorOpt> opt;
+ opt << TorOpt("AccountingMax", TorOpt::DataSize, "0");
+ opt << TorOpt("AccountingStart", TorOpt::String, "");
+ opt << TorOpt("Address", TorOpt::String, "");
+ opt << TorOpt("AllowDotExit", TorOpt::Boolean, "0");
+ opt << TorOpt("AllowInvalidNodes", TorOpt::CommaList, "middle,rendezvous");
+ opt << TorOpt("AllowNonRFC953Hostnames", TorOpt::Boolean, "0");
+ opt << TorOpt("AllowSingleHopCircuits", TorOpt::Boolean, "0");
+ opt << TorOpt("AllowSingleHopExits", TorOpt::Boolean, "0");
+ opt << TorOpt("AlternateBridgeAuthority", TorOpt::LineList, "");
+ opt << TorOpt("AlternateDirAuthority", TorOpt::LineList, "");
+ opt << TorOpt("AlternateHSAuthority", TorOpt::LineList, "");
+ opt << TorOpt("AssumeReachable", TorOpt::Boolean, "0");
+ opt << TorOpt("AuthDirBadDir", TorOpt::LineList, "");
+ opt << TorOpt("AuthDirBadExit", TorOpt::LineList, "");
+ opt << TorOpt("AuthDirInvalid", TorOpt::LineList, "");
+ opt << TorOpt("AuthDirReject", TorOpt::LineList, "");
+ opt << TorOpt("AuthDirRejectUnlisted", TorOpt::Boolean, "0");
+ opt << TorOpt("AuthDirListBadDirs", TorOpt::Boolean, "0");
+ opt << TorOpt("AuthDirListBadExits", TorOpt::Boolean, "0");
+ opt << TorOpt("AuthDirMaxServersPerAddr", TorOpt::Integer, "2");
+ opt << TorOpt("AuthDirMaxServersPerAuthAddr", TorOpt::Integer, "5");
+ opt << TorOpt("AuthoritativeDirectory", TorOpt::Boolean, "0");
+ opt << TorOpt("AutomapHostsOnResolve", TorOpt::Boolean, "0");
+ opt << TorOpt("AutomapHostsSuffixes", TorOpt::CommaList, ".onion,.exit");
+ opt << TorOpt("AvoidDiskWrites", TorOpt::Boolean, "0");
+ opt << TorOpt("BandwidthBurst", TorOpt::DataSize, "10485760");
+ opt << TorOpt("BandwidthRate", TorOpt::DataSize, "5242880");
+ opt << TorOpt("BridgeAuthoritativeDir", TorOpt::Boolean, "0");
+ opt << TorOpt("Bridge", TorOpt::LineList, "");
+ opt << TorOpt("BridgePassword", TorOpt::String, "");
+ opt << TorOpt("BridgeRecordUsageByCountry", TorOpt::Boolean, "1");
+ opt << TorOpt("BridgeRelay", TorOpt::Boolean, "0");
+ opt << TorOpt("CellStatistics", TorOpt::Boolean, "0");
+ opt << TorOpt("LearnCircuitBuildTimeout", TorOpt::Boolean, "1");
+ opt << TorOpt("CircuitBuildTimeout", TorOpt::TimeInterval, "0");
+ opt << TorOpt("CircuitIdleTimeout", TorOpt::TimeInterval, "3600");
+ opt << TorOpt("CircuitStreamTimeout", TorOpt::TimeInterval, "0");
+ opt << TorOpt("CircuitPriorityHalflife", TorOpt::Float, "-100.0");
+ opt << TorOpt("ClientDNSRejectInternalAddresses", TorOpt::Boolean, "1");
+ opt << TorOpt("ClientOnly", TorOpt::Boolean, "0");
+ opt << TorOpt("ClientRejectInternalAddresses", TorOpt::Boolean, "1");
+ opt << TorOpt("ClientTransportPlugin", TorOpt::LineList, "");
+ opt << TorOpt("ConsensusParams", TorOpt::String, "");
+ opt << TorOpt("ConnLimit", TorOpt::Integer, "1000");
+ opt << TorOpt("ConnDirectionStatistics", TorOpt::Boolean, "0");
+ opt << TorOpt("ConstrainedSockets", TorOpt::Boolean, "0");
+ opt << TorOpt("ConstrainedSockSize", TorOpt::DataSize, "8192");
+ opt << TorOpt("ContactInfo", TorOpt::String, "");
+ opt << TorOpt("ControlListenAddress", TorOpt::LineList, "");
+ opt << TorOpt("ControlPort", TorOpt::Port, "9051");
+ opt << TorOpt("ControlPortFileGroupReadable", TorOpt::Boolean, "0");
+ opt << TorOpt("ControlPortWriteToFile", TorOpt::Filename, "");
+ opt << TorOpt("ControlSocket", TorOpt::LineList, "");
+ opt << TorOpt("ControlSocketsGroupWritable", TorOpt::Boolean, "0");
+ opt << TorOpt("CookieAuthentication", TorOpt::Boolean, "0");
+ opt << TorOpt("CookieAuthFileGroupReadable", TorOpt::Boolean, "0");
+ opt << TorOpt("CookieAuthFile", TorOpt::String, "");
+ opt << TorOpt("CountPrivateBandwidth", TorOpt::Boolean, "0");
+ opt << TorOpt("DataDirectory", TorOpt::Filename, "");
+ opt << TorOpt("DirAllowPrivateAddresses", TorOpt::Boolean, "0");
+ opt << TorOpt("TestingAuthDirTimeToLearnReachability", TorOpt::TimeInterval, "1800");
+ opt << TorOpt("DirListenAddress", TorOpt::LineList, "");
+ opt << TorOpt("DirPolicy", TorOpt::LineList, "");
+ opt << TorOpt("DirPort", TorOpt::Port, "0");
+ opt << TorOpt("DirPortFrontPage", TorOpt::Filename, "");
+ opt << TorOpt("DirServer", TorOpt::LineList, "");
+ opt << TorOpt("DisableAllSwap", TorOpt::Boolean, "0");
+ opt << TorOpt("DisableIOCP", TorOpt::Boolean, "1");
+ opt << TorOpt("DisableNetwork", TorOpt::Boolean, "0");
+ opt << TorOpt("DNSPort", TorOpt::LineList, "");
+ opt << TorOpt("DNSListenAddress", TorOpt::LineList, "");
+ opt << TorOpt("DownloadExtraInfo", TorOpt::Boolean, "0");
+ opt << TorOpt("EnforceDistinctSubnets", TorOpt::Boolean, "1");
+ opt << TorOpt("EntryNodes", TorOpt::RouterList, "");
+ opt << TorOpt("EntryStatistics", TorOpt::Boolean, "0");
+ opt << TorOpt("TestingEstimatedDescriptorPropagationTime", TorOpt::TimeInterval, "600");
+ opt << TorOpt("ExcludeNodes", TorOpt::RouterList, "");
+ opt << TorOpt("ExcludeExitNodes", TorOpt::RouterList, "");
+ opt << TorOpt("ExcludeSingleHopRelays", TorOpt::Boolean, "1");
+ opt << TorOpt("ExitNodes", TorOpt::RouterList, "");
+ opt << TorOpt("ExitPolicy", TorOpt::LineList, "");
+ opt << TorOpt("ExitPolicyRejectPrivate", TorOpt::Boolean, "1");
+ opt << TorOpt("ExitPortStatistics", TorOpt::Boolean, "0");
+ opt << TorOpt("ExtraInfoStatistics", TorOpt::Boolean, "1");
+ opt << TorOpt("FallbackNetworkstatusFile", TorOpt::Filename, "/usr/local/share/tor/fallback-consensus");
+ opt << TorOpt("FascistFirewall", TorOpt::Boolean, "0");
+ opt << TorOpt("FirewallPorts", TorOpt::CommaList, "");
+ opt << TorOpt("FastFirstHopPK", TorOpt::Boolean, "1");
+ opt << TorOpt("FetchDirInfoEarly", TorOpt::Boolean, "0");
+ opt << TorOpt("FetchDirInfoExtraEarly", TorOpt::Boolean, "0");
+ opt << TorOpt("FetchServerDescriptors", TorOpt::Boolean, "1");
+ opt << TorOpt("FetchHidServDescriptors", TorOpt::Boolean, "1");
+ opt << TorOpt("FetchUselessDescriptors", TorOpt::Boolean, "0");
+ opt << TorOpt("FetchV2Networkstatus", TorOpt::Boolean, "0");
+ opt << TorOpt("GeoIPFile", TorOpt::Filename, "/usr/local/share/tor/geoip");
+ opt << TorOpt("GiveGuardFlagTo_CVE_2011_2768_VulnerableRelays", TorOpt::Boolean, "0");
+ opt << TorOpt("HardwareAccel", TorOpt::Boolean, "0");
+ opt << TorOpt("HeartbeatPeriod", TorOpt::TimeInterval, "21300");
+ opt << TorOpt("AccelName", TorOpt::String, "");
+ opt << TorOpt("AccelDir", TorOpt::Filename, "");
+ opt << TorOpt("HashedControlPassword", TorOpt::String, "");
+ opt << TorOpt("HidServDirectoryV2", TorOpt::Boolean, "1");
+ opt << TorOpt("HiddenServiceDir", TorOpt::Dependant, "");
+ opt << TorOpt("HiddenServiceOptions", TorOpt::Virtual, "");
+ opt << TorOpt("HiddenServicePort", TorOpt::Dependant, "");
+ opt << TorOpt("HiddenServiceVersion", TorOpt::Dependant, "");
+ opt << TorOpt("HiddenServiceAuthorizeClient", TorOpt::Dependant, "");
+ opt << TorOpt("HidServAuth", TorOpt::LineList, "");
+ opt << TorOpt("HSAuthoritativeDir", TorOpt::Boolean, "0");
+ opt << TorOpt("HTTPProxy", TorOpt::String, "");
+ opt << TorOpt("HTTPProxyAuthenticator", TorOpt::String, "");
+ opt << TorOpt("HTTPSProxy", TorOpt::String, "");
+ opt << TorOpt("HTTPSProxyAuthenticator", TorOpt::String, "");
+ opt << TorOpt("ServerTransportPlugin", TorOpt::LineList, "");
+ opt << TorOpt("Socks4Proxy", TorOpt::String, "");
+ opt << TorOpt("Socks5Proxy", TorOpt::String, "");
+ opt << TorOpt("Socks5ProxyUsername", TorOpt::String, "");
+ opt << TorOpt("Socks5ProxyPassword", TorOpt::String, "");
+ opt << TorOpt("KeepalivePeriod", TorOpt::TimeInterval, "300");
+ opt << TorOpt("Log", TorOpt::LineList, "");
+ opt << TorOpt("LogMessageDomains", TorOpt::Boolean, "0");
+ opt << TorOpt("LogTimeGranularity", TorOpt::TimeMsecInterval, "1000");
+ opt << TorOpt("LongLivedPorts", TorOpt::CommaList, "21,22,706,1863,5050,5190,5222,5223,6523,6667,6697,8300");
+ opt << TorOpt("MapAddress", TorOpt::LineList, "");
+ opt << TorOpt("MaxAdvertisedBandwidth", TorOpt::DataSize, "1073741824");
+ opt << TorOpt("MaxCircuitDirtiness", TorOpt::TimeInterval, "600");
+ opt << TorOpt("MaxClientCircuitsPending", TorOpt::Integer, "32");
+ opt << TorOpt("MaxOnionsPending", TorOpt::Integer, "100");
+ opt << TorOpt("MyFamily", TorOpt::String, "");
+ opt << TorOpt("NewCircuitPeriod", TorOpt::TimeInterval, "30");
+ opt << TorOpt("NamingAuthoritativeDirectory", TorOpt::Boolean, "0");
+ opt << TorOpt("NATDListenAddress", TorOpt::LineList, "");
+ opt << TorOpt("NATDPort", TorOpt::LineList, "0");
+ opt << TorOpt("Nickname", TorOpt::String, "");
+ opt << TorOpt("WarnUnsafeSocks", TorOpt::Boolean, "1");
+ opt << TorOpt("NodeFamily", TorOpt::LineList, "");
+ opt << TorOpt("NumCPUs", TorOpt::Integer, "0");
+ opt << TorOpt("NumEntryGuards", TorOpt::Integer, "3");
+ opt << TorOpt("ORListenAddress", TorOpt::LineList, "");
+ opt << TorOpt("ORPort", TorOpt::Port, "0");
+ opt << TorOpt("OutboundBindAddress", TorOpt::String, "");
+ opt << TorOpt("PerConnBWBurst", TorOpt::DataSize, "0");
+ opt << TorOpt("PerConnBWRate", TorOpt::DataSize, "0");
+ opt << TorOpt("PidFile", TorOpt::String, "");
+ opt << TorOpt("TestingTorNetwork", TorOpt::Boolean, "0");
+ opt << TorOpt("OptimisticData", TorOpt::BooleanAuto, "auto");
+ opt << TorOpt("PortForwarding", TorOpt::Boolean, "0");
+ opt << TorOpt("PortForwardingHelper", TorOpt::Filename, "tor-fw-helper");
+ opt << TorOpt("PreferTunneledDirConns", TorOpt::Boolean, "1");
+ opt << TorOpt("ProtocolWarnings", TorOpt::Boolean, "0");
+ opt << TorOpt("PublishServerDescriptor", TorOpt::CommaList, "1");
+ opt << TorOpt("PublishHidServDescriptors", TorOpt::Boolean, "1");
+ opt << TorOpt("ReachableAddresses", TorOpt::LineList, "");
+ opt << TorOpt("ReachableDirAddresses", TorOpt::LineList, "");
+ opt << TorOpt("ReachableORAddresses", TorOpt::LineList, "");
+ opt << TorOpt("RecommendedVersions", TorOpt::LineList, "");
+ opt << TorOpt("RecommendedClientVersions", TorOpt::LineList, "");
+ opt << TorOpt("RecommendedServerVersions", TorOpt::LineList, "");
+ opt << TorOpt("RefuseUnknownExits", TorOpt::BooleanAuto, "auto");
+ opt << TorOpt("RejectPlaintextPorts", TorOpt::CommaList, "");
+ opt << TorOpt("RelayBandwidthBurst", TorOpt::DataSize, "0");
+ opt << TorOpt("RelayBandwidthRate", TorOpt::DataSize, "0");
+ opt << TorOpt("RendPostPeriod", TorOpt::TimeInterval, "3600");
+ opt << TorOpt("RephistTrackTime", TorOpt::TimeInterval, "36000");
+ opt << TorOpt("RunAsDaemon", TorOpt::Boolean, "0");
+ opt << TorOpt("SafeLogging", TorOpt::String, "1");
+ opt << TorOpt("SafeSocks", TorOpt::Boolean, "0");
+ opt << TorOpt("ServerDNSAllowBrokenConfig", TorOpt::Boolean, "1");
+ opt << TorOpt("ServerDNSAllowNonRFC953Hostnames", TorOpt::Boolean, "0");
+ opt << TorOpt("ServerDNSDetectHijacking", TorOpt::Boolean, "1");
+ opt << TorOpt("ServerDNSRandomizeCase", TorOpt::Boolean, "1");
+ opt << TorOpt("ServerDNSResolvConfFile", TorOpt::String, "");
+ opt << TorOpt("ServerDNSSearchDomains", TorOpt::Boolean, "0");
+ opt << TorOpt("ServerDNSTestAddresses", TorOpt::CommaList, "www.google.com,www.mit.edu,www.yahoo.com,www.slashdot.org");
+ opt << TorOpt("ShutdownWaitLength", TorOpt::TimeInterval, "30");
+ opt << TorOpt("SocksListenAddress", TorOpt::LineList, "");
+ opt << TorOpt("SocksPolicy", TorOpt::LineList, "");
+ opt << TorOpt("SocksPort", TorOpt::LineList, "9051");
+ opt << TorOpt("SocksTimeout", TorOpt::TimeInterval, "200");
+ opt << TorOpt("StrictNodes", TorOpt::Boolean, "0");
+ opt << TorOpt("TestSocks", TorOpt::Boolean, "0");
+ opt << TorOpt("TokenBucketRefillInterval", TorOpt::TimeMsecInterval, "100");
+ opt << TorOpt("TrackHostExits", TorOpt::CommaList, "");
+ opt << TorOpt("TrackHostExitsExpire", TorOpt::TimeInterval, "1800");
+ opt << TorOpt("TransListenAddress", TorOpt::LineList, "");
+ opt << TorOpt("TransPort", TorOpt::LineList, "0");
+ opt << TorOpt("TunnelDirConns", TorOpt::Boolean, "1");
+ opt << TorOpt("UpdateBridgesFromAuthority", TorOpt::Boolean, "0");
+ opt << TorOpt("UseBridges", TorOpt::Boolean, "0");
+ opt << TorOpt("UseEntryGuards", TorOpt::Boolean, "1");
+ opt << TorOpt("UseMicrodescriptors", TorOpt::BooleanAuto, "auto");
+ opt << TorOpt("User", TorOpt::String, "");
+ opt << TorOpt("V1AuthoritativeDirectory", TorOpt::Boolean, "0");
+ opt << TorOpt("V2AuthoritativeDirectory", TorOpt::Boolean, "0");
+ opt << TorOpt("V3AuthoritativeDirectory", TorOpt::Boolean, "0");
+ opt << TorOpt("TestingV3AuthInitialVotingInterval", TorOpt::TimeInterval, "1800");
+ opt << TorOpt("TestingV3AuthInitialVoteDelay", TorOpt::TimeInterval, "300");
+ opt << TorOpt("TestingV3AuthInitialDistDelay", TorOpt::TimeInterval, "300");
+ opt << TorOpt("V3AuthVotingInterval", TorOpt::TimeInterval, "3600");
+ opt << TorOpt("V3AuthVoteDelay", TorOpt::TimeInterval, "300");
+ opt << TorOpt("V3AuthDistDelay", TorOpt::TimeInterval, "300");
+ opt << TorOpt("V3AuthNIntervalsValid", TorOpt::Integer, "3");
+ opt << TorOpt("V3AuthUseLegacyKey", TorOpt::Boolean, "0");
+ opt << TorOpt("V3BandwidthsFile", TorOpt::Filename, "");
+ opt << TorOpt("VersioningAuthoritativeDirectory", TorOpt::Boolean, "0");
+ opt << TorOpt("VirtualAddrNetwork", TorOpt::String, "127.192.0.0/10");
+ opt << TorOpt("WarnPlaintextPorts", TorOpt::CommaList, "23,109,110,143");
+ opt << TorOpt("_UseFilteringSSLBufferevents", TorOpt::Boolean, "0");
+ opt << TorOpt("__ReloadTorrcOnSIGHUP", TorOpt::Boolean, "1");
+ opt << TorOpt("__AllDirActionsPrivate", TorOpt::Boolean, "0");
+ opt << TorOpt("__DisablePredictedCircuits", TorOpt::Boolean, "0");
+ opt << TorOpt("__LeaveStreamsUnattached", TorOpt::Boolean, "0");
+ opt << TorOpt("__HashedControlSessionPassword", TorOpt::LineList, "");
+ opt << TorOpt("__OwningControllerProcess", TorOpt::String, "");
+ opt << TorOpt("MinUptimeHidServDirectoryV2", TorOpt::TimeInterval, "1500");
+ opt << TorOpt("VoteOnHidServDirectoriesV2", TorOpt::Boolean, "1");
+ opt << TorOpt("_UsingTestNetworkDefaults", TorOpt::Boolean, "0");
+ return opt;
+}
+
+QString
+createTestValue(TorOpt::OptType type)
+{
+ switch (type) {
+ case TorOpt::TimeInterval: return "32684";
+ case TorOpt::TimeMsecInterval: return "5000";
+ case TorOpt::String: return "test_string";
+ case TorOpt::RouterList: return "";
+ case TorOpt::LineList: return "123 456 789";
+ case TorOpt::Float: return "3.14";
+ case TorOpt::Dependant: return "dep";
+ case TorOpt::Virtual: return "virt";
+ case TorOpt::Filename: return "/usr/share/test/test.txt";
+ case TorOpt::CommaList: return "12,43,521,123";
+ case TorOpt::Boolean: return "1";
+ case TorOpt::BooleanAuto: return "1";
+ case TorOpt::Integer: return "7";
+ case TorOpt::DataSize: return "128";
+ case TorOpt::Port: return "9053";
+ case TorOpt::NIL: return "";
+ }
+}
+
+QString
+defaultValue(const QString& optName)
+{
+ static QList<TorOpt> opts = createTestOpts();
+ foreach (const TorOpt& opt, opts) {
+ if (opt.name() == optName)
+ return opt.defaultValue();
+ }
+ return QString();
+}
diff --git a/src/tests/Torrctest.h b/src/tests/Torrctest.h
new file mode 100644
index 0000000..14bce17
--- /dev/null
+++ b/src/tests/Torrctest.h
@@ -0,0 +1,44 @@
+/*
+** This file is part of Vidalia, and is subject to the license terms in the
+** LICENSE file, found in the top level directory of this distribution. If you
+** did not receive the LICENSE file with this file, you may obtain it from the
+** Vidalia source package distributed by the Vidalia Project at
+** http://www.torproject.org/projects/vidalia.html. No part of Vidalia,
+** including this file, may be copied, modified, propagated, or distributed
+** except according to the terms described in the LICENSE file.
+*/
+
+/*
+** \file TorrcTest.h
+** \brief test of torrc file handling
+*/
+
+#ifndef _TORRC_TEST_H
+#define _TORRC_TEST_H
+
+#include <QtTest/QTest>
+
+/** Full torrc test suite. */
+class TorrcTestSuite : public QObject
+{
+ Q_OBJECT
+
+public:
+ /** Constructor. */
+ TorrcTestSuite(QObject * parent = NULL);
+ /** Destructor. */
+ ~TorrcTestSuite();
+
+private slots:
+ /** Test TorrcLine class */
+ void testTorrcLine();
+ /** Test parser class */
+ void testTorrcParser();
+ /** Test main Torrc class */
+ void testTorrc();
+ /** Test with running Tor */
+ void testRunningTor();
+
+};
+
+#endif
diff --git a/src/tests/testMain.cpp b/src/tests/testMain.cpp
new file mode 100644
index 0000000..7632636
--- /dev/null
+++ b/src/tests/testMain.cpp
@@ -0,0 +1,43 @@
+/*
+** This file is part of Vidalia, and is subject to the license terms in the
+** LICENSE file, found in the top level directory of this distribution. If you
+** did not receive the LICENSE file with this file, you may obtain it from the
+** Vidalia source package distributed by the Vidalia Project at
+** http://www.torproject.org/projects/vidalia.html. No part of Vidalia,
+** including this file, may be copied, modified, propagated, or distributed
+** except according to the terms described in the LICENSE file.
+*/
+
+/*
+** \file testMain.cpp
+** \brief Main Vidalia entry point for test target
+*/
+
+#include "Vidalia.h"
+#include "stringutil.h"
+#include "TorrcTest.h"
+
+#include <QtTest/QTest>
+
+/** Helper method to run test cases. */
+template<typename T>
+void runTest(){
+ T * t = new T();
+ const int ret = QTest::qExec(t,QApplication::arguments());
+ if( ret != 0 ){
+ vError(QString("%1: test failed!").arg(t->metaObject()->className()));
+ }
+ delete t;
+}
+
+/** Main application entry point. */
+int
+main(int argc, char *argv[])
+{
+ const QStringList args = char_array_to_stringlist(argv+1, argc-1);
+ Vidalia vidalia(args, argc, argv);
+ /* Launch each test class */
+ runTest<TorrcTestSuite>();
+ return 0;
+}
+
1
0
[vidalia-plugins/master] Add sanity checks for bandwidth scheduler
by chiiph@torproject.org 25 Sep '12
by chiiph@torproject.org 25 Sep '12
25 Sep '12
commit a1decc38737c83e579993d8ead1f527ce3a84925
Author: Feroze Naina <ferozenaina(a)gmail.com>
Date: Mon Aug 20 18:56:18 2012 +0530
Add sanity checks for bandwidth scheduler
---
bwscheduler/bwscheduler.js | 24 +++++++++++++++++++++++-
1 files changed, 23 insertions(+), 1 deletions(-)
diff --git a/bwscheduler/bwscheduler.js b/bwscheduler/bwscheduler.js
index 2ce553b..03d96c9 100644
--- a/bwscheduler/bwscheduler.js
+++ b/bwscheduler/bwscheduler.js
@@ -156,7 +156,29 @@ var bwscheduler = {
enableApply: function() {
this.btnDiscard.enabled = true;
- this.btnApply.enabled = true;
+ if (this.sanityCheck())
+ this.btnApply.enabled = true;
+ else
+ this.btnApply.enabled = false;
+ },
+
+ sanityCheck: function() {
+ for (var i = 0; i < this.customwidget.length; i++) {
+ if (this.timeStart[i].time > this.timeEnd[i].time) {
+ this.lineError[i].setText("Start Time must be lesser than End Time");
+ this.lineError[i].show();
+ return false;
+ }
+ if (this.cmbUnit[i].currentText == "KB") {
+ if (this.spinRate[i].value > 0 && this.spinRate[i].value < 25) {
+ this.lineError[i].setText("Bandwidth Rate must be atleast 25 KB");
+ this.lineError[i].show();
+ return false;
+ }
+ }
+ }
+
+ return true;
},
enableRemove: function() {
1
0
[vidalia-plugins/master] Add scheduler backend to handle bandwidth limits
by chiiph@torproject.org 25 Sep '12
by chiiph@torproject.org 25 Sep '12
25 Sep '12
commit 5df0403bdac4250ae7891a73c4e802042da00cb8
Author: Feroze Naina <ferozenaina(a)gmail.com>
Date: Sun Aug 19 23:21:54 2012 +0530
Add scheduler backend to handle bandwidth limits
---
bwscheduler/bwscheduler.js | 257 ++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 257 insertions(+), 0 deletions(-)
diff --git a/bwscheduler/bwscheduler.js b/bwscheduler/bwscheduler.js
new file mode 100644
index 0000000..1f8b754
--- /dev/null
+++ b/bwscheduler/bwscheduler.js
@@ -0,0 +1,257 @@
+importExtension("qt");
+importExtension("qt.core");
+importExtension("qt.gui");
+importExtension("qt.uitools");
+importExtension("qt.network");
+
+var bwscheduler = {
+
+ weekDays : ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],
+
+ start: function() {
+ vdebug("BandwidthScheduler@start");
+
+ var configPath = pluginPath + "/bwscheduler/config.ini";
+ this.settings = new QSettings(configPath, QSettings.NativeFormat);
+
+ this.timer = new QTimer();
+ this.timer['timeout()'].connect(this, this.updateRate);
+ this.timer.start(60000);
+ },
+
+ updateRate: function() {
+ torrc.clear(["BandwidthRate", "BandwidthBurst"]);
+
+ var currentTime = QTime.currentTime();
+ var today = new Date()
+
+ var size = this.settings.beginReadArray("schedules");
+
+ for (var i = 0; i < size; i++) {
+ this.settings.setArrayIndex(i);
+ var day = this.settings.value("cmbDay");
+ var startTime = QTime.fromString(this.settings.value("timeStart"), "hh:mm");
+ var endTime = QTime.fromString(this.settings.value("timeEnd"), "hh:mm");
+ var bwRate = this.settings.value("spinRate");
+ var bwUnit = this.settings.value("cmbUnit");
+
+ if (startTime <= currentTime && currentTime <= endTime) {
+ if (day == "Everyday") {
+ torrc.setValue("BandwidthRate" , bwRate + " " + bwUnit);
+ torrc.setValue("BandwidthBurst" , bwRate + " " + bwUnit);
+ }
+ else if (day == this.weekDays[today.getDay()]) {
+ torrc.setValue("BandwidthRate" , bwRate + " " + bwUnit);
+ torrc.setValue("BandwidthBurst" , bwRate + " " + bwUnit);
+ }
+ }
+ }
+
+ this.settings.endArray();
+ torrc.apply(torControl);
+ },
+
+ updateList: function() {
+ try{
+ for (var i = 0; i < this.customwidget.length; i++) {
+ this.customwidget[i].hide();
+ this.listLayout.removeWidget(this.customwidget[i]);
+ }
+ }
+ catch(err){}
+
+ this.customwidget = new Array();
+ this.grpBox = new Array();
+ this.cmbDay = new Array();
+ this.timeStart = new Array();
+ this.timeEnd = new Array();
+ this.spinRate = new Array();
+ this.cmbUnit = new Array();
+ this.chkRemove = new Array();
+ this.lineError = new Array();
+
+ this.listLayout = this.scrollArea.widget().layout();
+ while(this.listLayout.count() > 1) this.listLayout.takeAt(0);
+
+ var loader = new QUiLoader(this.containerWidget);
+
+ var size = this.settings.beginReadArray("schedules");
+
+ for (var i = 0; i < size; i++) {
+ this.customwidget[i] = loader.load(new QFile(pluginPath + "/bwscheduler/schedulerwidget.ui"));
+ this.grpBox[i] = this.customwidget[i].children()[findWidget(this.customwidget[i], "groupBox")];
+ this.cmbDay[i] = this.grpBox[i].children()[findWidget(this.grpBox[i], "cmbDay")];
+ this.timeStart[i] = this.grpBox[i].children()[findWidget(this.grpBox[i], "timeStart")];
+ this.timeEnd[i] = this.grpBox[i].children()[findWidget(this.grpBox[i], "timeEnd")];
+ this.spinRate[i] = this.grpBox[i].children()[findWidget(this.grpBox[i], "spinRate")];
+ this.cmbUnit[i] = this.grpBox[i].children()[findWidget(this.grpBox[i], "cmbUnit")];
+ this.chkRemove[i] = this.grpBox[i].children()[findWidget(this.grpBox[i], "chkRemove")];
+ this.lineError[i] = this.grpBox[i].children()[findWidget(this.grpBox[i], "lineError")];
+ this.fillDays(this.cmbDay[i]);
+
+ this.settings.setArrayIndex(i);
+ this.cmbDay[i].setCurrentIndex(this.cmbDay[i].findText(this.settings.value("cmbDay")));
+ this.timeStart[i].time = QTime.fromString(this.settings.value("timeStart"), "hh:mm");
+ this.timeEnd[i].time = QTime.fromString(this.settings.value("timeEnd"), "hh:mm");
+ this.spinRate[i].value = this.settings.value("spinRate");
+ this.cmbUnit[i].setCurrentIndex(this.cmbUnit[i].findText(this.settings.value("cmbUnit")));
+
+ this.cmbDay[i]['currentIndexChanged(int)'].connect(this, this.enableApply);
+ this.timeStart[i]['timeChanged(QTime)'].connect(this, this.enableApply);
+ this.timeEnd[i]['timeChanged(QTime)'].connect(this, this.enableApply);
+ this.spinRate[i]['valueChanged(int)'].connect(this, this.enableApply);
+ this.cmbUnit[i]['currentIndexChanged(int)'].connect(this, this.enableApply);
+ this.chkRemove[i]['stateChanged(int)'].connect(this, this.enableRemove);
+
+ this.listLayout.insertWidget(0, this.customwidget[i], 0, 0);
+ }
+
+ this.settings.endArray();
+
+ this.btnApply.enabled = false;
+ this.btnDiscard.enabled = false;
+ },
+
+ applyServices: function() {
+ this.settings.remove("schedules");
+ this.settings.beginWriteArray("schedules");
+ for (var i = 0; i < this.customwidget.length; i++) {
+ this.settings.setArrayIndex(i);
+ this.settings.setValue("cmbDay", this.cmbDay[i].currentText);
+ this.settings.setValue("timeStart", this.timeStart[i].time.toString("hh:mm"));
+ this.settings.setValue("timeEnd", this.timeEnd[i].time.toString("hh:mm"));
+ this.settings.setValue("spinRate", this.spinRate[i].value);
+ this.settings.setValue("cmbUnit", this.cmbUnit[i].currentText);
+ }
+ this.settings.endArray();
+
+ this.updateList();
+ this.btnApply.enabled = false;
+ this.btnDiscard.enabled = false;
+ },
+
+ removeServices: function() {
+ this.settings.remove("schedules");
+ this.settings.beginWriteArray("schedules");
+ var pos = 0;
+ for (var i = 0; i < this.customwidget.length; i++) {
+ if (this.chkRemove[i].checkState() == Qt.Unchecked) {
+ this.settings.setArrayIndex(pos);
+ this.settings.setValue("cmbDay", this.cmbDay[i].currentText);
+ this.settings.setValue("timeStart", this.timeStart[i].time.toString("hh:mm"));
+ this.settings.setValue("timeEnd", this.timeEnd[i].time.toString("hh:mm"));
+ this.settings.setValue("spinRate", this.spinRate[i].value);
+ this.settings.setValue("cmbUnit", this.cmbUnit[i].currentText);
+ pos++;
+ }
+ }
+ this.settings.endArray();
+
+ this.updateList();
+ this.btnRemove.enabled = false;
+ },
+
+ enableApply: function() {
+ this.btnDiscard.enabled = true;
+ this.btnApply.enabled = true;
+ },
+
+ enableRemove: function() {
+ this.btnRemove.enabled = false;
+ for (var i = 0; i < this.customwidget.length; i++) {
+ if (this.chkRemove[i].checkState() == Qt.Checked) {
+ this.btnRemove.enabled = true;
+ break;
+ }
+ }
+ },
+
+ addService: function() {
+ var loader = new QUiLoader(this.containerWidget);
+ this.customwidget.push(loader.load(new QFile(pluginPath + "/bwscheduler/schedulerwidget.ui")));
+ var pos = this.customwidget.length-1;
+
+ this.grpBox[pos] = this.customwidget[pos].children()[findWidget(this.customwidget[pos], "groupBox")];
+ this.cmbDay[pos] = this.grpBox[pos].children()[findWidget(this.grpBox[pos], "cmbDay")];
+ this.timeStart[pos] = this.grpBox[pos].children()[findWidget(this.grpBox[pos], "timeStart")];
+ this.timeEnd[pos] = this.grpBox[pos].children()[findWidget(this.grpBox[pos], "timeEnd")];
+ this.spinRate[pos] = this.grpBox[pos].children()[findWidget(this.grpBox[pos], "spinRate")];
+ this.cmbUnit[pos] = this.grpBox[pos].children()[findWidget(this.grpBox[pos], "cmbUnit")];
+ this.chkRemove[pos] = this.grpBox[pos].children()[findWidget(this.grpBox[pos], "chkRemove")];
+ this.lineError[pos] = this.grpBox[pos].children()[findWidget(this.grpBox[pos], "lineError")];
+ this.fillDays(this.cmbDay[pos]);
+
+ this.cmbDay[pos]['currentIndexChanged(int)'].connect(this, this.enableApply);
+ this.timeStart[pos]['timeChanged(QTime)'].connect(this, this.enableApply);
+ this.timeEnd[pos]['timeChanged(QTime)'].connect(this, this.enableApply);
+ this.spinRate[pos]['valueChanged(int)'].connect(this, this.enableApply);
+ this.chkRemove[pos]['stateChanged(int)'].connect(this, this.enableRemove);
+
+ this.listLayout.insertWidget(0, this.customwidget[pos], 0, 0);
+ },
+
+ fillDays: function(cmbDay) {
+ cmbDay.addItem("Everyday");
+ cmbDay.addItem("Sunday", Qt.Sunday);
+ cmbDay.addItem("Monday", Qt.Monday);
+ cmbDay.addItem("Tuesday", Qt.Tuesday);
+ cmbDay.addItem("Wednesday", Qt.Wednesday);
+ cmbDay.addItem("Thursday", Qt.Thursday);
+ cmbDay.addItem("Friday", Qt.Friday);
+ cmbDay.addItem("Saturday", Qt.Saturday);
+ },
+
+ buildGUI: function() {
+ vdebug("BandwidthScheduler@buildGUI");
+
+ this.tab = new VidaliaTab("Bandwidth Scheduler", "BandwidthScheduler");
+
+ var containerui = new QFile(pluginPath + "/bwscheduler/bwscheduler.ui");
+ var loader = new QUiLoader(this.tab);
+ containerui.open(QIODevice.ReadOnly);
+
+ this.containerwidget = loader.load(containerui);
+
+ var layout = new QVBoxLayout();
+ layout.addWidget(this.containerwidget, 0, Qt.AlignCenter);
+ this.tab.setLayout(layout);
+
+ this.scrollArea = this.containerwidget.children()[findWidget(this.containerwidget, "scrollArea")];
+ if (this.scrollArea == null)
+ return this.tab;
+
+ this.chkEnabled = this.containerwidget.children()[findWidget(this.containerwidget, "chkEnabled")];
+ if (this.chkEnabled == null)
+ return this.tab;
+
+ this.btnAdd = this.containerwidget.children()[findWidget(this.containerwidget, "btnAdd")];
+ if (this.btnAdd == null)
+ return this.tab;
+
+ this.btnRemove = this.containerwidget.children()[findWidget(this.containerwidget, "btnRemove")];
+ if (this.btnRemove == null)
+ return this.tab;
+
+ this.btnApply = this.containerwidget.children()[findWidget(this.containerwidget, "btnApply")];
+ if (this.btnApply == null)
+ return this.tab;
+
+ this.btnDiscard = this.containerwidget.children()[findWidget(this.containerwidget, "btnDiscard")];
+ if (this.btnDiscard == null)
+ return this.tab;
+
+ this.btnAdd['clicked()'].connect(this, this.addService);
+ this.btnRemove['clicked()'].connect(this, this.removeServices);
+ this.btnApply['clicked()'].connect(this, this.applyServices);
+ this.btnDiscard['clicked()'].connect(this, this.updateList);
+
+ this.updateList();
+
+ return this.tab;
+ },
+
+
+ stop: function() {
+ vdebug("Tutorial@stop");
+ },
+};
1
0
25 Sep '12
commit 5558973925b7653c313593d1a86b0d6c04935c2f
Author: Feroze Naina <ferozenaina(a)gmail.com>
Date: Sun Aug 19 23:20:31 2012 +0530
Add UI for bandwidth scheduler plugin
---
bwscheduler/bwscheduler.ui | 177 ++++++++++++++++++++++++++++++++++++++++
bwscheduler/info.xml | 11 +++
bwscheduler/schedulerwidget.ui | 141 ++++++++++++++++++++++++++++++++
3 files changed, 329 insertions(+), 0 deletions(-)
diff --git a/bwscheduler/bwscheduler.ui b/bwscheduler/bwscheduler.ui
new file mode 100644
index 0000000..9b270f6
--- /dev/null
+++ b/bwscheduler/bwscheduler.ui
@@ -0,0 +1,177 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Form</class>
+ <widget class="QWidget" name="Form">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>670</width>
+ <height>628</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="2" column="0">
+ <spacer name="horizontalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="1" column="0" colspan="6">
+ <widget class="QScrollArea" name="scrollArea">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>600</width>
+ <height>400</height>
+ </size>
+ </property>
+ <property name="widgetResizable">
+ <bool>true</bool>
+ </property>
+ <widget class="QWidget" name="scrollAreaWidgetContents">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>650</width>
+ <height>537</height>
+ </rect>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>495</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QPushButton" name="btnApply">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Apply</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="5">
+ <widget class="QPushButton" name="btnRemove">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>32</width>
+ <height>32</height>
+ </size>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="icon">
+ <iconset resource="../../vidalia/src/vidalia/res/vidalia.qrc">
+ <normaloff>:/images/22x22/list-remove.png</normaloff>:/images/22x22/list-remove.png</iconset>
+ </property>
+ <property name="iconSize">
+ <size>
+ <width>22</width>
+ <height>22</height>
+ </size>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="2" colspan="4">
+ <widget class="QPushButton" name="btnDiscard">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Discard Changes</string>
+ </property>
+ <property name="default">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="4">
+ <widget class="QPushButton" name="btnAdd">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>32</width>
+ <height>32</height>
+ </size>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="icon">
+ <iconset resource="../../vidalia/src/vidalia/res/vidalia.qrc">
+ <normaloff>:/images/22x22/list-add.png</normaloff>:/images/22x22/list-add.png</iconset>
+ </property>
+ <property name="iconSize">
+ <size>
+ <width>22</width>
+ <height>22</height>
+ </size>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0">
+ <widget class="QCheckBox" name="chkEnabled">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Enable Bandwidth Scheduler</string>
+ </property>
+ <property name="checked">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources>
+ <include location="../../vidalia/src/vidalia/res/vidalia.qrc"/>
+ </resources>
+ <connections/>
+</ui>
diff --git a/bwscheduler/info.xml b/bwscheduler/info.xml
new file mode 100644
index 0000000..d3700a4
--- /dev/null
+++ b/bwscheduler/info.xml
@@ -0,0 +1,11 @@
+<VidaliaPlugin>
+ <name>Bandwidth Scheduler</name>
+ <date>30/07/2012</date>
+ <author>feroze</author>
+ <type persistent="true" gui="true" />
+ <files>
+ <file>bwscheduler.js</file>
+ </files>
+ <namespace>bwscheduler</namespace>
+ <icon>:/images/16x16/preferences-system.png</icon>
+</VidaliaPlugin>
diff --git a/bwscheduler/schedulerwidget.ui b/bwscheduler/schedulerwidget.ui
new file mode 100644
index 0000000..7fbaa5e
--- /dev/null
+++ b/bwscheduler/schedulerwidget.ui
@@ -0,0 +1,141 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Form</class>
+ <widget class="QWidget" name="Form">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>488</width>
+ <height>208</height>
+ </rect>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>400</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QGroupBox" name="groupBox">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>410</width>
+ <height>190</height>
+ </size>
+ </property>
+ <property name="title">
+ <string/>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="2" column="1">
+ <widget class="QLabel" name="lblStartTime">
+ <property name="text">
+ <string>Start Time</string>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="1">
+ <widget class="QLabel" name="lblBW">
+ <property name="text">
+ <string>Bandwidth</string>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="2">
+ <widget class="QSpinBox" name="spinRate"/>
+ </item>
+ <item row="4" column="1">
+ <widget class="QLabel" name="lblEndTime">
+ <property name="text">
+ <string>End Time</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLabel" name="lblDay">
+ <property name="text">
+ <string>Day</string>
+ </property>
+ </widget>
+ </item>
+ <item row="10" column="1" colspan="2">
+ <widget class="QCheckBox" name="chkRemove">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>25</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Mark for removal</string>
+ </property>
+ </widget>
+ </item>
+ <item row="11" column="2">
+ <widget class="QLabel" name="lineError">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="3">
+ <widget class="QComboBox" name="cmbUnit">
+ <item>
+ <property name="text">
+ <string>KB</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>MB</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>GB</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="4" column="2" colspan="2">
+ <widget class="QTimeEdit" name="timeEnd">
+ <property name="displayFormat">
+ <string>HH:mm</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="2" colspan="2">
+ <widget class="QTimeEdit" name="timeStart">
+ <property name="displayFormat">
+ <string>HH:mm</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="2" colspan="2">
+ <widget class="QComboBox" name="cmbDay"/>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
1
0
[vidalia-plugins/master] Allow user to enable or disable bandwidth scheduler
by chiiph@torproject.org 25 Sep '12
by chiiph@torproject.org 25 Sep '12
25 Sep '12
commit 025a6f5a0b54adf534ab90fb57be08f2272c3750
Author: Feroze Naina <ferozenaina(a)gmail.com>
Date: Sun Aug 19 23:23:03 2012 +0530
Allow user to enable or disable bandwidth scheduler
---
bwscheduler/bwscheduler.js | 69 +++++++++++++++++++++++++++----------------
bwscheduler/bwscheduler.ui | 4 +-
2 files changed, 45 insertions(+), 28 deletions(-)
diff --git a/bwscheduler/bwscheduler.js b/bwscheduler/bwscheduler.js
index 1f8b754..2ce553b 100644
--- a/bwscheduler/bwscheduler.js
+++ b/bwscheduler/bwscheduler.js
@@ -5,6 +5,7 @@ importExtension("qt.uitools");
importExtension("qt.network");
var bwscheduler = {
+ SETTING_ENABLED: "BandwidthSchedulerEnabled",
weekDays : ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],
@@ -20,35 +21,37 @@ var bwscheduler = {
},
updateRate: function() {
- torrc.clear(["BandwidthRate", "BandwidthBurst"]);
-
- var currentTime = QTime.currentTime();
- var today = new Date()
-
- var size = this.settings.beginReadArray("schedules");
-
- for (var i = 0; i < size; i++) {
- this.settings.setArrayIndex(i);
- var day = this.settings.value("cmbDay");
- var startTime = QTime.fromString(this.settings.value("timeStart"), "hh:mm");
- var endTime = QTime.fromString(this.settings.value("timeEnd"), "hh:mm");
- var bwRate = this.settings.value("spinRate");
- var bwUnit = this.settings.value("cmbUnit");
-
- if (startTime <= currentTime && currentTime <= endTime) {
- if (day == "Everyday") {
- torrc.setValue("BandwidthRate" , bwRate + " " + bwUnit);
- torrc.setValue("BandwidthBurst" , bwRate + " " + bwUnit);
- }
- else if (day == this.weekDays[today.getDay()]) {
- torrc.setValue("BandwidthRate" , bwRate + " " + bwUnit);
- torrc.setValue("BandwidthBurst" , bwRate + " " + bwUnit);
+ if (this.settings.value(this.SETTING_ENABLED) == "true") {
+ torrc.clear(["BandwidthRate", "BandwidthBurst"]);
+
+ var currentTime = QTime.currentTime();
+ var today = new Date()
+
+ var size = this.settings.beginReadArray("schedules");
+
+ for (var i = 0; i < size; i++) {
+ this.settings.setArrayIndex(i);
+ var day = this.settings.value("cmbDay");
+ var startTime = QTime.fromString(this.settings.value("timeStart"), "hh:mm");
+ var endTime = QTime.fromString(this.settings.value("timeEnd"), "hh:mm");
+ var bwRate = this.settings.value("spinRate");
+ var bwUnit = this.settings.value("cmbUnit");
+
+ if (startTime <= currentTime && currentTime <= endTime) {
+ if (day == "Everyday") {
+ torrc.setValue("BandwidthRate" , bwRate + " " + bwUnit);
+ torrc.setValue("BandwidthBurst" , bwRate + " " + bwUnit);
+ }
+ else if (day == this.weekDays[today.getDay()]) {
+ torrc.setValue("BandwidthRate" , bwRate + " " + bwUnit);
+ torrc.setValue("BandwidthBurst" , bwRate + " " + bwUnit);
+ }
}
}
- }
- this.settings.endArray();
- torrc.apply(torControl);
+ this.settings.endArray();
+ torrc.apply(torControl);
+ }
},
updateList: function() {
@@ -240,16 +243,30 @@ var bwscheduler = {
if (this.btnDiscard == null)
return this.tab;
+ this.chkEnabled['stateChanged(int)'].connect(this, this.toggleEnabled);
this.btnAdd['clicked()'].connect(this, this.addService);
this.btnRemove['clicked()'].connect(this, this.removeServices);
this.btnApply['clicked()'].connect(this, this.applyServices);
this.btnDiscard['clicked()'].connect(this, this.updateList);
+ this.chkEnabled.setCheckState((this.settings.value(this.SETTING_ENABLED, "false") == "true")?Qt.Checked:Qt.Unchecked);
+
this.updateList();
return this.tab;
},
+ toggleEnabled: function() {
+ var enableScheduler = (this.chkEnabled.checkState() == Qt.Checked) ? true : false;
+ this.settings.setValue(this.SETTING_ENABLED, enableScheduler.toString());
+ this.scrollArea.setEnabled(enableScheduler);
+ this.btnAdd.setEnabled(enableScheduler);
+
+ if (! enableScheduler) {
+ torrc.clear(["BandwidthRate", "BandwidthBurst"]);
+ torrc.apply(torControl);
+ }
+ },
stop: function() {
vdebug("Tutorial@stop");
diff --git a/bwscheduler/bwscheduler.ui b/bwscheduler/bwscheduler.ui
index 9b270f6..4daf621 100644
--- a/bwscheduler/bwscheduler.ui
+++ b/bwscheduler/bwscheduler.ui
@@ -30,7 +30,7 @@
<item row="1" column="0" colspan="6">
<widget class="QScrollArea" name="scrollArea">
<property name="enabled">
- <bool>true</bool>
+ <bool>false</bool>
</property>
<property name="minimumSize">
<size>
@@ -123,7 +123,7 @@
<item row="0" column="4">
<widget class="QPushButton" name="btnAdd">
<property name="enabled">
- <bool>true</bool>
+ <bool>false</bool>
</property>
<property name="minimumSize">
<size>
1
0
[torbrowser/master] Add mozIThirdPartyUtil.getFirstPartyURI API patch.
by mikeperry@torproject.org 25 Sep '12
by mikeperry@torproject.org 25 Sep '12
25 Sep '12
commit 31f5977ea51d755e758c2846edd6fcb8c8209b7b
Author: Mike Perry <mikeperry-git(a)fscked.org>
Date: Tue Sep 25 14:18:07 2012 -0700
Add mozIThirdPartyUtil.getFirstPartyURI API patch.
---
...d-mozIThirdPartyUtil.getFirstPartyURI-API.patch | 148 ++++++++++++++++++++
1 files changed, 148 insertions(+), 0 deletions(-)
diff --git a/src/current-patches/firefox/alpha/0020-Add-mozIThirdPartyUtil.getFirstPartyURI-API.patch b/src/current-patches/firefox/alpha/0020-Add-mozIThirdPartyUtil.getFirstPartyURI-API.patch
new file mode 100644
index 0000000..d7a24d9
--- /dev/null
+++ b/src/current-patches/firefox/alpha/0020-Add-mozIThirdPartyUtil.getFirstPartyURI-API.patch
@@ -0,0 +1,148 @@
+From e91ad38f3db238eebf2f1cae9383a6f317717bef Mon Sep 17 00:00:00 2001
+From: Mike Perry <mikeperry-git(a)torproject.org>
+Date: Tue, 28 Aug 2012 18:35:33 -0700
+Subject: [PATCH 20/21] Add mozIThirdPartyUtil.getFirstPartyURI API
+
+API allows you to get the url bar URI for a channel or nsIDocument.
+---
+ content/base/src/ThirdPartyUtil.cpp | 52 ++++++++++++++++++++++++++++
+ content/base/src/ThirdPartyUtil.h | 2 +
+ netwerk/base/public/mozIThirdPartyUtil.idl | 21 +++++++++++
+ 3 files changed, 75 insertions(+), 0 deletions(-)
+
+diff --git a/content/base/src/ThirdPartyUtil.cpp b/content/base/src/ThirdPartyUtil.cpp
+index 97a000e..87ffc8a 100644
+--- a/content/base/src/ThirdPartyUtil.cpp
++++ b/content/base/src/ThirdPartyUtil.cpp
+@@ -7,6 +7,9 @@
+ #include "nsIServiceManager.h"
+ #include "nsIHttpChannelInternal.h"
+ #include "nsIDOMWindow.h"
++#include "nsICookiePermission.h"
++#include "nsIDOMDocument.h"
++#include "nsIDocument.h"
+ #include "nsILoadContext.h"
+ #include "nsIPrincipal.h"
+ #include "nsIScriptObjectPrincipal.h"
+@@ -21,6 +24,7 @@ ThirdPartyUtil::Init()
+
+ nsresult rv;
+ mTLDService = do_GetService(NS_EFFECTIVETLDSERVICE_CONTRACTID, &rv);
++ mCookiePermissions = do_GetService(NS_COOKIEPERMISSION_CONTRACTID);
+ return rv;
+ }
+
+@@ -282,3 +286,51 @@ ThirdPartyUtil::GetBaseDomain(nsIURI* aHostURI,
+
+ return NS_OK;
+ }
++
++NS_IMETHODIMP
++ThirdPartyUtil::GetFirstPartyURI(nsIChannel *aChannel,
++ nsIDocument *aDoc,
++ nsIURI **aOutput)
++{
++ nsresult rv = NS_ERROR_NULL_POINTER;
++
++ if (!aChannel && aDoc) {
++ aChannel = aDoc->GetChannel();
++ }
++
++ // If aChannel is specified or available, use the official route
++ // for sure
++ if (aChannel) {
++ rv = mCookiePermissions->GetOriginatingURI(aChannel, aOutput);
++ }
++
++ // If the channel was missing, closed or broken, try the
++ // window hierarchy directly.
++ //
++ // This might fail to work for first-party loads themselves, but
++ // we don't need this codepath for that case.
++ if (NS_FAILED(rv) && aDoc) {
++ nsCOMPtr<nsIDOMWindow> top;
++ nsCOMPtr<nsIDOMDocument> topDDoc;
++
++ aDoc->GetWindow()->GetTop(getter_AddRefs(top));
++ top->GetDocument(getter_AddRefs(topDDoc));
++
++ nsCOMPtr<nsIDocument> topDoc(do_QueryInterface(topDDoc));
++ *aOutput = topDoc->GetOriginalURI();
++
++ if (*aOutput)
++ rv = NS_OK;
++ }
++
++ // TODO: We could provide a route through the loadgroup + notification
++ // callbacks too, but either channel or document was always available
++ // in the cases where this function was originally needed (the image cache).
++ // The notification callbacks also appear to suffers from the same limitation
++ // as the document path. See nsICookiePermissions.GetOriginatingURI() for
++ // details.
++
++ return rv;
++}
++
++
+diff --git a/content/base/src/ThirdPartyUtil.h b/content/base/src/ThirdPartyUtil.h
+index 269069b..37c30e8 100644
+--- a/content/base/src/ThirdPartyUtil.h
++++ b/content/base/src/ThirdPartyUtil.h
+@@ -9,6 +9,7 @@
+ #include "nsString.h"
+ #include "mozIThirdPartyUtil.h"
+ #include "nsIEffectiveTLDService.h"
++#include "nsICookiePermission.h"
+
+ class nsIURI;
+ class nsIChannel;
+@@ -28,6 +29,7 @@ private:
+ static already_AddRefed<nsIURI> GetURIFromWindow(nsIDOMWindow* aWin);
+
+ nsCOMPtr<nsIEffectiveTLDService> mTLDService;
++ nsCOMPtr<nsICookiePermission> mCookiePermissions;
+ };
+
+ #endif
+diff --git a/netwerk/base/public/mozIThirdPartyUtil.idl b/netwerk/base/public/mozIThirdPartyUtil.idl
+index 578d8db..1869d14 100644
+--- a/netwerk/base/public/mozIThirdPartyUtil.idl
++++ b/netwerk/base/public/mozIThirdPartyUtil.idl
+@@ -7,6 +7,7 @@
+ interface nsIURI;
+ interface nsIDOMWindow;
+ interface nsIChannel;
++interface nsIDocument;
+
+ /**
+ * Utility functions for determining whether a given URI, channel, or window
+@@ -140,6 +141,26 @@ interface mozIThirdPartyUtil : nsISupports
+ * @return the base domain.
+ */
+ AUTF8String getBaseDomain(in nsIURI aHostURI);
++
++
++ /**
++ * getFirstPartyURI
++ *
++ * Obtain the top-level url bar URI for either a channel or a document.
++ * Either parameter may be null (but not both).
++ *
++ * @param aChannel
++ * An arbitrary channel for some content element of a first party
++ * load. Can be null.
++ *
++ * @param aDoc
++ * An arbitrary third party document. Can be null.
++ *
++ * @return the first party url bar URI for the load.
++ */
++ nsIURI getFirstPartyURI(in nsIChannel aChannel,
++ in nsIDocument aDoc);
++
+ };
+
+ %{ C++
+--
+1.7.5.4
+
1
0
[torbrowser/maint-2.3] Add mozIThirdPartyUtil.getFirstPartyURI API patch.
by mikeperry@torproject.org 25 Sep '12
by mikeperry@torproject.org 25 Sep '12
25 Sep '12
commit 31f5977ea51d755e758c2846edd6fcb8c8209b7b
Author: Mike Perry <mikeperry-git(a)fscked.org>
Date: Tue Sep 25 14:18:07 2012 -0700
Add mozIThirdPartyUtil.getFirstPartyURI API patch.
---
...d-mozIThirdPartyUtil.getFirstPartyURI-API.patch | 148 ++++++++++++++++++++
1 files changed, 148 insertions(+), 0 deletions(-)
diff --git a/src/current-patches/firefox/alpha/0020-Add-mozIThirdPartyUtil.getFirstPartyURI-API.patch b/src/current-patches/firefox/alpha/0020-Add-mozIThirdPartyUtil.getFirstPartyURI-API.patch
new file mode 100644
index 0000000..d7a24d9
--- /dev/null
+++ b/src/current-patches/firefox/alpha/0020-Add-mozIThirdPartyUtil.getFirstPartyURI-API.patch
@@ -0,0 +1,148 @@
+From e91ad38f3db238eebf2f1cae9383a6f317717bef Mon Sep 17 00:00:00 2001
+From: Mike Perry <mikeperry-git(a)torproject.org>
+Date: Tue, 28 Aug 2012 18:35:33 -0700
+Subject: [PATCH 20/21] Add mozIThirdPartyUtil.getFirstPartyURI API
+
+API allows you to get the url bar URI for a channel or nsIDocument.
+---
+ content/base/src/ThirdPartyUtil.cpp | 52 ++++++++++++++++++++++++++++
+ content/base/src/ThirdPartyUtil.h | 2 +
+ netwerk/base/public/mozIThirdPartyUtil.idl | 21 +++++++++++
+ 3 files changed, 75 insertions(+), 0 deletions(-)
+
+diff --git a/content/base/src/ThirdPartyUtil.cpp b/content/base/src/ThirdPartyUtil.cpp
+index 97a000e..87ffc8a 100644
+--- a/content/base/src/ThirdPartyUtil.cpp
++++ b/content/base/src/ThirdPartyUtil.cpp
+@@ -7,6 +7,9 @@
+ #include "nsIServiceManager.h"
+ #include "nsIHttpChannelInternal.h"
+ #include "nsIDOMWindow.h"
++#include "nsICookiePermission.h"
++#include "nsIDOMDocument.h"
++#include "nsIDocument.h"
+ #include "nsILoadContext.h"
+ #include "nsIPrincipal.h"
+ #include "nsIScriptObjectPrincipal.h"
+@@ -21,6 +24,7 @@ ThirdPartyUtil::Init()
+
+ nsresult rv;
+ mTLDService = do_GetService(NS_EFFECTIVETLDSERVICE_CONTRACTID, &rv);
++ mCookiePermissions = do_GetService(NS_COOKIEPERMISSION_CONTRACTID);
+ return rv;
+ }
+
+@@ -282,3 +286,51 @@ ThirdPartyUtil::GetBaseDomain(nsIURI* aHostURI,
+
+ return NS_OK;
+ }
++
++NS_IMETHODIMP
++ThirdPartyUtil::GetFirstPartyURI(nsIChannel *aChannel,
++ nsIDocument *aDoc,
++ nsIURI **aOutput)
++{
++ nsresult rv = NS_ERROR_NULL_POINTER;
++
++ if (!aChannel && aDoc) {
++ aChannel = aDoc->GetChannel();
++ }
++
++ // If aChannel is specified or available, use the official route
++ // for sure
++ if (aChannel) {
++ rv = mCookiePermissions->GetOriginatingURI(aChannel, aOutput);
++ }
++
++ // If the channel was missing, closed or broken, try the
++ // window hierarchy directly.
++ //
++ // This might fail to work for first-party loads themselves, but
++ // we don't need this codepath for that case.
++ if (NS_FAILED(rv) && aDoc) {
++ nsCOMPtr<nsIDOMWindow> top;
++ nsCOMPtr<nsIDOMDocument> topDDoc;
++
++ aDoc->GetWindow()->GetTop(getter_AddRefs(top));
++ top->GetDocument(getter_AddRefs(topDDoc));
++
++ nsCOMPtr<nsIDocument> topDoc(do_QueryInterface(topDDoc));
++ *aOutput = topDoc->GetOriginalURI();
++
++ if (*aOutput)
++ rv = NS_OK;
++ }
++
++ // TODO: We could provide a route through the loadgroup + notification
++ // callbacks too, but either channel or document was always available
++ // in the cases where this function was originally needed (the image cache).
++ // The notification callbacks also appear to suffers from the same limitation
++ // as the document path. See nsICookiePermissions.GetOriginatingURI() for
++ // details.
++
++ return rv;
++}
++
++
+diff --git a/content/base/src/ThirdPartyUtil.h b/content/base/src/ThirdPartyUtil.h
+index 269069b..37c30e8 100644
+--- a/content/base/src/ThirdPartyUtil.h
++++ b/content/base/src/ThirdPartyUtil.h
+@@ -9,6 +9,7 @@
+ #include "nsString.h"
+ #include "mozIThirdPartyUtil.h"
+ #include "nsIEffectiveTLDService.h"
++#include "nsICookiePermission.h"
+
+ class nsIURI;
+ class nsIChannel;
+@@ -28,6 +29,7 @@ private:
+ static already_AddRefed<nsIURI> GetURIFromWindow(nsIDOMWindow* aWin);
+
+ nsCOMPtr<nsIEffectiveTLDService> mTLDService;
++ nsCOMPtr<nsICookiePermission> mCookiePermissions;
+ };
+
+ #endif
+diff --git a/netwerk/base/public/mozIThirdPartyUtil.idl b/netwerk/base/public/mozIThirdPartyUtil.idl
+index 578d8db..1869d14 100644
+--- a/netwerk/base/public/mozIThirdPartyUtil.idl
++++ b/netwerk/base/public/mozIThirdPartyUtil.idl
+@@ -7,6 +7,7 @@
+ interface nsIURI;
+ interface nsIDOMWindow;
+ interface nsIChannel;
++interface nsIDocument;
+
+ /**
+ * Utility functions for determining whether a given URI, channel, or window
+@@ -140,6 +141,26 @@ interface mozIThirdPartyUtil : nsISupports
+ * @return the base domain.
+ */
+ AUTF8String getBaseDomain(in nsIURI aHostURI);
++
++
++ /**
++ * getFirstPartyURI
++ *
++ * Obtain the top-level url bar URI for either a channel or a document.
++ * Either parameter may be null (but not both).
++ *
++ * @param aChannel
++ * An arbitrary channel for some content element of a first party
++ * load. Can be null.
++ *
++ * @param aDoc
++ * An arbitrary third party document. Can be null.
++ *
++ * @return the first party url bar URI for the load.
++ */
++ nsIURI getFirstPartyURI(in nsIChannel aChannel,
++ in nsIDocument aDoc);
++
+ };
+
+ %{ C++
+--
+1.7.5.4
+
1
0
[torbrowser/maint-2.2] Add mozIThirdPartyUtil.getFirstPartyURI API patch.
by mikeperry@torproject.org 25 Sep '12
by mikeperry@torproject.org 25 Sep '12
25 Sep '12
commit 7a1abc347144e4e24bef26c80a2c7b2ac441317b
Author: Mike Perry <mikeperry-git(a)fscked.org>
Date: Tue Sep 25 14:16:49 2012 -0700
Add mozIThirdPartyUtil.getFirstPartyURI API patch.
---
...d-mozIThirdPartyUtil.getFirstPartyURI-API.patch | 148 ++++++++++++++++++++
1 files changed, 148 insertions(+), 0 deletions(-)
diff --git a/src/current-patches/firefox/0020-Add-mozIThirdPartyUtil.getFirstPartyURI-API.patch b/src/current-patches/firefox/0020-Add-mozIThirdPartyUtil.getFirstPartyURI-API.patch
new file mode 100644
index 0000000..56d9848
--- /dev/null
+++ b/src/current-patches/firefox/0020-Add-mozIThirdPartyUtil.getFirstPartyURI-API.patch
@@ -0,0 +1,148 @@
+From 73e548ceee36b99f06e33010163ed8b8cc86b3dd Mon Sep 17 00:00:00 2001
+From: Mike Perry <mikeperry-git(a)torproject.org>
+Date: Tue, 28 Aug 2012 18:35:33 -0700
+Subject: [PATCH 20/20] Add mozIThirdPartyUtil.getFirstPartyURI API
+
+API allows you to get the url bar URI for a channel or nsIDocument.
+---
+ content/base/src/ThirdPartyUtil.cpp | 52 ++++++++++++++++++++++++++++
+ content/base/src/ThirdPartyUtil.h | 2 +
+ netwerk/base/public/mozIThirdPartyUtil.idl | 21 +++++++++++
+ 3 files changed, 75 insertions(+), 0 deletions(-)
+
+diff --git a/content/base/src/ThirdPartyUtil.cpp b/content/base/src/ThirdPartyUtil.cpp
+index 6a415e9..62333f3 100644
+--- a/content/base/src/ThirdPartyUtil.cpp
++++ b/content/base/src/ThirdPartyUtil.cpp
+@@ -40,6 +40,9 @@
+ #include "nsIServiceManager.h"
+ #include "nsIHttpChannelInternal.h"
+ #include "nsIDOMWindow.h"
++#include "nsICookiePermission.h"
++#include "nsIDOMDocument.h"
++#include "nsIDocument.h"
+ #include "nsILoadContext.h"
+ #include "nsIPrincipal.h"
+ #include "nsIScriptObjectPrincipal.h"
+@@ -54,6 +57,7 @@ ThirdPartyUtil::Init()
+
+ nsresult rv;
+ mTLDService = do_GetService(NS_EFFECTIVETLDSERVICE_CONTRACTID, &rv);
++ mCookiePermissions = do_GetService(NS_COOKIEPERMISSION_CONTRACTID);
+ return rv;
+ }
+
+@@ -315,3 +319,51 @@ ThirdPartyUtil::GetBaseDomain(nsIURI* aHostURI,
+
+ return NS_OK;
+ }
++
++NS_IMETHODIMP
++ThirdPartyUtil::GetFirstPartyURI(nsIChannel *aChannel,
++ nsIDocument *aDoc,
++ nsIURI **aOutput)
++{
++ nsresult rv = NS_ERROR_NULL_POINTER;
++
++ if (!aChannel && aDoc) {
++ aChannel = aDoc->GetChannel();
++ }
++
++ // If aChannel is specified or available, use the official route
++ // for sure
++ if (aChannel) {
++ rv = mCookiePermissions->GetOriginatingURI(aChannel, aOutput);
++ }
++
++ // If the channel was missing, closed or broken, try the
++ // window hierarchy directly.
++ //
++ // This might fail to work for first-party loads themselves, but
++ // we don't need this codepath for that case.
++ if (NS_FAILED(rv) && aDoc) {
++ nsCOMPtr<nsIDOMWindow> top;
++ nsCOMPtr<nsIDOMDocument> topDDoc;
++
++ aDoc->GetWindow()->GetTop(getter_AddRefs(top));
++ top->GetDocument(getter_AddRefs(topDDoc));
++
++ nsCOMPtr<nsIDocument> topDoc(do_QueryInterface(topDDoc));
++ *aOutput = topDoc->GetOriginalURI();
++
++ if (*aOutput)
++ rv = NS_OK;
++ }
++
++ // TODO: We could provide a route through the loadgroup + notification
++ // callbacks too, but either channel or document was always available
++ // in the cases where this function was originally needed (the image cache).
++ // The notification callbacks also appear to suffers from the same limitation
++ // as the document path. See nsICookiePermissions.GetOriginatingURI() for
++ // details.
++
++ return rv;
++}
++
++
+diff --git a/content/base/src/ThirdPartyUtil.h b/content/base/src/ThirdPartyUtil.h
+index 58ddb15..c8eab11 100644
+--- a/content/base/src/ThirdPartyUtil.h
++++ b/content/base/src/ThirdPartyUtil.h
+@@ -42,6 +42,7 @@
+ #include "nsString.h"
+ #include "mozIThirdPartyUtil.h"
+ #include "nsIEffectiveTLDService.h"
++#include "nsICookiePermission.h"
+
+ class nsIURI;
+ class nsIChannel;
+@@ -61,6 +62,7 @@ private:
+ static already_AddRefed<nsIURI> GetURIFromWindow(nsIDOMWindow* aWin);
+
+ nsCOMPtr<nsIEffectiveTLDService> mTLDService;
++ nsCOMPtr<nsICookiePermission> mCookiePermissions;
+ };
+
+ #endif
+diff --git a/netwerk/base/public/mozIThirdPartyUtil.idl b/netwerk/base/public/mozIThirdPartyUtil.idl
+index ad41985..fd2cb38 100644
+--- a/netwerk/base/public/mozIThirdPartyUtil.idl
++++ b/netwerk/base/public/mozIThirdPartyUtil.idl
+@@ -40,6 +40,7 @@
+ interface nsIURI;
+ interface nsIDOMWindow;
+ interface nsIChannel;
++interface nsIDocument;
+
+ /**
+ * Utility functions for determining whether a given URI, channel, or window
+@@ -173,6 +174,26 @@ interface mozIThirdPartyUtil : nsISupports
+ * @return the base domain.
+ */
+ AUTF8String getBaseDomain(in nsIURI aHostURI);
++
++
++ /**
++ * getFirstPartyURI
++ *
++ * Obtain the top-level url bar URI for either a channel or a document.
++ * Either parameter may be null (but not both).
++ *
++ * @param aChannel
++ * An arbitrary channel for some content element of a first party
++ * load. Can be null.
++ *
++ * @param aDoc
++ * An arbitrary third party document. Can be null.
++ *
++ * @return the first party url bar URI for the load.
++ */
++ nsIURI getFirstPartyURI(in nsIChannel aChannel,
++ in nsIDocument aDoc);
++
+ };
+
+ %{ C++
+--
+1.7.5.4
+
1
0