diff -Nru vidalia-0.1.13/CHANGELOG vidalia-0.2.8/CHANGELOG --- vidalia-0.1.13/CHANGELOG 2009-05-25 21:48:32.000000000 +0100 +++ vidalia-0.2.8/CHANGELOG 2010-04-11 23:52:36.000000000 +0100 @@ -1,19 +1,182 @@ +0.2.8 11-Apr-2010 + o Stop using our custom dock icon implementation on OS X and just use + QSystemTrayIcon everywhere. Fixes the build on Snow Leopard. + (Ticket #562) + o Update the bundled CA certificates to re-enable downloading bridges + from bridges.torproject.org via SSL. + o Include a pre-configured qt.conf file in the Mac OS X bundles that + disable Qt plugin loading from the default directories. Otherwise, + users who have Qt installed in a system-wide location would end up + loading the libraries twice and crashing. + o Include libgcc_s_dw2-1.dll in the Windows installers, since Qt 4.6 now + depends on that DLL. Including the .dll is currently hardcoded, so the + Windows installer must be built using Qt 4.6. (Ticket #555) + o Update the included version of miniupnpc to 1.4.20100407. + o Add Burmese and Thai UI translations. + + +0.2.7 25-Jan-2010 + o Remove the explicit palette set for the configuration dialog that + prevented the dialog from inheriting colors from the user's current + system theme. (Ticket #485. Patch from mkirk.) + o Correct the path to the badge pixmap used in time skew warning + messages. (Ticket #537. Patch from mkirk.) + o Fix compilation on Debian GNU/kFreeBSD. Patch from dererk. + o Clean up a couple status event messages related to dangerous port + warnings. + o Change the vidalia_ru.nsh output encoding from KOI8-R to Windows-1251. + (Ticket #527) + o Add an option for building an OS X 10.4 compatible binary. + + +0.2.6 02-Nov-2009 + o Remove the erroneous comma in the default vidalia.conf in the + Mac OS X drag-and-drop bundle, since we now dump whatever the + user types into a QString rather than parsing it into a + QStringList. + o Updated the Arabic, Russian and Slovenian translations. + + +0.2.5 14-Oct-2009 + o Add support in the Network settings page for configuring the + Socks4Proxy and Socks5Proxy* options that were added in + Tor 0.2.2.1-alpha. Patch from Christopher Davis. + o Add a "Automatically distribute my bridge address" checkbox (enabled + by default) to the bridge relay settings options. (Ticket #524) + o Add ports 7000 and 7001 to the list of ports excluded by the IRC + category in the exit policy configuration tab. (Ticket #517) + o Add a context menu for highlighted event items in the "Basic" message + log view that allows the user to copy the selected item text to the + clipboard. + o Maybe fix a time conversion bug that could result in Vidalia + displaying the wrong uptime for a relay in the network map. + o Stop trying to enforce proper quoting and escaping of arguments to be + given to the proxy executable (e.g., Polipo). Now the user is on their + own for properly formatting the command line used to start the proxy + executable. (Ticket #523) + + +0.2.4 07-Sep-2009 + o Split the message log into "Basic" and "Advanced" views. The + "Advanced" view contains standard log messages from Tor, while the new + experimental "Basic" view displays status events received from Tor. + (Ticket #265) + o Apply an application-global stylesheet on OS X that forces all tree + widgets in Vidalia to use the 12pt font recommended by Apple's human + interface guidelines. + o Add an OSX_FORCE_32BIT CMake option that can be used to force a 32-bit + build on Mac OS X versions that default to 64-bit builds (e.g., Snow + Leopard), if only 32-bit versions of the Qt libraries are available. + o Fix a bug introduced in 0.2.3 that prevented Vidalia from correctly + responding to ADDRMAP events from Tor. The result was that users would + sometimes see IP addresses in the connection list shown under the network + map rather than hostnames. + o Fix a bug in the default "bootstrap" vidalia.conf file included in the + OS X drag-and-drop bundles that pointed to a non-existent Polipo + configuration file, causing Polipo to fail on startup. + + +0.2.3 27-Aug-2009 + o Create the data directory before trying to copy over the default + Vidalia configuration file from inside the application bundle on Mac + OS X. Affects only OS X drag-and-drop installer users without a + previous Vidalia installation. + o Change all Tor event handling to use Qt's signals and slots mechanism + instead of custom QEvent subclasses. + o Fix another bug that resulted in the "Who has used my bridge?" link + initially being visible when the user clicks "Setup Relaying" from + the control panel if they are running a non-bridge relay. + (Ticket #509, reported by "vrapp") + o Always hide the "Who has used my bridge?" link when Tor isn't running, + since clicking it won't return useful information until Tor actually + is running. + + +0.2.2 14-Aug-2009 + o When the user clicks "Browse" in the Advanced settings page to locate + a new torrc, set the initial directory shown in the file dialog to the + current location of the user's torrc. (Ticket #505) + o Use 'ditto' to strip the architectures we don't want from the Qt + frameworks installed into the app bundle with the dist-osx, + dist-osx-bundle and dist-osx-split-bundle build targets. + o Fix a bug in the CMakeLists.txt files for ts2po and po2ts that caused + build errors on Panther for those two tools. + o Include rebuilt OpenSSL libraries in the Windows packages that are + built with the static (/MT) version of the Microsoft Visual C++ + Runtime. Otherwise, we would require users to install the MSVC + Redistributable, which doesn't work for portable installations such as + the Tor Browser Bundle. + o Remove the NSIS file for the Vidalia installer since we now ship + MSI-based installers on Windows. + + +0.2.1 03-Aug-2009 + o Add a "Find Bridges Now" button that will attempt to automatically + download a set of bridge addresses and add them to the list of bridges + in the Network settings page. + o Add support for building with Google's Breakpad crash reporting + library (currently disabled by default). + o Show or hide the "Who has used my bridge recently?" link along with + the other bridge-related widgets when the user toggles the relay mode + in the Network settings page. (Ticket #480) + o Tolerate bridge addresses that do not specify a port number, since Tor + now defaults to using port 443 in such cases. + o Add support for viewing the map as a full screen widget when built + with KDE Marble support. + o Compute the salted hash of the control password ourself when starting + Tor, rather than launching Tor once to hash the password, parsing the + output, and then again to actually start Tor. + o Add a signal handler that allows Vidalia to clean up and exit normally + when it catches a SIGINT or SIGTERM signal. (Ticket #481) + o If the user chooses to ignore further warnings for a particular port, + remove it from the WarnPlaintextPorts and RejectPlaintextPorts + settings immediately. Also remember their preferences and reapply them + later, even if Tor is unable to writes to its torrc.(Ticket #493) + o Don't display additional plaintext port warning message boxes until + the first visible message box is dismissed. (Ticket #493) + o Renamed the 'make win32-installer' CMake target to 'make dist-win32' + for consistency with our 'make dist-osx' target. + o Fix a couple bugs in the WiX-based Windows installer related to building + a Marble-enabled Vidalia installer. + o Write the list of source files containing translatable strings to a + .pro file and supply just the .pro file as an argument to lupdate, rather + than supplying all of the source file names themselves. + + +0.1.15 09-Jul-2009 + o Bump the minimum required Qt version to 4.3.0. + o Remove USE_QSSLSOCKET as a build option. If your Qt doesn't support + OpenSSL, then you don't get GeoIP lookups. + o Fix the TorPostFlight portion of the OS X bundle installer so it + doesn't fail when installing Torbutton. + o Include libeay32.dll in the Windows installers. + + +0.1.14 29-Jun-2009 + o Close the TorProcess more quickly after registering for log events, so + we avoid displaying duplicate log messages received over Tor's control + port and Tor's stdout log. (Ticket #484) + o Explicitly set CMAKE_OSX_SYSROOT to the 10.4 SDK rather than expecting + the packager to do so when building a Universal binary. + o Include Tor's geoip file in the Windows bundles. + + 0.1.13 25-May-2009 o Remove an old warning on the relay settings page that running a bridge relay requires Tor 0.2.0.8-alpha or newer. o Add a workaround for a bug that prevented Vidalia's tray icon from - getting added to the system notification area on Gnome when Vidalia was + getting added to the system notification area on Gnome when Vidalia was run on system startup. Patch by Steve Tyree. (Ticket #247) o Fix a bug that prevented the control panel from displaying when running on the Enlightenment window manager. Patch by Steve Tyree. o Rename the CMake variables used to store the location of Qt's lupdate - and lrelease executables. Recent versions of CMake decided to use the + and lrelease executables. Recent versions of CMake decided to use the same variable name, which was stomping on mine, resulting in the wrong lupdate and lrelease executables being used. o Use the TorProcess subclass of QProcess for launching Tor when hashing a control password so we can take advantage of its PATH+=:/usr/sbin trick on Debian there too. - o If a RouterDescriptor object is empty, don't try to display it in the + o If a RouterDescriptor object is empty, don't try to display it in the router descriptor details viewer. (Ticket #479) o Wait until Vidalia has registered for log events via the control port before ignoring Tor's output on stdout. Previously we would start @@ -24,6 +187,30 @@ up-to-date enough to be useful. +0.2.0 19-Mar-2009 + o Add support for changing UI languages without having to restart + Vidalia. + o Add preliminary support for using the KDE Marble widget for the + network map. It's currently a compile-time option and is disabled by + default. + o Add support for displaying Tor's plaintext port warnings. Also gives + the user the option to disable future warnings. + o Add an interface for displaying the geographic distribution of + clients who have recently used a bridge operator's relay. + o Add tooltips to tree items in the help browser's table of contents. Some + of the help topic labels are a bit long. + o Switch to a simpler About dialog and move the license information to a + separate HTML-formatted display. + o Switch to a simpler drag-and-drop installer in the OS X bundles. + o Switch to an MSI-based installer on Windows. + o Clear the list of default CA certificates used by QSslSocket before adding + the only one we care about. Suggested by coderman. + o Support building with Visual Studio again. + o Add a Debian package structure from dererk. + o Updated Albanian, Czech, Finnish, Polish, Portuguese, Romanian, + Swedish, Turkish and many other translations. + + 0.1.12 16-Mar-2009 o Fix a bug in the hidden service settings configuration class that could lead to compile errors in Visual Studio and on IRIX. @@ -41,9 +228,9 @@ 0.1.11 16-Feb-2009 - o Remove support for configuring Tor's User and Group options in the + o Remove support for configuring Tor's User and Group options in the Advanced settings page. - o Only set HttpsProxy if both the "I use a proxy..." checkbox and the + o Only set HttpsProxy if both the "I use a proxy..." checkbox and the "Use this proxy for HTTPS also" checkboxes are checked. Otherwise, unset it. (Ticket #440) o Fix a use of an uninitialized variable that would occur when Tor was diff -Nru vidalia-0.1.13/cmake/FindBreakpad.cmake vidalia-0.2.8/cmake/FindBreakpad.cmake --- vidalia-0.1.13/cmake/FindBreakpad.cmake 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/cmake/FindBreakpad.cmake 2009-06-23 23:53:29.000000000 +0100 @@ -0,0 +1,50 @@ +## +## $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.vidalia-project.net/. No part of Vidalia, including this file, +## may be copied, modified, propagated, or distributed except according to +## the terms described in the LICENSE file. +## + +## Tries to find the required Google Breakpad libraries. Once done this will +## define the variable BREAKPAD_LIBRARIES. + +message(STATUS "Looking for Google Breakpad libraries") +if (WIN32) + if (MSVC) + find_library(BREAKPAD_EXCEPTION_HANDLER_LIB + NAMES exception_handler + PATHS ${BREAKPAD_LIBRARY_DIR} + ) + if (NOT BREAKPAD_EXCEPTION_HANDLER_LIB) + message(FATAL_ERROR + "Could not find Breakpad exception handler library") + endif(NOT BREAKPAD_EXCEPTION_HANDLER_LIB) + + find_library(BREAKPAD_CRASH_GENERATION_LIB + NAMES crash_generation + PATHS ${BREAKPAD_LIBRARY_DIR} + ) + if (NOT BREAKPAD_CRASH_GENERATION_LIB) + message(FATAL_ERROR + "Could not find Breakpad crash generation library") + endif(NOT BREAKPAD_CRASH_GENERATION_LIB) + + set(BREAKPAD_LIBRARIES + ${BREAKPAD_EXCEPTION_HANDLER_LIB} + ${BREAKPAD_CRASH_GENERATION_LIB} + ) + message(STATUS "Looking for Google Breakpad libraries - found") + else(MSVC) + message(FATAL_ERROR + "Breakpad support on Windows currently requires Visual Studio.") + endif(MSVC) +else(WIN32) + message(FATAL_ERROR + "Breakpad support is not currently available on your platform.") +endif(WIN32) + diff -Nru vidalia-0.1.13/cmake/FindMarble.cmake vidalia-0.2.8/cmake/FindMarble.cmake --- vidalia-0.1.13/cmake/FindMarble.cmake 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/cmake/FindMarble.cmake 2009-02-24 20:21:40.000000000 +0000 @@ -0,0 +1,111 @@ +## +## $Id: FindMarble.cmake 3588 2009-02-24 20:21:40Z edmanm $ +## +## 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.vidalia-project.net/. No part of Vidalia, including this file, +## may be copied, modified, propagated, or distributed except according to +## the terms described in the LICENSE file. +## +## This file incorporates work from the KDE Marble project, and is covered by +## the following copyright and permission notice: +## +## Redistribution and use in source and binary forms, with or without +## modification, are permitted provided that the following conditions are +## met: +## +## * Redistributions of source code must retain the above copyright notice, +## this list of conditions and the following disclaimer. +## +## * Redistributions in binary form must reproduce the above copyright +## notice, this list of conditions and the following disclaimer in the +## documentation and/or other materials provided with the distribution. +## +## * Neither the names of the copyright owners nor the names of its +## contributors may be used to endorse or promote products derived from +## this software without specific prior written permission. +## +## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +## IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +## THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +## PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +## LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +## NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +## SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +## + +message(STATUS "Looking for Marble header files") +find_path(MARBLE_INCLUDE_DIR + NAMES MarbleWidget.h + PATH_SUFFIXES marble +) +if (MARBLE_INCLUDE_DIR) + message(STATUS "Looking for Marble header files - found") +else(MARBLE_INCLUDE_DIR) + message(FATAL_ERROR "Could not find Marble header files. If Marble is installed, you can run CMake again and specify its location with -DMARBLE_INCLUDE_DIR=") +endif(MARBLE_INCLUDE_DIR) + + +message(STATUS "Looking for Marble libraries") +find_library(MARBLEWIDGET_LIBRARY + NAMES marblewidget.7 marblewidget + PATHS ${MARBLE_LIBRARY_DIR} +) +if (MARBLEWIDGET_LIBRARY) + message(STATUS "Looking for Marble libraries - found") + set(MARBLE_LIBRARIES ${MARBLEWIDGET_LIBRARY}) + get_filename_component(MARBLE_LIBRARY_DIR ${MARBLEWIDGET_LIBRARY} PATH) +else(MARBLEWIDGET_LIBRARY) + message(FATAL_ERROR "Could not find Marble libraries. If Marble is installed, you can run CMake again and specify its location with -DMARBLE_LIBRARY_DIR=") +endif(MARBLEWIDGET_LIBRARY) + + +if (APPLE OR WIN32) + message(STATUS "Looking for Marble data files") + find_path(MARBLE_DATA_DIR + NAMES srtm.dgml + PATH_SUFFIXES maps/earth/srtm + ) + if (MARBLE_DATA_DIR) + message(STATUS "Looking for Marble data files - ${MARBLE_DATA_DIR}") + else (MARBLE_DATA_DIR) + message(FATAL_ERROR "Could not find Marble libraries. If Marble is installed, you can run CMake again and specify its location with -DMARBLE_DATA_DIR=") + endif(MARBLE_DATA_DIR) + + + message(STATUS "Looking for Marble plugin widgets") + find_library(MARBLE_OVERVIEWMAP_PLUGIN + NAMES MarbleOverviewMap + PATHS ${MARBLE_PLUGIN_DIR} + PATH_SUFFIXES render/overviewmap + ) + if (MARBLE_OVERVIEWMAP_PLUGIN) + message(STATUS "Looking for Marble plugin widgets - found overview map plugin") + set(MARBLE_PLUGINS ${MARBLE_PLUGINS} + ${MARBLE_OVERVIEWMAP_PLUGIN} + ) + endif(MARBLE_OVERVIEWMAP_PLUGIN) + + find_library(MARBLE_STARS_PLUGIN + NAMES MarbleStarsPlugin + PATHS ${MARBLE_PLUGIN_DIR} + PATH_SUFFIXES render/stars + ) + if (MARBLE_STARS_PLUGIN) + message(STATUS "Looking for Marble plugin widgets - found stars plugin") + set(MARBLE_PLUGINS ${MARBLE_PLUGINS} + ${MARBLE_STARS_PLUGIN} + ) + endif(MARBLE_STARS_PLUGIN) + + if (NOT MARBLE_PLUGINS) + message(STATUS "Looking for Marble plugin widgets - none found") + endif(NOT MARBLE_PLUGINS) +endif(APPLE OR WIN32) + diff -Nru vidalia-0.1.13/cmake/FindWiX.cmake vidalia-0.2.8/cmake/FindWiX.cmake --- vidalia-0.1.13/cmake/FindWiX.cmake 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/cmake/FindWiX.cmake 2008-12-07 04:42:14.000000000 +0000 @@ -0,0 +1,36 @@ +## +## $Id: FindWiX.cmake 3371 2008-12-07 04:42:14Z edmanm $ +## +## 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.vidalia-project.net/. No part of Vidalia, including this file, +## may be copied, modified, propagated, or distributed except according to +## the terms described in the LICENSE file. +## + +message(STATUS "Looking for WiX") +## Search for candle.exe +find_program(WIX_CANDLE_EXECUTABLE NAMES candle + PATHS ${WIX_BINARY_DIR} +) + +## Search for light.exe +find_program(WIX_LIGHT_EXECUTABLE NAMES light + PATHS ${WIX_BINARY_DIR} +) + +if (WIX_CANDLE_EXECUTABLE AND WIX_LIGHT_EXECUTABLE) + message(STATUS "Looking for WiX - found") + + ## Set the WiX binary directory variable, but only if it wasn't already + ## explicitly defined + if (NOT WIX_BINARY_DIR) + get_filename_component(WIX_BINARY_DIR ${WIX_LIGHT_EXECUTABLE} ABSOLUTE) + get_filename_component(WIX_BINARY_DIR ${WIX_BINARY_DIR} PATH) + endif(NOT WIX_BINARY_DIR) +else (WIX_CANDLE_EXECUTABLE AND WIX_LIGHT_EXECUTABLE) + message(STATUS "Looking for WiX - not found.") +endif(WIX_CANDLE_EXECUTABLE AND WIX_LIGHT_EXECUTABLE) + diff -Nru vidalia-0.1.13/cmake/ParseArgumentsMacro.cmake vidalia-0.2.8/cmake/ParseArgumentsMacro.cmake --- vidalia-0.1.13/cmake/ParseArgumentsMacro.cmake 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/cmake/ParseArgumentsMacro.cmake 2009-06-29 03:41:32.000000000 +0100 @@ -0,0 +1,35 @@ +## +## From http://www.cmake.org/Wiki/CMakeMacroParseArguments +## + +MACRO(PARSE_ARGUMENTS prefix arg_names option_names) + SET(DEFAULT_ARGS) + FOREACH(arg_name ${arg_names}) + SET(${prefix}_${arg_name}) + ENDFOREACH(arg_name) + FOREACH(option ${option_names}) + SET(${prefix}_${option} FALSE) + ENDFOREACH(option) + + SET(current_arg_name DEFAULT_ARGS) + SET(current_arg_list) + FOREACH(arg ${ARGN}) + SET(larg_names ${arg_names}) + LIST(FIND larg_names "${arg}" is_arg_name) + IF (is_arg_name GREATER -1) + SET(${prefix}_${current_arg_name} ${current_arg_list}) + SET(current_arg_name ${arg}) + SET(current_arg_list) + ELSE (is_arg_name GREATER -1) + SET(loption_names ${option_names}) + LIST(FIND loption_names "${arg}" is_option) + IF (is_option GREATER -1) + SET(${prefix}_${arg} TRUE) + ELSE (is_option GREATER -1) + SET(current_arg_list ${current_arg_list} ${arg}) + ENDIF (is_option GREATER -1) + ENDIF (is_arg_name GREATER -1) + ENDFOREACH(arg) + SET(${prefix}_${current_arg_name} ${current_arg_list}) +ENDMACRO(PARSE_ARGUMENTS) + diff -Nru vidalia-0.1.13/cmake/VidaliaMacros.cmake vidalia-0.2.8/cmake/VidaliaMacros.cmake --- vidalia-0.1.13/cmake/VidaliaMacros.cmake 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/cmake/VidaliaMacros.cmake 2009-08-26 23:42:15.000000000 +0100 @@ -1,5 +1,5 @@ ## -## $Id: VidaliaMacros.cmake 3747 2009-04-30 19:07:57Z edmanm $ +## $Id: VidaliaMacros.cmake 4067 2009-08-26 22:42:15Z edmanm $ ## ## 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 @@ -34,23 +34,24 @@ ## We need windres.exe when building on Win32 to compile the .rc file -if (WIN32) +if (WIN32 AND NOT MSVC) find_program(WIN32_WINDRES_EXECUTABLE NAMES windres.exe ${QT_BINARY_DIR}) if (NOT WIN32_WINDRES_EXECUTABLE) message(FATAL_ERROR - "Vidalia could not find windres. Please make sure Qt is installed and its bin directory is in your PATH environment variable." + "Vidalia could not find windres. Please make sure MinGW is installed and its bin directory is in your PATH environment variable." ) endif(NOT WIN32_WINDRES_EXECUTABLE) -endif(WIN32) +endif(WIN32 AND NOT MSVC) ## Adds custom commands to the specified target that will update each of the ## supplied .po files macro(VIDALIA_UPDATE_PO TARGET) ## Gather a list of all the files that might contain translated strings - FILE(GLOB_RECURSE translate_SRCS ${Vidalia_SOURCE_DIR}/*.cpp) - FILE(GLOB_RECURSE translate_HDRS ${Vidalia_SOURCE_DIR}/*.h) - FILE(GLOB_RECURSE translate_UIS ${Vidalia_SOURCE_DIR}/*.ui) + file(GLOB_RECURSE translate_SRCS ${Vidalia_SOURCE_DIR}/*.cpp) + file(GLOB_RECURSE translate_HDRS ${Vidalia_SOURCE_DIR}/*.h) + file(GLOB_RECURSE translate_UIS ${Vidalia_SOURCE_DIR}/*.ui) set(translate_SRCS ${translate_SRCS} ${translate_HDRS} ${translate_UIS}) + string(REPLACE ";" " " translate_SRCS "${translate_SRCS}") foreach (it ${ARGN}) get_filename_component(po ${it} ABSOLUTE) @@ -58,13 +59,16 @@ get_filename_component(outfile ${it} NAME_WE) set(ts ${CMAKE_CURRENT_BINARY_DIR}/${outfile}.ts) + set(pro ${CMAKE_CURRENT_BINARY_DIR}/${outfile}.pro) + file(WRITE ${pro} "SOURCES = ${translate_SRCS}") + add_custom_command(TARGET ${TARGET} # Convert the current .po files to .ts COMMAND ${VIDALIA_PO2TS_EXECUTABLE} ARGS -q -i ${po} -o ${ts} # Update the .ts files COMMAND ${VIDALIA_LUPDATE_EXECUTABLE} - ARGS -silent -noobsolete ${translate_SRCS} -ts ${ts} + ARGS -silent -noobsolete ${pro} -ts ${ts} # Convert the updated .ts files back to .po COMMAND ${VIDALIA_TS2PO_EXECUTABLE} ARGS -q -i ${ts} -o ${po} @@ -122,24 +126,164 @@ endmacro(VIDALIA_ADD_NSH) +## Wraps the input .po file specified by PO in a custom command to convert it +## to WiX's localization XML document in a .wxl file. The culture name is +## specified by CULTURE and codepage by CHARSET. +## Note that CHARSET is not currently used to set codepage of String elements +## but this may be necessary if Wix is not smart enough to do this right. +macro(VIDALIA_ADD_WXL OUTFILES PO CULTURE CHARSET) + get_filename_component(po ${PO} ABSOLUTE) + get_filename_component(outfile ${PO} NAME_WE) + + ## Create the .po -> .wxl conversion step + set(wxl ${CMAKE_CURRENT_BINARY_DIR}/${outfile}.wxl) + add_custom_command(OUTPUT ${wxl} + COMMAND ${VIDALIA_PO2WXL_EXECUTABLE} + ARGS -q -n ${CULTURE} -i ${po} -o ${wxl} + MAIN_DEPENDENCY ${po} + DEPENDS ${VIDALIA_PO2WXL_EXECUTABLE} + COMMENT "Generating ${outfile}.wxl" + ) + set(${OUTFILES} ${${OUTFILES}} ${wxl}) +endmacro(VIDALIA_ADD_WXL) + +## Queries the specified TOR_EXECUTABLE for its version string using the +## --version argument, parses its output and sets TOR_VERSION to the result. +## If no version could be determined, ${TOR_VERSION} will be undefined. +macro(VIDALIA_GET_TOR_VERSION TOR_VERSION TOR_EXECUTABLE) + get_filename_component(TOR_EXE_PATH ${TOR_EXECUTABLE} ABSOLUTE) + if (UNIX) + execute_process( + COMMAND ${TOR_EXE_PATH} --version + COMMAND tail -n 1 + COMMAND awk "{print $3}" + COMMAND sed -e s/\\.$// + OUTPUT_VARIABLE ${TOR_VERSION} + ) + else(UNIX) + message(FATAL_ERROR + "The vidalia_get_tor_version macro is not implemented for your platform") + endif(UNIX) + if (DEFINED ${TOR_VERSION}) + string(STRIP ${${TOR_VERSION}} ${TOR_VERSION}) + endif(DEFINED ${TOR_VERSION}) +endmacro(VIDALIA_GET_TOR_VERSION) + +if (APPLE) + include(${Vidalia_SOURCE_DIR}/cmake/ParseArgumentsMacro.cmake) + + ## Calls the install_name_tool utility to change the dependent shared + ## library or framework install name to the corresponding library or + ## framework that was previously installed in the .app bundle using + ## VIDALIA_INSTALL_QT4_FRAMEWORK or VIDALIA_INSTALL_DYLIB when the given + ## build target is executed. + macro(VIDALIA_INSTALL_NAME_TOOL) + parse_arguments(INSTALL_NAME_TOOL "TARGET;LIBRARIES;FRAMEWORKS" "" ${ARGN}) + + foreach(bin ${INSTALL_NAME_TOOL_DEFAULT_ARGS}) + foreach(it ${INSTALL_NAME_TOOL_FRAMEWORKS}) + add_custom_command(TARGET ${INSTALL_NAME_TOOL_TARGET} + COMMAND install_name_tool -change + ${it} @executable_path/../Frameworks/${it} ${bin} + ) + endforeach(it) + foreach(it ${INSTALL_NAME_TOOL_LIBRARIES}) + get_filename_component(libname ${it} NAME) + add_custom_command(TARGET ${INSTALL_NAME_TOOL_TARGET} + COMMAND install_name_tool -change + ${it} @executable_path/lib/${libname} ${bin} + ) + endforeach(it) + endforeach(bin) + endmacro(VIDALIA_INSTALL_NAME_TOOL) + + ## Copies the specified Qt4 framework into the .app bundle, updates its + ## shared library identification name, and changes any dependent Qt4 + ## framework or shared library names to reference a framework previously + ## installed in the .app bundle using VIDALIA_INSTALL_QT4_FRAMEWORK. + macro(VIDALIA_INSTALL_QT4_FRAMEWORK) + parse_arguments(INSTALL_QT4_FRAMEWORK + "NAME;TARGET;LIBRARY;APP_BUNDLE;DEPENDS_FRAMEWORKS;DEPENDS_LIBRARIES" "" + ${ARGN} + ) + set(ditto_ARGS "--rsrc") + foreach (it ${CMAKE_OSX_ARCHITECTURES}) + set(ditto_ARGS ${ditto_ARGS} --arch ${it}) + endforeach(it) + + set(framework "${INSTALL_QT4_FRAMEWORK_NAME}.framework/Versions/4") + set(outdir "${INSTALL_QT4_FRAMEWORK_APP_BUNDLE}/Contents/Frameworks/${framework}") + get_filename_component(libname "${INSTALL_QT4_FRAMEWORK_LIBRARY}" NAME) + add_custom_command(TARGET ${INSTALL_QT4_FRAMEWORK_TARGET} + COMMAND ${CMAKE_COMMAND} -E make_directory ${outdir} + COMMAND ditto ${ditto_ARGS} + ${INSTALL_QT4_FRAMEWORK_LIBRARY} ${outdir}/ + COMMAND install_name_tool -id + @executable_path/../Frameworks/${framework}/${libname} ${outdir}/${libname} + ) + vidalia_install_name_tool(${outdir}/${libname} + TARGET ${INSTALL_QT4_FRAMEWORK_TARGET} + LIBRARIES ${INSTALL_QT4_FRAMEWORK_DEPENDS_LIBRARIES} + FRAMEWORKS ${INSTALL_QT4_FRAMEWORK_DEPENDS_FRAMEWORKS} + ) + set(${INSTALL_QT4_FRAMEWORK_DEFAULT_ARGS} ${framework}/${libname}) + endmacro(VIDALIA_INSTALL_QT4_FRAMEWORK) + + ## Copies the specified .dylib into the .app bundle, updates its shared + ## library identification name, and changes any dependent framework or + ## shared library names to reference a framework or shared library + ## previously installed in the .app bundle. + macro(VIDALIA_INSTALL_DYLIB) + parse_arguments(INSTALL_DYLIB + "TARGET;LIBRARY;APP_BUNDLE;DEPENDS_FRAMEWORKS;DEPENDS_LIBRARIES" "" + ${ARGN} + ) + set(ditto_ARGS "--rsrc") + foreach (it ${CMAKE_OSX_ARCHITECTURES}) + set(ditto_ARGS ${ditto_ARGS} --arch ${it}) + endforeach(it) + + set(outdir "${INSTALL_DYLIB_APP_BUNDLE}/Contents/MacOS/lib/") + get_filename_component(libname "${INSTALL_DYLIB_LIBRARY}" NAME) + add_custom_command(TARGET ${INSTALL_DYLIB_TARGET} + COMMAND ${CMAKE_COMMAND} -E make_directory ${outdir} + COMMAND ditto ${ditto_ARGS} + ${INSTALL_DYLIB_LIBRARY} ${outdir}/ + COMMAND install_name_tool -id @executable_path/lib/${libname} + ) + vidalia_install_name_tool(${outir}/${libname} + TARGET ${INSTALL_DYLIB_TARGET} + LIBRARIES ${INSTALL_DYLIB_DEPENDS_LIBRARIES} + FRAMEWORKS ${INSTALL_DYLIB_DEPENDS_FRAMEWORKS} + ) + set(${INSTALL_DYLIB_DEFAULT_ARGS} "${libname}") + endmacro(VIDALIA_INSTALL_DYLIB) +endif(APPLE) + if (WIN32) - ## Wraps the supplied .rc files in windres commands - macro(WIN32_WRAP_RC outfiles) + ## Wraps the supplied .rc files in windres commands if we're building + ## with MinGW. Otherwise, it just adds the .rc files directly to the + ## list of output files. + macro(WIN32_ADD_RC outfiles) foreach(it ${ARGN}) - get_filename_component(it ${it} ABSOLUTE) - get_filename_component(outfile ${it} NAME_WE) - get_filename_component(rc_path ${it} PATH) + if (NOT MSVC) + get_filename_component(it ${it} ABSOLUTE) + get_filename_component(outfile ${it} NAME_WE) + get_filename_component(rc_path ${it} PATH) - set(outfile - ${CMAKE_CURRENT_BINARY_DIR}/${outfile}_res${CMAKE_CXX_OUTPUT_EXTENSION} - ) - add_custom_command(OUTPUT ${outfile} - COMMAND ${WIN32_WINDRES_EXECUTABLE} - ARGS -i ${it} -o ${outfile} --include-dir=${rc_path} - MAIN_DEPENDENCY ${it} - ) - set(${outfiles} ${${outfiles}} ${outfile}) + set(outfile + ${CMAKE_CURRENT_BINARY_DIR}/${outfile}_res${CMAKE_CXX_OUTPUT_EXTENSION} + ) + add_custom_command(OUTPUT ${outfile} + COMMAND ${WIN32_WINDRES_EXECUTABLE} + ARGS -i ${it} -o ${outfile} --include-dir=${rc_path} + MAIN_DEPENDENCY ${it} + ) + set(${outfiles} ${${outfiles}} ${outfile}) + else (NOT MSVC) + set(${outfiles} ${${outfiles}} ${it}) + endif(NOT MSVC) endforeach(it) - endmacro(WIN32_WRAP_RC) + endmacro(WIN32_ADD_RC) endif(WIN32) diff -Nru vidalia-0.1.13/CMakeLists.txt vidalia-0.2.8/CMakeLists.txt --- vidalia-0.1.13/CMakeLists.txt 2009-05-25 21:48:32.000000000 +0100 +++ vidalia-0.2.8/CMakeLists.txt 2010-04-11 23:47:20.000000000 +0100 @@ -1,5 +1,5 @@ ## -## $Id: CMakeLists.txt 3794 2009-05-25 20:34:39Z edmanm $ +## $Id: CMakeLists.txt 4254 2010-04-11 22:47:20Z edmanm $ ## ## 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 @@ -12,33 +12,49 @@ set(VER_MAJOR "0") -set(VER_MINOR "1") -set(VER_PATCH "13") +set(VER_MINOR "2") +set(VER_PATCH "8") set(VERSION "${VER_MAJOR}.${VER_MINOR}.${VER_PATCH}") message(STATUS "Configuring Vidalia ${VERSION}") project(Vidalia) ## Specify the minimim required CMake version -cmake_minimum_required(VERSION 2.4.0) +cmake_minimum_required(VERSION 2.4.7) if (COMMAND cmake_policy) # Force CMake 2.4 compatibility for handling linker search paths cmake_policy(SET CMP0003 OLD) endif(COMMAND cmake_policy) -## Require Qt >= 4.2.0 -set(QT_MIN_VERSION "4.2.0") +## We declare this option here, because it determines the minimum +## required Qt version +option(USE_MARBLE "Enable the KDE Marble-based map widget." OFF) + +## Specify the minimum version of Qt required +set(QT_MIN_VERSION "4.3.0") ## Specify the Qt libraries used include(FindQt4) find_package(Qt4 REQUIRED) set(QT_USE_QTNETWORK true) set(QT_USE_QTXML true) +if (USE_MARBLE) + set(QT_USE_QTSVG true) + set(QT_USE_QTWEBKIT true) + set(QT_USE_QTSCRIPT true) + set(QT_USE_QTDBUS true) +endif(USE_MARBLE) include(${QT_USE_FILE}) include(${CMAKE_SOURCE_DIR}/cmake/VidaliaMacros.cmake) include(CheckIncludeFile) include(CheckIncludeFileCXX) include(CheckTypeSize) -include(CPack) +include(CheckFunctionExists) +if (WIN32) + include(${CMAKE_SOURCE_DIR}/cmake/FindWiX.cmake) +endif(WIN32) +if (MSVC OR UNIX) + include(${CMAKE_SOURCE_DIR}/cmake/FindOpenSSL.cmake) +endif(MSVC OR UNIX) if(MSVC_IDE) set(CMAKE_SUPPRESS_REGENERATION TRUE) @@ -48,40 +64,66 @@ ## Define Vidalia-specific CMake options if (APPLE) + option(OSX_TIGER_COMPAT "Build an OS X 10.4 Compatible Vidalia." OFF) + if (OSX_TIGER_COMPAT) + set(CMAKE_EXE_LINKER_FLAGS "-mmacosx-version-min=10.4" + CACHE STRING "Flags used by the linker." FORCE) + set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.4u.sdk" + CACHE STRING "isysroot used for universal binary support" FORCE) + endif(OSX_TIGER_COMPAT) + option(OSX_FAT_BINARY "Build Vidalia as a Universal binary." OFF) if (OSX_FAT_BINARY) set(CMAKE_OSX_ARCHITECTURES "ppc;i386" CACHE STRING "OS X build architectures" FORCE) set(CMAKE_EXE_LINKER_FLAGS "-mmacosx-version-min=10.4" CACHE STRING "Flags used by the linker." FORCE) + set(CMAKE_OSX_SYSROOT "/Developer/SDKs/MacOSX10.4u.sdk" + CACHE STRING "isysroot used for universal binary support" FORCE) endif(OSX_FAT_BINARY) -endif(APPLE) -## Check for QSslSocket -set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${QT_INCLUDES}) -check_include_file_cxx("qsslsocket.h" HAVE_QSSLSOCKET_H) -if (HAVE_QSSLSOCKET_H) - check_symbol_exists(QT_NO_OPENSSL "QtGlobal" QT_NO_SSL_SUPPORT) - if (NOT QT_NO_SSL_SUPPORT) - option(USE_QSSLSOCKET "Use Qt's QSslSocket for GeoIP lookups." ON) - endif(NOT QT_NO_SSL_SUPPORT) -endif(HAVE_QSSLSOCKET_H) -if (USE_QSSLSOCKET) - if (MSVC OR UNIX) - include(${CMAKE_SOURCE_DIR}/cmake/FindOpenSSL.cmake) - endif(MSVC OR UNIX) -endif(USE_QSSLSOCKET) + option(OSX_FORCE_32BIT "Force a 32-bit build for compatibility." OFF) + if (OSX_FORCE_32BIT) + add_definitions(-m32) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32" + CACHE STRING "Flags used by the linker." FORCE) + endif(OSX_FORCE_32BIT) +endif(APPLE) ## UPnP support is currently optional (enabled by default) option(USE_MINIUPNPC "Enable UPnP support using the MiniUPnPc library." ON) +## Crash reporting via Google Breakpad is optional (disabled by default) +option(USE_BREAKPAD "Enable Google Breakpad crash reporting." OFF) +if (USE_BREAKPAD) + include(${CMAKE_SOURCE_DIR}/cmake/FindBreakpad.cmake) +endif(USE_BREAKPAD) + +## Automatic software update is optional (disabled by default) +if (WIN32) + option(USE_AUTOUPDATE "Enable automatic software update support." OFF) +endif(WIN32) + +## Find the KDE Marble library +if (USE_MARBLE) + include(${CMAKE_SOURCE_DIR}/cmake/FindMarble.cmake) +endif(USE_MARBLE) + ## Check for system header files check_include_file("limits.h" HAVE_LIMITS_H) check_include_file("sys/limits.h" HAVE_SYS_LIMITS_H) +check_include_file("signal.h" HAVE_SIGNAL_H) ## Check for the sizes of various data types check_type_size(int SIZEOF_INT) +## Check for the existence of some platform-specific functions +if (HAVE_SIGNAL_H) + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} "signal.h") + check_function_exists(sigaction HAVE_SIGACTION) + check_function_exists(signal HAVE_SIGNAL) +endif(HAVE_SIGNAL_H) + ## Write out a configuration file configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/config.h.in diff -Nru vidalia-0.1.13/config.h.in vidalia-0.2.8/config.h.in --- vidalia-0.1.13/config.h.in 2009-05-25 21:48:32.000000000 +0100 +++ vidalia-0.2.8/config.h.in 2009-06-23 23:53:29.000000000 +0100 @@ -1,5 +1,5 @@ /* -** $Id: config.h.in 2647 2008-06-03 03:34:27Z edmanm $ +** $Id: config.h.in 3879 2009-06-23 22:53:29Z edmanm $ ** ** 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 @@ -16,17 +16,25 @@ #define VIDALIA_VERSION "@VERSION@" -#cmakedefine HAVE_QSSLSOCKET_H - -#cmakedefine USE_QSSLSOCKET - #cmakedefine HAVE_LIMITS_H #cmakedefine HAVE_SYS_LIMITS_H +#cmakedefine HAVE_SIGNAL_H + +#cmakedefine HAVE_SIGACTION + +#cmakedefine HAVE_SIGNAL + #cmakedefine SIZEOF_INT @SIZEOF_INT@ #cmakedefine USE_MINIUPNPC +#cmakedefine USE_AUTOUPDATE + +#cmakedefine USE_MARBLE + +#cmakedefine USE_BREAKPAD + #endif diff -Nru vidalia-0.1.13/contrib/geoip.py vidalia-0.2.8/contrib/geoip.py --- vidalia-0.1.13/contrib/geoip.py 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/contrib/geoip.py 2009-05-13 19:54:28.000000000 +0100 @@ -0,0 +1,105 @@ +#!/usr/bin/python +## +## $Id: geoip.py 3767 2009-05-13 18:54:28Z edmanm $ +## +## 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.vidalia-project.net/. No part of Vidalia, including this file, +## may be copied, modified, propagated, or distributed except according to +## the terms described in the LICENSE file. +## + +from mod_python import apache +from mod_python import util +import GeoIP +import os + +def escape_output(f): + if ' ' in f: + f.replace("\\", "\\\\") + f.replace("\"", "\\\"") + return ("\"%s\"" % f) + return f + +def is_valid_geoip_record(r): + if r == None: + return False + if not r.has_key('latitude') or r['latitude'] == None: + return False + if not r.has_key('longitude') or r['longitude'] == None: + return False + return True + +# Get the form fields +def handler(req): + form = util.FieldStorage(req) + + # Get the specified output format and verify it is a valid format. If + # none is specified, default to the old "short" output format. + format = form.getfirst("format", "short").lower() + if format not in ("short", "long"): + format = "short" + + # Get a list of all IP addresses in this request. If none is specified, + # display the GeoIP information for the client's address. + iplist = [] + if form.has_key("ip"): + for ip in form.getlist("ip"): + iplist.extend(ip.split(",")) + else: + iplist.append(req.connection.remote_ip) + + # Open the GeoIP database + gi = GeoIP.open("/var/lib/geoip/GeoLiteCity.dat", GeoIP.GEOIP_MEMORY_CACHE) + + # Display the output according to the specified format + req.content_type = 'text/plain' + + if format == "long": + for ip in iplist: + r = gi.record_by_addr(ip) + if is_valid_geoip_record(r): + fields = [] + fields.append("IP=%s" % ip) + fields.append("LAT=%f" % r['latitude']) + fields.append("LON=%f" % r['longitude']) + + if r.has_key('city') and r['city'] != None: + fields.append("CITY=%s" % escape_output(r['city'])) + if r.has_key('region_name') and r['region_name'] != None: + fields.append("REGION=%s" % escape_output(r['region_name'])) + if r.has_key('country_name') and r['country_name'] != None: + fields.append("COUNTRY=%s" % escape_output(r['country_name'])) + if r.has_key('country_code') and r['country_code'] != None: + fields.append("CC=%s" % escape_output(r['country_code'])) + + r = gi.range_by_ip(ip) + if len(r) == 2: + fields.append("FROM=%s" % r[0]) + fields.append("TO=%s" % r[1]) + + response = " ".join(fields) + req.write(response + "\n") + + elif format == "short": + for ip in iplist: + r = gi.record_by_addr(ip) + if is_valid_geoip_record(r): + city = region = cc = "" + if r.has_key('city') and r['city'] != None: + city = r['city'].replace(",", " ") + if r.has_key('region') and r['region'] != None: + region = r['region'] + if r.has_key('country_code') and r['country_code'] != None: + cc = r['country_code'] + + response = "%s,%s,%s,%s,%f,%f" % (ip, city, region, cc, + r['latitude'],r['longitude']) + req.write(response + "\n") + else: + req.write(ip + ",UNKNOWN" + "\n") + + return apache.OK + diff -Nru vidalia-0.1.13/CREDITS vidalia-0.2.8/CREDITS --- vidalia-0.1.13/CREDITS 2009-05-25 21:48:32.000000000 +0100 +++ vidalia-0.2.8/CREDITS 2009-11-02 17:55:35.000000000 +0000 @@ -2,7 +2,10 @@ Matt Edman -Contributors: +Contributors: + Domenik Bork was a Google Summer of Code student during Summer 2008 and + added the hidden service configuration interface. + Ren Bucholz created some of the onion images off of which Corinna's icons and some of our own images are based. @@ -11,6 +14,9 @@ the .ico files to support more Windowses. He also created the graph style icons in the bandwidth graph settings. + dr|z3d created the Vidalia logo design and image files and helped redesign + the Vidalia website. + Geoff Goodell supplied us with nearly all of the flag icons that we use in the Appearance configuration page and network map. He also created the router status icons we use in @@ -37,15 +43,12 @@ library. Brandon Nase designed and built - the Vidalia-Project website. + the original vidalia-project.net website. Christoph Sieghart (sigi) gave us some code that converts world space coordinates (latitude,longitude) into image space coordinates (x,y) which we used in the Net Viewer. - The Tango Desktop Project created many of the - icons used in Vidalia. See LICENSE for details. - Michael Zuercher and Adam Tomjack of Zuerchertech LLC gave us the ZImageView class which handles drawing, scrolling and zooming the map image in the Network Viewer. @@ -83,4 +86,5 @@ DJHasis Traditional Chinese LinHongJun Turkish Yunus Kaba + Omer Ishakoglu diff -Nru vidalia-0.1.13/debian/changelog vidalia-0.2.8/debian/changelog --- vidalia-0.1.13/debian/changelog 2010-04-25 23:24:29.000000000 +0100 +++ vidalia-0.2.8/debian/changelog 2010-04-25 23:24:29.000000000 +0100 @@ -1,3 +1,105 @@ +vidalia (0.2.8-1~jaunty1~ppa1) karmic; urgency=low + + * Backport to Jaunty-bleed ppa. + + -- Nicola Ferralis Sun, 25 Apr 2010 15:14:56 -0700 + +vidalia (0.2.8-1~jaunty1) jaunty; urgency=low + + * New upstream release. + * New debconf translations: + - Portuguese (Closes: #577000). + - Russian (Closes: #577162). + + -- Erinn Clark Sat, 17 Apr 2010 18:54:45 -0700 + +vidalia (0.2.7-3) unstable; urgency=low + + * Fix broken config script. + + -- Erinn Clark Mon, 05 Apr 2010 02:56:03 -0700 + +vidalia (0.2.7-2) unstable; urgency=low + + * Add option to debconf question to disable Tor on boot in concert with Tor's + recent sourcing of /etc/default/tor.vidalia. (Closes: #542671) + + -- Erinn Clark Sun, 04 Apr 2010 20:16:07 -0700 + +vidalia (0.2.7-1) unstable; urgency=low + + * New upstream release (Closes: #566931). + - Droping pkg from experimental, now going to unstable. + - Drop 0.1.x stable branch in favor of 0.2.x, due to devel matureness. + - Removing kFreeBSD-gcc4.4-fix.patch. Patch accepted and applied on + upstream side before this package to be uploaded (check #566931). + - Added upstream uploader into the about-to-dissappear repacking + source target gpg keyring ('source-repkg'). + * The 'All systems are go!' upload. + + -- Ulises Vitulli Sun, 31 Jan 2010 17:11:20 -0300 + +vidalia (0.2.6-1) unstable; urgency=low + + * New upstream release. + + -- Erinn Clark Fri, 15 Jan 2010 16:14:58 -0800 + +vidalia (0.2.5-1) experimental; urgency=low + + * Upstream development release: + o Add support in the Network settings page for configuring the + Socks4Proxy and Socks5Proxy* options added on Tor 0.2.2.1-alpha. + o Add a context menu for highlighted event items in the "Basic" message + log view that allows the user to copy the selected item text to the + clipboard. + o Maybe fix a time conversion bug that could result in Vidalia + displaying the wrong uptime for a relay in the network map. + o Stop trying to enforce proper quoting and escaping of arguments to be + given to the proxy executable. + + -- Ulises Vitulli Tue, 27 Oct 2009 14:16:32 -0300 + +vidalia (0.2.4-2) experimental; urgency=low + + * Added repackaging from source target functionalty on debian scripts + - README.Source + - debian/rules + * Fix bug which points to a non running Tor process + + -- Ulises Vitulli Mon, 19 Oct 2009 19:36:29 -0300 + +vidalia (0.2.4-1) experimental; urgency=low + + * Upstream development branch sync. + + -- Ulises Vitulli Sat, 12 Sep 2009 09:26:18 -0300 + +vidalia (0.2.0-1) experimental; urgency=low + + * Upload of development branch. + + -- Ulises Vitulli Thu, 23 Jul 2009 22:48:05 -0300 + +vidalia (0.1.15-2) unstable; urgency=low + + * Added repackaging from source target functionalty on debian scripts + - README.Source + - debian/rules + * Fix bug which points to a non running Tor process (Closes: #542670). + + -- Ulises Vitulli Mon, 19 Oct 2009 19:20:36 -0300 + +vidalia (0.1.15-1) unstable; urgency=low + + * New upstream release. + * Debconf translations: + - Czech (Closes: #535973). + * Really fix debconf script issue. + * Update Standard-version to 3.8.2 (no changes needed) + + -- Ulises Vitulli Tue, 21 Jul 2009 06:00:49 -0300 + vidalia (0.1.13-3) unstable; urgency=low * Fixing debconf scripts issue that output twice the same message. diff -Nru vidalia-0.1.13/debian/config vidalia-0.2.8/debian/config --- vidalia-0.1.13/debian/config 2010-04-25 23:24:29.000000000 +0100 +++ vidalia-0.2.8/debian/config 2010-04-25 23:24:29.000000000 +0100 @@ -1,14 +1,57 @@ #!/bin/sh + set -e +if [ -f /usr/share/debconf/confmodule ]; then + . /usr/share/debconf/confmodule +fi -#DEBHELPER# -. /usr/share/debconf/confmodule +seen='false' +askuser() { + question='vidalia/info' + db_input high $question || true + db_go || true + db_get $question +} -if [ "$1" = "configure" ]; then - db_fset vidalia/info seen false - db_input high vidalia/info || true - db_go +if [ "$1" = "configure" ] || [ "$1" = "reconfigure" ]; then + if dpkg -l tor > /dev/null 2>&1; then + # installed + if [ -e '/var/run/tor/tor.pid' ] || [ "$1" = "reconfigure" ]; then + # and already running + askuser + seen='true' + case "$RET" in + (no) + if [ -f /etc/default/tor.vidalia ]; then + ucf --debconf-ok --three-way /usr/share/vidalia/default.tor-on /etc/default/tor.vidalia + fi + ;; + (yes-now) + invoke-rc.d --force tor stop + if [ -f /etc/default/tor.vidalia ]; then + ucf --debconf-ok --three-way /usr/share/vidalia/default.tor-on /etc/default/tor.vidalia + fi + ;; + (yes-always) + invoke-rc.d --force tor stop + ucf --debconf-ok --three-way /usr/share/vidalia/default.tor-off /etc/default/tor.vidalia + ;; + esac + fi + fi + + if pgrep -x tor > /dev/null 2>&1; then + # still running?? (e.g. chroot) + if [ "$seen" = "false" ]; then + askuser + if [ "$RET" = "true" ]; then + echo -n "Stopping tor daemon: " + pkill -x tor > /dev/null && echo "tor." || echo 'Failed!' + fi + fi + fi + db_stop fi -exit 0 +#DEBHELPER# diff -Nru vidalia-0.1.13/debian/control vidalia-0.2.8/debian/control --- vidalia-0.1.13/debian/control 2010-04-25 23:24:29.000000000 +0100 +++ vidalia-0.2.8/debian/control 2010-04-25 23:24:29.000000000 +0100 @@ -2,14 +2,14 @@ Section: net Priority: extra Maintainer: Vern Sun -Uploaders: Ulises Vitulli +Uploaders: Ulises Vitulli , Erinn Clark Build-Depends: debhelper (>= 5), autotools-dev, libqt4-dev (>= 4.1.0), po-debconf (>= 1.0), cmake (>= 2.4.8), libssl-dev (>= 0.9.8g), quilt -Standards-Version: 3.8.1 +Standards-Version: 3.8.4 Homepage: http://www.vidalia-project.net Package: vidalia Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, debconf (>=1.5.11) | debconf-2.0 +Depends: ${shlibs:Depends}, ${misc:Depends}, debconf (>=1.5.11) | debconf-2.0, ucf Recommends: tor Suggests: iceweasel-torbutton Description: controller GUI for the Tor software diff -Nru vidalia-0.1.13/debian/default.tor-off vidalia-0.2.8/debian/default.tor-off --- vidalia-0.1.13/debian/default.tor-off 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/debian/default.tor-off 2010-04-25 23:24:29.000000000 +0100 @@ -0,0 +1,3 @@ +if [ -x /usr/bin/vidalia ]; then + RUN_DAEMON=no +fi diff -Nru vidalia-0.1.13/debian/default.tor-on vidalia-0.2.8/debian/default.tor-on --- vidalia-0.1.13/debian/default.tor-on 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/debian/default.tor-on 2010-04-25 23:24:29.000000000 +0100 @@ -0,0 +1 @@ +# diff -Nru vidalia-0.1.13/debian/patches/debians-tor-binary-path.patch vidalia-0.2.8/debian/patches/debians-tor-binary-path.patch --- vidalia-0.1.13/debian/patches/debians-tor-binary-path.patch 2010-04-25 23:24:29.000000000 +0100 +++ vidalia-0.2.8/debian/patches/debians-tor-binary-path.patch 2010-04-25 23:24:29.000000000 +0100 @@ -1,8 +1,8 @@ Author: dererk Description: Even though upstream has implemented a block of code to perform this check, as Tor's binary is located in /usr/sbin path, regular users are likely to lack that path in their PATH enviroment variable. This patch purpose is setting it to the right Debian's Tor package. ---- old/src/vidalia/config/torsettings.cpp 2009-01-14 13:56:54.000000000 -0200 -+++ new/src/vidalia/config/torsettings.cpp 2009-01-14 14:42:46.000000000 -0200 -@@ -65,7 +65,8 @@ +--- old/src/vidalia/config/TorSettings.cpp 2009-01-14 13:56:54.000000000 -0200 ++++ new/src/vidalia/config/TorSettings.cpp 2010-01-23 06:02:41.930010310 -0300 +@@ -68,7 +68,8 @@ else setDefault(SETTING_TOR_EXECUTABLE, programFiles + "\\Tor\\tor.exe"); #else diff -Nru vidalia-0.1.13/debian/po/cs.po vidalia-0.2.8/debian/po/cs.po --- vidalia-0.1.13/debian/po/cs.po 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/debian/po/cs.po 2010-04-25 23:24:29.000000000 +0100 @@ -0,0 +1,46 @@ +# This file is distributed under the same license as the vidalia package. +# Martin Sin , 2009. +# +msgid "" +msgstr "" +"Project-Id-Version: vidalia 0.1.13-3\n" +"Report-Msgid-Bugs-To: vidalia@packages.debian.org\n" +"POT-Creation-Date: 2008-09-18 15:32-0300\n" +"PO-Revision-Date: 2009-07-06 16:01+0200\n" +"Last-Translator: Martin Sin \n" +"Language-Team: Czech \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Type: boolean +#. Description +#: ../templates:1001 +msgid "Do you want to stop the existing Tor process and let Vidalia start Tor?" +msgstr "Přejete si ukončit stávající proces Tor a spustit ho pomocí Vidalia?" + +#. Type: boolean +#. Description +#: ../templates:1001 +msgid "" +"It looks like there is a Tor process already running. If you want to start " +"Tor using Vidalia, you might have to stop the existing Tor process. " +"Otherwise you will have to enable 'ControlPort' option into Tor as explained " +"in the documentation carried with this package ('/usr/share/doc/vidalia/" +"README.Debian')." +msgstr "" +"Vypadá to, že proces Tor už běží. Pokud chcete začít používat Vidalia v Tor, " +"měli byste ukončit běžící proces. Jinak budete muset povolit volbu " +"'ControlPort' v Tor tak, jak je vysvětleno v dokumentaci tohoto balíčku " +"('/usr/share/doc/vidalia/README.Debian')." + +#. Type: boolean +#. Description +#: ../templates:1001 +msgid "" +"Note that if you choose to let Vidalia start Tor, you will have to manually " +"disable Tor starting automatically on every reboot (See 'README.Debian')." +msgstr "" +"Pamatujte, že jakmile umožníte Vidalia spustit Tor, budete muset ještě ručně " +"zakázat automatické spuštění při každém restartu počítače (viz. " +"'README.Debian')." diff -Nru vidalia-0.1.13/debian/po/pt.po vidalia-0.2.8/debian/po/pt.po --- vidalia-0.1.13/debian/po/pt.po 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/debian/po/pt.po 2010-04-25 23:24:29.000000000 +0100 @@ -1,51 +1,65 @@ # translation of vidalia debconf to Portuguese -# Copyright (C) 2008 Américo Monteiro +# Copyright (C) 2008 the vidalia's copyright holder # This file is distributed under the same license as the vidalia package. # -# Américo Monteiro , 2008. +# Américo Monteiro , 2008, 2010. msgid "" msgstr "" -"Project-Id-Version: vidalia 0.1.9-1\n" -"Report-Msgid-Bugs-To: vidalia@packages.debian.org\n" -"POT-Creation-Date: 2008-09-18 15:32-0300\n" -"PO-Revision-Date: 2008-09-19 21:35+0100\n" +"Project-Id-Version: vidalia 0.2.7-3\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2010-04-06 10:32+0200\n" +"PO-Revision-Date: 2010-04-06 18:25+0100\n" "Last-Translator: Américo Monteiro \n" "Language-Team: Portuguese \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Generator: KBabel 1.11.4\n" +"X-Generator: Lokalize 1.0\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" -#. Type: boolean +#. Type: select #. Description #: ../templates:1001 msgid "Do you want to stop the existing Tor process and let Vidalia start Tor?" msgstr "" "Deseja parar o processo Tor existente e deixar o Vidalia iniciar o Tor?" -#. Type: boolean -#. Description -#: ../templates:1001 -msgid "" -"It looks like there is a Tor process already running. If you want to start " -"Tor using Vidalia, you might have to stop the existing Tor process. " -"Otherwise you will have to enable 'ControlPort' option into Tor as explained " -"in the documentation carried with this package ('/usr/share/doc/vidalia/" -"README.Debian')." -msgstr "" -"Parece que já existe um processo Tor a correr. Se você deseja iniciar o Tor " -"usando o Vidalia, você poderá ter que parar o processo Tor existente. Caso " -"contrário você terá que activar a opção 'ControlPort' no Tor como está " -"explicado na documentação que acompanha este pacote ('/usr/share/doc/vidalia/" -"README.Debian')." +#. Type: select +#. Choices +#: ../templates:1002 +msgid "No" +msgstr "Não" -#. Type: boolean -#. Description -#: ../templates:1001 -msgid "" -"Note that if you choose to let Vidalia start Tor, you will have to manually " -"disable Tor starting automatically on every reboot (See 'README.Debian')." -msgstr "" -"Note que se você deseja que o Vidalia inicie o Tor, você terá que desactivar " -"manualmente o arranque automático do Tor a cada arranque da máquina (veja " -"'README.Debian')." +#. Type: select +#. Choices +#: ../templates:1002 +msgid "Yes (just for now)" +msgstr "Sim (apenas desta vez)" + +#. Type: select +#. Choices +#: ../templates:1002 +msgid "Yes (and disable it for every boot)" +msgstr "Sim (e desactivá-lo em todos os arranques)" + +#~ msgid "" +#~ "It looks like there is a Tor process already running. If you want to " +#~ "start Tor using Vidalia, you might have to stop the existing Tor process. " +#~ "Otherwise you will have to enable 'ControlPort' option into Tor as " +#~ "explained in the documentation carried with this package ('/usr/share/" +#~ "doc/vidalia/README.Debian')." +#~ msgstr "" +#~ "Parece que já existe um processo Tor a correr. Se você deseja iniciar o " +#~ "Tor usando o Vidalia, você poderá ter que parar o processo Tor existente. " +#~ "Caso contrário você terá que activar a opção 'ControlPort' no Tor como " +#~ "está explicado na documentação que acompanha este pacote ('/usr/share/doc/" +#~ "vidalia/README.Debian')." + +#~ msgid "" +#~ "Note that if you choose to let Vidalia start Tor, you will have to " +#~ "manually disable Tor starting automatically on every reboot (See 'README." +#~ "Debian')." +#~ msgstr "" +#~ "Note que se você deseja que o Vidalia inicie o Tor, você terá que " +#~ "desactivar manualmente o arranque automático do Tor a cada arranque da " +#~ "máquina (veja 'README.Debian')." diff -Nru vidalia-0.1.13/debian/po/ru.po vidalia-0.2.8/debian/po/ru.po --- vidalia-0.1.13/debian/po/ru.po 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/debian/po/ru.po 2010-04-25 23:24:29.000000000 +0100 @@ -1,51 +1,44 @@ -# translation of ru.po to Russian +# translation of vidalia_0.2.7-3_ru.po to Russian # Copyright (C) 2008 Yuri Kozlov # This file is distributed under the same license as the vidalia package. # # Yuri Kozlov , 2008. +# Yuri Kozlov , 2010. msgid "" msgstr "" -"Project-Id-Version: ru\n" -"Report-Msgid-Bugs-To: vidalia@packages.debian.org\n" -"POT-Creation-Date: 2008-09-18 15:32-0300\n" -"PO-Revision-Date: 2008-09-18 23:02+0400\n" -"Last-Translator: Yuri Kozlov \n" +"Project-Id-Version: vidalia 0.2.7-3\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2010-04-06 10:32+0200\n" +"PO-Revision-Date: 2010-04-10 12:03+0400\n" +"Last-Translator: Yuri Kozlov \n" "Language-Team: Russian \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Generator: KBabel 1.11.4\n" -"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%" -"10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n" +"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n" -#. Type: boolean +#. Type: select #. Description #: ../templates:1001 msgid "Do you want to stop the existing Tor process and let Vidalia start Tor?" msgstr "Остановить работающий процесс Tor и позволить Vidalia запустить Tor?" -#. Type: boolean -#. Description -#: ../templates:1001 -msgid "" -"It looks like there is a Tor process already running. If you want to start " -"Tor using Vidalia, you might have to stop the existing Tor process. " -"Otherwise you will have to enable 'ControlPort' option into Tor as explained " -"in the documentation carried with this package ('/usr/share/doc/vidalia/" -"README.Debian')." -msgstr "" -"Кажется, что процесс Tor уже запущен. Если вы хотите запустить Tor используя " -"Vidalia, то нужно остановить работающий процесс Tor. Или же вы можете " -"включить параметр 'ControlPort' в Tor (см. документацию по этому пакету, " -"файл /usr/share/doc/vidalia/README.Debian)." +#. Type: select +#. Choices +#: ../templates:1002 +msgid "No" +msgstr "Нет" + +#. Type: select +#. Choices +#: ../templates:1002 +msgid "Yes (just for now)" +msgstr "Да (прямо сейчас)" + +#. Type: select +#. Choices +#: ../templates:1002 +msgid "Yes (and disable it for every boot)" +msgstr "Да (и отключить запуск при загрузке машины)" -#. Type: boolean -#. Description -#: ../templates:1001 -msgid "" -"Note that if you choose to let Vidalia start Tor, you will have to manually " -"disable Tor starting automatically on every reboot (See 'README.Debian')." -msgstr "" -"Заметим, что если вы выберете запуск Tor с помощью Vidalia, то вам нужно " -"самостоятельно выключить автоматический запуск Tor при включении машины (см. " -"'README.Debian')." diff -Nru vidalia-0.1.13/debian/po/sv.po vidalia-0.2.8/debian/po/sv.po --- vidalia-0.1.13/debian/po/sv.po 2010-04-25 23:24:29.000000000 +0100 +++ vidalia-0.2.8/debian/po/sv.po 2010-04-25 23:24:29.000000000 +0100 @@ -1,7 +1,6 @@ -# translation of vidalia.po to swedish -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. +# This file is distributed under the same license as the vidalia package. # +# translation of vidalia.po to swedish # Martin Bagge , 2008. msgid "" msgstr "" diff -Nru vidalia-0.1.13/debian/postinst vidalia-0.2.8/debian/postinst --- vidalia-0.1.13/debian/postinst 2010-04-25 23:24:29.000000000 +0100 +++ vidalia-0.2.8/debian/postinst 2010-04-25 23:24:29.000000000 +0100 @@ -1,40 +1,7 @@ #!/bin/sh set -e - -#DEBHELPER# - -. /usr/share/debconf/confmodule - - -seen='false' -askuser() { - db_get vidalia/info -} - -if [ "$1" = "configure" ]; then - if dpkg -l tor > /dev/null 2>&1; then - # installed - if [ -e '/var/run/tor/tor.pid' ]; then - # and already running - askuser - seen='true' - if [ "$RET" = "true" ]; then - invoke-rc.d --force tor stop - fi - fi - fi - - if pgrep -x tor > /dev/null 2>&1; then - # still running?? (e.g. chroot) - if [ "$seen" = "false" ]; then - askuser - if [ "$RET" = "true" ]; then - echo -n "Stopping tor daemon: " - pkill -x tor > /dev/null && echo "tor." || echo 'Failed!' - fi - fi - fi - db_stop +if [ -f /usr/share/debconf/confmodule ]; then + . /usr/share/debconf/confmodule fi -exit 0 +#DEBHELPER# diff -Nru vidalia-0.1.13/debian/postrm vidalia-0.2.8/debian/postrm --- vidalia-0.1.13/debian/postrm 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/debian/postrm 2010-04-25 23:24:29.000000000 +0100 @@ -0,0 +1,14 @@ +#!/bin/sh +set -e + +#DEBHELPER# + +if [ "$1" = "purge" ]; then + echo " Removing /etc/default/tor.vidalia" + rm -f /etc/default/tor.vidalia + if [ -x "/usr/bin/ucf" ]; then + ucf --purge /etc/default/tor.vidalia + fi +fi + +exit 0 diff -Nru vidalia-0.1.13/debian/README.Debian vidalia-0.2.8/debian/README.Debian --- vidalia-0.1.13/debian/README.Debian 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/debian/README.Debian 2010-04-25 23:24:29.000000000 +0100 @@ -4,28 +4,15 @@ There are currently two ways of communication supported between Tor daemon (carried with 'tor' package), and Vidalia interface: -1. Letting Vidalia start Tor process by its own. +1. Letting Vidalia start Tor process on its own. --------------------------------------------- This is default option on debconf while configuring vidalia package (easy reconfigurable by running 'dpkg-reconfigure vidalia'). - This option implies that you have to manually disable Tor - starting automatically on every reboot, as shown below: - - # update-rc.d -f tor remove - Removing any system startup links for /etc/init.d/tor ... - /etc/rc0.d/K20tor - /etc/rc1.d/K20tor - /etc/rc2.d/S20tor - /etc/rc3.d/S20tor - /etc/rc4.d/S20tor - /etc/rc5.d/S20tor - /etc/rc6.d/K20tor - - You can create all the symlinks back by using: - # update-rc.d tor defaults - + This is now handled in the debconf front-end to Vidalia. If you decide you no + longer wish to have Vidalia control Tor, and want to re-enable Tor's ability to + start when your machine boots, dpkg-reconfigure vidalia and choose 'no'. 2. Enable Tor to use a control port to communicate with Vidalia. ------------------------------------------------------------- @@ -35,8 +22,10 @@ and adding the proper value to 'HashedControlPassword', as shown below: # tor --hash-password SOME_PASSWORD_HERE - Sep 17 18:48:49.421 [notice] Tor v0.2.0.30 (r15956). This is experimental software. Do not rely on it for strong anonymity. (Running on Linux x86_64) - 16:167F667A98F859D2600BD708B48B95343FEF7800B479E2AA4284ACF029 + Sep 17 18:48:49.421 [notice] Tor v0.2.0.30 (r15956). This is experimental + software. Do not rely on it for strong anonymity. (Running on Linux x86_64) + +16:167F667A98F859D2600BD708B48B95343FEF7800B479E2AA4284ACF029 You will have to have something like this: @@ -51,3 +40,4 @@ -- Ulises Vitulli Wed, 17 Sep 2008 17:24:06 -0300 + (Updated by Erinn Clark Sun, 04 Apr 2010 20:16:07 -0700) diff -Nru vidalia-0.1.13/debian/README.debs vidalia-0.2.8/debian/README.debs --- vidalia-0.1.13/debian/README.debs 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/debian/README.debs 2010-02-16 07:39:18.000000000 +0000 @@ -0,0 +1,31 @@ +================================ +Debian and Ubuntu packages +================================ + +Binary packages +-------------------------------- +Debian and Ubuntu packages are now available in the Tor Debian/Ubuntu +repository. Instructions for adding the repository to your +/etc/apt/sources.list and installing Vidalia can be found here: +https://www.torproject.org/docs/debian-vidalia.html.en + +Building your own +-------------------------------- +If you would like to build your own packages, you can get the current +debian/ directory by cloning the git repository: + +git clone http://git.debian.org/git/collab-maint/vidalia.git + +Then move everything from the debian/0.2.x directory into the +vidalia-x.x.x/debian/ directory and build packages as normal. + +Instructions +-------------------------------- +For information about building Debian and Ubuntu packages, please consult +the following documentation: + +1. https://wiki.debian.org/DebianPackagingHandbook +2. http://www.debian.org/doc/maint-guide/ch-build.en.html +3. https://www.netfort.gr.jp/~dancer/software/pbuilder-doc/pbuilder-doc.html +4. https://wiki.ubuntu.com/PackagingGuide/Complete +5. https://wiki.ubuntu.com/PbuilderHowto diff -Nru vidalia-0.1.13/debian/README.source vidalia-0.2.8/debian/README.source --- vidalia-0.1.13/debian/README.source 2010-04-25 23:24:29.000000000 +0100 +++ vidalia-0.2.8/debian/README.source 2010-04-25 23:24:29.000000000 +0100 @@ -1,7 +1,34 @@ +Repackaging upstream source +=========================== + +Official source has been repkg to exclude debian/ directory coming from official + release. + +This is the whole process applied to exclude that directory could be found on + the source-rpkg debian/rules target: + +dererk erebus[~/debian/vidalia/devel/vidalia-0.2.4]$ debian/rules source-repkg +gpg: Signature made Mon Sep 7 14:15:07 2009 ART using DSA key ID 5FA14861 +gpg: Good signature from "Matt Edman " +gpg: aka "Matt Edman " +gpg: aka "Matt Edman " +gpg: aka "Matt Edman " +gpg: WARNING: This key is not certified with a trusted signature! +gpg: There is no indication that the signature belongs to the owner. +Primary key fingerprint: 9467 294A 9985 3C9C 65CB 141D AF7E 0E43 5FA1 4861 +Repackaged source file located in /home/dererk/debian/vidalia/devel/vidalia-0.2.4/debian/rpkg-source +Target accomplished. + + + +Building Vidalia from source +============================ + # # getting the upstream sources # -New upstream tarballs are located here http://www.torproject.org/vidalia/dist/vidalia-0.1.13.tar.gz +New official upstream tarballs are located here http://www.torproject.org/vidalia/ + # # Debian specific patches @@ -11,8 +38,8 @@ # # using pbuilder # -tar -zxf vidalia-0.1.13.tar.gz -cd vidalia-0.1.13/ +tar -zxf vidalia-0.1.15.tar.gz +cd vidalia-0.1.15/ pbuilder Here a small readme in order to use the upstream tarballs: @@ -25,8 +52,8 @@ DEBIAN_FRONTEND="readline" AUTO_DEBSIGN=yes -So for building this package go to vidalia-0.1.13/ and call there e.g.: - % ln -sf ../vidalia-0.1.13.tar.gz vidalia_0.1.13.orig.tar.gz +So for building this package go to vidalia-0.1.15/ and call there e.g.: + % ln -sf ../vidalia-0.1.15.tar.gz vidalia_0.1.15.orig.tar.gz % dch -i % pdebuild diff -Nru vidalia-0.1.13/debian/rules vidalia-0.2.8/debian/rules --- vidalia-0.1.13/debian/rules 2010-04-25 23:24:29.000000000 +0100 +++ vidalia-0.2.8/debian/rules 2010-04-25 23:24:29.000000000 +0100 @@ -15,6 +15,9 @@ DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) +# Used for repacking upstream tarball +UPVERSION=$(shell echo `head -n 1 debian/changelog|sed -e 's/^[^(]*(\([^)]*\)).*/\1/'`|sed -e 's/-.*//') + CFLAGS = -Wall -g @@ -85,5 +88,19 @@ dh_md5sums dh_builddeb +source-repkg: + [ -d $(CURDIR)/debian/rpkg-source ] || mkdir $(CURDIR)/debian/rpkg-source ; \ + cd debian/rpkg-source; \ + wget -q http://www.torproject.org/vidalia/dist/vidalia-$(UPVERSION).tar.gz ; \ + wget -q http://www.torproject.org/vidalia/dist/vidalia-$(UPVERSION).tar.gz.asc ; \ + gpg --no-default-keyring --keyring ./repackaging-keyring.gpg --import ../upstream-keyring.pubkey ; \ + gpg --no-default-keyring --keyring ./repackaging-keyring.gpg --verify vidalia-$(UPVERSION).tar.gz.asc || \ + exit 1 ; \ + tar zxf vidalia-$(UPVERSION).tar.gz ; \ + rm -rf vidalia-$(UPVERSION)/debian ; \ + tar zcf vidalia-$(UPVERSION).repkg.tar.gz vidalia-$(UPVERSION) && \ + echo "Target accomplished. Repackaged source file located in $(CURDIR)/debian/rpkg-source" + + binary: binary-indep binary-arch .PHONY: build clean binary-indep binary-arch binary install diff -Nru vidalia-0.1.13/debian/templates vidalia-0.2.8/debian/templates --- vidalia-0.1.13/debian/templates 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/debian/templates 2010-04-25 23:24:29.000000000 +0100 @@ -1,11 +1,5 @@ Template: vidalia/info -Type: boolean -Default: true +Type: select +Choices-C: no, yes-now, yes-always _Description: Do you want to stop the existing Tor process and let Vidalia start Tor? - It looks like there is a Tor process already running. If you want to start Tor - using Vidalia, you might have to stop the existing Tor process. Otherwise you - will have to enable 'ControlPort' option into Tor as explained in the documentation - carried with this package ('/usr/share/doc/vidalia/README.Debian'). - . - Note that if you choose to let Vidalia start Tor, you will have to manually disable - Tor starting automatically on every reboot (See 'README.Debian'). +__Choices: No, Yes (just for now), Yes (and disable it for every boot) diff -Nru vidalia-0.1.13/debian/upstream-keyring.pubkey vidalia-0.2.8/debian/upstream-keyring.pubkey --- vidalia-0.1.13/debian/upstream-keyring.pubkey 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/debian/upstream-keyring.pubkey 2010-04-25 23:24:29.000000000 +0100 @@ -0,0 +1,475 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: GnuPG v1.4.10 (GNU/Linux) + +mQGiBEMCjw4RBAC9TqSa2YZjkKgSN/Tg+ccWZOfFABgrJTisaycttnBRo03+roB7 +SQLyQWp0qY2D6rfuK4DuheE3hFFAlHcapOl4qKMXGIGj1LYRbO+H+AqNhfE2kwoQ +LoxdQv5ALK2UBnA/oQ3HW9GbwMlPlLHJV53t7ORzI4ZpFHgxgr1ffOw5xwCg5zqx +rNS03Qaqp0q0G9wplem/2X8D/i2nr6g98SKDrNi9Q1yIKJkcgb5d7ImRT/XfmFfS +SGYhPIhQFaFKZDLXPh9ZHF2KyI+sJpTIU2Eq7KgdPqvlONRFO4gR24cUD3gNjRLN +2bEfSADVygNu1g6mQRoIlB9xE4WuparGtipRtK0dVLSsM1/VF+RARW6hvlorRChq +4y+xA/0W1WmRwx0wjZa4UyWwdHjpk3T0fBNaChVHEDFezt9HpzNy0dMsvmudEYfH +nGquZnA5LeAfvJtCK/WjigP0mGUS+B0VPrx2Y/Xp7VEfIpbHgELOFvSv5ovn3l+k +PbyDRuA+v6EaIRegN+KpRV8UYpf7mZKoVoKgPfix6ChXKtY017QbTWF0dCBFZG1h +biA8ZWRtYW5tQHJwaS5lZHU+iEYEEBECAAYFAkRqBQQACgkQMClaFO3FYrFTmgCg +y282HsNr3LprgE0UXJbxvAXvF8EAn1Vpg56HhA2p/u9taQplbR2No1mjiEYEEBEC +AAYFAkRqBQQACgkQMClaFO3FYrHMpACfZuXDVyblhvm8DRUAWNXQ5pAS1GUAoOXi +vqY/0rEd4x7EYH9mE0e21Y6RiEYEEBECAAYFAkR1+aUACgkQ61qJaiiYi/WbiACf +fXDwrlIPBY6jZfxjt6pIiHq2KGMAn2PT6OtGyKXOBywU7hpuQkGeZD2SiEYEEBEC +AAYFAkT2HZAACgkQ/tbRwNpznjMtpACeNMZAGh1zG2A3pwVofsQYSX+aVtEAoNAS +deyuNZHFMfCfqHs2gGHPuA8HiEYEEBECAAYFAkY2B4AACgkQyGgRVFYkyFwjJgCe +PzGWc0lZQtKq5bPjhFAmzCqwqz8An16UkV6uWFtYoa/AQKS3fKGmLdTjiGMEExEC +ACMCGwMGCwkIBwMCBBUCCAMEFgIDAQIeAQIXgAUCQw07wgIZAQAKCRCvfg5DX6FI +YWD1AKDJzHS3/djK8byPAhQhiZUAnncYdACeKLNwEk58e4Ox+QYixc+WsmlGrjqI +RgQQEQIABgUCR3vBIwAKCRDQz5Y998ESZbWBAKC47BQDQI7WqsPZ8wGNs60CfXYj +kACfcM09lUmBi+5sP6ubxDkjmiTanqqIRgQQEQIABgUCSgVz/AAKCRBO/m9WkTW9 +nRRNAJ4hOJa3XpkAJZKrwHlyPIlgdWkcsQCfWqUONs4XrX2YeD6cdN7XX6OcLTSI +RgQSEQIABgUCR4JwhAAKCRDeeq9ulMCcf89PAKCpaaInPqB0KQp3FMH8z0271q08 +SQCfVq2zHO42tr2go+8XICqFJpkJGPKIRgQSEQIABgUCSgCiXAAKCRBFZb8QyTkR +D5M4AJ0U7/dH8P+hNGr21+SyC/u6I6Bc7wCdHuyn3a5iCHl3Qf5SCiMpXQ8trwCJ +AhwEEgECAAYFAksRhzgACgkQmZMeJdkeASxyZg/9EhQ9OE0nvK4NuDikbrjVRbQD +j6FBj/DNzu77eyOJg4nkBRc+eTY2d8QmzAp+zANGE7pWzWV2UCxT4QFfQe2GGAZt +PRqHlH5GCuwLWDtTrsqeVEad+TylEQRXXHum6H9ciYW50pUKNBlm868SgqMoolh4 +hPU7E9Hfh/6XFXsiK5OEPj6cWYtmPtgLL7Ad7twPnnxzIQuRFsRxkIMCbBbJsKXC +nGpQv+6cP3ZAXLznQPewfSTC322Fvh+BeTz45OW9uzUSui+okbSIqvsNZC8N3hFd +HZEf3F9UCt1nyWBYZq0Y/0dMslr+OIg1S3sGdLHMR2ZSIJ4DVFRkCPd/gKD5I5jj +kGVvWHzODwpq2M69ZjE0TYfZ1nylD0Oo13hrMusnkU77mHDsnsFjzwRwHbdqklb6 +PNrE2u9F6auu2iTQmtik23hs92R/cnGM8Y4u9unCO86aUA9ke8bQBxmw9rAm6+Qp +jNWYDX/P5/SYE7RBDGq8lV53aAMb5RqsMV0DFid7sZ60jiOTvj5o/gnJQM8zwerb +Mmwa9CXV7scg008Bi969npECYTnBKa3bXwnRl4gBdCvmSpKYixrZDPedH4F6gfdv +ceVgyaBHUYwmr/acLthYr/nWx7imVDF1k38BE+a7EapMTiowMeDcNGeLRo2gUTYR +7NqhwRUiVn2kQq24Gi+0H01hdHQgRWRtYW4gPGVkbWFubTJAY3MucnBpLmVkdT6I +RgQQEQIABgUCRGoFBAAKCRAwKVoU7cVisZVMAJsExHrIA+cxplYi8OS19MICz15e +igCg+UZdlihFEEKlsDjWdQDSdAsflBSIRgQQEQIABgUCRHX5qgAKCRDrWolqKJiL +9XFNAJ9LkS1Jy+zpj7MHij2JvUCOcP/7HwCgwv8JkA82TH8ZAzGjF1hjlJaYQjyI +RgQQEQIABgUCRPYdlwAKCRD+1tHA2nOeMzjWAJ9ilBS11uH87b4AS9jGwB3kOS8Z +LACgjrRiYoVz0TxpuPE+SoM7T8FG56yIRgQQEQIABgUCRjYHhgAKCRDIaBFUViTI +XJw1AJ4t1AwMa0EpUF+vWBJAUd94YxgarQCeNdmXLP99X4dGd6B5xx2KaLD2BOqI +YAQTEQIAIAUCQw07CQIbAwYLCQgHAwIEFQIIAwQWAgMBAh4BAheAAAoJEK9+DkNf +oUhht0gAnR7mMnktrlMGwFEvG/3kPKqOnZ2wAJ95mM7LdJx/mi8956qAyMcocOAR +y4hGBBARAgAGBQJHe8EqAAoJENDPlj33wRJlmG8An0qMRvG6oWh1tU5C2VvMI+XR +XfmbAJ9HL6VWaMvcso1AV0Sf91hSkiMgFohGBBARAgAGBQJKBXP8AAoJEE7+b1aR +Nb2dU0cAoI4zbKtHQ4/BAMNGCrWpkpZUzokuAJ4z5UD/lQfjK5qAe8ml4DYedcNM +L4hGBBIRAgAGBQJHgnCEAAoJEN56r26UwJx/fvsAnApdz87KjABp5qqGd1oc8lq3 +DP60AJ9y4pHdHIKQCj6T0R8kp3PRvwZXyohGBBIRAgAGBQJKAKJcAAoJEEVlvxDJ +OREPYeYAn3bqSSEe+j4KoVtMUIgjr4Xe4BM2AJ46IU4g96HVQX4eCOrLWjJ2CYDZ +HIkCHAQSAQIABgUCSxGHOAAKCRCZkx4l2R4BLPq5D/0dJ3lYEZub/ub84orfzJQ0 +2Wny12QhAYHZ/Tfy6mTG7HNlMfJa8mPmDh2Pp9PzTc3r35u7mUTdzr3uoOw5OPCn +PODn/NCRq0oCA5wRBLhJhGtQz5yxzrP9p2obF4Mc8BxDQhALVUBWAot3pK0o6x41 +MnvNhHU6QCkN59M0UP5f679ypMU4bVon1pY6pXqyImVcywz0EZ+X1RrPNfi4sGYG +4IAONSCMEO+f/uzfaRayrSunUzbba1RXYDI+zZP9tVGNJhIPD1PdSIfV9WM6CKzc +AQDv+qCLH8tT48allkys1W5uGcqrOyANzucI1Nd29S/+fxRnIKTDTryAJ77q1t0l +wnjj4Anpn9g7Q1/QBz3ck6Z0p9SxVjM3rMCsDW/StHh55MwBVd4IzZlJiEyOAVMv +f97vQ1OZg/nrzgZpQTWhG0VzCTL2UpD5iBGH8BFLjI2agCVT/4m1aUM+o7OxgTKs +T5owCrpzUJn13k9Yp/uBSy+5VSP91WoSc6Ze6bZaEil12+Y5/mfJt+XvQWcfOxcf +tLLhDbx4fpLmgMeDm6XXIgenpN3wTppaaOAI5L6OoLRbwbjYCmyTAO0DW9PzVv50 +Gk3FgFQybDfe0VoF2i3nx5oHYa9wxQDW8JzwTTsRb7kotm+MtlJymLeh5n1KRPlg +eRNzaNgYhbF5bn57J8pKFbQiTWF0dCBFZG1hbiA8TWF0dF9FZG1hbkBiYXlsb3Iu +ZWR1PohGBBARAgAGBQJEagUEAAoJEDApWhTtxWKxzKQAn2blw1cm5Yb5vA0VAFjV +0OaQEtRlAKDl4r6mP9KxHeMexGB/ZhNHttWOkYhGBBARAgAGBQJEdfmqAAoJEOta +iWoomIv12E4AnRJJr7YmfpaDlDA9cN9adP08/bNJAJ0SuWAbLxLTBCxTSJ3Rals1 +OkZktYhGBBARAgAGBQJE9h2XAAoJEP7W0cDac54zercAoMnEMjwVvkCbbgGXOzhG +zZJtah4cAJ0f6mH6/2VE2G80arGyOmTxDVMRh4hGBBARAgAGBQJGNgeGAAoJEMho +EVRWJMhcLQ4Anjyjboc3N/2EvE+vCnQaSbr2ECkHAKCJxXM2Swygv/vil3O+TZkr +KpDaaIhgBBMRAgAgBQJDAo8OAhsDBgsJCAcDAgQVAggDBBYCAwECHgECF4AACgkQ +r34OQ1+hSGFLbQCgndQj8SZsA52RQn/x3lMYnAOq8NwAoLEDd1FOumTYwAO9Ckq+ +HAKYMV1BiEYEEBECAAYFAkd7wSoACgkQ0M+WPffBEmUIfwCdGqODP6uw8B69AOwY +XdDTFiGDi/8Anje0pBVl/lhQTHZKPvOlgBgfkrmliEYEEBECAAYFAkoFc/wACgkQ +Tv5vVpE1vZ3MIgCcC2YanPZNPdRacLeo4Dxzc94RNZ4AoJIJcaPaGj1OHen+rWOV +QDA9dU0DiEYEEhECAAYFAkoAolwACgkQRWW/EMk5EQ+wIQCfW7kH6jRBHusJFWeb +TECW3BvahygAn2hnN0/lW/OspqwQgmpscy806ys0iQIcBBIBAgAGBQJLEYc4AAoJ +EJmTHiXZHgEsOgoQAKI7NnuP3sxfK7tslaDNC33HFsUcBmzDNx26isOytzQyq6mo +STQmUZHnYeD3hlj9zFhDEPHCTlHGY8Y1o64OYJxM5Yl+CHGURvHHDkoqbtb3/8iI +N5jvzMZNHnMZwjpUsgjAxyRU8DT+K0OH0QNomMrBheKa9dwbvF2xUn714+nNn6A3 +DhkeRCRirPoyAW0kmc4yF4NzywtZgtDUY2gqKO23jnUcAFmFf+nzgC8je5dJXD+k +/pmJOWprPExp6+QgTwZ/YGnIVIZ4zSdmAsjuAa9LylwIc9Mgsv80PQDxEEg8xkE4 +G/eC8QATmS5rE6NE5+GxsT2WYAr1MAWU7Hol4sl9AF2X46N2jyzW1L9e9XPkTU2k +5nSa7jIcylAQ1cmonSUUVx+ryFBgLCIqDU6CkTTX/ybXW9nMZ+2NJmsy7CgUZd+l +gcchqzd3LeeyAD6pswZKQnoSmPvFueh3DtRHUpI4ZC04iS9jp/pQ64uhpwqYFaZD +4WTZHXHjpo73zkvBVtAsGSLp462XHkuLUvT8196dqJaIfB/d3/c+Oo/W9hnIqsld +2rnAv/3hCVqzlak7hBpbb0bNlBKvp5n+AoLpCr2tv8seZycz9mQWLZAU+qHb//Sb +oNXS80f9/kQIUhazuffOAL9yUlDc/mb/hTJNH+QMEg3YYEzvOlxae/8EcEt3tCdN +YXR0IEVkbWFuIDxlZG1hbm1AdmlkYWxpYS1wcm9qZWN0Lm5ldD6IRgQQEQIABgUC +RPYdlwAKCRD+1tHA2nOeMzaLAJ9/W3hsXQubHVq+fra06fKMSw+/PACdEpHS0/e8 +BXr7JsHdGsX1HYAuPzKIRgQQEQIABgUCRjYHhgAKCRDIaBFUViTIXFI3AJ0etvbh +F5crJPCd7+l619CRUgs0nACeLu4Fzxq6QQoLkBIA0eEwaaDJ4lmIYAQTEQIAIAUC +RDnrFwIbAwYLCQgHAwIEFQIIAwQWAgMBAh4BAheAAAoJEK9+DkNfoUhhNLoAn05h +fSWwzZlcKDHyvOk4kIaWiFyeAKCktwPJ/UldOFHKBxvwvC8uSaGhtYhGBBARAgAG +BQJHe8EqAAoJENDPlj33wRJlRu4An0wd0gojlpl3pd8bJ+KZYoWYqoFIAJ90zp59 +ufESM8eYVg+F2mnOu2Tzs4hGBBARAgAGBQJKBXP8AAoJEE7+b1aRNb2dBxcAnjTE +A/uHFhOBc0V0VwjSHup4RhyeAJ4kUPh9nf+yA9Zp4yAoI1L4EUyoj4hGBBIRAgAG +BQJHgnCFAAoJEN56r26UwJx/+wYAoIIYduqXUmdgdIzFV1fDnKKmzK0fAKCamVUJ +yudqmHf81UO7S6cfOzldzohGBBIRAgAGBQJKAKJcAAoJEEVlvxDJOREPWLIAn2lf +BbNUYG+an5/e/b4QthaXf8QPAJ4tJVFymjfeBdsqmMh4unMBb3kxAokCHAQSAQIA +BgUCSxGHOAAKCRCZkx4l2R4BLNbZD/9EHQhiN7ts1HWYy3M+RG2gc06GInXwQ8U/ +DliMh36csO+QJ9Vbu4GH/i2huXymiIrcbAc5vcx2LI70AK8lcNKwYEo7P3LFTkhj +JQ797GrZskxqMORM9n1p/11JITVrlAJ2nXY2iTkyA/1VI1fZEXd/TknHPX/P6yoQ +n6j522zSAZf2rRwuudO/MYKLLg/a3SrEAzP4/8VNYxWkSxdfEVRgCeJkfnLEC+h3 +gMsxG3JT5mKbqtabvWxce8bcBJA1jWfsjIDRnFFMmJZty8AgjP1Pdfjwl7HY8HaN +k2iDr8ydG12e50t3/0w3EMKcl/wCUPYvhPb/CtR3aE8vheFSS52FSFmbUo+OFq4a +jrqz5BEQhx87dbnYuVtbBPriVY7Lxy1YDFoHm5nhinDBLru7bNVuQvsC68xSiBj/ +Zm5bnnKjYngWQIyRWt1D2VSG+8tqYKmYCZHNlR7O/BwAeE0f5Ht4hc5hRdRfSDSC +iaqbktsJ2ETIfqahoSrikq/VZun6XX0+YdnphujGYCHK9ipE1PVmkbLVabIjnHP2 +KCzjjPun8LCSPWZ6lp4PrakD/DZNhpCqokcBVRsjy9t3Hfmb0wwL0x5fNAPU0PKv +/07s7bhBLGAGF2SFG8E54G9OK1Y05jIwZkZ3YzECopMS46vag9H+6MhocnoL6FS4 +lGEgUgDjNrkEDQRDAo+YEBAAszeZ5VsPg+nZcUWJgxYgFEqIztQxL34MLkRFu4IB +qbnkY3k0TuBQPMw3JxR/+O13GwAhUDEPxOxSnJvX6yAkacewVUbVQpy0focarJBM +aSdAQg6cQh3rGuUhRpVIA91wtvaoz9WakNQIy2NuHTRhxKNTDGdBvofEsJA7hIzV +tPeblmpfxhjTZfx1aBPk74SiFjuTNY7AJyubzvKilsToEPt7CxuAecVsRDntj1Bv +mFsjuSRCfaYxmCm2RiLBNrwbSjcHYvl2XGXRhqzjLXbjUrHPyzgnnYaN97dkpVLU +5xG6Q4XjVQEWRU6aIgqJOCxa/RWah59Z3U8x5lYK6Duf7Q+KMB4LceaCLkL/AYaR +NqfDJyVTytxohBbYCps3DhX3LDKvg+XAH9IEqfHe5x0+LhiobLdV+hTBtrW73CRO +1x3wMNlHCbdZ35vMcEyfcdpRTPg8U/VHCdzn2Iy6R+A2TNkrMapWF1wrJ+vySRCX +XhITCBkv9eKriveps5a9J1I0jjlv4O5yXqTbZXXvK7jJdArRQsi+pdOxsoVyFCL5 +191HmX2rKAJAtoiVjzrSuVb20gNeDk04Zr0tQnjeeT7BxfOdMXcQFbaDxImd2g8u +3pQT26loEmL3Ske0PCtvYRTeK7ypBYc7L9BnwYIBBuQMSWmP5etpmUSaZr6QH+4q +KasAAwUP/RE5Ac1VjIp8CK4QGdagONOBvwFat9b9DNCbkvNeRkSeI2oJu47pA4AQ +SFtQyxKDIi4GUmw1JHVYOeA1KdmNWXCEI5NQfbEcPHD9pvblY2E2YWEIi9W33LOK +0KngmffM8CWkf3PcGCtzUMk0P0sBVFtNakNH6lyVVlCODLuo4tTlKa1MeLnw+jcd +NgYtK3DZIuryaVNP2qa1SsSyunps27Mli17pgNXvEzPzeT2yg6EQYhReK28URaNd +fPO1YsuLEmtd64/LxXT3VDA1q3spjkTv2z9LIqTgOd7sgDwkJWtUnDtfMDxc09yl +dIuVXN6iLozGySxi9R32RKyZQFl5i8r0V8TExyFTJttfQY8OGJL1zRumQ3/wUBMP +jWbnUD3pgxB/kcPlgvn3HpfWdOqmZ6Foz230ZKM6Bd9qXNgpiBZ4Sflo4IEf+/5b +i7Z1E9+3dN9A0g23/QqpSV0k+nIZxiPdMs9B9qoOYvUpOwrYljbwp3LKJgeXB2Gw +K2f/UxjFom78Aaen/zA7Pv9swpencW0vC5Z0HqMYQ12UGy3mt6y15k3lyRowfA0Q +QHy1IoIAC7ZkZj7QzEk5sPATxWhOxc09kAF7zLLhjOEX6FWADd5E7gJip5Qbw1fK +pbelQ2c6yeFKSPQQG041k8RNgbLTcJsZaB9ShFbMIgT0CgIAoaQTiEkEGBECAAkF +AkMCj5gCGwwACgkQr34OQ1+hSGHp5QCgqjZuxYl7xS+qDsAsuDye1sUW+wwAoN/E +HU+1ap6mRImtkjz7AIuUiJcOmQGhBD8WGugRBACSvUOFKhQV+i2WwCVpZgcgMrM4 +mDtM3wOh0UCRW0CgAHqYh4MeNcnF/PmtJ1KqVqrKgwPxl7dwPtTCO9iKJf3OOHqr +pDfVQUG5vqtAfCTYaGx3Nq/DJRwhTm4h6Ku9Fh4c3GAcP6ujzrBLCA+rVAMXztnO +sytUFPZZAVM2FXDLjwCgoxc5VHCggwXcnVAz9xnmygweYRUD90F4rKDG17FhSrvw +Zz6LNt+SFKCYRA0Oww/DRFlTcmDg54aV5ZwL2OsaMtU66t4m5q0myz7wIETepIpb +0qSrNKYDvVNo3+AG7JltxxlaWice196gqYcNAYdSvpQ2A4PzI/EeeeesRZ74I8HW +g8hBnDgwx68sGLiTClvPvCQYr9MD/1635a85oEEGCreQNGiXqj9r++K0LrPj6jRy +CUrK0Sg73Hlk7x7ncgrIyuG3OhpIFcPNs5JuWA0Pm+ca4DwVa9lJmdZx0Y9SJuFE ++E+VgPmUfHwOEkYjvYRbndKXY7hUgUjGW67lZhPXmNKCu/4ifgP45ZRwFmxln/r/ +aCrZfdaCtCFBbmRyZXcgTGV3bWFuIDxhbmRyZXdAbGV3bWFuLmNvbT6IRgQQEQIA +BgUCQpcplgAKCRA39h1cjIDDXx1gAJ0WNwOr+xUFslc/k1rHY6mTrLScqwCgzR/p +gkopP8R9E1ZzjN4HZUEC2HOIRgQQEQIABgUCQ+wUKgAKCRDrWolqKJiL9cScAKCF +uqn17iZEbZXKCMIXVZbkWQNYuACeO3CSrHYPtukpJqDVRq+Q6eq9TQyIRgQQEQIA +BgUCQ/AIHwAKCRAgTGEVDmBmmfH/AJ9FfD6aG9ztaLWsg0iohHXb3F9D/gCgnsiB +OCUNU27Q8sLY7oCScas+XgKIRgQQEQIABgUCROnG/QAKCRCmFJ0IgOXweVfrAJ9n +0vynXSsWBBpa3h50k3tXFKDYjACfdDZUBrPGMkHmnDAH5ulqNr8jKz+IRgQQEQIA +BgUCROnHAwAKCRCmFJ0IgOXweaQvAJ9fwO50sU24G52i1ZVRV+p/QvhHcwCeLdEN +zyIC4Vjs6Pva1h1io2nY+wyIRgQQEQIABgUCR91p2AAKCRC4hBqRnQ+s5B+tAJ4g +UrCBUkWxrMLeYFhv7pHnDj7M6ACgh3fLthFQgUrzqM18jQ5g8hQlndyIRgQQEQIA +BgUCR+T7dQAKCRC666LXRWytUVrVAJ9YpLkwnMqBQlSh76/qGfudsmxBmwCgjJhU +nZLwTsNXAdbp8WV5y9J1ggaIRgQQEQIABgUCSDjZjwAKCRCvfg5DX6FIYRsnAJ41 +iwsAv6bz4Ls43LyXZgWbfUn7AwCeKaBCGIoydKZvpY8gAYSqJuxuRSaIRgQQEQIA +BgUCSaCi0wAKCRBxUjiOE0tRPB1yAJ9KJjazVM34XDIX2W0K4qrESgk2nACg2lvO +w9M+PNKqjepedfNMREBFdEWIRgQQEQIABgUCSaCi0wAKCRBxUjiOE0tRPK6kAKCE +jK34yd3UQlS8x6me8raPdfSenwCgrunXCaIhBFnt9C6Kr/6atklFcLyIRgQQEQIA +BgUCScf6eQAKCRAJHBHSroYAtoT/AKCkCynXzUT+GIFkBO1mLOY5BgJUxQCgm59v +EVzoirATC3AJfhpLGZIVpp2IRgQQEQIABgUCSfUO5QAKCRAk0yv5qpXDSaT8AKCQ +xAK44oIeEMxD8uvN12foB4pPjgCfVqasoNhm7nvRe25sUcQMm5XwbbCIRgQREQIA +BgUCSKzw+AAKCRAJA5Z3Vhnjfd2BAJ9wx3Co0lISHJyueekRwuLe0AsY0QCdHQ6E +XUa7hnuU9fbBIlnAzbDoFe+IRgQSEQIABgUCSgCiRwAKCRBFZb8QyTkRD2NMAKCP +xBeoqdnMSF6LBiOg92CqhTNYdQCfZYdp0uFfvBKNA580U7Wc9MJMv2OIRgQSEQIA +BgUCSs+Q0QAKCRDeeq9ulMCcf8HuAKCCefA4EhEy4rfu+C9Vg5+LCM+61QCdG8D3 +U+SPc/lCURQTchz840iy5JWIXQQTEQIAHgUCQZcw3AIbAwYLCQgHAwIDFQIDAxYC +AQIeAQIXgAAKCRA7nQk/MbCXS88lAJ0Ya57Z6k1vwhrAFDwZUBULuBULoQCYoLcU +eEairmrPAzA4iPpYjqgq64hlBBMRAgAeBQJBlzDcAhsDBgsJCAcDAgMVAgMDFgIB +Ah4BAheAABIJEDudCT8xsJdLB2VHUEcAAQHPJQCdGGue2epNb8IawBQ8GVAVC7gV +C6EAmKC3FHhGoq5qzwMwOIj6WI6oKuuJARwEEAECAAYFAkgykJ4ACgkQBAGqIEbT +l/8UUQf/UCKIghnwytkKk0nPCUd6TCbkw+R3rNVy4LY5a2mFhxzBBfmeIGnpjUG4 +TgR6kyKBg2AltV5ItDuL6Q/I75nXR3sNPa5pZkcdWbHjjxgPVbButtfhwWb9T0sS +ZC6vLjz2Z70BF7vVCfQdXXNFhIehrAICd2g0WY/R+fNELpPgk2OXGGZN1AqsPd40 +azF2MXZ+3wCnSFuxcsvAu8VtFV1mGivO0M/uhHk8yAixiQC3+Bt2I3d1B6vCcwd6 +/NOam7J/wqKkyJzV+8GYIX9FM3JQXHLyVhKYYgx6CD1lN0p1gkQFJOoQkRiifSTT +LL/jWoLijD7vpf34XQm9x5ingr6eXYkCHAQSAQIABgUCSxGHXwAKCRCZkx4l2R4B +LP2JD/9SWepMQaSBIzIoOPV16CQ3OI1hHLKRuoZ/EBUQrAeA85WdMG//FyCw1rSw +tc39Y3rEst81Ka78bJB9jbX16AJSMQGZeD1SzzQGGqMUMO5+Qbhr7XzUqbIBZT0w +srzD+nBcjxV86JjJlqACChwdhnACOCMqiklD/tLQ0ax/RLjcSQpBshA5l/mS9q/6 +cQd0bV+rzoNisgbNpBsCelQOs4XpsFVWq4h7Y22MIAmO+yoKPGoNh4x8LwldNKC5 +8WldCZ3q8W2iftoIFBQofP1oJ3yYe4CL/uO3x0ZyitYthWtctXrgWmnKYfsGM6M8 +NWD84EMcnjjjHdzSv+Y8vBxHSP13W/lNCw37l4LP7PWpYTd+yk3Owgpuu/F9nVos +fkA0ZkhT9PR9L8A8ibpqOu9Z6+nUejSO9F8Nxw+RK+JG2Vob1impwBlUCS8kcHkS +XOXJ5j5Dr6ITouefGBxSbbLl382ED7HkFYS5R3vZN5P2/Uo6JOPMXqyXZX12/fLt +Fmwe6jzALg1OG6SZRk9YHcU3/KWsMdbtq8NAlAXcrfV0M8O0r90s8WPy19jtHEml +bXcTKgOcw0jeQy+t27XBS6A46BJzdxArqrzVpoIy0gx7ZipSwG3RV1rI8WXL/qIV +GrsME9H4Jp9QYXlIMolyj/2KdTGEYn+UA26pZM2pMjLnLWJ1zIkCHAQTAQIABgUC +SXg0hgAKCRA3SO0sRn98RT+ZEACKiLBKumZSCRWnQUpDD3J1f/PFmoWkHubQ01Oh +9JJg9njd+pq0XYWaqvnm2pKcDVBV2+lY3PJy8GQcI7I83BPqTSahVwL9EFfvkwCe +bvUK4UKYqlDGCjxI5GERtSt2SxsOOYANFpx2C+pltq+KuLi2YABuyP/fKyXJlcqm +fLpLRTYPcKbqtJj80Ri0HipNSsKQeFfXsVzFWzp8Z0yWISno4d78424eGdDu2ehV +hZaN5rs6Bouha3i3cY1BW5nEB29q3+6FO1NGgoaGC4+iICu8T6yxhA6mi2z4/Diw +XWLS3v3Ayh4MD4HCiRUO0CENfD7Jy54JPY1kUDPT2uRC3flHeJP8qAUNJUtFUI/e ++Q6k0SGJY+661ZL4t2UWhxV39/jdlmoD/0gR/foLhh+AjH2pd+Jd0C6+gmvabl1u +X6sC//Ma7HrTEOsTXlu9EGsyDD9IAhCZ2h0iLS6hGjiif8I/98i+43n9ZRFSq/Uu +tR6gDnnNHnFWGTClOqwGJnHgWwNW5FkLNzrvp0vqL82lkU3FqjFk3kaBCR/VJMct +5deH+SzaMRK1NwcvoxTgwqs9TMF9ZYt0PGUb+rlg9mwIVuwRm3YowiE2b70yqbuy +RWenJ6fMpu2lHOI0AY+YDc+noB+X3nTzwVYqQBk2aQUkip/3p6k6/KUvEbzWx1Kk +LDAwo4kCHAQTAQIABgUCSXg0hgAKCRA3SO0sRn98ReXND/9KMJGgRpzQImpX0c8I +vzNiWKiKyQ6QfgY+7xlJ+vzGBUbmhf8ReqYUMpdTf98LboTgd1QhtJkR17HLp8c+ +6HjHcCAXOH+H6WHCcSH1VxBDqKSZlhRwdQVL/hP5Vm+wD6FUy7cB2oUNHWY/tqzt +LERhnJm6d/+NiQIHvp+wotia4GrBbflLGi/h75kuj9DH8mdT7uOv0G3qEtgtWQMr +eJRqfHOvRlRlP3cD/rwQFXGL02wiJA05skmClpYp6v6WSxYmqgDnJUtluraDoKrB +rpO3+ckzFPeIlCYx0Ltgp5/Grhx9NZRWExLTIdRZ1aIiiVa+Q644pMl2bTjJjG8t +WyGRALXPudmcTnvkkioDWa+7RrBQxXfm/h0Xqx5wiiGUSPoRqyvBMMFfDwB+Yp/I +z0AaSeQyZdSag2c8OnFE3B0xxvYSvYNXRJGOoC1zXG95TkLEvDJ5BW6CJB7aAmkZ +U8MzCrN4LszcecYajFMr9UbzdkfeE0P+0RSg/oKWP2hFeqgSXr8DJq6iUPHIB8jg +tVUW7RSNgQauIX3fXqGpaNWmcQC8LkfvPsEbemsQb0bWz7qAuviIf9q652nI/Qjn +oWqSFccltMnPjcBLR2mDpcBm8C3DJTaiE1BhRpLdbGP4sqsx++oEDSt94qY21rlV +wNccLKIJYeTsyGTBmUsfHvliGrQhQW5kcmV3IExld21hbiA8YXBsZXdtYW5Ab3Nl +bS5jb20+iEYEEBECAAYFAkAS2F8ACgkQwvMvQbaWZTgcPACeIvKAZmWnDua4YgGb +NaOnDJBDu/oAoPVTavrz6DzpvQMb9o+yvs17xNLriEYEEBECAAYFAkKXKZYACgkQ +N/YdXIyAw1/DzgCbB/f7wKoZuC3XuclYequ/5+J8/PkAoJtXh290iskeFByXhsgQ +pI0zPELciEYEEBECAAYFAkPsFCoACgkQ61qJaiiYi/XsVQCdE7I5GVp0VavMr9wb +jNtLf2NG6GMAmQELQdUhJKtS93u87rrafp0IxXxEiEYEEBECAAYFAkPwCB8ACgkQ +IExhFQ5gZplX8gCgkIj+hnFyc6B7xJyztU+OpTpIyMsAmwSgL2SzrH+nihh644GL +l7TW/C4xiEkEMBECAAkFAkRZf4ECHSAACgkQO50JPzGwl0vvTQCfeq9AH02kJ74c +jfx1jcl/sz1dEgIAnisnERXAADeLhkdQ+xQb11Lypm0OiFsEExECABsFAj8WGugG +CwkIBwMCAxUCAwMWAgECHgECF4AACgkQO50JPzGwl0tqOACfY0vGR9q1GFpSMTa+ +s7PjJt/WVU4AnAnY3qJjjTKqKCCuU2L2xbzlW4N1iGMEExECABsFAj8WGugGCwkI +BwMCAxUCAwMWAgECHgECF4AAEgkQO50JPzGwl0sHZUdQRwABAWo4AJ9jS8ZH2rUY +WlIxNr6zs+Mm39ZVTgCcCdjeomONMqooIK5TYvbFvOVbg3W0JUFuZHJldyBMZXdt +YW4gPGFuZHJld0B0b3Jwcm9qZWN0Lm9yZz6IRgQQEQIABgUCR91p2AAKCRC4hBqR +nQ+s5GoKAJ9QOiciHpc2kYC4pJjeQZMtp+sdeQCeIBQYnbPBX50XiMml44N5zrvK +wj6IRgQQEQIABgUCR+T7dQAKCRC666LXRWytURhZAJ49pQtaAZOA+VqK9Mx4nl4Q +wlG07ACfWy+I9hkBVhwAD/sbVzMhqk6EWDWIRgQQEQIABgUCSDjZjwAKCRCvfg5D +X6FIYXl5AKCFwuE7vVkp1c3ni28hDiYm9RNIEgCgnbk4Uq074kL87azZm2cEkUzX +3qaIRgQQEQIABgUCSaCi0wAKCRBxUjiOE0tRPNlQAKC1CaCpqYC9Y3aKf3MqvwYt +gHbwfgCgm0V4U8/pgO2xsO7HE5BKbfyNIkiIRgQQEQIABgUCScbxbAAKCRCoMpM/ +wC9TxcGrAKC6BhDkmNXYi55lac2+G1HYYsIWcwCgoG7PXNwy/1IMpVkdLY1WGFBh +MkOIRgQQEQIABgUCScfzBwAKCRDndeMk20Gzh63eAJ0UzRDbUbpj5CDRha0obKFE +AXtqPACfdE+GInGndfM2JeAaaSMj5UUkTiOIRgQQEQIABgUCScf6eQAKCRAJHBHS +roYAtvVyAJsFL5vNuMIk6pHIiST/0bmM1PNe3wCfXKNbtswwL9mP07xJI5V1IGPN +Vl+IRgQQEQIABgUCSfUO5QAKCRAk0yv5qpXDSU8pAJ9Cfo0Kqb+DbEgC2ATRa+9y +kDTKRQCfWygLH49sSSybfUULvUlr8lZ17SuIRgQREQIABgUCSKzw+AAKCRAJA5Z3 +VhnjfX2DAJ91He3p7kfooFYP/wDh0TYYaEFmdgCeIzUtA6GTJc8WdvmFdJVvJki8 +0uiIRgQSEQIABgUCSgCiRwAKCRBFZb8QyTkRD7+mAJ9orJ3td+PC/ms5cG73pHa0 +7Hft4ACgmvflyV9mEzchSOU15FRa3hs2zTyIRgQSEQIABgUCSs+Q0QAKCRDeeq9u +lMCcf0G6AKC2eVTk6UmX0nY+etiIecMHP0Nt7gCghq5C1dLwCqVTBvoCx8ashmgw +8auIYAQTEQIAIAUCRkku8QIbAwYLCQgHAwIEFQIIAwQWAgMBAh4BAheAAAoJEDud +CT8xsJdL1IwAmwXqFAoX73//N7PI3FUydjB1sFyKAJ9ytUKN8gXR77TKin2Rcl1S +z2bLiokBHAQQAQIABgUCSDKQngAKCRAEAaogRtOX/6myB/9SwG1zPkYFzwHsrnGv +GJE9XuESLEsXRaKzjI/PT4mybperKIaoLJ5q6DdChj7mkDv+JqAW/MwuKp8kshU7 +d42VqwjAKDUx+QUMJXDIITHsCzCCf23b9WcMtmk6eRQew+JHHjqU+Rz5Sjz/xHox +xXm2B1yI64APnok7fMXtu+80Pj0sxEF+fQc/VwnYXO5lJu3Xjmy7Ck6cUbL5D6v0 +dxCEyenuk+YDwdjIdZKqII1ma4COMpEzfAosb7Mqp4uNyWZPY2RUUd4TIjfu7Suv +Kud/7G732Vrt1UyNUSOvGisTJM5XiVnSM78LQhgi0GKY6m2rMVI/qSjRp23Uk02+ +ga7giQIcBBIBAgAGBQJLEYdfAAoJEJmTHiXZHgEsv0MP/R3OafCCw6raezng1clx +hHAH81rSEnEpgeJ4Bo221lW+LXZZDaOQ0CjKGjyDwTzxp19Z+ll0BMJHZbUNw0H7 +BbEHfLt40hCLcnYEcF54jzR9icfASMTMvnGGPuKqXubJD2I2jtAiWJJypX0oX5Xy +CHpYWKv2AQWMVOle/aPDKWSIz/CnFb9gi+12olJOMG9KpYuH3djI7jyPZn+NMMmP +Dm1b520N/Eq2yOYZI92AF/LTyLPxTptj/2Wv4Z/D8mKtgKvSKtfS2i5O4Kys5nrf +s97plMkI9r1m2BzYGuLH49Vmf7v6M7r5kWC8RzhPUh19qbxdioaXWw5MdxSUX5w0 +fh9AWsEDOxA0DWFXYwDlJ3hBYj5y4ZwVEDavfCiTEuEc8oIryZKhv5pSG9KF73sj +CrXE2tOnfFmFiUa1wtlPvnyPWmLq2CFMnkkw0ICov38+xZHTtS+xx3y3sS/F0KBf +WRkqkOvfEKEUUTyURWShDIHPIXUCD0enjI1S+PJW9c4MToc2xU4XBhQcmvPtYZHs +ylSuUvGCHuePjaMBQwCVvoRGqEJP8EYmnnWefG6NGu/f5rccLYMU7w+N41HzoAKg +NMDxIxzqC/GThpxZpnYuecAuIP8Yjh127nE/8aXUB70lNsNMspabMVCdQLcLoyqW +iSthBbCqlKgMyQ7uLy02CpbjiQIcBBMBAgAGBQJJeDSGAAoJEDdI7SxGf3xFSxcP +/2MnOrokSpegiRRohgubHJ99HBsS0t6wgxKVzUJJcWUYdXzJxOnuL677SdXVRzXq +hUCXPdtrqX3Dvu3Qq88uiBm6EjbSl8XgmLdqj2mGJq199lkH69+jMe8Yv11F/Fyh +4rUJZWj3AhrG6OgRxlQ4w00rV9sm5sl+0aw4f1/MQVMv9ayn69tUolEIidE1/8mX +ehGxzqi35wDghUbtI0s4ylvN49PIBV8aQWExzs/1dScZCKRMU7iCyn4BAKln4XiS +EFROdPCFRBdWCLESfUdKsx/6SYRaZDPH2g7oXlGh0v2iInEts+T9gV+8qeHJjmRC +X99EqmKYf2yepPNegN95PMsogK/FLlYkLf8/HGn04GiTrpsFUsYcnrsBjJM6ginM +U5Urdkb9djY/QfpJqj2/NRV+VfEcuzuRRpjsSpX7HUK4W/ZT4r2WtL4wPXgpZk2g +Z212VZj5Lx8qA8WqFNKAAJ85RRu/PX2t8Hn8dfvUPUbh7EfjwQ9KmNnroyTiSDzO +JhLFDrL/LBP3aBII3Mi7GMhxjnW7r6XAjmMeKG8oxqZEcyX3zv/JYupOM6H8W0Dg +3VGSxb4VhaGlQUk+2K8gdzrZ1RfTNH8BbhOeKZCfpUCNSKjwgrIxh0egrPUJJwP1 +UCyHF7nhn2uMzJ+nopSL4g3AEeJ0q28Xal6ahHDFzUX2tCpBbmRyZXcgTGV3bWFu +IChwaG9ib3MpIDxwaG9ib3NAcm9vdG1lLm9yZz6IRgQQEQIABgUCQpcplAAKCRA3 +9h1cjIDDXwWUAJ0U3g4IZSCjFphyX/fTmTmaNsu6YACg3L74xQv7ztojuPyax0Le +QT2L2dqIRgQQEQIABgUCQ+wUJQAKCRDrWolqKJiL9UJ1AKCyMQfjJ/knchXtSkTT +pSEboa7OegCg4IYVflORoDFE8ElwGDeINfkDC1SIRgQQEQIABgUCQ/AIHQAKCRAg +TGEVDmBmmTKoAKDyrymskLWpsWB5WwDPoMYWaRcVSACdEgQsDI7eMrDjJj7ys6me +04+5rwCIRgQQEQIABgUCROnG/QAKCRCmFJ0IgOXweVfrAJ9n0vynXSsWBBpa3h50 +k3tXFKDYjACfdDZUBrPGMkHmnDAH5ulqNr8jKz+IRgQQEQIABgUCR91p0gAKCRC4 +hBqRnQ+s5AbFAJ9dmYX2dSWNJndTbIh4q6cp5HoDfACfSDSofkD9LB6S9qe0OcSw +26iEgSOIRgQQEQIABgUCR+T7cgAKCRC666LXRWytURmNAKCCrIH72IwknR/wLP7P +WQFd3k+dVACgj2poz2UpaGA5O0ie7TM5hk6gfieIRgQQEQIABgUCSDjZjwAKCRCv +fg5DX6FIYRJ1AJ9q3mcFUcidoYX0qmu2zc1W8rvKRgCfcLjXT3VCNXTVsQMBM/Kc +OaQZ4uuIRgQQEQIABgUCSaCi0wAKCRBxUjiOE0tRPK6kAKCEjK34yd3UQlS8x6me +8raPdfSenwCgrunXCaIhBFnt9C6Kr/6atklFcLyIRgQQEQIABgUCScbxbAAKCRCo +MpM/wC9TxRiYAKCYmarbF2oa8UHH0+ZLdb5de2FnRwCcC73UQC4leyc+uWQPCnUE +BAEP41KIRgQQEQIABgUCScf6eQAKCRAJHBHSroYAtux4AJ0U9J8rpOyajq/k+YAN +SNOTLVD0OgCghW1xUnWj2tFxb0w44vPmOSQSXg+IRgQQEQIABgUCSfUO5AAKCRAk +0yv5qpXDSSLNAKCqoLj2ppb2dpXd8yEAP1kYdFMDBQCfX4WbDYpphJzKmg2uImhr +aJ7IFyiIRgQREQIABgUCSKzw+AAKCRAJA5Z3VhnjfWV2AJ49KCgP9Q9C/9/HxiZa +HlKR9/qb4wCdF5YKFnN5Oj5E8JSMR6wbbtimXJOIRgQSEQIABgUCSgCiRwAKCRBF +Zb8QyTkRD2YpAJsGfN8EcDGo3Pm7pvQOjoU8kqG3CACfR4trJuk15Ev9lCkhmBFB +BEDPQ3mIRgQSEQIABgUCSs+Q0QAKCRDeeq9ulMCcf/6NAKDeJ76kbDzPAxWqGb2x +ozfB8OFGJgCeMqPlMakdpkG0bT2d7fAzkyFKjGWIXgQTEQIAHgUCQpPBmwIbAwYL +CQgHAwIDFQIDAxYCAQIeAQIXgAAKCRA7nQk/MbCXS4sQAJ9zrNGx0kooCrlsSrF4 +/CsrRr+9xQCeOKko4dtrKgVOvH+jS0+aXyBwcvCIYQQTEQIAIQIbAwYLCQgHAwID +FQIDAxYCAQIeAQIXgAUCRf4OtgIZAQAKCRA7nQk/MbCXS0T6AJ9MyBM7qfldS6Z7 +H2GUQicVdiOl7ACeMQSxrBh/wPULIA5QdwoP/EJ5AdGJARwEEAECAAYFAkgykJ4A +CgkQBAGqIEbTl//uTAgAvpuFxz6K3ufyxRruXsy9qndzUxBuasUaKQOwKdHbuvGh +J+58joQd8poNpYSSSJjJDXt1KxgTWeDLw4IKJnSB0nfZD2i3rhpm4Ekl8piFxFn6 +XCodhGZanGfi+j8LAn3iKdJmABceklgtMlzqQKKkfMtMOp4Un41+7nQ6MhU8X2Be ++pdaLVBKT84IAqA/WTLYRxToHJJX/4fUCFUcgTql7StWb/n7iArhIgMi6GpsF1jN +TTy0E6+x/zbByXpbkw/Q9toOX3W0yukOybxs4jZkSCWefuJYgBYWfdp+METFB4mD +knzqZKLg1vOWqtbSRP3RpNkTf8O0AAlSHrpKxPvgAokCHAQSAQIABgUCSxGHXwAK +CRCZkx4l2R4BLCYdD/4+/UVChR2gYhiRHU2tHHW3hw0xJZPL1DU1L2JPl0KdudOi +GMdsyrrN+FGzI9y93jalcAGO7uoMweDKStQwg1zFT+mN3c7qqdpse3SEYqPgzgQZ +R9sZT2JAklAvCHhrIhA9powWBON/2K9aED8lYnqtY3gK1OzzgkfzALfdyBTHsLBg +89os9Q/7eWsowx+P4EgRjSKvUPgeN9POnYWZb7cINhGBQBEJKd5j7aZ5P6r0WcgS +Cu5Li0JJzbqpm2DnIsbQXk8aRkkbQdzpNUDh/RWRizOMXoRMVqupzycqDmiuSCfR +LJ/n6/Q/tUfaJ9LXRP4reI9r1zOkmj4gBHFNYyVL+HKngIBrVydPLu8kiue02W1X +gSHUvT//doLsroPRCaPWmsd0DxVDJDbOLzk06W6D2ia/EaUDHwWt2d8XZM2RiBJP +i+t/mmo/cHiYDrddf+hpleSWwfHmPh/L18flepFr+qYxRIpWQxEBj7YbtCAcwCdj +EPrQbIdJIPmMOS5Alf+hi5CUfLfuyqwXFWVhKHQn6CKOVIgEF+h2b9KEy170ZO0J +WfjCkFHqSZFEEQvNXncyDMlVDv9RqfAzpw1Rt1OyKhtOh2i+fWMEzMSzidvs+1Y7 +v9n8km0a6QUwdM5GCV7ld/goBtiHz30kCWqHeXYduFv1Ze98ZzVvDwsg6XVxTokC +HAQTAQIABgUCSXg0hgAKCRA3SO0sRn98ReXND/9KMJGgRpzQImpX0c8IvzNiWKiK +yQ6QfgY+7xlJ+vzGBUbmhf8ReqYUMpdTf98LboTgd1QhtJkR17HLp8c+6HjHcCAX +OH+H6WHCcSH1VxBDqKSZlhRwdQVL/hP5Vm+wD6FUy7cB2oUNHWY/tqztLERhnJm6 +d/+NiQIHvp+wotia4GrBbflLGi/h75kuj9DH8mdT7uOv0G3qEtgtWQMreJRqfHOv +RlRlP3cD/rwQFXGL02wiJA05skmClpYp6v6WSxYmqgDnJUtluraDoKrBrpO3+ckz +FPeIlCYx0Ltgp5/Grhx9NZRWExLTIdRZ1aIiiVa+Q644pMl2bTjJjG8tWyGRALXP +udmcTnvkkioDWa+7RrBQxXfm/h0Xqx5wiiGUSPoRqyvBMMFfDwB+Yp/Iz0AaSeQy +ZdSag2c8OnFE3B0xxvYSvYNXRJGOoC1zXG95TkLEvDJ5BW6CJB7aAmkZU8MzCrN4 +LszcecYajFMr9UbzdkfeE0P+0RSg/oKWP2hFeqgSXr8DJq6iUPHIB8jgtVUW7RSN +gQauIX3fXqGpaNWmcQC8LkfvPsEbemsQb0bWz7qAuviIf9q652nI/QjnoWqSFccl +tMnPjcBLR2mDpcBm8C3DJTaiE1BhRpLdbGP4sqsx++oEDSt94qY21rlVwNccLKIJ +YeTsyGTBmUsfHvliGrQqQW5kcmV3IExld21hbiAocjAwdGluKSA8ZGVpbW9zQHJv +b3RtZS5vcmc+iEYEEBECAAYFAkKWQHUACgkQCGFIj4FV5PNBCACfTD4yyr7j9C7h +pCDL/GqCPDoguoIAn2CqIdPXW/aYWE+MvLaFC4A0pMIZiEYEEBECAAYFAkKXKZYA +CgkQN/YdXIyAw19OEwCfelsC+XqipLeY5OQN5MQQ6c6TT9cAoLkvGeFOG/IoomVX +9L9PkHHl9/36iEYEEBECAAYFAkPsFCoACgkQ61qJaiiYi/UIFQCff0PxaCR2PKO7 +EXQG/C6w6BvkM20Anitdt7z2dvA/ncB6I9BOu6vrKJ4PiEYEEBECAAYFAkPwCB8A +CgkQIExhFQ5gZpnjxgCff07aKmc/HwODr/PAmoRGo4Fm7OQAnA9to/L9LjcH+w5e +5d4JnZypvB/xiEYEEBECAAYFAkTpxwMACgkQphSdCIDl8Hmq7gCeNk7PichJI3n4 +yDNajaTk71dC2NwAmQE4pISFvakxUxdzp3hmopZHOQIyiEkEMBECAAkFAkbgp9IC +HQAACgkQO50JPzGwl0uybACeM5XgY1MMc2nl9CA+UWdEUSUdqDAAnRvzG/a9nUo6 +icFJe/VRibeumqf4iF4EExECAB4FAkKTwXECGwMGCwkIBwMCAxUCAwMWAgECHgEC +F4AACgkQO50JPzGwl0s5KACeIJB0WEj+msveBsmzJwjk+ni+ehAAoI0B2TdtvQLe +CeYceQUKZ7uEJ1VRtDFBbmRyZXcgTGV3bWFuIChGcmVlIEhhdmVuKSA8cGhvYm9z +QGZyZWVoYXZlbi5uZXQ+iEgEMBECAAkFAkbgp+oCHQAACgkQO50JPzGwl0suUQCY +55ZyoqkpbuoFgQr68Xw/F8XYzwCgoiMd4Jzomne4XI+gBI68+zlrfHmIXgQTEQIA +HgUCReuDowIbAwYLCQgHAwIDFQIDAxYCAQIeAQIXgAAKCRA7nQk/MbCXSztpAJ99 +EeO2ZFWWdkksQeSYU4D+mu73JACfSa1pqxUq9HiQGl3CriYbiYINozG0N0FuZHJl +dyBMZXdtYW4gKFNpbXBsZSBFbmQgVXNlciBMaW51eCkgPHBob2Jvc0BzZXVsLm9y +Zz6ISQQwEQIACQUCRuCn2AIdAAAKCRA7nQk/MbCXS4qgAKCU79Lk4VGApcrNXrrx +NugH92hPlgCghn0G00B8BHpn78M3heBxZRRRtzGIXgQTEQIAHgUCReuDdAIbAwYL +CQgHAwIDFQIDAxYCAQIeAQIXgAAKCRA7nQk/MbCXSxl0AJ4r9Sy8WfoID2h87na9 +jVCP76258ACfdNNKKuOFFeg0BGo4km+es559+t60OEFuZHJldyBMZXdtYW4gKFRl +Y2hUYXJnZXQsIEluYy4pIDxhbmRyZXdAdGVjaHRhcmdldC5jb20+iEYEEBECAAYF +AkKXKZYACgkQN/YdXIyAw1+BhQCeJ82/9YGvUbDURpUW+I9/59AL6lMAoJ/5JKNn ++ODcF9K078yZmNZFICmKiEYEEBECAAYFAkPsFCoACgkQ61qJaiiYi/X1LACgmP2y +3vSvMC8mF8uPIVR26WYo5ioAoLjRwRAn/NlPjjjGS3jw964sE0N2iEYEEBECAAYF +AkPwCB8ACgkQIExhFQ5gZpn5SACcDs9aXVYUDzVDmQ3SmnM13sH/aZEAnApsYkli +t2lhHo8CcgG0yxtkLwYoiEYEEBECAAYFAkTpxwMACgkQphSdCIDl8HkH6gCfX9NJ +8khL/DCGjACiKj5EuQHs4SYAn38zpeoQP0V7XsEgr0y4AlIZBjmgiEYEEBECAAYF +AkfdadgACgkQuIQakZ0PrOTiJwCbB6Xd4a4RCpQBjKz9plH6x7narmQAniyNcuQn +7/L7bGr0pcX93DVbXacziEYEEBECAAYFAkg42Y8ACgkQr34OQ1+hSGE/tACcC/NK +mmeiaRwNkSK9RMZpCoQuk8YAn3Q9Dox1yup4zdkJjn2NJB6ePnoziEYEEBECAAYF +AkmgotMACgkQcVI4jhNLUTyUcACfU3GqmDsAmE6lH2D0IYB1nQiiULEAnR8YbGKc +xrtMCo67fc1HJOuWWBa+iEYEERECAAYFAkis8PgACgkQCQOWd1YZ432DRQCfaD1s +5UVNuDmFZOvyrIj+dFSnO1YAnRS1WNq+ZJTwvubjMgE2FA1aWWe+iEYEEhECAAYF +AkoAokcACgkQRWW/EMk5EQ+mdQCcCNKttjypWOKvqm6A3MwsxMGMyr0AnAiBb3Tq +sc3So4NAjhYL9XVMpuFkiEkEMBECAAkFAkoGRUsCHSAACgkQO50JPzGwl0uPYQCd +HQRZgrnQLzaiulxylSrHfmf3QdIAniWESyFRIEWH0h0gyQOhn9GORJmTiF4EExEC +AB4FAkGXMT4CGwMGCwkIBwMCAxUCAwMWAgECHgECF4AACgkQO50JPzGwl0t0NACg +nk1vL81DTaoik5deccOCHw9fkrgAn0ahJPD1hqyhmT8Xt6aXCJu7+uosiGYEExEC +AB4FAkGXMT4CGwMGCwkIBwMCAxUCAwMWAgECHgECF4AAEgkQO50JPzGwl0sHZUdQ +RwABAXQ0AKCeTW8vzUNNqiKTl15xw4IfD1+SuACfRqEk8PWGrKGZPxe3ppcIm7v6 +6iyJARwEEAECAAYFAkgykJ4ACgkQBAGqIEbTl//eVAf9GpMt18bMoE30REB24rhp +0ZGRlGELsAwf2v1l7PPx7xB8qh96MEOcTAh+Rn8XrBE82TdEUJ9lB0mLjduOoNM0 +MGxco4YVavkwUhDzJ19rMqjZLJsTndVcgXbNxhm05SDG7g2FEduqVxHIwiavYUBH +pIg6cuUvih5GB2xlnSMg5kufCiprL+a0jgd8vpGwZWBMnltqTZlHorJlqWHldWV0 +nqNQxCOYRcEJMbEgMctD5Vn2iDCnhriGHxIhaRzaBoJWV9O5ab3FeHlY3FP91hpG +lhW9TRFBBRdzV9rE2tCSatR16t0Lhev3F1yxCw1/3Khy5YGjd3EpTdAtWblJ3pDq +kYkCHAQTAQIABgUCSXg0hgAKCRA3SO0sRn98RYYRD/9xxFOMwrszxZ34ryUEEVCW +srSgSn8A5SLPV611wweKUEtNsziy1op3nG2sQRY8xePPM3F16XB9Tg/9M29LJGyO +EJo7E5Wsu2M+7/I2oQLzYhnMe+CLC8jPivvozAZkCWJosqCn+/edQf7Scg4ZDgXb +M5cB71iUte8vCsPCTaIxGDgjwY3ITM485PEm0Yx953bsWsovqwdjkFqaBy31p9gq +O51tIDxZwOmlVdv0hlB2IHWXEvDupYev/XKWr5VpjdAg8obiMawoPg5pZ5W7L6PY +w1Jsex6+nNmVQ1GCf1YjXaQD5xWTgZ3w63XBpe/ZODA0okPGf4yGcr5/sU/XXmBv +5sFIpOTsscqkMM4Z4uU5cbwcWNxzxRJUUpshgPp9MartLH0z3yEnByCvVUEcd9+x +UM6I22MnJW4iMP4PpaAl8wQjMsAUVplunkgleFpirQR1nhsY11OucJwfGrzeSr/v +mdrGBAYP8Jr3onVvu2iesBv9wgw5ZMPitOFpI697eeYK5J8kzfJjPZp7zqclPCSs +XRDGa/i/z0OG0n0PFkpJX+zAPi5+AMqgDAtXoLksfEAOK3S7wYoIDJxObGcKy6h6 +gixuMoPUE33o2Rnl5j8usOF7MK2+5ogfee7oPQWxCIPU50ZsfF3ztumHYq3+MeLO +w+brHY+a64a8V+Tlk2kQ3bQ5QW5kcmV3IExld21hbiAoVGVjaFRhcmdldCwgSW5j +LikgPGFsZXdtYW5AdGVjaHRhcmdldC5jb20+iEYEEBECAAYFAkKXKZYACgkQN/Yd +XIyAw18nVgCgsDrPTzjicf+RxvDW3Iy6NBCNigAAn3f9cHdTIveTIAThRs6Wodlr +leEviEYEEBECAAYFAkPsFCoACgkQ61qJaiiYi/XanQCgkIoDEnsEdPqEYL6kAuDA +nHfdzFYAoM5oNpTz/5Sar//KKq9WwUds2uYdiEYEEBECAAYFAkPwCB8ACgkQIExh +FQ5gZpk84ACg3q/QFRYsOOlMpEH82ED4L5sVq2wAoLLWlJ2MO54VTa4JF8/0M4xu +XyRRiEYEEBECAAYFAkTpxwMACgkQphSdCIDl8HmcVwCfUViboYpXGc1/wePHB16E +VgGYfWIAnjK4lzmyVMkC8tyCynJY0WN77ZahiEYEEBECAAYFAkfdadgACgkQuIQa +kZ0PrOR5pgCdFk5k6iep+h7fMkxUGFnZV9rLgj8AnjbY9S42gU+sc3SXUu7srx5K +x6pyiEYEEBECAAYFAkg42Y8ACgkQr34OQ1+hSGEPbwCgheI9ypfRjRJbSJlS+EYi +4tY5EpUAn0TMOSAgKJ31cNydEP7ULGWRAKgUiEYEEBECAAYFAkmgotMACgkQcVI4 +jhNLUTy3awCghll2CUzV46C47seb6CrHc83z7NMAniSIlksmuyS/MLBP/t6jBZO6 +sg0HiEYEERECAAYFAkis8PgACgkQCQOWd1YZ432RwQCdEyvfNCipt36NwYHhbl7I +G+g5akgAn0u25Nud+U4ehaOBK6bQT0DUTokmiEYEEhECAAYFAkoAokcACgkQRWW/ +EMk5EQ8QtACfUXjRUI8JhqjKIAWJELExaLNGdQAAn0PGL31ShrCZtrtXZJ5SizW7 +w0IIiEkEMBECAAkFAkoGRRoCHSAACgkQO50JPzGwl0vsJQCfTHqg95Cr9B8PgasT +sjYGZ8jrMpsAnjZFEegXS78gLlssMj1Xe1/36O9riF4EExECAB4FAkGXMV0CGwMG +CwkIBwMCAxUCAwMWAgECHgECF4AACgkQO50JPzGwl0sIiACglWvrLWM3XTPVqqvh +K8n1Wh1g3CsAnjZu1tC7xRnbiIv5GYPkNwt/LGybiGYEExECAB4FAkGXMV0CGwMG +CwkIBwMCAxUCAwMWAgECHgECF4AAEgkQO50JPzGwl0sHZUdQRwABAQiIAKCVa+st +YzddM9Wqq+EryfVaHWDcKwCeNm7W0LvFGduIi/kZg+Q3C38sbJuJARwEEAECAAYF +AkgykJ4ACgkQBAGqIEbTl/9+SAf/VttUCjfmgRZlrE7xrc8Sg5tOnN86SIZwCfv0 +aD7b45pR92/Pgkz9MJzqpqQMBV+Sc2hIxEQE0a/waoH77HHQQTpSD7WItgm4JhiU +stfykO6flZoiUF6JaCU1VABSEykS+m1TuHfm83W+KsZqD9FIdYhpN+Se+W8t9aoU +eAKiSXiJbULsrwrmQGDcSyK3gbL2X5g2rbGat59SKLrWQHi/X47zH0oeLfHogrOV +XTi2L4zIVfBfVaxTkbZFgrYlI3MOwqdEM0CcZh/CYPda7mKdDopk5lUX9akpuTax +7p0xMw5LHruPSmQAPOVKFWjb8s/akpeKFSqqzRUFwUkP3qthYIkCHAQTAQIABgUC +SXg0hgAKCRA3SO0sRn98RWEGEACXR6BrWOmg4Rzv6uCFMJMrncby2RLTa0x1pTLw +R0O43NZBtUCIBlYqgzw6NiVSM8MSoC0a7iNuSlE1VK3khxkHo2ZyXmLSYBOy8Aq6 +EOEVGGUwEvk2B/Vsxm2JU65XnFa0GWvYBMfd16Am8B6JyY70+BK8ArSkkG+MaqPX +BNgAWTIeBttsFDe66DMibINs2PV7LIlW2tGqnpFzMaB1S5epzUlFrTfyw224Hg+c +LvDS7XRhrVpShw4HGipbM8TED9lZTzBgYfVBa+c4LcYQvJeku7wsFIl1iaXKsk9+ +uMs9nlS34K/mH8BAqyRkwqUmD/WtEzT30w++k65yZy1evLGfzwA2INGDsRzCmbmh +jc7I8TFDuQIjrxX9IV8HO1qcxtXpkpu0Hub5AbsFnf2c3DtwqoqahtA86jAkNdf9 +tFjhwRhRstzBr3J6M6+NVGkoKFHSLugsIOVItcoxKg0XU4wzmrJgWhLbSlB9mAym +22O8HI0aQ27efRzWnxQvR3XhiDfMwUytgzYKbCFBYYn3X0cl0/fmIO2F/iDib+dE +iwS+uauwq0kAfzdR1c0Gl8B03K3WFxAjga+lO2vD+NVFHT2WliSNDGelRBF3byBt +oBNuDol9RqomN5nuSmWRKjKeG4694cvSTEyb9M48bpO+oSGqPlpw9fUDcy7tk9io +/CP887Q8QW5kcmV3IExld21hbiAoTGV3bWFuIFJhY2luZywgTExDKSA8YW5kcmV3 +QGxld21hbnJhY2luZy5jb20+iEYEEBECAAYFAkKWQIEACgkQCGFIj4FV5PPitACd +GLAVaaW/VoWRDKa3CRLqOSYO5m0An3CUN60aS7Pud80QXcG9iGLXGhCriEYEEBEC +AAYFAkKXKZYACgkQN/YdXIyAw19V4ACgmkFtQx9UVW1IhE7CX78h//f58CcAoO57 +7anR5JkXfgi0UTB1I/mlndSIiEYEEBECAAYFAkPsFCoACgkQ61qJaiiYi/UcNgCe +NMDX3Q3yrTnrKSTMEqK0ZzT3WYsAnRa/YMGOaK02Sak2v49+5xBLwh2diEYEEBEC +AAYFAkPwCCAACgkQIExhFQ5gZpkNqwCgnQZZZ25rPkbi9Jda9pWtoOgscpIAni4B +YF6meG/9tPy4WP1fnuehZFoiiEYEEBECAAYFAkTpxwMACgkQphSdCIDl8HkVeQCc +CUcbH9ZVBO2W/2Q5q/7mSYhk3AsAn1GZUlTeLNx2UdwgfZ6WwjIPsXMAiEYEEBEC +AAYFAkfdadgACgkQuIQakZ0PrOQp2wCffhkUJ4bTzjMryUDg/E7fHHwToPMAnRl1 +CDG3U466bmCMsX/goq/hut7LiEYEEBECAAYFAkg42Y8ACgkQr34OQ1+hSGGQ/gCe +IMTHTAUacLTarRQvow+9g/wr9soAoKx6Pc8NaY7s/gBRsBGN2kUIes5CiEYEEREC +AAYFAkis8PgACgkQCQOWd1YZ43130QCfU/wULfJhVZPBj3xUD28+QBZeoOIAn0P4 +Zqk/KQrjWJeacta1/haF6A0QiEkEMBECAAkFAkkdBRQCHSAACgkQO50JPzGwl0vz +XgCfZEbht4Gg0MOph4TPrmltNKPQ/iAAnRFI3scvp5Uy5ntmyNdkCwt5tZaMiF4E +ExECAB4FAkGXMQcCGwMGCwkIBwMCAxUCAwMWAgECHgECF4AACgkQO50JPzGwl0tO +iwCfYy3O7Ala8j2hAhM6iVwF+tjubIIAn004jOdzOmijXZjFYNq8RzgL5bcWiGYE +ExECAB4FAkGXMQcCGwMGCwkIBwMCAxUCAwMWAgECHgECF4AAEgkQO50JPzGwl0sH +ZUdQRwABAU6LAJ9jLc7sCVryPaECEzqJXAX62O5sggCfTTiM53M6aKNdmMVg2rxH +OAvltxaJARwEEAECAAYFAkgykJ4ACgkQBAGqIEbTl/+56Af/UszIJVW2JMN5bmrK +in3f8A1WR1T17t22bUTk8Tk/xxUfBbdT9l2O8+dfnKRV5xezXs//LdkJbF2PdTme +QI7tGcaqYubOFhp9F1wppUemIeZaKkvd7T9ynQMFg12Wozpd4W105pHr2Q6k0P2s +vRpt+fki2rZDsqRDFTLM5Cv50EevPEn9TiNs9YVO3KI1HE7txvw6YWn0l3DvlcaT +YuhyCh95z+vF/52yRb60Ctd4ufMh+7bFKtK5cw7dCT0Ywd3+EEOMxGQmzzQTG1qj +AcClYngqgnFAUzYAAUy3hhn9rM9PWKKZzq+VUzIe+w2ffNIo6Zlw9F5CCa+bYj4Z +z+2YrLkEDQQ/Fhu3EBAAozhMHj0bqDWCMjr9CyCDWdUjPnMSm18N2TzCInEfn7+T +iMZ2h1Yk08chW3JCDHDKPv4uCSKITQris4f7lEIcckprsAR0Pp9v9kErye0aLqwe +h2croQ5RfCteu5Ai8X4IPgl3k1n1GdpJq+n5LJd4sy3oZAVrvnMXOS0i8uE7PVct +Dctljkrql/LpwLEVa1/rvL7ZzLpB3+/uFe3VnpK65P0wk05oiFpRjjDcZtzDwj4g +fQGd5/gAZS9JZXdyLF+leXq4+gfdDXa7j4Len+Z6S9d0mKYNp2wfBMm2U3CVlwnT +oZS11fdYUHdD8nw+rdxo5QDeulnDuniL4seeHn+XHCUQ4aBGA+5a2krlUiy/dZmZ +6jg/XVshswwbNpLVUIJT9XZtsTOGH2OCa1Xj5/9r/rLcVhH2eDI55XUB6S6sQ1LB +5yofhvomVZerbR+VnRiq31sxx03V3FCf4SF6ePycGQtf6lbXD8NUTxcTblHstnlg +7Geb99QTnvRExgaMaSSJVfAFwS0Qg30UWhjTJ5UyesMhuSu/7lzj6IRx3yp9+udw +8cJ2tZj6BXs6HX/wV9cO5cgmuNzRgtYfkXcOZEVBtBh6Mn4F0gwURLtqz8ms92Ga +h/MqOvrt/I3+WGi2zW+N6UrHhTT+sU5Ur/P9zY1m72MS5+/RVYp4rk7R0BPwgf8A +AwUP/3KKMQOwSpHAS8SdlOP1Veyj4q+N4Zn7RGMI3jsrPcCA+jhye5YGoMo6J32s +B8TTMcLHU0tlOmm3CV93iUtP/5JSz//xLw6f5s3utJXRrBeRRT3k3zPAJMmZPcKt ++oXkV9tcwxcz4H4S9EyCRAmLcIZX3ftsYpkU/MYnVey8AT5gZsbzggTl4PDDot0i +7ZJa1lAg8yqLuya3Z2/MI/MuOQk5j7fzuEyMQ4ebOwYEh5WQjYs5p1Do5HJvkiDS +i8duYJkbuGku/ee0YgUHQY6tmvA4ve7bBg66mv3792iL9ayMRMMXRfSBGdXB/Hca +EIaEKQiNLIwr4FupnKlWU3e8K+achK1rx27yStDoaTL0IqR/WxBtVXxx7FKtlNhm +g8crd/4FN6Asz47hpw/BbU4jPmdhBTCbMmhvDiNxujc9F5Dr/3mcbFmja5ORV/xW +gb05T7ltU4B/fXob55PnOT+SNmLnhzToO/WdZwMcVZ7Xw2iWXeEaKxAsLYWa8DQw +ZcvXl+GR6oAsAWjen6QgrzV/41ucCpDTRk0wAH9p9lJv4rRWp9DupjbFbWXTeWxo +0QScPVux0ZckYPMQZHnlz7/hZ02IwDf1NQhyrVLUbZPgIKovw27cjrzFFYgLLOiM +m5pFI1QPfSmTYbOS9NnpSDyjY+tyfxEtxWEvLAb3TXieuGpxiE4EGBECAAYFAj8W +G7cAEgkQO50JPzGwl0sHZUdQRwABAbCUAJ9tAhxIpawrn6hQ254cNEdWEIZt1gCf +bJKXjoJ3w3VRaafeHrCcgV9qNqA= +=zLr0 +-----END PGP PUBLIC KEY BLOCK----- diff -Nru vidalia-0.1.13/debian/vidalia.desktop vidalia-0.2.8/debian/vidalia.desktop --- vidalia-0.1.13/debian/vidalia.desktop 2010-04-25 23:24:29.000000000 +0100 +++ vidalia-0.2.8/debian/vidalia.desktop 2010-04-25 23:24:29.000000000 +0100 @@ -1,10 +1,8 @@ [Desktop Entry] -Version=1.0 +Type=Application +Exec=vidalia Name=Vidalia -GenericName=GUI controller for Tor Onion Routing Network -Comment=GUI controller for Tor Onion Routing Network -Exec=/usr/bin/vidalia +Icon=vidalia +GenericName=Tor GUI Terminal=false -Type=Application -Icon=/usr/share/pixmaps/vidalia.xpm -Categories=Network;Qt;Security; +Categories=Qt;Network; diff -Nru vidalia-0.1.13/debian/vidalia.install vidalia-0.2.8/debian/vidalia.install --- vidalia-0.1.13/debian/vidalia.install 2010-04-25 23:24:29.000000000 +0100 +++ vidalia-0.2.8/debian/vidalia.install 2010-04-25 23:24:29.000000000 +0100 @@ -1,2 +1,4 @@ debian/vidalia.xpm usr/share/pixmaps debian/vidalia.desktop usr/share/applications +debian/default.tor-on usr/share/vidalia +debian/default.tor-off usr/share/vidalia diff -Nru vidalia-0.1.13/doc/CMakeLists.txt vidalia-0.2.8/doc/CMakeLists.txt --- vidalia-0.1.13/doc/CMakeLists.txt 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/doc/CMakeLists.txt 2009-04-29 00:27:12.000000000 +0100 @@ -1,5 +1,5 @@ ## -## $Id: CMakeLists.txt 2362 2008-02-29 04:30:11Z edmanm $ +## $Id: CMakeLists.txt 3739 2009-04-28 23:27:12Z edmanm $ ## ## 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 @@ -15,8 +15,18 @@ ${CMAKE_CURRENT_SOURCE_DIR}/vidalia.1.in ${CMAKE_CURRENT_SOURCE_DIR}/vidalia.1 ) + +set(DOXYGEN_INPUT_DIR ${Vidalia_SOURCE_DIR}) +set(DOXYGEN_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}) configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in - ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile + ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile ) +include(FindDoxygen) +if (DOXYGEN_FOUND) + add_custom_target(doxygen + COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile + ) +endif(DOXYGEN_FOUND) + diff -Nru vidalia-0.1.13/doc/Doxyfile.in vidalia-0.2.8/doc/Doxyfile.in --- vidalia-0.1.13/doc/Doxyfile.in 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/doc/Doxyfile.in 2009-04-29 00:27:12.000000000 +0100 @@ -5,7 +5,7 @@ #--------------------------------------------------------------------------- PROJECT_NAME = Vidalia PROJECT_NUMBER = @VERSION@ -OUTPUT_DIRECTORY = ./ +OUTPUT_DIRECTORY = @DOXYGEN_OUTPUT_DIR@ CREATE_SUBDIRS = NO OUTPUT_LANGUAGE = English USE_WINDOWS_ENCODING = NO @@ -82,7 +82,7 @@ #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- -INPUT = ../src +INPUT = @DOXYGEN_INPUT_DIR@ FILE_PATTERNS = *.cpp \ *.h RECURSIVE = YES diff -Nru vidalia-0.1.13/doc/geoip-spec.txt vidalia-0.2.8/doc/geoip-spec.txt --- vidalia-0.1.13/doc/geoip-spec.txt 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/doc/geoip-spec.txt 2008-11-24 16:05:58.000000000 +0000 @@ -1,4 +1,4 @@ -$Id: geoip-spec.txt 2622 2008-05-29 00:31:29Z edmanm $ +$Id: geoip-spec.txt 3349 2008-11-24 16:05:58Z edmanm $ 0. Introduction. @@ -55,7 +55,7 @@ Geographic information is formatted in the body of an HTTP response as - IPAddress,City,State,Country,Latitutde,Longitude + IPAddress,City,State,Country,Latitude,Longitude Multiple IP addresses in a single GET request are separated by commas. For example: @@ -91,7 +91,7 @@ (e.g., "1.2.3.4,UNKNOWN"). If no IP addresses are provided in a request, geographic information - for the IP address of the requestor is returned. Vidalia currently + for the IP address of the requester is returned. Vidalia currently does not use this feature. We cache geographic information in an unsorted text file called diff -Nru vidalia-0.1.13/doc/status-events-ui.txt vidalia-0.2.8/doc/status-events-ui.txt --- vidalia-0.1.13/doc/status-events-ui.txt 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/doc/status-events-ui.txt 2009-02-25 00:14:32.000000000 +0000 @@ -0,0 +1,227 @@ + + Adding an Interface for Tor Status Events + + +1. Introduction & Motivation + +This document is intended to describe the addition of an interface to display +summaries of Tor status events in Vidalia. The status event interface is +intended to supplant the existing message log interface. The messages that +appear in the message log are often useful for developers helping users +determine why their Tor is not functioning as expected, but the messages +themselves are usually too confusing for average users. + +The goal of the status event interface is to provide two functions. First, it +should promptly notify users when their Tor process is not working properly +(e.g., unable to fetch any directory information). Currently, relevant error +messages from Tor are simply appended to the message log without any +indication to the user that there is something in the log they should look at. +Second, in the case of a warning or error status event, the status event +interface should help the user understand what the problem is and make +specific suggestions for the user to correct the problem. + + +2. Overview + +2.1. Main Interface + +The main Vidalia UI will be a single window with multiple tabs or toolbar +buttons at the top. The first tab will always be a "Home" tab. The Home tab +displays general information on Tor, such as whether or not Tor is running, +Tor version information (if Tor is running), whether Vidalia is also running a +proxy application (e.g., Polipo), and information on whether the user is +currently running a Tor relay. + +Below the general information is where the status event information will be +located. Status events will be added as a series of items to a QListBox. Each +item in the list box has a 48x48 icon indicating the type of status event. +Available types are STATUS_GENERAL, STATUS_CLIENT and STATUS_SERVER. If the +event has a WARN or ERR, a "badge" will be added to the lower-right corner of +the status event icon. WARN events will have a "yellow triangle with a black +exclamation point" badge. ERR events will have a "red circle with white X" +badge added to the status event icon. + +To the right of the icon (or to the left, if the current translation is a RTL +language), will be two to three lines of text. The first line will be in a +bold typeface and will contain a short, one sentence summary of the event. For +example, "Your Tor server is inaccessible" could be the summary sentence for +REACHABILITY_FAILED events. + +Below the summary line is up to two lines of descriptive text. In the event of +WARN or ERR status events, the descriptive text gives the user possible +suggestions as to what caused the status event and how they can fix it. If the +descriptive text does not fit in two lines, the part of the message that does +not fit will be replaced with an ellipses ("..."). Clicking on the status +event once will expand the QListBox item vertically allowing the item's full +descriptive text to be seen. Hovering over an item will also display the full +text in a tooltip. + +On the far right (or, again, far left in the case of RTL languages), will be a +clickable gray "X". Users can click on the "X" to remove the associated event +from the QListBox. Some events may be removed from the list automatically, +since they can be superseded by another event. As an example, consider an item +representing a REACHABILITY_FAILED status event indicating to the user that +their Tor relay is not reachable from outside their network. If Tor +subsequently emits a REACHABILITY_SUCCEEDED status event, the +REACHABILITY_FAILED event is no longer relevant or accurate and may be removed +from the list. In any case, the list of status events will automatically be +cleared each time Tor is restarted. + +The list of status events can also be filtered by the user in order to display +only WARN and/or ERR events. The filtering is accomplished via three clickable +QAction buttons near the status event list. Each button is labeled with the +same badge icon that is used to denote status event severity on the list +item's icon. + + +2.2. Tray Icon Notifications + +As mentioned earlier, currently important warning or error messages are simply +appended to the user's message log without any indication to the user that +they should go look at the log. Consequently, we will use badges on the tray +or dock icon to indicate to the user that there are status event messages they +should look at more closely. + +In the case of ERR or WARN status events, a message "balloon" or "bubble" may +also be displayed if the user's window manager permits it. While icon badges +are common on OS X dock icons, dock icons do not support message balloons. +Instead, we will make the dock icon bounce in order to get the user's +attention, which is a common notification mechanism on OS X. + + +3. Displayed Status Events + +Tor currently exposes many status events via its control interface. Like log +messages, however, not all of them are of interest to the user. In this +section, we describe the particular set of status events that will be handled +and displayed to the user in the status event summary interface. Note that +some status events, such as BOOTSTRAP and DANGEROUS_VERSION events are already +handled by Vidalia and displayed to the user via other means, such as a +progress bar or a message boxes, respectively. + + +3.1. DIR_ALL_UNREACHABLE + +Tor sends this events when it is unable to connect to any of the known +directory servers, likely because the user's local network is down. Vidalia +should suggest to the user that they verify their computer is connected to the +Internet. + + +3.3. ENOUGH_DIR_INFO + +This event indicates that Tor has enough directory information to begin +building circuits, but hasn't built one yet. This event can be superseded by a +subsequent CIRCUIT_ESTABLISHED event. + + +3.4. NOT_ENOUGH_DIR_INFO + +Tor sends this event when it believes it does not have sufficient directory +information to build circuits. + + +3.5. CIRCUIT_ESTABLISHED + +This event indicates that Tor has successfully retrieved enough directory +information and has constructed a circuit. No further user action needs to be +taken, but a status event message should still be added indicating to the user +that their Tor client is functioning properly. Additionally, Vidalia currently +changes its tray or dock to green when this event is received. + + +3.6. CHECKING_REACHABILITY + "ORADDRESS=IP:port" + "DIRADDRESS=IP:port" + +This status event will indicate to the user that Tor is checking to see if +their Tor relay is accessible from outside their network. No further action +needs to be taken unless a REACHABILITY_FAILED status event is subsequently +received. + + +3.7. REACHABILITY_FAILED + "ORADDRESS=IP:port" + "DIRADDRESS=IP:port" + +When Vidalia receives a REACHABILITY_FAILED status event, it will notify the +user and suggest ways to make their relay reachable by Tor clients. Most often +this means they have a NAT or firewall that needs the user's ORPort and +possibly DirPort opened. Vidalia could offer to use its UPnP functionality to +attempt to configure the user's network for them. + + +3.8. REACHABILITY_SUCCEEDED + "ORADDRESS=IP:port" + "DIRADDRESS=IP:port + +This event should indicate to the user that their relay was found to be +reachable. No further user action needs to be taken. + + +3.9. GOOD_SERVER_DESCRIPTOR and ACCEPTED_SERVER_DESCRIPTOR + "DIRAUTH=addr:port" +Tor will send these event after the user's Tor relay has successfully uploaded +its server descriptor to at least one of the directory authorities. This +typically means that the user's relay is functioning properly. No further user +action needs to be taken. + + +3.10. BAD_SERVER_DESCRIPTOR + "DIRAUTH=addr:port" + "REASON=string" + +When Vidalia receives this event, it should notify the user. The most likely +reason for this problem is the user's clock is not set correctly. The status +event text should suggest to the user that they should verify their system's +clock is accurate. + + +3.11. BUG + "REASON=STRING" + +Tor sends this status event when an internal check has indicated that there is +likely a Tor software bug. The descriptive text will suggest to the user how +and where to report the bug, as well as what information to include in the bug +report. It may also be useful to generate additional information +automatically, such as the user's operating system version, Tor software +version, etc. The user can then just copy-paste that information into the bug +report. + +It is possible that a bug can be triggered repeatedly, so Vidalia will make +sure that only one status event for a particular bug will be displayed. Bug +status events will be compared based on the string provided in the event's +REASON field. + + +3.12. CLOCK_SKEW + SKEW="+" / "-" SECONDS + MIN_SKEW="+" / "-" SECONDS. + SOURCE="DIRSERV:IP:Port" / "NETWORKSTATUS:IP:PORT" / "CONSENSUS" + +If the user's clock skew is high relative to the directory authorities, +Vidalia should notify the user and suggest that they check the accuracy of +their system clock. If the skew is low, then this event should be ignored and +no further action needs to be taken. + + +4. Unhandled Status Events + +The status events described in the previous section are a subset of the status +events Tor currently is capable of reporting. Further, it is quite likely that +Tor will add status events after a particular Vidalia version is released. +Since all status events follow a similar, well-defined interface, it is +possible for Vidalia to still parse these and display them to the user in some +generic format; however, this is not likely to be useful to the user. Recall +that the purpose of adding the status event interface is to be able to provide +specific and directed suggestions to users about how to fix a particular +problem that occurs with their Tor process. If Vidalia just blindly displays +some status events without adding any details on the problem or how to fix it, +the interface is not likely to be any more useful than the existing message +log interface. + +As a result, the default behavior should be for Vidalia to simply discard +status events that it does not recognize. We may want to consider adding a +"verbose" option that does display all status events for the user. It's not +clear that this would be benefical to the user, though. + diff -Nru vidalia-0.1.13/doc/TODO vidalia-0.2.8/doc/TODO --- vidalia-0.1.13/doc/TODO 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/doc/TODO 1970-01-01 01:00:00.000000000 +0100 @@ -1,108 +0,0 @@ -Things to complete for 0.1.x: - * There is a ticket about not being able to save config changes when an alternate - torrc is specified. Needs to be verified and fixed. (Ticket #159) - * We should close any logs that have 'stdout' or 'stderr' as the target after - we connect to Tor's control port, but pass command line arguments to Tor - to tell it to log to stdout and stderr initially, in case it dies before - we can connect to its control port. This way, if Vidalia freezes, Tor - won't freeze. - * Start using the DESCCHANGED event to find out when our own descriptor - changes, if the user is running a server. - - -Features planned for 0.1.x: - * Our GeoIP cache should recognize IP addresses on the same subnet. - (Ticket #154) - * Scheduled rate-limiting, so the user can adjust their bandwidth - limits depending on what time of day it is. - * An interface for letting the user send arbitrary signals to Tor. The phase - 1 GUI competition judges didn't like the idea, but our users and Roger - seem to like the idea. Oh what is a Vidalia developer to do? - * Provide an interface for configuring all torrc options. This might look - something like a table, populated via "getinfo config/names". (Ticket #76) - * A web-based interface for viewing the status of Tor from the user's - browser and possibly configuring Tor, too. (Ticket #42) - * We should support and use the ControlSocket option whenever possible. - * No sooner did we add support for 'getinfo addr-mappings' than did - 'getinfo addr-mappings' become deprecated. We should move to the shiny - new 'getinfo address-mappings' instead (cool kids don't abbreviate). - - -Packaging: - * Create a Vidalia package for Debian. - * The general consensus so far has been that Polipo is better/faster than - Privoxy, so we should start thinking about moving to Polipo. Ideally, - Vidalia will launch Polipo in the background just like it does Tor so - the user doesn't have to know that Polipo exists and Windows users don't - have another icon cluttering their tray. - * Building a Windows bundle installer is a bit of a pain initially, - since you have to create a bunch of specifically-named directories and - copy files from Vidalia's svn directory. Can we make this easier? For - example, maybe we could make a batch file that takes as arguments paths to - the Tor, Privoxy, and Vidalia installers, and then produces a completed - bundle installer. - - -Localization: - * Website and wiki. The website shouldn't be too hard since we only have a - couple pages, but it doesn't look like Trac lends itself to multiple languages - on the wiki too easily. - * OS X installer. Is there a standard way OS X handles installer - translations? I assume we'd mostly just need to translate our little - VidaliaBundleWelcome.rtf file and maybe a couple strings in the .plist - files, but how does the user choose which language they want to see? - * A web-based interface for helping translators submit translations of - individual strings would be super neat. - - -Miscellaneous Tasks: - * Google's breakpad looks like it may be handy for getting useful stack - traces more easily on Windows. We should give it a spin and see if it's - worth it. - * We should work much harder specifying what Vidalia does. When we add a - feature that interacts with Tor, we should specify exactly which control - commands we're sending, where in the UI the values come from, what we ask - Tor to populate certain widgets, etc. This has the added benefit of making - it easier for other non-developer type folks to write and maintain our help - docs. - * Work on improving the network map with better graphics, server pinpoints - that are more visible and clickable, and clickable circuits. Marble might - be a good start for some of that. - * When creating the Tor service on Windows, we either should be creating a - separate user to run the service as (instead of running it as Local - System), or we should write a patch for Tor to do it (Ticket #174). - * We should parse the Tor log messages we pipe from stdout and look for - errors or warnings, so we can give better error messages (e.g., "Hey, you - probably already have a Tor running without a control port open."). Suggested - by Karsten Loesing. - * Improve window transparency support. In particular, figure out how to do the - following correctly on X11 (from the Qt docs): - "This feature is available on Mac OS X, X11 platforms that support the Composite - extension, and Windows 2000 and later. - - Note that under X11 you need to have a composite manager running, and the X11 - specific _NET_WM_WINDOW_OPACITY atom needs to be supported by the window manager - you are using." - * Think about smarter ways to handle the GeoIP lookups. Our servers get - quite a bit of traffic from GeoIP lookups and it would be nice if we could - cut this back a bit. - * Rework src/control/ a bit so it is more modular and can be dropped into - any other Qt application that wants to talk to Tor. - * The 'Save' button in the config dialog should be grayed out until the user - actually changes some settings. - * We need to come up with a simple set of instructions for Windows users to - give us helpful information when their Vidalia crashes. The standard Windows - error messages are not useful, so we need to tell Windows folks how to get - a backtrace. This may also involve telling them to first download a - Vidalia binary with debugging symbols before reproducing their crash. - * If we get rid of Privoxy, it would be good to have a set of tray and dock - icons for Vidalia that show some sort of activity when the user is - actively using Tor. - - -Notes from Roger: - * It looks like we need to restart Vidalia to get a new language choice to - take effect. This means restarting my Tor, which will break my current - Tor activity. I know it's probably a hassle to make it change languages - without a restart, but it will make our foreign users a lot happier. - diff -Nru vidalia-0.1.13/HACKING vidalia-0.2.8/HACKING --- vidalia-0.1.13/HACKING 2009-05-25 21:48:32.000000000 +0100 +++ vidalia-0.2.8/HACKING 2009-06-10 00:41:54.000000000 +0100 @@ -1,4 +1,4 @@ -$Id: HACKING 2976 2008-08-16 20:42:03Z edmanm $ +$Id: HACKING 3828 2009-06-09 23:41:54Z edmanm $ Vidalia Coding and Repository Specification @@ -54,7 +54,7 @@ This directory contains code that implements the GUI components of Vidalia. Whenever possible and sane, each component should be placed in - an appropriately-named subdirectory of ./trunk/src/gui. + an appropriately-named subdirectory of ./trunk/src/vidalia. ./trunk/src/vidalia/res: @@ -84,16 +84,16 @@ 2.1.1. Source File Names - C++ classes should be divided in to a .h file, containing the - class declarations, and a .cpp file containg the class + C++ classes should be divided in to a .h file, containing the + class declarations, and a .cpp file containg the class implementation. Each .cpp file should implement only one public class. + Filenames containing a class should follow the same "CamelCase" + capitalization format as the class name itself. + + Source files that do not implement a C++ class should be named logically and + in all lowercase letters. For example, threading-related code would go in + thread.cpp and thread.h. - Source files that do not implement a C++ class should be named logically. - For example, threading code would go in thread.cpp and thread.h. - - Filenames should be all lower case to prevent potential cross-platform - compilation issues due to Windows being case insensitive as opposed to - nearly every OS being case sensitive. 2.1.2. Class Names @@ -109,21 +109,26 @@ { }; + + Doxygen-style comments should be used above each method declaration in + the class. + 2.1.3. Method Names Method names should begin with a lower case letter. If a method name is a combination of distinct words, each word should be capitalized. Methods - should have descriptions of their purpose in Doxygen tags. Example: + should have descriptions of their purpose. Example: - /** Description of what someMethod does. - * \param foo The number of foo. - * \return the return value of someMethod. - */ + /* Description of what someMethod does. */ int MyClass::someMethod(int foo) { } - + + Doxygen tags should be used for comments above the method definition + ONLY if the method's declaration in the class header file does not + already have a Doxygen-style comments. + Note that the method's return type is declared on a line by itself. Private member function should NOT have an underscore prepended to their name. @@ -193,12 +198,14 @@ ------------------------------------------------------------ QCheckBox chk chkEnableFoo QComboBox cmbo cmboNames + QDialogButtonBox - buttonBox QFrame frm frmMain QGroupBox grp grpAdvanced QLabel lbl lblHeader QLineEdit line lineAddress QListView lst lstMessages QProgressBar pbar pbarDownload + - progressBar QPushButton btn btnClose QRadioButton rdo rdoSomeOption QSpinBox spn spnDial @@ -268,8 +275,11 @@ 2.5. Parentheses + There should NOT be a space between an opening parenthesis and the + first argument, nor between the end of the last argument and a closing + parenthesis. - int value = someObject.someMethod(foo, bar, baz); + int value = someObject.someMethod(foo, bar, baz); 2.6. Method Arguments diff -Nru vidalia-0.1.13/INSTALL vidalia-0.2.8/INSTALL --- vidalia-0.1.13/INSTALL 2009-05-25 21:48:32.000000000 +0100 +++ vidalia-0.2.8/INSTALL 2009-12-22 21:28:48.000000000 +0000 @@ -1,12 +1,12 @@ - Instruction for Building and Installing Vidalia from Source + Instructions for Building and Installing Vidalia from Source Before building and running Vidalia, you will need to have the following packages installed: - * Qt >= 4.2 http://trolltech.com/downloads/opensource - * Tor >= 0.1.2.18 https://www.torproject.org/download.html + * Qt >= 4.3 http://qt.nokia.com/downloads + * Tor >= 0.2.0.34 https://www.torproject.org/download.html * CMake >= 2.4.0 http://www.cmake.org/HTML/Download.html @@ -67,6 +67,9 @@ mkdir build && cd build cmake -G "MinGW Makefiles" .. + There should be no spaces in the path to your build directory. Otherwise, + Vidalia will fail to build. + 3. Compile Vidalia by running: mingw32-make @@ -108,7 +111,7 @@ 3. Download the Qt/Windows open source edition source code and extract it to a directory with no spaces (e.g., C:\Qt\4.3.3). - http://trolltech.com/developer/downloads/qt/windows + http://qt.nokia.com/downloads/windows-cpp 4. Edit the Visual Studio 2005 command prompt environment variables to include the platform SDK files, by opening @@ -172,29 +175,57 @@ Available Configuration Options ------------------------------- - You can customize your Vidalia build by supplying arguments and values to the `cmake` commands above. Each of the configuration options can be specified on the command line and follows the format "-D := - -DUSE_QSSLSOCKET=0 Disable building Vidalia with SSL - support. + -DUSE_QSSLSOCKET=0 + + Disable building Vidalia with SSL support. + + -DUSE_MINIUPNPC=0 + + Disable UPnP support in Vidalia. + + -DOSX_FAT_BINARY=1 + + Build Vidalia as a Universal binary. - -DUSE_MINIUPNPC=0 Disable UPnP support in Vidalia. + -DOSX_TIGER_COMPAT=1 + + Build Vidalia compatible with OS X Tiger (10.4). - -DOSX_FAT_BINARY=1 Build Vidalia as a Universal binary. + -DOSX_FORCE_32BIT=1 - -DQT_QMAKE_EXECUTABLE=/path/to/qmake Specifies the location of Qt's - 'qmake' binary. + Forces a 32-bit build. This is useful on platforms that default to 64-bit + (e.g. Snow Leopard), but only have 32-bit versions of the Qt libraries + available. - -DOPENSSL_LIBRARY_DIR=/path/to/openssl Specifies the location of OpenSSL's - libraries. + -DQT_QMAKE_EXECUTABLE=/path/to/qmake + + Specifies the location of Qt's 'qmake' binary. - -DCMAKE_INSTALL_PREFIX=/usr/local Specifies the install prefix used - for `make install`. + -DOPENSSL_LIBRARY_DIR=/path/to/openssl + + Specifies the location of OpenSSL's libraries. + + -DCMAKE_INSTALL_PREFIX=/usr/local + + Specifies the install prefix used for `make install`. + + -DCMAKE_BUILD_TYPE= + + Available build types include: "release", "debug", "minsizerel" + + -DUSE_MARBLE=1 + + Replace the flat map with a 3-D sphere using the Marble libraries. + + -DWIX_BINARY_DIR=C:\Path\To\WiX\ + + Specifies the location of your WiX executables, such as candle.exe and + light.exe (optional, Windows-only). - -DCMAKE_BUILD_TYPE= Available build types include: - "release", "debug", "minsizerel" For example, to configure CMake to look for Qt in "/usr/local/Qt-4.3.2/bin", you would run: @@ -206,3 +237,33 @@ CMake also supports other generators besides Makefiles on certain platforms. See 'cmake --help' or 'man cmake' (on non-Windows platforms) for more information about supported generators and configuration options. + + +Additional Build Targets +------------------------- +Vidalia contains a number of additional CMake build targets to assist in +building code documentation and platform-specific packages. The targets are: + + 'dist' Creates a Vidalia source code tarball. + + 'dist-osx' Creates a Vidalia-only Mac OS X .dmg. + + 'dist-osx-bundle' Creates a Vidalia bundle .dmg. See + pkg/osx/build-bundle.txt for additional + information on the CMake options necessary to create + a proper OS X bundle. + + 'dist-osx-split-bundle' Creates a "split" Mac OS X bundle. See + pkg/osx/build-bundle.txt for additional + information on the CMake options necessary to create + a proper OS X bundle. + + 'dist-win32' Creates a Windows .msi package. You will also + need to define -DWIX_BINARY_DIR= + in order to use this build target. + + 'doxygen' Creates the Doxygen-generated code + documentation for Vidalia's source. You must + have Doxygen installed for this target to + function. + diff -Nru vidalia-0.1.13/LICENSE vidalia-0.2.8/LICENSE --- vidalia-0.1.13/LICENSE 2009-05-25 21:48:32.000000000 +0100 +++ vidalia-0.2.8/LICENSE 2009-06-23 23:53:29.000000000 +0100 @@ -87,6 +87,7 @@ Copyright (c) 2001-2004, Roger Dingledine Copyright (c) 2004-2007, Roger Dingledine, Nick Mathewson +Copyright (c) 2007-2009, The Tor Project, Inc. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -149,6 +150,36 @@ for use in the OpenSSL Toolkit (http://www.openssl.org/)" =============================================================================== +The function append_string() in Vidalia's src/vidalia/CrashReporter.cpp is +also derived from the strlcat() implementation by Todd C. Miller. It is +licensed under the following license: + + * Copyright (c) 1998 Todd C. Miller + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +=============================================================================== + Some of the help documentation text used in Vidalia is derived from the TorFAQ Wiki . It is licensed under the MIT license as follows: diff -Nru vidalia-0.1.13/pkg/CMakeLists.txt vidalia-0.2.8/pkg/CMakeLists.txt --- vidalia-0.1.13/pkg/CMakeLists.txt 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/pkg/CMakeLists.txt 2009-06-28 16:53:49.000000000 +0100 @@ -1,5 +1,5 @@ ## -## $Id: CMakeLists.txt 2877 2008-07-13 17:48:54Z edmanm $ +## $Id: CMakeLists.txt 3904 2009-06-28 15:53:49Z edmanm $ ## ## 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 @@ -25,3 +25,20 @@ ${CMAKE_CURRENT_BINARY_DIR}/package.sh COPYONLY ) + +set(basename "vidalia-${VERSION}") +set(tarname "${basename}.tar.gz") +add_custom_target(dist + COMMAND svn export + ${Vidalia_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/${basename} + COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_CURRENT_BINARY_DIR} + tar czf ${tarname} ${basename}/ + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_BINARY_DIR}/${tarname} ${Vidalia_BINARY_DIR} + COMMAND ${CMAKE_COMMAND} -E remove -f + ${CMAKE_CURRENT_BINARY_DIR}/${tarname} + COMMAND ${CMAKE_COMMAND} -E remove_directory + ${CMAKE_CURRENT_BINARY_DIR}/${basename} + COMMENT "Creating ${tarname}" +) + Binary files /tmp/KPMk4L7DHV/vidalia-0.1.13/pkg/osx/background.png and /tmp/EwwyCgG7oU/vidalia-0.2.8/pkg/osx/background.png differ diff -Nru vidalia-0.1.13/pkg/osx/build-bundle.txt vidalia-0.2.8/pkg/osx/build-bundle.txt --- vidalia-0.1.13/pkg/osx/build-bundle.txt 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/pkg/osx/build-bundle.txt 2010-02-17 04:49:11.000000000 +0000 @@ -1,11 +1,18 @@ - Building the Vidalia/Tor/Privoxy OS X Bundle + Building the Vidalia/Tor/Polipo OS X Bundle + +XCode +0. You need the most recent version of XCode, including the 10.4 SDK. +Download the latest XCode updates available from http://developer.apple.com and make sure +you're installing 10.4 support. Libevent 1. Download and extract the latest libevent source from http://www.monkey.org/~provos/libevent/ 2. Configure libevent with the following: - ./configure --enable-static --disable-shared +CFLAGS="-O -g -mmacosx-version-min=10.4 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386" \ +LDFLAGS="-Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk" \ +./configure --enable-static --disable-shared --disable-dependency-tracking CC="gcc-4.0" 3. Build and install libevent as follows: make && make install @@ -18,9 +25,12 @@ Qt -4. Download and extract the open source version of Qt 4.2 or higher from +4. Download and extract the open source version of Qt 4.3 or higher from Trolltech at the following address: - http://www.trolltech.com/developer/downloads/qt/mac + http://qt.nokia.com/downloads/mac-os-cpp + + Alternatively, download the open source Qt dmg and install. You can now skip 5 +and 6. 5. Configure Qt with the following (OS X 10.4 or later): export MACOSX_DEPLOYENT_TARGET=10.4 @@ -31,58 +41,60 @@ make && make install -Privoxy -7. Download the OS X Privoxy package from - http://prdownloads.sourceforge.net/ijbswa/privoxyosx_setup_3.0.3.zip?download - - Note the location in which you save this .zip file, because you will need - to specify it in Step 8. +Polipo +7. Download the OS X Polipo source from: +http://www.pps.jussieu.fr/~jch/software/files/polipo/. + +7a. Download the Tor modifications to Polipo from: +https://git.torproject.org/checkout/tor/master/contrib/polipo/. + +Alternatively, download a tarball with the Polipo source and Tor +modifications together from: +http://interloper.org/tmp/polipo/polipo-1.0.4.1-with-mods.tar.gz +8. Follow the directions to build polipo at + https://git.torproject.org/checkout/tor/master/contrib/polipo/README Tor -8. Download and extract the latest Tor source from +9. Download and extract the latest Tor source from https://www.torproject.org/download - Note the location in which you extract Tor's source, because you will need - to specify it in Step 8. - -9. Configure Tor with the following: - ./configure --prefix=/Library/Tor --bindir=/Library/Tor --sysconfdir=/Library + Note the location to which you extract Tor's source, because you will need + to specify it in Step 12. +10. Configure Tor with the following: +CFLAGS="-O -g -mmacosx-version-min=10.4 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386" \ +LDFLAGS="-Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk" \ +CONFDIR=/Applications/Vidalia.app \ +./configure --prefix=/Applications/Vidalia.app --bindir=/Applications/Vidalia.app \ +--sysconfdir=/Library --disable-dependency-tracking CC="gcc-4.0" -Vidalia -10. Configure Vidalia with the following: +11. Build Tor by running 'make'. You do NOT need to run 'make install' +afterwards. - export MACOSX_DEPLOYMENT_TARGET=10.4 - cmake -DOSX_FAT_BINARY=1 -DCMAKE_OSX_SYSROOT=/Developer/SDKs/MacOSX10.4u.sdk . - The Vidalia binary on OS X links to Qt statically, so you will need to have - your Qt installation configured appropriately. - -11. Run `make` to build Vidalia. +Vidalia +12. Configure Vidalia with the following: -12. Download the latest Torbutton and LICENSE file from https://torbutton.torproject.org/dev/. -Remember where you put this file. - - -Finish -12. From Vidalia's pkg/ directory in Vidalia's source, run the following: - ./package.sh osx-bundle - - Example: - ./package.sh osx-bundle ~/tor-0.2.0.11-alpha ~/privoxyosx_setup_3.0.3.zip - - The script that builds the .mpkg (pkg/osx/bundle/buildmpkg.sh) gets Tor's - version number from the directory name, so it should be named appropriately, - as in the example above. - -The resulting .dmg containg the .mpkg and necessary licenses will be placed in -the 'pkg' directory under Vidalia's source. - -NOTE: Steps 1-6 only need to be done once initially, unless you need to change the -packaged version of Libevent or Qt. Step 7 also only needs to be done once, -unless Privoxy ever gets updated. Steps 8-9 need to be repeated when the -bundled version of Tor changes. Steps 10-11 need to be repeated when the -bundled version of Vidalia changes. + export MACOSX_DEPLOYMENT_TARGET=10.4 + mkdir build && cd build + cmake -DOSX_TIGER_COMPAT=1 \ + -DQT_QMAKE_EXECUTABLE=/path/to/qmake \ + -DTOR_SOURCE_DIR= \ + -DPOLIPO_SOURCE_DIR= \ + -DTORBUTTON_XPI= .. + +13. Run `make dist-osx-bundle` to build Vidalia and package all of the +components (Vidalia, Tor, Polipo and Torbutton) into a single .dmg. The resulting +.dmg will be placed in the 'build' directory created in Step 11. + +14. (Optional) Run 'make dist-osx-split-bundle' if you would like to build +the split OS X bundle. + +NOTE: Steps 1-6 only need to be done once initially, unless you need to +change the packaged version of Libevent or Qt. Step 7 also only needs to +be done once, unless Polipo ever gets updated. Steps 9-11 need to be +repeated when the bundled version of Tor changes. Steps 12-13 need to be +repeated when the bundled version of Vidalia changes. diff -Nru vidalia-0.1.13/pkg/osx/builddmg.sh.in vidalia-0.2.8/pkg/osx/builddmg.sh.in --- vidalia-0.1.13/pkg/osx/builddmg.sh.in 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/pkg/osx/builddmg.sh.in 1970-01-01 01:00:00.000000000 +0100 @@ -1,78 +0,0 @@ -#!/bin/bash -# -# $Id: builddmg.sh.in 3021 2008-08-30 14:01:18Z phobos $ -# -# 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.vidalia-project.net/. No part of Vidalia, including this file, -# may be copied, modified, propagated, or distributed except according to the -# terms described in the LICENSE file. -# -############################################################################## - -# Make sure enough arguments were supplied -if [ "$#" -ne 2 ] -then - echo "Usage: $0 " - exit 1 -fi - -# Make sure the source directory exists -srcdir=$1 -if [ ! -d "$srcdir" ] -then - echo "Specified source directory doesn't exit: $srcdir" - exit 1 -fi -echo "Source Directory: $srcdir" - -# Determine OSX Version and map version to name -if [ -x /usr/bin/sw_vers ] -then - # This is poor, yet functional. We don't care about the 3rd number in - # the OS version - OSVER=`/usr/bin/sw_vers | grep ProductVersion | cut -f2 | cut -d"." -f1,2` - case "$OSVER" in - "10.6") ARCH="universal";; - "10.5") ARCH="universal";; - "10.4") ARCH="universal";; - "10.3") ARCH="ppc";; - "10.2") ARCH="ppc";; - "10.1") ARCH="ppc";; - "10.0") ARCH="ppc";; - *) ARCH="unknown";; - esac -else - ARCH="unknown" -fi - -# Set the location of the temporary files -BUILD_DIR=/tmp/vidalia-osx-$$ -# Set the Vidalia version -VERSION="@VERSION@" -# Set the name of the output .dmg file -DMG="vidalia-$VERSION-$ARCH.dmg" - -# Get the rest of the command-line arguments -filelist=$2 -echo "Files to copy: $filelist" -echo "Destination Disk Image: $DMG" -volname=`echo "$DMG" | sed -e "s/.*\///" | sed -e "s/.dmg//"` -echo "Volume Name: $volname" - -# Create the temporary directory -mkdir $BUILD_DIR || exit 1 - -# Copy over the specified files into the disk image -for file in $filelist -do - echo "Copying $srcdir/$file to $BUILD_DIR/$file" - cp -r "$srcdir/$file" "$BUILD_DIR/$file" -done - -# Create the disk image -hdiutil create -format UDZO -srcfolder "$BUILD_DIR" -volname "$volname" "$DMG" -rm -rf "$BUILD_DIR" - diff -Nru vidalia-0.1.13/pkg/osx/buildmpkg.sh.in vidalia-0.2.8/pkg/osx/buildmpkg.sh.in --- vidalia-0.1.13/pkg/osx/buildmpkg.sh.in 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/pkg/osx/buildmpkg.sh.in 1970-01-01 01:00:00.000000000 +0100 @@ -1,277 +0,0 @@ -#!/bin/sh -# $Id: buildmpkg.sh.in 3021 2008-08-30 14:01:18Z phobos $ -# -# 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.vidalia-project.net/. No part of Vidalia, including this file, -# may be copied, modified, propagated, or distributed except according to the -# terms described in the LICENSE file. -# -# * * * * * * -# -# This file is derived from contrib/osx/package.sh from Tor -# (https://www.torproject.org), licensed as follows: -# -# Copyright (c) 2001-2004, Roger Dingledine -# Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson -# Copyright (c) 2008, Andrew Lewman -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following disclaimer -# in the documentation and/or other materials provided with the -# distribution. -# -# * Neither the names of the copyright owners nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -######################################################################### - - -# This script builds a Macintosh OS X metapackage containing 4 packages: -# - One for Vidalia. -# - One for Tor. -# - One for Privoxy. -# - One for a Tor-specific Privoxy configuration script. -# - -if [ $# -ne 2 ] -then - echo "usage: package.sh " - exit 1 -fi - -# Determine OSX Version and map version to name -if [ -x /usr/bin/sw_vers ] -then - # This is poor, yet functional. We don't care about the 3rd number in - # the OS version - OSVER=`/usr/bin/sw_vers | grep ProductVersion | cut -f2 | cut -d"." -f1,2` - case "$OSVER" in - "10.6") ARCH="universal";; - "10.5") ARCH="universal";; - "10.4") ARCH="universal";; - "10.3") ARCH="ppc";; - "10.2") ARCH="ppc";; - "10.1") ARCH="ppc";; - "10.0") ARCH="ppc";; - *) ARCH="unknown";; - esac -else - ARCH="unknown" -fi - -# Get the location of Vidalia -VID_DIR="../../" -# Get the location of Tor -TOR_DIR="$1" -# Get the location of the Privoxy package zip file -PRIVOXY_PKG="$2" -# Vidalia's version string -VIDALIAVERSION="@VERSION@" -# Tor's version string -TORVERSION=`echo "$TOR_DIR" | sed -e "s/.*\///" | sed -e "s/tor-//"` -# Name of the output bundle -BUNDLE="vidalia-bundle-$TORVERSION-$VIDALIAVERSION-$ARCH" -# Set the location of the temporary files -BUILD_DIR=/tmp/vidalia-osx-$$ -# Set the location of the .mpkg -MPKG_DIR="$BUILD_DIR/output" -# Set the location where sub-packages will be placed -PKG_DIR="$MPKG_DIR/.contained_packages" -# Set the location of the resulting .dmg file -OUT_DIR="$VID_DIR/pkg" -# Path to PackageMaker -PACKAGEMAKER=/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker -# Where have we put the xpi and license for Torbutton? Edit this if your -# torbutton and torbutton license live somewhere else. -TORBUTTON_PATH=~/tmp/torbutton-1.2.0-fx.xpi -TORBUTTON_LIC_PATH=~/tmp/LICENSE - -umask 022 -echo I might ask you for your password now, so you can sudo. -sudo rm -rf $BUILD_DIR -mkdir $BUILD_DIR || exit 1 -for subdir in tor_packageroot \ - tor_resources \ - torbutton_packageroot \ - privoxyconf_packageroot \ - privoxyconf_resources \ - vidalia_packageroot \ - vidaliabundle_resources \ - output; do - mkdir $BUILD_DIR/$subdir -done -mkdir $PKG_DIR - -## -# Assemble the Vidalia package -## -echo "** Building Vidalia.pkg **" -mkdir -p $BUILD_DIR/vidalia_packageroot/Applications/Vidalia.app -mkdir -p $BUILD_DIR/vidalia_packageroot/Library/Vidalia -cp -R $VID_DIR/src/vidalia/Vidalia.app $BUILD_DIR/vidalia_packageroot/Applications/ -cp $VID_DIR/CREDITS $VID_DIR/CHANGELOG $VID_DIR/README $BUILD_DIR/vidalia_packageroot/Library/Vidalia - -find $BUILD_DIR/vidalia_packageroot \( -type d -or -perm +111 \) -print0 | sudo xargs -0 chmod 775 -find $BUILD_DIR/vidalia_packageroot -type f \! \( -perm +111 \) -print0 | sudo xargs -0 chmod 664 -find $BUILD_DIR/vidalia_packageroot -print0 | sudo xargs -0 chown root:admin - -$PACKAGEMAKER -build \ - -p $PKG_DIR/Vidalia.pkg \ - -f $BUILD_DIR/vidalia_packageroot \ - -i VidaliaInfo.plist \ - -d VidaliaDesc.plist - -## -# Assemble the Tor package -## -echo "** Building Tor.pkg **" -pushd $TOR_DIR -make install DESTDIR=$BUILD_DIR/tor_packageroot -popd -chmod 755 TorPostFlight -cp $TOR_DIR/contrib/osx/Tor_Uninstaller.applescript $BUILD_DIR/tor_resources/ -cp $TOR_DIR/contrib/osx/uninstall_tor_bundle.sh $BUILD_DIR/tor_resources/ -cp package_list.txt $BUILD_DIR/tor_resources/ -cp TorPostflight $BUILD_DIR/tor_resources/postflight - -# Tor's documentation -DOC=$BUILD_DIR/tor_resources/documents -mkdir $DOC -mkdir $DOC/howto -cp $TOR_DIR/doc/website/stylesheet.css $TOR_DIR/doc/website/tor-doc-osx.html.* $DOC/howto -cp $TOR_DIR/doc/website/tor-doc-server.html.* $DOC/howto -cp $TOR_DIR/doc/website/tor-hidden-service.html.* $DOC/howto -cp $TOR_DIR/doc/website/tor-switchproxy.html.* $DOC/howto -cp $TOR_DIR/AUTHORS $DOC/AUTHORS.txt -groff $TOR_DIR/doc/tor.1.in -T ps -m man | pstopdf -i -o $DOC/tor-reference.pdf -groff $TOR_DIR/doc/tor-resolve.1 -T ps -m man | pstopdf -i -o $DOC/tor-resolve.pdf -mkdir $DOC/Advanced -cp $TOR_DIR/doc/spec/tor-spec.txt \ - $TOR_DIR/doc/spec/rend-spec.txt \ - $TOR_DIR/doc/spec/control-spec.txt \ - $TOR_DIR/doc/spec/socks-extensions.txt \ - $TOR_DIR/doc/spec/version-spec.txt \ - $TOR_DIR/doc/spec/address-spec.txt \ - $TOR_DIR/doc/spec/path-spec.txt \ - $DOC/Advanced -cp $TOR_DIR/doc/HACKING $DOC/Advanced/HACKING.txt -cp $TOR_DIR/ChangeLog $DOC/Advanced/ChangeLog.txt - -find $BUILD_DIR/tor_packageroot \( -type d -or -perm +111 \) -print0 | sudo xargs -0 chmod 775 -find $BUILD_DIR/tor_packageroot -type f \! \( -perm +111 \) -print0 | sudo xargs -0 chmod 664 -find $BUILD_DIR/tor_packageroot -print0 | sudo xargs -0 chown root:admin - -$PACKAGEMAKER -build \ - -p $PKG_DIR/Tor.pkg \ - -f $BUILD_DIR/tor_packageroot \ - -r $BUILD_DIR/tor_resources \ - -i $TOR_DIR/contrib/osx/TorInfo.plist \ - -d $TOR_DIR/contrib/osx/TorDesc.plist - -## -# Make Torbutton Installation package -## -echo "** Building Torbutton package**" -mkdir -p $BUILD_DIR/torbutton_packageroot/Library/Torbutton -cp $TORBUTTON_PATH $BUILD_DIR/torbutton_packageroot/Library/Torbutton/ -cp $TORBUTTON_LIC_PATH $BUILD_DIR/torbutton_packageroot/Library/Torbutton/Torbutton-LICENSE.txt - -find $BUILD_DIR/torbutton_packageroot \( -type d -or -perm +111 \) -print0 | sudo xargs -0 chmod 775 -find $BUILD_DIR/torbutton_packageroot -type f \! \( -perm +111 \) -print0 | sudo xargs -0 chmod 664 -find $BUILD_DIR/torbutton_packageroot -print0 | sudo xargs -0 chown root:admin - -$PACKAGEMAKER -build \ - -p $PKG_DIR/torbutton.pkg \ - -f $BUILD_DIR/torbutton_packageroot \ - -i TorbuttonInfo.plist \ - -d TorbuttonDesc.plist - -## -# Unzip the Privoxy.pkg and move it into place -## -echo "** Extracting Privoxy.pkg **" -unzip $PRIVOXY_PKG -d $PKG_DIR/ -find $PKG_DIR/Privoxy.pkg -type d -print0 | xargs -0 chmod u+w - -## -# Build the Privoxy configuration package -## -echo "** Building PrivoxyConf.pkg **" -mkdir -p $BUILD_DIR/privoxyconf_packageroot/Library/Privoxy -cp privoxy.config $BUILD_DIR/privoxyconf_packageroot/Library/Privoxy/config -cp default.action $BUILD_DIR/privoxyconf_packageroot/Library/Privoxy/default.action -chmod 755 PrivoxyConfPostFlight -cp PrivoxyConfPostFlight $BUILD_DIR/privoxyconf_resources/postflight - -find $BUILD_DIR/privoxyconf_packageroot -print0 | sudo xargs -0 chown root:wheel - -$PACKAGEMAKER -build \ - -p $PKG_DIR/PrivoxyConf.pkg \ - -f $BUILD_DIR/privoxyconf_packageroot \ - -r $BUILD_DIR/privoxyconf_resources \ - -i PrivoxyConfInfo.plist \ - -d PrivoxyConfDesc.plist - - -## -# Build the metapackage -## -echo "** Building the bundle metapackage **" -MPKG=$MPKG_DIR/$BUNDLE.mpkg -mkdir -p "$MPKG/Contents/Resources" -echo -n "pmkrpkg1" > "$MPKG/Contents/PkgInfo" -cp VidaliaBundleWelcome.rtf "$MPKG/Contents/Resources/Welcome.rtf" -cp VidaliaBundleInfo.plist "$MPKG/Contents/Info.plist" -cp VidaliaBundleDesc.plist "$MPKG/Contents/Resources/Description.plist" - -### Copy readmes and licenses into toplevel. -PRIVOXY_RESDIR=$PKG_DIR/Privoxy.pkg/Contents/Resources -cp $PRIVOXY_RESDIR/License.html $MPKG_DIR/Privoxy\ License.html -cp $PRIVOXY_RESDIR/ReadMe.txt $MPKG_DIR/Privoxy\ ReadMe.txt -cp $TOR_DIR/LICENSE $MPKG_DIR/Tor\ License.txt -cp $VID_DIR/LICENSE $MPKG_DIR/Vidalia\ License.txt -cp $VID_DIR/LICENSE-GPLV2 $MPKG_DIR/GNU\ GPLv2.txt -cp $VID_DIR/LICENSE-GPLV3 $MPKG_DIR/GNU\ GPLv3.txt -cp $VID_DIR/LICENSE-OPENSSL $MPKG_DIR/OpenSSL\ License.txt -cp $TORBUTTON_LIC_PATH $MPKG_DIR/Torbutton-LICENSE.txt - - -## -# Put the metapackage into a dmg -## -echo "** Building $BUNDLE.dmg **" -find $MPKG_DIR -print0 | sudo xargs -0 chown root:wheel -mv $MPKG_DIR "$BUILD_DIR/$BUNDLE" -rm -f "$BUNDLE.dmg" -USER="`whoami`" -sudo hdiutil create -format UDZO -srcfolder "$BUILD_DIR/$BUNDLE" "$OUT_DIR/$BUNDLE.dmg" -sudo chown "$USER" "$OUT_DIR/$BUNDLE.dmg" - - -## -# Clean up and finish -## -sudo rm -rf $BUILD_DIR - Binary files /tmp/KPMk4L7DHV/vidalia-0.1.13/pkg/osx/bundle-background.png and /tmp/EwwyCgG7oU/vidalia-0.2.8/pkg/osx/bundle-background.png differ Binary files /tmp/KPMk4L7DHV/vidalia-0.1.13/pkg/osx/bundle-ds_store and /tmp/EwwyCgG7oU/vidalia-0.2.8/pkg/osx/bundle-ds_store differ diff -Nru vidalia-0.1.13/pkg/osx/CMakeLists.txt vidalia-0.2.8/pkg/osx/CMakeLists.txt --- vidalia-0.1.13/pkg/osx/CMakeLists.txt 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/pkg/osx/CMakeLists.txt 2010-02-17 16:27:56.000000000 +0000 @@ -1,5 +1,5 @@ ## -## $Id: CMakeLists.txt 2858 2008-07-13 04:29:06Z edmanm $ +## $Id: CMakeLists.txt 4216 2010-02-17 16:27:56Z phobos $ ## ## 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 @@ -10,28 +10,195 @@ ## the terms described in the LICENSE file. ## -## OS X Packaging Files -configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/builddmg.sh.in - ${CMAKE_CURRENT_BINARY_DIR}/builddmg.sh -) -configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/buildmpkg.sh.in - ${CMAKE_CURRENT_BINARY_DIR}/buildmpkg.sh -) -configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/VidaliaBundleDesc.plist.in - ${CMAKE_CURRENT_BINARY_DIR}/VidaliaBundleDesc.plist -) -configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/VidaliaBundleInfo.plist.in - ${CMAKE_CURRENT_BINARY_DIR}/VidaliaBundleInfo.plist -) -configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/VidaliaDesc.plist.in - ${CMAKE_CURRENT_BINARY_DIR}/VidaliaDesc.plist -) -configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/VidaliaInfo.plist.in - ${CMAKE_CURRENT_BINARY_DIR}/VidaliaInfo.plist + +set(VIDALIA_APP_BUNDLE_ROOT ${Vidalia_BINARY_DIR}/src/vidalia/Vidalia.app) +get_target_property(VIDALIA_EXECUTABLE Vidalia LOCATION) +add_custom_target(dist-osx-libraries DEPENDS Vidalia) +if (QT_USE_FRAMEWORKS) + vidalia_install_qt4_framework(QtCore + TARGET dist-osx-libraries NAME QtCore + LIBRARY ${QT_QTCORE_LIBRARY}/QtCore + APP_BUNDLE ${VIDALIA_APP_BUNDLE_ROOT} + ) + vidalia_install_qt4_framework(QtGui + TARGET dist-osx-libraries NAME QtGui + LIBRARY ${QT_QTGUI_LIBRARY}/QtGui + APP_BUNDLE ${VIDALIA_APP_BUNDLE_ROOT} + DEPENDS_FRAMEWORKS ${QtCore} + ) + vidalia_install_qt4_framework(QtNetwork + TARGET dist-osx-libraries NAME QtNetwork + LIBRARY ${QT_QTNETWORK_LIBRARY}/QtNetwork + APP_BUNDLE ${VIDALIA_APP_BUNDLE_ROOT} + DEPENDS_FRAMEWORKS ${QtCore} + ) + vidalia_install_qt4_framework(QtXml + TARGET dist-osx-libraries NAME QtXml + LIBRARY ${QT_QTXML_LIBRARY}/QtXml + APP_BUNDLE ${VIDALIA_APP_BUNDLE_ROOT} + DEPENDS_FRAMEWORKS ${QtCore} + ) + vidalia_install_name_tool(${VIDALIA_EXECUTABLE} + TARGET dist-osx-libraries + FRAMEWORKS ${QtCore} ${QtGui} ${QtNetwork} ${QtXml} + ) + if (USE_MARBLE) + vidalia_install_qt4_framework(QtSvg + TARGET dist-osx-libraries NAME QtSvg + LIBRARY ${QT_QTSVG_LIBRARY}/QtSvg + APP_BUNDLE ${VIDALIA_APP_BUNDLE_ROOT} + DEPENDS_FRAMEWORKS ${QtCore} ${QtGui} + ) + vidalia_install_qt4_framework(QtScript + TARGET dist-osx-libraries NAME QtScript + LIBRARY ${QT_QTSCRIPT_LIBRARY}/QtScript + APP_BUNDLE ${VIDALIA_APP_BUNDLE_ROOT} + DEPENDS_FRAMEWORKS ${QtCore} + ) + vidalia_install_qt4_framework(QtDBus + TARGET dist-osx-libraries NAME QtDBus + LIBRARY ${QT_QTDBUS_LIBRARY}/QtDBus + APP_BUNDLE ${VIDALIA_APP_BUNDLE_ROOT} + DEPENDS_FRAMEWORKS ${QtCore} ${QtXml} + ) + vidalia_install_qt4_framework(QtPhonon + TARGET dist-osx-libraries NAME phonon + LIBRARY ${QT_PHONON_LIBRARY}/phonon + APP_BUNDLE ${VIDALIA_APP_BUNDLE_ROOT} + DEPENDS_FRAMEWORKS ${QtCore} ${QtGui} ${QtXml} ${QtDBus} + ) + vidalia_install_qt4_framework(QtWebKit + TARGET dist-osx-libraries NAME QtWebKit + LIBRARY ${QT_QTWEBKIT_LIBRARY}/QtWebKit + APP_BUNDLE ${VIDALIA_APP_BUNDLE_ROOT} + DEPENDS_FRAMEWORKS ${QtCore} ${QtGui} ${QtNetwork} ${QtXml} ${QtDBus} + ${QtPhonon} + ) + vidalia_install_dylib(MarbleWidget + TARGET dist-osx-libraries + LIBRARY ${MARBLEWIDGET_LIBRARY} + APP_BUNDLE ${VIDALIA_APP_BUNDLE_ROOT} + DEPENDS_FRAMEWORKS ${QtCore} ${QtGui} ${QtNetwork} ${QtXml} ${QtSvg} + ${QtDBus} ${QtScript} ${QtWebKit} + ) + vidalia_install_name_tool(${VIDALIA_EXECUTABLE} + TARGET dist-osx-libraries + FRAMEWORKS ${QtSvg} ${QtDBus} ${QtScript} ${QtWebKit} + LIBRARIES ${MARBLEWIDGET_LIBRARY} + ) + endif(USE_MARBLE) +endif(QT_USE_FRAMEWORKS) + +if (OSX_FAT_BINARY) + set(DMG_ARCH "universal") +else(OSX_FAT_BINARY) + set(DMG_ARCH ${CMAKE_OSX_ARCHITECTURES}) +endif(OSX_FAT_BINARY) + +add_custom_target(dist-osx + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/pkg-dmg + --source ${VIDALIA_APP_BUNDLE_ROOT} + --target ${Vidalia_BINARY_DIR}/vidalia-${VERSION}-${DMG_ARCH}.dmg + --sourcefile --volname "Vidalia ${VERSION}" + --icon ${Vidalia_SOURCE_DIR}/src/vidalia/res/icons/Vidalia.icns + --symlink "/Applications:/Drag to here" + --mkdir /.background + --copy ${CMAKE_CURRENT_SOURCE_DIR}/background.png:/.background/ + --copy ${CMAKE_CURRENT_SOURCE_DIR}/nonbundle-ds_store:/.DS_Store + --copy ${CMAKE_CURRENT_SOURCE_DIR}/qt.conf:/Vidalia.app/Contents/Resources/qt.conf + --mkdir /Licenses + --copy ${Vidalia_SOURCE_DIR}/LICENSE:/Licenses/License.txt + --copy ${Vidalia_SOURCE_DIR}/LICENSE-GPLV2:/Licenses/License-GPLv2.txt + --copy ${Vidalia_SOURCE_DIR}/LICENSE-GPLV3:/Licenses/License-GPLv3.txt + --copy ${Vidalia_SOURCE_DIR}/LICENSE-OPENSSL:/Licenses/License-OpenSSL.txt + --copy ${Vidalia_SOURCE_DIR}/README:/ReadMe.txt + --copy ${Vidalia_SOURCE_DIR}/CHANGELOG:/Changes.txt + COMMENT "Creating vidalia-${VERSION}-${DMG_ARCH}.dmg" + VERBATIM ) +add_dependencies(dist-osx dist-osx-libraries) + +if (TOR_SOURCE_DIR AND POLIPO_SOURCE_DIR AND TORBUTTON_XPI) + get_filename_component(TOR_SOURCE_DIR ${TOR_SOURCE_DIR} ABSOLUTE) + get_filename_component(POLIPO_SOURCE_DIR ${POLIPO_SOURCE_DIR} ABSOLUTE) + get_filename_component(TORBUTTON_XPI ${TORBUTTON_XPI} ABSOLUTE) + + ## Determine Tor's version string used to build the .dmg filename + vidalia_get_tor_version(TOR_VERSION "${TOR_SOURCE_DIR}/src/or/tor") + if (TOR_VERSION) + message(STATUS "Found Tor ${TOR_VERSION}") + else (TOR_VERSION) + message(FATAL_ERROR "Unable to determine version of ${TOR_SOURCE_DIR}/src/or/tor") + endif(TOR_VERSION) + + ## Configure the Torbutton installation script file + get_filename_component(TORBUTTON_XPI_FILENAME ${TORBUTTON_XPI} NAME) + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/InstallTorbutton.scpt.in + ${CMAKE_CURRENT_BINARY_DIR}/InstallTorbutton.scpt + ) + + set(bundle_DMG "vidalia-bundle-${TOR_VERSION}-${VERSION}-${DMG_ARCH}.dmg") + add_custom_target(dist-osx-bundle + COMMAND osacompile + -o "${CMAKE_CURRENT_BINARY_DIR}/Install Torbutton for Firefox.app" + ${CMAKE_CURRENT_BINARY_DIR}/InstallTorbutton.scpt + COMMAND ${CMAKE_COMMAND} -E copy + ${TORBUTTON_XPI} + "${CMAKE_CURRENT_BINARY_DIR}/Install Torbutton for Firefox.app/" + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/pkg-dmg + --source ${VIDALIA_APP_BUNDLE_ROOT} + --target ${Vidalia_BINARY_DIR}/${bundle_DMG} + --sourcefile --volname "Vidalia Bundle ${VERSION}" + --icon ${Vidalia_SOURCE_DIR}/src/vidalia/res/icons/Vidalia.icns + --symlink "/Applications:/Drag to here" + --mkdir /.background + --copy ${CMAKE_CURRENT_SOURCE_DIR}/bundle-background.png:/.background/ + --copy ${CMAKE_CURRENT_SOURCE_DIR}/bundle-ds_store:/.DS_Store + --copy ${CMAKE_CURRENT_SOURCE_DIR}/vidalia.conf.sample:/Vidalia.app/Contents/Resources/vidalia.conf + --copy ${CMAKE_CURRENT_SOURCE_DIR}/qt.conf:/Vidalia.app/Contents/Resources/qt.conf + --mkdir /Licenses + --copy ${Vidalia_SOURCE_DIR}/LICENSE:/Licenses/License.txt + --copy ${Vidalia_SOURCE_DIR}/LICENSE-GPLV2:/Licenses/License-GPLv2.txt + --copy ${Vidalia_SOURCE_DIR}/LICENSE-GPLV3:/Licenses/License-GPLv3.txt + --copy ${Vidalia_SOURCE_DIR}/LICENSE-OPENSSL:/Licenses/License-OpenSSL.txt + --copy ${Vidalia_SOURCE_DIR}/CHANGELOG:/Changes.txt + --copy ${TOR_SOURCE_DIR}/src/or/tor:/Vidalia.app/Contents/MacOS/ + --copy ${TOR_SOURCE_DIR}/src/tools/tor-checkkey:/Vidalia.app/Contents/MacOS/ + --copy ${TOR_SOURCE_DIR}/src/tools/tor-gencert:/Vidalia.app/Contents/MacOS/ + --copy ${TOR_SOURCE_DIR}/src/tools/tor-resolve:/Vidalia.app/Contents/MacOS/ + --copy ${TOR_SOURCE_DIR}/src/config/geoip:/Vidalia.app/Contents/Resources/ + --copy ${TOR_SOURCE_DIR}/src/config/torrc.sample:/Vidalia.app/Contents/Resources/ + --copy ${POLIPO_SOURCE_DIR}/polipo:/Vidalia.app/Contents/MacOS/ + --copy ${CMAKE_CURRENT_SOURCE_DIR}/polipo.conf:/Vidalia.app/Contents/Resources/ + --copy "${CMAKE_CURRENT_BINARY_DIR}/Install Torbutton for Firefox.app:/" + COMMENT "Creating ${bundle_DMG}" + VERBATIM + ) + add_dependencies(dist-osx-bundle dist-osx-libraries) + + add_custom_target(dist-osx-split-bundle + COMMAND hdiutil segment -segmentSize 1.5m + -o "${Vidalia_BINARY_DIR}/split-${bundle_DMG}" "${Vidalia_BINARY_DIR}/${bundle_DMG}" + COMMENT "Creating split-${bundle_DMG}" + VERBATIM + ) + add_dependencies(dist-osx-split-bundle dist-osx-bundle) +else(TOR_SOURCE_DIR AND POLIPO_SOURCE_DIR AND TORBUTTON_XPI) + message("-- Skipping dist-osx-bundle build target") + add_custom_target(dist-osx-bundle + COMMAND ${CMAKE_COMMAND} -E echo + "!! The dist-osx-bundle target is not configured." + COMMAND ${CMAKE_COMMAND} -E echo + "!! You must set the -DTOR_SOURCE_DIR,-DPOLIPO_SOURCE_DIR and -DTORBUTTON_XPI CMake variables." + COMMAND ${CMAKE_COMMAND} -E echo "!! Quitting." + ) + add_custom_target(dist-osx-split-bundle + COMMAND ${CMAKE_COMMAND} -E echo + "!! The dist-osx-split-bundle target is not configured. Quitting." + COMMAND ${CMAKE_COMMAND} -E echo + "!! You must set the -DTOR_SOURCE_DIR, -DPOLIPO_SOURCE_DIR and -DTORBUTTON_XPI CMake variables." + COMMAND ${CMAKE_COMMAND} -E echo "!! Quitting." + ) +endif(TOR_SOURCE_DIR AND POLIPO_SOURCE_DIR AND TORBUTTON_XPI) + diff -Nru vidalia-0.1.13/pkg/osx/default.action vidalia-0.2.8/pkg/osx/default.action --- vidalia-0.1.13/pkg/osx/default.action 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/pkg/osx/default.action 1970-01-01 01:00:00.000000000 +0100 @@ -1,1260 +0,0 @@ -###################################################################### -# -# File : $Source: /cvsroot/ijbswa/current/default.action.master,v $ -# -# $Id: default.action.master,v 1.45 2006/11/18 10:36:17 hal9 Exp $ -# -# Requires : This version requires Privoxy v3.0.5 or later due to -# syntax changes. -# -# Purpose : Default actions file, see -# http://www.privoxy.org/user-manual/actions-file.html. -# This file is subject to periodic updating. Local exceptions -# and enhancements are better placed in user.action. -# -# Copyright : Written by and Copyright (C) 2001 - 2006 the -# Privoxy team. http://www.privoxy.org/ -# -# Note: Updated versions of this file will be made available from time -# to time. Check http://sourceforge.net/project/showfiles.php?group_id=11118 -# for updates and/or subscribe to the announce mailing list -# (http://lists.sourceforge.net/lists/listinfo/ijbswa-announce) if you -# wish to receive an email notice whenever updates are released. -# -# We value your feedback. However, to provide you with the best support, -# please note: -# -# * Use the support forum to get help: -# http://sourceforge.net/tracker/?group_id=11118&atid=211118 -# * Submit feedback for this actions file only through the -# SF actions file feedback tracker: -# http://sourceforge.net/tracker/?group_id=11118&atid=460288 -# * Submit bugs only through our bug forum: -# http://sourceforge.net/tracker/?group_id=11118&atid=111118 -# Make sure that the bug has not already been submitted. Please try -# to verify that it is a Privoxy bug, and not a browser or site -# bug first. If you are using your own custom configuration, please -# try the stock configs to see if the problem is a configuration -# related bug. And if possible please try the latest CVS sources. -# * Submit feature requests only through our feature request forum: -# http://sourceforge.net/tracker/?atid=361118&group_id=11118&func=browse -# -# For any other issues, feel free to use the mailing lists: -# http://sourceforge.net/mail/?group_id=11118 -# -# Anyone interested in actively participating in development and related -# discussions can join the appropriate mailing list here: -# http://sourceforge.net/mail/?group_id=11118. Archives are available -# here too. -# -# The current development version of this file is located: -# http://ijbswa.cvs.sourceforge.net/*checkout*/ijbswa/current/default.action.master -# -############################################################################# -# Syntax -############################################################################# -# -# A much better explanation can be found in the user manual which is -# part of the distribution and can be found at http://www.privoxy.org/user-manual -# -# To determine which actions apply to a request, the URL of the request is -# compared to all patterns in this file. Every time it matches, the list of -# applicable actions for this URL is incrementally updated. You can trace -# this process by visiting http://config.privoxy.org/show-url-info -# -# There are 4 types of lines in this file: comments (like this line), -# actions, aliases and patterns, all of which are explained below. -# -############################################################################# -# Pattern Syntax -############################################################################# -# -# 1. On Domains and Paths -# ----------------------- -# -# Generally, a pattern has the form /, where both the -# and part are optional. The pattern matching syntax is different for -# each. If you only specify a domain part, the "/" can be left out, but it is -# required for the path part. -# -# www.example.com -# is a domain-only pattern and will match any request to www.example.com -# -# www.example.com/ -# means exactly the same (but is slightly less efficient) -# -# www.example.com/index.html -# matches only the document /index.html on www.example.com -# -# /index.html -# matches the document /index.html, regardless of the domain -# -# index.html -# matches nothing, since it would be interpreted as a domain name and -# there is no top-level domain called ".html". -# -# 2. Domain Syntax -# ---------------- -# -# The matching of the domain part offers some flexible options: If the -# domain starts or ends with a dot, it becomes unanchored at that end: -# -# www.example.com -# matches only www.example.com -# -# .example.com -# matches any domain that ENDS in .example.com -# -# www. -# matches any domain that STARTS with www. -# -# .example. -# matches any domain that CONTAINS example -# -# -# Additionally, there are wildcards that you can use in the domain names -# themselves. They work pretty similar to shell wildcards: "*" stands for -# zero or more arbitrary characters, "?" stands for one, and you can define -# charachter classes in square brackets and they can be freely mixed: -# -# ad*.example.com -# matches adserver.example.com, ads.example.com, etc but not sfads.example.com -# -# *ad*.example.com -# matches all of the above -# -# .?pix.com -# matches www.ipix.com, pictures.epix.com, a.b.c.d.e.upix.com etc -# -# www[1-9a-ez].example.com -# matches www1.example.com, www4.example.com, wwwd.example.com, -# wwwz.example.com etc, but not wwww.example.com -# -# You get the idea? -# -# 2. Path Syntax -# -------------- -# -# Paths are specified as full regular expressions, and are more flexible than -# the domain syntax above. A comprehensive discussion of regular expressions -# wouldn't fit here. -# -# Perl compatible regular expressions are used. See the pcre/docs/ direcory or -# man perlre (also available at http://perldoc.perl.org/perlre.html) for -# details. The appendix to our User Manual also has some detail. -# -# Please note that matching in the path is CASE INSENSITIVE by default, but -# you can switch to case sensitive by starting the pattern with the "(?-i)" -# switch: -# -# www.example.com/(?-i)PaTtErN.* -# will match only documents whose path starts with PaTtErN in exactly this -# capitalization. -# -# Partially case-sensetive and partially case-insensitive patterns are -# possible, but the rules about splitting them up are extremely complex -# - see the PCRE documentation for more information. -# -############################################################################# -# Action Syntax -############################################################################# -# -# There are 3 kinds of actions: -# -# Boolean (e.g. "block"): -# +name # enable -# -name # disable -# -# Parameterized (e.g. "hide-user-agent"): -# +name{param} # enable and set parameter to "param" -# -name # disable -# -# Multi-value (e.g. "add-header", "send-wafer"): -# +name{param} # enable and add parameter "param" -# -name{param} # remove the parameter "param" -# -name # disable totally -# -# The default (if you don't specify anything in this file) is not to take -# any actions - i.e completely disabled, so Privoxy will just be a -# normal, non-blocking, non-anonymizing proxy. You must specifically -# enable the privacy and blocking features you need (although the -# provided default actions file will do that for you). -# -# Later actions always override earlier ones. For multi-valued actions, -# the actions are applied in the order they are specified. -# -############################################################################# -# Valid actions are: -############################################################################# -# -# +add-header{Name: value} -# Adds the specified HTTP header, which is not checked for validity. -# You may specify this many times to specify many headers. -# -# +block -# Block this URL. Privoxy will ignore this URL completely, and not request -# it. -# -# +content-type-overwrite -# Replaces the "Content-Type:" HTTP server header, so that unwanted -# download menus will not pop up, or changes the browser's rendering mode. -# -# +crunch-client-header{string} -# Deletes every header sent by the client that contains the string the -# user supplied as parameter. -# -# +crunch-if-none-match -# Deletes the "If-None-Match:" HTTP client header. -# -# +crunch-server-header{string} -# Deletes every header sent by the server that contains the string the -# user supplied as a parameter. -# -# +deanimate-gifs{last} -# +deanimate-gifs{first} -# Deanimate all animated GIF images, i.e. reduce them to their last -# frame. This will also shrink the images considerably. (In bytes, -# not pixels!) -# If the option "first" is given, the first frame of the animation -# is used as the replacement. If "last" is given, the last frame of -# the animation is used instead, which propably makes more sense for -# most banner animations, but also has the risk of not showing the -# entire last frame (if it is only a delta to an earlier frame). -# -# +downgrade-http-version -# Downgrade HTTP/1.1 client requests to HTTP/1.0 and downgrade the -# responses as well. Use this action for servers that use HTTP/1.1 -# protocol features that Privoxy currently can't handle yet. -# -# +fast-redirects{check-decoded-url} -# +fast-redirects{simple-check} -# Many sites, like yahoo.com, don't just link to other sites. -# Instead, they will link to some script on their own server, -# giving the destination as a parameter, which will then redirect -# you to the final target. -# -# URLs resulting from this scheme typically look like: -# http://some.place/some_script?http://some.where-else -# -# Sometimes, there are even multiple consecutive redirects encoded -# in the URL. These redirections via scripts make your web browing -# more traceable, since the server from which you follow such a link -# can see where you go to. Apart from that, valuable bandwidth and -# time is wasted, while your browser aks the server for one redirect -# after the other. Plus, it feeds the advertisers. -# -# The +fast-redirects{check-decoded-url} option enables interception of -# these requests by Privoxy, who will cut off all but the last valid URL -# in the request and send a local redirect back to your browser without -# contacting the intermediate sites. NOTE: Syntax change as of v.3.0.4. -# -# +filter{name} -# All files of text-based type, most notably HTML and JavaScript, to which -# this action applies, can be filtered on-the-fly through the specified -# regular expression based substitutions. (Note: plain text documents are -# exempted from filtering, because web servers often use the text/plain -# MIME type for all files whose type they don't know.) By default, -# filtering works only on the raw document content itself (that which can -# be seen with View Source), not the headers. Repeat for multiple filters. -# Use with caution: filters can be very intrusive. -# -# Filters predefined in the supplied default.action include: -# -# js-annoyances: Get rid of particularly annoying JavaScript abuse -# js-events: Kill all JS event bindings (Radically destructive! Use only on real suckers) -# html-annoyances: Get rid of particularly annoying HTML abuse -# content-cookies: Kill cookies that come in the HTML or JS content -# refresh-tags: Kill automatic refresh tags (for dial-on-demand setups) -# unsolicited-popups: Disable only unsolicited pop-up windows -# all-popups: Kill all popups in JavaScript and HTML -# img-reorder: Reorder attributes in tags to make the banners-by-* filters more effective -# banners-by-size: Kill banners by size (very efficient!) -# banners-by-link: Kill banners by their links to known clicktrackers -# webbugs: Squish WebBugs (1x1 invisible GIFs used for user tracking) -# tiny-textforms: Extend those tiny textareas up to 40x80 and kill the hard wrap -# jumping-windows: Prevent windows from resizing and moving themselves -# frameset-borders: Give frames a border -# demoronizer: Fix MS's non-standard use of standard charsets -# shockwave-flash: Kill embedded Shockwave Flash objects -# quicktime-kioskmode: Make Quicktime movies saveable -# fun: Text replacements for subversive browsing fun! -# crude-parental: Kill all web pages that contain the words "sex" or "warez" -# ie-exploits: Disable some known Internet Explorer bug exploits -# site-specifics: Cure for site-specific problems. Don't apply generally! -# google: Removes text ads and other Google specific improvements -# yahoo: Removes text ads and other Yahoo specific improvements -# msn: Removes text ads and other MSN specific improvements -# blogspot: Cleans up Blogspot blogs -# html-to-xml: Header filter to change the Content-Type from html to xml -# xml-to-html: Header filter to change the Content-Type from xml to html -# no-ping: Removes non-standard ping attributes from anchor and area tags -# hide-tor-exit-notation: Header filter to remove the Tor exit node notation in Host and Referer headers -# -# +filter-client-headers -# By default, filters only apply to the document content itself. This will -# extend those filters to include the client's headers as well. -# -# +filter-server-headers -# By default, filters only apply to the document content itself. This will -# extend those filters to include the server's headers as well. -# -# +force-text-mode -# Declares a document as plain text, even if the "Content-Type:" isn't detected -# as such. -# -# +handle-as-empty-document -# This action alone doesn't do anything noticeable. It just marks URLs. If -# the block action also applies, the presence or absence of this mark -# decides whether an HTML "blocked" page, or an empty document will be sent -# to the client as a substitute for the blocked content. -# -# +hide-accept-language{lang} -# +hide-accept-language{block} -# Deletes or replaces the "Accept-Language:" HTTP header in client -# requests. -# -# +hide-content-disposition{block} -# +hide-content-disposition{string} -# Deletes or replaces the "Content-Disposition:" HTTP header set by some -# servers. This can be used to prevent download menus for content you -# prefer to view inside the browser, for example. -# -# +hide-forwarded-for-headers -# Block any existing X-Forwarded-for header, and do not add a new one. -# -# +hide-from-header{block} -# +hide-from-header{spam@sittingduck.xqq} -# If the browser sends a "From:" header containing your e-mail address, -# either completely removes the header ("block"), or change it to the -# specified e-mail address. -# -# +hide-if-modified-since{block} -# +hide-if-modified-since{-1} -# Deletes the "If-Modified-Since:" HTTP client header or modifies its -# value, preventing another way to track users. -# -# +hide-referer{block} -# +hide-referer{forge} -# +hide-referer{http://nowhere.com} -# Don't send the "Referer:" (sic) header to the web site. You can -# block it, forge a URL to the same server as the request (which is -# preferred because some sites will not send images otherwise) or -# set it to a constant string. -# -# +hide-referrer{...} -# Alternative spelling of +hide-referer. Has the same parameters, -# and can be freely mixed with, "+hide-referer". ("referrer" is the -# correct English spelling, however the HTTP specification has a -# bug - it requires it to be spelt "referer"). -# -# +hide-user-agent{browser-type} -# Change the "User-Agent:" header so web servers can't tell your -# browser type. (Breaks many web sites). Specify the user-agent -# value you want - e.g., to pretend to be using Netscape on Linux: -# +hide-user-agent{Mozilla (X11; I; Linux 2.0.32 i586)} -# Or to identify yourself explicitly as a Privoxy user: -# +hide-user-agent{Privoxy/1.0} -# (Don't change the version number from 1.0 - after all, why tell them?) -# -# +handle-as-image -# Treat this URL as an image. This only matters if it's also "+block"ed, -# in which case a "blocked" image can be sent rather than a HTML page. -# See +set-image-blocker{} for the control over what is actually sent. -# -# +inspect-jpegs -# Scan jpeg headers for malformed comment blocks and correct them. -# -# +set-image-blocker{blank} -# +set-image-blocker{pattern} -# +set-image-blocker{} with being any valid image URL -# Decides what to do with URLs that end up tagged with {+block +handle-as-image}. -# There are 4 options: -# * "-set-image-blocker" will send a HTML "blocked" page, usually -# resulting in a "broken image" icon. -# * "+set-image-blocker{blank}" will send a 1x1 transparent image -# * "+set-image-blocker{pattern}" will send a 4x4 grey/white pattern -# which is less intrusive than the logo but easier to recognize -# than the transparent one. -# * "+set-image-blocker{}" will send a HTTP temporary redirect -# to the specified image URL. -# -# -# +limit-connect{portlist} -# The CONNECT methods exists in HTTP to allow access to secure websites -# (https:// URLs) through proxies. It works very simply: The proxy -# connects to the server on the specified port, and then short-circuits -# its connections to the cliant and to the remote proxy. -# This can be a big security hole, since CONNECT-enabled proxies can -# be abused as TCP relays very easily. -# By default, i.e. in the absence of a +limit-connect action, Privoxy -# will only allow CONNECT requests to port 443, which is the standard port -# for https. -# If you want to allow CONNECT for more ports than that, or want to forbid -# CONNECT altogether, you can specify a comma separated list of ports and port -# ranges (the latter using dashes, with the minimum defaulting to 0 and max to 65K): -# -# +limit-connect{443} # This is the default and need no be specified. -# +limit-connect{80,443} # Ports 80 and 443 are OK. -# +limit-connect{-3, 7, 20-100, 500-} # Port less than 3, 7, 20 to 100, and above 500 are OK. -# -# +overwrite-last-modified{block} -# +overwrite-last-modified{reset-to-request-time} -# +overwrite-last-modified{randomize} -# Removing the "Last-Modified:" header is useful for filter testing, where -# you want to force a real reload instead of getting status code "304", -# which would cause the browser to reuse the old version of the page. -# -# The "randomize" option overwrites the value of the "Last-Modified:" -# header with a randomly chosen time between the original value and the -# current time. In theory the server could send each document with a -# different "Last-Modified:" header to track visits without using cookies. -# "Randomize" makes it impossible and the browser can still revalidate -# cached documents. -# -# "reset-to-request-time" overwrites the value of the "Last-Modified:" -# header with the current time. You could use this option together with -# hided-if-modified-since to further customize your random range. -# -# +prevent-compression -# Prevent the website from compressing the data. Some websites do -# that, which is a problem for Privoxy, since +filter, +kill-popups -# and +gif-deanimate will not work on compressed data. Will slow down -# connections to those websites, though. -# -# +prevent-keeping-cookies -# +session-cookies-only -# If the website sets cookies, make sure they are erased when you exit -# and restart your web browser. This makes profiling cookies useless, -# but won't break sites which require cookies so that you can log in -# or for transactions. -# -# +crunch-outgoing-cookies -# Prevent the website from reading cookies -# -# +crunch-incoming-cookies -# Prevent the website from setting cookies -# -# +kill-popups (deprecated) -# Filter the website through a built-in filter to disable -# window.open() etc. The two alternative spellings are -# equivalent. -# -# +redirect{} -# Convinces the browser that the requested document has been moved to -# another location and the browser should get it from the specified -# URL. -# -# +send-vanilla-wafer -# This action only applies if you are using a jarfile. It sends a -# cookie to every site stating that you do not accept any copyright -# on cookies sent to you, and asking them not to track you. Of -# course, this is a (relatively) unique header they could use to -# track you. -# -# +send-wafer{name=value} -# This allows you to add an arbitrary cookie. Specify it multiple -# times in order to add several cookies. -# -# +treat-forbidden-connects-like-blocks -# If this action is enabled, Privoxy no longer makes a difference between -# forbidden connects and ordinary blocks. -# -# By default Privoxy answers forbidden "Connect" requests with a short -# error message inside the headers. If the browser doesn't display headers -# (most don't), you just see an empty page. With this action enabled, -# Privoxy displays the message that is used for ordinary blocks instead. If -# you decide to make an exception for the page in question, you can do so -# by following the "See why" link. -# -############################################################################# - -############################################################################# -# Settings -- Don't change. -############################################################################# -{{settings}} -############################################################################# -for-privoxy-version=3.0.6 - -############################################################################# -# Aliases -############################################################################# -{{alias}} -############################################################################# -# -# You can define a short form for a list of permissions - e.g., instead -# of "-crunch-incoming-cookies -crunch-outgoing-cookies -filter -fast-redirects", -# you can just write "shop". This is called an alias. -# -# Currently, an alias can contain any character except space, tab, '=', '{' -# or '}'. -# But please use only 'a'-'z', '0'-'9', '+', and '-'. -# -# Alias names are not case sensitive. -# -# Aliases beginning with '+' or '-' may be used for system action names -# in future releases - so try to avoid alias names like this. (e.g. -# "+crunch-all-cookies" below is not a good name) -# -# Aliases must be defined before they are used. -# - -# These aliases just save typing later: -# -+crunch-all-cookies = +crunch-incoming-cookies +crunch-outgoing-cookies --crunch-all-cookies = -crunch-incoming-cookies -crunch-outgoing-cookies - allow-all-cookies = -crunch-all-cookies -session-cookies-only - allow-popups = -filter{all-popups} -kill-popups -filter{unsolicited-popups} -+block-as-image = +block +handle-as-image --block-as-image = -block - -# These aliases define combinations of actions -# that are useful for certain types of sites: -# -fragile = -block -crunch-all-cookies -filter -fast-redirects -hide-referer -kill-popups -prevent-compression -shop = -crunch-all-cookies allow-popups - -# Your favourite blend of filters: -# -myfilters = +filter{html-annoyances} +filter{js-annoyances} +filter{all-popups}\ - +filter{webbugs} +filter{nimda} +filter{banners-by-size} #+filter{fun} - -# Allow ads for selected useful free sites: -# -allow-ads = -block -filter{banners-by-size} -filter{banners-by-link} - -############################################################################# -# Defaults -############################################################################# -{ \ --add-header \ --block \ --content-type-overwrite \ --crunch-client-header \ --crunch-if-none-match \ --crunch-outgoing-cookies \ --crunch-incoming-cookies \ --crunch-server-header \ --deanimate-gifs \ --downgrade-http-version \ --fast-redirects \ --filter{js-annoyances} \ --filter{js-events} \ --filter{html-annoyances} \ --filter{content-cookies} \ --filter{refresh-tags} \ --filter{unsolicited-popups} \ --filter{all-popups} \ --filter{img-reorder} \ --filter{banners-by-size} \ --filter{banners-by-link} \ --filter{webbugs} \ --filter{tiny-textforms} \ --filter{jumping-windows} \ --filter{frameset-borders} \ --filter{demoronizer} \ --filter{shockwave-flash} \ --filter{quicktime-kioskmode} \ --filter{fun} \ --filter{crude-parental} \ --filter{ie-exploits} \ --filter{site-specifics} \ --filter{google} \ --filter{yahoo} \ --filter{msn} \ --filter{blogspot} \ --filter{xml-to-html} \ --filter{html-to-xml} \ --filter{no-ping} \ --filter{hide-tor-exit-notation} \ --filter-client-headers \ --filter-server-headers \ --force-text-mode \ --handle-as-empty-document \ --handle-as-image \ --hide-accept-language \ --hide-content-disposition \ --hide-if-modified-since \ -+hide-forwarded-for-headers \ -+hide-from-header{block} \ --hide-referrer \ --hide-user-agent \ --inspect-jpegs \ --kill-popups \ -+limit-connect{1-} \ --prevent-compression \ --overwrite-last-modified \ --redirect \ --send-vanilla-wafer \ --send-wafer \ --session-cookies-only \ -+set-image-blocker{pattern} \ --treat-forbidden-connects-like-blocks \ -} -/ # Match all URLs - -############################################################################# -# These extensions belong to images: -############################################################################# -{+handle-as-image -filter} -############################################################################# -/.*\.(gif|jpe?g|png|bmp|ico)($|\?) - -############################################################################# -# These don't: -############################################################################# -{-handle-as-image} -/.*\.(js|php|css|.?html?) - -############################################################################# -# Generic block patterns by host: -############################################################################# -{+block} -ad*. -.*ads. -.ad. -.*advert*. -*banner*. -count*. -*counter. -promotions. -metrics. - -############################################################################# -# Generic unblockers by host: -############################################################################# -{-block} -adsl. -ad[udmw]*. -adbl*. -adam*. -adapt*. -adob*. -adrenaline. -adtp*. -adv[oia]*. -.*road*. -.olympiad*. -.*load*. -.*[epu]ad*. -county*. -countr*. - -############################################################################# -# Generic block patterns by path: -############################################################################# -{+block} -/(.*/)?ad(\?|/|s|v|_?(image|se?rv|box)|cycle|rotate|mentor|click|f[ra]m|script|stream|fetch|log|space) -/.*ads(new)?/ -/(.*/)?(ad|all|nn|db|promo(tion)?)?[-_]?banner -/(.*/)?(publicite|werbung|reklaa?m|annonse|maino(kset|nta|s)?/) -/.*(count|track|compteur|(?. +# Portions created by the Initial Developer are Copyright (C) 2005 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the terms of +# either the GNU General Public License Version 2 or later (the "GPL"), or +# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** + +use strict; +use warnings; + +=pod + +=head1 NAME + +B - Mac OS X disk image (.dmg) packager + +=head1 SYNOPSIS + +B +B<--source> I +B<--target> I +[B<--format> I] +[B<--volname> I] +[B<--tempdir> I] +[B<--mkdir> I] +[B<--copy> I[:I]] +[B<--symlink> I[:I]] +[B<--license> I] +[B<--resource> I] +[B<--icon> I] +[B<--attribute> I:I[:I...] +[B<--idme>] +[B<--sourcefile>] +[B<--verbosity> I] +[B<--dry-run>] + +=head1 DESCRIPTION + +I takes a directory identified by I and transforms +it into a disk image stored as I. The disk image will +occupy the least space possible for its format, or the least space that the +authors have been able to figure out how to achieve. + +=head1 OPTIONS + +=over 5 + +==item B<--source> I + +Identifies the directory that will be packaged up. This directory is not +touched, a copy will be made in a temporary directory for staging purposes. +See B<--tempdir>. + +==item B<--target> I + +The disk image to create. If it exists and is not in use, it will be +overwritten. If I already contains a suitable extension, +it will be used unmodified. If no extension is present, or the extension +is incorrect for the selected format, the proper extension will be added. +See B<--format>. + +==item B<--format> I + +The format to create the disk image in. Valid values for I are: + - UDZO - zlib-compressed, read-only; extension I<.dmg> + - UDBZ - bzip2-compressed, read-only; extension I<.dmg>; + create and use on 10.4 ("Tiger") and later only + - UDRW - read-write; extension I<.dmg> + - UDSP - read-write, sparse; extension I<.sparseimage> + +UDZO is the default format. + +See L for a description of these formats. + +=item B<--volname> I + +The name of the volume in the disk image. If not specified, I +defaults to the name of the source directory from B<--source>. + +=item B<--tempdir> I + +A temporary directory to stage intermediate files in. I must +have enough space available to accommodate twice the size of the files +being packaged. If not specified, defaults to the same directory that +the I is to be placed in. B will remove any +temporary files it places in I. + +=item B<--mkdir> I + +Specifies a directory that should be created in the disk image. +I and any ancestor directories will be created. This is +useful in conjunction with B<--copy>, when copying files to directories +that may not exist in I. B<--mkdir> may appear multiple +times. + +=item B<--copy> I[:I] + +Additional files to copy into the disk image. If I is +specified, I is copied to the location I identifies, +otherwise, I is copied to the root of the new volume. B<--copy> +provides a way to package up a I by adding files to it +without modifying the original I. B<--copy> may appear +multiple times. + +This option is useful for adding .DS_Store files and window backgrounds +to disk images. + +=item B<--symlink> I[:I] + +Like B<--copy>, but allows symlinks to point out of the volume. Empty symlink +destinations are interpreted as "like the source path, but inside the dmg" + +This option is useful for adding symlinks to external resources, +e.g. to /Applications. + +=item B<--license> I + +A plain text file containing a license agreement to be displayed before +the disk image is mounted. English is the only supported language. To +include license agreements in other languages, in multiple languages, +or to use formatted text, prepare a resource and use L<--resource>. + +=item B<--resource> I + +A resource file to merge into I. If I is UDZO or +UDBZ, the disk image will be flattened to a single-fork file that contains +the resource but may be freely transferred without any special encodings. +I must be in a format suitable for L. See L for a +description of the format, and L for a discussion on flattened +disk images. B<--resource> may appear multiple times. + +This option is useful for adding license agreements and other messages +to disk images. + +=item B<--icon> I + +Specifies an I file that will be used as the icon for the root of +the volume. This file will be copied to the new volume and the custom +icon attribute will be set on the root folder. + +=item B<--attribute> I:I[:I...] + +Sets the attributes of I to the attribute list in I. See +L + +=item B<--idme> + +Enable IDME to make the disk image "Internet-enabled." The first time +the image is mounted, if IDME processing is enabled on the system, the +contents of the image will be copied out of the image and the image will +be placed in the trash with IDME disabled. + +=item B<--sourcefile> + +If this option is present, I is treated as a file, and is +placed as a file within the volume's root folder. Without this option, +I is treated as the volume root itself. + +=item B<--verbosity> I + +Adjusts the level of loudness of B. The possible values for +I are: + 0 - Only error messages are displayed. + 1 - Print error messages and command invocations. + 2 - Print everything, including command output. + +The default I is 2. + +=item B<--dry-run> + +When specified, the commands that would be executed are printed, without +actually executing them. When commands depend on the output of previous +commands, dummy values are displayed. + +=back + +=head1 NON-OPTIONS + +=over 5 + +=item + +Resource forks aren't copied. + +=item + +The root folder of the created volume is designated as the folder +to open when the volume is mounted. See L. + +=item + +All files in the volume are set to be world-readable, only writable +by the owner, and world-executable when appropriate. All other +permissions bits are cleared. + +=item + +When possible, disk images are created without any partition tables. This +is what L refers to as I<-layout NONE>, and saves a handful of +kilobytes. The alternative, I, contains a partition table that +is not terribly handy on disk images that are not intended to represent any +physical disk. + +=item + +Read-write images are created with journaling off. Any read-write image +created by this tool is expected to be transient, and the goal of this tool +is to create images which consume a minimum of space. + +=back + +=head1 EXAMPLE + +pkg-dmg --source /Applications/DeerPark.app --target ~/DeerPark.dmg + --sourcefile --volname DeerPark --icon ~/DeerPark.icns + --mkdir /.background + --copy DeerParkBackground.png:/.background/background.png + --copy DeerParkDSStore:/.DS_Store + --symlink /Applications:"/Drag to here" + +=head1 REQUIREMENTS + +I has been tested with Mac OS X releases 10.2 ("Jaguar") +through 10.4 ("Tiger"). Certain adjustments to behavior are made +depending on the host system's release. Mac OS X 10.3 ("Panther") or +later are recommended. + +=head1 LICENSE + +MPL 1.1/GPL 2.0/LGPL 2.1. Your choice. + +=head1 AUTHOR + +Mark Mentovai + +=head1 SEE ALSO + +L, L, L, L, L, +L, L + +=cut + +use Fcntl; +use POSIX; +use Getopt::Long; + +sub argumentEscape(@); +sub cleanupDie($); +sub command(@); +sub commandInternal($@); +sub commandInternalVerbosity($$@); +sub commandOutput(@); +sub commandOutputVerbosity($@); +sub commandVerbosity($@); +sub copyFiles($@); +sub diskImageMaker($$$$$$$$); +sub giveExtension($$); +sub hdidMountImage($@); +sub isFormatCompressed($); +sub licenseMaker($$); +sub pathSplit($); +sub setAttributes($@); +sub trapSignal($); +sub usage(); + +# Variables used as globals +my(@gCleanup, %gConfig, $gDarwinMajor, $gDryRun, $gVerbosity); + +# Use the commands by name if they're expected to be in the user's +# $PATH (/bin:/sbin:/usr/bin:/usr/sbin). Otherwise, go by absolute +# path. These may be overridden with --config. +%gConfig = ('cmd_bless' => 'bless', + 'cmd_chmod' => 'chmod', + 'cmd_diskutil' => 'diskutil', + 'cmd_du' => 'du', + 'cmd_hdid' => 'hdid', + 'cmd_hdiutil' => 'hdiutil', + 'cmd_mkdir' => 'mkdir', + 'cmd_mktemp' => 'mktemp', + 'cmd_Rez' => '/Developer/Tools/Rez', + 'cmd_rm' => 'rm', + 'cmd_rsync' => 'rsync', + 'cmd_SetFile' => '/Developer/Tools/SetFile', + + # create_directly indicates whether hdiutil create supports + # -srcfolder and -srcdevice. It does on >= 10.3 (Panther). + # This is fixed up for earlier systems below. If false, + # hdiutil create is used to create empty disk images that + # are manually filled. + 'create_directly' => 1, + + # If hdiutil attach -mountpoint exists, use it to avoid + # mounting disk images in the default /Volumes. This reduces + # the likelihood that someone will notice a mounted image and + # interfere with it. Only available on >= 10.3 (Panther), + # fixed up for earlier systems below. + # + # This is presently turned off for all systems, because there + # is an infrequent synchronization problem during ejection. + # diskutil eject might return before the image is actually + # unmounted. If pkg-dmg then attempts to clean up its + # temporary directory, it could remove items from a read-write + # disk image or attempt to remove items from a read-only disk + # image (or a read-only item from a read-write image) and fail, + # causing pkg-dmg to abort. This problem is experienced + # under Tiger, which appears to eject asynchronously where + # previous systems treated it as a synchronous operation. + # Using hdiutil attach -mountpoint didn't always keep images + # from showing up on the desktop anyway. + 'hdiutil_mountpoint' => 0, + + # hdiutil makehybrid results in optimized disk images that + # consume less space and mount more quickly. Use it when + # it's available, but that's only on >= 10.3 (Panther). + # If false, hdiutil create is used instead. Fixed up for + # earlier systems below. + 'makehybrid' => 1, + + # hdiutil create doesn't allow specifying a folder to open + # at volume mount time, so those images are mounted and + # their root folders made holy with bless -openfolder. But + # only on >= 10.3 (Panther). Earlier systems are out of luck. + # Even on Panther, bless refuses to run unless root. + # Fixed up below. + 'openfolder_bless' => 1, + + # It's possible to save a few more kilobytes by including the + # partition only without any partition table in the image. + # This is a good idea on any system, so turn this option off. + # + # Except it's buggy. "-layout NONE" seems to be creating + # disk images with more data than just the partition table + # stripped out. You might wind up losing the end of the + # filesystem - the last file (or several) might be incomplete. + 'partition_table' => 1, + + # To create a partition table-less image from something + # created by makehybrid, the hybrid image needs to be + # mounted and a new image made from the device associated + # with the relevant partition. This requires >= 10.4 + # (Tiger), presumably because earlier systems have + # problems creating images from devices themselves attached + # to images. If this is false, makehybrid images will + # have partition tables, regardless of the partition_table + # setting. Fixed up for earlier systems below. + 'recursive_access' => 1); + +# --verbosity +$gVerbosity = 2; + +# --dry-run +$gDryRun = 0; + +# %gConfig fix-ups based on features and bugs present in certain releases. +my($ignore, $uname_r, $uname_s); +($uname_s, $ignore, $uname_r, $ignore, $ignore) = POSIX::uname(); +if($uname_s eq 'Darwin') { + ($gDarwinMajor, $ignore) = split(/\./, $uname_r, 2); + + # $major is the Darwin major release, which for our purposes, is 4 higher + # than the interesting digit in a Mac OS X release. + if($gDarwinMajor <= 6) { + # <= 10.2 (Jaguar) + # hdiutil create does not support -srcfolder or -srcdevice + $gConfig{'create_directly'} = 0; + # hdiutil attach does not support -mountpoint + $gConfig{'hdiutil_mountpoint'} = 0; + # hdiutil mkhybrid does not exist + $gConfig{'makehybrid'} = 0; + } + if($gDarwinMajor <= 7) { + # <= 10.3 (Panther) + # Can't mount a disk image and then make a disk image from the device + $gConfig{'recursive_access'} = 0; + # bless does not support -openfolder on 10.2 (Jaguar) and must run + # as root under 10.3 (Panther) + $gConfig{'openfolder_bless'} = 0; + } +} +else { + # If it's not Mac OS X, just assume all of those good features are + # available. They're not, but things will fail long before they + # have a chance to make a difference. + # + # Now, if someone wanted to document some of these private formats... + print STDERR ($0.": warning, not running on Mac OS X, ". + "this could be interesting.\n"); +} + +# Non-global variables used in Getopt +my(@attributes, @copyFiles, @createSymlinks, $iconFile, $idme, $licenseFile, + @makeDirs, $outputFormat, @resourceFiles, $sourceFile, $sourceFolder, + $targetImage, $tempDir, $volumeName); + +# --format +$outputFormat = 'UDZO'; + +# --idme +$idme = 0; + +# --sourcefile +$sourceFile = 0; + +# Leaving this might screw up the Apple tools. +delete $ENV{'NEXT_ROOT'}; + +# This script can get pretty messy, so trap a few signals. +$SIG{'INT'} = \&trapSignal; +$SIG{'HUP'} = \&trapSignal; +$SIG{'TERM'} = \&trapSignal; + +Getopt::Long::Configure('pass_through'); +GetOptions('source=s' => \$sourceFolder, + 'target=s' => \$targetImage, + 'volname=s' => \$volumeName, + 'format=s' => \$outputFormat, + 'tempdir=s' => \$tempDir, + 'mkdir=s' => \@makeDirs, + 'copy=s' => \@copyFiles, + 'symlink=s' => \@createSymlinks, + 'license=s' => \$licenseFile, + 'resource=s' => \@resourceFiles, + 'icon=s' => \$iconFile, + 'attribute=s' => \@attributes, + 'idme' => \$idme, + 'sourcefile' => \$sourceFile, + 'verbosity=i' => \$gVerbosity, + 'dry-run' => \$gDryRun, + 'config=s' => \%gConfig); # "hidden" option not in usage() + +if(@ARGV) { + # All arguments are parsed by Getopt + usage(); + exit(1); +} + +if($gVerbosity<0 || $gVerbosity>2) { + usage(); + exit(1); +} + +if(!defined($sourceFolder) || $sourceFolder eq '' || + !defined($targetImage) || $targetImage eq '') { + # --source and --target are required arguments + usage(); + exit(1); +} + +# Make sure $sourceFolder doesn't contain trailing slashes. It messes with +# rsync. +while(substr($sourceFolder, -1) eq '/') { + chop($sourceFolder); +} + +if(!defined($volumeName)) { + # Default volumeName is the name of the source directory. + my(@components); + @components = pathSplit($sourceFolder); + $volumeName = pop(@components); +} + +my(@tempDirComponents, $targetImageFilename); +@tempDirComponents = pathSplit($targetImage); +$targetImageFilename = pop(@tempDirComponents); + +if(defined($tempDir)) { + @tempDirComponents = pathSplit($tempDir); +} +else { + # Default tempDir is the same directory as what is specified for + # targetImage + $tempDir = join('/', @tempDirComponents); +} + +# Ensure that the path of the target image has a suitable extension. If +# it didn't, hdiutil would add one, and we wouldn't be able to find the +# file. +# +# Note that $targetImageFilename is not being reset. This is because it's +# used to build other names below, and we don't need to be adding all sorts +# of extra unnecessary extensions to the name. +my($originalTargetImage, $requiredExtension); +$originalTargetImage = $targetImage; +if($outputFormat eq 'UDSP') { + $requiredExtension = '.sparseimage'; +} +else { + $requiredExtension = '.dmg'; +} +$targetImage = giveExtension($originalTargetImage, $requiredExtension); + +if($targetImage ne $originalTargetImage) { + print STDERR ($0.": warning: target image extension is being added\n"); + print STDERR (' The new filename is '. + giveExtension($targetImageFilename,$requiredExtension)."\n"); +} + +# Make a temporary directory in $tempDir for our own nefarious purposes. +my(@output, $tempSubdir, $tempSubdirTemplate); +$tempSubdirTemplate=join('/', @tempDirComponents, + 'pkg-dmg.'.$$.'.XXXXXXXX'); +if(!(@output = commandOutput($gConfig{'cmd_mktemp'}, '-d', + $tempSubdirTemplate)) || $#output != 0) { + cleanupDie('mktemp failed'); +} + +if($gDryRun) { + (@output)=($tempSubdirTemplate); +} + +($tempSubdir) = @output; + +push(@gCleanup, + sub {commandVerbosity(0, $gConfig{'cmd_rm'}, '-rf', $tempSubdir);}); + +my($tempMount, $tempRoot, @tempsToMake); +$tempRoot = $tempSubdir.'/stage'; +$tempMount = $tempSubdir.'/mount'; +push(@tempsToMake, $tempRoot); +if($gConfig{'hdiutil_mountpoint'}) { + push(@tempsToMake, $tempMount); +} + +if(command($gConfig{'cmd_mkdir'}, @tempsToMake) != 0) { + cleanupDie('mkdir tempRoot/tempMount failed'); +} + +# This cleanup object is not strictly necessary, because $tempRoot is inside +# of $tempSubdir, but the rest of the script relies on this object being +# on the cleanup stack and expects to remove it. +push(@gCleanup, + sub {commandVerbosity(0, $gConfig{'cmd_rm'}, '-rf', $tempRoot);}); + +# If $sourceFile is true, it means that $sourceFolder is to be treated as +# a file and placed as a file within the volume root, as opposed to being +# treated as the volume root itself. rsync will do this by default, if no +# trailing '/' is present. With a trailing '/', $sourceFolder becomes +# $tempRoot, instead of becoming an entry in $tempRoot. +if(command($gConfig{'cmd_rsync'}, '-a', '--copy-unsafe-links', + $sourceFolder.($sourceFile?'':'/'),$tempRoot) != 0) { + cleanupDie('rsync failed'); +} + +if(@makeDirs) { + my($makeDir, @tempDirsToMake); + foreach $makeDir (@makeDirs) { + if($makeDir =~ /^\//) { + push(@tempDirsToMake, $tempRoot.$makeDir); + } + else { + push(@tempDirsToMake, $tempRoot.'/'.$makeDir); + } + } + if(command($gConfig{'cmd_mkdir'}, '-p', @tempDirsToMake) != 0) { + cleanupDie('mkdir failed'); + } +} + +# copy files and/or create symlinks +copyFiles($tempRoot, 'copy', @copyFiles); +copyFiles($tempRoot, 'symlink', @createSymlinks); + +if($gConfig{'create_directly'}) { + # If create_directly is false, the contents will be rsynced into a + # disk image and they would lose their attributes. + setAttributes($tempRoot, @attributes); +} + +if(defined($iconFile)) { + if(command($gConfig{'cmd_rsync'}, '-a', '--copy-unsafe-links', $iconFile, + $tempRoot.'/.VolumeIcon.icns') != 0) { + cleanupDie('rsync failed for volume icon'); + } + + # It's pointless to set the attributes of the root when diskutil create + # -srcfolder is being used. In that case, the attributes will be set + # later, after the image is already created. + if(isFormatCompressed($outputFormat) && + (command($gConfig{'cmd_SetFile'}, '-a', 'C', $tempRoot) != 0)) { + cleanupDie('SetFile failed'); + } +} + +if(command($gConfig{'cmd_chmod'}, '-R', 'a+rX,a-st,u+w,go-w', + $tempRoot) != 0) { + cleanupDie('chmod failed'); +} + +my($unflattenable); +if(isFormatCompressed($outputFormat)) { + $unflattenable = 1; +} +else { + $unflattenable = 0; +} + +diskImageMaker($tempRoot, $targetImage, $outputFormat, $volumeName, + $tempSubdir, $tempMount, $targetImageFilename, defined($iconFile)); + +if(defined($licenseFile) && $licenseFile ne '') { + my($licenseResource); + $licenseResource = $tempSubdir.'/license.r'; + if(!licenseMaker($licenseFile, $licenseResource)) { + cleanupDie('licenseMaker failed'); + } + push(@resourceFiles, $licenseResource); + # Don't add a cleanup object because licenseResource is in tempSubdir. +} + +if(@resourceFiles) { + # Add resources, such as a license agreement. + + # Only unflatten read-only and compressed images. It's not supported + # on other image times. + if($unflattenable && + (command($gConfig{'cmd_hdiutil'}, 'unflatten', $targetImage)) != 0) { + cleanupDie('hdiutil unflatten failed'); + } + # Don't push flatten onto the cleanup stack. If we fail now, we'll be + # removing $targetImage anyway. + + # Type definitions come from Carbon.r. + if(command($gConfig{'cmd_Rez'}, 'Carbon.r', @resourceFiles, '-a', '-o', + $targetImage) != 0) { + cleanupDie('Rez failed'); + } + + # Flatten. This merges the resource fork into the data fork, so no + # special encoding is needed to transfer the file. + if($unflattenable && + (command($gConfig{'cmd_hdiutil'}, 'flatten', $targetImage)) != 0) { + cleanupDie('hdiutil flatten failed'); + } +} + +# $tempSubdir is no longer needed. It's buried on the stack below the +# rm of the fresh image file. Splice in this fashion is equivalent to +# pop-save, pop, push-save. +splice(@gCleanup, -2, 1); +# No need to remove licenseResource separately, it's in tempSubdir. +if(command($gConfig{'cmd_rm'}, '-rf', $tempSubdir) != 0) { + cleanupDie('rm -rf tempSubdir failed'); +} + +if($idme) { + if(command($gConfig{'cmd_hdiutil'}, 'internet-enable', '-yes', + $targetImage) != 0) { + cleanupDie('hdiutil internet-enable failed'); + } +} + +# Done. + +exit(0); + +# argumentEscape(@arguments) +# +# Takes a list of @arguments and makes them shell-safe. +sub argumentEscape(@) { + my(@arguments); + @arguments = @_; + my($argument, @argumentsOut); + foreach $argument (@arguments) { + $argument =~ s%([^A-Za-z0-9_\-/.=+,])%\\$1%g; + push(@argumentsOut, $argument); + } + return @argumentsOut; +} + +# cleanupDie($message) +# +# Displays $message as an error message, and then runs through the +# @gCleanup stack, performing any cleanup operations needed before +# exiting. Does not return, exits with exit status 1. +sub cleanupDie($) { + my($message); + ($message) = @_; + print STDERR ($0.': '.$message.(@gCleanup?' (cleaning up)':'')."\n"); + while(@gCleanup) { + my($subroutine); + $subroutine = pop(@gCleanup); + &$subroutine; + } + exit(1); +} + +# command(@arguments) +# +# Runs the specified command at the verbosity level defined by $gVerbosity. +# Returns nonzero on failure, returning the exit status if appropriate. +# Discards command output. +sub command(@) { + my(@arguments); + @arguments = @_; + return commandVerbosity($gVerbosity,@arguments); +} + +# commandInternal($command, @arguments) +# +# Runs the specified internal command at the verbosity level defined by +# $gVerbosity. +# Returns zero(!) on failure, because commandInternal is supposed to be a +# direct replacement for the Perl system call wrappers, which, unlike shell +# commands and C equivalent system calls, return true (instead of 0) to +# indicate success. +sub commandInternal($@) { + my(@arguments, $command); + ($command, @arguments) = @_; + return commandInternalVerbosity($gVerbosity, $command, @arguments); +} + +# commandInternalVerbosity($verbosity, $command, @arguments) +# +# Run an internal command, printing a bogus command invocation message if +# $verbosity is true. +# +# If $command is unlink: +# Removes the files specified by @arguments. Wraps unlink. +# +# If $command is symlink: +# Creates the symlink specified by @arguments. Wraps symlink. +sub commandInternalVerbosity($$@) { + my(@arguments, $command, $verbosity); + ($verbosity, $command, @arguments) = @_; + if($command eq 'unlink') { + if($verbosity || $gDryRun) { + print(join(' ', 'rm', '-f', argumentEscape(@arguments))."\n"); + } + if($gDryRun) { + return $#arguments+1; + } + return unlink(@arguments); + } + elsif($command eq 'symlink') { + if($verbosity || $gDryRun) { + print(join(' ', 'ln', '-s', argumentEscape(@arguments))."\n"); + } + if($gDryRun) { + return 1; + } + my($source, $target); + ($source, $target) = @arguments; + return symlink($source, $target); + } +} + +# commandOutput(@arguments) +# +# Runs the specified command at the verbosity level defined by $gVerbosity. +# Output is returned in an array of lines. undef is returned on failure. +# The exit status is available in $?. +sub commandOutput(@) { + my(@arguments); + @arguments = @_; + return commandOutputVerbosity($gVerbosity, @arguments); +} + +# commandOutputVerbosity($verbosity, @arguments) +# +# Runs the specified command at the verbosity level defined by the +# $verbosity argument. Output is returned in an array of lines. undef is +# returned on failure. The exit status is available in $?. +# +# If an error occurs in fork or exec, an error message is printed to +# stderr and undef is returned. +# +# If $verbosity is 0, the command invocation is not printed, and its +# stdout is not echoed back to stdout. +# +# If $verbosity is 1, the command invocation is printed. +# +# If $verbosity is 2, the command invocation is printed and the output +# from stdout is echoed back to stdout. +# +# Regardless of $verbosity, stderr is left connected. +sub commandOutputVerbosity($@) { + my(@arguments, $verbosity); + ($verbosity, @arguments) = @_; + my($pid); + if($verbosity || $gDryRun) { + print(join(' ', argumentEscape(@arguments))."\n"); + } + if($gDryRun) { + return(1); + } + if (!defined($pid = open(*COMMAND, '-|'))) { + printf STDERR ($0.': fork: '.$!."\n"); + return undef; + } + elsif ($pid) { + # parent + my(@lines); + while(!eof(*COMMAND)) { + my($line); + chop($line = ); + if($verbosity > 1) { + print($line."\n"); + } + push(@lines, $line); + } + close(*COMMAND); + if ($? == -1) { + printf STDERR ($0.': fork: '.$!."\n"); + return undef; + } + elsif ($? & 127) { + printf STDERR ($0.': exited on signal '.($? & 127). + ($? & 128 ? ', core dumped' : '')."\n"); + return undef; + } + return @lines; + } + else { + # child; this form of exec is immune to shell games + if(!exec {$arguments[0]} (@arguments)) { + printf STDERR ($0.': exec: '.$!."\n"); + exit(-1); + } + } +} + +# commandVerbosity($verbosity, @arguments) +# +# Runs the specified command at the verbosity level defined by the +# $verbosity argument. Returns nonzero on failure, returning the exit +# status if appropriate. Discards command output. +sub commandVerbosity($@) { + my(@arguments, $verbosity); + ($verbosity, @arguments) = @_; + if(!defined(commandOutputVerbosity($verbosity, @arguments))) { + return -1; + } + return $?; +} + +# copyFiles($tempRoot, $method, @arguments) +# +# Copies files or create symlinks in the disk image. +# See --copy and --symlink descriptions for details. +# If $method is 'copy', @arguments are interpreted as source:target, if $method +# is 'symlink', @arguments are interpreted as symlink:target. +sub copyFiles($@) { + my(@fileList, $method, $tempRoot); + ($tempRoot, $method, @fileList) = @_; + my($file, $isSymlink); + $isSymlink = ($method eq 'symlink'); + foreach $file (@fileList) { + my($source, $target); + ($source, $target) = split(/:/, $file); + if(!defined($target) and $isSymlink) { + # empty symlink targets would result in an invalid target and fail, + # but they shall be interpreted as "like source path, but inside dmg" + $target = $source; + } + if(!defined($target)) { + $target = $tempRoot; + } + elsif($target =~ /^\//) { + $target = $tempRoot.$target; + } + else { + $target = $tempRoot.'/'.$target; + } + + my($success); + if($isSymlink) { + $success = commandInternal('symlink', $source, $target); + } + else { + $success = !command($gConfig{'cmd_rsync'}, '-a', '--copy-unsafe-links', + $source, $target); + } + if(!$success) { + cleanupDie('copyFiles failed for method '.$method); + } + } +} + +# diskImageMaker($source, $destination, $format, $name, $tempDir, $tempMount, +# $baseName, $setRootIcon) +# +# Creates a disk image in $destination of format $format corresponding to the +# source directory $source. $name is the volume name. $tempDir is a good +# place to write temporary files, which should be empty (aside from the other +# things that this script might create there, like stage and mount). +# $tempMount is a mount point for temporary disk images. $baseName is the +# name of the disk image, and is presently unused. $setRootIcon is true if +# a volume icon was added to the staged $source and indicates that the +# custom volume icon bit on the volume root needs to be set. +sub diskImageMaker($$$$$$$$) { + my($baseName, $destination, $format, $name, $setRootIcon, $source, + $tempDir, $tempMount); + ($source, $destination, $format, $name, $tempDir, $tempMount, + $baseName, $setRootIcon) = @_; + if(isFormatCompressed($format)) { + my($uncompressedImage); + + if($gConfig{'makehybrid'}) { + my($hybridImage); + $hybridImage = giveExtension($tempDir.'/hybrid', '.dmg'); + + if(command($gConfig{'cmd_hdiutil'}, 'makehybrid', '-hfs', + '-hfs-volume-name', $name, '-hfs-openfolder', $source, '-ov', + $source, '-o', $hybridImage) != 0) { + cleanupDie('hdiutil makehybrid failed'); + } + + $uncompressedImage = $hybridImage; + + # $source is no longer needed and will be removed before anything + # else can fail. splice in this form is the same as pop/push. + splice(@gCleanup, -1, 1, + sub {commandInternalVerbosity(0, 'unlink', $hybridImage);}); + + if(command($gConfig{'cmd_rm'}, '-rf', $source) != 0) { + cleanupDie('rm -rf failed'); + } + + if(!$gConfig{'partition_table'} && $gConfig{'recursive_access'}) { + # Even if we do want to create disk images without partition tables, + # it's impossible unless recursive_access is set. + my($rootDevice, $partitionDevice, $partitionMountPoint); + + if(!(($rootDevice, $partitionDevice, $partitionMountPoint) = + hdidMountImage($tempMount, '-readonly', $hybridImage))) { + cleanupDie('hdid mount failed'); + } + + push(@gCleanup, sub {commandVerbosity(0, + $gConfig{'cmd_diskutil'}, 'eject', $rootDevice);}); + + my($udrwImage); + $udrwImage = giveExtension($tempDir.'/udrw', '.dmg'); + + if(command($gConfig{'cmd_hdiutil'}, 'create', '-format', 'UDRW', + '-ov', '-srcdevice', $partitionDevice, $udrwImage) != 0) { + cleanupDie('hdiutil create failed'); + } + + $uncompressedImage = $udrwImage; + + # Going to eject before anything else can fail. Get the eject off + # the stack. + pop(@gCleanup); + + # $hybridImage will be removed soon, but until then, it needs to + # stay on the cleanup stack. It needs to wait until after + # ejection. $udrwImage is staying around. Make it appear as + # though it's been done before $hybridImage. + # + # splice in this form is the same as popping one element to + # @tempCleanup and pushing the subroutine. + my(@tempCleanup); + @tempCleanup = splice(@gCleanup, -1, 1, + sub {commandInternalVerbosity(0, 'unlink', $udrwImage);}); + push(@gCleanup, @tempCleanup); + + if(command($gConfig{'cmd_diskutil'}, 'eject', $rootDevice) != 0) { + cleanupDie('diskutil eject failed'); + } + + # Pop unlink of $uncompressedImage + pop(@gCleanup); + + if(commandInternal('unlink', $hybridImage) != 1) { + cleanupDie('unlink hybridImage failed: '.$!); + } + } + } + else { + # makehybrid is not available, fall back to making a UDRW and + # converting to a compressed image. It ought to be possible to + # create a compressed image directly, but those come out far too + # large (journaling?) and need to be read-write to fix up the + # volume icon anyway. Luckily, we can take advantage of a single + # call back into this function. + my($udrwImage); + $udrwImage = giveExtension($tempDir.'/udrw', '.dmg'); + + diskImageMaker($source, $udrwImage, 'UDRW', $name, $tempDir, + $tempMount, $baseName, $setRootIcon); + + # The call back into diskImageMaker already removed $source. + + $uncompressedImage = $udrwImage; + } + + # The uncompressed disk image is now in its final form. Compress it. + # Jaguar doesn't support hdiutil convert -ov, but it always allows + # overwriting. + # bzip2-compressed UDBZ images can only be created and mounted on 10.4 + # and later. The bzip2-level imagekey is only effective when creating + # images in 10.5. In 10.4, bzip2-level is harmlessly ignored, and the + # default value of 1 is always used. + if(command($gConfig{'cmd_hdiutil'}, 'convert', '-format', $format, + '-imagekey', ($format eq 'UDBZ' ? 'bzip2-level=9' : 'zlib-level=9'), + (defined($gDarwinMajor) && $gDarwinMajor <= 6 ? () : ('-ov')), + $uncompressedImage, '-o', $destination) != 0) { + cleanupDie('hdiutil convert failed'); + } + + # $uncompressedImage is going to be unlinked before anything else can + # fail. splice in this form is the same as pop/push. + splice(@gCleanup, -1, 1, + sub {commandInternalVerbosity(0, 'unlink', $destination);}); + + if(commandInternal('unlink', $uncompressedImage) != 1) { + cleanupDie('unlink uncompressedImage failed: '.$!); + } + + # At this point, the only thing that the compressed block has added to + # the cleanup stack is the removal of $destination. $source has already + # been removed, and its cleanup entry has been removed as well. + } + elsif($format eq 'UDRW' || $format eq 'UDSP') { + my(@extraArguments); + if(!$gConfig{'partition_table'}) { + @extraArguments = ('-layout', 'NONE'); + } + + if($gConfig{'create_directly'}) { + # Use -fs HFS+ to suppress the journal. + if(command($gConfig{'cmd_hdiutil'}, 'create', '-format', $format, + @extraArguments, '-fs', 'HFS+', '-volname', $name, + '-ov', '-srcfolder', $source, $destination) != 0) { + cleanupDie('hdiutil create failed'); + } + + # $source is no longer needed and will be removed before anything + # else can fail. splice in this form is the same as pop/push. + splice(@gCleanup, -1, 1, + sub {commandInternalVerbosity(0, 'unlink', $destination);}); + + if(command($gConfig{'cmd_rm'}, '-rf', $source) != 0) { + cleanupDie('rm -rf failed'); + } + } + else { + # hdiutil create does not support -srcfolder or -srcdevice, it only + # knows how to create blank images. Figure out how large an image + # is needed, create it, and fill it. This is needed for Jaguar. + + # Use native block size for hdiutil create -sectors. + delete $ENV{'BLOCKSIZE'}; + + my(@duOutput, $ignore, $sizeBlocks, $sizeOverhead, $sizeTotal, $type); + if(!(@output = commandOutput($gConfig{'cmd_du'}, '-s', $tempRoot)) || + $? != 0) { + cleanupDie('du failed'); + } + ($sizeBlocks, $ignore) = split(' ', $output[0], 2); + + # The filesystem itself takes up 152 blocks of its own blocks for the + # filesystem up to 8192 blocks, plus 64 blocks for every additional + # 4096 blocks or portion thereof. + $sizeOverhead = 152 + 64 * POSIX::ceil( + (($sizeBlocks - 8192) > 0) ? (($sizeBlocks - 8192) / (4096 - 64)) : 0); + + # The number of blocks must be divisible by 8. + my($mod); + if($mod = ($sizeOverhead % 8)) { + $sizeOverhead += 8 - $mod; + } + + # sectors is taken as the size of a disk, not a filesystem, so the + # partition table eats into it. + if($gConfig{'partition_table'}) { + $sizeOverhead += 80; + } + + # That was hard. Leave some breathing room anyway. Use 1024 sectors + # (512kB). These read-write images wouldn't be useful if they didn't + # have at least a little free space. + $sizeTotal = $sizeBlocks + $sizeOverhead + 1024; + + # Minimum sizes - these numbers are larger on Jaguar than on later + # systems. Just use the Jaguar numbers, since it's unlikely to wind + # up here on any other release. + if($gConfig{'partition_table'} && $sizeTotal < 8272) { + $sizeTotal = 8272; + } + if(!$gConfig{'partition_table'} && $sizeTotal < 8192) { + $sizeTotal = 8192; + } + + # hdiutil create without -srcfolder or -srcdevice will not accept + # -format. It uses -type. Fortunately, the two supported formats + # here map directly to the only two supported types. + if ($format eq 'UDSP') { + $type = 'SPARSE'; + } + else { + $type = 'UDIF'; + } + + if(command($gConfig{'cmd_hdiutil'}, 'create', '-type', $type, + @extraArguments, '-fs', 'HFS+', '-volname', $name, + '-ov', '-sectors', $sizeTotal, $destination) != 0) { + cleanupDie('hdiutil create failed'); + } + + push(@gCleanup, + sub {commandInternalVerbosity(0, 'unlink', $destination);}); + + # The rsync will occur shortly. + } + + my($mounted, $rootDevice, $partitionDevice, $partitionMountPoint); + + $mounted=0; + if(!$gConfig{'create_directly'} || $gConfig{'openfolder_bless'} || + $setRootIcon) { + # The disk image only needs to be mounted if: + # create_directly is false, because the content needs to be copied + # openfolder_bless is true, because bless -openfolder needs to run + # setRootIcon is true, because the root needs its attributes set. + if(!(($rootDevice, $partitionDevice, $partitionMountPoint) = + hdidMountImage($tempMount, $destination))) { + cleanupDie('hdid mount failed'); + } + + $mounted=1; + + push(@gCleanup, sub {commandVerbosity(0, + $gConfig{'cmd_diskutil'}, 'eject', $rootDevice);}); + } + + if(!$gConfig{'create_directly'}) { + # Couldn't create and copy directly in one fell swoop. Now that + # the volume is mounted, copy the files. --copy-unsafe-links is + # unnecessary since it was used to copy everything to the staging + # area. There can be no more unsafe links. + if(command($gConfig{'cmd_rsync'}, '-a', + $source.'/',$partitionMountPoint) != 0) { + cleanupDie('rsync to new volume failed'); + } + + # We need to get the rm -rf of $source off the stack, because it's + # being cleaned up here. There are two items now on top of it: + # removing the target image and, above that, ejecting it. Splice it + # out. + my(@tempCleanup); + @tempCleanup = splice(@gCleanup, -2); + # The next splice is the same as popping once and pushing @tempCleanup. + splice(@gCleanup, -1, 1, @tempCleanup); + + if(command($gConfig{'cmd_rm'}, '-rf', $source) != 0) { + cleanupDie('rm -rf failed'); + } + } + + if($gConfig{'openfolder_bless'}) { + # On Tiger, the bless docs say to use --openfolder, but only + # --openfolder is accepted on Panther. Tiger takes it with a single + # dash too. Jaguar is out of luck. + if(command($gConfig{'cmd_bless'}, '-openfolder', + $partitionMountPoint) != 0) { + cleanupDie('bless failed'); + } + } + + setAttributes($partitionMountPoint, @attributes); + + if($setRootIcon) { + # When "hdiutil create -srcfolder" is used, the root folder's + # attributes are not copied to the new volume. Fix up. + + if(command($gConfig{'cmd_SetFile'}, '-a', 'C', + $partitionMountPoint) != 0) { + cleanupDie('SetFile failed'); + } + } + + if($mounted) { + # Pop diskutil eject + pop(@gCleanup); + + if(command($gConfig{'cmd_diskutil'}, 'eject', $rootDevice) != 0) { + cleanupDie('diskutil eject failed'); + } + } + + # End of UDRW/UDSP section. At this point, $source has been removed + # and its cleanup entry has been removed from the stack. + } + else { + cleanupDie('unrecognized format'); + print STDERR ($0.": unrecognized format\n"); + exit(1); + } +} + +# giveExtension($file, $extension) +# +# If $file does not end in $extension, $extension is added. The new +# filename is returned. +sub giveExtension($$) { + my($extension, $file); + ($file, $extension) = @_; + if(substr($file, -length($extension)) ne $extension) { + return $file.$extension; + } + return $file; +} + +# hdidMountImage($mountPoint, @arguments) +# +# Runs the hdid command with arguments specified by @arguments. +# @arguments may be a single-element array containing the name of the +# disk image to mount. Returns a three-element array, with elements +# corresponding to: +# - The root device of the mounted image, suitable for ejection +# - The device corresponding to the mounted partition +# - The mounted partition's mount point +# +# If running on a system that supports easy mounting at points outside +# of the default /Volumes with hdiutil attach, it is used instead of hdid, +# and $mountPoint is used as the mount point. +# +# The root device will differ from the partition device when the disk +# image contains a partition table, otherwise, they will be identical. +# +# If hdid fails, undef is returned. +sub hdidMountImage($@) { + my(@arguments, @command, $mountPoint); + ($mountPoint, @arguments) = @_; + my(@output); + + if($gConfig{'hdiutil_mountpoint'}) { + @command=($gConfig{'cmd_hdiutil'}, 'attach', @arguments, + '-mountpoint', $mountPoint); + } + else { + @command=($gConfig{'cmd_hdid'}, @arguments); + } + + if(!(@output = commandOutput(@command)) || + $? != 0) { + return undef; + } + + if($gDryRun) { + return('/dev/diskX','/dev/diskXsY','/Volumes/'.$volumeName); + } + + my($line, $restOfLine, $rootDevice); + + foreach $line (@output) { + my($device, $mountpoint); + if($line !~ /^\/dev\//) { + # Consider only lines that correspond to /dev entries + next; + } + ($device, $restOfLine) = split(' ', $line, 2); + + if(!defined($rootDevice) || $rootDevice eq '') { + # If this is the first device seen, it's the root device to be + # used for ejection. Keep it. + $rootDevice = $device; + } + + if($restOfLine =~ /(\/.*)/) { + # The first partition with a mount point is the interesting one. It's + # usually Apple_HFS and usually the last one in the list, but beware of + # the possibility of other filesystem types and the Apple_Free partition. + # If the disk image contains no partition table, the partition will not + # have a type, so look for the mount point by looking for a slash. + $mountpoint = $1; + return($rootDevice, $device, $mountpoint); + } + } + + # No mount point? This is bad. If there's a root device, eject it. + if(defined($rootDevice) && $rootDevice ne '') { + # Failing anyway, so don't care about failure + commandVerbosity(0, $gConfig{'cmd_diskutil'}, 'eject', $rootDevice); + } + + return undef; +} + +# isFormatCompressed($format) +# +# Returns true if $format corresponds to a compressed disk image format. +# Returns false otherwise. +sub isFormatCompressed($) { + my($format); + ($format) = @_; + return $format eq 'UDZO' || $format eq 'UDBZ'; +} + +# licenseMaker($text, $resource) +# +# Takes a plain text file at path $text and creates a license agreement +# resource containing the text at path $license. English-only, and +# no special formatting. This is the bare-bones stuff. For more +# intricate license agreements, create your own resource. +# +# ftp://ftp.apple.com/developer/Development_Kits/SLAs_for_UDIFs_1.0.dmg +sub licenseMaker($$) { + my($resource, $text); + ($text, $resource) = @_; + if(!sysopen(*TEXT, $text, O_RDONLY)) { + print STDERR ($0.': licenseMaker: sysopen text: '.$!."\n"); + return 0; + } + if(!sysopen(*RESOURCE, $resource, O_WRONLY|O_CREAT|O_EXCL)) { + print STDERR ($0.': licenseMaker: sysopen resource: '.$!."\n"); + return 0; + } + print RESOURCE << '__EOT__'; +// See /System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/Script.h for language IDs. +data 'LPic' (5000) { + // Default language ID, 0 = English + $"0000" + // Number of entries in list + $"0001" + + // Entry 1 + // Language ID, 0 = English + $"0000" + // Resource ID, 0 = STR#/TEXT/styl 5000 + $"0000" + // Multibyte language, 0 = no + $"0000" +}; + +resource 'STR#' (5000, "English") { + { + // Language (unused?) = English + "English", + // Agree + "Agree", + // Disagree + "Disagree", +__EOT__ + # This stuff needs double-quotes for interpolations to work. + print RESOURCE (" // Print, ellipsis is 0xC9\n"); + print RESOURCE (" \"Print\xc9\",\n"); + print RESOURCE (" // Save As, ellipsis is 0xC9\n"); + print RESOURCE (" \"Save As\xc9\",\n"); + print RESOURCE (' // Descriptive text, curly quotes are 0xD2 and 0xD3'. + "\n"); + print RESOURCE (' "If you agree to the terms of this license '. + "agreement, click \xd2Agree\xd3 to access the software. If you ". + "do not agree, press \xd2Disagree.\xd3\"\n"); +print RESOURCE << '__EOT__'; + }; +}; + +// Beware of 1024(?) byte (character?) line length limitation. Split up long +// lines. +// If straight quotes are used ("), remember to escape them (\"). +// Newline is \n, to leave a blank line, use two of them. +// 0xD2 and 0xD3 are curly double-quotes ("), 0xD4 and 0xD5 are curly +// single quotes ('), 0xD5 is also the apostrophe. +data 'TEXT' (5000, "English") { +__EOT__ + + while(!eof(*TEXT)) { + my($line); + chop($line = ); + + while(defined($line)) { + my($chunk); + + # Rez doesn't care for lines longer than (1024?) characters. Split + # at less than half of that limit, in case everything needs to be + # backwhacked. + if(length($line)>500) { + $chunk = substr($line, 0, 500); + $line = substr($line, 500); + } + else { + $chunk = $line; + $line = undef; + } + + if(length($chunk) > 0) { + # Unsafe characters are the double-quote (") and backslash (\), escape + # them with backslashes. + $chunk =~ s/(["\\])/\\$1/g; + + print RESOURCE ' "'.$chunk.'"'."\n"; + } + } + print RESOURCE ' "\n"'."\n"; + } + close(*TEXT); + + print RESOURCE << '__EOT__'; +}; + +data 'styl' (5000, "English") { + // Number of styles following = 1 + $"0001" + + // Style 1. This is used to display the first two lines in bold text. + // Start character = 0 + $"0000 0000" + // Height = 16 + $"0010" + // Ascent = 12 + $"000C" + // Font family = 1024 (Lucida Grande) + $"0400" + // Style bitfield, 0x1=bold 0x2=italic 0x4=underline 0x8=outline + // 0x10=shadow 0x20=condensed 0x40=extended + $"00" + // Style, unused? + $"02" + // Size = 12 point + $"000C" + // Color, RGB + $"0000 0000 0000" +}; +__EOT__ + close(*RESOURCE); + + return 1; +} + +# pathSplit($pathname) +# +# Splits $pathname into an array of path components. +sub pathSplit($) { + my($pathname); + ($pathname) = @_; + return split(/\//, $pathname); +} + +# setAttributes($root, @attributeList) +# +# @attributeList is an array, each element of which must be in the form +# :. is a list of attributes, per SetFile. is a file +# which is taken as relative to $root (even if it appears as an absolute +# path.) SetFile is called to set the attributes on each file in +# @attributeList. +sub setAttributes($@) { + my(@attributes, $root); + ($root, @attributes) = @_; + my($attribute); + foreach $attribute (@attributes) { + my($attrList, $file, @fileList, @fixedFileList); + ($attrList, @fileList) = split(/:/, $attribute); + if(!defined($attrList) || !@fileList) { + cleanupDie('--attribute requires :'); + } + @fixedFileList=(); + foreach $file (@fileList) { + if($file =~ /^\//) { + push(@fixedFileList, $root.$file); + } + else { + push(@fixedFileList, $root.'/'.$file); + } + } + if(command($gConfig{'cmd_SetFile'}, '-a', $attrList, @fixedFileList)) { + cleanupDie('SetFile failed to set attributes'); + } + } + return; +} + +sub trapSignal($) { + my($signalName); + ($signalName) = @_; + cleanupDie('exiting on SIG'.$signalName); +} + +sub usage() { + print STDERR ( +"usage: pkg-dmg --source \n". +" --target \n". +" [--format ] (default: UDZO)\n". +" [--volname ] (default: same name as source)\n". +" [--tempdir ] (default: same dir as target)\n". +" [--mkdir ] (make directory in image)\n". +" [--copy [:]] (extra files to add)\n". +" [--symlink [:]] (extra symlinks to add)\n". +" [--license ] (plain text license agreement)\n". +" [--resource ] (flat .r files to merge)\n". +" [--icon ] (volume icon)\n". +" [--attribute :] (set file attributes)\n". +" [--idme] (make Internet-enabled image)\n". +" [--sourcefile] (treat --source as a file)\n". +" [--verbosity ] (0, 1, 2; default=2)\n". +" [--dry-run] (print what would be done)\n"); + return; +} diff -Nru vidalia-0.1.13/pkg/osx/polipo.conf vidalia-0.2.8/pkg/osx/polipo.conf --- vidalia-0.1.13/pkg/osx/polipo.conf 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/pkg/osx/polipo.conf 2009-07-02 01:26:15.000000000 +0100 @@ -0,0 +1,161 @@ +### Basic configuration +### ******************* + +# Uncomment one of these if you want to allow remote clients to +# connect: + +# proxyAddress = "::0" # both IPv4 and IPv6 +# proxyAddress = "0.0.0.0" # IPv4 only + +proxyAddress = "127.0.0.1" +proxyPort = 8118 + +# If you do that, you'll want to restrict the set of hosts allowed to +# connect: + +# allowedClients = "127.0.0.1, 134.157.168.57" +# allowedClients = "127.0.0.1, 134.157.168.0/24" + +allowedClients = 127.0.0.1 +allowedPorts = 1-65535 + +# Uncomment this if you want your Polipo to identify itself by +# something else than the host name: + +proxyName = "localhost" + +# Uncomment this if there's only one user using this instance of Polipo: + +cacheIsShared = false + +# Uncomment this if you want to use a parent proxy: + +# parentProxy = "squid.example.org:3128" + +# Uncomment this if you want to use a parent SOCKS proxy: + +socksParentProxy = "localhost:9050" +socksProxyType = socks5 + + +### Memory +### ****** + +# Uncomment this if you want Polipo to use a ridiculously small amount +# of memory (a hundred C-64 worth or so): + +# chunkHighMark = 819200 +# objectHighMark = 128 + +# Uncomment this if you've got plenty of memory: + +# chunkHighMark = 50331648 +# objectHighMark = 16384 + +chunkHighMark = 33554432 + +### On-disk data +### ************ + +# Uncomment this if you want to disable the on-disk cache: + +diskCacheRoot = "" + +# Uncomment this if you want to put the on-disk cache in a +# non-standard location: + +# diskCacheRoot = "~/.polipo-cache/" + +# Uncomment this if you want to disable the local web server: + +localDocumentRoot = "" + +# Uncomment this if you want to enable the pages under /polipo/index? +# and /polipo/servers?. This is a serious privacy leak if your proxy +# is shared. + +# disableIndexing = false +# disableServersList = false + +disableLocalInterface = true +disableConfiguration = true + +### Domain Name System +### ****************** + +# Uncomment this if you want to contact IPv4 hosts only (and make DNS +# queries somewhat faster): +# +# dnsQueryIPv6 = no + +# Uncomment this if you want Polipo to prefer IPv4 to IPv6 for +# double-stack hosts: +# +# dnsQueryIPv6 = reluctantly + +# Uncomment this to disable Polipo's DNS resolver and use the system's +# default resolver instead. If you do that, Polipo will freeze during +# every DNS query: + +dnsUseGethostbyname = yes + + +### HTTP +### **** + +# Uncomment this if you want to enable detection of proxy loops. +# This will cause your hostname (or whatever you put into proxyName +# above) to be included in every request: + +disableVia = true + +# Uncomment this if you want to slightly reduce the amount of +# information that you leak about yourself: + +# censoredHeaders = from, accept-language +# censorReferer = maybe + +censoredHeaders = from,accept-language,x-pad,link +censorReferer = maybe + +# Uncomment this if you're paranoid. This will break a lot of sites, +# though: + +# censoredHeaders = set-cookie, cookie, cookie2, from, accept-language +# censorReferer = true + +# Uncomment this if you want to use Poor Man's Multiplexing; increase +# the sizes if you're on a fast line. They should each amount to a few +# seconds' worth of transfer; if pmmSize is small, you'll want +# pmmFirstSize to be larger. + +# Note that PMM is somewhat unreliable. + +# pmmFirstSize = 16384 +# pmmSize = 8192 + +# Uncomment this if your user-agent does something reasonable with +# Warning headers (most don't): + +# relaxTransparency = maybe + +# Uncomment this if you never want to revalidate instances for which +# data is available (this is not a good idea): + +# relaxTransparency = yes + +# Uncomment this if you have no network: + +# proxyOffline = yes + +# Uncomment this if you want to avoid revalidating instances with a +# Vary header (this is not a good idea): + +# mindlesslyCacheVary = true + +# Suggestions from Incognito configuration +maxConnectionAge = 5m +maxConnectionRequests = 120 +serverMaxSlots = 8 +serverSlots = 2 +tunnelAllowedPorts = 1-65535 diff -Nru vidalia-0.1.13/pkg/osx/PrivoxyConfDesc.plist vidalia-0.2.8/pkg/osx/PrivoxyConfDesc.plist --- vidalia-0.1.13/pkg/osx/PrivoxyConfDesc.plist 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/pkg/osx/PrivoxyConfDesc.plist 1970-01-01 01:00:00.000000000 +0100 @@ -1,10 +0,0 @@ - - - - - IFPkgDescriptionTitle - Privoxy configuration for Tor - IFPkgDescriptionVersion - 0.1 - - diff -Nru vidalia-0.1.13/pkg/osx/privoxy.config vidalia-0.2.8/pkg/osx/privoxy.config --- vidalia-0.1.13/pkg/osx/privoxy.config 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/pkg/osx/privoxy.config 1970-01-01 01:00:00.000000000 +0100 @@ -1,1179 +0,0 @@ -# Sample Configuration File for Privoxy v3.0.6 -# -# $Id: config,v 1.56 2006/11/14 01:54:36 hal9 Exp $ -# -# Copyright (C) 2001-2006 Privoxy Developers http://privoxy.org -# -#################################################################### -# # -# Table of Contents # -# # -# I. INTRODUCTION # -# II. FORMAT OF THE CONFIGURATION FILE # -# # -# 1. LOCAL SET-UP DOCUMENTATION # -# 2. CONFIGURATION AND LOG FILE LOCATIONS # -# 3. DEBUGGING # -# 4. ACCESS CONTROL AND SECURITY # -# 5. FORWARDING # -# 6. WINDOWS GUI OPTIONS # -# # -#################################################################### -# -# -# I. INTRODUCTION -# =============== -# -# This file holds the Privoxy configuration. If you modify this file, -# you will need to send a couple of requests (of any kind) to the -# proxy before any changes take effect. -# -# When starting Privoxy on Unix systems, give the name of this file as -# an argument. On Windows systems, Privoxy will look for this file -# with the name 'config.txt' in the same directory where Privoxy -# is installed. -# -# -# II. FORMAT OF THE CONFIGURATION FILE -# ==================================== -# -# Configuration lines consist of an initial keyword followed by a -# list of values, all separated by whitespace (any number of spaces -# or tabs). For example, -# -# actionsfile default.action -# -# Indicates that the actionsfile is named 'default.action'. -# -# The '#' indicates a comment. Any part of a line following a '#' -# is ignored, except if the '#' is preceded by a '\'. -# -# Thus, by placing a # at the start of an existing configuration line, -# you can make it a comment and it will be treated as if it weren't -# there. This is called "commenting out" an option and can be useful. -# -# Note that commenting out and option and leaving it at its default -# are two completely different things! Most options behave very -# differently when unset. See the the "Effect if unset" explanation -# in each option's description for details. -# -# Long lines can be continued on the next line by using a `\' as the -# last character. -# - -# -# 1. LOCAL SET-UP DOCUMENTATION -# ============================= -# -# If you intend to operate Privoxy for more users than just yourself, -# it might be a good idea to let them know how to reach you, what -# you block and why you do that, your policies, etc. -# - -# -# 1.1. user-manual -# ================ -# -# Specifies: -# -# Location of the Privoxy User Manual. -# -# Type of value: -# -# A fully qualified URI -# -# Default value: -# -# Unset -# -# Effect if unset: -# -# http://www.privoxy.org/version/user-manual/ will be used, -# where version is the Privoxy version. -# -# Notes: -# -# The User Manual URI is the single best source of information on -# Privoxy, and is used for help links from some of the internal -# CGI pages. The manual itself is normally packaged with the -# binary distributions, so you probably want to set this to -# a locally installed copy. For multi-user setups, you could -# provide a copy on a local webserver for all your users and use -# the corresponding URL here. -# -# Examples: -# -# The best all purpose solution is simply to put the full local -# PATH to where the User Manual is located: -# -# user-manual /usr/share/doc/privoxy/user-manual -# -# The User Manual is then available to anyone with -# access to the proxy, by following the built-in URL: -# http://config.privoxy.org/user-manual/ (or the shortcut: -# http://p.p/user-manual/). -# -# If the documentation is not on the local system, it can be -# accessed from a remote server, as: -# -# user-manual http://example.com/privoxy/user-manual/ -# -# WARNING!!! -# -# If set, this option should be the first option in the config -# file, because it is used while the config file is being read. -# -#user-manual http://www.privoxy.org/user-manual/ - -# -# 1.2. trust-info-url -# =================== -# -# Specifies: -# -# A URL to be displayed in the error page that users will see if -# access to an untrusted page is denied. -# -# Type of value: -# -# URL -# -# Default value: -# -# Two example URL are provided -# -# Effect if unset: -# -# No links are displayed on the "untrusted" error page. -# -# Notes: -# -# The value of this option only matters if the experimental trust -# mechanism has been activated. (See trustfile above.) -# -# If you use the trust mechanism, it is a good idea to write -# up some on-line documentation about your trust policy and to -# specify the URL(s) here. Use multiple times for multiple URLs. -# -# The URL(s) should be added to the trustfile as well, so users -# don't end up locked out from the information on why they were -# locked out in the first place! -# -trust-info-url http://www.example.com/why_we_block.html -trust-info-url http://www.example.com/what_we_allow.html - -# -# 1.3. admin-address -# ================== -# -# Specifies: -# -# An email address to reach the proxy administrator. -# -# Type of value: -# -# Email address -# -# Default value: -# -# Unset -# -# Effect if unset: -# -# No email address is displayed on error pages and the CGI user -# interface. -# -# Notes: -# -# If both admin-address and proxy-info-url are unset, the whole -# "Local Privoxy Support" box on all generated pages will not -# be shown. -# -#admin-address privoxy-admin@example.com - -# -# 1.4. proxy-info-url -# =================== -# -# Specifies: -# -# A URL to documentation about the local Privoxy setup, -# configuration or policies. -# -# Type of value: -# -# URL -# -# Default value: -# -# Unset -# -# Effect if unset: -# -# No link to local documentation is displayed on error pages and -# the CGI user interface. -# -# Notes: -# -# If both admin-address and proxy-info-url are unset, the whole -# "Local Privoxy Support" box on all generated pages will not -# be shown. -# -# This URL shouldn't be blocked ;-) -# -#proxy-info-url http://www.example.com/proxy-service.html - -# -# 2. CONFIGURATION AND LOG FILE LOCATIONS -# ======================================= -# -# Privoxy can (and normally does) use a number of other files for -# additional configuration, help and logging. This section of the -# configuration file tells Privoxy where to find those other files. -# -# The user running Privoxy, must have read permission for all -# configuration files, and write permission to any files that would -# be modified, such as log files and actions files. -# - -# -# 2.1. confdir -# ============ -# -# Specifies: -# -# The directory where the other configuration files are located -# -# Type of value: -# -# Path name -# -# Default value: -# -# /etc/privoxy (Unix) or Privoxy installation dir (Windows) -# -# Effect if unset: -# -# Mandatory -# -# Notes: -# -# No trailing "/", please -# -# When development goes modular and multi-user, the blocker, -# filter, and per-user config will be stored in subdirectories of -# "confdir". For now, the configuration directory structure is -# flat, except for confdir/templates, where the HTML templates -# for CGI output reside (e.g. Privoxy's 404 error page). -# -confdir . - -# -# 2.2. logdir -# =========== -# -# Specifies: -# -# The directory where all logging takes place (i.e. where logfile -# and jarfile are located) -# -# Type of value: -# -# Path name -# -# Default value: -# -# /var/log/privoxy (Unix) or Privoxy installation dir (Windows) -# -# Effect if unset: -# -# Mandatory -# -# Notes: -# -# No trailing "/", please -# -logdir . - -# -# 2.3. actionsfile -# ================ -# -# Specifies: -# -# The actions file(s) to use -# -# Type of value: -# -# File name, relative to confdir, without the .action suffix -# -# Default values: -# -# standard # Internal purposes, no editing recommended -# -# default # Main actions file -# -# user # User customizations -# -# Effect if unset: -# -# No actions are taken at all. Simple neutral proxying. -# -# Notes: -# -# Multiple actionsfile lines are permitted, and are in fact -# recommended! -# -# The default values include standard.action, which is used -# for internal purposes and should be loaded, default.action, -# which is the "main" actions file maintained by the developers, -# and user.action, where you can make your personal additions. -# -# Actions files are where all the per site and per URL -# configuration is done for ad blocking, cookie management, -# privacy considerations, etc. There is no point in using Privoxy -# without at least one actions file. -# -actionsfile standard # Internal purpose, recommended -actionsfile default # Main actions file -actionsfile user # User customizations - -# -# 2.4. filterfile -# =============== -# -# Specifies: -# -# The filter file(s) to use -# -# Type of value: -# -# File name, relative to confdir -# -# Default value: -# -# default.filter (Unix) or default.filter.txt (Windows) -# -# Effect if unset: -# -# No textual content filtering takes place, i.e. all +filter{name} -# actions in the actions files are turned neutral. -# -# Notes: -# -# Multiple filterfile lines are permitted. -# -# The filter files contain content modification rules that use -# regular expressions. These rules permit powerful changes on -# the content of Web pages, and optionally the headers as well, -# e.g., you could disable your favorite JavaScript annoyances, -# re-write the actual displayed text, or just have some fun -# playing buzzword bingo with web pages. -# -# The +filter{name} actions rely on the relevant filter (name) -# to be defined in a filter file! -# -# A pre-defined filter file called default.filter that contains a -# number of useful filters for common problems is included in the -# distribution. See the section on the filter action for a list. -# -# It is recommended to place any locally adapted filters into a -# separate file, such as user.filter. -# -filterfile default.filter -#filterfile user.filter # User customizations - -# -# 2.5. logfile -# ============ -# -# Specifies: -# -# The log file to use -# -# Type of value: -# -# File name, relative to logdir -# -# Default value: -# -# logfile (Unix) or privoxy.log (Windows) -# -# Effect if unset: -# -# No log file is used, all log messages go to the console (STDERR). -# -# Notes: -# -# The logfile is where all logging and error messages are -# written. The level of detail and number of messages are set with -# the debug option (see below). The logfile can be useful for -# tracking down a problem with Privoxy (e.g., it's not blocking -# an ad you think it should block) but in most cases you probably -# will never look at it. -# -# Your logfile will grow indefinitely, and you will probably -# want to periodically remove it. On Unix systems, you can do -# this with a cron job (see "man cron"). For Red Hat, a logrotate -# script has been included. -# -# On SuSE Linux systems, you can place a line like -# "/var/log/privoxy.* +1024k 644 nobody.nogroup" in /etc/logfiles, -# with the effect that cron.daily will automatically archive, -# gzip, and empty the log, when it exceeds 1M size. -# -# Any log files must be writable by whatever user Privoxy is -# being run as (default on UNIX, user id is "privoxy"). -# -#logfile privoxy.log - -# -# 2.6. jarfile -# ============ -# -# Specifies: -# -# The file to store intercepted cookies in -# -# Type of value: -# -# File name, relative to logdir -# -# Default value: -# -# Unset (commented out). When activated: jarfile (Unix) or -# privoxy.jar (Windows) -# -# Effect if unset: -# -# Intercepted cookies are not stored in a dedicated log file. -# -# Notes: -# -# The jarfile may grow to ridiculous sizes over time. -# -# If debug 8 (show header parsing) is enabled, cookies are written -# to the logfile with the rest of the headers. -# -#jarfile jar.log - -# -# 2.7. trustfile -# ============== -# -# Specifies: -# -# The trust file to use -# -# Type of value: -# -# File name, relative to confdir -# -# Default value: -# -# Unset (commented out). When activated: trust (Unix) or trust.txt -# (Windows) -# -# Effect if unset: -# -# The entire trust mechanism is turned off. -# -# Notes: -# -# The trust mechanism is an experimental feature for building -# white-lists and should be used with care. It is NOT recommended -# for the casual user. -# -# If you specify a trust file, Privoxy will only allow access to -# sites that are specified in the trustfile. Sites can be listed -# in one of two ways: -# -# Prepending a ~ character limits access to this site only (and -# any sub-paths within this site), e.g. ~www.example.com. -# -# Or, you can designate sites as trusted referrers, by prepending -# the name with a + character. The effect is that access to -# untrusted sites will be granted -- but only if a link from this -# trusted referrer was used. The link target will then be added -# to the "trustfile" so that future, direct accesses will be -# granted. Sites added via this mechanism do not become trusted -# referrers themselves (i.e. they are added with a ~ designation). -# -# If you use the + operator in the trust file, it may grow -# considerably over time. -# -# It is recommended that Privoxy be compiled with the -# --disable-force, --disable-toggle and --disable-editor options, -# if this feature is to be used. -# -# Possible applications include limiting Internet access for -# children. -# -#trustfile trust - -# -# 3. DEBUGGING -# ============ -# -# These options are mainly useful when tracing a problem. Note that -# you might also want to invoke Privoxy with the --no-daemon command -# line option when debugging. -# - -# -# 3.1. debug -# ========== -# -# Specifies: -# -# Key values that determine what information gets logged to -# the logfile. -# -# Type of value: -# -# Integer values -# -# Default value: -# -# 12289 (i.e.: URLs plus informational and warning messages) -# -# Effect if unset: -# -# Nothing gets logged. -# -# Notes: -# -# The available debug levels are: -# -# debug 1 # show each GET/POST/CONNECT request -# debug 2 # show each connection status -# debug 4 # show I/O status -# debug 8 # show header parsing -# debug 16 # log all data into the logfile -# debug 32 # debug force feature -# debug 64 # debug regular expression filter -# debug 128 # debug fast redirects -# debug 256 # debug GIF de-animation -# debug 512 # Common Log Format -# debug 1024 # debug kill pop-ups -# debug 2048 # CGI user interface -# debug 4096 # Startup banner and warnings. -# debug 8192 # Non-fatal errors -# -# To select multiple debug levels, you can either add them or -# use multiple debug lines. -# -# A debug level of 1 is informative because it will show you each -# request as it happens. 1, 4096 and 8192 are highly recommended -# so that you will notice when things go wrong. The other levels -# are probably only of interest if you are hunting down a specific -# problem. They can produce a hell of an output (especially 16). -# -# The reporting of fatal errors (i.e. ones which crash Privoxy) -# is always on and cannot be disabled. -# -# If you want to use CLF (Common Log Format), you should set -# "debug 512" ONLY and not enable anything else. -# -#debug 1 # show each GET/POST/CONNECT request -debug 4096 # Startup banner and warnings -debug 8192 # Errors - *we highly recommended enabling this* - -# -# 3.2. single-threaded -# ==================== -# -# Specifies: -# -# Whether to run only one server thread -# -# Type of value: -# -# None -# -# Default value: -# -# Unset -# -# Effect if unset: -# -# Multi-threaded (or, where unavailable: forked) operation, -# i.e. the ability to serve multiple requests simultaneously. -# -# Notes: -# -# This option is only there for debug purposes and you should -# never need to use it. It will drastically reduce performance. -# -#single-threaded - -# -# 4. ACCESS CONTROL AND SECURITY -# ============================== -# -# This section of the config file controls the security-relevant -# aspects of Privoxy's configuration. -# - -# -# 4.1. listen-address -# =================== -# -# Specifies: -# -# The IP address and TCP port on which Privoxy will listen for -# client requests. -# -# Type of value: -# -# [IP-Address]:Port -# -# Default value: -# -# 127.0.0.1:8118 -# -# Effect if unset: -# -# Bind to 127.0.0.1 (localhost), port 8118. This is suitable and -# recommended for home users who run Privoxy on the same machine -# as their browser. -# -# Notes: -# -# You will need to configure your browser(s) to this proxy address -# and port. -# -# If you already have another service running on port 8118, or -# if you want to serve requests from other machines (e.g. on your -# local network) as well, you will need to override the default. -# -# If you leave out the IP address, Privoxy will bind to all -# interfaces (addresses) on your machine and may become reachable -# from the Internet. In that case, consider using access control -# lists (ACL's, see below), and/or a firewall. -# -# If you open Privoxy to untrusted users, you will also want -# to turn off the enable-edit-actions and enable-remote-toggle -# options! -# -# Example: -# -# Suppose you are running Privoxy on a machine which has the -# address 192.168.0.1 on your local private network (192.168.0.0) -# and has another outside connection with a different address. You -# want it to serve requests from inside only: -# -# listen-address 192.168.0.1:8118 -# -listen-address 127.0.0.1:8118 - -# -# 4.2. toggle -# =========== -# -# Specifies: -# -# Initial state of "toggle" status -# -# Type of value: -# -# 1 or 0 -# -# Default value: -# -# 1 -# -# Effect if unset: -# -# Act as if toggled on -# -# Notes: -# -# If set to 0, Privoxy will start in "toggled off" mode, -# i.e. behave like a normal, content-neutral proxy where all ad -# blocking, filtering, etc are disabled. See enable-remote-toggle -# below. This is not really useful anymore, since toggling is -# much easier via the web interface than via editing the conf file. -# -# The windows version will only display the toggle icon in the -# system tray if this option is present. -# -toggle 1 - -# -# 4.3. enable-remote-toggle -# ========================= -# -# Specifies: -# -# Whether or not the web-based toggle feature may be used -# -# Type of value: -# -# 0 or 1 -# -# Default value: -# -# 1 -# -# Effect if unset: -# -# The web-based toggle feature is disabled. -# -# Notes: -# -# When toggled off, Privoxy acts like a normal, content-neutral -# proxy, i.e. it acts as if none of the actions applied to -# any URL. -# -# For the time being, access to the toggle feature can not be -# controlled separately by "ACLs" or HTTP authentication, so that -# everybody who can access Privoxy (see "ACLs" and listen-address -# above) can toggle it for all users. So this option is not -# recommended for multi-user environments with untrusted users. -# -# Note that you must have compiled Privoxy with support for this -# feature, otherwise this option has no effect. -# -enable-remote-toggle 0 - -# -# 4.4. enable-remote-http-toggle -# ============================== -# -# Specifies: -# -# Whether or not Privoxy recognizes special HTTP headers to change -# its behaviour. -# -# Type of value: -# -# 0 or 1 -# -# Default value: -# -# 1 -# -# Effect if unset: -# -# Privoxy ignores special HTTP headers. -# -# Notes: -# -# When toggled on, the client can change Privoxy's behaviour by -# setting special HTTP headers. Currently the only supported -# special header is "X-Filter: No", to disable filtering for -# the ongoing request, even if it is enabled in one of the -# action files. -# -# If you are using Privoxy in a multi-user environment or with -# untrustworthy clients and want to enforce filtering, you will -# have to disable this option, otherwise you can ignore it. -# -enable-remote-http-toggle 0 - -# -# 4.5. enable-edit-actions -# ======================== -# -# Specifies: -# -# Whether or not the web-based actions file editor may be used -# -# Type of value: -# -# 0 or 1 -# -# Default value: -# -# 1 -# -# Effect if unset: -# -# The web-based actions file editor is disabled. -# -# Notes: -# -# For the time being, access to the editor can not be controlled -# separately by "ACLs" or HTTP authentication, so that everybody -# who can access Privoxy (see "ACLs" and listen-address above) -# can modify its configuration for all users. So this option is -# not recommended for multi-user environments with untrusted users. -# -# Note that you must have compiled Privoxy with support for this -# feature, otherwise this option has no effect. -# -enable-edit-actions 0 - -# -# 4.6. ACLs: permit-access and deny-access -# ======================================== -# -# Specifies: -# -# Who can access what. -# -# Type of value: -# -# src_addr[/src_masklen] [dst_addr[/dst_masklen]] -# -# Where src_addr and dst_addr are IP addresses in dotted decimal -# notation or valid DNS names, and src_masklen and dst_masklen are -# subnet masks in CIDR notation, i.e. integer values from 2 to 30 -# representing the length (in bits) of the network address. The -# masks and the whole destination part are optional. -# -# Default value: -# -# Unset -# -# Effect if unset: -# -# Don't restrict access further than implied by listen-address -# -# Notes: -# -# Access controls are included at the request of ISPs and systems -# administrators, and are not usually needed by individual -# users. For a typical home user, it will normally suffice to -# ensure that Privoxy only listens on the localhost (127.0.0.1) -# or internal (home) network address by means of the listen-address -# option. -# -# Please see the warnings in the FAQ that this proxy is not -# intended to be a substitute for a firewall or to encourage -# anyone to defer addressing basic security weaknesses. -# -# Multiple ACL lines are OK. If any ACLs are specified, then -# the Privoxy talks only to IP addresses that match at least one -# permit-access line and don't match any subsequent deny-access -# line. In other words, the last match wins, with the default -# being deny-access. -# -# If Privoxy is using a forwarder (see forward below) for a -# particular destination URL, the dst_addr that is examined is -# the address of the forwarder and NOT the address of the ultimate -# target. This is necessary because it may be impossible for the -# local Privoxy to determine the IP address of the ultimate target -# (that's often what gateways are used for). -# -# You should prefer using IP addresses over DNS names, because -# the address lookups take time. All DNS names must resolve! You -# can not use domain patterns like "*.org" or partial domain -# names. If a DNS name resolves to multiple IP addresses, only -# the first one is used. -# -# Denying access to particular sites by ACL may have undesired -# side effects if the site in question is hosted on a machine -# which also hosts other sites. -# -# Examples: -# -# Explicitly define the default behavior if no ACL and -# listen-address are set: "localhost" is OK. The absence of a -# dst_addr implies that all destination addresses are OK: -# -# permit-access localhost -# -# Allow any host on the same class C subnet as www.privoxy.org -# access to nothing but www.example.com: -# -# permit-access www.privoxy.org/24 www.example.com/32 -# -# Allow access from any host on the 26-bit subnet 192.168.45.64 -# to anywhere, with the exception that 192.168.45.73 may not -# access www.dirty-stuff.example.com: -# -# permit-access 192.168.45.64/26 -# deny-access 192.168.45.73 www.dirty-stuff.example.com -# - -# -# 4.7. buffer-limit -# ================= -# -# Specifies: -# -# Maximum size of the buffer for content filtering. -# -# Type of value: -# -# Size in Kbytes -# -# Default value: -# -# 4096 -# -# Effect if unset: -# -# Use a 4MB (4096 KB) limit. -# -# Notes: -# -# For content filtering, i.e. the +filter and +deanimate-gif -# actions, it is necessary that Privoxy buffers the entire document -# body. This can be potentially dangerous, since a server could -# just keep sending data indefinitely and wait for your RAM to -# exhaust -- with nasty consequences. Hence this option. -# -# When a document buffer size reaches the buffer-limit, it is -# flushed to the client unfiltered and no further attempt to filter -# the rest of the document is made. Remember that there may be -# multiple threads running, which might require up to buffer-limit -# Kbytes each, unless you have enabled "single-threaded" above. -# -buffer-limit 4096 - -# -# 5. FORWARDING -# ============= -# -# This feature allows routing of HTTP requests through a chain -# of multiple proxies. It can be used to better protect privacy -# and confidentiality when accessing specific domains by routing -# requests to those domains through an anonymous public proxy. -# Or to use a caching proxy to speed up browsing. Or chaining to -# a parent proxy may be necessary because the machine that Privoxy -# runs on has no direct Internet access. -# -# Also specified here are SOCKS proxies. Privoxy supports the SOCKS -# 4 and SOCKS 4A protocols. -# - -# -# 5.1. forward -# ============ -# -# Specifies: -# -# To which parent HTTP proxy specific requests should be routed. -# -# Type of value: -# -# target_pattern http_parent[:port] -# -# where target_pattern is a URL pattern that specifies to which -# requests (i.e. URLs) this forward rule shall apply. Use / -# to denote "all URLs". http_parent[:port] is the DNS name or -# IP address of the parent HTTP proxy through which the requests -# should be forwarded, optionally followed by its listening port -# (default: 8080). Use a single dot (.) to denote "no forwarding". -# -# Default value: -# -# Unset -# -# Effect if unset: -# -# Don't use parent HTTP proxies. -# -# Notes: -# -# If http_parent is ".", then requests are not forwarded to -# another HTTP proxy but are made directly to the web servers. -# -# Multiple lines are OK, they are checked in sequence, and the -# last match wins. -# -# Examples: -# -# Everything goes to an example anonymizing proxy, except SSL on -# port 443 (which it doesn't handle): -# -# forward / anon-proxy.example.org:8080 -# forward :443 . -# -# Everything goes to our example ISP's caching proxy, except for -# requests to that ISP's sites: -# -# forward / caching-proxy.example-isp.net:8000 -# forward .example-isp.net . -# - -# -# 5.2. forward-socks4 and forward-socks4a -# ======================================= -# -# Specifies: -# -# Through which SOCKS proxy (and to which parent HTTP proxy) -# specific requests should be routed. -# -# Type of value: -# -# target_pattern socks_proxy[:port] http_parent[:port] -# -# where target_pattern is a URL pattern that specifies to which -# requests (i.e. URLs) this forward rule shall apply. Use / to -# denote "all URLs". http_parent and socks_proxy are IP addresses -# in dotted decimal notation or valid DNS names (http_parent may -# be "." to denote "no HTTP forwarding"), and the optional port -# parameters are TCP ports, i.e. integer values from 1 to 64535 -# -# Default value: -# -# Unset -# -# Effect if unset: -# -# Don't use SOCKS proxies. -# -# Notes: -# -# Multiple lines are OK, they are checked in sequence, and the -# last match wins. -# -# The difference between forward-socks4 and forward-socks4a -# is that in the SOCKS 4A protocol, the DNS resolution of the -# target hostname happens on the SOCKS server, while in SOCKS 4 -# it happens locally. -# -# If http_parent is ".", then requests are not forwarded to another -# HTTP proxy but are made (HTTP-wise) directly to the web servers, -# albeit through a SOCKS proxy. -# -# Examples: -# -# From the company example.com, direct connections are made to all -# "internal" domains, but everything outbound goes through their -# ISP's proxy by way of example.com's corporate SOCKS 4A gateway -# to the Internet. -# -# forward-socks4a / socks-gw.example.com:1080 www-cache.example-isp.net:8080 -# forward .example.com . -# -# A rule that uses a SOCKS 4 gateway for all destinations but no -# HTTP parent looks like this: -# -# forward-socks4 / socks-gw.example.com:1080 . -# -# To chain Privoxy and Tor, both running on the same system, -# you should use the rule: -# -forward-socks4a / 127.0.0.1:9050 . - -# -# The public Tor network can't be used to reach your local network, -# therefore it's a good idea to make some exceptions: -# -# forward 192.168.*.*/ . -# forward 10.*.*.*/ . -# forward 127.*.*.*/ . -# -# Unencrypted connections to systems in these address ranges will -# be as (un)secure as the local network is, but the alternative is -# that you can't reach the network at all. -# -# If you also want to be able to reach servers in your local -# network by using their names, you will need additional -# exceptions that look like this: -# -# forward localhost/ . -# - -# -# 5.3. forwarded-connect-retries -# ============================== -# -# Specifies: -# -# How often Privoxy retries if a forwarded connection request -# fails. -# -# Type of value: -# -# Number of retries. -# -# Default value: -# -# 0 -# -# Effect if unset: -# -# Forwarded connections are treated like direct connections and -# no retry attempts are made. -# -# Notes: -# -# forwarded-connect-retries is mainly interesting for socks4a -# connections, where Privoxy can't detect why the connections -# failed. The connection might have failed because of a DNS timeout -# in which case a retry makes sense, but it might also have failed -# because the server doesn't exist or isn't reachable. In this -# case the retry will just delay the appearance of Privoxy's -# error message. -# -# Only use this option, if you are getting many forwarding related -# error messages, that go away when you try again manually. Start -# with a small value and check Privoxy's logfile from time to time, -# to see how many retries are usually needed. -# -# Examples: -# -# forwarded-connect-retries 1 -# -forwarded-connect-retries 0 - -# -# 6. WINDOWS GUI OPTIONS -# ====================== -# -# Privoxy has a number of options specific to the Windows GUI -# interface: -# - -# If "activity-animation" is set to 1, the Privoxy icon will animate -# when "Privoxy" is active. To turn off, set to 0. -# -#activity-animation 1 - -# If "log-messages" is set to 1, Privoxy will log messages to the -# console window: -# -log-messages 0 - -# If "log-buffer-size" is set to 1, the size of the log buffer, -# i.e. the amount of memory used for the log messages displayed in -# the console window, will be limited to "log-max-lines" (see below). -# -# Warning: Setting this to 0 will result in the buffer to grow -# infinitely and eat up all your memory! -# -#log-buffer-size 1 - -# log-max-lines is the maximum number of lines held in the log -# buffer. See above. -# -#log-max-lines 200 - -# If "log-highlight-messages" is set to 1, Privoxy will highlight -# portions of the log messages with a bold-faced font: -# -#log-highlight-messages 1 - -# The font used in the console window: -# -#log-font-name Comic Sans MS - -# Font size used in the console window: -# -#log-font-size 8 - -# "show-on-task-bar" controls whether or not Privoxy will appear as -# a button on the Task bar when minimized: -# -#show-on-task-bar 0 - -# If "close-button-minimizes" is set to 1, the Windows close button -# will minimize Privoxy instead of closing the program (close with -# the exit option on the File menu). -# -#close-button-minimizes 1 - -# The "hide-console" option is specific to the MS-Win console version -# of Privoxy. If this option is used, Privoxy will disconnect from -# and hide the command console. -# -#hide-console - -# diff -Nru vidalia-0.1.13/pkg/osx/PrivoxyConfInfo.plist vidalia-0.2.8/pkg/osx/PrivoxyConfInfo.plist --- vidalia-0.1.13/pkg/osx/PrivoxyConfInfo.plist 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/pkg/osx/PrivoxyConfInfo.plist 1970-01-01 01:00:00.000000000 +0100 @@ -1,22 +0,0 @@ - - - - - CFBundleIdentifier - Privoxy configuration for Tor - CFBundleGetInfoString - Privoxy configuration for Tor - CFBundleName - Privoxy configuration for Tor - CFBundleShortVersionString - 0.1 - IFPkgFlagAuthorizationAction - RootAuthorization - IFPkgFlagRestartAction - RecommendedRestart - IFPkgFlagFollowLinks - - IFPkgFlagIsRequired - - - diff -Nru vidalia-0.1.13/pkg/osx/PrivoxyConfPostFlight vidalia-0.2.8/pkg/osx/PrivoxyConfPostFlight --- vidalia-0.1.13/pkg/osx/PrivoxyConfPostFlight 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/pkg/osx/PrivoxyConfPostFlight 1970-01-01 01:00:00.000000000 +0100 @@ -1,17 +0,0 @@ -#!/bin/sh - -# PrivoxyConfPostFlight gets invoked after any install or upgrade. - -TARGET=$2/Library/Privoxy -LOG='Privoxy-postflight-log.txt' - -# If Privoxy was running, kill it before starting a new one -PID=`ps -ax | grep privoxy | grep -v grep | awk '{ print $1 }'` -if [ x$PID != x ] -then - sudo kill $PID 2>&1 > $TARGET/$LOG -fi - -# Start Privoxy, so it's using the new config -$TARGET/StartPrivoxy.command 2>&1 > $TARGET/$LOG - diff -Nru vidalia-0.1.13/pkg/osx/qt.conf vidalia-0.2.8/pkg/osx/qt.conf --- vidalia-0.1.13/pkg/osx/qt.conf 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/pkg/osx/qt.conf 2010-02-17 16:24:23.000000000 +0000 @@ -0,0 +1,2 @@ +[Paths] +Plugins = diff -Nru vidalia-0.1.13/pkg/osx/TorbuttonDesc.plist vidalia-0.2.8/pkg/osx/TorbuttonDesc.plist --- vidalia-0.1.13/pkg/osx/TorbuttonDesc.plist 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/pkg/osx/TorbuttonDesc.plist 1970-01-01 01:00:00.000000000 +0100 @@ -1,10 +0,0 @@ - - - - - IFPkgDescriptionTitle - Torbutton Extension for Firefox - IFPkgDescriptionVersion - 0.1 - - diff -Nru vidalia-0.1.13/pkg/osx/TorbuttonInfo.plist vidalia-0.2.8/pkg/osx/TorbuttonInfo.plist --- vidalia-0.1.13/pkg/osx/TorbuttonInfo.plist 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/pkg/osx/TorbuttonInfo.plist 1970-01-01 01:00:00.000000000 +0100 @@ -1,22 +0,0 @@ - - - - - CFBundleIdentifier - Torbutton Extension for Firefox - CFBundleGetInfoString - Torbutton configuration for Tor - CFBundleName - Torbutton configuration for Tor - CFBundleShortVersionString - 0.1 - IFPkgFlagAuthorizationAction - RootAuthorization - IFPkgFlagRestartAction - RecommendedRestart - IFPkgFlagFollowLinks - - IFPkgFlagIsRequired - - - diff -Nru vidalia-0.1.13/pkg/osx/TorPostFlight vidalia-0.2.8/pkg/osx/TorPostFlight --- vidalia-0.1.13/pkg/osx/TorPostFlight 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/pkg/osx/TorPostFlight 1970-01-01 01:00:00.000000000 +0100 @@ -1,77 +0,0 @@ -#!/bin/sh -# -# Copyright (c) 2007 Andrew Lewman - -# TorPostflight gets invoked after any install or upgrade. - -TARGET=$2/Library/Tor -TORDIR=$TARGET/var/lib/tor -LOGFILE=/var/log/tor.log -TORBUTTON_VERSION="1.2.0-fx" - -# Check defaults for TARGET -if [ "$TARGET" == "//Library/Tor" ]; then - TARGET=/Library/Tor -fi - -# Create the tor directory, if it doesn't exist. -if [ ! -d $TORDIR ]; then - mkdir -p $TORDIR -fi - -# Check its permissions. -chmod 770 $TORDIR - -# Check the logfile and make sure it exists. -if [ ! -f $LOGFILE ]; then - touch $LOGFILE - chown $TORUSER $LOGFILE - chgrp daemon $LOGFILE - chmod 660 $LOGFILE -fi - -# Create the configuration file only if there wan't one already. -if [ ! -f $TARGET/torrc ]; then - cp $TARGET/torrc.sample $TARGET/torrc - chmod 660 $TARGET/torrc -fi - -# Ensure symbolic links -cd /usr/bin -if [ -e /usr/bin/tor -a ! -L /usr/bin/tor ]; then - mv tor tor_old -fi -if [ -e /usr/bin/tor-resolve -a ! -L /usr/bin/tor-resolve ]; then - mv tor-resolve tor-resolve_old -fi -ln -sf $TARGET/tor . -ln -sf $TARGET/tor-resolve . - -#cd /usr/share/man/man1 -#MAN1=$TARGET/man/man1 -#ln -sf $MAN1/*.1 . - -if [ ! -e /var/log/tor -o -L /var/log/tor ]; then - cd /var/log - rm -f tor -fi - -if [ -d /Library/StartupItems/Privoxy ]; then - find /Library/StartupItems/Privoxy -print0 | xargs -0 chown root:wheel -fi - -if [ -f $PACKAGE_PATH/Contents/Resources/uninstall_tor_bundle.sh ]; then - cp $PACKAGE_PATH/Contents/Resources/uninstall_tor_bundle.sh $TARGET/uninstall_tor_bundle.sh - chmod 550 $TARGET/uninstall_tor_bundle.sh -fi - -# Copy Documentation -if [ -d $PACKAGE_PATH/Contents/Resources/documents ];then - cp -r $PACKAGE_PATH/Contents/Resources/documents $TARGET/documents -fi - -if [ -f /Applications/Firefox.app/Contents/MacOS/firefox ]; then - if [ -f /Library/Torbutton/torbutton-$TORBUTTON_VERSION.xpi ]; then - su $USER /Applications/Firefox.app/Contents/MacOS/firefox /Library/Torbutton/torbutton-$TORBUTTON_VERSION.xpi - fi -fi diff -Nru vidalia-0.1.13/pkg/osx/VidaliaBundleDesc.plist.in vidalia-0.2.8/pkg/osx/VidaliaBundleDesc.plist.in --- vidalia-0.1.13/pkg/osx/VidaliaBundleDesc.plist.in 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/pkg/osx/VidaliaBundleDesc.plist.in 1970-01-01 01:00:00.000000000 +0100 @@ -1,14 +0,0 @@ - - - - - IFPkgDescriptionDeleteWarning - - IFPkgDescriptionDescription - Bundled package of Vidalia, Tor, Privoxy, and Torbutton. - IFPkgDescriptionTitle - Vidalia - Tor - Privoxy - Torbutton Bundle - IFPkgDescriptionVersion - @VERSION@ - - diff -Nru vidalia-0.1.13/pkg/osx/VidaliaBundleInfo.plist.in vidalia-0.2.8/pkg/osx/VidaliaBundleInfo.plist.in --- vidalia-0.1.13/pkg/osx/VidaliaBundleInfo.plist.in 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/pkg/osx/VidaliaBundleInfo.plist.in 1970-01-01 01:00:00.000000000 +0100 @@ -1,51 +0,0 @@ - - - - - CFBundleName - Vidalia Bundle - CFBundleGetInfoString - Vidalia Bundle @VERSION@ - CFBundleIdentifier - net.vidalia-project.vidaliabundle - CFBundleShortVersionString - @VERSION@ - IFPkgFlagComponentDirectory - ../.contained_packages - IFPkgFlagPackageList - - - IFPkgFlagPackageLocation - Vidalia.pkg - IFPkgFlagPackageSelection - selected - - - IFPkgFlagPackageLocation - Tor.pkg - IFPkgFlagPackageSelection - selected - - - IFPkgFlagPackageLocation - Privoxy.pkg - IFPkgFlagPackageSelection - selected - - - IFPkgFlagPackageLocation - PrivoxyConf.pkg - IFPkgFlagPackageSelection - selected - - - IFPkgFlagPackageLocation - torbutton.pkg - IFPkgFlagPackageSelection - selected - - - IFPkgFormatVersion - 0.10000000149011612 - - diff -Nru vidalia-0.1.13/pkg/osx/VidaliaBundleWelcome.rtf vidalia-0.2.8/pkg/osx/VidaliaBundleWelcome.rtf --- vidalia-0.1.13/pkg/osx/VidaliaBundleWelcome.rtf 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/pkg/osx/VidaliaBundleWelcome.rtf 1970-01-01 01:00:00.000000000 +0100 @@ -1,88 +0,0 @@ -{\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf420 -{\fonttbl\f0\fswiss\fcharset77 Helvetica-Bold;\f1\fswiss\fcharset77 Helvetica;\f2\fswiss\fcharset77 Helvetica-Oblique; -\f3\fswiss\fcharset77 Helvetica-BoldOblique;} -{\colortbl;\red255\green255\blue255;} -\paperw11900\paperh16840\margl1440\margr1440\vieww18220\viewh14340\viewkind0 -\deftab720 -\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardeftab720\ql\qnatural - -\f0\b\fs28 \cf0 Welcome to the Vidalia Bundle Installer!\ -\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardeftab720\ql\qnatural - -\f1\b0\fs24 \cf0 \ -This will install Vidalia, Tor, Privoxy, and Torbutton on your computer.\ -They are pre-configured to work seamlessly together.\ -\ -Vidalia, Tor, Privoxy, and Torbutton are separate products. They are packaged together for your convenience.\ -\ -\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardeftab720\ql\qnatural - -\f0\b \cf0 Vidalia -\f1\b0 is a GUI for Tor, allowing you to control, monitor, -\f0\b \ -\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardeftab720\ql\qnatural - -\f1\b0 \cf0 and configure your Tor installation.\ -\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardeftab720\ql\qnatural - -\f2\i \cf0 ({\field{\*\fldinst{HYPERLINK "http://www.vidalia-project.net/"}}{\fldrslt http://www.vidalia-project.net/}} -\f1\i0 ) -\f0\b \ -\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardeftab720\ql\qnatural - -\f1\b0 \cf0 \ -\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardeftab720\ql\qnatural - -\f0\b \cf0 Tor -\f1\b0 is a system for using the Internet anonymously, -\f0\b \ -\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardeftab720\ql\qnatural - -\f1\b0 \cf0 helping you anonymize Web browsing and publishing, \ -instant messaging, IRC, SSH, and more.\ -\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardeftab720\ql\qnatural - -\f2\i \cf0 ({\field{\*\fldinst{HYPERLINK "https://www.torproject.org"}}{\fldrslt https://www.torproject.org}}) -\f1\i0 -\f0\b \ -\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardeftab720\ql\qnatural - -\f1\b0 \cf0 \ -\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardeftab720\ql\qnatural - -\f0\b \cf0 Privoxy -\f1\b0 is a filtering web proxy that integrates well with -\f0\b \ -\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardeftab720\ql\qnatural - -\f1\b0 \cf0 Tor, protecting your privacy as well as removing ads,\ -banners, and popups.\ -\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural\pardirnatural - -\f2\i \cf0 ({\field{\*\fldinst{HYPERLINK "http://www.privoxy.org/"}}{\fldrslt http://www.privoxy.org/}} -\f1\i0 ) -\f0\b \ -\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardeftab720\ql\qnatural -\cf0 \ -Torbutton -\f1\b0 is a 1-click way for Firefox users to enable or disable the browser's use of Tor. \ -\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardeftab720\ql\qnatural - -\f2\i \cf0 Torbutton will not install if you do not have Firefox installed. -\f0\i0\b \ - -\f2\i\b0 ({\field{\*\fldinst{HYPERLINK "https://torbutton.torproject.org/"}}{\fldrslt https://torbutton.torproject.org/}}) -\f0\i0\b \ -\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardeftab720\ql\qnatural - -\f1\b0 \cf0 \ -\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardeftab720\ql\qnatural - -\f3\i\b \cf0 Note -\f2\b0 : -\f1\i0 If you have previously installed an old Tor/Privoxy-only -\f0\b \ -\pard\pardeftab720\ql\qnatural - -\f1\b0 \cf0 bundle, we recommend that you remove it before continuing.\ -} \ No newline at end of file diff -Nru vidalia-0.1.13/pkg/osx/vidalia.conf.sample vidalia-0.2.8/pkg/osx/vidalia.conf.sample --- vidalia-0.1.13/pkg/osx/vidalia.conf.sample 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/pkg/osx/vidalia.conf.sample 2009-11-01 00:48:07.000000000 +0000 @@ -0,0 +1,9 @@ +[General] +ProxyExecutable=/Applications/Vidalia.app/Contents/MacOS/polipo +ProxyExecutableArguments=-c /Applications/Vidalia.app/Contents/Resources/polipo.conf +RunProxyAtStart=true +InterfaceStyle=Macintosh (Aqua) + +[Tor] +TorExecutable=/Applications/Vidalia.app/Contents/MacOS/tor +DataDirectory=~/.tor/ diff -Nru vidalia-0.1.13/pkg/osx/VidaliaDesc.plist.in vidalia-0.2.8/pkg/osx/VidaliaDesc.plist.in --- vidalia-0.1.13/pkg/osx/VidaliaDesc.plist.in 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/pkg/osx/VidaliaDesc.plist.in 1970-01-01 01:00:00.000000000 +0100 @@ -1,10 +0,0 @@ - - - - - IFPkgDescriptionTitle - Vidalia - IFPkgDescriptionVersion - @VERSION@ - - diff -Nru vidalia-0.1.13/pkg/osx/VidaliaInfo.plist.in vidalia-0.2.8/pkg/osx/VidaliaInfo.plist.in --- vidalia-0.1.13/pkg/osx/VidaliaInfo.plist.in 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/pkg/osx/VidaliaInfo.plist.in 1970-01-01 01:00:00.000000000 +0100 @@ -1,26 +0,0 @@ - - - - - CFBundleIdentifier - Vidalia @VERSION@ - CFBundleGetInfoString - Vidalia @VERSION@ - CFBundleName - Vidalia - CFBundleShortVersionString - @VERSION@ - IFPkgFlagAllowBackRev - - IFPkgFlagFollowLinks - - IFPkgFlagIsRequired - - IFPkgFlagRootVolumeOnly - - IfPkgFlagBackgroundScaling - proportional - IFPkgFlagBackgroundAlignment - bottomleft - - diff -Nru vidalia-0.1.13/pkg/package.sh vidalia-0.2.8/pkg/package.sh --- vidalia-0.1.13/pkg/package.sh 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/pkg/package.sh 2009-07-02 01:32:59.000000000 +0100 @@ -1,6 +1,6 @@ #!/bin/bash ## -## $Id: package.sh 2725 2008-06-14 14:15:31Z edmanm $ +## $Id: package.sh 3933 2009-07-02 00:32:59Z edmanm $ ## ## 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 @@ -11,76 +11,32 @@ ## the terms described in the LICENSE file. ## - # Builds distribution packages for various platforms. - # Check for proper script arguments if [ "$#" -eq 0 ] then - echo "Usage: $0 " + echo "Usage: $0 " exit 1 fi - # Make the distribution depending on what type was requested case "$1" in # -# Source tarball (.tar.gz) -# -"tarball") - # Put the tarball in the current directory - destdir=`pwd` - srcdir=`dirname $(pwd) | sed -e "s/.*\///"` - tarball="$destdir/$srcdir.tar.gz" - - echo "Creating source tarball: $tarball" - pushd "../.." 1>/dev/null - filelist=`svn ls -R $srcdir/ | - sed -e "s/^/$srcdir\/&/" | - sed -e "/\/$/d" | - sed -e "s/\n/ /"` - tar -czf "$tarball" $filelist - popd -1 1>/dev/null - ;; - -# -# OS X .dmg +# rpm package # -"osx") - cp -R ../src/vidalia/Vidalia.app ../ - srcdir="../" - srcfiles="Vidalia.app README CREDITS CHANGELOG" - srcfiles="$srcfiles LICENSE LICENSE-GPLV2 LICENSE-GPLV3" - srcfiles="$srcfiles LICENSE-LGPLV3 LICENSE-OPENSSL" - osx/builddmg.sh "$srcdir" "$srcfiles" - ;; - -# -# OS X .mpkg (Bundle) -# -"osx-bundle") - if [ $# -ne 3 ] +"rpm") + if [ $# -ne 2 ] then - echo "Usage: $0 osx-bundle " - exit 1 + echo "Usage: $0 rpm " + exit 1 fi - torpath="$2" - privoxy="$3" - - pushd "osx" - ./buildmpkg.sh "$torpath" "$privoxy" + vidalia_source_path="$2" + pushd rpm + rpmbuild -ba --define "_sourcedir $vidalia_source_path" vidalia.spec popd ;; - -# -# Windows .exe installer -# -"win32") - echo "Unimplemented" - ;; -# # Invalid # *) @@ -89,4 +45,3 @@ esac exit $? - diff -Nru vidalia-0.1.13/pkg/rpm/vidalia.spec.in vidalia-0.2.8/pkg/rpm/vidalia.spec.in --- vidalia-0.1.13/pkg/rpm/vidalia.spec.in 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/pkg/rpm/vidalia.spec.in 2010-02-01 09:23:01.000000000 +0000 @@ -1,136 +1,141 @@ -## -## $Id: vidalia.spec.in 2917 2008-07-30 09:18:11Z oliver $ -## -## 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.vidalia-project.net/. No part of Vidalia, including this file, -## may be copied, modified, propagated, or distributed except according to -## the terms described in the LICENSE file. -## - -#%package vidalia -Name : vidalia -Version : @VERSION@ -Release : 1 -# -License : GPL -Summary : A Tor GUI for Linux -Group : Applications/Internet - -URL : http://www.vidalia-project.net -Vendor : Matt Edman, Justin Hipple -Packager : Oliver Niesner - -Source0 : %{name}-%{version}.tar.gz - -#AutoReq : No -#AutoProv : No - -Requires : tor >= 0.1.2.18 -BuildRequires : qt4 >= 4.2 -BuildRequires : cmake >= 2.4 -#BuildRoot : /var/tmp/%{name}-buildroot +Name: vidalia +Version: @VERSION@ +Release: 1%{?dist} +Summary: GUI controller for the Tor Onion Routing Network + +Group: Applications/Internet +License: GPLv2+ +URL: https://www.torproject.org/vidalia/ +Source0: https://www.torproject.org/%{name}/dist/%{name}-%{version}.tar.gz +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) + +BuildRequires: desktop-file-utils +BuildRequires: openssl-devel +BuildRequires: qt4-devel +BuildRequires: cmake + +Requires: tor +Requires: privoxy +Requires: hicolor-icon-theme + %description +Vidalia is a cross-platform controller GUI for Tor, built using the Qt +framework. Vidalia allows you to start and stop Tor, view the status of Tor at +a glance, and monitor Tor's bandwidth usage. Vidalia also makes it easy to +contribute to the Tor network by helping you setup a Tor server, if you wish. + + +%package doc +Summary: Documentation for %{name} +Group: Documentation +BuildRequires: doxygen +Requires: %{name} = %{version}-%{release} + + +%description doc +Doxygen generated documentations for %{name}. -Vidalia is an easy-to-use Tor controller GUI %prep -rm -rf %{buildroot} +%setup -q -####################################################################### -# setup macro -# -a num : Only unpack source number after changing to the directory -# -b num : Only unpack source number before changing to the directory -# -c : Create directory before unpacking. -# -D : Do not delete the directory before unpacking -# -n name : Name the directory as name -# -q : Run quiety with minimum output -# -T : Disable the automatic unpacking of the archives. -####################################################################### -%setup -%build -#./configure -#make - -cmake . && make +%build +%if 0%{?_qt4_bindir:1} +PATH=%{_qt4_bindir}:$PATH; export PATH +%else +PATH=%{_libdir}/qt4/bin:$PATH; export PATH +%endif +%cmake . -######################################################### -# Common Red Hat RPM macros (rpm --showrc for more info) -# {_sourcedir} : /usr/src/redhat/SOURCES -# {_builddir} : /usr/src/redhat/BUILD -# {_tmppath} : /var/tmp -# {_libdir} : /usr/lib -# {_bindir} : /usr/bin -# {_datadir} : /usr/share -# {_mandir} : /usr/share/man -# {_docdir} : /usr/share/doc -# {buildroot} -# {name} -# {version} -# {release} -######################################################### +make %{?_smp_mflags} -%install -rm -rf $RPM_BUILD_ROOT -mkdir -p $RPM_BUILD_ROOT/usr/local/bin -mkdir -p $RPM_BUILD_ROOT/usr/local/share/man/man1 -#install -s -m 755 eject $RPM_BUILD_ROOT/usr/bin/eject -#install -m 644 eject.1 $RPM_BUILD_ROOT/usr/man/man1/eject.1 +cd doc +doxygen Doxyfile.in -%makeinstall -#%post -%clean +%install rm -rf %{buildroot} -%files -/usr/local/bin/vidalia -/usr/local/share/man/man1/vidalia.1 +make install \ + INSTALL="install -p" \ + DESTDIR=%{buildroot} -##################################################### -# defattr sets the default attributes for all files -##################################################### -%defattr(-, root, root) +install -Dpm0644 doc/%{name}.1 \ + %{buildroot}%{_mandir}/man1/%{name}.1 -%changelog -* Wed Jul 30 2008 Oliver Niesner 0.1.6-1 -- bump to 0.1.6 -- fix man path -* Mon Mar 31 2008 Oliver Niesner 0.1.2-1 -- bump to 0.1.2 +mkdir -p %{buildroot}%{_docdir}/%{name}-%{version}-doxygen/ -* Tue Mar 04 2008 Oliver Niesner 0.1.0-1 -- bump to 0.1.0 and modifications to meet cmake requirements! +cp -r src/%{name}/help/ \ + %{buildroot}%{_docdir}/%{name}-%{version}-doxygen/ -* Mon Nov 26 2007 Oliver Niesner 0.0.16-1 -- bump to 0.0.16 -* Thu Oct 29 2007 Oliver Niesner 0.0.15-1 -- bump to 0.0.15 -* Thu Aug 30 2007 Oliver Niesner 0.0.14-1 -- bump to 0.0.14 +%post +touch --no-create %{_datadir}/icons/hicolor &>/dev/null || : -* Thu Aug 07 2007 Oliver Niesner 0.0.13-1 -- bump to 0.0.13 -* Thu Jun 05 2007 Oliver Niesner 0.0.12-1 -- bump to 0.0.12 +%postun +if [ $1 -eq 0 ] ; then + touch --no-create %{_datadir}/icons/hicolor &>/dev/null + gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || : +fi -* Thu Feb 08 2007 Oliver Niesner 0.0.11-1 -- bump to 0.0.11 release -* Mon Jan 08 2007 Oliver Niesner 0.0.10-1 -- bump to 0.0.10 release +%posttrans +gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || : -* Mon Nov 06 2006 Oliver Niesner 0.0.9-1 -- first release build for 0.0.9 -* Tue Oct 11 2006 Oliver Niesner 0.0.8-1 -- initial release +%clean +rm -rf %{buildroot} + + +%files +%defattr(-,root,root,-) +%doc CHANGELOG CREDITS HACKING LICENSE LICENSE-GPLV2 LICENSE-GPLV3 LICENSE-OPENSSL README +%{_bindir}/%{name} +%{_mandir}/man1/%{name}* +%{_datadir}/applications/%{name}.desktop +%{_datadir}/icons/hicolor/*/apps/%{name}.png + + +%files doc +%defattr(-,root,root,-) +%{_docdir}/%{name}-%{version}-doxygen/ + + +%changelog +* Fri Jan 29 2010 Erinn Clark - 0.2.7-1 +- New upstream release +- Updated documentation installation process + +* Sat Jun 13 2009 Matt Edman - 0.2.1-1 +- Added to Vidalia Subversion repository + +* Mon Jun 01 2009 Simon Wesp - 0.1.13-2 +- Merge builds for fedora and epel + +* Mon Jun 01 2009 Simon Wesp - 0.1.13-1 +- Update to 0.1.13 +- Adjust to fedora and epel + +* Sun Apr 06 2009 Simon Wesp - 0.1.12-1 +- New upstream release +- Correct typo in URL +- Add R: hicolor for new handling of icons +- Add update-icon-cache sniplet +- Use summary of upstream for Desktopfile and in spec file +- Create doxygen-documentations + +* Sun Feb 15 2009 Simon Wesp - 0.1.10-2 +- Correct Qt in Summary +- Correct Qt in desktop-file-source +- Add a german Translation in the desktop-file-source +- Using CMAKE-macro instead of cmake +- Add more files to more documentation + +* Tue Feb 10 2009 Simon Wesp - 0.1.10-1 +- Initial Package build diff -Nru vidalia-0.1.13/pkg/win32/ar/vidalia_ar.po vidalia-0.2.8/pkg/win32/ar/vidalia_ar.po --- vidalia-0.1.13/pkg/win32/ar/vidalia_ar.po 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/pkg/win32/ar/vidalia_ar.po 2009-12-12 10:23:10.000000000 +0000 @@ -0,0 +1,290 @@ +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: translations@vidalia-project.net\n" +"POT-Creation-Date: 2008-07-12 05:29+0000\n" +"PO-Revision-Date: 2009-12-09 15:45-0700\n" +"Last-Translator: Anas Qtiesh \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Pootle 1.1.0\n" + +msgctxt "BundleSetupCaption" +msgid "${BUNDLE_NAME} setup" +msgstr "إعداد {BUNDLE_NAME}$" + +msgctxt "BundleWelcomeText" +msgid "" +"This wizard will guide you through the installation of Tor, Vidalia, Polipo, " +"and Torbutton.\n" +"\n" +"Tor is a system for using the Internet anonymously, helping you anonymize " +"Web browsing and publishing, instant messaging, IRC, and more. Vidalia is a " +"GUI that helps you control, monitor, and configure Tor.\n" +"\n" +"Polipo is a caching web proxy that helps increase performance of browsing " +"the web through Tor.\n" +"\n" +"Torbutton is a Firefox extension that allows you to quickly enable or " +"disable anonymous web browsing.\n" +"\n" +"If you have previously installed Tor, Vidalia, Polipo, or Firefox, please " +"make sure they are not running before continuing this installation.\n" +"\n" +"$_CLICK" +msgstr "" +"هذه النافذة سترشدك خلال تنصيب تور وفيداليا وبوليبو ومفتاح تور.\n" +"\n" +"تور عبارة عن برنامج لاستخدام الانترنت مع الحفاظ على جهالة الهوية، بحيث يساعد " +"في إخفاء هويتك أثناء التصفح والنشر على الانترنت، وبرامج التراسل الفوري " +"وغيرها. فيداليا واجهة رسومية تساعدك في التحكم والمراقبة وضبط إعدادات تور.\n" +"\n" +"بوليبو وكيل (بروكسي) انترنت يستخدم لحفظ ملفات مؤقتة تساعد في زيادة سرعة " +"التصفح أثناء استخدام تور.\n" +"\n" +"مفتاح تور هو إضافة لفايرفوكس تسمح لك بتشغيل أو تعطيل إخفاء الهوية أثناء " +"التصفح وبسرعة وسهولة.\n" +"\n" +"إن كنت قد نصبت تور أو فيداليا أو بوليبو أو فايرفوكس في السابق يرجى التأكد من " +"أن أنهم غير مشغلين أثناء تنصيب البرنامج.\n" +"\n" +"$_CLICK" + +msgctxt "BundleWelcomeTitle" +msgid "Welcome to the ${BUNDLE_NAME} Setup Wizard" +msgstr "أهلاً بكم إلى معالج إعداد ${BUNDLE_NAME}" + +msgctxt "BundleLinkText" +msgid "${TOR_NAME} installation documentation" +msgstr "مستندات تنصيب ${TOR_NAME}" + +msgctxt "BundleFinishText" +msgid "" +"Installation is complete.\n" +"Please see https://www.torproject.org/docs/tor-doc-windows to learn how to " +"configure your applications to use Tor.\n" +"\n" +"If you installed Torbutton, you will need to restart Firefox." +msgstr "" +"اكتملت عملية التنصيب.\n" +"يرجى مراجعة https://www.torproject.org/docs/tor-doc-windows لتعلم كيفية ضبط " +"إعدادات تطبيقاتك لاستخدام تور.\n" +"\n" +"إن كنت قد نصبت مفتاح تور سيتوجب عليك إعادة تشغيل فايرفوكس." + +msgctxt "BundleRunNow" +msgid "Run installed components now" +msgstr "قم بتشغيل البرنامج الآن" + +msgctxt "VidaliaGroupDesc" +msgid "Vidalia is a GUI that helps you control, monitor, and configure Tor." +msgstr "فيداليا هو واجهة رسومية تساعدك على التحكم والمراقبة وضبط إعدادات تور." + +msgctxt "VidaliaUninstDesc" +msgid "Remove ${VIDALIA_DESC}." +msgstr "إزالة ${VIDALIA_DESC}." + +msgctxt "VidaliaSetupCaption" +msgid "${VIDALIA_NAME} setup" +msgstr "${VIDALIA_NAME} إعداد" + +msgctxt "VidaliaWelcomeText" +msgid "" +"This wizard will guide you through the installation of Vidalia, a GUI that " +"helps you control, monitor, and configure Tor.\n" +"\n" +"$_CLICK" +msgstr "" +"سيرشدك معالج الإعداد هذا خلال عملية تنصيب فيداليا، وهو واجهة رسومية تساعدك " +"على التحكم والمراقبة وضبط إعدادات تور.\n" +"\n" +"$_CLICK" + +msgctxt "VidaliaWelcomeTitle" +msgid "Welcome to the ${VIDALIA_NAME} Setup Wizard" +msgstr "أهلاً لكم في معالج إعداد ${VIDALIA_NAME}" + +msgctxt "VidaliaLinkText" +msgid "${VIDALIA_NAME} homepage" +msgstr "${VIDALIA_NAME} الصفحة الرئيسية" + +msgctxt "VidaliaAppDesc" +msgid "Vidalia is a GUI that helps you control, monitor, and configure Tor." +msgstr "فيداليا هي واجهة مستخدم تساعدك على التحكم ومراقبة وتضبيط برنامج تور." + +msgctxt "VidaliaStartup" +msgid "Run At Startup" +msgstr "تشغيل عند إقلاع النظام" + +msgctxt "VidaliaStartupDesc" +msgid "Automatically run ${VIDALIA_NAME} at startup." +msgstr "قم بتشغيل ${VIDALIA_NAME} بشكل تلقائي عند الإقلاع." + +msgctxt "VidaliaShortcuts" +msgid "Add to Start Menu" +msgstr "أضف إلى قائمة إبدأ" + +msgctxt "VidaliaShortcutsDesc" +msgid "Add ${VIDALIA_NAME} to your Start menu." +msgstr "أضف ${VIDALIA_NAME} إلى قائمة إبدأ" + +msgctxt "VidaliaRunNow" +msgid "Run ${VIDALIA_NAME}" +msgstr "قم بتشغيل ${VIDALIA_NAME}" + +msgctxt "TorGroupDesc" +msgid "" +"Tor is a system for using the Internet anonymously, helping you anonymize " +"Web browsing and publishing, instant messaging, IRC, and more." +msgstr "" +"تور عبارة عن برنامج لاستخدام الانترنت مع الحفاظ على جهالة الهوية، بحيث يساعد " +"في إخفاء هويتك أثناء التصفح والنشر على الانترنت، وبرامج التراسل الفوري " +"وغيرها." + +msgctxt "TorUninstDesc" +msgid "Remove ${TOR_DESC}." +msgstr "إزالة ${TOR_DESC}." + +msgctxt "TorAppDesc" +msgid "Install ${TOR_DESC}." +msgstr "إعداد ${TOR_DESC}." + +msgctxt "TorAskOverwriteTorrc" +msgid "" +"You already have a Tor configuration file.$\n" +"$\n" +"Do you want to overwrite it with the default sample configuration file?" +msgstr "" +"لديك ملف ضبط إعدادات تور بشكل مسبق.$\n" +"$\n" +"هل تريد الكتابة فوقه بعينة ملف الإعداد الإفتراضية؟" + +msgctxt "TorDocumentation" +msgid "Documentation" +msgstr "ملفات متعلقة" + +msgctxt "TorDocumentationDesc" +msgid "Install ${TOR_NAME} documentation." +msgstr "تنصيب مستندات ${TOR_NAME}." + +msgctxt "TorShortcuts" +msgid "Add to Start Menu" +msgstr "أضف إلى قائمة إبدأ" + +msgctxt "TorShortcutsDesc" +msgid "Add ${TOR_NAME} to your Start menu." +msgstr "أضف ${TOR_NAME} إلى قائمة إبدأ" + +msgctxt "PolipoGroupDesc" +msgid "" +"Polipo is a caching web proxy that increases performance of web browsing " +"through Tor." +msgstr "" +"بوليبو وكيل (بروكسي) انترنت يستخدم لحفظ ملفات مؤقتة تساعد في زيادة سرعة " +"التصفح أثناء استخدام تور." + +msgctxt "PolipoUninstDesc" +msgid "Remove ${POLIPO_DESC}." +msgstr "إزالة ${POLIPO_DESC}." + +msgctxt "PolipoAppDesc" +msgid "Install ${POLIPO_DESC}." +msgstr "تنصيب ${POLIPO_DESC}." + +msgctxt "PolipoShortcuts" +msgid "Add to Start Menu" +msgstr "أضف إلى قائمة إبدأ" + +msgctxt "PolipoShortcutsDesc" +msgid "Add ${POLIPO_NAME} to your Start menu." +msgstr "أضف ${POLIPO_NAME} إلى قائمة إبدأ" + +msgctxt "PolipoStartup" +msgid "Run At Startup" +msgstr "تشغيل عند إقلاع النظام" + +msgctxt "PolipoStartupDesc" +msgid "Automatically run ${POLIPO_NAME} at startup." +msgstr "تشغيل ${POLIPO_NAME} عند إقلاع الحاسب." + +msgctxt "TorbuttonGroupDesc" +msgid "" +"Torbutton is a Firefox extension that allows you to quickly enable or " +"disable anonymous web browsing." +msgstr "" +"مفتاح تور هو إضافة لفايرفوكس تسمح لك بتشغيل أو تعطيل إخفاء الهوية أثناء " +"التصفح وبسرعة وسهولة." + +msgctxt "TorbuttonUninstDesc" +msgid "Remove ${TORBUTTON_DESC}." +msgstr "إزالة ${TORBUTTON_DESC}." + +msgctxt "TorbuttonAppDesc" +msgid "Install ${TORBUTTON_DESC}." +msgstr "إعداد ${TORBUTTON_DESC}." + +msgctxt "TorbuttonAddToFirefox" +msgid "Add to Firefox" +msgstr "أضف إلى فايرفوكس" + +msgctxt "TorbuttonAddToFirefoxDesc" +msgid "Add the ${TORBUTTON_DESC} extension to Firefox." +msgstr "أضف ملحق ${TORBUTTON_DESC} للفايرفوكس" + +msgctxt "TorbuttonFirefoxNotFound" +msgid "Firefox was not found on your system. Not installing Torbutton." +msgstr "لم نعثر على فايرفوكس على جهازك. لن يتم إعداد زر تور." + +msgctxt "AppData" +msgid "Application Data" +msgstr "بيانات التطبيق" + +msgctxt "AppDataUninstDesc" +msgid "Remove saved application data and configuration files." +msgstr "إمسح بيانات التطبيق المحفوظة وملفات الإعدادات." + +msgctxt "LanguageCode" +msgid "en" +msgstr "إنكليزي" + +msgctxt "FirefoxWarningPageTitle" +msgid "Firefox is not installed" +msgstr "فايرفوكس غير مثبت" + +msgctxt "FirefoxWarningPageSubtitle" +msgid "" +"We recommend that you install Firefox before continuing, for best safety." +msgstr "ينصح بتثبيت فايرفوكس قبل الإستمرار, لأفضل حماية." + +msgctxt "FirefoxWarningPageUpperText" +msgid "" +"The Mozilla Firefox Web browser is not installed on your computer.\n" +"Tor will work with other browsers, such as Internet Explorer, but\n" +"is easier to use with Firefox, which also does a better job of\n" +"protecting your anonymity.\n" +"\n" +"If you would like to install Firefox, please press Cancel, then go\n" +"to the Firefox download page at" +msgstr "" +"متصفح موزيلا فايفوكس غير مثبت في حاسوبك.\n" +"تور يعمل مع باقي المتصفحات، مثل الإنترنت إكسبلورر، ولكن\n" +"من السهل إسنعماله مع الفايرفوكس، الذي يقوم بحماية هويتك بشكل أفضل.\n" +"\n" +"إذا اردت تنصيب فايرفوكس, رجاءاً إضغط على إلغاء، ثم إذهب \n" +"إلى صفحة تحميل فايرفوكس على" + +msgctxt "FirefoxWarningPageLowerText" +msgid "" +"When you are done installing Firefox, you can once again run the\n" +"Tor installer.\n" +"\n" +"Or, if you would prefer to install Tor without Firefox, simply\n" +"press Next to continue." +msgstr "" +"بعد اتمام تنصيب فايرفوكس، يمكنك تشغيل\n" +"ملف تنصيب تور مرة أخرى.\n" +"\n" +"أو إذا كنت تفضل تثبيت تور بدون فايرفوكسـ ببساطة\n" +"إضغط \"التالي\" للاستمرار" diff -Nru vidalia-0.1.13/pkg/win32/build-bundle-installer.txt vidalia-0.2.8/pkg/win32/build-bundle-installer.txt --- vidalia-0.1.13/pkg/win32/build-bundle-installer.txt 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/pkg/win32/build-bundle-installer.txt 2009-08-31 02:45:12.000000000 +0100 @@ -1,4 +1,4 @@ - Building the Vidalia/Tor/Privoxy/Torbutton Bundle + Building the Vidalia/Tor/Polipo/Torbutton Bundle 1. Create a base directory under which the necessary sources will be extracted @@ -13,22 +13,22 @@ 2. Create directories for each component in the bundle. - C:\bundle\privoxy\ + C:\bundle\polipo\ C:\bundle\tor\ C:\bundle\vidalia\ C:\bundle\torbutton\ 3. Modify the appropriate version values (VIDALIA_APPVERSION, TOR_APPVERSION, -PRIVOXY_APPVERSION, and TORBUTTON_APPVERSION) at the top of vidalia-bundle.nsi. +POLIPO_APPVERSION, and TORBUTTON_APPVERSION) at the top of vidalia-bundle.nsi. 4. Create directories for the appropriate versions of each component. - C:\bundle\privoxy\3.0.6\ - C:\bundle\tor\0.2.0.29-rc\ - C:\bundle\vidalia\0.1.6\ - C:\bundle\torbutton\1.2.0rc6\ + C:\bundle\polipo\1.0.4\ + C:\bundle\tor\0.2.1.19\ + C:\bundle\vidalia\0.2.3\ + C:\bundle\torbutton\1.2.2\ -5. Install Vidalia, Tor, and Privoxy to the directories you created for them +5. Install Vidalia, Tor, and Polipo to the directories you created for them in Step 4. Remember that you may need to grab the torrc.sample file from %APPDATA%\Tor that was created by Tor's installer and place it in the directory for the bundle's version of Tor. You may also need to grab @@ -39,25 +39,7 @@ 6. Place the Torbutton Firefox extension (.xpi) and license file (LICENSE) in the directory you created for it in Step 4. -7. Modify Privoxy's config.txt file as follows: - - * Add "forward-socks4a / localhost:9050 ." (without quotes) to the top - * Comment out "logfile privoxy.log" in Section 1.5 - * Comment out "jarfile jar.log" in Section 1.6 - * Uncomment "log-messages 1" in Section 6 and change the '1' to a '0' - * Modify the values of enable-remote-toggle, enable-remote-http-toggle, - and enable-edit-actions to be '0'. (Sections 4.3, 4.4, and 4.5) - - Also modify Privoxy's default.action as follows: - - * Replace the line that says "-limit-connect \" with "+limit-connect{1-} \" - - A privoxy.config and default.action with the necessary changes are included - in Vidalia's pkg/win32/ directory. If you use the privoxy.config from - Vidalia's pkg/win32/ directory, you will need to rename the file to - config.txt after copying it to Privoxy's directory. Vidalia's default.action - file only needs to be copied to Privoxy's directory; you do not need to - rename it. +7. Place the polipo.conf into the polipo directory you created in Step 4. 8. Run the vidalia-bundle.nsi script. The bundle will be named according the the versions you specified in Step 4 and placed in the base directory created @@ -67,5 +49,5 @@ For each additional release of some component of the bundle, follow Steps 4-8. If the version of some component didn't change, you can skip its step. For -example, if the version of Privoxy didn't change then you can skip Step 7. +example, if the version of polipo didn't change then you can skip Step 7. diff -Nru vidalia-0.1.13/pkg/win32/build-vidalia-installer.txt vidalia-0.2.8/pkg/win32/build-vidalia-installer.txt --- vidalia-0.1.13/pkg/win32/build-vidalia-installer.txt 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/pkg/win32/build-vidalia-installer.txt 2009-11-14 01:20:44.000000000 +0000 @@ -1,4 +1,4 @@ -$Id: build-vidalia-installer.txt 3627 2009-03-18 01:15:20Z phobos $ +$Id: build-vidalia-installer.txt 4165 2009-11-14 01:20:44Z edmanm $ Building a Windows Vidalia Installer @@ -8,15 +8,12 @@ installer for Vidalia. For information on building a Windows bundle installer, please see Vidalia's pkg/win32/build-bundle.txt. -Before building the Vidalia installer for the first time, you will need to -download and install a recent version of NSIS (Nullsoft Scriptable Install -System). NSIS can be downloaded from the following website: - - http://nsis.sourceforge.net/Download - -You will also need all of the prerequisites necessary for building Vidalia, -such as Qt and CMake. These requirements are detailed in the INSTALL file, in -the root of Vidalia's source tree. +You will all of the prerequisites necessary for building Vidalia, such as +Qt and CMake. These requirements are detailed in the INSTALL file, in the +root of Vidalia's source tree. If you need to build OpenSSL from source +(Step 2 below), you will also need Microsoft Visual Studio installed. +These instructions were tested with Visual Studio 2008 Professional, but +may work with earlier versions of Visual Studio as well. To sign the resulting installer suitable for distribution, you will need to install GnuPG or PGP. GnuPG can be downloaded here: @@ -24,95 +21,129 @@ http://www.gnupg.org/download/index.html -1. Compiling the Installer +The following steps describe the process used to create Vidalia's +"release" installers. Note that these instructions use the character ">" +to represent a command prompt. Yours probably looks slightly different. -The following steps describe the process used to create Vidalia's "release" -executable installers. +1. Install the Windows Installer XML Toolset -1.1. Compile a 'release' Version of Vidalia +Vidalia uses the Windows Installer XML Toolset (WiX) to create a .msi +installer file from a source file generated from pkg/win32/vidalia.wxs.in, +so you must have WiX 3.0 or later installed. This only needs to be done +once. + +If you already have WiX installed, you can skip to the next step. +Otherwise, download and run the most recent WiX installer from here: - First, extract Vidalia's source to a directory, or fetch the latest - revision from our Subversion repository. + http://wix.sourceforge.net/downloadv3.html - http://trac.vidalia-project.net/wiki/GettingTheCode - In the root of Vidalia's source tree, create a build directory: +2. Download and build OpenSSL - mkdir build - cd build - - Configure Vidalia as follows: +The OpenSSL DLL files shipped in Vidalia's Windows installers are compiled +with the static version of the Microsoft Visual C Runtime (MSVCRT). Doing +so allows Qt's OpenSSL support to function on computers without the latest +MSVCRT installed, which is important for portable installations such as +the Tor Browser Bundle. - cmake -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=minsizerel .. +If you have previously completed this step, you can skip to Step 3. If you +do not want to compile OpenSSL from source, you can use the pre-built +OpenSSL libraries available here: - Finally, compile Vidalia by running: - - make + http://pasiphae.cs.rpi.edu/~edmanm/vidalia/openssl-0.9.8k.zip + http://pasiphae.cs.rpi.edu/~edmanm/vidalia/openssl-0.9.8k.zip.asc (sig) +Otherwise, continue with the steps below. -1.2. Collect Required Dependencies +2.1. Download the OpenSSL 0.9.8k source code from here: - Create a "bin" directory by running the following command from your build - directory: + http://www.openssl.org/source/ - mkdir bin +You should verify PGP signature or SHA1 hash of the file you download. +2.2. Extract the source code to a directory on your hard drive. In the +interest of simplifying exposition, let %OPENSSLDIR% denote the location +to which you extract the OpenSSL source code. - Copy the following Qt .dll files from your Qt installation into your "bin" - directory: +2.3. Configure the OpenSSL source code by running: - copy $QTDIR\QtCore4.dll bin\ - copy $QTDIR\QtGui4.dll bin\ - copy $QTDIR\QtNetwork4.dll bin\ - copy $QTDIR\QtXml4.dll bin\ - - where "$QTDIR" is the path to your Qt installation. + > perl Configure VC-WIN32 --prefix=C:/OpenSSL/0.9.8k + +You can replace "C:/OpenSSL/0.9.8k" with another directory of your choice, +but you MUST use forward slashes in the path. + +2.4. Build the assembly language files by running: + > ms\do_masm - Copy the MinGW .dll file into your "bin" directory: +2.5. Open ms\ntdll.mak in a text editor and find the line that starts with +"CFLAG=". Change the "/MD" argument near the start of that line to "/MT". - copy $MINGWDIR\bin\mingwm10.dll bin\ +2.6. In the same file, find the line that starts with "LFLAGS". Add the +argument "/manifest:no" to the end of it. Save your changes and close the +editor. - where "$MINGWDIR" is the path to your MinGW installation. +2.7. From a Visual Studio command prompt, compile OpenSSL by running: - Copy the OpenSSL .dll file into your "bin" directory: + > nmake -f ms\ntdll.mak - copy $OPENSSLDIR\bin\ssleay32.dll bin\ +2.8. After OpenSSL has finished compiling, you can test and install it by +running: - where "$OPENSSLDIR" is the path to your OpenSSL installation. + > nmake -f ms\ntdll.mak test + > nmake -f ms\ntdll.mak install - Copy the Vidalia executable into your "bin" directory: +2.9. After the "install" command completes, your OpenSSL libraries will be +copied to the install prefix specified in Step 2.3 above. - copy src\vidalia\vidalia.exe bin\ +3. Compile a 'release' Version of Vidalia -1.3. Create the Executable Installer +3.1. First, extract Vidalia's source to a directory, or fetch the latest +revision from our Subversion repository. - Open Windows Explorer and navigate to - - $BUILDIR\pkg\win32 + https://trac.vidalia-project.net/wiki/GettingTheCode + +3.2. In the root of Vidalia's source tree, create a build directory and +'cd' into it: + + > mkdir build + > cd build + +3.3. Configure Vidalia as follows: + + > cmake -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=minsizerel \ + -DMINGW_BINARY_DIR=C:\\bin \ + -DOPENSSL_BINARY_DIR=C:\\bin \ + -DWIX_BINARY_DIR=C:\\bin .. + +MINGW_BINARY_DIR should point to the MinGW installation directory that +contains mingwm10.dll. OPENSSL_BINARY_DIR should point to the OpenSSL +directory that contains ssleay32.dll and libeay32.dll. If you compiled +OpenSSL from source in Step 2. + +3.4. Finally, compile Vidalia by running: - where "$BUILDIR" is replaced by the path to the build directory you created - in Step 1.1.2 above. + > make + +4. Create the Installer .msi File - Locate the file "vidalia.nsi" and right-click on it. From the context menu, - select "Compile NSIS Script". You will see an NSIS window appear and display - some progress information while it compiles the installer. When it completes, - you will have a complete Vidalia installation executable located in: +After the previous 'make' command has completed, you can run: - $BUILDIR\pkg\win32\vidalia-$VERSION.exe + > make dist-win32 - where "$VERSION" is the version of Vidalia for which the installer was built. +When it completes, you will have a complete Vidalia installer located in +the current directory named 'vidalia-$VERSION.msi', where $VERSION is the +version of the Vidalia source code you compiled. -1.4. Sign the Package (optional, recommended) +4.1. Sign the completed installer (optional, recommended) - From the root of Vidalia's source tree, run the following commands: +From the root of Vidalia's source tree, run the following commands: - cd pkg\win32 - gpg -ba vidalia-$VERSION.exe + > gpg -ba vidalia-$VERSION.msi - where "$VERSION" is replaced by the version of Vidalia for which you just - built a Windows installer. +where "$VERSION" is replaced by the version of Vidalia for which you just +built a Windows installer. diff -Nru vidalia-0.1.13/pkg/win32/CMakeLists.txt vidalia-0.2.8/pkg/win32/CMakeLists.txt --- vidalia-0.1.13/pkg/win32/CMakeLists.txt 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/pkg/win32/CMakeLists.txt 2009-11-08 18:35:31.000000000 +0000 @@ -1,5 +1,5 @@ ## -## $Id: CMakeLists.txt 3033 2008-09-02 04:35:26Z edmanm $ +## $Id: CMakeLists.txt 4164 2009-11-08 18:35:31Z edmanm $ ## ## 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 @@ -22,25 +22,50 @@ endif(NOT OPENSSL_BINARY_DIR) endif(USE_QSSLSOCKET) -## Only configure the bundle installer if paths to Tor, Privoxy, and +## Only configure the bundle installer if paths to Tor, Polipo, and ## Torbutton are specified set(CONFIGURE_BUNDLE_NSI TRUE) if (NOT TOR_PACKAGE_DIR) set(CONFIGURE_BUNDLE_NSI FALSE) endif(NOT TOR_PACKAGE_DIR) -if (NOT PRIVOXY_PACKAGE_DIR) +if (NOT POLIPO_PACKAGE_DIR) set(CONFIGURE_BUNDLE_NSI FALSE) -endif(NOT PRIVOXY_PACKAGE_DIR) +endif(NOT POLIPO_PACKAGE_DIR) if (NOT TORBUTTON_PACKAGE_DIR) set(CONFIGURE_BUNDLE_NSI FALSE) endif(NOT TORBUTTON_PACKAGE_DIR) ## Windows Packages configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/vidalia.nsi.in - ${CMAKE_CURRENT_BINARY_DIR}/vidalia.nsi + ${CMAKE_CURRENT_SOURCE_DIR}/vidalia.wxs.in + ${CMAKE_CURRENT_BINARY_DIR}/vidalia.wxs @ONLY ) +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/polipo.wxs.in + ${CMAKE_CURRENT_BINARY_DIR}/polipo.wxs + @ONLY +) +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/thandy.wxs.in + ${CMAKE_CURRENT_BINARY_DIR}/thandy.wxs + @ONLY +) +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/torbutton.wxs.in + ${CMAKE_CURRENT_BINARY_DIR}/torbutton.wxs + @ONLY +) +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/tor.wxs.in + ${CMAKE_CURRENT_BINARY_DIR}/tor.wxs + @ONLY +) +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/WixUI_Custom.wxs + ${CMAKE_CURRENT_BINARY_DIR}/WixUI_Custom.wxs + COPYONLY +) if (CONFIGURE_BUNDLE_NSI) configure_file( @@ -80,7 +105,7 @@ vidalia_add_nsh(vidalia_NSH ro/vidalia_ro.po ROMANIAN ISO-8859-2) vidalia_add_nsh(vidalia_NSH - ru/vidalia_ru.po RUSSIAN KOI8-R) + ru/vidalia_ru.po RUSSIAN Windows-1251) vidalia_add_nsh(vidalia_NSH sv/vidalia_sv.po SWEDISH ISO-8859-1) #vidalia_add_nsh(vidalia_NSH @@ -88,4 +113,63 @@ #vidalia_add_nsh(vidalia_NSH # zh_TW/vidalia_ZH_TW.po TRADCHINESE GB18030) -add_custom_target(i18n-win32-installer ALL DEPENDS ${vidalia_NSH}) +add_custom_target(i18n-win32-installer DEPENDS ${vidalia_NSH}) + +## Convert the .po files to WiX .wxl files at build time +vidalia_add_wxl(vidalia_WXL + cs/vidalia_cs.po cs ISO-8859-2) +vidalia_add_wxl(vidalia_WXL + de/vidalia_de.po de ISO-8859-1) +vidalia_add_wxl(vidalia_WXL + en/vidalia_en.po en ISO-8859-1) +vidalia_add_wxl(vidalia_WXL + es/vidalia_es.po es ISO-8859-1) +vidalia_add_wxl(vidalia_WXL + fa/vidalia_fa.po fa ISO-8859-6) +vidalia_add_wxl(vidalia_WXL + fi/vidalia_fi.po fi ISO-8859-1) +vidalia_add_wxl(vidalia_WXL + fr/vidalia_fr.po fr ISO-8859-1) +vidalia_add_wxl(vidalia_WXL + he/vidalia_he.po he ISO-8859-8) +vidalia_add_wxl(vidalia_WXL + it/vidalia_it.po it ISO-8859-1) +vidalia_add_wxl(vidalia_WXL + nl/vidalia_nl.po nl ISO-8859-1) +vidalia_add_wxl(vidalia_WXL + pl/vidalia_pl.po pl ISO-8859-2) +vidalia_add_wxl(vidalia_WXL + pt/vidalia_pt.po pt ISO-8859-1) +vidalia_add_wxl(vidalia_WXL + ro/vidalia_ro.po ro ISO-8859-2) +vidalia_add_wxl(vidalia_WXL + ru/vidalia_ru.po ru 1251) +vidalia_add_wxl(vidalia_WXL + sv/vidalia_sv.po sv ISO-8859-1) +vidalia_add_wxl(vidalia_WXL + zh_CN/vidalia_zh_CN.po zh-CN 936) +vidalia_add_wxl(vidalia_WXL + zh_TW/vidalia_ZH_TW.po zh-TW 950) + +add_custom_target(dist-win32 + COMMAND ${WIX_CANDLE_EXECUTABLE} + ${CMAKE_CURRENT_BINARY_DIR}/vidalia.wxs + -o ${CMAKE_CURRENT_BINARY_DIR}/vidalia.wixobj + + COMMAND ${WIX_CANDLE_EXECUTABLE} + ${CMAKE_CURRENT_BINARY_DIR}/WixUI_Custom.wxs + -o ${CMAKE_CURRENT_BINARY_DIR}/WixUI_Custom.wixobj + + COMMAND ${WIX_LIGHT_EXECUTABLE} + ${CMAKE_CURRENT_BINARY_DIR}/vidalia.wixobj + ${CMAKE_CURRENT_BINARY_DIR}/WixUI_Custom.wixobj + -o ${Vidalia_BINARY_DIR}/vidalia-${VERSION}.msi + -ext ${WIX_BINARY_DIR}/WixUIExtension.dll + + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/vidalia.wxs + ${CMAKE_CURRENT_SOURCE_DIR}/WixUI_Custom.wxs + ${vidalia_WXL} + + COMMENT "Building vidalia-${VERSION}.msi" +) + diff -Nru vidalia-0.1.13/pkg/win32/cs/vidalia_cs.po vidalia-0.2.8/pkg/win32/cs/vidalia_cs.po --- vidalia-0.1.13/pkg/win32/cs/vidalia_cs.po 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/pkg/win32/cs/vidalia_cs.po 2009-08-31 03:49:46.000000000 +0100 @@ -16,22 +16,23 @@ msgid "${BUNDLE_NAME} setup" msgstr "Instalace ${BUNDLE_NAME}" +#, fuzzy msgctxt "BundleWelcomeText" msgid "" -"This wizard will guide you through the installation of Tor, Vidalia, " -"Privoxy, and Torbutton.\n" +"This wizard will guide you through the installation of Tor, Vidalia, Polipo, " +"and Torbutton.\n" "\n" "Tor is a system for using the Internet anonymously, helping you anonymize " "Web browsing and publishing, instant messaging, IRC, and more. Vidalia is a " "GUI that helps you control, monitor, and configure Tor.\n" "\n" -"Privoxy is a filtering web proxy that protects your privacy and helps remove " -"ads, banners, and popups.\n" +"Polipo is a caching web proxy that helps increase performance of browsing " +"the web through Tor.\n" "\n" "Torbutton is a Firefox extension that allows you to quickly enable or " "disable anonymous web browsing.\n" "\n" -"If you have previously installed Tor, Vidalia, Privoxy, or Firefox, please " +"If you have previously installed Tor, Vidalia, Polipo, or Firefox, please " "make sure they are not running before continuing this installation.\n" "\n" "$_CLICK" @@ -186,37 +187,41 @@ msgid "Add ${TOR_NAME} to your Start menu." msgstr "Přidat ${TOR_NAME} do vaší Nabídky start." -msgctxt "PrivoxyGroupDesc" +msgctxt "PolipoGroupDesc" msgid "" -"Privoxy is a filtering web proxy that protects your privacy and helps remove " -"ads, banners, and popups." +"Polipo is a caching web proxy that increases performance of web browsing " +"through Tor." msgstr "" -"Privoxy je filtrační web proxy, která ochrání vaše soukromí a pomůže " -"odstranit reklamu, banery a popup okna." -msgctxt "PrivoxyUninstDesc" -msgid "Remove ${PRIVOXY_DESC}." -msgstr "Odstranit ${PRIVOXY_DESC}." +#, fuzzy +msgctxt "PolipoUninstDesc" +msgid "Remove ${POLIPO_DESC}." +msgstr "Odstranit ${POLIPO_DESC}." -msgctxt "PrivoxyAppDesc" -msgid "Install ${PRIVOXY_DESC}." -msgstr "Instalovat ${PRIVOXY_DESC}." +#, fuzzy +msgctxt "PolipoAppDesc" +msgid "Install ${POLIPO_DESC}." +msgstr "Instalovat ${POLIPO_DESC}." -msgctxt "PrivoxyShortcuts" +#, fuzzy +msgctxt "PolipoShortcuts" msgid "Add to Start Menu" -msgstr "Přidat do Nabídky start" +msgstr "Přidat do Nabídky Start" -msgctxt "PrivoxyShortcutsDesc" -msgid "Add ${PRIVOXY_NAME} to your Start menu." -msgstr "Přidat ${PRIVOXY_NAME} do vaší Nabídky start." +#, fuzzy +msgctxt "PolipoShortcutsDesc" +msgid "Add ${POLIPO_NAME} to your Start menu." +msgstr "Přidat ${POLIPO_NAME} do vaší Nabídky start." -msgctxt "PrivoxyStartup" +#, fuzzy +msgctxt "PolipoStartup" msgid "Run At Startup" msgstr "Spustit při startu" -msgctxt "PrivoxyStartupDesc" -msgid "Automatically run ${PRIVOXY_NAME} at startup." -msgstr "Automaticky spustit ${PRIVOXY_NAME} při startu." +#, fuzzy +msgctxt "PolipoStartupDesc" +msgid "Automatically run ${POLIPO_NAME} at startup." +msgstr "Automaticky spustit ${POLIPO_NAME} při startu." msgctxt "TorbuttonGroupDesc" msgid "" @@ -303,3 +308,4 @@ "\n" "Pokud preferujete instalovat Tor bez prohlížeče Firefox, jednoduše\n" "klikněte na Pokračovat." + diff -Nru vidalia-0.1.13/pkg/win32/de/vidalia_de.po vidalia-0.2.8/pkg/win32/de/vidalia_de.po --- vidalia-0.1.13/pkg/win32/de/vidalia_de.po 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/pkg/win32/de/vidalia_de.po 2010-03-08 17:29:32.000000000 +0000 @@ -3,8 +3,8 @@ "Project-Id-Version: Vidalia\n" "Report-Msgid-Bugs-To: translations@vidalia-project.net\n" "POT-Creation-Date: 2008-07-12 05:29+0000\n" -"PO-Revision-Date: 2008-12-29 22:13+0000\n" -"Last-Translator: Matt \n" +"PO-Revision-Date: 2010-03-03 17:10-0700\n" +"Last-Translator: CS \n" "Language-Team: translations@vidalia-project.net\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -18,25 +18,25 @@ msgctxt "BundleWelcomeText" msgid "" -"This wizard will guide you through the installation of Tor, Vidalia, " -"Privoxy, and Torbutton.\n" +"This wizard will guide you through the installation of Tor, Vidalia, Polipo, " +"and Torbutton.\n" "\n" "Tor is a system for using the Internet anonymously, helping you anonymize " "Web browsing and publishing, instant messaging, IRC, and more. Vidalia is a " "GUI that helps you control, monitor, and configure Tor.\n" "\n" -"Privoxy is a filtering web proxy that protects your privacy and helps remove " -"ads, banners, and popups.\n" +"Polipo is a caching web proxy that helps increase performance of browsing " +"the web through Tor.\n" "\n" "Torbutton is a Firefox extension that allows you to quickly enable or " "disable anonymous web browsing.\n" "\n" -"If you have previously installed Tor, Vidalia, Privoxy, or Firefox, please " +"If you have previously installed Tor, Vidalia, Polipo, or Firefox, please " "make sure they are not running before continuing this installation.\n" "\n" "$_CLICK" msgstr "" -"Dieser Assistent wird Sie durch die Installation von Tor, Vidaliam Privoxy " +"Dieser Assistent wird Sie durch die Installation von Tor, Vidalia, Polipo " "und Torbutton begleiten.\n" "\n" "Tor ist ein System, um das Internet anonym zu nutzen. Es anonymisiert das " @@ -44,13 +44,13 @@ "Vidalia ist eine Oberfläche zur Einrichtung, Steuerung und Überwachung von " "Tor.\n" "\n" -"Privoxy ist ein filternder Webproxy, der Ihnen hilft, Ihre Privatphäre zu " -"schützen und Werbung, Banner und Popups entfernt.\n" +"Polipo ist ein filternder Webproxy, welcher die Leistung des Webbrowsens " +"mittels Tor erhöht.\n" "\n" -"Torbutton ist eine Erweiterung für Firefox, die das schnelle An- und " +"Torbutton ist eine Erweiterung für Firefox, die das schnelle Ein- und " "Ausschalten des anonymes Webbrowsens ermöglicht.\n" "\n" -"Sollten Sie Tor, Vidalia, Privoxy oder Firefox bereits früher installiert " +"Sollten Sie Tor, Vidalia, Polipo oder Firefox bereits früher installiert " "haben, stellen Sie sicher, dass diese Programme nicht laufen, bevor Sie die " "Installation fortsetzen.\n" "\n" @@ -72,9 +72,10 @@ "\n" "If you installed Torbutton, you will need to restart Firefox." msgstr "" -"Die Installation wird abgeschlossen.\n" +"Die Installation ist abgeschlossen.\n" "Bitte besuchen Sie https://www.torproject.org/docs/tor-doc-windows um zu " "erfahren, wie Sie Ihre Anwendungen zur Benutzung mit Tor einrichten können.\n" +"\n" "Sollten Sie Torbutton installiert haben, müssen Sie Firefox neu starten." msgctxt "BundleRunNow" @@ -112,7 +113,7 @@ msgctxt "VidaliaLinkText" msgid "${VIDALIA_NAME} homepage" -msgstr "${VIDALIA_NAME} Homepage" +msgstr "${VIDALIA_NAME} Webseite" msgctxt "VidaliaAppDesc" msgid "Vidalia is a GUI that helps you control, monitor, and configure Tor." @@ -146,7 +147,7 @@ "Web browsing and publishing, instant messaging, IRC, and more." msgstr "" "Tor ist ein System, um das Internet anonym zu nutzen. Es anonymisiert das " -"Browsen, das Veröffentlichen von Inhalten, Instant Messaging, IRC, usw." +"Webbrowsen, das Veröffentlichen von Inhalten, Instant Messaging, IRC, usw." msgctxt "TorUninstDesc" msgid "Remove ${TOR_DESC}." @@ -183,45 +184,45 @@ msgid "Add ${TOR_NAME} to your Start menu." msgstr "${TOR_NAME} zu Ihrem Startmenü hinzufügen." -msgctxt "PrivoxyGroupDesc" +msgctxt "PolipoGroupDesc" msgid "" -"Privoxy is a filtering web proxy that protects your privacy and helps remove " -"ads, banners, and popups." +"Polipo is a caching web proxy that increases performance of web browsing " +"through Tor." msgstr "" -"Privoxy ist ein filternder Webproxy, der Ihnen hilft, Ihre Privatphäre zu " -"schützen und Werbung, Banner und Popups entfernt." +"Polipo ist ein speichernder Web-Proxy, der die Leistung des Webbrowsens " +"durch Tor erhöht." -msgctxt "PrivoxyUninstDesc" -msgid "Remove ${PRIVOXY_DESC}." -msgstr "Entferne ${PRIVOXY_DESC}." +msgctxt "PolipoUninstDesc" +msgid "Remove ${POLIPO_DESC}." +msgstr "Entferne ${POLIPO_DESC}." -msgctxt "PrivoxyAppDesc" -msgid "Install ${PRIVOXY_DESC}." -msgstr "Installiere ${PRIVOXY_DESC}." +msgctxt "PolipoAppDesc" +msgid "Install ${POLIPO_DESC}." +msgstr "Installiere ${POLIPO_DESC}." -msgctxt "PrivoxyShortcuts" +msgctxt "PolipoShortcuts" msgid "Add to Start Menu" msgstr "Zum Startmenü hinzufügen" -msgctxt "PrivoxyShortcutsDesc" -msgid "Add ${PRIVOXY_NAME} to your Start menu." -msgstr "${PRIVOXY_NAME} zu Ihrem Startmenü hinzufügen." +msgctxt "PolipoShortcutsDesc" +msgid "Add ${POLIPO_NAME} to your Start menu." +msgstr "${POLIPO_NAME} zu Ihrem Startmenü hinzufügen." -msgctxt "PrivoxyStartup" +msgctxt "PolipoStartup" msgid "Run At Startup" msgstr "Beim Systemstart ausführen" -msgctxt "PrivoxyStartupDesc" -msgid "Automatically run ${PRIVOXY_NAME} at startup." -msgstr "${PRIVOXY_NAME} beim Systemstart automatisch ausführen." +msgctxt "PolipoStartupDesc" +msgid "Automatically run ${POLIPO_NAME} at startup." +msgstr "${POLIPO_NAME} beim Systemstart automatisch ausführen." msgctxt "TorbuttonGroupDesc" msgid "" "Torbutton is a Firefox extension that allows you to quickly enable or " "disable anonymous web browsing." msgstr "" -"Torbutton ist eine Erweiterung für Firefox, die das schnelle An- und " -"Ausschalten des anonymes Webbrowsens ermöglicht." +"Torbutton ist eine Erweiterung für Firefox, die das schnelle Ein- und " +"Ausschalten des anonymen Webbrowsens ermöglicht." msgctxt "TorbuttonUninstDesc" msgid "Remove ${TORBUTTON_DESC}." @@ -284,7 +285,7 @@ "\n" "Wenn Sie Firefox installieren wollen, klicken Sie bitte auf Abbrechen und " "besuchen\n" -"anschließend die Firefox Downloadseite unter" +"Sie anschliessend die Firefox Downloadseite unter" msgctxt "FirefoxWarningPageLowerText" msgid "" Binary files /tmp/KPMk4L7DHV/vidalia-0.1.13/pkg/win32/default-header.bmp and /tmp/EwwyCgG7oU/vidalia-0.2.8/pkg/win32/default-header.bmp differ Binary files /tmp/KPMk4L7DHV/vidalia-0.1.13/pkg/win32/default-welcome.bmp and /tmp/EwwyCgG7oU/vidalia-0.2.8/pkg/win32/default-welcome.bmp differ diff -Nru vidalia-0.1.13/pkg/win32/en/vidalia_en.po vidalia-0.2.8/pkg/win32/en/vidalia_en.po --- vidalia-0.1.13/pkg/win32/en/vidalia_en.po 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/pkg/win32/en/vidalia_en.po 2009-08-31 04:27:41.000000000 +0100 @@ -3,7 +3,7 @@ "Project-Id-Version: Vidalia\n" "Report-Msgid-Bugs-To: translations@vidalia-project.net\n" "POT-Creation-Date: 2008-07-12 05:29+0000\n" -"PO-Revision-Date: 2008-07-17 02:50+0000\n" +"PO-Revision-Date: 2009-08-31 03:26+0000\n" "Last-Translator: Matt \n" "Language-Team: translations@vidalia-project.net\n" "MIME-Version: 1.0\n" @@ -18,38 +18,38 @@ msgctxt "BundleWelcomeText" msgid "" -"This wizard will guide you through the installation of Tor, Vidalia, " -"Privoxy, and Torbutton.\n" +"This wizard will guide you through the installation of Tor, Vidalia, Polipo, " +"and Torbutton.\n" "\n" "Tor is a system for using the Internet anonymously, helping you anonymize " "Web browsing and publishing, instant messaging, IRC, and more. Vidalia is a " "GUI that helps you control, monitor, and configure Tor.\n" "\n" -"Privoxy is a filtering web proxy that protects your privacy and helps remove " -"ads, banners, and popups.\n" +"Polipo is a caching web proxy that helps increase performance of browsing " +"the web through Tor.\n" "\n" "Torbutton is a Firefox extension that allows you to quickly enable or " "disable anonymous web browsing.\n" "\n" -"If you have previously installed Tor, Vidalia, Privoxy, or Firefox, please " +"If you have previously installed Tor, Vidalia, Polipo, or Firefox, please " "make sure they are not running before continuing this installation.\n" "\n" "$_CLICK" msgstr "" -"This wizard will guide you through the installation of Tor, Vidalia, " -"Privoxy, and Torbutton.\n" +"This wizard will guide you through the installation of Tor, Vidalia, Polipo, " +"and Torbutton.\n" "\n" "Tor is a system for using the Internet anonymously, helping you anonymize " "Web browsing and publishing, instant messaging, IRC, and more. Vidalia is a " "GUI that helps you control, monitor, and configure Tor.\n" "\n" -"Privoxy is a filtering web proxy that protects your privacy and helps remove " -"ads, banners, and popups.\n" +"Polipo is a caching web proxy that helps increase performance of browsing " +"the web through Tor.\n" "\n" "Torbutton is a Firefox extension that allows you to quickly enable or " "disable anonymous web browsing.\n" "\n" -"If you have previously installed Tor, Vidalia, Privoxy, or Firefox, please " +"If you have previously installed Tor, Vidalia, Polipo, or Firefox, please " "make sure they are not running before continuing this installation.\n" "\n" "$_CLICK" @@ -134,7 +134,7 @@ msgctxt "VidaliaRunNow" msgid "Run ${VIDALIA_NAME}" -msgstr "Run ${VIDALIA_NAME} now" +msgstr "Run ${VIDALIA_NAME}" msgctxt "TorGroupDesc" msgid "" @@ -178,37 +178,37 @@ msgid "Add ${TOR_NAME} to your Start menu." msgstr "Add ${TOR_NAME} to your Start menu." -msgctxt "PrivoxyGroupDesc" +msgctxt "PolipoGroupDesc" msgid "" -"Privoxy is a filtering web proxy that protects your privacy and helps remove " -"ads, banners, and popups." +"Polipo is a caching web proxy that increases performance of web browsing " +"through Tor." msgstr "" -"Privoxy is a filtering web proxy that protects your privacy and helps remove " -"ads, banners, and popups." +"Polipo is a caching web proxy that increases performance of web browsing " +"through Tor." -msgctxt "PrivoxyUninstDesc" -msgid "Remove ${PRIVOXY_DESC}." -msgstr "Remove ${PRIVOXY_DESC}." - -msgctxt "PrivoxyAppDesc" -msgid "Install ${PRIVOXY_DESC}." -msgstr "Install ${PRIVOXY_DESC}." +msgctxt "PolipoUninstDesc" +msgid "Remove ${POLIPO_DESC}." +msgstr "Remove ${POLIPO_DESC}." -msgctxt "PrivoxyShortcuts" +msgctxt "PolipoAppDesc" +msgid "Install ${POLIPO_DESC}." +msgstr "Install ${POLIPO_DESC}." + +msgctxt "PolipoShortcuts" msgid "Add to Start Menu" msgstr "Add to Start Menu" -msgctxt "PrivoxyShortcutsDesc" -msgid "Add ${PRIVOXY_NAME} to your Start menu." -msgstr "Add ${PRIVOXY_NAME} to your Start menu." +msgctxt "PolipoShortcutsDesc" +msgid "Add ${POLIPO_NAME} to your Start menu." +msgstr "Add ${POLIPO_NAME} to your Start menu." -msgctxt "PrivoxyStartup" +msgctxt "PolipoStartup" msgid "Run At Startup" msgstr "Run At Startup" -msgctxt "PrivoxyStartupDesc" -msgid "Automatically run ${PRIVOXY_NAME} at startup." -msgstr "Automatically run ${PRIVOXY_NAME} at startup." +msgctxt "PolipoStartupDesc" +msgid "Automatically run ${POLIPO_NAME} at startup." +msgstr "Automatically run ${POLIPO_NAME} at startup." msgctxt "TorbuttonGroupDesc" msgid "" @@ -252,12 +252,13 @@ msgctxt "FirefoxWarningPageTitle" msgid "Firefox is not installed" -msgstr "" +msgstr "Firefox is not installed" msgctxt "FirefoxWarningPageSubtitle" msgid "" "We recommend that you install Firefox before continuing, for best safety." msgstr "" +"We recommend that you install Firefox before continuing, for best safety." msgctxt "FirefoxWarningPageUpperText" msgid "" @@ -269,6 +270,13 @@ "If you would like to install Firefox, please press Cancel, then go\n" "to the Firefox download page at" msgstr "" +"The Mozilla Firefox Web browser is not installed on your computer.\n" +"Tor will work with other browsers, such as Internet Explorer, but\n" +"is easier to use with Firefox, which also does a better job of\n" +"protecting your anonymity.\n" +"\n" +"If you would like to install Firefox, please press Cancel, then go\n" +"to the Firefox download page at" msgctxt "FirefoxWarningPageLowerText" msgid "" @@ -278,3 +286,8 @@ "Or, if you would prefer to install Tor without Firefox, simply\n" "press Next to continue." msgstr "" +"When you are done installing Firefox, you can once again run the\n" +"Tor installer.\n" +"\n" +"Or, if you would prefer to install Tor without Firefox, simply\n" +"press Next to continue." diff -Nru vidalia-0.1.13/pkg/win32/es/vidalia_es.po vidalia-0.2.8/pkg/win32/es/vidalia_es.po --- vidalia-0.1.13/pkg/win32/es/vidalia_es.po 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/pkg/win32/es/vidalia_es.po 2009-12-01 02:42:46.000000000 +0000 @@ -3,8 +3,8 @@ "Project-Id-Version: Vidalia Windows Installers\n" "Report-Msgid-Bugs-To: translations@vidalia-project.net\n" "POT-Creation-Date: 2008-07-12 05:29+0000\n" -"PO-Revision-Date: 2008-09-16 08:15+0000\n" -"Last-Translator: Susan Neni Meiro \n" +"PO-Revision-Date: 2009-11-18 18:44-0700\n" +"Last-Translator: ariel viera \n" "Language-Team: none\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -18,20 +18,20 @@ msgctxt "BundleWelcomeText" msgid "" -"This wizard will guide you through the installation of Tor, Vidalia, " -"Privoxy, and Torbutton.\n" +"This wizard will guide you through the installation of Tor, Vidalia, Polipo, " +"and Torbutton.\n" "\n" "Tor is a system for using the Internet anonymously, helping you anonymize " "Web browsing and publishing, instant messaging, IRC, and more. Vidalia is a " "GUI that helps you control, monitor, and configure Tor.\n" "\n" -"Privoxy is a filtering web proxy that protects your privacy and helps remove " -"ads, banners, and popups.\n" +"Polipo is a caching web proxy that helps increase performance of browsing " +"the web through Tor.\n" "\n" "Torbutton is a Firefox extension that allows you to quickly enable or " "disable anonymous web browsing.\n" "\n" -"If you have previously installed Tor, Vidalia, Privoxy, or Firefox, please " +"If you have previously installed Tor, Vidalia, Polipo, or Firefox, please " "make sure they are not running before continuing this installation.\n" "\n" "$_CLICK" @@ -39,16 +39,14 @@ "Este asistente le guiará a través de la instalación de Tor, Vidalia, " "Privoxy, y Torbutton.\n" "\n" -"Tor es un sistema para anonimizar Internet, ayudándolo a anonimizar su " -"navegación Web y publicaciones, mensajería instantánea, IRC, y más. Vidalia " -"es una interfaz de usuario que le ayuda a controlar, monotorizar y " -"configurar Tor.\n" -"\n" -"Privoxy es un proxy de filtrado de web que proteje su privacidad y ayuda a " -"eliminar publicidad, banners y popups.\n" -"\n" -"Torbutton es una extensión para Firefox que le permite habilitar o " -"deshabilitar rapidamente la navegación anónima por la web.\n" +"Tor es un sistema para lograr el anonimato en Internet, ayudándolo a hacer " +"anónima su navegación Web, publicaciones, mensajería instantánea, IRC, y " +"más. Vidalia es una interfaz de usuario que le ayuda a controlar, " +"monotorizar y configurar Tor.\n" +"\n" +"Polipo es un web proxy cache que ayuda a mejorar el performance al navegar " +"por la web via Tor.Torbutton es una extensión para Firefox que le permite " +"habilitar o deshabilitar rapidamente la navegación anónima por la web.\n" "\n" "Si ha instalado previamente Tor, Vidalia, Privoxy, o Firefox, por favor " "asegúrese que no se estén ejecutando antes de continuar con la instalación.\n" @@ -183,37 +181,42 @@ msgid "Add ${TOR_NAME} to your Start menu." msgstr "Añadir ${TOR_NAME} al menú Inicio" -msgctxt "PrivoxyGroupDesc" +msgctxt "PolipoGroupDesc" msgid "" -"Privoxy is a filtering web proxy that protects your privacy and helps remove " -"ads, banners, and popups." +"Polipo is a caching web proxy that increases performance of web browsing " +"through Tor." msgstr "" -"Privoxy es un proxy de filtrado de web que protege su privacidad y ayuda a " -"eliminar publicidad, banners y popups." - -msgctxt "PrivoxyUninstDesc" -msgid "Remove ${PRIVOXY_DESC}." -msgstr "Eliminar ${PRIVOXY_DESC}." +"Polipo es un cache web proxy que mejora el performance de la navegación " +"usando Tor." -msgctxt "PrivoxyAppDesc" -msgid "Install ${PRIVOXY_DESC}." -msgstr "Instalar ${PRIVOXY_DESC}." +msgctxt "PolipoUninstDesc" +msgid "Remove ${POLIPO_DESC}." +msgstr "Eliminar ${POLIPO_DESC}." + +#, fuzzy +msgctxt "PolipoAppDesc" +msgid "Install ${POLIPO_DESC}." +msgstr "Instalar ${POLIPO_DESC}." -msgctxt "PrivoxyShortcuts" +#, fuzzy +msgctxt "PolipoShortcuts" msgid "Add to Start Menu" msgstr "Añadir al menú Inicio" -msgctxt "PrivoxyShortcutsDesc" -msgid "Add ${PRIVOXY_NAME} to your Start menu." -msgstr "Añadir ${PRIVOXY_NAME} a al menú Inicio." +#, fuzzy +msgctxt "PolipoShortcutsDesc" +msgid "Add ${POLIPO_NAME} to your Start menu." +msgstr "Añadir ${POLIPO_NAME} a al menú Inicio." -msgctxt "PrivoxyStartup" +#, fuzzy +msgctxt "PolipoStartup" msgid "Run At Startup" -msgstr "Ejecutar al iniciar sesión" +msgstr "Ejecutar al inciar sesión" -msgctxt "PrivoxyStartupDesc" -msgid "Automatically run ${PRIVOXY_NAME} at startup." -msgstr "Ejecutar automáticamente ${PRIVOXY_NAME} al iniciar sesión." +#, fuzzy +msgctxt "PolipoStartupDesc" +msgid "Automatically run ${POLIPO_NAME} at startup." +msgstr "Ejecutar automáticamente ${POLIPO_NAME} al iniciar sesión." msgctxt "TorbuttonGroupDesc" msgid "" @@ -263,8 +266,7 @@ msgid "" "We recommend that you install Firefox before continuing, for best safety." msgstr "" -"Le recomendamos que instale Firefox antes de continuar, para mayor " -"seguridad." +"Le recomendamos que instale Firefox antes de continuar, para mayor seguridad." msgctxt "FirefoxWarningPageUpperText" msgid "" diff -Nru vidalia-0.1.13/pkg/win32/et/vidalia.po vidalia-0.2.8/pkg/win32/et/vidalia.po --- vidalia-0.1.13/pkg/win32/et/vidalia.po 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/pkg/win32/et/vidalia.po 2010-02-18 08:01:00.000000000 +0000 @@ -0,0 +1,271 @@ +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: translations@vidalia-project.net\n" +"POT-Creation-Date: 2008-07-12 05:29+0000\n" +"PO-Revision-Date: 2010-02-12 13:08-0700\n" +"Last-Translator: Heiki Ojasild \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Pootle 1.1.0\n" + +msgctxt "BundleSetupCaption" +msgid "${BUNDLE_NAME} setup" +msgstr "${BUNDLE_NAME} installeerija" + +msgctxt "BundleWelcomeText" +msgid "" +"This wizard will guide you through the installation of Tor, " +"Vidalia, Polipo, and Torbutton.\n\nTor is a system for using the " +"Internet anonymously, helping you anonymize Web browsing and publishing, " +"instant messaging, IRC, and more. Vidalia is a GUI that helps you " +"control, monitor, and configure Tor.\n\nPolipo is a caching web proxy " +"that helps increase performance of browsing the web through " +"Tor.\n\nTorbutton is a Firefox extension that allows you to quickly " +"enable or disable anonymous web browsing.\n\nIf you have previously " +"installed Tor, Vidalia, Polipo, or Firefox, please make sure they are " +"not running before continuing this installation.\n\n$_CLICK" +msgstr "" +"See programm juhatab sind läbi Tori, Vidalia, Polipon ning Torbuttoni " +"installeerimise.\n" +"\n" +"Tor on süsteem Interneti anonüümseks kasutamiseks, mis aitab sul jääda " +"anonüümseks veebis surfates ja infot avaldades, ning kasutades kiirsuhtlust, " +"IRCd ja palju muud. Vidalia on graafiline programm, mis aitab sul " +"kontrollida, jälgida ning konfigureerida Tori.\n" +"\n" +"Polipo on vaheserver, mis aitab sul tõsta veebi läbi Tori lehitsemise " +"jõudlust, salvestades ajutiselt osa infot, mille veebiserverid sulle " +"saadavad.\n" +"\n" +"Torbutton on Mozilla Firefoxi lisa, mis laseb sul kiiresti vahetada " +"anonüümse ja mitteanonüümse veebilehitsemise vahel.\n" +"\n" +"Kui sa oled varem installeerinud Tori, Vidalia, Polipo või Firefoxi, siis " +"tee palun kindlaks, et nad ei jookse, enne kui jätkad installatsiooniga.\n" +"\n" +"$_CLICK" + +msgctxt "BundleWelcomeTitle" +msgid "Welcome to the ${BUNDLE_NAME} Setup Wizard" +msgstr "Tere tulemast ${BUNDLE_NAME} installeerimisprogrammi" + +msgctxt "BundleLinkText" +msgid "${TOR_NAME} installation documentation" +msgstr "${TOR_NAME} installatsioonidokumendid" + +msgctxt "BundleFinishText" +msgid "Installation is complete.\nPlease see https://www.torproject.org/docs/tor-doc-windows to learn how to configure your applications to use Tor.\n\nIf you installed Torbutton, you will need to restart Firefox." +msgstr "" +"Installatsioon on lõpetatud.\n" +"Palun vaata https://www.torproject.org/docs/tor-doc-windows selleks, et " +"õppida, kuidas konfigureerida oma rakendused Tori kasutama.\n" +"\n" +"Kui sa installeerisid Torbuttoni, siis sa pead Firefoxi taaskäivitama." + +msgctxt "BundleRunNow" +msgid "Run installed components now" +msgstr "Käivita installeeritud komponendid nüüd" + +msgctxt "VidaliaGroupDesc" +msgid "Vidalia is a GUI that helps you control, monitor, and configure Tor." +msgstr "" +"Vidalia on graafiline programm, mis aitab sul kontrollida, jälgida ning " +"konfigureerida Tori." + +msgctxt "VidaliaUninstDesc" +msgid "Remove ${VIDALIA_DESC}." +msgstr "Eemalda ${VIDALIA_DESC}." + +msgctxt "VidaliaSetupCaption" +msgid "${VIDALIA_NAME} setup" +msgstr "${VIDALIA_NAME} installeerija" + +msgctxt "VidaliaWelcomeText" +msgid "This wizard will guide you through the installation of Vidalia, a GUI that helps you control, monitor, and configure Tor.\n\n$_CLICK" +msgstr "" +"See programm juhatab su läbi Vidalia installeerimise.\n" +"\n" +"$_CLICK" + +msgctxt "VidaliaWelcomeTitle" +msgid "Welcome to the ${VIDALIA_NAME} Setup Wizard" +msgstr "Tere tulemast ${VIDALIA_NAME} installeerimisprogrammi" + +msgctxt "VidaliaLinkText" +msgid "${VIDALIA_NAME} homepage" +msgstr "${VIDALIA_NAME} koduleht" + +msgctxt "VidaliaAppDesc" +msgid "Vidalia is a GUI that helps you control, monitor, and configure Tor." +msgstr "" +"Vidalia on graafiline programm, mis aitab sul kontrollida, jälgida ning " +"konfigureerida Tori." + +msgctxt "VidaliaStartup" +msgid "Run At Startup" +msgstr "Käivita automaatselt sisselogimisel" + +msgctxt "VidaliaStartupDesc" +msgid "Automatically run ${VIDALIA_NAME} at startup." +msgstr "Käivita ${VIDALIA_NAME} automaatselt sisselogimisel." + +msgctxt "VidaliaShortcuts" +msgid "Add to Start Menu" +msgstr "Lisa Start menüüsse." + +msgctxt "VidaliaShortcutsDesc" +msgid "Add ${VIDALIA_NAME} to your Start menu." +msgstr "Lisa ${VIDALIA_NAME} sinu Start menüüsse." + +msgctxt "VidaliaRunNow" +msgid "Run ${VIDALIA_NAME}" +msgstr "Käivita ${VIDALIA_NAME}" + +msgctxt "TorGroupDesc" +msgid "Tor is a system for using the Internet anonymously, helping you anonymize Web browsing and publishing, instant messaging, IRC, and more." +msgstr "" +"Tor on süsteem Interneti anonüümseks kasutamiseks, aidates sul muuta " +"veebilehitsemise, veebis avaldamise, kiirsuhtluse, IRC jpm anonüümseks." + +msgctxt "TorUninstDesc" +msgid "Remove ${TOR_DESC}." +msgstr "Eemalda ${TOR_DESC}." + +msgctxt "TorAppDesc" +msgid "Install ${TOR_DESC}." +msgstr "Installeeri ${TOR_DESC}." + +msgctxt "TorAskOverwriteTorrc" +msgid "You already have a Tor configuration file.$\n$\nDo you want to overwrite it with the default sample configuration file?" +msgstr "" +"Sul juba on Tori konfiguratsioonifail.$\n" +"$\n" +"Kas sa soovid selle üle kirjutada tavapärase näidiskonfiguratsioonifailiga?" + +msgctxt "TorDocumentation" +msgid "Documentation" +msgstr "Dokumentatsioon" + +msgctxt "TorDocumentationDesc" +msgid "Install ${TOR_NAME} documentation." +msgstr "Installeeri ${TOR_NAME} dokumentatsioon." + +msgctxt "TorShortcuts" +msgid "Add to Start Menu" +msgstr "Lisa Start menüüsse" + +msgctxt "TorShortcutsDesc" +msgid "Add ${TOR_NAME} to your Start menu." +msgstr "Lisa ${TOR_NAME} sinu Start menüüsse." + +msgctxt "PolipoGroupDesc" +msgid "Polipo is a caching web proxy that increases performance of web browsing through Tor." +msgstr "" +"Polipo on veebi vaheserver, mis suurendab veebi läbi Tori lehitsemise " +"jõudlust." + +msgctxt "PolipoUninstDesc" +msgid "Remove ${POLIPO_DESC}." +msgstr "Eemalda ${POLIPO_DESC}." + +msgctxt "PolipoAppDesc" +msgid "Install ${POLIPO_DESC}." +msgstr "Installeeri ${POLIPO_DESC}." + +msgctxt "PolipoShortcuts" +msgid "Add to Start Menu" +msgstr "Lisa Start menüüsse." + +msgctxt "PolipoShortcutsDesc" +msgid "Add ${POLIPO_NAME} to your Start menu." +msgstr "Lisa ${POLIPO_NAME} sinu Start menüüsse." + +msgctxt "PolipoStartup" +msgid "Run At Startup" +msgstr "Käivita sisselogimisel" + +msgctxt "PolipoStartupDesc" +msgid "Automatically run ${POLIPO_NAME} at startup." +msgstr "Automaatselt käivita ${POLIPO_NAME} sisselogimisel." + +msgctxt "TorbuttonGroupDesc" +msgid "Torbutton is a Firefox extension that allows you to quickly enable or disable anonymous web browsing." +msgstr "" +"Torbutton on Mozilla Firefoxi lisa, mis lubab sul kiiresti lülitada " +"anonüümset veebilehitsemist sisse ja välja." + +msgctxt "TorbuttonUninstDesc" +msgid "Remove ${TORBUTTON_DESC}." +msgstr "Eemalda ${TORBUTTON_DESC}." + +msgctxt "TorbuttonAppDesc" +msgid "Install ${TORBUTTON_DESC}." +msgstr "Installeeri ${TORBUTTON_DESC}." + +msgctxt "TorbuttonAddToFirefox" +msgid "Add to Firefox" +msgstr "Lisa Mozilla Firefoxile" + +msgctxt "TorbuttonAddToFirefoxDesc" +msgid "Add the ${TORBUTTON_DESC} extension to Firefox." +msgstr "Lisa ${TORBUTTON_DESC} lisa Mozilla Firefoxile." + +msgctxt "TorbuttonFirefoxNotFound" +msgid "Firefox was not found on your system. Not installing Torbutton." +msgstr "" +"Mozilla Firefoxi ei leitud sinu süsteemist. Torbuttonit ei installeerita." + +msgctxt "AppData" +msgid "Application Data" +msgstr "Rakenduse andmed" + +msgctxt "AppDataUninstDesc" +msgid "Remove saved application data and configuration files." +msgstr "Eemalda salvestatud rakenduse andmed ja konfiguratsioonifailid." + +msgctxt "LanguageCode" +msgid "en" +msgstr "et" + +msgctxt "FirefoxWarningPageTitle" +msgid "Firefox is not installed" +msgstr "Mozilla Firefox ei ole installeeritud." + +msgctxt "FirefoxWarningPageSubtitle" +msgid "We recommend that you install Firefox before continuing, for best safety." +msgstr "" +"Me soovitame sul installeerida parema turvalisuse huvides enne jätkamist " +"Mozilla Firefox." + +msgctxt "FirefoxWarningPageUpperText" +msgid "The Mozilla Firefox Web browser is not installed on your computer.\n" +"Tor will work with other browsers, such as Internet Explorer, but\n" +"is easier to use with Firefox, which also does a better job of\n" +"protecting your anonymity." +"\n\n" +"If you would like to install Firefox, please press Cancel, then go\n" +"to the Firefox download page at" +msgstr "" +"Mozilla Firefoxi veebilehitseja ei ole installeeritud sinu arvutis.\n" +"Tor töötab teiste veebilehitsejatega, nagu Internet Explorer, kuid\n" +"on palju lihtsamini kasutatav Firefoxiga, mis ühtlasi kaitseb\n" +"su anonüümsust paremini.\n" +"\n" +"Kui sa soovid installeerida Firefoxi, siis katkesta installatsioon ja mine\n" +"Firefoxi allalaadimislehele siin:" + +msgctxt "FirefoxWarningPageLowerText" +msgid "When you are done installing Firefox, you can once again run the\n" +"Tor installer." +"\n\n" +"Or, if you would prefer to install Tor without Firefox, simply\n" +"press Next to continue." +msgstr "" +"Kui sa oled Firefoxi installeerimise lõpetanud, siis võid Tori installeri\n" +"uuesti käivitada.\n" +"\n" +"Kui sa soovid Tori installeerida ilma Firefoxita, jätka lihtsalt " +"installatsiooniga." diff -Nru vidalia-0.1.13/pkg/win32/fa/vidalia_fa.po vidalia-0.2.8/pkg/win32/fa/vidalia_fa.po --- vidalia-0.1.13/pkg/win32/fa/vidalia_fa.po 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/pkg/win32/fa/vidalia_fa.po 2009-08-31 03:49:46.000000000 +0100 @@ -3,8 +3,8 @@ "Project-Id-Version: Vidalia\n" "Report-Msgid-Bugs-To: translations@vidalia-project.net\n" "POT-Creation-Date: 2008-07-12 05:29+0000\n" -"PO-Revision-Date: 2008-07-17 03:19+0000\n" -"Last-Translator: Matt \n" +"PO-Revision-Date: 2009-06-23 05:14+0000\n" +"Last-Translator: Nami B \n" "Language-Team: translations@vidalia-project.net\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -20,42 +20,46 @@ #, fuzzy msgctxt "BundleWelcomeText" msgid "" -"This wizard will guide you through the installation of Tor, Vidalia, " -"Privoxy, and Torbutton.\n" +"This wizard will guide you through the installation of Tor, Vidalia, Polipo, " +"and Torbutton.\n" "\n" "Tor is a system for using the Internet anonymously, helping you anonymize " "Web browsing and publishing, instant messaging, IRC, and more. Vidalia is a " "GUI that helps you control, monitor, and configure Tor.\n" "\n" -"Privoxy is a filtering web proxy that protects your privacy and helps remove " -"ads, banners, and popups.\n" +"Polipo is a caching web proxy that helps increase performance of browsing " +"the web through Tor.\n" "\n" "Torbutton is a Firefox extension that allows you to quickly enable or " "disable anonymous web browsing.\n" "\n" -"If you have previously installed Tor, Vidalia, Privoxy, or Firefox, please " +"If you have previously installed Tor, Vidalia, Polipo, or Firefox, please " "make sure they are not running before continuing this installation.\n" "\n" "$_CLICK" msgstr "" -"ا?ن دست?ار شما را در سرتاسر ?ار?ذار? تور، و?دال?ا، ?ر?وا?س? و د?مه تور هدا?ت " -"م? ?ند.\n" -"\n" -"ا?ر شما ??شتر تور، و?دال?ا، ?ر?وا?س? ?ا فا?رفا?س را ?ار?ذار? ?رده ا?د، " -"خواهشمند است ??ش از ادامه دادن ا?ن ?ار?ذار? اطم?نان ??دا ?ن?د ?ه آنها درحال " -"اجرا نم? باشند.\n" +"این دستیار شما را در طی بارگذاری تُر، ویدالیا، پریواکسی، و تُرباتِن راه‌نمایی " +"می‌کند.\n" "\n" +"تُر سیستمی برای استفاده از اینترنت به‌صورت ناشناس است و به شما کمک می‌کند که " +"کارهایی مثل گردش و نوشتن در وب، پیام فوری، IRC را مخفی کنید.\n" +"پریواکسی یک پراکسی برای فیلتر کردن وب است که از حریم شخصی شما محافظت می‌کند و " +"تبلیغات را حذف می‌کند.\n" +"تُرباتِن یک افزونه‌ی فایرفاکس است که به شما اجازه می‌دهد امکان گردش ناشناس در وب " +"را به‌سرعت فعال یا غیرفعال کنید.\n" +"اگر پیش از این تُر، ویدالیا، پریواکس، یا فایرفاکس را نصب کرده‌اید، خواهشمند " +"است از بسته بودن آن‌ها در حین نصب این برنامه اطمینان پیدا کنید.\n" "$_CLICK" #, fuzzy msgctxt "BundleWelcomeTitle" msgid "Welcome to the ${BUNDLE_NAME} Setup Wizard" -msgstr "به دست?ار بر?ا?? ${BUNDLE_NAME} خوش آمد?د" +msgstr "به دستیار تنظیم ${BUNDLE_NAME} خوش آمدید" #, fuzzy msgctxt "BundleLinkText" msgid "${TOR_NAME} installation documentation" -msgstr "مستندات ?ار?ذار? ${TOR_NAME}" +msgstr "مستندات بارگذاری ${TOR_NAME}" #, fuzzy msgctxt "BundleFinishText" @@ -184,39 +188,40 @@ msgid "Add ${TOR_NAME} to your Start menu." msgstr "افزودن ${TOR_NAME} به فهرست آغاز." -#, fuzzy -msgctxt "PrivoxyGroupDesc" +msgctxt "PolipoGroupDesc" msgid "" -"Privoxy is a filtering web proxy that protects your privacy and helps remove " -"ads, banners, and popups." -msgstr "?ار?ذار? ${PRIVOXY_DESC}." +"Polipo is a caching web proxy that increases performance of web browsing " +"through Tor." +msgstr "" -msgctxt "PrivoxyUninstDesc" -msgid "Remove ${PRIVOXY_DESC}." +msgctxt "PolipoUninstDesc" +msgid "Remove ${POLIPO_DESC}." msgstr "" #, fuzzy -msgctxt "PrivoxyAppDesc" -msgid "Install ${PRIVOXY_DESC}." -msgstr "?ار?ذار? ${PRIVOXY_DESC}." +msgctxt "PolipoAppDesc" +msgid "Install ${POLIPO_DESC}." +msgstr "?ار?ذار? ${POLIPO_DESC}." -msgctxt "PrivoxyShortcuts" +#, fuzzy +msgctxt "PolipoShortcuts" msgid "Add to Start Menu" msgstr "افزودن به فهرست آغاز" -msgctxt "PrivoxyShortcutsDesc" -msgid "Add ${PRIVOXY_NAME} to your Start menu." -msgstr "افزودن ${PRIVOXY_NAME} به فهرست آغاز." +#, fuzzy +msgctxt "PolipoShortcutsDesc" +msgid "Add ${POLIPO_NAME} to your Start menu." +msgstr "افزودن ${POLIPO_NAME} به فهرست آغاز." #, fuzzy -msgctxt "PrivoxyStartup" +msgctxt "PolipoStartup" msgid "Run At Startup" -msgstr "اجرا?ردن در راه انداز?" +msgstr "اجرا ?ردن در راه انداز?" #, fuzzy -msgctxt "PrivoxyStartupDesc" -msgid "Automatically run ${PRIVOXY_NAME} at startup." -msgstr "اجرا ?ردن ${PRIVOXY_NAME} در راه انداز? بطور خود?ار." +msgctxt "PolipoStartupDesc" +msgid "Automatically run ${POLIPO_NAME} at startup." +msgstr "اجرا ?ردن ${POLIPO_NAME} در راه انداز? بطور خود?ار." #, fuzzy msgctxt "TorbuttonGroupDesc" @@ -289,3 +294,4 @@ "Or, if you would prefer to install Tor without Firefox, simply\n" "press Next to continue." msgstr "" + diff -Nru vidalia-0.1.13/pkg/win32/fi/vidalia_fi.po vidalia-0.2.8/pkg/win32/fi/vidalia_fi.po --- vidalia-0.1.13/pkg/win32/fi/vidalia_fi.po 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/pkg/win32/fi/vidalia_fi.po 2010-04-09 07:59:53.000000000 +0100 @@ -3,8 +3,8 @@ "Project-Id-Version: Vidalia Windows Installers\n" "Report-Msgid-Bugs-To: translations@vidalia-project.net\n" "POT-Creation-Date: 2008-07-12 05:29+0000\n" -"PO-Revision-Date: 2009-02-07 23:34+0000\n" -"Last-Translator: Harri Vähätalo \n" +"PO-Revision-Date: 2010-04-08 15:41-0600\n" +"Last-Translator: AmaliaH \n" "Language-Team: none\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -18,39 +18,39 @@ msgctxt "BundleWelcomeText" msgid "" -"This wizard will guide you through the installation of Tor, Vidalia, " -"Privoxy, and Torbutton.\n" +"This wizard will guide you through the installation of Tor, Vidalia, Polipo, " +"and Torbutton.\n" "\n" "Tor is a system for using the Internet anonymously, helping you anonymize " "Web browsing and publishing, instant messaging, IRC, and more. Vidalia is a " "GUI that helps you control, monitor, and configure Tor.\n" "\n" -"Privoxy is a filtering web proxy that protects your privacy and helps remove " -"ads, banners, and popups.\n" +"Polipo is a caching web proxy that helps increase performance of browsing " +"the web through Tor.\n" "\n" "Torbutton is a Firefox extension that allows you to quickly enable or " "disable anonymous web browsing.\n" "\n" -"If you have previously installed Tor, Vidalia, Privoxy, or Firefox, please " +"If you have previously installed Tor, Vidalia, Polipo, or Firefox, please " "make sure they are not running before continuing this installation.\n" "\n" "$_CLICK" msgstr "" -"Tämä velho auttaa asentaakseen Tor-ohjelman, Vidalian, Privoxyn ja " -"Torbuttonin.\n" -"Tor on järjestelmä, jolla voi käyttää Internettiä tuntemattomasti tekemällä " -"anonyymiseksi sivujen selailun, pikaviestimisen, irkkaamisen ja muiden " -"käytön. Vidalia on käyttöliittymä ohjaamaan, seuraamaan ja säätämään Tor-" -"ohjelman toimintaa.\n" +"Tämä velho auttaa asentamaan Tor-ohjelman, Vidalian, Polipon ja Torbuttonin.\n" +"Tor on järjestelmä, jonka avulla voit käyttää Internettiä tuntemattomana " +"tekemällä anonyymiseksi sivujen selailun, pikaviestimisen, irkkaamisen ja " +"muiden vastaavien ohjelmien käytön. Vidalia on graafinen käyttöliittymä " +"jolla ohjataan, seurataan ja säädetään Tor-ohjelman toimintaa.\n" "\n" -"Privoxy on suodattava välityspalvelin, joka suojaa yksityisyyttä ja auttaa " -"poistamalla mainoksia, bannereita ja popup-ikkunoita.\n" +"Polipo on välimuistina toimiva web välityspalvelin, joka auttaa parantaa " +"nettiselailun nopeutta Torria käytettäessä.\n" "\n" "Torbutton on Firefoxin lisäosa, jolla voi helposti ottaa käyttöön tai " "poistaa käytöstä anonyymisen sivujen selailun.\n" "\n" -"Jos koneelle on jo asennettu Tor, Vidalia tai Privoxy, suositeltavaa on " -"tarkistaa ettei mikään niistä ole päällä ennen asennuksen jatkamista.\n" +"Jos koneelle on jo asennettu Tor, Vidalia, Polipo, Privoxy tai Firefox, on " +"suositeltavaa tarkistaa ettei mikään niistä ole päällä ennen tämän " +"asennuksen jatkamista.\n" "\n" "$_CLICK" @@ -60,7 +60,7 @@ msgctxt "BundleLinkText" msgid "${TOR_NAME} installation documentation" -msgstr "${TOR_NAME}-asennusohje" +msgstr "${TOR_NAME}-asennusdokumentaatio" msgctxt "BundleFinishText" msgid "" @@ -71,11 +71,10 @@ "If you installed Torbutton, you will need to restart Firefox." msgstr "" "Asennus on valmis.\n" -"Ole hyvä ja tutustu https://www.torproject.org/docs/tor-doc-windows " -"-ohjesivuun oppiakseen kuinka voi asettaa ohjelmat käyttämään Tor-ohjelmaa.\n" +"Tutustu https://www.torproject.org/docs/tor-doc-windows -ohjesivuun missä " +"kerrotaan kuinka tehdä Tor-ohjelman vaatimat asetukset eri ohjelmille.\n" "\n" -"Jos Torbutton on asennettuna, niin Firefox joudutaan käynnistämään " -"uudestaan." +"Jos asensit Torbuttonin, Firefox tulee käynnistää uudestaan." msgctxt "BundleRunNow" msgid "Run installed components now" @@ -85,7 +84,7 @@ msgid "Vidalia is a GUI that helps you control, monitor, and configure Tor." msgstr "" "Vidalia on käyttöliittymä ohjaamaan, tarkkailemaan ja säätämään Tor-ohjelman " -"toimintaa." +"asetuksia." msgctxt "VidaliaUninstDesc" msgid "Remove ${VIDALIA_DESC}." @@ -93,7 +92,7 @@ msgctxt "VidaliaSetupCaption" msgid "${VIDALIA_NAME} setup" -msgstr "${VIDALIA_NAME}n asennus" +msgstr "${VIDALIA_NAME}:n asennus" msgctxt "VidaliaWelcomeText" msgid "" @@ -109,11 +108,11 @@ msgctxt "VidaliaWelcomeTitle" msgid "Welcome to the ${VIDALIA_NAME} Setup Wizard" -msgstr "Tervetuloa ${VIDALIA_NAME}n asennukseen" +msgstr "Tervetuloa ${VIDALIA_NAME}:n asennukseen" msgctxt "VidaliaLinkText" msgid "${VIDALIA_NAME} homepage" -msgstr "${VIDALIA_NAME}n kotisivu" +msgstr "${VIDALIA_NAME}:n kotisivu" msgctxt "VidaliaAppDesc" msgid "Vidalia is a GUI that helps you control, monitor, and configure Tor." @@ -123,11 +122,11 @@ msgctxt "VidaliaStartup" msgid "Run At Startup" -msgstr "Käynnistä Windowssin käynnistyessä" +msgstr "Käynnistä Windowsin käynnistyessä" msgctxt "VidaliaStartupDesc" msgid "Automatically run ${VIDALIA_NAME} at startup." -msgstr "Käynnistä automaattisesti ${VIDALIA_NAME} Windowssin käynnistyessä." +msgstr "Käynnistä automaattisesti ${VIDALIA_NAME} Windowsin käynnistyessä." msgctxt "VidaliaShortcuts" msgid "Add to Start Menu" @@ -164,17 +163,17 @@ "$\n" "Do you want to overwrite it with the default sample configuration file?" msgstr "" -"Sinulla on jo ennestään Tor-asetustiedosto.$\n" +"Sinulla on jo ennestään Tor asetustiedosto.$\n" "$\n" -"Haluatko, että se korvataan oletusesimerkillä?" +"Haluatko, että se korvataan esimerkki asetustiedostolla?" msgctxt "TorDocumentation" msgid "Documentation" -msgstr "Ohje" +msgstr "Dokumentaatio" msgctxt "TorDocumentationDesc" msgid "Install ${TOR_NAME} documentation." -msgstr "Asenna ${TOR_NAME}-ohjelman ohje." +msgstr "Asenna ${TOR_NAME}-dokumentaatio." msgctxt "TorShortcuts" msgid "Add to Start Menu" @@ -184,45 +183,45 @@ msgid "Add ${TOR_NAME} to your Start menu." msgstr "Lisää ${TOR_NAME} Käynnistä-valikkoon." -msgctxt "PrivoxyGroupDesc" +msgctxt "PolipoGroupDesc" msgid "" -"Privoxy is a filtering web proxy that protects your privacy and helps remove " -"ads, banners, and popups." +"Polipo is a caching web proxy that increases performance of web browsing " +"through Tor." msgstr "" -"Privoxy on suodattava välityspalvelin, joka suojaa yksityisyyttä ja auttaa " -"poistamalla mainoksia, bannereita ja popup-ikkunoita." +"Polipo on välimuistiin tallentava web välityspalvelin joka auttaa " +"parantamaan web selailun nopeutta Torria käytettäessä." -msgctxt "PrivoxyUninstDesc" -msgid "Remove ${PRIVOXY_DESC}." -msgstr "Poista ${PRIVOXY_DESC}." +msgctxt "PolipoUninstDesc" +msgid "Remove ${POLIPO_DESC}." +msgstr "Poista ${POLIPO_DESC}." -msgctxt "PrivoxyAppDesc" -msgid "Install ${PRIVOXY_DESC}." -msgstr "Asenna ${PRIVOXY_DESC}." +msgctxt "PolipoAppDesc" +msgid "Install ${POLIPO_DESC}." +msgstr "Asenna ${POLIPO_DESC}." -msgctxt "PrivoxyShortcuts" +msgctxt "PolipoShortcuts" msgid "Add to Start Menu" msgstr "Lisää Käynnistä-valikkoon" -msgctxt "PrivoxyShortcutsDesc" -msgid "Add ${PRIVOXY_NAME} to your Start menu." -msgstr "Lisää ${PRIVOXY_NAME} Käynnistä-valikkoon." +msgctxt "PolipoShortcutsDesc" +msgid "Add ${POLIPO_NAME} to your Start menu." +msgstr "Lisää ${POLIPO_NAME} Käynnistä-valikkoon." -msgctxt "PrivoxyStartup" +msgctxt "PolipoStartup" msgid "Run At Startup" -msgstr "Käynnistä käyttöjärjestelmän käynnistyessä" +msgstr "Käynnistä Windowsin käynnistyessä" -msgctxt "PrivoxyStartupDesc" -msgid "Automatically run ${PRIVOXY_NAME} at startup." -msgstr "Käynnistä automaattisesti ${PRIVOXY_NAME} Windowssin käynnistyessä." +msgctxt "PolipoStartupDesc" +msgid "Automatically run ${POLIPO_NAME} at startup." +msgstr "Käynnistä automaattisesti ${POLIPO_NAME} Windowsin käynnistyessä." msgctxt "TorbuttonGroupDesc" msgid "" "Torbutton is a Firefox extension that allows you to quickly enable or " "disable anonymous web browsing." msgstr "" -"Torbutton on Mozilla Firefoxille lisäosa, jolla voi ottaa käyttöön tai " -"poistaa käytöstä anonyymisen sivujen selailun." +"Torbutton on Firefox lisäosa, jonka avulla voi ottaa nopeasti käyttöön tai " +"poistaa käytöstä anonyymisen web sivujen selailun." msgctxt "TorbuttonUninstDesc" msgid "Remove ${TORBUTTON_DESC}." @@ -238,7 +237,7 @@ msgctxt "TorbuttonAddToFirefoxDesc" msgid "Add the ${TORBUTTON_DESC} extension to Firefox." -msgstr "Lisää ${TORBUTTON_DESC}-lisäosa Firefoxiin." +msgstr "Lisää ${TORBUTTON_DESC} -lisäosa Firefoxiin." msgctxt "TorbuttonFirefoxNotFound" msgid "Firefox was not found on your system. Not installing Torbutton." @@ -246,7 +245,7 @@ msgctxt "AppData" msgid "Application Data" -msgstr "Ohjelmatiedot" +msgstr "Sovelluksen tiedot" msgctxt "AppDataUninstDesc" msgid "Remove saved application data and configuration files." @@ -258,14 +257,14 @@ msgctxt "FirefoxWarningPageTitle" msgid "Firefox is not installed" -msgstr "Firefoxia ei ole asennettuna" +msgstr "Firefox ei ole asennettu" msgctxt "FirefoxWarningPageSubtitle" msgid "" "We recommend that you install Firefox before continuing, for best safety." msgstr "" -"Suosittelemme Firefoxin asennusta ennen jatkamista, parhaimman " -"turvallisuuden vuoksi." +"Turvallisuuden vuoksi Firefoxin asentaminen on suositeltavaa ennen " +"jatkamista." msgctxt "FirefoxWarningPageUpperText" msgid "" @@ -277,12 +276,13 @@ "If you would like to install Firefox, please press Cancel, then go\n" "to the Firefox download page at" msgstr "" -"Mozilla Firefox -internetselain ei ole asennettuna.\n" -"Tor toimii myös muillakin selaimilla kuten esim. Internet Explorer, mutta\n" -"on helpompaa käyttää Firefoxilla, joka turvaa yksityisyyden paremmin.\n" +"Mozilla Firefox selain ei ole asennettuna tähän tietokoneeseen.\n" +"Tor toimii muillakin selaimilla, kuten Internet Explorer, mutta\n" +"on helpompaa käyttää Firefoxilla, joka lisäksi turvaa yksityisyyden " +"paremmin.\n" "\n" "Jos haluat asentaa Firefoxin, paina Peruuta ja mene\n" -"Firefoxin lataussivulle osoitteeseen" +"Firefoxin lataussivulle osoitteeseen:" msgctxt "FirefoxWarningPageLowerText" msgid "" diff -Nru vidalia-0.1.13/pkg/win32/fr/vidalia_fr.po vidalia-0.2.8/pkg/win32/fr/vidalia_fr.po --- vidalia-0.1.13/pkg/win32/fr/vidalia_fr.po 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/pkg/win32/fr/vidalia_fr.po 2009-09-30 00:46:27.000000000 +0100 @@ -3,8 +3,8 @@ "Project-Id-Version: Vidalia\n" "Report-Msgid-Bugs-To: translations@vidalia-project.net\n" "POT-Creation-Date: 2008-07-12 05:29+0000\n" -"PO-Revision-Date: 2008-11-19 23:27+0000\n" -"Last-Translator: Mfr \n" +"PO-Revision-Date: 2009-09-21 10:44+0000\n" +"Last-Translator: Michael Scherer \n" "Language-Team: translations@vidalia-project.net\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -16,23 +16,23 @@ msgid "${BUNDLE_NAME} setup" msgstr "Mise à jour de ${BUNDLE_NAME}" -# GUI traduit en logiciel pour plus de clarté +# Traduction de la partie sur Polipo msgctxt "BundleWelcomeText" msgid "" -"This wizard will guide you through the installation of Tor, Vidalia, " -"Privoxy, and Torbutton.\n" +"This wizard will guide you through the installation of Tor, Vidalia, Polipo, " +"and Torbutton.\n" "\n" "Tor is a system for using the Internet anonymously, helping you anonymize " "Web browsing and publishing, instant messaging, IRC, and more. Vidalia is a " "GUI that helps you control, monitor, and configure Tor.\n" "\n" -"Privoxy is a filtering web proxy that protects your privacy and helps remove " -"ads, banners, and popups.\n" +"Polipo is a caching web proxy that helps increase performance of browsing " +"the web through Tor.\n" "\n" "Torbutton is a Firefox extension that allows you to quickly enable or " "disable anonymous web browsing.\n" "\n" -"If you have previously installed Tor, Vidalia, Privoxy, or Firefox, please " +"If you have previously installed Tor, Vidalia, Polipo, or Firefox, please " "make sure they are not running before continuing this installation.\n" "\n" "$_CLICK" @@ -42,11 +42,11 @@ "\n" "Tor est un système pour utiliser internet anonymement, vous aidant à " "anonymer la navigation Web, la publication, la messagerie instantanée, " -"l'IRC, et plus encore. Vidalia est un logiciel qui vous aide à contrôler," -"surveiller et configurer Tor.\n" +"l'IRC, et plus encore. Vidalia est un logiciel qui vous aide à " +"contrôler,surveiller et configurer Tor.\n" "\n" -"Privoxy est un mandataire proxy web de filtrage qui protège votre anonymat " -"et aide à supprimer les publicités, bannières et les popups.\n" +"Polipo est un mandataire proxy de cache qui améliore la navigation web à " +"travers Tor.\n" "\n" "Torbutton est un module complémentaire de Firefox qui vous permet d'activer " "ou de désactiver rapidement la navigation anonyme.\n" @@ -186,37 +186,37 @@ msgid "Add ${TOR_NAME} to your Start menu." msgstr "Ajouter ${TOR_NAME} à votre Menu Démarrer." -msgctxt "PrivoxyGroupDesc" +msgctxt "PolipoGroupDesc" msgid "" -"Privoxy is a filtering web proxy that protects your privacy and helps remove " -"ads, banners, and popups." +"Polipo is a caching web proxy that increases performance of web browsing " +"through Tor." msgstr "" -"Privoxy est un mandataire proxy web de filtrage qui protège votre anonymat " -"et aide à supprimer les publicités, bannières et les popups." +"Polipo est un mandataire proxy de cache qui améliore la navigation web à " +"travers Tor." -msgctxt "PrivoxyUninstDesc" -msgid "Remove ${PRIVOXY_DESC}." -msgstr "Supprimer ${PRIVOXY_DESC}." +msgctxt "PolipoUninstDesc" +msgid "Remove ${POLIPO_DESC}." +msgstr "Supprimer ${POLIPO_DESC}." -msgctxt "PrivoxyAppDesc" -msgid "Install ${PRIVOXY_DESC}." -msgstr "Installer ${PRIVOXY_DESC}." +msgctxt "PolipoAppDesc" +msgid "Install ${POLIPO_DESC}." +msgstr "Installer ${POLIPO_DESC}." -msgctxt "PrivoxyShortcuts" +msgctxt "PolipoShortcuts" msgid "Add to Start Menu" msgstr "Ajouter au Menu Démarrer" -msgctxt "PrivoxyShortcutsDesc" -msgid "Add ${PRIVOXY_NAME} to your Start menu." -msgstr "Ajouter ${PRIVOXY_NAME} à votre Menu Démarrer." +msgctxt "PolipoShortcutsDesc" +msgid "Add ${POLIPO_NAME} to your Start menu." +msgstr "Ajouter ${POLIPO_NAME} à votre Menu Démarrer." -msgctxt "PrivoxyStartup" +msgctxt "PolipoStartup" msgid "Run At Startup" msgstr "Lancer au démarrage" -msgctxt "PrivoxyStartupDesc" -msgid "Automatically run ${PRIVOXY_NAME} at startup." -msgstr "Lancer automatiquement ${PRIVOXY_NAME} au démarrage." +msgctxt "PolipoStartupDesc" +msgid "Automatically run ${POLIPO_NAME} at startup." +msgstr "Lancer automatiquement ${POLIPO_NAME} au démarrage." msgctxt "TorbuttonGroupDesc" msgid "" diff -Nru vidalia-0.1.13/pkg/win32/he/vidalia_he.po vidalia-0.2.8/pkg/win32/he/vidalia_he.po --- vidalia-0.1.13/pkg/win32/he/vidalia_he.po 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/pkg/win32/he/vidalia_he.po 2009-08-31 03:49:46.000000000 +0100 @@ -16,22 +16,23 @@ msgid "${BUNDLE_NAME} setup" msgstr "התקנת ${BUNDLE_NAME}" +#, fuzzy msgctxt "BundleWelcomeText" msgid "" -"This wizard will guide you through the installation of Tor, Vidalia, " -"Privoxy, and Torbutton.\n" +"This wizard will guide you through the installation of Tor, Vidalia, Polipo, " +"and Torbutton.\n" "\n" "Tor is a system for using the Internet anonymously, helping you anonymize " "Web browsing and publishing, instant messaging, IRC, and more. Vidalia is a " "GUI that helps you control, monitor, and configure Tor.\n" "\n" -"Privoxy is a filtering web proxy that protects your privacy and helps remove " -"ads, banners, and popups.\n" +"Polipo is a caching web proxy that helps increase performance of browsing " +"the web through Tor.\n" "\n" "Torbutton is a Firefox extension that allows you to quickly enable or " "disable anonymous web browsing.\n" "\n" -"If you have previously installed Tor, Vidalia, Privoxy, or Firefox, please " +"If you have previously installed Tor, Vidalia, Polipo, or Firefox, please " "make sure they are not running before continuing this installation.\n" "\n" "$_CLICK" @@ -175,37 +176,41 @@ msgid "Add ${TOR_NAME} to your Start menu." msgstr "הוסף את ${TOR_NAME} לתפריט התחלה." -msgctxt "PrivoxyGroupDesc" +msgctxt "PolipoGroupDesc" msgid "" -"Privoxy is a filtering web proxy that protects your privacy and helps remove " -"ads, banners, and popups." +"Polipo is a caching web proxy that increases performance of web browsing " +"through Tor." msgstr "" -"Privoxy הינו שרת פרוקסי מסנן המגן על פרטיותך ועוזר בהסרת פרסומות וחלונות " -"קופצים." -msgctxt "PrivoxyUninstDesc" -msgid "Remove ${PRIVOXY_DESC}." -msgstr "הסר ${PRIVOXY_DESC}." +#, fuzzy +msgctxt "PolipoUninstDesc" +msgid "Remove ${POLIPO_DESC}." +msgstr "הסר ${POLIPO_DESC}." + +#, fuzzy +msgctxt "PolipoAppDesc" +msgid "Install ${POLIPO_DESC}." +msgstr "התקן ${POLIPO_DESC}." -msgctxt "PrivoxyAppDesc" -msgid "Install ${PRIVOXY_DESC}." -msgstr "התקן ${PRIVOXY_DESC}." - -msgctxt "PrivoxyShortcuts" +#, fuzzy +msgctxt "PolipoShortcuts" msgid "Add to Start Menu" msgstr "הוסף לתפריט התחלה" -msgctxt "PrivoxyShortcutsDesc" -msgid "Add ${PRIVOXY_NAME} to your Start menu." -msgstr "הוסף את ${PRIVOXY_NAME} לתפריט התחלה." +#, fuzzy +msgctxt "PolipoShortcutsDesc" +msgid "Add ${POLIPO_NAME} to your Start menu." +msgstr "הוסף את ${POLIPO_NAME} לתפריט התחלה." -msgctxt "PrivoxyStartup" +#, fuzzy +msgctxt "PolipoStartup" msgid "Run At Startup" msgstr "הרץ בעת אתחול" -msgctxt "PrivoxyStartupDesc" -msgid "Automatically run ${PRIVOXY_NAME} at startup." -msgstr "הרץ ${PRIVOXY_NAME} אוטומטית בעת אתחול." +#, fuzzy +msgctxt "PolipoStartupDesc" +msgid "Automatically run ${POLIPO_NAME} at startup." +msgstr "הרץ ${POLIPO_NAME} אוטומטית בעת אתחול." msgctxt "TorbuttonGroupDesc" msgid "" diff -Nru vidalia-0.1.13/pkg/win32/it/vidalia_it.po vidalia-0.2.8/pkg/win32/it/vidalia_it.po --- vidalia-0.1.13/pkg/win32/it/vidalia_it.po 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/pkg/win32/it/vidalia_it.po 2009-10-02 10:39:32.000000000 +0100 @@ -3,8 +3,8 @@ "Project-Id-Version: Vidalia\n" "Report-Msgid-Bugs-To: translations@vidalia-project.net\n" "POT-Creation-Date: 2008-07-12 05:29+0000\n" -"PO-Revision-Date: 2009-02-25 12:39+0000\n" -"Last-Translator: Mark Stock \n" +"PO-Revision-Date: 2009-10-02 09:39+0000\n" +"Last-Translator: Jan Reister \n" "Language-Team: translations@vidalia-project.net\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -16,22 +16,23 @@ msgid "${BUNDLE_NAME} setup" msgstr "Installazione di ${BUNDLE_NAME}" +#, fuzzy msgctxt "BundleWelcomeText" msgid "" -"This wizard will guide you through the installation of Tor, Vidalia, " -"Privoxy, and Torbutton.\n" +"This wizard will guide you through the installation of Tor, Vidalia, Polipo, " +"and Torbutton.\n" "\n" "Tor is a system for using the Internet anonymously, helping you anonymize " "Web browsing and publishing, instant messaging, IRC, and more. Vidalia is a " "GUI that helps you control, monitor, and configure Tor.\n" "\n" -"Privoxy is a filtering web proxy that protects your privacy and helps remove " -"ads, banners, and popups.\n" +"Polipo is a caching web proxy that helps increase performance of browsing " +"the web through Tor.\n" "\n" "Torbutton is a Firefox extension that allows you to quickly enable or " "disable anonymous web browsing.\n" "\n" -"If you have previously installed Tor, Vidalia, Privoxy, or Firefox, please " +"If you have previously installed Tor, Vidalia, Polipo, or Firefox, please " "make sure they are not running before continuing this installation.\n" "\n" "$_CLICK" @@ -39,9 +40,9 @@ "Questo wizard assisterà nell'installazione di Tor, Vidalia, Privoxy e " "Torbutton.\n" "\n" -"Tor è un software che consente di navigare anonimamente Internet, assistendo " -"nell'anonimizzare le pagine visitate e pubblicate, i sistemi di " -"messaggistica istantanea, IRC e altro ancora. Vidalia è una GUI che " +"Tor è un software che consente di usare Internet in modo anonimo, aiutandoti " +"a rendere anonimela navigazione e la pubblicazione sul web, la messaggistica " +"istantanea, IRC e altro ancora. Vidalia è una interfaccia grafica che " "semplifica il controllo e la configurazione di Tor.\n" "\n" "Privoxy è un proxy filtrante che protegge la privacy e rimuove pubblicità " @@ -84,7 +85,9 @@ msgctxt "VidaliaGroupDesc" msgid "Vidalia is a GUI that helps you control, monitor, and configure Tor." -msgstr "Vidalia è un programma di configurazione e controllo grafico per Tor." +msgstr "" +"Vidalia è una interfaccia grafica per controllare, monitorare e configurare " +"Tor." msgctxt "VidaliaUninstDesc" msgid "Remove ${VIDALIA_DESC}." @@ -112,11 +115,11 @@ msgctxt "VidaliaLinkText" msgid "${VIDALIA_NAME} homepage" -msgstr "Homepage del progetto ${VIDALIA_NAME}" +msgstr "Homepage di ${VIDALIA_NAME}" msgctxt "VidaliaAppDesc" msgid "Vidalia is a GUI that helps you control, monitor, and configure Tor." -msgstr "Vidalia è un programma di configurazione e controllo grafico per Tor." +msgstr "Vidalia è una GUI per controllare, monitorare e configurare Tor." msgctxt "VidaliaStartup" msgid "Run At Startup" @@ -124,15 +127,15 @@ msgctxt "VidaliaStartupDesc" msgid "Automatically run ${VIDALIA_NAME} at startup." -msgstr "Avvia ${VIDALIA_NAME} all'accensione del pc." +msgstr "Avvia ${VIDALIA_NAME} automaticamente all'accensione del pc." msgctxt "VidaliaShortcuts" msgid "Add to Start Menu" -msgstr "Aggiungi al menu Start" +msgstr "Aggiungi al menu Avvio" msgctxt "VidaliaShortcutsDesc" msgid "Add ${VIDALIA_NAME} to your Start menu." -msgstr "Aggiunge ${VIDALIA_NAME} alla cartella Progammi del menu Start." +msgstr "Aggiunge ${VIDALIA_NAME} alla cartella Progammi del menu Avvio." msgctxt "VidaliaRunNow" msgid "Run ${VIDALIA_NAME}" @@ -143,9 +146,9 @@ "Tor is a system for using the Internet anonymously, helping you anonymize " "Web browsing and publishing, instant messaging, IRC, and more." msgstr "" -"Tor è un sistema per usare anonimamente Internet, favorire l'anonimato nella " -"navigazione e nella pubblicazione Web, messaggistica istantanea, IRC, e " -"altro ancora." +"Tor è un sistema per usare Internet in modo anonimo, permettendoti di " +"rendere anonimi la navigazione e la pubblicazione web, la messaggistica " +"istantanea, IRC, e altro ancora." msgctxt "TorUninstDesc" msgid "Remove ${TOR_DESC}." @@ -175,43 +178,49 @@ msgctxt "TorShortcuts" msgid "Add to Start Menu" -msgstr "Aggiungi al menu Start" +msgstr "Aggiungi al menu Avvio" msgctxt "TorShortcutsDesc" msgid "Add ${TOR_NAME} to your Start menu." -msgstr "Aggiunge ${TOR_NAME} alla cartella Programmi del menu Start." +msgstr "Aggiunge ${TOR_NAME} alla cartella Programmi del menu Avvio." -msgctxt "PrivoxyGroupDesc" +msgctxt "PolipoGroupDesc" msgid "" -"Privoxy is a filtering web proxy that protects your privacy and helps remove " -"ads, banners, and popups." +"Polipo is a caching web proxy that increases performance of web browsing " +"through Tor." msgstr "" -"Privoxy è un proxy web filtrante che protegge la privacy e aiuta a rimuovere " -"pubblicità (ad, banner e popup)." - -msgctxt "PrivoxyUninstDesc" -msgid "Remove ${PRIVOXY_DESC}." -msgstr "Disinstalla ${PRIVOXY_DESC}." +"Polipo è un caching web proxy che migliora le prestazioni dela navigazione " +"web con Tor." -msgctxt "PrivoxyAppDesc" -msgid "Install ${PRIVOXY_DESC}." -msgstr "Installa ${PRIVOXY_DESC}." +#, fuzzy +msgctxt "PolipoUninstDesc" +msgid "Remove ${POLIPO_DESC}." +msgstr "Disinstalla ${POLIPO_DESC}." + +#, fuzzy +msgctxt "PolipoAppDesc" +msgid "Install ${POLIPO_DESC}." +msgstr "Installa ${POLIPO_DESC}." -msgctxt "PrivoxyShortcuts" +#, fuzzy +msgctxt "PolipoShortcuts" msgid "Add to Start Menu" -msgstr "Aggiungi al menu Start" +msgstr "Aggiungi al menu Avvio" -msgctxt "PrivoxyShortcutsDesc" -msgid "Add ${PRIVOXY_NAME} to your Start menu." -msgstr "Aggiunge ${PRIVOXY_NAME} alla cartella Programmi del menu Start." +#, fuzzy +msgctxt "PolipoShortcutsDesc" +msgid "Add ${POLIPO_NAME} to your Start menu." +msgstr "Aggiunge ${POLIPO_NAME} alla cartella Programmi del menu Avvio." -msgctxt "PrivoxyStartup" +#, fuzzy +msgctxt "PolipoStartup" msgid "Run At Startup" msgstr "Attiva all'avvio del pc" -msgctxt "PrivoxyStartupDesc" -msgid "Automatically run ${PRIVOXY_NAME} at startup." -msgstr "Avvia ${PRIVOXY_NAME} all'accensione del pc." +#, fuzzy +msgctxt "PolipoStartupDesc" +msgid "Automatically run ${POLIPO_NAME} at startup." +msgstr "Avvia ${POLIPO_NAME} all'accensione del pc." msgctxt "TorbuttonGroupDesc" msgid "" @@ -244,11 +253,11 @@ msgctxt "AppData" msgid "Application Data" -msgstr "Application Data" +msgstr "Dati dell'applicazione" msgctxt "AppDataUninstDesc" msgid "Remove saved application data and configuration files." -msgstr "Remove saved application data and configuration files." +msgstr "Elimina i dati dell'applicazione salvati ed i file di configurazione." msgctxt "LanguageCode" msgid "en" @@ -262,7 +271,7 @@ msgid "" "We recommend that you install Firefox before continuing, for best safety." msgstr "" -"Raccomandiamo di installare Firefox prima di continuare, per una maggiore " +"Consigliamo di installare Firefox prima di continuare, per una maggiore " "sicurezza" msgctxt "FirefoxWarningPageUpperText" @@ -275,11 +284,10 @@ "If you would like to install Firefox, please press Cancel, then go\n" "to the Firefox download page at" msgstr "" -"Mozilla Firefox web browser non è installato sul tuo computer.\n" +"Il browser web Mozilla Firefox non è installato sul tuo computer.\n" "Tor funzionerà con altri browser, come Internet Explorer, ma\n" -"è più semplice da utilizzare con FIrefox, che svolge anche un migliore " -"lavoro di\n" -"protezione dell'anonimato.\n" +"è più semplice da utilizzare con Firefox, che funziona anche meglio\n" +"per proteggere il tuo anonimato.\n" "\n" "Se vuoi installare Firefox, premi Annulla, quindi vai\n" "alla pagina di download di Firefox a" @@ -293,7 +301,7 @@ "press Next to continue." msgstr "" "Quando hai installato Firefox, puoi nuovamente eseguire\n" -"Tor installer.\n" +"l'installatore di Tor.\n" "\n" "O, se preferisci installare Tor senza Firefox,\n" "premi Avanti per continuare" diff -Nru vidalia-0.1.13/pkg/win32/mktransform.vbs vidalia-0.2.8/pkg/win32/mktransform.vbs --- vidalia-0.1.13/pkg/win32/mktransform.vbs 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/pkg/win32/mktransform.vbs 2009-03-06 12:03:34.000000000 +0000 @@ -0,0 +1,67 @@ +' Copyright (C) 2008-2009 The Tor Project, Inc. +' See LICENSE file for rights and terms. +' +' This script automates the task of creating transforms from one MSI database +' to another. This is required for language based transforms, for example. +' +' To apply vidalia_fr.msi localization to vidalia.msi with name 'fr': +' cscript.exe mktransform.vbs fr vidalia.msi vidalia_fr.msi +' +Const msiOpenDatabaseModeReadOnly = 0 +Const msiOpenDatabaseModeTransact = 1 +Const msiViewModifyAssign = 3 +Const msiTransformErrorNone = 0 +Const msiTransformValidationNone = 0 + +Dim message +If Wscript.Arguments.Count < 3 Then + message = "Usage: mktransform " + Wscript.Echo message + Wscript.Quit 1 +End If + +Dim transformName +Dim minMsiFile +Dim currMsiFile +transformName = Wscript.Arguments.Item(0) +minMsiFile = Wscript.Arguments.Item(1) +currMsiFile = Wscript.Arguments.Item(2) + +CreateTransform transformName, minMsiFile, currMsiFile +Wscript.Quit 0 + +Sub CreateTransform (TransformName, MinMsiFile, CurrMsiFile) + ' Create transform from minimal to current/target MSI database + Set installer = Wscript.CreateObject("WindowsInstaller.Installer") : CheckError + Dim database1 : Set database1 = installer.OpenDatabase(MinMsiFile, msiOpenDatabaseModeTransact) : CheckError + Dim database2 : Set database2 = installer.OpenDatabase(CurrMsiFile, msiOpenDatabaseModeReadOnly) : CheckError + Dim transform : transform = TransformName & ".mst" + database2.GenerateTransform database1, transform : CheckError + database2.CreateTransformSummaryInfo database1, transform, msiTransformErrorNone, msiTransformValidationNone : CheckError + + ' Embed Transform into the database with the requested name + Set view = database1.OpenView("SELECT `Name`,`Data` FROM _Storages") : CheckError + view.Execute : CheckError + Set record = installer.CreateRecord(2) + record.StringData(1) = TransformName + record.SetStream 2, transform : CheckError + view.Modify msiViewModifyAssign, record : CheckError + database1.Commit : CheckError + Set database1 = Nothing + Set database2 = Nothing +End Sub + +Sub CheckError + If Err = 0 Then Exit Sub + Dim message, errRec + message = Err.Source & " " & Hex(Err) & ": " & Err.Description + If Not installer Is Nothing Then + Set errRec = installer.LastErrorRecord + If Not errRec Is Nothing Then + message = message & vbNewLine & errRec.FormatText + End If + End If + Wscript.Echo message + Wscript.Quit 1 +End Sub + diff -Nru vidalia-0.1.13/pkg/win32/nl/vidalia_nl.po vidalia-0.2.8/pkg/win32/nl/vidalia_nl.po --- vidalia-0.1.13/pkg/win32/nl/vidalia_nl.po 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/pkg/win32/nl/vidalia_nl.po 2009-09-30 00:47:32.000000000 +0100 @@ -3,8 +3,8 @@ "Project-Id-Version: Vidalia\n" "Report-Msgid-Bugs-To: translations@vidalia-project.net\n" "POT-Creation-Date: 2008-07-12 05:29+0000\n" -"PO-Revision-Date: 2008-07-17 02:56+0000\n" -"Last-Translator: Matt \n" +"PO-Revision-Date: 2009-09-22 10:57+0000\n" +"Last-Translator: Flabber \n" "Language-Team: translations@vidalia-project.net\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -16,23 +16,22 @@ msgid "${BUNDLE_NAME} setup" msgstr "${BUNDLE_NAME} setup" -#, fuzzy msgctxt "BundleWelcomeText" msgid "" -"This wizard will guide you through the installation of Tor, Vidalia, " -"Privoxy, and Torbutton.\n" +"This wizard will guide you through the installation of Tor, Vidalia, Polipo, " +"and Torbutton.\n" "\n" "Tor is a system for using the Internet anonymously, helping you anonymize " "Web browsing and publishing, instant messaging, IRC, and more. Vidalia is a " "GUI that helps you control, monitor, and configure Tor.\n" "\n" -"Privoxy is a filtering web proxy that protects your privacy and helps remove " -"ads, banners, and popups.\n" +"Polipo is a caching web proxy that helps increase performance of browsing " +"the web through Tor.\n" "\n" "Torbutton is a Firefox extension that allows you to quickly enable or " "disable anonymous web browsing.\n" "\n" -"If you have previously installed Tor, Vidalia, Privoxy, or Firefox, please " +"If you have previously installed Tor, Vidalia, Polipo, or Firefox, please " "make sure they are not running before continuing this installation.\n" "\n" "$_CLICK" @@ -40,7 +39,16 @@ "Deze wizard zal u leiden door de installatie van Tor, Vidalia, Privoxy, and " "Torbutton.\n" "\n" -"Indien u eerder Tor, Vidalia, Privoxy, of Firefox heeft geïnstalleerd, zorg " +"Tor is een systeem om het internet anoniem te gebruiken, om anoniem te " +"surfen, te publiceren, berichten te sturen, IRC enzomeer. Vidalia is een " +"programma om Tor te configureren en op te volgen.\n" +"\n" +"Polipo is een net-proxy dat de performantie van het surfen met Tor verhoogt.\n" +"\n" +"Torbutten is een Firefox-extensie dat toelaat om snel te wisselen tussen " +"gewoon en anoniem surfen.\n" +"\n" +"Indien u eerder Tor, Vidalia, Polipo, of Firefox heeft geïnstalleerd, zorg " "dan dat deze zijn afgesloten voordat u verder gaat met deze installatie.\n" "\n" "$_CLICK" @@ -73,7 +81,7 @@ msgctxt "VidaliaGroupDesc" msgid "Vidalia is a GUI that helps you control, monitor, and configure Tor." -msgstr "Installeer ${VIDALIA_DESC}." +msgstr "Vidalia is een programma om Tor te configureren en op te volgen." msgctxt "VidaliaUninstDesc" msgid "Remove ${VIDALIA_DESC}." @@ -90,7 +98,8 @@ "\n" "$_CLICK" msgstr "" -"Deze wizard zal u leiden door de installatie van ${VIDALIA_DESC}.\n" +"Deze wizard zal u leiden door de installatie van Vidalia, een programma om " +"Tor te configureren en op te volgen.\n" "\n" "$_CLICK" @@ -100,11 +109,11 @@ msgctxt "VidaliaLinkText" msgid "${VIDALIA_NAME} homepage" -msgstr "${VIDALIA_NAME} homepage" +msgstr "${VIDALIA_NAME} webpagina" msgctxt "VidaliaAppDesc" msgid "Vidalia is a GUI that helps you control, monitor, and configure Tor." -msgstr "Installeer ${VIDALIA_DESC}." +msgstr "Vidalia is een programma om Tor te configureren en op te volgen." msgctxt "VidaliaStartup" msgid "Run At Startup" @@ -130,7 +139,9 @@ msgid "" "Tor is a system for using the Internet anonymously, helping you anonymize " "Web browsing and publishing, instant messaging, IRC, and more." -msgstr "Installeer ${TOR_DESC}." +msgstr "" +"Tor is een systeem om het internet anoniem te gebruiken, om anoniem op het " +"net te surfen, te publiceren, berichten te sturen, IRC, en zo meer." msgctxt "TorUninstDesc" msgid "Remove ${TOR_DESC}." @@ -166,41 +177,45 @@ msgid "Add ${TOR_NAME} to your Start menu." msgstr "Voeg ${TOR_NAME} toe aan uw Start menu." -msgctxt "PrivoxyGroupDesc" +msgctxt "PolipoGroupDesc" msgid "" -"Privoxy is a filtering web proxy that protects your privacy and helps remove " -"ads, banners, and popups." +"Polipo is a caching web proxy that increases performance of web browsing " +"through Tor." msgstr "" +"Polipo is een net-proxy om de performantie van het surfen via Tor te " +"verhogen." -msgctxt "PrivoxyUninstDesc" -msgid "Remove ${PRIVOXY_DESC}." -msgstr "Verwijder ${PRIVOXY_DESC}." +msgctxt "PolipoUninstDesc" +msgid "Remove ${POLIPO_DESC}." +msgstr "Verwijder ${POLIPO_DESC}." -msgctxt "PrivoxyAppDesc" -msgid "Install ${PRIVOXY_DESC}." -msgstr "Installeer ${PRIVOXY_DESC}." +msgctxt "PolipoAppDesc" +msgid "Install ${POLIPO_DESC}." +msgstr "Installeer ${POLIPO_DESC}." -msgctxt "PrivoxyShortcuts" +msgctxt "PolipoShortcuts" msgid "Add to Start Menu" msgstr "Voeg toe aan Start Menu" -msgctxt "PrivoxyShortcutsDesc" -msgid "Add ${PRIVOXY_NAME} to your Start menu." -msgstr "Voeg ${PRIVOXY_NAME} toe aan uw Start menu." +msgctxt "PolipoShortcutsDesc" +msgid "Add ${POLIPO_NAME} to your Start menu." +msgstr "Voeg ${POLIPO_NAME} toe aan uw Start menu." -msgctxt "PrivoxyStartup" +msgctxt "PolipoStartup" msgid "Run At Startup" msgstr "Start automatisch" -msgctxt "PrivoxyStartupDesc" -msgid "Automatically run ${PRIVOXY_NAME} at startup." -msgstr "Start ${PRIVOXY_NAME} automatisch bij het opstarten van Windows." +msgctxt "PolipoStartupDesc" +msgid "Automatically run ${POLIPO_NAME} at startup." +msgstr "Start ${POLIPO_NAME} automatisch bij het opstarten van Windows." msgctxt "TorbuttonGroupDesc" msgid "" "Torbutton is a Firefox extension that allows you to quickly enable or " "disable anonymous web browsing." msgstr "" +"Torbutton is een Firefox-extensie dat toelaat snel te wisselen tussen gewoon " +"en anoniem surfen." msgctxt "TorbuttonUninstDesc" msgid "Remove ${TORBUTTON_DESC}." @@ -225,11 +240,12 @@ msgctxt "AppData" msgid "Application Data" -msgstr "Application Data" +msgstr "Toepassingsgegevens" msgctxt "AppDataUninstDesc" msgid "Remove saved application data and configuration files." -msgstr "Remove saved application data and configuration files." +msgstr "" +"Verwijder de opgeslagen toepassingsgegevens en de configuratiebestanden." msgctxt "LanguageCode" msgid "en" @@ -237,12 +253,14 @@ msgctxt "FirefoxWarningPageTitle" msgid "Firefox is not installed" -msgstr "" +msgstr "Firefox is niet geïnstalleerd." msgctxt "FirefoxWarningPageSubtitle" msgid "" "We recommend that you install Firefox before continuing, for best safety." msgstr "" +"Wij raden U aan om Firefox te installeren voor de hoogste veiligheid " +"vooraleer verder te gaan." msgctxt "FirefoxWarningPageUpperText" msgid "" @@ -254,6 +272,13 @@ "If you would like to install Firefox, please press Cancel, then go\n" "to the Firefox download page at" msgstr "" +"Mozilla Firefox is niet geïnstalleerd op uw computer.\n" +"Tor werkt wel met andere programma's als Internet Explorer, maar \n" +"is gemakkellijker in gebruik met Firefox, dat daarenboven beter werkt om uw " +"anonimiteit te bewaren.\n" +"\n" +"Als U Firefox wilt installeren, druk op Annuleer, en ga \n" +"naar de Firefox-pagina op" msgctxt "FirefoxWarningPageLowerText" msgid "" @@ -263,3 +288,8 @@ "Or, if you would prefer to install Tor without Firefox, simply\n" "press Next to continue." msgstr "" +"Als U klaar bent met de installatie van Firefox, \n" +"kan U het Tor-installatieprogramma opnieuw starten.\n" +"\n" +"Of, indien U Tor wil installeren zonder Firefox, druk \n" +"Volgende om verder te gaan." diff -Nru vidalia-0.1.13/pkg/win32/pl/vidalia_pl.po vidalia-0.2.8/pkg/win32/pl/vidalia_pl.po --- vidalia-0.1.13/pkg/win32/pl/vidalia_pl.po 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/pkg/win32/pl/vidalia_pl.po 2009-09-06 15:38:45.000000000 +0100 @@ -3,13 +3,14 @@ "Project-Id-Version: Vidalia Windows Installers\n" "Report-Msgid-Bugs-To: translations@vidalia-project.net\n" "POT-Creation-Date: 2008-07-12 05:29+0000\n" -"PO-Revision-Date: 2008-09-15 18:35+0000\n" +"PO-Revision-Date: 2009-09-06 14:24+0000\n" "Last-Translator: Lukasz Kieres \n" "Language-Team: none\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n" +"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 " +"|| n%100>=20) ? 1 : 2);\n" "X-Generator: Pootle 1.1.0\n" msgctxt "BundleSetupCaption" @@ -18,40 +19,40 @@ msgctxt "BundleWelcomeText" msgid "" -"This wizard will guide you through the installation of Tor, Vidalia, " -"Privoxy, and Torbutton.\n" +"This wizard will guide you through the installation of Tor, Vidalia, Polipo, " +"and Torbutton.\n" "\n" "Tor is a system for using the Internet anonymously, helping you anonymize " "Web browsing and publishing, instant messaging, IRC, and more. Vidalia is a " "GUI that helps you control, monitor, and configure Tor.\n" "\n" -"Privoxy is a filtering web proxy that protects your privacy and helps remove " -"ads, banners, and popups.\n" +"Polipo is a caching web proxy that helps increase performance of browsing " +"the web through Tor.\n" "\n" "Torbutton is a Firefox extension that allows you to quickly enable or " "disable anonymous web browsing.\n" "\n" -"If you have previously installed Tor, Vidalia, Privoxy, or Firefox, please " +"If you have previously installed Tor, Vidalia, Polipo, or Firefox, please " "make sure they are not running before continuing this installation.\n" "\n" "$_CLICK" msgstr "" -"Kreator przeprowadzi Cię przez instalację Tora, Vidalii, Privoxy oraz " +"Kreator przeprowadzi Cię przez instalację Tora, Vidalii, Polipo oraz " "Torbuttona.\n" "\n" "Tor jest systemem pozwalającym anonimowo surfować po internecie, pomaga " -"zachować anonimowość podczas przeglądania i publikacji stron www, " -"używania komunikatorów, IRC i innych. Vidalia jest graficznym interfejsem " -"użytkownika, który pomaga sterować, monitorować i konfigurować Tora.\n\n" -"Privoxy jest lokalnym serwerem proxy, który filtrując chroni Twoją " -"prywatność i pomaga usuwać reklamy, bannery oraz popupy.\n" +"zachować anonimowość podczas przeglądania i publikacji stron www, używania " +"komunikatorów, IRC i innych. Vidalia jest graficznym interfejsem " +"użytkownika, który pomaga sterować, monitorować i konfigurować Tora.\n" "\n" +"Polipi jest cache'ującym serwerem proxy, który pomaga zwiększyć wydajność " +"podczas przeglądania sieci z użycien Tora.\n" "Torbutton jest rozszerzeniem Firefoxa, które umożliwa w szybki sposób " "przełączanie się w tryb anonimowego surfowania.\n" "\n" -"Jeśli poprzednio instalowałeś Tora, Vidalię, Privoxy lub Firefoxa, " -"upewnij się, że żadne z nich nie jest w tej chwili uruchomione, zanim " -"kontynuujesz tę instalację.\n" +"Jeśli poprzednio instalowałeś Tora, Vidalię, Polipo lub Firefoxa, upewnij " +"się, że żadne z nich nie jest w tej chwili uruchomione, zanim kontynuujesz " +"tę instalację.\n" "\n" "$_CLICK" @@ -72,11 +73,10 @@ "If you installed Torbutton, you will need to restart Firefox." msgstr "" "Instalacja zakończona.\n" -"Proszę zobaczyć https://www.torproject.org/docs/tor-doc-windows aby dowiedzieć " -"sić, jak skonfigurować aplikacje do współpracy z Torem.\n" +"Proszę zobaczyć https://www.torproject.org/docs/tor-doc-windows aby " +"dowiedzieć sić, jak skonfigurować aplikacje do współpracy z Torem.\n" "\n" -"Jeśli instalowałeś Torbutton'a, będziesz musiał uruchomić ponownie " -"Firefox'a." +"Jeśli instalowałeś Torbutton'a, będziesz musiał uruchomić ponownie Firefox'a." msgctxt "BundleRunNow" msgid "Run installed components now" @@ -84,7 +84,9 @@ msgctxt "VidaliaGroupDesc" msgid "Vidalia is a GUI that helps you control, monitor, and configure Tor." -msgstr "Vidalia jest graficznym interfejsem użytkownika, który pomaga sterować, monitorować i konfigurować Tora." +msgstr "" +"Vidalia jest graficznym interfejsem użytkownika, który pomaga sterować, " +"monitorować i konfigurować Tora." msgctxt "VidaliaUninstDesc" msgid "Remove ${VIDALIA_DESC}." @@ -117,8 +119,8 @@ msgctxt "VidaliaAppDesc" msgid "Vidalia is a GUI that helps you control, monitor, and configure Tor." msgstr "" -"Vidalia jest graficznym interfejsem użytkownika, który umożliwa " -"sterowanie, monitorowanie i konfigurację Tora." +"Vidalia jest graficznym interfejsem użytkownika, który umożliwa sterowanie, " +"monitorowanie i konfigurację Tora." msgctxt "VidaliaStartup" msgid "Run At Startup" @@ -145,9 +147,9 @@ "Tor is a system for using the Internet anonymously, helping you anonymize " "Web browsing and publishing, instant messaging, IRC, and more." msgstr "" -"Tor jest systemem umożliwiającym anonimowe użytkowanie Internetu, " -"pomagając pozostać Ci anonimowym podczas przeglądania stron www, " -"wysyłania plików, komunikacji, IRC i innych." +"Tor jest systemem umożliwiającym anonimowe użytkowanie Internetu, pomagając " +"pozostać Ci anonimowym podczas przeglądania stron www, wysyłania plików, " +"komunikacji, IRC i innych." msgctxt "TorUninstDesc" msgid "Remove ${TOR_DESC}." @@ -159,10 +161,12 @@ msgctxt "TorAskOverwriteTorrc" msgid "" -"You already have a Tor configuration file.\n" +"You already have a Tor configuration file.$\n" +"$\n" "Do you want to overwrite it with the default sample configuration file?" msgstr "" -"Posiadasz już plik konfiguracyjny Tora.\n" +"Posiadasz już plik konfiguracyjny Tora.$\n" +"$\n" "Czy chcesz nadpisać go przykładowym domyślnym plikiem konfiguracyjnym ?" msgctxt "TorDocumentation" @@ -181,37 +185,37 @@ msgid "Add ${TOR_NAME} to your Start menu." msgstr "Dodaje ${TOR_NAME} do Twojego Menu Start" -msgctxt "PrivoxyGroupDesc" +msgctxt "PolipoGroupDesc" msgid "" -"Privoxy is a filtering web proxy that protects your privacy and helps remove " -"ads, banners, and popups." +"Polipo is a caching web proxy that increases performance of web browsing " +"through Tor." msgstr "" -"Privoxy jest lokalnym serwerem proxy, który filtruje i chroni Twoją " -"prywatność usuwając reklamy, bannery i popupy." +"Polipo jest cache'ującym serwerem proxy, który przyspiesza przeglądanie " +"sieci przy użyciu Tora." -msgctxt "PrivoxyUninstDesc" -msgid "Remove ${PRIVOXY_DESC}." -msgstr "Usuń ${PRIVOXY_DESC}." +msgctxt "PolipoUninstDesc" +msgid "Remove ${POLIPO_DESC}." +msgstr "Usuń ${POLIPO_DESC}." -msgctxt "PrivoxyAppDesc" -msgid "Install ${PRIVOXY_DESC}." -msgstr "Instaluj ${PRIVOXY_DESC}." +msgctxt "PolipoAppDesc" +msgid "Install ${POLIPO_DESC}." +msgstr "Instaluj ${POLIPO_DESC}." -msgctxt "PrivoxyShortcuts" +msgctxt "PolipoShortcuts" msgid "Add to Start Menu" msgstr "Dodaj do Menu Start" -msgctxt "PrivoxyShortcutsDesc" -msgid "Add ${PRIVOXY_NAME} to your Start menu." -msgstr "Dodaje ${PRIVOXY_NAME} do Twojego Menu Start" +msgctxt "PolipoShortcutsDesc" +msgid "Add ${POLIPO_NAME} to your Start menu." +msgstr "Dodaje ${POLIPO_NAME} do Twojego Menu Start" -msgctxt "PrivoxyStartup" +msgctxt "PolipoStartup" msgid "Run At Startup" -msgstr "Uruchamiaj na starcie" +msgstr "Uruchom na starcie" -msgctxt "PrivoxyStartupDesc" -msgid "Automatically run ${PRIVOXY_NAME} at startup." -msgstr "Automatycznie uruchamia ${PRIVOXY_NAME} na starcie systemu." +msgctxt "PolipoStartupDesc" +msgid "Automatically run ${POLIPO_NAME} at startup." +msgstr "Automatycznie uruchamia ${POLIPO_NAME} na starcie systemu." msgctxt "TorbuttonGroupDesc" msgid "" @@ -239,8 +243,10 @@ msgctxt "TorbuttonFirefoxNotFound" msgid "Firefox was not found on your system. Not installing Torbutton." -msgstr "Firefox nie został znaleziony w Twoim systemie. Torbutton nie zostanie zainstalowany." -"Firefox nie został znaleziony w systemie. Instalacja Torbuttona zaniechana." +msgstr "" +"Firefox nie został znaleziony w Twoim systemie. Torbutton nie zostanie " +"zainstalowany.Firefox nie został znaleziony w systemie. Instalacja " +"Torbuttona zaniechana." msgctxt "AppData" msgid "Application Data" diff -Nru vidalia-0.1.13/pkg/win32/polipo.conf vidalia-0.2.8/pkg/win32/polipo.conf --- vidalia-0.1.13/pkg/win32/polipo.conf 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/pkg/win32/polipo.conf 2009-12-22 16:09:23.000000000 +0000 @@ -1,4 +1,4 @@ -### $Id: polipo.conf 2489 2008-04-06 00:00:07Z edmanm $ +### $Id: polipo.conf 4189 2009-12-22 16:09:23Z phobos $ # ### Basic configuration ### ******************* diff -Nru vidalia-0.1.13/pkg/win32/polipo.wxs.in vidalia-0.2.8/pkg/win32/polipo.wxs.in --- vidalia-0.1.13/pkg/win32/polipo.wxs.in 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/pkg/win32/polipo.wxs.in 2009-03-10 09:18:28.000000000 +0000 @@ -0,0 +1,220 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + omus + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1]]> + + + + + + + + + + + + 1]]> + + + + + + + + + 1]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -Nru vidalia-0.1.13/pkg/win32/pt/vidalia_pt.po vidalia-0.2.8/pkg/win32/pt/vidalia_pt.po --- vidalia-0.1.13/pkg/win32/pt/vidalia_pt.po 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/pkg/win32/pt/vidalia_pt.po 2009-12-14 11:22:09.000000000 +0000 @@ -3,8 +3,8 @@ "Project-Id-Version: Vidalia\n" "Report-Msgid-Bugs-To: translations@vidalia-project.net\n" "POT-Creation-Date: 2008-07-12 05:29+0000\n" -"PO-Revision-Date: 2009-01-23 16:42+0000\n" -"Last-Translator: Anderson Luiz Lazzarini Silveira \n" +"PO-Revision-Date: 2009-12-14 04:19-0700\n" +"Last-Translator: Tiago Faria \n" "Language-Team: translations@vidalia-project.net\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -18,41 +18,41 @@ msgctxt "BundleWelcomeText" msgid "" -"This wizard will guide you through the installation of Tor, Vidalia, " -"Privoxy, and Torbutton.\n" +"This wizard will guide you through the installation of Tor, Vidalia, Polipo, " +"and Torbutton.\n" "\n" "Tor is a system for using the Internet anonymously, helping you anonymize " "Web browsing and publishing, instant messaging, IRC, and more. Vidalia is a " "GUI that helps you control, monitor, and configure Tor.\n" "\n" -"Privoxy is a filtering web proxy that protects your privacy and helps remove " -"ads, banners, and popups.\n" +"Polipo is a caching web proxy that helps increase performance of browsing " +"the web through Tor.\n" "\n" "Torbutton is a Firefox extension that allows you to quickly enable or " "disable anonymous web browsing.\n" "\n" -"If you have previously installed Tor, Vidalia, Privoxy, or Firefox, please " +"If you have previously installed Tor, Vidalia, Polipo, or Firefox, please " "make sure they are not running before continuing this installation.\n" "\n" "$_CLICK" msgstr "" -"Este assistente irá guiá-lo através da instalação do Tor, Vidalia, Privoxy e " +"Este assistente irá guiá-lo na instalação do Tor, Vidalia, Privoxy e " "Torbutton.\n" "\n" -"Tor é um sistema para se usar a Internet anonimamente, ajudando você a " -"manter a anonimidade de seu Browser e publicador, mensagem instantânea, IRC, " -"e mais. Vidalia é um GUI que ajuda você a controlar, monitorar e configurar " -"o Tor.\n" -"\n" -"Privox é um filtro de proxy que proteje sua privacidade e o ajuda a remover " -"ads, banners, e poupus.\n" -"\n" -"Torbutton é uma extensão do Firefox que permite você a desabilitar ou " -"habilitar rapidamente o anonimato de seu Browser.\n" -"\n" -"Se você já instalou previamente o Tor, Vidalia, Privoxy ou Firefox, por " -"favor certifique-se de que eles não estejam sendo executados antes " -"prosseguir com esta instalação.\n" +"Tor é um sistema que lhe permite utilizar a Internet de uma forma anónima, " +"ajudando-o a manter o anonimato no seu navegador e publicador, mensagens " +"instantâneas, IRC, e outras aplicações. Vidalia é uma aplicação gráfica que " +"o ajuda a controlar, monitorizar e configurar o Tor.\n" +"\n" +"Polipo é um proxy que mantém cópias locais das páginas visitadas, melhorando " +"a velocidade de acesso a páginas enquanto utiliza Tor.\n" +"\n" +"Torbutton é uma extensão do Firefox que permite activar e desactivar " +"rapidamente o anonimato de seu navegador.\n" +"\n" +"Se já instalou previamente o Tor, Vidalia, Polipo ou Firefox, por favor " +"certifique-se de que nenhuma das aplicações está actualmente em " +"funcionamento, antes de prosseguir com esta instalação.\n" "\n" "$_CLICK" @@ -74,9 +74,9 @@ msgstr "" "A instalação foi completada.\n" "Por favor visite https://www.torproject.org/docs/tor-doc-windows para " -"aprender como configurar os seus aplicativos para usar o Tor.\n" +"aprender como configurar as suas aplicaçãoes para utilizar o Tor.\n" "\n" -"Se você instalou o Torbutton, você terá que reiniciar o Firefox." +"Se instalou o Torbutton, terá que reiniciar o Firefox." msgctxt "BundleRunNow" msgid "Run installed components now" @@ -85,7 +85,8 @@ msgctxt "VidaliaGroupDesc" msgid "Vidalia is a GUI that helps you control, monitor, and configure Tor." msgstr "" -"Vidalia é um GUI que ajuda você a controlar, monitorar e configurar o Tor." +"Vidalia é uma aplicação gráfica que o ajuda a controlar, monitorizar e " +"configurar o Tor." msgctxt "VidaliaUninstDesc" msgid "Remove ${VIDALIA_DESC}." @@ -102,7 +103,8 @@ "\n" "$_CLICK" msgstr "" -"Este assistente irá guiá-lo através da instalação do ${VIDALIA_DESC}.\n" +"Este assistente irá guiá-lo na instalação do Vidalia, uma aplicação gráfica " +"que lhe permite controlar, monitorizar e configurar o Tor.\n" "\n" "$_CLICK" @@ -112,12 +114,13 @@ msgctxt "VidaliaLinkText" msgid "${VIDALIA_NAME} homepage" -msgstr "${VIDALIA_NAME} Site" +msgstr "${VIDALIA_NAME} website" msgctxt "VidaliaAppDesc" msgid "Vidalia is a GUI that helps you control, monitor, and configure Tor." msgstr "" -"Vidalia é um GUI que ajuda você a controlar, monitorar, e configurar o Tor." +"Vidalia é uma aplicação gráfica que o ajuda a controlar, monitorizar, e " +"configurar o Tor." msgctxt "VidaliaStartup" msgid "Run At Startup" @@ -137,16 +140,16 @@ msgctxt "VidaliaRunNow" msgid "Run ${VIDALIA_NAME}" -msgstr "Executar o ${VIDALIA_NAME} agora" +msgstr "Executar o ${VIDALIA_NAME}" msgctxt "TorGroupDesc" msgid "" "Tor is a system for using the Internet anonymously, helping you anonymize " "Web browsing and publishing, instant messaging, IRC, and more." msgstr "" -"Tor é um sistema para utilizar a internet anonimamente, ajudando você a " -"manter o anonimato no Browser e publicador, mensagem instantânea, IRC, e " -"mais" +"Tor é um sistema para utilizar a Internet anonimamente, ajudando-o a manter " +"o anonimato no navegador e publicador, aplicação de mensagens instantâneas, " +"IRC, e outras." msgctxt "TorUninstDesc" msgid "Remove ${TOR_DESC}." @@ -162,9 +165,9 @@ "$\n" "Do you want to overwrite it with the default sample configuration file?" msgstr "" -"Você já tem um arquivo de configuração do Tor.$\n" +"Você já tem um ficheiro de configuração do Tor.$\n" "$\n" -"Você deseja substituí-lo com o arquivo de exemplo de configuração padrão?" +"Você deseja substituí-lo com o ficheiro de exemplo de configuração padrão?" msgctxt "TorDocumentation" msgid "Documentation" @@ -182,45 +185,46 @@ msgid "Add ${TOR_NAME} to your Start menu." msgstr "Adicionar o ${TOR_NAME} ao seu Menu Iniciar." -msgctxt "PrivoxyGroupDesc" +# caching web proxy? Acham bem? - Tiago +msgctxt "PolipoGroupDesc" msgid "" -"Privoxy is a filtering web proxy that protects your privacy and helps remove " -"ads, banners, and popups." +"Polipo is a caching web proxy that increases performance of web browsing " +"through Tor." msgstr "" -"Privoxy é um filtro de proxy que proteje sua privacidade e remove ads, " -"banners, e popups." +"O Polipo é um proxy de cópias locais que melhora o desempenho da rede " +"enquanto utiliza Tor." -msgctxt "PrivoxyUninstDesc" -msgid "Remove ${PRIVOXY_DESC}." -msgstr "Remover ${PRIVOXY_DESC}." +msgctxt "PolipoUninstDesc" +msgid "Remove ${POLIPO_DESC}." +msgstr "Remover ${POLIPO_DESC}." -msgctxt "PrivoxyAppDesc" -msgid "Install ${PRIVOXY_DESC}." -msgstr "Instalar ${PRIVOXY_DESC}." +msgctxt "PolipoAppDesc" +msgid "Install ${POLIPO_DESC}." +msgstr "Instalar ${POLIPO_DESC}." -msgctxt "PrivoxyShortcuts" +msgctxt "PolipoShortcuts" msgid "Add to Start Menu" msgstr "Adicionar ao Menu Iniciar" -msgctxt "PrivoxyShortcutsDesc" -msgid "Add ${PRIVOXY_NAME} to your Start menu." -msgstr "Adicionar o ${PRIVOXY_NAME} ao seu Menu Iniciar." +msgctxt "PolipoShortcutsDesc" +msgid "Add ${POLIPO_NAME} to your Start menu." +msgstr "Adicionar o ${POLIPO_NAME} ao seu Menu Iniciar." -msgctxt "PrivoxyStartup" +msgctxt "PolipoStartup" msgid "Run At Startup" msgstr "Executar Na Inicialização" -msgctxt "PrivoxyStartupDesc" -msgid "Automatically run ${PRIVOXY_NAME} at startup." -msgstr "Executar o ${PRIVOXY_NAME} automaticamente na inicialização." +msgctxt "PolipoStartupDesc" +msgid "Automatically run ${POLIPO_NAME} at startup." +msgstr "Executar o ${POLIPO_NAME} automaticamente na inicialização." msgctxt "TorbuttonGroupDesc" msgid "" "Torbutton is a Firefox extension that allows you to quickly enable or " "disable anonymous web browsing." msgstr "" -"Torbutton é uma extensão do Firefox que permite você a habilitar e " -"desabilitar rapidamente o anonimato do seu Browser." +"Torbutton é uma extensão do Firefox que permite activar e desactivar " +"rapidamente o anonimato do seu navegador." msgctxt "TorbuttonUninstDesc" msgid "Remove ${TORBUTTON_DESC}." @@ -236,7 +240,7 @@ msgctxt "TorbuttonAddToFirefoxDesc" msgid "Add the ${TORBUTTON_DESC} extension to Firefox." -msgstr "Adicionar a extensão ${TORBUTTON_DESC} no Firefox." +msgstr "Adicionar a extensão ${TORBUTTON_DESC} ao Firefox." msgctxt "TorbuttonFirefoxNotFound" msgid "Firefox was not found on your system. Not installing Torbutton." @@ -249,11 +253,11 @@ msgctxt "AppDataUninstDesc" msgid "Remove saved application data and configuration files." -msgstr "Remover dados da aplicação e arquivos de configuração salvos." +msgstr "Remover dados da aplicação e ficheiros de configuração salvos." msgctxt "LanguageCode" msgid "en" -msgstr "pt-br" +msgstr "pt" msgctxt "FirefoxWarningPageTitle" msgid "Firefox is not installed" @@ -263,7 +267,7 @@ msgid "" "We recommend that you install Firefox before continuing, for best safety." msgstr "" -"Nós recomendamos que você instale o Firefox antes de continuar, para maior " +"Nós recomendamos a instalação do Firefox antes de continuar, para maior " "segurança." msgctxt "FirefoxWarningPageUpperText" @@ -276,12 +280,14 @@ "If you would like to install Firefox, please press Cancel, then go\n" "to the Firefox download page at" msgstr "" -"O Mozilla Firefox Browser de internet não está instalado em seu computador.\n" -"Tor vai funcionar em outros Browsers, assim como no Internet Explorer, mas\n" -"é mais facil utilizar junto ao Firefox, o qual se encarrega melhor " -"protejento seu anonimato.\n" -"Se você quer instalar o Firefox, porfavor clique no botão Cancel, que você " -"será redirecionado para a Página de download do Firefox " +"O navegador de Internet Mozilla Firefox não está instalado no seu " +"computador.\n" +"O Tor vai funcionar com outros navegadores, assim como no Internet Explorer, " +"mas é mais fácil a sua utilização com o Firefox, que fará um melhor " +"trabalho para manter o seu anonimato.\n" +"\n" +"Se quer instalar o Firefox, por favor clique no botão Cancelar, e será " +"redireccionado para a página de download do Firefox " msgctxt "FirefoxWarningPageLowerText" msgid "" @@ -291,8 +297,8 @@ "Or, if you would prefer to install Tor without Firefox, simply\n" "press Next to continue." msgstr "" -"Quando você terminar de instalar o Firefox, você pode rodar o\n" -"Instalador do Tor novamente.\n" +"Quando terminar de instalar o Firefox, pode executar o instalador do Tor " +"novamente.\n" "\n" -"Ou, se você preferir instalar o Tor sem o Firefox, simplismente clique Next " -"para continuar." +"Ou, se você preferir instalar o Tor sem o Firefox, simplesmente clique " +"Seguinte para continuar." diff -Nru vidalia-0.1.13/pkg/win32/ro/vidalia_ro.po vidalia-0.2.8/pkg/win32/ro/vidalia_ro.po --- vidalia-0.1.13/pkg/win32/ro/vidalia_ro.po 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/pkg/win32/ro/vidalia_ro.po 2009-09-18 11:41:04.000000000 +0100 @@ -3,8 +3,8 @@ "Project-Id-Version: Vidalia\n" "Report-Msgid-Bugs-To: translations@vidalia-project.net\n" "POT-Creation-Date: 2008-07-12 05:29+0000\n" -"PO-Revision-Date: 2008-11-02 22:56+0000\n" -"Last-Translator: Tiberiu Cristea \n" +"PO-Revision-Date: 2009-09-06 17:17+0000\n" +"Last-Translator: tqsoftware \n" "Language-Team: translations@vidalia-project.net\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -18,26 +18,24 @@ msgstr "Instalare ${BUNDLE_NAME}" # "supliment Firefox" este terminologia folosita de Mozilla in interfata in limba romana a mozilla.org. De aceea am preferat aceasta exprimare in locul "extensie Firefox". -# # Pe viitor, incercati ca in traduceri, atunci cand va adresati utiliyatorului, sa folositi persoana a II-a plural si nu singular. -# # De asemenea, evitati articularea inutila a numelor proprii, de exemplu "Tor-ului". "Tor" e mai corect, mai curat si mai simplu. msgctxt "BundleWelcomeText" msgid "" -"This wizard will guide you through the installation of Tor, Vidalia, " -"Privoxy, and Torbutton.\n" +"This wizard will guide you through the installation of Tor, Vidalia, Polipo, " +"and Torbutton.\n" "\n" "Tor is a system for using the Internet anonymously, helping you anonymize " "Web browsing and publishing, instant messaging, IRC, and more. Vidalia is a " "GUI that helps you control, monitor, and configure Tor.\n" "\n" -"Privoxy is a filtering web proxy that protects your privacy and helps remove " -"ads, banners, and popups.\n" +"Polipo is a caching web proxy that helps increase performance of browsing " +"the web through Tor.\n" "\n" "Torbutton is a Firefox extension that allows you to quickly enable or " "disable anonymous web browsing.\n" "\n" -"If you have previously installed Tor, Vidalia, Privoxy, or Firefox, please " +"If you have previously installed Tor, Vidalia, Polipo, or Firefox, please " "make sure they are not running before continuing this installation.\n" "\n" "$_CLICK" @@ -190,37 +188,41 @@ msgid "Add ${TOR_NAME} to your Start menu." msgstr "Adaugă ${TOR_NAME} în meniul Start." -msgctxt "PrivoxyGroupDesc" +msgctxt "PolipoGroupDesc" msgid "" -"Privoxy is a filtering web proxy that protects your privacy and helps remove " -"ads, banners, and popups." +"Polipo is a caching web proxy that increases performance of web browsing " +"through Tor." msgstr "" -"Privoxy este un proxy web pentru filtrare care vă protejează intimitatea şi " -"ajută la înlăturarea reclamelor, bannerelor şi ferestrelor de tip pop-up." +"Polipo este un proxy web pentru depozitare care creşte performanţele " +"navigării pe Web prin Tor." -msgctxt "PrivoxyUninstDesc" -msgid "Remove ${PRIVOXY_DESC}." -msgstr "Înlătură ${PRIVOXY_DESC}." +msgctxt "PolipoUninstDesc" +msgid "Remove ${POLIPO_DESC}." +msgstr "Elimini ${POLIPO_DESC}." + +msgctxt "PolipoAppDesc" +msgid "Install ${POLIPO_DESC}." +msgstr "Instalezi ${POLIPO_DESC}." -msgctxt "PrivoxyAppDesc" -msgid "Install ${PRIVOXY_DESC}." -msgstr "Instalează ${PRIVOXY_DESC}." - -msgctxt "PrivoxyShortcuts" +#, fuzzy +msgctxt "PolipoShortcuts" msgid "Add to Start Menu" msgstr "Adaugă în meniul Start" -msgctxt "PrivoxyShortcutsDesc" -msgid "Add ${PRIVOXY_NAME} to your Start menu." -msgstr "Adaugă ${PRIVOXY_NAME} în meniul Start." +#, fuzzy +msgctxt "PolipoShortcutsDesc" +msgid "Add ${POLIPO_NAME} to your Start menu." +msgstr "Adaugă ${POLIPO_NAME} în meniul Start." -msgctxt "PrivoxyStartup" +#, fuzzy +msgctxt "PolipoStartup" msgid "Run At Startup" msgstr "Porneşte odată cu sistemul de operare" -msgctxt "PrivoxyStartupDesc" -msgid "Automatically run ${PRIVOXY_NAME} at startup." -msgstr "Rulează ${PRIVOXY_NAME} la pornire." +#, fuzzy +msgctxt "PolipoStartupDesc" +msgid "Automatically run ${POLIPO_NAME} at startup." +msgstr "Rulează ${POLIPO_NAME} la pornire." msgctxt "TorbuttonGroupDesc" msgid "" diff -Nru vidalia-0.1.13/pkg/win32/ru/vidalia_ru.po vidalia-0.2.8/pkg/win32/ru/vidalia_ru.po --- vidalia-0.1.13/pkg/win32/ru/vidalia_ru.po 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/pkg/win32/ru/vidalia_ru.po 2009-10-31 21:19:53.000000000 +0000 @@ -3,14 +3,14 @@ "Project-Id-Version: Vidalia\n" "Report-Msgid-Bugs-To: translations@vidalia-project.net\n" "POT-Creation-Date: 2008-07-12 05:29+0000\n" -"PO-Revision-Date: 2008-07-17 03:12+0000\n" -"Last-Translator: Matt \n" +"PO-Revision-Date: 2009-10-30 18:56+0000\n" +"Last-Translator: Alexey Vertinsky \n" "Language-Team: translations@vidalia-project.net\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%" -"10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n" +"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && " +"n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n" "X-Generator: Pootle 1.1.0\n" msgctxt "BundleSetupCaption" @@ -19,40 +19,38 @@ msgctxt "BundleWelcomeText" msgid "" -"This wizard will guide you through the installation of Tor, Vidalia, " -"Privoxy, and Torbutton.\n" +"This wizard will guide you through the installation of Tor, Vidalia, Polipo, " +"and Torbutton.\n" "\n" "Tor is a system for using the Internet anonymously, helping you anonymize " "Web browsing and publishing, instant messaging, IRC, and more. Vidalia is a " "GUI that helps you control, monitor, and configure Tor.\n" "\n" -"Privoxy is a filtering web proxy that protects your privacy and helps remove " -"ads, banners, and popups.\n" +"Polipo is a caching web proxy that helps increase performance of browsing " +"the web through Tor.\n" "\n" "Torbutton is a Firefox extension that allows you to quickly enable or " "disable anonymous web browsing.\n" "\n" -"If you have previously installed Tor, Vidalia, Privoxy, or Firefox, please " +"If you have previously installed Tor, Vidalia, Polipo, or Firefox, please " "make sure they are not running before continuing this installation.\n" "\n" "$_CLICK" msgstr "" -"Эта программа установит Tor, Vidalia, Privoxy, и Torbutton.\n" +"Этот помощник поможет вам установить Tor, Vidalia, Privoxy, и Torbutton.\n" "\n" "Tor это система анонимного использования сети Internet, которая поможет " -"анонимизировать Вашу веб-деятельность, системы мгновенного обмена " -"сообщениями, IRC, и многое другое. Vidalia это программа с оконным " -"интерфейсом для настройки, управления и контроля Tor.\n" +"анонимизировать просмотр страниц, публикации, обмен сообщениями, IRC, и " +"многое другое. Vidalia это программа с оконным интерфейсом для настройки, " +"управления и контроля Tor.\n" "\n" -"Privoxy это фильтрующий веб-прокси который помогает защитить вашу " -"приватность, а также удаляет рекламу, баннеры, и всплывающие сообщения.\n" +"Privoxy это кэширующий веб-прокси который ускоряет работу в интернете.\n" "\n" -"Torbutton это расширение Firefox для быстрого включения/выключения режима " -"анонимного использования браузера.\n" +"Torbutton это расширение Firefox позволяющее быстро включить или выключить " +"режим анонимного просмотра страниц.\n" "\n" -"Если вы ранее уже устанавливали Tor, Vidalia, Privoxy, или Firefox, " -"пожалуйста убедитесь что эти программы остановлены и потом продолжите " -"установку.\n" +"Если у вас уже установлены Tor, Vidalia, Privoxy, или Firefox; Прежде чем " +"продолжить установку: убедитесь что эти программы не запущены.\n" "\n" "$_CLICK" @@ -185,37 +183,37 @@ msgid "Add ${TOR_NAME} to your Start menu." msgstr "Добавить ${TOR_NAME} в Главное Меню." -msgctxt "PrivoxyGroupDesc" +msgctxt "PolipoGroupDesc" msgid "" -"Privoxy is a filtering web proxy that protects your privacy and helps remove " -"ads, banners, and popups." +"Polipo is a caching web proxy that increases performance of web browsing " +"through Tor." msgstr "" -"Privoxy это фильтрующий веб-прокси который помогает защитить вашу " -"приватность, а также удаляет рекламу, баннеры, и всплывающие сообщения." +"Polipo это кэширующий прокси сервер, он ускоряет работу с интернетом через " +"Tor." -msgctxt "PrivoxyUninstDesc" -msgid "Remove ${PRIVOXY_DESC}." -msgstr "Удалить ${PRIVOXY_DESC}." +msgctxt "PolipoUninstDesc" +msgid "Remove ${POLIPO_DESC}." +msgstr "Удалить ${POLIPO_DESC}." -msgctxt "PrivoxyAppDesc" -msgid "Install ${PRIVOXY_DESC}." -msgstr "Установить ${PRIVOXY_DESC}." +msgctxt "PolipoAppDesc" +msgid "Install ${POLIPO_DESC}." +msgstr "Установить ${POLIPO_DESC}." -msgctxt "PrivoxyShortcuts" +msgctxt "PolipoShortcuts" msgid "Add to Start Menu" -msgstr "Ярлыки в Главное Меню" +msgstr "Добавить в Меню \"Пуск\"" -msgctxt "PrivoxyShortcutsDesc" -msgid "Add ${PRIVOXY_NAME} to your Start menu." -msgstr "Добавить ${PRIVOXY_NAME} в Главное Меню." +msgctxt "PolipoShortcutsDesc" +msgid "Add ${POLIPO_NAME} to your Start menu." +msgstr "Добавить ${POLIPO_NAME} в ваше меню \"Пуск\"." -msgctxt "PrivoxyStartup" +msgctxt "PolipoStartup" msgid "Run At Startup" -msgstr "Автозапуск" +msgstr "Запускать при старте системы" -msgctxt "PrivoxyStartupDesc" -msgid "Automatically run ${PRIVOXY_NAME} at startup." -msgstr "Автоматически запускать ${PRIVOXY_NAME} при загрузке системы." +msgctxt "PolipoStartupDesc" +msgid "Automatically run ${POLIPO_NAME} at startup." +msgstr "Автоматически запускать ${POLIPO_NAME} при загрузке системы." msgctxt "TorbuttonGroupDesc" msgid "" @@ -260,12 +258,12 @@ msgctxt "FirefoxWarningPageTitle" msgid "Firefox is not installed" -msgstr "" +msgstr "Firefox не установлен на компьютере" msgctxt "FirefoxWarningPageSubtitle" msgid "" "We recommend that you install Firefox before continuing, for best safety." -msgstr "" +msgstr "Из соображений безопасности, мы рекомендуем сначала установить Firefox" msgctxt "FirefoxWarningPageUpperText" msgid "" @@ -277,6 +275,13 @@ "If you would like to install Firefox, please press Cancel, then go\n" "to the Firefox download page at" msgstr "" +"Firefox не установлен на вашем компьютере.\n" +"Tor будет работать с другими браузерами, такими как Internet Explorer, но\n" +"лучше использовать Firefox, который, к тому же, заботится о Вашей " +"анонимности.\n" +"\n" +"Если Вы хотите установить Firefox , нажмите Отмена, а затем перейдите \n" +"на страницу для скачиваания Firefox" msgctxt "FirefoxWarningPageLowerText" msgid "" @@ -286,3 +291,8 @@ "Or, if you would prefer to install Tor without Firefox, simply\n" "press Next to continue." msgstr "" +"Когда Вы закончите установку Firefox, Вы можете опять запустить\n" +"установку Tor. \n" +"\n" +"Или, если Вы хотите установить Tor без Firefox, просто\n" +"нажмите Далее." diff -Nru vidalia-0.1.13/pkg/win32/sv/vidalia_sv.po vidalia-0.2.8/pkg/win32/sv/vidalia_sv.po --- vidalia-0.1.13/pkg/win32/sv/vidalia_sv.po 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/pkg/win32/sv/vidalia_sv.po 2009-08-31 03:49:46.000000000 +0100 @@ -16,22 +16,23 @@ msgid "${BUNDLE_NAME} setup" msgstr "${BUNDLE_NAME}-installer" +#, fuzzy msgctxt "BundleWelcomeText" msgid "" -"This wizard will guide you through the installation of Tor, Vidalia, " -"Privoxy, and Torbutton.\n" +"This wizard will guide you through the installation of Tor, Vidalia, Polipo, " +"and Torbutton.\n" "\n" "Tor is a system for using the Internet anonymously, helping you anonymize " "Web browsing and publishing, instant messaging, IRC, and more. Vidalia is a " "GUI that helps you control, monitor, and configure Tor.\n" "\n" -"Privoxy is a filtering web proxy that protects your privacy and helps remove " -"ads, banners, and popups.\n" +"Polipo is a caching web proxy that helps increase performance of browsing " +"the web through Tor.\n" "\n" "Torbutton is a Firefox extension that allows you to quickly enable or " "disable anonymous web browsing.\n" "\n" -"If you have previously installed Tor, Vidalia, Privoxy, or Firefox, please " +"If you have previously installed Tor, Vidalia, Polipo, or Firefox, please " "make sure they are not running before continuing this installation.\n" "\n" "$_CLICK" @@ -183,36 +184,41 @@ msgid "Add ${TOR_NAME} to your Start menu." msgstr "Lägg till ${TOR_NAME} i din startmeny." -msgctxt "PrivoxyGroupDesc" +msgctxt "PolipoGroupDesc" msgid "" -"Privoxy is a filtering web proxy that protects your privacy and helps remove " -"ads, banners, and popups." +"Polipo is a caching web proxy that increases performance of web browsing " +"through Tor." msgstr "" -"Privoxy är en filtrerande webbproxy som tar bort reklam, bannrar och pop-ups." -msgctxt "PrivoxyUninstDesc" -msgid "Remove ${PRIVOXY_DESC}." -msgstr "Ta bort ${PRIVOXY_DESC}." +#, fuzzy +msgctxt "PolipoUninstDesc" +msgid "Remove ${POLIPO_DESC}." +msgstr "Ta bort ${POLIPO_DESC}." + +#, fuzzy +msgctxt "PolipoAppDesc" +msgid "Install ${POLIPO_DESC}." +msgstr "Installera ${POLIPO_DESC}." -msgctxt "PrivoxyAppDesc" -msgid "Install ${PRIVOXY_DESC}." -msgstr "Installera ${PRIVOXY_DESC}." - -msgctxt "PrivoxyShortcuts" +#, fuzzy +msgctxt "PolipoShortcuts" msgid "Add to Start Menu" msgstr "Lägg till i startmenyn" -msgctxt "PrivoxyShortcutsDesc" -msgid "Add ${PRIVOXY_NAME} to your Start menu." -msgstr "Lägg till ${PRIVOXY_NAME} i din startmeny." +#, fuzzy +msgctxt "PolipoShortcutsDesc" +msgid "Add ${POLIPO_NAME} to your Start menu." +msgstr "Lägg till ${POLIPO_NAME} i din startmeny." -msgctxt "PrivoxyStartup" +#, fuzzy +msgctxt "PolipoStartup" msgid "Run At Startup" msgstr "Kör vid uppstart" -msgctxt "PrivoxyStartupDesc" -msgid "Automatically run ${PRIVOXY_NAME} at startup." -msgstr "Kör automatiskt igång ${PRIVOXY_NAME} vid uppstart." +#, fuzzy +msgctxt "PolipoStartupDesc" +msgid "Automatically run ${POLIPO_NAME} at startup." +msgstr "Kör automatiskt igång ${POLIPO_NAME} vid uppstart." msgctxt "TorbuttonGroupDesc" msgid "" @@ -297,3 +303,4 @@ "\n" "Eller om du föredrar att installera Tor utan Firefox, så\n" "tryck på Nästa för att fortsätta" + diff -Nru vidalia-0.1.13/pkg/win32/templates/vidalia.pot vidalia-0.2.8/pkg/win32/templates/vidalia.pot --- vidalia-0.1.13/pkg/win32/templates/vidalia.pot 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/pkg/win32/templates/vidalia.pot 2009-08-31 03:05:02.000000000 +0100 @@ -16,7 +16,17 @@ msgstr "" msgctxt "BundleWelcomeText" -msgid "This wizard will guide you through the installation of Tor, Vidalia, Privoxy, and Torbutton.\n\nTor is a system for using the Internet anonymously, helping you anonymize Web browsing and publishing, instant messaging, IRC, and more. Vidalia is a GUI that helps you control, monitor, and configure Tor.\n\nPrivoxy is a filtering web proxy that protects your privacy and helps remove ads, banners, and popups.\n\nTorbutton is a Firefox extension that allows you to quickly enable or disable anonymous web browsing.\n\nIf you have previously installed Tor, Vidalia, Privoxy, or Firefox, please make sure they are not running before continuing this installation.\n\n$_CLICK" +msgid "" +"This wizard will guide you through the installation of Tor, " +"Vidalia, Polipo, and Torbutton.\n\nTor is a system for using the " +"Internet anonymously, helping you anonymize Web browsing and publishing, " +"instant messaging, IRC, and more. Vidalia is a GUI that helps you " +"control, monitor, and configure Tor.\n\nPolipo is a caching web proxy " +"that helps increase performance of browsing the web through " +"Tor.\n\nTorbutton is a Firefox extension that allows you to quickly " +"enable or disable anonymous web browsing.\n\nIf you have previously " +"installed Tor, Vidalia, Polipo, or Firefox, please make sure they are " +"not running before continuing this installation.\n\n$_CLICK" msgstr "" msgctxt "BundleWelcomeTitle" @@ -115,32 +125,32 @@ msgid "Add ${TOR_NAME} to your Start menu." msgstr "" -msgctxt "PrivoxyGroupDesc" -msgid "Privoxy is a filtering web proxy that protects your privacy and helps remove ads, banners, and popups." +msgctxt "PolipoGroupDesc" +msgid "Polipo is a caching web proxy that increases performance of web browsing through Tor." msgstr "" -msgctxt "PrivoxyUninstDesc" -msgid "Remove ${PRIVOXY_DESC}." +msgctxt "PolipoUninstDesc" +msgid "Remove ${POLIPO_DESC}." msgstr "" -msgctxt "PrivoxyAppDesc" -msgid "Install ${PRIVOXY_DESC}." +msgctxt "PolipoAppDesc" +msgid "Install ${POLIPO_DESC}." msgstr "" -msgctxt "PrivoxyShortcuts" +msgctxt "PolipoShortcuts" msgid "Add to Start Menu" msgstr "" -msgctxt "PrivoxyShortcutsDesc" -msgid "Add ${PRIVOXY_NAME} to your Start menu." +msgctxt "PolipoShortcutsDesc" +msgid "Add ${POLIPO_NAME} to your Start menu." msgstr "" -msgctxt "PrivoxyStartup" +msgctxt "PolipoStartup" msgid "Run At Startup" msgstr "" -msgctxt "PrivoxyStartupDesc" -msgid "Automatically run ${PRIVOXY_NAME} at startup." +msgctxt "PolipoStartupDesc" +msgid "Automatically run ${POLIPO_NAME} at startup." msgstr "" msgctxt "TorbuttonGroupDesc" @@ -203,4 +213,4 @@ "\n\n" "Or, if you would prefer to install Tor without Firefox, simply\n" "press Next to continue." -msgstr "" \ No newline at end of file +msgstr "" diff -Nru vidalia-0.1.13/pkg/win32/thandy.wxs.in vidalia-0.2.8/pkg/win32/thandy.wxs.in --- vidalia-0.1.13/pkg/win32/thandy.wxs.in 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/pkg/win32/thandy.wxs.in 2009-03-10 09:18:28.000000000 +0000 @@ -0,0 +1,106 @@ + + + + + + + + + + + + + + + + + + + omus + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -Nru vidalia-0.1.13/pkg/win32/torbutton.wxs.in vidalia-0.2.8/pkg/win32/torbutton.wxs.in --- vidalia-0.1.13/pkg/win32/torbutton.wxs.in 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/pkg/win32/torbutton.wxs.in 2009-03-10 09:18:28.000000000 +0000 @@ -0,0 +1,147 @@ + + + + + + + + + + + + + + + + + + + + omus + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1]]> + + + + + + + + + + + + 1]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -Nru vidalia-0.1.13/pkg/win32/tor.wxs.in vidalia-0.2.8/pkg/win32/tor.wxs.in --- vidalia-0.1.13/pkg/win32/tor.wxs.in 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/pkg/win32/tor.wxs.in 2009-03-10 09:18:28.000000000 +0000 @@ -0,0 +1,405 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + omus + Tor Installation + + + 0 + Tor + Tor + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1]]> + + + + + + + + + + + + 1]]> + + + + + + + 1]]> + + + + + + + 1]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -Nru vidalia-0.1.13/pkg/win32/tr/vidalia_tr.po vidalia-0.2.8/pkg/win32/tr/vidalia_tr.po --- vidalia-0.1.13/pkg/win32/tr/vidalia_tr.po 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/pkg/win32/tr/vidalia_tr.po 2009-08-31 03:49:46.000000000 +0100 @@ -0,0 +1,250 @@ +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: translations@vidalia-project.net\n" +"POT-Creation-Date: 2008-07-12 05:29+0000\n" +"PO-Revision-Date: 2009-03-22 12:57+0200\n" +"Last-Translator: yunuskaba \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Translate Toolkit 1.1.1\n" + +msgctxt "BundleSetupCaption" +msgid "${BUNDLE_NAME} setup" +msgstr "${BUNDLE_NAME} Kurulumu" + +msgctxt "BundleWelcomeText" +msgid "" +"This wizard will guide you through the installation of Tor, Vidalia, Polipo, " +"and Torbutton.\n" +"\n" +"Tor is a system for using the Internet anonymously, helping you anonymize " +"Web browsing and publishing, instant messaging, IRC, and more. Vidalia is a " +"GUI that helps you control, monitor, and configure Tor.\n" +"\n" +"Polipo is a caching web proxy that helps increase performance of browsing " +"the web through Tor.\n" +"\n" +"Torbutton is a Firefox extension that allows you to quickly enable or " +"disable anonymous web browsing.\n" +"\n" +"If you have previously installed Tor, Vidalia, Polipo, or Firefox, please " +"make sure they are not running before continuing this installation.\n" +"\n" +"$_CLICK" +msgstr "" + +msgctxt "BundleWelcomeTitle" +msgid "Welcome to the ${BUNDLE_NAME} Setup Wizard" +msgstr "${BUNDLE_NAME} Kurulum sihibazına Hoş Geldiniz" + +msgctxt "BundleLinkText" +msgid "${TOR_NAME} installation documentation" +msgstr "${TOR_NAME} kurulum dökümanları" + +msgctxt "BundleFinishText" +msgid "" +"Installation is complete.\n" +"Please see https://www.torproject.org/docs/tor-doc-windows to learn how to " +"configure your applications to use Tor.\n" +"\n" +"If you installed Torbutton, you will need to restart Firefox." +msgstr "" + +msgctxt "BundleRunNow" +msgid "Run installed components now" +msgstr "Yüklü bileşenleri çalıştır" + +msgctxt "VidaliaGroupDesc" +msgid "Vidalia is a GUI that helps you control, monitor, and configure Tor." +msgstr "" + +msgctxt "VidaliaUninstDesc" +msgid "Remove ${VIDALIA_DESC}." +msgstr "Kaldır ${VIDALIA_DESC}." + +msgctxt "VidaliaSetupCaption" +msgid "${VIDALIA_NAME} setup" +msgstr "${VIDALIA_NAME} Kurulumu" + +msgctxt "VidaliaWelcomeText" +msgid "" +"This wizard will guide you through the installation of Vidalia, a GUI that " +"helps you control, monitor, and configure Tor.\n" +"\n" +"$_CLICK" +msgstr "" + +msgctxt "VidaliaWelcomeTitle" +msgid "Welcome to the ${VIDALIA_NAME} Setup Wizard" +msgstr "${VIDALIA_NAME} Kurulum sihibazına Hoş Geldiniz" + +msgctxt "VidaliaLinkText" +msgid "${VIDALIA_NAME} homepage" +msgstr "${VIDALIA_NAME} anasayfası" + +msgctxt "VidaliaAppDesc" +msgid "Vidalia is a GUI that helps you control, monitor, and configure Tor." +msgstr "Vidalia arayüzü Tor'u kolayca yönetmenize yardımcı eder." + +msgctxt "VidaliaStartup" +msgid "Run At Startup" +msgstr "" + +msgctxt "VidaliaStartupDesc" +msgid "Automatically run ${VIDALIA_NAME} at startup." +msgstr "${VIDALIA_NAME} başlangıçta çalıştır." + +msgctxt "VidaliaShortcuts" +msgid "Add to Start Menu" +msgstr "" + +msgctxt "VidaliaShortcutsDesc" +msgid "Add ${VIDALIA_NAME} to your Start menu." +msgstr " ${VIDALIA_NAME} Başlangıca ekle." + +msgctxt "VidaliaRunNow" +msgid "Run ${VIDALIA_NAME}" +msgstr "Çalıştır ${VIDALIA_NAME}" + +msgctxt "TorGroupDesc" +msgid "" +"Tor is a system for using the Internet anonymously, helping you anonymize " +"Web browsing and publishing, instant messaging, IRC, and more." +msgstr "" + +msgctxt "TorUninstDesc" +msgid "Remove ${TOR_DESC}." +msgstr "Kaldır ${TOR_DESC}." + +msgctxt "TorAppDesc" +msgid "Install ${TOR_DESC}." +msgstr "Kur ${TOR_DESC}." + +msgctxt "TorAskOverwriteTorrc" +msgid "" +"You already have a Tor configuration file.$\n" +"$\n" +"Do you want to overwrite it with the default sample configuration file?" +msgstr "" + +msgctxt "TorDocumentation" +msgid "Documentation" +msgstr "Dökümanlar" + +msgctxt "TorDocumentationDesc" +msgid "Install ${TOR_NAME} documentation." +msgstr "${TOR_NAME} kurulum dökümanlarını yükle." + +msgctxt "TorShortcuts" +msgid "Add to Start Menu" +msgstr "" + +msgctxt "TorShortcutsDesc" +msgid "Add ${TOR_NAME} to your Start menu." +msgstr " ${TOR_NAME} Başlangıca ekle." + +msgctxt "PolipoGroupDesc" +msgid "" +"Polipo is a caching web proxy that increases performance of web browsing " +"through Tor." +msgstr "" + +#, fuzzy +msgctxt "PolipoUninstDesc" +msgid "Remove ${POLIPO_DESC}." +msgstr "Kaldır ${POLIPO_DESC}." + +#, fuzzy +msgctxt "PolipoAppDesc" +msgid "Install ${POLIPO_DESC}." +msgstr "Kur ${POLIPO_DESC}." + +#, fuzzy +msgctxt "PolipoShortcuts" +msgid "Add to Start Menu" +msgstr "Başlangıç Menüsüne Ekle" + +#, fuzzy +msgctxt "PolipoShortcutsDesc" +msgid "Add ${POLIPO_NAME} to your Start menu." +msgstr " ${POLIPO_NAME} Başlangıca ekle." + +#, fuzzy +msgctxt "PolipoStartup" +msgid "Run At Startup" +msgstr "Başlangıçta Çalıştır" + +#, fuzzy +msgctxt "PolipoStartupDesc" +msgid "Automatically run ${POLIPO_NAME} at startup." +msgstr "${POLIPO_NAME} başlangıçta otomaik olarak çalıştır." + +msgctxt "TorbuttonGroupDesc" +msgid "" +"Torbutton is a Firefox extension that allows you to quickly enable or " +"disable anonymous web browsing." +msgstr "" + +msgctxt "TorbuttonUninstDesc" +msgid "Remove ${TORBUTTON_DESC}." +msgstr "Kaldır ${TORBUTTON_DESC}." + +msgctxt "TorbuttonAppDesc" +msgid "Install ${TORBUTTON_DESC}." +msgstr "Kur ${TORBUTTON_DESC}." + +msgctxt "TorbuttonAddToFirefox" +msgid "Add to Firefox" +msgstr "Firefoxa ekle" + +msgctxt "TorbuttonAddToFirefoxDesc" +msgid "Add the ${TORBUTTON_DESC} extension to Firefox." +msgstr " ${TORBUTTON_DESC} eklentisini Firefoxa ekle." + +msgctxt "TorbuttonFirefoxNotFound" +msgid "Firefox was not found on your system. Not installing Torbutton." +msgstr "Yüklü bir Firefox bulunamadı, torbutton kurulamadı" + +msgctxt "AppData" +msgid "Application Data" +msgstr "Uygulama Verisi" + +msgctxt "AppDataUninstDesc" +msgid "Remove saved application data and configuration files." +msgstr "Uygulama veriliverini ve ayar dosylarını kaldır" + +msgctxt "LanguageCode" +msgid "en" +msgstr "İngilizce" + +msgctxt "FirefoxWarningPageTitle" +msgid "Firefox is not installed" +msgstr "Firefox yüklü değil" + +msgctxt "FirefoxWarningPageSubtitle" +msgid "" +"We recommend that you install Firefox before continuing, for best safety." +msgstr "Güvenliğiniz için yüklemeden önce Firefoxu yüklemenizi tavsiye ederiz." + +msgctxt "FirefoxWarningPageUpperText" +msgid "" +"The Mozilla Firefox Web browser is not installed on your computer.\n" +"Tor will work with other browsers, such as Internet Explorer, but\n" +"is easier to use with Firefox, which also does a better job of\n" +"protecting your anonymity.\n" +"\n" +"If you would like to install Firefox, please press Cancel, then go\n" +"to the Firefox download page at" +msgstr "" + +msgctxt "FirefoxWarningPageLowerText" +msgid "" +"When you are done installing Firefox, you can once again run the\n" +"Tor installer.\n" +"\n" +"Or, if you would prefer to install Tor without Firefox, simply\n" +"press Next to continue." +msgstr "" diff -Nru vidalia-0.1.13/pkg/win32/uk/vidalia_uk.po vidalia-0.2.8/pkg/win32/uk/vidalia_uk.po --- vidalia-0.1.13/pkg/win32/uk/vidalia_uk.po 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/pkg/win32/uk/vidalia_uk.po 2009-08-31 03:49:46.000000000 +0100 @@ -0,0 +1,261 @@ +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: translations@vidalia-project.net\n" +"POT-Creation-Date: 2008-07-12 05:29+0000\n" +"PO-Revision-Date: 2008-12-24 21:56+0000\n" +"Last-Translator: Roger Dingledine \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Pootle 1.1.0\n" + +msgctxt "BundleSetupCaption" +msgid "${BUNDLE_NAME} setup" +msgstr "${BUNDLE_NAME} інсталяція" + +msgctxt "BundleWelcomeText" +msgid "" +"This wizard will guide you through the installation of Tor, Vidalia, Polipo, " +"and Torbutton.\n" +"\n" +"Tor is a system for using the Internet anonymously, helping you anonymize " +"Web browsing and publishing, instant messaging, IRC, and more. Vidalia is a " +"GUI that helps you control, monitor, and configure Tor.\n" +"\n" +"Polipo is a caching web proxy that helps increase performance of browsing " +"the web through Tor.\n" +"\n" +"Torbutton is a Firefox extension that allows you to quickly enable or " +"disable anonymous web browsing.\n" +"\n" +"If you have previously installed Tor, Vidalia, Polipo, or Firefox, please " +"make sure they are not running before continuing this installation.\n" +"\n" +"$_CLICK" +msgstr "" + +msgctxt "BundleWelcomeTitle" +msgid "Welcome to the ${BUNDLE_NAME} Setup Wizard" +msgstr "" + +msgctxt "BundleLinkText" +msgid "${TOR_NAME} installation documentation" +msgstr "" + +msgctxt "BundleFinishText" +msgid "" +"Installation is complete.\n" +"Please see https://www.torproject.org/docs/tor-doc-windows to learn how to " +"configure your applications to use Tor.\n" +"\n" +"If you installed Torbutton, you will need to restart Firefox." +msgstr "" + +msgctxt "BundleRunNow" +msgid "Run installed components now" +msgstr "Запустити встановленні компоненти зараз" + +msgctxt "VidaliaGroupDesc" +msgid "Vidalia is a GUI that helps you control, monitor, and configure Tor." +msgstr "" + +msgctxt "VidaliaUninstDesc" +msgid "Remove ${VIDALIA_DESC}." +msgstr "" + +msgctxt "VidaliaSetupCaption" +msgid "${VIDALIA_NAME} setup" +msgstr "" + +msgctxt "VidaliaWelcomeText" +msgid "" +"This wizard will guide you through the installation of Vidalia, a GUI that " +"helps you control, monitor, and configure Tor.\n" +"\n" +"$_CLICK" +msgstr "" + +msgctxt "VidaliaWelcomeTitle" +msgid "Welcome to the ${VIDALIA_NAME} Setup Wizard" +msgstr "" + +msgctxt "VidaliaLinkText" +msgid "${VIDALIA_NAME} homepage" +msgstr "Домашня сторінка ${VIDALIA_NAME}" + +msgctxt "VidaliaAppDesc" +msgid "Vidalia is a GUI that helps you control, monitor, and configure Tor." +msgstr "" +"Vidalia це інтерфейс який допоможе вам керувати, спостерігати, та " +"налаштовувати Tor." + +msgctxt "VidaliaStartup" +msgid "Run At Startup" +msgstr "Запускати при завантаженні" + +msgctxt "VidaliaStartupDesc" +msgid "Automatically run ${VIDALIA_NAME} at startup." +msgstr "Автоматично запускати ${VIDALIA_NAME} при завантаженні." + +msgctxt "VidaliaShortcuts" +msgid "Add to Start Menu" +msgstr "Додати до меню Пуск" + +msgctxt "VidaliaShortcutsDesc" +msgid "Add ${VIDALIA_NAME} to your Start menu." +msgstr "Додати ${VIDALIA_NAME} до вашого меню Пуск." + +msgctxt "VidaliaRunNow" +msgid "Run ${VIDALIA_NAME}" +msgstr "Запустити ${VIDALIA_NAME}" + +msgctxt "TorGroupDesc" +msgid "" +"Tor is a system for using the Internet anonymously, helping you anonymize " +"Web browsing and publishing, instant messaging, IRC, and more." +msgstr "" +"Tor це система для анонімного користування Інтернет, допомагає зберегти " +"анонімність при перегляді Веб сторінок та публікації, обміну миттєвими " +"повідомленнями, IRC, і багато чого іншого." + +msgctxt "TorUninstDesc" +msgid "Remove ${TOR_DESC}." +msgstr "Видалити ${TOR_DESC}." + +msgctxt "TorAppDesc" +msgid "Install ${TOR_DESC}." +msgstr "Встановити ${TOR_DESC}." + +msgctxt "TorAskOverwriteTorrc" +msgid "" +"You already have a Tor configuration file.$\n" +"$\n" +"Do you want to overwrite it with the default sample configuration file?" +msgstr "" +"У вас вже є конфігураційний файл Tor.$\n" +"$\n" +"Бажаєте перезаписати його типовим зразком конфігураційного файла?" + +msgctxt "TorDocumentation" +msgid "Documentation" +msgstr "Документація" + +msgctxt "TorDocumentationDesc" +msgid "Install ${TOR_NAME} documentation." +msgstr "Встановити документацію ${TOR_NAME}." + +msgctxt "TorShortcuts" +msgid "Add to Start Menu" +msgstr "Додати до меню Пуск" + +msgctxt "TorShortcutsDesc" +msgid "Add ${TOR_NAME} to your Start menu." +msgstr "Додати ${TOR_NAME} до вашого меню Пуск." + +msgctxt "PolipoGroupDesc" +msgid "" +"Polipo is a caching web proxy that increases performance of web browsing " +"through Tor." +msgstr "" + +#, fuzzy +msgctxt "PolipoUninstDesc" +msgid "Remove ${POLIPO_DESC}." +msgstr "Видалити ${POLIPO_DESC}." + +#, fuzzy +msgctxt "PolipoAppDesc" +msgid "Install ${POLIPO_DESC}." +msgstr "Встановити ${POLIPO_DESC}." + +#, fuzzy +msgctxt "PolipoShortcuts" +msgid "Add to Start Menu" +msgstr "Додати до меню Пуск" + +#, fuzzy +msgctxt "PolipoShortcutsDesc" +msgid "Add ${POLIPO_NAME} to your Start menu." +msgstr "Додати ${POLIPO_NAME} до вашого меню Пуск." + +#, fuzzy +msgctxt "PolipoStartup" +msgid "Run At Startup" +msgstr "Запускати при завантаженні" + +#, fuzzy +msgctxt "PolipoStartupDesc" +msgid "Automatically run ${POLIPO_NAME} at startup." +msgstr "Автоматично запускати ${POLIPO_NAME} при завантаженні." + +msgctxt "TorbuttonGroupDesc" +msgid "" +"Torbutton is a Firefox extension that allows you to quickly enable or " +"disable anonymous web browsing." +msgstr "" +"Torbutton це розширення для Firefox яке дозволяє вам швидко включати або " +"виключати анонімний перегляд веб сторінок." + +msgctxt "TorbuttonUninstDesc" +msgid "Remove ${TORBUTTON_DESC}." +msgstr "Видалити ${TORBUTTON_DESC}." + +msgctxt "TorbuttonAppDesc" +msgid "Install ${TORBUTTON_DESC}." +msgstr "Встановити ${TORBUTTON_DESC}." + +msgctxt "TorbuttonAddToFirefox" +msgid "Add to Firefox" +msgstr "Додати до Firefox" + +msgctxt "TorbuttonAddToFirefoxDesc" +msgid "Add the ${TORBUTTON_DESC} extension to Firefox." +msgstr "Додати розширення ${TORBUTTON_DESC} до Firefox." + +msgctxt "TorbuttonFirefoxNotFound" +msgid "Firefox was not found on your system. Not installing Torbutton." +msgstr "" + +msgctxt "AppData" +msgid "Application Data" +msgstr "Дані програми" + +msgctxt "AppDataUninstDesc" +msgid "Remove saved application data and configuration files." +msgstr "Видалити збережені дані програми та файли конфігурації." + +msgctxt "LanguageCode" +msgid "en" +msgstr "en" + +msgctxt "FirefoxWarningPageTitle" +msgid "Firefox is not installed" +msgstr "Firefox не встановлено" + +msgctxt "FirefoxWarningPageSubtitle" +msgid "" +"We recommend that you install Firefox before continuing, for best safety." +msgstr "" + +msgctxt "FirefoxWarningPageUpperText" +msgid "" +"The Mozilla Firefox Web browser is not installed on your computer.\n" +"Tor will work with other browsers, such as Internet Explorer, but\n" +"is easier to use with Firefox, which also does a better job of\n" +"protecting your anonymity.\n" +"\n" +"If you would like to install Firefox, please press Cancel, then go\n" +"to the Firefox download page at" +msgstr "" + +msgctxt "FirefoxWarningPageLowerText" +msgid "" +"When you are done installing Firefox, you can once again run the\n" +"Tor installer.\n" +"\n" +"Or, if you would prefer to install Tor without Firefox, simply\n" +"press Next to continue." +msgstr "" + diff -Nru vidalia-0.1.13/pkg/win32/vidalia-bundle.nsi.in vidalia-0.2.8/pkg/win32/vidalia-bundle.nsi.in --- vidalia-0.1.13/pkg/win32/vidalia-bundle.nsi.in 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/pkg/win32/vidalia-bundle.nsi.in 2010-02-17 19:28:50.000000000 +0000 @@ -1,5 +1,5 @@ ;; -;; $Id: vidalia-bundle.nsi.in 3092 2008-09-14 19:19:54Z edmanm $ +;; $Id: vidalia-bundle.nsi.in 4217 2010-02-17 19:28:50Z phobos $ ;; ;; 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 @@ -24,16 +24,16 @@ !define TOR_NAME "Tor" !define TOR_EXEC "tor.exe" -!define TOR_APPVERSION "0.2.0.31" +!define TOR_APPVERSION "0.2.2.8-alpha" !define TOR_DESC "${TOR_NAME} ${TOR_APPVERSION}" -!define PRIVOXY_NAME "Privoxy" -!define PRIVOXY_EXEC "privoxy.exe" -!define PRIVOXY_APPVERSION "3.0.6" -!define PRIVOXY_DESC "${PRIVOXY_NAME} ${PRIVOXY_APPVERSION}" +!define POLIPO_NAME "Polipo" +!define POLIPO_EXEC "polipo.exe" +!define POLIPO_APPVERSION "1.0.4.1" +!define POLIPO_DESC "${POLIPO_NAME} ${POLIPO_APPVERSION}" !define TORBUTTON_NAME "Torbutton" -!define TORBUTTON_APPVERSION "1.2.0" +!define TORBUTTON_APPVERSION "1.2.4-fx" !define TORBUTTON_DESC "${TORBUTTON_NAME} ${TORBUTTON_APPVERSION}" !define BUNDLE_NAME "Vidalia Bundle" @@ -161,8 +161,10 @@ File "@QT_BINARY_DIR@\QtGui4.dll" File "@QT_BINARY_DIR@\QtNetwork4.dll" File "@QT_BINARY_DIR@\QtXml4.dll" + File "@QT_BINARY_DIR@\libgcc_s_dw2-1.dll" File "@MINGW_BINARY_DIR@\mingwm10.dll" File "@OPENSSL_BINARY_DIR@\ssleay32.dll" + File "@OPENSSL_BINARY_DIR@\libeay32.dll" File "@Vidalia_SOURCE_DIR@\README" File "@Vidalia_SOURCE_DIR@\CHANGELOG" File "@Vidalia_SOURCE_DIR@\LICENSE" @@ -177,7 +179,7 @@ CreateDirectory "$APPDATA\Vidalia" SetOutPath "$APPDATA\Vidalia" File "@Vidalia_SOURCE_DIR@\pkg\geoip-cache" - + ;If there's already a torrc config file, ask if they want to ;overwrite it with the new one. StrCpy $configfile "torrc" @@ -248,7 +250,10 @@ File "@TOR_PACKAGE_DIR@\tor.exe" File "@TOR_PACKAGE_DIR@\tor-resolve.exe" WriteIniStr "$INSTDIR\Tor\Tor Website.url" "InternetShortcut" "URL" "https://www.torproject.org" - + ; Include tor's geoip file, too + SetOutPath "$APPDATA\Tor" + File "@TOR_PACKAGE_DIR@\geoip" + ; If the user is also installing Vidalia, then don't confuse them by ; an extra torrc in %APPDATA%\Tor SectionGetFlags ${Vidalia} $0 @@ -256,7 +261,6 @@ IntCmp $0 ${SF_SELECTED} skiptorrc StrCpy $configfile "torrc" - SetOutPath "$APPDATA\Tor" ; If there's already a torrc config file, ask if they want to ; overwrite it with the new one. @@ -327,71 +331,65 @@ ;-------------------------------- -; Privoxy -var bInstallPrivoxy -SectionGroup "${PRIVOXY_DESC}" PrivoxyGroup +; Polipo +var bInstallPolipo +SectionGroup "${POLIPO_DESC}" PolipoGroup ;-------------------------------- - ; Privoxy application binaries - Section "${PRIVOXY_NAME}" Privoxy + ; Polipo application binaries + Section "${POLIPO_NAME}" Polipo SectionIn 1 2 ; add files / whatever that need to be installed here. - SetOutPath "$INSTDIR\Privoxy" - File /r /x @PRIVOXY_PACKAGE_DIR@\config.txt @PRIVOXY_PACKAGE_DIR@\*.* - File /nonfatal /oname=config.original @PRIVOXY_PACKAGE_DIR@\config.txt - File /oname=config.txt @Vidalia_SOURCE_DIR@\pkg\win32\privoxy.config - - WriteRegStr HKEY_CLASSES_ROOT "PrivoxyActionFile\shell\open\command" "" 'Notepad.exe "%1"' - WriteRegStr HKEY_CLASSES_ROOT ".action" "" "PrivoxyActionFile" - WriteRegStr HKEY_CLASSES_ROOT "PrivoxyFilterFile\shell\open\command" "" 'Notepad.exe "%1"' - WriteRegStr HKEY_CLASSES_ROOT ".filter" "" "PrivoxyFilterFile" - + SetOutPath "$INSTDIR\Polipo" + SetShellVarContext current + + File /r /x "@POLIPO_PACKAGE_DIR@\polipo.conf" "@POLIPO_PACKAGE_DIR@\*.*" + File "@CMAKE_CURRENT_SOURCE_DIR@\polipo.conf" + + ; Let Vidalia know that Polipo was installed + IntCmp $bInstallVidalia 1 AddVidaliaSettings SkipVidaliaSettings SkipVidaliaSettings + AddVidaliaSettings: + Push $INSTDIR + Push "\" + Push "\\" + Call StrRep + Pop $R0 + WriteINIStr "$APPDATA\Vidalia\vidalia.conf" General ProxyExecutable "$R0\\Polipo\\${POLIPO_EXEC}" + WriteINIStr "$APPDATA\Vidalia\vidalia.conf" General ProxyExecutableArguments '-c \"$R0\\Polipo\\polipo.conf\"' + WriteINIStr "$APPDATA\Vidalia\vidalia.conf" General RunProxyAtStart "true" + SkipVidaliaSettings: + ; Write the installation path into the registry - WriteRegStr HKCU SOFTWARE\Privoxy "Install_Dir" "$INSTDIR" + WriteRegStr HKCU SOFTWARE\Polipo "Install_Dir" "$INSTDIR" ; Write the uninstall keys for Windows - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Privoxy" "DisplayName" "${PRIVOXY_DESC}" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Privoxy" "UninstallString" '"$INSTDIR\${UNINSTALLER}"' - WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Privoxy" "NoModify" 1 - WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Privoxy" "NoRepair" 1 + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Polipo" "DisplayName" "${POLIPO_DESC}" + WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Polipo" "UninstallString" '"$INSTDIR\${UNINSTALLER}"' + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Polipo" "NoModify" 1 + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Polipo" "NoRepair" 1 - IntOp $bInstallPrivoxy 0 + 1 + IntOp $bInstallPolipo 0 + 1 SectionEnd ;-------------------------------- - ; Privoxy Start menu shortcuts - Section "$(PrivoxyShortcuts)" PrivoxyShortcuts + ; Polipo Start menu shortcuts + Section "$(PolipoShortcuts)" PolipoShortcuts SectionIn 1 SetShellVarContext all ; (Add to "All Users" Start Menu if possible) - RMDir /r "${SHORTCUTS}\Privoxy" - CreateDirectory "${SHORTCUTS}\Privoxy" - CreateShortCut "${SHORTCUTS}\Privoxy\Privoxy.lnk" "$INSTDIR\Privoxy\privoxy.exe" - CreateShortCut "${SHORTCUTS}\Privoxy\Web-based Feedback.lnk" "$INSTDIR\Privoxy\doc\user-manual\contact.html" - WriteINIStr "${SHORTCUTS}\Privoxy\Web-based Configuration.url" "InternetShortcut" "URL" "http://config.privoxy.org/" + RMDir /r "${SHORTCUTS}\Polipo" + CreateDirectory "${SHORTCUTS}\Polipo" + CreateShortCut "${SHORTCUTS}\Polipo\Polipo.lnk" "$INSTDIR\Polipo\polipo.exe" + CreateShortCut "${SHORTCUTS}\Polipo\Web-based Feedback.lnk" "$INSTDIR\Polipo\doc\user-manual\contact.html" - CreateDirectory "${SHORTCUTS}\Privoxy\Edit Config" - CreateShortCut "${SHORTCUTS}\Privoxy\Edit Config\Main Configuration.lnk" "Notepad.exe" '"$INSTDIR\Privoxy\config.txt"' - CreateShortCut "${SHORTCUTS}\Privoxy\Edit Config\Default Actions.lnk" "Notepad.exe" '"$INSTDIR\Privoxy\default.action"' - CreateShortCut "${SHORTCUTS}\Privoxy\Edit Config\User Actions.lnk" "Notepad.exe" '"$INSTDIR\Privoxy\user.action"' - CreateShortCut "${SHORTCUTS}\Privoxy\Edit Config\Filters.lnk" "Notepad.exe" '"$INSTDIR\Privoxy\default.filter"' - CreateShortCut "${SHORTCUTS}\Privoxy\Edit Config\Trust list.lnk" "Notepad.exe" '"$INSTDIR\Privoxy\trust.txt"' + CreateDirectory "${SHORTCUTS}\Polipo\Edit Config" + CreateShortCut "${SHORTCUTS}\Polipo\Edit Config\Main Configuration.lnk" "Notepad.exe" '"$INSTDIR\Polipo\polipo.conf"' - CreateDirectory "${SHORTCUTS}\Privoxy\Documentation" - CreateShortCut "${SHORTCUTS}\Privoxy\Documentation\User Manual.lnk" "$INSTDIR\Privoxy\doc\user-manual\index.html" - CreateShortCut "${SHORTCUTS}\Privoxy\Documentation\Frequently Asked Questions.lnk" "$INSTDIR\Privoxy\doc\faq\index.html" - CreateShortCut "${SHORTCUTS}\Privoxy\Documentation\Credits.lnk" "Notepad.exe" '"$INSTDIR\Privoxy\AUTHORS.txt"' - CreateShortCut "${SHORTCUTS}\Privoxy\Documentation\License.lnk" "Notepad.exe" '"$INSTDIR\Privoxy\LICENSE.txt"' - CreateShortCut "${SHORTCUTS}\Privoxy\Documentation\ReadMe file.lnk" "Notepad.exe" '"$INSTDIR\Privoxy\README.txt"' - WriteINIStr "$SMPROGRAMS\Privoxy\Documentation\Web Site.url" "InternetShortcut" "URL" "http://privoxy.org/" + CreateDirectory "${SHORTCUTS}\Polipo\Documentation" + CreateShortCut "${SHORTCUTS}\Polipo\Documentation\User Manual.lnk" "$INSTDIR\Polipo\doc\user-manual\index.html" + WriteINIStr "$SMPROGRAMS\Polipo\Documentation\Web Site.url" "InternetShortcut" "URL" "http://www.pps.jussieu.fr/~jch/software/polipo/" CreateShortCut "${SHORTCUTS}\Uninstall.lnk" "$INSTDIR\Uninstall.exe" "" "$INSTDIR\${UNINSTALLER}" 0 SectionEnd - ;-------------------------------- - ; Run Privoxy at startup - Section "$(PrivoxyStartup)" PrivoxyStartup - SectionIn 1 - CreateShortCut "$SMSTARTUP\Privoxy.lnk" "$INSTDIR\Privoxy\privoxy.exe" "" "" 0 SW_SHOWMINIMIZED - SectionEnd SectionGroupEnd ;-------------------------------- @@ -478,18 +476,18 @@ IntCmp $bInstallVidalia 1 run_vidalia check_tor check_tor run_vidalia: Exec '"$INSTDIR\Vidalia\${VIDALIA_EXEC}"' - goto check_privoxy + goto done check_tor: - IntCmp $bInstallTor 1 run_tor check_privoxy check_privoxy + IntCmp $bInstallTor 1 run_tor check_polipo check_polipo run_tor: Exec '"$INSTDIR\Tor\${TOR_EXEC}"' - check_privoxy: - IntCmp $bInstallPrivoxy 1 run_privoxy done done - run_privoxy: - SetOutPath "$INSTDIR\Privoxy" - ExecShell "" '"$INSTDIR\Privoxy\${PRIVOXY_EXEC}"' "" SW_SHOWMINIMIZED + check_polipo: + IntCmp $bInstallPolipo 1 run_polipo done done + run_polipo: + SetOutPath "$INSTDIR\Polipo" + Exec '"$INSTDIR\Polipo\${POLIPO_EXEC}" -c "$INSTDIR\Polipo\polipo.conf"' done: FunctionEnd @@ -528,16 +526,11 @@ SectionEnd SectionGroupEnd -Section "un.Privoxy ${PRIVOXY_APPVERSION}" UninstallPrivoxy +Section "un.Polipo ${POLIPO_APPVERSION}" UninstallPolipo SetShellVarContext all - RMDir /r "$INSTDIR\Privoxy" - RMDir /r "${SHORTCUTS}\Privoxy" - Delete "$SMSTARTUP\Privoxy.lnk" - DeleteRegKey HKEY_CLASSES_ROOT ".action" - DeleteRegKey HKEY_CLASSES_ROOT "PrivoxyActionFile" - DeleteRegKey HKEY_CLASSES_ROOT ".filter" - DeleteRegKey HKEY_CLASSES_ROOT "PrivoxyFilterFile" - DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Privoxy" + RMDir /r "$INSTDIR\Polipo" + RMDir /r "${SHORTCUTS}\Polipo" + DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Polipo" SectionEnd ; XXX: We still need to find a way to actually remove Torbutton from Firefox @@ -568,16 +561,16 @@ SectionSetFlags ${UninstallVidalia} $0 CheckVidaliaAppData: - IfFileExists "$APPDATA\Vidalia\*.*" CheckPrivoxy + IfFileExists "$APPDATA\Vidalia\*.*" CheckPolipo SectionGetFlags ${UninstallVidaliaAppData} $0 IntOp $0 $0 & ${SECTION_OFF} SectionSetFlags ${UninstallVidaliaAppData} $0 - CheckPrivoxy: - IfFileExists "$INSTDIR\Privoxy\*.*" Done - SectionGetFlags ${UninstallPrivoxy} $0 + CheckPolipo: + IfFileExists "$INSTDIR\Polipo\*.*" Done + SectionGetFlags ${UninstallPolipo} $0 IntOp $0 $0 & ${SECTION_OFF} - SectionSetFlags ${UninstallPrivoxy} $0 + SectionSetFlags ${UninstallPolipo} $0 Done: FunctionEnd @@ -586,7 +579,7 @@ SetShellVarContext all IfFileExists "$INSTDIR\Tor\*.*" DontRemoveTheUninstaller IfFileExists "$INSTDIR\Vidalia\*.*" DontRemoveTheUninstaller - IfFileExists "$INSTDIR\Privoxy\*.*" DontRemoveTheUninstaller + IfFileExists "$INSTDIR\Polipo\*.*" DontRemoveTheUninstaller RMDir /r "$INSTDIR" RMDir /r "${SHORTCUTS}" DontRemoveTheUninstaller: @@ -603,10 +596,10 @@ !insertmacro MUI_DESCRIPTION_TEXT ${VidaliaStartup} "$(VidaliaStartupDesc)" !insertmacro MUI_DESCRIPTION_TEXT ${VidaliaShortcuts} "$(VidaliaShortcutsDesc)" - !insertmacro MUI_DESCRIPTION_TEXT ${Privoxy} "$(PrivoxyAppDesc)" - !insertmacro MUI_DESCRIPTION_TEXT ${PrivoxyGroup} "$(PrivoxyGroupDesc)" - !insertmacro MUI_DESCRIPTION_TEXT ${PrivoxyStartup} "$(PrivoxyStartupDesc)" - !insertmacro MUI_DESCRIPTION_TEXT ${PrivoxyShortcuts} "$(PrivoxyShortcutsDesc)" + !insertmacro MUI_DESCRIPTION_TEXT ${Polipo} "$(PolipoAppDesc)" + !insertmacro MUI_DESCRIPTION_TEXT ${PolipoGroup} "$(PolipoGroupDesc)" + !insertmacro MUI_DESCRIPTION_TEXT ${PolipoStartup} "$(PolipoStartupDesc)" + !insertmacro MUI_DESCRIPTION_TEXT ${PolipoShortcuts} "$(PolipoShortcutsDesc)" !insertmacro MUI_DESCRIPTION_TEXT ${Torbutton} "$(TorbuttonAppDesc)" !insertmacro MUI_DESCRIPTION_TEXT ${TorbuttonGroup} "$(TorbuttonGroupDesc)" @@ -618,7 +611,7 @@ !insertmacro MUI_DESCRIPTION_TEXT ${UninstallTorAppData} "$(AppDataUninstDesc)" !insertmacro MUI_DESCRIPTION_TEXT ${UninstallVidalia} "$(VidaliaUninstDesc)" !insertmacro MUI_DESCRIPTION_TEXT ${UninstallVidaliaAppData} "$(AppDataUninstDesc)" - !insertmacro MUI_DESCRIPTION_TEXT ${UninstallPrivoxy} "$(PrivoxyUninstDesc)" + !insertmacro MUI_DESCRIPTION_TEXT ${UninstallPolipo} "$(PolipoUninstDesc)" !insertmacro MUI_UNFUNCTION_DESCRIPTION_END diff -Nru vidalia-0.1.13/pkg/win32/vidalia.nsi.in vidalia-0.2.8/pkg/win32/vidalia.nsi.in --- vidalia-0.1.13/pkg/win32/vidalia.nsi.in 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/pkg/win32/vidalia.nsi.in 1970-01-01 01:00:00.000000000 +0100 @@ -1,234 +0,0 @@ -;; -;; $Id: vidalia.nsi.in 3671 2009-04-04 06:20:28Z edmanm $ -;; -;; 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.vidalia-project.net/. No part of Vidalia, including this file, -;; may be copied, modified, propagated, or distributed except according to -;; the terms described in the LICENSE file. -;; - - -!include "MUI.nsh" - -SetCompressor /SOLID lzma -!packhdr header.dat "upx --best header.dat" - -;--------------------------------- -; Global definitions -!define VIDALIA_NAME "Vidalia" -!define VIDALIA_EXEC "vidalia.exe" -!define VIDALIA_APPVERSION "@VERSION@" -!define VIDALIA_PRODVERSION "@VER_MAJOR@.@VER_MINOR@.@VER_PATCH@.0" -!define VIDALIA_AUTHORS "Matt Edman, Justin Hipple" -!define VIDALIA_INSTALLFILE "vidalia-${VIDALIA_APPVERSION}.exe" -!define VIDALIA_DESC "${VIDALIA_NAME} ${VIDALIA_APPVERSION}" - -;-------------------------------- -; Installer file details -VIAddVersionKey "ProductName" "${VIDALIA_NAME}" -VIAddVersionKey "Comments" "${VIDALIA_DESC}" -VIAddVersionKey "CompanyName" "${VIDALIA_AUTHORS}" -VIAddVersionKey "LegalTrademarks" "${VIDALIA_AUTHORS}" -VIAddVersionKey "LegalCopyright" "${VIDALIA_AUTHORS}" -VIAddVersionKey "FileVersion" "${VIDALIA_APPVERSION}" -VIAddVersionKey "FileDescription" "${VIDALIA_DESC}" -VIProductVersion "${VIDALIA_PRODVERSION}" - -;-------------------------------- -; Basic installer information -Name "${VIDALIA_NAME}" -Caption "$(VidaliaSetupCaption)" -BrandingText "${VIDALIA_DESC}" -OutFile "${VIDALIA_INSTALLFILE}" -InstallDir "$PROGRAMFILES\${VIDALIA_NAME}" -InstallDirRegKey HKCU "Software" "${VIDALIA_NAME}" -SetOverWrite ifnewer -AutoCloseWindow false -ShowInstDetails show -CRCCheck on -XPStyle on - -;-------------------------------- -; Install types -!ifndef NOINSTTYPES ; only if not defined - InstType "Full" - InstType "Base" - ;InstType /COMPONENTSONLYONCUSTOM -!endif - -;-------------------------------- -; MUI Options -!define MUI_WELCOMEPAGE_TITLE "$(VidaliaWelcomeTitle)" -!define MUI_WELCOMEPAGE_TEXT "$(VidaliaWelcomeText)" -!define MUI_ABORTWARNING -!define MUI_FINISHPAGE_NOAUTOCLOSE -!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\win-install.ico" -!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\win-uninstall.ico" -!define MUI_HEADERIMAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Header\win.bmp" -!define MUI_HEADERIMAGE -!define MUI_FINISHPAGE_RUN "$INSTDIR\${VIDALIA_EXEC}" -!define MUI_FINISHPAGE_RUN_TEXT "$(VidaliaRunNow)" -!define MUI_FINISHPAGE_LINK "$(VidaliaLinkText)" -!define MUI_FINISHPAGE_LINK_LOCATION "http://www.vidalia-project.net" - -;-------------------------------- -; Pages -!insertmacro MUI_PAGE_WELCOME -!insertmacro MUI_PAGE_COMPONENTS -!insertmacro MUI_PAGE_DIRECTORY -!insertmacro MUI_PAGE_INSTFILES -!insertmacro MUI_PAGE_FINISH -!insertmacro MUI_UNPAGE_WELCOME -!insertmacro MUI_UNPAGE_COMPONENTS -!insertmacro MUI_UNPAGE_CONFIRM -!insertmacro MUI_UNPAGE_INSTFILES -!insertmacro MUI_UNPAGE_FINISH - -;-------------------------------- -; Available languages -!insertmacro MUI_LANGUAGE "Czech" -;!insertmacro MUI_LANGUAGE "Dutch" -!insertmacro MUI_LANGUAGE "English" -;!insertmacro MUI_LANGUAGE "Farsi" -!insertmacro MUI_LANGUAGE "Finnish" -!insertmacro MUI_LANGUAGE "French" -!insertmacro MUI_LANGUAGE "German" -!insertmacro MUI_LANGUAGE "Hebrew" -!insertmacro MUI_LANGUAGE "Italian" -!insertmacro MUI_LANGUAGE "Polish" -!insertmacro MUI_LANGUAGE "Portuguese" -!insertmacro MUI_LANGUAGE "Romanian" -!insertmacro MUI_LANGUAGE "Russian" -!insertmacro MUI_LANGUAGE "Spanish" -#!insertmacro MUI_LANGUAGE "SimpChinese" -!insertmacro MUI_LANGUAGE "Swedish" -#!insertmacro MUI_LANGUAGE "TradChinese" -!include "vidalia_cs.nsh" -!include "vidalia_de.nsh" -!include "vidalia_en.nsh" -!include "vidalia_es.nsh" -;!include "vidalia_fa.nsh" -!include "vidalia_fi.nsh" -!include "vidalia_fr.nsh" -!include "vidalia_he.nsh" -!include "vidalia_it.nsh" -;!include "vidalia_nl.nsh" -!include "vidalia_pl.nsh" -!include "vidalia_pt.nsh" -!include "vidalia_ro.nsh" -!include "vidalia_ru.nsh" -!include "vidalia_sv.nsh" -#!include "vidalia_zh_CN.nsh" -#!include "vidalia_zh_TW.nsh" - -;-------------------------------- -; Functions -Function .onInit - !insertmacro MUI_LANGDLL_DISPLAY -FunctionEnd - -;-------------------------------- -; Required Components -Section "${VIDALIA_DESC}" Vidalia - SectionIn RO - - ; Set output path to the installation directory. - SetOutPath $INSTDIR - File "@Vidalia_BINARY_DIR@\src\vidalia\${VIDALIA_EXEC}" - File "@MINGW_BINARY_DIR@\mingwm10.dll" - File "@OPENSSL_BINARY_DIR@\ssleay32.dll" - File "@QT_BINARY_DIR@\QtCore4.dll" - File "@QT_BINARY_DIR@\QtGui4.dll" - File "@QT_BINARY_DIR@\QtNetwork4.dll" - File "@QT_BINARY_DIR@\QtXml4.dll" - File "@Vidalia_SOURCE_DIR@\CREDITS" - File "@Vidalia_SOURCE_DIR@\CHANGELOG" - File "@Vidalia_SOURCE_DIR@\LICENSE" - File "@Vidalia_SOURCE_DIR@\LICENSE-GPLV2" - File "@Vidalia_SOURCE_DIR@\LICENSE-GPLV3" - File "@Vidalia_SOURCE_DIR@\LICENSE-LGPLV3" - File "@Vidalia_SOURCE_DIR@\LICENSE-OPENSSL" - File "@Vidalia_SOURCE_DIR@\README" - - ; Include a prebuilt GeoIP cache - SetOutPath "$APPDATA\Vidalia" - File "@Vidalia_SOURCE_DIR@\pkg\geoip-cache" - - ; Save the chosen language code - WriteINIStr "$APPDATA\Vidalia\vidalia.conf" General LanguageCode "$(LanguageCode)" - - ; Write the uninstall keys for Windows - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${VIDALIA_NAME}" "DisplayName" "${VIDALIA_DESC}" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${VIDALIA_NAME}" "UninstallString" '"$INSTDIR\uninstall.exe"' - WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${VIDALIA_NAME}" "NoModify" 1 - WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${VIDALIA_NAME}" "NoRepair" 1 - WriteUninstaller "uninstall.exe" -SectionEnd - -;-------------------------------- -; Start Menu Shortcuts -; Optional section (can be disabled by the user) -Section "$(VidaliaShortcuts)" Shortcuts - SectionIn 1 - SetShellVarContext all - CreateDirectory "$SMPROGRAMS\${VIDALIA_NAME}" - CreateShortCut "$SMPROGRAMS\${VIDALIA_NAME}\${VIDALIA_NAME}.lnk" "$INSTDIR\${VIDALIA_EXEC}" "" "$INSTDIR\${VIDALIA_EXEC}" 0 - CreateShortCut "$SMPROGRAMS\${VIDALIA_NAME}\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0 -SectionEnd - -;-------------------------------- -; Run At Startup -Section "$(VidaliaStartup)" RunAtStartup - SectionIn 1 - WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Run" "${VIDALIA_NAME}" '"$INSTDIR\${VIDALIA_EXEC}"' -SectionEnd - -;-------------------------------- -; Uninstaller -Section "-Uninstall" Uninstall -SectionEnd - -Section "un.${VIDALIA_NAME} ${VIDALIA_APPVERSION}" UninstallVidalia - SetShellVarContext all - - ; Remove registry keys - DeleteRegValue HKCU "Software\Microsoft\Windows\CurrentVersion\Run\" "${VIDALIA_NAME}" - DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${VIDALIA_NAME}" - DeleteRegKey HKCU "Software\${VIDALIA_NAME}" - - ; Remove files and uninstaller - Delete $INSTDIR\uninstall.exe - - ; Remove shortcuts, if any - Delete "$SMPROGRAMS\${VIDALIA_NAME}\*.*" - - ; Remove directories used - RMDir "$SMPROGRAMS\${VIDALIA_NAME}" - RMDir /r "$INSTDIR" -SectionEnd - -Section "un.$(AppData)" UninstallVidaliaAppData - SetShellVarContext current - RMDir /r "$APPDATA\Vidalia" -SectionEnd - -Function un.onInit - !insertmacro MUI_LANGDLL_DISPLAY -FunctionEnd - -;-------------------------------- -; Descriptions -!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN - !insertmacro MUI_DESCRIPTION_TEXT ${Vidalia} "$(VidaliaAppDesc)" - !insertmacro MUI_DESCRIPTION_TEXT ${Shortcuts} "$(VidaliaShortcutsDesc)" - !insertmacro MUI_DESCRIPTION_TEXT ${RunAtStartup} "$(VidaliaStartupDesc)" -!insertmacro MUI_FUNCTION_DESCRIPTION_END - -!insertmacro MUI_UNFUNCTION_DESCRIPTION_BEGIN - !insertmacro MUI_DESCRIPTION_TEXT ${UninstallVidalia} $(VidaliaUninstDesc) - !insertmacro MUI_DESCRIPTION_TEXT ${UninstallVidaliaAppData} $(AppDataUninstDesc) -!insertmacro MUI_UNFUNCTION_DESCRIPTION_END - diff -Nru vidalia-0.1.13/pkg/win32/vidalia.wxs.in vidalia-0.2.8/pkg/win32/vidalia.wxs.in --- vidalia-0.1.13/pkg/win32/vidalia.wxs.in 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/pkg/win32/vidalia.wxs.in 2010-02-17 19:31:27.000000000 +0000 @@ -0,0 +1,366 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -Nru vidalia-0.1.13/pkg/win32/WixUI_Custom.wxs vidalia-0.2.8/pkg/win32/WixUI_Custom.wxs --- vidalia-0.1.13/pkg/win32/WixUI_Custom.wxs 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/pkg/win32/WixUI_Custom.wxs 2008-12-09 23:49:58.000000000 +0000 @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + 1 + + 1 + + 1 + 1 + 1 + 1 + + WixUI_InstallMode = "Change" + WixUI_InstallMode = "InstallCustom" + 1 + + WixUI_InstallMode = "InstallCustom" + WixUI_InstallMode = "InstallTypical" OR WixUI_InstallMode = "InstallComplete" + WixUI_InstallMode = "Change" + WixUI_InstallMode = "Repair" OR WixUI_InstallMode = "Remove" + + 1 + + 1 + 1 + 1 + 1 + + + + + diff -Nru vidalia-0.1.13/pkg/win32/zh_CN/vidalia_zh_CN.po vidalia-0.2.8/pkg/win32/zh_CN/vidalia_zh_CN.po --- vidalia-0.1.13/pkg/win32/zh_CN/vidalia_zh_CN.po 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/pkg/win32/zh_CN/vidalia_zh_CN.po 2009-12-01 02:41:49.000000000 +0000 @@ -3,8 +3,8 @@ "Project-Id-Version: Vidalia\n" "Report-Msgid-Bugs-To: translations@vidalia-project.net\n" "POT-Creation-Date: 2008-07-12 05:29+0000\n" -"PO-Revision-Date: 2008-07-22 17:25+0000\n" -"Last-Translator: Matt \n" +"PO-Revision-Date: 2009-11-28 12:14-0700\n" +"Last-Translator: yfdyh000 \n" "Language-Team: translations@vidalia-project.net\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -18,28 +18,34 @@ msgctxt "BundleWelcomeText" msgid "" -"This wizard will guide you through the installation of Tor, Vidalia, " -"Privoxy, and Torbutton.\n" +"This wizard will guide you through the installation of Tor, Vidalia, Polipo, " +"and Torbutton.\n" "\n" "Tor is a system for using the Internet anonymously, helping you anonymize " "Web browsing and publishing, instant messaging, IRC, and more. Vidalia is a " "GUI that helps you control, monitor, and configure Tor.\n" "\n" -"Privoxy is a filtering web proxy that protects your privacy and helps remove " -"ads, banners, and popups.\n" +"Polipo is a caching web proxy that helps increase performance of browsing " +"the web through Tor.\n" "\n" "Torbutton is a Firefox extension that allows you to quickly enable or " "disable anonymous web browsing.\n" "\n" -"If you have previously installed Tor, Vidalia, Privoxy, or Firefox, please " +"If you have previously installed Tor, Vidalia, Polipo, or Firefox, please " "make sure they are not running before continuing this installation.\n" "\n" "$_CLICK" msgstr "" -"该向导将会引导您安装 Tor,Vidalia,Privoxy 和 Torbutton.\n" +"该向导将会引导您完成 Tor、Vidalia、Polipo 和 Torbutton 的安装。\n" "\n" -"如果您曾经安装过 Tor,Vidalia,Privoxy 或 Firefox,请确保在运行此安装向导前这些" -"程序未在运行.\n" +"Tor 是可以匿名访问 Internt 的系统,能够帮助您隐匿网页的浏览与发布、即时聊天、IRC 及其他活动。Vidalia " +"是一个用户图形界面,能帮助您控制、监视和配置Tor。\n" +"\n" +"Polipo 是一种缓冲型网页代理可以帮助增强 Tor 的网页浏览性能。\n" +"\n" +"Torbutton 是一个 Firefox 浏览器扩展,可以快速启用或禁用匿名网页浏览。\n" +"\n" +"如果您曾经安装过 Tor、Vidalia、Polipo 或 Firefox,请确保在运行此安装向导前这些程序未在运行。\n" "\n" "$_CLICK" @@ -59,24 +65,22 @@ "\n" "If you installed Torbutton, you will need to restart Firefox." msgstr "" -"安装完成.\n" -"请访问 https://www.torproject.org/docs/tor-doc-windows 来获取关于 Tor 的配置" -"信息.\n" +"安装完成。\n" +"请访问 https://www.torproject.org/docs/tor-doc-windows 了解如何配置应用程序使用 Tor。\n" "\n" -"如果选择了安装 Torbutton,您需要重新启动火狐(Firefox)浏览器." +"如果您选择了安装 Torbutton,您需要重新启动火狐 (Firefox) 浏览器。" msgctxt "BundleRunNow" msgid "Run installed components now" msgstr "现在运行已安装组件" -#, fuzzy msgctxt "VidaliaGroupDesc" msgid "Vidalia is a GUI that helps you control, monitor, and configure Tor." -msgstr "安装 ${VIDALIA_DESC}." +msgstr "Vidalia 是能帮助您控制、监视及配置 Tor 的图形化界面。" msgctxt "VidaliaUninstDesc" msgid "Remove ${VIDALIA_DESC}." -msgstr "Remove ${VIDALIA_DESC}." +msgstr "移除 ${VIDALIA_DESC}。" msgctxt "VidaliaSetupCaption" msgid "${VIDALIA_NAME} setup" @@ -89,7 +93,7 @@ "\n" "$_CLICK" msgstr "" -"该向导将会引导您安装 ${VIDALIA_DESC}.\n" +"该向导将会引导您安装 Vidalia - 一种能帮助您控制、监视及配置 Tor 的图形化界面。\n" "\n" "$_CLICK" @@ -101,10 +105,9 @@ msgid "${VIDALIA_NAME} homepage" msgstr "${VIDALIA_NAME} 主页快捷方式" -#, fuzzy msgctxt "VidaliaAppDesc" msgid "Vidalia is a GUI that helps you control, monitor, and configure Tor." -msgstr "安装 ${VIDALIA_DESC}." +msgstr "Vidalia 是能帮助您控制、监视及配置 Tor 的图形化界面。" msgctxt "VidaliaStartup" msgid "Run At Startup" @@ -112,7 +115,7 @@ msgctxt "VidaliaStartupDesc" msgid "Automatically run ${VIDALIA_NAME} at startup." -msgstr "自动在系统启动时运行 ${VIDALIA_NAME}." +msgstr "自动在系统启动时运行 ${VIDALIA_NAME}。" msgctxt "VidaliaShortcuts" msgid "Add to Start Menu" @@ -120,26 +123,25 @@ msgctxt "VidaliaShortcutsDesc" msgid "Add ${VIDALIA_NAME} to your Start menu." -msgstr "添加 ${VIDALIA_NAME} 至开始菜单程序组." +msgstr "添加 ${VIDALIA_NAME} 至开始菜单程序组。" msgctxt "VidaliaRunNow" msgid "Run ${VIDALIA_NAME}" msgstr "现在运行 ${VIDALIA_NAME}" -#, fuzzy msgctxt "TorGroupDesc" msgid "" "Tor is a system for using the Internet anonymously, helping you anonymize " "Web browsing and publishing, instant messaging, IRC, and more." -msgstr "安装 ${TOR_DESC}." +msgstr "Tor 是一种可以匿名访问 Internt 的系统,它可以帮助您隐匿网页的浏览与发布、即时聊天、IRC 及其他更多活动。" msgctxt "TorUninstDesc" msgid "Remove ${TOR_DESC}." -msgstr "Remove ${TOR_DESC}." +msgstr "移除 ${TOR_DESC}。" msgctxt "TorAppDesc" msgid "Install ${TOR_DESC}." -msgstr "安装 ${TOR_DESC}." +msgstr "安装 ${TOR_DESC}。" msgctxt "TorAskOverwriteTorrc" msgid "" @@ -147,9 +149,9 @@ "$\n" "Do you want to overwrite it with the default sample configuration file?" msgstr "" -"安装程序检测到已存在的 Tor 配置文件.$\n" +"安装程序检测到已存在的 Tor 配置文件。$\n" "$\n" -"是否要使用默认的配置文件覆盖它?" +"是否要使用默认的配置文件覆盖它?" msgctxt "TorDocumentation" msgid "Documentation" @@ -157,7 +159,7 @@ msgctxt "TorDocumentationDesc" msgid "Install ${TOR_NAME} documentation." -msgstr "安装 ${TOR_NAME} 文档." +msgstr "安装 ${TOR_NAME} 文档。" msgctxt "TorShortcuts" msgid "Add to Start Menu" @@ -165,65 +167,63 @@ msgctxt "TorShortcutsDesc" msgid "Add ${TOR_NAME} to your Start menu." -msgstr "添加 ${TOR_NAME} 至开始菜单程序组." +msgstr "添加 ${TOR_NAME} 至开始菜单程序组。" -#, fuzzy -msgctxt "PrivoxyGroupDesc" +msgctxt "PolipoGroupDesc" msgid "" -"Privoxy is a filtering web proxy that protects your privacy and helps remove " -"ads, banners, and popups." -msgstr "安装 ${PRIVOXY_DESC}." - -msgctxt "PrivoxyUninstDesc" -msgid "Remove ${PRIVOXY_DESC}." -msgstr "Remove ${PRIVOXY_DESC}." - -msgctxt "PrivoxyAppDesc" -msgid "Install ${PRIVOXY_DESC}." -msgstr "安装 ${PRIVOXY_DESC}." +"Polipo is a caching web proxy that increases performance of web browsing " +"through Tor." +msgstr "Polipo 是缓冲型网页代理能够增强使用 Tor 时的网页浏览性能。" + +msgctxt "PolipoUninstDesc" +msgid "Remove ${POLIPO_DESC}." +msgstr "移除 ${POLIPO_DESC}。" + +msgctxt "PolipoAppDesc" +msgid "Install ${POLIPO_DESC}." +msgstr "安装 ${POLIPO_DESC}。" -msgctxt "PrivoxyShortcuts" +msgctxt "PolipoShortcuts" msgid "Add to Start Menu" -msgstr "添加至开始菜单程序组" +msgstr "添加至开始菜单" -msgctxt "PrivoxyShortcutsDesc" -msgid "Add ${PRIVOXY_NAME} to your Start menu." -msgstr "添加 ${PRIVOXY_NAME} 至开始菜单程序组." +msgctxt "PolipoShortcutsDesc" +msgid "Add ${POLIPO_NAME} to your Start menu." +msgstr "添加 ${POLIPO_NAME} 至开始菜单。" -msgctxt "PrivoxyStartup" +msgctxt "PolipoStartup" msgid "Run At Startup" msgstr "在系统启动时运行" -msgctxt "PrivoxyStartupDesc" -msgid "Automatically run ${PRIVOXY_NAME} at startup." -msgstr "自动在系统启动时运行 ${PRIVOXY_NAME}." +msgctxt "PolipoStartupDesc" +msgid "Automatically run ${POLIPO_NAME} at startup." +msgstr "自动在系统启动时运行 ${POLIPO_NAME}。" -#, fuzzy msgctxt "TorbuttonGroupDesc" msgid "" "Torbutton is a Firefox extension that allows you to quickly enable or " "disable anonymous web browsing." -msgstr "安装 ${TORBUTTON_DESC}." +msgstr "Torbutton 是一个 Firefox 浏览器扩展,可以快速开启或关闭匿名网页浏览。" msgctxt "TorbuttonUninstDesc" msgid "Remove ${TORBUTTON_DESC}." -msgstr "Remove ${TORBUTTON_DESC}." +msgstr "移除 ${TORBUTTON_DESC}。" msgctxt "TorbuttonAppDesc" msgid "Install ${TORBUTTON_DESC}." -msgstr "安装 ${TORBUTTON_DESC}." +msgstr "安装 ${TORBUTTON_DESC}。" msgctxt "TorbuttonAddToFirefox" msgid "Add to Firefox" -msgstr "添加至火狐(Firefox)浏览器" +msgstr "添加至火狐 (Firefox) 浏览器" msgctxt "TorbuttonAddToFirefoxDesc" msgid "Add the ${TORBUTTON_DESC} extension to Firefox." -msgstr "添加 ${TORBUTTON_DESC} 扩展至火狐(Firefox)浏览器." +msgstr "添加 ${TORBUTTON_DESC} 扩展至火狐 (Firefox) 浏览器。" msgctxt "TorbuttonFirefoxNotFound" msgid "Firefox was not found on your system. Not installing Torbutton." -msgstr "安装程序未检测到火狐(Firefox)浏览器,因此将停止添加 Torbutton 扩展." +msgstr "安装程序未检测到火狐 (Firefox) 浏览器,因此将停止添加 Torbutton 扩展。" msgctxt "AppData" msgid "Application Data" @@ -231,7 +231,7 @@ msgctxt "AppDataUninstDesc" msgid "Remove saved application data and configuration files." -msgstr "Remove saved application data and configuration files." +msgstr "删除保存的程序数据和配置文件。" msgctxt "LanguageCode" msgid "en" @@ -239,12 +239,12 @@ msgctxt "FirefoxWarningPageTitle" msgid "Firefox is not installed" -msgstr "" +msgstr "尚未安装 Firefox 浏览器" msgctxt "FirefoxWarningPageSubtitle" msgid "" "We recommend that you install Firefox before continuing, for best safety." -msgstr "" +msgstr "我们建议您在继续安装前安装 Firefox 浏览器,以获得最佳的安全性。" msgctxt "FirefoxWarningPageUpperText" msgid "" @@ -256,6 +256,10 @@ "If you would like to install Firefox, please press Cancel, then go\n" "to the Firefox download page at" msgstr "" +"您的计算机尚未安装 Mozilla Firefox 网页浏览器。\n" +"Tor 将与配合其他浏览器工作,例如 Internet Explorer,但 Firefox 更易于使用,并能更好的保护您的匿名性。\n" +"\n" +"如果您想安装 Firefox,请点击 取消 并访问 Firefox 的下载页面 " msgctxt "FirefoxWarningPageLowerText" msgid "" @@ -265,3 +269,6 @@ "Or, if you would prefer to install Tor without Firefox, simply\n" "press Next to continue." msgstr "" +"当您完成 Firefox 的安装后,再运行 Tor 安装程序。\n" +"\n" +"如果您希望仅安装 Tor 而不使用 Firefox,请点击 下一步 继续安装。" diff -Nru vidalia-0.1.13/pkg/win32/zh_TW/vidalia_zh_TW.po vidalia-0.2.8/pkg/win32/zh_TW/vidalia_zh_TW.po --- vidalia-0.1.13/pkg/win32/zh_TW/vidalia_zh_TW.po 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/pkg/win32/zh_TW/vidalia_zh_TW.po 2009-08-31 03:49:46.000000000 +0100 @@ -19,20 +19,20 @@ #, fuzzy msgctxt "BundleWelcomeText" msgid "" -"This wizard will guide you through the installation of Tor, Vidalia, " -"Privoxy, and Torbutton.\n" +"This wizard will guide you through the installation of Tor, Vidalia, Polipo, " +"and Torbutton.\n" "\n" "Tor is a system for using the Internet anonymously, helping you anonymize " "Web browsing and publishing, instant messaging, IRC, and more. Vidalia is a " "GUI that helps you control, monitor, and configure Tor.\n" "\n" -"Privoxy is a filtering web proxy that protects your privacy and helps remove " -"ads, banners, and popups.\n" +"Polipo is a caching web proxy that helps increase performance of browsing " +"the web through Tor.\n" "\n" "Torbutton is a Firefox extension that allows you to quickly enable or " "disable anonymous web browsing.\n" "\n" -"If you have previously installed Tor, Vidalia, Privoxy, or Firefox, please " +"If you have previously installed Tor, Vidalia, Polipo, or Firefox, please " "make sure they are not running before continuing this installation.\n" "\n" "$_CLICK" @@ -168,36 +168,41 @@ msgid "Add ${TOR_NAME} to your Start menu." msgstr "添加 ${TOR_NAME} 至開始菜單程式集." -#, fuzzy -msgctxt "PrivoxyGroupDesc" +msgctxt "PolipoGroupDesc" msgid "" -"Privoxy is a filtering web proxy that protects your privacy and helps remove " -"ads, banners, and popups." -msgstr "安裝 ${PRIVOXY_DESC}." +"Polipo is a caching web proxy that increases performance of web browsing " +"through Tor." +msgstr "" -msgctxt "PrivoxyUninstDesc" -msgid "Remove ${PRIVOXY_DESC}." -msgstr "Remove ${PRIVOXY_DESC}." +#, fuzzy +msgctxt "PolipoUninstDesc" +msgid "Remove ${POLIPO_DESC}." +msgstr "Remove ${POLIPO_DESC}." -msgctxt "PrivoxyAppDesc" -msgid "Install ${PRIVOXY_DESC}." -msgstr "安裝 ${PRIVOXY_DESC}." +#, fuzzy +msgctxt "PolipoAppDesc" +msgid "Install ${POLIPO_DESC}." +msgstr "安裝 ${POLIPO_DESC}." -msgctxt "PrivoxyShortcuts" +#, fuzzy +msgctxt "PolipoShortcuts" msgid "Add to Start Menu" msgstr "添加至開始菜單程式集" -msgctxt "PrivoxyShortcutsDesc" -msgid "Add ${PRIVOXY_NAME} to your Start menu." -msgstr "添加 ${PRIVOXY_NAME} 至開始菜單程式集." +#, fuzzy +msgctxt "PolipoShortcutsDesc" +msgid "Add ${POLIPO_NAME} to your Start menu." +msgstr "添加 ${POLIPO_NAME} 至開始菜單程式集." -msgctxt "PrivoxyStartup" +#, fuzzy +msgctxt "PolipoStartup" msgid "Run At Startup" msgstr "在系統啟動時執行" -msgctxt "PrivoxyStartupDesc" -msgid "Automatically run ${PRIVOXY_NAME} at startup." -msgstr "自動在系統啟動時執行 ${PRIVOXY_NAME}." +#, fuzzy +msgctxt "PolipoStartupDesc" +msgid "Automatically run ${POLIPO_NAME} at startup." +msgstr "自動在系統啟動時執行 ${POLIPO_NAME}." #, fuzzy msgctxt "TorbuttonGroupDesc" @@ -266,3 +271,4 @@ "Or, if you would prefer to install Tor without Firefox, simply\n" "press Next to continue." msgstr "" + diff -Nru vidalia-0.1.13/README vidalia-0.2.8/README --- vidalia-0.1.13/README 2009-05-25 21:48:32.000000000 +0100 +++ vidalia-0.2.8/README 2009-04-25 04:25:33.000000000 +0100 @@ -1,13 +1,24 @@ +================================ +Overview +================================ Vidalia is a cross-platform controller GUI for Tor, built using the Qt framework. Using Vidalia, you can start and stop Tor, view the status of Tor at a glance, and monitor Tor's bandwidth usage. Vidalia also makes it easy to contribute to the Tor network by helping you set up and manage your own Tor server. -Vidalia runs on most platforms supported by Qt 4.2 or later, including +Vidalia runs on most platforms supported by Qt 4.3 or later, including Windows, Mac OS X, and Linux or other Unix variants using the X11 window system. Vidalia is written by Matt Edman and Justin Hipple. -See LICENSE for licensing information. +See the LICENSE file for licensing information. + +================================ +Installation (Mac OS X) +================================ +Installation is simple. Drag the Vidalia icon to Applications. + +In Finder, browse to Applications and then double-click the Vidalia +icon. diff -Nru vidalia-0.1.13/README.breakpad vidalia-0.2.8/README.breakpad --- vidalia-0.1.13/README.breakpad 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/README.breakpad 2009-06-23 23:53:29.000000000 +0100 @@ -0,0 +1,94 @@ + + Building Vidalia with Breakpad-based Crash Reporting Support + + +Windows +-------- +Pre-requisites: + * Subversion + * CMake 2.4 or later (CMake >= 2.6 preferred) + * Microsoft Visual C++ Professional 2005 or later (VC++ >= 2008 preferred) + NOTE: Google Breakpad requires Microsoft's ATL, so users of Visual Studio + "Express" editions may need to install that separately (if even + supported). + +1. Download and build Qt with Visual Studio support + 1.1. Download the latest Qt source code for Windows from Qt's website: + + http://get.qtsoftware.com/qt/source/ + + 1.2. Extract the .zip file to a directory + 1.3. Open a Visual Studio command prompt + 1.4. 'cd' to the location of your extract Qt source + 1.5. We want to enable building .pdb files for the release versions of the + Qt DLLs, since Breakpad derives its symbol information from the .pdb + files. To do so, unfortunately we have to edit the qmake.conf "mkspec" + for the compiler we're using. For example, if you're using Visual + Studio 2008, you would open the file + + $QTDIR\mkspecs\win32-msvc2008\qmake.conf + + (where $QTDIR is the location of your Qt source code) and add "-Zi" to + QMAKE_CFLAGS_RELEASE. The resulting line would look like: + + + QMAKE_CFLAGS_RELEASE = -Zi -O2 -MD -GL + + You also need to add "/DEBUG /OPT:REF /OPT:ICF" to the list of linker + flags in QMAKE_LFLAGS_RELEASE. The resulting line should look like the + following: + + QMAKE_LFLAGS_RELEASE = /DEBUG /OPT:REF /OPT:ICF /INCREMENTAL:NO /LTCG + + Different Visual Studio mkspecs may look slightly different and have + different sets of default flags. Save your changes to qmake.conf after + you're done. + + 1.6. Configure the Qt source for a Visual Studio build, along with whatever + other options you want (e.g., OpenSSL support). As an example, I used + the following command to configure my Qt: + + $ configure.exe -platform win32-msvc2008 \ + -opensource -debug-and-release \ + -fast -no-qt3support \ + -nomake demos -nomake examples \ + -openssl -I E:\OpenSSL\9.8k\include \ + -L E:\OpenSSL\9.8k\lib\VC + + 1.7. After configure.exe is finished running, simply run nmake.exe to build + Qt. The entire process may take several hours depending on the options + used and the speed of your machine. + +2. Download and build the latest Breakpad source from Subversion + 2.1. Fetch the latest Google Breakpad source code from Subversion + + $ svn cp http://google-breakpad.googlecode.com/svn/trunk/ breakpad + + 2.2. Open breakpad\src\client\windows\breakpad_client.sln + 2.3. Right-click on the "crash_generation" project and select 'Properties' + 2.4. Go to "Configuration Properties" -> "C/C++" -> "Language" and disable + "Treat wchar_t as Built-in Type". + 2.5. Repeat 2.2 and 2.3 for the "crash_report_sender" and "exception_handler" + projects as well. + 2.6. Right-click on the top-level solution and select "Build Solution" or + hit F7 to build the entire solution. + +3. Build Vidalia with Breakpad support enabled + 3.1. Fetch the latest 'breakpad' branch from Vidalia's Subversion repository. + + $ svn co https://svn.vidalia-project.net/svn/vidalia/branches/breakpad vidalia-breakpad + + 3.2. Use CMake to generate a Visual Studio .sln file for Vidalia with + Breakpad support enabled. + + $ mkdir build-vs + $ cd build-vs + $ cmake.exe -DUSE_BREAKPAD=1 \ + -DBREAKPAD_INCLUDE_DIR=E:\breakpad\src \ + -DBREAKPAD_LIBRARY_DIR=E:\Breakpad\src\client\windows\Debug .. + + You will need to adjust the paths above to point to the location of + the Breakpad source directory and binaries you built in Step 2. + 3.3. Open the solution file build-vs\Vidalia.sln with Visual Studio. + 3.4. Right-click on the top-level solution and select "Build Solution", or + hit F7 to build the entire solution. diff -Nru vidalia-0.1.13/README.marble vidalia-0.2.8/README.marble --- vidalia-0.1.13/README.marble 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/README.marble 2009-08-19 17:20:08.000000000 +0100 @@ -0,0 +1,62 @@ + +Building Vidalia with KDE Marble Support +---------------------------------------- + +Vidalia recently added experimental support for replacing the existing 2D +network map widget with the KDE Marble 3D globe widget. It is currently a +compile-time option and is disabled by default. + +The following steps build Vidalia with the Marble widget. + +1. Download the patched version of Marble. + + svn co https://svn.vidalia-project.net/svn/marble/trunk marble + +Hopefully these patches will soon be merged into Marble's trunk. For now, we +still have to build with the Vidalia-specific patched Marble. + +2. Build the patched Marble. + + OS X: + cd ~/marble + mkdir build && cd build + cmake -DCMAKE_INSTALL_PREFIX=. -DQTONLY=1 .. + make && make install + + If you are building a Universal binary, you will need to make the following + changes to ~/marble/CMakeLists.txt before building Marble: + + - #SET( CMAKE_OSX_ARCHITECTURES ppc;i386 ) #Comment out if not universal binary + - SET( CMAKE_OSX_ARCHITECTURES i386 ) #Comment out if universal binary + + SET( CMAKE_OSX_ARCHITECTURES ppc;i386 ) #Comment out if not universal binary + + #SET( CMAKE_OSX_ARCHITECTURES i386 ) #Comment out if universal binary + + Everywhere else: + cd marble + mkdir build && cd build + cmake -DQTONLY=1 .. + make && make install + +3. Configure Vidalia with Marble support. + + OS X & Windows: + cd vidalia (or wherever your Vidalia source tree lives) + mkdir build && cd build + cmake -DUSE_MARBLE=1 \ + -DMARBLE_INCLUDE_DIR=~/marble/src/lib \ + -DMARBLE_DATA_DIR=~/marble/data \ + -DMARBLE_LIBRARY_DIR=~/marble/build/src/lib \ + -DMARBLE_PLUGIN_DIR=~/marble/build/src/plugins .. + + Everywhere else: + cd vidalia (or wherever your Vidalia source tree lives) + mkdir build && cd build + cmake -DUSE_MARBLE=1 .. + +You will need to adjust each of the paths above according to where you checked +out and installed Marble in Steps 1 and 2. + +4. Build Vidalia + + See the INSTALL file included with Vidalia for details. + diff -Nru vidalia-0.1.13/src/CMakeLists.txt vidalia-0.2.8/src/CMakeLists.txt --- vidalia-0.1.13/src/CMakeLists.txt 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/CMakeLists.txt 2009-06-23 23:53:29.000000000 +0100 @@ -1,5 +1,5 @@ ## -## $Id: CMakeLists.txt 2855 2008-07-13 04:08:49Z edmanm $ +## $Id: CMakeLists.txt 3879 2009-06-23 22:53:29Z edmanm $ ## ## 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 @@ -24,6 +24,24 @@ if(MSVC) add_definitions(-D_USE_MATH_DEFINES=1) + + ## Qt's Visual Studio builds explicitly disable treating wchar_t as a + ## built-in type, so we need to do that as well otherwise we get linker + ## errors due to name mangling if we try to use a wchar_t-related method + add_definitions(/Zc:wchar_t-) + + ## Specify that we want the "W" version of Windows methods, such as + ## CreateFileW or WriteFileW + add_definitions(-DUNICODE=1) + + ## Disable incremental linking for all build types, not just Release + ## and MinSizeRel + set(CMAKE_EXE_LINKER_FLAGS_DEBUG + "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /INCREMENTAL:NO" + ) + set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO + "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /INCREMENTAL:NO" + ) endif(MSVC) ## Add some Qt definitions @@ -39,6 +57,9 @@ link_directories(${CMAKE_CURRENT_BINARY_DIR}/miniupnpc) add_subdirectory(miniupnpc) endif(USE_MINIUPNPC) +if (USE_BREAKPAD) + add_subdirectory(crashreporter) +endif(USE_BREAKPAD) add_subdirectory(common) add_subdirectory(tools) diff -Nru vidalia-0.1.13/src/common/CMakeLists.txt vidalia-0.2.8/src/common/CMakeLists.txt --- vidalia-0.1.13/src/common/CMakeLists.txt 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/common/CMakeLists.txt 2009-06-11 18:57:53.000000000 +0100 @@ -1,5 +1,5 @@ ## -## $Id: CMakeLists.txt 2571 2008-05-10 04:23:18Z edmanm $ +## $Id: CMakeLists.txt 3840 2009-06-11 17:57:53Z edmanm $ ## ## 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 @@ -12,23 +12,23 @@ set(common_SRCS + CountryInfo.cpp crypto.cpp file.cpp html.cpp - log.cpp + Log.cpp net.cpp procutil.cpp stringutil.cpp - torsocket.cpp - zlibbytearray.cpp + TorSocket.cpp + TorSslSocket.cpp + ZlibByteArray.cpp +) +qt4_wrap_cpp(common_SRCS + CountryInfo.h + TorSocket.h + TorSslSocket.h ) -qt4_wrap_cpp(common_SRCS torsocket.h) - - -if(USE_QSSLSOCKET) - set(common_SRCS ${common_SRCS} torsslsocket.cpp) - qt4_wrap_cpp(common_SRCS torsslsocket.h) -endif(USE_QSSLSOCKET) if(WIN32) set(common_SRCS ${common_SRCS} @@ -38,9 +38,12 @@ add_library(common STATIC ${common_SRCS}) -target_link_libraries(common ${QT_LIBRARIES}) +target_link_libraries(common + ${QT_QTCORE_LIBRARY} + ${QT_QTNETWORK_LIBRARY} +) -if(USE_QSSLSOCKET AND OPENSSL_LIBRARIES) +if(OPENSSL_LIBRARIES) target_link_libraries(common ${OPENSSL_LIBRARIES}) -endif(USE_QSSLSOCKET AND OPENSSL_LIBRARIES) +endif(OPENSSL_LIBRARIES) diff -Nru vidalia-0.1.13/src/common/CountryInfo.cpp vidalia-0.2.8/src/common/CountryInfo.cpp --- vidalia-0.1.13/src/common/CountryInfo.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/common/CountryInfo.cpp 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,238 @@ +/* +** 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.vidalia-project.net/. 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 CountryInfo.cpp +** \version $Id: CountryInfo.cpp 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Provides a method to look up a localized country name given its +** ISO 3166 2-letter country code. +*/ + +#include "CountryInfo.h" + +#include + + +CountryInfo::CountryInfo(QObject *parent) + : QObject(parent) +{ +} + +QString +CountryInfo::countryName(const QString &countryCode) +{ + static QMap db; + if (db.isEmpty()) { + db.insert("af", QT_TR_NOOP("Afghanistan")); + db.insert("al", QT_TR_NOOP("Albania ")); + db.insert("dz", QT_TR_NOOP("Algeria ")); + db.insert("ad", QT_TR_NOOP("Andorra")); + db.insert("ao", QT_TR_NOOP("Angola")); + db.insert("ag", QT_TR_NOOP("Antigua & Barbuda")); + db.insert("ar", QT_TR_NOOP("Argentina")); + db.insert("am", QT_TR_NOOP("Armenia")); + db.insert("au", QT_TR_NOOP("Australia")); + db.insert("at", QT_TR_NOOP("Austria ")); + db.insert("az", QT_TR_NOOP("Azerbaijan")); + db.insert("bs", QT_TR_NOOP("Bahamas")); + db.insert("bh", QT_TR_NOOP("Bahrain ")); + db.insert("bd", QT_TR_NOOP("Bangladesh")); + db.insert("bb", QT_TR_NOOP("Barbados")); + db.insert("by", QT_TR_NOOP("Belarus")); + db.insert("be", QT_TR_NOOP("Belgium")); + db.insert("bz", QT_TR_NOOP("Belize")); + db.insert("bj", QT_TR_NOOP("Benin ")); + db.insert("bt", QT_TR_NOOP("Bhutan")); + db.insert("bo", QT_TR_NOOP("Bolivia")); + db.insert("ba", QT_TR_NOOP("Bosnia & Herzegovina")); + db.insert("bw", QT_TR_NOOP("Botswana")); + db.insert("br", QT_TR_NOOP("Brazil")); + db.insert("bn", QT_TR_NOOP("Brunei Darussalam")); + db.insert("bg", QT_TR_NOOP("Bulgaria")); + db.insert("bf", QT_TR_NOOP("Burkina Faso")); + db.insert("bi", QT_TR_NOOP("Burundi")); + db.insert("kh", QT_TR_NOOP("Cambodia")); + db.insert("cm", QT_TR_NOOP("Cameroon")); + db.insert("ca", QT_TR_NOOP("Canada")); + db.insert("cv", QT_TR_NOOP("Cape Verde")); + db.insert("cf", QT_TR_NOOP("Central African Republic")); + db.insert("td", QT_TR_NOOP("Chad")); + db.insert("cl", QT_TR_NOOP("Chile")); + db.insert("cn", QT_TR_NOOP("China")); + db.insert("co", QT_TR_NOOP("Colombia")); + db.insert("km", QT_TR_NOOP("Comoros")); + db.insert("cd", QT_TR_NOOP("Congo, The Democratic Republic of the")); + db.insert("cg", QT_TR_NOOP("Congo")); + db.insert("cr", QT_TR_NOOP("Costa Rica")); + db.insert("ci", QT_TR_NOOP("Cote d’Ivoire")); + db.insert("hr", QT_TR_NOOP("Croatia")); + db.insert("cu", QT_TR_NOOP("Cuba")); + db.insert("cy", QT_TR_NOOP("Cyprus")); + db.insert("cz", QT_TR_NOOP("Czech Republic")); + db.insert("dk", QT_TR_NOOP("Denmark")); + db.insert("dj", QT_TR_NOOP("Djibouti")); + db.insert("dm", QT_TR_NOOP("Dominica")); + db.insert("do", QT_TR_NOOP("Dominican Republic")); + db.insert("ec", QT_TR_NOOP("Ecuador")); + db.insert("eg", QT_TR_NOOP("Egypt")); + db.insert("sv", QT_TR_NOOP("El Salvador")); + db.insert("gq", QT_TR_NOOP("Equatorial Guinea")); + db.insert("er", QT_TR_NOOP("Eritrea")); + db.insert("ee", QT_TR_NOOP("Estonia")); + db.insert("et", QT_TR_NOOP("Ethiopia ")); + db.insert("fj", QT_TR_NOOP("Fiji ")); + db.insert("fi", QT_TR_NOOP("Finland ")); + db.insert("fr", QT_TR_NOOP("France")); + db.insert("ga", QT_TR_NOOP("Gabon")); + db.insert("gm", QT_TR_NOOP("Gambia")); + db.insert("ge", QT_TR_NOOP("Georgia")); + db.insert("de", QT_TR_NOOP("Germany")); + db.insert("gh", QT_TR_NOOP("Ghana")); + db.insert("gr", QT_TR_NOOP("Greece ")); + db.insert("gd", QT_TR_NOOP("Grenada")); + db.insert("gt", QT_TR_NOOP("Guatemala")); + db.insert("gu", QT_TR_NOOP("Guam ")); + db.insert("gn", QT_TR_NOOP("Guinea")); + db.insert("gw", QT_TR_NOOP("Guinea-Bissau")); + db.insert("gy", QT_TR_NOOP("Guyana")); + db.insert("hk", QT_TR_NOOP("Hong Kong")); + db.insert("ht", QT_TR_NOOP("Haiti")); + db.insert("hn", QT_TR_NOOP("Honduras")); + db.insert("hu", QT_TR_NOOP("Hungary ")); + db.insert("is", QT_TR_NOOP("Iceland ")); + db.insert("in", QT_TR_NOOP("India ")); + db.insert("id", QT_TR_NOOP("Indonesia ")); + db.insert("ir", QT_TR_NOOP("Iran ")); + db.insert("iq", QT_TR_NOOP("Iraq ")); + db.insert("ie", QT_TR_NOOP("Ireland ")); + db.insert("il", QT_TR_NOOP("Israel")); + db.insert("it", QT_TR_NOOP("Italy")); + db.insert("jm", QT_TR_NOOP("Jamaica")); + db.insert("jp", QT_TR_NOOP("Japan")); + db.insert("jo", QT_TR_NOOP("Jordan")); + db.insert("kz", QT_TR_NOOP("Kazakhstan")); + db.insert("ke", QT_TR_NOOP("Kenya")); + db.insert("ki", QT_TR_NOOP("Kiribati")); + db.insert("kp", QT_TR_NOOP("Korea, North ")); + db.insert("kr", QT_TR_NOOP("Korea, South ")); + db.insert("kw", QT_TR_NOOP("Kuwait")); + db.insert("kg", QT_TR_NOOP("Kyrgyzstan")); + db.insert("la", QT_TR_NOOP("Laos")); + db.insert("lv", QT_TR_NOOP("Latvia")); + db.insert("lb", QT_TR_NOOP("Lebanon")); + db.insert("ls", QT_TR_NOOP("Lesotho")); + db.insert("lr", QT_TR_NOOP("Liberia")); + db.insert("ly", QT_TR_NOOP("Libya ")); + db.insert("li", QT_TR_NOOP("Liechtenstein")); + db.insert("lt", QT_TR_NOOP("Lithuania")); + db.insert("lu", QT_TR_NOOP("Luxembourg")); + db.insert("mk", QT_TR_NOOP("Macedonia")); + db.insert("mg", QT_TR_NOOP("Madagascar")); + db.insert("mw", QT_TR_NOOP("Malawi")); + db.insert("my", QT_TR_NOOP("Malaysia")); + db.insert("mv", QT_TR_NOOP("Maldives ")); + db.insert("ml", QT_TR_NOOP("Mali")); + db.insert("mt", QT_TR_NOOP("Malta")); + db.insert("mh", QT_TR_NOOP("Marshall Islands")); + db.insert("mr", QT_TR_NOOP("Mauritania")); + db.insert("mu", QT_TR_NOOP("Mauritius")); + db.insert("mx", QT_TR_NOOP("Mexico ")); + db.insert("fm", QT_TR_NOOP("Micronesia")); + db.insert("md", QT_TR_NOOP("Moldova")); + db.insert("mc", QT_TR_NOOP("Monaco")); + db.insert("mn", QT_TR_NOOP("Mongolia")); + db.insert("me", QT_TR_NOOP("Montenegro")); + db.insert("ma", QT_TR_NOOP("Morocco")); + db.insert("mz", QT_TR_NOOP("Mozambique")); + db.insert("mm", QT_TR_NOOP("Myanmar ")); + db.insert("na", QT_TR_NOOP("Namibia")); + db.insert("nr", QT_TR_NOOP("Nauru")); + db.insert("np", QT_TR_NOOP("Nepal")); + db.insert("nl", QT_TR_NOOP("Netherlands")); + db.insert("nz", QT_TR_NOOP("New Zealand")); + db.insert("ni", QT_TR_NOOP("Nicaragua")); + db.insert("ne", QT_TR_NOOP("Niger")); + db.insert("ng", QT_TR_NOOP("Nigeria")); + db.insert("no", QT_TR_NOOP("Norway")); + db.insert("om", QT_TR_NOOP("Oman")); + db.insert("pk", QT_TR_NOOP("Pakistan")); + db.insert("pw", QT_TR_NOOP("Palau")); + db.insert("ps", QT_TR_NOOP("Palestine")); + db.insert("pa", QT_TR_NOOP("Panama")); + db.insert("pg", QT_TR_NOOP("Papua New Guinea")); + db.insert("py", QT_TR_NOOP("Paraguay")); + db.insert("pe", QT_TR_NOOP("Peru")); + db.insert("ph", QT_TR_NOOP("Philippines")); + db.insert("pl", QT_TR_NOOP("Poland")); + db.insert("pt", QT_TR_NOOP("Portugal")); + db.insert("qa", QT_TR_NOOP("Qatar")); + db.insert("ro", QT_TR_NOOP("Romania")); + db.insert("ru", QT_TR_NOOP("Russia")); + db.insert("rw", QT_TR_NOOP("Rwanda")); + db.insert("kn", QT_TR_NOOP("Saint Kitts & Nevis")); + db.insert("lc", QT_TR_NOOP("Saint Lucia")); + db.insert("vc", QT_TR_NOOP("Saint Vincent & the Grenadines")); + db.insert("ws", QT_TR_NOOP("Samoa")); + db.insert("sm", QT_TR_NOOP("San Marino")); + db.insert("st", QT_TR_NOOP("Sao Tome & Principe")); + db.insert("sa", QT_TR_NOOP("Saudi Arabia")); + db.insert("sn", QT_TR_NOOP("Senegal")); + db.insert("rs", QT_TR_NOOP("Serbia")); + db.insert("sc", QT_TR_NOOP("Seychelles")); + db.insert("sl", QT_TR_NOOP("Sierra Leone")); + db.insert("sg", QT_TR_NOOP("Singapore")); + db.insert("sk", QT_TR_NOOP("Slovakia")); + db.insert("si", QT_TR_NOOP("Slovenia")); + db.insert("sb", QT_TR_NOOP("Solomon Islands")); + db.insert("so", QT_TR_NOOP("Somalia")); + db.insert("za", QT_TR_NOOP("South Africa")); + db.insert("es", QT_TR_NOOP("Spain")); + db.insert("lk", QT_TR_NOOP("Sri Lanka")); + db.insert("sd", QT_TR_NOOP("Sudan")); + db.insert("sr", QT_TR_NOOP("Suriname")); + db.insert("sz", QT_TR_NOOP("Swaziland")); + db.insert("se", QT_TR_NOOP("Sweden")); + db.insert("ch", QT_TR_NOOP("Switzerland")); + db.insert("sy", QT_TR_NOOP("Syria")); + db.insert("tw", QT_TR_NOOP("Taiwan ")); + db.insert("tj", QT_TR_NOOP("Tajikistan")); + db.insert("tz", QT_TR_NOOP("Tanzania")); + db.insert("th", QT_TR_NOOP("Thailand")); + db.insert("tl", QT_TR_NOOP("Timor-Leste (East Timor)")); + db.insert("tg", QT_TR_NOOP("Togo")); + db.insert("to", QT_TR_NOOP("Tonga")); + db.insert("tt", QT_TR_NOOP("Trinidad & Tobago")); + db.insert("tn", QT_TR_NOOP("Tunisia")); + db.insert("tr", QT_TR_NOOP("Turkey")); + db.insert("tm", QT_TR_NOOP("Turkmenistan")); + db.insert("tv", QT_TR_NOOP("Tuvalu")); + db.insert("ug", QT_TR_NOOP("Uganda")); + db.insert("ua", QT_TR_NOOP("Ukraine")); + db.insert("ae", QT_TR_NOOP("United Arab Emirates")); + db.insert("gb", QT_TR_NOOP("United Kingdom")); + db.insert("us", QT_TR_NOOP("United States")); + db.insert("uy", QT_TR_NOOP("Uruguay")); + db.insert("uz", QT_TR_NOOP("Uzbekistan")); + db.insert("vu", QT_TR_NOOP("Vanuatu")); + db.insert("va", QT_TR_NOOP("Vatican")); + db.insert("ve", QT_TR_NOOP("Venezuela")); + db.insert("vn", QT_TR_NOOP("Vietnam")); + db.insert("eh", QT_TR_NOOP("Western Sahara")); + db.insert("ye", QT_TR_NOOP("Yemen")); + db.insert("zm", QT_TR_NOOP("Zambia")); + db.insert("zw", QT_TR_NOOP("Zimbabwe")); + } + + QString cc = countryCode.toLower(); + if (db.contains(cc)) + return tr(db.value(cc).toLocal8Bit().data()); + return QString(); +} + diff -Nru vidalia-0.1.13/src/common/CountryInfo.h vidalia-0.2.8/src/common/CountryInfo.h --- vidalia-0.1.13/src/common/CountryInfo.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/common/CountryInfo.h 2009-04-28 21:28:01.000000000 +0100 @@ -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.vidalia-project.net/. 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 CountryInfo.h +** \version $Id: CountryInfo.h 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Provides a method to look up a localized country name given its +** ISO 3166-1 2-letter country code. +*/ + +#ifndef _COUNTRYINFO_H +#define _COUNTRYINFO_H + +#include +#include + + +class CountryInfo : public QObject +{ + Q_OBJECT + +public: + /** Default constructor. + */ + CountryInfo(QObject *parent); + + /** Returns the name of the country represented by countryCode, where + * countryCode is a 2-letter ISO 3166-1 alpha-2 two-letter country + * code. The name will be returned translated to the current locale if an + * appropriate QTranslator is currently installed. + */ + static QString countryName(const QString &countryCode); +}; + +#endif + diff -Nru vidalia-0.1.13/src/common/crypto.cpp vidalia-0.2.8/src/common/crypto.cpp --- vidalia-0.1.13/src/common/crypto.cpp 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/common/crypto.cpp 2009-06-06 18:46:49.000000000 +0100 @@ -46,14 +46,16 @@ /* ** \file crypto.cpp -** \version $Id: crypto.cpp 2433 2008-03-22 02:15:31Z edmanm $ +** \version $Id: crypto.cpp 3818 2009-06-06 17:46:49Z edmanm $ ** \brief Provides support for pseuodrandom number generation. */ +#include "crypto.h" + #include #include +#include #include -#include "crypto.h" #if defined(Q_OS_WIN32) #include @@ -156,3 +158,33 @@ return str; } +/** Generates a salted hash of secret using the random salt + * according to the iterated and salted S2K algorithm in RFC 2440. c + * is the one-octet coded count value that specifies how much data to hash. + * salt must contain at least 8 bytes, otherwise this method will + * return a default-constructed QByteArray. */ +QByteArray +crypto_secret_to_key(const QString &secret, const QByteArray &salt, quint8 c) +{ + if (salt.size() < 8) + return QByteArray(); + +#define EXPBIAS 6 + int count = ((quint32)16 + (c & 15)) << ((c >> 4) + EXPBIAS); +#undef EXPBIAS + + QCryptographicHash hash(QCryptographicHash::Sha1); + QByteArray tmp = salt.left(8).append(secret.toAscii()); + while (count) { + if (count > tmp.length()) { + hash.addData(tmp); + count -= tmp.length(); + } else { + hash.addData(tmp.left(count)); + count = 0; + } + } + + return hash.result(); +} + diff -Nru vidalia-0.1.13/src/common/crypto.h vidalia-0.2.8/src/common/crypto.h --- vidalia-0.1.13/src/common/crypto.h 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/common/crypto.h 2009-06-06 18:46:49.000000000 +0100 @@ -46,7 +46,7 @@ /* ** \file crypto.h -** \version $Id: crypto.h 2362 2008-02-29 04:30:11Z edmanm $ +** \version $Id: crypto.h 3818 2009-06-06 17:46:49Z edmanm $ ** \brief Provides support for pseuodrandom number generation. */ @@ -67,6 +67,13 @@ /** Generates a pseudorandom string of length len containing printable * ASCII characters from the range '!' (0x21) to '~' (0x7e). */ QString crypto_rand_string(int len); +/** Generates a salted hash of secret using the random salt + * according to the iterated and salted S2K algorithm in RFC 2440. c + * is the one-octet coded count value that specifies how much data to hash. + * salt must contain at least 8 bytes, otherwise this method will + * return a default-constructed QByteArray. */ +QByteArray +crypto_secret_to_key(const QString &secret, const QByteArray &salt, quint8 c); #endif diff -Nru vidalia-0.1.13/src/common/file.cpp vidalia-0.2.8/src/common/file.cpp --- vidalia-0.1.13/src/common/file.cpp 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/common/file.cpp 2009-04-28 21:28:01.000000000 +0100 @@ -10,39 +10,40 @@ /* ** \file file.cpp -** \version $Id: file.cpp 3511 2009-02-05 00:56:16Z edmanm $ +** \version $Id: file.cpp 3735 2009-04-28 20:28:01Z edmanm $ ** \brief Functions and definitions for common file I/O operations */ -#include -#include -#include "stringutil.h" #include "file.h" +#include "stringutil.h" #if defined(Q_OS_WIN32) #include "win32.h" #endif +#include +#include + /** Create an empty file named filename. if createdir is true, * then the full path to filename will be created. Returns true on * success, or false on error and errmsg will be set. */ bool -touch_file(QString filename, bool createdir, QString *errmsg) +touch_file(const QString &filename, bool createdir, QString *errmsg) { /* Expand the file's path if it starts with a shortcut, like "~/" or * "%APPDATA%" */ - filename = expand_filename(filename); + QString expanded = expand_filename(filename); /* If the file's path doesn't exist and we're supposed to create it, do that * now. */ - if (createdir && !create_path(QFileInfo(filename).absolutePath())) { + if (createdir && !create_path(QFileInfo(expanded).absolutePath())) { return false; } /* Touch the file */ - QFile file(filename); - if (!QFileInfo(filename).exists()) { + QFile file(expanded); + if (!QFileInfo(expanded).exists()) { if (!file.open(QIODevice::WriteOnly)) { return err(errmsg, file.errorString()); } @@ -52,12 +53,11 @@ /** Creates all directories in path, if they do not exist. */ bool -create_path(QString path) +create_path(const QString &path) { QDir dir(path); if (!dir.exists()) { - path = dir.absolutePath(); - if (!dir.mkpath(path)) { + if (!dir.mkpath(dir.absolutePath())) { return false; } } @@ -68,14 +68,15 @@ * destination must already exist. Returns true on success, and false * otherwise. */ bool -copy_dir(QString source, QString dest) +copy_dir(const QString &source, const QString &dest) { /* Source and destination as QDir's */ QDir src(source); QDir dst(dest); /* Get contents of the directory */ - QFileInfoList contents = src.entryInfoList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot); + QFileInfoList contents = src.entryInfoList(QDir::Files | QDir::Dirs + | QDir::NoDotAndDotDot); /* Copy each entry in src to dst */ foreach (QFileInfo fileInfo, contents) { @@ -105,20 +106,21 @@ * expand "%APPDATA%" and "%PROGRAMFILES%". If filename does not * start with a shortcut, filename will be returned unmodified. */ QString -expand_filename(QString filename) +expand_filename(const QString &filename) { + QString fname = filename; #if defined(Q_OS_WIN32) - if (filename.startsWith("%APPDATA%\\") || - filename.startsWith("%APPDATA%/")) - return filename.replace(0, 9, win32_app_data_folder()); + if (fname.startsWith("%APPDATA%\\") || + fname.startsWith("%APPDATA%/")) + return fname.replace(0, 9, win32_app_data_folder()); - if (filename.startsWith("%PROGRAMFILES%\\") || - filename.startsWith("%PROGRAMFILES%/")) - return filename.replace(0, 14, win32_program_files_folder()); + if (fname.startsWith("%PROGRAMFILES%\\") || + fname.startsWith("%PROGRAMFILES%/")) + return fname.replace(0, 14, win32_program_files_folder()); #else - if (filename.startsWith("~/")) - return filename.replace(0, 1, QDir::homePath()); + if (fname.startsWith("~/")) + return fname.replace(0, 1, QDir::homePath()); #endif - return filename; + return fname; } diff -Nru vidalia-0.1.13/src/common/file.h vidalia-0.2.8/src/common/file.h --- vidalia-0.1.13/src/common/file.h 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/common/file.h 2009-02-03 02:21:55.000000000 +0000 @@ -10,7 +10,7 @@ /* ** \file file.h -** \version $Id: file.h 3511 2009-02-05 00:56:16Z edmanm $ +** \version $Id: file.h 3505 2009-02-03 02:21:55Z edmanm $ ** \brief Functions and definitions for common file I/O operations */ @@ -23,20 +23,21 @@ /** Create an empty file named filename. if createdir is true, * then the full path to filename will be created. Returns true on * success, or false on error and errmsg will be set. */ -bool touch_file(QString filename, bool createdir = false, QString *errmsg = 0); +bool touch_file(const QString &filename, bool createdir = false, + QString *errmsg = 0); /** Creates all directories in path, if they do not exist. */ -bool create_path(QString path); +bool create_path(const QString &path); /** Expands filename if it starts with "~/". On Windows, this will * expand "%APPDATA%" and "%PROGRAMFILES%". If filename does not * start with a shortcut, filename will be returned unmodified. */ -QString expand_filename(QString filename); +QString expand_filename(const QString &filename); /** Recursively copy the contents of one directory to another. The * destination must already exist. Returns true on success, and false * otherwise. */ -bool copy_dir(QString source, QString dest); +bool copy_dir(const QString &source, const QString &dest); #endif diff -Nru vidalia-0.1.13/src/common/log.cpp vidalia-0.2.8/src/common/log.cpp --- vidalia-0.1.13/src/common/log.cpp 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/common/log.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,175 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 log.cpp -** \version $Id: log.cpp 2362 2008-02-29 04:30:11Z edmanm $ -** \brief Debug message logging -*/ - -#include -#include - -#include "log.h" - -/** Open log files for appending as write-only text. */ -#define LOGFILE_MODE \ - (QIODevice::WriteOnly|QIODevice::Append|QIODevice::Text) -/** Format for log message timestamps. */ -#define TIMESTAMP_FMT "MMM dd HH:mm:ss.zzz" - - -/** Default constructor. Logs at level Notice by default. */ -Log::Log() -{ - _logLevel = Notice; -} - -/** Destructor. Closes the log file. */ -Log::~Log() -{ - close(); -} - -/** Returns a list of strings representing available log levels. */ -QStringList -Log::logLevels() -{ - return (QStringList() << "debug" << "info" << "notice" - << "warn" << "error"); -} - -/** Sets the current log level to level. If level is Off, then - * the log file will be closed as well. If level is Unknown, no change - * to the current log level is made. */ -void -Log::setLogLevel(LogLevel level) -{ - if (level >= Debug && level < Unknown) - _logLevel = level; - if (level == Off) - _logFile.close(); -} - -/** Opens file for appending, to which log messages will be written. */ -bool -Log::open(FILE *file) -{ - if (_logFile.isOpen()) - close(); - - _logFile.open(file, LOGFILE_MODE); - return isOpen(); -} - -/** Opens file for appending, to which log messages will be written. */ -bool -Log::open(QString file) -{ - if (_logFile.isOpen()) - close(); - - _logFile.setFileName(file); - _logFile.open(LOGFILE_MODE); - return isOpen(); -} - -/** Flushes any outstanding log messages and closes the log file. */ -void -Log::close() -{ - if (_logFile.isOpen()) { - _logFile.flush(); - _logFile.close(); - } -} - -/** Creates a log message with severity level and initial message - * contents message. The log message can be appended to until the - * returned LogMessage's destructor is called, at which point the complete - * message is written to the log file. */ -inline Log::LogMessage -Log::log(LogLevel level) -{ - if (level < _logLevel) - return LogMessage(level, 0); - return LogMessage(level, &_logFile); -} - -/** Creates a log message with severity level. The log message can be - * appended to until the returned LogMessage's destructor is called, at - * which point the complete message is written to the log file. */ -Log::LogMessage -Log::log(LogLevel level, QString msg) -{ - return log(level) << msg; -} - -/** Returns a string description of the given LogLevel level. */ -inline QString -Log::logLevelToString(LogLevel level) -{ - switch (level) { - case Debug: return "debug"; - case Info: return "info"; - case Notice: return "notice"; - case Warn: return "warn"; - case Error: return "error"; - case Off: return "off"; - default: return "unknown"; - } -} - -/** Returns a LogLevel for the level given by str, or Unknown if the - * given string does not represent a valid LogLevel value. */ -Log::LogLevel -Log::stringToLogLevel(QString str) -{ - str = str.toLower(); - if (str == "debug") - return Debug; - else if (str == "info") - return Info; - else if (str == "notice") - return Notice; - else if (str == "warn") - return Warn; - else if (str == "error") - return Error; - else if (str == "off") - return Off; - return Unknown; -} - -/** Returns a formatted log message, prefixed with a timestamp and the log - * message severity level. */ -inline QString -Log::LogMessage::toString() const -{ - QString msg = QDateTime::currentDateTime().toString(TIMESTAMP_FMT); - msg.append(" [" + Log::logLevelToString(stream->type) + "] "); - msg.append(stream->buf); - return msg; -} - -/** Destructor. Writes the buffered log message out to the log file specified - * in the constructor. */ -Log::LogMessage::~LogMessage() -{ - if (!--stream->ref) { - if (stream->out && !stream->buf.isEmpty()) { - QTextStream log(stream->out); - log << toString() << endl; - log.flush(); - } - delete stream; - } -} - diff -Nru vidalia-0.1.13/src/common/Log.cpp vidalia-0.2.8/src/common/Log.cpp --- vidalia-0.1.13/src/common/Log.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/common/Log.cpp 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,175 @@ +/* +** 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.vidalia-project.net/. 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 Log.cpp +** \version $Id: Log.cpp 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Debug message logging +*/ + +#include "Log.h" + +#include +#include + +/** Open log files for appending as write-only text. */ +#define LOGFILE_MODE \ + (QIODevice::WriteOnly|QIODevice::Append|QIODevice::Text) +/** Format for log message timestamps. */ +#define TIMESTAMP_FMT "MMM dd HH:mm:ss.zzz" + + +/** Default constructor. Logs at level Notice by default. */ +Log::Log() +{ + _logLevel = Notice; +} + +/** Destructor. Closes the log file. */ +Log::~Log() +{ + close(); +} + +/** Returns a list of strings representing available log levels. */ +QStringList +Log::logLevels() +{ + return (QStringList() << "debug" << "info" << "notice" + << "warn" << "error"); +} + +/** Sets the current log level to level. If level is Off, then + * the log file will be closed as well. If level is Unknown, no change + * to the current log level is made. */ +void +Log::setLogLevel(LogLevel level) +{ + if (level >= Debug && level < Unknown) + _logLevel = level; + if (level == Off) + _logFile.close(); +} + +/** Opens file for appending, to which log messages will be written. */ +bool +Log::open(FILE *file) +{ + if (_logFile.isOpen()) + close(); + + _logFile.open(file, LOGFILE_MODE); + return isOpen(); +} + +/** Opens file for appending, to which log messages will be written. */ +bool +Log::open(QString file) +{ + if (_logFile.isOpen()) + close(); + + _logFile.setFileName(file); + _logFile.open(LOGFILE_MODE); + return isOpen(); +} + +/** Flushes any outstanding log messages and closes the log file. */ +void +Log::close() +{ + if (_logFile.isOpen()) { + _logFile.flush(); + _logFile.close(); + } +} + +/** Creates a log message with severity level and initial message + * contents message. The log message can be appended to until the + * returned LogMessage's destructor is called, at which point the complete + * message is written to the log file. */ +inline Log::LogMessage +Log::log(LogLevel level) +{ + if (level < _logLevel) + return LogMessage(level, 0); + return LogMessage(level, &_logFile); +} + +/** Creates a log message with severity level. The log message can be + * appended to until the returned LogMessage's destructor is called, at + * which point the complete message is written to the log file. */ +Log::LogMessage +Log::log(LogLevel level, QString msg) +{ + return log(level) << msg; +} + +/** Returns a string description of the given LogLevel level. */ +inline QString +Log::logLevelToString(LogLevel level) +{ + switch (level) { + case Debug: return "debug"; + case Info: return "info"; + case Notice: return "notice"; + case Warn: return "warn"; + case Error: return "error"; + case Off: return "off"; + default: return "unknown"; + } +} + +/** Returns a LogLevel for the level given by str, or Unknown if the + * given string does not represent a valid LogLevel value. */ +Log::LogLevel +Log::stringToLogLevel(QString str) +{ + str = str.toLower(); + if (str == "debug") + return Debug; + else if (str == "info") + return Info; + else if (str == "notice") + return Notice; + else if (str == "warn") + return Warn; + else if (str == "error") + return Error; + else if (str == "off") + return Off; + return Unknown; +} + +/** Returns a formatted log message, prefixed with a timestamp and the log + * message severity level. */ +inline QString +Log::LogMessage::toString() const +{ + QString msg = QDateTime::currentDateTime().toString(TIMESTAMP_FMT); + msg.append(" [" + Log::logLevelToString(stream->type) + "] "); + msg.append(stream->buf); + return msg; +} + +/** Destructor. Writes the buffered log message out to the log file specified + * in the constructor. */ +Log::LogMessage::~LogMessage() +{ + if (!--stream->ref) { + if (stream->out && !stream->buf.isEmpty()) { + QTextStream log(stream->out); + log << toString() << endl; + log.flush(); + } + delete stream; + } +} + diff -Nru vidalia-0.1.13/src/common/log.h vidalia-0.2.8/src/common/log.h --- vidalia-0.1.13/src/common/log.h 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/common/log.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,157 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 log.h -** \version $Id: log.h 2362 2008-02-29 04:30:11Z edmanm $ -** \brief Debug message logging -*/ - -#ifndef _LOG_H -#define _LOG_H - -#include -#include -#include -#include -#include - - -/** The Log class is similar to the QDebug class provided with Qt, but with - * finer-grained logging levels, slightly different output (for example, not - * everything is wrapped in double quotes), supports using .arg(), and can - * still be used even if Qt was compiled with QT_NO_DEBUG_STREAM. */ -class Log -{ -public: - /** Logging severity levels. */ - enum LogLevel { - Debug = 0, /**< Verbose debugging output. */ - Info, /**< Primarily program flow output. */ - Notice, /**< Non-failure (but important) events. */ - Warn, /**< Recoverable failure conditions. */ - Error, /**< Critical, non-recoverable errors. */ - Off, /**< No logging output. */ - Unknown /**< Unknown/invalid log level. */ - }; - class LogMessage; - - /** Default constructor. */ - Log(); - /** Destructor. */ - ~Log(); - - /** Opens a file on disk (or stdout or stderr) to which log messages will be - * written. */ - bool open(FILE *file); - /** Opens a file on disk to which log messages will be written. */ - bool open(QString file); - /** Closes the log file. */ - void close(); - /** Returns true if the log file is open and ready for writing. */ - bool isOpen() { return _logFile.isOpen() && _logFile.isWritable(); } - /** Returns a string description of the last file error encountered. */ - QString errorString() { return _logFile.errorString(); } - - /** Sets the current log level to level. */ - void setLogLevel(LogLevel level); - /** Returns a list of strings representing valid log levels. */ - static QStringList logLevels(); - /** Returns a string description of the given LogLevel level. */ - static inline QString logLevelToString(LogLevel level); - /** Returns a LogLevel for the level given by str. */ - static LogLevel stringToLogLevel(QString str); - - /** Creates a log message with severity level and initial message - * contents message. The log message can be appended to until the - * returned LogMessage's destructor is called, at which point the complete - * message is written to the log file. */ - LogMessage log(LogLevel level, QString message); - /** Creates a log message with severity level. The log message can be - * appended to until the returned LogMessage's destructor is called, at - * which point the complete message is written to the log file. */ - inline LogMessage log(LogLevel level); - -private: - LogLevel _logLevel; /**< Minimum log severity level. */ - QFile _logFile; /**< Log output destination. */ -}; - -/** This internal class represents a single message that is to be written to - * the log destination. The message is buffered until it is written to the - * log in this class's destructor. */ -class Log::LogMessage -{ -public: - struct Stream { - Stream(Log::LogLevel t, QIODevice *o) - : type(t), out(o), ref(1) {} - Log::LogLevel type; - QIODevice *out; - int ref; - QString buf; - } *stream; - - inline LogMessage(Log::LogLevel t, QIODevice *o) - : stream(new Stream(t,o)) {} - inline LogMessage(const LogMessage &o) - : stream(o.stream) { ++stream->ref; } - inline QString toString() const; - ~LogMessage(); - - /* Support both the << and .arg() methods */ - inline LogMessage &operator<<(const QString &t) - { stream->buf += t; return *this; } - inline LogMessage arg(const QString &a) - { stream->buf = stream->buf.arg(a); return *this; } - inline LogMessage &operator<<(const QStringList &a) - { stream->buf += a.join(","); return *this; } - inline LogMessage arg(const QStringList &a) - { stream->buf = stream->buf.arg(a.join(",")); return *this; } - inline LogMessage &operator<<(const QHostAddress &a) - { stream->buf += a.toString(); return *this; } - inline LogMessage arg(const QHostAddress &a) - { stream->buf = stream->buf.arg(a.toString()); return *this; } - inline LogMessage &operator<<(short a) - { stream->buf += QString::number(a); return *this; } - inline LogMessage arg(short a) - { stream->buf = stream->buf.arg(a); return *this; } - inline LogMessage &operator<<(ushort a) - { stream->buf += QString::number(a); return *this; } - inline LogMessage arg(ushort a) - { stream->buf = stream->buf.arg(a); return *this; } - inline LogMessage &operator<<(int a) - { stream->buf += QString::number(a); return *this; } - inline LogMessage arg(int a) - { stream->buf = stream->buf.arg(a); return *this; } - inline LogMessage &operator<<(uint a) - { stream->buf += QString::number(a); return *this; } - inline LogMessage arg(uint a) - { stream->buf = stream->buf.arg(a); return *this; } - inline LogMessage &operator<<(long a) - { stream->buf += QString::number(a); return *this; } - inline LogMessage arg(long a) - { stream->buf = stream->buf.arg(a); return *this; } - inline LogMessage &operator<<(ulong a) - { stream->buf += QString::number(a); return *this; } - inline LogMessage arg(ulong a) - { stream->buf = stream->buf.arg(a); return *this; } - inline LogMessage &operator<<(qlonglong a) - { stream->buf += QString::number(a); return *this; } - inline LogMessage arg(qlonglong a) - { stream->buf = stream->buf.arg(a); return *this; } - inline LogMessage &operator<<(qulonglong a) - { stream->buf += QString::number(a); return *this; } - inline LogMessage arg(qulonglong a) - { stream->buf = stream->buf.arg(a); return *this; } -}; - -#endif - diff -Nru vidalia-0.1.13/src/common/Log.h vidalia-0.2.8/src/common/Log.h --- vidalia-0.1.13/src/common/Log.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/common/Log.h 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,157 @@ +/* +** 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.vidalia-project.net/. 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 Log.h +** \version $Id: Log.h 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Debug message logging +*/ + +#ifndef _LOG_H +#define _LOG_H + +#include +#include +#include +#include +#include + + +/** The Log class is similar to the QDebug class provided with Qt, but with + * finer-grained logging levels, slightly different output (for example, not + * everything is wrapped in double quotes), supports using .arg(), and can + * still be used even if Qt was compiled with QT_NO_DEBUG_STREAM. */ +class Log +{ +public: + /** Logging severity levels. */ + enum LogLevel { + Debug = 0, /**< Verbose debugging output. */ + Info, /**< Primarily program flow output. */ + Notice, /**< Non-failure (but important) events. */ + Warn, /**< Recoverable failure conditions. */ + Error, /**< Critical, non-recoverable errors. */ + Off, /**< No logging output. */ + Unknown /**< Unknown/invalid log level. */ + }; + class LogMessage; + + /** Default constructor. */ + Log(); + /** Destructor. */ + ~Log(); + + /** Opens a file on disk (or stdout or stderr) to which log messages will be + * written. */ + bool open(FILE *file); + /** Opens a file on disk to which log messages will be written. */ + bool open(QString file); + /** Closes the log file. */ + void close(); + /** Returns true if the log file is open and ready for writing. */ + bool isOpen() { return _logFile.isOpen() && _logFile.isWritable(); } + /** Returns a string description of the last file error encountered. */ + QString errorString() { return _logFile.errorString(); } + + /** Sets the current log level to level. */ + void setLogLevel(LogLevel level); + /** Returns a list of strings representing valid log levels. */ + static QStringList logLevels(); + /** Returns a string description of the given LogLevel level. */ + static inline QString logLevelToString(LogLevel level); + /** Returns a LogLevel for the level given by str. */ + static LogLevel stringToLogLevel(QString str); + + /** Creates a log message with severity level and initial message + * contents message. The log message can be appended to until the + * returned LogMessage's destructor is called, at which point the complete + * message is written to the log file. */ + LogMessage log(LogLevel level, QString message); + /** Creates a log message with severity level. The log message can be + * appended to until the returned LogMessage's destructor is called, at + * which point the complete message is written to the log file. */ + inline LogMessage log(LogLevel level); + +private: + LogLevel _logLevel; /**< Minimum log severity level. */ + QFile _logFile; /**< Log output destination. */ +}; + +/** This internal class represents a single message that is to be written to + * the log destination. The message is buffered until it is written to the + * log in this class's destructor. */ +class Log::LogMessage +{ +public: + struct Stream { + Stream(Log::LogLevel t, QIODevice *o) + : type(t), out(o), ref(1) {} + Log::LogLevel type; + QIODevice *out; + int ref; + QString buf; + } *stream; + + inline LogMessage(Log::LogLevel t, QIODevice *o) + : stream(new Stream(t,o)) {} + inline LogMessage(const LogMessage &o) + : stream(o.stream) { ++stream->ref; } + inline QString toString() const; + ~LogMessage(); + + /* Support both the << and .arg() methods */ + inline LogMessage &operator<<(const QString &t) + { stream->buf += t; return *this; } + inline LogMessage arg(const QString &a) + { stream->buf = stream->buf.arg(a); return *this; } + inline LogMessage &operator<<(const QStringList &a) + { stream->buf += a.join(","); return *this; } + inline LogMessage arg(const QStringList &a) + { stream->buf = stream->buf.arg(a.join(",")); return *this; } + inline LogMessage &operator<<(const QHostAddress &a) + { stream->buf += a.toString(); return *this; } + inline LogMessage arg(const QHostAddress &a) + { stream->buf = stream->buf.arg(a.toString()); return *this; } + inline LogMessage &operator<<(short a) + { stream->buf += QString::number(a); return *this; } + inline LogMessage arg(short a) + { stream->buf = stream->buf.arg(a); return *this; } + inline LogMessage &operator<<(ushort a) + { stream->buf += QString::number(a); return *this; } + inline LogMessage arg(ushort a) + { stream->buf = stream->buf.arg(a); return *this; } + inline LogMessage &operator<<(int a) + { stream->buf += QString::number(a); return *this; } + inline LogMessage arg(int a) + { stream->buf = stream->buf.arg(a); return *this; } + inline LogMessage &operator<<(uint a) + { stream->buf += QString::number(a); return *this; } + inline LogMessage arg(uint a) + { stream->buf = stream->buf.arg(a); return *this; } + inline LogMessage &operator<<(long a) + { stream->buf += QString::number(a); return *this; } + inline LogMessage arg(long a) + { stream->buf = stream->buf.arg(a); return *this; } + inline LogMessage &operator<<(ulong a) + { stream->buf += QString::number(a); return *this; } + inline LogMessage arg(ulong a) + { stream->buf = stream->buf.arg(a); return *this; } + inline LogMessage &operator<<(qlonglong a) + { stream->buf += QString::number(a); return *this; } + inline LogMessage arg(qlonglong a) + { stream->buf = stream->buf.arg(a); return *this; } + inline LogMessage &operator<<(qulonglong a) + { stream->buf += QString::number(a); return *this; } + inline LogMessage arg(qulonglong a) + { stream->buf = stream->buf.arg(a); return *this; } +}; + +#endif + diff -Nru vidalia-0.1.13/src/common/net.cpp vidalia-0.2.8/src/common/net.cpp --- vidalia-0.1.13/src/common/net.cpp 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/common/net.cpp 2009-04-28 21:28:01.000000000 +0100 @@ -10,14 +10,14 @@ /* ** \file net.cpp -** \version $Id: net.cpp 2362 2008-02-29 04:30:11Z edmanm $ +** \version $Id: net.cpp 3735 2009-04-28 20:28:01Z edmanm $ ** \brief Common network I/O and utility functions */ -#include - #include "net.h" +#include + /** Attempts a connection to host on port. Returns true if the * connection was successful, or false if the connection attempt failed. */ diff -Nru vidalia-0.1.13/src/common/procutil.cpp vidalia-0.2.8/src/common/procutil.cpp --- vidalia-0.1.13/src/common/procutil.cpp 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/common/procutil.cpp 2009-05-01 04:26:38.000000000 +0100 @@ -10,19 +10,19 @@ /* ** \file procutil.cpp -** \version $Id: procutil.cpp 3276 2008-11-03 00:08:59Z edmanm $ +** \version $Id: procutil.cpp 3751 2009-05-01 03:26:38Z edmanm $ ** \brief Process information and pidfile functions */ +#include "procutil.h" +#include "stringutil.h" + #include #include #include #include #include -#include "stringutil.h" -#include "procutil.h" - /** Returns the PID of the current process. */ qint64 @@ -59,7 +59,7 @@ /** Writes the given file to disk containing the current process's PID. */ bool -write_pidfile(QString pidFileName, QString *errmsg) +write_pidfile(const QString &pidFileName, QString *errmsg) { /* Make sure the directory exists */ QDir pidFileDir = QFileInfo(pidFileName).absoluteDir(); @@ -82,7 +82,7 @@ /** Reads the given pidfile and returns the value contained in it. If the file * does not exist 0 is returned. Returns -1 if an error occurs. */ qint64 -read_pidfile(QString pidFileName, QString *errmsg) +read_pidfile(const QString &pidFileName, QString *errmsg) { qint64 pid; diff -Nru vidalia-0.1.13/src/common/procutil.h vidalia-0.2.8/src/common/procutil.h --- vidalia-0.1.13/src/common/procutil.h 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/common/procutil.h 2009-05-01 04:26:38.000000000 +0100 @@ -10,15 +10,14 @@ /* ** \file procutil.h -** \version $Id: procutil.h 3276 2008-11-03 00:08:59Z edmanm $ +** \version $Id: procutil.h 3751 2009-05-01 03:26:38Z edmanm $ ** \brief Process information and pidfile functions */ #ifndef _PROCUTIL_H #define _PROCUTIL_H -#include - +#include #if defined(Q_OS_WIN) #include "win32.h" #else @@ -28,6 +27,9 @@ #include #endif +#include + +class QString; /** Returns the PID of the current process. */ qint64 get_pid(); @@ -36,11 +38,11 @@ bool is_process_running(qint64 pid); /** Writes the given file to disk containing the current process's PID. */ -bool write_pidfile(QString pidfile, QString *errmsg = 0); +bool write_pidfile(const QString &pidfile, QString *errmsg = 0); /** Reads the giiven pidfile and returns the value in it. If the file does not * exist, -1 is returned. */ -qint64 read_pidfile(QString pidfile, QString *errmsg = 0); +qint64 read_pidfile(const QString &pidfile, QString *errmsg = 0); /** Return a list of all currently running PIDs and their associated process * names. */ diff -Nru vidalia-0.1.13/src/common/stringutil.cpp vidalia-0.2.8/src/common/stringutil.cpp --- vidalia-0.1.13/src/common/stringutil.cpp 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/common/stringutil.cpp 2009-04-28 21:28:01.000000000 +0100 @@ -10,12 +10,15 @@ /* ** \file stringutil.cpp -** \version $Id: stringutil.cpp 2486 2008-04-05 14:43:08Z edmanm $ +** \version $Id: stringutil.cpp 3735 2009-04-28 20:28:01Z edmanm $ ** \brief Common string manipulation functions */ #include "stringutil.h" +#include +#include + /** Create a QStringList from the array of C-style strings. */ QStringList @@ -305,3 +308,49 @@ return true; } +/** Returns a human-readable description of the time elapsed given by + * seconds, broken down into days, hours, minutes and seconds. */ +QString +string_format_uptime(quint64 seconds) +{ + QString uptime; + int secs = (seconds % 60); + int mins = (seconds / 60 % 60); + int hours = (seconds / 3600 % 24); + int days = (seconds / 86400); + + if (days) + uptime += qApp->translate("stringutil.h", "%1 days ").arg(days); + if (hours) + uptime += qApp->translate("stringutil.h", "%1 hours ").arg(hours); + if (mins) + uptime += qApp->translate("stringutil.h", "%1 mins ").arg(mins); + if (secs) + uptime += qApp->translate("stringutil.h", "%1 secs").arg(secs); + + return uptime; +} + +/** Returns a string representation of date formatted according to + * "yyyy-MM-dd HH:mm:ss". */ +QString +string_format_datetime(const QDateTime &date) +{ + return date.toString("yyyy-MM-dd HH:mm:ss"); +} + +/** Returns a string representation of bytes with the appropriate + * suffix of either "B/s", "KB/s", "MB/s" or "GB/s". */ +QString +string_format_bandwidth(quint64 bytes) +{ + if (bytes < 1024) + return qApp->translate("stringutil.h", "%1 B/s").arg(bytes); + if (bytes < 1048576) + return qApp->translate("stringutil.h", "%1 KB/s").arg(bytes/1024.0, 0, 'f', 2); + if (bytes < 1073741824) + return qApp->translate("stringutil.h", "%1 MB/s").arg(bytes/1048576.0, 0, 'f', 2); + + return qApp->translate("stringutil.h", "%1 GB/s").arg(bytes/1073741824.0, 0, 'f', 2); +} + diff -Nru vidalia-0.1.13/src/common/stringutil.h vidalia-0.2.8/src/common/stringutil.h --- vidalia-0.1.13/src/common/stringutil.h 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/common/stringutil.h 2009-08-29 19:39:35.000000000 +0100 @@ -10,7 +10,7 @@ /* ** \file stringutil.h -** \version $Id: stringutil.h 2486 2008-04-05 14:43:08Z edmanm $ +** \version $Id: stringutil.h 4085 2009-08-29 18:39:35Z edmanm $ ** \brief Common string manipulation functions */ @@ -19,6 +19,7 @@ #include #include +#include /** Creates a QStringList from the array of C strings. */ @@ -40,7 +41,8 @@ * word separator (" ", for example), and placing the line ending le at * the end of each line, except the last.*/ QString string_wrap(const QString &str, int width, - const QString &sep, const QString &le); + const QString &sep = QString(" "), + const QString &le = QString("\n")); /** Encodes the bytes in buf as an uppercase hexadecimal string and * returns the result. This function is derived from base16_encode() in Tor's @@ -73,5 +75,17 @@ * otherwise. */ bool string_is_hex(const QString &str); +/** Returns a human-readable description of the time elapsed given by + * seconds, broken down into days, hours, minutes and seconds. */ +QString string_format_uptime(quint64 seconds); + +/** Returns a string representation of date formatted according to + * "yyyy-MM-dd HH:mm:ss". */ +QString string_format_datetime(const QDateTime &date); + +/** Returns a string representation of bytes with the appropriate + * (localized) suffix of either "B/s", "KB/s", "MB/s" or "GB/s". */ +QString string_format_bandwidth(quint64 bytes); + #endif diff -Nru vidalia-0.1.13/src/common/torsocket.cpp vidalia-0.2.8/src/common/torsocket.cpp --- vidalia-0.1.13/src/common/torsocket.cpp 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/common/torsocket.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,125 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 torsocket.cpp -** \version $Id: torsocket.cpp 2362 2008-02-29 04:30:11Z edmanm $ -** \brief A QTcpSocket that makes requests over Tor -*/ - -#include - -#include "torsocket.h" - -#define SOCKS_VERSION 0x04 /**< SOCKS version. */ -#define SOCKS_CONNECT 0x01 /**< SOCKS connect command ID. */ -#define SOCKS_FAKE_IP 0x00000001 /**< Bogus IP. */ -#define SOCKS_RESPONSE_LEN 0x08 /**< SOCKS server response length. */ -#define SOCKS_RESPONSE_VERSION 0x00 /**< SOCKS server response version. */ -#define SOCKS_CONNECT_STATUS_OK 0x5A /**< SOCKS server response status. */ - - -/** Constructor. */ -TorSocket::TorSocket(const QHostAddress &socksAddr, - quint16 socksPort, QObject *parent) -: QTcpSocket(parent), - _socksAddr(socksAddr), - _socksPort(socksPort) -{ - QObject::connect(this, SIGNAL(error(QAbstractSocket::SocketError)), - this, SLOT(onError(QAbstractSocket::SocketError))); - QObject::connect(this, SIGNAL(readyRead()), - this, SLOT(onHandshakeResponse())); - QObject::connect(this, SIGNAL(connected()), - this, SLOT(connectedToProxy())); -} - -/** Connects to the specified hostname and port via Tor. */ -void -TorSocket::connectToRemoteHost(const QString &remoteHost, quint16 remotePort) -{ - _remoteHost = remoteHost; - _remotePort = remotePort; - QTcpSocket::connectToHost(_socksAddr, _socksPort); -} - -/** Called when a connection error has occurred. */ -void -TorSocket::onError(QAbstractSocket::SocketError error) -{ - Q_UNUSED(error); - emit socketError(errorString()); -} - -/** Called when the socket is connected to the proxy and sends our - * half of a Socks4a handshake. */ -void -TorSocket::connectedToProxy() -{ - sendSocksHandshake(_remoteHost, _remotePort); -} - -/** Sends the first part of a Socks4a handshake, using the remote hostname and - * port specified in the previous call to connectToHost(). The message should - * be formatted as follows: - * - * 0x04 (socks version) - * 0x01 (connect) - * PORT (two bytes, most significant byte first) - * 0x00 0x00 0x00 0x01 (fake IP address: tells proxy to use SOCKS4a) - * 0x00 (empty username field) - * HOSTNAME (target hostname) - * 0x00 (marks the end of the hostname field) - */ -void -TorSocket::sendSocksHandshake(const QString &remoteHost, quint16 remotePort) -{ - QDataStream sock(this); - sock << (quint8)SOCKS_VERSION; - sock << (quint8)SOCKS_CONNECT; - sock << (quint16)remotePort; - sock << (quint32)SOCKS_FAKE_IP; - sock << (quint8)0; - sock.writeRawData(qPrintable(remoteHost), remoteHost.length()); - sock << (quint8)0; -} - -/** Handles the second half of the handshake, received from the SOCKS - * proxy server. The response should be formatted as follows: - * - * 0x00 (response version) - * STATUS (0x5A means success; other values mean failure) - * PORT (not set) - * ADDRESS (not set) - */ -void -TorSocket::onHandshakeResponse() -{ - QByteArray response; - if (bytesAvailable() >= SOCKS_RESPONSE_LEN) { - /* We've received our response, so stop waiting for it. */ - QObject::disconnect(this, SIGNAL(readyRead()), - this, SLOT(onHandshakeResponse())); - - /* Read the 8-byte response off the socket. */ - response = read(SOCKS_RESPONSE_LEN); - - /* Check to make sure we got a good response from the proxy. */ - if ((uchar)response[0] == (uchar)SOCKS_RESPONSE_VERSION && - (uchar)response[1] == (uchar)SOCKS_CONNECT_STATUS_OK) { - /* Connection status was okay. */ - emit connectedToRemoteHost(); - } else { - /* Remote connection failed, so close the connection to the proxy. */ - disconnectFromHost(); - } - } -} - diff -Nru vidalia-0.1.13/src/common/TorSocket.cpp vidalia-0.2.8/src/common/TorSocket.cpp --- vidalia-0.1.13/src/common/TorSocket.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/common/TorSocket.cpp 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,125 @@ +/* +** 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.vidalia-project.net/. 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 TorSocket.cpp +** \version $Id: TorSocket.cpp 3735 2009-04-28 20:28:01Z edmanm $ +** \brief A QTcpSocket that makes requests over Tor +*/ + +#include "TorSocket.h" + +#include + +#define SOCKS_VERSION 0x04 /**< SOCKS version. */ +#define SOCKS_CONNECT 0x01 /**< SOCKS connect command ID. */ +#define SOCKS_FAKE_IP 0x00000001 /**< Bogus IP. */ +#define SOCKS_RESPONSE_LEN 0x08 /**< SOCKS server response length. */ +#define SOCKS_RESPONSE_VERSION 0x00 /**< SOCKS server response version. */ +#define SOCKS_CONNECT_STATUS_OK 0x5A /**< SOCKS server response status. */ + + +/** Constructor. */ +TorSocket::TorSocket(const QHostAddress &socksAddr, + quint16 socksPort, QObject *parent) +: QTcpSocket(parent), + _socksAddr(socksAddr), + _socksPort(socksPort) +{ + QObject::connect(this, SIGNAL(error(QAbstractSocket::SocketError)), + this, SLOT(onError(QAbstractSocket::SocketError))); + QObject::connect(this, SIGNAL(readyRead()), + this, SLOT(onHandshakeResponse())); + QObject::connect(this, SIGNAL(connected()), + this, SLOT(connectedToProxy())); +} + +/** Connects to the specified hostname and port via Tor. */ +void +TorSocket::connectToRemoteHost(const QString &remoteHost, quint16 remotePort) +{ + _remoteHost = remoteHost; + _remotePort = remotePort; + QTcpSocket::connectToHost(_socksAddr, _socksPort); +} + +/** Called when a connection error has occurred. */ +void +TorSocket::onError(QAbstractSocket::SocketError error) +{ + Q_UNUSED(error); + emit socketError(errorString()); +} + +/** Called when the socket is connected to the proxy and sends our + * half of a Socks4a handshake. */ +void +TorSocket::connectedToProxy() +{ + sendSocksHandshake(_remoteHost, _remotePort); +} + +/** Sends the first part of a Socks4a handshake, using the remote hostname and + * port specified in the previous call to connectToHost(). The message should + * be formatted as follows: + * + * 0x04 (socks version) + * 0x01 (connect) + * PORT (two bytes, most significant byte first) + * 0x00 0x00 0x00 0x01 (fake IP address: tells proxy to use SOCKS4a) + * 0x00 (empty username field) + * HOSTNAME (target hostname) + * 0x00 (marks the end of the hostname field) + */ +void +TorSocket::sendSocksHandshake(const QString &remoteHost, quint16 remotePort) +{ + QDataStream sock(this); + sock << (quint8)SOCKS_VERSION; + sock << (quint8)SOCKS_CONNECT; + sock << (quint16)remotePort; + sock << (quint32)SOCKS_FAKE_IP; + sock << (quint8)0; + sock.writeRawData(qPrintable(remoteHost), remoteHost.length()); + sock << (quint8)0; +} + +/** Handles the second half of the handshake, received from the SOCKS + * proxy server. The response should be formatted as follows: + * + * 0x00 (response version) + * STATUS (0x5A means success; other values mean failure) + * PORT (not set) + * ADDRESS (not set) + */ +void +TorSocket::onHandshakeResponse() +{ + QByteArray response; + if (bytesAvailable() >= SOCKS_RESPONSE_LEN) { + /* We've received our response, so stop waiting for it. */ + QObject::disconnect(this, SIGNAL(readyRead()), + this, SLOT(onHandshakeResponse())); + + /* Read the 8-byte response off the socket. */ + response = read(SOCKS_RESPONSE_LEN); + + /* Check to make sure we got a good response from the proxy. */ + if ((uchar)response[0] == (uchar)SOCKS_RESPONSE_VERSION && + (uchar)response[1] == (uchar)SOCKS_CONNECT_STATUS_OK) { + /* Connection status was okay. */ + emit connectedToRemoteHost(); + } else { + /* Remote connection failed, so close the connection to the proxy. */ + disconnectFromHost(); + } + } +} + diff -Nru vidalia-0.1.13/src/common/torsocket.h vidalia-0.2.8/src/common/torsocket.h --- vidalia-0.1.13/src/common/torsocket.h 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/common/torsocket.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,63 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 torsocket.h -** \version $Id: torsocket.h 2362 2008-02-29 04:30:11Z edmanm $ -** \brief A QTcpSocket that makes requests over Tor -*/ - -#ifndef _TORSOCKET_H -#define _TORSOCKET_H - -#include -#include - - -class TorSocket : public QTcpSocket -{ - Q_OBJECT - -public: - /** Constructor. */ - TorSocket(const QHostAddress &socksAddr, - quint16 socksPort, QObject *parent = 0); - - /** Connects to the specified hostname and port via Tor. */ - void connectToRemoteHost(const QString &remoteHost, quint16 remotePort); - -signals: - /** Emitted when a connection has been established through Tor to the remote - * host specified in a prior call to connectToHost(). */ - void connectedToRemoteHost(); - /** Emitted when a connection error has occurred. */ - void socketError(QString errmsg); - -private slots: - /** Called when the socket is connected to the proxy and sends our - * half of a Socks4a handshake. */ - void connectedToProxy(); - /** Handles the server's response part of a Socks4a handshake. */ - void onHandshakeResponse(); - /** Called when a connection error has occurred. */ - void onError(QAbstractSocket::SocketError error); - -private: - /** Sends the client part of a Socks4a handshake with a proxy server. */ - void sendSocksHandshake(const QString &remoteHost, quint16 remotePort); - - QHostAddress _socksAddr; /**< Address of Tor's SOCKS listener. */ - QString _remoteHost; /**< Remote hostname. */ - quint16 _socksPort; /**< Port of Tor's SOCKS listener. */ - quint16 _remotePort; /**< Remote host port. */ -}; - -#endif - diff -Nru vidalia-0.1.13/src/common/TorSocket.h vidalia-0.2.8/src/common/TorSocket.h --- vidalia-0.1.13/src/common/TorSocket.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/common/TorSocket.h 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,63 @@ +/* +** 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.vidalia-project.net/. 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 TorSocket.h +** \version $Id: TorSocket.h 3735 2009-04-28 20:28:01Z edmanm $ +** \brief A QTcpSocket that makes requests over Tor +*/ + +#ifndef _TORSOCKET_H +#define _TORSOCKET_H + +#include +#include + + +class TorSocket : public QTcpSocket +{ + Q_OBJECT + +public: + /** Constructor. */ + TorSocket(const QHostAddress &socksAddr, + quint16 socksPort, QObject *parent = 0); + + /** Connects to the specified hostname and port via Tor. */ + void connectToRemoteHost(const QString &remoteHost, quint16 remotePort); + +signals: + /** Emitted when a connection has been established through Tor to the remote + * host specified in a prior call to connectToHost(). */ + void connectedToRemoteHost(); + /** Emitted when a connection error has occurred. */ + void socketError(QString errmsg); + +private slots: + /** Called when the socket is connected to the proxy and sends our + * half of a Socks4a handshake. */ + void connectedToProxy(); + /** Handles the server's response part of a Socks4a handshake. */ + void onHandshakeResponse(); + /** Called when a connection error has occurred. */ + void onError(QAbstractSocket::SocketError error); + +private: + /** Sends the client part of a Socks4a handshake with a proxy server. */ + void sendSocksHandshake(const QString &remoteHost, quint16 remotePort); + + QHostAddress _socksAddr; /**< Address of Tor's SOCKS listener. */ + QString _remoteHost; /**< Remote hostname. */ + quint16 _socksPort; /**< Port of Tor's SOCKS listener. */ + quint16 _remotePort; /**< Remote host port. */ +}; + +#endif + diff -Nru vidalia-0.1.13/src/common/torsslsocket.cpp vidalia-0.2.8/src/common/torsslsocket.cpp --- vidalia-0.1.13/src/common/torsslsocket.cpp 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/common/torsslsocket.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,161 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 torsslsocket.cpp -** \version $Id: /local/vidalia/trunk/src/util/torsocket.cpp 1564 2006-12-26T06:06:04.965088Z edmanm $ -** \brief A QSslSocket that makes encrypted requests over Tor -*/ - -#include "torsslsocket.h" - -#include -#include - - -#define SOCKS_VERSION 0x04 /**< SOCKS version. */ -#define SOCKS_CONNECT 0x01 /**< SOCKS connect command ID. */ -#define SOCKS_FAKE_IP 0x00000001 /**< Bogus IP. */ -#define SOCKS_RESPONSE_LEN 0x08 /**< SOCKS server response length. */ -#define SOCKS_RESPONSE_VERSION 0x00 /**< SOCKS server response version. */ -#define SOCKS_CONNECT_STATUS_OK 0x5A /**< SOCKS server response status. */ - - -/** Constructor. */ -TorSslSocket::TorSslSocket(const QHostAddress &socksAddr, - quint16 socksPort, QObject *parent) -: QSslSocket(parent), - _socksAddr(socksAddr), - _socksPort(socksPort) -{ - QObject::connect(this, SIGNAL(sslErrors(QList)), - this, SLOT(onSslErrors(QList))); - QObject::connect(this, SIGNAL(error(QAbstractSocket::SocketError)), - this, SLOT(onError(QAbstractSocket::SocketError))); - QObject::connect(this, SIGNAL(readyRead()), - this, SLOT(onHandshakeResponse())); - QObject::connect(this, SIGNAL(connected()), - this, SLOT(connectedToProxy())); - QObject::connect(this, SIGNAL(encrypted()), - this, SLOT(onEncrypted())); -} - -/** Connects to the specified hostname and port via Tor. */ -void -TorSslSocket::connectToRemoteHost(const QString &remoteHost, quint16 remotePort, - bool encrypted) -{ - _remoteHost = remoteHost; - _remotePort = remotePort; - _encrypted = encrypted; - QTcpSocket::connectToHost(_socksAddr, _socksPort); -} - -/** Called when a connection error has occurred. */ -void -TorSslSocket::onError(QAbstractSocket::SocketError error) -{ - Q_UNUSED(error); - emit socketError(errorString()); -} - -/** Called when one or more SSL errors occur on the socket. */ -void -TorSslSocket::onSslErrors(const QList &errors) -{ - QStringList errorStrings; - foreach (QSslError error, errors) { - errorStrings << "\"" + error.errorString() + "\""; - } - emit socketError(errorStrings.join(",")); -} - -/** Called when a connection has been established to the proxy host and starts - * a Socks4a handshake. */ -void -TorSslSocket::connectedToProxy() -{ - sendSocksHandshake(_remoteHost, _remotePort); -} - -/** Called when an encrypted connection has been established to the remote - * host. */ -void -TorSslSocket::onEncrypted() -{ - emit connectedToRemoteHost(); -} - -/** Sends the first part of a Socks4a handshake, using the remote hostname and - * port specified in the previous call to connectToHost(). The message should - * be formatted as follows: - * - * 0x04 (socks version) - * 0x01 (connect) - * PORT (two bytes, most significant byte first) - * 0x00 0x00 0x00 0x01 (fake IP address: tells proxy to use SOCKS4a) - * 0x00 (empty username field) - * HOSTNAME (target hostname) - * 0x00 (marks the end of the hostname field) - */ -void -TorSslSocket::sendSocksHandshake(const QString &remoteHost, quint16 remotePort) -{ - QDataStream sock(this); - sock << (quint8)SOCKS_VERSION; - sock << (quint8)SOCKS_CONNECT; - sock << (quint16)remotePort; - sock << (quint32)SOCKS_FAKE_IP; - sock << (quint8)0; - sock.writeRawData(qPrintable(remoteHost), remoteHost.length()); - sock << (quint8)0; -} - -/** Handles the second half of the handshake, received from the SOCKS - * proxy server. The response should be formatted as follows: - * - * 0x00 (response version) - * STATUS (0x5A means success; other values mean failure) - * PORT (not set) - * ADDRESS (not set) - */ -void -TorSslSocket::onHandshakeResponse() -{ - QByteArray response; - if (bytesAvailable() >= SOCKS_RESPONSE_LEN) { - /* We've received our response, so stop waiting for it. */ - QObject::disconnect(this, SIGNAL(readyRead()), - this, SLOT(onHandshakeResponse())); - - /* Read the 8-byte response off the socket. */ - response = read(SOCKS_RESPONSE_LEN); - - /* Check to make sure we got a good response from the proxy. */ - if ((uchar)response[0] == (uchar)SOCKS_RESPONSE_VERSION && - (uchar)response[1] == (uchar)SOCKS_CONNECT_STATUS_OK) { - if (_encrypted) { - /* Connection status was okay, so start client encryption. */ - /* We first need to set the peer name to the intended remote host, - * otherwise Qt will use the proxy (e.g., 127.0.0.1) as the peer name - * when validating the server certificate. */ - setPeerName(_remoteHost); - startClientEncryption(); - } else { - /* Caller wanted an unencrypted, unauthenticated, uncool conn. */ - emit connectedToRemoteHost(); - } - } else { - /* Remote connection failed, so close the connection to the proxy. */ - disconnectFromHost(); - } - } -} - diff -Nru vidalia-0.1.13/src/common/TorSslSocket.cpp vidalia-0.2.8/src/common/TorSslSocket.cpp --- vidalia-0.1.13/src/common/TorSslSocket.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/common/TorSslSocket.cpp 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,160 @@ +/* +** 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.vidalia-project.net/. 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 TorSslSocket.cpp +** \version $Id: /local/vidalia/trunk/src/util/torsocket.cpp 1564 2006-12-26T06:06:04.965088Z edmanm $ +** \brief A QSslSocket that makes encrypted requests over Tor +*/ + +#include "TorSslSocket.h" + +#include +#include + +#define SOCKS_VERSION 0x04 /**< SOCKS version. */ +#define SOCKS_CONNECT 0x01 /**< SOCKS connect command ID. */ +#define SOCKS_FAKE_IP 0x00000001 /**< Bogus IP. */ +#define SOCKS_RESPONSE_LEN 0x08 /**< SOCKS server response length. */ +#define SOCKS_RESPONSE_VERSION 0x00 /**< SOCKS server response version. */ +#define SOCKS_CONNECT_STATUS_OK 0x5A /**< SOCKS server response status. */ + + +/** Constructor. */ +TorSslSocket::TorSslSocket(const QHostAddress &socksAddr, + quint16 socksPort, QObject *parent) +: QSslSocket(parent), + _socksAddr(socksAddr), + _socksPort(socksPort) +{ + QObject::connect(this, SIGNAL(sslErrors(QList)), + this, SLOT(onSslErrors(QList))); + QObject::connect(this, SIGNAL(error(QAbstractSocket::SocketError)), + this, SLOT(onError(QAbstractSocket::SocketError))); + QObject::connect(this, SIGNAL(readyRead()), + this, SLOT(onHandshakeResponse())); + QObject::connect(this, SIGNAL(connected()), + this, SLOT(connectedToProxy())); + QObject::connect(this, SIGNAL(encrypted()), + this, SLOT(onEncrypted())); +} + +/** Connects to the specified hostname and port via Tor. */ +void +TorSslSocket::connectToRemoteHost(const QString &remoteHost, quint16 remotePort, + bool encrypted) +{ + _remoteHost = remoteHost; + _remotePort = remotePort; + _encrypted = encrypted; + QTcpSocket::connectToHost(_socksAddr, _socksPort); +} + +/** Called when a connection error has occurred. */ +void +TorSslSocket::onError(QAbstractSocket::SocketError error) +{ + Q_UNUSED(error); + emit socketError(errorString()); +} + +/** Called when one or more SSL errors occur on the socket. */ +void +TorSslSocket::onSslErrors(const QList &errors) +{ + QStringList errorStrings; + foreach (QSslError error, errors) { + errorStrings << "\"" + error.errorString() + "\""; + } + emit socketError(errorStrings.join(",")); +} + +/** Called when a connection has been established to the proxy host and starts + * a Socks4a handshake. */ +void +TorSslSocket::connectedToProxy() +{ + sendSocksHandshake(_remoteHost, _remotePort); +} + +/** Called when an encrypted connection has been established to the remote + * host. */ +void +TorSslSocket::onEncrypted() +{ + emit connectedToRemoteHost(); +} + +/** Sends the first part of a Socks4a handshake, using the remote hostname and + * port specified in the previous call to connectToHost(). The message should + * be formatted as follows: + * + * 0x04 (socks version) + * 0x01 (connect) + * PORT (two bytes, most significant byte first) + * 0x00 0x00 0x00 0x01 (fake IP address: tells proxy to use SOCKS4a) + * 0x00 (empty username field) + * HOSTNAME (target hostname) + * 0x00 (marks the end of the hostname field) + */ +void +TorSslSocket::sendSocksHandshake(const QString &remoteHost, quint16 remotePort) +{ + QDataStream sock(this); + sock << (quint8)SOCKS_VERSION; + sock << (quint8)SOCKS_CONNECT; + sock << (quint16)remotePort; + sock << (quint32)SOCKS_FAKE_IP; + sock << (quint8)0; + sock.writeRawData(qPrintable(remoteHost), remoteHost.length()); + sock << (quint8)0; +} + +/** Handles the second half of the handshake, received from the SOCKS + * proxy server. The response should be formatted as follows: + * + * 0x00 (response version) + * STATUS (0x5A means success; other values mean failure) + * PORT (not set) + * ADDRESS (not set) + */ +void +TorSslSocket::onHandshakeResponse() +{ + QByteArray response; + if (bytesAvailable() >= SOCKS_RESPONSE_LEN) { + /* We've received our response, so stop waiting for it. */ + QObject::disconnect(this, SIGNAL(readyRead()), + this, SLOT(onHandshakeResponse())); + + /* Read the 8-byte response off the socket. */ + response = read(SOCKS_RESPONSE_LEN); + + /* Check to make sure we got a good response from the proxy. */ + if ((uchar)response[0] == (uchar)SOCKS_RESPONSE_VERSION && + (uchar)response[1] == (uchar)SOCKS_CONNECT_STATUS_OK) { + if (_encrypted) { + /* Connection status was okay, so start client encryption. */ + /* We first need to set the peer name to the intended remote host, + * otherwise Qt will use the proxy (e.g., 127.0.0.1) as the peer name + * when validating the server certificate. */ + setPeerName(_remoteHost); + startClientEncryption(); + } else { + /* Caller wanted an unencrypted, unauthenticated, uncool conn. */ + emit connectedToRemoteHost(); + } + } else { + /* Remote connection failed, so close the connection to the proxy. */ + disconnectFromHost(); + } + } +} + diff -Nru vidalia-0.1.13/src/common/torsslsocket.h vidalia-0.2.8/src/common/torsslsocket.h --- vidalia-0.1.13/src/common/torsslsocket.h 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/common/torsslsocket.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,71 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 torsslsocket.h -** \version $Id: /local/vidalia/trunk/src/util/torsocket.h 1564 2006-12-26T06:06:04.965088Z edmanm $ -** \brief A QSslSocket that makes encrypted requests over Tor -*/ - -#ifndef _TORSSLSOCKET_H -#define _TORSSLSOCKET_H - -#include -#include - - -class TorSslSocket : public QSslSocket -{ - Q_OBJECT - -public: - /** Constructor. */ - TorSslSocket(const QHostAddress &socksAddr, - quint16 socksPort, QObject *parent = 0); - - /** Connects to the specified hostname and port via Tor. */ - void connectToRemoteHost(const QString &remoteHost, quint16 remotePort, - bool encrypted); - -signals: - /** Emitted when a connection has been established through Tor to the remote - * host specified in a prior call to connectToHost(). */ - void connectedToRemoteHost(); - /** Emitted when a connection error has occurred. */ - void socketError(QString errmsg); - -private slots: - /** Called when the socket is connected to the proxy and sends our - * half of a Socks4a handshake. */ - void connectedToProxy(); - /** Called when an encrypted connection has been established to the remote - * host. */ - void onEncrypted(); - /** Handles the server's response part of a Socks4a handshake. */ - void onHandshakeResponse(); - /** Called when a connection error has occurred. */ - void onError(QAbstractSocket::SocketError error); - /** Called when one or more SSL errors occur on the socket. */ - void onSslErrors(const QList &errors); - -private: - /** Sends the client part of a Socks4a handshake with a proxy server. */ - void sendSocksHandshake(const QString &remoteHost, quint16 remotePort); - - QHostAddress _socksAddr; /**< Address of Tor's SOCKS listener. */ - QString _remoteHost; /**< Remote hostname. */ - quint16 _socksPort; /**< Port of Tor's SOCKS listener. */ - quint16 _remotePort; /**< Remote host port. */ - bool _encrypted; /**< Set to true if the connection to the remote - host should be encrypted. */ -}; - -#endif - diff -Nru vidalia-0.1.13/src/common/TorSslSocket.h vidalia-0.2.8/src/common/TorSslSocket.h --- vidalia-0.1.13/src/common/TorSslSocket.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/common/TorSslSocket.h 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,71 @@ +/* +** 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.vidalia-project.net/. 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 TorSslSocket.h +** \version $Id: /local/vidalia/trunk/src/util/torsocket.h 1564 2006-12-26T06:06:04.965088Z edmanm $ +** \brief A QSslSocket that makes encrypted requests over Tor +*/ + +#ifndef _TORSSLSOCKET_H +#define _TORSSLSOCKET_H + +#include +#include + + +class TorSslSocket : public QSslSocket +{ + Q_OBJECT + +public: + /** Constructor. */ + TorSslSocket(const QHostAddress &socksAddr, + quint16 socksPort, QObject *parent = 0); + + /** Connects to the specified hostname and port via Tor. */ + void connectToRemoteHost(const QString &remoteHost, quint16 remotePort, + bool encrypted); + +signals: + /** Emitted when a connection has been established through Tor to the remote + * host specified in a prior call to connectToHost(). */ + void connectedToRemoteHost(); + /** Emitted when a connection error has occurred. */ + void socketError(QString errmsg); + +private slots: + /** Called when the socket is connected to the proxy and sends our + * half of a Socks4a handshake. */ + void connectedToProxy(); + /** Called when an encrypted connection has been established to the remote + * host. */ + void onEncrypted(); + /** Handles the server's response part of a Socks4a handshake. */ + void onHandshakeResponse(); + /** Called when a connection error has occurred. */ + void onError(QAbstractSocket::SocketError error); + /** Called when one or more SSL errors occur on the socket. */ + void onSslErrors(const QList &errors); + +private: + /** Sends the client part of a Socks4a handshake with a proxy server. */ + void sendSocksHandshake(const QString &remoteHost, quint16 remotePort); + + QHostAddress _socksAddr; /**< Address of Tor's SOCKS listener. */ + QString _remoteHost; /**< Remote hostname. */ + quint16 _socksPort; /**< Port of Tor's SOCKS listener. */ + quint16 _remotePort; /**< Remote host port. */ + bool _encrypted; /**< Set to true if the connection to the remote + host should be encrypted. */ +}; + +#endif + diff -Nru vidalia-0.1.13/src/common/win32.cpp vidalia-0.2.8/src/common/win32.cpp --- vidalia-0.1.13/src/common/win32.cpp 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/common/win32.cpp 2009-06-01 08:00:35.000000000 +0100 @@ -10,17 +10,19 @@ /* ** \file win32.cpp -** \version $Id: win32.cpp 3527 2009-02-16 23:28:41Z sjmurdoch $ +** \version $Id: win32.cpp 3810 2009-06-01 07:00:35Z edmanm $ ** \brief Win32-specific functions */ #include "win32.h" -#include -#include + #include #include #include +#include +#include +# #if defined(UNICODE) /* Force the ascii verisons of these functions, so we can run on Win98. We * don't pass any Unicode strings to these functions anyway. */ @@ -153,7 +155,8 @@ /** * Callback for EnumThreadWindows which sends the WM_QUIT message */ -BOOL CALLBACK quitWindowCallback(HWND hwnd, LPARAM targetPID) +BOOL CALLBACK +quitWindowCallback(HWND hwnd, LPARAM targetPID) { DWORD hwndPID = 0; @@ -162,6 +165,7 @@ GetWindowThreadProcessId(hwnd, &hwndPID); if (hwndPID == (DWORD)targetPID) PostMessage(hwnd, WM_QUIT, 0, (LPARAM)NULL); + return TRUE; } /** diff -Nru vidalia-0.1.13/src/common/win32.h vidalia-0.2.8/src/common/win32.h --- vidalia-0.1.13/src/common/win32.h 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/common/win32.h 2009-04-28 21:28:01.000000000 +0100 @@ -10,18 +10,19 @@ /* ** \file win32.h -** \version $Id: win32.h 3527 2009-02-16 23:28:41Z sjmurdoch $ +** \version $Id: win32.h 3735 2009-04-28 20:28:01Z edmanm $ ** \brief Win32-specific functions */ #ifndef _WIN32_H #define _WIN32_H -#define WIN32_LEAN_AND_MEAN -#include #include #include +#define WIN32_LEAN_AND_MEAN +#include + /** Retrieves the location of the user's %PROGRAMFILES% folder. */ QString win32_program_files_folder(); diff -Nru vidalia-0.1.13/src/common/zlibbytearray.cpp vidalia-0.2.8/src/common/zlibbytearray.cpp --- vidalia-0.1.13/src/common/zlibbytearray.cpp 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/common/zlibbytearray.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,382 +0,0 @@ -/* -** 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.vidalia-project.net/. No part of Vidalia, including this file, -** may be copied, modified, propagated, or distributed except according to the -** terms described in the LICENSE file. -** -** * * * -** -** Zlib support in this class is derived from Tor's torgzip.[ch]. -** Tor is distributed under this license: -** -** Copyright (c) 2001-2004, Roger Dingledine -** Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** -** * Redistributions in binary form must reproduce the above -** copyright notice, this list of conditions and the following disclaimer -** in the documentation and/or other materials provided with the -** distribution. -** -** * Neither the names of the copyright owners nor the names of its -** contributors may be used to endorse or promote products derived from -** this software without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* -** \file zlibbytearray.cpp -** \version $Id: zlibbytearray.cpp 2444 2008-03-23 04:23:08Z edmanm $ -** \brief Wrapper around QByteArray that adds compression capabilities -*/ - -#include - -#include "config.h" -#ifdef HAVE_LIMITS_H -#include -#elif HAVE_SYS_LIMITS_H -#include -#endif - -/* The following check for UINT_MAX is derived from Tor's torint.h. See - * the top of this file for details on Tor's license. */ -#ifndef UINT_MAX -#if (SIZEOF_INT == 2) -#define UINT_MAX 0xffffu -#elif (SIZEOF_INT == 4) -#define UINT_MAX 0xffffffffu -#elif (SIZEOF_INT == 8) -#define UINT_MAX 0xffffffffffffffffu -#else -#error "Your platform uses a sizeof(int) that we don't understand." -#endif -#endif - -#include "zlib.h" -#include "zlibbytearray.h" - - -/** Constructor */ -ZlibByteArray::ZlibByteArray(QByteArray data) -: QByteArray(data) -{ -} - -/** Return the 'bits' value to tell zlib to use method.*/ -int -ZlibByteArray::methodBits(CompressionMethod method) -{ - /* Bits+16 means "use gzip" in zlib >= 1.2 */ - return (method == Gzip ? 15+16 : 15); -} - -/** Returns a string description of method. */ -QString -ZlibByteArray::methodString(CompressionMethod method) -{ - switch (method) { - case None: return "None"; - case Zlib: return "Zlib"; - case Gzip: return "Gzip"; - default: return "Unknown"; - } -} - -/** Returns true if the Zlib compression library is available and usable. */ -bool -ZlibByteArray::isZlibAvailable() -{ - static int isZlibAvailable = -1; - if (isZlibAvailable >= 0) - return isZlibAvailable; - - /* From zlib.h: - * "The application can compare zlibVersion and ZLIB_VERSION for consistency. - * If the first character differs, the library code actually used is - * not compatible with the zlib.h header file used by the application." */ - QString libVersion(zlibVersion()); - QString headerVersion(ZLIB_VERSION); - if (libVersion.isEmpty() || headerVersion.isEmpty() || - libVersion.at(0) != headerVersion.at(0)) - isZlibAvailable = 0; - else - isZlibAvailable = 1; - - return isZlibAvailable; -} - -/** Returns true iff we support gzip-based compression. Otherwise, we need to - * use zlib. */ -bool -ZlibByteArray::isGzipSupported() -{ - static int isGzipSupported = -1; - if (isGzipSupported >= 0) - return isGzipSupported; - - QString version(zlibVersion()); - if (version.startsWith("0.") || - version.startsWith("1.0") || - version.startsWith("1.1")) - isGzipSupported = 0; - else - isGzipSupported = 1; - - return isGzipSupported; -} - -/** Compresses the current contents of this object using method. - * Returns the compressed data if successful. If an error occurs, this will - * return an empty QByteArray and set the optional errmsg to a string - * describing the failure. */ -QByteArray -ZlibByteArray::compress(const CompressionMethod method, - QString *errmsg) const -{ - return compress(QByteArray(data()), method, errmsg); -} - -/** Compresses in using method. Returns the compressed data - * if successful. If an error occurs, this will return an empty QByteArray and - * set the optional errmsg to a string describing the failure. */ -QByteArray -ZlibByteArray::compress(const QByteArray in, - const CompressionMethod method, - QString *errmsg) -{ - QByteArray out; - QString errorstr; - struct z_stream_s *stream = NULL; - size_t out_size; - size_t out_len; - size_t in_len = in.length(); - off_t offset; - - if (method == None) - return in; - if (method == Gzip && !isGzipSupported()) { - /* Old zlib versions don't support gzip in deflateInit2 */ - if (errmsg) - *errmsg = QString("Gzip not supported with zlib %1") - .arg(ZLIB_VERSION); - return QByteArray(); - } - - stream = new struct z_stream_s; - stream->zalloc = Z_NULL; - stream->zfree = Z_NULL; - stream->opaque = NULL; - stream->next_in = (unsigned char*)in.data(); - stream->avail_in = in_len; - - if (deflateInit2(stream, Z_BEST_COMPRESSION, Z_DEFLATED, - methodBits(method), - 8, Z_DEFAULT_STRATEGY) != Z_OK) { - errorstr = QString("Error from deflateInit2: %1") - .arg(stream->msg ? stream->msg : ""); - goto err; - } - - /* Guess 50% compression. */ - out_size = in_len / 2; - if (out_size < 1024) out_size = 1024; - - out.resize(out_size); - stream->next_out = (unsigned char*)out.data(); - stream->avail_out = out_size; - - while (1) { - switch (deflate(stream, Z_FINISH)) - { - case Z_STREAM_END: - goto done; - case Z_OK: - /* In case zlib doesn't work as I think .... */ - if (stream->avail_out >= stream->avail_in+16) - break; - case Z_BUF_ERROR: - offset = stream->next_out - ((unsigned char*)out.data()); - out_size *= 2; - out.resize(out_size); - stream->next_out = (unsigned char*)(out.data() + offset); - if (out_size - offset > UINT_MAX) { - errorstr = - "Ran over unsigned int limit of zlib while uncompressing"; - goto err; - } - stream->avail_out = (unsigned int)(out_size - offset); - break; - default: - errorstr = QString("%1 compression didn't finish: %2") - .arg(methodString(method)) - .arg(stream->msg ? stream->msg : ""); - goto err; - } - } -done: - out_len = stream->total_out; - if (deflateEnd(stream)!=Z_OK) { - errorstr = "Error freeing zlib structures"; - goto err; - } - out.resize(out_len); - delete stream; - return out; -err: - if (stream) { - deflateEnd(stream); - delete stream; - } - if (errmsg) - *errmsg = errorstr; - return QByteArray(); -} - -/** Uncompresses the current contents of this object using method. - * Returns the uncompressed data if successful. If an error occurs, this will - * return an empty QByteArray and set the optional errmsg to a string - * describing the failure. */ -QByteArray -ZlibByteArray::uncompress(const CompressionMethod method, - QString *errmsg) const -{ - return uncompress(QByteArray(data()), method, errmsg); -} - -/** Uncompresses in using method. Returns the uncompressed data - * if successful. If an error occurs, this will return an empty QByteArray and - * set the optional errmsg to a string describing the failure. */ -QByteArray -ZlibByteArray::uncompress(const QByteArray in, - const CompressionMethod method, - QString *errmsg) -{ - QByteArray out; - QString errorstr; - struct z_stream_s *stream = NULL; - size_t out_size; - size_t out_len; - size_t in_len = in.length(); - off_t offset; - int r; - - if (method == None) - return in; - if (method == Gzip && !isGzipSupported()) { - /* Old zlib versions don't support gzip in inflateInit2 */ - if (errmsg) - *errmsg = QString("Gzip not supported with zlib %1") - .arg(ZLIB_VERSION); - return QByteArray(); - } - - stream = new struct z_stream_s; - stream->zalloc = Z_NULL; - stream->zfree = Z_NULL; - stream->opaque = NULL; - stream->msg = NULL; - stream->next_in = (unsigned char*) in.data(); - stream->avail_in = in_len; - - if (inflateInit2(stream, - methodBits(method)) != Z_OK) { - errorstr = QString("Error from inflateInit2: %1") - .arg(stream->msg ? stream->msg : ""); - goto err; - } - - out_size = in_len * 2; /* guess 50% compression. */ - if (out_size < 1024) out_size = 1024; - - out.resize(out_size); - stream->next_out = (unsigned char*)out.data(); - stream->avail_out = out_size; - - while (1) { - switch (inflate(stream, Z_FINISH)) - { - case Z_STREAM_END: - if (stream->avail_in == 0) - goto done; - /* There may be more compressed data here. */ - if ((r = inflateEnd(stream)) != Z_OK) { - errorstr = "Error freeing zlib structures"; - goto err; - } - if (inflateInit2(stream, methodBits(method)) != Z_OK) { - errorstr = QString("Error from second inflateInit2: %1") - .arg(stream->msg ? stream->msg : ""); - goto err; - } - break; - case Z_OK: - if (stream->avail_in == 0) - goto done; - /* In case zlib doesn't work as I think.... */ - if (stream->avail_out >= stream->avail_in+16) - break; - case Z_BUF_ERROR: - if (stream->avail_out > 0) { - errorstr = QString("Possible truncated or corrupt %1 data") - .arg(methodString(method)); - goto err; - } - offset = stream->next_out - (unsigned char*)out.data(); - out_size *= 2; - out.resize(out_size); - stream->next_out = (unsigned char*)(out.data() + offset); - if (out_size - offset > UINT_MAX) { - errorstr = - "Ran over unsigned int limit of zlib while uncompressing"; - goto err; - } - stream->avail_out = (unsigned int)(out_size - offset); - break; - default: - errorstr = QString("%1 decompression returned an error: %2") - .arg(methodString(method)) - .arg(stream->msg ? stream->msg : ""); - goto err; - } - } -done: - out_len = stream->next_out - (unsigned char*)out.data(); - r = inflateEnd(stream); - delete stream; - if (r != Z_OK) { - errorstr = "Error freeing zlib structure"; - goto err; - } - out.resize(out_len); - return out; -err: - if (stream) { - inflateEnd(stream); - delete stream; - } - if (errmsg) - *errmsg = errorstr; - return QByteArray(); -} - diff -Nru vidalia-0.1.13/src/common/ZlibByteArray.cpp vidalia-0.2.8/src/common/ZlibByteArray.cpp --- vidalia-0.1.13/src/common/ZlibByteArray.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/common/ZlibByteArray.cpp 2010-01-22 18:49:00.000000000 +0000 @@ -0,0 +1,383 @@ +/* +** 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.vidalia-project.net/. No part of Vidalia, including this file, +** may be copied, modified, propagated, or distributed except according to the +** terms described in the LICENSE file. +** +** * * * +** +** Zlib support in this class is derived from Tor's torgzip.[ch]. +** Tor is distributed under this license: +** +** Copyright (c) 2001-2004, Roger Dingledine +** Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** +** * Redistributions in binary form must reproduce the above +** copyright notice, this list of conditions and the following disclaimer +** in the documentation and/or other materials provided with the +** distribution. +** +** * Neither the names of the copyright owners nor the names of its +** contributors may be used to endorse or promote products derived from +** this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/* +** \file ZlibByteArray.cpp +** \version $Id: ZlibByteArray.cpp 4203 2010-01-22 18:49:00Z edmanm $ +** \brief Wrapper around QByteArray that adds compression capabilities +*/ + +#include "config.h" + +#include + +#ifdef HAVE_LIMITS_H +#include +#elif defined(HAVE_SYS_LIMITS_H) +#include +#endif + +/* The following check for UINT_MAX is derived from Tor's torint.h. See + * the top of this file for details on Tor's license. */ +#ifndef UINT_MAX +#if (SIZEOF_INT == 2) +#define UINT_MAX 0xffffu +#elif (SIZEOF_INT == 4) +#define UINT_MAX 0xffffffffu +#elif (SIZEOF_INT == 8) +#define UINT_MAX 0xffffffffffffffffu +#else +#error "Your platform uses a sizeof(int) that we don't understand." +#endif +#endif + +#include "zlib.h" +#include + + +/** Constructor */ +ZlibByteArray::ZlibByteArray(QByteArray data) +: QByteArray(data) +{ +} + +/** Return the 'bits' value to tell zlib to use method.*/ +int +ZlibByteArray::methodBits(CompressionMethod method) +{ + /* Bits+16 means "use gzip" in zlib >= 1.2 */ + return (method == Gzip ? 15+16 : 15); +} + +/** Returns a string description of method. */ +QString +ZlibByteArray::methodString(CompressionMethod method) +{ + switch (method) { + case None: return "None"; + case Zlib: return "Zlib"; + case Gzip: return "Gzip"; + default: return "Unknown"; + } +} + +/** Returns true if the Zlib compression library is available and usable. */ +bool +ZlibByteArray::isZlibAvailable() +{ + static int isZlibAvailable = -1; + if (isZlibAvailable >= 0) + return isZlibAvailable; + + /* From zlib.h: + * "The application can compare zlibVersion and ZLIB_VERSION for consistency. + * If the first character differs, the library code actually used is + * not compatible with the zlib.h header file used by the application." */ + QString libVersion(zlibVersion()); + QString headerVersion(ZLIB_VERSION); + if (libVersion.isEmpty() || headerVersion.isEmpty() || + libVersion.at(0) != headerVersion.at(0)) + isZlibAvailable = 0; + else + isZlibAvailable = 1; + + return isZlibAvailable; +} + +/** Returns true iff we support gzip-based compression. Otherwise, we need to + * use zlib. */ +bool +ZlibByteArray::isGzipSupported() +{ + static int isGzipSupported = -1; + if (isGzipSupported >= 0) + return isGzipSupported; + + QString version(zlibVersion()); + if (version.startsWith("0.") || + version.startsWith("1.0") || + version.startsWith("1.1")) + isGzipSupported = 0; + else + isGzipSupported = 1; + + return isGzipSupported; +} + +/** Compresses the current contents of this object using method. + * Returns the compressed data if successful. If an error occurs, this will + * return an empty QByteArray and set the optional errmsg to a string + * describing the failure. */ +QByteArray +ZlibByteArray::compress(const CompressionMethod method, + QString *errmsg) const +{ + return compress(QByteArray(data()), method, errmsg); +} + +/** Compresses in using method. Returns the compressed data + * if successful. If an error occurs, this will return an empty QByteArray and + * set the optional errmsg to a string describing the failure. */ +QByteArray +ZlibByteArray::compress(const QByteArray in, + const CompressionMethod method, + QString *errmsg) +{ + QByteArray out; + QString errorstr; + struct z_stream_s *stream = NULL; + size_t out_size; + size_t out_len; + size_t in_len = in.length(); + off_t offset; + + if (method == None) + return in; + if (method == Gzip && !isGzipSupported()) { + /* Old zlib versions don't support gzip in deflateInit2 */ + if (errmsg) + *errmsg = QString("Gzip not supported with zlib %1") + .arg(ZLIB_VERSION); + return QByteArray(); + } + + stream = new struct z_stream_s; + stream->zalloc = Z_NULL; + stream->zfree = Z_NULL; + stream->opaque = NULL; + stream->next_in = (unsigned char*)in.data(); + stream->avail_in = in_len; + + if (deflateInit2(stream, Z_BEST_COMPRESSION, Z_DEFLATED, + methodBits(method), + 8, Z_DEFAULT_STRATEGY) != Z_OK) { + errorstr = QString("Error from deflateInit2: %1") + .arg(stream->msg ? stream->msg : ""); + goto err; + } + + /* Guess 50% compression. */ + out_size = in_len / 2; + if (out_size < 1024) out_size = 1024; + + out.resize(out_size); + stream->next_out = (unsigned char*)out.data(); + stream->avail_out = out_size; + + while (1) { + switch (deflate(stream, Z_FINISH)) + { + case Z_STREAM_END: + goto done; + case Z_OK: + /* In case zlib doesn't work as I think .... */ + if (stream->avail_out >= stream->avail_in+16) + break; + case Z_BUF_ERROR: + offset = stream->next_out - ((unsigned char*)out.data()); + out_size *= 2; + out.resize(out_size); + stream->next_out = (unsigned char*)(out.data() + offset); + if (out_size - offset > UINT_MAX) { + errorstr = + "Ran over unsigned int limit of zlib while uncompressing"; + goto err; + } + stream->avail_out = (unsigned int)(out_size - offset); + break; + default: + errorstr = QString("%1 compression didn't finish: %2") + .arg(methodString(method)) + .arg(stream->msg ? stream->msg : ""); + goto err; + } + } +done: + out_len = stream->total_out; + if (deflateEnd(stream)!=Z_OK) { + errorstr = "Error freeing zlib structures"; + goto err; + } + out.resize(out_len); + delete stream; + return out; +err: + if (stream) { + deflateEnd(stream); + delete stream; + } + if (errmsg) + *errmsg = errorstr; + return QByteArray(); +} + +/** Uncompresses the current contents of this object using method. + * Returns the uncompressed data if successful. If an error occurs, this will + * return an empty QByteArray and set the optional errmsg to a string + * describing the failure. */ +QByteArray +ZlibByteArray::uncompress(const CompressionMethod method, + QString *errmsg) const +{ + return uncompress(QByteArray(data()), method, errmsg); +} + +/** Uncompresses in using method. Returns the uncompressed data + * if successful. If an error occurs, this will return an empty QByteArray and + * set the optional errmsg to a string describing the failure. */ +QByteArray +ZlibByteArray::uncompress(const QByteArray in, + const CompressionMethod method, + QString *errmsg) +{ + QByteArray out; + QString errorstr; + struct z_stream_s *stream = NULL; + size_t out_size; + size_t out_len; + size_t in_len = in.length(); + off_t offset; + int r; + + if (method == None) + return in; + if (method == Gzip && !isGzipSupported()) { + /* Old zlib versions don't support gzip in inflateInit2 */ + if (errmsg) + *errmsg = QString("Gzip not supported with zlib %1") + .arg(ZLIB_VERSION); + return QByteArray(); + } + + stream = new struct z_stream_s; + stream->zalloc = Z_NULL; + stream->zfree = Z_NULL; + stream->opaque = NULL; + stream->msg = NULL; + stream->next_in = (unsigned char*) in.data(); + stream->avail_in = in_len; + + if (inflateInit2(stream, + methodBits(method)) != Z_OK) { + errorstr = QString("Error from inflateInit2: %1") + .arg(stream->msg ? stream->msg : ""); + goto err; + } + + out_size = in_len * 2; /* guess 50% compression. */ + if (out_size < 1024) out_size = 1024; + + out.resize(out_size); + stream->next_out = (unsigned char*)out.data(); + stream->avail_out = out_size; + + while (1) { + switch (inflate(stream, Z_FINISH)) + { + case Z_STREAM_END: + if (stream->avail_in == 0) + goto done; + /* There may be more compressed data here. */ + if ((r = inflateEnd(stream)) != Z_OK) { + errorstr = "Error freeing zlib structures"; + goto err; + } + if (inflateInit2(stream, methodBits(method)) != Z_OK) { + errorstr = QString("Error from second inflateInit2: %1") + .arg(stream->msg ? stream->msg : ""); + goto err; + } + break; + case Z_OK: + if (stream->avail_in == 0) + goto done; + /* In case zlib doesn't work as I think.... */ + if (stream->avail_out >= stream->avail_in+16) + break; + case Z_BUF_ERROR: + if (stream->avail_out > 0) { + errorstr = QString("Possible truncated or corrupt %1 data") + .arg(methodString(method)); + goto err; + } + offset = stream->next_out - (unsigned char*)out.data(); + out_size *= 2; + out.resize(out_size); + stream->next_out = (unsigned char*)(out.data() + offset); + if (out_size - offset > UINT_MAX) { + errorstr = + "Ran over unsigned int limit of zlib while uncompressing"; + goto err; + } + stream->avail_out = (unsigned int)(out_size - offset); + break; + default: + errorstr = QString("%1 decompression returned an error: %2") + .arg(methodString(method)) + .arg(stream->msg ? stream->msg : ""); + goto err; + } + } +done: + out_len = stream->next_out - (unsigned char*)out.data(); + r = inflateEnd(stream); + delete stream; + if (r != Z_OK) { + errorstr = "Error freeing zlib structure"; + goto err; + } + out.resize(out_len); + return out; +err: + if (stream) { + inflateEnd(stream); + delete stream; + } + if (errmsg) + *errmsg = errorstr; + return QByteArray(); +} + diff -Nru vidalia-0.1.13/src/common/zlibbytearray.h vidalia-0.2.8/src/common/zlibbytearray.h --- vidalia-0.1.13/src/common/zlibbytearray.h 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/common/zlibbytearray.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,102 +0,0 @@ -/* -** 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.vidalia-project.net/. No part of Vidalia, including this file, -** may be copied, modified, propagated, or distributed except according to the -** terms described in the LICENSE file. -** -** * * * -** -** Zlib support in this class is derived from Tor's torgzip.[ch]. -** Tor is distributed under this license: -** -** Copyright (c) 2001-2004, Roger Dingledine -** Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** -** * Redistributions in binary form must reproduce the above -** copyright notice, this list of conditions and the following disclaimer -** in the documentation and/or other materials provided with the -** distribution. -** -** * Neither the names of the copyright owners nor the names of its -** contributors may be used to endorse or promote products derived from -** this software without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -/* -** \file zlibbytearray.h -** \version $Id: zlibbytearray.h 2362 2008-02-29 04:30:11Z edmanm $ -** \brief Wrapper around QByteArray that adds compression capabilities -*/ - -#ifndef _ZLIBBYTEARRAY_H -#define _ZLIBBYTEARRAY_H - -#include -#include - - -class ZlibByteArray : public QByteArray -{ -public: - /** Available compression methods. */ - enum CompressionMethod { - None, /**< No compression method. */ - Gzip, /**< Gzip compression method. */ - Zlib /**< Zlib compression method. */ - }; - - /** Constructor. */ - ZlibByteArray(QByteArray data); - - /** Compresses the current contents of this object using method. */ - QByteArray compress(const CompressionMethod method = Zlib, - QString *errmsg = 0) const; - /** Compreses the contents of in using method. */ - static QByteArray compress(const QByteArray in, - const CompressionMethod method = Zlib, - QString *errmsg = 0); - /** Uncompresses the current contents of this object using method. */ - QByteArray uncompress(CompressionMethod method = Zlib, - QString *errmsg = 0) const; - /** Uncompresses the contents of in using method. */ - static QByteArray uncompress(const QByteArray in, - const CompressionMethod method = Zlib, - QString *errmsg = 0); - - /** Returns true if the Zlib compression library is available and usable. */ - static bool isZlibAvailable(); - /** Returns true iff we support gzip-based compression. Otherwise, we need to - * use zlib. */ - static bool isGzipSupported(); - -private: - /** Return the 'bits' value to tell zlib to use method.*/ - static int methodBits(CompressionMethod method); - /** Returns a string description of method. */ - static QString methodString(CompressionMethod method); -}; - -#endif - diff -Nru vidalia-0.1.13/src/common/ZlibByteArray.h vidalia-0.2.8/src/common/ZlibByteArray.h --- vidalia-0.1.13/src/common/ZlibByteArray.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/common/ZlibByteArray.h 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,102 @@ +/* +** 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.vidalia-project.net/. No part of Vidalia, including this file, +** may be copied, modified, propagated, or distributed except according to the +** terms described in the LICENSE file. +** +** * * * +** +** Zlib support in this class is derived from Tor's torgzip.[ch]. +** Tor is distributed under this license: +** +** Copyright (c) 2001-2004, Roger Dingledine +** Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** +** * Redistributions in binary form must reproduce the above +** copyright notice, this list of conditions and the following disclaimer +** in the documentation and/or other materials provided with the +** distribution. +** +** * Neither the names of the copyright owners nor the names of its +** contributors may be used to endorse or promote products derived from +** this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/* +** \file ZlibByteArray.h +** \version $Id: ZlibByteArray.h 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Wrapper around QByteArray that adds compression capabilities +*/ + +#ifndef _ZLIBBYTEARRAY_H +#define _ZLIBBYTEARRAY_H + +#include +#include + + +class ZlibByteArray : public QByteArray +{ +public: + /** Available compression methods. */ + enum CompressionMethod { + None, /**< No compression method. */ + Gzip, /**< Gzip compression method. */ + Zlib /**< Zlib compression method. */ + }; + + /** Constructor. */ + ZlibByteArray(QByteArray data); + + /** Compresses the current contents of this object using method. */ + QByteArray compress(const CompressionMethod method = Zlib, + QString *errmsg = 0) const; + /** Compreses the contents of in using method. */ + static QByteArray compress(const QByteArray in, + const CompressionMethod method = Zlib, + QString *errmsg = 0); + /** Uncompresses the current contents of this object using method. */ + QByteArray uncompress(CompressionMethod method = Zlib, + QString *errmsg = 0) const; + /** Uncompresses the contents of in using method. */ + static QByteArray uncompress(const QByteArray in, + const CompressionMethod method = Zlib, + QString *errmsg = 0); + + /** Returns true if the Zlib compression library is available and usable. */ + static bool isZlibAvailable(); + /** Returns true iff we support gzip-based compression. Otherwise, we need to + * use zlib. */ + static bool isGzipSupported(); + +private: + /** Return the 'bits' value to tell zlib to use method.*/ + static int methodBits(CompressionMethod method); + /** Returns a string description of method. */ + static QString methodString(CompressionMethod method); +}; + +#endif + diff -Nru vidalia-0.1.13/src/crashreporter/CMakeLists.txt vidalia-0.2.8/src/crashreporter/CMakeLists.txt --- vidalia-0.1.13/src/crashreporter/CMakeLists.txt 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/crashreporter/CMakeLists.txt 2009-06-25 05:14:36.000000000 +0100 @@ -0,0 +1,73 @@ +## +## $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.vidalia-project.net/. No part of Vidalia, including this file, +## may be copied, modified, propagated, or distributed except according to +## the terms described in the LICENSE file. +## + +include_directories( + ${CMAKE_CURRENT_BINARY_DIR} + ${BREAKPAD_INCLUDE_DIR} +) + +## Add the application source files +set(crashreporter_SRCS + main.cpp + CrashReportDialog.cpp + CrashReportUploader.cpp + UploadProgressDialog.cpp +) +qt4_wrap_cpp(crashreporter_SRCS + CrashReportDialog.h + CrashReportUploader.h + UploadProgressDialog.h +) +qt4_wrap_ui(crashreporter_SRCS + CrashReportDialog.ui + UploadProgressDialog.ui +) +qt4_add_resources(crashreporter_SRCS + res/CrashReporter.qrc +) +if (MSVC) + configure_file( + res/CrashReporter.rc.in + ${CMAKE_CURRENT_BINARY_DIR}/CrashReporter.rc + ) + set(crashreporter_SRCS + ${crashreporter_SRCS} + ${CMAKE_CURRENT_BINARY_DIR}/CrashReporter.rc + ) +endif(MSVC) + +## Create the crashreporter executable +if (WIN32) + add_executable(crashreporter WIN32 ${crashreporter_SRCS}) +else(WIN32) + add_executable(crashreporter ${crashreporter_SRCS}) +endif(WIN32) + +## Link the crash reporter application with the Qt and Breakpad libraries +target_link_libraries(crashreporter + ${QT_QTCORE_LIBRARY} + ${QT_QTGUI_LIBRARY} + ${QT_QTNETWORK_LIBRARY} + common +) +if (WIN32) + target_link_libraries(crashreporter + ${QT_QTMAIN_LIBRARY} + ) +endif(WIN32) + +## Remember the location of the crash reporter binary so we can use it in +## the Windows packaging scripts +get_target_property(CRASHREPORTER_EXECUTABLE crashreporter LOCATION_RelWithDebInfo) +set(VIDALIA_CRASHREPORTER_EXECUTABLE ${CRASHREPORTER_EXECUTABLE} + CACHE STRING "Location of Vidalia's crash reporting application." FORCE) + diff -Nru vidalia-0.1.13/src/crashreporter/CrashReportDialog.cpp vidalia-0.2.8/src/crashreporter/CrashReportDialog.cpp --- vidalia-0.1.13/src/crashreporter/CrashReportDialog.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/crashreporter/CrashReportDialog.cpp 2009-06-23 23:53:29.000000000 +0100 @@ -0,0 +1,129 @@ +/* +** 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.vidalia-project.net/. 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 CrashReportDialog.cpp +** \version $Id$ +** \brief Dialog that asks the user whether they would like to +** submit the crash report, along with optional additional details +** about what they were doing at the time of the crash. +*/ + +#include "CrashReportDialog.h" +#include "CrashReportUploader.h" +#include "UploadProgressDialog.h" + +#include "stringutil.h" + +#include +#include +#include +#include + + +CrashReportDialog::CrashReportDialog(QWidget *parent) + : QDialog(parent) +{ + ui.setupUi(this); + + /* Tweak the text displayed on the buttons at the bottom of the dialog */ + QPushButton *btn; + btn = ui.buttonBox->button(QDialogButtonBox::Ok); + btn->setText(tr("Restart Vidalia")); + + btn = ui.buttonBox->button(QDialogButtonBox::Cancel); + btn->setText(tr("Don't Restart")); +} + +void +CrashReportDialog::setCrashAnnotations(const QHash &annotations) +{ + _annotations = annotations; +} + +void +CrashReportDialog::setMinidump(const QString &id, const QByteArray &minidump) +{ + _minidump = minidump; + _minidumpId = id; +} + +void +CrashReportDialog::submitCrashReport() +{ + CrashReportUploader *uploader = new CrashReportUploader(); + UploadProgressDialog *progressDialog = new UploadProgressDialog(this); + QMap parameters; + + connect(uploader, SIGNAL(statusChanged(QString)), + progressDialog, SLOT(setStatus(QString))); + connect(uploader, SIGNAL(uploadProgress(int, int)), + progressDialog, SLOT(setUploadProgress(int, int))); + connect(uploader, SIGNAL(uploadFinished()), + progressDialog, SLOT(accept())); + connect(uploader, SIGNAL(uploadFailed(QString)), + progressDialog, SLOT(uploadFailed(QString))); + + /* Set up the form fields that will be uploaded with the minidump */ + QString comments = ui.textDetails->toPlainText(); + if (! comments.isEmpty()) + parameters.insert("Comments", comments); + parameters.insert("ProductName", "Vidalia"); + parameters.insert("Vendor", "Vidalia"); + parameters.insert("Version", _annotations.value("BuildVersion")); + parameters.insert("CrashTime", _annotations.value("CrashTime")); + parameters.insert("StartupTime", _annotations.value("StartupTime")); + + /* Start the upload (returns immediately) */ + uploader->uploadMinidump(QUrl("https://crashes.vidalia-project.net/submit"), + _minidumpId, _minidump, parameters); + + /* Displays a modal progress dialog showing the progress of the upload. This + * will return when either the upload completes or the user hits "Cancel". */ + if (progressDialog->exec() == QDialog::Rejected) + uploader->cancel(); /* User clicked "Cancel" */ + + delete uploader; +} + +void +CrashReportDialog::accept() +{ + /* Upload the crash report, unless the user opted out */ + if (ui.chkSubmitCrashReport->isChecked()) + submitCrashReport(); + + /* Attempt to restart Vidalia with the saved arguments */ + QString exe = _annotations.value("RestartExecutable"); + QString args = _annotations.value("RestartExecutableArgs"); + QStringList argList = string_parse_arguments(args); + if (! QProcess::startDetached(exe, argList, QFileInfo(exe).absolutePath())) { + QMessageBox dlg(QMessageBox::Warning, tr("Unable to restart Vidalia"), + tr("We were unable to automatically restart Vidalia. " + "Please restart Vidalia manually."), + QMessageBox::Ok, this); + dlg.exec(); + } + + /* Close the dialog */ + QDialog::accept(); +} + +void +CrashReportDialog::reject() +{ + /* Upload the crash report, unless the user opted out */ + if (ui.chkSubmitCrashReport->isChecked()) + submitCrashReport(); + + /* Close this dialog without restarting Vidalia */ + QDialog::reject(); +} + diff -Nru vidalia-0.1.13/src/crashreporter/CrashReportDialog.h vidalia-0.2.8/src/crashreporter/CrashReportDialog.h --- vidalia-0.1.13/src/crashreporter/CrashReportDialog.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/crashreporter/CrashReportDialog.h 2009-06-23 23:53:29.000000000 +0100 @@ -0,0 +1,92 @@ +/* +** 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.vidalia-project.net/. 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 CrashReportDialog.h +** \version $Id$ +** \brief Dialog that asks the user whether they would like to +** submit the crash report, along with optional additional details +** about what they were doing at the time of the crash. +*/ + +#include "ui_CrashReportDialog.h" + +#include +#include + +class QString; + + +class CrashReportDialog : public QDialog +{ + Q_OBJECT + +public: + /** Default constructor. + */ + CrashReportDialog(QWidget *parent = 0); + + /** Sets the crash annotations key-value pairs associated with + * the generated minidump. + */ + void setCrashAnnotations(const QHash &annotations); + + /** Sets the minidump contents generated by the crashed + * applications exception handler. + */ + void setMinidump(const QString &id, const QByteArray &minidump); + + /** Uploads the generated minidump, user comments, and any additional + * crash annotations generated by the exception handler to the crash + * reporting server. + * \sa setMinidump() + * \sa setCrashAnnotations() + */ + void submitCrashReport(); + +public slots: + /** Called when the user clicks the "Restart Vidalia" button on the + * dialog. If the "Submit my crash report..." checkbox is checked, it + * will first attempt to submit the crash report. After that is complete, + * it will try to restart the Vidalia process with any arguments specified + * in the crash annotations file. + * \sa setCrashAnnotations() + */ + virtual void accept(); + + /** Called when the user clicks the "Don't Restart" button on the + * dialog. If the "Submit my crash report.." checkbox is checked, it + * will attempt to submit the crash report and then exit without + * restarting Vidalia. + */ + virtual void reject(); + +private: + /** Each minidump is given a randomly-generated GUID when it is created, + * which is used to form the minidump filename. This ID is also used by + * the crash reporting server when accepting and processing uploaded + * minidumps. + */ + QString _minidumpId; + + /** Contents of the generated minidump. + */ + QByteArray _minidump; + + /** Set of parsed key-value pairs generated by the crashed application's + * exception handler and written alongside the minidump. + */ + QHash _annotations; + + /** Qt Designer created object. + */ + Ui::CrashReportDialog ui; +}; + diff -Nru vidalia-0.1.13/src/crashreporter/CrashReportDialog.ui vidalia-0.2.8/src/crashreporter/CrashReportDialog.ui --- vidalia-0.1.13/src/crashreporter/CrashReportDialog.ui 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/crashreporter/CrashReportDialog.ui 2009-06-23 23:53:29.000000000 +0100 @@ -0,0 +1,156 @@ + + + CrashReportDialog + + + + 0 + 0 + 434 + 310 + + + + Submit a Crash Report + + + + :/images/32x32/tools-report-bug.png:/images/32x32/tools-report-bug.png + + + + + + + + + :/images/64x64/tools-report-bug.png + + + + + + + + 9 + 75 + true + + + + Vidalia encountered an error and needed to close + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + + + + + A crash report has been created that you can automatically send to the Vidalia developers to help identify and fix the problem. The submitted report does not contain any personally identifying information, but your connection to the crash reporting server may not be anonymous. + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + + + + + Qt::Horizontal + + + + + + + Please also describe what you were doing before the application crashed (optional): + + + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft + + + true + + + + + + + true + + + false + + + false + + + + + + + Send my crash report to the Vidalia developers + + + true + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + + + buttonBox + accepted() + CrashReportDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + CrashReportDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff -Nru vidalia-0.1.13/src/crashreporter/CrashReportUploader.cpp vidalia-0.2.8/src/crashreporter/CrashReportUploader.cpp --- vidalia-0.1.13/src/crashreporter/CrashReportUploader.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/crashreporter/CrashReportUploader.cpp 2009-06-23 23:53:29.000000000 +0100 @@ -0,0 +1,153 @@ +/* +** 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.vidalia-project.net/. 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 CrashReportUploader.cpp +** \version $Id$ +** \brief Uploads a minidump file and any extra information to a crash +** reporting server. +*/ + +#include "CrashReportUploader.h" + +#include +#include +#include +#include +#include +#include +#include +#include + + +CrashReportUploader::CrashReportUploader(QObject *parent) + : QObject(parent), + _requestId(-1) +{ + /* Clear the default CA certificate store and add the only one we want */ + QSslSocket::setDefaultCaCertificates(QList()); + QSslSocket::addDefaultCaCertificates(":/pki/gd-class2-root.crt"); + + /* Create the QHttp object used to talk to the crash reporting server */ + _http = new QHttp(this); + connect(_http, SIGNAL(stateChanged(int)), + this, SLOT(httpStateChanged(int))); + connect(_http, SIGNAL(requestFinished(int, bool)), + this, SLOT(httpRequestFinished(int, bool))); + connect(_http, SIGNAL(dataSendProgress(int, int)), + this, SIGNAL(uploadProgress(int, int))); + + /* Seed the lame PRNG we'll use to generate the multipart boundary marker */ + qsrand(QDateTime::currentDateTime().toTime_t()); +} + +void +CrashReportUploader::uploadMinidump(const QUrl &serverUrl, + const QString &minidumpId, + const QByteArray &minidump, + const QMap ¶meters) +{ + QByteArray body; + + /* Set the destination host. If it looks like the destination URL uses SSL, + * then we need to tell the QHttp object to use it as well. */ + if (! serverUrl.scheme().compare("https", Qt::CaseInsensitive)) { + _http->setHost(serverUrl.host(), QHttp::ConnectionModeHttps, + serverUrl.port(443)); + } else { + _http->setHost(serverUrl.host(), QHttp::ConnectionModeHttp, + serverUrl.port(80)); + } + + /* Set up the request header */ + QHttpRequestHeader header("POST", serverUrl.path()); + QString boundary = generateBoundaryMarker(); + header.setValue("Host", serverUrl.host()); + header.setContentType(QString("multipart/form-data; boundary=%1") + .arg(boundary)); + + /* Add all the key=value parameters to the request body */ + foreach (QString key, parameters.keys()) { + QString value = parameters.value(key); + if (! value.isEmpty()) { + body.append(QString("--%1\r\n").arg(boundary)); + body.append(QString("Content-Disposition: form-data; name=\"%1\"").arg(key)); + body.append("\r\n\r\n"); + body.append(value.toUtf8()); + body.append("\r\n"); + } + } + + /* Append the minidump contents */ + body.append(QString("--%1\r\n").arg(boundary)); + body.append("Content-Disposition: form-data; "); + body.append("name=\"upload_file_minidump\"; "); + body.append(QString("filename=\"%1\"\r\n").arg(minidumpId)); + body.append("Content-Type: application/octet-stream\r\n\r\n"); + body.append(minidump); + body.append(QString("\r\n--%1\r\n").arg(boundary)); + + /* Initiate the request and return the request ID */ + _requestId = _http->request(header, body); +} + +QString +CrashReportUploader::generateBoundaryMarker() const +{ + return QString("%1%2").arg((quint32)qrand(), 8, 16, QChar('0')) + .arg((quint32)qrand(), 8, 16, QChar('0')); +} + +void +CrashReportUploader::cancel() +{ + _http->abort(); +} + +void +CrashReportUploader::httpStateChanged(int state) +{ + switch (state) { + case QHttp::Connecting: + emit statusChanged(tr("Connecting...")); + break; + + case QHttp::Sending: + emit statusChanged(tr("Sending crash report...")); + break; + + case QHttp::Reading: + emit statusChanged(tr("Receiving response...")); + break; + + default: + break; + } +} + +void +CrashReportUploader::httpRequestFinished(int id, bool error) +{ + if (id != _requestId) + return; + + if (error) { + QString errorString = _http->errorString(); + emit uploadFailed(errorString); + } else { + QHttpResponseHeader response = _http->lastResponse(); + if (response.statusCode() == 200) + emit uploadFinished(); + else + emit uploadFailed(response.reasonPhrase()); + } + _http->close(); +} + diff -Nru vidalia-0.1.13/src/crashreporter/CrashReportUploader.h vidalia-0.2.8/src/crashreporter/CrashReportUploader.h --- vidalia-0.1.13/src/crashreporter/CrashReportUploader.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/crashreporter/CrashReportUploader.h 2009-06-23 23:53:29.000000000 +0100 @@ -0,0 +1,110 @@ +/* +** 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.vidalia-project.net/. 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 CrashReportUploader.h +** \version $Id$ +** \brief Uploads a minidump file and any extra information to a crash +** reporting server. +*/ + +#ifndef _CRASHREPORTUPLOADER_H +#define _CRASHREPORTUPLOADER_H + +#include +#include +#include + +class QUrl; +class QString; +class QByteArray; + + +class CrashReportUploader : public QObject +{ + Q_OBJECT + +public: + /** Default constructor. + */ + CrashReportUploader(QObject *parent = 0); + + /** Starts uploading minidump to serverUrl and returns + * immediately. minidumpId is the minidump GUID generated by + * the exception handler and used for the minidump's filename. The + * optional parameters can be used to pass additional form fields + * to the crash reporting server. + */ + void uploadMinidump(const QUrl &serverUrl, + const QString &minidumpId, + const QByteArray &minidump, + const QMap ¶meters); + +public slots: + /** Cancels a pending minidump upload. + */ + void cancel(); + +signals: + /** Emitted when the underlying QHttp object posts data to the server. + * done indicates how many bytes out of total + * have been sent so far. + */ + void uploadProgress(int done, int total); + + /** Emitted when the status of the POST request changes. status + * describes the new current state of the request. + */ + void statusChanged(const QString &status); + + /** Emitted when the previous minidump upload completes successfully. + */ + void uploadFinished(); + + /** Emitted when the previous crash report upload fails. The QString + * error is a human-readable string describing the error + * encountered. + */ + void uploadFailed(const QString &error); + +private slots: + /** Called when the state of the underlying QHttp object changes. A + * statusChanged() signal is emitted with the appropriate text + * describing the new state of the POST request. + */ + void httpStateChanged(int state); + + /** Called when the underlying QHttp object used to upload the minidump + * completes. error is set to false if the upload was + * successful, or true if the upload failed. If id does not + * match the request ID previously returned by QHttp::get(), then the + * signal is ignored since it is the result of a close() or abort() + * request. + */ + void httpRequestFinished(int id, bool error); + +private: + /** Generates a "random" 8-byte multipart boundary marker encoded into + * 16 hex characters. + */ + QString generateBoundaryMarker() const; + + /** Unique numeric identifier of the current minidump upload POST request. + */ + int _requestId; + + /** Object used to POST a minidump to the crash server and read the + * response. + */ + QHttp *_http; +}; + +#endif + diff -Nru vidalia-0.1.13/src/crashreporter/main.cpp vidalia-0.2.8/src/crashreporter/main.cpp --- vidalia-0.1.13/src/crashreporter/main.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/crashreporter/main.cpp 2009-06-23 23:53:29.000000000 +0100 @@ -0,0 +1,182 @@ +/* +** 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.vidalia-project.net/. 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 main.cpp +** \version $Id$ +** \brief Application that is run after Vidalia crashes and asks the +** user if they would like to submit the crash report. +*/ + +#include "CrashReportDialog.h" + +#include +#include +#include +#include +#include + + +/** Open the minidump file given by fileName and read its entire + * contents into a QByteArray. Returns the contents of the minidump file + * on success. If an error occurs, this returns a default-constructed + * QByteArray and sets errorMessage to a string describing the error + * ecountered. + */ +QByteArray +read_minidump_file(const QString &fileName, QString &errorMessage) +{ + QByteArray md; + QFile mdFile(fileName); + + if (! mdFile.open(QIODevice::ReadOnly)) { + errorMessage = mdFile.errorString(); + return QByteArray(); + } + while (! mdFile.atEnd()) { + md.append(mdFile.readAll()); + if (mdFile.error() != QFile::NoError) { + errorMessage = mdFile.errorString(); + return QByteArray(); + } + } + mdFile.close(); + return md; +} + +/** Read the crash dump annotations file given by fileName and parse + * each line into a Key=Value pair. Returns a QHash containing the keys + * mapped to their values on success. If a file or parse error occurs, this + * returns a default-constructed QHash and sets errorMessage to a + * string describing the error encountered. + */ +QHash +read_annotations_file(const QString &fileName, QString &errorMessage) +{ + QHash annotations; + + /* Open the annotations file for reading text */ + QFile infile(fileName); + if (! infile.open(QIODevice::ReadOnly | QIODevice::Text)) { + errorMessage = infile.errorString(); + return QHash(); + } + + /* The annotations file should be UTF-8 encoded */ + QTextStream reader(&infile); + reader.setCodec(QTextCodec::codecForName("utf-8")); + while (! reader.atEnd()) { + QString line = reader.readLine().trimmed(); + if (line.isEmpty()) + continue; + + int idx = line.indexOf("="); + if (idx > 0 && idx < line.length()-1) { + QString key = line.mid(0, idx).trimmed(); + QString val = line.mid(idx + 1).trimmed(); + annotations.insert(key, val); + } + } + return annotations; +} + +int +main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + CrashReportDialog crashDialog; + QFileInfo minidumpFile, extraInfoFile; + QString minidumpFilePath, extraInfoFilePath, errorMessage; + QHash annotations; + QByteArray minidump; + + if (argc < 2) { + errorMessage = "No minidump file specified."; + goto err; + } + + /* Ensure that the specified minidump file exists and is readable */ + minidumpFile = QFileInfo(argv[1]); + minidumpFilePath = minidumpFile.absoluteFilePath(); + if (! minidumpFile.exists() || ! minidumpFile.size()) { + errorMessage = QString("The specified minidump file does not exist: %1") + .arg(minidumpFilePath); + goto err; + } + if (! minidumpFile.isReadable()) { + errorMessage = QString("The specified minidump file is not readable: %1") + .arg(minidumpFilePath); + goto err; + } + + /* Ensure that the specified minidump has an associated extra crash + * information file that exists and is readable. */ + extraInfoFile = QFileInfo(minidumpFilePath + ".info"); + extraInfoFilePath = extraInfoFile.absoluteFilePath(); + if (! extraInfoFile.exists() || ! extraInfoFile.size()) { + errorMessage = QString("The specified minidump does not have a " + "corresponding crash annotations file: %1") + .arg(extraInfoFilePath); + goto err; + } + if (! extraInfoFile.isReadable()) { + errorMessage = QString("The specified crash information file is not " + "readable: %1").arg(extraInfoFilePath); + goto err; + } + + /* Read the minidump file's contents */ + minidump = read_minidump_file(minidumpFilePath, errorMessage); + if (minidump.isNull()) { + errorMessage = QString("Unable to read minidump file '%1': %2") + .arg(minidumpFilePath) + .arg(errorMessage); + goto err; + } + /* Read and parse the crash annotations file */ + annotations = read_annotations_file(extraInfoFilePath, errorMessage); + if (annotations.isEmpty()) { + errorMessage = QString("Unable to read crash annotations file '%1': %2") + .arg(extraInfoFilePath) + .arg(errorMessage); + goto err; + } + + /* Display the crash reporting dialog */ + crashDialog.setMinidump(minidumpFile.baseName(), minidump); + crashDialog.setCrashAnnotations(annotations); + crashDialog.show(); + return app.exec(); + +err: + /* We encountered an error trying to load the minidump or extra crash + * information file. So, display an error and then bail, since now there's + * nothing for us to send. */ + QMessageBox dlg; + dlg.setWindowIcon(QIcon(":/images/32x32/tools-report-bug.png")); + dlg.setWindowTitle("Crash Reporter Error"); + + dlg.setIconPixmap(QPixmap(":/images/64x64/tools-report-bug.png")); + dlg.setStandardButtons(QMessageBox::Ok); + + dlg.setText("Vidalia encountered an error and needed to close"); + dlg.setInformativeText( + "

Vidalia attempted to automatically create an error report to " + "help diagnose the problem, but was unable to do so. Please report " + "this problem, along with what you were doing before Vidalia crashed, " + "to the developers at:

" + "" + "https://trac.vidalia-project.net/wiki/ReportingBugs

" + "

Click \"Show Details\" below for information about the problem " + "encountered."); + + dlg.setDetailedText(errorMessage); + return dlg.exec(); +} Binary files /tmp/KPMk4L7DHV/vidalia-0.1.13/src/crashreporter/res/32x32/tools-report-bug.png and /tmp/EwwyCgG7oU/vidalia-0.2.8/src/crashreporter/res/32x32/tools-report-bug.png differ Binary files /tmp/KPMk4L7DHV/vidalia-0.1.13/src/crashreporter/res/48x48/tools-report-bug.png and /tmp/EwwyCgG7oU/vidalia-0.2.8/src/crashreporter/res/48x48/tools-report-bug.png differ Binary files /tmp/KPMk4L7DHV/vidalia-0.1.13/src/crashreporter/res/64x64/tools-report-bug.png and /tmp/EwwyCgG7oU/vidalia-0.2.8/src/crashreporter/res/64x64/tools-report-bug.png differ Binary files /tmp/KPMk4L7DHV/vidalia-0.1.13/src/crashreporter/res/CrashReporter.ico and /tmp/EwwyCgG7oU/vidalia-0.2.8/src/crashreporter/res/CrashReporter.ico differ diff -Nru vidalia-0.1.13/src/crashreporter/res/CrashReporter.qrc vidalia-0.2.8/src/crashreporter/res/CrashReporter.qrc --- vidalia-0.1.13/src/crashreporter/res/CrashReporter.qrc 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/crashreporter/res/CrashReporter.qrc 2009-06-23 23:53:29.000000000 +0100 @@ -0,0 +1,11 @@ + + + + 32x32/tools-report-bug.png + 48x48/tools-report-bug.png + 64x64/tools-report-bug.png + + + gd-class2-root.crt + + diff -Nru vidalia-0.1.13/src/crashreporter/res/CrashReporter.rc.in vidalia-0.2.8/src/crashreporter/res/CrashReporter.rc.in --- vidalia-0.1.13/src/crashreporter/res/CrashReporter.rc.in 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/crashreporter/res/CrashReporter.rc.in 2009-06-23 23:53:29.000000000 +0100 @@ -0,0 +1,46 @@ +/* +** 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.vidalia-project.net/. 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 CrashReporter.rc.in +** \version $Id$ +** Defines resource identifiers for icons used on Win32. +*/ + +#include + + +1 VERSIONINFO +FILEVERSION @VER_MAJOR@,@VER_MINOR@,@VER_PATCH@,0 +PRODUCTVERSION @VER_MAJOR@,@VER_MINOR@,@VER_PATCH@,0 +FILEFLAGSMASK 0 +FILEOS VOS__WINDOWS32 +FILETYPE VFT_APP +{ + BLOCK "StringFileInfo" + { + BLOCK "040904E4" + { + VALUE "FileVersion", "@VERSION@" + VALUE "ProductVersion", "@VERSION@" + VALUE "InternalName", "CrashReporter" + VALUE "ProductName", "Vidalia Crash Reporter" + VALUE "FileDescription", "Vidalia Crash Reporter" + VALUE "OriginalFilename", "CrashReporter.exe" + VALUE "CompanyName", "vidalia-project.net" + VALUE "LegalCopyright", "Copyright (C) 2009, Matt Edman" + } + } +} + + +/* Application icon */ +101 ICON DISCARDABLE "@CMAKE_CURRENT_SOURCE_DIR@/res/CrashReporter.ico" + diff -Nru vidalia-0.1.13/src/crashreporter/res/gd-class2-root.crt vidalia-0.2.8/src/crashreporter/res/gd-class2-root.crt --- vidalia-0.1.13/src/crashreporter/res/gd-class2-root.crt 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/crashreporter/res/gd-class2-root.crt 2009-06-23 23:53:29.000000000 +0100 @@ -0,0 +1,24 @@ +-----BEGIN CERTIFICATE----- +MIIEADCCAuigAwIBAgIBADANBgkqhkiG9w0BAQUFADBjMQswCQYDVQQGEwJVUzEh +MB8GA1UEChMYVGhlIEdvIERhZGR5IEdyb3VwLCBJbmMuMTEwLwYDVQQLEyhHbyBE +YWRkeSBDbGFzcyAyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTA0MDYyOTE3 +MDYyMFoXDTM0MDYyOTE3MDYyMFowYzELMAkGA1UEBhMCVVMxITAfBgNVBAoTGFRo +ZSBHbyBEYWRkeSBHcm91cCwgSW5jLjExMC8GA1UECxMoR28gRGFkZHkgQ2xhc3Mg +MiBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCCASAwDQYJKoZIhvcNAQEBBQADggEN +ADCCAQgCggEBAN6d1+pXGEmhW+vXX0iG6r7d/+TvZxz0ZWizV3GgXne77ZtJ6XCA +PVYYYwhv2vLM0D9/AlQiVBDYsoHUwHU9S3/Hd8M+eKsaA7Ugay9qK7HFiH7Eux6w +wdhFJ2+qN1j3hybX2C32qRe3H3I2TqYXP2WYktsqbl2i/ojgC95/5Y0V4evLOtXi +EqITLdiOr18SPaAIBQi2XKVlOARFmR6jYGB0xUGlcmIbYsUfb18aQr4CUWWoriMY +avx4A6lNf4DD+qta/KFApMoZFv6yyO9ecw3ud72a9nmYvLEHZ6IVDd2gWMZEewo+ +YihfukEHU1jPEX44dMX4/7VpkI+EdOqXG68CAQOjgcAwgb0wHQYDVR0OBBYEFNLE +sNKR1EwRcbNhyz2h/t2oatTjMIGNBgNVHSMEgYUwgYKAFNLEsNKR1EwRcbNhyz2h +/t2oatTjoWekZTBjMQswCQYDVQQGEwJVUzEhMB8GA1UEChMYVGhlIEdvIERhZGR5 +IEdyb3VwLCBJbmMuMTEwLwYDVQQLEyhHbyBEYWRkeSBDbGFzcyAyIENlcnRpZmlj +YXRpb24gQXV0aG9yaXR5ggEAMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQAD +ggEBADJL87LKPpH8EsahB4yOd6AzBhRckB4Y9wimPQoZ+YeAEW5p5JYXMP80kWNy +OO7MHAGjHZQopDH2esRU1/blMVgDoszOYtuURXO1v0XJJLXVggKtI3lpjbi2Tc7P +TMozI+gciKqdi0FuFskg5YmezTvacPd+mSYgFFQlq25zheabIZ0KbIIOqPjCDPoQ +HmyW74cNxA9hi63ugyuV+I6ShHI56yDqg+2DzZduCLzrTia2cyvk0/ZM/iZx4mER +dEr/VxqHD3VILs9RaRegAhJhldXRQLIQTO7ErBBDpqWeCtWVYpoNz4iCxTIM5Cuf +ReYNnyicsbkqWletNw+vHX/bvZ8= +-----END CERTIFICATE----- diff -Nru vidalia-0.1.13/src/crashreporter/UploadProgressDialog.cpp vidalia-0.2.8/src/crashreporter/UploadProgressDialog.cpp --- vidalia-0.1.13/src/crashreporter/UploadProgressDialog.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/crashreporter/UploadProgressDialog.cpp 2009-06-23 23:53:29.000000000 +0100 @@ -0,0 +1,61 @@ +/* +** 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.vidalia-project.net/. 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 UploadProgressDialog.cpp +** \version $Id$ +** \brief Displays the progress of uploading a crash report to the server +*/ + +#include "UploadProgressDialog.h" + + +UploadProgressDialog::UploadProgressDialog(QWidget *parent) + : QDialog(parent) +{ + ui.setupUi(this); + + setModal(true); +} + +void +UploadProgressDialog::setVisible(bool visible) +{ + if (visible) { + ui.progressBar->setRange(0, 0); + ui.buttonBox->setStandardButtons(QDialogButtonBox::Cancel); + } + QDialog::setVisible(visible); +} + +void +UploadProgressDialog::setStatus(const QString &status) +{ + ui.lblStatus->setText(status); +} + +void +UploadProgressDialog::setUploadProgress(int done, int total) +{ + ui.progressBar->setRange(0, total); + ui.progressBar->setValue(done); +} + +void +UploadProgressDialog::uploadFailed(const QString &error) +{ + ui.lblStatus->setText(tr("Unable to send report: %1").arg(error)); + + ui.progressBar->setRange(0, 1); + ui.progressBar->setValue(1); + + ui.buttonBox->setStandardButtons(QDialogButtonBox::Ok); +} + diff -Nru vidalia-0.1.13/src/crashreporter/UploadProgressDialog.h vidalia-0.2.8/src/crashreporter/UploadProgressDialog.h --- vidalia-0.1.13/src/crashreporter/UploadProgressDialog.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/crashreporter/UploadProgressDialog.h 2009-06-23 23:53:29.000000000 +0100 @@ -0,0 +1,63 @@ +/* +** 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.vidalia-project.net/. 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 UploadProgressDialog.cpp +** \version $Id$ +** \brief Displays the progress of uploading a crash report to the server +*/ + +#ifndef _UPLOADPROGRESSDIALOG_H +#define _UPLOADPROGRESSDIALOG_H + +#include "ui_UploadProgressDialog.h" + + +class UploadProgressDialog : public QDialog +{ + Q_OBJECT + +public: + /** Default constructor. + */ + UploadProgressDialog(QWidget *parent = 0); + +public slots: + /** Sets the status message text in the dialog to status. + */ + void setStatus(const QString &status); + + /** Updates the minidump upload progress bar to value out of + * maximum steps. If value and maximum are both 0, + * then a "busy" progress bar is displayed. + */ + void setUploadProgress(int value, int maximum); + + /** Called when the minidump upload fails. The string error + * provides a human-readable description of the reason the upload + * failed, which is displayed for the user. + */ + void uploadFailed(const QString &error); + +protected: + /** Overloaded method called when the progress dialog is first shown in + * order to initialize the progress bar, status text and dialog button + * box. + */ + virtual void setVisible(bool visible); + +private: + /** Qt Designer generated object. + */ + Ui::UploadProgressDialog ui; +}; + +#endif + diff -Nru vidalia-0.1.13/src/crashreporter/UploadProgressDialog.ui vidalia-0.2.8/src/crashreporter/UploadProgressDialog.ui --- vidalia-0.1.13/src/crashreporter/UploadProgressDialog.ui 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/crashreporter/UploadProgressDialog.ui 2009-06-23 23:53:29.000000000 +0100 @@ -0,0 +1,106 @@ + + + UploadProgressDialog + + + + 0 + 0 + 366 + 104 + + + + Uploading Crash Report + + + + :/images/32x32/tools-report-bug.png:/images/32x32/tools-report-bug.png + + + true + + + + + + + + + :/images/48x48/tools-report-bug.png + + + + + + + + + + true + + + + + + + 0 + + + false + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel + + + + + + + + + + + buttonBox + accepted() + UploadProgressDialog + accept() + + + 182 + 81 + + + 182 + 51 + + + + + buttonBox + rejected() + UploadProgressDialog + reject() + + + 182 + 81 + + + 182 + 51 + + + + + diff -Nru vidalia-0.1.13/src/miniupnpc/CMakeLists.txt vidalia-0.2.8/src/miniupnpc/CMakeLists.txt --- vidalia-0.1.13/src/miniupnpc/CMakeLists.txt 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/src/miniupnpc/CMakeLists.txt 2010-04-10 00:17:13.000000000 +0100 @@ -1,5 +1,5 @@ ## -## $Id: CMakeLists.txt 2831 2008-07-03 02:38:02Z edmanm $ +## $Id: CMakeLists.txt 4251 2010-04-09 23:17:13Z edmanm $ ## ## 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 @@ -21,6 +21,7 @@ upnpcommands.c upnperrors.c upnpreplyparse.c + connecthostport.c ) if (NOT WIN32) set(miniupnpc_SRCS ${miniupnpc_SRCS} minissdpc.c) diff -Nru vidalia-0.1.13/src/miniupnpc/codelength.h vidalia-0.2.8/src/miniupnpc/codelength.h --- vidalia-0.1.13/src/miniupnpc/codelength.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/miniupnpc/codelength.h 2009-05-30 01:36:22.000000000 +0100 @@ -0,0 +1,24 @@ +/* $Id: codelength.h,v 1.1 2008/10/06 22:04:06 nanard Exp $ */ +/* Project : miniupnp + * Author : Thomas BERNARD + * copyright (c) 2005-2008 Thomas Bernard + * This software is subjet to the conditions detailed in the + * provided LICENCE file. */ +#ifndef __CODELENGTH_H__ +#define __CODELENGTH_H__ + +/* Encode length by using 7bit per Byte : + * Most significant bit of each byte specifies that the + * following byte is part of the code */ +#define DECODELENGTH(n, p) n = 0; \ + do { n = (n << 7) | (*p & 0x7f); } \ + while(*(p++)&0x80); + +#define CODELENGTH(n, p) if(n>=268435456) *(p++) = (n >> 28) | 0x80; \ + if(n>=2097152) *(p++) = (n >> 21) | 0x80; \ + if(n>=16384) *(p++) = (n >> 14) | 0x80; \ + if(n>=128) *(p++) = (n >> 7) | 0x80; \ + *(p++) = n & 0x7f; + +#endif + diff -Nru vidalia-0.1.13/src/miniupnpc/connecthostport.c vidalia-0.2.8/src/miniupnpc/connecthostport.c --- vidalia-0.1.13/src/miniupnpc/connecthostport.c 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/miniupnpc/connecthostport.c 2010-04-10 00:17:13.000000000 +0100 @@ -0,0 +1,221 @@ +/* $Id: connecthostport.c,v 1.2 2010/04/05 00:08:15 nanard Exp $ */ +/* Project : miniupnp + * Author : Thomas Bernard + * Copyright (c) 2010 Thomas Bernard + * This software is subject to the conditions detailed in the + * LICENCE file provided in this distribution. */ + +/* use getaddrinfo() or gethostbyname() + * uncomment the following line in order to use gethostbyname() */ +/* #define USE_GETHOSTBYNAME */ + +#include +#include +#ifdef WIN32 +#include +#include +#include +#define snprintf _snprintf +#define herror +#define socklen_t int +#else /* #ifdef WIN32 */ +#include +#include +#define closesocket close +#include +/* defining MINIUPNPC_IGNORE_EINTR enable the ignore of interruptions + * during the connect() call */ +#define MINIUPNPC_IGNORE_EINTR +#ifndef USE_GETHOSTBYNAME +#include +#include +#endif /* #ifndef USE_GETHOSTBYNAME */ +#endif /* #else WIN32 */ + +/* definition of PRINT_SOCKET_ERROR */ +#ifdef WIN32 +#define PRINT_SOCKET_ERROR(x) printf("Socket error: %s, %d\n", x, WSAGetLastError()); +#else +#define PRINT_SOCKET_ERROR(x) perror(x) +#endif + +#if defined(__amigaos__) || defined(__amigaos4__) +#define herror(A) printf("%s\n", A) +#endif + +#include "connecthostport.h" + +/* connecthostport() + * return a socket connected (TCP) to the host and port + * or -1 in case of error */ +int connecthostport(const char * host, unsigned short port) +{ + int s, n; +#ifdef USE_GETHOSTBYNAME + struct sockaddr_in dest; + struct hostent *hp; +#else /* #ifdef USE_GETHOSTBYNAME */ + char port_str[8]; + struct addrinfo *ai, *p; + struct addrinfo hints; +#endif /* #ifdef USE_GETHOSTBYNAME */ +#ifdef MINIUPNPC_SET_SOCKET_TIMEOUT + struct timeval timeout; +#endif /* #ifdef MINIUPNPC_SET_SOCKET_TIMEOUT */ + +#ifdef USE_GETHOSTBYNAME + hp = gethostbyname(host); + if(hp == NULL) + { + herror(host); + return -1; + } + memcpy(&dest.sin_addr, hp->h_addr, sizeof(dest.sin_addr)); + memset(dest.sin_zero, 0, sizeof(dest.sin_zero)); + s = socket(PF_INET, SOCK_STREAM, 0); + if(s < 0) + { + PRINT_SOCKET_ERROR("socket"); + return -1; + } +#ifdef MINIUPNPC_SET_SOCKET_TIMEOUT + /* setting a 3 seconds timeout for the connect() call */ + timeout.tv_sec = 3; + timeout.tv_usec = 0; + if(setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(struct timeval)) < 0) + { + PRINT_SOCKET_ERROR("setsockopt"); + } + timeout.tv_sec = 3; + timeout.tv_usec = 0; + if(setsockopt(s, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof(struct timeval)) < 0) + { + PRINT_SOCKET_ERROR("setsockopt"); + } +#endif /* #ifdef MINIUPNPC_SET_SOCKET_TIMEOUT */ + dest.sin_family = AF_INET; + dest.sin_port = htons(port); + n = connect(s, (struct sockaddr *)&dest, sizeof(struct sockaddr_in)); +#ifdef MINIUPNPC_IGNORE_EINTR + while(n < 0 && errno == EINTR) + { + socklen_t len; + fd_set wset; + int err; + FD_ZERO(&wset); + FD_SET(s, &wset); + if((n = select(s + 1, NULL, &wset, NULL, NULL)) == -1 && errno == EINTR) + continue; + /*len = 0;*/ + /*n = getpeername(s, NULL, &len);*/ + len = sizeof(err); + if(getsockopt(s, SOL_SOCKET, SO_ERROR, &err, &len) < 0) { + PRINT_SOCKET_ERROR("getsockopt"); + closesocket(s); + return -1; + } + if(err != 0) { + errno = err; + n = -1; + } + } +#endif /* #ifdef MINIUPNPC_IGNORE_EINTR */ + if(n<0) + { + PRINT_SOCKET_ERROR("connect"); + closesocket(s); + return -1; + } +#else /* #ifdef USE_GETHOSTBYNAME */ + /* use getaddrinfo() instead of gethostbyname() */ + memset(&hints, 0, sizeof(hints)); + /* hints.ai_flags = AI_ADDRCONFIG; */ +#ifdef AI_NUMERICSERV + hints.ai_flags = AI_NUMERICSERV; +#endif + hints.ai_socktype = SOCK_STREAM; + hints.ai_family = AF_UNSPEC; /* AF_INET, AF_INET6 or AF_UNSPEC */ + /* hints.ai_protocol = IPPROTO_TCP; */ + snprintf(port_str, sizeof(port_str), "%hu", port); + n = getaddrinfo(host, port_str, &hints, &ai); + if(n != 0) + { +#ifdef WIN32 + fprintf(stderr, "getaddrinfo() error : %d\n", n); +#else + fprintf(stderr, "getaddrinfo() error : %s\n", gai_strerror(n)); +#endif + return -1; + } + s = -1; + for(p = ai; p; p = p->ai_next) + { + s = socket(p->ai_family, p->ai_socktype, p->ai_protocol); + if(s < 0) + continue; +#ifdef MINIUPNPC_SET_SOCKET_TIMEOUT + /* setting a 3 seconds timeout for the connect() call */ + timeout.tv_sec = 3; + timeout.tv_usec = 0; + if(setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(struct timeval)) < 0) + { + PRINT_SOCKET_ERROR("setsockopt"); + } + timeout.tv_sec = 3; + timeout.tv_usec = 0; + if(setsockopt(s, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof(struct timeval)) < 0) + { + PRINT_SOCKET_ERROR("setsockopt"); + } +#endif /* #ifdef MINIUPNPC_SET_SOCKET_TIMEOUT */ + n = connect(s, p->ai_addr, p->ai_addrlen); +#ifdef MINIUPNPC_IGNORE_EINTR + while(n < 0 && errno == EINTR) + { + socklen_t len; + fd_set wset; + int err; + FD_ZERO(&wset); + FD_SET(s, &wset); + if((n = select(s + 1, NULL, &wset, NULL, NULL)) == -1 && errno == EINTR) + continue; + /*len = 0;*/ + /*n = getpeername(s, NULL, &len);*/ + len = sizeof(err); + if(getsockopt(s, SOL_SOCKET, SO_ERROR, &err, &len) < 0) { + PRINT_SOCKET_ERROR("getsockopt"); + closesocket(s); + freeaddrinfo(ai); + return -1; + } + if(err != 0) { + errno = err; + n = -1; + } + } +#endif /* #ifdef MINIUPNPC_IGNORE_EINTR */ + if(n < 0) + { + closesocket(s); + continue; + } + else + { + break; + } + } + freeaddrinfo(ai); + if(s < 0) + { + PRINT_SOCKET_ERROR("socket"); + return -1; + } + if(n < 0) + { + PRINT_SOCKET_ERROR("connect"); + return -1; + } +#endif /* #ifdef USE_GETHOSTBYNAME */ + return s; +} + diff -Nru vidalia-0.1.13/src/miniupnpc/connecthostport.h vidalia-0.2.8/src/miniupnpc/connecthostport.h --- vidalia-0.1.13/src/miniupnpc/connecthostport.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/miniupnpc/connecthostport.h 2010-04-10 00:17:13.000000000 +0100 @@ -0,0 +1,17 @@ +/* $Id: connecthostport.h,v 1.1 2010/04/04 23:21:03 nanard Exp $ */ +/* Project: miniupnp + * http://miniupnp.free.fr/ + * Author: Thomas Bernard + * Copyright (c) 2010 Thomas Bernard + * This software is subjects to the conditions detailed + * in the LICENCE file provided within this distribution */ +#ifndef __CONNECTHOSTPORT_H__ +#define __CONNECTHOSTPORT_H__ + +/* connecthostport() + * return a socket connected (TCP) to the host and port + * or -1 in case of error */ +int connecthostport(const char * host, unsigned short port); + +#endif + diff -Nru vidalia-0.1.13/src/miniupnpc/igd_desc_parse.c vidalia-0.2.8/src/miniupnpc/igd_desc_parse.c --- vidalia-0.1.13/src/miniupnpc/igd_desc_parse.c 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/src/miniupnpc/igd_desc_parse.c 2010-04-10 00:17:13.000000000 +0100 @@ -1,11 +1,11 @@ -/* $Id: igd_desc_parse.c,v 1.7 2006/11/19 22:32:33 nanard Exp $ */ +/* $Id: igd_desc_parse.c,v 1.10 2010/04/05 20:36:59 nanard Exp $ */ /* Project : miniupnp * http://miniupnp.free.fr/ * Author : Thomas Bernard - * Copyright (c) 2005 Thomas Bernard + * Copyright (c) 2005-2010 Thomas Bernard * This software is subject to the conditions detailed in the - * LICENCE file provided in this distribution. - * */ + * LICENCE file provided in this distribution. */ + #include "igd_desc_parse.h" #include #include @@ -18,6 +18,12 @@ memcpy( datas->cureltname, name, l); datas->cureltname[l] = '\0'; datas->level++; + if( (l==7) && !memcmp(name, "service", l) ) { + datas->tmp.controlurl[0] = '\0'; + datas->tmp.eventsuburl[0] = '\0'; + datas->tmp.scpdurl[0] = '\0'; + datas->tmp.servicetype[0] = '\0'; + } } /* End element handler : @@ -30,7 +36,6 @@ /*printf("endelt %2d %.*s\n", datas->level, l, name);*/ if( (l==7) && !memcmp(name, "service", l) ) { - /*datas->state++; */ /* if( datas->state < 1 && !strcmp(datas->servicetype, @@ -38,15 +43,19 @@ "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1")) datas->state ++; */ - if(0==strcmp(datas->servicetype_CIF, - "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1")) - datas->state = 2; - if(0==strcmp(datas->servicetype, - "urn:schemas-upnp-org:service:WANIPConnection:1") ) - datas->state = 3; -/* if(0==strcmp(datas->servicetype, - "urn:schemas-upnp-org:service:WANPPPConnection:1") ) - datas->state = 4; */ + if(0==strcmp(datas->tmp.servicetype, + "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1")) { + memcpy(&datas->CIF, &datas->tmp, sizeof(struct IGDdatas_service)); + } else if(0==strcmp(datas->tmp.servicetype, + "urn:schemas-upnp-org:service:WANIPConnection:1") + || 0==strcmp(datas->tmp.servicetype, + "urn:schemas-upnp-org:service:WANPPPConnection:1") ) { + if(datas->first.servicetype[0] == '\0') { + memcpy(&datas->first, &datas->tmp, sizeof(struct IGDdatas_service)); + } else { + memcpy(&datas->second, &datas->tmp, sizeof(struct IGDdatas_service)); + } + } } } @@ -60,32 +69,16 @@ datas->level, datas->cureltname, l, data); */ if( !strcmp(datas->cureltname, "URLBase") ) dstmember = datas->urlbase; - else if(datas->state<=1) - { - if( !strcmp(datas->cureltname, "serviceType") ) - dstmember = datas->servicetype_CIF; - else if( !strcmp(datas->cureltname, "controlURL") ) - dstmember = datas->controlurl_CIF; - else if( !strcmp(datas->cureltname, "eventSubURL") ) - dstmember = datas->eventsuburl_CIF; - else if( !strcmp(datas->cureltname, "SCPDURL") ) - dstmember = datas->scpdurl_CIF; - else if( !strcmp(datas->cureltname, "deviceType") ) - dstmember = datas->devicetype_CIF; - } - else if(datas->state==2) - { - if( !strcmp(datas->cureltname, "serviceType") ) - dstmember = datas->servicetype; - else if( !strcmp(datas->cureltname, "controlURL") ) - dstmember = datas->controlurl; - else if( !strcmp(datas->cureltname, "eventSubURL") ) - dstmember = datas->eventsuburl; - else if( !strcmp(datas->cureltname, "SCPDURL") ) - dstmember = datas->scpdurl; - else if( !strcmp(datas->cureltname, "deviceType") ) - dstmember = datas->devicetype; - } + else if( !strcmp(datas->cureltname, "serviceType") ) + dstmember = datas->tmp.servicetype; + else if( !strcmp(datas->cureltname, "controlURL") ) + dstmember = datas->tmp.controlurl; + else if( !strcmp(datas->cureltname, "eventSubURL") ) + dstmember = datas->tmp.eventsuburl; + else if( !strcmp(datas->cureltname, "SCPDURL") ) + dstmember = datas->tmp.scpdurl; +/* else if( !strcmp(datas->cureltname, "deviceType") ) + dstmember = datas->devicetype_tmp;*/ if(dstmember) { if(l>=MINIUPNPC_URL_MAXSIZE) @@ -97,19 +90,25 @@ void printIGD(struct IGDdatas * d) { - printf("urlbase = %s\n", d->urlbase); + printf("urlbase = '%s'\n", d->urlbase); printf("WAN Device (Common interface config) :\n"); - printf(" deviceType = %s\n", d->devicetype_CIF); - printf(" serviceType = %s\n", d->servicetype_CIF); - printf(" controlURL = %s\n", d->controlurl_CIF); - printf(" eventSubURL = %s\n", d->eventsuburl_CIF); - printf(" SCPDURL = %s\n", d->scpdurl_CIF); - printf("WAN Connection Device :\n"); - printf(" deviceType = %s\n", d->devicetype); - printf(" servicetype = %s\n", d->servicetype); - printf(" controlURL = %s\n", d->controlurl); - printf(" eventSubURL = %s\n", d->eventsuburl); - printf(" SCPDURL = %s\n", d->scpdurl); + /*printf(" deviceType = '%s'\n", d->CIF.devicetype);*/ + printf(" serviceType = '%s'\n", d->CIF.servicetype); + printf(" controlURL = '%s'\n", d->CIF.controlurl); + printf(" eventSubURL = '%s'\n", d->CIF.eventsuburl); + printf(" SCPDURL = '%s'\n", d->CIF.scpdurl); + printf("WAN Connection Device (IP or PPP Connection):\n"); + /*printf(" deviceType = '%s'\n", d->first.devicetype);*/ + printf(" servicetype = '%s'\n", d->first.servicetype); + printf(" controlURL = '%s'\n", d->first.controlurl); + printf(" eventSubURL = '%s'\n", d->first.eventsuburl); + printf(" SCPDURL = '%s'\n", d->first.scpdurl); + printf("secondary WAN Connection Device (IP or PPP Connection):\n"); + /*printf(" deviceType = '%s'\n", d->second.devicetype);*/ + printf(" servicetype = '%s'\n", d->second.servicetype); + printf(" controlURL = '%s'\n", d->second.controlurl); + printf(" eventSubURL = '%s'\n", d->second.eventsuburl); + printf(" SCPDURL = '%s'\n", d->second.scpdurl); } diff -Nru vidalia-0.1.13/src/miniupnpc/igd_desc_parse.h vidalia-0.2.8/src/miniupnpc/igd_desc_parse.h --- vidalia-0.1.13/src/miniupnpc/igd_desc_parse.h 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/src/miniupnpc/igd_desc_parse.h 2010-04-10 00:17:13.000000000 +0100 @@ -1,8 +1,8 @@ -/* $Id: igd_desc_parse.h,v 1.5 2007/04/11 15:21:09 nanard Exp $ */ +/* $Id: igd_desc_parse.h,v 1.7 2010/04/05 20:36:59 nanard Exp $ */ /* Project : miniupnp * http://miniupnp.free.fr/ * Author : Thomas Bernard - * Copyright (c) 2005 Thomas Bernard + * Copyright (c) 2005-2010 Thomas Bernard * This software is subject to the conditions detailed in the * LICENCE file provided in this distribution. * */ @@ -12,21 +12,28 @@ /* Structure to store the result of the parsing of UPnP * descriptions of Internet Gateway Devices */ #define MINIUPNPC_URL_MAXSIZE (128) -struct IGDdatas { - char cureltname[MINIUPNPC_URL_MAXSIZE]; - char urlbase[MINIUPNPC_URL_MAXSIZE]; - int level; - int state; - char controlurl_CIF[MINIUPNPC_URL_MAXSIZE]; - char eventsuburl_CIF[MINIUPNPC_URL_MAXSIZE]; - char scpdurl_CIF[MINIUPNPC_URL_MAXSIZE]; - char servicetype_CIF[MINIUPNPC_URL_MAXSIZE]; - char devicetype_CIF[MINIUPNPC_URL_MAXSIZE]; +struct IGDdatas_service { char controlurl[MINIUPNPC_URL_MAXSIZE]; char eventsuburl[MINIUPNPC_URL_MAXSIZE]; char scpdurl[MINIUPNPC_URL_MAXSIZE]; char servicetype[MINIUPNPC_URL_MAXSIZE]; - char devicetype[MINIUPNPC_URL_MAXSIZE]; + /*char devicetype[MINIUPNPC_URL_MAXSIZE];*/ +}; + +struct IGDdatas { + char cureltname[MINIUPNPC_URL_MAXSIZE]; + char urlbase[MINIUPNPC_URL_MAXSIZE]; + int level; + /*int state;*/ + /* "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1" */ + struct IGDdatas_service CIF; + /* "urn:schemas-upnp-org:service:WANIPConnection:1" + * "urn:schemas-upnp-org:service:WANPPPConnection:1" */ + struct IGDdatas_service first; + /* if both WANIPConnection and WANPPPConnection are present */ + struct IGDdatas_service second; + /* tmp */ + struct IGDdatas_service tmp; }; void IGDstartelt(void *, const char *, int); diff -Nru vidalia-0.1.13/src/miniupnpc/minisoap.c vidalia-0.2.8/src/miniupnpc/minisoap.c --- vidalia-0.1.13/src/miniupnpc/minisoap.c 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/src/miniupnpc/minisoap.c 2010-04-10 00:17:13.000000000 +0100 @@ -1,7 +1,7 @@ -/* $Id: minisoap.c,v 1.15 2008/02/17 17:57:07 nanard Exp $ */ +/* $Id: minisoap.c,v 1.18 2009/12/04 11:29:18 nanard Exp $ */ /* Project : miniupnp * Author : Thomas Bernard - * Copyright (c) 2005 Thomas Bernard + * Copyright (c) 2005-2009 Thomas Bernard * This software is subject to the conditions detailed in the * LICENCE file provided in this distribution. * @@ -19,6 +19,7 @@ #include #endif #include "minisoap.h" +#include "miniupnpcstrings.h" /* only for malloc */ #include @@ -83,16 +84,19 @@ bodysize = (int)strlen(body); /* We are not using keep-alive HTTP connections. * HTTP/1.1 needs the header Connection: close to do that. - * This is the default with HTTP/1.0 */ + * This is the default with HTTP/1.0 + * Using HTTP/1.1 means we need to support chunked transfer-encoding : + * When using HTTP/1.1, the router "BiPAC 7404VNOX" always use chunked + * transfer encoding. */ /* Connection: Close is normally there only in HTTP/1.1 but who knows */ portstr[0] = '\0'; if(port != 80) snprintf(portstr, sizeof(portstr), ":%hu", port); headerssize = snprintf(headerbuf, sizeof(headerbuf), - "POST %s HTTP/1.1\r\n" -/* "POST %s HTTP/1.0\r\n"*/ +/* "POST %s HTTP/1.1\r\n" */ + "POST %s HTTP/1.0\r\n" "Host: %s%s\r\n" - "User-Agent: POSIX, UPnP/1.0, miniUPnPc/1.0\r\n" + "User-Agent: " OS_STRING ", UPnP/1.0, MiniUPnPc/" MINIUPNPC_VERSION_STRING "\r\n" "Content-Length: %d\r\n" "Content-Type: text/xml\r\n" "SOAPAction: \"%s\"\r\n" diff -Nru vidalia-0.1.13/src/miniupnpc/minissdpc.c vidalia-0.2.8/src/miniupnpc/minissdpc.c --- vidalia-0.1.13/src/miniupnpc/minissdpc.c 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/src/miniupnpc/minissdpc.c 2010-04-10 00:17:13.000000000 +0100 @@ -1,7 +1,7 @@ -/* $Id: minissdpc.c,v 1.4 2007/12/19 14:56:58 nanard Exp $ */ +/* $Id: minissdpc.c,v 1.13 2009/12/04 16:57:29 nanard Exp $ */ /* Project : miniupnp * Author : Thomas BERNARD - * copyright (c) 2005-2007 Thomas Bernard + * copyright (c) 2005-2009 Thomas Bernard * This software is subjet to the conditions detailed in the * provided LICENCE file. */ /*#include */ @@ -10,17 +10,33 @@ #include #include #include +#if defined(WIN32) || defined(__amigaos__) || defined(__amigaos4__) +#ifdef WIN32 +#include +#include +#include +#endif +#if defined(__amigaos__) || defined(__amigaos4__) +#include +#endif +#if defined(__amigaos__) +#define uint16_t unsigned short +#endif +/* Hack */ +#define UNIX_PATH_LEN 108 +struct sockaddr_un { + uint16_t sun_family; + char sun_path[UNIX_PATH_LEN]; +}; +#else #include #include +#endif #include "minissdpc.h" #include "miniupnpc.h" -#define DECODELENGTH(n, p) n = 0; \ - do { n = (n << 7) | (*p & 0x7f); } \ - while(*(p++)&0x80); -#define CODELENGTH(n, p) do { *p = (n & 0x7f) | ((n > 0x7f) ? 0x80 : 0); \ - p++; n >>= 7; } while(n); +#include "codelength.h" struct UPNPDev * getDevicesFromMiniSSDPD(const char * devtype, const char * socketpath) @@ -45,6 +61,7 @@ } addr.sun_family = AF_UNIX; strncpy(addr.sun_path, socketpath, sizeof(addr.sun_path)); + /* TODO : check if we need to handle the EINTR */ if(connect(s, (struct sockaddr *)&addr, sizeof(struct sockaddr_un)) < 0) { /*syslog(LOG_WARNING, "connect(\"%s\"): %m", socketpath);*/ @@ -52,9 +69,15 @@ return NULL; } stsize = strlen(devtype); - buffer[0] = 1; + buffer[0] = 1; /* request type 1 : request devices/services by type */ p = buffer + 1; l = stsize; CODELENGTH(l, p); + if(p + stsize > buffer + sizeof(buffer)) + { + /* devtype is too long ! */ + close(s); + return NULL; + } memcpy(p, devtype, stsize); p += stsize; if(write(s, buffer, p - buffer) < 0) diff -Nru vidalia-0.1.13/src/miniupnpc/miniupnpc.c vidalia-0.2.8/src/miniupnpc/miniupnpc.c --- vidalia-0.1.13/src/miniupnpc/miniupnpc.c 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/src/miniupnpc/miniupnpc.c 2010-04-10 00:17:13.000000000 +0100 @@ -1,42 +1,79 @@ -/* $Id: miniupnpc.c,v 1.52 2008/02/18 13:28:33 nanard Exp $ */ +/* $Id: miniupnpc.c,v 1.78 2010/04/05 20:36:59 nanard Exp $ */ /* Project : miniupnp * Author : Thomas BERNARD - * copyright (c) 2005-2007 Thomas Bernard + * copyright (c) 2005-2010 Thomas Bernard * This software is subjet to the conditions detailed in the - * provided LICENCE file. */ -#include + * provided LICENSE file. */ +#define __EXTENSIONS__ 1 +#if !defined(MACOSX) && !defined(__sun) +#if !defined(_XOPEN_SOURCE) && !defined(__OpenBSD__) && !defined(__NetBSD__) +#ifndef __cplusplus +#define _XOPEN_SOURCE 600 +#endif +#endif +#ifndef __BSD_VISIBLE +#define __BSD_VISIBLE 1 +#endif +#endif + +#ifdef __APPLE__ +#define _DARWIN_C_SOURCE +#endif + #include +#include #include #ifdef WIN32 +/* Win32 Specific includes and defines */ #include -#include +#include #include +/*#include */ #define snprintf _snprintf +#if defined(_MSC_VER) && (_MSC_VER >= 1400) +#define strncasecmp _memicmp +#else /* defined(_MSC_VER) && (_MSC_VER >= 1400) */ #define strncasecmp memicmp +#endif /* defined(_MSC_VER) && (_MSC_VER >= 1400) */ #define MAXHOSTNAMELEN 64 -#else +#else /* #ifdef WIN32 */ +/* Standard POSIX includes */ #include +#if defined(__amigaos__) && !defined(__amigaos4__) +/* Amiga OS 3 specific stuff */ +#define socklen_t int +#else +#include +#endif #include #include #include #include #include -#include #include +#if !defined(__amigaos__) && !defined(__amigaos4__) +#include +#endif +#include +#include #define closesocket close +#define MINIUPNPC_IGNORE_EINTR +#endif /* #else WIN32 */ +#ifdef MINIUPNPC_SET_SOCKET_TIMEOUT +#include +#endif +#if defined(__amigaos__) || defined(__amigaos4__) +/* Amiga OS specific stuff */ +#define TIMEVAL struct timeval #endif + #include "miniupnpc.h" #include "minissdpc.h" #include "miniwget.h" #include "minisoap.h" #include "minixml.h" #include "upnpcommands.h" - -/* Uncomment the following to transmit the msearch from the same port - * as the UPnP multicast port. With WinXP this seems to result in the - * responses to the msearch being lost, thus if things dont work then - * comment this out. */ -/* #define TX_FROM_UPNP_PORT */ +#include "connecthostport.h" #ifdef WIN32 #define PRINT_SOCKET_ERROR(x) printf("Socket error: %s, %d\n", x, WSAGetLastError()); @@ -44,8 +81,12 @@ #define PRINT_SOCKET_ERROR(x) perror(x) #endif +#define SOAPPREFIX "s" +#define SERVICEPREFIX "u" +#define SERVICEPREFIX2 'u' + /* root description parsing */ -void parserootdesc(const char * buffer, int bufsize, struct IGDdatas * data) +LIBSPEC void parserootdesc(const char * buffer, int bufsize, struct IGDdatas * data) { struct xmlparser parser; /* xmlparser object */ @@ -57,12 +98,13 @@ parser.datafunc = IGDdata; parser.attfunc = 0; parsexml(&parser); -#ifndef NDEBUG +#ifdef DEBUG printIGD(data); #endif } -/* Content-length: nnn */ +/* getcontentlenfromline() : parse the Content-Length HTTP header line. + * Content-length: nnn */ static int getcontentlenfromline(const char * p, int n) { static const char contlenstr[] = "content-length"; @@ -97,6 +139,10 @@ return a; } +/* getContentLengthAndHeaderLength() + * retrieve header length and content length from an HTTP response + * TODO : retrieve Transfer-Encoding: header value, in order to support + * HTTP/1.1, chunked transfer encoding must be supported. */ static void getContentLengthAndHeaderLength(char * p, int n, int * contentlen, int * headerlen) @@ -135,51 +181,42 @@ const char * action, struct UPNParg * args, char * buffer, int * bufsize) { - struct sockaddr_in dest; char hostname[MAXHOSTNAMELEN+1]; unsigned short port = 0; char * path; char soapact[128]; char soapbody[2048]; - int soapbodylen; char * buf; int buffree; int n; int contentlen, headerlen; /* for the response */ + snprintf(soapact, sizeof(soapact), "%s#%s", service, action); if(args==NULL) { - /*soapbodylen = snprintf(soapbody, sizeof(soapbody), + /*soapbodylen = */snprintf(soapbody, sizeof(soapbody), "\r\n" - "" - "" - "" - "" - "\r\n", action, service);*/ - soapbodylen = snprintf(soapbody, sizeof(soapbody), - "\r\n" - "" - "" - "" - "" - "" + "<" SOAPPREFIX ":Envelope " + "xmlns:" SOAPPREFIX "=\"http://schemas.xmlsoap.org/soap/envelope/\" " + SOAPPREFIX ":encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">" + "<" SOAPPREFIX ":Body>" + "<" SERVICEPREFIX ":%s xmlns:" SERVICEPREFIX "=\"%s\">" + "" + "" "\r\n", action, service, action); } else { char * p; const char * pe, * pv; + int soapbodylen; soapbodylen = snprintf(soapbody, sizeof(soapbody), "\r\n" - "" - "" - "", + "<" SOAPPREFIX ":Envelope " + "xmlns:" SOAPPREFIX "=\"http://schemas.xmlsoap.org/soap/envelope/\" " + SOAPPREFIX ":encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">" + "<" SOAPPREFIX ":Body>" + "<" SERVICEPREFIX ":%s xmlns:" SERVICEPREFIX "=\"%s\">", action, service); p = soapbody + soapbodylen; while(args->elt) @@ -211,31 +248,20 @@ } *(p++) = '<'; *(p++) = '/'; - *(p++) = 'm'; + *(p++) = SERVICEPREFIX2; *(p++) = ':'; pe = action; while(*pe) *(p++) = *(pe++); - strncpy(p, ">\r\n", + strncpy(p, ">\r\n", soapbody + sizeof(soapbody) - p); } if(!parseURL(url, hostname, &port, &path)) return -1; if(s<0) { - s = socket(PF_INET, SOCK_STREAM, 0); - if(s<0) - { - PRINT_SOCKET_ERROR("socket"); - *bufsize = 0; - return -1; - } - dest.sin_family = AF_INET; - dest.sin_port = htons(port); - dest.sin_addr.s_addr = inet_addr(hostname); - if(connect(s, (struct sockaddr *)&dest, sizeof(struct sockaddr))<0) + s = connecthostport(hostname, port); + if(s < 0) { - PRINT_SOCKET_ERROR("connect"); - closesocket(s); *bufsize = 0; return -1; } @@ -335,7 +361,9 @@ } /* port upnp discover : SSDP protocol */ -#define PORT (1900) +#define PORT 1900 +#define XSTR(s) STR(s) +#define STR(s) #s #define UPNP_MCAST_ADDR "239.255.255.250" /* upnpDiscover() : @@ -343,18 +371,18 @@ * no devices was found. * It is up to the caller to free the chained list * delay is in millisecond (poll) */ -struct UPNPDev * upnpDiscover(int delay, const char * multicastif, - const char * minissdpdsock) +LIBSPEC struct UPNPDev * upnpDiscover(int delay, const char * multicastif, + const char * minissdpdsock, int sameport) { struct UPNPDev * tmp; struct UPNPDev * devlist = 0; int opt = 1; static const char MSearchMsgFmt[] = "M-SEARCH * HTTP/1.1\r\n" - "HOST: " UPNP_MCAST_ADDR ":" "1900" "\r\n" + "HOST: " UPNP_MCAST_ADDR ":" XSTR(PORT) "\r\n" "ST: %s\r\n" "MAN: \"ssdp:discover\"\r\n" - "MX: 3\r\n" + "MX: %u\r\n" "\r\n"; static const char * const deviceList[] = { "urn:schemas-upnp-org:device:InternetGatewayDevice:1", @@ -367,9 +395,15 @@ char bufr[1536]; /* reception and emission buffer */ int sudp; int n; - struct sockaddr_in sockudp_r, sockudp_w; + struct sockaddr sockudp_r; + unsigned int mx; + int rv; + struct addrinfo hints, *servinfo, *p; +#ifdef WIN32 + /*MIB_IPFORWARDROW ip_forward;*/ +#endif -#ifndef WIN32 +#if !defined(WIN32) && !defined(__amigaos__) && !defined(__amigaos4__) /* first try to get infos from minissdpd ! */ if(!minissdpdsock) minissdpdsock = "/var/run/minissdpd.sock"; @@ -394,18 +428,67 @@ PRINT_SOCKET_ERROR("socket"); return NULL; } - /* reception */ - memset(&sockudp_r, 0, sizeof(struct sockaddr_in)); - sockudp_r.sin_family = AF_INET; -#ifdef TX_FROM_UPNP_PORT - sockudp_r.sin_port = htons(PORT); -#endif - sockudp_r.sin_addr.s_addr = INADDR_ANY; - /* emission */ - memset(&sockudp_w, 0, sizeof(struct sockaddr_in)); - sockudp_w.sin_family = AF_INET; - sockudp_w.sin_port = htons(PORT); - sockudp_w.sin_addr.s_addr = inet_addr(UPNP_MCAST_ADDR); + /* reception */ + memset(&sockudp_r, 0, sizeof(struct sockaddr)); + if(0/*ipv6*/) { + struct sockaddr_in6 * p = (struct sockaddr_in6 *)&sockudp_r; + p->sin6_family = AF_INET6; + if(sameport) + p->sin6_port = htons(PORT); + p->sin6_addr = in6addr_any;//IN6ADDR_ANY_INIT;/*INADDR_ANY;*/ + } else { + struct sockaddr_in * p = (struct sockaddr_in *)&sockudp_r; + p->sin_family = AF_INET; + if(sameport) + p->sin_port = htons(PORT); + p->sin_addr.s_addr = INADDR_ANY; + } +#if 0 + /* emission */ + memset(&sockudp_w, 0, sizeof(struct sockaddr_in)); + sockudp_w.sin_family = AF_INET; + sockudp_w.sin_port = htons(PORT); + sockudp_w.sin_addr.s_addr = inet_addr(UPNP_MCAST_ADDR); +#endif +#ifdef WIN32 +/* This code could help us to use the right Network interface for + * SSDP multicast traffic */ +/* TODO : Get IP associated with the index given in the ip_forward struct + * in order to give this ip to setsockopt(sudp, IPPROTO_IP, IP_MULTICAST_IF) */ + /* + if(GetBestRoute(inet_addr("223.255.255.255"), 0, &ip_forward) == NO_ERROR) { + DWORD dwRetVal = 0; + PMIB_IPADDRTABLE pIPAddrTable; + DWORD dwSize = 0; + IN_ADDR IPAddr; + int i; + printf("ifIndex=%lu nextHop=%lx \n", ip_forward.dwForwardIfIndex, ip_forward.dwForwardNextHop); + pIPAddrTable = (MIB_IPADDRTABLE *) malloc(sizeof (MIB_IPADDRTABLE)); + if (GetIpAddrTable(pIPAddrTable, &dwSize, 0) == ERROR_INSUFFICIENT_BUFFER) { + free(pIPAddrTable); + pIPAddrTable = (MIB_IPADDRTABLE *) malloc(dwSize); + } + if(pIPAddrTable) { + dwRetVal = GetIpAddrTable( pIPAddrTable, &dwSize, 0 ); + printf("\tNum Entries: %ld\n", pIPAddrTable->dwNumEntries); + for (i=0; i < (int) pIPAddrTable->dwNumEntries; i++) { + printf("\n\tInterface Index[%d]:\t%ld\n", i, pIPAddrTable->table[i].dwIndex); + IPAddr.S_un.S_addr = (u_long) pIPAddrTable->table[i].dwAddr; + printf("\tIP Address[%d]: \t%s\n", i, inet_ntoa(IPAddr) ); + IPAddr.S_un.S_addr = (u_long) pIPAddrTable->table[i].dwMask; + printf("\tSubnet Mask[%d]: \t%s\n", i, inet_ntoa(IPAddr) ); + IPAddr.S_un.S_addr = (u_long) pIPAddrTable->table[i].dwBCastAddr; + printf("\tBroadCast[%d]: \t%s (%ld)\n", i, inet_ntoa(IPAddr), pIPAddrTable->table[i].dwBCastAddr); + printf("\tReassembly size[%d]:\t%ld\n", i, pIPAddrTable->table[i].dwReasmSize); + printf("\tType and State[%d]:", i); + printf("\n"); + } + free(pIPAddrTable); + pIPAddrTable = NULL; + } + } +*/ +#endif #ifdef WIN32 if (setsockopt(sudp, SOL_SOCKET, SO_REUSEADDR, (const char *)&opt, sizeof (opt)) < 0) @@ -421,7 +504,10 @@ { struct in_addr mc_if; mc_if.s_addr = inet_addr(multicastif); - sockudp_r.sin_addr.s_addr = mc_if.s_addr; + if(0/*ipv6*/) { + } else { + ((struct sockaddr_in *)&sockudp_r)->sin_addr.s_addr = mc_if.s_addr; + } if(setsockopt(sudp, IPPROTO_IP, IP_MULTICAST_IF, (const char *)&mc_if, sizeof(mc_if)) < 0) { PRINT_SOCKET_ERROR("setsockopt"); @@ -429,13 +515,15 @@ } /* Avant d'envoyer le paquet on bind pour recevoir la reponse */ - if (bind(sudp, (struct sockaddr *)&sockudp_r, sizeof(struct sockaddr_in)) != 0) + if (bind(sudp, &sockudp_r, 0/*ipv6*/?sizeof(struct sockaddr_in6):sizeof(struct sockaddr_in)) != 0) { PRINT_SOCKET_ERROR("bind"); closesocket(sudp); return NULL; } + /* Calculating maximum response time in seconds */ + mx = ((unsigned int)delay) / 1000u; /* receiving SSDP response packet */ for(n = 0;;) { @@ -443,8 +531,9 @@ { /* sending the SSDP M-SEARCH packet */ n = snprintf(bufr, sizeof(bufr), - MSearchMsgFmt, deviceList[deviceIndex++]); + MSearchMsgFmt, deviceList[deviceIndex++], mx); /*printf("Sending %s", bufr);*/ +#if 0 n = sendto(sudp, bufr, n, 0, (struct sockaddr *)&sockudp_w, sizeof(struct sockaddr_in)); if (n < 0) { @@ -452,6 +541,31 @@ closesocket(sudp); return devlist; } +#endif + memset(&hints, 0, sizeof(hints)); + hints.ai_family = AF_UNSPEC; // AF_INET6 or AF_INET + hints.ai_socktype = SOCK_DGRAM; + /*hints.ai_flags = */ + if ((rv = getaddrinfo(UPNP_MCAST_ADDR, XSTR(PORT), &hints, &servinfo)) != 0) { +#ifdef WIN32 + fprintf(stderr, "getaddrinfo() failed: %d\n", rv); +#else + fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(rv)); +#endif + return devlist; + } + for(p = servinfo; p; p = p->ai_next) { + n = sendto(sudp, bufr, n, 0, p->ai_addr, p->ai_addrlen); + if (n < 0) { + PRINT_SOCKET_ERROR("sendto"); + continue; + } + } + freeaddrinfo(servinfo); + if(n < 0) { + closesocket(sudp); + return devlist; + } } /* Waiting for SSDP REPLY packet to M-SEARCH */ n = ReceiveData(sudp, bufr, sizeof(bufr), delay); @@ -493,7 +607,7 @@ /* freeUPNPDevlist() should be used to * free the chained list returned by upnpDiscover() */ -void freeUPNPDevlist(struct UPNPDev * devlist) +LIBSPEC void freeUPNPDevlist(struct UPNPDev * devlist) { struct UPNPDev * next; while(devlist) @@ -529,7 +643,7 @@ /* Prepare the Urls for usage... */ -void GetUPNPUrls(struct UPNPUrls * urls, struct IGDdatas * data, +LIBSPEC void GetUPNPUrls(struct UPNPUrls * urls, struct IGDdatas * data, const char * descURL) { char * p; @@ -539,9 +653,9 @@ n1 = strlen(descURL); n1 += 2; /* 1 byte more for Null terminator, 1 byte for '/' if needed */ n2 = n1; n3 = n1; - n1 += strlen(data->scpdurl); - n2 += strlen(data->controlurl); - n3 += strlen(data->controlurl_CIF); + n1 += strlen(data->first.scpdurl); + n2 += strlen(data->first.controlurl); + n3 += strlen(data->CIF.controlurl); urls->ipcondescURL = (char *)malloc(n1); urls->controlURL = (char *)malloc(n2); @@ -556,23 +670,23 @@ strncpy(urls->controlURL, urls->ipcondescURL, n2); strncpy(urls->controlURL_CIF, urls->ipcondescURL, n3); - url_cpy_or_cat(urls->ipcondescURL, data->scpdurl, n1); + url_cpy_or_cat(urls->ipcondescURL, data->first.scpdurl, n1); - url_cpy_or_cat(urls->controlURL, data->controlurl, n2); + url_cpy_or_cat(urls->controlURL, data->first.controlurl, n2); - url_cpy_or_cat(urls->controlURL_CIF, data->controlurl_CIF, n3); + url_cpy_or_cat(urls->controlURL_CIF, data->CIF.controlurl, n3); #ifdef DEBUG - printf("urls->ipcondescURL='%s' %d n1=%d\n", urls->ipcondescURL, - strlen(urls->ipcondescURL), n1); - printf("urls->controlURL='%s' %d n2=%d\n", urls->controlURL, - strlen(urls->controlURL), n2); - printf("urls->controlURL_CIF='%s' %d n3=%d\n", urls->controlURL_CIF, - strlen(urls->controlURL_CIF), n3); + printf("urls->ipcondescURL='%s' %u n1=%d\n", urls->ipcondescURL, + (unsigned)strlen(urls->ipcondescURL), n1); + printf("urls->controlURL='%s' %u n2=%d\n", urls->controlURL, + (unsigned)strlen(urls->controlURL), n2); + printf("urls->controlURL_CIF='%s' %u n3=%d\n", urls->controlURL_CIF, + (unsigned)strlen(urls->controlURL_CIF), n3); #endif } -void +LIBSPEC void FreeUPNPUrls(struct UPNPUrls * urls) { if(!urls) @@ -589,11 +703,17 @@ int ReceiveData(int socket, char * data, int length, int timeout) { int n; -#ifndef WIN32 +#if !defined(WIN32) && !defined(__amigaos__) && !defined(__amigaos4__) struct pollfd fds[1]; /* for the poll */ - fds[0].fd = socket; - fds[0].events = POLLIN; - n = poll(fds, 1, timeout); +#ifdef MINIUPNPC_IGNORE_EINTR + do { +#endif + fds[0].fd = socket; + fds[0].events = POLLIN; + n = poll(fds, 1, timeout); +#ifdef MINIUPNPC_IGNORE_EINTR + } while(n < 0 && errno == EINTR); +#endif if(n < 0) { PRINT_SOCKET_ERROR("poll"); @@ -610,7 +730,6 @@ FD_SET(socket, &socketSet); timeval.tv_sec = timeout / 1000; timeval.tv_usec = (timeout % 1000) * 1000; - /*n = select(0, &socketSet, NULL, NULL, &timeval);*/ n = select(FD_SETSIZE, &socketSet, NULL, NULL, &timeval); if(n < 0) { @@ -636,7 +755,7 @@ char status[64]; unsigned int uptime; status[0] = '\0'; - UPNP_GetStatusInfo(urls->controlURL, data->servicetype, + UPNP_GetStatusInfo(urls->controlURL, data->first.servicetype, status, &uptime, NULL); if(0 == strcmp("Connected", status)) { @@ -659,7 +778,7 @@ * passed as parameters are set. Donc forget to call FreeUPNPUrls(urls) to * free allocated memory. */ -int +LIBSPEC int UPNP_GetValidIGD(struct UPNPDev * devlist, struct UPNPUrls * urls, struct IGDdatas * data, @@ -693,7 +812,7 @@ parserootdesc(descXML, descXMLsize, data); free(descXML); descXML = NULL; - if(0==strcmp(data->servicetype_CIF, + if(0==strcmp(data->CIF.servicetype, "urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1") || state >= 3 ) { @@ -707,6 +826,25 @@ if((state >= 2) || UPNPIGD_IsConnected(urls, data)) return state; FreeUPNPUrls(urls); + if(data->second.servicetype[0] != '\0') { +#ifdef DEBUG + printf("We tried %s, now we try %s !\n", + data->first.servicetype, data->second.servicetype); +#endif + /* swaping WANPPPConnection and WANIPConnection ! */ + memcpy(&data->tmp, &data->first, sizeof(struct IGDdatas_service)); + memcpy(&data->first, &data->second, sizeof(struct IGDdatas_service)); + memcpy(&data->second, &data->tmp, sizeof(struct IGDdatas_service)); + GetUPNPUrls(urls, data, dev->descURL); +#ifdef DEBUG + printf("UPNPIGD_IsConnected(%s) = %d\n", + urls->controlURL, + UPNPIGD_IsConnected(urls, data)); +#endif + if((state >= 2) || UPNPIGD_IsConnected(urls, data)) + return state; + FreeUPNPUrls(urls); + } } memset(data, 0, sizeof(struct IGDdatas)); } diff -Nru vidalia-0.1.13/src/miniupnpc/miniupnpc.h vidalia-0.2.8/src/miniupnpc/miniupnpc.h --- vidalia-0.1.13/src/miniupnpc/miniupnpc.h 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/src/miniupnpc/miniupnpc.h 2010-04-10 00:17:13.000000000 +0100 @@ -1,4 +1,4 @@ -/* $Id: miniupnpc.h,v 1.17 2007/12/19 14:58:54 nanard Exp $ */ +/* $Id: miniupnpc.h,v 1.19 2009/10/10 19:15:35 nanard Exp $ */ /* Project: miniupnp * http://miniupnp.free.fr/ * Author: Thomas Bernard @@ -39,9 +39,11 @@ * Default path for minissdpd socket will be used if minissdpdsock argument * is NULL. * If multicastif is not NULL, it will be used instead of the default - * multicast interface for sending SSDP discover packets. */ + * multicast interface for sending SSDP discover packets. + * If sameport is not null, SSDP packets will be sent from the source port + * 1900 (same as destination port) otherwise system assign a source port. */ LIBSPEC struct UPNPDev * upnpDiscover(int delay, const char * multicastif, - const char * minissdpdsock); + const char * minissdpdsock, int sameport); /* freeUPNPDevlist() * free list returned by upnpDiscover() */ LIBSPEC void freeUPNPDevlist(struct UPNPDev * devlist); @@ -100,6 +102,10 @@ * read or if we timed out. Returns negative if there was an error. */ int ReceiveData(int socket, char * data, int length, int timeout); +/* return 0 or 1 */ +LIBSPEC int UPNPIGD_IsConnected(struct UPNPUrls *, struct IGDdatas *); + + #ifdef __cplusplus } #endif diff -Nru vidalia-0.1.13/src/miniupnpc/miniupnpcmodule.c vidalia-0.2.8/src/miniupnpc/miniupnpcmodule.c --- vidalia-0.1.13/src/miniupnpc/miniupnpcmodule.c 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/src/miniupnpc/miniupnpcmodule.c 2010-04-10 00:17:13.000000000 +0100 @@ -1,8 +1,8 @@ -/* $Id: miniupnpcmodule.c,v 1.7 2007/12/19 15:00:47 nanard Exp $*/ +/* $Id: miniupnpcmodule.c,v 1.14 2009/10/16 09:02:47 nanard Exp $*/ /* Project : miniupnp * Author : Thomas BERNARD * website : http://miniupnp.tuxfamily.org/ - * copyright (c) 2007 Thomas Bernard + * copyright (c) 2007-2009 Thomas Bernard * This software is subjet to the conditions detailed in the * provided LICENCE file. */ #include @@ -10,6 +10,7 @@ #include "structmember.h" #include "miniupnpc.h" #include "upnpcommands.h" +#include "upnperrors.h" /* for compatibility with Python < 2.4 */ #ifndef Py_RETURN_NONE @@ -71,10 +72,13 @@ { freeUPNPDevlist(self->devlist); self->devlist = 0; - } + } + Py_BEGIN_ALLOW_THREADS self->devlist = upnpDiscover((int)self->discoverdelay/*timeout in ms*/, 0/* multicast if*/, - 0/*minissdpd socket*/); + 0/*minissdpd socket*/, + 0/*sameport flag*/); + Py_END_ALLOW_THREADS /* Py_RETURN_NONE ??? */ for(dev = self->devlist, i = 0; dev; dev = dev->pNext) i++; @@ -85,8 +89,12 @@ static PyObject * UPnP_selectigd(UPnPObject *self) { - if(UPNP_GetValidIGD(self->devlist, &self->urls, &self->data, - self->lanaddr, sizeof(self->lanaddr))) + int r; +Py_BEGIN_ALLOW_THREADS + r = UPNP_GetValidIGD(self->devlist, &self->urls, &self->data, + self->lanaddr, sizeof(self->lanaddr)); +Py_END_ALLOW_THREADS + if(r) { return Py_BuildValue("s", self->urls.controlURL); } @@ -101,69 +109,111 @@ static PyObject * UPnP_totalbytesent(UPnPObject *self) { - return Py_BuildValue("I", - UPNP_GetTotalBytesSent(self->urls.controlURL_CIF, - self->data.servicetype_CIF)); + UNSIGNED_INTEGER i; +Py_BEGIN_ALLOW_THREADS + i = UPNP_GetTotalBytesSent(self->urls.controlURL_CIF, + self->data.servicetype_CIF); +Py_END_ALLOW_THREADS + return Py_BuildValue("I", i); } static PyObject * UPnP_totalbytereceived(UPnPObject *self) { - return Py_BuildValue("I", - UPNP_GetTotalBytesReceived(self->urls.controlURL_CIF, - self->data.servicetype_CIF)); + UNSIGNED_INTEGER i; +Py_BEGIN_ALLOW_THREADS + i = UPNP_GetTotalBytesReceived(self->urls.controlURL_CIF, + self->data.servicetype_CIF); +Py_END_ALLOW_THREADS + return Py_BuildValue("I", i); } static PyObject * UPnP_totalpacketsent(UPnPObject *self) { - return Py_BuildValue("I", - UPNP_GetTotalPacketsSent(self->urls.controlURL_CIF, - self->data.servicetype_CIF)); + UNSIGNED_INTEGER i; +Py_BEGIN_ALLOW_THREADS + i = UPNP_GetTotalPacketsSent(self->urls.controlURL_CIF, + self->data.servicetype_CIF); +Py_END_ALLOW_THREADS + return Py_BuildValue("I", i); } static PyObject * UPnP_totalpacketreceived(UPnPObject *self) { - return Py_BuildValue("I", - UPNP_GetTotalPacketsReceived(self->urls.controlURL_CIF, - self->data.servicetype_CIF)); + UNSIGNED_INTEGER i; +Py_BEGIN_ALLOW_THREADS + i = UPNP_GetTotalPacketsReceived(self->urls.controlURL_CIF, + self->data.servicetype_CIF); +Py_END_ALLOW_THREADS + return Py_BuildValue("I", i); } static PyObject * UPnP_statusinfo(UPnPObject *self) { char status[64]; + char lastconnerror[64]; unsigned int uptime = 0; + int r; status[0] = '\0'; - UPNP_GetStatusInfo(self->urls.controlURL, self->data.servicetype, - status, &uptime); - return Py_BuildValue("(s,I)", status, uptime); + lastconnerror[0] = '\0'; +Py_BEGIN_ALLOW_THREADS + r = UPNP_GetStatusInfo(self->urls.controlURL, self->data.servicetype, + status, &uptime, lastconnerror); +Py_END_ALLOW_THREADS + if(r==UPNPCOMMAND_SUCCESS) { + return Py_BuildValue("(s,I,s)", status, uptime, lastconnerror); + } else { + /* TODO: have our own exception type ! */ + PyErr_SetString(PyExc_Exception, strupnperror(r)); + return NULL; + } } static PyObject * UPnP_connectiontype(UPnPObject *self) { char connectionType[64]; + int r; connectionType[0] = '\0'; - UPNP_GetConnectionTypeInfo(self->urls.controlURL, - self->data.servicetype, - connectionType); - return Py_BuildValue("s", connectionType); +Py_BEGIN_ALLOW_THREADS + r = UPNP_GetConnectionTypeInfo(self->urls.controlURL, + self->data.servicetype, + connectionType); +Py_END_ALLOW_THREADS + if(r==UPNPCOMMAND_SUCCESS) { + return Py_BuildValue("s", connectionType); + } else { + /* TODO: have our own exception type ! */ + PyErr_SetString(PyExc_Exception, strupnperror(r)); + return NULL; + } } static PyObject * UPnP_externalipaddress(UPnPObject *self) { char externalIPAddress[16]; + int r; externalIPAddress[0] = '\0'; - UPNP_GetExternalIPAddress(self->urls.controlURL, - self->data.servicetype, - externalIPAddress); - return Py_BuildValue("s", externalIPAddress); +Py_BEGIN_ALLOW_THREADS + r = UPNP_GetExternalIPAddress(self->urls.controlURL, + self->data.servicetype, + externalIPAddress); +Py_END_ALLOW_THREADS + if(r==UPNPCOMMAND_SUCCESS) { + return Py_BuildValue("s", externalIPAddress); + } else { + /* TODO: have our own exception type ! */ + PyErr_SetString(PyExc_Exception, strupnperror(r)); + return NULL; + } } -/* AddPortMapping(externalPort, protocol, internalHost, internalPort, desc) +/* AddPortMapping(externalPort, protocol, internalHost, internalPort, desc, + * remoteHost) * protocol is 'UDP' or 'TCP' */ static PyObject * UPnP_addportmapping(UPnPObject *self, PyObject *args) @@ -175,25 +225,33 @@ const char * proto; const char * host; const char * desc; + const char * remoteHost; int r; - if (!PyArg_ParseTuple(args, "HssHs", &ePort, &proto, - &host, &iPort, &desc)) + if (!PyArg_ParseTuple(args, "HssHss", &ePort, &proto, + &host, &iPort, &desc, &remoteHost)) return NULL; +Py_BEGIN_ALLOW_THREADS sprintf(extPort, "%hu", ePort); sprintf(inPort, "%hu", iPort); r = UPNP_AddPortMapping(self->urls.controlURL, self->data.servicetype, - extPort, inPort, host, desc, proto); - if(r) + extPort, inPort, host, desc, proto, remoteHost); +Py_END_ALLOW_THREADS + if(r==UPNPCOMMAND_SUCCESS) { Py_RETURN_TRUE; } else { - Py_RETURN_FALSE; + // TODO: RAISE an Exception. See upnpcommands.h for errors codes. + // upnperrors.c + //Py_RETURN_FALSE; + /* TODO: have our own exception type ! */ + PyErr_SetString(PyExc_Exception, strupnperror(r)); + return NULL; } } -/* DeletePortMapping(extPort, proto) +/* DeletePortMapping(extPort, proto, removeHost='') * proto = 'UDP', 'TCP' */ static PyObject * UPnP_deleteportmapping(UPnPObject *self, PyObject *args) @@ -201,22 +259,41 @@ char extPort[6]; unsigned short ePort; const char * proto; - if(!PyArg_ParseTuple(args, "Hs", &ePort, &proto)) + const char * remoteHost = ""; + int r; + if(!PyArg_ParseTuple(args, "Hs|z", &ePort, &proto, &remoteHost)) return NULL; +Py_BEGIN_ALLOW_THREADS sprintf(extPort, "%hu", ePort); - UPNP_DeletePortMapping(self->urls.controlURL, self->data.servicetype, - extPort, proto); - Py_RETURN_TRUE; + r = UPNP_DeletePortMapping(self->urls.controlURL, self->data.servicetype, + extPort, proto, remoteHost); +Py_END_ALLOW_THREADS + if(r==UPNPCOMMAND_SUCCESS) { + Py_RETURN_TRUE; + } else { + /* TODO: have our own exception type ! */ + PyErr_SetString(PyExc_Exception, strupnperror(r)); + return NULL; + } } static PyObject * UPnP_getportmappingnumberofentries(UPnPObject *self) { unsigned int n = 0; - UPNP_GetPortMappingNumberOfEntries(self->urls.controlURL, + int r; +Py_BEGIN_ALLOW_THREADS + r = UPNP_GetPortMappingNumberOfEntries(self->urls.controlURL, self->data.servicetype, &n); - return Py_BuildValue("I", n); +Py_END_ALLOW_THREADS + if(r==UPNPCOMMAND_SUCCESS) { + return Py_BuildValue("I", n); + } else { + /* TODO: have our own exception type ! */ + PyErr_SetString(PyExc_Exception, strupnperror(r)); + return NULL; + } } /* GetSpecificPortMapping(ePort, proto) @@ -232,11 +309,13 @@ unsigned short iPort; if(!PyArg_ParseTuple(args, "Hs", &ePort, &proto)) return NULL; +Py_BEGIN_ALLOW_THREADS sprintf(extPort, "%hu", ePort); UPNP_GetSpecificPortMappingEntry(self->urls.controlURL, self->data.servicetype, extPort, proto, intClient, intPort); +Py_END_ALLOW_THREADS if(intClient[0]) { iPort = (unsigned short)atoi(intPort); @@ -267,6 +346,7 @@ unsigned int dur; if(!PyArg_ParseTuple(args, "i", &i)) return NULL; +Py_BEGIN_ALLOW_THREADS snprintf(index, sizeof(index), "%d", i); rHost[0] = '\0'; enabled[0] = '\0'; duration[0] = '\0'; desc[0] = '\0'; @@ -277,11 +357,8 @@ extPort, intClient, intPort, protocol, desc, enabled, rHost, duration); - if(r) - { - Py_RETURN_NONE; - } - else +Py_END_ALLOW_THREADS + if(r==UPNPCOMMAND_SUCCESS) { ePort = (unsigned short)atoi(extPort); iPort = (unsigned short)atoi(intPort); @@ -290,6 +367,10 @@ ePort, protocol, intClient, iPort, desc, enabled, rHost, dur); } + else + { + Py_RETURN_NONE; + } } /* miniupnpc.UPnP object Method Table */ diff -Nru vidalia-0.1.13/src/miniupnpc/miniupnpcstrings.h vidalia-0.2.8/src/miniupnpc/miniupnpcstrings.h --- vidalia-0.1.13/src/miniupnpc/miniupnpcstrings.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/miniupnpc/miniupnpcstrings.h 2010-04-10 00:17:13.000000000 +0100 @@ -0,0 +1,15 @@ +/* $Id: miniupnpcstrings.h.in,v 1.2 2009/10/30 09:18:18 nanard Exp $ */ +/* Project: miniupnp + * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ + * Author: Thomas Bernard + * Copyright (c) 2005-2009 Thomas Bernard + * This software is subjects to the conditions detailed + * in the LICENCE file provided within this distribution */ +#ifndef __MINIUPNPCSTRINGS_H__ +#define __MINIUPNPCSTRINGS_H__ + +#define OS_STRING "Darwin/10.3.0" +#define MINIUPNPC_VERSION_STRING "1.4" + +#endif + diff -Nru vidalia-0.1.13/src/miniupnpc/miniwget.c vidalia-0.2.8/src/miniupnpc/miniwget.c --- vidalia-0.1.13/src/miniupnpc/miniwget.c 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/src/miniupnpc/miniwget.c 2010-04-10 00:17:13.000000000 +0100 @@ -1,38 +1,49 @@ -/* $Id: miniwget.c,v 1.19 2007/11/02 14:16:19 nanard Exp $ */ +/* $Id: miniwget.c,v 1.36 2010/04/05 12:34:05 nanard Exp $ */ /* Project : miniupnp * Author : Thomas Bernard - * Copyright (c) 2005 Thomas Bernard + * Copyright (c) 2005-2010 Thomas Bernard * This software is subject to the conditions detailed in the - * LICENCE file provided in this distribution. - * */ + * LICENCE file provided in this distribution. */ + #include #include #include #include "miniupnpc.h" #ifdef WIN32 #include +#include #include #define MAXHOSTNAMELEN 64 #define MIN(x,y) (((x)<(y))?(x):(y)) #define snprintf _snprintf -#define herror #define socklen_t int -#else +#else /* #ifdef WIN32 */ #include #include +#if defined(__amigaos__) && !defined(__amigaos4__) +#define socklen_t int +#else /* #if defined(__amigaos__) && !defined(__amigaos4__) */ +#include +#endif /* #else defined(__amigaos__) && !defined(__amigaos4__) */ #include -#include -#include #include +#include #define closesocket close -#endif -/* for MIN() macro : */ +/* defining MINIUPNPC_IGNORE_EINTR enable the ignore of interruptions + * during the connect() call */ +#define MINIUPNPC_IGNORE_EINTR +#endif /* #else WIN32 */ #if defined(__sun) || defined(sun) -#include +#define MIN(x,y) (((x)<(y))?(x):(y)) #endif +#include "miniupnpcstrings.h" +#include "miniwget.h" +#include "connecthostport.h" + /* miniwget2() : - * */ + * do all the work. + * Return NULL if something failed. */ static void * miniwget2(const char * url, const char * host, unsigned short port, const char * path, @@ -40,44 +51,29 @@ { char buf[2048]; int s; - struct sockaddr_in dest; - struct hostent *hp; + int n; + int len; + int sent; + *size = 0; - hp = gethostbyname(host); - if(hp==NULL) - { - herror(host); - return NULL; - } - /* memcpy((char *)&dest.sin_addr, hp->h_addr, hp->h_length); */ - memcpy(&dest.sin_addr, hp->h_addr, sizeof(dest.sin_addr)); - memset(dest.sin_zero, 0, sizeof(dest.sin_zero)); - s = socket(PF_INET, SOCK_STREAM, 0); + s = connecthostport(host, port); if(s < 0) - { - perror("socket"); return NULL; - } - dest.sin_family = AF_INET; - dest.sin_port = htons(port); - if(connect(s, (struct sockaddr *)&dest, sizeof(struct sockaddr_in))<0) - { - perror("connect"); - closesocket(s); - return NULL; - } /* get address for caller ! */ if(addr_str) { - struct sockaddr_in saddr; - socklen_t len; + struct sockaddr saddr; + socklen_t saddrlen; - len = sizeof(saddr); - getsockname(s, (struct sockaddr *)&saddr, &len); -#ifndef WIN32 - inet_ntop(AF_INET, &saddr.sin_addr, addr_str, addr_str_len); -#else + saddrlen = sizeof(saddr); + if(getsockname(s, &saddr, &saddrlen) < 0) + { + perror("getsockname"); + } + else + { +#if defined(__amigaos__) && !defined(__amigaos4__) /* using INT WINAPI WSAAddressToStringA(LPSOCKADDR, DWORD, LPWSAPROTOCOL_INFOA, LPSTR, LPDWORD); * But his function make a string with the port : nn.nn.nn.nn:port */ /* if(WSAAddressToStringA((SOCKADDR *)&saddr, sizeof(saddr), @@ -85,23 +81,56 @@ { printf("WSAAddressToStringA() failed : %d\n", WSAGetLastError()); }*/ - strncpy(addr_str, inet_ntoa(saddr.sin_addr), addr_str_len); + strncpy(addr_str, inet_ntoa(((struct sockaddr_in *)&saddr)->sin_addr), addr_str_len); +#else + /*inet_ntop(AF_INET, &saddr.sin_addr, addr_str, addr_str_len);*/ + n = getnameinfo(&saddr, saddrlen, + addr_str, addr_str_len, + NULL, 0, + NI_NUMERICHOST | NI_NUMERICSERV); + if(n != 0) { +#ifdef WIN32 + fprintf(stderr, "getnameinfo() failed : %d\n", n); +#else + fprintf(stderr, "getnameinfo() failed : %s\n", gai_strerror(n)); +#endif + } #endif + } #ifdef DEBUG printf("address miniwget : %s\n", addr_str); #endif } - snprintf(buf, sizeof(buf), - "GET %s HTTP/1.1\r\n" + len = snprintf(buf, sizeof(buf), + "GET %s HTTP/1.0\r\n" "Host: %s:%d\r\n" "Connection: Close\r\n" + "User-Agent: " OS_STRING ", UPnP/1.0, MiniUPnPc/" MINIUPNPC_VERSION_STRING "\r\n" + "\r\n", path, host, port); - /*write(s, buf, strlen(buf));*/ - send(s, buf, strlen(buf), 0); + sent = 0; + /* sending the HTTP request */ + while(sent < len) + { + n = send(s, buf+sent, len-sent, 0); + if(n < 0) + { + perror("send"); + closesocket(s); + return NULL; + } + else + { + sent += n; + } + } { - int n, headers=1; + /* TODO : in order to support HTTP/1.1, chunked transfer encoding + * must be supported. That means parsing of headers must be + * added. */ + int headers=1; char * respbuffer = NULL; int allreadyread = 0; /*while((n = recv(s, buf, 2048, 0)) > 0)*/ @@ -112,12 +141,14 @@ int i=0; while(i= 199901L) +#define UNSIGNED_INTEGER unsigned long long +#define STRTOUI strtoull +#else +#define UNSIGNED_INTEGER unsigned int +#define STRTOUI strtoul +#endif + +LIBSPEC UNSIGNED_INTEGER UPNP_GetTotalBytesSent(const char * controlURL, const char * servicetype); -LIBSPEC unsigned int +LIBSPEC UNSIGNED_INTEGER UPNP_GetTotalBytesReceived(const char * controlURL, const char * servicetype); -LIBSPEC unsigned int +LIBSPEC UNSIGNED_INTEGER UPNP_GetTotalPacketsSent(const char * controlURL, const char * servicetype); -LIBSPEC unsigned int +LIBSPEC UNSIGNED_INTEGER UPNP_GetTotalPacketsReceived(const char * controlURL, const char * servicetype); @@ -86,6 +94,8 @@ unsigned int * bitrateUp); /* UPNP_AddPortMapping() + * if desc is NULL, it will be defaulted to "libminiupnpc" + * remoteHost is usually NULL because IGD don't support it. * * Return values : * 0 : SUCCESS @@ -114,9 +124,12 @@ const char * inPort, const char * inClient, const char * desc, - const char * proto); + const char * proto, + const char * remoteHost); /* UPNP_DeletePortMapping() + * Use same argument values as what was used for AddPortMapping(). + * remoteHost is usually NULL because IGD don't support it. * Return Values : * 0 : SUCCESS * NON ZERO : error. Either an UPnP error code or an undefined error. @@ -126,7 +139,8 @@ * 714 NoSuchEntryInArray - The specified value does not exist in the array */ LIBSPEC int UPNP_DeletePortMapping(const char * controlURL, const char * servicetype, - const char * extPort, const char * proto); + const char * extPort, const char * proto, + const char * remoteHost); /* UPNP_GetPortMappingNumberOfEntries() * not supported by all routers */ diff -Nru vidalia-0.1.13/src/miniupnpc/upnperrors.c vidalia-0.2.8/src/miniupnpc/upnperrors.c --- vidalia-0.1.13/src/miniupnpc/upnperrors.c 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/src/miniupnpc/upnperrors.c 2009-05-30 01:36:22.000000000 +0100 @@ -1,17 +1,28 @@ -/* $Id: upnperrors.c,v 1.2 2008/02/05 12:50:22 nanard Exp $ */ +/* $Id: upnperrors.c,v 1.3 2008/04/27 17:21:51 nanard Exp $ */ /* Project : miniupnp * Author : Thomas BERNARD * copyright (c) 2007 Thomas Bernard * All Right reserved. + * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ * This software is subjet to the conditions detailed in the * provided LICENCE file. */ #include #include "upnperrors.h" +#include "upnpcommands.h" const char * strupnperror(int err) { const char * s = NULL; switch(err) { + case UPNPCOMMAND_SUCCESS: + s = "Success"; + break; + case UPNPCOMMAND_UNKNOWN_ERROR: + s = "Miniupnpc Unknown Error"; + break; + case UPNPCOMMAND_INVALID_ARGS: + s = "Miniupnpc Invalid Arguments"; + break; case 401: s = "Invalid Action"; break; diff -Nru vidalia-0.1.13/src/miniupnpc/upnperrors.h vidalia-0.2.8/src/miniupnpc/upnperrors.h --- vidalia-0.1.13/src/miniupnpc/upnperrors.h 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/src/miniupnpc/upnperrors.h 2009-05-30 01:36:22.000000000 +0100 @@ -1,4 +1,4 @@ -/* $Id: upnperrors.h,v 1.1 2007/12/22 11:28:04 nanard Exp $ */ +/* $Id: upnperrors.h,v 1.2 2008/07/02 23:31:15 nanard Exp $ */ /* (c) 2007 Thomas Bernard * All rights reserved. * MiniUPnP Project. @@ -8,9 +8,19 @@ #ifndef __UPNPERRORS_H__ #define __UPNPERRORS_H__ +#include "declspec.h" + +#ifdef __cplusplus +extern "C" { +#endif + /* strupnperror() * Return a string description of the UPnP error code * or NULL for undefinded errors */ -const char * strupnperror(int err); +LIBSPEC const char * strupnperror(int err); + +#ifdef __cplusplus +} +#endif #endif diff -Nru vidalia-0.1.13/src/miniupnpc/upnpreplyparse.h vidalia-0.2.8/src/miniupnpc/upnpreplyparse.h --- vidalia-0.1.13/src/miniupnpc/upnpreplyparse.h 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/src/miniupnpc/upnpreplyparse.h 2010-04-10 00:17:13.000000000 +0100 @@ -1,14 +1,14 @@ -/* $Id: upnpreplyparse.h,v 1.8 2008/02/21 13:05:27 nanard Exp $ */ +/* $Id: upnpreplyparse.h,v 1.10 2009/07/09 16:01:50 nanard Exp $ */ /* MiniUPnP project * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ - * (c) 2006 Thomas Bernard + * (c) 2006-2009 Thomas Bernard * This software is subject to the conditions detailed * in the LICENCE file provided within the distribution */ #ifndef __UPNPREPLYPARSE_H__ #define __UPNPREPLYPARSE_H__ -#if defined(NO_SYS_QUEUE_H) || defined(WIN32) +#if defined(NO_SYS_QUEUE_H) || defined(WIN32) || defined(__HAIKU__) #include "bsdqueue.h" #else #include diff -Nru vidalia-0.1.13/src/tools/CMakeLists.txt vidalia-0.2.8/src/tools/CMakeLists.txt --- vidalia-0.1.13/src/tools/CMakeLists.txt 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/src/tools/CMakeLists.txt 2009-03-28 22:27:44.000000000 +0000 @@ -1,5 +1,5 @@ ## -## $Id: CMakeLists.txt 3014 2008-08-27 15:31:17Z edmanm $ +## $Id: CMakeLists.txt 3645 2009-03-28 22:27:44Z coderman $ ## ## 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 @@ -16,5 +16,7 @@ if (WIN32) add_subdirectory(po2nsh) add_subdirectory(nsh2po EXCLUDE_FROM_ALL) + add_subdirectory(po2wxl) + add_subdirectory(wixtool) endif(WIN32) diff -Nru vidalia-0.1.13/src/tools/nsh2po/CMakeLists.txt vidalia-0.2.8/src/tools/nsh2po/CMakeLists.txt --- vidalia-0.1.13/src/tools/nsh2po/CMakeLists.txt 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/src/tools/nsh2po/CMakeLists.txt 2009-06-11 18:57:53.000000000 +0100 @@ -1,5 +1,5 @@ ## -## $Id: CMakeLists.txt 2889 2008-07-17 02:07:03Z edmanm $ +## $Id: CMakeLists.txt 3840 2009-06-11 17:57:53Z edmanm $ ## ## 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 @@ -40,5 +40,7 @@ add_executable(nsh2po ${nsh2po_SRCS}) ## Link the executable with the appropriate Qt libraries -target_link_libraries(nsh2po ${QT_LIBRARIES}) +target_link_libraries(nsh2po + ${QT_QTCORE_LIBRARY} +) diff -Nru vidalia-0.1.13/src/tools/po2nsh/CMakeLists.txt vidalia-0.2.8/src/tools/po2nsh/CMakeLists.txt --- vidalia-0.1.13/src/tools/po2nsh/CMakeLists.txt 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/src/tools/po2nsh/CMakeLists.txt 2009-06-17 19:11:27.000000000 +0100 @@ -1,5 +1,5 @@ ## -## $Id: CMakeLists.txt 2859 2008-07-13 04:35:03Z edmanm $ +## $Id: CMakeLists.txt 3870 2009-06-17 18:11:27Z edmanm $ ## ## 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 @@ -19,7 +19,9 @@ add_executable(po2nsh ${po2nsh_SRCS}) ## Link the executable with the appropriate Qt libraries -target_link_libraries(po2nsh ${QT_LIBRARIES} common) +target_link_libraries(po2nsh + ${QT_QTCORE_LIBRARY} +) ## Remember the location of po2nsh so we can use it in custom commands get_target_property(PO2NSH_EXECUTABLE po2nsh LOCATION) diff -Nru vidalia-0.1.13/src/tools/po2nsh/po2nsh.cpp vidalia-0.2.8/src/tools/po2nsh/po2nsh.cpp --- vidalia-0.1.13/src/tools/po2nsh/po2nsh.cpp 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/src/tools/po2nsh/po2nsh.cpp 2009-06-17 19:11:27.000000000 +0100 @@ -13,7 +13,6 @@ #include #include #include -#include /** Parse the context name from str, where the context name is of the diff -Nru vidalia-0.1.13/src/tools/po2ts/CMakeLists.txt vidalia-0.2.8/src/tools/po2ts/CMakeLists.txt --- vidalia-0.1.13/src/tools/po2ts/CMakeLists.txt 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/src/tools/po2ts/CMakeLists.txt 2009-08-12 05:51:23.000000000 +0100 @@ -1,5 +1,5 @@ ## -## $Id: CMakeLists.txt 2833 2008-07-04 02:45:48Z edmanm $ +## $Id: CMakeLists.txt 4030 2009-08-12 04:51:23Z edmanm $ ## ## 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 @@ -19,7 +19,11 @@ add_executable(po2ts ${po2ts_SRCS}) ## Link the executable with the appropriate Qt libraries -target_link_libraries(po2ts ${QT_LIBRARIES}) +target_link_libraries(po2ts + ${QT_QTCORE_LIBRARY} + ${QT_QTCORE_LIB_DEPENDENCIES} + ${QT_QTXML_LIBRARY} +) ## Remember the location of po2ts so we can use it in custom commands get_target_property(PO2TS_EXECUTABLE po2ts LOCATION) diff -Nru vidalia-0.1.13/src/tools/po2wxl/CMakeLists.txt vidalia-0.2.8/src/tools/po2wxl/CMakeLists.txt --- vidalia-0.1.13/src/tools/po2wxl/CMakeLists.txt 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/tools/po2wxl/CMakeLists.txt 2009-06-11 18:57:53.000000000 +0100 @@ -0,0 +1,31 @@ +## +## $Id: CMakeLists.txt 3840 2009-06-11 17:57:53Z edmanm $ +## +## 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.vidalia-project.net/. No part of Vidalia, including this file, +## may be copied, modified, propagated, or distributed except according to +## the terms described in the LICENSE file. +## + +## po2wxl source files +set(po2wxl_SRCS + po2wxl.cpp +) + +## Create the po2wxl executable +add_executable(po2wxl ${po2wxl_SRCS}) + +## Link the executable with the appropriate Qt libraries +target_link_libraries(po2wxl + ${QT_QTCORE_LIBRARY} + ${QT_QTXML_LIBRARY} +) + +## Remember the location of po2wxl so we can use it in custom commands +get_target_property(PO2WXL_EXECUTABLE po2wxl LOCATION) +set(VIDALIA_PO2WXL_EXECUTABLE ${PO2WXL_EXECUTABLE} + CACHE STRING "Location of Vidalia's po2wxl converter." FORCE) + diff -Nru vidalia-0.1.13/src/tools/po2wxl/po2wxl.cpp vidalia-0.2.8/src/tools/po2wxl/po2wxl.cpp --- vidalia-0.1.13/src/tools/po2wxl/po2wxl.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/tools/po2wxl/po2wxl.cpp 2009-04-08 06:04:15.000000000 +0100 @@ -0,0 +1,343 @@ +/* +** $Id: po2wxl.cpp 3679 2009-04-08 05:04:15Z edmanm $ +** +** 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.vidalia-project.net/. No part of Vidalia, including this file, +** may be copied, modified, propagated, or distributed except according to the +** terms described in the LICENSE file. +*/ + +#include +#include +#include +#include +#include + +#define WXL_NAMESPACE "http://schemas.microsoft.com/wix/2006/localization" +#define WXL_ELEMENT_ROOT "WixLocalization" +#define WXL_ELEMENT_MESSAGE "String" +#define WXL_ATTR_MESSAGE_ID "Id" +#define WXL_ATTR_LANGUAGE "LCID" +#define WXL_ATTR_TRANSLATION_TYPE "Culture" +#define WXL_ATTR_OVERRIDABLE "Overridable" + +/** We need to provide an element with the LCID for this locale + * that is used in the WiX Product definition. */ +QString +culture_lcid(const QString &culture) +{ + /* For now character encoding focused, not generally locale / dialect aware. */ + QString lcid = "0"; + if(!culture.compare("en", Qt::CaseInsensitive)) + lcid = "1033"; + else if(!culture.compare("cs", Qt::CaseInsensitive)) + lcid = "1029"; + else if(!culture.compare("de", Qt::CaseInsensitive)) + lcid = "1031"; + else if(!culture.compare("es", Qt::CaseInsensitive)) + lcid = "1034"; + else if(!culture.compare("fa", Qt::CaseInsensitive)) + lcid = "1065"; + else if(!culture.compare("fi", Qt::CaseInsensitive)) + lcid = "1035"; + else if(!culture.compare("fr", Qt::CaseInsensitive)) + lcid = "1036"; + else if(!culture.compare("he", Qt::CaseInsensitive)) + lcid = "1037"; + else if(!culture.compare("it", Qt::CaseInsensitive)) + lcid = "1040"; + else if(!culture.compare("nl", Qt::CaseInsensitive)) + lcid = "1043"; + else if(!culture.compare("pl", Qt::CaseInsensitive)) + lcid = "1045"; + else if(!culture.compare("pt", Qt::CaseInsensitive)) + lcid = "1046"; + else if(!culture.compare("ro", Qt::CaseInsensitive)) + lcid = "1048"; + else if(!culture.compare("ru", Qt::CaseInsensitive)) + lcid = "1049"; + else if(!culture.compare("sv", Qt::CaseInsensitive)) + lcid = "1053"; + return lcid; +} + +/** Create a new message string element using the source string msgid + * and the translation msgstr and assign identifier attribute. */ +QDomElement +new_message_element(QDomDocument *wxl, const QString &strid, + const QString &msgid, const QString &msgstr) +{ + QDomElement message; + + message = wxl->createElement(WXL_ELEMENT_MESSAGE); + message.setAttribute(WXL_ATTR_MESSAGE_ID, strid); + + /* Always allow localized string to be dynamic. This is required for + * multi-language packages to link correctly. + */ + message.setAttribute(WXL_ATTR_OVERRIDABLE, "yes"); + if (!msgstr.isEmpty()) + message.appendChild(wxl->createTextNode(msgstr)); + else + message.appendChild(wxl->createTextNode(msgid)); + + return message; +} + +/** Create a new WXL document of the appropriate doctype and root + * element with the Microsoft style culture name for locale. */ +QDomDocument +new_wxl_document(const QString &culture) +{ + QDomDocument wxl; + + QDomElement root = wxl.createElementNS(WXL_NAMESPACE, WXL_ELEMENT_ROOT); + root.setAttribute(WXL_ATTR_TRANSLATION_TYPE, culture); + wxl.appendChild(root); + + return wxl; +} + +/** Parse the context name from str, where the context name is of the + * form DQUOTE ContextName DQUOTE. */ +QString +parse_message_context(const QString &str) +{ + QString out = str.trimmed(); + out = out.replace("\"", ""); + return out; +} + +/** Parse the context name from str, where str is of the + * form ContextName#Number. This is the format used by translate-toolkit. */ +QString +parse_message_context_lame(const QString &str) +{ + if (str.contains("#")) + return str.section("#", 0, 0); + return QString(); +} + +/** Parse the PO-formatted message string from msg. If msg is a + * multiline string, the extra double quotes will be replaced with newlines + * appropriately. */ +QString +parse_message_string(const QString &msg) +{ + QString out = msg.trimmed(); + + out.replace("\"\n\"", "\n"); + if (out.startsWith("\"")) + out = out.remove(0, 1); + if (out.endsWith("\"")) + out.chop(1); + out.replace("\\\"", "\""); + + /* convert NSIS style vars to Properties; avoid QRegExp if possible. */ + int lind, rind; + while ( ((lind = out.indexOf("${")) >= 0) && + ((rind = out.indexOf("}", lind)) > lind) ) { + out.replace(lind, 2, "["); + out.replace(--rind, 1, "]"); + } + return out; +} + +/** Read and return the next non-empty line from stream. */ +QString +read_next_line(QTextStream *stream) +{ + stream->skipWhiteSpace(); + return stream->readLine().append("\n"); +} + +/** Skip past the header portion of the PO file and any leading whitespace. + * The next line read from po will be the first non-header line in the + * document. */ +void +skip_po_header(QTextStream *po) +{ + QString line; + /* Skip any leading whitespace before the header */ + po->skipWhiteSpace(); + /* Read to the first empty line */ + line = po->readLine(); + while (!po->atEnd() && !line.isEmpty()) + line = po->readLine(); +} + +/** Convert po from the PO format to a WXL-formatted XML document. + * wxl will be set to the resulting WXL document. Return the number of + * converted strings on success, or -1 on error and errorMessage will + * be set. */ +int +po2wxl(const QString& culture, QTextStream *po, QDomDocument *wxl, + QString *errorMessage) +{ + QString line; + QString msgctxt, msgid, msgstr; + QDomElement msgElement; + int n_strings = 0; + + Q_ASSERT(po); + Q_ASSERT(wxl); + Q_ASSERT(errorMessage); + + *wxl = new_wxl_document(culture); + + /* Set the LCID to Language code for use as !(loc.LCID) in Product. */ + QString lcid = culture_lcid(culture); + wxl->documentElement().appendChild( + new_message_element(wxl, WXL_ATTR_LANGUAGE, lcid, lcid)); + + skip_po_header(po); + line = read_next_line(po); + while (!po->atEnd()) { + /* Ignore all "#" lines except "#:" */ + while (line.startsWith("#")) { + if (line.startsWith("#:")) { + /* Context was specified with the stupid overloaded "#:" syntax.*/ + msgctxt = line.section(" ", 1); + msgctxt = parse_message_context_lame(msgctxt); + } + line = read_next_line(po); + } + + /* A context specified on a "msgctxt" line takes precedence over a context + * specified using the overload "#:" notation. */ + if (line.startsWith("msgctxt ")) { + msgctxt = line.section(" ", 1); + msgctxt = parse_message_context(msgctxt); + line = read_next_line(po); + } + + /* Parse the (possibly multiline) message source string */ + if (!line.startsWith("msgid ")) { + *errorMessage = "expected 'msgid' line"; + return -1; + } + msgid = line.section(" ", 1); + + line = read_next_line(po); + while (line.startsWith("\"")) { + msgid.append(line); + line = read_next_line(po); + } + msgid = parse_message_string(msgid); + + /* Parse the (possibly multiline) translated string */ + if (!line.startsWith("msgstr ")) { + *errorMessage = "expected 'msgstr' line"; + return -1; + } + msgstr = line.section(" ", 1); + + line = read_next_line(po); + while (line.startsWith("\"")) { + msgstr.append(line); + line = read_next_line(po); + } + msgstr = parse_message_string(msgstr); + + /* Add the message and translation to the .wxl document */ + wxl->documentElement().appendChild( + new_message_element(wxl, msgctxt, msgid, msgstr)); + + n_strings++; + } + return n_strings; +} + +/** Display application usage and exit. */ +void +print_usage_and_exit() +{ + QTextStream error(stderr); + error << "usage: po2wxl [-q] -n -i -o " + "[-c ]\n"; + error << " -q (optional) Quiet mode (errors are still displayed)\n"; + error << " -n Culture name for translation\n"; + error << " -i Input .po file\n"; + error << " -o Output .wxl file\n"; + error << " -c Text encoding (default: utf-8)\n"; + error.flush(); + exit(1); +} + +int +main(int argc, char *argv[]) +{ + QTextStream error(stderr); + QString culture, errorMessage; + char *infile, *outfile; + QTextCodec *codec = QTextCodec::codecForName("utf-8"); + bool quiet = false; + + /* Check for the correct number of input parameters. */ + if (argc < 5 || argc > 9) + print_usage_and_exit(); + for (int i = 1; i < argc; i++) { + QString arg(argv[i]); + if (!arg.compare("-q", Qt::CaseInsensitive)) + quiet = true; + else if (!arg.compare("-n", Qt::CaseInsensitive) && ++i < argc) + culture = argv[i]; + else if (!arg.compare("-i", Qt::CaseInsensitive) && ++i < argc) + infile = argv[i]; + else if (!arg.compare("-o", Qt::CaseInsensitive) && ++i < argc) + outfile = argv[i]; + else if (!arg.compare("-c", Qt::CaseInsensitive) && ++i < argc) { + codec = QTextCodec::codecForName(argv[i]); + if (!codec) { + error << "Invalid text encoding specified\n"; + return 1; + } + } else + print_usage_and_exit(); + } + + /* Open the input PO file for reading. */ + QFile poFile(infile); + if (!poFile.open(QIODevice::ReadOnly | QIODevice::Text)) { + error << QString("Unable to open '%1' for reading: %2\n").arg(infile) + .arg(poFile.errorString()); + return 2; + } + + QDomDocument wxl; + QTextStream po(&poFile); + po.setCodec(codec); + int n_strings = po2wxl(culture, &po, &wxl, &errorMessage); + if (n_strings < 0) { + error << QString("Unable to convert '%1': %2\n").arg(infile) + .arg(errorMessage); + return 3; + } + + /* Open the WXL file for writing. */ + QFile wxlFile(outfile); + if (!wxlFile.open(QIODevice::WriteOnly | QIODevice::Text)) { + error << QString("Unable to open '%1' for writing: %2\n").arg(outfile) + .arg(wxlFile.errorString()); + return 4; + } + + /* Write the .wxl output. */ + QTextStream out(&wxlFile); + out.setCodec(codec); + out << QString("\n") + .arg(QString(codec->name())); + out << wxl.toString(4); + + if (!quiet) { + QTextStream results(stdout); + results << QString("Converted %1 strings from %2 to %3.\n").arg(n_strings) + .arg(infile) + .arg(outfile); + } + return 0; +} + diff -Nru vidalia-0.1.13/src/tools/ts2po/CMakeLists.txt vidalia-0.2.8/src/tools/ts2po/CMakeLists.txt --- vidalia-0.1.13/src/tools/ts2po/CMakeLists.txt 2009-05-25 21:48:28.000000000 +0100 +++ vidalia-0.2.8/src/tools/ts2po/CMakeLists.txt 2009-08-12 05:51:23.000000000 +0100 @@ -1,5 +1,5 @@ ## -## $Id: CMakeLists.txt 2833 2008-07-04 02:45:48Z edmanm $ +## $Id: CMakeLists.txt 4030 2009-08-12 04:51:23Z edmanm $ ## ## 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 @@ -40,7 +40,11 @@ add_executable(ts2po ${ts2po_SRCS}) ## Link the executable with the appropriate Qt libraries -target_link_libraries(ts2po ${QT_LIBRARIES}) +target_link_libraries(ts2po + ${QT_QTCORE_LIBRARY} + ${QT_QTCORE_LIB_DEPENDENCIES} + ${QT_QTXML_LIBRARY} +) ## Remember the location of ts2po so we can use it in custom commands get_target_property(TS2PO_EXECUTABLE ts2po LOCATION) diff -Nru vidalia-0.1.13/src/tools/wixtool/CMakeLists.txt vidalia-0.2.8/src/tools/wixtool/CMakeLists.txt --- vidalia-0.1.13/src/tools/wixtool/CMakeLists.txt 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/tools/wixtool/CMakeLists.txt 2009-06-11 18:57:53.000000000 +0100 @@ -0,0 +1,27 @@ +## +## $Id: CMakeLists.txt 3840 2009-06-11 17:57:53Z edmanm $ +## +## Copyright (C) 2009 The Tor Project, Inc. +## See LICENSE file for terms; may be used according +## Vidalia or Tor license constraints. (dual license) +## + +## wixtool source files +set(wixtool_SRCS + wixtool.cpp +) + +## Create the wixtool executable +add_executable(wixtool ${wixtool_SRCS}) + +## Link the executable with the appropriate Qt libraries +target_link_libraries(wixtool + ${QT_QTCORE_LIBRARY} + ${QT_QTXML_LIBRARY} +) + +## Remember location so we can use it in custom commands +get_target_property(WIXTOOL_EXECUTABLE wixtool LOCATION) +set(VIDALIA_WIXTOOL_EXECUTABLE ${WIXTOOL_EXECUTABLE} + CACHE STRING "Location of Vidalia's wixtool program." FORCE) + diff -Nru vidalia-0.1.13/src/tools/wixtool/wixtool.cpp vidalia-0.2.8/src/tools/wixtool/wixtool.cpp --- vidalia-0.1.13/src/tools/wixtool/wixtool.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/tools/wixtool/wixtool.cpp 2009-06-01 08:00:35.000000000 +0100 @@ -0,0 +1,710 @@ +/* +** $Id: wixtool.cpp 3810 2009-06-01 07:00:35Z edmanm $ +** +** Copyright (C) 2009 The Tor Project, Inc. +** See LICENSE file for terms; may be used according +** Vidalia or Tor license constraints. (dual license) +*/ + +#include +#include +#include +#include +#include +#include + +#define WIX_ATTR_ID "Id" +#define WIX_ATTR_DIRACTION "uninstall" +#define WIX_ATTR_REGACTION "createAndRemoveOnUninstall" +#define WIX_ATTR_VALUE "Value" +#define WIX_ATTR_KEY "KeyPath" +#define WIX_ATTR_GUID "Guid" +#define WIX_ATTR_NAME "Name" +#define WIX_ATTR_REG_TYPE "Type" +#define WIX_ATTR_REG_NAME "Name" +#define WIX_ATTR_REG_ROOT "Root" +#define WIX_ATTR_REG_KEYPATH "Key" +#define WIX_ATTR_REG_ACTION "Action" +#define WIX_REG_KEY_TYPE "integer" +#define WIX_TAG_FILE "File" +#define WIX_TAG_DIR "Directory" +#define WIX_TAG_FEATURE "Feature" +#define WIX_TAG_COMPONENT "Component" +#define WIX_TAG_COMPONENT_REF "ComponentRef" +#define WIX_TAG_CREATEDIR "CreateFolder" +#define WIX_TAG_REMOVEDIR "RemoveFolder" +#define WIX_TAG_REGKEY "RegistryKey" +#define WIX_TAG_REGVAL "RegistryValue" + +typedef void (*TraverseCallback)(void *cbdata, QDomElement e); + +/* Splice command takes an element or sub tree from one + * document and inserts it into another. This is useful for + * expanding placeholder elements with their desired content + * for example. + * If an element name is not unique the conventional WiX Id + * attribute can be used to identify the specific element. + */ +typedef struct s_SpliceData { + QString dtag; + QString did; + QDomElement splice; +} SpliceData; + +/* Replace operates on tags by name or Id like Splice but + * only makes modifications to individual elements. Replace + * can also remove elements. (replace with null) + */ +typedef struct s_ReplaceData { + QString dtag; + QString did; + QString dprop; + QString newtag; + QString newprop; + QString newpropval; +} ReplaceData; + +/* Add operates on tags by name or Id as usual. + */ +typedef struct s_AddData { + QString dtag; + QString did; + QString newtag; + QString newprop; + QString newpropval; +} AddData; + +/* In order to support local per user installation some basic + * constrains must apply to every component included in a + * package. This includes using a key path for each component + * via registry keys and placing all application data under the + * local user profile folder. + * This utility will navigate the components and convert any + * keys to registry key paths and create folders in the deployment + * hierarchy as required. + */ +typedef struct s_UserLocalData { + QString keypath; + QString featureid; + QStringList newcomps; +} UserLocalData; + + +/* Note that we must walk the tree ourselves as locate by ID + * nor suitable select by classification is available in the + * Qt API. + */ +bool +do_walkdoc(QDomNode n, + TraverseCallback cb, + void * cbdata, + QString *errorMessage) +{ + QTextStream error(stderr); + if ( !n.isNull() ) { + if ( n.isElement() ) { + QDomElement e = n.toElement(); + (*cb)(cbdata, e); + } + if ( n.hasChildNodes() ) { + QDomNodeList subnodes = n.childNodes(); + int i = 0; + while (i < subnodes.count()) { + do_walkdoc(subnodes.item(i++), cb, cbdata, errorMessage); + } + } + } + return true; +} + +bool +walkdoc(QDomDocument *doc, + TraverseCallback cb, + void * cbdata, + QString *errorMessage) +{ + QTextStream error(stderr); + QDomNode n = doc->documentElement(); + do_walkdoc(n, cb, cbdata, errorMessage); + return true; +} + +void +splicefunc(void *cbdata, + QDomElement e) +{ + SpliceData *d = reinterpret_cast(cbdata); + QString eid = e.attribute(WIX_ATTR_ID); + + if (e.tagName().compare(d->dtag) == 0) { + /* if a specific Id is set, verify it too. */ + if (d->did.isEmpty() || + (eid.size() && !eid.compare(d->did)) ) { + + /* expected behavior is to graft children of the splice under target. + * if we're only given a single element graft it instead. + */ + if (d->splice.hasChildNodes()) { + QDomNodeList subnodes = d->splice.childNodes(); + int i = 0; + while (i < subnodes.count()) { + e.appendChild(e.ownerDocument().importNode(subnodes.item(i++), true)); + } + } + else { + e.appendChild(e.ownerDocument().importNode(d->splice, true)); + } + } + } +} + +/** Make modifications to requested documents. + * returns false on error and errorMessage will be set. + */ +bool +docsplice(QDomDocument *doc, + QString arguments, + QString *errorMessage) +{ + Q_ASSERT(doc); + Q_ASSERT(errorMessage); + SpliceData cbdata; + + QStringList spliceinfo = arguments.split("="); + if (spliceinfo.count() != 2) { + *errorMessage = "Invalid argument for splice command: " + arguments; + return false; + } + if (spliceinfo[0].contains(':')) { + /* Id syntax */ + QStringList destinfo = spliceinfo[0].split(":"); + cbdata.dtag = destinfo[0]; + cbdata.did = destinfo[1]; + } + else { + cbdata.dtag = spliceinfo[0]; + } + + QStringList srcinfo = spliceinfo[1].split(":"); + if (srcinfo.count() < 2) { + *errorMessage = "Invalid source argument for splice command: " + arguments; + return false; + } + QFile spliceFile(srcinfo[0]); + if (!spliceFile.open(QIODevice::ReadOnly | QIODevice::Text)) { + *errorMessage = QString("Unable to open '%1' for reading: %2\n") + .arg(srcinfo[0]).arg(spliceFile.errorString()); + return false; + } + QTextStream sfiletxt(&spliceFile); + QDomDocument sdoc; + QString parseError; + int badline, badcol; + if (!sdoc.setContent (sfiletxt.readAll(), false, &parseError, &badline, &badcol)) { + *errorMessage = QString("Error parsing splice document '%1' at line %2 and column %3: %4") + .arg(srcinfo[0]).arg(badline).arg(badcol).arg(parseError); + return false; + } + + QDomNodeList elist = sdoc.elementsByTagName(srcinfo[1]); + if (elist.count() == 0) { + *errorMessage = QString("Unable to locate splice element '%1' in document.\n").arg(srcinfo[1]); + return false; + } + if (srcinfo.count() == 3) { + /* Id syntax for source elem */ + for (int i=0; i < elist.count(); i++) { + QString eid = elist.item(i).toElement().attribute(WIX_ATTR_ID); + if (eid.size() && !eid.compare(srcinfo[2])) { + cbdata.splice = elist.item(i).toElement(); + } + } + } + else { + /* without an Id the tag name should be unique. */ + cbdata.splice = elist.item(0).toElement(); + } + return walkdoc(doc, &splicefunc, &cbdata, errorMessage); +} + +void +replacefunc(void *cbdata, + QDomElement e) +{ + ReplaceData *d = reinterpret_cast(cbdata); + QString eid = e.attribute(WIX_ATTR_ID); + + if (e.tagName().compare(d->dtag) == 0) { + /* if a specific Id is set, verify it too. */ + if (d->did.isEmpty() || + (eid.size() && !eid.compare(d->did)) ) { + + /* no destination means remove node from tree */ + if (d->newtag.isNull()) { + QDomNode parent = e.parentNode(); + parent.removeChild(e); + } + else { + if (d->newtag.compare(e.tagName())) { + e.setTagName (d->newtag); + } + if (d->newprop.isNull()) { + /* clear all attributes (except Id if present) */ + QDomNamedNodeMap attrs = e.attributes(); + for (int i = 0; i < attrs.count(); i++) { + if (attrs.item(i).nodeName().compare(WIX_ATTR_ID)) { + e.removeAttribute(attrs.item(i).nodeName()); + } + } + } + else { + /* only modify / clear a specific property */ + QDomNode prop = e.attributeNode(d->newprop); + if (!prop.isNull()) { + e.setAttribute(d->newprop, d->newpropval); + } + } + } + } + } +} + +/** Make modifications to requested documents. + * returns false on error and errorMessage will be set. + */ +bool +docreplace(QDomDocument *doc, + QString arguments, + QString *errorMessage) +{ + Q_ASSERT(doc); + Q_ASSERT(errorMessage); + ReplaceData cbdata; + + QStringList replaceinfo = arguments.split("="); + if (replaceinfo.count() < 1) { + *errorMessage = "Invalid argument for replace command: " + arguments; + return false; + } + if (replaceinfo[0].contains(':')) { + /* Id syntax */ + QStringList destinfo = replaceinfo[0].split(":"); + cbdata.dtag = destinfo[0]; + cbdata.did = destinfo[1]; + if (destinfo.count() >= 3) { + cbdata.dprop = destinfo[2]; + } + } + else { + cbdata.dtag = replaceinfo[0]; + } + if (replaceinfo.count() > 1) { + QStringList srcinfo = replaceinfo[1].split(":"); + if (srcinfo.count() < 1) { + *errorMessage = "Invalid target argument for replace command: " + arguments; + return false; + } + if (srcinfo.count() >= 1) { + if (srcinfo[0].length()) cbdata.newtag = srcinfo[0]; + } + if (srcinfo.count() >= 2) { + if (srcinfo[1].length()) cbdata.newprop = srcinfo[1]; + } + if (srcinfo.count() >= 3) { + if (srcinfo[2].length()) cbdata.newpropval = srcinfo[2]; + } + } + return walkdoc(doc, &replacefunc, &cbdata, errorMessage); +} + +void +addfunc(void *cbdata, + QDomElement e) +{ + AddData *d = reinterpret_cast(cbdata); + QString eid = e.attribute(WIX_ATTR_ID); + + if (e.tagName().compare(d->dtag) == 0) { + /* if a specific Id is set, verify it too. */ + if (d->did.isEmpty() || + (eid.size() && !eid.compare(d->did)) ) { + if (d->newtag.compare(d->dtag)) { + QDomElement ne = e.ownerDocument().createElement(d->newtag); + if (!d->newprop.isNull()) { + ne.setAttribute(d->newprop, d->newpropval); + } + e.appendChild(ne); + } + else { + e.setAttribute(d->newprop, d->newpropval); + } + } + } +} + +/** Make modifications to requested documents. + * returns false on error and errorMessage will be set. + */ +bool +docadd(QDomDocument *doc, + QString arguments, + QString *errorMessage) +{ + Q_ASSERT(doc); + Q_ASSERT(errorMessage); + AddData cbdata; + + QStringList addinfo = arguments.split("="); + if (addinfo.count() < 1) { + *errorMessage = "Invalid argument for add command: " + arguments; + return false; + } + if (addinfo[0].contains(':')) { + /* Id syntax */ + QStringList destinfo = addinfo[0].split(":"); + cbdata.dtag = destinfo[0]; + cbdata.did = destinfo[1]; + } + else { + cbdata.dtag = addinfo[0]; + } + if (addinfo.count() > 1) { + QStringList srcinfo = addinfo[1].split(":"); + if (srcinfo.count() < 1) { + *errorMessage = "Invalid target argument for add command: " + arguments; + return false; + } + if (srcinfo.count() >= 1) { + if (srcinfo[0].length()) cbdata.newtag = srcinfo[0]; + } + if (srcinfo.count() >= 2) { + if (srcinfo[1].length()) cbdata.newprop = srcinfo[1]; + } + if (srcinfo.count() >= 3) { + if (srcinfo[2].length()) cbdata.newpropval = srcinfo[2]; + } + } + return walkdoc(doc, &addfunc, &cbdata, errorMessage); +} + +void +createRegLocalComponent(QDomElement e, + QString dirName, + QString keyPath) +{ + QDomElement nrk = e.ownerDocument().createElement(WIX_TAG_REGKEY); + QDomElement nrv = e.ownerDocument().createElement(WIX_TAG_REGVAL); + nrk.setAttribute(WIX_ATTR_REG_ROOT, "HKCU"); + nrk.setAttribute(WIX_ATTR_REG_ACTION, "createAndRemoveOnUninstall"); + nrk.setAttribute(WIX_ATTR_REG_KEYPATH, keyPath); + nrv.setAttribute(WIX_ATTR_REG_TYPE, WIX_REG_KEY_TYPE); + nrv.setAttribute(WIX_ATTR_REG_NAME, dirName); + nrv.setAttribute(WIX_ATTR_VALUE, "1"); + nrv.setAttribute(WIX_ATTR_KEY, "yes"); + nrk.appendChild(nrv); + e.appendChild(nrk); +} + +void +createDirMgmtComponent(QDomElement e, + QString dirName) +{ + QDomElement nce; + /* An empty dir might produce a createdir, so only add if not present. */ + if (e.elementsByTagName(WIX_TAG_CREATEDIR).count() == 0) { + nce = e.ownerDocument().createElement(WIX_TAG_CREATEDIR); + e.appendChild(nce); + } + nce = e.ownerDocument().createElement(WIX_TAG_REMOVEDIR); + nce.setAttribute("On", WIX_ATTR_DIRACTION); + nce.setAttribute(WIX_ATTR_ID, QString("Remove").append(dirName)); + e.appendChild(nce); +} + +void +userlocalfunc(void *cbdata, + QDomElement e) +{ + UserLocalData *ulinfo = reinterpret_cast(cbdata); + QString eid = e.attribute(WIX_ATTR_ID); + + if (e.tagName().compare(WIX_TAG_FILE) == 0) { + e.removeAttribute(WIX_ATTR_KEY); + } + else if (e.tagName().compare(WIX_TAG_COMPONENT) == 0) { + /* If the WiX tools get confused we need to remove KeyPath attrs + * on any component elements after creation or merging. + * Empty directories with a CreateFolder and nothing else will do this. + */ + e.removeAttribute(WIX_ATTR_KEY); + } + else if (e.tagName().compare(WIX_TAG_FEATURE) == 0) { + /* be sure to remove any default feature names; changed added above. */ + QDomNodeList cnl = e.elementsByTagName(WIX_TAG_COMPONENT_REF); + for (int i = 0; i < cnl.count(); i++) { + QDomElement cre = cnl.item(i).toElement(); + if (cre.attribute(WIX_ATTR_ID).compare(WIX_TAG_COMPONENT) == 0) { + e.removeChild(cre); + } + } + if (ulinfo->featureid.compare(e.attribute(WIX_ATTR_ID)) == 0) { + /* this is the target feature element for the new components, if any. */ + QDomElement ne; + for (int i = 0; i < ulinfo->newcomps.count(); i++) { + QString currid = ulinfo->newcomps[i]; + ne = e.ownerDocument().createElement(WIX_TAG_COMPONENT_REF); + ne.setAttribute(WIX_ATTR_ID, currid); + e.appendChild(ne); + } + } + } + else if (e.tagName().compare(WIX_TAG_DIR) == 0) { + QString dirName = e.attribute(WIX_ATTR_NAME); + QString dirId = e.attribute(WIX_ATTR_ID); + /* find all child components for this dir and see if it contains: + * create/remove folder elements, a registry element + */ + if ( e.hasChildNodes() ) { + QDomElement fc; + bool hasComponent = false; + bool hasRegKey; + QDomNodeList subnodes = e.childNodes(); + for (int i = 0; i < subnodes.count(); i++) { + hasRegKey = false; + if (subnodes.item(i).isElement()) { + QDomElement ce = subnodes.item(i).toElement(); + if (ce.tagName().compare(WIX_TAG_COMPONENT) == 0) { + if (!hasComponent) { + hasComponent = true; + fc = ce; + if (ce.attribute(WIX_ATTR_ID).compare(WIX_TAG_COMPONENT) == 0) { + /* Fix default named components before adding registry elements. */ + ce.setAttribute(WIX_ATTR_ID, QString("DCOMP").append(dirName)); + ulinfo->newcomps.append(ce.attribute(WIX_ATTR_ID)); + } + if (ce.elementsByTagName(WIX_TAG_REMOVEDIR).count() == 0) { + createDirMgmtComponent(ce, ce.attribute(WIX_ATTR_ID)); + } + } + QDomNodeList compnodes = ce.childNodes(); + for (int j = 0; j < compnodes.count(); j++) { + if (compnodes.item(j).isElement()) { + QDomElement compe = compnodes.item(j).toElement(); + if (compe.tagName().compare(WIX_TAG_REGKEY) == 0) { + hasRegKey = true; + } + } + } + if (!hasRegKey) { + createRegLocalComponent(ce, QString("RK").append(ce.attribute(WIX_ATTR_ID)), ulinfo->keypath); + } + } + } + } + if (!hasComponent) { + /* Certain system directories must be ignored; we don't manage them. */ + if (dirId.compare("LocalAppDataFolder") && + dirId.compare("AppDataFolder") && + dirId.compare("CommonAppDataFolder") && + dirId.compare("CommonFilesFolder") && + dirId.compare("DesktopFolder") && + dirId.compare("PersonalFolder") && + dirId.compare("ProgramFilesFolder") && + dirId.compare("ProgramMenuFolder") && + dirId.compare("StartMenuFolder") && + dirId.compare("StartupFolder") && + dirId.compare("SystemFolder") && + dirId.compare("TempFolder") && + dirId.compare("WindowsFolder") ) { + /* if there is no component under this dir parent then we + * must create a component for the sole purpose of dir + * creation with the requisite registry key path. + */ + QDomElement ne = e.ownerDocument().createElement(WIX_TAG_COMPONENT); + QString compId = QString("ULDirComp_").append(dirName); + ne.setAttribute(WIX_ATTR_GUID, "*"); + ne.setAttribute(WIX_ATTR_ID, compId); + e.appendChild(ne); + createDirMgmtComponent(ne, dirName); + createRegLocalComponent(ne, QString("DRK").append(dirName), ulinfo->keypath); + ulinfo->newcomps.append(compId); + } + } + } + } +} + +/** Make modifications to requested documents. + * returns false on error and errorMessage will be set. + */ +bool +docuserlocal(QDomDocument *doc, + QString argument, + QString *errorMessage) +{ + Q_ASSERT(doc); + Q_ASSERT(errorMessage); + UserLocalData cbdata; + + QStringList ulinfo = argument.split(":"); + if (ulinfo.count() < 2) { + *errorMessage = "Invalid argument for userlocal command: " + argument; + return false; + } + cbdata.keypath = ulinfo[0]; + cbdata.featureid = ulinfo[1]; + return walkdoc(doc, &userlocalfunc, &cbdata, errorMessage); +} + +/** Display application usage and exit. */ +void +print_usage_and_exit() +{ + QTextStream error(stderr); + error << "usage: wixtool [-q] -i -o [... ]" << endl; + error << " command one of: " << endl; + error << " splice Splice children from one document into another." << endl; + error << " replace Replace elements or attributes in a document." << endl; + error << " add Add elements or attributes into a document." << endl; + error << " userlocal Convert File elements into per-user local elements." << endl; + error << " -i Input or template file" << endl; + error << " -o Output file" << endl; + error << endl; + error << " splice args: desttagname[:Id]=file:basetag[:Id]" << endl; + error << " Splice children of basetag in file under desttagname" << endl; + error << endl; + error << " replace args: tagname[:Id]:property=newtagname[:Id]:property:value" << endl; + error << " If newtagname is empty the element is deleted" << endl; + error << " If newproperty is empty the property is deleted" << endl; + error << endl; + error << " add args: desttagname[:Id]=newtagname[:Id]:property:value" << endl; + error << " Add properties or child elements to target" << endl; + error << " If newtagname is empty only properties added to dest" << endl; + error << endl; + error << " userlocal arg: :" << endl; + error << " Convert KeyPath File elements into the per user local idiom" << endl; + error << " with corresponding Create/RemoveDir and RegistryKey elements." << endl; + error << endl; + error << " NOTE: text content within an element is not accessible." << endl; + error << " Use the Value= attribute syntax if necessary." << endl; + error << " The optional :Id syntax restricts matching to elements with" << endl; + error << " the Id attribute set to the value indicated." << endl; + error.flush(); + exit(1); +} + +int +main(int argc, char *argv[]) +{ + QTextStream error(stderr); + QString command, errorMessage; + char *infile = 0, *outfile = 0; + QTextCodec *codec = QTextCodec::codecForName("utf-8"); + bool quiet = false; + QStringList commandargs; + + /* Check for the correct number of input parameters. */ + if (argc < 6) + print_usage_and_exit(); + + /* Verify command is supported. */ + command = argv[1]; + if ( command.compare("splice", Qt::CaseInsensitive) && + command.compare("replace", Qt::CaseInsensitive) && + command.compare("add", Qt::CaseInsensitive) && + command.compare("userlocal", Qt::CaseInsensitive) ) { + print_usage_and_exit(); + } + + /* Gather remaining arguments. */ + for (int i = 2; i < argc; i++) { + QString arg(argv[i]); + if (!arg.compare("-q", Qt::CaseInsensitive)) + quiet = true; + else if (!arg.compare("-i", Qt::CaseInsensitive) && ++i < argc) + infile = argv[i]; + else if (!arg.compare("-o", Qt::CaseInsensitive) && ++i < argc) + outfile = argv[i]; + else if (infile && outfile) { + commandargs.append(arg); + } + } + if ( !infile || !outfile || !commandargs.count() ) { + print_usage_and_exit(); + } + + /* Open the source document for reading. */ + QFile srcFile(infile); + QTextStream sfiletxt(&srcFile); + sfiletxt.setCodec(codec); + if (!srcFile.open(QIODevice::ReadOnly | QIODevice::Text)) { + error << QString("Unable to open '%1' for reading: %2\n").arg(infile) + .arg(srcFile.errorString()); + return 2; + } + + /* Make sure the outfile does not exist before we use it. */ + if (QFile::exists(outfile)) { + if (!QFile::remove(outfile)) { + error << QString("Unable to truncate outfile '%1'\n").arg(outfile); + return 2; + } + } + + QDomDocument doc; + QString parseError; + int badline, badcol; + if (!doc.setContent (sfiletxt.readAll(), false, &parseError, &badline, &badcol)) { + error << QString("Error parsing source document '%1' at line %2 and column %3: %4") + .arg(infile).arg(badline).arg(badcol).arg(parseError); + return 3; + } + + if (!command.compare("userlocal", Qt::CaseInsensitive)) { + if (!docuserlocal(&doc, commandargs[0], &errorMessage)) { + error << QString("Unable to convert document components to user local: %1\n") + .arg(errorMessage); + return 4; + } + } + else { + for (int i = 0; i < commandargs.count(); i++) { + if (!command.compare("splice", Qt::CaseInsensitive)) { + if (!docsplice(&doc, commandargs[i], &errorMessage)) { + error << QString("Unable to process splice command '%1': %2\n") + .arg(commandargs[i]).arg(errorMessage); + return 4; + } + } + else if (!command.compare("replace", Qt::CaseInsensitive)) { + if (!docreplace(&doc, commandargs[i], &errorMessage)) { + error << QString("Unable to process replace command '%1': %2\n") + .arg(commandargs[i]).arg(errorMessage); + return 4; + } + } + else if (!command.compare("add", Qt::CaseInsensitive)) { + if (!docadd(&doc, commandargs[i], &errorMessage)) { + error << QString("Unable to process add command '%1': %2\n") + .arg(commandargs[i]).arg(errorMessage); + return 4; + } + } + } + } + + /* Open the output file for writing. */ + QFile docFile(outfile); + if (!docFile.open(QIODevice::WriteOnly | QIODevice::Text)) { + error << QString("Unable to open '%1' for writing: %2\n").arg(outfile) + .arg(docFile.errorString()); + return 5; + } + + /* Write the .wxl output. */ + QTextStream out(&docFile); + out << doc.toString(4); + + return 0; +} + diff -Nru vidalia-0.1.13/src/torcontrol/addressmap.cpp vidalia-0.2.8/src/torcontrol/addressmap.cpp --- vidalia-0.1.13/src/torcontrol/addressmap.cpp 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/addressmap.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,102 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 addressmap.cpp -** \version $Id: bandwidthevent.h 1563 2006-12-26 06:06:04Z edmanm $ -** \brief Stores a list of address mappings and their expiration times -*/ - -#include -#include "tcglobal.h" -#include "addressmap.h" - -/** Format of expiry times in address map events. */ -#define DATE_FMT "\"yyyy-MM-dd HH:mm:ss\"" - - -/** Adds a new address mapping from the address from to the address - * to, that expires at expires. */ -void -AddressMap::add(QString from, QString to, QDateTime expires) -{ - tc::debug("New address mapping: %1 -> %2 (expires %3)").arg(from) - .arg(to) - .arg(expires.isValid() ? expires.toString(DATE_FMT) - : "never"); - insert(from, addr_map_entry_t(to, expires)); -} - -/** Adds a new address mapping by parsing the fields in mapping, which - * should be formatted as follows: - * - * Address SP Address SP Expiry - * Expiry = DQUOTE ISOTime DQUOTE / "NEVER" - */ -void -AddressMap::add(QString mapping) -{ - QStringList parts = mapping.split(" "); - if (parts.size() >= 2) { - QDateTime expires; - if (parts.size() >= 4 && parts.at(2) != "NEVER") { - expires = QDateTime::fromString(parts.at(2) + " " + parts.at(3), - DATE_FMT); - - /* Tor gives us the expiry time in UTC, but we will do subsequent - * comparisons based on local time. So do the proper conversion now. */ - expires.setTimeSpec(Qt::UTC); - expires = expires.toLocalTime(); - } - add(parts.at(0), parts.at(1), expires); - } -} - -/** Returns true if entry is expired; false otherwise. */ -bool -AddressMap::isExpired(addr_map_entry_t entry) const -{ - if (entry.second.isValid()) - return (entry.second < QDateTime::currentDateTime()); - return false; /* No expiry time == valid forever */ -} - -/** Returns true if there exists a mapping for addr and that mapping is - * not expired. */ -bool -AddressMap::isMapped(QString addr) const -{ - return (contains(addr) && !isExpired(value(addr))); -} - -/** Returns the address to which addr is currently mapped. If there is - * no mapping for addr (or the mapping is expired), then an empty - * string is returned. */ -QString -AddressMap::mappedTo(QString addr) const -{ - addr_map_entry_t entry = value(addr); - return (isExpired(entry) ? QString() : entry.first); -} - -/** Returns the reverse of this address map by swapping each address in the - * address map with its mapped address. The expiration times are unaltered. */ -AddressMap -AddressMap::reverse() const -{ - AddressMap reverseMap; - foreach (QString from, keys()) { - /* Flip the "from" and the "to" addresses and retain the expiry time. */ - addr_map_entry_t entry = value(from); - reverseMap.add(entry.first, from, entry.second); - } - return reverseMap; -} - diff -Nru vidalia-0.1.13/src/torcontrol/AddressMap.cpp vidalia-0.2.8/src/torcontrol/AddressMap.cpp --- vidalia-0.1.13/src/torcontrol/AddressMap.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/AddressMap.cpp 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,105 @@ +/* +** 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.vidalia-project.net/. 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 AddressMap.cpp +** \version $Id: bandwidthevent.h 1563 2006-12-26 06:06:04Z edmanm $ +** \brief Stores a list of address mappings and their expiration times +*/ + +#include "tcglobal.h" +#include "AddressMap.h" + +#include + + +/** Format of expiry times in address map events. */ +#define DATE_FMT "\"yyyy-MM-dd HH:mm:ss\"" + + +/** Adds a new address mapping from the address from to the address + * to, that expires at expires. */ +void +AddressMap::add(const QString &from, const QString &to, + const QDateTime &expires) +{ + tc::debug("New address mapping: %1 -> %2 (expires %3)").arg(from) + .arg(to) + .arg(expires.isValid() ? expires.toString(DATE_FMT) + : "never"); + insert(from, AddressMapEntry(to, expires)); +} + +/** Adds a new address mapping by parsing the fields in mapping, which + * should be formatted as follows: + * + * Address SP Address SP Expiry + * Expiry = DQUOTE ISOTime DQUOTE / "NEVER" + */ +void +AddressMap::add(const QString &mapping) +{ + QStringList parts = mapping.split(" "); + if (parts.size() >= 2) { + QDateTime expires; + if (parts.size() >= 4 && parts.at(2) != "NEVER") { + expires = QDateTime::fromString(parts.at(2) + " " + parts.at(3), + DATE_FMT); + + /* Tor gives us the expiry time in UTC, but we will do subsequent + * comparisons based on local time. So do the proper conversion now. */ + expires.setTimeSpec(Qt::UTC); + expires = expires.toLocalTime(); + } + add(parts.at(0), parts.at(1), expires); + } +} + +/** Returns true if entry is expired; false otherwise. */ +bool +AddressMap::isExpired(const AddressMapEntry &entry) const +{ + if (entry.second.isValid()) + return (entry.second < QDateTime::currentDateTime()); + return false; /* No expiry time == valid forever */ +} + +/** Returns true if there exists a mapping for addr and that mapping is + * not expired. */ +bool +AddressMap::isMapped(const QString &addr) const +{ + return (contains(addr) && !isExpired(value(addr))); +} + +/** Returns the address to which addr is currently mapped. If there is + * no mapping for addr (or the mapping is expired), then an empty + * string is returned. */ +QString +AddressMap::mappedTo(const QString &addr) const +{ + AddressMapEntry entry = value(addr); + return (isExpired(entry) ? QString() : entry.first); +} + +/** Returns the reverse of this address map by swapping each address in the + * address map with its mapped address. The expiration times are unaltered. */ +AddressMap +AddressMap::reverse() const +{ + AddressMap reverseMap; + foreach (QString from, keys()) { + /* Flip the "from" and the "to" addresses and retain the expiry time. */ + AddressMapEntry entry = value(from); + reverseMap.add(entry.first, from, entry.second); + } + return reverseMap; +} + diff -Nru vidalia-0.1.13/src/torcontrol/addressmapevent.h vidalia-0.2.8/src/torcontrol/addressmapevent.h --- vidalia-0.1.13/src/torcontrol/addressmapevent.h 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/addressmapevent.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,51 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 addressmapevent.h -** \version $Id: bandwidthevent.h 1563 2006-12-26 06:06:04Z edmanm $ -** \brief Event dispatched upon receiving a new or updated address mapping -** from Tor. -*/ - -#ifndef _ADDRESSMAPEVENT_H -#define _ADDRESSMAPEVENT_H - -#include -#include -#include - - -class AddressMapEvent : public QEvent -{ -public: - /** Constructor */ - AddressMapEvent(QString from, QString to, QDateTime expires) - : QEvent((QEvent::Type)CustomEventType::AddressMapEvent) - { _from = from; _to = to; _expires = expires; } - - /** Returns the source address for this address mapping. */ - QString from() const { return _from; } - /** Returns the target address for this address mapping. */ - QString to() const { return _to; } - /** Returns the date and time at which this mapping should expire, in local - * time. */ - QDateTime expires() const { return _expires; } - /** Returns true if this address mapping is expired. */ - bool isExpired() const { return (_expires > QDateTime::currentDateTime()); } - -private: - QString _from; /**< The source address of this mapping. */ - QString _to; /**< The target address of this mapping. */ - QDateTime _expires; /**< The time at which this mapping expires (if ever). */ -}; - -#endif - diff -Nru vidalia-0.1.13/src/torcontrol/addressmap.h vidalia-0.2.8/src/torcontrol/addressmap.h --- vidalia-0.1.13/src/torcontrol/addressmap.h 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/addressmap.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,70 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 addressmap.h -** \version $Id: bandwidthevent.h 1563 2006-12-26 06:06:04Z edmanm $ -** \brief Stores a list of address mappings and their expiration times -*/ - -#ifndef _ADDRESSMAP_H -#define _ADDRESSMAP_H - -#include -#include -#include - -/** Defines a type that pairs a mapping's target address with an expiration - * time for that mapping. */ -typedef QPair addr_map_entry_t; - - -class AddressMap : public QHash -{ -public: - /** Types of address mappings. */ - enum AddressMapType { - AddressMapAll, /**< All address mapping types. */ - AddressMapConfig, /**< Address mappings set in the torrc. */ - AddressMapCache, /**< Address mappings cached by Tor. */ - AddressMapControl /**< Address mappings set by a controller. */ - }; - - /** Constructor. Creates an empty table for storing address mappinsgs. */ - AddressMap() - : QHash() {} - - /** Adds a new address mapping or updates an existing one for the address - * specified by from. The mapping will remain valid until the date in - * expires. */ - void add(QString from, QString to, QDateTime expires); - /** Adds a new address mapping or updates an existing one based on fields - * parsed from mapping. */ - void add(QString mapping); - - /** Returns true if the address map table contains a mapping for addr - * that is not expired. */ - bool isMapped(QString addr) const; - - /** Returns the address to which addr is currently mapped. If there - * is no mapping for addr (or the mapping is expired), then an - * empty string is returned. */ - QString mappedTo(QString addr) const; - - /** Returns the reverse of this address map. */ - AddressMap reverse() const; - -private: - /** Returns true if entry is expired; false otherwise. */ - bool isExpired(addr_map_entry_t entry) const; -}; - -#endif - diff -Nru vidalia-0.1.13/src/torcontrol/AddressMap.h vidalia-0.2.8/src/torcontrol/AddressMap.h --- vidalia-0.1.13/src/torcontrol/AddressMap.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/AddressMap.h 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,70 @@ +/* +** 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.vidalia-project.net/. 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 AddressMap.h +** \version $Id: bandwidthevent.h 1563 2006-12-26 06:06:04Z edmanm $ +** \brief Stores a list of address mappings and their expiration times +*/ + +#ifndef _ADDRESSMAP_H +#define _ADDRESSMAP_H + +#include +#include +#include + +/** Defines a type that pairs a mapping's target address with an expiration + * time for that mapping. */ +typedef QPair AddressMapEntry; + + +class AddressMap : public QHash +{ +public: + /** Types of address mappings. */ + enum AddressMapType { + AddressMapAll, /**< All address mapping types. */ + AddressMapConfig, /**< Address mappings set in the torrc. */ + AddressMapCache, /**< Address mappings cached by Tor. */ + AddressMapControl /**< Address mappings set by a controller. */ + }; + + /** Constructor. Creates an empty table for storing address mappinsgs. */ + AddressMap() + : QHash() {} + + /** Adds a new address mapping or updates an existing one for the address + * specified by from. The mapping will remain valid until the date in + * expires. */ + void add(const QString &from, const QString &to, const QDateTime &expires); + /** Adds a new address mapping or updates an existing one based on fields + * parsed from mapping. */ + void add(const QString &mapping); + + /** Returns true if the address map table contains a mapping for addr + * that is not expired. */ + bool isMapped(const QString &addr) const; + + /** Returns the address to which addr is currently mapped. If there + * is no mapping for addr (or the mapping is expired), then an + * empty string is returned. */ + QString mappedTo(const QString &addr) const; + + /** Returns the reverse of this address map. */ + AddressMap reverse() const; + +private: + /** Returns true if entry is expired; false otherwise. */ + bool isExpired(const AddressMapEntry &entry) const; +}; + +#endif + diff -Nru vidalia-0.1.13/src/torcontrol/bandwidthevent.h vidalia-0.2.8/src/torcontrol/bandwidthevent.h --- vidalia-0.1.13/src/torcontrol/bandwidthevent.h 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/bandwidthevent.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,42 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 bandwidthevent.h -** \version $Id: bandwidthevent.h 2362 2008-02-29 04:30:11Z edmanm $ -** \brief Event dispatched upon receiving a bandwidth update from Tor -*/ - -#ifndef _BANDWIDTHEVENT_H -#define _BANDWIDTHEVENT_H - -#include - - -class BandwidthEvent : public QEvent -{ -public: - /** Constructor */ - BandwidthEvent(quint64 bytesRead, quint64 bytesWritten) - : QEvent((QEvent::Type)CustomEventType::BandwidthEvent) - { _bytesRead = bytesRead; _bytesWritten = bytesWritten; } - - /** Returns the number of bytes read in the last second */ - quint64 bytesRead() const { return _bytesRead; } - /** Returns the number of bytes written in the last second */ - quint64 bytesWritten() const { return _bytesWritten; } - -private: - quint64 _bytesWritten; - quint64 _bytesRead; -}; - -#endif - diff -Nru vidalia-0.1.13/src/torcontrol/bootstrapstatus.cpp vidalia-0.2.8/src/torcontrol/bootstrapstatus.cpp --- vidalia-0.1.13/src/torcontrol/bootstrapstatus.cpp 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/bootstrapstatus.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,97 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 bootstrapstatus.cpp -** \version $Id: bootstrapstatus.cpp 2782 2008-06-21 21:52:15Z edmanm $ -** \brief Describes the Tor software's current bootstrapping status -*/ - -#include "bootstrapstatus.h" - - -BootstrapStatus::BootstrapStatus() -{ - _severity = tc::UnrecognizedSeverity; - _reason = tc::UnrecognizedReason; - _status = UnrecognizedStatus; - _action = UnrecognizedRecommendation; - _percentComplete = -1; -} - -/** Constructor. */ -BootstrapStatus::BootstrapStatus(tc::Severity severity, Status status, - int percentComplete, - const QString &description, - const QString &warning, - tc::ConnectionStatusReason reason, - Recommendation action) -{ - _severity = severity; - _status = status; - _percentComplete = qBound(0, percentComplete, 100); - _description = description; - _warning = warning; - _reason = reason; - _action = action; -} - -/** Converts a string TAG value to a BootstrapStatus enum value. */ -BootstrapStatus::Status -BootstrapStatus::statusFromString(const QString &str) -{ - if (!str.compare("CONN_DIR", Qt::CaseInsensitive)) - return ConnectingToDirMirror; - if (!str.compare("HANDSHAKE_DIR", Qt::CaseInsensitive)) - return HandshakingWithDirMirror; - if (!str.compare("ONEHOP_CREATE", Qt::CaseInsensitive)) - return CreatingOneHopCircuit; - if (!str.compare("REQUESTING_STATUS", Qt::CaseInsensitive)) - return RequestingNetworkStatus; - if (!str.compare("LOADING_STATUS", Qt::CaseInsensitive)) - return LoadingNetworkStatus; - if (!str.compare("LOADING_KEYS", Qt::CaseInsensitive)) - return LoadingAuthorityCertificates; - if (!str.compare("REQUESTING_DESCRIPTORS", Qt::CaseInsensitive)) - return RequestingDescriptors; - if (!str.compare("LOADING_DESCRIPTORS", Qt::CaseInsensitive)) - return LoadingDescriptors; - if (!str.compare("CONN_OR", Qt::CaseInsensitive)) - return ConnectingToEntryGuard; - if (!str.compare("HANDSHAKE_OR", Qt::CaseInsensitive)) - return HandshakingWithEntryGuard; - if (!str.compare("CIRCUIT_CREATE", Qt::CaseInsensitive)) - return EstablishingCircuit; - if (!str.compare("DONE", Qt::CaseInsensitive)) - return BootstrappingDone; - return UnrecognizedStatus; -} - -/** Returns the action that the Tor software recommended be taken in response - * to this bootstrap status. */ -BootstrapStatus::Recommendation -BootstrapStatus::actionFromString(const QString &str) -{ - if (!str.compare("WARN", Qt::CaseInsensitive)) - return RecommendWarn; - if (!str.compare("IGNORE", Qt::CaseInsensitive)) - return RecommendIgnore; - return UnrecognizedRecommendation; -} - -/** Returns true if this object represents a valid bootstrap status phase. */ -bool -BootstrapStatus::isValid() const -{ - return (_severity != tc::UnrecognizedSeverity - && _status != UnrecognizedStatus - && _percentComplete >= 0); -} - diff -Nru vidalia-0.1.13/src/torcontrol/BootstrapStatus.cpp vidalia-0.2.8/src/torcontrol/BootstrapStatus.cpp --- vidalia-0.1.13/src/torcontrol/BootstrapStatus.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/BootstrapStatus.cpp 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,97 @@ +/* +** 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.vidalia-project.net/. 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 BootstrapStatus.cpp +** \version $Id: BootstrapStatus.cpp 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Describes the Tor software's current bootstrapping status +*/ + +#include "BootstrapStatus.h" + + +BootstrapStatus::BootstrapStatus() +{ + _severity = tc::UnrecognizedSeverity; + _reason = tc::UnrecognizedReason; + _status = UnrecognizedStatus; + _action = UnrecognizedRecommendation; + _percentComplete = -1; +} + +/** Constructor. */ +BootstrapStatus::BootstrapStatus(tc::Severity severity, Status status, + int percentComplete, + const QString &description, + const QString &warning, + tc::ConnectionStatusReason reason, + Recommendation action) +{ + _severity = severity; + _status = status; + _percentComplete = qBound(0, percentComplete, 100); + _description = description; + _warning = warning; + _reason = reason; + _action = action; +} + +/** Converts a string TAG value to a BootstrapStatus enum value. */ +BootstrapStatus::Status +BootstrapStatus::statusFromString(const QString &str) +{ + if (!str.compare("CONN_DIR", Qt::CaseInsensitive)) + return ConnectingToDirMirror; + if (!str.compare("HANDSHAKE_DIR", Qt::CaseInsensitive)) + return HandshakingWithDirMirror; + if (!str.compare("ONEHOP_CREATE", Qt::CaseInsensitive)) + return CreatingOneHopCircuit; + if (!str.compare("REQUESTING_STATUS", Qt::CaseInsensitive)) + return RequestingNetworkStatus; + if (!str.compare("LOADING_STATUS", Qt::CaseInsensitive)) + return LoadingNetworkStatus; + if (!str.compare("LOADING_KEYS", Qt::CaseInsensitive)) + return LoadingAuthorityCertificates; + if (!str.compare("REQUESTING_DESCRIPTORS", Qt::CaseInsensitive)) + return RequestingDescriptors; + if (!str.compare("LOADING_DESCRIPTORS", Qt::CaseInsensitive)) + return LoadingDescriptors; + if (!str.compare("CONN_OR", Qt::CaseInsensitive)) + return ConnectingToEntryGuard; + if (!str.compare("HANDSHAKE_OR", Qt::CaseInsensitive)) + return HandshakingWithEntryGuard; + if (!str.compare("CIRCUIT_CREATE", Qt::CaseInsensitive)) + return EstablishingCircuit; + if (!str.compare("DONE", Qt::CaseInsensitive)) + return BootstrappingDone; + return UnrecognizedStatus; +} + +/** Returns the action that the Tor software recommended be taken in response + * to this bootstrap status. */ +BootstrapStatus::Recommendation +BootstrapStatus::actionFromString(const QString &str) +{ + if (!str.compare("WARN", Qt::CaseInsensitive)) + return RecommendWarn; + if (!str.compare("IGNORE", Qt::CaseInsensitive)) + return RecommendIgnore; + return UnrecognizedRecommendation; +} + +/** Returns true if this object represents a valid bootstrap status phase. */ +bool +BootstrapStatus::isValid() const +{ + return (_severity != tc::UnrecognizedSeverity + && _status != UnrecognizedStatus + && _percentComplete >= 0); +} + diff -Nru vidalia-0.1.13/src/torcontrol/bootstrapstatusevent.h vidalia-0.2.8/src/torcontrol/bootstrapstatusevent.h --- vidalia-0.1.13/src/torcontrol/bootstrapstatusevent.h 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/bootstrapstatusevent.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,70 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 bootstrapstatusevent.h -** \version $Id: bootstrapstatusevent.h 2780 2008-06-21 21:48:32Z edmanm $ -** \brief Event sent by Tor when its bootstrapping status changes -*/ - -#ifndef _BOOTSTRAPSTATUSEVENT_H -#define _BOOTSTRAPSTATUSEVENT_H - -#include -#include -#include "clientstatusevent.h" -#include "bootstrapstatus.h" - - -class BootstrapStatusEvent : public ClientStatusEvent -{ -public: - /** Constructor. */ - BootstrapStatusEvent(const BootstrapStatus &status) - : ClientStatusEvent(status.severity(), ClientStatusEvent::Bootstrap), - _bootstrapStatus(status) {} - - /** Returns the BootstrapStatus enum value indicated by this bootstrap - * status event. */ - BootstrapStatus status() const { return _bootstrapStatus; } - - /** Returns an integer between 0 and 100 representing an estimate of how - * much of Tor's bootstrapping process it has completed. */ - int percentComplete() const { return status().percentComplete(); } - - /** Returns a description of Tor's current bootstrapping status. */ - QString description() const { return status().description(); } - - /** Returns a description of the most recent error Tor encountered while - * attempting to bootstrap, if this event's severity is 'warn'. Otherwise, - * this returns a default-constructed QString. */ - QString warning() const { return status().warning(); } - - /** Returns a ConnectionStatusReason enum value describing the most recent - * error Tor encountered while attempting to bootstrap, if this event's - * severity is 'warn'. Otherwise, this simply returns - * tc::UnrecognizedReason. */ - tc::ConnectionStatusReason reason() const { return status().reason(); } - - /** Returns the action that the Tor software recommended be taken in - * response to this bootstrap status event. */ - BootstrapStatus::Recommendation recommendedAction() const { - return status().recommendedAction(); - } - -private: - /** Current bootstrapping status value. - * \sa status - */ - BootstrapStatus _bootstrapStatus; -}; - -#endif - diff -Nru vidalia-0.1.13/src/torcontrol/bootstrapstatus.h vidalia-0.2.8/src/torcontrol/bootstrapstatus.h --- vidalia-0.1.13/src/torcontrol/bootstrapstatus.h 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/bootstrapstatus.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,143 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 bootstrapstatus.h -** \version $Id: bootstrapstatus.h 2782 2008-06-21 21:52:15Z edmanm $ -** \brief Describes the Tor software's current bootstrap status -*/ - -#ifndef _BOOTSTRAPSTATUS_H -#define _BOOTSTRAPSTATUS_H - -#include -#include "tcglobal.h" - - -class BootstrapStatus -{ -public: - /** Currently enumerated bootstrapping states defined by Tor's control - * protocol (Tor >= 0.2.1.0-alpha-dev. */ - enum Status { - UnrecognizedStatus, - ConnectingToDirMirror, - HandshakingWithDirMirror, - CreatingOneHopCircuit, - RequestingNetworkStatus, - LoadingNetworkStatus, - LoadingAuthorityCertificates, - RequestingDescriptors, - LoadingDescriptors, - ConnectingToEntryGuard, - HandshakingWithEntryGuard, - EstablishingCircuit, - BootstrappingDone - }; - /** Actions the Tor software might recommend controllers take in response to - * a bootstrap status problem event. */ - enum Recommendation { - UnrecognizedRecommendation, - RecommendIgnore, - RecommendWarn - }; - - /** Default constructor. */ - BootstrapStatus(); - - /** Constructor. */ - BootstrapStatus(tc::Severity severity, - Status status, int percentComplete, - const QString &description, - const QString &warning = QString(), - tc::ConnectionStatusReason reason = tc::UnrecognizedReason, - Recommendation action = UnrecognizedRecommendation); - - /** Returns the severity of this bootstrap status event. */ - tc::Severity severity() const { return _severity; } - - /** Returns the BootstrapStatus enum value indicated by this bootstrap - * status event. */ - Status status() const { return _status; } - - /** Returns an integer between 0 and 100 representing an estimate of how - * much of Tor's bootstrapping process it has completed. */ - int percentComplete() const { return _percentComplete; } - - /** Returns a description of Tor's current bootstrapping status. */ - QString description() const { return _description; } - - /** Returns a description of the most recent error Tor encountered while - * attempting to bootstrap, if this event's severity is 'warn'. Otherwise, - * this returns a default-constructed QString. */ - QString warning() const { return _warning; } - - /** Returns a ConnectionStatusReason enum value describing the most recent - * error Tor encountered while attempting to bootstrap, if this event's - * severity is 'warn'. Otherwise, this simply returns - * tc::UnrecognizedReason. */ - tc::ConnectionStatusReason reason() const { return _reason; } - - /** Returns the action that the Tor software recommended be taken in - * response to this bootstrap status event. */ - Recommendation recommendedAction() const { return _action; } - - /** Returns true if this object represents a valid bootstrap status - * phase. */ - bool isValid() const; - - /** Converts a string TAG value to a BootstrapStatus enum value. */ - static Status statusFromString(const QString &tag); - /** Converts a string RECOMMENDATION value to a RecommendAction enum - * value. */ - static Recommendation actionFromString(const QString &str); - -private: - /** Severity of the current bootstrap status. - * \sa severity - */ - tc::Severity _severity; - - /** Current bootstrapping status value. - * \sa status - */ - Status _status; - - /** Approximate percentage of Tor's bootstrapping process that is complete. - * \sa percentComplete - */ - int _percentComplete; - - /** Description of Tor's current bootstrapping status. - * \sa description - */ - QString _description; - - /** Description of the most recent error Tor encountered while attempting to - * bootstrap. - * \sa warning - */ - QString _warning; - - /** ConnectionStatusReason enum value describing the most recent error Tor - * encountered while attempting to bootstrap. - * \sa reason - */ - tc::ConnectionStatusReason _reason; - - /** Recommendation enum value describing Tor's suggested response to this - * bootstrap status event. - * \sa recommendedAction - */ - Recommendation _action; -}; - -#endif - diff -Nru vidalia-0.1.13/src/torcontrol/BootstrapStatus.h vidalia-0.2.8/src/torcontrol/BootstrapStatus.h --- vidalia-0.1.13/src/torcontrol/BootstrapStatus.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/BootstrapStatus.h 2009-08-17 03:25:08.000000000 +0100 @@ -0,0 +1,147 @@ +/* +** 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.vidalia-project.net/. 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 BootstrapStatus.h +** \version $Id: BootstrapStatus.h 4054 2009-08-17 02:25:08Z edmanm $ +** \brief Describes the Tor software's current bootstrap status +*/ + +#ifndef _BOOTSTRAPSTATUS_H +#define _BOOTSTRAPSTATUS_H + +#include "tcglobal.h" + +#include +#include + + +class BootstrapStatus +{ +public: + /** Currently enumerated bootstrapping states defined by Tor's control + * protocol (Tor >= 0.2.1.0-alpha-dev. */ + enum Status { + UnrecognizedStatus, + ConnectingToDirMirror, + HandshakingWithDirMirror, + CreatingOneHopCircuit, + RequestingNetworkStatus, + LoadingNetworkStatus, + LoadingAuthorityCertificates, + RequestingDescriptors, + LoadingDescriptors, + ConnectingToEntryGuard, + HandshakingWithEntryGuard, + EstablishingCircuit, + BootstrappingDone + }; + /** Actions the Tor software might recommend controllers take in response to + * a bootstrap status problem event. */ + enum Recommendation { + UnrecognizedRecommendation, + RecommendIgnore, + RecommendWarn + }; + + /** Default constructor. */ + BootstrapStatus(); + + /** Constructor. */ + BootstrapStatus(tc::Severity severity, + Status status, int percentComplete, + const QString &description, + const QString &warning = QString(), + tc::ConnectionStatusReason reason = tc::UnrecognizedReason, + Recommendation action = UnrecognizedRecommendation); + + /** Returns the severity of this bootstrap status event. */ + tc::Severity severity() const { return _severity; } + + /** Returns the BootstrapStatus enum value indicated by this bootstrap + * status event. */ + Status status() const { return _status; } + + /** Returns an integer between 0 and 100 representing an estimate of how + * much of Tor's bootstrapping process it has completed. */ + int percentComplete() const { return _percentComplete; } + + /** Returns a description of Tor's current bootstrapping status. */ + QString description() const { return _description; } + + /** Returns a description of the most recent error Tor encountered while + * attempting to bootstrap, if this event's severity is 'warn'. Otherwise, + * this returns a default-constructed QString. */ + QString warning() const { return _warning; } + + /** Returns a ConnectionStatusReason enum value describing the most recent + * error Tor encountered while attempting to bootstrap, if this event's + * severity is 'warn'. Otherwise, this simply returns + * tc::UnrecognizedReason. */ + tc::ConnectionStatusReason reason() const { return _reason; } + + /** Returns the action that the Tor software recommended be taken in + * response to this bootstrap status event. */ + Recommendation recommendedAction() const { return _action; } + + /** Returns true if this object represents a valid bootstrap status + * phase. */ + bool isValid() const; + + /** Converts a string TAG value to a BootstrapStatus enum value. */ + static Status statusFromString(const QString &tag); + /** Converts a string RECOMMENDATION value to a RecommendAction enum + * value. */ + static Recommendation actionFromString(const QString &str); + +private: + /** Severity of the current bootstrap status. + * \sa severity + */ + tc::Severity _severity; + + /** Current bootstrapping status value. + * \sa status + */ + Status _status; + + /** Approximate percentage of Tor's bootstrapping process that is complete. + * \sa percentComplete + */ + int _percentComplete; + + /** Description of Tor's current bootstrapping status. + * \sa description + */ + QString _description; + + /** Description of the most recent error Tor encountered while attempting to + * bootstrap. + * \sa warning + */ + QString _warning; + + /** ConnectionStatusReason enum value describing the most recent error Tor + * encountered while attempting to bootstrap. + * \sa reason + */ + tc::ConnectionStatusReason _reason; + + /** Recommendation enum value describing Tor's suggested response to this + * bootstrap status event. + * \sa recommendedAction + */ + Recommendation _action; +}; + +Q_DECLARE_METATYPE(BootstrapStatus); + +#endif + diff -Nru vidalia-0.1.13/src/torcontrol/circuit.cpp vidalia-0.2.8/src/torcontrol/circuit.cpp --- vidalia-0.1.13/src/torcontrol/circuit.cpp 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/circuit.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,121 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 circuit.cpp -** \version $Id: circuit.cpp 3531 2009-02-17 01:33:36Z edmanm $ -** \brief Object representing a Tor circuit -*/ - -#include -#include - -#include "tcglobal.h" -#include "circuit.h" - - -/** Default constructor. */ -Circuit::Circuit() -{ - _status = Unknown; - _isValid = false; -} - -/** Parses the string given in Tor control protocol format for a circuit. The - * format is: - * - * CircuitID SP CircStatus [SP Path] - * - * If the status is "LAUNCHED", the Path is empty. Server names in the path - * must follow Tor's VERBOSE_NAMES format. - */ -Circuit::Circuit(const QString &circuit) -{ - QStringList parts = circuit.split(" ", QString::SkipEmptyParts); - if (parts.size() >= 2) { - /* Get the circuit ID */ - _circId = parts.at(0); - if (! isValidCircuitId(_circId)) - goto err; - - /* Get the circuit status value */ - _status = Circuit::toStatus(parts.at(1)); - - /* Get the circuit path (list of routers) */ - if (parts.size() > 2 && parts.at(2).startsWith("$")) { - foreach (QString hop, parts.at(2).split(",")) { - QStringList parts = hop.split(QRegExp("[=~]")); - if (parts.size() != 2) - goto err; - - _ids << parts.at(0).mid(1); - _names << parts.at(1); - } - } - - _isValid = true; - } - return; - -err: - tc::warn("Improperly formatted circuit: '%1'").arg(circuit); - _isValid = false; -} - -/** Returns true iff circId consists of only between 1 and 16 - * (inclusive) ASCII-encoded letters and numbers. */ -bool -Circuit::isValidCircuitId(const CircuitId &circId) -{ - int length = circId.length(); - if (length < 1 || length > 16) - return false; - - for (int i = 0; i < length; i++) { - char c = circId[i].toAscii(); - if (c < '0' && c > '9' && c < 'A' && c > 'Z' && c < 'a' && c > 'z') - return false; - } - return true; -} - -/** Converts the circuit status string to its proper enum value */ -Circuit::Status -Circuit::toStatus(const QString &status) -{ - if (!status.compare("LAUNCHED", Qt::CaseInsensitive)) - return Launched; - if (!status.compare("BUILT", Qt::CaseInsensitive)) - return Built; - if (!status.compare("EXTENDED", Qt::CaseInsensitive)) - return Extended; - if (!status.compare("FAILED", Qt::CaseInsensitive)) - return Failed; - if (!status.compare("CLOSED", Qt::CaseInsensitive)) - return Closed; - return Unknown; -} - -/** Returns a string representation of the circuit's status. */ -QString -Circuit::statusString() const -{ - QString status; - switch (_status) { - case Launched: status = tr("New"); break; - case Built: status = tr("Open"); break; - case Extended: status = tr("Building"); break; - case Failed: status = tr("Failed"); break; - case Closed: status = tr("Closed"); break; - default: status = tr("Unknown"); break; - } - return status; -} - diff -Nru vidalia-0.1.13/src/torcontrol/Circuit.cpp vidalia-0.2.8/src/torcontrol/Circuit.cpp --- vidalia-0.1.13/src/torcontrol/Circuit.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/Circuit.cpp 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,121 @@ +/* +** 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.vidalia-project.net/. 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 Circuit.cpp +** \version $Id: Circuit.cpp 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Object representing a Tor circuit +*/ + +#include "tcglobal.h" +#include "Circuit.h" + +#include +#include + + +/** Default constructor. */ +Circuit::Circuit() +{ + _status = Unknown; + _isValid = false; +} + +/** Parses the string given in Tor control protocol format for a circuit. The + * format is: + * + * CircuitID SP CircStatus [SP Path] + * + * If the status is "LAUNCHED", the Path is empty. Server names in the path + * must follow Tor's VERBOSE_NAMES format. + */ +Circuit::Circuit(const QString &circuit) +{ + QStringList parts = circuit.split(" ", QString::SkipEmptyParts); + if (parts.size() >= 2) { + /* Get the circuit ID */ + _circId = parts.at(0); + if (! isValidCircuitId(_circId)) + goto err; + + /* Get the circuit status value */ + _status = Circuit::toStatus(parts.at(1)); + + /* Get the circuit path (list of routers) */ + if (parts.size() > 2 && parts.at(2).startsWith("$")) { + foreach (QString hop, parts.at(2).split(",")) { + QStringList parts = hop.split(QRegExp("[=~]")); + if (parts.size() != 2) + goto err; + + _ids << parts.at(0).mid(1); + _names << parts.at(1); + } + } + + _isValid = true; + } + return; + +err: + tc::warn("Improperly formatted circuit: '%1'").arg(circuit); + _isValid = false; +} + +/** Returns true iff circId consists of only between 1 and 16 + * (inclusive) ASCII-encoded letters and numbers. */ +bool +Circuit::isValidCircuitId(const CircuitId &circId) +{ + int length = circId.length(); + if (length < 1 || length > 16) + return false; + + for (int i = 0; i < length; i++) { + char c = circId[i].toAscii(); + if (c < '0' && c > '9' && c < 'A' && c > 'Z' && c < 'a' && c > 'z') + return false; + } + return true; +} + +/** Converts the circuit status string to its proper enum value */ +Circuit::Status +Circuit::toStatus(const QString &status) +{ + if (!status.compare("LAUNCHED", Qt::CaseInsensitive)) + return Launched; + if (!status.compare("BUILT", Qt::CaseInsensitive)) + return Built; + if (!status.compare("EXTENDED", Qt::CaseInsensitive)) + return Extended; + if (!status.compare("FAILED", Qt::CaseInsensitive)) + return Failed; + if (!status.compare("CLOSED", Qt::CaseInsensitive)) + return Closed; + return Unknown; +} + +/** Returns a string representation of the circuit's status. */ +QString +Circuit::statusString() const +{ + QString status; + switch (_status) { + case Launched: status = tr("New"); break; + case Built: status = tr("Open"); break; + case Extended: status = tr("Building"); break; + case Failed: status = tr("Failed"); break; + case Closed: status = tr("Closed"); break; + default: status = tr("Unknown"); break; + } + return status; +} + diff -Nru vidalia-0.1.13/src/torcontrol/circuitestablishedevent.h vidalia-0.2.8/src/torcontrol/circuitestablishedevent.h --- vidalia-0.1.13/src/torcontrol/circuitestablishedevent.h 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/circuitestablishedevent.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,32 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 circuitestablishedevent.h -** \version $Id: circuitestablishedevent.h 2780 2008-06-21 21:48:32Z edmanm $ -** \brief Event sent when Tor has first successfully established a circuit -*/ - -#ifndef _CIRCUITESTABLISHEDEVENT_H -#define _CIRCUITESTABLISHEDEVENT_H - -#include "clientstatusevent.h" - - -class CircuitEstablishedEvent : public ClientStatusEvent -{ -public: - /** Constructor. */ - CircuitEstablishedEvent(tc::Severity severity) - : ClientStatusEvent(severity, ClientStatusEvent::CircuitEstablished) {} -}; - -#endif - diff -Nru vidalia-0.1.13/src/torcontrol/circuitevent.h vidalia-0.2.8/src/torcontrol/circuitevent.h --- vidalia-0.1.13/src/torcontrol/circuitevent.h 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/circuitevent.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,52 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 circuitevent.h -** \version $Id: circuitevent.h 2977 2008-08-17 01:28:25Z edmanm $ -** \brief Event dispatched containing updated circuit status information -*/ - -#ifndef _CIRCUITEVENT_H -#define _CIRCUITEVENT_H - -#include -#include - -#include "eventtype.h" -#include "circuit.h" - - -class CircuitEvent : public QEvent -{ -public: - /** Constructor */ - CircuitEvent(Circuit circuit) - : QEvent((QEvent::Type)CustomEventType::CircuitEvent) - { _circuit = circuit; } - - /** Returns the Circuit object for this event. */ - Circuit circuit() const { return _circuit; } - /** Returns the ID for this circuit event. */ - CircuitId id() const { return _circuit.id(); } - /** Returns the status of this circuit event. */ - Circuit::Status status() const { return _circuit.status(); } - /** Returns the names of the routers in the path for this circuit event. */ - QStringList routerNames() const { return _circuit.routerNames(); } - /** Returns the IDs of the routers in the path for this circuit event. */ - QStringList routerIDs() const { return _circuit.routerIDs(); } - -private: - /** Circuit object for this event. */ - Circuit _circuit; -}; - -#endif - diff -Nru vidalia-0.1.13/src/torcontrol/circuit.h vidalia-0.2.8/src/torcontrol/circuit.h --- vidalia-0.1.13/src/torcontrol/circuit.h 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/circuit.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,82 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 circuit.h -** \version $Id: circuit.h 2977 2008-08-17 01:28:25Z edmanm $ -** \brief Object representing a Tor circuit -*/ - -#ifndef _CIRCUIT_H -#define _CIRCUIT_H - -#include -#include - -/** Circuit IDs contains 1-16 alphanumeric ASCII characters. */ -typedef QString CircuitId; - - -class Circuit -{ - Q_DECLARE_TR_FUNCTIONS(Circuit) - -public: - /** Circuit status events */ - enum Status { - Unknown, /**< Unknown circuit status */ - Launched, /**< Circuit ID assigned to new circuit */ - Built, /**< All hops finished */ - Extended, /**< Circuit extended by one hop */ - Failed, /**< Circuit closed (was not built) */ - Closed /**< Circuit closed (was built) */ - }; - - /** Default constructor. */ - Circuit(); - /** Constructor. */ - Circuit(const CircuitId &circuit); - - /** Returns true if this circuit is valid. */ - bool isValid() const { return _isValid; } - - /** Returns the ID for this circuit */ - CircuitId id() const { return _circId; } - /** Returns the status of this circuit */ - Status status() const { return _status; } - /** Returns a string representation of the status of this circuit. */ - QString statusString() const; - /** Returns the length of the circuit's path. */ - uint length() const { return _ids.size(); } - /** Returns the circuit's path as an ordered list of router nicknames. */ - QStringList routerNames() const { return _names; } - /** Returns the circuit's path as an ordered list of router fingerprints. */ - QStringList routerIDs() const { return _ids; } - - /** Converts a string description of a circuit's status to an enum value */ - static Status toStatus(const QString &strStatus); - - /** Returns true iff circId consists of only between 1 and 16 - * (inclusive) ASCII-encoded letters and numbers. */ - static bool isValidCircuitId(const CircuitId &circId); - -private: - CircuitId _circId; /**< Circuit ID. */ - Status _status; /**< Circuit status. */ - QStringList _names; /**< Nicknames of the routers in the circuit. */ - QStringList _ids; /**< IDs of the routers in the circuit. */ - bool _isValid; -}; - -/** A collection of circuits. */ -typedef QList CircuitList; - -#endif - diff -Nru vidalia-0.1.13/src/torcontrol/Circuit.h vidalia-0.2.8/src/torcontrol/Circuit.h --- vidalia-0.1.13/src/torcontrol/Circuit.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/Circuit.h 2009-08-17 03:25:08.000000000 +0100 @@ -0,0 +1,85 @@ +/* +** 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.vidalia-project.net/. 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 Circuit.h +** \version $Id: Circuit.h 4054 2009-08-17 02:25:08Z edmanm $ +** \brief Object representing a Tor circuit +*/ + +#ifndef _CIRCUIT_H +#define _CIRCUIT_H + +#include +#include +#include + +/** Circuit IDs contains 1-16 alphanumeric ASCII characters. */ +typedef QString CircuitId; + + +class Circuit +{ + Q_DECLARE_TR_FUNCTIONS(Circuit) + +public: + /** Circuit status events */ + enum Status { + Unknown, /**< Unknown circuit status */ + Launched, /**< Circuit ID assigned to new circuit */ + Built, /**< All hops finished */ + Extended, /**< Circuit extended by one hop */ + Failed, /**< Circuit closed (was not built) */ + Closed /**< Circuit closed (was built) */ + }; + + /** Default constructor. */ + Circuit(); + /** Constructor. */ + Circuit(const CircuitId &circuit); + + /** Returns true if this circuit is valid. */ + bool isValid() const { return _isValid; } + + /** Returns the ID for this circuit */ + CircuitId id() const { return _circId; } + /** Returns the status of this circuit */ + Status status() const { return _status; } + /** Returns a string representation of the status of this circuit. */ + QString statusString() const; + /** Returns the length of the circuit's path. */ + uint length() const { return _ids.size(); } + /** Returns the circuit's path as an ordered list of router nicknames. */ + QStringList routerNames() const { return _names; } + /** Returns the circuit's path as an ordered list of router fingerprints. */ + QStringList routerIDs() const { return _ids; } + + /** Converts a string description of a circuit's status to an enum value */ + static Status toStatus(const QString &strStatus); + + /** Returns true iff circId consists of only between 1 and 16 + * (inclusive) ASCII-encoded letters and numbers. */ + static bool isValidCircuitId(const CircuitId &circId); + +private: + CircuitId _circId; /**< Circuit ID. */ + Status _status; /**< Circuit status. */ + QStringList _names; /**< Nicknames of the routers in the circuit. */ + QStringList _ids; /**< IDs of the routers in the circuit. */ + bool _isValid; +}; + +Q_DECLARE_METATYPE(Circuit); + +/** A collection of circuits. */ +typedef QList CircuitList; + +#endif + diff -Nru vidalia-0.1.13/src/torcontrol/clientstatusevent.cpp vidalia-0.2.8/src/torcontrol/clientstatusevent.cpp --- vidalia-0.1.13/src/torcontrol/clientstatusevent.cpp 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/clientstatusevent.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,43 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 clientstatusevent.cpp -** \version $Id: clientstatusevent.cpp 2780 2008-06-21 21:48:32Z edmanm $ -** \brief Base class for all Tor client status events -*/ - -#include "clientstatusevent.h" - - -/** Returns a ClientStatusEvent::Status enum value for the status event type - * represented by str. */ -ClientStatusEvent::Status -ClientStatusEvent::statusFromString(const QString &str) -{ - if (!str.compare("ENOUGH_DIR_INFO", Qt::CaseInsensitive)) - return EnoughDirectoryInfo; - if (!str.compare("NOT_ENOUGH_DIR_INFO", Qt::CaseInsensitive)) - return NotEnoughDirectoryInfo; - if (!str.compare("CIRCUIT_ESTABLISHED", Qt::CaseInsensitive)) - return CircuitEstablished; - if (!str.compare("CIRCUIT_NOT_ESTABLISHED", Qt::CaseInsensitive)) - return CircuitNotEstablished; - if (!str.compare("DANGEROUS_SOCKS", Qt::CaseInsensitive)) - return DangerousSocks; - if (!str.compare("SOCKS_UNKNOWN_PROTOCOL", Qt::CaseInsensitive)) - return UnknownSocksProtocol; - if (!str.compare("SOCKS_BAD_HOSTNAME", Qt::CaseInsensitive)) - return SocksBadHostname; - if (!str.compare("BOOTSTRAP", Qt::CaseInsensitive)) - return Bootstrap; - return UnrecognizedStatus; -} - diff -Nru vidalia-0.1.13/src/torcontrol/clientstatusevent.h vidalia-0.2.8/src/torcontrol/clientstatusevent.h --- vidalia-0.1.13/src/torcontrol/clientstatusevent.h 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/clientstatusevent.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,55 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 clientstatusevent.h -** \version $Id: clientstatusevent.h 2780 2008-06-21 21:48:32Z edmanm $ -** \brief Base class for all Tor client status events -*/ - -#ifndef _CLIENTSTATUSEVENT_H -#define _CLIENTSTATUSEVENT_H - -#include "statusevent.h" - - -class ClientStatusEvent : public StatusEvent -{ -public: - /** Tor client status event type. */ - enum Status { - UnrecognizedStatus, - Bootstrap, - CircuitEstablished, - CircuitNotEstablished, - NotEnoughDirectoryInfo, - EnoughDirectoryInfo, - DangerousSocks, - UnknownSocksProtocol, - SocksBadHostname - }; - - /** Constructor. */ - ClientStatusEvent(tc::Severity severity, Status status) - : StatusEvent((QEvent::Type)CustomEventType::ClientStatusEvent, severity), - _status(status) {} - - /** Returns the client status indicated by this event. */ - Status status() const { return _status; } - /** Returns a ClientStatusEvent::Status enum value for the status event type - * represented by str. */ - static Status statusFromString(const QString &str); - -private: - Status _status; /**< Tor Client status indicated by this event. */ -}; - -#endif - diff -Nru vidalia-0.1.13/src/torcontrol/CMakeLists.txt vidalia-0.2.8/src/torcontrol/CMakeLists.txt --- vidalia-0.1.13/src/torcontrol/CMakeLists.txt 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/CMakeLists.txt 2009-08-17 03:25:08.000000000 +0100 @@ -1,5 +1,5 @@ ## -## $Id: CMakeLists.txt 2838 2008-07-06 22:43:48Z edmanm $ +## $Id: CMakeLists.txt 4054 2009-08-17 02:25:08Z edmanm $ ## ## 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 @@ -12,49 +12,47 @@ set(torcontrol_SRCS - addressmap.cpp - bootstrapstatus.cpp - circuit.cpp - clientstatusevent.cpp - controlcommand.cpp - controlconnection.cpp - controlreply.cpp - controlsocket.cpp - dangerousversionevent.cpp - generalstatusevent.cpp - logevent.cpp - orconnevent.cpp - protocolinfo.cpp - replyline.cpp - routerdescriptor.cpp - routerstatus.cpp - sendcommandevent.cpp - serverstatusevent.cpp - stream.cpp + AddressMap.cpp + BootstrapStatus.cpp + Circuit.cpp + ControlCommand.cpp + ControlConnection.cpp + ControlReply.cpp + ControlSocket.cpp + ProtocolInfo.cpp + ReplyLine.cpp + RouterDescriptor.cpp + RouterStatus.cpp + SendCommandEvent.cpp + Stream.cpp tcglobal.cpp - torcontrol.cpp - torevents.cpp - torprocess.cpp - torsignal.cpp + TorControl.cpp + TorEvents.cpp + TorProcess.cpp + TorSignal.cpp ) qt4_wrap_cpp(torcontrol_SRCS - controlconnection.h - controlsocket.h - torcontrol.h - torevents.h - torprocess.h + ControlConnection.h + ControlSocket.h + TorControl.h + TorEvents.h + TorProcess.h ) if (WIN32) set(torcontrol_SRCS ${torcontrol_SRCS} - torservice.cpp + TorService.cpp ) qt4_wrap_cpp(torcontrol_SRCS - torservice.h + TorService.h ) endif(WIN32) add_library(torcontrol STATIC ${torcontrol_SRCS}) -target_link_libraries(torcontrol ${QT_LIBRARIES} common) +target_link_libraries(torcontrol + ${QT_QTCORE_LIBRARY} + ${QT_QTNETWORK_LIBRARY} + common +) diff -Nru vidalia-0.1.13/src/torcontrol/controlcommand.cpp vidalia-0.2.8/src/torcontrol/controlcommand.cpp --- vidalia-0.1.13/src/torcontrol/controlcommand.cpp 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/controlcommand.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,124 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 controlcommand.cpp -** \version $Id: controlcommand.cpp 2362 2008-02-29 04:30:11Z edmanm $ -** \brief A command sent to Tor's control interface -*/ - -#include "controlcommand.h" - - -/** Default constructor. */ -ControlCommand::ControlCommand() -{ -} - -/** Creates a command using the specified keyword. */ -ControlCommand::ControlCommand(const QString &keyword) -{ - _keyword = keyword; -} - -/** Creates a control command using the specified keyword and argument. */ -ControlCommand::ControlCommand(const QString &keyword, const QString &arg) -{ - _keyword = keyword; - addArgument(arg); -} - -/** Creates a control command using the specified keyword and list of - * arguments. */ -ControlCommand::ControlCommand(const QString &keyword, const QStringList &args) -{ - _keyword = keyword; - _arguments = args; -} - -/** Sets the keyword for this command. */ -void -ControlCommand::setKeyword(const QString &keyword) -{ - _keyword = keyword; -} - -/** Adds an argument to this command's argument list. */ -void -ControlCommand::addArgument(const QString &arg) -{ - _arguments << arg; -} - -/** Adds all arguments in args to this control command. */ -void -ControlCommand::addArguments(const QStringList &args) -{ - foreach (QString arg, args) { - addArgument(arg); - } -} - -/** Adds data to the end of this command. */ -void -ControlCommand::appendData(const QString &data) -{ - _data << data; -} - -/** Escapes any special characters in this command. */ -QString -ControlCommand::escape(const QString &unescaped) const -{ - QString str = unescaped; - if (str.startsWith(".")) { - str.prepend("."); - } - if (str.endsWith("\r")) { - str.append("\n"); - } else { - str.append("\r\n"); - } - return str; -} - -/** Formats a command according to Tor's Control Protocol V1. The proper - * format of a command is as follows: - * - * Command = Keyword Arguments CRLF / "+" Keyword Arguments CRLF Data - * Keyword = 1*ALPHA - * Arguments = *(SP / VCHAR) - */ -QString -ControlCommand::toString() const -{ - int i; - QString str; - - /* If this command contains data, then a "+" is prepended to the keyword */ - if (_data.size() > 0) { - str = "+"; - } - str += _keyword + " "; - - /* Append all specified arguments separated by a space */ - str += _arguments.join(" "); - - /* Append whatever data lines have been specified */ - if (_data.size() > 0) { - str += "\r\n"; - for (i = 0; i < _data.size(); i++) { - str += escape(_data.at(i)); - } - str += "."; - } - return str.append("\r\n"); -} - diff -Nru vidalia-0.1.13/src/torcontrol/ControlCommand.cpp vidalia-0.2.8/src/torcontrol/ControlCommand.cpp --- vidalia-0.1.13/src/torcontrol/ControlCommand.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/ControlCommand.cpp 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,124 @@ +/* +** 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.vidalia-project.net/. 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 ControlCommand.cpp +** \version $Id: ControlCommand.cpp 3735 2009-04-28 20:28:01Z edmanm $ +** \brief A command sent to Tor's control interface +*/ + +#include "ControlCommand.h" + + +/** Default constructor. */ +ControlCommand::ControlCommand() +{ +} + +/** Creates a command using the specified keyword. */ +ControlCommand::ControlCommand(const QString &keyword) +{ + _keyword = keyword; +} + +/** Creates a control command using the specified keyword and argument. */ +ControlCommand::ControlCommand(const QString &keyword, const QString &arg) +{ + _keyword = keyword; + addArgument(arg); +} + +/** Creates a control command using the specified keyword and list of + * arguments. */ +ControlCommand::ControlCommand(const QString &keyword, const QStringList &args) +{ + _keyword = keyword; + _arguments = args; +} + +/** Sets the keyword for this command. */ +void +ControlCommand::setKeyword(const QString &keyword) +{ + _keyword = keyword; +} + +/** Adds an argument to this command's argument list. */ +void +ControlCommand::addArgument(const QString &arg) +{ + _arguments << arg; +} + +/** Adds all arguments in args to this control command. */ +void +ControlCommand::addArguments(const QStringList &args) +{ + foreach (QString arg, args) { + addArgument(arg); + } +} + +/** Adds data to the end of this command. */ +void +ControlCommand::appendData(const QString &data) +{ + _data << data; +} + +/** Escapes any special characters in this command. */ +QString +ControlCommand::escape(const QString &unescaped) const +{ + QString str = unescaped; + if (str.startsWith(".")) { + str.prepend("."); + } + if (str.endsWith("\r")) { + str.append("\n"); + } else { + str.append("\r\n"); + } + return str; +} + +/** Formats a command according to Tor's Control Protocol V1. The proper + * format of a command is as follows: + * + * Command = Keyword Arguments CRLF / "+" Keyword Arguments CRLF Data + * Keyword = 1*ALPHA + * Arguments = *(SP / VCHAR) + */ +QString +ControlCommand::toString() const +{ + int i; + QString str; + + /* If this command contains data, then a "+" is prepended to the keyword */ + if (_data.size() > 0) { + str = "+"; + } + str += _keyword + " "; + + /* Append all specified arguments separated by a space */ + str += _arguments.join(" "); + + /* Append whatever data lines have been specified */ + if (_data.size() > 0) { + str += "\r\n"; + for (i = 0; i < _data.size(); i++) { + str += escape(_data.at(i)); + } + str += "."; + } + return str.append("\r\n"); +} + diff -Nru vidalia-0.1.13/src/torcontrol/controlcommand.h vidalia-0.2.8/src/torcontrol/controlcommand.h --- vidalia-0.1.13/src/torcontrol/controlcommand.h 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/controlcommand.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,59 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 controlcommand.h -** \version $Id: controlcommand.h 2362 2008-02-29 04:30:11Z edmanm $ -** \brief A command sent to Tor's control interface -*/ - -#ifndef _CONTROLCOMMAND_H -#define _CONTROLCOMMAND_H - -#include - - -class ControlCommand -{ -public: - ControlCommand(); - ControlCommand(const QString &keyword); - ControlCommand(const QString &keyword, const QString &arg); - ControlCommand(const QString &keyword, const QStringList &args); - - /** Returns the keyword for this control command. */ - QString keyword() const { return _keyword; } - - /** Set the keyword for this control command */ - void setKeyword(const QString &keyword); - - /** Add an argument to this control command */ - void addArgument(const QString &arg); - /** Adds all arguments in args to this control command. */ - void addArguments(const QStringList &args); - - /** Append a data line for this control command */ - void appendData(const QString &data); - - /** Format this control command into a format conforming to Tor's v1 - * protocol specification. */ - QString toString() const; - -private: - /** Escape special characters in the supplied string */ - QString escape(const QString &str) const; - - QString _keyword; - QStringList _arguments; - QStringList _data; -}; - -#endif - diff -Nru vidalia-0.1.13/src/torcontrol/ControlCommand.h vidalia-0.2.8/src/torcontrol/ControlCommand.h --- vidalia-0.1.13/src/torcontrol/ControlCommand.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/ControlCommand.h 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,59 @@ +/* +** 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.vidalia-project.net/. 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 ControlCommand.h +** \version $Id: ControlCommand.h 3735 2009-04-28 20:28:01Z edmanm $ +** \brief A command sent to Tor's control interface +*/ + +#ifndef _CONTROLCOMMAND_H +#define _CONTROLCOMMAND_H + +#include + + +class ControlCommand +{ +public: + ControlCommand(); + ControlCommand(const QString &keyword); + ControlCommand(const QString &keyword, const QString &arg); + ControlCommand(const QString &keyword, const QStringList &args); + + /** Returns the keyword for this control command. */ + QString keyword() const { return _keyword; } + + /** Set the keyword for this control command */ + void setKeyword(const QString &keyword); + + /** Add an argument to this control command */ + void addArgument(const QString &arg); + /** Adds all arguments in args to this control command. */ + void addArguments(const QStringList &args); + + /** Append a data line for this control command */ + void appendData(const QString &data); + + /** Format this control command into a format conforming to Tor's v1 + * protocol specification. */ + QString toString() const; + +private: + /** Escape special characters in the supplied string */ + QString escape(const QString &str) const; + + QString _keyword; + QStringList _arguments; + QStringList _data; +}; + +#endif + diff -Nru vidalia-0.1.13/src/torcontrol/controlconnection.cpp vidalia-0.2.8/src/torcontrol/controlconnection.cpp --- vidalia-0.1.13/src/torcontrol/controlconnection.cpp 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/controlconnection.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,375 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 controlconnection.cpp -** \version $Id: controlconnection.cpp 2838 2008-07-06 22:43:48Z edmanm $ -** \brief A connection to Tor's control interface, responsible for sending and -** receiving commands and events -*/ - -#include -#include -#include -#include "tcglobal.h" - -#include "controlconnection.h" - -/** Maximum number of times we'll try to connect to Tor before giving up.*/ -#define MAX_CONNECT_ATTEMPTS 5 -/** Time to wait between control connection attempts (in milliseconds). */ -#define CONNECT_RETRY_DELAY 2*1000 - - -/** Default constructor. */ -ControlConnection::ControlConnection(TorEvents *events) -{ - _events = events; - _status = Unset; - _sock = 0; - _sendWaiter = new SendCommandEvent::SendWaiter(); -} - -/** Destructor. */ -ControlConnection::~ControlConnection() -{ - /* Exit the event loop */ - exit(); - /* Wait for the thread to finish */ - wait(); - /* Clean up after the send waiter */ - delete _sendWaiter; -} - -/** Connect to the specified Tor control interface. */ -void -ControlConnection::connect(const QHostAddress &addr, quint16 port) -{ - if (isRunning()) { - tc::error("Bug: Tried to call ControlConnection::connect() when the " - "control thread is already running."); - return; - } - - /* Save the destination information */ - _addr = addr; - _port = port; - _sock = 0; - _connectAttempt = 0; - setStatus(Connecting); - - /* Kick off the thread in which the control socket will live */ - QThread::start(); -} - -/** Attempt to establish a connection to Tor's control interface. We will try - * a maximum of MAX_CONNECT_ATTEMPTS, waiting CONNECT_RETRY_DELAY between each - * attempt, to give slow Tors a chance to finish binding their control port. */ -void -ControlConnection::connect() -{ - _connectAttempt++; - tc::debug("Connecting to Tor (Attempt %1 of %2)").arg(_connectAttempt) - .arg(MAX_CONNECT_ATTEMPTS); - - _connMutex.lock(); - _sock->connectToHost(_addr, _port); - _connMutex.unlock(); -} - -/** Disconnect from Tor's control interface. */ -void -ControlConnection::disconnect() -{ - setStatus(Disconnecting); - _connMutex.lock(); - _sock->disconnectFromHost(); - _connMutex.unlock(); -} - -/** Called when the control socket is connected. This method checks that the - * control protocol version of the Tor we connected to is at least V1. */ -void -ControlConnection::onConnected() -{ - setStatus(Connected); - emit connected(); -} - -/** Called when the control socket is disconnected and stops the control - * thread's event loop. */ -void -ControlConnection::onDisconnected() -{ - setStatus(Disconnected); - emit disconnected(); - exit(0); -} - -/** Called when the control socket encounters error. */ -void -ControlConnection::onError(QAbstractSocket::SocketError error) -{ - if (status() == Connecting) { - /* If we got a 'connection refused' and we haven't exceeded - * MAX_CONNECT_ATTEMPTS, then try to reconnect since Tor is probably - * running, but it doesn't have a ControlPort open yet. */ - if (error == QAbstractSocket::ConnectionRefusedError && - _connectAttempt < MAX_CONNECT_ATTEMPTS) { - tc::debug("Control connection refused. Retrying in %1ms.") - .arg(CONNECT_RETRY_DELAY); - _connectTimer->start(CONNECT_RETRY_DELAY); - } else { - /* Exceeded maximum number of connect attempts. Give up. */ - QString errstr = ControlSocket::toString(error); - tc::error("Vidalia was unable to connect to Tor: %1").arg(errstr); - emit connectFailed(tr("Vidalia was unable to connect to Tor. (%1)") - .arg(errstr)); - setStatus(Disconnected); - } - } else if (error == QAbstractSocket::RemoteHostClosedError) { - /* Tor closed the connection. This is common when we send a 'shutdown' or - * 'halt' signal to Tor and doesn't need to be logged as loudly. */ - tc::warn("Tor closed the control connection."); - } else { - /* Some other error. */ - /*XXX We may want to be emitting these so the GUI thread can learn about - * them and display an error message. */ - tc::error("Control socket error: %1").arg(ControlSocket::toString(error)); - } -} - -/** Cancels a pending control connection to Tor. */ -void -ControlConnection::cancelConnect() -{ - tc::warn("Control connection attempt cancelled."); - setStatus(Disconnected); - exit(0); -} - -/** Returns true if the control socket is connected to Tor. */ -bool -ControlConnection::isConnected() -{ - return (status() == Connected); -} - -/** Returns the status of the control connection. */ -ControlConnection::Status -ControlConnection::status() -{ - QMutexLocker locker(&_statusMutex); - return _status; -} - -/** Returns a string description of the control Status value - * status. */ -QString -ControlConnection::statusString(Status status) -{ - QString str; - switch (status) { - case Unset: str = "Unset"; break; - case Disconnected: str = "Disconnected"; break; - case Disconnecting: str = "Disconnecting"; break; - case Connecting: str = "Connecting"; break; - case Connected: str = "Connected"; break; - default: str = "unknown"; - } - return str; -} - -/** Sets the control connection status. */ -void -ControlConnection::setStatus(Status status) -{ - QMutexLocker locker(&_statusMutex); - tc::debug("Control connection status changed from '%1' to '%2'") - .arg(statusString(_status)) - .arg(statusString(status)); - _status = status; -} - -/** Sends a control command to Tor and waits for the reply. */ -bool -ControlConnection::send(const ControlCommand &cmd, - ControlReply &reply, QString *errmsg) -{ - bool result = false; - QString errstr; - - _recvMutex.lock(); - if (send(cmd, &errstr)) { - /* Create and enqueue a new receive waiter */ - ReceiveWaiter *w = new ReceiveWaiter(); - _recvQueue.enqueue(w); - _recvMutex.unlock(); - - /* Wait for and get the result, clean up, and return */ - result = w->getResult(&reply, &errstr); - if (!result) - tc::error("Failed to receive control reply: %1").arg(errstr); - delete w; - } else { - tc::error("Failed to send control command (%1): %2").arg(cmd.keyword()) - .arg(errstr); - _recvMutex.unlock(); - } - - if (!result && errmsg) - *errmsg = errstr; - return result; -} - -/** Sends a control command to Tor and returns true if the command was sent - * successfully. Otherwise, returns false and *errmsg (if supplied) - * will be set. */ -bool -ControlConnection::send(const ControlCommand &cmd, QString *errmsg) -{ - _connMutex.lock(); - if (!_sock || !_sock->isConnected()) { - _connMutex.unlock(); - return err(errmsg, tr("Control socket is not connected.")); - } - QCoreApplication::postEvent(_sock, new SendCommandEvent(cmd, _sendWaiter)); - _connMutex.unlock(); - - return _sendWaiter->getResult(errmsg); -} - -/** Called when there is data on the control socket. */ -void -ControlConnection::onReadyRead() -{ - QMutexLocker locker(&_connMutex); - ReceiveWaiter *waiter; - QString errmsg; - - while (_sock->canReadLine()) { - ControlReply reply; - if (_sock->readReply(reply, &errmsg)) { - if (reply.getStatus() == "650") { - /* Asynchronous event message */ - tc::debug("Control Event: %1").arg(reply.toString()); - - if (_events) { - _events->handleEvent(reply); - } - } else { - /* Response to a previous command */ - tc::debug("Control Reply: %1").arg(reply.toString()); - - _recvMutex.lock(); - if (!_recvQueue.isEmpty()) { - waiter = _recvQueue.dequeue(); - waiter->setResult(true, reply); - } - _recvMutex.unlock(); - } - } else { - tc::error("Unable to read control reply: %1").arg(errmsg); - } - } -} - -/** Main thread implementation. Creates and connects a control socket, then - * spins up an event loop. */ -void -ControlConnection::run() -{ - /* Create a new control socket */ - _connMutex.lock(); - _sock = new ControlSocket(); - _connectTimer = new QTimer(); - _connectTimer->setSingleShot(true); - - QObject::connect(_sock, SIGNAL(readyRead()), this, SLOT(onReadyRead()), - Qt::DirectConnection); - QObject::connect(_sock, SIGNAL(disconnected()), this, SLOT(onDisconnected()), - Qt::DirectConnection); - QObject::connect(_sock, SIGNAL(connected()), this, SLOT(onConnected()), - Qt::DirectConnection); - QObject::connect(_sock, SIGNAL(error(QAbstractSocket::SocketError)), - this, SLOT(onError(QAbstractSocket::SocketError)), - Qt::DirectConnection); - QObject::connect(_connectTimer, SIGNAL(timeout()), this, SLOT(connect()), - Qt::DirectConnection); - - _connMutex.unlock(); - - /* Attempt to connect to Tor */ - connect(); - tc::debug("Starting control connection event loop."); - exec(); - tc::debug("Exited control connection event loop."); - - /* Clean up the socket */ - _connMutex.lock(); - _sock->disconnect(this); - delete _sock; - delete _connectTimer; - _sock = 0; - _connMutex.unlock(); - - /* If there are any messages waiting for a response, clear them. */ - if (_sendWaiter->status() == SendCommandEvent::SendWaiter::Waiting) - _sendWaiter->setResult(false, tr("Control socket is not connected.")); - - _recvMutex.lock(); - while (!_recvQueue.isEmpty()) { - ReceiveWaiter *w = _recvQueue.dequeue(); - w->setResult(false, ControlReply(), - tr("Control socket is not connected.")); - } - _recvMutex.unlock(); -} - - -/* - * ControlConnection::ReceiveWaiter - */ -/** Waits for and gets the reply from a control command. */ -bool -ControlConnection::ReceiveWaiter::getResult(ControlReply *reply, - QString *errmsg) -{ - forever { - _mutex.lock(); - if (_status == Waiting) { - _waitCond.wait(&_mutex); - _mutex.unlock(); - } else { - _mutex.unlock(); - break; - } - } - if (errmsg) { - *errmsg = _errmsg; - } - *reply = _reply; - return (_status == Success); -} - -/** Sets the result and reply from a control command. */ -void -ControlConnection::ReceiveWaiter::setResult(bool success, - const ControlReply &reply, - const QString &errmsg) -{ - _mutex.lock(); - _status = (success ? Success : Failed); - _reply = reply; - _errmsg = errmsg; - _mutex.unlock(); - _waitCond.wakeAll(); -} - diff -Nru vidalia-0.1.13/src/torcontrol/ControlConnection.cpp vidalia-0.2.8/src/torcontrol/ControlConnection.cpp --- vidalia-0.1.13/src/torcontrol/ControlConnection.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/ControlConnection.cpp 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,375 @@ +/* +** 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.vidalia-project.net/. 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 ControlConnection.cpp +** \version $Id: ControlConnection.cpp 3735 2009-04-28 20:28:01Z edmanm $ +** \brief A connection to Tor's control interface, responsible for sending and +** receiving commands and events +*/ + +#include "ControlConnection.h" +#include "tcglobal.h" +#include "stringutil.h" + +#include +#include + +/** Maximum number of times we'll try to connect to Tor before giving up.*/ +#define MAX_CONNECT_ATTEMPTS 5 +/** Time to wait between control connection attempts (in milliseconds). */ +#define CONNECT_RETRY_DELAY 2*1000 + + +/** Default constructor. */ +ControlConnection::ControlConnection(TorEvents *events) +{ + _events = events; + _status = Unset; + _sock = 0; + _sendWaiter = new SendCommandEvent::SendWaiter(); +} + +/** Destructor. */ +ControlConnection::~ControlConnection() +{ + /* Exit the event loop */ + exit(); + /* Wait for the thread to finish */ + wait(); + /* Clean up after the send waiter */ + delete _sendWaiter; +} + +/** Connect to the specified Tor control interface. */ +void +ControlConnection::connect(const QHostAddress &addr, quint16 port) +{ + if (isRunning()) { + tc::error("Bug: Tried to call ControlConnection::connect() when the " + "control thread is already running."); + return; + } + + /* Save the destination information */ + _addr = addr; + _port = port; + _sock = 0; + _connectAttempt = 0; + setStatus(Connecting); + + /* Kick off the thread in which the control socket will live */ + QThread::start(); +} + +/** Attempt to establish a connection to Tor's control interface. We will try + * a maximum of MAX_CONNECT_ATTEMPTS, waiting CONNECT_RETRY_DELAY between each + * attempt, to give slow Tors a chance to finish binding their control port. */ +void +ControlConnection::connect() +{ + _connectAttempt++; + tc::debug("Connecting to Tor (Attempt %1 of %2)").arg(_connectAttempt) + .arg(MAX_CONNECT_ATTEMPTS); + + _connMutex.lock(); + _sock->connectToHost(_addr, _port); + _connMutex.unlock(); +} + +/** Disconnect from Tor's control interface. */ +void +ControlConnection::disconnect() +{ + setStatus(Disconnecting); + _connMutex.lock(); + _sock->disconnectFromHost(); + _connMutex.unlock(); +} + +/** Called when the control socket is connected. This method checks that the + * control protocol version of the Tor we connected to is at least V1. */ +void +ControlConnection::onConnected() +{ + setStatus(Connected); + emit connected(); +} + +/** Called when the control socket is disconnected and stops the control + * thread's event loop. */ +void +ControlConnection::onDisconnected() +{ + setStatus(Disconnected); + emit disconnected(); + exit(0); +} + +/** Called when the control socket encounters error. */ +void +ControlConnection::onError(QAbstractSocket::SocketError error) +{ + if (status() == Connecting) { + /* If we got a 'connection refused' and we haven't exceeded + * MAX_CONNECT_ATTEMPTS, then try to reconnect since Tor is probably + * running, but it doesn't have a ControlPort open yet. */ + if (error == QAbstractSocket::ConnectionRefusedError && + _connectAttempt < MAX_CONNECT_ATTEMPTS) { + tc::debug("Control connection refused. Retrying in %1ms.") + .arg(CONNECT_RETRY_DELAY); + _connectTimer->start(CONNECT_RETRY_DELAY); + } else { + /* Exceeded maximum number of connect attempts. Give up. */ + QString errstr = ControlSocket::toString(error); + tc::error("Vidalia was unable to connect to Tor: %1").arg(errstr); + emit connectFailed(tr("Vidalia was unable to connect to Tor. (%1)") + .arg(errstr)); + setStatus(Disconnected); + } + } else if (error == QAbstractSocket::RemoteHostClosedError) { + /* Tor closed the connection. This is common when we send a 'shutdown' or + * 'halt' signal to Tor and doesn't need to be logged as loudly. */ + tc::warn("Tor closed the control connection."); + } else { + /* Some other error. */ + /*XXX We may want to be emitting these so the GUI thread can learn about + * them and display an error message. */ + tc::error("Control socket error: %1").arg(ControlSocket::toString(error)); + } +} + +/** Cancels a pending control connection to Tor. */ +void +ControlConnection::cancelConnect() +{ + tc::warn("Control connection attempt cancelled."); + setStatus(Disconnected); + exit(0); +} + +/** Returns true if the control socket is connected to Tor. */ +bool +ControlConnection::isConnected() +{ + return (status() == Connected); +} + +/** Returns the status of the control connection. */ +ControlConnection::Status +ControlConnection::status() +{ + QMutexLocker locker(&_statusMutex); + return _status; +} + +/** Returns a string description of the control Status value + * status. */ +QString +ControlConnection::statusString(Status status) +{ + QString str; + switch (status) { + case Unset: str = "Unset"; break; + case Disconnected: str = "Disconnected"; break; + case Disconnecting: str = "Disconnecting"; break; + case Connecting: str = "Connecting"; break; + case Connected: str = "Connected"; break; + default: str = "unknown"; + } + return str; +} + +/** Sets the control connection status. */ +void +ControlConnection::setStatus(Status status) +{ + QMutexLocker locker(&_statusMutex); + tc::debug("Control connection status changed from '%1' to '%2'") + .arg(statusString(_status)) + .arg(statusString(status)); + _status = status; +} + +/** Sends a control command to Tor and waits for the reply. */ +bool +ControlConnection::send(const ControlCommand &cmd, + ControlReply &reply, QString *errmsg) +{ + bool result = false; + QString errstr; + + _recvMutex.lock(); + if (send(cmd, &errstr)) { + /* Create and enqueue a new receive waiter */ + ReceiveWaiter *w = new ReceiveWaiter(); + _recvQueue.enqueue(w); + _recvMutex.unlock(); + + /* Wait for and get the result, clean up, and return */ + result = w->getResult(&reply, &errstr); + if (!result) + tc::error("Failed to receive control reply: %1").arg(errstr); + delete w; + } else { + tc::error("Failed to send control command (%1): %2").arg(cmd.keyword()) + .arg(errstr); + _recvMutex.unlock(); + } + + if (!result && errmsg) + *errmsg = errstr; + return result; +} + +/** Sends a control command to Tor and returns true if the command was sent + * successfully. Otherwise, returns false and *errmsg (if supplied) + * will be set. */ +bool +ControlConnection::send(const ControlCommand &cmd, QString *errmsg) +{ + _connMutex.lock(); + if (!_sock || !_sock->isConnected()) { + _connMutex.unlock(); + return err(errmsg, tr("Control socket is not connected.")); + } + QCoreApplication::postEvent(_sock, new SendCommandEvent(cmd, _sendWaiter)); + _connMutex.unlock(); + + return _sendWaiter->getResult(errmsg); +} + +/** Called when there is data on the control socket. */ +void +ControlConnection::onReadyRead() +{ + QMutexLocker locker(&_connMutex); + ReceiveWaiter *waiter; + QString errmsg; + + while (_sock->canReadLine()) { + ControlReply reply; + if (_sock->readReply(reply, &errmsg)) { + if (reply.getStatus() == "650") { + /* Asynchronous event message */ + tc::debug("Control Event: %1").arg(reply.toString()); + + if (_events) { + _events->handleEvent(reply); + } + } else { + /* Response to a previous command */ + tc::debug("Control Reply: %1").arg(reply.toString()); + + _recvMutex.lock(); + if (!_recvQueue.isEmpty()) { + waiter = _recvQueue.dequeue(); + waiter->setResult(true, reply); + } + _recvMutex.unlock(); + } + } else { + tc::error("Unable to read control reply: %1").arg(errmsg); + } + } +} + +/** Main thread implementation. Creates and connects a control socket, then + * spins up an event loop. */ +void +ControlConnection::run() +{ + /* Create a new control socket */ + _connMutex.lock(); + _sock = new ControlSocket(); + _connectTimer = new QTimer(); + _connectTimer->setSingleShot(true); + + QObject::connect(_sock, SIGNAL(readyRead()), this, SLOT(onReadyRead()), + Qt::DirectConnection); + QObject::connect(_sock, SIGNAL(disconnected()), this, SLOT(onDisconnected()), + Qt::DirectConnection); + QObject::connect(_sock, SIGNAL(connected()), this, SLOT(onConnected()), + Qt::DirectConnection); + QObject::connect(_sock, SIGNAL(error(QAbstractSocket::SocketError)), + this, SLOT(onError(QAbstractSocket::SocketError)), + Qt::DirectConnection); + QObject::connect(_connectTimer, SIGNAL(timeout()), this, SLOT(connect()), + Qt::DirectConnection); + + _connMutex.unlock(); + + /* Attempt to connect to Tor */ + connect(); + tc::debug("Starting control connection event loop."); + exec(); + tc::debug("Exited control connection event loop."); + + /* Clean up the socket */ + _connMutex.lock(); + _sock->disconnect(this); + delete _sock; + delete _connectTimer; + _sock = 0; + _connMutex.unlock(); + + /* If there are any messages waiting for a response, clear them. */ + if (_sendWaiter->status() == SendCommandEvent::SendWaiter::Waiting) + _sendWaiter->setResult(false, tr("Control socket is not connected.")); + + _recvMutex.lock(); + while (!_recvQueue.isEmpty()) { + ReceiveWaiter *w = _recvQueue.dequeue(); + w->setResult(false, ControlReply(), + tr("Control socket is not connected.")); + } + _recvMutex.unlock(); +} + + +/* + * ControlConnection::ReceiveWaiter + */ +/** Waits for and gets the reply from a control command. */ +bool +ControlConnection::ReceiveWaiter::getResult(ControlReply *reply, + QString *errmsg) +{ + forever { + _mutex.lock(); + if (_status == Waiting) { + _waitCond.wait(&_mutex); + _mutex.unlock(); + } else { + _mutex.unlock(); + break; + } + } + if (errmsg) { + *errmsg = _errmsg; + } + *reply = _reply; + return (_status == Success); +} + +/** Sets the result and reply from a control command. */ +void +ControlConnection::ReceiveWaiter::setResult(bool success, + const ControlReply &reply, + const QString &errmsg) +{ + _mutex.lock(); + _status = (success ? Success : Failed); + _reply = reply; + _errmsg = errmsg; + _mutex.unlock(); + _waitCond.wakeAll(); +} + diff -Nru vidalia-0.1.13/src/torcontrol/controlconnection.h vidalia-0.2.8/src/torcontrol/controlconnection.h --- vidalia-0.1.13/src/torcontrol/controlconnection.h 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/controlconnection.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,131 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 controlconnection.h -** \version $Id: controlconnection.h 2838 2008-07-06 22:43:48Z edmanm $ -** \brief A connection to Tor's control interface, responsible for sending and -** receiving commands and events -**/ - -#ifndef _CONTROLCONNECTION_H -#define _CONTROLCONNECTION_H - -#include -#include -#include -#include -#include -#include - -#include "eventtype.h" -#include "controlsocket.h" -#include "torevents.h" -#include "sendcommandevent.h" - - -class ControlConnection : public QThread -{ - Q_OBJECT - -public: - /** Control connection status */ - enum Status { - Unset, /**< Control connection status is not yet set. */ - Disconnected, /**< Control connection disconnected. */ - Disconnecting, /**< Control connection is disconnecting. */ - Connecting, /**< Control connection attempt pending. */ - Connected /**< Control connection established. */ - }; - - /** Default constructor. */ - ControlConnection(TorEvents *events = 0); - /** Destructor. */ - ~ControlConnection(); - - /** Connect to the specified Tor control interface. */ - void connect(const QHostAddress &addr, quint16 port); - /** Cancels a pending control connection to Tor. */ - void cancelConnect(); - /** Disconnect from Tor's control interface. */ - void disconnect(); - /** Returns true if the control socket is connected to Tor. */ - bool isConnected(); - /** Returns the status of the control connection. */ - Status status(); - /** Sends a control command to Tor and waits for the reply. */ - bool send(const ControlCommand &cmd, ControlReply &reply, QString *errmsg = 0); - /** Sends a control command to Tor and does not wait for a reply. */ - bool send(const ControlCommand &cmd, QString *errmsg = 0); - -signals: - /** Emitted when a control connection has been established. */ - void connected(); - /** Emitted when a control connection has been closed. */ - void disconnected(); - /** Emitted when a control connection fails. */ - void connectFailed(QString errmsg); - -private slots: - /** Connects to Tor's control interface. */ - void connect(); - /** Called when there is data on the control socket. */ - void onReadyRead(); - /** Called when the control socket is connected. */ - void onConnected(); - /** Called when the control socket is disconnected. */ - void onDisconnected(); - /** Called when the control socket encounters an error. */ - void onError(QAbstractSocket::SocketError error); - -private: - /** Sets the control connection status. */ - void setStatus(Status status); - /** Returns the string description of status. */ - QString statusString(Status status); - /** Main thread implementation. */ - void run(); - - ControlSocket* _sock; /**< Socket used to communicate with Tor. */ - TorEvents* _events; /**< Dispatches asynchronous events from Tor. */ - Status _status; /**< Status of the control connection. */ - QHostAddress _addr; /**< Address of Tor's control interface. */ - quint16 _port; /**< Port of Tor's control interface. */ - QMutex _connMutex; /**< Mutex around the control socket. */ - QMutex _recvMutex; /**< Mutex around the queue of ReceiveWaiters. */ - QMutex _statusMutex; /**< Mutex around the connection status value. */ - int _connectAttempt; /**< How many times we've tried to connect to Tor while - waiting for Tor to start. */ - QTimer* _connectTimer; /**< Timer used to delay connect attempts. */ - - /** Private class used to wait for a response to a control command. */ - class ReceiveWaiter { - public: - /** Default constructor. */ - ReceiveWaiter() { _status = Waiting; } - /** Waits for and gets the reply from a control command. */ - bool getResult(ControlReply *reply, QString *errmsg = 0); - /** Sets the result and reply from a control command. */ - void setResult(bool success, const ControlReply &reply, - const QString &errmsg = QString()); - private: - /** Status of the receive waiter. */ - enum ReceiveStatus { Waiting, Failed, Success } _status; - ControlReply _reply; /**< Reply to a previous command. */ - QMutex _mutex; /**< Mutex around the wait condition. */ - QWaitCondition _waitCond; /**< Waits for a control rpely. */ - QString _errmsg; /**< Error message if the reply fails. */ - }; - QQueue _recvQueue; /**< Objects waiting for a reply. */ - SendCommandEvent::SendWaiter* _sendWaiter; -}; - -#endif - diff -Nru vidalia-0.1.13/src/torcontrol/ControlConnection.h vidalia-0.2.8/src/torcontrol/ControlConnection.h --- vidalia-0.1.13/src/torcontrol/ControlConnection.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/ControlConnection.h 2009-08-17 03:25:08.000000000 +0100 @@ -0,0 +1,130 @@ +/* +** 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.vidalia-project.net/. 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 ControlConnection.h +** \version $Id: ControlConnection.h 4054 2009-08-17 02:25:08Z edmanm $ +** \brief A connection to Tor's control interface, responsible for sending and +** receiving commands and events +**/ + +#ifndef _CONTROLCONNECTION_H +#define _CONTROLCONNECTION_H + +#include "ControlSocket.h" +#include "TorEvents.h" +#include "SendCommandEvent.h" + +#include +#include +#include +#include +#include +#include + + +class ControlConnection : public QThread +{ + Q_OBJECT + +public: + /** Control connection status */ + enum Status { + Unset, /**< Control connection status is not yet set. */ + Disconnected, /**< Control connection disconnected. */ + Disconnecting, /**< Control connection is disconnecting. */ + Connecting, /**< Control connection attempt pending. */ + Connected /**< Control connection established. */ + }; + + /** Default constructor. */ + ControlConnection(TorEvents *events = 0); + /** Destructor. */ + ~ControlConnection(); + + /** Connect to the specified Tor control interface. */ + void connect(const QHostAddress &addr, quint16 port); + /** Cancels a pending control connection to Tor. */ + void cancelConnect(); + /** Disconnect from Tor's control interface. */ + void disconnect(); + /** Returns true if the control socket is connected to Tor. */ + bool isConnected(); + /** Returns the status of the control connection. */ + Status status(); + /** Sends a control command to Tor and waits for the reply. */ + bool send(const ControlCommand &cmd, ControlReply &reply, QString *errmsg = 0); + /** Sends a control command to Tor and does not wait for a reply. */ + bool send(const ControlCommand &cmd, QString *errmsg = 0); + +signals: + /** Emitted when a control connection has been established. */ + void connected(); + /** Emitted when a control connection has been closed. */ + void disconnected(); + /** Emitted when a control connection fails. */ + void connectFailed(QString errmsg); + +private slots: + /** Connects to Tor's control interface. */ + void connect(); + /** Called when there is data on the control socket. */ + void onReadyRead(); + /** Called when the control socket is connected. */ + void onConnected(); + /** Called when the control socket is disconnected. */ + void onDisconnected(); + /** Called when the control socket encounters an error. */ + void onError(QAbstractSocket::SocketError error); + +private: + /** Sets the control connection status. */ + void setStatus(Status status); + /** Returns the string description of status. */ + QString statusString(Status status); + /** Main thread implementation. */ + void run(); + + ControlSocket* _sock; /**< Socket used to communicate with Tor. */ + TorEvents* _events; /**< Dispatches asynchronous events from Tor. */ + Status _status; /**< Status of the control connection. */ + QHostAddress _addr; /**< Address of Tor's control interface. */ + quint16 _port; /**< Port of Tor's control interface. */ + QMutex _connMutex; /**< Mutex around the control socket. */ + QMutex _recvMutex; /**< Mutex around the queue of ReceiveWaiters. */ + QMutex _statusMutex; /**< Mutex around the connection status value. */ + int _connectAttempt; /**< How many times we've tried to connect to Tor while + waiting for Tor to start. */ + QTimer* _connectTimer; /**< Timer used to delay connect attempts. */ + + /** Private class used to wait for a response to a control command. */ + class ReceiveWaiter { + public: + /** Default constructor. */ + ReceiveWaiter() { _status = Waiting; } + /** Waits for and gets the reply from a control command. */ + bool getResult(ControlReply *reply, QString *errmsg = 0); + /** Sets the result and reply from a control command. */ + void setResult(bool success, const ControlReply &reply, + const QString &errmsg = QString()); + private: + /** Status of the receive waiter. */ + enum ReceiveStatus { Waiting, Failed, Success } _status; + ControlReply _reply; /**< Reply to a previous command. */ + QMutex _mutex; /**< Mutex around the wait condition. */ + QWaitCondition _waitCond; /**< Waits for a control rpely. */ + QString _errmsg; /**< Error message if the reply fails. */ + }; + QQueue _recvQueue; /**< Objects waiting for a reply. */ + SendCommandEvent::SendWaiter* _sendWaiter; +}; + +#endif + diff -Nru vidalia-0.1.13/src/torcontrol/controlreply.cpp vidalia-0.2.8/src/torcontrol/controlreply.cpp --- vidalia-0.1.13/src/torcontrol/controlreply.cpp 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/controlreply.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,77 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 controlreply.cpp -** \version $Id: controlreply.cpp 2362 2008-02-29 04:30:11Z edmanm $ -** \brief A response from Tor's control interface -*/ - -#include "controlreply.h" - -/** Default constructor */ -ControlReply::ControlReply() -{ -} - -/** Add a line associated with this reply */ -void -ControlReply::appendLine(ReplyLine line) -{ - _lines << line; -} - -/** Returns the requested line from this reply */ -ReplyLine -ControlReply::getLine(int idx) const -{ - return _lines.at(idx); -} - -/** Returns all lines for this reply */ -QList -ControlReply::getLines() const -{ - return _lines; -} - -/** Returns the status of the first line in the reply */ -QString -ControlReply::getStatus() const -{ - return getLine().getStatus(); -} - -/** Returns the message of the first line in the reply */ -QString -ControlReply::getMessage() const -{ - return getLine().getMessage(); -} - -/** Returns the data for the first line in the reply. */ -QStringList -ControlReply::getData() const -{ - return getLine().getData(); -} - -/** Returns the entire contents of the control reply. */ -QString -ControlReply::toString() const -{ - QString str; - foreach (ReplyLine line, _lines) { - str.append(line.toString()); - str.append("\n"); - } - return str.trimmed(); -} - diff -Nru vidalia-0.1.13/src/torcontrol/ControlReply.cpp vidalia-0.2.8/src/torcontrol/ControlReply.cpp --- vidalia-0.1.13/src/torcontrol/ControlReply.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/ControlReply.cpp 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,78 @@ +/* +** 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.vidalia-project.net/. 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 ControlReply.cpp +** \version $Id: ControlReply.cpp 3735 2009-04-28 20:28:01Z edmanm $ +** \brief A response from Tor's control interface +*/ + +#include "ControlReply.h" + + +/** Default constructor */ +ControlReply::ControlReply() +{ +} + +/** Add a line associated with this reply */ +void +ControlReply::appendLine(ReplyLine line) +{ + _lines << line; +} + +/** Returns the requested line from this reply */ +ReplyLine +ControlReply::getLine(int idx) const +{ + return _lines.at(idx); +} + +/** Returns all lines for this reply */ +QList +ControlReply::getLines() const +{ + return _lines; +} + +/** Returns the status of the first line in the reply */ +QString +ControlReply::getStatus() const +{ + return getLine().getStatus(); +} + +/** Returns the message of the first line in the reply */ +QString +ControlReply::getMessage() const +{ + return getLine().getMessage(); +} + +/** Returns the data for the first line in the reply. */ +QStringList +ControlReply::getData() const +{ + return getLine().getData(); +} + +/** Returns the entire contents of the control reply. */ +QString +ControlReply::toString() const +{ + QString str; + foreach (ReplyLine line, _lines) { + str.append(line.toString()); + str.append("\n"); + } + return str.trimmed(); +} + diff -Nru vidalia-0.1.13/src/torcontrol/controlreply.h vidalia-0.2.8/src/torcontrol/controlreply.h --- vidalia-0.1.13/src/torcontrol/controlreply.h 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/controlreply.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,53 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 controlreply.h -** \version $Id: controlreply.h 2362 2008-02-29 04:30:11Z edmanm $ -** \brief A response from Tor's control interface -*/ - -#ifndef _CONTROLREPLY_H -#define _CONTROLREPLY_H - -#include - -#include "replyline.h" - - -class ControlReply -{ -public: - /** Default constructor */ - ControlReply(); - - /** Add a line associated with this reply */ - void appendLine(ReplyLine line); - - /** Returns a single line from this reply */ - ReplyLine getLine(int idx = 0) const; - /** Returns all lines for this reply */ - QList getLines() const; - - /** Returns the status of the first line in the reply */ - QString getStatus() const; - /** Returns the messasge of the first line in the reply */ - QString getMessage() const; - /** Returns the data for the first line in the reply. */ - QStringList getData() const; - /** Returns the entire contents of the control reply. */ - QString toString() const; - -private: - QList _lines; -}; - -#endif - diff -Nru vidalia-0.1.13/src/torcontrol/ControlReply.h vidalia-0.2.8/src/torcontrol/ControlReply.h --- vidalia-0.1.13/src/torcontrol/ControlReply.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/ControlReply.h 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,53 @@ +/* +** 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.vidalia-project.net/. 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 ControlReply.h +** \version $Id: ControlReply.h 3735 2009-04-28 20:28:01Z edmanm $ +** \brief A response from Tor's control interface +*/ + +#ifndef _CONTROLREPLY_H +#define _CONTROLREPLY_H + +#include "ReplyLine.h" + +#include + + +class ControlReply +{ +public: + /** Default constructor */ + ControlReply(); + + /** Add a line associated with this reply */ + void appendLine(ReplyLine line); + + /** Returns a single line from this reply */ + ReplyLine getLine(int idx = 0) const; + /** Returns all lines for this reply */ + QList getLines() const; + + /** Returns the status of the first line in the reply */ + QString getStatus() const; + /** Returns the messasge of the first line in the reply */ + QString getMessage() const; + /** Returns the data for the first line in the reply. */ + QStringList getData() const; + /** Returns the entire contents of the control reply. */ + QString toString() const; + +private: + QList _lines; +}; + +#endif + diff -Nru vidalia-0.1.13/src/torcontrol/controlsocket.cpp vidalia-0.2.8/src/torcontrol/controlsocket.cpp --- vidalia-0.1.13/src/torcontrol/controlsocket.cpp 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/controlsocket.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,218 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 controlsocket.cpp -** \version $Id: controlsocket.cpp 2838 2008-07-06 22:43:48Z edmanm $ -** \brief Socket used to connect to Tor's control interface -*/ - -#include -#include "tcglobal.h" - -#include "controlsocket.h" -#include "sendcommandevent.h" - -/** Timeout reads in 250ms. We can set this to a short value because if there -* isn't any data to read, we want to return anyway. */ -#define READ_TIMEOUT 250 - - -/** Default constructor. */ -ControlSocket::ControlSocket() -{ -} - -/** Returns true if the control socket is connected and ready to send or - * receive. */ -bool -ControlSocket::isConnected() -{ - return (isValid() && state() == QAbstractSocket::ConnectedState); -} - -/** Processes custom events sent to this object (e.g. SendCommandEvents) from - * other threads. */ -void -ControlSocket::customEvent(QEvent *event) -{ - if (event->type() == CustomEventType::SendCommandEvent) { - SendCommandEvent *sce = dynamic_cast(event); - if (! sce) - return; - - QString errmsg; - bool result = sendCommand(sce->command(), &errmsg); - if (sce->waiter()) - sce->waiter()->setResult(result, errmsg); - sce->accept(); - } -} - -/** Send a control command to Tor on the control socket, conforming to Tor's - * Control Protocol V1: - * - * Command = Keyword Arguments CRLF / "+" Keyword Arguments CRLF Data - * Keyword = 1*ALPHA - * Arguments = *(SP / VCHAR) - */ -bool -ControlSocket::sendCommand(ControlCommand cmd, QString *errmsg) -{ - if (!isConnected()) { - return err(errmsg, tr("Control socket is not connected.")); - } - - /* Format the control command */ - QString strCmd = cmd.toString(); - tc::debug("Control Command: %1").arg(strCmd.trimmed()); - - /* Attempt to send the command to Tor */ - if (write(strCmd.toAscii()) != strCmd.length()) { - return err(errmsg, tr("Error sending control command. [%1]") - .arg(errorString())); - } - flush(); - return true; -} - -/** Reads line data, one chunk at a time, until a newline character is - * encountered. */ -bool -ControlSocket::readLineData(QString &line, QString *errmsg) -{ - char buffer[1024]; /* Read in 1024 byte chunks at a time */ - int bytesRecv = QAbstractSocket::readLine(buffer, 1024); - while (bytesRecv != -1) { - line.append(buffer); - if (buffer[bytesRecv-1] == '\n') { - break; - } - bytesRecv = QAbstractSocket::readLine(buffer, 1024); - } - if (bytesRecv == -1) { - return err(errmsg, errorString()); - } - return true; -} - -/** Reads a line of data from the socket and returns true if successful or - * false if an error occurred while waiting for a line of data to become - * available. */ -bool -ControlSocket::readLine(QString &line, QString *errmsg) -{ - /* Make sure we have data to read before attempting anything. Note that this - * essentially makes our socket a blocking socket */ - while (!canReadLine()) { - if (!isConnected()) { - return err(errmsg, tr("Socket disconnected while attempting " - "to read a line of data.")); - } - waitForReadyRead(READ_TIMEOUT); - } - line.clear(); - return readLineData(line, errmsg); -} - -/** Read a complete reply from the control socket. Replies take the following - * form, based on Tor's Control Protocol v1: - * - * Reply = *(MidReplyLine / DataReplyLine) EndReplyLine - * - * MidReplyLine = "-" ReplyLine - * DataReplyLine = "+" ReplyLine Data - * EndReplyLine = SP ReplyLine - * ReplyLine = StatusCode [ SP ReplyText ] CRLF - * ReplyText = XXXX - * StatusCode = XXiX - */ -bool -ControlSocket::readReply(ControlReply &reply, QString *errmsg) -{ - QChar c; - QString line; - - if (!isConnected()) { - return false; - } - - /* The implementation below is (loosely) based on the Java control library - * from Tor */ - do { - /* Read a line of the response */ - if (!readLine(line, errmsg)) { - return false; - } - - if (line.length() < 4) { - return err(errmsg, tr("Invalid control reply. [%1]").arg(line)); - } - - /* Parse the status and message */ - ReplyLine replyLine(line.mid(0, 3), line.mid(4)); - c = line.at(3); - - /* If the reply line contains data, then parse out the data up until the - * trailing CRLF "." CRLF */ - if (c == QChar('+') && - !line.startsWith("250+PROTOCOLINFO")) { - /* XXX The second condition above is a hack to deal with Tor - * 0.2.0.5-alpha that gives a malformed PROTOCOLINFO reply. This - * should be removed once that version of Tor is sufficiently dead. */ - while (true) { - if (!readLine(line, errmsg)) { - return false; - } - if (line.trimmed() == ".") { - break; - } - replyLine.appendData(line); - } - } - reply.appendLine(replyLine); - } while (c != QChar(' ')); - return true; -} - -/** Returns the string description of error. */ -QString -ControlSocket::toString(const QAbstractSocket::SocketError error) -{ - QString str; - switch (error) { - case ConnectionRefusedError: - str = "Connection refused by peer."; break; - case RemoteHostClosedError: - str = "Remote host closed the connection."; break; - case HostNotFoundError: - str = "Host address not found."; break; - case SocketAccessError: - str = "Insufficient access privileges."; break; - case SocketResourceError: - str = "Insufficient resources."; break; - case SocketTimeoutError: - str = "Socket operation timed out."; break; - case DatagramTooLargeError: - str = "Datagram size exceeded the operating system limit."; break; - case NetworkError: - str = "Network error occurred."; break; - case AddressInUseError: - str = "Specified address already in use."; break; - case SocketAddressNotAvailableError: - str = "Specified address does not belong to the host."; break; - case UnsupportedSocketOperationError: - str = "The requested operation is not supported."; break; - default: - str = "An unidentified error occurred."; break; - } - return str; -} - diff -Nru vidalia-0.1.13/src/torcontrol/ControlSocket.cpp vidalia-0.2.8/src/torcontrol/ControlSocket.cpp --- vidalia-0.1.13/src/torcontrol/ControlSocket.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/ControlSocket.cpp 2009-08-17 03:25:08.000000000 +0100 @@ -0,0 +1,218 @@ +/* +** 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.vidalia-project.net/. 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 ControlSocket.cpp +** \version $Id: ControlSocket.cpp 4054 2009-08-17 02:25:08Z edmanm $ +** \brief Socket used to connect to Tor's control interface +*/ + +#include "ControlSocket.h" +#include "SendCommandEvent.h" +#include "tcglobal.h" + +#include "stringutil.h" + +/** Timeout reads in 250ms. We can set this to a short value because if there +* isn't any data to read, we want to return anyway. */ +#define READ_TIMEOUT 250 + + +/** Default constructor. */ +ControlSocket::ControlSocket() +{ +} + +/** Returns true if the control socket is connected and ready to send or + * receive. */ +bool +ControlSocket::isConnected() +{ + return (isValid() && state() == QAbstractSocket::ConnectedState); +} + +/** Processes custom events sent to this object (e.g. SendCommandEvents) from + * other threads. */ +void +ControlSocket::customEvent(QEvent *event) +{ + if (event->type() == QEvent::User) { + SendCommandEvent *sce = dynamic_cast(event); + if (! sce) + return; + + QString errmsg; + bool result = sendCommand(sce->command(), &errmsg); + if (sce->waiter()) + sce->waiter()->setResult(result, errmsg); + sce->accept(); + } +} + +/** Send a control command to Tor on the control socket, conforming to Tor's + * Control Protocol V1: + * + * Command = Keyword Arguments CRLF / "+" Keyword Arguments CRLF Data + * Keyword = 1*ALPHA + * Arguments = *(SP / VCHAR) + */ +bool +ControlSocket::sendCommand(ControlCommand cmd, QString *errmsg) +{ + if (!isConnected()) { + return err(errmsg, tr("Control socket is not connected.")); + } + + /* Format the control command */ + QString strCmd = cmd.toString(); + tc::debug("Control Command: %1").arg(strCmd.trimmed()); + + /* Attempt to send the command to Tor */ + if (write(strCmd.toAscii()) != strCmd.length()) { + return err(errmsg, tr("Error sending control command. [%1]") + .arg(errorString())); + } + flush(); + return true; +} + +/** Reads line data, one chunk at a time, until a newline character is + * encountered. */ +bool +ControlSocket::readLineData(QString &line, QString *errmsg) +{ + char buffer[1024]; /* Read in 1024 byte chunks at a time */ + int bytesRecv = QAbstractSocket::readLine(buffer, 1024); + while (bytesRecv != -1) { + line.append(buffer); + if (buffer[bytesRecv-1] == '\n') { + break; + } + bytesRecv = QAbstractSocket::readLine(buffer, 1024); + } + if (bytesRecv == -1) { + return err(errmsg, errorString()); + } + return true; +} + +/** Reads a line of data from the socket and returns true if successful or + * false if an error occurred while waiting for a line of data to become + * available. */ +bool +ControlSocket::readLine(QString &line, QString *errmsg) +{ + /* Make sure we have data to read before attempting anything. Note that this + * essentially makes our socket a blocking socket */ + while (!canReadLine()) { + if (!isConnected()) { + return err(errmsg, tr("Socket disconnected while attempting " + "to read a line of data.")); + } + waitForReadyRead(READ_TIMEOUT); + } + line.clear(); + return readLineData(line, errmsg); +} + +/** Read a complete reply from the control socket. Replies take the following + * form, based on Tor's Control Protocol v1: + * + * Reply = *(MidReplyLine / DataReplyLine) EndReplyLine + * + * MidReplyLine = "-" ReplyLine + * DataReplyLine = "+" ReplyLine Data + * EndReplyLine = SP ReplyLine + * ReplyLine = StatusCode [ SP ReplyText ] CRLF + * ReplyText = XXXX + * StatusCode = XXiX + */ +bool +ControlSocket::readReply(ControlReply &reply, QString *errmsg) +{ + QChar c; + QString line; + + if (!isConnected()) { + return false; + } + + /* The implementation below is (loosely) based on the Java control library + * from Tor */ + do { + /* Read a line of the response */ + if (!readLine(line, errmsg)) { + return false; + } + + if (line.length() < 4) { + return err(errmsg, tr("Invalid control reply. [%1]").arg(line)); + } + + /* Parse the status and message */ + ReplyLine replyLine(line.mid(0, 3), line.mid(4)); + c = line.at(3); + + /* If the reply line contains data, then parse out the data up until the + * trailing CRLF "." CRLF */ + if (c == QChar('+') && + !line.startsWith("250+PROTOCOLINFO")) { + /* XXX The second condition above is a hack to deal with Tor + * 0.2.0.5-alpha that gives a malformed PROTOCOLINFO reply. This + * should be removed once that version of Tor is sufficiently dead. */ + while (true) { + if (!readLine(line, errmsg)) { + return false; + } + if (line.trimmed() == ".") { + break; + } + replyLine.appendData(line); + } + } + reply.appendLine(replyLine); + } while (c != QChar(' ')); + return true; +} + +/** Returns the string description of error. */ +QString +ControlSocket::toString(const QAbstractSocket::SocketError error) +{ + QString str; + switch (error) { + case ConnectionRefusedError: + str = "Connection refused by peer."; break; + case RemoteHostClosedError: + str = "Remote host closed the connection."; break; + case HostNotFoundError: + str = "Host address not found."; break; + case SocketAccessError: + str = "Insufficient access privileges."; break; + case SocketResourceError: + str = "Insufficient resources."; break; + case SocketTimeoutError: + str = "Socket operation timed out."; break; + case DatagramTooLargeError: + str = "Datagram size exceeded the operating system limit."; break; + case NetworkError: + str = "Network error occurred."; break; + case AddressInUseError: + str = "Specified address already in use."; break; + case SocketAddressNotAvailableError: + str = "Specified address does not belong to the host."; break; + case UnsupportedSocketOperationError: + str = "The requested operation is not supported."; break; + default: + str = "An unidentified error occurred."; break; + } + return str; +} + diff -Nru vidalia-0.1.13/src/torcontrol/controlsocket.h vidalia-0.2.8/src/torcontrol/controlsocket.h --- vidalia-0.1.13/src/torcontrol/controlsocket.h 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/controlsocket.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,57 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 controlsocket.h -** \version $Id: controlsocket.h 2838 2008-07-06 22:43:48Z edmanm $ -** \brief Socket used to connect to Tor's control interface -*/ - -#ifndef _CONTROLSOCKET_H -#define _CONTROLSOCKET_H - -#include - -#include "controlcommand.h" -#include "controlreply.h" - - -class ControlSocket : public QTcpSocket -{ - Q_OBJECT - -public: - /** Default constructor. */ - ControlSocket(); - - /** Send a command to Tor */ - bool sendCommand(ControlCommand cmd, QString *errmsg = 0); - /** Read a response from Tor */ - bool readReply(ControlReply &reply, QString *errmsg = 0); - - /** Returns true if the control socket is connected and ready to send or - * receive. */ - bool isConnected(); - - /** Returns the string description of error. */ - static QString toString(const QAbstractSocket::SocketError error); - -protected: - /** Processes custom events sent to this object (e.g. SendCommandEvents) - * from other threads. */ - void customEvent(QEvent *event); - /** Reads line data off the socket in chunks. */ - bool readLineData(QString &line, QString *errmsg = 0); - /** Reads a line of data from the socket (blocking) */ - bool readLine(QString &line, QString *errmsg = 0); -}; - -#endif - diff -Nru vidalia-0.1.13/src/torcontrol/ControlSocket.h vidalia-0.2.8/src/torcontrol/ControlSocket.h --- vidalia-0.1.13/src/torcontrol/ControlSocket.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/ControlSocket.h 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,57 @@ +/* +** 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.vidalia-project.net/. 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 ControlSocket.h +** \version $Id: ControlSocket.h 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Socket used to connect to Tor's control interface +*/ + +#ifndef _CONTROLSOCKET_H +#define _CONTROLSOCKET_H + +#include "ControlCommand.h" +#include "ControlReply.h" + +#include + + +class ControlSocket : public QTcpSocket +{ + Q_OBJECT + +public: + /** Default constructor. */ + ControlSocket(); + + /** Send a command to Tor */ + bool sendCommand(ControlCommand cmd, QString *errmsg = 0); + /** Read a response from Tor */ + bool readReply(ControlReply &reply, QString *errmsg = 0); + + /** Returns true if the control socket is connected and ready to send or + * receive. */ + bool isConnected(); + + /** Returns the string description of error. */ + static QString toString(const QAbstractSocket::SocketError error); + +protected: + /** Processes custom events sent to this object (e.g. SendCommandEvents) + * from other threads. */ + void customEvent(QEvent *event); + /** Reads line data off the socket in chunks. */ + bool readLineData(QString &line, QString *errmsg = 0); + /** Reads a line of data from the socket (blocking) */ + bool readLine(QString &line, QString *errmsg = 0); +}; + +#endif + diff -Nru vidalia-0.1.13/src/torcontrol/dangerousversionevent.cpp vidalia-0.2.8/src/torcontrol/dangerousversionevent.cpp --- vidalia-0.1.13/src/torcontrol/dangerousversionevent.cpp 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/dangerousversionevent.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,34 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 dangerousversionevent.cpp -** \version $Id: dangerousversionevent.cpp 2362 2008-02-29 04:30:11Z edmanm $ -** \brief Event sent when Tor realizes its version is not recommended -*/ - -#include "dangerousversionevent.h" - - -/** Returns a DangerousVersionEvent::Reason enum value for str, - * representing the reason why Tor thinks its version is dangerous. */ -DangerousVersionEvent::Reason -DangerousVersionEvent::reasonFromString(const QString &str) -{ - if (!str.compare("UNRECOMMENDED", Qt::CaseInsensitive)) - return UnrecommendedVersion; - if (!str.compare("OLD", Qt::CaseInsensitive) - || !str.compare("OBSOLETE", Qt::CaseInsensitive)) - return ObsoleteVersion; - if (!str.compare("NEW", Qt::CaseInsensitive)) - return NewVersion; - return UnrecognizedReason; -} - diff -Nru vidalia-0.1.13/src/torcontrol/dangerousversionevent.h vidalia-0.2.8/src/torcontrol/dangerousversionevent.h --- vidalia-0.1.13/src/torcontrol/dangerousversionevent.h 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/dangerousversionevent.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,65 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 dangerousversionevent.h -** \version $Id: dangerousversionevent.h 2780 2008-06-21 21:48:32Z edmanm $ -** \brief Event sent when Tor realizes its version is not recommended -*/ - -#ifndef _DANGEROUSVERSIONEVENT_H -#define _DANGEROUSVERSIONEVENT_H - -#include -#include "generalstatusevent.h" - - -class DangerousVersionEvent : public GeneralStatusEvent -{ -public: - /** Possible reasons Tor thinks its version is dangerous. */ - enum Reason { - UnrecognizedReason, - NewVersion, /**< The current version is newer than any recommended - version. */ - ObsoleteVersion, /**< The current version is older than any recommended - version. */ - UnrecommendedVersion /**< The current version of Tor should not be used. */ - }; - - /** Constructor. */ - DangerousVersionEvent(tc::Severity severity, Reason reason, - const QString ¤tVersion, - const QStringList &recommendedVersions) - : GeneralStatusEvent(severity, GeneralStatusEvent::DangerousTorVersion), - _reason(reason), - _current(currentVersion), - _recommended(recommendedVersions) {} - - /** Returns the Reason enum value indicating the reason Tor thinks its - * version is dangerous. */ - Reason reason() const { return _reason; } - /** Returns the user's current Tor version. */ - QString currentVersion() const { return _current; } - /** Returns a list of recommended Tor versions. */ - QStringList recommendedVersions() const { return _recommended; } - - /** Returns a DangerousVersionEvent::Reason enum value for str, - * representing the reason why Tor thinks its version is dangerous. */ - static Reason reasonFromString(const QString &str); - -private: - Reason _reason; /**< Reason this Tor version is dangerous. */ - QString _current; /**< The user's current Tor version. */ - QStringList _recommended; /**< A list of recommended Tor versions. */ -}; - -#endif - diff -Nru vidalia-0.1.13/src/torcontrol/eventtype.h vidalia-0.2.8/src/torcontrol/eventtype.h --- vidalia-0.1.13/src/torcontrol/eventtype.h 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/eventtype.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,50 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 eventtype.h -** \version $Id: eventtype.h 2362 2008-02-29 04:30:11Z edmanm $ -** \brief Custom events dispatched upon receiving notification from Tor -*/ - -#ifndef _EVENTTYPE_H -#define _EVENTTYPE_H - -#include - - -/** Custom event type identifiers. */ -namespace CustomEventType { - /** Bandwidth update event. */ - const int BandwidthEvent = QEvent::User; - /** Circuit status event. */ - const int CircuitEvent = QEvent::User+1; - /** Stream status event. */ - const int StreamEvent = QEvent::User+2; - /** Log message event. */ - const int LogEvent = QEvent::User+3; - /** OR connection status event. */ - const int OrConnEvent = QEvent::User+4; - /** New descriptor event. */ - const int NewDescriptorEvent = QEvent::User+5; - /** Control command send event. */ - const int SendCommandEvent = QEvent::User+6; - /** New address mapping event. */ - const int AddressMapEvent = QEvent::User+7; - /** Tor client status events. */ - const int ClientStatusEvent = QEvent::User+8; - /** Tor server status events. */ - const int ServerStatusEvent = QEvent::User+9; - /** General Tor status events. */ - const int GeneralStatusEvent = QEvent::User+10; -} - -#endif - diff -Nru vidalia-0.1.13/src/torcontrol/generalstatusevent.cpp vidalia-0.2.8/src/torcontrol/generalstatusevent.cpp --- vidalia-0.1.13/src/torcontrol/generalstatusevent.cpp 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/generalstatusevent.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,41 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 generalstatusevent.cpp -** \version $Id: generalstatusevent.cpp 2362 2008-02-29 04:30:11Z edmanm $ -** \brief Base class for all general Tor status events -*/ - -#include "generalstatusevent.h" - - -/** Returns a GeneralStatusEvent::Status enum value for the status value - * represented by str. */ -GeneralStatusEvent::Status -GeneralStatusEvent::statusFromString(const QString &str) -{ - if (!str.compare("CLOCK_JUMPED", Qt::CaseInsensitive)) - return ClockJumped; - if (!str.compare("DANGEROUS_VERSION", Qt::CaseInsensitive)) - return DangerousTorVersion; - if (!str.compare("TOO_MANY_CONNECTIONS", Qt::CaseInsensitive)) - return TooManyConnections; - if (!str.compare("BUG", Qt::CaseInsensitive)) - return TorBug; - if (!str.compare("CLOCK_SKEW", Qt::CaseInsensitive)) - return ClockSkew; - if (!str.compare("BAD_LIBEVENT", Qt::CaseInsensitive)) - return BadLibevent; - if (!str.compare("DIR_ALL_UNREACHABLE", Qt::CaseInsensitive)) - return DirAllUnreachable; - return UnrecognizedStatus; -} - diff -Nru vidalia-0.1.13/src/torcontrol/generalstatusevent.h vidalia-0.2.8/src/torcontrol/generalstatusevent.h --- vidalia-0.1.13/src/torcontrol/generalstatusevent.h 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/generalstatusevent.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,54 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 generalstatusevent.h -** \version $Id: generalstatusevent.h 2780 2008-06-21 21:48:32Z edmanm $ -** \brief Base class for all general Tor status events -*/ - -#ifndef _GENERALSTATUSEVENT_H -#define _GENERALSTATUSEVENT_H - -#include "statusevent.h" - - -class GeneralStatusEvent : public StatusEvent -{ -public: - /**< General Tor status event types. */ - enum Status { - UnrecognizedStatus, - ClockJumped, - DangerousTorVersion, - TooManyConnections, - TorBug, - ClockSkew, - BadLibevent, - DirAllUnreachable - }; - - /** Constructor */ - GeneralStatusEvent(tc::Severity severity, Status status) - : StatusEvent((QEvent::Type)CustomEventType::ServerStatusEvent, severity), - _status(status) {} - - /** Returns the general Tor status indicated by this event. */ - Status status() const { return _status; } - /** Returns a GeneralStatusEvent::Status enum value for the status value - * represented by str. */ - static Status statusFromString(const QString &str); - -private: - Status _status; /**< General Tor status value indicated by this event. */ -}; - -#endif - diff -Nru vidalia-0.1.13/src/torcontrol/logevent.cpp vidalia-0.2.8/src/torcontrol/logevent.cpp --- vidalia-0.1.13/src/torcontrol/logevent.cpp 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/logevent.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,80 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 logevent.cpp -** \version $Id: logevent.cpp 2362 2008-02-29 04:30:11Z edmanm $ -** \brief Event dispatched containing a log message from Tor -*/ - -#include "eventtype.h" -#include "logevent.h" - - -/** Default constructor */ -LogEvent::LogEvent(Severity severity, QString message) -: QEvent((QEvent::Type)CustomEventType::LogEvent) -{ - _severity = severity; - _message = message.trimmed(); -} - -/** Converts a string description of a severity to its enum value */ -LogEvent::Severity -LogEvent::toSeverity(QString strSeverity) -{ - Severity s; - strSeverity = strSeverity.toUpper(); - if (strSeverity == "DEBUG") { - s = Debug; - } else if (strSeverity == "INFO") { - s = Info; - } else if (strSeverity == "NOTICE") { - s = Notice; - } else if (strSeverity == "WARN") { - s = Warn; - } else if (strSeverity == "ERR" || strSeverity == "ERROR") { - s = Error; - } else { - s = Unknown; - } - return s; -} - -/** Converts a Severity enum value to a string description */ -QString -LogEvent::severityToString(Severity s) -{ - QString str; - switch (s) { - case Debug: str = tr("Debug"); break; - case Info: str = tr("Info"); break; - case Notice: str = tr("Notice"); break; - case Warn: str = tr("Warning"); break; - case Error: str = tr("Error"); break; - default: str = tr("Unknown"); break; - } - return str; -} - -/** Returns the severity of this log event */ -LogEvent::Severity -LogEvent::severity() const -{ - return _severity; -} - -/** Returns the message for this log event */ -QString -LogEvent::message() const -{ - return _message; -} - diff -Nru vidalia-0.1.13/src/torcontrol/LogEvent.cpp vidalia-0.2.8/src/torcontrol/LogEvent.cpp --- vidalia-0.1.13/src/torcontrol/LogEvent.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/LogEvent.cpp 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,80 @@ +/* +** 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.vidalia-project.net/. 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 LogEvent.cpp +** \version $Id: LogEvent.cpp 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Event dispatched containing a log message from Tor +*/ + +#include "LogEvent.h" +#include "eventtype.h" + + +/** Default constructor */ +LogEvent::LogEvent(Severity severity, QString message) +: QEvent((QEvent::Type)CustomEventType::LogEvent) +{ + _severity = severity; + _message = message.trimmed(); +} + +/** Converts a string description of a severity to its enum value */ +LogEvent::Severity +LogEvent::toSeverity(QString strSeverity) +{ + Severity s; + strSeverity = strSeverity.toUpper(); + if (strSeverity == "DEBUG") { + s = Debug; + } else if (strSeverity == "INFO") { + s = Info; + } else if (strSeverity == "NOTICE") { + s = Notice; + } else if (strSeverity == "WARN") { + s = Warn; + } else if (strSeverity == "ERR" || strSeverity == "ERROR") { + s = Error; + } else { + s = Unknown; + } + return s; +} + +/** Converts a Severity enum value to a string description */ +QString +LogEvent::severityToString(Severity s) +{ + QString str; + switch (s) { + case Debug: str = tr("Debug"); break; + case Info: str = tr("Info"); break; + case Notice: str = tr("Notice"); break; + case Warn: str = tr("Warning"); break; + case Error: str = tr("Error"); break; + default: str = tr("Unknown"); break; + } + return str; +} + +/** Returns the severity of this log event */ +LogEvent::Severity +LogEvent::severity() const +{ + return _severity; +} + +/** Returns the message for this log event */ +QString +LogEvent::message() const +{ + return _message; +} + diff -Nru vidalia-0.1.13/src/torcontrol/logevent.h vidalia-0.2.8/src/torcontrol/logevent.h --- vidalia-0.1.13/src/torcontrol/logevent.h 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/logevent.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,59 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 logevent.h -** \version $Id: logevent.h 2362 2008-02-29 04:30:11Z edmanm $ -** \brief Event dispatched containing a log message from Tor -*/ - -#ifndef _LOGEVENT_H -#define _LOGEVENT_H - -#include -#include -#include - - -class LogEvent : public QEvent -{ - Q_DECLARE_TR_FUNCTIONS(LogEvent) - -public: - /** Log message severity levels */ - enum Severity { - Unknown = 0, - Debug = (1u<<4), /**< Debug level log message. */ - Info = (1u<<3), /**< Info level log message. */ - Notice = (1u<<2), /**< Notice level log message. */ - Warn = (1u<<1), /**< Warn level log message. */ - Error = (1u<<0) /**< Error level log message. */ - }; - - /** Default constructor */ - LogEvent(Severity severity, QString message); - - /** Converts the string description of a severity to its enum value */ - static Severity toSeverity(QString strSeverity); - /** Converts the Severity enum value to a string description */ - static QString severityToString(Severity severity); - - /** Returns the severity of this log event */ - Severity severity() const; - /** Returns the message for this log event */ - QString message() const; - -private: - Severity _severity; - QString _message; -}; - -#endif - diff -Nru vidalia-0.1.13/src/torcontrol/LogEvent.h vidalia-0.2.8/src/torcontrol/LogEvent.h --- vidalia-0.1.13/src/torcontrol/LogEvent.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/LogEvent.h 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,59 @@ +/* +** 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.vidalia-project.net/. 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 LogEvent.h +** \version $Id: LogEvent.h 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Event dispatched containing a log message from Tor +*/ + +#ifndef _LOGEVENT_H +#define _LOGEVENT_H + +#include +#include +#include + + +class LogEvent : public QEvent +{ + Q_DECLARE_TR_FUNCTIONS(LogEvent) + +public: + /** Log message severity levels */ + enum Severity { + Unknown = 0, + Debug = (1u<<4), /**< Debug level log message. */ + Info = (1u<<3), /**< Info level log message. */ + Notice = (1u<<2), /**< Notice level log message. */ + Warn = (1u<<1), /**< Warn level log message. */ + Error = (1u<<0) /**< Error level log message. */ + }; + + /** Default constructor */ + LogEvent(Severity severity, QString message); + + /** Converts the string description of a severity to its enum value */ + static Severity toSeverity(QString strSeverity); + /** Converts the Severity enum value to a string description */ + static QString severityToString(Severity severity); + + /** Returns the severity of this log event */ + Severity severity() const; + /** Returns the message for this log event */ + QString message() const; + +private: + Severity _severity; + QString _message; +}; + +#endif + diff -Nru vidalia-0.1.13/src/torcontrol/newdescriptorevent.h vidalia-0.2.8/src/torcontrol/newdescriptorevent.h --- vidalia-0.1.13/src/torcontrol/newdescriptorevent.h 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/newdescriptorevent.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,41 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 newdescriptorevent.h -** \version $Id: newdescriptorevent.h 2362 2008-02-29 04:30:11Z edmanm $ -** \brief Event dispatched upon receiving a new descriptor from Tor -*/ - -#ifndef _NEWDESCRIPTOREVENT_H -#define _NEWDESCRIPTOREVENT_H - -#include -#include - - -class NewDescriptorEvent : public QEvent -{ -public: - /** Default constructor */ - NewDescriptorEvent(QStringList idList) - : QEvent((QEvent::Type)CustomEventType::NewDescriptorEvent) - { _idList = idList; } - - /** Returns a list of new server IDs. */ - QStringList descriptorIDs() const { return _idList; } - -private: - /** A list of new descriptors available. */ - QStringList _idList; -}; - -#endif - diff -Nru vidalia-0.1.13/src/torcontrol/orconnevent.cpp vidalia-0.2.8/src/torcontrol/orconnevent.cpp --- vidalia-0.1.13/src/torcontrol/orconnevent.cpp 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/orconnevent.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,67 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 orconnevent.cpp -** \version $Id: orconnevent.cpp 2362 2008-02-29 04:30:11Z edmanm $ -** \brief Event dispatched upon receiving an ORCONN update from Tor -*/ - -#include "orconnevent.h" - -#include "eventtype.h" - -/** Constructor - * \param status OR connection status. - * \param server OR server. - */ -OrConnEvent::OrConnEvent(Status status, QString server) -: QEvent((QEvent::Type)CustomEventType::OrConnEvent) -{ - _status = status; - _server = server; -} - -/** Converts a string description of a connection's status to an enum value */ -OrConnEvent::Status -OrConnEvent::toStatus(QString status) -{ - Status s; - status = status.toUpper(); - if (status == "NEW") { - s = New; - } else if (status == "LAUNCHED") { - s = Launched; - } else if (status == "CONNECTED") { - s = Connected; - } else if (status == "FAILED") { - s = Failed; - } else if (status == "CLOSED") { - s = Closed; - } else { - s = Unknown; - } - return s; -} - -/** Returns the status for this OR connection. */ -OrConnEvent::Status -OrConnEvent::status() -{ - return _status; -} - -/** Returns the OR server with which this connection is associated. */ -QString -OrConnEvent::server() -{ - return _server; -} - diff -Nru vidalia-0.1.13/src/torcontrol/orconnevent.h vidalia-0.2.8/src/torcontrol/orconnevent.h --- vidalia-0.1.13/src/torcontrol/orconnevent.h 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/orconnevent.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,55 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 orconnevent.h -** \version $Id: orconnevent.h 2362 2008-02-29 04:30:11Z edmanm $ -** \brief Event dispatched upon receiving an ORCONN update from Tor -*/ - -#ifndef _ORCONNEVENT_H -#define _ORCONNEVENT_H - -#include -#include - -class OrConnEvent : public QEvent -{ -public: - /** OR connection status */ - enum Status { - Unknown, /**< Unknown OR status. */ - New, /**< Incoming connection. */ - Launched, /**< Outgoing connection. */ - Connected, /**< TLS handshake finished. */ - Failed, /**< Connection closed before handshake completed. */ - Closed /**< Connection closed that had previously handshaked. */ - }; - - /** Contructor */ - OrConnEvent(Status status, QString server); - - /** Converts a string description of a connection's status to an enum value */ - static Status toStatus(QString status); - - /** Returns the status for this OR connection. */ - Status status(); - /** Returns the OR server with which this connection is associated. */ - QString server(); - -private: - /** OR connection status associated with this event. */ - Status _status; - /** OR server */ - QString _server; -}; - -#endif - diff -Nru vidalia-0.1.13/src/torcontrol/protocolinfo.cpp vidalia-0.2.8/src/torcontrol/protocolinfo.cpp --- vidalia-0.1.13/src/torcontrol/protocolinfo.cpp 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/protocolinfo.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,36 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 protocolinfo.cpp -** \version $Id: protocolinfo.cpp 2362 2008-02-29 04:30:11Z edmanm $ -** \brief Container for information in a PROTOCOLINFO reply from Tor -*/ - -#include "protocolinfo.h" - - -/** Returns true if this ProtocolInfo object contains no data. */ -bool -ProtocolInfo::isEmpty() const -{ - return (_torVersion.isEmpty() && - _authMethods.isEmpty() && - _cookieAuthFile.isEmpty()); -} - -/** Sets the authentication methods Tor currently accepts. methods - * should be a comma-delimited list of authentication methods. */ -void -ProtocolInfo::setAuthMethods(const QString authMethods) -{ - _authMethods = authMethods.split(","); -} - diff -Nru vidalia-0.1.13/src/torcontrol/ProtocolInfo.cpp vidalia-0.2.8/src/torcontrol/ProtocolInfo.cpp --- vidalia-0.1.13/src/torcontrol/ProtocolInfo.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/ProtocolInfo.cpp 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,36 @@ +/* +** 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.vidalia-project.net/. 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 ProtocolInfo.cpp +** \version $Id: ProtocolInfo.cpp 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Container for information in a PROTOCOLINFO reply from Tor +*/ + +#include "ProtocolInfo.h" + + +/** Returns true if this ProtocolInfo object contains no data. */ +bool +ProtocolInfo::isEmpty() const +{ + return (_torVersion.isEmpty() + && _authMethods.isEmpty() + && _cookieAuthFile.isEmpty()); +} + +/** Sets the authentication methods Tor currently accepts. methods + * should be a comma-delimited list of authentication methods. */ +void +ProtocolInfo::setAuthMethods(const QString authMethods) +{ + _authMethods = authMethods.split(","); +} + diff -Nru vidalia-0.1.13/src/torcontrol/protocolinfo.h vidalia-0.2.8/src/torcontrol/protocolinfo.h --- vidalia-0.1.13/src/torcontrol/protocolinfo.h 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/protocolinfo.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,56 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 protocolinfo.h -** \version $Id: protocolinfo.h 2362 2008-02-29 04:30:11Z edmanm $ -** \brief Container for information in a PROTOCOLINFO reply from Tor -*/ - -#ifndef _PROTOCOLINFO_H -#define _PROTOCOLINFO_H - -#include - - -class ProtocolInfo -{ -public: - /** Default constructor. */ - ProtocolInfo() {} - - /** Returns true if this ProtocolInfo object contains no data. */ - bool isEmpty() const; - - /** Sets the authentication methods Tor currently accepts. methods - * should be a comma-delimited list of authentication methods. */ - void setAuthMethods(const QString methods); - /** Returns the authentication methods Tor currently accepts. */ - QStringList authMethods() const { return _authMethods; } - - /** Sets the file to which Tor has written its authentication cookie. */ - void setCookieAuthFile(const QString cookieAuthFile) - { _cookieAuthFile = cookieAuthFile; } - /** Returns the file to which Tor has written its authentication cookie. */ - QString cookieAuthFile() const { return _cookieAuthFile; } - - /** Sets the version of Tor to which the controller is connected. */ - void setTorVersion(const QString torVersion) { _torVersion = torVersion; } - /** Returns the version of Tor to which the controller is connected. */ - QString torVersionString() const { return _torVersion; } - -private: - QString _torVersion; /**< The Tor version in the PROTOCOLINFO reply. */ - QString _cookieAuthFile; /**< Tor's authentication cookie file. */ - QStringList _authMethods; /**< Tor's ccepted authentication methods. */ -}; - -#endif - diff -Nru vidalia-0.1.13/src/torcontrol/ProtocolInfo.h vidalia-0.2.8/src/torcontrol/ProtocolInfo.h --- vidalia-0.1.13/src/torcontrol/ProtocolInfo.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/ProtocolInfo.h 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,56 @@ +/* +** 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.vidalia-project.net/. 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 ProtocolInfo.h +** \version $Id: ProtocolInfo.h 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Container for information in a PROTOCOLINFO reply from Tor +*/ + +#ifndef _PROTOCOLINFO_H +#define _PROTOCOLINFO_H + +#include + + +class ProtocolInfo +{ +public: + /** Default constructor. */ + ProtocolInfo() {} + + /** Returns true if this ProtocolInfo object contains no data. */ + bool isEmpty() const; + + /** Sets the authentication methods Tor currently accepts. methods + * should be a comma-delimited list of authentication methods. */ + void setAuthMethods(const QString methods); + /** Returns the authentication methods Tor currently accepts. */ + QStringList authMethods() const { return _authMethods; } + + /** Sets the file to which Tor has written its authentication cookie. */ + void setCookieAuthFile(const QString cookieAuthFile) + { _cookieAuthFile = cookieAuthFile; } + /** Returns the file to which Tor has written its authentication cookie. */ + QString cookieAuthFile() const { return _cookieAuthFile; } + + /** Sets the version of Tor to which the controller is connected. */ + void setTorVersion(const QString torVersion) { _torVersion = torVersion; } + /** Returns the version of Tor to which the controller is connected. */ + QString torVersionString() const { return _torVersion; } + +private: + QString _torVersion; /**< The Tor version in the PROTOCOLINFO reply. */ + QString _cookieAuthFile; /**< Tor's authentication cookie file. */ + QStringList _authMethods; /**< Tor's ccepted authentication methods. */ +}; + +#endif + diff -Nru vidalia-0.1.13/src/torcontrol/replyline.cpp vidalia-0.2.8/src/torcontrol/replyline.cpp --- vidalia-0.1.13/src/torcontrol/replyline.cpp 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/replyline.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,108 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 replyline.cpp -** \version $Id: replyline.cpp 2362 2008-02-29 04:30:11Z edmanm $ -** \brief Reply from a previous control command sent to Tor -*/ - -#include "replyline.h" - -/** Default constructor */ -ReplyLine::ReplyLine() -{ -} - -/** Constructor */ -ReplyLine::ReplyLine(const QString &status, const QString &msg) -{ - _status = status; - setMessage(msg); -} - -/** Constructor */ -ReplyLine::ReplyLine(const QString &status, const QString &msg, - const QString &data) -{ - _status = status; - setMessage(msg); - appendData(data); -} - -/** Set the status code for this reply line. See Tor Control Protocol V1 - * specification for a description of status codes. */ -void -ReplyLine::setStatus(const QString &status) -{ - _status = status; -} - -/** Returns the status code for this reply line. */ -QString -ReplyLine::getStatus() const -{ - return _status; -} - -/** Sets the ReplyText message this reply line to msg. */ -void -ReplyLine::setMessage(const QString &msg) -{ - _message = unescape(msg); -} - -/** Returns the ReplyText portion of this reply line. */ -QString -ReplyLine::getMessage() const -{ - return _message; -} - -/** Appends data to this reply line. */ -void -ReplyLine::appendData(const QString &data) -{ - _data << unescape(data); -} - -/** Returns a QStringList of all data lines for this reply line */ -QStringList -ReplyLine::getData() const -{ - return _data; -} - -/** Unescapes special characters in str and returns the unescaped - * result. */ -QString -ReplyLine::unescape(const QString &escaped) -{ - QString str = escaped; - /* If the line starts with a "." and was escaped, then unescape it */ - if (str.startsWith("..")) { - str.remove(0, 1); - } - - /* Trim off trailing whitespace (including \r\n) */ - return str.trimmed(); -} - -QString -ReplyLine::toString() const -{ - QString str = _status + " " + _message; - if (!_data.isEmpty()) { - str.append("\n"); - str.append(_data.join("\n")); - } - return str; -} - diff -Nru vidalia-0.1.13/src/torcontrol/ReplyLine.cpp vidalia-0.2.8/src/torcontrol/ReplyLine.cpp --- vidalia-0.1.13/src/torcontrol/ReplyLine.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/ReplyLine.cpp 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,109 @@ +/* +** 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.vidalia-project.net/. 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 ReplyLine.cpp +** \version $Id: ReplyLine.cpp 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Reply from a previous control command sent to Tor +*/ + +#include "ReplyLine.h" + + +/** Default constructor */ +ReplyLine::ReplyLine() +{ +} + +/** Constructor */ +ReplyLine::ReplyLine(const QString &status, const QString &msg) +{ + _status = status; + setMessage(msg); +} + +/** Constructor */ +ReplyLine::ReplyLine(const QString &status, const QString &msg, + const QString &data) +{ + _status = status; + setMessage(msg); + appendData(data); +} + +/** Set the status code for this reply line. See Tor Control Protocol V1 + * specification for a description of status codes. */ +void +ReplyLine::setStatus(const QString &status) +{ + _status = status; +} + +/** Returns the status code for this reply line. */ +QString +ReplyLine::getStatus() const +{ + return _status; +} + +/** Sets the ReplyText message this reply line to msg. */ +void +ReplyLine::setMessage(const QString &msg) +{ + _message = unescape(msg); +} + +/** Returns the ReplyText portion of this reply line. */ +QString +ReplyLine::getMessage() const +{ + return _message; +} + +/** Appends data to this reply line. */ +void +ReplyLine::appendData(const QString &data) +{ + _data << unescape(data); +} + +/** Returns a QStringList of all data lines for this reply line */ +QStringList +ReplyLine::getData() const +{ + return _data; +} + +/** Unescapes special characters in str and returns the unescaped + * result. */ +QString +ReplyLine::unescape(const QString &escaped) +{ + QString str = escaped; + /* If the line starts with a "." and was escaped, then unescape it */ + if (str.startsWith("..")) { + str.remove(0, 1); + } + + /* Trim off trailing whitespace (including \r\n) */ + return str.trimmed(); +} + +QString +ReplyLine::toString() const +{ + QString str = _status + " " + _message; + if (!_data.isEmpty()) { + str.append("\n"); + str.append(_data.join("\n")); + } + return str; +} + diff -Nru vidalia-0.1.13/src/torcontrol/replyline.h vidalia-0.2.8/src/torcontrol/replyline.h --- vidalia-0.1.13/src/torcontrol/replyline.h 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/replyline.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,62 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 replyline.h -** \version $Id: replyline.h 2362 2008-02-29 04:30:11Z edmanm $ -** \brief Reply from a previous control command sent to Tor -*/ - -#ifndef _REPLYLINE_H -#define _REPLYLINE_H - -#include - - -class ReplyLine -{ -public: - ReplyLine(); - ReplyLine(const QString &status, const QString &message); - ReplyLine(const QString &status, const QString &message, const QString &data); - - /** Set the status code to status. */ - void setStatus(const QString &status); - /** Returns the status code for this reply line. */ - QString getStatus() const; - - /** Sets the ReplyText message this reply line to msg. */ - void setMessage(const QString &msg); - /** Returns the ReplyText portion of this reply line. */ - QString getMessage() const; - - /** Appends data to this reply line. */ - void appendData(const QString &data); - /** Returns a QStringList of all data lines for this reply line. */ - QStringList getData() const; - /** Returns true if this reply contained a data portion. */ - bool hasData() const { return _data.size() > 0; } - - /** Returns the entire contents of this reply line, including the status, - * message, and any extra data. */ - QString toString() const; - -private: - /** Unescapes special characters in str and returns the unescaped - * result. */ - static QString unescape(const QString &escaped); - - QString _status; /**< Response status code. */ - QString _message; /**< ReplyText portion of this reply line. */ - QStringList _data; /**< Contents of any DataReplyLines in this line. */ -}; - -#endif - diff -Nru vidalia-0.1.13/src/torcontrol/ReplyLine.h vidalia-0.2.8/src/torcontrol/ReplyLine.h --- vidalia-0.1.13/src/torcontrol/ReplyLine.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/ReplyLine.h 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,62 @@ +/* +** 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.vidalia-project.net/. 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 ReplyLine.h +** \version $Id: ReplyLine.h 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Reply from a previous control command sent to Tor +*/ + +#ifndef _REPLYLINE_H +#define _REPLYLINE_H + +#include + + +class ReplyLine +{ +public: + ReplyLine(); + ReplyLine(const QString &status, const QString &message); + ReplyLine(const QString &status, const QString &message, const QString &data); + + /** Set the status code to status. */ + void setStatus(const QString &status); + /** Returns the status code for this reply line. */ + QString getStatus() const; + + /** Sets the ReplyText message this reply line to msg. */ + void setMessage(const QString &msg); + /** Returns the ReplyText portion of this reply line. */ + QString getMessage() const; + + /** Appends data to this reply line. */ + void appendData(const QString &data); + /** Returns a QStringList of all data lines for this reply line. */ + QStringList getData() const; + /** Returns true if this reply contained a data portion. */ + bool hasData() const { return _data.size() > 0; } + + /** Returns the entire contents of this reply line, including the status, + * message, and any extra data. */ + QString toString() const; + +private: + /** Unescapes special characters in str and returns the unescaped + * result. */ + static QString unescape(const QString &escaped); + + QString _status; /**< Response status code. */ + QString _message; /**< ReplyText portion of this reply line. */ + QStringList _data; /**< Contents of any DataReplyLines in this line. */ +}; + +#endif + diff -Nru vidalia-0.1.13/src/torcontrol/routerdescriptor.cpp vidalia-0.2.8/src/torcontrol/routerdescriptor.cpp --- vidalia-0.1.13/src/torcontrol/routerdescriptor.cpp 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/routerdescriptor.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,82 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 routerdescriptor.cpp -** \version $Id: routerdescriptor.cpp 2362 2008-02-29 04:30:11Z edmanm $ -** \brief Parses a blob of router descriptor text from Tor -*/ - -#include - -#include "routerdescriptor.h" - - -/** Constructor. Just assigns the ID and determines whether the router is - * responsive or not based on the presence of a "!" at the start of the ID. - * See tor-spec.txt for details. */ -RouterDescriptor::RouterDescriptor(QStringList descriptor) -{ - _status = Online; - parseDescriptor(descriptor); -} - -/** Parses this router's descriptor for relevant information. */ -void -RouterDescriptor::parseDescriptor(QStringList descriptor) -{ - foreach (QString line, descriptor) { - if (line.startsWith("router ")) { - QStringList parts = line.remove(0,qstrlen("router ")).split(" "); - _name = parts.at(0); - _ip = QHostAddress(parts.at(1)); - _orPort = (quint16)parts.at(2).toUInt(); - _dirPort = (quint16)parts.at(4).toUInt(); - } else if (line.startsWith("platform ")) { - _platform = line.remove(0,qstrlen("platform ")); - } else if (line.startsWith("published ")) { - _published = QDateTime::fromString( - line.remove(0,qstrlen("published ")), - "yyyy-MM-dd HH:mm:ss"); - } else if (line.startsWith("opt fingerprint ")) { - _fingerprint = line.remove(0,qstrlen("opt fingerprint ")); - _id = _fingerprint.remove(" "); - } else if (line.startsWith("fingerprint ")) { - _fingerprint = line.remove(0,qstrlen("fingerprint ")); - _id = _fingerprint.remove(" "); - } else if (line.startsWith("uptime ")) { - _uptime = (quint64)line.remove(0,qstrlen("uptime ")).toULongLong(); - } else if (line.startsWith("bandwidth ")) { - QStringList bw = line.remove(0,qstrlen("bandwidth ")).split(" "); - _avgBandwidth = (quint64)bw.at(0).toULongLong(); - _burstBandwidth = (quint64)bw.at(1).toULongLong(); - _observedBandwidth = (quint64)bw.at(2).toULongLong(); - } else if (line.startsWith("contact ")) { - _contact = line.remove(0,qstrlen("contact ")); - } else if (line.startsWith("hibernating ")) { - if (line.remove(0,qstrlen("hibernating ")).trimmed() == "1") { - _status = Hibernating; - } - } - } -} - -/** Returns a string representation of the status of this router. */ -QString -RouterDescriptor::status() -{ - if (_status == Online) { - return tr("Online"); - } else if (_status == Hibernating) { - return tr("Hibernating"); - } - return tr("Offline"); -} - diff -Nru vidalia-0.1.13/src/torcontrol/RouterDescriptor.cpp vidalia-0.2.8/src/torcontrol/RouterDescriptor.cpp --- vidalia-0.1.13/src/torcontrol/RouterDescriptor.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/RouterDescriptor.cpp 2009-10-14 22:52:34.000000000 +0100 @@ -0,0 +1,83 @@ +/* +** 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.vidalia-project.net/. 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 RouterDescriptor.cpp +** \version $Id: RouterDescriptor.cpp 4144 2009-10-14 21:52:34Z edmanm $ +** \brief Parses a blob of router descriptor text from Tor +*/ + +#include "RouterDescriptor.h" + +#include + + +/** Constructor. Just assigns the ID and determines whether the router is + * responsive or not based on the presence of a "!" at the start of the ID. + * See tor-spec.txt for details. */ +RouterDescriptor::RouterDescriptor(QStringList descriptor) +{ + _status = Online; + parseDescriptor(descriptor); +} + +/** Parses this router's descriptor for relevant information. */ +void +RouterDescriptor::parseDescriptor(QStringList descriptor) +{ + foreach (QString line, descriptor) { + if (line.startsWith("router ")) { + QStringList parts = line.remove(0,qstrlen("router ")).split(" "); + _name = parts.at(0); + _ip = QHostAddress(parts.at(1)); + _orPort = (quint16)parts.at(2).toUInt(); + _dirPort = (quint16)parts.at(4).toUInt(); + } else if (line.startsWith("platform ")) { + _platform = line.remove(0,qstrlen("platform ")); + } else if (line.startsWith("published ")) { + _published = QDateTime::fromString( + line.remove(0,qstrlen("published ")), + "yyyy-MM-dd HH:mm:ss"); + _published.setTimeSpec(Qt::UTC); + } else if (line.startsWith("opt fingerprint ")) { + _fingerprint = line.remove(0,qstrlen("opt fingerprint ")); + _id = _fingerprint.remove(" "); + } else if (line.startsWith("fingerprint ")) { + _fingerprint = line.remove(0,qstrlen("fingerprint ")); + _id = _fingerprint.remove(" "); + } else if (line.startsWith("uptime ")) { + _uptime = (quint64)line.remove(0,qstrlen("uptime ")).toULongLong(); + } else if (line.startsWith("bandwidth ")) { + QStringList bw = line.remove(0,qstrlen("bandwidth ")).split(" "); + _avgBandwidth = (quint64)bw.at(0).toULongLong(); + _burstBandwidth = (quint64)bw.at(1).toULongLong(); + _observedBandwidth = (quint64)bw.at(2).toULongLong(); + } else if (line.startsWith("contact ")) { + _contact = line.remove(0,qstrlen("contact ")); + } else if (line.startsWith("hibernating ")) { + if (line.remove(0,qstrlen("hibernating ")).trimmed() == "1") { + _status = Hibernating; + } + } + } +} + +/** Returns a string representation of the status of this router. */ +QString +RouterDescriptor::status() +{ + if (_status == Online) { + return tr("Online"); + } else if (_status == Hibernating) { + return tr("Hibernating"); + } + return tr("Offline"); +} + diff -Nru vidalia-0.1.13/src/torcontrol/routerdescriptor.h vidalia-0.2.8/src/torcontrol/routerdescriptor.h --- vidalia-0.1.13/src/torcontrol/routerdescriptor.h 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/routerdescriptor.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,112 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 routerdescriptor.h -** \version $Id: routerdescriptor.h 2362 2008-02-29 04:30:11Z edmanm $ -** \brief Parses a blob of router descriptor text from Tor -*/ - -#ifndef _ROUTERDESCRIPTOR_H -#define _ROUTERDESCRIPTOR_H - -#include -#include -#include -#include -#include - - -class RouterDescriptor -{ - Q_DECLARE_TR_FUNCTIONS(RouterDescriptor) - -public: - /** Possible router states. */ - enum RouterStatus { - Online, /**< Router is online and reachable. */ - Hibernating, /**< Router is currently hibernating. */ - Offline /**< Router is unresponsive. */ - }; - - /** Default constructor. */ - RouterDescriptor() {} - /** Constructor. */ - RouterDescriptor(QStringList descriptor); - - /** Returns the router's name. */ - QString name() const { return _name; } - /** Returns the router's IP address. */ - QHostAddress ip() const { return _ip; } - /** Returns the router's ORPort. */ - quint16 orPort() const { return _orPort; } - /** Returns the router's DirPort. */ - quint16 dirPort() const { return _dirPort; } - /** Returns the router's ID. */ - QString id() const { return _id; } - /** Returns the platform on which this router is running. */ - QString platform() const { return _platform; } - /** Returns the length of time this router has been up. */ - quint64 uptime() const { return _uptime; } - /** Returns the router's contact information. */ - QString contact() const { return _contact; } - /** Returns the date and time the router was published. */ - QDateTime published() const { return _published; } - /** Returns the fingerprint for this router. */ - QString fingerprint() const { return _fingerprint; } - /** Returns the average bandwidth for this router. */ - quint64 averageBandwidth() const { return _avgBandwidth; } - /** Returns the burst bandwidth for this router. */ - quint64 burstBandwidth() const { return _burstBandwidth; } - /** Returns the observed bandwidth for this router. */ - quint64 observedBandwidth() const { return _observedBandwidth; } - /** Returns true if this router is online and responsive. */ - bool online() const { return _status == Online; } - /** Returns true if this router is unresponsive. */ - bool offline() const { return _status == Offline; } - /** Returns true if this router is hibernating. */ - bool hibernating() const { return _status == Hibernating; } - /** Returns true if the router has neither a nickname or an ID. */ - bool isEmpty() { return (_id.isEmpty() && _name.isEmpty()); } - /** Returns a string representation of the status of this router. */ - QString status(); - - /** Returns geographic location information for this router. Note that this - * information is NOT part of the Tor directory protocol, but can be - * determined out of band and set using setLocation(). */ - QString location() const { return _location; } - /** Sets geographic location information for this router. */ - void setLocation(QString location) { _location = location; } - /** Sets the descriptors status to Offline if offline is true. */ - void setOffline(bool offline) { _status = (offline ? Offline : Online); } - -private: - /** Parses this router's descriptor for relevant information. */ - void parseDescriptor(QStringList descriptor); - - RouterStatus _status; /**< Availability status of this router. */ - QString _id; /**< Router's descriptor ID. */ - QString _name; /**< The router's name. */ - QString _fingerprint; /**< Router's fingerprint. */ - QString _platform; /**< Platform on which router is running. */ - QString _contact; /**< Router operator contact information. */ - QHostAddress _ip; /**< Router's IP address. */ - quint16 _orPort; /**< Router's ORPort. */ - quint16 _dirPort; /**< Router's DirPort. */ - QDateTime _published; /**< Date router descriptor was published. */ - quint64 _uptime; /**< Time the router has been online. */ - quint64 _avgBandwidth; /**< Average bandwidth. */ - quint64 _burstBandwidth; /**< Burst bandwidth. */ - quint64 _observedBandwidth; /**< Observed bandwidth. */ - QString _location; /**< Geographic location information. */ -}; - -#endif - diff -Nru vidalia-0.1.13/src/torcontrol/RouterDescriptor.h vidalia-0.2.8/src/torcontrol/RouterDescriptor.h --- vidalia-0.1.13/src/torcontrol/RouterDescriptor.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/RouterDescriptor.h 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,112 @@ +/* +** 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.vidalia-project.net/. 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 RouterDescriptor.h +** \version $Id: RouterDescriptor.h 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Parses a blob of router descriptor text from Tor +*/ + +#ifndef _ROUTERDESCRIPTOR_H +#define _ROUTERDESCRIPTOR_H + +#include +#include +#include +#include +#include + + +class RouterDescriptor +{ + Q_DECLARE_TR_FUNCTIONS(RouterDescriptor) + +public: + /** Possible router states. */ + enum RouterStatus { + Online, /**< Router is online and reachable. */ + Hibernating, /**< Router is currently hibernating. */ + Offline /**< Router is unresponsive. */ + }; + + /** Default constructor. */ + RouterDescriptor() {} + /** Constructor. */ + RouterDescriptor(QStringList descriptor); + + /** Returns the router's name. */ + QString name() const { return _name; } + /** Returns the router's IP address. */ + QHostAddress ip() const { return _ip; } + /** Returns the router's ORPort. */ + quint16 orPort() const { return _orPort; } + /** Returns the router's DirPort. */ + quint16 dirPort() const { return _dirPort; } + /** Returns the router's ID. */ + QString id() const { return _id; } + /** Returns the platform on which this router is running. */ + QString platform() const { return _platform; } + /** Returns the length of time this router has been up. */ + quint64 uptime() const { return _uptime; } + /** Returns the router's contact information. */ + QString contact() const { return _contact; } + /** Returns the date and time the router was published. */ + QDateTime published() const { return _published; } + /** Returns the fingerprint for this router. */ + QString fingerprint() const { return _fingerprint; } + /** Returns the average bandwidth for this router. */ + quint64 averageBandwidth() const { return _avgBandwidth; } + /** Returns the burst bandwidth for this router. */ + quint64 burstBandwidth() const { return _burstBandwidth; } + /** Returns the observed bandwidth for this router. */ + quint64 observedBandwidth() const { return _observedBandwidth; } + /** Returns true if this router is online and responsive. */ + bool online() const { return _status == Online; } + /** Returns true if this router is unresponsive. */ + bool offline() const { return _status == Offline; } + /** Returns true if this router is hibernating. */ + bool hibernating() const { return _status == Hibernating; } + /** Returns true if the router has neither a nickname or an ID. */ + bool isEmpty() { return (_id.isEmpty() && _name.isEmpty()); } + /** Returns a string representation of the status of this router. */ + QString status(); + + /** Returns geographic location information for this router. Note that this + * information is NOT part of the Tor directory protocol, but can be + * determined out of band and set using setLocation(). */ + QString location() const { return _location; } + /** Sets geographic location information for this router. */ + void setLocation(QString location) { _location = location; } + /** Sets the descriptors status to Offline if offline is true. */ + void setOffline(bool offline) { _status = (offline ? Offline : Online); } + +private: + /** Parses this router's descriptor for relevant information. */ + void parseDescriptor(QStringList descriptor); + + RouterStatus _status; /**< Availability status of this router. */ + QString _id; /**< Router's descriptor ID. */ + QString _name; /**< The router's name. */ + QString _fingerprint; /**< Router's fingerprint. */ + QString _platform; /**< Platform on which router is running. */ + QString _contact; /**< Router operator contact information. */ + QHostAddress _ip; /**< Router's IP address. */ + quint16 _orPort; /**< Router's ORPort. */ + quint16 _dirPort; /**< Router's DirPort. */ + QDateTime _published; /**< Date router descriptor was published. */ + quint64 _uptime; /**< Time the router has been online. */ + quint64 _avgBandwidth; /**< Average bandwidth. */ + quint64 _burstBandwidth; /**< Burst bandwidth. */ + quint64 _observedBandwidth; /**< Observed bandwidth. */ + QString _location; /**< Geographic location information. */ +}; + +#endif + diff -Nru vidalia-0.1.13/src/torcontrol/routerstatus.cpp vidalia-0.2.8/src/torcontrol/routerstatus.cpp --- vidalia-0.1.13/src/torcontrol/routerstatus.cpp 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/routerstatus.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,123 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 routerstatus.cpp -** \version $Id: routerstatus.cpp 2508 2008-04-12 22:02:22Z edmanm $ -** \brief Parses a blob of router status text from Tor -*/ - -#include -#include "routerstatus.h" - -/** Defines the time format used when parsing the published date and time from - * a router's status. */ -#define TIME_FORMAT "yyyy-MM-dd HH:mm:ss" - - -/** Constructor. Parses status for router status information. The given - * string should match the router status entry format from Tor's dir-spec.txt. - * The currently recognized lines are: - * - * "r" SP nickname SP identity SP digest SP publication SP IP SP ORPort - * SP DirPort NL - * "s" SP Flags NL - * - * Unrecognized lines are currently ignored. - * - * */ -RouterStatus::RouterStatus(const QStringList &status) -{ - bool ok; - - _valid = false; - _flags = 0; - - foreach (QString line, status) { - if (line.startsWith("r ")) { - QStringList parts = line.split(" ", QString::SkipEmptyParts); - if (parts.size() < 9) - return; - - /* Nickname */ - _name = parts.at(1); - /* Identity key digest */ - _id = base16_encode(QByteArray::fromBase64(parts.at(2).toAscii())); - if (_id.isEmpty()) - return; - /* Most recent descriptor digest */ - _digest = base16_encode(QByteArray::fromBase64(parts.at(3).toAscii())); - if (_digest.isEmpty()) - return; - /* Most recent publication date */ - _published = QDateTime::fromString(parts.at(4) + " " + parts.at(5), - TIME_FORMAT); - if (!_published.isValid()) - return; - /* IP address */ - _ipAddress = QHostAddress(parts.at(6)); - if (_ipAddress.isNull()) - return; - /* ORPort */ - _orPort = parts.at(7).toUInt(&ok); - if (!ok) - return; - /* DirPort */ - _dirPort = parts.at(8).toUInt(&ok); - if (!ok) - return; - - _valid = true; - } else if (line.startsWith("s ")) { - /* Status flags */ - QStringList flags = line.split(" ", QString::SkipEmptyParts); - flags.removeFirst(); /* Remove the "s" */ - - foreach (QString flag, flags) { - _flags |= flagValue(flag); - } - } - } -} - -/** Returns a Flags enum value for the given router status flag. If - * flag is not recognized, then Unknown is returned. */ -RouterStatus::Flag -RouterStatus::flagValue(const QString &flag) -{ - if (!flag.compare("Authority", Qt::CaseInsensitive)) - return Authority; - if (!flag.compare("BadExit", Qt::CaseInsensitive)) - return BadExit; - if (!flag.compare("BadDirectory", Qt::CaseInsensitive)) - return BadDirectory; - if (!flag.compare("Exit", Qt::CaseInsensitive)) - return Exit; - if (!flag.compare("Fast", Qt::CaseInsensitive)) - return Fast; - if (!flag.compare("Guard", Qt::CaseInsensitive)) - return Guard; - if (!flag.compare("HSDir", Qt::CaseInsensitive)) - return HSDir; - if (!flag.compare("Named", Qt::CaseInsensitive)) - return Named; - if (!flag.compare("Running", Qt::CaseInsensitive)) - return Running; - if (!flag.compare("Stable", Qt::CaseInsensitive)) - return Stable; - if (!flag.compare("Valid", Qt::CaseInsensitive)) - return Valid; - if (!flag.compare("V2Dir", Qt::CaseInsensitive)) - return V2Dir; - if (!flag.compare("V3Dir", Qt::CaseInsensitive)) - return V3Dir; - return Unknown; /* Unknown status flag */ -} - diff -Nru vidalia-0.1.13/src/torcontrol/RouterStatus.cpp vidalia-0.2.8/src/torcontrol/RouterStatus.cpp --- vidalia-0.1.13/src/torcontrol/RouterStatus.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/RouterStatus.cpp 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,124 @@ +/* +** 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.vidalia-project.net/. 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 RouterStatus.cpp +** \version $Id: RouterStatus.cpp 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Parses a blob of router status text from Tor +*/ + +#include "RouterStatus.h" + +#include "stringutil.h" + +/** Defines the time format used when parsing the published date and time from + * a router's status. */ +#define TIME_FORMAT "yyyy-MM-dd HH:mm:ss" + + +/** Constructor. Parses status for router status information. The given + * string should match the router status entry format from Tor's dir-spec.txt. + * The currently recognized lines are: + * + * "r" SP nickname SP identity SP digest SP publication SP IP SP ORPort + * SP DirPort NL + * "s" SP Flags NL + * + * Unrecognized lines are currently ignored. + * + * */ +RouterStatus::RouterStatus(const QStringList &status) +{ + bool ok; + + _valid = false; + _flags = 0; + + foreach (QString line, status) { + if (line.startsWith("r ")) { + QStringList parts = line.split(" ", QString::SkipEmptyParts); + if (parts.size() < 9) + return; + + /* Nickname */ + _name = parts.at(1); + /* Identity key digest */ + _id = base16_encode(QByteArray::fromBase64(parts.at(2).toAscii())); + if (_id.isEmpty()) + return; + /* Most recent descriptor digest */ + _digest = base16_encode(QByteArray::fromBase64(parts.at(3).toAscii())); + if (_digest.isEmpty()) + return; + /* Most recent publication date */ + _published = QDateTime::fromString(parts.at(4) + " " + parts.at(5), + TIME_FORMAT); + if (!_published.isValid()) + return; + /* IP address */ + _ipAddress = QHostAddress(parts.at(6)); + if (_ipAddress.isNull()) + return; + /* ORPort */ + _orPort = parts.at(7).toUInt(&ok); + if (!ok) + return; + /* DirPort */ + _dirPort = parts.at(8).toUInt(&ok); + if (!ok) + return; + + _valid = true; + } else if (line.startsWith("s ")) { + /* Status flags */ + QStringList flags = line.split(" ", QString::SkipEmptyParts); + flags.removeFirst(); /* Remove the "s" */ + + foreach (QString flag, flags) { + _flags |= flagValue(flag); + } + } + } +} + +/** Returns a Flags enum value for the given router status flag. If + * flag is not recognized, then Unknown is returned. */ +RouterStatus::Flag +RouterStatus::flagValue(const QString &flag) +{ + if (!flag.compare("Authority", Qt::CaseInsensitive)) + return Authority; + if (!flag.compare("BadExit", Qt::CaseInsensitive)) + return BadExit; + if (!flag.compare("BadDirectory", Qt::CaseInsensitive)) + return BadDirectory; + if (!flag.compare("Exit", Qt::CaseInsensitive)) + return Exit; + if (!flag.compare("Fast", Qt::CaseInsensitive)) + return Fast; + if (!flag.compare("Guard", Qt::CaseInsensitive)) + return Guard; + if (!flag.compare("HSDir", Qt::CaseInsensitive)) + return HSDir; + if (!flag.compare("Named", Qt::CaseInsensitive)) + return Named; + if (!flag.compare("Running", Qt::CaseInsensitive)) + return Running; + if (!flag.compare("Stable", Qt::CaseInsensitive)) + return Stable; + if (!flag.compare("Valid", Qt::CaseInsensitive)) + return Valid; + if (!flag.compare("V2Dir", Qt::CaseInsensitive)) + return V2Dir; + if (!flag.compare("V3Dir", Qt::CaseInsensitive)) + return V3Dir; + return Unknown; /* Unknown status flag */ +} + diff -Nru vidalia-0.1.13/src/torcontrol/routerstatus.h vidalia-0.2.8/src/torcontrol/routerstatus.h --- vidalia-0.1.13/src/torcontrol/routerstatus.h 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/routerstatus.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,101 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 routerstatus.h -** \version $Id: routerstatus.h 2508 2008-04-12 22:02:22Z edmanm $ -** \brief Parses a blob of router status text from Tor -*/ - -#ifndef _ROUTERSTATUS_H -#define _ROUTERSTATUS_H - -#include -#include -#include -#include - - -class RouterStatus -{ -public: - /** Possible router status flags. */ - enum Flag { - Unknown = 0x0000, - Authority = 0x0001, - BadExit = 0x0002, - BadDirectory = 0x0004, - Exit = 0x0008, - Fast = 0x0010, - Guard = 0x0020, - HSDir = 0x0040, - Named = 0x0080, - Stable = 0x0100, - Running = 0x0200, - Valid = 0x0400, - V2Dir = 0x0800, - V3Dir = 0x1000 - }; - Q_DECLARE_FLAGS(Flags, Flag) - - /** Constructor. */ - RouterStatus(const QStringList &status); - - /** Returns the router's hexadecimal-encoded router identity key digest. */ - QString id() const { return _id; } - /** Returns the router's nickname. */ - QString name() const { return _name; } - /** Returns the hexadecimal-encoded digest of the router's most recent - * descriptor. */ - QString descriptorDigest() const { return _digest; } - /** Returns the router's most recent IP address. */ - QHostAddress ipAddress() const { return _ipAddress; } - /** Returns the publication time of the router's most recent descriptor. */ - QDateTime published() const { return _published; } - /** Returns the router's OR port number. */ - quint16 orPort() const { return _orPort; } - /** Returns the router's directory port number. */ - quint16 dirPort() const { return _dirPort; } - - /** Returns an OR-ed field of the router's current status flags. */ - Flags flags() const { return _flags; } - /** Returns true if this router is currently listed as Running. */ - bool isRunning() const { return (flags() & Running); } - - /** Returns true if this router status object is valid. This method should - * be called to verify that the QStringList given in this object's - * constructor contained properly formatted router status lines. */ - bool isValid() const { return _valid; } - -private: - /** Returns a Flags enum value for the given router status flag. If - * flag is not recognized, then Unknown is returned. */ - Flag flagValue(const QString &flag); - - bool _valid; /**< True if this object is a valid RouterStatus. */ - QString _name; /**< Router nickname. */ - QString _id; /**< Hexadecimal-encoded router identity digest. */ - QString _digest; /**< Hexadecimal-encoded hash of the router's most recent - descriptor. */ - QDateTime _published; /**< The publication time of the router's most recent - descriptor. */ - QHostAddress _ipAddress; /**< Current IP address. */ - quint16 _orPort; /**< Current OR port. */ - quint16 _dirPort; /**< Current directory port. */ - Flags _flags; /**< OR-ed field of the router's current status flags. */ -}; - -Q_DECLARE_OPERATORS_FOR_FLAGS(RouterStatus::Flags) - -/** A collection of RouterStatus objects. */ -typedef QList NetworkStatus; - -#endif - diff -Nru vidalia-0.1.13/src/torcontrol/RouterStatus.h vidalia-0.2.8/src/torcontrol/RouterStatus.h --- vidalia-0.1.13/src/torcontrol/RouterStatus.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/RouterStatus.h 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,101 @@ +/* +** 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.vidalia-project.net/. 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 RouterStatus.h +** \version $Id: RouterStatus.h 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Parses a blob of router status text from Tor +*/ + +#ifndef _ROUTERSTATUS_H +#define _ROUTERSTATUS_H + +#include +#include +#include +#include + + +class RouterStatus +{ +public: + /** Possible router status flags. */ + enum Flag { + Unknown = 0x0000, + Authority = 0x0001, + BadExit = 0x0002, + BadDirectory = 0x0004, + Exit = 0x0008, + Fast = 0x0010, + Guard = 0x0020, + HSDir = 0x0040, + Named = 0x0080, + Stable = 0x0100, + Running = 0x0200, + Valid = 0x0400, + V2Dir = 0x0800, + V3Dir = 0x1000 + }; + Q_DECLARE_FLAGS(Flags, Flag) + + /** Constructor. */ + RouterStatus(const QStringList &status); + + /** Returns the router's hexadecimal-encoded router identity key digest. */ + QString id() const { return _id; } + /** Returns the router's nickname. */ + QString name() const { return _name; } + /** Returns the hexadecimal-encoded digest of the router's most recent + * descriptor. */ + QString descriptorDigest() const { return _digest; } + /** Returns the router's most recent IP address. */ + QHostAddress ipAddress() const { return _ipAddress; } + /** Returns the publication time of the router's most recent descriptor. */ + QDateTime published() const { return _published; } + /** Returns the router's OR port number. */ + quint16 orPort() const { return _orPort; } + /** Returns the router's directory port number. */ + quint16 dirPort() const { return _dirPort; } + + /** Returns an OR-ed field of the router's current status flags. */ + Flags flags() const { return _flags; } + /** Returns true if this router is currently listed as Running. */ + bool isRunning() const { return (flags() & Running); } + + /** Returns true if this router status object is valid. This method should + * be called to verify that the QStringList given in this object's + * constructor contained properly formatted router status lines. */ + bool isValid() const { return _valid; } + +private: + /** Returns a Flags enum value for the given router status flag. If + * flag is not recognized, then Unknown is returned. */ + Flag flagValue(const QString &flag); + + bool _valid; /**< True if this object is a valid RouterStatus. */ + QString _name; /**< Router nickname. */ + QString _id; /**< Hexadecimal-encoded router identity digest. */ + QString _digest; /**< Hexadecimal-encoded hash of the router's most recent + descriptor. */ + QDateTime _published; /**< The publication time of the router's most recent + descriptor. */ + QHostAddress _ipAddress; /**< Current IP address. */ + quint16 _orPort; /**< Current OR port. */ + quint16 _dirPort; /**< Current directory port. */ + Flags _flags; /**< OR-ed field of the router's current status flags. */ +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(RouterStatus::Flags) + +/** A collection of RouterStatus objects. */ +typedef QList NetworkStatus; + +#endif + diff -Nru vidalia-0.1.13/src/torcontrol/sendcommandevent.cpp vidalia-0.2.8/src/torcontrol/sendcommandevent.cpp --- vidalia-0.1.13/src/torcontrol/sendcommandevent.cpp 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/sendcommandevent.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,67 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 sendcommandevent.cpp -** \version $Id: sendcommandevent.cpp 2837 2008-07-06 22:41:50Z edmanm $ -** \brief An event posted to a socket living in another thread, indicating -** that it should send the given control command. -*/ - -#include - -#include "sendcommandevent.h" - - -SendCommandEvent::SendCommandEvent(const ControlCommand &cmd, SendWaiter *w) - : QEvent((QEvent::Type)CustomEventType::SendCommandEvent) -{ - _cmd = cmd; - _waiter = w; -} - -/** Sets the result of the send operation. */ -void -SendCommandEvent::SendWaiter::setResult(bool success, const QString &errmsg) -{ - _mutex.lock(); - _status = (success ? Success : Failed); - _errmsg = errmsg; - _mutex.unlock(); - _waitCond.wakeAll(); -} - -/** Waits for and gets the result of the send operation. */ -bool -SendCommandEvent::SendWaiter::getResult(QString *errmsg) -{ - forever { - _mutex.lock(); - if (_status == Waiting) { - _waitCond.wait(&_mutex); - _mutex.unlock(); - } else { - _mutex.unlock(); - break; - } - } - if (errmsg) { - *errmsg = _errmsg; - } - return (_status == Success); -} - -/** Returns the SendWaiter's current SenderStatus value. */ -SendCommandEvent::SendWaiter::SenderStatus -SendCommandEvent::SendWaiter::status() -{ - QMutexLocker locker(&_mutex); - return _status; -} diff -Nru vidalia-0.1.13/src/torcontrol/SendCommandEvent.cpp vidalia-0.2.8/src/torcontrol/SendCommandEvent.cpp --- vidalia-0.1.13/src/torcontrol/SendCommandEvent.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/SendCommandEvent.cpp 2009-08-17 03:25:08.000000000 +0100 @@ -0,0 +1,67 @@ +/* +** 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.vidalia-project.net/. 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 SendEommandEvent.cpp +** \version $Id: SendCommandEvent.cpp 4054 2009-08-17 02:25:08Z edmanm $ +** \brief An event posted to a socket living in another thread, indicating +** that it should send the given control command. +*/ + +#include "SendCommandEvent.h" + +#include + + +SendCommandEvent::SendCommandEvent(const ControlCommand &cmd, SendWaiter *w) + : QEvent(QEvent::User) +{ + _cmd = cmd; + _waiter = w; +} + +/** Sets the result of the send operation. */ +void +SendCommandEvent::SendWaiter::setResult(bool success, const QString &errmsg) +{ + _mutex.lock(); + _status = (success ? Success : Failed); + _errmsg = errmsg; + _mutex.unlock(); + _waitCond.wakeAll(); +} + +/** Waits for and gets the result of the send operation. */ +bool +SendCommandEvent::SendWaiter::getResult(QString *errmsg) +{ + forever { + _mutex.lock(); + if (_status == Waiting) { + _waitCond.wait(&_mutex); + _mutex.unlock(); + } else { + _mutex.unlock(); + break; + } + } + if (errmsg) { + *errmsg = _errmsg; + } + return (_status == Success); +} + +/** Returns the SendWaiter's current SenderStatus value. */ +SendCommandEvent::SendWaiter::SenderStatus +SendCommandEvent::SendWaiter::status() +{ + QMutexLocker locker(&_mutex); + return _status; +} diff -Nru vidalia-0.1.13/src/torcontrol/sendcommandevent.h vidalia-0.2.8/src/torcontrol/sendcommandevent.h --- vidalia-0.1.13/src/torcontrol/sendcommandevent.h 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/sendcommandevent.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,62 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 sendcommandevent.h -** \version $Id: sendcommandevent.h 2837 2008-07-06 22:41:50Z edmanm $ -** \brief An event posted to a socket living in another thread, indicating -** that it should send the given control command. -*/ - -#ifndef _SENDCOMMANDEVENT_H -#define _SENDCOMMANDEVENT_H - -#include -#include -#include - -#include "eventtype.h" -#include "controlcommand.h" - - -class SendCommandEvent : public QEvent { -public: - /** Object used to wait for the result of a send operation. */ - class SendWaiter { - public: - /** Status of the send SendWaiter. */ - enum SenderStatus { Waiting, Failed, Success } _status; - /** Default constructor. */ - SendWaiter() { _status = Waiting; } - /** Sets the result of the send operation. */ - void setResult(bool success, const QString &errmsg = QString()); - /** Waits for and returns the result of the send operation. */ - bool getResult(QString *errmsg = 0); - /** Returns the SendWaiter's current SenderStatus value. */ - SenderStatus status(); - private: - QMutex _mutex; /**< Mutex around the wait condition. */ - QWaitCondition _waitCond; /**< Waits for the send to complete. */ - QString _errmsg; /**< Error message if the send fails. */ - }; - - /** Constructor. */ - SendCommandEvent(const ControlCommand &cmd, SendWaiter *w = 0); - /** Returns the control command to send to Tor. */ - ControlCommand command() { return _cmd; } - /** Returns a SendWaiter (if any) for the result of this send. */ - SendWaiter* waiter() { return _waiter; } - -private: - ControlCommand _cmd; /**< Command to send to Tor. */ - SendWaiter* _waiter; /**< SendWaiter for the result of this event. */ -}; - -#endif diff -Nru vidalia-0.1.13/src/torcontrol/SendCommandEvent.h vidalia-0.2.8/src/torcontrol/SendCommandEvent.h --- vidalia-0.1.13/src/torcontrol/SendCommandEvent.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/SendCommandEvent.h 2009-08-17 03:25:08.000000000 +0100 @@ -0,0 +1,61 @@ +/* +** 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.vidalia-project.net/. 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 SendCommandEvent.h +** \version $Id: SendCommandEvent.h 4054 2009-08-17 02:25:08Z edmanm $ +** \brief An event posted to a socket living in another thread, indicating +** that it should send the given control command. +*/ + +#ifndef _SENDCOMMANDEVENT_H +#define _SENDCOMMANDEVENT_H + +#include "ControlCommand.h" + +#include +#include +#include + + +class SendCommandEvent : public QEvent { +public: + /** Object used to wait for the result of a send operation. */ + class SendWaiter { + public: + /** Status of the send SendWaiter. */ + enum SenderStatus { Waiting, Failed, Success } _status; + /** Default constructor. */ + SendWaiter() { _status = Waiting; } + /** Sets the result of the send operation. */ + void setResult(bool success, const QString &errmsg = QString()); + /** Waits for and returns the result of the send operation. */ + bool getResult(QString *errmsg = 0); + /** Returns the SendWaiter's current SenderStatus value. */ + SenderStatus status(); + private: + QMutex _mutex; /**< Mutex around the wait condition. */ + QWaitCondition _waitCond; /**< Waits for the send to complete. */ + QString _errmsg; /**< Error message if the send fails. */ + }; + + /** Constructor. */ + SendCommandEvent(const ControlCommand &cmd, SendWaiter *w = 0); + /** Returns the control command to send to Tor. */ + ControlCommand command() { return _cmd; } + /** Returns a SendWaiter (if any) for the result of this send. */ + SendWaiter* waiter() { return _waiter; } + +private: + ControlCommand _cmd; /**< Command to send to Tor. */ + SendWaiter* _waiter; /**< SendWaiter for the result of this event. */ +}; + +#endif diff -Nru vidalia-0.1.13/src/torcontrol/serverstatusevent.cpp vidalia-0.2.8/src/torcontrol/serverstatusevent.cpp --- vidalia-0.1.13/src/torcontrol/serverstatusevent.cpp 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/serverstatusevent.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,49 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 serverstatusevent.cpp -** \version $Id: serverstatusevent.cpp 2362 2008-02-29 04:30:11Z edmanm $ -** \brief Base class for all Tor server status events -*/ - -#include "serverstatusevent.h" - - -/** Returns a ServerStatusEvent::Status enum value for the server status - * represented by str. */ -ServerStatusEvent::Status -ServerStatusEvent::statusFromString(const QString &str) -{ - if (!str.compare("EXTERNAL_ADDRESS", Qt::CaseInsensitive)) - return ExternalAddressChanged; - if (!str.compare("CHECKING_REACHABILITY", Qt::CaseInsensitive)) - return CheckingReachability; - if (!str.compare("REACHABILITY_SUCCEEDED", Qt::CaseInsensitive)) - return ReachabilitySucceeded; - if (!str.compare("GOOD_SERVER_DESCRIPTOR", Qt::CaseInsensitive)) - return GoodServerDescriptor; - if (!str.compare("NAMESERVER_STATUS", Qt::CaseInsensitive)) - return NameserverStatusChanged; - if (!str.compare("NAMESERVER_ALL_DOWN", Qt::CaseInsensitive)) - return NameserversAllDown; - if (!str.compare("DNS_HIJACKED", Qt::CaseInsensitive)) - return DnsHijacked; - if (!str.compare("DNS_USELESS", Qt::CaseInsensitive)) - return DnsUseless; - if (!str.compare("BAD_SERVER_DESCRIPTOR", Qt::CaseInsensitive)) - return RejectedServerDescriptor; - if (!str.compare("ACCEPTED_SERVER_DESCRIPTOR", Qt::CaseInsensitive)) - return AcceptedServerDescriptor; - if (!str.compare("REACHABILITY_FAILED", Qt::CaseInsensitive)) - return ReachabilityFailed; - return UnrecognizedStatus; -} - diff -Nru vidalia-0.1.13/src/torcontrol/serverstatusevent.h vidalia-0.2.8/src/torcontrol/serverstatusevent.h --- vidalia-0.1.13/src/torcontrol/serverstatusevent.h 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/serverstatusevent.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,58 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 serverstatusevent.h -** \version $Id: serverstatusevent.h 2780 2008-06-21 21:48:32Z edmanm $ -** \brief Base class for all Tor server status events -*/ - -#ifndef _SERVERSTATUSEVENT_H -#define _SERVERSTATUSEVENT_H - -#include "statusevent.h" - - -class ServerStatusEvent : public StatusEvent -{ -public: - /**< Tor server status event types. */ - enum Status { - UnrecognizedStatus, - ExternalAddressChanged, - NameserverStatusChanged, - NameserversAllDown, - DnsHijacked, - DnsUseless, - AcceptedServerDescriptor, - RejectedServerDescriptor, - GoodServerDescriptor, - CheckingReachability, - ReachabilityFailed, - ReachabilitySucceeded - }; - - /** Constructor */ - ServerStatusEvent(tc::Severity severity, Status status) - : StatusEvent((QEvent::Type)CustomEventType::ServerStatusEvent, severity), - _status(status) {} - - /** Returns the server status indicated by this event. */ - Status status() const { return _status; } - /** Returns a ServerStatusEvent::Status enum value for the server status - * represented by str. */ - static Status statusFromString(const QString &str); - -private: - Status _status; /**< Tor Server status indicated by this event. */ -}; - -#endif - diff -Nru vidalia-0.1.13/src/torcontrol/statusevent.h vidalia-0.2.8/src/torcontrol/statusevent.h --- vidalia-0.1.13/src/torcontrol/statusevent.h 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/statusevent.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,44 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 statusevent.h -** \version $Id: statusevent.h 2780 2008-06-21 21:48:32Z edmanm $ -** \brief Base class for all Tor status events -*/ - -#ifndef _STATUSEVENT_H -#define _STATUSEVENT_H - -#include -#include -#include "eventtype.h" -#include "tcglobal.h" - - -class StatusEvent : public QEvent -{ -public: - /** Constructor */ - StatusEvent(QEvent::Type type, tc::Severity severity) - : QEvent(type), _severity(severity) {} - - /** Returns the severity of this status event. */ - tc::Severity severity() const { return _severity; } - /** Returns a StatusEvent::Severity enum value for the severity represented - * by str. */ - static tc::Severity severityFromString(const QString &str); - -private: - tc::Severity _severity; /**< Severity of this status event. */ -}; - -#endif - diff -Nru vidalia-0.1.13/src/torcontrol/stream.cpp vidalia-0.2.8/src/torcontrol/stream.cpp --- vidalia-0.1.13/src/torcontrol/stream.cpp 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/stream.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,154 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 stream.cpp -** \version $Id: stream.cpp 2977 2008-08-17 01:28:25Z edmanm $ -** \brief Object representing a Tor stream -*/ - -#include - -#include "circuit.h" -#include "stream.h" - - -/** Default constructor. */ -Stream::Stream() -{ - _status = Unknown; - _port = 0; -} - -/** Constructor */ -Stream::Stream(const StreamId &streamId, Status status, - const CircuitId &circuitId, const QString &address, - quint16 port) -{ - _streamId = streamId; - _status = status; - _circuitId = circuitId; - _address = address; - _port = port; -} - -/** Constructor */ -Stream::Stream(const StreamId &streamId, Status status, - const CircuitId &circuitId, const QString &target) -{ - _streamId = streamId; - _status = status; - _circuitId = circuitId; - _port = 0; - - int i = target.indexOf(":"); - if (i >= 0) - _address = target.mid(0, i); - if (i + 1 < target.length()) - _port = target.mid(i+1).toUInt(); -} - -/** Parses the given string for stream information, given in Tor control - * protocol format. The format is: - * - * StreamID SP StreamStatus SP CircID SP Target - */ -Stream -Stream::fromString(const QString &stream) -{ - QStringList parts = stream.split(" ", QString::SkipEmptyParts); - if (parts.size() >= 4) { - /* Get the stream ID */ - StreamId streamId = parts.at(0); - /* Get the stream status value */ - Stream::Status status = Stream::toStatus(parts.at(1)); - /* Get the ID of the circuit on which this stream travels */ - CircuitId circId = parts.at(2); - /* Get the target address for this stream */ - QString target = parts.at(3); - - return Stream(streamId, status, circId, target); - } - return Stream(); -} - -/** Returns true iff streamId consists of only between 1 and 16 - * (inclusive) ASCII-encoded letters and numbers. */ -bool -Stream::isValidStreamId(const StreamId &streamId) -{ - int length = streamId.length(); - if (length < 1 || length > 16) - return false; - - for (int i = 0; i < length; i++) { - char c = streamId[i].toAscii(); - if (c < '0' && c > '9' && c < 'A' && c > 'Z' && c < 'a' && c > 'z') - return false; - } - return true; -} - -/** Converts a string description of a stream's status to its enum value */ -Stream::Status -Stream::toStatus(const QString &strStatus) -{ - if (!strStatus.compare("NEW", Qt::CaseInsensitive)) - return New; - if (!strStatus.compare("NEWRESOLVE", Qt::CaseInsensitive)) - return NewResolve; - if (!strStatus.compare("SENTCONNECT", Qt::CaseInsensitive)) - return SentConnect; - if (!strStatus.compare("SENTRESOLVE", Qt::CaseInsensitive)) - return SentResolve; - if (!strStatus.compare("SUCCEEDED", Qt::CaseInsensitive)) - return Succeeded; - if (!strStatus.compare("FAILED", Qt::CaseInsensitive)) - return Failed; - if (!strStatus.compare("CLOSED", Qt::CaseInsensitive)) - return Closed; - if (!strStatus.compare("DETACHED", Qt::CaseInsensitive)) - return Detached; - if (!strStatus.compare("REMAP", Qt::CaseInsensitive)) - return Remap; - return Unknown; -} - -/** Returns a human-understandable string representation of this - * stream's status. */ -QString -Stream::statusString() const -{ - QString status; - switch (_status) { - case New: status = tr("New"); break; - case NewResolve: - case SentResolve: status = tr("Resolving"); break; - case SentConnect: status = tr("Connecting"); break; - case Succeeded: status = tr("Open"); break; - case Failed: status = tr("Failed"); break; - case Closed: status = tr("Closed"); break; - case Detached: status = tr("Retrying"); break; - case Remap: status = tr("Remapped"); break; - default: status = tr("Unknown"); break; - } - return status; -} - -/** Returns true if all fields in this Stream object are valid. */ -bool -Stream::isValid() const -{ - return (isValidStreamId(_streamId) - && Circuit::isValidCircuitId(_circuitId) - && (_status != Unknown) - && !_address.isEmpty()); -} - diff -Nru vidalia-0.1.13/src/torcontrol/Stream.cpp vidalia-0.2.8/src/torcontrol/Stream.cpp --- vidalia-0.1.13/src/torcontrol/Stream.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/Stream.cpp 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,154 @@ +/* +** 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.vidalia-project.net/. 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 Stream.cpp +** \version $Id: Stream.cpp 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Object representing a Tor stream +*/ + +#include "Stream.h" +#include "Circuit.h" + +#include + + +/** Default constructor. */ +Stream::Stream() +{ + _status = Unknown; + _port = 0; +} + +/** Constructor */ +Stream::Stream(const StreamId &streamId, Status status, + const CircuitId &circuitId, const QString &address, + quint16 port) +{ + _streamId = streamId; + _status = status; + _circuitId = circuitId; + _address = address; + _port = port; +} + +/** Constructor */ +Stream::Stream(const StreamId &streamId, Status status, + const CircuitId &circuitId, const QString &target) +{ + _streamId = streamId; + _status = status; + _circuitId = circuitId; + _port = 0; + + int i = target.indexOf(":"); + if (i >= 0) + _address = target.mid(0, i); + if (i + 1 < target.length()) + _port = target.mid(i+1).toUInt(); +} + +/** Parses the given string for stream information, given in Tor control + * protocol format. The format is: + * + * StreamID SP StreamStatus SP CircID SP Target + */ +Stream +Stream::fromString(const QString &stream) +{ + QStringList parts = stream.split(" ", QString::SkipEmptyParts); + if (parts.size() >= 4) { + /* Get the stream ID */ + StreamId streamId = parts.at(0); + /* Get the stream status value */ + Stream::Status status = Stream::toStatus(parts.at(1)); + /* Get the ID of the circuit on which this stream travels */ + CircuitId circId = parts.at(2); + /* Get the target address for this stream */ + QString target = parts.at(3); + + return Stream(streamId, status, circId, target); + } + return Stream(); +} + +/** Returns true iff streamId consists of only between 1 and 16 + * (inclusive) ASCII-encoded letters and numbers. */ +bool +Stream::isValidStreamId(const StreamId &streamId) +{ + int length = streamId.length(); + if (length < 1 || length > 16) + return false; + + for (int i = 0; i < length; i++) { + char c = streamId[i].toAscii(); + if (c < '0' && c > '9' && c < 'A' && c > 'Z' && c < 'a' && c > 'z') + return false; + } + return true; +} + +/** Converts a string description of a stream's status to its enum value */ +Stream::Status +Stream::toStatus(const QString &strStatus) +{ + if (!strStatus.compare("NEW", Qt::CaseInsensitive)) + return New; + if (!strStatus.compare("NEWRESOLVE", Qt::CaseInsensitive)) + return NewResolve; + if (!strStatus.compare("SENTCONNECT", Qt::CaseInsensitive)) + return SentConnect; + if (!strStatus.compare("SENTRESOLVE", Qt::CaseInsensitive)) + return SentResolve; + if (!strStatus.compare("SUCCEEDED", Qt::CaseInsensitive)) + return Succeeded; + if (!strStatus.compare("FAILED", Qt::CaseInsensitive)) + return Failed; + if (!strStatus.compare("CLOSED", Qt::CaseInsensitive)) + return Closed; + if (!strStatus.compare("DETACHED", Qt::CaseInsensitive)) + return Detached; + if (!strStatus.compare("REMAP", Qt::CaseInsensitive)) + return Remap; + return Unknown; +} + +/** Returns a human-understandable string representation of this + * stream's status. */ +QString +Stream::statusString() const +{ + QString status; + switch (_status) { + case New: status = tr("New"); break; + case NewResolve: + case SentResolve: status = tr("Resolving"); break; + case SentConnect: status = tr("Connecting"); break; + case Succeeded: status = tr("Open"); break; + case Failed: status = tr("Failed"); break; + case Closed: status = tr("Closed"); break; + case Detached: status = tr("Retrying"); break; + case Remap: status = tr("Remapped"); break; + default: status = tr("Unknown"); break; + } + return status; +} + +/** Returns true if all fields in this Stream object are valid. */ +bool +Stream::isValid() const +{ + return (isValidStreamId(_streamId) + && Circuit::isValidCircuitId(_circuitId) + && (_status != Unknown) + && !_address.isEmpty()); +} + diff -Nru vidalia-0.1.13/src/torcontrol/streamevent.h vidalia-0.2.8/src/torcontrol/streamevent.h --- vidalia-0.1.13/src/torcontrol/streamevent.h 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/streamevent.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,50 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 streamevent.h -** \version $Id: streamevent.h 2977 2008-08-17 01:28:25Z edmanm $ -** \brief Event dispatched when a stream status update is received from Tor -*/ - -#ifndef _STREAMEVENT_H -#define _STREAMEVENT_H - -#include - -#include "eventtype.h" -#include "stream.h" - - -class StreamEvent : public QEvent -{ -public: - /** Default constructor */ - StreamEvent(Stream stream) - : QEvent((QEvent::Type)CustomEventType::StreamEvent) - { _stream = stream; } - - /** Returns the Stream object for this stream event. */ - Stream stream() const { return _stream; } - /** Returns the ID for this stream event. */ - StreamId id() const { return _stream.id(); } - /** Returns the status for this stream event. */ - Stream::Status status() const { return _stream.status(); } - /** Returns the ID of the circuit to which this stream is assigned */ - CircuitId circuitId() const { return _stream.circuitId(); } - /** Returns the target for this stream event. */ - QString target() const { return _stream.target(); } - -private: - Stream _stream; /**< Stream object for this stream event. */ -}; - -#endif - diff -Nru vidalia-0.1.13/src/torcontrol/stream.h vidalia-0.2.8/src/torcontrol/stream.h --- vidalia-0.1.13/src/torcontrol/stream.h 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/stream.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,98 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 stream.h -** \version $Id: stream.h 2977 2008-08-17 01:28:25Z edmanm $ -** \brief Object representing a Tor stream -*/ - -#ifndef _STREAM_H -#define _STREAM_H - -#include -#include -#include -#include - -#include "circuit.h" - -/** Stream IDs contains 1-16 alphanumeric ASCII characters. */ -typedef QString StreamId; - - -class Stream -{ - Q_DECLARE_TR_FUNCTIONS(Stream) - -public: - /** Stream status values */ - enum Status { - Unknown, /**< Unknown status type given */ - New, /**< New request to connect */ - NewResolve, /**< New request to resolve an address */ - SentConnect, /**< Sent a connect cell */ - SentResolve, /**< Sent a resolve cell */ - Succeeded, /**< Stream established */ - Failed, /**< Stream failed */ - Closed, /**< Stream closed */ - Detached, /**< Detached from circuit */ - Remap /**< Address re-mapped to another */ - }; - - /** Default constructor */ - Stream(); - /** Constructor */ - Stream(const StreamId &streamId, Status status, const CircuitId &circuitId, - const QString &target); - /** Constructor */ - Stream(const StreamId &streamId, Status status, const CircuitId &circuitId, - const QString &address, quint16 port); - - /** Parses the given string for a stream, in Tor control protocol format. */ - static Stream fromString(const QString &stream); - /** Converts a string description of a stream's status to its enum value */ - static Status toStatus(const QString &strStatus); - - /** Returns true iff the Stream object's fields are all valid. */ - bool isValid() const; - - /** Returns the ID for this stream. */ - StreamId id() const { return _streamId; } - /** Returns the status for this stream. */ - Status status() const { return _status; } - /** Returns a string representation of this stream's status. */ - QString statusString() const; - /** Returns the ID of the circuit to which this stream is assigned. */ - CircuitId circuitId() const { return _circuitId; } - /** Returns the target address and port for this stream. */ - QString target() const { return (_address + ":" + QString::number(_port)); } - /** Returns the target address for this stream. */ - QString targetAddress() const { return _address; } - /** Returns the target port for this stream. */ - quint16 targetPort() const { return _port; } - - /** Returns true iff streamId consists of only between 1 and 16 - * (inclusive) ASCII-encoded letters and numbers. */ - static bool isValidStreamId(const StreamId &streamId); - -private: - StreamId _streamId; /**< Unique ID associated with this stream. */ - CircuitId _circuitId; /**< ID of the circuit carrying this stream. */ - QString _address; /**< Stream target address. */ - Status _status; /**< Stream status value. */ - quint16 _port; /**< Stream target port. */ -}; - -/** A collection of Stream objects. */ -typedef QList StreamList; - -#endif - diff -Nru vidalia-0.1.13/src/torcontrol/Stream.h vidalia-0.2.8/src/torcontrol/Stream.h --- vidalia-0.1.13/src/torcontrol/Stream.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/Stream.h 2009-08-17 03:25:08.000000000 +0100 @@ -0,0 +1,101 @@ +/* +** 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.vidalia-project.net/. 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 Stream.h +** \version $Id: Stream.h 4054 2009-08-17 02:25:08Z edmanm $ +** \brief Object representing a Tor stream +*/ + +#ifndef _STREAM_H +#define _STREAM_H + +#include "Circuit.h" + +#include +#include +#include +#include +#include + +/** Stream IDs contains 1-16 alphanumeric ASCII characters. */ +typedef QString StreamId; + + +class Stream +{ + Q_DECLARE_TR_FUNCTIONS(Stream) + +public: + /** Stream status values */ + enum Status { + Unknown, /**< Unknown status type given */ + New, /**< New request to connect */ + NewResolve, /**< New request to resolve an address */ + SentConnect, /**< Sent a connect cell */ + SentResolve, /**< Sent a resolve cell */ + Succeeded, /**< Stream established */ + Failed, /**< Stream failed */ + Closed, /**< Stream closed */ + Detached, /**< Detached from circuit */ + Remap /**< Address re-mapped to another */ + }; + + /** Default constructor */ + Stream(); + /** Constructor */ + Stream(const StreamId &streamId, Status status, const CircuitId &circuitId, + const QString &target); + /** Constructor */ + Stream(const StreamId &streamId, Status status, const CircuitId &circuitId, + const QString &address, quint16 port); + + /** Parses the given string for a stream, in Tor control protocol format. */ + static Stream fromString(const QString &stream); + /** Converts a string description of a stream's status to its enum value */ + static Status toStatus(const QString &strStatus); + + /** Returns true iff the Stream object's fields are all valid. */ + bool isValid() const; + + /** Returns the ID for this stream. */ + StreamId id() const { return _streamId; } + /** Returns the status for this stream. */ + Status status() const { return _status; } + /** Returns a string representation of this stream's status. */ + QString statusString() const; + /** Returns the ID of the circuit to which this stream is assigned. */ + CircuitId circuitId() const { return _circuitId; } + /** Returns the target address and port for this stream. */ + QString target() const { return (_address + ":" + QString::number(_port)); } + /** Returns the target address for this stream. */ + QString targetAddress() const { return _address; } + /** Returns the target port for this stream. */ + quint16 targetPort() const { return _port; } + + /** Returns true iff streamId consists of only between 1 and 16 + * (inclusive) ASCII-encoded letters and numbers. */ + static bool isValidStreamId(const StreamId &streamId); + +private: + StreamId _streamId; /**< Unique ID associated with this stream. */ + CircuitId _circuitId; /**< ID of the circuit carrying this stream. */ + QString _address; /**< Stream target address. */ + Status _status; /**< Stream status value. */ + quint16 _port; /**< Stream target port. */ +}; + +Q_DECLARE_METATYPE(Stream); + +/** A collection of Stream objects. */ +typedef QList StreamList; + +#endif + diff -Nru vidalia-0.1.13/src/torcontrol/tcglobal.cpp vidalia-0.2.8/src/torcontrol/tcglobal.cpp --- vidalia-0.1.13/src/torcontrol/tcglobal.cpp 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/tcglobal.cpp 2009-08-17 03:25:08.000000000 +0100 @@ -10,7 +10,7 @@ /* ** \file tcglobal.cpp -** \version $Id: tcglobal.cpp 2803 2008-06-27 03:38:42Z edmanm $ +** \version $Id: tcglobal.cpp 4054 2009-08-17 02:25:08Z edmanm $ ** \brief Provides common methods and constants used by the torcontrol library */ @@ -53,7 +53,7 @@ /* Converts str to a ConnectionStatusReason enum value. */ ConnectionStatusReason -toConnectionStatusReason(const QString &str) +connectionStatusReasonFromString(const QString &str) { if (str.isEmpty()) return UnrecognizedReason; @@ -80,18 +80,18 @@ /* Converts str to a Severity enum value. */ Severity -toSeverity(const QString &str) +severityFromString(const QString &str) { if (!str.compare("DEBUG", Qt::CaseInsensitive)) - return SeverityDebug; + return DebugSeverity; if (!str.compare("INFO", Qt::CaseInsensitive)) - return SeverityInfo; + return InfoSeverity; if (!str.compare("NOTICE", Qt::CaseInsensitive)) - return SeverityNotice; + return NoticeSeverity; if (!str.compare("WARN", Qt::CaseInsensitive)) - return SeverityWarn; + return WarnSeverity; if (!str.compare("ERR", Qt::CaseInsensitive)) - return SeverityError; + return ErrorSeverity; return UnrecognizedSeverity; } diff -Nru vidalia-0.1.13/src/torcontrol/tcglobal.h vidalia-0.2.8/src/torcontrol/tcglobal.h --- vidalia-0.1.13/src/torcontrol/tcglobal.h 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/tcglobal.h 2009-08-17 03:25:08.000000000 +0100 @@ -10,7 +10,7 @@ /* ** \file tcglobal.h -** \version $Id: tcglobal.h 2780 2008-06-21 21:48:32Z edmanm $ +** \version $Id: tcglobal.h 4054 2009-08-17 02:25:08Z edmanm $ ** \brief Provides common methods and constants used by the torcontrol library */ @@ -18,7 +18,7 @@ #define _TCGLOBAL_H #include - +#include namespace tc { /** Helper class to handle formatting log messages with arguments. */ @@ -68,19 +68,33 @@ }; /** Severity values used in log message and status events. */ enum Severity { - UnrecognizedSeverity, /**< An unrecognized severity value. */ - SeverityDebug, /**< Hyper-verbose events used for debugging. */ - SeverityInfo, /**< Verbose events that can occur frequently. */ - SeverityNotice, /**< A not-so-bad event. */ - SeverityWarn, /**< An important, but non-fatal event. */ - SeverityError /**< A critical event. */ + UnrecognizedSeverity = 0, /**< An unrecognized severity value. */ + DebugSeverity = (1u<<4), /**< Hyper-verbose events used for debugging. */ + InfoSeverity = (1u<<3), /**< Verbose events that can occur frequently. */ + NoticeSeverity = (1u<<2), /**< A not-so-bad event. */ + WarnSeverity = (1u<<1), /**< An important, but non-fatal event. */ + ErrorSeverity = (1u<<0) /**< A critical event. */ + }; + /** SOCKS error types used by Tor status event notifications. These are + * emitted in the TorControl::socksError() signal. */ + enum SocksError { + DangerousSocksTypeError, /**< The SOCKS type uses only IP addresses. */ + UnknownSocksProtocolError, /**< Unknown SOCKS protocol type. */ + BadSocksHostnameError /**< Application provided an invalid hostname. */ + }; + /** Reasons that use of the user's current Tor version would be + * discouraged. */ + enum TorVersionStatus { + ObsoleteTorVersion, + UnrecommendedTorVersion, + NewTorVersion }; /** Converts str to a Severity enum value. */ - Severity toSeverity(const QString &str); + Severity severityFromString(const QString &str); /** Converts str to a ConnectionStatusReason enum value. */ - ConnectionStatusReason toConnectionStatusReason(const QString &str); + ConnectionStatusReason connectionStatusReasonFromString(const QString &str); /** Creates a new message using fmt and a severity level of * QtDebugMsg. */ @@ -99,5 +113,9 @@ DebugMessage fatal(const QString &fmt); } +Q_DECLARE_METATYPE(tc::Severity) +Q_DECLARE_METATYPE(tc::SocksError) +Q_DECLARE_METATYPE(tc::TorVersionStatus) + #endif diff -Nru vidalia-0.1.13/src/torcontrol/torcontrol.cpp vidalia-0.2.8/src/torcontrol/torcontrol.cpp --- vidalia-0.1.13/src/torcontrol/torcontrol.cpp 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/torcontrol.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,1056 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 torcontrol.cpp -** \version $Id: torcontrol.cpp 3777 2009-05-17 04:18:13Z edmanm $ -** \brief Object for interacting with the Tor process and control interface -*/ - -#include -#include -#include -#include "torcontrol.h" - - -/** Default constructor */ -TorControl::TorControl() -{ - /* Create an instance of a connection to Tor's control interface and give - * it an object to use to handle asynchronous events. */ - _controlConn = new ControlConnection(&_torEvents); - QObject::connect(_controlConn, SIGNAL(connected()), - this, SLOT(onConnected())); - QObject::connect(_controlConn, SIGNAL(connectFailed(QString)), - this, SLOT(onConnectFailed(QString))); - QObject::connect(_controlConn, SIGNAL(disconnected()), - this, SLOT(onDisconnected())); - - /* Create an object used to start and stop a Tor process. */ - _torProcess = new TorProcess(this); - QObject::connect(_torProcess, SIGNAL(started()), - this, SLOT(onStarted())); - QObject::connect(_torProcess, SIGNAL(finished(int, QProcess::ExitStatus)), - this, SLOT(onStopped(int, QProcess::ExitStatus))); - QObject::connect(_torProcess, SIGNAL(startFailed(QString)), - this, SLOT(onStartFailed(QString))); - QObject::connect(_torProcess, SIGNAL(log(QString, QString)), - this, SLOT(onLogStdout(QString, QString))); - -#if defined(Q_OS_WIN32) - _torService = new TorService(this); - QObject::connect(_torService, SIGNAL(started()), this, SLOT(onStarted())); - QObject::connect(_torService, SIGNAL(finished(int, QProcess::ExitStatus)), - this, SLOT(onStopped(int, QProcess::ExitStatus))); - QObject::connect(_torService, SIGNAL(startFailed(QString)), - this, SLOT(onStartFailed(QString))); -#endif -} - -/** Default destructor */ -TorControl::~TorControl() -{ - /* Disconnect the control socket */ - if (isConnected()) { - disconnect(); - } - /* If we started our own Tor, stop it now */ - if (isVidaliaRunningTor()) { - stop(); - } - delete _controlConn; -} - -/** Start the Tor process using the executable tor and the list of - * arguments in args. */ -void -TorControl::start(const QString &tor, const QStringList &args) -{ - if (isRunning()) { - emit started(); - } else { -#if defined(Q_OS_WIN32) - /* If the Tor service is installed, run that. Otherwise, start a new - * Tor process. */ - if (TorService::isSupported() && _torService->isInstalled()) - _torService->start(); - else - _torProcess->start(expand_filename(tor), args); -#else - /* Start a new Tor process */ - _torProcess->start(expand_filename(tor), args); -#endif - } -} - -/** Emits a signal that the Tor process started */ -void -TorControl::onStarted() -{ - emit started(); -} - -/** Emits a signal that the Tor process failed to start and includes an error - * message (hopefully) indicating why. */ -void -TorControl::onStartFailed(QString errmsg) -{ - emit startFailed(errmsg); -} - -/** Stop the Tor process. */ -bool -TorControl::stop(QString *errmsg) -{ - bool rc = false; - if (_controlConn->isConnected()) - rc = signal(TorSignal::Halt, errmsg); - if (!rc) - rc = _torProcess->stop(errmsg); - return rc; -} - -/** Emits a signal that the Tor process stopped */ -void -TorControl::onStopped(int exitCode, QProcess::ExitStatus exitStatus) -{ - if (_controlConn->status() == ControlConnection::Connecting) - _controlConn->cancelConnect(); - - emit stopped(); - emit stopped(exitCode, exitStatus); -} - -/** Detects if the Tor process is running under Vidalia. Returns true if - * Vidalia owns the Tor process, or false if it was an independent Tor. */ -bool -TorControl::isVidaliaRunningTor() -{ - return (_torProcess->state() != QProcess::NotRunning); -} - -/** Detect if the Tor process is running. */ -bool -TorControl::isRunning() -{ - return (_torProcess->state() != QProcess::NotRunning - || _controlConn->isConnected()); -} - -/** Called when Tor has printed a log message to stdout. */ -void -TorControl::onLogStdout(QString severity, QString message) -{ - LogEvent::Severity s = LogEvent::toSeverity(severity); - _torEvents.dispatch(TorEvents::toTorEvent(s), new LogEvent(s, message)); -} - -/** Connect to Tor's control port. The control port to use is determined by - * Vidalia's configuration file. */ -void -TorControl::connect(const QHostAddress &address, quint16 port) -{ - _controlConn->connect(address, port); -} - -/** Emits a signal that the control socket successfully established a - * connection to Tor. */ -void -TorControl::onConnected() -{ - /* Let interested parties know that the control socket connected */ - emit connected(); -} - -/** Emits a signal that the control connection to Tor failed. */ -void -TorControl::onConnectFailed(QString errmsg) -{ - emit connectFailed(errmsg); -} - -/** Disconnect from Tor's control port */ -void -TorControl::disconnect() -{ - if (isConnected()) - _controlConn->disconnect(); -} - -/** Emits a signal that the control socket disconnected from Tor */ -void -TorControl::onDisconnected() -{ - if (_torProcess) { - /* If we're running a Tor process, then start reading logs from stdout - * again, in case our control connection just died but Tor is still - * running. In this case, there may be relevant information in the logs. */ - _torProcess->openStdout(); - } - /* Tor isn't running, so it has no version */ - _torVersion = QString(); - - /* Let interested parties know we lost our control connection */ - emit disconnected(); -} - -/** Check if the control socket is connected */ -bool -TorControl::isConnected() -{ - return _controlConn->isConnected(); -} - -/** Send a message to Tor and reads the response. If Vidalia was unable to - * send the command to Tor or read its response, false is returned. If the - * response was read and the status code is not 250 OK, false is also - * returned. */ -bool -TorControl::send(ControlCommand cmd, ControlReply &reply, QString *errmsg) -{ - if (_controlConn->send(cmd, reply, errmsg)) { - if (reply.getStatus() == "250") { - return true; - } - if (errmsg) { - *errmsg = reply.getMessage(); - } - } - return false; -} - -/** Sends a message to Tor and discards the response. */ -bool -TorControl::send(ControlCommand cmd, QString *errmsg) -{ - ControlReply reply; - return send(cmd, reply, errmsg); -} - -/** Sends an authentication cookie to Tor. The syntax is: - * - * "AUTHENTICATE" SP 1*HEXDIG CRLF - */ -bool -TorControl::authenticate(const QByteArray cookie, QString *errmsg) -{ - ControlCommand cmd("AUTHENTICATE", base16_encode(cookie)); - ControlReply reply; - QString str; - - if (!send(cmd, reply, &str)) { - emit authenticationFailed(str); - return err(errmsg, str); - } - onAuthenticated(); - return true; -} - -/** Sends an authentication password to Tor. The syntax is: - * - * "AUTHENTICATE" SP QuotedString CRLF - */ -bool -TorControl::authenticate(const QString password, QString *errmsg) -{ - ControlCommand cmd("AUTHENTICATE", QString("%1") - .arg(string_escape(password))); - ControlReply reply; - QString str; - - if (!send(cmd, reply, &str)) { - emit authenticationFailed(str); - return err(errmsg, str); - } - onAuthenticated(); - return true; -} - -/** Called when the controller has successfully authenticated to Tor. */ -void -TorControl::onAuthenticated() -{ - /* The version of Tor isn't going to change while we're connected to it, so - * save it for later. */ - getInfo("version", _torVersion); - /* We want to use verbose names in events and GETINFO results. */ - useFeature("VERBOSE_NAMES"); - - emit authenticated(); -} - -/** Sends a PROTOCOLINFO command to Tor and parses the response. */ -ProtocolInfo -TorControl::protocolInfo(QString *errmsg) -{ - ControlCommand cmd("PROTOCOLINFO", "1"); - ControlReply reply; - ProtocolInfo pi; - QString msg, topic; - QHash keyvals; - int idx; - bool ok; - - if (!send(cmd, reply, errmsg)) - return ProtocolInfo(); - - foreach (ReplyLine line, reply.getLines()) { - if (line.getStatus() != "250") - continue; - - msg = line.getMessage().trimmed(); - idx = msg.indexOf(" "); - topic = msg.mid(0, idx).toUpper(); - - if (idx > 0) { - keyvals = string_parse_keyvals(msg.mid(idx+1), &ok); - if (!ok) - continue; /* Ignore malformed lines */ - } else { - keyvals = QHash(); - } - - if (topic == "AUTH") { - if (keyvals.contains("METHODS")) - pi.setAuthMethods(keyvals.value("METHODS")); - if (keyvals.contains("COOKIEFILE")) - pi.setCookieAuthFile(keyvals.value("COOKIEFILE")); - } else if (topic == "VERSION") { - if (keyvals.contains("Tor")) - pi.setTorVersion(keyvals.value("Tor")); - } - } - return pi; -} - -/** Tells Tor the controller wants to enable feature via the - * USEFEATURE control command. Returns true if the given feature was - * successfully enabled. */ -bool -TorControl::useFeature(const QString &feature, QString *errmsg) -{ - ControlCommand cmd("USEFEATURE", feature); - return send(cmd, errmsg); -} - -BootstrapStatus -TorControl::bootstrapStatus(QString *errmsg) -{ - QString str = getInfo("status/bootstrap-phase").toString(); - if (!str.isEmpty()) { - tc::Severity severity = tc::toSeverity(str.section(' ', 0, 0)); - QHash args = string_parse_keyvals(str); - return BootstrapStatus(severity, - BootstrapStatus::statusFromString(args.value("TAG")), - args.value("PROGRESS").toInt(), - args.value("SUMMARY"), - args.value("WARNING"), - tc::toConnectionStatusReason(args.value("REASON")), - BootstrapStatus::actionFromString( - args.value("RECOMMENDATION"))); - } - return BootstrapStatus(); -} - -/** Returns true if Tor either has an open circuit or (on Tor >= - * 0.2.0.1-alpha) has previously decided it's able to establish a circuit. */ -bool -TorControl::circuitEstablished() -{ - /* If Tor is recent enough, we can 'getinfo status/circuit-established' to - * see if Tor has an open circuit */ - if (getTorVersion() >= 0x020001) { - QString tmp; - if (getInfo("status/circuit-established", tmp)) - return (tmp == "1"); - } - - /* Either Tor was too old or our getinfo failed, so try to get a list of all - * circuits and check their statuses. */ - CircuitList circs = getCircuits(); - foreach (Circuit circ, circs) { - if (circ.status() == Circuit::Built) - return true; - } - return false; -} - -/** Sends a GETINFO message to Tor based on the given map of keyvals. The - * syntax is: - * - * "GETINFO" 1*(SP keyword) CRLF - */ -bool -TorControl::getInfo(QHash &map, QString *errmsg) -{ - ControlCommand cmd("GETINFO"); - ControlReply reply; - - /* Add the keys as arguments to the GETINFO message */ - foreach (QString key, map.keys()) { - cmd.addArgument(key); - } - - /* Ask Tor for the specified info values */ - if (send(cmd, reply, errmsg)) { - /* Parse the response for the returned values */ - foreach (ReplyLine line, reply.getLines()) { - /* Split the "key=val" line and map them */ - QStringList keyval = line.getMessage().split("="); - if (keyval.size() == 2) { - map.insert(keyval.at(0), keyval.at(1)); - } - } - return true; - } - return false; -} - -/** Sends a GETINFO message to Tor using the given list of keys and - * returns a QVariantMap containing the specified keys and their values as - * returned by Tor. Returns a default constructed QVariantMap on failure. */ -QVariantMap -TorControl::getInfo(const QStringList &keys, QString *errmsg) -{ - ControlCommand cmd("GETINFO"); - ControlReply reply; - QVariantMap infoMap; - - cmd.addArguments(keys); - if (!send(cmd, reply, errmsg)) - return QVariantMap(); - - foreach (ReplyLine line, reply.getLines()) { - QString msg = line.getMessage(); - int index = msg.indexOf("="); - QString key = msg.mid(0, index); - QStringList val; - - if (index > 0 && index < msg.length()-1) - val << msg.mid(index+1); - if (line.hasData()) - val << line.getData(); - - if (infoMap.contains(key)) { - QStringList values = infoMap.value(key).toStringList(); - values << val; - infoMap.insert(key, values); - } else { - infoMap.insert(key, val); - } - } - return infoMap; -} - -/** Sends a GETINFO message to Tor with a single key and returns a - * QVariant containing the value returned by Tor. Returns a default - * constructed QVariant on failure. */ -QVariant -TorControl::getInfo(const QString &key, QString *errmsg) -{ - QVariantMap map = getInfo(QStringList() << key, errmsg); - return map.value(key); -} - -/** Overloaded method to send a GETINFO command for a single info value */ -bool -TorControl::getInfo(QString key, QString &val, QString *errmsg) -{ - QHash map; - map.insert(key, ""); - - if (getInfo(map, errmsg)) { - val = map.value(key); - return true; - } - return false; -} - -/** Sends a signal to Tor */ -bool -TorControl::signal(TorSignal::Signal sig, QString *errmsg) -{ - ControlCommand cmd("SIGNAL"); - cmd.addArgument(TorSignal::toString(sig)); - - if (sig == TorSignal::Shutdown || sig == TorSignal::Halt) { - /* Tor closes the connection before giving us a response to any commands - * asking it to stop running, so don't try to get a response. */ - return _controlConn->send(cmd, errmsg); - } - return send(cmd, errmsg); -} - -/** Returns an address on which Tor is listening for application - * requests. If none are available, a null QHostAddress is returned. */ -QHostAddress -TorControl::getSocksAddress(QString *errmsg) -{ - QHostAddress socksAddr; - - /* If SocksPort is 0, then Tor is not accepting any application requests. */ - if (getSocksPort() == 0) { - return QHostAddress::Null; - } - - /* Get a list of SocksListenAddress lines and return the first valid IP - * address parsed from the list. */ - QStringList addrList = getSocksAddressList(errmsg); - foreach (QString addr, addrList) { - addr = addr.mid(0, addr.indexOf(":")); - if (socksAddr.setAddress(addr)) { - return socksAddr; - } - } - /* Otherwise Tor is listening on its default 127.0.0.1 */ - return QHostAddress::LocalHost; -} - -/** Returns a (possibly empty) list of all currently configured - * SocksListenAddress entries. */ -QStringList -TorControl::getSocksAddressList(QString *errmsg) -{ - QStringList addrList; - if (getConf("SocksListenAddress", addrList, errmsg)) { - return addrList; - } - return QStringList(); -} - -/** Returns a valid SOCKS port for Tor, or 0 if Tor is not accepting - * application requests. */ -quint16 -TorControl::getSocksPort(QString *errmsg) -{ - QList portList = getSocksPortList(errmsg); - if (portList.size() > 0) { - return portList.at(0); - } - return 0; -} - -/** Returns a list of all currently configured SOCKS ports. If Tor is not - * accepting any application connections, an empty list will be returned. */ -QList -TorControl::getSocksPortList(QString *errmsg) -{ - bool valid; - quint16 port, socksPort; - QString portString; - QList portList; - - /* Get the value of the SocksPort configuration variable */ - if (getConf("SocksPort", portString, errmsg)) { - socksPort = (quint16)portString.toUInt(&valid); - if (valid) { - if (socksPort == 0) { - /* A SocksPort of 0 means Tor is not accepting any application - * connections. */ - return QList(); - } - } - } - /* Get a list of SOCKS ports from SocksListenAddress entries */ - QStringList addrList = getSocksAddressList(errmsg); - foreach (QString addr, addrList) { - if (addr.contains(":")) { - portString = addr.mid(addr.indexOf(":")+1); - port = (quint16)portString.toUInt(&valid); - if (valid) { - portList << port; - } - } - } - /* If there were no SocksListenAddress entries, or one or more of them did - * not specify a port, then add the value of SocksPort, too */ - if (!portList.size() || (portList.size() != addrList.size())) { - portList << socksPort; - } - return portList; -} - -/** Reeturns Tor's version as a string. */ -QString -TorControl::getTorVersionString() -{ - return _torVersion; -} - -/** Returns Tor's version as a numeric value. Note that this discards any - * version status flag, such as "-alpha" or "-rc". */ -quint32 -TorControl::getTorVersion() -{ - static QString versionString; - static quint32 version = 0; - quint8 major, minor, micro, patch; - - /* Only recompute the version number if the version string changed */ - if (versionString == _torVersion) - return version; - versionString = _torVersion; - - /* Split the version string at either "." or "-" characters */ - QStringList parts = versionString.split(QRegExp("\\.|-|\\ ")); - if (parts.size() >= 4) { - major = (quint8)parts.at(0).toUInt(); - minor = (quint8)parts.at(1).toUInt(); - micro = (quint8)parts.at(2).toUInt(); - patch = (quint8)parts.at(3).toUInt(); - version = ((major << 24) | (minor << 16) | (micro << 8) | patch); - } else { - /* Couldn't parse the version string */ - version = 0; - } - return version; -} - -/** Sets an event and its handler. If add is true, then the event is added, - * otherwise it is removed. If set is true, then the given event will be - * registered with Tor. */ -bool -TorControl::setEvent(TorEvents::TorEvent e, QObject *obj, - bool add, bool set, QString *errmsg) -{ - if (add) { - _torEvents.add(e, obj); - } else { - _torEvents.remove(e, obj); - } - if (set && isConnected()) { - return setEvents(errmsg); - } - return true; -} - -/** Registers for a set of logging events according to the given filter. If - * the control socket is currently connected, this method will try to register - * the log events with Tor, otherwise it will simply return true. */ -bool -TorControl::setLogEvents(uint filter, QObject *obj, QString *errmsg) -{ - setEvent(TorEvents::LogError , obj, filter & LogEvent::Error , false); - setEvent(TorEvents::LogWarn , obj, filter & LogEvent::Warn , false); - setEvent(TorEvents::LogNotice, obj, filter & LogEvent::Notice, false); - setEvent(TorEvents::LogInfo , obj, filter & LogEvent::Info , false); - setEvent(TorEvents::LogDebug , obj, filter & LogEvent::Debug , false); - - if (isConnected()) { - bool rc = setEvents(errmsg); - if (rc && _torProcess) - /* The control socket is connected and the request for log events from - * the control port was successful, so we can stop reading from stdout. */ - _torProcess->closeStdout(); - return rc; - } - return true; -} - -/** Register for the events currently in the event list */ -bool -TorControl::setEvents(QString *errmsg) -{ - ControlCommand cmd("SETEVENTS"); - quint32 torVersion = getTorVersion(); - - /* Add each event to the argument list */ - foreach (TorEvents::TorEvent e, _torEvents.eventList()) { - if (torVersion < 0x010203 - && (e == TorEvents::GeneralStatus - || e == TorEvents::ClientStatus - || e == TorEvents::ServerStatus)) { - /* Tor < 0.1.2.3-alpha does not support STATUS_GENERAL, STATUS_CLIENT - * and STATUS_SERVER events. */ - continue; - } - cmd.addArgument(TorEvents::toString(e)); - } - return send(cmd, errmsg); -} - -/** Sets each configuration key in map to the value associated - * with its key. */ -bool -TorControl::setConf(QHash map, QString *errmsg) -{ - ControlCommand cmd("SETCONF"); - - /* Add each keyvalue to the argument list */ - foreach (QString key, map.uniqueKeys()) { - foreach (QString value, map.values(key)) { - if (value.length() > 0) - cmd.addArgument(key + "=" + string_escape(value)); - else - cmd.addArgument(key); - } - } - return send(cmd, errmsg); -} - -/** Sets a single configuration key to the given value. */ -bool -TorControl::setConf(QString key, QString value, QString *errmsg) -{ - QHash map; - map.insert(key, value); - return setConf(map, errmsg); -} - -/** Sets a single configuration string that is formatted .*/ -bool -TorControl::setConf(QString keyAndValue, QString *errmsg) -{ - QHash map; - map.insert(keyAndValue, ""); - return setConf(map, errmsg); -} - -/** Gets values for a set of configuration keys, each of which has a single - * value. */ -bool -TorControl::getConf(QHash &map, QString *errmsg) -{ - QHash multiMap; - foreach (QString key, map.keys()) { - multiMap.insert(key, QStringList()); - } - if (getConf(multiMap, errmsg)) { - foreach (QString key, multiMap.keys()) { - if (map.contains(key)) { - map.insert(key, multiMap.value(key).join("\n")); - } - } - } - return false; -} - -/** Gets a set of configuration keyvalues and stores them in map. */ -bool -TorControl::getConf(QHash &map, QString *errmsg) -{ - ControlCommand cmd("GETCONF"); - ControlReply reply; - QStringList confValue; - QString confKey; - - /* Add the keys as arguments to the GETINFO message */ - foreach (QString key, map.keys()) { - cmd.addArgument(key); - } - - /* Ask Tor for the specified info values */ - if (send(cmd, reply, errmsg)) { - /* Parse the response for the returned values */ - foreach (ReplyLine line, reply.getLines()) { - /* Split the "key=val" line and map them */ - QStringList keyval = line.getMessage().split("="); - if (keyval.size() == 2) { - confKey = keyval.at(0); - - if (map.contains(confKey)) { - /* This configuration key has multiple values, so add this one to - * the list. */ - confValue = map.value(confKey); - } - confValue << keyval.at(1); - map.insert(keyval.at(0), confValue); - } - } - return true; - } - return false; -} - -/** Gets a single configuration value for key. */ -bool -TorControl::getConf(QString key, QString &value, QString *errmsg) -{ - QStringList confValues; - if (getConf(key, confValues, errmsg)) { - value = confValues.join("\n"); - return true; - } - return false; -} - -/** Gets a list of configuration values for key. */ -bool -TorControl::getConf(QString key, QStringList &value, QString *errmsg) -{ - QHash map; - map.insert(key, QStringList()); - - if (getConf(map, errmsg)) { - value = map.value(key); - return true; - } - return false; -} - -/** Sends a GETICONF message to Tor using the given list of keys and - * returns a QVariantMap containing the specified keys and their values as - * returned by Tor. Returns a default constructed QVariantMap on failure. */ -QVariantMap -TorControl::getConf(const QStringList &keys, QString *errmsg) -{ - ControlCommand cmd("GETCONF"); - ControlReply reply; - QVariantMap confMap; - - cmd.addArguments(keys); - if (!send(cmd, reply, errmsg)) - return QVariantMap(); - - foreach (ReplyLine line, reply.getLines()) { - QString msg = line.getMessage(); - int index = msg.indexOf("="); - QString key = msg.mid(0, index); - QString val; - - if (index > 0 && index < msg.length()-1) - val = msg.mid(index+1); - - if (confMap.contains(key)) { - QStringList values = confMap.value(key).toStringList(); - values << val; - confMap.insert(key, values); - } else { - confMap.insert(key, val); - } - } - return confMap; -} - -/** Sends a GETCONF message to Tor with a single key and returns a - * QVariant containing the value returned by Tor. Returns a default - * constructed QVariant on failure. */ -QVariant -TorControl::getConf(const QString &key, QString *errmsg) -{ - QVariantMap map = getConf(QStringList() << key, errmsg); - return map.value(key); -} - -/** Sends a GETCONF message to Tor with the single key and returns a QString - * containing the value returned by Tor */ -QString -TorControl::getHiddenServiceConf(const QString &key, QString *errmsg) -{ - ControlCommand cmd("GETCONF"); - ControlReply reply; - QVariantMap confMap; - - cmd.addArgument(key); - if (!send(cmd, reply, errmsg)) - return ""; - - return reply.toString(); -} - -/** Asks Tor to save the current configuration to its torrc. */ -bool -TorControl::saveConf(QString *errmsg) -{ - ControlCommand cmd("SAVECONF"); - return send(cmd, errmsg); -} - -/** Tells Tor to reset the given configuration keys back to defaults. */ -bool -TorControl::resetConf(QStringList keys, QString *errmsg) -{ - ControlCommand cmd("RESETCONF"); - - /* Add each key to the argument list */ - foreach (QString key, keys) { - cmd.addArgument(key); - } - return send(cmd, errmsg); -} - -/** Tells Tor to reset a single given configuration key back to its default - * value. */ -bool -TorControl::resetConf(QString key, QString *errmsg) -{ - return resetConf(QStringList() << key, errmsg); -} - -/** Returns the descriptor for the router whose fingerprint matches - * id. If id is invalid or the router's descriptor cannot - * be parsed, then an invalid RouterDescriptor is returned. */ -RouterDescriptor -TorControl::getRouterDescriptor(const QString &id, QString *errmsg) -{ - QStringList descriptor = getInfo("desc/id/" + id, errmsg).toStringList(); - return RouterDescriptor(descriptor); -} - -/** Returns the status of the router whose fingerprint matches id. If - * id is invalid or the router's status cannot be parsed, then an - * invalid RouterStatus is returned. */ -RouterStatus -TorControl::getRouterStatus(const QString &id, QString *errmsg) -{ - QStringList status = getInfo("ns/id/" + id, errmsg).toStringList(); - return RouterStatus(status); -} - -/** Returns a RouterStatus object for every known router in the network. If - * the network status document cannot be parsed, then an empty NetworkStatus - * is returned. */ -NetworkStatus -TorControl::getNetworkStatus(QString *errmsg) -{ - QStringList networkStatusLines = getInfo("ns/all", errmsg).toStringList(); - QList networkStatus; - int len = networkStatusLines.size(); - int i = 0; - - while (i < len) { - /* Extract the "r", "s", and whatever other status lines */ - QStringList routerStatusLines; - do { - routerStatusLines << networkStatusLines.at(i); - } while (++i < len && ! networkStatusLines.at(i).startsWith("r ")); - - /* Create a new RouterStatus object and add it to the network status, if - * it's valid. */ - RouterStatus routerStatus(routerStatusLines); - if (routerStatus.isValid()) - networkStatus << routerStatus; - } - return networkStatus; -} - -/** Returns the annotations for the router whose fingerprint matches - * id. If id is invalid or the router's annotations cannot be - * parsed, then an empty DescriptorAnnotations is returned and errmsg - * is set if it's not NULL. (Tor >= 0.2.0.13-alpha only) */ -DescriptorAnnotations -TorControl::getDescriptorAnnotations(const QString &id, QString *errmsg) -{ - QStringList lines = getInfo("desc-annotations/id/"+id, errmsg).toStringList(); - DescriptorAnnotations annotations; - QString key, value; - - foreach (QString line, lines) { - int idx = line.indexOf(" "); - - /* Extract the annotation key */ - key = line.mid(0, idx); - if (key.startsWith("@")) - key = key.remove(0, 1); - - /* Extract the annotation value (if present) */ - if (idx > 0 && idx < line.length()-1) - annotations.insert(key, line.mid(idx + 1).trimmed()); - else - annotations.insert(key, QString()); - } - return annotations; -} - -/** Gets a list of current circuits. */ -QList -TorControl::getCircuits(QString *errmsg) -{ - ControlCommand cmd("GETINFO", "circuit-status"); - ControlReply reply; - CircuitList circuits; - - if (!send(cmd, reply, errmsg)) - return CircuitList(); - - /* The rest of the circuits just come as data, one per line */ - foreach(QString line, reply.getData()) { - Circuit circ(line); - if (circ.isValid()) - circuits << circ; - } - return circuits; -} - -/** Closes the circuit specified by circId. If ifUnused is - * true, then the circuit will not be closed unless it is unused. */ -bool -TorControl::closeCircuit(const CircuitId &circId, bool ifUnused, QString *errmsg) -{ - ControlCommand cmd("CLOSECIRCUIT", circId); - if (ifUnused) { - cmd.addArgument("IfUnused"); - } - return send(cmd, errmsg); -} - -/** Gets a list of current streams. */ -QList -TorControl::getStreams(QString *errmsg) -{ - ControlCommand cmd("GETINFO", "stream-status"); - ControlReply reply; - QList streams; - Stream s; - - if (send(cmd, reply, errmsg)) { - /* Sometimes there is a stream on the first message line */ - QString msg = reply.getMessage(); - s = Stream::fromString(msg.mid(msg.indexOf("=")+1)); - if (s.isValid()) - streams << s; - - /* The rest of the streams just come as data, one per line */ - foreach (QString line, reply.getData()) { - s = Stream::fromString(line); - if (s.isValid()) - streams << s; - } - } - return streams; -} - -/** Closes the stream specified by streamId. */ -bool -TorControl::closeStream(const StreamId &streamId, QString *errmsg) -{ - ControlCommand cmd("CLOSESTREAM", streamId); - cmd.addArgument("1"); /* 1 == REASON_MISC (tor-spec.txt) */ - return send(cmd, errmsg); -} - - /** Gets a list of address mappings of the type specified by type - * (defaults to AddressMapAll. */ -AddressMap -TorControl::getAddressMap(AddressMap::AddressMapType type, QString *errmsg) -{ - AddressMap addressMap; - QStringList entries; - - switch (type) { - case AddressMap::AddressMapConfig: - entries = getInfo("address-mappings/config").toStringList(); - break; - case AddressMap::AddressMapCache: - entries = getInfo("address-mappings/cache").toStringList(); - break; - case AddressMap::AddressMapControl: - entries = getInfo("address-mappings/control").toStringList(); - break; - default: - entries = getInfo("address-mappings/all").toStringList(); - } - - foreach (QString entry, entries) { - addressMap.add(entry); - } - return addressMap; -} - diff -Nru vidalia-0.1.13/src/torcontrol/TorControl.cpp vidalia-0.2.8/src/torcontrol/TorControl.cpp --- vidalia-0.1.13/src/torcontrol/TorControl.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/TorControl.cpp 2009-09-01 14:54:27.000000000 +0100 @@ -0,0 +1,1053 @@ +/* +** 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.vidalia-project.net/. 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 TorControl.cpp +** \version $Id: TorControl.cpp 4100 2009-09-01 13:54:27Z edmanm $ +** \brief Object for interacting with the Tor process and control interface +*/ + +#include "TorControl.h" +#include "RouterDescriptor.h" +#include "ProtocolInfo.h" +#include "RouterStatus.h" +#include "file.h" +#include "stringutil.h" + +#include +#include + + +/** Default constructor */ +TorControl::TorControl() +{ +#define RELAY_SIGNAL(src, sig) \ + QObject::connect((src), (sig), this, (sig)) + + /* Create a TorEvents object to receive and parse asynchronous events + * from Tor's control port, and relay them as external signals from + * this TorControl object. */ + _eventHandler = new TorEvents(this); + RELAY_SIGNAL(_eventHandler, SIGNAL(circuitEstablished())); + RELAY_SIGNAL(_eventHandler, SIGNAL(dangerousTorVersion(tc::TorVersionStatus, + QString, QStringList))); + RELAY_SIGNAL(_eventHandler, SIGNAL(addressMapped(QString,QString,QDateTime))); + RELAY_SIGNAL(_eventHandler, SIGNAL(bandwidthUpdate(quint64, quint64))); + RELAY_SIGNAL(_eventHandler, SIGNAL(circuitStatusChanged(Circuit))); + RELAY_SIGNAL(_eventHandler, SIGNAL(streamStatusChanged(Stream))); + RELAY_SIGNAL(_eventHandler, SIGNAL(newDescriptors(QStringList))); + RELAY_SIGNAL(_eventHandler, SIGNAL(logMessage(tc::Severity, QString))); + RELAY_SIGNAL(_eventHandler, SIGNAL(dangerousPort(quint16, bool))); + RELAY_SIGNAL(_eventHandler, SIGNAL(socksError(tc::SocksError, QString))); + RELAY_SIGNAL(_eventHandler, SIGNAL(bootstrapStatusChanged(BootstrapStatus))); + RELAY_SIGNAL(_eventHandler, SIGNAL(clockSkewed(int, QString))); + RELAY_SIGNAL(_eventHandler, SIGNAL(bug(QString))); + RELAY_SIGNAL(_eventHandler, SIGNAL(dnsHijacked())); + RELAY_SIGNAL(_eventHandler, SIGNAL(dnsUseless())); + RELAY_SIGNAL(_eventHandler, + SIGNAL(externalAddressChanged(QHostAddress, QString))); + RELAY_SIGNAL(_eventHandler, + SIGNAL(checkingOrPortReachability(QHostAddress, quint16))); + RELAY_SIGNAL(_eventHandler, + SIGNAL(orPortReachabilityFinished(QHostAddress,quint16,bool))); + RELAY_SIGNAL(_eventHandler, + SIGNAL(checkingDirPortReachability(QHostAddress, quint16))); + RELAY_SIGNAL(_eventHandler, + SIGNAL(dirPortReachabilityFinished(QHostAddress,quint16,bool))); + RELAY_SIGNAL(_eventHandler, + SIGNAL(serverDescriptorRejected(QHostAddress, quint16, QString))); + RELAY_SIGNAL(_eventHandler, + SIGNAL(serverDescriptorAccepted(QHostAddress, quint16))); + RELAY_SIGNAL(_eventHandler, SIGNAL(serverDescriptorAccepted())); + + /* Create an instance of a connection to Tor's control interface and give + * it an object to use to handle asynchronous events. */ + _controlConn = new ControlConnection(_eventHandler); + RELAY_SIGNAL(_controlConn, SIGNAL(connected())); + RELAY_SIGNAL(_controlConn, SIGNAL(connectFailed(QString))); + QObject::connect(_controlConn, SIGNAL(disconnected()), + this, SLOT(onDisconnected())); + + /* Create an object used to start and stop a Tor process. */ + _torProcess = new TorProcess(this); + RELAY_SIGNAL(_torProcess, SIGNAL(started())); + RELAY_SIGNAL(_torProcess, SIGNAL(startFailed(QString))); + QObject::connect(_torProcess, SIGNAL(finished(int, QProcess::ExitStatus)), + this, SLOT(onStopped(int, QProcess::ExitStatus))); + QObject::connect(_torProcess, SIGNAL(log(QString, QString)), + this, SLOT(onLogStdout(QString, QString))); + +#if defined(Q_OS_WIN32) + _torService = new TorService(this); + RELAY_SIGNAL(_torService, SIGNAL(started())); + RELAY_SIGNAL(_torService, SIGNAL(startFailed(QString))); + QObject::connect(_torService, SIGNAL(finished(int, QProcess::ExitStatus)), + this, SLOT(onStopped(int, QProcess::ExitStatus))); +#endif +#undef RELAY_SIGNAL +} + +/** Default destructor */ +TorControl::~TorControl() +{ + /* Disconnect the control socket */ + if (isConnected()) { + disconnect(); + } + /* If we started our own Tor, stop it now */ + if (isVidaliaRunningTor()) { + stop(); + } + delete _controlConn; +} + +/** Start the Tor process using the executable tor and the list of + * arguments in args. */ +void +TorControl::start(const QString &tor, const QStringList &args) +{ + if (isRunning()) { + emit started(); + } else { +#if defined(Q_OS_WIN32) + /* If the Tor service is installed, run that. Otherwise, start a new + * Tor process. */ + if (TorService::isSupported() && _torService->isInstalled()) + _torService->start(); + else + _torProcess->start(expand_filename(tor), args); +#else + /* Start a new Tor process */ + _torProcess->start(expand_filename(tor), args); +#endif + } +} + +/** Stop the Tor process. */ +bool +TorControl::stop(QString *errmsg) +{ + bool rc = false; + if (_controlConn->isConnected()) + rc = signal(TorSignal::Halt, errmsg); + if (!rc) + rc = _torProcess->stop(errmsg); + return rc; +} + +/** Emits a signal that the Tor process stopped */ +void +TorControl::onStopped(int exitCode, QProcess::ExitStatus exitStatus) +{ + if (_controlConn->status() == ControlConnection::Connecting) + _controlConn->cancelConnect(); + + emit stopped(); + emit stopped(exitCode, exitStatus); +} + +/** Detects if the Tor process is running under Vidalia. Returns true if + * Vidalia owns the Tor process, or false if it was an independent Tor. */ +bool +TorControl::isVidaliaRunningTor() +{ + return (_torProcess->state() != QProcess::NotRunning); +} + +/** Detect if the Tor process is running. */ +bool +TorControl::isRunning() +{ + return (_torProcess->state() != QProcess::NotRunning + || _controlConn->isConnected()); +} + +/** Stops reading log messages from the Tor process's stdout. This has no + * effect if isVidaliaRunningTor() is false. */ +void +TorControl::closeTorStdout() +{ + if (_torProcess) + _torProcess->closeStdout(); +} + +/** Called when Tor has printed a log message to stdout. */ +void +TorControl::onLogStdout(const QString &severity, const QString &message) +{ + emit logMessage(tc::severityFromString(severity), message.trimmed()); +} + +/** Connect to Tor's control port. The control port to use is determined by + * Vidalia's configuration file. */ +void +TorControl::connect(const QHostAddress &address, quint16 port) +{ + _controlConn->connect(address, port); +} + +/** Disconnect from Tor's control port */ +void +TorControl::disconnect() +{ + if (isConnected()) + _controlConn->disconnect(); +} + +/** Emits a signal that the control socket disconnected from Tor */ +void +TorControl::onDisconnected() +{ + if (_torProcess) { + /* If we're running a Tor process, then start reading logs from stdout + * again, in case our control connection just died but Tor is still + * running. In this case, there may be relevant information in the logs. */ + _torProcess->openStdout(); + } + /* Tor isn't running, so it has no version */ + _torVersion = QString(); + + /* Let interested parties know we lost our control connection */ + emit disconnected(); +} + +/** Check if the control socket is connected */ +bool +TorControl::isConnected() +{ + return _controlConn->isConnected(); +} + +/** Send a message to Tor and reads the response. If Vidalia was unable to + * send the command to Tor or read its response, false is returned. If the + * response was read and the status code is not 250 OK, false is also + * returned. */ +bool +TorControl::send(ControlCommand cmd, ControlReply &reply, QString *errmsg) +{ + if (_controlConn->send(cmd, reply, errmsg)) { + if (reply.getStatus() == "250") { + return true; + } + if (errmsg) { + *errmsg = reply.getMessage(); + } + } + return false; +} + +/** Sends a message to Tor and discards the response. */ +bool +TorControl::send(ControlCommand cmd, QString *errmsg) +{ + ControlReply reply; + return send(cmd, reply, errmsg); +} + +/** Sends an authentication cookie to Tor. The syntax is: + * + * "AUTHENTICATE" SP 1*HEXDIG CRLF + */ +bool +TorControl::authenticate(const QByteArray cookie, QString *errmsg) +{ + ControlCommand cmd("AUTHENTICATE", base16_encode(cookie)); + ControlReply reply; + QString str; + + if (!send(cmd, reply, &str)) { + emit authenticationFailed(str); + return err(errmsg, str); + } + onAuthenticated(); + return true; +} + +/** Sends an authentication password to Tor. The syntax is: + * + * "AUTHENTICATE" SP QuotedString CRLF + */ +bool +TorControl::authenticate(const QString &password, QString *errmsg) +{ + ControlCommand cmd("AUTHENTICATE", string_escape(password)); + ControlReply reply; + QString str; + + if (!send(cmd, reply, &str)) { + emit authenticationFailed(str); + return err(errmsg, str); + } + onAuthenticated(); + return true; +} + +/** Called when the controller has successfully authenticated to Tor. */ +void +TorControl::onAuthenticated() +{ + /* The version of Tor isn't going to change while we're connected to it, so + * save it for later. */ + getInfo("version", _torVersion); + /* We want to use verbose names in events and GETINFO results. */ + useFeature("VERBOSE_NAMES"); + /* We want to use extended events in all async events */ + useFeature("EXTENDED_EVENTS"); + + emit authenticated(); +} + +/** Sends a PROTOCOLINFO command to Tor and parses the response. */ +ProtocolInfo +TorControl::protocolInfo(QString *errmsg) +{ + ControlCommand cmd("PROTOCOLINFO", "1"); + ControlReply reply; + ProtocolInfo pi; + QString msg, topic; + QHash keyvals; + int idx; + bool ok; + + if (!send(cmd, reply, errmsg)) + return ProtocolInfo(); + + foreach (ReplyLine line, reply.getLines()) { + if (line.getStatus() != "250") + continue; + + msg = line.getMessage().trimmed(); + idx = msg.indexOf(" "); + topic = msg.mid(0, idx).toUpper(); + + if (idx > 0) { + keyvals = string_parse_keyvals(msg.mid(idx+1), &ok); + if (!ok) + continue; /* Ignore malformed lines */ + } else { + keyvals = QHash(); + } + + if (topic == "AUTH") { + if (keyvals.contains("METHODS")) + pi.setAuthMethods(keyvals.value("METHODS")); + if (keyvals.contains("COOKIEFILE")) + pi.setCookieAuthFile(keyvals.value("COOKIEFILE")); + } else if (topic == "VERSION") { + if (keyvals.contains("Tor")) + pi.setTorVersion(keyvals.value("Tor")); + } + } + return pi; +} + +/** Tells Tor the controller wants to enable feature via the + * USEFEATURE control command. Returns true if the given feature was + * successfully enabled. */ +bool +TorControl::useFeature(const QString &feature, QString *errmsg) +{ + ControlCommand cmd("USEFEATURE", feature); + return send(cmd, errmsg); +} + +BootstrapStatus +TorControl::bootstrapStatus(QString *errmsg) +{ + QString str = getInfo("status/bootstrap-phase").toString(); + if (!str.isEmpty()) { + tc::Severity severity = tc::severityFromString(str.section(' ', 0, 0)); + QHash args = string_parse_keyvals(str); + return BootstrapStatus(severity, + BootstrapStatus::statusFromString(args.value("TAG")), + args.value("PROGRESS").toInt(), + args.value("SUMMARY"), + args.value("WARNING"), + tc::connectionStatusReasonFromString(args.value("REASON")), + BootstrapStatus::actionFromString( + args.value("RECOMMENDATION"))); + } + return BootstrapStatus(); +} + +/** Returns true if Tor either has an open circuit or (on Tor >= + * 0.2.0.1-alpha) has previously decided it's able to establish a circuit. */ +bool +TorControl::isCircuitEstablished() +{ + /* If Tor is recent enough, we can 'getinfo status/circuit-established' to + * see if Tor has an open circuit */ + if (getTorVersion() >= 0x020001) { + QString tmp; + if (getInfo("status/circuit-established", tmp)) + return (tmp == "1"); + } + + /* Either Tor was too old or our getinfo failed, so try to get a list of all + * circuits and check their statuses. */ + CircuitList circs = getCircuits(); + foreach (Circuit circ, circs) { + if (circ.status() == Circuit::Built) + return true; + } + return false; +} + +/** Sends a GETINFO message to Tor based on the given map of keyvals. The + * syntax is: + * + * "GETINFO" 1*(SP keyword) CRLF + */ +bool +TorControl::getInfo(QHash &map, QString *errmsg) +{ + ControlCommand cmd("GETINFO"); + ControlReply reply; + + /* Add the keys as arguments to the GETINFO message */ + foreach (QString key, map.keys()) { + cmd.addArgument(key); + } + + /* Ask Tor for the specified info values */ + if (send(cmd, reply, errmsg)) { + /* Parse the response for the returned values */ + foreach (ReplyLine line, reply.getLines()) { + /* Split the "key=val" line and map them */ + QStringList keyval = line.getMessage().split("="); + if (keyval.size() == 2) { + map.insert(keyval.at(0), keyval.at(1)); + } + } + return true; + } + return false; +} + +/** Sends a GETINFO message to Tor using the given list of keys and + * returns a QVariantMap containing the specified keys and their values as + * returned by Tor. Returns a default constructed QVariantMap on failure. */ +QVariantMap +TorControl::getInfo(const QStringList &keys, QString *errmsg) +{ + ControlCommand cmd("GETINFO"); + ControlReply reply; + QVariantMap infoMap; + + cmd.addArguments(keys); + if (!send(cmd, reply, errmsg)) + return QVariantMap(); + + foreach (ReplyLine line, reply.getLines()) { + QString msg = line.getMessage(); + int index = msg.indexOf("="); + QString key = msg.mid(0, index); + QStringList val; + + if (index > 0 && index < msg.length()-1) + val << msg.mid(index+1); + if (line.hasData()) + val << line.getData(); + + if (infoMap.contains(key)) { + QStringList values = infoMap.value(key).toStringList(); + values << val; + infoMap.insert(key, values); + } else { + infoMap.insert(key, val); + } + } + return infoMap; +} + +/** Sends a GETINFO message to Tor with a single key and returns a + * QVariant containing the value returned by Tor. Returns a default + * constructed QVariant on failure. */ +QVariant +TorControl::getInfo(const QString &key, QString *errmsg) +{ + QVariantMap map = getInfo(QStringList() << key, errmsg); + return map.value(key); +} + +/** Overloaded method to send a GETINFO command for a single info value */ +bool +TorControl::getInfo(QString key, QString &val, QString *errmsg) +{ + QHash map; + map.insert(key, ""); + + if (getInfo(map, errmsg)) { + val = map.value(key); + return true; + } + return false; +} + +/** Sends a signal to Tor */ +bool +TorControl::signal(TorSignal::Signal sig, QString *errmsg) +{ + ControlCommand cmd("SIGNAL"); + cmd.addArgument(TorSignal::toString(sig)); + + if (sig == TorSignal::Shutdown || sig == TorSignal::Halt) { + /* Tor closes the connection before giving us a response to any commands + * asking it to stop running, so don't try to get a response. */ + return _controlConn->send(cmd, errmsg); + } + return send(cmd, errmsg); +} + +/** Returns an address on which Tor is listening for application + * requests. If none are available, a null QHostAddress is returned. */ +QHostAddress +TorControl::getSocksAddress(QString *errmsg) +{ + QHostAddress socksAddr; + + /* If SocksPort is 0, then Tor is not accepting any application requests. */ + if (getSocksPort() == 0) { + return QHostAddress::Null; + } + + /* Get a list of SocksListenAddress lines and return the first valid IP + * address parsed from the list. */ + QStringList addrList = getSocksAddressList(errmsg); + foreach (QString addr, addrList) { + addr = addr.mid(0, addr.indexOf(":")); + if (socksAddr.setAddress(addr)) { + return socksAddr; + } + } + /* Otherwise Tor is listening on its default 127.0.0.1 */ + return QHostAddress::LocalHost; +} + +/** Returns a (possibly empty) list of all currently configured + * SocksListenAddress entries. */ +QStringList +TorControl::getSocksAddressList(QString *errmsg) +{ + QStringList addrList; + if (getConf("SocksListenAddress", addrList, errmsg)) { + return addrList; + } + return QStringList(); +} + +/** Returns a valid SOCKS port for Tor, or 0 if Tor is not accepting + * application requests. */ +quint16 +TorControl::getSocksPort(QString *errmsg) +{ + QList portList = getSocksPortList(errmsg); + if (portList.size() > 0) { + return portList.at(0); + } + return 0; +} + +/** Returns a list of all currently configured SOCKS ports. If Tor is not + * accepting any application connections, an empty list will be returned. */ +QList +TorControl::getSocksPortList(QString *errmsg) +{ + bool valid; + quint16 port, socksPort; + QString portString; + QList portList; + + /* Get the value of the SocksPort configuration variable */ + if (getConf("SocksPort", portString, errmsg)) { + socksPort = (quint16)portString.toUInt(&valid); + if (valid) { + if (socksPort == 0) { + /* A SocksPort of 0 means Tor is not accepting any application + * connections. */ + return QList(); + } + } + } + /* Get a list of SOCKS ports from SocksListenAddress entries */ + QStringList addrList = getSocksAddressList(errmsg); + foreach (QString addr, addrList) { + if (addr.contains(":")) { + portString = addr.mid(addr.indexOf(":")+1); + port = (quint16)portString.toUInt(&valid); + if (valid) { + portList << port; + } + } + } + /* If there were no SocksListenAddress entries, or one or more of them did + * not specify a port, then add the value of SocksPort, too */ + if (!portList.size() || (portList.size() != addrList.size())) { + portList << socksPort; + } + return portList; +} + +/** Reeturns Tor's version as a string. */ +QString +TorControl::getTorVersionString() +{ + return _torVersion; +} + +/** Returns Tor's version as a numeric value. Note that this discards any + * version status flag, such as "-alpha" or "-rc". */ +quint32 +TorControl::getTorVersion() +{ + static QString versionString; + static quint32 version = 0; + quint8 major, minor, micro, patch; + + /* Only recompute the version number if the version string changed */ + if (versionString == _torVersion) + return version; + versionString = _torVersion; + + /* Split the version string at either "." or "-" characters */ + QStringList parts = versionString.split(QRegExp("\\.|-|\\ ")); + if (parts.size() >= 4) { + major = (quint8)parts.at(0).toUInt(); + minor = (quint8)parts.at(1).toUInt(); + micro = (quint8)parts.at(2).toUInt(); + patch = (quint8)parts.at(3).toUInt(); + version = ((major << 24) | (minor << 16) | (micro << 8) | patch); + } else { + /* Couldn't parse the version string */ + version = 0; + } + return version; +} + +/** Sets an event and its handler. If add is true, then the event is added, + * otherwise it is removed. If set is true, then the given event will be + * registered with Tor. */ +bool +TorControl::setEvent(TorEvents::Event e, bool add, bool set, QString *errmsg) +{ + _events = (add ? (_events | e) : (_events & ~e)); + if (set && isConnected()) + return setEvents(errmsg); + return true; +} + +/** Register for the events currently in the event list */ +bool +TorControl::setEvents(QString *errmsg) +{ + ControlCommand cmd("SETEVENTS"); + + for (TorEvents::Event e = TorEvents::EVENT_MIN; e <= TorEvents::EVENT_MAX;) { + if (_events & e) + cmd.addArgument(TorEvents::toString(e)); + e = static_cast(e << 1); + } + return send(cmd, errmsg); +} + +/** Sets each configuration key in map to the value associated + * with its key. */ +bool +TorControl::setConf(QHash map, QString *errmsg) +{ + ControlCommand cmd("SETCONF"); + + /* Add each keyvalue to the argument list */ + foreach (QString key, map.uniqueKeys()) { + /* If a key has multiple values (e.g., a QMultiHash), they are stored + * in order from most recently inserted to least recently inserted. + * So, walk the list in reverse so that we append the configuration + * values to the SETCONF command in the same order they were inserted + * into the QHash. */ + QList values = map.values(key); + for (int i = values.size()-1; i >= 0; i--) { + QString value = values.at(i); + if (value.length() > 0) + cmd.addArgument(key + "=" + string_escape(value)); + else + cmd.addArgument(key); + } + } + return send(cmd, errmsg); +} + +/** Sets a single configuration key to the given value. */ +bool +TorControl::setConf(QString key, QString value, QString *errmsg) +{ + QHash map; + map.insert(key, value); + return setConf(map, errmsg); +} + +/** Sets a single configuration string that is formatted .*/ +bool +TorControl::setConf(QString keyAndValue, QString *errmsg) +{ + QHash map; + map.insert(keyAndValue, ""); + return setConf(map, errmsg); +} + +/** Gets values for a set of configuration keys, each of which has a single + * value. */ +bool +TorControl::getConf(QHash &map, QString *errmsg) +{ + QHash multiMap; + foreach (QString key, map.keys()) { + multiMap.insert(key, QStringList()); + } + if (getConf(multiMap, errmsg)) { + foreach (QString key, multiMap.keys()) { + if (map.contains(key)) { + map.insert(key, multiMap.value(key).join("\n")); + } + } + } + return false; +} + +/** Gets a set of configuration keyvalues and stores them in map. */ +bool +TorControl::getConf(QHash &map, QString *errmsg) +{ + ControlCommand cmd("GETCONF"); + ControlReply reply; + QStringList confValue; + QString confKey; + + /* Add the keys as arguments to the GETINFO message */ + foreach (QString key, map.keys()) { + cmd.addArgument(key); + } + + /* Ask Tor for the specified info values */ + if (send(cmd, reply, errmsg)) { + /* Parse the response for the returned values */ + foreach (ReplyLine line, reply.getLines()) { + /* Split the "key=val" line and map them */ + QStringList keyval = line.getMessage().split("="); + if (keyval.size() == 2) { + confKey = keyval.at(0); + + if (map.contains(confKey)) { + /* This configuration key has multiple values, so add this one to + * the list. */ + confValue = map.value(confKey); + } + confValue << keyval.at(1); + map.insert(keyval.at(0), confValue); + } + } + return true; + } + return false; +} + +/** Gets a single configuration value for key. */ +bool +TorControl::getConf(QString key, QString &value, QString *errmsg) +{ + QStringList confValues; + if (getConf(key, confValues, errmsg)) { + value = confValues.join("\n"); + return true; + } + return false; +} + +/** Gets a list of configuration values for key. */ +bool +TorControl::getConf(QString key, QStringList &value, QString *errmsg) +{ + QHash map; + map.insert(key, QStringList()); + + if (getConf(map, errmsg)) { + value = map.value(key); + return true; + } + return false; +} + +/** Sends a GETICONF message to Tor using the given list of keys and + * returns a QVariantMap containing the specified keys and their values as + * returned by Tor. Returns a default constructed QVariantMap on failure. */ +QVariantMap +TorControl::getConf(const QStringList &keys, QString *errmsg) +{ + ControlCommand cmd("GETCONF"); + ControlReply reply; + QVariantMap confMap; + + cmd.addArguments(keys); + if (!send(cmd, reply, errmsg)) + return QVariantMap(); + + foreach (ReplyLine line, reply.getLines()) { + QString msg = line.getMessage(); + int index = msg.indexOf("="); + QString key = msg.mid(0, index); + QString val; + + if (index > 0 && index < msg.length()-1) + val = msg.mid(index+1); + + if (confMap.contains(key)) { + QStringList values = confMap.value(key).toStringList(); + values << val; + confMap.insert(key, values); + } else { + confMap.insert(key, val); + } + } + return confMap; +} + +/** Sends a GETCONF message to Tor with a single key and returns a + * QVariant containing the value returned by Tor. Returns a default + * constructed QVariant on failure. */ +QVariant +TorControl::getConf(const QString &key, QString *errmsg) +{ + QVariantMap map = getConf(QStringList() << key, errmsg); + return map.value(key); +} + +/** Sends a GETCONF message to Tor with the single key and returns a QString + * containing the value returned by Tor */ +QString +TorControl::getHiddenServiceConf(const QString &key, QString *errmsg) +{ + ControlCommand cmd("GETCONF"); + ControlReply reply; + QVariantMap confMap; + + cmd.addArgument(key); + if (!send(cmd, reply, errmsg)) + return ""; + + return reply.toString(); +} + +/** Asks Tor to save the current configuration to its torrc. */ +bool +TorControl::saveConf(QString *errmsg) +{ + ControlCommand cmd("SAVECONF"); + return send(cmd, errmsg); +} + +/** Tells Tor to reset the given configuration keys back to defaults. */ +bool +TorControl::resetConf(QStringList keys, QString *errmsg) +{ + ControlCommand cmd("RESETCONF"); + + /* Add each key to the argument list */ + foreach (QString key, keys) { + cmd.addArgument(key); + } + return send(cmd, errmsg); +} + +/** Tells Tor to reset a single given configuration key back to its default + * value. */ +bool +TorControl::resetConf(QString key, QString *errmsg) +{ + return resetConf(QStringList() << key, errmsg); +} + +/** Returns an unparsed router descriptor for the router whose fingerprint + * matches id. The returned text can later be parsed by the + * RouterDescriptor class. If id is invalid, then an empty + * QStringList is returned. */ +QStringList +TorControl::getRouterDescriptorText(const QString &id, QString *errmsg) +{ + return getInfo("desc/id/" + id, errmsg).toStringList(); +} + +/** Returns the descriptor for the router whose fingerprint matches + * id. If id is invalid or the router's descriptor cannot + * be parsed, then an invalid RouterDescriptor is returned. */ +RouterDescriptor +TorControl::getRouterDescriptor(const QString &id, QString *errmsg) +{ + return RouterDescriptor(getRouterDescriptorText(id, errmsg)); +} + +/** Returns the status of the router whose fingerprint matches id. If + * id is invalid or the router's status cannot be parsed, then an + * invalid RouterStatus is returned. */ +RouterStatus +TorControl::getRouterStatus(const QString &id, QString *errmsg) +{ + QStringList status = getInfo("ns/id/" + id, errmsg).toStringList(); + return RouterStatus(status); +} + +/** Returns a RouterStatus object for every known router in the network. If + * the network status document cannot be parsed, then an empty NetworkStatus + * is returned. */ +NetworkStatus +TorControl::getNetworkStatus(QString *errmsg) +{ + QStringList networkStatusLines = getInfo("ns/all", errmsg).toStringList(); + QList networkStatus; + int len = networkStatusLines.size(); + int i = 0; + + while (i < len) { + /* Extract the "r", "s", and whatever other status lines */ + QStringList routerStatusLines; + do { + routerStatusLines << networkStatusLines.at(i); + } while (++i < len && ! networkStatusLines.at(i).startsWith("r ")); + + /* Create a new RouterStatus object and add it to the network status, if + * it's valid. */ + RouterStatus routerStatus(routerStatusLines); + if (routerStatus.isValid()) + networkStatus << routerStatus; + } + return networkStatus; +} + +/** Returns the annotations for the router whose fingerprint matches + * id. If id is invalid or the router's annotations cannot be + * parsed, then an empty DescriptorAnnotations is returned and errmsg + * is set if it's not NULL. (Tor >= 0.2.0.13-alpha only) */ +DescriptorAnnotations +TorControl::getDescriptorAnnotations(const QString &id, QString *errmsg) +{ + QStringList lines = getInfo("desc-annotations/id/"+id, errmsg).toStringList(); + DescriptorAnnotations annotations; + QString key, value; + + foreach (QString line, lines) { + int idx = line.indexOf(" "); + + /* Extract the annotation key */ + key = line.mid(0, idx); + if (key.startsWith("@")) + key = key.remove(0, 1); + + /* Extract the annotation value (if present) */ + if (idx > 0 && idx < line.length()-1) + annotations.insert(key, line.mid(idx + 1).trimmed()); + else + annotations.insert(key, QString()); + } + return annotations; +} + +/** Gets a list of current circuits. */ +QList +TorControl::getCircuits(QString *errmsg) +{ + ControlCommand cmd("GETINFO", "circuit-status"); + ControlReply reply; + CircuitList circuits; + + if (!send(cmd, reply, errmsg)) + return CircuitList(); + + /* The rest of the circuits just come as data, one per line */ + foreach(QString line, reply.getData()) { + Circuit circ(line); + if (circ.isValid()) + circuits << circ; + } + return circuits; +} + +/** Closes the circuit specified by circId. If ifUnused is + * true, then the circuit will not be closed unless it is unused. */ +bool +TorControl::closeCircuit(const CircuitId &circId, bool ifUnused, QString *errmsg) +{ + ControlCommand cmd("CLOSECIRCUIT", circId); + if (ifUnused) { + cmd.addArgument("IfUnused"); + } + return send(cmd, errmsg); +} + +/** Gets a list of current streams. */ +QList +TorControl::getStreams(QString *errmsg) +{ + ControlCommand cmd("GETINFO", "stream-status"); + ControlReply reply; + QList streams; + Stream s; + + if (send(cmd, reply, errmsg)) { + /* Sometimes there is a stream on the first message line */ + QString msg = reply.getMessage(); + s = Stream::fromString(msg.mid(msg.indexOf("=")+1)); + if (s.isValid()) + streams << s; + + /* The rest of the streams just come as data, one per line */ + foreach (QString line, reply.getData()) { + s = Stream::fromString(line); + if (s.isValid()) + streams << s; + } + } + return streams; +} + +/** Closes the stream specified by streamId. */ +bool +TorControl::closeStream(const StreamId &streamId, QString *errmsg) +{ + ControlCommand cmd("CLOSESTREAM", streamId); + cmd.addArgument("1"); /* 1 == REASON_MISC (tor-spec.txt) */ + return send(cmd, errmsg); +} + + /** Gets a list of address mappings of the type specified by type + * (defaults to AddressMapAll. */ +AddressMap +TorControl::getAddressMap(AddressMap::AddressMapType type, QString *errmsg) +{ + AddressMap addressMap; + QStringList entries; + + switch (type) { + case AddressMap::AddressMapConfig: + entries = getInfo("address-mappings/config").toStringList(); + break; + case AddressMap::AddressMapCache: + entries = getInfo("address-mappings/cache").toStringList(); + break; + case AddressMap::AddressMapControl: + entries = getInfo("address-mappings/control").toStringList(); + break; + default: + entries = getInfo("address-mappings/all").toStringList(); + } + + foreach (QString entry, entries) { + addressMap.add(entry); + } + return addressMap; +} + diff -Nru vidalia-0.1.13/src/torcontrol/torcontrol.h vidalia-0.2.8/src/torcontrol/torcontrol.h --- vidalia-0.1.13/src/torcontrol/torcontrol.h 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/torcontrol.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,262 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 torcontrol.h -** \version $Id: torcontrol.h 2977 2008-08-17 01:28:25Z edmanm $ -** \brief Object for interacting with the Tor process and control interface -*/ - -#ifndef _TORCONTROL_H -#define _TORCONTROL_H - -#include -#include -#include -#include -#include - -#include "controlconnection.h" -#include "torprocess.h" -#include "torevents.h" -#include "torsignal.h" -#include "routerdescriptor.h" -#include "routerstatus.h" -#include "bootstrapstatus.h" -#include "addressmap.h" -#include "protocolinfo.h" - -#if defined(Q_OS_WIN32) -#include "torservice.h" -#endif - - -/** DescriptorAnnotations stores a map of annotation keys to (possibly empty) - * annotation values. */ -typedef QHash DescriptorAnnotations; - - -class TorControl : public QObject -{ - Q_OBJECT - -public: - /** Default constructor */ - TorControl(); - /** Default destructor */ - ~TorControl(); - - /** Start the Tor process */ - void start(const QString &tor, const QStringList &args); - /** Stop the Tor process */ - bool stop(QString *errmsg = 0); - /** Detect if the Tor process is running */ - bool isRunning(); - /** Detects if the Tor process is running under Vidalia. */ - bool isVidaliaRunningTor(); - - /** Connect to Tor's control socket */ - void connect(const QHostAddress &address, quint16 port); - /** Disconnect from Tor's control socket */ - void disconnect(); - /** Check if we're connected to Tor's control socket */ - bool isConnected(); - /** Sends an authentication cookie to Tor. */ - bool authenticate(const QByteArray cookie, QString *errmsg = 0); - /** Sends an authentication password to Tor. */ - bool authenticate(const QString password = QString(), QString *errmsg = 0); - - /** Sends a PROTOCOLINFO command to Tor and parses the response. */ - ProtocolInfo protocolInfo(QString *errmsg = 0); - - /** Returns the Tor software's current bootstrap phase and status. */ - BootstrapStatus bootstrapStatus(QString *errmsg = 0); - - /** Returns true if Tor either has an open circuit or (on Tor >= - * 0.2.0.1-alpha) has previously decided it's able to establish a circuit. */ - bool circuitEstablished(); - - /** Sends a GETINFO message to Tor based on the given keys */ - bool getInfo(QHash &map, QString *errmsg = 0); - /** Sends a GETINFO message for a single info value to Tor */ - bool getInfo(QString key, QString &val, QString *errmsg = 0); - - /** Sends a GETINFO message to Tor using the given list of keys and - * returns a QVariantMap containing the specified keys and their values as - * returned by Tor. Returns a default constructed QVariantMap on failure. */ - QVariantMap getInfo(const QStringList &keys, QString *errmsg = 0); - /** Sends a GETINFO message to Tor with a single key and returns a - * QVariant containing the value returned by Tor. Returns a default - * constructed QVariant on failure. */ - QVariant getInfo(const QString &key, QString *errmsg = 0); - - - /** Sends a signal to Tor */ - bool signal(TorSignal::Signal sig, QString *errmsg = 0); - - /** Returns an address on which Tor is listening for application - * requests. If none are available, a null QHostAddress is returned. */ - QHostAddress getSocksAddress(QString *errmsg = 0); - /** Returns a (possibly empty) list of all currently configured - * SocksListenAddress entries. */ - QStringList getSocksAddressList(QString *errmsg = 0); - /** Returns a valid SOCKS port for Tor, or 0 if Tor is not accepting - * application requests. */ - quint16 getSocksPort(QString *errmsg = 0); - /** Returns a list of all currently configured SOCKS ports. If Tor is not - * accepting any application connections, an empty list will be returned. */ - QList getSocksPortList(QString *errmsg = 0); - - /** Returns Tor's version as a string. */ - QString getTorVersionString(); - /** Returns Tor's version as a numeric value. */ - quint32 getTorVersion(); - - /** Sets an event and its handler. If add is true, then the event is added, - * otherwise it is removed. If set is true, then the given event will be - * registered with Tor. */ - bool setEvent(TorEvents::TorEvent e, QObject *obj, - bool add, bool set = true, QString *errmsg = 0); - /** Registers for a set of logging events according to the given filter. */ - bool setLogEvents(uint filter, QObject *obj, QString *errmsg = 0); - /** Register events of interest with Tor */ - bool setEvents(QString *errmsg = 0); - - - /** Sets each configuration key in map to the value associated with its key. */ - bool setConf(QHash map, QString *errmsg = 0); - /** Sets a single configuration key to the given value. */ - bool setConf(QString key, QString value, QString *errmsg = 0); - /** Sets a single configuration string that is formatted . */ - bool setConf(QString keyAndValue, QString *errmsg = 0); - /** Gets values for a set of configuration keys, each of which has a single - * value. */ - bool getConf(QHash &map, QString *errmsg = 0); - /** Gets a set of configuration keyvalues and stores them in map. */ - bool getConf(QHash &map, QString *errmsg = 0); - /** Gets a single configuration value for key. */ - bool getConf(QString key, QString &value, QString *errmsg = 0); - /** Gets a list of configuration values for key. */ - bool getConf(QString key, QStringList &value, QString *errmsg = 0); - - /** Sends a GETCONF message to Tor using the given list of keys and - * returns a QVariantMap containing the specified keys and their values as - * returned by Tor. Returns a default constructed QVariantMap on failure. */ - QVariantMap getConf(const QStringList &keys, QString *errmsg = 0); - /** Sends a GETCONF message to Tor with a single key and returns a - * QVariant containing the value returned by Tor. Returns a default - * constructed QVariant on failure. */ - QVariant getConf(const QString &key, QString *errmsg = 0); - /** Sends a GETCONF message to Tor with the single key and returns a QString - * containing the value returned by Tor */ - QString getHiddenServiceConf(const QString &key, QString *errmsg = 0); - - /** Asks Tor to save the current configuration to its torrc */ - bool saveConf(QString *errmsg = 0); - /** Tells Tor to reset the given configuration keys back to defaults. */ - bool resetConf(QStringList keys, QString *errmsg = 0); - /** Tells Tor to reset a configuration key back to its default value. */ - bool resetConf(QString key, QString *errmsg = 0); - - /** Returns the descriptor for the router whose fingerprint matches - * id. If id is invalid or the router's descriptor cannot be - * parsed, then an invalid RouterDescriptor is returned. */ - RouterDescriptor getRouterDescriptor(const QString &id, QString *errmsg = 0); - /** Returns the status of the router whose fingerprint matches id. If - * id is invalid or the router's status cannot be parsed, then an - * invalid RouterStatus is returned. */ - RouterStatus getRouterStatus(const QString &id, QString *errmsg = 0); - /** Returns a RouterStatus object for every known router in the network. If - * the network status document cannot be parsed, then an empty NetworkStatus - * is returned. */ - NetworkStatus getNetworkStatus(QString *errmsg = 0); - /** Returns the annotations for the router whose fingerprint matches - * id. If id is invalid or the router's descriptor cannot be - * parsed, then an empty DescriptorAnnotations is returned and - * errmsg is set if it's not NULL. (Tor >= 0.2.0.13-alpha only) */ - DescriptorAnnotations getDescriptorAnnotations(const QString &id, - QString *errmsg = 0); - - /** Gets a list of current circuits. */ - CircuitList getCircuits(QString *errmsg = 0); - /** Gets a list of current streams. */ - StreamList getStreams(QString *errmsg = 0); - - /** Gets a list of address mappings of the type specified by type - * (defaults to AddressMapAll. */ - AddressMap getAddressMap( - AddressMap::AddressMapType type = AddressMap::AddressMapAll, - QString *errmsg = 0); - -public slots: - /** Closes the circuit specified by circId. If ifUnused is - * true, then the circuit will not be closed unless it is unused. */ - bool closeCircuit(const CircuitId &circId, bool ifUnused = false, - QString *errmsg = 0); - /** Closes the stream specified by streamId. */ - bool closeStream(const StreamId &streamId, QString *errmsg = 0); - -signals: - /** Emitted when the Tor process has started */ - void started(); - /** Emitted when the Tor process fails to start. */ - void startFailed(QString errmsg); - /** Emitted when the Tor process has stopped */ - void stopped(int exitCode, QProcess::ExitStatus exitStatus); - /** Emitted when the Tor process has stopped. */ - void stopped(); - /** Emitted when the controller has connected to Tor */ - void connected(); - /** Emitted when the controller failed to connect to Tor. */ - void connectFailed(QString errmsg); - /** Emitted when the controller has disconnected from Tor */ - void disconnected(); - /** Emitted when the control socket is connected and authenticated. */ - void authenticated(); - /** Emitted when Tor rejects our authentication attempt. */ - void authenticationFailed(QString errmsg); - -private: - /** Instantiates a connection used to talk to Tor's control port */ - ControlConnection* _controlConn; - /** Manages and monitors the Tor process */ - TorProcess* _torProcess; - /** Keep track of which events we're interested in */ - TorEvents _torEvents; - /** The version of Tor we're currently talking to. */ - QString _torVersion; -#if defined(Q_OS_WIN32) - /** Manages the Tor service, if supported and enabled */ - TorService* _torService; -#endif - - /** Send a message to Tor and read the response */ - bool send(ControlCommand cmd, ControlReply &reply, QString *errmsg = 0); - /** Send a message to Tor and discard the response */ - bool send(ControlCommand cmd, QString *errmsg = 0); - /** Tells Tor the controller wants to enable feature via the - * USEFEATURE control command. Returns true if the given feature was - * successfully enabled. */ - bool useFeature(const QString &feature, QString *errmsg = 0); - -/* The slots below simply relay signals from the appropriate member objects */ -private slots: - void onStarted(); - void onStartFailed(QString errmsg); - void onStopped(int exitCode, QProcess::ExitStatus exitStatus); - void onConnected(); - void onConnectFailed(QString errmsg); - void onDisconnected(); - void onLogStdout(QString severity, QString message); - void onAuthenticated(); -}; - -#endif - diff -Nru vidalia-0.1.13/src/torcontrol/TorControl.h vidalia-0.2.8/src/torcontrol/TorControl.h --- vidalia-0.1.13/src/torcontrol/TorControl.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/TorControl.h 2009-08-20 04:41:13.000000000 +0100 @@ -0,0 +1,402 @@ +/* +** 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.vidalia-project.net/. 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 TorControl.h +** \version $Id: TorControl.h 4060 2009-08-20 03:41:13Z edmanm $ +** \brief Object for interacting with the Tor process and control interface +*/ + +#ifndef _TORCONTROL_H +#define _TORCONTROL_H + +#include "tcglobal.h" +#include "ControlConnection.h" +#include "TorProcess.h" +#include "TorEvents.h" +#include "TorSignal.h" +#include "RouterDescriptor.h" +#include "RouterStatus.h" +#include "BootstrapStatus.h" +#include "Circuit.h" +#include "Stream.h" +#include "AddressMap.h" + +#if defined(Q_OS_WIN32) +#include "TorService.h" +#endif + +#include +#include +#include +#include +#include + +class ProtocolInfo; + +/** DescriptorAnnotations stores a map of annotation keys to (possibly empty) + * annotation values. */ +typedef QHash DescriptorAnnotations; + + +class TorControl : public QObject +{ + Q_OBJECT + +public: + /** Default constructor */ + TorControl(); + /** Default destructor */ + ~TorControl(); + + /** Start the Tor process */ + void start(const QString &tor, const QStringList &args); + /** Stop the Tor process */ + bool stop(QString *errmsg = 0); + /** Detect if the Tor process is running */ + bool isRunning(); + /** Detects if the Tor process is running under Vidalia. */ + bool isVidaliaRunningTor(); + /** Stops reading log messages from the Tor process's stdout. This has no + * effect if isVidaliaRunningTor() is false. */ + void closeTorStdout(); + + /** Connect to Tor's control socket */ + void connect(const QHostAddress &address, quint16 port); + /** Disconnect from Tor's control socket */ + void disconnect(); + /** Check if we're connected to Tor's control socket */ + bool isConnected(); + /** Sends an authentication cookie to Tor. */ + bool authenticate(const QByteArray cookie, QString *errmsg = 0); + /** Sends an authentication password to Tor. */ + bool authenticate(const QString &password = QString(), QString *errmsg = 0); + + /** Sends a PROTOCOLINFO command to Tor and parses the response. */ + ProtocolInfo protocolInfo(QString *errmsg = 0); + + /** Returns the Tor software's current bootstrap phase and status. */ + BootstrapStatus bootstrapStatus(QString *errmsg = 0); + + /** Returns true if Tor either has an open circuit or (on Tor >= + * 0.2.0.1-alpha) has previously decided it's able to establish a circuit. */ + bool isCircuitEstablished(); + + /** Sends a GETINFO message to Tor based on the given keys */ + bool getInfo(QHash &map, QString *errmsg = 0); + /** Sends a GETINFO message for a single info value to Tor */ + bool getInfo(QString key, QString &val, QString *errmsg = 0); + + /** Sends a GETINFO message to Tor using the given list of keys and + * returns a QVariantMap containing the specified keys and their values as + * returned by Tor. Returns a default constructed QVariantMap on failure. */ + QVariantMap getInfo(const QStringList &keys, QString *errmsg = 0); + /** Sends a GETINFO message to Tor with a single key and returns a + * QVariant containing the value returned by Tor. Returns a default + * constructed QVariant on failure. */ + QVariant getInfo(const QString &key, QString *errmsg = 0); + + /** Sends a signal to Tor */ + bool signal(TorSignal::Signal sig, QString *errmsg = 0); + + /** Returns an address on which Tor is listening for application + * requests. If none are available, a null QHostAddress is returned. */ + QHostAddress getSocksAddress(QString *errmsg = 0); + /** Returns a (possibly empty) list of all currently configured + * SocksListenAddress entries. */ + QStringList getSocksAddressList(QString *errmsg = 0); + /** Returns a valid SOCKS port for Tor, or 0 if Tor is not accepting + * application requests. */ + quint16 getSocksPort(QString *errmsg = 0); + /** Returns a list of all currently configured SOCKS ports. If Tor is not + * accepting any application connections, an empty list will be returned. */ + QList getSocksPortList(QString *errmsg = 0); + + /** Returns Tor's version as a string. */ + QString getTorVersionString(); + /** Returns Tor's version as a numeric value. */ + quint32 getTorVersion(); + + /** Sets an event and its handler. If add is true, then the event is added, + * otherwise it is removed. If set is true, then the given event will be + * registered with Tor. */ + bool setEvent(TorEvents::Event e, bool add = true, bool set = true, + QString *errmsg = 0); + /** Register events of interest with Tor */ + bool setEvents(QString *errmsg = 0); + + /** Sets each configuration key in map to the value associated with its key. */ + bool setConf(QHash map, QString *errmsg = 0); + /** Sets a single configuration key to the given value. */ + bool setConf(QString key, QString value, QString *errmsg = 0); + /** Sets a single configuration string that is formatted . */ + bool setConf(QString keyAndValue, QString *errmsg = 0); + /** Gets values for a set of configuration keys, each of which has a single + * value. */ + bool getConf(QHash &map, QString *errmsg = 0); + /** Gets a set of configuration keyvalues and stores them in map. */ + bool getConf(QHash &map, QString *errmsg = 0); + /** Gets a single configuration value for key. */ + bool getConf(QString key, QString &value, QString *errmsg = 0); + /** Gets a list of configuration values for key. */ + bool getConf(QString key, QStringList &value, QString *errmsg = 0); + + /** Sends a GETCONF message to Tor using the given list of keys and + * returns a QVariantMap containing the specified keys and their values as + * returned by Tor. Returns a default constructed QVariantMap on failure. */ + QVariantMap getConf(const QStringList &keys, QString *errmsg = 0); + /** Sends a GETCONF message to Tor with a single key and returns a + * QVariant containing the value returned by Tor. Returns a default + * constructed QVariant on failure. */ + QVariant getConf(const QString &key, QString *errmsg = 0); + /** Sends a GETCONF message to Tor with the single key and returns a QString + * containing the value returned by Tor */ + QString getHiddenServiceConf(const QString &key, QString *errmsg = 0); + + /** Asks Tor to save the current configuration to its torrc */ + bool saveConf(QString *errmsg = 0); + /** Tells Tor to reset the given configuration keys back to defaults. */ + bool resetConf(QStringList keys, QString *errmsg = 0); + /** Tells Tor to reset a configuration key back to its default value. */ + bool resetConf(QString key, QString *errmsg = 0); + + /** Returns an unparsed router descriptor for the router whose fingerprint + * matches id. The returned text can later be parsed by the + * RouterDescriptor class. If id is invalid, then an empty + * QStringList is returned. */ + QStringList getRouterDescriptorText(const QString &id, QString *errmsg = 0); + /** Returns the descriptor for the router whose fingerprint matches + * id. If id is invalid or the router's descriptor cannot be + * parsed, then an invalid RouterDescriptor is returned. */ + RouterDescriptor getRouterDescriptor(const QString &id, QString *errmsg = 0); + /** Returns the status of the router whose fingerprint matches id. If + * id is invalid or the router's status cannot be parsed, then an + * invalid RouterStatus is returned. */ + RouterStatus getRouterStatus(const QString &id, QString *errmsg = 0); + /** Returns a RouterStatus object for every known router in the network. If + * the network status document cannot be parsed, then an empty NetworkStatus + * is returned. */ + NetworkStatus getNetworkStatus(QString *errmsg = 0); + /** Returns the annotations for the router whose fingerprint matches + * id. If id is invalid or the router's descriptor cannot be + * parsed, then an empty DescriptorAnnotations is returned and + * errmsg is set if it's not NULL. (Tor >= 0.2.0.13-alpha only) */ + DescriptorAnnotations getDescriptorAnnotations(const QString &id, + QString *errmsg = 0); + + /** Gets a list of current circuits. */ + CircuitList getCircuits(QString *errmsg = 0); + /** Gets a list of current streams. */ + StreamList getStreams(QString *errmsg = 0); + + /** Gets a list of address mappings of the type specified by type + * (defaults to AddressMapAll. */ + AddressMap getAddressMap( + AddressMap::AddressMapType type = AddressMap::AddressMapAll, + QString *errmsg = 0); + +public slots: + /** Closes the circuit specified by circId. If ifUnused is + * true, then the circuit will not be closed unless it is unused. */ + bool closeCircuit(const CircuitId &circId, bool ifUnused = false, + QString *errmsg = 0); + /** Closes the stream specified by streamId. */ + bool closeStream(const StreamId &streamId, QString *errmsg = 0); + +signals: + /** Emitted when the Tor process has started */ + void started(); + /** Emitted when the Tor process fails to start. */ + void startFailed(QString errmsg); + /** Emitted when the Tor process has stopped */ + void stopped(int exitCode, QProcess::ExitStatus exitStatus); + /** Emitted when the Tor process has stopped. */ + void stopped(); + /** Emitted when the controller has connected to Tor */ + void connected(); + /** Emitted when the controller failed to connect to Tor. */ + void connectFailed(QString errmsg); + /** Emitted when the controller has disconnected from Tor */ + void disconnected(); + /** Emitted when the control socket is connected and authenticated. */ + void authenticated(); + /** Emitted when Tor rejects our authentication attempt. */ + void authenticationFailed(QString errmsg); + + /** Emitted when Tor writes the message msg to the control port + * with message severity level. + */ + void logMessage(tc::Severity level, const QString &msg); + + /** Emitted when Tor sends a bandwidth usage update (roughly once every + * second). bytesReceived is the number of bytes read by Tor over + * the previous second and bytesWritten is the number of bytes + * sent over the same interval. + */ + void bandwidthUpdate(quint64 bytesReceived, quint64 bytesSent); + + /** Emitted when the stream status of stream has changed. + */ + void streamStatusChanged(const Stream &stream); + + /** Emitted when the circuit status of circuit has changed. + */ + void circuitStatusChanged(const Circuit &circuit); + + /** Emitted when Tor has mapped the address from to the address + * to. expires indicates the time at which when the address + * mapping will no longer be considered valid. + */ + void addressMapped(const QString &from, const QString &to, + const QDateTime &expires); + + /** Emitted when Tor has received one or more new router descriptors. + * ids contains a list of digests of the new descriptors. + */ + void newDescriptors(const QStringList &ids); + + /** Indicates Tor has been able to successfully establish one or more + * circuits. + */ + void circuitEstablished(); + + /** Indicates that Tor has decided the user's Tor software version + * is no longer recommended for some reason. recommended is + * a list of Tor software versions that are considered current. + */ + void dangerousTorVersion(tc::TorVersionStatus reason, + const QString &version, + const QStringList &recommended); + + /** Emitted during Tor's startup process to indicate how far in its + * bootstrapping process it has progressed. status may indicate + * the current bootstrapping stage or an error during bootstrapping. + */ + void bootstrapStatusChanged(const BootstrapStatus &status); + + /** Emitted when the user attempts to establish a connection to some + * destination on port port, which is a port known to use + * plaintext connections (as determined by Tor's WarnPlaintextPorts and + * RejectPlaintextPorts torrc options). rejected indicates whether + * Tor rejected the connection or permitted it to connect anyway. + */ + void dangerousPort(quint16 port, bool rejected); + + /** Emitted when Tor detects a problem with a SOCKS connection from the + * user, such as a bad hostname, dangerous SOCKS protocol type, or a bad + * hostname. type indicates the type of error encountered and + * destination (if non-empty) specifies the attempted connection + * destination address or hostname. + */ + void socksError(tc::SocksError type, const QString &destination); + + /** Emitted when Tor decides the client's external IP address has changed + * to ip. If hostname is non-empty, Tor obtained the new + * value for ip by resolving hostname. + */ + void externalAddressChanged(const QHostAddress &ip, const QString &hostname); + + /** Indicates that Tor has determined the client's clock is potentially + * skewed by skew seconds relative to source. + */ + void clockSkewed(int skew, const QString &source); + + /** Emitted when Tor has encountered an internal bug. reason is + * Tor's description of the bug. + */ + void bug(const QString &reason); + + /** Emitted when Tor determines that the user's DNS provider is providing + * an address for non-existent domains when it should really be saying + * "NXDOMAIN". + */ + void dnsHijacked(); + + /** Emitted when Tor determines that the user's DNS provider is providing + * a hijacked address even for well-known websites. + */ + void dnsUseless(); + + /** Indicates Tor has started testing the reachability of its OR port + * using the IP address ip and port port. + */ + void checkingOrPortReachability(const QHostAddress &ip, quint16 port); + + /** Tor has completed testing the reachability of its OR port using + * the IP address ip and port port. If the user's OR port + * was reachable, reachable will be set to true. + */ + void orPortReachabilityFinished(const QHostAddress &ip, quint16 port, + bool reachable); + + /** Indicates Tor has started testing the reachability of its directory + * port using the IP address ip and port port. + */ + void checkingDirPortReachability(const QHostAddress &ip, quint16 port); + + /** Tor has completed testing the reachability of its directory port using + * the IP address ip and port port. If the user's directory + * port was reachable, reachable will be set to true. + */ + void dirPortReachabilityFinished(const QHostAddress &ip, quint16 port, + bool reachable); + + /** Emitted when the directory authority with IP address ip and + * port port rejected the user's server descriptor. reason + * describes why the descriptor was rejected (e.g., malformed, skewed + * clock, etc.). + */ + void serverDescriptorRejected(const QHostAddress &ip, quint16 port, + const QString &reason); + + /** Emitted when the directory authority with IP address ip and + * port port accepted the user's server descriptor. + */ + void serverDescriptorAccepted(const QHostAddress &ip, quint16 port); + + /** Emitted when at least one directory authority has accepted the user's + * server descriptor. + */ + void serverDescriptorAccepted(); + +private: + /** Instantiates a connection used to talk to Tor's control port */ + ControlConnection* _controlConn; + /** Manages and monitors the Tor process */ + TorProcess* _torProcess; + /** Keep track of which events we're interested in */ + TorEvents* _eventHandler; + TorEvents::Events _events; + /** The version of Tor we're currently talking to. */ + QString _torVersion; +#if defined(Q_OS_WIN32) + /** Manages the Tor service, if supported and enabled */ + TorService* _torService; +#endif + + /** Send a message to Tor and read the response */ + bool send(ControlCommand cmd, ControlReply &reply, QString *errmsg = 0); + /** Send a message to Tor and discard the response */ + bool send(ControlCommand cmd, QString *errmsg = 0); + /** Tells Tor the controller wants to enable feature via the + * USEFEATURE control command. Returns true if the given feature was + * successfully enabled. */ + bool useFeature(const QString &feature, QString *errmsg = 0); + +/* The slots below simply relay signals from the appropriate member objects */ +private slots: + void onStopped(int exitCode, QProcess::ExitStatus exitStatus); + void onDisconnected(); + void onLogStdout(const QString &severity, const QString &message); + void onAuthenticated(); +}; + +#endif + diff -Nru vidalia-0.1.13/src/torcontrol/torevents.cpp vidalia-0.2.8/src/torcontrol/torevents.cpp --- vidalia-0.1.13/src/torcontrol/torevents.cpp 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/torevents.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,467 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 torevents.cpp -** \version $Id: torevents.cpp 2780 2008-06-21 21:48:32Z edmanm $ -** \brief Parses and dispatches events from Tor -*/ - -#include -#include - -#include "circuit.h" -#include "stream.h" -#include "torevents.h" -#include "unrecognizedserverstatusevent.h" -#include "unrecognizedclientstatusevent.h" -#include "unrecognizedgeneralstatusevent.h" -#include "circuitestablishedevent.h" -#include "dangerousversionevent.h" -#include "bootstrapstatusevent.h" - -/** Format of expiry times in address map events. */ -#define DATE_FMT "\"yyyy-MM-dd HH:mm:ss\"" - - -/** Default constructor */ -TorEvents::TorEvents() -{ -} - -/** Adds an event and interested object to the list */ -void -TorEvents::add(TorEvent e, QObject *obj) -{ - if (!_eventList.values(e).contains(obj)) { - _eventList.insert(e, obj); - } -} - -/** Removes obj from the list of target objects for event e. */ -void -TorEvents::remove(TorEvent e, QObject *obj) -{ - QMultiHash::iterator i = _eventList.find(e); - while (i != _eventList.end() && i.key() == e) { - if (i.value() == obj) { - _eventList.erase(i); - break; - } - i++; - } -} - -/** Returns true if an event has any registered handlers */ -bool -TorEvents::contains(TorEvent event) -{ - if (_eventList.contains(event)) { - return (_eventList.values(event).count() > 0); - } - return false; -} - -/** Returns the list of events in which we're interested */ -QList -TorEvents::eventList() -{ - return _eventList.keys(); -} - -/** Dispatches a given event to all its handler targets. */ -void -TorEvents::dispatch(TorEvent e, QEvent *event) -{ - foreach (QObject *obj, _eventList.values(e)) { - QApplication::postEvent(obj, event); - } -} - -/** Converts an event type to a string Tor understands */ -QString -TorEvents::toString(TorEvent e) -{ - QString event; - switch (e) { - case Bandwidth: event = "BW"; break; - case LogDebug: event = "DEBUG"; break; - case LogInfo: event = "INFO"; break; - case LogNotice: event = "NOTICE"; break; - case LogWarn: event = "WARN"; break; - case LogError: event = "ERR"; break; - case CircuitStatus: event = "CIRC"; break; - case StreamStatus: event = "STREAM"; break; - case OrConnStatus: event = "ORCONN"; break; - case NewDescriptor: event = "NEWDESC"; break; - case AddressMap: event = "ADDRMAP"; break; - case GeneralStatus: event = "STATUS_GENERAL"; break; - case ClientStatus: event = "STATUS_CLIENT"; break; - case ServerStatus: event = "STATUS_SERVER"; break; - default: event = "UNKNOWN"; break; - } - return event; -} - -/** Converts a log severity to its related Tor event */ -TorEvents::TorEvent -TorEvents::toTorEvent(LogEvent::Severity severity) -{ - TorEvent e; - switch (severity) { - case LogEvent::Debug: e = LogDebug; break; - case LogEvent::Info: e = LogInfo; break; - case LogEvent::Notice: e = LogNotice; break; - case LogEvent::Warn: e = LogWarn; break; - case LogEvent::Error: e = LogError; break; - default: e = Unknown; break; - } - return e; -} - -/** Converts an event in the string form sent by Tor to its enum value */ -TorEvents::TorEvent -TorEvents::toTorEvent(const QString &event) -{ - TorEvent e; - if (event == "BW") { - e = Bandwidth; - } else if (event == "CIRC") { - e = CircuitStatus; - } else if (event == "STREAM") { - e = StreamStatus; - } else if (event == "DEBUG") { - e = LogDebug; - } else if (event == "INFO") { - e = LogInfo; - } else if (event == "NOTICE") { - e = LogNotice; - } else if (event == "WARN") { - e = LogWarn; - } else if (event == "ERR") { - e = LogError; - } else if (event == "NEWDESC") { - e = NewDescriptor; - } else if (event == "ADDRMAP") { - e = AddressMap; - } else if (event == "STATUS_GENERAL") { - e = GeneralStatus; - } else if (event == "STATUS_CLIENT") { - e = ClientStatus; - } else if (event == "STATUS_SERVER") { - e = ServerStatus; - } else if (event == "ORCONN") { - e = OrConnStatus; - } else { - e = Unknown; - } - return e; -} - -/** Parse the event type out of a message line and return the corresponding - * Event enum value */ -TorEvents::TorEvent -TorEvents::parseEventType(const ReplyLine &line) -{ - QString msg = line.getMessage(); - int i = msg.indexOf(" "); - return toTorEvent(msg.mid(0, i)); -} - -/** Handles an event message from Tor. An event message can potentially have - * more than one line, so we will iterate through them all and dispatch the - * necessary events. */ -void -TorEvents::handleEvent(const ControlReply &reply) -{ - foreach(ReplyLine line, reply.getLines()) { - switch (parseEventType(line)) { - case Bandwidth: handleBandwidthUpdate(line); break; - case CircuitStatus: handleCircuitStatus(line); break; - case StreamStatus: handleStreamStatus(line); break; - case OrConnStatus: handleOrConnStatus(line); break; - case NewDescriptor: handleNewDescriptor(line); break; - case AddressMap: handleAddressMap(line); break; - - case GeneralStatus: - handleStatusEvent(GeneralStatus, line); break; - case ClientStatus: - handleStatusEvent(ClientStatus, line); break; - case ServerStatus: - handleStatusEvent(ServerStatus, line); break; - - case LogDebug: - case LogInfo: - case LogNotice: - case LogWarn: - case LogError: - handleLogMessage(line); break; - default: break; - } - } -} - -/** Handle a bandwidth update event, to inform the controller of the bandwidth - * used in the last second. The format of this message is: - * - * "650" SP "BW" SP BytesRead SP BytesWritten - * BytesRead = 1*DIGIT - * BytesWritten = 1*DIGIT - */ -void -TorEvents::handleBandwidthUpdate(const ReplyLine &line) -{ - QStringList msg = line.getMessage().split(" "); - if (msg.size() >= 3) { - quint64 bytesIn = (quint64)msg.at(1).toULongLong(); - quint64 bytesOut = (quint64)msg.at(2).toULongLong(); - - /* Post the event to each of the interested targets */ - dispatch(Bandwidth, new BandwidthEvent(bytesIn, bytesOut)); - } -} - -/** Handle a circuit status event. The format of this message is: - * - * "650" SP "CIRC" SP CircuitID SP CircStatus SP Path - * CircStatus = - * "LAUNCHED" / ; circuit ID assigned to new circuit - * "BUILT" / ; all hops finished, can now accept streams - * "EXTENDED" / ; one more hop has been completed - * "FAILED" / ; circuit closed (was not built) - * "CLOSED" ; circuit closed (was built) - * Path = ServerID *("," ServerID) - */ -void -TorEvents::handleCircuitStatus(const ReplyLine &line) -{ - QString msg = line.getMessage().trimmed(); - int i = msg.indexOf(" ") + 1; - if (i > 0) { - /* Post the event to each of the interested targets */ - Circuit circ(msg.mid(i)); - if (circ.isValid()) - dispatch(CircuitStatus, new CircuitEvent(circ)); - } -} - -/** Handle a stream status event. The format of this message is: - * - * "650" SP "STREAM" SP StreamID SP StreamStatus SP CircID SP Target SP - * StreamStatus = - * "NEW" / ; New request to connect - * "NEWRESOLVE" / ; New request to resolve an address - * "SENTCONNECT" / ; Sent a connect cell along a circuit - * "SENTRESOLVE" / ; Sent a resolve cell along a circuit - * "SUCCEEDED" / ; Received a reply; stream established - * "FAILED" / ; Stream failed and not retriable. - * "CLOSED" / ; Stream closed - * "DETACHED" ; Detached from circuit; still retriable. - * Target = Address ":" Port - * - * If the circuit ID is 0, then the stream is unattached. - */ -void -TorEvents::handleStreamStatus(const ReplyLine &line) -{ - QString msg = line.getMessage().trimmed(); - int i = msg.indexOf(" ") + 1; - if (i > 0) { - /* Post the event to each of the interested targets */ - dispatch(StreamStatus, new StreamEvent(Stream::fromString(msg.mid(i)))); - } -} - -/** Handle a log message event. The format of this message is: - * The syntax is: - * - * "650" SP Severity SP ReplyText - * or - * "650+" Severity CRLF Data - * Severity = "DEBUG" / "INFO" / "NOTICE" / "WARN"/ "ERR" - */ -void -TorEvents::handleLogMessage(const ReplyLine &line) -{ - QString msg = line.getMessage(); - int i = msg.indexOf(" "); - LogEvent::Severity severity = LogEvent::toSeverity(msg.mid(0, i)); - QString logLine = (line.getData().size() > 0 ? line.getData().join("\n") : - msg.mid(i+1)); - - dispatch(toTorEvent(severity), new LogEvent(severity, logLine)); -} - -/** Handle an OR Connection Status event. The syntax is: - * "650" SP "ORCONN" SP (ServerID / Target) SP ORStatus - * - * ORStatus = "NEW" / "LAUNCHED" / "CONNECTED" / "FAILED" / "CLOSED" - * - * NEW is for incoming connections, and LAUNCHED is for outgoing - * connections. CONNECTED means the TLS handshake has finished (in - * either direction). FAILED means a connection is being closed - * that hasn't finished its handshake, and CLOSED is for connections - * that have handshaked. - * - * A ServerID is specified unless it's a NEW connection, in which - * case we don't know what server it is yet, so we use Address:Port. - */ -void -TorEvents::handleOrConnStatus(const ReplyLine &line) -{ - QStringList msg = line.getMessage().split(" "); - if (msg.size() >= 3) { - dispatch(OrConnStatus, - new OrConnEvent(OrConnEvent::toStatus(msg.at(2)), msg.at(1))); - } -} - -/** Handles a new descriptor event. The format for event messages of this type - * is: - * - * "650" SP "NEWDESC" 1*(SP ServerID) - */ -void -TorEvents::handleNewDescriptor(const ReplyLine &line) -{ - QString descs = line.getMessage(); - QStringList descList = descs.mid(descs.indexOf(" ")+1).split(" "); - if (descList.size() > 0) { - dispatch(NewDescriptor, new NewDescriptorEvent(descList)); - } -} - -/** Handles a new or updated address mapping event. The format for event - * messages of this type is: - * - * "650" SP "ADDRMAP" SP Address SP Address SP Expiry - * Expiry = DQUOTE ISOTime DQUOTE / "NEVER" - * - * Expiry is expressed as the local time (rather than GMT). - */ -void -TorEvents::handleAddressMap(const ReplyLine &line) -{ - QStringList msg = line.getMessage().split(" "); - if (msg.size() >= 4) { - QDateTime expires; - if (msg.size() >= 5 && msg.at(3) != "NEVER") - expires = QDateTime::fromString(msg.at(3) + " " + msg.at(4), DATE_FMT); - dispatch(AddressMap, new AddressMapEvent(msg.at(1), msg.at(2), expires)); - } -} - -/** Handles a Tor status event. The format for event messages of this type is: - * - * "650" SP StatusType SP StatusSeverity SP StatusAction - * [SP StatusArguments] CRLF - * - * StatusType = "STATUS_GENERAL" / "STATUS_CLIENT" / "STATUS_SERVER" - * StatusSeverity = "NOTICE" / "WARN" / "ERR" - * StatusAction = 1*ALPHA - * StatusArguments = StatusArgument *(SP StatusArgument) - * StatusArgument = StatusKeyword '=' StatusValue - * StatusKeyword = 1*(ALNUM / "_") - * StatusValue = 1*(ALNUM / '_') / QuotedString - */ -void -TorEvents::handleStatusEvent(TorEvent type, const ReplyLine &line) -{ - QString status; - tc::Severity severity; - QHash args; - QString msg = line.getMessage(); - - severity = tc::toSeverity(msg.section(' ', 1, 1)); - status = msg.section(' ', 2, 2); - args = string_parse_keyvals(msg.section(' ', 3)); - switch (type) { - case ClientStatus: - dispatchClientStatusEvent(severity, status, args); break; - case ServerStatus: - dispatchServerStatusEvent(severity, status, args); break; - default: - dispatchGeneralStatusEvent(severity, status, args); - } -} - -/** Parses and posts a Tor client status event. */ -void -TorEvents::dispatchClientStatusEvent(tc::Severity severity, - const QString &action, - const QHash &args) -{ - ClientStatusEvent *event; - ClientStatusEvent::Status status - = ClientStatusEvent::statusFromString(action); - - switch (status) { - case ClientStatusEvent::CircuitEstablished: - event = new CircuitEstablishedEvent(severity); break; - - case ClientStatusEvent::Bootstrap: - event = new BootstrapStatusEvent(BootstrapStatus(severity, - BootstrapStatus::statusFromString(args.value("TAG")), - args.value("PROGRESS").toInt(), - args.value("SUMMARY"), - args.value("WARNING"), - tc::toConnectionStatusReason(args.value("REASON")), - BootstrapStatus::actionFromString( - args.value("RECOMMENDATION")))); - - break; - - default: - event = new UnrecognizedClientStatusEvent(severity, action, args); - } - dispatch(ClientStatus, event); -} - -/** Parses and posts a Tor server status event. */ -void -TorEvents::dispatchServerStatusEvent(tc::Severity severity, - const QString &action, - const QHash &args) -{ - ServerStatusEvent *event; - ServerStatusEvent::Status status - = ServerStatusEvent::statusFromString(action); - - switch (status) { - default: - event = new UnrecognizedServerStatusEvent(severity, action, args); - } - dispatch(ServerStatus, event); -} - -/** Parses and posts a general Tor status event. */ -void -TorEvents::dispatchGeneralStatusEvent(tc::Severity severity, - const QString &action, - const QHash &args) -{ - GeneralStatusEvent *event; - GeneralStatusEvent::Status status - = GeneralStatusEvent::statusFromString(action); - - switch (status) { - case GeneralStatusEvent::DangerousTorVersion: - /* Dangerous Tor version ("DANGEROUS_VERSION") */ - event = new DangerousVersionEvent(severity, - DangerousVersionEvent::reasonFromString(args.value("REASON")), - args.value("CURRENT"), - args.value("RECOMMENDED").split(",", QString::SkipEmptyParts)); - break; - default: - event = new UnrecognizedGeneralStatusEvent(severity, action, args); - } - dispatch(GeneralStatus, event); -} - diff -Nru vidalia-0.1.13/src/torcontrol/TorEvents.cpp vidalia-0.2.8/src/torcontrol/TorEvents.cpp --- vidalia-0.1.13/src/torcontrol/TorEvents.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/TorEvents.cpp 2009-09-01 14:54:27.000000000 +0100 @@ -0,0 +1,458 @@ +/* +** 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.vidalia-project.net/. 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 TorEvents.cpp +** \version $Id: TorEvents.cpp 4100 2009-09-01 13:54:27Z edmanm $ +** \brief Parses and dispatches events from Tor +*/ + + +#include "TorEvents.h" +#include "ControlReply.h" +#include "ReplyLine.h" +#include "Circuit.h" +#include "Stream.h" +#include "BootstrapStatus.h" + +#include "stringutil.h" + +#include +#include + +/** Format of expiry times in address map events. */ +#define DATE_FMT "\"yyyy-MM-dd HH:mm:ss\"" + + +/** Default constructor */ +TorEvents::TorEvents(QObject *parent) + : QObject(parent) +{ + qRegisterMetaType(); + qRegisterMetaType(); + qRegisterMetaType(); + + qRegisterMetaType("BootstrapStatus"); + qRegisterMetaType("Circuit"); + qRegisterMetaType("Stream"); + + qRegisterMetaType("QHostAddress"); + qRegisterMetaType("QDateTime"); +} + +/** Converts an event type to a string Tor understands */ +QString +TorEvents::toString(Event e) +{ + QString event; + switch (e) { + case Bandwidth: event = "BW"; break; + case LogDebug: event = "DEBUG"; break; + case LogInfo: event = "INFO"; break; + case LogNotice: event = "NOTICE"; break; + case LogWarn: event = "WARN"; break; + case LogError: event = "ERR"; break; + case CircuitStatus: event = "CIRC"; break; + case StreamStatus: event = "STREAM"; break; + case NewDescriptor: event = "NEWDESC"; break; + case AddressMap: event = "ADDRMAP"; break; + case GeneralStatus: event = "STATUS_GENERAL"; break; + case ClientStatus: event = "STATUS_CLIENT"; break; + case ServerStatus: event = "STATUS_SERVER"; break; + default: event = "UNKNOWN"; break; + } + return event; +} + +/** Converts an event in the string form sent by Tor to its enum value */ +TorEvents::Event +TorEvents::toTorEvent(const QString &event) +{ + Event e; + if (event == "BW") { + e = Bandwidth; + } else if (event == "CIRC") { + e = CircuitStatus; + } else if (event == "STREAM") { + e = StreamStatus; + } else if (event == "DEBUG") { + e = LogDebug; + } else if (event == "INFO") { + e = LogInfo; + } else if (event == "NOTICE") { + e = LogNotice; + } else if (event == "WARN") { + e = LogWarn; + } else if (event == "ERR") { + e = LogError; + } else if (event == "NEWDESC") { + e = NewDescriptor; + } else if (event == "ADDRMAP") { + e = AddressMap; + } else if (event == "STATUS_GENERAL") { + e = GeneralStatus; + } else if (event == "STATUS_CLIENT") { + e = ClientStatus; + } else if (event == "STATUS_SERVER") { + e = ServerStatus; + } else { + e = Unknown; + } + return e; +} + +/** Parse the event type out of a message line and return the corresponding + * Event enum value */ +TorEvents::Event +TorEvents::parseEventType(const ReplyLine &line) +{ + QString msg = line.getMessage(); + int i = msg.indexOf(" "); + return toTorEvent(msg.mid(0, i)); +} + +/** Handles an event message from Tor. An event message can potentially have + * more than one line, so we will iterate through them all and dispatch the + * necessary events. */ +void +TorEvents::handleEvent(const ControlReply &reply) +{ + foreach(ReplyLine line, reply.getLines()) { + switch (parseEventType(line)) { + case Bandwidth: handleBandwidthUpdate(line); break; + case CircuitStatus: handleCircuitStatus(line); break; + case StreamStatus: handleStreamStatus(line); break; + case NewDescriptor: handleNewDescriptor(line); break; + case AddressMap: handleAddressMap(line); break; + + case GeneralStatus: + handleStatusEvent(GeneralStatus, line); break; + case ClientStatus: + handleStatusEvent(ClientStatus, line); break; + case ServerStatus: + handleStatusEvent(ServerStatus, line); break; + + case LogDebug: + case LogInfo: + case LogNotice: + case LogWarn: + case LogError: + handleLogMessage(line); break; + default: break; + } + } +} + +/** Handle a bandwidth update event, to inform the controller of the bandwidth + * used in the last second. The format of this message is: + * + * "650" SP "BW" SP BytesRead SP BytesWritten + * BytesRead = 1*DIGIT + * BytesWritten = 1*DIGIT + */ +void +TorEvents::handleBandwidthUpdate(const ReplyLine &line) +{ + QStringList msg = line.getMessage().split(" "); + if (msg.size() >= 3) { + quint64 bytesIn = (quint64)msg.at(1).toULongLong(); + quint64 bytesOut = (quint64)msg.at(2).toULongLong(); + + /* Post the event to each of the interested targets */ + emit bandwidthUpdate(bytesIn, bytesOut); + } +} + +/** Handle a circuit status event. The format of this message is: + * + * "650" SP "CIRC" SP CircuitID SP CircStatus SP Path + * CircStatus = + * "LAUNCHED" / ; circuit ID assigned to new circuit + * "BUILT" / ; all hops finished, can now accept streams + * "EXTENDED" / ; one more hop has been completed + * "FAILED" / ; circuit closed (was not built) + * "CLOSED" ; circuit closed (was built) + * Path = ServerID *("," ServerID) + */ +void +TorEvents::handleCircuitStatus(const ReplyLine &line) +{ + QString msg = line.getMessage().trimmed(); + int i = msg.indexOf(" ") + 1; + if (i > 0) { + /* Post the event to each of the interested targets */ + Circuit circ(msg.mid(i)); + if (circ.isValid()) + emit circuitStatusChanged(circ); + } +} + +/** Handle a stream status event. The format of this message is: + * + * "650" SP "STREAM" SP StreamID SP StreamStatus SP CircID SP Target SP + * StreamStatus = + * "NEW" / ; New request to connect + * "NEWRESOLVE" / ; New request to resolve an address + * "SENTCONNECT" / ; Sent a connect cell along a circuit + * "SENTRESOLVE" / ; Sent a resolve cell along a circuit + * "SUCCEEDED" / ; Received a reply; stream established + * "FAILED" / ; Stream failed and not retriable. + * "CLOSED" / ; Stream closed + * "DETACHED" ; Detached from circuit; still retriable. + * Target = Address ":" Port + * + * If the circuit ID is 0, then the stream is unattached. + */ +void +TorEvents::handleStreamStatus(const ReplyLine &line) +{ + QString msg = line.getMessage().trimmed(); + int i = msg.indexOf(" ") + 1; + if (i > 0) { + Stream stream = Stream::fromString(msg.mid(i)); + if (stream.isValid()) + emit streamStatusChanged(stream); + } +} + +/** Handle a log message event. The format of this message is: + * The syntax is: + * + * "650" SP Severity SP ReplyText + * or + * "650+" Severity CRLF Data + * Severity = "DEBUG" / "INFO" / "NOTICE" / "WARN"/ "ERR" + */ +void +TorEvents::handleLogMessage(const ReplyLine &line) +{ + QString msg = line.getMessage(); + int i = msg.indexOf(" "); + tc::Severity severity = tc::severityFromString(msg.mid(0, i)); + QString logLine = (line.getData().size() > 0 ? line.getData().join("\n") : + msg.mid(i+1)); + + emit logMessage(severity, logLine); +} + +/** Handles a new descriptor event. The format for event messages of this type + * is: + * + * "650" SP "NEWDESC" 1*(SP ServerID) + */ +void +TorEvents::handleNewDescriptor(const ReplyLine &line) +{ + QString descs = line.getMessage(); + QStringList descList = descs.mid(descs.indexOf(" ")+1).split(" "); + emit newDescriptors(descList); +} + +/** Handles a new or updated address mapping event. The format for event + * messages of this type is: + * + * "650" SP "ADDRMAP" SP Address SP Address SP Expiry + * Expiry = DQUOTE ISOTime DQUOTE / "NEVER" + * + * Expiry is expressed as the local time (rather than GMT). + */ +void +TorEvents::handleAddressMap(const ReplyLine &line) +{ + QStringList msg = line.getMessage().split(" "); + if (msg.size() >= 4) { + QDateTime expires; + if (msg.size() >= 5 && msg.at(3) != "NEVER") + expires = QDateTime::fromString(msg.at(3) + " " + msg.at(4), DATE_FMT); + emit addressMapped(msg.at(1), msg.at(2), expires); + } +} + +/** Handles a Tor status event. The format for event messages of this type is: + * + * "650" SP StatusType SP StatusSeverity SP StatusAction + * [SP StatusArguments] CRLF + * + * StatusType = "STATUS_GENERAL" / "STATUS_CLIENT" / "STATUS_SERVER" + * StatusSeverity = "NOTICE" / "WARN" / "ERR" + * StatusAction = 1*ALPHA + * StatusArguments = StatusArgument *(SP StatusArgument) + * StatusArgument = StatusKeyword '=' StatusValue + * StatusKeyword = 1*(ALNUM / "_") + * StatusValue = 1*(ALNUM / '_') / QuotedString + */ +void +TorEvents::handleStatusEvent(Event e, const ReplyLine &line) +{ + QString status; + tc::Severity severity; + QHash args; + QString msg = line.getMessage(); + + severity = tc::severityFromString(msg.section(' ', 1, 1)); + status = msg.section(' ', 2, 2); + args = string_parse_keyvals(msg.section(' ', 3)); + switch (e) { + case ClientStatus: + handleClientStatusEvent(severity, status, args); + break; + + case ServerStatus: + handleServerStatusEvent(severity, status, args); + break; + + case GeneralStatus: + handleGeneralStatusEvent(severity, status, args); + break; + + default: + break; + } +} + +/** Parses and emits a general Tor status event. */ +void +TorEvents::handleGeneralStatusEvent(tc::Severity severity, + const QString &action, + const QHash &args) +{ + if (! action.compare("DANGEROUS_TOR_VERSION", Qt::CaseInsensitive)) { + QString reason = args.value("REASON"); + QString current = args.value("CURRENT"); + QStringList recommended = args.value("RECOMMENDED") + .split(",", QString::SkipEmptyParts); + if (! reason.compare("NEW", Qt::CaseInsensitive)) + emit dangerousTorVersion(tc::NewTorVersion, current, recommended); + else if (! reason.compare("UNRECOMMENDED", Qt::CaseInsensitive)) + emit dangerousTorVersion(tc::UnrecommendedTorVersion, current, recommended); + else if (! reason.compare("OBSOLETE", Qt::CaseInsensitive) + || ! reason.compare("OLD", Qt::CaseInsensitive)) + emit dangerousTorVersion(tc::ObsoleteTorVersion, current, recommended); + } else if (! action.compare("CLOCK_SKEW", Qt::CaseInsensitive)) { + int skew; + bool ok = false; + if (args.contains("SKEW")) + skew = args.value("SKEW").toInt(&ok); + else if (args.contains("MIN_SKEW")) + skew = args.value("MIN_SKEW").toInt(&ok); + if (ok) + emit clockSkewed(skew, args.value("SOURCE")); + } else if (! action.compare("BUG", Qt::CaseInsensitive)) { + emit bug(args.value("REASON")); + } +} + +/** Parses and emits a Tor client status event. */ +void +TorEvents::handleClientStatusEvent(tc::Severity severity, + const QString &action, + const QHash &args) +{ + if (! action.compare("CIRCUIT_ESTABLISHED", Qt::CaseInsensitive)) { + emit circuitEstablished(); + } else if (! action.compare("DANGEROUS_PORT", Qt::CaseInsensitive)) { + bool reject = ! args.value("RESULT").compare("REJECT", Qt::CaseInsensitive); + emit dangerousPort(args.value("PORT").toUInt(), reject); + } else if (! action.compare("DANGEROUS_SOCKS", Qt::CaseInsensitive)) { + emit socksError(tc::DangerousSocksTypeError, args.value("ADDRESS")); + } else if (! action.compare("SOCKS_UNKNOWN_PROTOCOL", Qt::CaseInsensitive)) { + emit socksError(tc::UnknownSocksProtocolError, QString()); + } else if (! action.compare("SOCKS_BAD_HOSTNAME", Qt::CaseInsensitive)) { + emit socksError(tc::BadSocksHostnameError, args.value("HOSTNAME")); + } else if (! action.compare("BOOTSTRAP", Qt::CaseInsensitive)) { + BootstrapStatus status + = BootstrapStatus(severity, + BootstrapStatus::statusFromString(args.value("TAG")), + args.value("PROGRESS").toInt(), + args.value("SUMMARY"), + args.value("WARNING"), + tc::connectionStatusReasonFromString(args.value("REASON")), + BootstrapStatus::actionFromString( + args.value("RECOMMENDATION"))); + emit bootstrapStatusChanged(status); + } +} + +/** Parses and emits a Tor server status event. */ +void +TorEvents::handleServerStatusEvent(tc::Severity severity, + const QString &action, + const QHash &args) +{ + if (! action.compare("EXTERNAL_ADDRESS", Qt::CaseInsensitive)) { + emit externalAddressChanged(QHostAddress(args.value("ADDRESS")), + args.value("HOSTNAME")); + } else if (! action.compare("CHECKING_REACHABILITY", Qt::CaseInsensitive)) { + if (args.contains("ORADDRESS")) { + QPair pair = splitAddress(args.value("ORADDRESS")); + if (! pair.first.isNull()) + emit checkingOrPortReachability(pair.first, pair.second); + } else if (args.contains("DIRADDRESS")) { + QPair pair = splitAddress(args.value("DIRADDRESS")); + if (! pair.first.isNull()) + emit checkingDirPortReachability(pair.first, pair.second); + } + } else if (! action.compare("REACHABILITY_SUCCEEDED", Qt::CaseInsensitive)) { + if (args.contains("ORADDRESS")) { + QPair pair = splitAddress(args.value("ORADDRESS")); + if (! pair.first.isNull()) + emit orPortReachabilityFinished(pair.first, pair.second, true); + } else if (args.contains("DIRADDRESS")) { + QPair pair = splitAddress(args.value("DIRADDRESS")); + if (! pair.first.isNull()) + emit dirPortReachabilityFinished(pair.first, pair.second, true); + } + } else if (! action.compare("REACHABILITY_FAILED", Qt::CaseInsensitive)) { + if (args.contains("ORADDRESS")) { + QPair pair = splitAddress(args.value("ORADDRESS")); + if (! pair.first.isNull()) + emit orPortReachabilityFinished(pair.first, pair.second, false); + } else if (args.contains("DIRADDRESS")) { + QPair pair = splitAddress(args.value("DIRADDRESS")); + if (! pair.first.isNull()) + emit dirPortReachabilityFinished(pair.first, pair.second, false); + } + } else if (! action.compare("GOOD_SERVER_DESCRIPTOR", Qt::CaseInsensitive)) { + emit serverDescriptorAccepted(); + } else if (! action.compare("ACCEPTED_SERVER_DESCRIPTOR", Qt::CaseInsensitive)) { + QPair pair = splitAddress(args.value("DIRAUTH")); + if (! pair.first.isNull()) + emit serverDescriptorAccepted(pair.first, pair.second); + } else if (! action.compare("BAD_SERVER_DESCRIPTOR", Qt::CaseInsensitive)) { + QPair pair = splitAddress(args.value("DIRAUTH")); + if (! pair.first.isNull()) + emit serverDescriptorRejected(pair.first, pair.second, + args.value("REASON")); + } else if (! action.compare("DNS_HIJACKED", Qt::CaseInsensitive)) { + emit dnsHijacked(); + } else if (! action.compare("DNS_USELESS", Qt::CaseInsensitive)) { + emit dnsUseless(); + } +} + +/** Splits a string in the form "IP:PORT" into a QHostAddress and quint16 + * pair. If either portion is invalid, a default-constructed QPair() is + * returned. */ +QPair +TorEvents::splitAddress(const QString &address) +{ + bool ok; + int idx = address.indexOf(":"); + if (idx <= 0 || idx >= address.length()-1) + return QPair(); + + QHostAddress ip = QHostAddress(address.mid(0, idx)); + quint16 port = static_cast(address.mid(idx+1).toUInt(&ok)); + if (ip.isNull() || ! ok) + return QPair(); + return QPair(ip, port); +} + + diff -Nru vidalia-0.1.13/src/torcontrol/torevents.h vidalia-0.2.8/src/torcontrol/torevents.h --- vidalia-0.1.13/src/torcontrol/torevents.h 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/torevents.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,123 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 torevents.h -** \version $Id: torevents.h 2780 2008-06-21 21:48:32Z edmanm $ -** \brief Parses and dispatches events from Tor -*/ - -#ifndef _TOREVENTS_H -#define _TOREVENTS_H - -#include -#include -#include - -#include "eventtype.h" -#include "logevent.h" -#include "bandwidthevent.h" -#include "circuitevent.h" -#include "streamevent.h" -#include "orconnevent.h" -#include "newdescriptorevent.h" -#include "addressmapevent.h" -#include "statusevent.h" -#include "controlreply.h" - - -class TorEvents : public QObject -{ - Q_OBJECT - -public: - /** Asynchronous events sent from Tor to the controller */ - enum TorEvent { - Unknown, - Bandwidth, - LogDebug, LogInfo, LogNotice, LogWarn, LogError, - CircuitStatus, - StreamStatus, - OrConnStatus, - NewDescriptor, - AddressMap, - GeneralStatus, - ClientStatus, - ServerStatus - }; - - /** Default Constructor */ - TorEvents(); - - /** Adds an event and interested object to the event list */ - void add(TorEvent event, QObject *obj); - /** Removes obj from the list of target objects for event - * e. */ - void remove(TorEvent event, QObject *obj); - /** Returns true if an event has any registered handlers */ - bool contains(TorEvent event); - /** Returns the list of events in which we're interested */ - QList eventList(); - - /** Parses an event message and emits the proper signal */ - void handleEvent(const ControlReply &reply); - - /** Dispatches a given event to all its handler targets. */ - void dispatch(TorEvent e, QEvent *event); - - /** Converts an Event to a string */ - static QString toString(TorEvents::TorEvent e); - /** Converts a log severity to an event */ - static TorEvent toTorEvent(LogEvent::Severity severity); - - -private: - /** Stores a mapping of Tor events to a list of the objects interested in - * hearing about those events. */ - QMultiHash _eventList; - - /** Parses the event type from the event message */ - static TorEvent parseEventType(const ReplyLine &line); - /** Converts a string to an Event */ - static TorEvent toTorEvent(const QString &event); - - /** Handle a bandwidth update event */ - void handleBandwidthUpdate(const ReplyLine &line); - /** Handle a circuit status event */ - void handleCircuitStatus(const ReplyLine &line); - /** Handle a stream status event */ - void handleStreamStatus(const ReplyLine &line); - /** Handle a log message event */ - void handleLogMessage(const ReplyLine &line); - /** Handle an OR connection status event. */ - void handleOrConnStatus(const ReplyLine &line); - /** Handles a new list of descriptors event. */ - void handleNewDescriptor(const ReplyLine &line); - /** Handles a new or updated address map event. */ - void handleAddressMap(const ReplyLine &line); - /** Handles a Tor status event. */ - void handleStatusEvent(TorEvent type, const ReplyLine &line); - - /** Parses and posts a Tor client status event. */ - void dispatchClientStatusEvent(tc::Severity severity, - const QString &action, - const QHash &args); - /** Parses and posts a Tor server status event. */ - void dispatchServerStatusEvent(tc::Severity severity, - const QString &action, - const QHash &args); - /** Parses and posts a general Tor status event. */ - void dispatchGeneralStatusEvent(tc::Severity severity, - const QString &action, - const QHash &args); -}; - -#endif - diff -Nru vidalia-0.1.13/src/torcontrol/TorEvents.h vidalia-0.2.8/src/torcontrol/TorEvents.h --- vidalia-0.1.13/src/torcontrol/TorEvents.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/TorEvents.h 2009-08-20 04:41:13.000000000 +0100 @@ -0,0 +1,255 @@ +/* +** 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.vidalia-project.net/. 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 TorEvents.h +** \version $Id: TorEvents.h 4060 2009-08-20 03:41:13Z edmanm $ +** \brief Parses and dispatches events from Tor +*/ + +#ifndef _TOREVENTS_H +#define _TOREVENTS_H + +#include "tcglobal.h" + +#include +#include +#include +#include + +class Circuit; +class Stream; +class BootstrapStatus; +class ControlReply; +class ReplyLine; + +class QString; +class QDateTime; +class QHostAddress; + + +class TorEvents : public QObject +{ + Q_OBJECT + +public: + /** Asynchronous events sent from Tor to the controller */ + enum Event { + Unknown = 0, + Bandwidth = (1u << 0), + LogDebug = (1u << 1), + LogInfo = (1u << 2), + LogNotice = (1u << 3), + LogWarn = (1u << 4), + LogError = (1u << 5), + CircuitStatus = (1u << 6), + StreamStatus = (1u << 7), + OrConnStatus = (1u << 8), + NewDescriptor = (1u << 9), + AddressMap = (1u << 10), + GeneralStatus = (1u << 11), + ClientStatus = (1u << 12), + ServerStatus = (1u << 13) + }; + static const Event EVENT_MIN = TorEvents::Bandwidth; + static const Event EVENT_MAX = TorEvents::ServerStatus; + Q_DECLARE_FLAGS(Events, Event); + + /** Default Constructor */ + TorEvents(QObject *parent = 0); + + /** Parses an event message and emits the proper signal */ + void handleEvent(const ControlReply &reply); + + /** Converts an Event to a string */ + static QString toString(TorEvents::Event e); + +signals: + /** Emitted when Tor writes the message msg to the control port + * with message severity level. + */ + void logMessage(tc::Severity level, const QString &msg); + + /** Emitted when Tor sends a bandwidth usage update (roughly once every + * second). bytesReceived is the number of bytes read by Tor over + * the previous second and bytesWritten is the number of bytes + * sent over the same interval. + */ + void bandwidthUpdate(quint64 bytesReceived, quint64 bytesSent); + + /** Emitted when the stream status of stream has changed. + */ + void streamStatusChanged(const Stream &stream); + + /** Emitted when the circuit status of circuit has changed. + */ + void circuitStatusChanged(const Circuit &circuit); + + /** Emitted when Tor has mapped the address from to the address + * to. expires indicates the time at which when the address + * mapping will no longer be considered valid. + */ + void addressMapped(const QString &from, const QString &to, + const QDateTime &expires); + + /** Emitted when Tor has received one or more new router descriptors. + * ids contains a list of digests of the new descriptors. + */ + void newDescriptors(const QStringList &ids); + + /** Indicates Tor has been able to successfully establish one or more + * circuits. + */ + void circuitEstablished(); + + /** Indicates that Tor has decided the user's Tor software version + * is no longer recommended for some reason. recommended is + * a list of Tor software versions that are considered current. + */ + void dangerousTorVersion(tc::TorVersionStatus reason, + const QString &version, + const QStringList &recommended); + + /** Emitted during Tor's startup process to indicate how far in its + * bootstrapping process it has progressed. status may indicate + * the current bootstrapping stage or an error during bootstrapping. + */ + void bootstrapStatusChanged(const BootstrapStatus &status); + + /** Emitted when the user attempts to establish a connection to some + * destination on port port, which is a port known to use + * plaintext connections (as determined by Tor's WarnPlaintextPorts and + * RejectPlaintextPorts torrc options). rejected indicates whether + * Tor rejected the connection or permitted it to connect anyway. + */ + void dangerousPort(quint16 port, bool rejected); + + /** Emitted when Tor detects a problem with a SOCKS connection from the + * user, such as a bad hostname, dangerous SOCKS protocol type, or a bad + * hostname. type indicates the type of error encountered and + * destination (if non-empty) specifies the attempted connection + * destination address or hostname. + */ + void socksError(tc::SocksError error, const QString &destination); + + /** Emitted when Tor has encountered an internal bug. reason is + * Tor's description of the bug. + */ + void bug(const QString &reason); + + /** Emitted when Tor decides the client's external IP address has changed + * to ip. If hostname is non-empty, Tor obtained the new + * value for ip by resolving hostname. + */ + void externalAddressChanged(const QHostAddress &ip, const QString &hostname); + + /** Indicates that Tor has determined the client's clock is potentially + * skewed by skew seconds relative to source. + */ + void clockSkewed(int skew, const QString &source); + + /** Emitted when Tor determines that the user's DNS provider is providing + * an address for non-existent domains when it should really be saying + * "NXDOMAIN". + */ + void dnsHijacked(); + + /** Emitted when Tor determines that the user's DNS provider is providing + * a hijacked address even for well-known websites. + */ + void dnsUseless(); + + /** Indicates Tor has started testing the reachability of its OR port + * using the IP address ip and port port. + */ + void checkingOrPortReachability(const QHostAddress &ip, quint16 port); + + /** Tor has completed testing the reachability of its OR port using + * the IP address ip and port port. If the user's OR port + * was reachable, reachable will be set to true. + */ + void orPortReachabilityFinished(const QHostAddress &ip, quint16 port, + bool reachable); + + /** Indicates Tor has started testing the reachability of its directory + * port using the IP address ip and port port. + */ + void checkingDirPortReachability(const QHostAddress &ip, quint16 port); + + /** Tor has completed testing the reachability of its directory port using + * the IP address ip and port port. If the user's directory + * port was reachable, reachable will be set to true. + */ + void dirPortReachabilityFinished(const QHostAddress &ip, quint16 port, + bool reachable); + + /** Emitted when the directory authority with IP address ip and + * port port rejected the user's server descriptor. reason + * describes why the descriptor was rejected (e.g., malformed, skewed + * clock, etc.). + */ + void serverDescriptorRejected(const QHostAddress &ip, quint16 port, + const QString &reason); + + /** Emitted when the directory authority with IP address ip and + * port port accepted the user's server descriptor. + */ + void serverDescriptorAccepted(const QHostAddress &ip, quint16 port); + + /** Emitted when at least one directory authority has accepted the user's + * server descriptor. + */ + void serverDescriptorAccepted(); + +private: + /** Parses the event type from the event message */ + static Event parseEventType(const ReplyLine &line); + /** Converts a string to an Event */ + static Event toTorEvent(const QString &event); + /** Splits a string in the form "IP:PORT" into a QHostAddress and quint16 + * pair. If either portion is invalid, a default-constructed QPair() is + * returned. */ + static QPair splitAddress(const QString &address); + + /** Handle a bandwidth update event */ + void handleBandwidthUpdate(const ReplyLine &line); + /** Handle a circuit status event */ + void handleCircuitStatus(const ReplyLine &line); + /** Handle a stream status event */ + void handleStreamStatus(const ReplyLine &line); + /** Handle a log message event */ + void handleLogMessage(const ReplyLine &line); + /** Handle an OR connection status event. */ + void handleOrConnStatus(const ReplyLine &line); + /** Handles a new list of descriptors event. */ + void handleNewDescriptor(const ReplyLine &line); + /** Handles a new or updated address map event. */ + void handleAddressMap(const ReplyLine &line); + + /** Handles a Tor status event. */ + void handleStatusEvent(Event type, const ReplyLine &line); + /** Parses and posts a general Tor status event. */ + void handleGeneralStatusEvent(tc::Severity severity, + const QString &action, + const QHash &args); + /** Parses and posts a Tor client status event. */ + void handleClientStatusEvent(tc::Severity severity, + const QString &action, + const QHash &args); + /** Parses and posts a Tor server status event. */ + void handleServerStatusEvent(tc::Severity severity, + const QString &action, + const QHash &args); +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(TorEvents::Events) + +#endif + diff -Nru vidalia-0.1.13/src/torcontrol/torprocess.cpp vidalia-0.2.8/src/torcontrol/torprocess.cpp --- vidalia-0.1.13/src/torcontrol/torprocess.cpp 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/torprocess.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,202 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 torprocess.cpp -** \version $Id: torprocess.cpp 2695 2008-06-12 06:50:05Z edmanm $ -** \brief Starts and stops a Tor process -*/ - -#include -#include -#include "tcglobal.h" - -/* Needed for _PROCESS_INFORMATION so that pid() works on Win32 */ -#if defined (Q_OS_WIN32) -#include -#endif - -#include "torprocess.h" - - -/** Default constructor */ -TorProcess::TorProcess(QObject *parent) -: QProcess(parent) -{ - openStdout(); - connect(this, SIGNAL(readyReadStandardOutput()), - this, SLOT(onReadyRead())); - connect(this, SIGNAL(error(QProcess::ProcessError)), - this, SLOT(onError(QProcess::ProcessError))); -} - -/** Formats the Tor process arguments for logging. */ -QString -TorProcess::formatArguments(const QStringList &args) -{ - QStringList out; - foreach (QString arg, args) { - out << (arg.contains(" ") || arg.isEmpty() ? string_escape(arg) : arg); - } - return out.join(" "); -} - -/** Attempts to start the Tor process using the location, executable, and - * command-line arguments specified in Vidalia's settings. If Tor starts, the - * signal started() will be emitted. If Tor fails to start, - * startFailed(errmsg) will be emitted, with an appropriate error message. */ -void -TorProcess::start(const QString &app, const QStringList &args) -{ - QString exe = app; -#if defined(Q_OS_WIN32) - /* If we're on Windows, QProcess::start requires that paths with spaces are - * quoted before being passed to it. */ - exe = "\"" + exe + "\""; -#endif - - /* Attempt to start Tor with the given command-line arguments */ - QStringList env = QProcess::systemEnvironment(); -#if !defined(Q_OS_WIN32) - /* Add "/usr/sbin" to an existing $PATH - * XXX What if they have no path? Would always just making one with - * "/usr/sbin" smart? Should we add anything else? */ - for (int i = 0; i < env.size(); i++) { - QString envVar = env.at(i); - if (envVar.startsWith("PATH=")) - env.replace(i, envVar += ":/usr/sbin"); - } -#endif - setEnvironment(env); - - tc::debug("Starting Tor using '%1 %2'").arg(app).arg(formatArguments(args)); - QProcess::start(exe, args, QIODevice::ReadOnly | QIODevice::Text); -} - -/** Stops the Tor process */ -bool -TorProcess::stop(QString *errmsg) -{ - /* First, check if the process is already stopped before closing it - * forcefully. */ - if (state() == QProcess::NotRunning) { - return true; - } - - tc::debug("Stopping the Tor process."); - /* Tell the process to stop */ -#if defined(Q_OS_WIN32) - /* Tor on Windows doesn't understand a WM_CLOSE message (which is what - * QProcess::terminate() sends it), so we have to kill it harshly. */ - kill(); -#else - terminate(); - - /* Wait for it to complete */ - if (!waitForFinished(5000)) { - tc::error("Tor failed to stop: %1").arg(errorString()); - if (errmsg) { - *errmsg = - tr("Process %1 failed to stop. [%2]").arg(pid()).arg(errorString()); - } - return false; - } -#endif - return true; -} - -/** Return the process ID for the current process. */ -quint64 -TorProcess::pid() -{ -#if defined(Q_OS_WIN32) - return (quint64)((QProcess::pid())->dwProcessId); -#else - return QProcess::pid(); -#endif -} - -/** Opens logging on stdout. When this is open, the log() signal will be - * emitted when Tor prints a message to stdout. */ -void -TorProcess::openStdout() -{ - setReadChannelMode(QProcess::MergedChannels); - setReadChannel(QProcess::StandardOutput); -} - -/** Closes logging on stdout. When this is closed, the log() signal will not - * be emitted when Tor prints a message to stdout. */ -void -TorProcess::closeStdout() -{ - /* Close the stdout channel */ - closeReadChannel(QProcess::StandardOutput); - /* Read anything left waiting on the buffer */ - onReadyRead(); -} - -/** Called when there is data to be read from stdout */ -void -TorProcess::onReadyRead() -{ - int i, j; - QString line; - - while (canReadLine()) { - line = readLine(); - if (!line.isEmpty()) { - /* Parse the log message and emit log() */ - i = line.indexOf("["); - j = line.indexOf("]"); - if (i > 0 && j > i && line.length() >= j+2) { - emit log(line.mid(i+1, j-i-1), line.mid(j+2)); - } - } - } -} - -/** Called when the process encounters an error. If the error tells us that - * the process failed to start, then we will emit the startFailed() signal and - * an error message indicating why. */ -void -TorProcess::onError(QProcess::ProcessError error) -{ - if (error == QProcess::FailedToStart) { - tc::error("The Tor process failed to start: %1").arg(errorString()); - /* Tor didn't start, so let everyone know why. */ - emit startFailed(errorString()); - } else { - tc::error("Tor process error: %1").arg(errorString()); - } -} - -/** Returns the version reported by the Tor executable specified in - * exe, or a default-constructed QString on failure. */ -QString -TorProcess::version(const QString &exe) -{ - QProcess tor; - - tor.start(exe, QStringList() << "--version"); - if (!tor.waitForStarted() || !tor.waitForFinished()) - return QString(); - - while (tor.canReadLine()) { - QString line = tor.readLine(); - if (line.startsWith("Tor version", Qt::CaseInsensitive)) { - QStringList parts = line.split(" "); - if (parts.size() >= 3) - return parts.at(2); - } - } - return QString(); -} - diff -Nru vidalia-0.1.13/src/torcontrol/TorProcess.cpp vidalia-0.2.8/src/torcontrol/TorProcess.cpp --- vidalia-0.1.13/src/torcontrol/TorProcess.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/TorProcess.cpp 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,203 @@ +/* +** 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.vidalia-project.net/. 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 TorProcess.cpp +** \version $Id: TorProcess.cpp 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Starts and stops a Tor process +*/ + +#include "TorProcess.h" +#include "tcglobal.h" + +#include "stringutil.h" + +#include + +/* Needed for _PROCESS_INFORMATION so that pid() works on Win32 */ +#if defined (Q_OS_WIN32) +#include +#endif + + +/** Default constructor */ +TorProcess::TorProcess(QObject *parent) +: QProcess(parent) +{ + openStdout(); + connect(this, SIGNAL(readyReadStandardOutput()), + this, SLOT(onReadyRead())); + connect(this, SIGNAL(error(QProcess::ProcessError)), + this, SLOT(onError(QProcess::ProcessError))); +} + +/** Formats the Tor process arguments for logging. */ +QString +TorProcess::formatArguments(const QStringList &args) +{ + QStringList out; + foreach (QString arg, args) { + out << (arg.contains(" ") || arg.isEmpty() ? string_escape(arg) : arg); + } + return out.join(" "); +} + +/** Attempts to start the Tor process using the location, executable, and + * command-line arguments specified in Vidalia's settings. If Tor starts, the + * signal started() will be emitted. If Tor fails to start, + * startFailed(errmsg) will be emitted, with an appropriate error message. */ +void +TorProcess::start(const QString &app, const QStringList &args) +{ + QString exe = app; +#if defined(Q_OS_WIN32) + /* If we're on Windows, QProcess::start requires that paths with spaces are + * quoted before being passed to it. */ + exe = "\"" + exe + "\""; +#endif + + /* Attempt to start Tor with the given command-line arguments */ + QStringList env = QProcess::systemEnvironment(); +#if !defined(Q_OS_WIN32) + /* Add "/usr/sbin" to an existing $PATH + * XXX What if they have no path? Would always just making one with + * "/usr/sbin" smart? Should we add anything else? */ + for (int i = 0; i < env.size(); i++) { + QString envVar = env.at(i); + if (envVar.startsWith("PATH=")) + env.replace(i, envVar += ":/usr/sbin"); + } +#endif + setEnvironment(env); + + tc::debug("Starting Tor using '%1 %2'").arg(app).arg(formatArguments(args)); + QProcess::start(exe, args, QIODevice::ReadOnly | QIODevice::Text); +} + +/** Stops the Tor process */ +bool +TorProcess::stop(QString *errmsg) +{ + /* First, check if the process is already stopped before closing it + * forcefully. */ + if (state() == QProcess::NotRunning) { + return true; + } + + tc::debug("Stopping the Tor process."); + /* Tell the process to stop */ +#if defined(Q_OS_WIN32) + /* Tor on Windows doesn't understand a WM_CLOSE message (which is what + * QProcess::terminate() sends it), so we have to kill it harshly. */ + kill(); +#else + terminate(); + + /* Wait for it to complete */ + if (!waitForFinished(5000)) { + tc::error("Tor failed to stop: %1").arg(errorString()); + if (errmsg) { + *errmsg = + tr("Process %1 failed to stop. [%2]").arg(pid()).arg(errorString()); + } + return false; + } +#endif + return true; +} + +/** Return the process ID for the current process. */ +quint64 +TorProcess::pid() +{ +#if defined(Q_OS_WIN32) + return (quint64)((QProcess::pid())->dwProcessId); +#else + return QProcess::pid(); +#endif +} + +/** Opens logging on stdout. When this is open, the log() signal will be + * emitted when Tor prints a message to stdout. */ +void +TorProcess::openStdout() +{ + setReadChannelMode(QProcess::MergedChannels); + setReadChannel(QProcess::StandardOutput); +} + +/** Closes logging on stdout. When this is closed, the log() signal will not + * be emitted when Tor prints a message to stdout. */ +void +TorProcess::closeStdout() +{ + /* Close the stdout channel */ + closeReadChannel(QProcess::StandardOutput); + /* Read anything left waiting on the buffer */ + onReadyRead(); +} + +/** Called when there is data to be read from stdout */ +void +TorProcess::onReadyRead() +{ + int i, j; + QString line; + + while (canReadLine()) { + line = readLine(); + if (!line.isEmpty()) { + /* Parse the log message and emit log() */ + i = line.indexOf("["); + j = line.indexOf("]"); + if (i > 0 && j > i && line.length() >= j+2) { + emit log(line.mid(i+1, j-i-1), line.mid(j+2)); + } + } + } +} + +/** Called when the process encounters an error. If the error tells us that + * the process failed to start, then we will emit the startFailed() signal and + * an error message indicating why. */ +void +TorProcess::onError(QProcess::ProcessError error) +{ + if (error == QProcess::FailedToStart) { + tc::error("The Tor process failed to start: %1").arg(errorString()); + /* Tor didn't start, so let everyone know why. */ + emit startFailed(errorString()); + } else { + tc::error("Tor process error: %1").arg(errorString()); + } +} + +/** Returns the version reported by the Tor executable specified in + * exe, or a default-constructed QString on failure. */ +QString +TorProcess::version(const QString &exe) +{ + QProcess tor; + + tor.start(exe, QStringList() << "--version"); + if (!tor.waitForStarted() || !tor.waitForFinished()) + return QString(); + + while (tor.canReadLine()) { + QString line = tor.readLine(); + if (line.startsWith("Tor version", Qt::CaseInsensitive)) { + QStringList parts = line.split(" "); + if (parts.size() >= 3) + return parts.at(2); + } + } + return QString(); +} + diff -Nru vidalia-0.1.13/src/torcontrol/torprocess.h vidalia-0.2.8/src/torcontrol/torprocess.h --- vidalia-0.1.13/src/torcontrol/torprocess.h 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/torprocess.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,67 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 torprocess.h -** \version $Id: torprocess.h 2362 2008-02-29 04:30:11Z edmanm $ -** \brief Starts and stops a Tor process -*/ - -#ifndef _TORPROCESS_H -#define _TORPROCESS_H - -#include - - -class TorProcess : public QProcess -{ - Q_OBJECT - -public: - /** Default constructor. */ - TorProcess(QObject *parent = 0); - - /** Start the Tor process */ - void start(const QString &app, const QStringList &args); - /** Stop the Tor process */ - bool stop(QString *errmsg = 0); - - /** Return the Tor process's PID (workaround for some Windows funkiness) */ - quint64 pid(); - - /** Enable reading log messages from stdout. */ - void openStdout(); - /** Disable reading log messages from stdout. */ - void closeStdout(); - - /** Returns the version reported by the Tor executable specified in - * exe, or a default-constructed QString on failure. */ - static QString version(const QString &exe); - -signals: - /** Emitted when Tor prints a log message to the console */ - void log(const QString &severity, const QString &message); - /** Emitted when Tor fails to start, perhaps because the path to Tor was - * bogus. */ - void startFailed(const QString &errorMessage); - -private slots: - /** Called when there is data to be read from stdout */ - void onReadyRead(); - /** Called when an error occurs in the process. */ - void onError(QProcess::ProcessError error); - -private: - /** Formats the Tor process arguments for logging. */ - QString formatArguments(const QStringList &args); -}; - -#endif - diff -Nru vidalia-0.1.13/src/torcontrol/TorProcess.h vidalia-0.2.8/src/torcontrol/TorProcess.h --- vidalia-0.1.13/src/torcontrol/TorProcess.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/TorProcess.h 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,67 @@ +/* +** 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.vidalia-project.net/. 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 TorProcess.h +** \version $Id: TorProcess.h 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Starts and stops a Tor process +*/ + +#ifndef _TORPROCESS_H +#define _TORPROCESS_H + +#include + + +class TorProcess : public QProcess +{ + Q_OBJECT + +public: + /** Default constructor. */ + TorProcess(QObject *parent = 0); + + /** Start the Tor process */ + void start(const QString &app, const QStringList &args); + /** Stop the Tor process */ + bool stop(QString *errmsg = 0); + + /** Return the Tor process's PID (workaround for some Windows funkiness) */ + quint64 pid(); + + /** Enable reading log messages from stdout. */ + void openStdout(); + /** Disable reading log messages from stdout. */ + void closeStdout(); + + /** Returns the version reported by the Tor executable specified in + * exe, or a default-constructed QString on failure. */ + static QString version(const QString &exe); + +signals: + /** Emitted when Tor prints a log message to the console */ + void log(const QString &severity, const QString &message); + /** Emitted when Tor fails to start, perhaps because the path to Tor was + * bogus. */ + void startFailed(const QString &errorMessage); + +private slots: + /** Called when there is data to be read from stdout */ + void onReadyRead(); + /** Called when an error occurs in the process. */ + void onError(QProcess::ProcessError error); + +private: + /** Formats the Tor process arguments for logging. */ + QString formatArguments(const QStringList &args); +}; + +#endif + diff -Nru vidalia-0.1.13/src/torcontrol/torservice.cpp vidalia-0.2.8/src/torcontrol/torservice.cpp --- vidalia-0.1.13/src/torcontrol/torservice.cpp 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/torservice.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,312 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 torservice.cpp -** \version $Id: torservice.cpp 2695 2008-06-12 06:50:05Z edmanm $ -** \brief Starts, stops, installs, and uninstalls a Tor service (Win32). -*/ - -#include - -#include "tcglobal.h" -#include "torservice.h" - -/** Returned by TorService::exitCode() when we are unable to determine the - * actual exit code of the service (unless, of course, Tor returns -999999). */ -#define UNKNOWN_EXIT_CODE -999999 - -/** List of dynamically loaded NT service functions. */ -ServiceFunctions TorService::_service_fns = - { false, - NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL }; - - -/** Default ctor. */ -TorService::TorService(QObject *parent) - : QObject(parent) -{ - _scm = openSCM(); -} - -/** Default dtor. */ -TorService::~TorService() -{ - closeHandle(_scm); -} - -/** Returns true if services are supported. */ -bool -TorService::isSupported() -{ - return (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based); -} - -/** Dyanmically loads NT service related functions from advapi32.dll. This - * function is adapted from Tor's nt_service_load_library() function. See - * LICENSE for details on Tor's license. */ -bool -TorService::loadServiceFunctions() -{ -#define LOAD_SERVICE_FN(f) do { \ - void *fn; \ - if (!((fn = QLibrary::resolve("advapi32", #f)))) { \ - return false; \ - } else { \ - _service_fns.f = (f ## _fn) fn; \ - } \ - } while (0) - - if (!isSupported()) { - _service_fns.loaded = false; - } else if (!_service_fns.loaded) { - LOAD_SERVICE_FN(ChangeServiceConfig2A); - LOAD_SERVICE_FN(CloseServiceHandle); - LOAD_SERVICE_FN(ControlService); - LOAD_SERVICE_FN(CreateServiceA); - LOAD_SERVICE_FN(DeleteService); - LOAD_SERVICE_FN(OpenSCManagerA); - LOAD_SERVICE_FN(OpenServiceA); - LOAD_SERVICE_FN(QueryServiceStatus); - LOAD_SERVICE_FN(SetServiceStatus); - LOAD_SERVICE_FN(StartServiceA); - _service_fns.loaded = true; - } - return _service_fns.loaded; -} - -/** Opens a handle to the Tor service. Returns NULL on error. */ -SC_HANDLE -TorService::openService() -{ - if (!loadServiceFunctions()) - return NULL; - if (!_scm) - return NULL; - return _service_fns.OpenServiceA(_scm, - (LPCTSTR)TOR_SERVICE_NAME, - TOR_SERVICE_ACCESS); -} - -/** Opens a handle to the service control manager. Returns NULL on error. */ -SC_HANDLE -TorService::openSCM() -{ - if (!loadServiceFunctions()) - return NULL; - return _service_fns.OpenSCManagerA(NULL, NULL, SC_MANAGER_ALL_ACCESS); -} - -/** Closes the service handle. */ -void -TorService::closeHandle(SC_HANDLE handle) -{ - if (!loadServiceFunctions()) - return; - _service_fns.CloseServiceHandle(handle); -} - -/** Returns true if the Tor service is installed. */ -bool -TorService::isInstalled() -{ - bool installed; - SC_HANDLE service = openService(); - installed = (service != NULL); - closeHandle(service); - return installed; -} - -/** Returns true if the Tor service is running. */ -bool -TorService::isRunning() -{ - return (status() == SERVICE_RUNNING); -} - -/** Starts Tor service. */ -void -TorService::start() -{ - SC_HANDLE service = openService(); - - if (!service) { - tc::error("Bug: We tried to start the Tor service, but it is not installed."); - emit startFailed(tr("The Tor service is not installed.")); - return; - } - - /* Starting a service can take up to 30 seconds! */ - if (status() != SERVICE_RUNNING) { - int tries = 0; - tc::debug("Starting the Tor service."); - _service_fns.StartServiceA(service, 0, NULL); - - while ((status() != SERVICE_RUNNING) && ++tries <= 5) - Sleep(1000); - } - - if (status() == SERVICE_RUNNING) { - emit started(); - } else { - tc::error("Unable to start the Tor service."); - emit startFailed(tr("Unable to start the Tor service.")); - } - closeHandle(service); -} - -/** Stops Tor service. */ -bool -TorService::stop() -{ - SC_HANDLE service = openService(); - - if (!service) - return false; - - if (status() != SERVICE_STOPPED) { - SERVICE_STATUS stat; - stat.dwCurrentState = SERVICE_RUNNING; - tc::debug("Stopping the Tor service."); - if (_service_fns.ControlService(service, SERVICE_CONTROL_STOP, &stat)) { - /* XXX Five seconds isn't long enough to wait when we're stopping a Tor - * that is running as a server, but we don't want to block for 30 - * seconds. It would be nice if we could get an async notification when - * the service stops or fails to stop. */ - int tries = 0; - while ((status() != SERVICE_STOPPED) && (++tries <= 5)) - Sleep(1000); - } - } - closeHandle(service); - - /* Find out if the service really stopped and return the result */ - if (status() == SERVICE_STOPPED) { - emit finished(exitCode(), exitStatus()); - return true; - } - /* XXX This needs an actual reason message. */ - tc::error("Unable to stop the Tor service."); - return false; -} - -/** Returns the exit code of the last Tor service that finished. */ -int -TorService::exitCode() -{ - SC_HANDLE service; - int exitCode = UNKNOWN_EXIT_CODE; - - service = openService(); - if (service) { - SERVICE_STATUS s; - if (_service_fns.QueryServiceStatus(service, &s)) { - /* Services return one exit code, but it could be in one of two - * variables. Fun. */ - exitCode = (int)(s.dwWin32ExitCode == ERROR_SERVICE_SPECIFIC_ERROR - ? s.dwServiceSpecificExitCode - : s.dwWin32ExitCode); - } - closeHandle(service); - } - return exitCode; -} - -/** Returns the exit status of the last Tor service that finished. */ -QProcess::ExitStatus -TorService::exitStatus() -{ - /* NT services don't really have an equivalent to QProcess::CrashExit, so - * this just returns QProcess::NormalExit. Tor _could_ set - * dwServiceSpecificExitCode to some magic value when it starts and then - * set it to the real exit code when Tor exits. Then we would know if the - * service crashed when dwServiceSpecificExitCode is still the magic value. - * However, I don't care and it doesn't really matter anyway. */ - return QProcess::NormalExit; -} - -/** Installs the Tor service. Returns true if the service was successfully - * installed or already exists. */ -bool -TorService::install(const QString &torPath, const QString &torrc, - quint16 controlPort) -{ - SC_HANDLE service; - - if (!_scm) - return false; - - service = openService(); - if (!service) { - QString command = QString("\"%1\" --nt-service -f \"%2\" ControlPort %3") - .arg(torPath) - .arg(torrc) - .arg(controlPort); - - tc::debug("Installing the Tor service using the command line '%1'") - .arg(command); - service = _service_fns.CreateServiceA(_scm, - (LPCTSTR)TOR_SERVICE_NAME, (LPCTSTR)TOR_SERVICE_DISP, - TOR_SERVICE_ACCESS, SERVICE_WIN32_OWN_PROCESS, - SERVICE_AUTO_START, SERVICE_ERROR_IGNORE, - (LPCTSTR)command.toAscii().data(), NULL, NULL, NULL, - NULL, NULL); - if (!service) { - /* XXX This needs an actual reason message. */ - tc::error("Failed to install the Tor service."); - return false; - } - - SERVICE_DESCRIPTION desc; - desc.lpDescription = TOR_SERVICE_DESC; - _service_fns.ChangeServiceConfig2A(service, - SERVICE_CONFIG_DESCRIPTION, &desc); - closeHandle(service); - } - return true; -} - -/** Removes the Tor service. Returns true if the service was removed - * successfully or does not exist. */ -bool -TorService::remove() -{ - bool removed = true; - SC_HANDLE service = openService(); - - if (service) { - stop(); - tc::debug("Removing the Tor service."); - removed = _service_fns.DeleteService(service); - closeHandle(service); - } - if (!removed) { - /* XXX This needs an actual reason message. */ - tc::error("Failed to remove the Tor service."); - } - return removed; -} - -/** Gets the status of the Tor service. */ -DWORD -TorService::status() -{ - SC_HANDLE service; - SERVICE_STATUS s; - DWORD stat = SERVICE_ERROR; - - service = openService(); - if (service && _service_fns.QueryServiceStatus(service, &s)) - stat = s.dwCurrentState; - closeHandle(service); - return stat; -} - diff -Nru vidalia-0.1.13/src/torcontrol/TorService.cpp vidalia-0.2.8/src/torcontrol/TorService.cpp --- vidalia-0.1.13/src/torcontrol/TorService.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/TorService.cpp 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,313 @@ +/* +** 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.vidalia-project.net/. 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 TorService.cpp +** \version $Id: TorService.cpp 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Starts, stops, installs, and uninstalls a Tor service (Win32). +*/ + +#include "TorService.h" +#include "tcglobal.h" + +#include + +/** Returned by TorService::exitCode() when we are unable to determine the + * actual exit code of the service (unless, of course, Tor returns -999999). */ +#define UNKNOWN_EXIT_CODE -999999 + +/** List of dynamically loaded NT service functions. */ +ServiceFunctions TorService::_service_fns = + { false, + NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL + }; + + +/** Default ctor. */ +TorService::TorService(QObject *parent) + : QObject(parent) +{ + _scm = openSCM(); +} + +/** Default dtor. */ +TorService::~TorService() +{ + closeHandle(_scm); +} + +/** Returns true if services are supported. */ +bool +TorService::isSupported() +{ + return (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based); +} + +/** Dyanmically loads NT service related functions from advapi32.dll. This + * function is adapted from Tor's nt_service_load_library() function. See + * LICENSE for details on Tor's license. */ +bool +TorService::loadServiceFunctions() +{ +#define LOAD_SERVICE_FN(f) do { \ + void *fn; \ + if (!((fn = QLibrary::resolve("advapi32", #f)))) { \ + return false; \ + } else { \ + _service_fns.f = (f ## _fn) fn; \ + } \ + } while (0) + + if (!isSupported()) { + _service_fns.loaded = false; + } else if (!_service_fns.loaded) { + LOAD_SERVICE_FN(ChangeServiceConfig2A); + LOAD_SERVICE_FN(CloseServiceHandle); + LOAD_SERVICE_FN(ControlService); + LOAD_SERVICE_FN(CreateServiceA); + LOAD_SERVICE_FN(DeleteService); + LOAD_SERVICE_FN(OpenSCManagerA); + LOAD_SERVICE_FN(OpenServiceA); + LOAD_SERVICE_FN(QueryServiceStatus); + LOAD_SERVICE_FN(SetServiceStatus); + LOAD_SERVICE_FN(StartServiceA); + _service_fns.loaded = true; + } + return _service_fns.loaded; +} + +/** Opens a handle to the Tor service. Returns NULL on error. */ +SC_HANDLE +TorService::openService() +{ + if (!loadServiceFunctions()) + return NULL; + if (!_scm) + return NULL; + return _service_fns.OpenServiceA(_scm, + (LPCTSTR)TOR_SERVICE_NAME, + TOR_SERVICE_ACCESS); +} + +/** Opens a handle to the service control manager. Returns NULL on error. */ +SC_HANDLE +TorService::openSCM() +{ + if (!loadServiceFunctions()) + return NULL; + return _service_fns.OpenSCManagerA(NULL, NULL, SC_MANAGER_ALL_ACCESS); +} + +/** Closes the service handle. */ +void +TorService::closeHandle(SC_HANDLE handle) +{ + if (!loadServiceFunctions()) + return; + _service_fns.CloseServiceHandle(handle); +} + +/** Returns true if the Tor service is installed. */ +bool +TorService::isInstalled() +{ + bool installed; + SC_HANDLE service = openService(); + installed = (service != NULL); + closeHandle(service); + return installed; +} + +/** Returns true if the Tor service is running. */ +bool +TorService::isRunning() +{ + return (status() == SERVICE_RUNNING); +} + +/** Starts Tor service. */ +void +TorService::start() +{ + SC_HANDLE service = openService(); + + if (!service) { + tc::error("Bug: We tried to start the Tor service, but it is not installed."); + emit startFailed(tr("The Tor service is not installed.")); + return; + } + + /* Starting a service can take up to 30 seconds! */ + if (status() != SERVICE_RUNNING) { + int tries = 0; + tc::debug("Starting the Tor service."); + _service_fns.StartServiceA(service, 0, NULL); + + while ((status() != SERVICE_RUNNING) && ++tries <= 5) + Sleep(1000); + } + + if (status() == SERVICE_RUNNING) { + emit started(); + } else { + tc::error("Unable to start the Tor service."); + emit startFailed(tr("Unable to start the Tor service.")); + } + closeHandle(service); +} + +/** Stops Tor service. */ +bool +TorService::stop() +{ + SC_HANDLE service = openService(); + + if (!service) + return false; + + if (status() != SERVICE_STOPPED) { + SERVICE_STATUS stat; + stat.dwCurrentState = SERVICE_RUNNING; + tc::debug("Stopping the Tor service."); + if (_service_fns.ControlService(service, SERVICE_CONTROL_STOP, &stat)) { + /* XXX Five seconds isn't long enough to wait when we're stopping a Tor + * that is running as a server, but we don't want to block for 30 + * seconds. It would be nice if we could get an async notification when + * the service stops or fails to stop. */ + int tries = 0; + while ((status() != SERVICE_STOPPED) && (++tries <= 5)) + Sleep(1000); + } + } + closeHandle(service); + + /* Find out if the service really stopped and return the result */ + if (status() == SERVICE_STOPPED) { + emit finished(exitCode(), exitStatus()); + return true; + } + /* XXX This needs an actual reason message. */ + tc::error("Unable to stop the Tor service."); + return false; +} + +/** Returns the exit code of the last Tor service that finished. */ +int +TorService::exitCode() +{ + SC_HANDLE service; + int exitCode = UNKNOWN_EXIT_CODE; + + service = openService(); + if (service) { + SERVICE_STATUS s; + if (_service_fns.QueryServiceStatus(service, &s)) { + /* Services return one exit code, but it could be in one of two + * variables. Fun. */ + exitCode = (int)(s.dwWin32ExitCode == ERROR_SERVICE_SPECIFIC_ERROR + ? s.dwServiceSpecificExitCode + : s.dwWin32ExitCode); + } + closeHandle(service); + } + return exitCode; +} + +/** Returns the exit status of the last Tor service that finished. */ +QProcess::ExitStatus +TorService::exitStatus() +{ + /* NT services don't really have an equivalent to QProcess::CrashExit, so + * this just returns QProcess::NormalExit. Tor _could_ set + * dwServiceSpecificExitCode to some magic value when it starts and then + * set it to the real exit code when Tor exits. Then we would know if the + * service crashed when dwServiceSpecificExitCode is still the magic value. + * However, I don't care and it doesn't really matter anyway. */ + return QProcess::NormalExit; +} + +/** Installs the Tor service. Returns true if the service was successfully + * installed or already exists. */ +bool +TorService::install(const QString &torPath, const QString &torrc, + quint16 controlPort) +{ + SC_HANDLE service; + + if (!_scm) + return false; + + service = openService(); + if (!service) { + QString command = QString("\"%1\" --nt-service -f \"%2\" ControlPort %3") + .arg(torPath) + .arg(torrc) + .arg(controlPort); + + tc::debug("Installing the Tor service using the command line '%1'") + .arg(command); + service = _service_fns.CreateServiceA(_scm, + (LPCTSTR)TOR_SERVICE_NAME, (LPCTSTR)TOR_SERVICE_DISP, + TOR_SERVICE_ACCESS, SERVICE_WIN32_OWN_PROCESS, + SERVICE_AUTO_START, SERVICE_ERROR_IGNORE, + (LPCTSTR)command.toAscii().data(), NULL, NULL, NULL, + NULL, NULL); + if (!service) { + /* XXX This needs an actual reason message. */ + tc::error("Failed to install the Tor service."); + return false; + } + + SERVICE_DESCRIPTION desc; + desc.lpDescription = TOR_SERVICE_DESC; + _service_fns.ChangeServiceConfig2A(service, + SERVICE_CONFIG_DESCRIPTION, &desc); + closeHandle(service); + } + return true; +} + +/** Removes the Tor service. Returns true if the service was removed + * successfully or does not exist. */ +bool +TorService::remove() +{ + bool removed = true; + SC_HANDLE service = openService(); + + if (service) { + stop(); + tc::debug("Removing the Tor service."); + removed = _service_fns.DeleteService(service); + closeHandle(service); + } + if (!removed) { + /* XXX This needs an actual reason message. */ + tc::error("Failed to remove the Tor service."); + } + return removed; +} + +/** Gets the status of the Tor service. */ +DWORD +TorService::status() +{ + SC_HANDLE service; + SERVICE_STATUS s; + DWORD stat = SERVICE_ERROR; + + service = openService(); + if (service && _service_fns.QueryServiceStatus(service, &s)) + stat = s.dwCurrentState; + closeHandle(service); + return stat; +} + diff -Nru vidalia-0.1.13/src/torcontrol/torservice.h vidalia-0.2.8/src/torcontrol/torservice.h --- vidalia-0.1.13/src/torcontrol/torservice.h 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/torservice.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,152 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 torservice.h -** \version $Id: torservice.h 2362 2008-02-29 04:30:11Z edmanm $ -** \brief Starts, stops, installs, and uninstalls a Tor service (Win32). -*/ - -#ifndef _TORSERVICE_H -#define _TORSERVICE_H - -#include -#include - -#include -#define TOR_SERVICE_NAME "tor" -#define TOR_SERVICE_DISP "Tor Win32 Service" -#define TOR_SERVICE_DESC \ - TEXT("Provides an anonymous Internet communication system.") -#define TOR_SERVICE_ACCESS SERVICE_ALL_ACCESS -#define SERVICE_ERROR 8 - -/* NT service function prototypes. This code is adapted from Tor's - * nt_service_load_library() in main.c. See LICENSE for details on - * Tor's license. */ -typedef BOOL (WINAPI *ChangeServiceConfig2A_fn)( - SC_HANDLE hService, - DWORD dwInfoLevel, - LPVOID lpInfo); -typedef BOOL (WINAPI *CloseServiceHandle_fn)( - SC_HANDLE hSCObject); -typedef BOOL (WINAPI *ControlService_fn)( - SC_HANDLE hService, - DWORD dwControl, - LPSERVICE_STATUS lpServiceStatus); -typedef SC_HANDLE (WINAPI *CreateServiceA_fn)( - SC_HANDLE hSCManager, - LPCTSTR lpServiceName, - LPCTSTR lpDisplayName, - DWORD dwDesiredAccess, - DWORD dwServiceType, - DWORD dwStartType, - DWORD dwErrorControl, - LPCTSTR lpBinaryPathName, - LPCTSTR lpLoadOrderGroup, - LPDWORD lpdwTagId, - LPCTSTR lpDependencies, - LPCTSTR lpServiceStartName, - LPCTSTR lpPassword); -typedef BOOL (WINAPI *DeleteService_fn)( - SC_HANDLE hService); -typedef SC_HANDLE (WINAPI *OpenSCManagerA_fn)( - LPCTSTR lpMachineName, - LPCTSTR lpDatabaseName, - DWORD dwDesiredAccess); -typedef SC_HANDLE (WINAPI *OpenServiceA_fn)( - SC_HANDLE hSCManager, - LPCTSTR lpServiceName, - DWORD dwDesiredAccess); -typedef BOOL (WINAPI *QueryServiceStatus_fn)( - SC_HANDLE hService, - LPSERVICE_STATUS lpServiceStatus); -typedef BOOL (WINAPI *SetServiceStatus_fn)(SERVICE_STATUS_HANDLE, - LPSERVICE_STATUS); -typedef BOOL (WINAPI *StartServiceA_fn)( - SC_HANDLE hService, - DWORD dwNumServiceArgs, - LPCTSTR* lpServiceArgVectors); - -/** Table of NT service related functions. */ -struct ServiceFunctions { - bool loaded; - ChangeServiceConfig2A_fn ChangeServiceConfig2A; - CloseServiceHandle_fn CloseServiceHandle; - ControlService_fn ControlService; - CreateServiceA_fn CreateServiceA; - DeleteService_fn DeleteService; - OpenSCManagerA_fn OpenSCManagerA; - OpenServiceA_fn OpenServiceA; - QueryServiceStatus_fn QueryServiceStatus; - SetServiceStatus_fn SetServiceStatus; - StartServiceA_fn StartServiceA; -}; - - -class TorService : public QObject -{ - Q_OBJECT - -public: - /** Returns if services are supported. */ - static bool isSupported(); - /** Dynamically loads NT service related functions from advapi32.dll. */ - static bool loadServiceFunctions(); - - /** Default ctor. */ - TorService(QObject* parent = 0); - /** Default dtor. */ - ~TorService(); - - /** Returns true if the Tor service is installed. */ - bool isInstalled(); - /** Returns true if the Tor service is running. */ - bool isRunning(); - /** Starts the Tor service. Emits started on success. */ - void start(); - /** Stops the Tor service. Emits finished on success. */ - bool stop(); - /** Returns the exit code of the last Tor service that finished. */ - int exitCode(); - /** Returns the exit status of the last Tor service that finished. */ - QProcess::ExitStatus exitStatus(); - /** Installs the Tor service. */ - bool install(const QString &torPath, const QString &torrc, - quint16 controlPort); - /** Removes the Tor service. */ - bool remove(); - -signals: - /** Called when the service gets started. */ - void started(); - /** Called when the service gets stopped. */ - void finished(int exitCode, QProcess::ExitStatus); - /** Called when there is an error in starting the service. */ - void startFailed(QString error); - -private: - /** Opens a handle to the Tor service. Returns NULL on error. */ - SC_HANDLE openService(); - /** Opens a handle to the service control manager. Returns NULL on error. */ - static SC_HANDLE openSCM(); - /** Closes the service handle. */ - static void closeHandle(SC_HANDLE handle); - /** Gets the status of the Tor service. */ - DWORD status(); - - /** Handle to the service control manager. */ - SC_HANDLE _scm; - /** List of dynamically loaded NT service functions. */ - static ServiceFunctions _service_fns; -}; - -#endif - diff -Nru vidalia-0.1.13/src/torcontrol/TorService.h vidalia-0.2.8/src/torcontrol/TorService.h --- vidalia-0.1.13/src/torcontrol/TorService.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/TorService.h 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,152 @@ +/* +** 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.vidalia-project.net/. 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 torservice.h +** \version $Id: TorService.h 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Starts, stops, installs, and uninstalls a Tor service (Win32). +*/ + +#ifndef _TORSERVICE_H +#define _TORSERVICE_H + +#include +#include + +#include +#define TOR_SERVICE_NAME "tor" +#define TOR_SERVICE_DISP "Tor Win32 Service" +#define TOR_SERVICE_DESC \ + TEXT("Provides an anonymous Internet communication system.") +#define TOR_SERVICE_ACCESS SERVICE_ALL_ACCESS +#define SERVICE_ERROR 8 + +/* NT service function prototypes. This code is adapted from Tor's + * nt_service_load_library() in main.c. See LICENSE for details on + * Tor's license. */ +typedef BOOL (WINAPI *ChangeServiceConfig2A_fn)( + SC_HANDLE hService, + DWORD dwInfoLevel, + LPVOID lpInfo); +typedef BOOL (WINAPI *CloseServiceHandle_fn)( + SC_HANDLE hSCObject); +typedef BOOL (WINAPI *ControlService_fn)( + SC_HANDLE hService, + DWORD dwControl, + LPSERVICE_STATUS lpServiceStatus); +typedef SC_HANDLE (WINAPI *CreateServiceA_fn)( + SC_HANDLE hSCManager, + LPCTSTR lpServiceName, + LPCTSTR lpDisplayName, + DWORD dwDesiredAccess, + DWORD dwServiceType, + DWORD dwStartType, + DWORD dwErrorControl, + LPCTSTR lpBinaryPathName, + LPCTSTR lpLoadOrderGroup, + LPDWORD lpdwTagId, + LPCTSTR lpDependencies, + LPCTSTR lpServiceStartName, + LPCTSTR lpPassword); +typedef BOOL (WINAPI *DeleteService_fn)( + SC_HANDLE hService); +typedef SC_HANDLE (WINAPI *OpenSCManagerA_fn)( + LPCTSTR lpMachineName, + LPCTSTR lpDatabaseName, + DWORD dwDesiredAccess); +typedef SC_HANDLE (WINAPI *OpenServiceA_fn)( + SC_HANDLE hSCManager, + LPCTSTR lpServiceName, + DWORD dwDesiredAccess); +typedef BOOL (WINAPI *QueryServiceStatus_fn)( + SC_HANDLE hService, + LPSERVICE_STATUS lpServiceStatus); +typedef BOOL (WINAPI *SetServiceStatus_fn)(SERVICE_STATUS_HANDLE, + LPSERVICE_STATUS); +typedef BOOL (WINAPI *StartServiceA_fn)( + SC_HANDLE hService, + DWORD dwNumServiceArgs, + LPCTSTR* lpServiceArgVectors); + +/** Table of NT service related functions. */ +struct ServiceFunctions { + bool loaded; + ChangeServiceConfig2A_fn ChangeServiceConfig2A; + CloseServiceHandle_fn CloseServiceHandle; + ControlService_fn ControlService; + CreateServiceA_fn CreateServiceA; + DeleteService_fn DeleteService; + OpenSCManagerA_fn OpenSCManagerA; + OpenServiceA_fn OpenServiceA; + QueryServiceStatus_fn QueryServiceStatus; + SetServiceStatus_fn SetServiceStatus; + StartServiceA_fn StartServiceA; +}; + + +class TorService : public QObject +{ + Q_OBJECT + +public: + /** Returns if services are supported. */ + static bool isSupported(); + /** Dynamically loads NT service related functions from advapi32.dll. */ + static bool loadServiceFunctions(); + + /** Default ctor. */ + TorService(QObject* parent = 0); + /** Default dtor. */ + ~TorService(); + + /** Returns true if the Tor service is installed. */ + bool isInstalled(); + /** Returns true if the Tor service is running. */ + bool isRunning(); + /** Starts the Tor service. Emits started on success. */ + void start(); + /** Stops the Tor service. Emits finished on success. */ + bool stop(); + /** Returns the exit code of the last Tor service that finished. */ + int exitCode(); + /** Returns the exit status of the last Tor service that finished. */ + QProcess::ExitStatus exitStatus(); + /** Installs the Tor service. */ + bool install(const QString &torPath, const QString &torrc, + quint16 controlPort); + /** Removes the Tor service. */ + bool remove(); + +signals: + /** Called when the service gets started. */ + void started(); + /** Called when the service gets stopped. */ + void finished(int exitCode, QProcess::ExitStatus); + /** Called when there is an error in starting the service. */ + void startFailed(QString error); + +private: + /** Opens a handle to the Tor service. Returns NULL on error. */ + SC_HANDLE openService(); + /** Opens a handle to the service control manager. Returns NULL on error. */ + static SC_HANDLE openSCM(); + /** Closes the service handle. */ + static void closeHandle(SC_HANDLE handle); + /** Gets the status of the Tor service. */ + DWORD status(); + + /** Handle to the service control manager. */ + SC_HANDLE _scm; + /** List of dynamically loaded NT service functions. */ + static ServiceFunctions _service_fns; +}; + +#endif + diff -Nru vidalia-0.1.13/src/torcontrol/torsignal.cpp vidalia-0.2.8/src/torcontrol/torsignal.cpp --- vidalia-0.1.13/src/torcontrol/torsignal.cpp 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/torsignal.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,35 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 torsignal.cpp -** \version $Id: torsignal.cpp 2362 2008-02-29 04:30:11Z edmanm $ -** \brief Sends a signal to Tor's control interface -*/ - -#include "torsignal.h" - -/** Returns a string representation of a signal that Tor understands. */ -QString -TorSignal::toString(Signal signal) -{ - QString sigtype; - switch (signal) { - case Reload: sigtype = "RELOAD"; break; - case Shutdown: sigtype = "SHUTDOWN"; break; - case Dump: sigtype = "DUMP"; break; - case Debug: sigtype = "DEBUG"; break; - case Halt: sigtype = "HALT"; break; - case NewNym: sigtype = "NEWNYM"; break; - default: return "UNKNOWN"; - } - return sigtype; -} - diff -Nru vidalia-0.1.13/src/torcontrol/TorSignal.cpp vidalia-0.2.8/src/torcontrol/TorSignal.cpp --- vidalia-0.1.13/src/torcontrol/TorSignal.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/TorSignal.cpp 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,36 @@ +/* +** 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.vidalia-project.net/. 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 TorSignal.cpp +** \version $Id: TorSignal.cpp 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Sends a signal to Tor's control interface +*/ + +#include "TorSignal.h" + + +/** Returns a string representation of a signal that Tor understands. */ +QString +TorSignal::toString(Signal signal) +{ + QString sigtype; + switch (signal) { + case Reload: sigtype = "RELOAD"; break; + case Shutdown: sigtype = "SHUTDOWN"; break; + case Dump: sigtype = "DUMP"; break; + case Debug: sigtype = "DEBUG"; break; + case Halt: sigtype = "HALT"; break; + case NewNym: sigtype = "NEWNYM"; break; + default: return "UNKNOWN"; + } + return sigtype; +} + diff -Nru vidalia-0.1.13/src/torcontrol/torsignal.h vidalia-0.2.8/src/torcontrol/torsignal.h --- vidalia-0.1.13/src/torcontrol/torsignal.h 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/torsignal.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,41 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 torsignal.h -** \version $Id: torsignal.h 2362 2008-02-29 04:30:11Z edmanm $ -** \brief Sends a signal to Tor's control interface -*/ - -#ifndef _TORSIGNAL_H -#define _TORSGINAL_H - -#include - - -class TorSignal -{ -public: - /** Signals that can be sent by the controller */ - enum Signal { - Reload, /**< SIGHUP: Reloads config items and refetch directory */ - Shutdown, /**< SIGINT: Controlled shutdown */ - Dump, /**< SIGUSR1: Log information about current circuits */ - Debug, /**< SIGUSR2: Switch all open logs to loglevel debug */ - Halt, /**< SIGTERM: Immediate shutdown */ - NewNym /**< NEWNYM: Switch to all new clean circuits */ - }; - - /** Returns a string representation of a signal that Tor understands. */ - static QString toString(Signal signal); -}; - -#endif - diff -Nru vidalia-0.1.13/src/torcontrol/TorSignal.h vidalia-0.2.8/src/torcontrol/TorSignal.h --- vidalia-0.1.13/src/torcontrol/TorSignal.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/TorSignal.h 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,41 @@ +/* +** 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.vidalia-project.net/. 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 TorSignal.h +** \version $Id: TorSignal.h 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Sends a signal to Tor's control interface +*/ + +#ifndef _TORSIGNAL_H +#define _TORSGINAL_H + +#include + + +class TorSignal +{ +public: + /** Signals that can be sent by the controller */ + enum Signal { + Reload, /**< SIGHUP: Reloads config items and refetch directory */ + Shutdown, /**< SIGINT: Controlled shutdown */ + Dump, /**< SIGUSR1: Log information about current circuits */ + Debug, /**< SIGUSR2: Switch all open logs to loglevel debug */ + Halt, /**< SIGTERM: Immediate shutdown */ + NewNym /**< NEWNYM: Switch to all new clean circuits */ + }; + + /** Returns a string representation of a signal that Tor understands. */ + static QString toString(Signal signal); +}; + +#endif + diff -Nru vidalia-0.1.13/src/torcontrol/unrecognizedclientstatusevent.h vidalia-0.2.8/src/torcontrol/unrecognizedclientstatusevent.h --- vidalia-0.1.13/src/torcontrol/unrecognizedclientstatusevent.h 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/unrecognizedclientstatusevent.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,48 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 unrecognizedclientstatusevent.h -** \version $Id: unrecognizedclientstatusevent.h 2780 2008-06-21 21:48:32Z edmanm $ -** \brief Client status event with an unrecognized status value -*/ - -#ifndef _UNRECOGNIZEDCLIENTSTATUSEVENT_H -#define _UNRECOGNIZEDCLIENTSTATUSEVENT_H - -#include -#include "clientstatusevent.h" - - -class UnrecognizedClientStatusEvent : public ClientStatusEvent -{ -public: - /** Constructor. statusString is the unrecognized client status value - * string and args is the (possibly empty) list of status event - * arguments. */ - UnrecognizedClientStatusEvent(tc::Severity severity, - const QString &statusString, - const QHash &args) - : ClientStatusEvent(severity, ClientStatusEvent::UnrecognizedStatus), - _statusString(statusString), _args(args) {} - - /** Returns the status string for this client status event. */ - QString statusString() const { return _statusString; } - /** Returns a (possibly empty) list of status event arguments given for this - * event. */ - QHash arguments() const { return _args; } - -private: - QString _statusString; /**< Name of the unrecognized status event. */ - QHash _args; /**< Status event arguments. */ -}; - -#endif - diff -Nru vidalia-0.1.13/src/torcontrol/unrecognizedgeneralstatusevent.h vidalia-0.2.8/src/torcontrol/unrecognizedgeneralstatusevent.h --- vidalia-0.1.13/src/torcontrol/unrecognizedgeneralstatusevent.h 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/unrecognizedgeneralstatusevent.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,48 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 unrecognizedgeneralstatusevent.h -** \version $Id: unrecognizedgeneralstatusevent.h 2780 2008-06-21 21:48:32Z edmanm $ -** \brief General status event with an unrecognized status value -*/ - -#ifndef _UNRECOGNIZEDGENERALSTATUSEVENT_H -#define _UNRECOGNIZEDGENERALSTATUSEVENT_H - -#include -#include "generalstatusevent.h" - - -class UnrecognizedGeneralStatusEvent : public GeneralStatusEvent -{ -public: - /** Constructor. statusString is the unrecognized general status - * string and args is the (possibly empty) list of status event - * arguments. */ - UnrecognizedGeneralStatusEvent(tc::Severity severity, - const QString &statusString, - const QHash &args) - : GeneralStatusEvent(severity, GeneralStatusEvent::UnrecognizedStatus), - _statusString(statusString), _args(args) {} - - /** Returns the status string for this general status event. */ - QString statusString() const { return _statusString; } - /** Returns a (possibly empty) list of status event arguments given for this - * event. */ - QHash arguments() const { return _args; } - -private: - QString _statusString; /**< Name of the unrecognized status event. */ - QHash _args; /**< Status event arguments. */ -}; - -#endif - diff -Nru vidalia-0.1.13/src/torcontrol/unrecognizedserverstatusevent.h vidalia-0.2.8/src/torcontrol/unrecognizedserverstatusevent.h --- vidalia-0.1.13/src/torcontrol/unrecognizedserverstatusevent.h 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/torcontrol/unrecognizedserverstatusevent.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,48 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 unrecognizedserverstatusevent.h -** \version $Id: unrecognizedserverstatusevent.h 2780 2008-06-21 21:48:32Z edmanm $ -** \brief Server status event with an unrecognized status value -*/ - -#ifndef _UNRECOGNIZEDSERVERSTATUSEVENT_H -#define _UNRECOGNIZEDSERVERSTATUSEVENT_H - -#include -#include "serverstatusevent.h" - - -class UnrecognizedServerStatusEvent : public ServerStatusEvent -{ -public: - /** Constructor. statusString is the unrecognized server status value - * string we and args is the (possibly empty) list of status event - * arguments. */ - UnrecognizedServerStatusEvent(tc::Severity severity, - const QString &statusString, - const QHash &args) - : ServerStatusEvent(severity, ServerStatusEvent::UnrecognizedStatus), - _statusString(statusString), _args(args) {} - - /** Returns the status string for this server status event. */ - QString statusString() const { return _statusString; } - /** Returns a (possibly empty) list of status event arguments given for this - * event. */ - QHash arguments() const { return _args; } - -private: - QString _statusString; /**< Name of the unrecognized status event. */ - QHash _args; /**< Status event arguments. */ -}; - -#endif - diff -Nru vidalia-0.1.13/src/vidalia/about/aboutdialog.cpp vidalia-0.2.8/src/vidalia/about/aboutdialog.cpp --- vidalia-0.1.13/src/vidalia/about/aboutdialog.cpp 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/about/aboutdialog.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,71 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 aboutdialog.cpp -** \version $Id: aboutdialog.cpp 2983 2008-08-17 05:59:43Z edmanm $ -** \brief Displays information about Vidalia, Tor, and Qt -*/ - -#include -#include -#include "aboutdialog.h" - - -/** Default Constructor **/ -AboutDialog::AboutDialog(QWidget *parent, Qt::WFlags flags) -: VidaliaWindow("AboutDialog", parent, flags) -{ - ui.setupUi(this); - - /* Pressing 'Esc' or 'Ctrl+W' will close the window */ - setShortcut("Esc", SLOT(close())); - setShortcut("Ctrl+W", SLOT(close())); - - /* Save the TorControl object to use later */ - _torControl = Vidalia::torControl(); - - /* Get Vidalia's version number */ - ui.lblVidaliaVersion->setText(Vidalia::version()); - - /* Get Qt's version number */ - ui.lblQtVersion->setText(QT_VERSION_STR); - - /* Load the brief licensing information and hide it initally */ - loadLicense(); -} - -/** Loads the license information */ -void -AboutDialog::loadLicense() -{ - QFile licenseFile(":/docs/short_license.txt"); - licenseFile.open(QFile::ReadOnly); - ui.txtLicense->setPlainText(licenseFile.readAll()); - licenseFile.close(); -} - -/** Displays the About dialog window **/ -void -AboutDialog::showWindow() -{ - /* Access the TorControl object to retrieve version */ - if (_torControl->isRunning()) { - QString version = _torControl->getTorVersionString(); - if (version.isEmpty()) { - version = tr(""); - } - ui.lblTorVersion->setText(version); - } else { - ui.lblTorVersion->setText(tr("")); - } - VidaliaWindow::showWindow(); -} - diff -Nru vidalia-0.1.13/src/vidalia/about/AboutDialog.cpp vidalia-0.2.8/src/vidalia/about/AboutDialog.cpp --- vidalia-0.1.13/src/vidalia/about/AboutDialog.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/about/AboutDialog.cpp 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,62 @@ +/* +** 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.vidalia-project.net/. 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 AboutDialog.cpp +** \version $Id: AboutDialog.cpp 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Displays information about Vidalia, Tor, and Qt +*/ + +#include "AboutDialog.h" +#include "LicenseDialog.h" +#include "Vidalia.h" + +#include +#include +#include + + +/** Default Constructor. */ +AboutDialog::AboutDialog(QWidget *parent, Qt::WindowFlags flags) + : QDialog(parent, Qt::CustomizeWindowHint | Qt::WindowSystemMenuHint) +{ + ui.setupUi(this); + + /* Add a "License" button to the button box at the bottom */ + QPushButton *licenseButton; + licenseButton = ui.buttonBox->addButton(tr("License"), + QDialogButtonBox::ActionRole); + + /* Get Vidalia's version number */ + ui.lblVidaliaVersion->setText(QString("Vidalia %1").arg(Vidalia::version())); + + /* Get Tor's version number or hide it if Tor isn't running */ + if (Vidalia::torControl()->isConnected()) { + QString version = Vidalia::torControl()->getTorVersionString(); + if (! version.isEmpty()) + ui.lblTorVersion->setText(QString("Tor %1").arg(version)); + else + ui.lblTorVersion->setVisible(false); + } else { + ui.lblTorVersion->setVisible(false); + } + + /* Get Qt's version number */ + ui.lblQtVersion->setText(QString("Qt %1").arg(QT_VERSION_STR)); + + /* Display the license information dialog when the "License" button + * is clicked. */ + connect(licenseButton, SIGNAL(clicked()), + new LicenseDialog(this), SLOT(exec())); + + /* Close this dialog when the "Close" button is clicked */ + connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(reject())); +} + diff -Nru vidalia-0.1.13/src/vidalia/about/aboutdialog.h vidalia-0.2.8/src/vidalia/about/aboutdialog.h --- vidalia-0.1.13/src/vidalia/about/aboutdialog.h 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/about/aboutdialog.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,48 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 aboutdialog.h -** \version $Id: aboutdialog.h 2362 2008-02-29 04:30:11Z edmanm $ -** \brief Displays information about Vidalia, Tor, and Qt -*/ - -#ifndef _ABOUTDIALOG_H -#define _ABOUTDIALOG_H - -#include -#include -#include "ui_aboutdialog.h" - - -class AboutDialog : public VidaliaWindow -{ - Q_OBJECT - -public: - /** Default constructor **/ - AboutDialog(QWidget *parent = 0, Qt::WFlags flags = 0); - -public slots: - /** Overriden VidaliaWindow::showWindow() */ - void showWindow(); - -private: - /** Loads the license file */ - void loadLicense(); - - /** Qt Designer generated QObject **/ - Ui::AboutDialog ui; - /** TorControl for access to Tor version info **/ - TorControl *_torControl; -}; - -#endif - diff -Nru vidalia-0.1.13/src/vidalia/about/AboutDialog.h vidalia-0.2.8/src/vidalia/about/AboutDialog.h --- vidalia-0.1.13/src/vidalia/about/AboutDialog.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/about/AboutDialog.h 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,37 @@ +/* +** 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.vidalia-project.net/. 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 AboutDialog.h +** \version $Id: AboutDialog.h 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Displays information about Vidalia, Tor, and Qt +*/ + +#ifndef _ABOUTDIALOG_H +#define _ABOUTDIALOG_H + +#include "ui_AboutDialog.h" +#include "LicenseDialog.h" + + +class AboutDialog : public QDialog +{ + Q_OBJECT + +public: + /** Default constructor */ + AboutDialog(QWidget *parent = 0, Qt::WindowFlags flags = 0); + +private: + Ui::AboutDialog ui; /**< Qt Designer generated QObject **/ +}; + +#endif + diff -Nru vidalia-0.1.13/src/vidalia/about/aboutdialog.ui vidalia-0.2.8/src/vidalia/about/aboutdialog.ui --- vidalia-0.1.13/src/vidalia/about/aboutdialog.ui 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/about/aboutdialog.ui 1970-01-01 01:00:00.000000000 +0100 @@ -1,311 +0,0 @@ - - - - - AboutDialog - - - - 0 - 0 - 500 - 420 - - - - - 500 - 420 - - - - Qt::NoContextMenu - - - About Vidalia - - - :/images/32x32/help-about.png - - - - - 9 - - - 6 - - - - - 0 - - - 6 - - - - - - 5 - 0 - 0 - 0 - - - - Qt::NoContextMenu - - - - - - :/images/128x128/tor-on.png - - - Qt::AlignCenter - - - - - - - - true - - - - Vidalia - - - Qt::AlignCenter - - - - - - - Vidalia Version - - - Qt::AlignCenter - - - true - - - - - - - Qt::Vertical - - - QSizePolicy::Preferred - - - - 20 - 40 - - - - - - - - - - 0 - - - 6 - - - - - - 5 - 0 - 0 - 0 - - - - Qt::NoContextMenu - - - - - - :/images/128x128/qt-logo.png - - - Qt::AlignCenter - - - - - - - - true - - - - Qt - - - Qt::AlignCenter - - - - - - - Qt Version - - - Qt::AlignCenter - - - true - - - - - - - Qt::Vertical - - - QSizePolicy::Preferred - - - - 20 - 40 - - - - - - - - - - 0 - - - 6 - - - - - - 5 - 0 - 0 - 0 - - - - Qt::NoContextMenu - - - - - - :/images/128x128/tor-logo.png - - - Qt::AlignCenter - - - - - - - - true - - - - Tor - - - Qt::AlignCenter - - - - - - - Tor Version - - - Qt::AlignCenter - - - true - - - - - - - Qt::Vertical - - - QSizePolicy::Preferred - - - - 20 - 41 - - - - - - - - - - - 10 - - - - Qt::NoContextMenu - - - QTextEdit::FixedColumnWidth - - - 78 - - - true - - - - - - - - - 0 - 398 - 500 - 22 - - - - - - - - - - diff -Nru vidalia-0.1.13/src/vidalia/about/AboutDialog.ui vidalia-0.2.8/src/vidalia/about/AboutDialog.ui --- vidalia-0.1.13/src/vidalia/about/AboutDialog.ui 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/about/AboutDialog.ui 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,108 @@ + + AboutDialog + + + Qt::NonModal + + + + 0 + 0 + 215 + 271 + + + + + 0 + 0 + + + + + 0 + 0 + + + + About Vidalia + + + false + + + + + + + 0 + 132 + + + + + + + :/images/128x128/tor-logo.png + + + Qt::AlignCenter + + + + + + + + 75 + false + true + + + + Vidalia 0.2.0 + + + Qt::AlignCenter + + + + + + + Tor 0.2.0.32 + + + Qt::AlignCenter + + + + + + + + false + + + + Qt 4.4.2 + + + Qt::AlignCenter + + + + + + + QDialogButtonBox::Close + + + + + + + + + + diff -Nru vidalia-0.1.13/src/vidalia/about/LicenseDialog.cpp vidalia-0.2.8/src/vidalia/about/LicenseDialog.cpp --- vidalia-0.1.13/src/vidalia/about/LicenseDialog.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/about/LicenseDialog.cpp 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,41 @@ +/* +** 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.vidalia-project.net/. 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 LicenseDialog.cpp +** \version $Id: LicenseDialog.cpp 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Displays HTML-formatted license information for Vidalia and related +** software. +*/ + +#include "LicenseDialog.h" + +#include +#include + + +LicenseDialog::LicenseDialog(QWidget *parent) + : QDialog(parent) +{ + ui.setupUi(this); + + ui.txtLicense->setHtml(loadHtml(":/docs/license.html")); + ui.txtCredits->setHtml(loadHtml(":/docs/credits.html")); +} + +QString +LicenseDialog::loadHtml(const QString &source) const +{ + QFile file(source); + if (! file.open(QIODevice::ReadOnly | QIODevice::Text)) + return QString(); + return QString(file.readAll()); +} + diff -Nru vidalia-0.1.13/src/vidalia/about/LicenseDialog.h vidalia-0.2.8/src/vidalia/about/LicenseDialog.h --- vidalia-0.1.13/src/vidalia/about/LicenseDialog.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/about/LicenseDialog.h 2009-04-28 21:28:01.000000000 +0100 @@ -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.vidalia-project.net/. 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 LicenseDialog.h +** \version $Id: LicenseDialog.h 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Displays HTML-formatted license information for Vidalia and related +** software. +*/ + +#ifndef _LICENSEDIALOG_H +#define _LICENSEDIALOG_H + +#include "ui_LicenseDialog.h" + + +class LicenseDialog : public QDialog +{ + Q_OBJECT + +public: + /** Default constructor. + */ + LicenseDialog(QWidget *parent = 0); + +protected: + /** Reads and returns all HTML-formatted text from source. + */ + virtual QString loadHtml(const QString &source) const; + +private: + Ui::LicenseDialog ui; +}; + +#endif + diff -Nru vidalia-0.1.13/src/vidalia/about/LicenseDialog.ui vidalia-0.2.8/src/vidalia/about/LicenseDialog.ui --- vidalia-0.1.13/src/vidalia/about/LicenseDialog.ui 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/about/LicenseDialog.ui 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,149 @@ + + LicenseDialog + + + + 0 + 0 + 701 + 584 + + + + License Information + + + + 0 + + + + + QLayout::SetDefaultConstraint + + + 12 + + + + + + 0 + 0 + + + + QTabWidget::Rounded + + + 0 + + + + License + + + + + + + + + 0 + 0 + + + + false + + + false + + + true + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + + + Credits + + + + + + + + + 0 + 0 + + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Close + + + + + + + + + + + buttonBox + accepted() + LicenseDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + LicenseDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff -Nru vidalia-0.1.13/src/vidalia/bwgraph/BandwidthGraph.cpp vidalia-0.2.8/src/vidalia/bwgraph/BandwidthGraph.cpp --- vidalia-0.1.13/src/vidalia/bwgraph/BandwidthGraph.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/bwgraph/BandwidthGraph.cpp 2009-08-17 03:25:08.000000000 +0100 @@ -0,0 +1,268 @@ +/* +** 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.vidalia-project.net/. 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 BandwidthGraph.cpp +** \version $Id: BandwidthGraph.cpp 4054 2009-08-17 02:25:08Z edmanm $ +** \brief Displays a graph of Tor's bandwidth usage +*/ + +#include "BandwidthGraph.h" +#include "Vidalia.h" + +#define BWGRAPH_LINE_SEND (1u<<0) +#define BWGRAPH_LINE_RECV (1u<<1) +#define SETTING_FILTER "LineFilter" +#define SETTING_OPACITY "Opacity" +#define SETTING_ALWAYS_ON_TOP "AlwaysOnTop" +#define SETTING_STYLE "GraphStyle" +#define DEFAULT_FILTER (BWGRAPH_LINE_SEND|BWGRAPH_LINE_RECV) +#define DEFAULT_ALWAYS_ON_TOP false +#define DEFAULT_OPACITY 100 +#define DEFAULT_STYLE GraphFrame::AreaGraph + +#define ADD_TO_FILTER(f,v,b) (f = ((b) ? ((f) | (v)) : ((f) & ~(v)))) + +/* Define the format used for displaying the date and time */ +#define DATETIME_FMT "MMM dd hh:mm:ss" + +/* Images used in the graph style drop-down */ +#define IMG_AREA_GRAPH ":/images/16x16/graph-area.png" +#define IMG_LINE_GRAPH ":/images/16x16/graph-line.png" + + +/** Default constructor */ +BandwidthGraph::BandwidthGraph(QWidget *parent, Qt::WFlags flags) + : VidaliaWindow("BandwidthGraph", parent, flags) +{ + /* Invoke Qt Designer generated QObject setup routine */ + ui.setupUi(this); + + /* Ask Tor to notify us about bandwidth updates */ + Vidalia::torControl()->setEvent(TorEvents::Bandwidth); + connect(Vidalia::torControl(), SIGNAL(bandwidthUpdate(quint64,quint64)), + this, SLOT(updateGraph(quint64,quint64))); + + /* Pressing 'Esc' or 'Ctrl+W' will close the window */ + setShortcut("Esc", SLOT(close())); + setShortcut("Ctrl+W", SLOT(close())); + + /* Bind events to actions */ + createActions(); + + /* Initialize Sent/Receive data counters */ + reset(); + /* Hide Bandwidth Graph Settings frame */ + showSettingsFrame(false); + /* Load the previously saved settings */ + loadSettings(); + + /* Turn off opacity group on unsupported platforms */ +#if defined(Q_WS_WIN) + if(!(QSysInfo::WindowsVersion & QSysInfo::WV_NT_based) + || QSysInfo::WindowsVersion < QSysInfo::WV_2000) { + ui.frmOpacity->setVisible(false); + } +#endif + +#if defined(Q_WS_X11) + ui.frmOpacity->setVisible(false); +#endif +} + +/** Called when the user changes the UI translation. */ +void +BandwidthGraph::retranslateUi() +{ + ui.retranslateUi(this); +} + +/** Binds events to actions. */ +void +BandwidthGraph::createActions() +{ + connect(ui.btnToggleSettings, SIGNAL(toggled(bool)), + this, SLOT(showSettingsFrame(bool))); + + connect(ui.btnReset, SIGNAL(clicked()), + this, SLOT(reset())); + + connect(ui.btnSaveSettings, SIGNAL(clicked()), + this, SLOT(saveChanges())); + + connect(ui.btnCancelSettings, SIGNAL(clicked()), + this, SLOT(cancelChanges())); + + connect(ui.sldrOpacity, SIGNAL(valueChanged(int)), + this, SLOT(setOpacity(int))); +} + +/** Adds new data to the graph. */ +void +BandwidthGraph::updateGraph(quint64 bytesRead, quint64 bytesWritten) +{ + /* Graph only cares about kilobytes */ + ui.frmGraph->addPoints(bytesRead/1024.0, bytesWritten/1024.0); +} + +/** Loads the saved Bandwidth Graph settings. */ +void +BandwidthGraph::loadSettings() +{ + /* Set window opacity slider widget */ + ui.sldrOpacity->setValue(getSetting(SETTING_OPACITY, DEFAULT_OPACITY).toInt()); + setOpacity(ui.sldrOpacity->value()); + + /* Set whether the window appears on top. */ + ui.chkAlwaysOnTop->setChecked(getSetting(SETTING_ALWAYS_ON_TOP, + DEFAULT_ALWAYS_ON_TOP).toBool()); + if (ui.chkAlwaysOnTop->isChecked()) { + setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint); + } else { + setWindowFlags(windowFlags() & ~Qt::WindowStaysOnTopHint); + } + + /* Set the line filter checkboxes accordingly */ + uint filter = getSetting(SETTING_FILTER, DEFAULT_FILTER).toUInt(); + ui.chkReceiveRate->setChecked(filter & BWGRAPH_LINE_RECV); + ui.chkSendRate->setChecked(filter & BWGRAPH_LINE_SEND); + + /* Set whether we are plotting bandwidth as area graphs or not */ + int graphStyle = getSetting(SETTING_STYLE, DEFAULT_STYLE).toInt(); + if (graphStyle < 0 || graphStyle >= ui.cmbGraphStyle->count()) { + graphStyle = DEFAULT_STYLE; + } + ui.cmbGraphStyle->setCurrentIndex(graphStyle); + ui.frmGraph->setGraphStyle((GraphFrame::GraphStyle)graphStyle); + + /* Set graph frame settings */ + ui.frmGraph->setShowCounters(ui.chkReceiveRate->isChecked(), + ui.chkSendRate->isChecked()); +} + +/** Resets the log start time. */ +void +BandwidthGraph::reset() +{ + /* Set to current time */ + ui.statusbar->showMessage(tr("Since:") + " " + + QDateTime::currentDateTime() + .toString(DATETIME_FMT)); + /* Reset the graph */ + ui.frmGraph->resetGraph(); +} + +/** Saves the Bandwidth Graph settings and adjusts the graph if necessary. */ +void +BandwidthGraph::saveChanges() +{ + /* Hide the settings frame and reset toggle button */ + showSettingsFrame(false); + + /* Save the opacity and graph style */ + saveSetting(SETTING_OPACITY, ui.sldrOpacity->value()); + saveSetting(SETTING_STYLE, ui.cmbGraphStyle->currentIndex()); + + /* Save the Always On Top setting */ + saveSetting(SETTING_ALWAYS_ON_TOP, ui.chkAlwaysOnTop->isChecked()); + if (ui.chkAlwaysOnTop->isChecked()) { + setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint); + } else { + setWindowFlags(windowFlags() & ~Qt::WindowStaysOnTopHint); + } + setOpacity(ui.sldrOpacity->value()); + + /* Save the line filter values */ + uint filter = 0; + ADD_TO_FILTER(filter, BWGRAPH_LINE_RECV, ui.chkReceiveRate->isChecked()); + ADD_TO_FILTER(filter, BWGRAPH_LINE_SEND, ui.chkSendRate->isChecked()); + saveSetting(SETTING_FILTER, filter); + + + /* Update the graph frame settings */ + ui.frmGraph->setShowCounters(ui.chkReceiveRate->isChecked(), + ui.chkSendRate->isChecked()); + ui.frmGraph->setGraphStyle((GraphFrame::GraphStyle)ui.cmbGraphStyle->currentIndex()); + + /* A change in window flags causes the window to disappear, so make sure + * it's still visible. */ + showNormal(); +} + +/** Simply restores the previously saved settings. */ +void +BandwidthGraph::cancelChanges() +{ + /* Hide the settings frame and reset toggle button */ + showSettingsFrame(false); + + /* Reload the settings */ + loadSettings(); +} + +/** Toggles the Settings pane on and off, changes toggle button text. */ +void +BandwidthGraph::showSettingsFrame(bool show) +{ + static QSize minSize = minimumSize(); + + QSize newSize = size(); + if (show) { + /* Extend the bottom of the bandwidth graph and show the settings */ + ui.frmSettings->setVisible(true); + ui.btnToggleSettings->setChecked(true); + ui.btnToggleSettings->setText(tr("Hide Settings")); + + /* 6 = vertical spacing between the settings frame and graph frame */ + newSize.setHeight(newSize.height() + ui.frmSettings->height() + 6); + } else { + /* Shrink the height of the bandwidth graph and hide the settings */ + ui.frmSettings->setVisible(false); + ui.btnToggleSettings->setChecked(false); + ui.btnToggleSettings->setText(tr("Show Settings")); + + /* 6 = vertical spacing between the settings frame and graph frame */ + newSize.setHeight(newSize.height() - ui.frmSettings->height() - 6); + setMinimumSize(minSize); + } + resize(newSize); +} + +/** Sets the opacity of the Bandwidth Graph window. */ +void +BandwidthGraph::setOpacity(int value) +{ + qreal newValue = value / 100.0; + + /* Opacity only supported by Mac and Win32 */ +#if defined(Q_WS_MAC) + this->setWindowOpacity(newValue); + ui.lblPercentOpacity->setText(QString::number(value)); +#elif defined(Q_WS_WIN) + if (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based + && QSysInfo::WindowsVersion >= QSysInfo::WV_2000) { + this->setWindowOpacity(newValue); + ui.lblPercentOpacity->setText(QString::number(value)); + } +#else + Q_UNUSED(newValue); +#endif +} + +/** Overloads the default show() slot so we can set opacity. */ +void +BandwidthGraph::showWindow() +{ + /* Load saved settings */ + loadSettings(); + /* Show the window */ + VidaliaWindow::showWindow(); +} + diff -Nru vidalia-0.1.13/src/vidalia/bwgraph/BandwidthGraph.h vidalia-0.2.8/src/vidalia/bwgraph/BandwidthGraph.h --- vidalia-0.1.13/src/vidalia/bwgraph/BandwidthGraph.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/bwgraph/BandwidthGraph.h 2009-08-17 03:25:08.000000000 +0100 @@ -0,0 +1,78 @@ +/* +** 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.vidalia-project.net/. 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 BandwidthGraph.h +** \version $Id: BandwidthGraph.h 4054 2009-08-17 02:25:08Z edmanm $ +** \brief Displays a graph of Tor's bandwidth usage +*/ + +#ifndef _BWGRAPH_H +#define _BWGRAPH_H + +#include "ui_BandwidthGraph.h" +#include "VidaliaWindow.h" +#include "VidaliaSettings.h" +#include "TorControl.h" + +#include +#include + +/** Redraw graph every 1000ms **/ +#define REFRESH_RATE 1000 + + +class BandwidthGraph : public VidaliaWindow +{ + Q_OBJECT + +public: + /** Default constructor */ + BandwidthGraph(QWidget *parent = 0, Qt::WFlags flags = 0); + +public slots: + /** Overloaded QWidget.show */ + void showWindow(); + +protected: + /** Called when the user changes the UI translation. */ + virtual void retranslateUi(); + +private slots: + /** Adds new data to the graph */ + void updateGraph(quint64 bytesRead, quint64 bytesWritten); + /** Called when settings button is toggled */ + void showSettingsFrame(bool show); + /** Called when the settings button is toggled */ + void setOpacity(int value); + /** Called when the user saves settings */ + void saveChanges(); + /** Called when the user cancels changes settings */ + void cancelChanges(); + /** Called when the reset button is pressed */ + void reset(); + +private: + /** Create and bind actions to events **/ + void createActions(); + /** Loads the saved Bandwidth Graph settings */ + void loadSettings(); + + /** A TorControl object used to talk to Tor. */ + TorControl* _torControl; + /** A VidaliaSettings object that handles getting/saving settings */ + VidaliaSettings* _settings; + + /** Qt Designer generated object */ + Ui::BandwidthGraph ui; +}; + +#endif + diff -Nru vidalia-0.1.13/src/vidalia/bwgraph/BandwidthGraph.ui vidalia-0.2.8/src/vidalia/bwgraph/BandwidthGraph.ui --- vidalia-0.1.13/src/vidalia/bwgraph/BandwidthGraph.ui 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/bwgraph/BandwidthGraph.ui 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,485 @@ + + BandwidthGraph + + + + 0 + 0 + 283 + 138 + + + + Qt::NoContextMenu + + + Tor Bandwidth Usage + + + :/images/32x32/utilities-system-monitor.png + + + + + 9 + + + 6 + + + + + 0 + + + 6 + + + + + Show Settings + + + true + + + + + + + Qt::Horizontal + + + + 21 + 20 + + + + + + + + Reset + + + + + + + + + + 120 + 80 + + + + + 10 + + + + Qt::NoContextMenu + + + QFrame::Box + + + QFrame::Plain + + + + + + + + 0 + 0 + 0 + 0 + + + + + 355 + 85 + + + + + 355 + 82 + + + + Qt::NoContextMenu + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 9 + + + 6 + + + + + 3 + + + 6 + + + + + Qt::NoContextMenu + + + + + + Qt::RightToLeft + + + Receive Rate + + + false + + + + + + + Qt::NoContextMenu + + + + + + Qt::RightToLeft + + + Send Rate + + + false + + + + + + + Qt::RightToLeft + + + Always on Top + + + + + + + Qt::Vertical + + + + 20 + 21 + + + + + + + + + + 0 + + + 1 + + + + + 0 + + + 6 + + + + + Qt::Horizontal + + + + 20 + 20 + + + + + + + + Style + + + + + + + + + + + :/images/16x16/graph-line.png + + + + + + + + :/images/16x16/graph-area.png + + + + + + + + + + Qt::NoContextMenu + + + QFrame::NoFrame + + + QFrame::Plain + + + + 0 + + + 3 + + + + + Qt::NoContextMenu + + + Changes the transparency of the Bandwidth Graph + + + 30 + + + 100 + + + 100 + + + 100 + + + false + + + Qt::Horizontal + + + false + + + QSlider::NoTicks + + + 10 + + + + + + + Qt::Vertical + + + + 20 + 20 + + + + + + + + 0 + + + 0 + + + + + Qt::Horizontal + + + + 21 + + + + + + + + + 25 + 0 + + + + + 10 + + + + Qt::NoContextMenu + + + Qt::RightToLeft + + + 100 + + + + + + + + 10 + + + + Qt::NoContextMenu + + + % Opaque + + + + + + + Qt::Horizontal + + + + 21 + + + + + + + + + + + + + Qt::Vertical + + + + 21 + 20 + + + + + + + + + + Qt::Horizontal + + + + 21 + 20 + + + + + + + + 0 + + + 1 + + + + + Save + + + + + + + Cancel + + + + + + + + + + + + + + + GraphFrame + QFrame +

bwgraph/GraphFrame.h
+ + + + + + + btnToggleSettings + btnReset + chkReceiveRate + chkSendRate + chkAlwaysOnTop + cmbGraphStyle + sldrOpacity + btnSaveSettings + btnCancelSettings + + + diff -Nru vidalia-0.1.13/src/vidalia/bwgraph/bwgraph.cpp vidalia-0.2.8/src/vidalia/bwgraph/bwgraph.cpp --- vidalia-0.1.13/src/vidalia/bwgraph/bwgraph.cpp 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/bwgraph/bwgraph.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,272 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 bwgraph.cpp -** \version $Id: bwgraph.cpp 2983 2008-08-17 05:59:43Z edmanm $ -** \brief Displays a graph of Tor's bandwidth usage -*/ - -#include -#include -#include "bwgraph.h" - -#define BWGRAPH_LINE_SEND (1u<<0) -#define BWGRAPH_LINE_RECV (1u<<1) -#define SETTING_FILTER "LineFilter" -#define SETTING_OPACITY "Opacity" -#define SETTING_ALWAYS_ON_TOP "AlwaysOnTop" -#define SETTING_STYLE "GraphStyle" -#define DEFAULT_FILTER (BWGRAPH_LINE_SEND|BWGRAPH_LINE_RECV) -#define DEFAULT_ALWAYS_ON_TOP false -#define DEFAULT_OPACITY 100 -#define DEFAULT_STYLE GraphFrame::AreaGraph - -#define ADD_TO_FILTER(f,v,b) (f = ((b) ? ((f) | (v)) : ((f) & ~(v)))) - -/* Define the format used for displaying the date and time */ -#define DATETIME_FMT "MMM dd hh:mm:ss" - -/* Images used in the graph style drop-down */ -#define IMG_AREA_GRAPH ":/images/16x16/graph-area.png" -#define IMG_LINE_GRAPH ":/images/16x16/graph-line.png" - - -/** Default constructor */ -BandwidthGraph::BandwidthGraph(QWidget *parent, Qt::WFlags flags) - : VidaliaWindow("BandwidthGraph", parent, flags) -{ - /* Invoke Qt Designer generated QObject setup routine */ - ui.setupUi(this); - - /* Pressing 'Esc' or 'Ctrl+W' will close the window */ - setShortcut("Esc", SLOT(close())); - setShortcut("Ctrl+W", SLOT(close())); - - /* Bind events to actions */ - createActions(); - - /* Ask Tor to notify us about bandwidth updates */ - _torControl = Vidalia::torControl(); - _torControl->setEvent(TorEvents::Bandwidth, this, true); - - /* Initialize Sent/Receive data counters */ - reset(); - /* Hide Bandwidth Graph Settings frame */ - showSettingsFrame(false); - /* Load the previously saved settings */ - loadSettings(); - - /* Turn off opacity group on unsupported platforms */ -#if defined(Q_WS_WIN) - if(!(QSysInfo::WindowsVersion & QSysInfo::WV_NT_based) - || QSysInfo::WindowsVersion < QSysInfo::WV_2000) { - ui.frmOpacity->setVisible(false); - } -#endif - -#if defined(Q_WS_X11) - ui.frmOpacity->setVisible(false); -#endif -} - -/** Custom event handler. Checks if the event is a bandwidth update event. If it - * is, it will add the data point to the history and updates the graph. */ -void -BandwidthGraph::customEvent(QEvent *event) -{ - if (event->type() == CustomEventType::BandwidthEvent) { - BandwidthEvent *bw = (BandwidthEvent *)event; - updateGraph(bw->bytesRead(), bw->bytesWritten()); - } -} - -/** Binds events to actions. */ -void -BandwidthGraph::createActions() -{ - connect(ui.btnToggleSettings, SIGNAL(toggled(bool)), - this, SLOT(showSettingsFrame(bool))); - - connect(ui.btnReset, SIGNAL(clicked()), - this, SLOT(reset())); - - connect(ui.btnSaveSettings, SIGNAL(clicked()), - this, SLOT(saveChanges())); - - connect(ui.btnCancelSettings, SIGNAL(clicked()), - this, SLOT(cancelChanges())); - - connect(ui.sldrOpacity, SIGNAL(valueChanged(int)), - this, SLOT(setOpacity(int))); -} - -/** Adds new data to the graph. */ -void -BandwidthGraph::updateGraph(quint64 bytesRead, quint64 bytesWritten) -{ - /* Graph only cares about kilobytes */ - ui.frmGraph->addPoints(bytesRead/1024.0, bytesWritten/1024.0); -} - -/** Loads the saved Bandwidth Graph settings. */ -void -BandwidthGraph::loadSettings() -{ - /* Set window opacity slider widget */ - ui.sldrOpacity->setValue(getSetting(SETTING_OPACITY, DEFAULT_OPACITY).toInt()); - setOpacity(ui.sldrOpacity->value()); - - /* Set whether the window appears on top. */ - ui.chkAlwaysOnTop->setChecked(getSetting(SETTING_ALWAYS_ON_TOP, - DEFAULT_ALWAYS_ON_TOP).toBool()); - if (ui.chkAlwaysOnTop->isChecked()) { - setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint); - } else { - setWindowFlags(windowFlags() & ~Qt::WindowStaysOnTopHint); - } - - /* Set the line filter checkboxes accordingly */ - uint filter = getSetting(SETTING_FILTER, DEFAULT_FILTER).toUInt(); - ui.chkReceiveRate->setChecked(filter & BWGRAPH_LINE_RECV); - ui.chkSendRate->setChecked(filter & BWGRAPH_LINE_SEND); - - /* Set whether we are plotting bandwidth as area graphs or not */ - int graphStyle = getSetting(SETTING_STYLE, DEFAULT_STYLE).toInt(); - if (graphStyle < 0 || graphStyle >= ui.cmbGraphStyle->count()) { - graphStyle = DEFAULT_STYLE; - } - ui.cmbGraphStyle->setCurrentIndex(graphStyle); - ui.frmGraph->setGraphStyle((GraphFrame::GraphStyle)graphStyle); - - /* Set graph frame settings */ - ui.frmGraph->setShowCounters(ui.chkReceiveRate->isChecked(), - ui.chkSendRate->isChecked()); -} - -/** Resets the log start time. */ -void -BandwidthGraph::reset() -{ - /* Set to current time */ - ui.statusbar->showMessage(tr("Since:") + " " + - QDateTime::currentDateTime() - .toString(DATETIME_FMT)); - /* Reset the graph */ - ui.frmGraph->resetGraph(); -} - -/** Saves the Bandwidth Graph settings and adjusts the graph if necessary. */ -void -BandwidthGraph::saveChanges() -{ - /* Hide the settings frame and reset toggle button */ - showSettingsFrame(false); - - /* Save the opacity and graph style */ - saveSetting(SETTING_OPACITY, ui.sldrOpacity->value()); - saveSetting(SETTING_STYLE, ui.cmbGraphStyle->currentIndex()); - - /* Save the Always On Top setting */ - saveSetting(SETTING_ALWAYS_ON_TOP, ui.chkAlwaysOnTop->isChecked()); - if (ui.chkAlwaysOnTop->isChecked()) { - setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint); - } else { - setWindowFlags(windowFlags() & ~Qt::WindowStaysOnTopHint); - } - setOpacity(ui.sldrOpacity->value()); - - /* Save the line filter values */ - uint filter = 0; - ADD_TO_FILTER(filter, BWGRAPH_LINE_RECV, ui.chkReceiveRate->isChecked()); - ADD_TO_FILTER(filter, BWGRAPH_LINE_SEND, ui.chkSendRate->isChecked()); - saveSetting(SETTING_FILTER, filter); - - - /* Update the graph frame settings */ - ui.frmGraph->setShowCounters(ui.chkReceiveRate->isChecked(), - ui.chkSendRate->isChecked()); - ui.frmGraph->setGraphStyle((GraphFrame::GraphStyle)ui.cmbGraphStyle->currentIndex()); - - /* A change in window flags causes the window to disappear, so make sure - * it's still visible. */ - showNormal(); -} - -/** Simply restores the previously saved settings. */ -void -BandwidthGraph::cancelChanges() -{ - /* Hide the settings frame and reset toggle button */ - showSettingsFrame(false); - - /* Reload the settings */ - loadSettings(); -} - -/** Toggles the Settings pane on and off, changes toggle button text. */ -void -BandwidthGraph::showSettingsFrame(bool show) -{ - static QSize minSize = minimumSize(); - - QSize newSize = size(); - if (show) { - /* Extend the bottom of the bandwidth graph and show the settings */ - ui.frmSettings->setVisible(true); - ui.btnToggleSettings->setChecked(true); - ui.btnToggleSettings->setText(tr("Hide Settings")); - - /* 6 = vertical spacing between the settings frame and graph frame */ - newSize.setHeight(newSize.height() + ui.frmSettings->height() + 6); - } else { - /* Shrink the height of the bandwidth graph and hide the settings */ - ui.frmSettings->setVisible(false); - ui.btnToggleSettings->setChecked(false); - ui.btnToggleSettings->setText(tr("Show Settings")); - - /* 6 = vertical spacing between the settings frame and graph frame */ - newSize.setHeight(newSize.height() - ui.frmSettings->height() - 6); - setMinimumSize(minSize); - } - resize(newSize); -} - -/** Sets the opacity of the Bandwidth Graph window. */ -void -BandwidthGraph::setOpacity(int value) -{ - qreal newValue = value / 100.0; - - /* Opacity only supported by Mac and Win32 */ -#if defined(Q_WS_MAC) - this->setWindowOpacity(newValue); - ui.lblPercentOpacity->setText(QString::number(value)); -#elif defined(Q_WS_WIN) - if (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based - && QSysInfo::WindowsVersion >= QSysInfo::WV_2000) { - this->setWindowOpacity(newValue); - ui.lblPercentOpacity->setText(QString::number(value)); - } -#else - Q_UNUSED(newValue); -#endif -} - -/** Overloads the default show() slot so we can set opacity. */ -void -BandwidthGraph::showWindow() -{ - /* Load saved settings */ - loadSettings(); - /* Show the window */ - VidaliaWindow::showWindow(); -} - diff -Nru vidalia-0.1.13/src/vidalia/bwgraph/bwgraph.h vidalia-0.2.8/src/vidalia/bwgraph/bwgraph.h --- vidalia-0.1.13/src/vidalia/bwgraph/bwgraph.h 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/bwgraph/bwgraph.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,79 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 bwgraph.h -** \version $Id: bwgraph.h 2362 2008-02-29 04:30:11Z edmanm $ -** \brief Displays a graph of Tor's bandwidth usage -*/ - -#ifndef _BWGRAPH_H -#define _BWGRAPH_H - -#include -#include - -#include -#include -#include - -#include "ui_bwgraph.h" - -/** Redraw graph every 1000ms **/ -#define REFRESH_RATE 1000 - - -class BandwidthGraph : public VidaliaWindow -{ - Q_OBJECT - -public: - /** Default constructor */ - BandwidthGraph(QWidget *parent = 0, Qt::WFlags flags = 0); - -public slots: - /** Overloaded QWidget.show */ - void showWindow(); - -protected: - /** Called to deliver a bandwidth update event from Tor. */ - void customEvent(QEvent *event); - -private slots: - /** Adds new data to the graph */ - void updateGraph(quint64 bytesRead, quint64 bytesWritten); - /** Called when settings button is toggled */ - void showSettingsFrame(bool show); - /** Called when the settings button is toggled */ - void setOpacity(int value); - /** Called when the user saves settings */ - void saveChanges(); - /** Called when the user cancels changes settings */ - void cancelChanges(); - /** Called when the reset button is pressed */ - void reset(); - -private: - /** Create and bind actions to events **/ - void createActions(); - /** Loads the saved Bandwidth Graph settings */ - void loadSettings(); - - /** A TorControl object used to talk to Tor. */ - TorControl* _torControl; - /** A VidaliaSettings object that handles getting/saving settings */ - VidaliaSettings* _settings; - - /** Qt Designer generated object */ - Ui::BandwidthGraph ui; -}; - -#endif - diff -Nru vidalia-0.1.13/src/vidalia/bwgraph/bwgraph.ui vidalia-0.2.8/src/vidalia/bwgraph/bwgraph.ui --- vidalia-0.1.13/src/vidalia/bwgraph/bwgraph.ui 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/bwgraph/bwgraph.ui 1970-01-01 01:00:00.000000000 +0100 @@ -1,485 +0,0 @@ - - BandwidthGraph - - - - 0 - 0 - 283 - 138 - - - - Qt::NoContextMenu - - - Tor Bandwidth Usage - - - :/images/32x32/utilities-system-monitor.png - - - - - 9 - - - 6 - - - - - 0 - - - 6 - - - - - Show Settings - - - true - - - - - - - Qt::Horizontal - - - - 21 - 20 - - - - - - - - Reset - - - - - - - - - - 120 - 80 - - - - - 10 - - - - Qt::NoContextMenu - - - QFrame::Box - - - QFrame::Plain - - - - - - - - 0 - 0 - 0 - 0 - - - - - 355 - 85 - - - - - 355 - 82 - - - - Qt::NoContextMenu - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 9 - - - 6 - - - - - 3 - - - 6 - - - - - Qt::NoContextMenu - - - - - - Qt::RightToLeft - - - Receive Rate - - - false - - - - - - - Qt::NoContextMenu - - - - - - Qt::RightToLeft - - - Send Rate - - - false - - - - - - - Qt::RightToLeft - - - Always on Top - - - - - - - Qt::Vertical - - - - 20 - 21 - - - - - - - - - - 0 - - - 1 - - - - - 0 - - - 6 - - - - - Qt::Horizontal - - - - 20 - 20 - - - - - - - - Style - - - - - - - - - - - :/images/16x16/graph-line.png - - - - - - - - :/images/16x16/graph-area.png - - - - - - - - - - Qt::NoContextMenu - - - QFrame::NoFrame - - - QFrame::Plain - - - - 0 - - - 3 - - - - - Qt::NoContextMenu - - - Changes the transparency of the Bandwidth Graph - - - 30 - - - 100 - - - 100 - - - 100 - - - false - - - Qt::Horizontal - - - false - - - QSlider::NoTicks - - - 10 - - - - - - - Qt::Vertical - - - - 20 - 20 - - - - - - - - 0 - - - 0 - - - - - Qt::Horizontal - - - - 21 - - - - - - - - - 25 - 0 - - - - - 10 - - - - Qt::NoContextMenu - - - Qt::RightToLeft - - - 100 - - - - - - - - 10 - - - - Qt::NoContextMenu - - - % Opaque - - - - - - - Qt::Horizontal - - - - 21 - - - - - - - - - - - - - Qt::Vertical - - - - 21 - 20 - - - - - - - - - - Qt::Horizontal - - - - 21 - 20 - - - - - - - - 0 - - - 1 - - - - - Save - - - - - - - Cancel - - - - - - - - - - - - - - - GraphFrame - QFrame -
bwgraph/graphframe.h
-
-
- - - - - btnToggleSettings - btnReset - chkReceiveRate - chkSendRate - chkAlwaysOnTop - cmbGraphStyle - sldrOpacity - btnSaveSettings - btnCancelSettings - - -
diff -Nru vidalia-0.1.13/src/vidalia/bwgraph/graphframe.cpp vidalia-0.2.8/src/vidalia/bwgraph/graphframe.cpp --- vidalia-0.1.13/src/vidalia/bwgraph/graphframe.cpp 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/bwgraph/graphframe.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,321 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 graphframe.cpp -** \version $Id: graphframe.cpp 2988 2008-08-18 00:52:14Z edmanm $ -** \brief Graphs a series of send and receive data points -*/ - -#include - -#include "graphframe.h" - - -/** Default contructor */ -GraphFrame::GraphFrame(QWidget *parent) -: QFrame(parent) -{ - /* Create Graph Frame related objects */ - _recvData = new QList(); - _sendData = new QList(); - _painter = new QPainter(); - _graphStyle = SolidLine; - - /* Initialize graph values */ - _recvData->prepend(0); - _sendData->prepend(0); - _maxPoints = getNumPoints(); - _showRecv = true; - _showSend = true; - _maxValue = MIN_SCALE; - _scaleWidth = 0; -} - -/** Default destructor */ -GraphFrame::~GraphFrame() -{ - delete _painter; - delete _recvData; - delete _sendData; -} - -/** Gets the width of the desktop, which is the maximum number of points - * we can plot in the graph. */ -int -GraphFrame::getNumPoints() -{ - QDesktopWidget *desktop = QApplication::desktop(); - int width = desktop->width(); - return width; -} - -/** Adds new data points to the graph. */ -void -GraphFrame::addPoints(qreal recv, qreal send) -{ - /* If maximum number of points plotted, remove oldest */ - if (_sendData->size() == _maxPoints) { - _sendData->removeLast(); - _recvData->removeLast(); - } - - /* Add the points to their respective lists */ - _sendData->prepend(send); - _recvData->prepend(recv); - - /* Add to the total counters */ - _totalSend += send; - _totalRecv += recv; - - /* Check for a new maximum value */ - if (send > _maxValue) _maxValue = send; - if (recv > _maxValue) _maxValue = recv; - - this->update(); -} - -/** Clears the graph. */ -void -GraphFrame::resetGraph() -{ - _recvData->clear(); - _sendData->clear(); - _recvData->prepend(0); - _sendData->prepend(0); - _maxValue = MIN_SCALE; - _totalSend = 0; - _totalRecv = 0; - this->update(); -} - -/** Toggles display of respective graph lines and counters. */ -void -GraphFrame::setShowCounters(bool showRecv, bool showSend) -{ - _showRecv = showRecv; - _showSend = showSend; - this->update(); -} - -/** Overloads default QWidget::paintEvent. Draws the actual - * bandwidth graph. */ -void -GraphFrame::paintEvent(QPaintEvent *event) -{ - Q_UNUSED(event); - - /* Set current graph dimensions */ - _rec = this->frameRect(); - - /* Start the painter */ - _painter->begin(this); - - /* We want antialiased lines and text */ - _painter->setRenderHint(QPainter::Antialiasing); - _painter->setRenderHint(QPainter::TextAntialiasing); - - /* Fill in the background */ - _painter->fillRect(_rec, QBrush(BACK_COLOR)); - _painter->drawRect(_rec); - - /* Paint the scale */ - paintScale(); - /* Plot the send/receive data */ - paintData(); - /* Paint the send/recv totals */ - paintTotals(); - - /* Stop the painter */ - _painter->end(); -} - -/** Paints an integral and an outline of that integral for each data set (send - * and/or receive) that is to be displayed. The integrals will be drawn first, - * followed by the outlines, since we want the area of overlapping integrals - * to blend, but not the outlines of those integrals. */ -void -GraphFrame::paintData() -{ - QVector recvPoints, sendPoints; - - /* Convert the bandwidth data points to graph points */ - recvPoints = pointsFromData(_recvData); - sendPoints = pointsFromData(_sendData); - - if (_graphStyle == AreaGraph) { - /* Plot the bandwidth data as area graphs */ - if (_showRecv) - paintIntegral(recvPoints, RECV_COLOR, 0.6); - if (_showSend) - paintIntegral(sendPoints, SEND_COLOR, 0.4); - } - - /* Plot the bandwidth as solid lines. If the graph style is currently an - * area graph, we end up outlining the integrals. */ - if (_showRecv) - paintLine(recvPoints, RECV_COLOR); - if (_showSend) - paintLine(sendPoints, SEND_COLOR); -} - -/** Returns a list of points on the bandwidth graph based on the supplied set - * of send or receive values. */ -QVector -GraphFrame::pointsFromData(QList* list) -{ - QVector points; - int x = _rec.width(); - int y = _rec.height(); - qreal scale = (y - (y/10)) / _maxValue; - qreal currValue; - - /* Translate all data points to points on the graph frame */ - points << QPointF(x, y); - for (int i = 0; i < list->size(); i++) { - currValue = y - (list->at(i) * scale); - if (x - SCROLL_STEP < _scaleWidth) { - points << QPointF(_scaleWidth, currValue); - break; - } - points << QPointF(x, currValue); - x -= SCROLL_STEP; - } - points << QPointF(_scaleWidth, y); - return points; -} - -/** Plots an integral using the data points in points. The area will be - * filled in using color and an alpha-blending level of alpha - * (default is opaque). */ -void -GraphFrame::paintIntegral(QVector points, QColor color, qreal alpha) -{ - /* Save the current brush, plot the integral, and restore the old brush */ - QBrush oldBrush = _painter->brush(); - color.setAlphaF(alpha); - _painter->setBrush(QBrush(color)); - _painter->drawPolygon(points.data(), points.size()); - _painter->setBrush(oldBrush); -} - -/** Iterates the input list and draws a line on the graph in the appropriate - * color. */ -void -GraphFrame::paintLine(QVector points, QColor color, Qt::PenStyle lineStyle) -{ - /* Save the current brush, plot the line, and restore the old brush */ - QPen oldPen = _painter->pen(); - _painter->setPen(QPen(color, lineStyle)); - _painter->drawPolyline(points.data(), points.size()); - _painter->setPen(oldPen); -} - -/** Paints selected total indicators on the graph. */ -void -GraphFrame::paintTotals() -{ - int x = _scaleWidth + FONT_SIZE, y = 0; - int rowHeight = FONT_SIZE; - -#if !defined(Q_WS_MAC) - /* On Mac, we don't need vertical spacing between the text rows. */ - rowHeight += 5; -#endif - - /* If total received is selected */ - if (_showRecv) { - y = rowHeight; - _painter->setPen(RECV_COLOR); - _painter->drawText(x, y, - tr("Recv: ") + totalToStr(_totalRecv) + - " ("+tr("%1 KB/s").arg(_recvData->first(), 0, 'f', 2)+")"); - } - - /* If total sent is selected */ - if (_showSend) { - y += rowHeight; - _painter->setPen(SEND_COLOR); - _painter->drawText(x, y, - tr("Sent: ") + totalToStr(_totalSend) + - " ("+tr("%1 KB/s").arg(_sendData->first(), 0, 'f', 2)+")"); - } -} - -/** Returns a formatted string with the correct size suffix. */ -QString -GraphFrame::totalToStr(qreal total) -{ - /* Determine the correct size suffix */ - if (total < 1024) { - /* Use KB suffix */ - return tr("%1 KB").arg(total, 0, 'f', 2); - } else if (total < 1048576) { - /* Use MB suffix */ - return tr("%1 MB").arg(total/1024.0, 0, 'f', 2); - } else { - /* Use GB suffix */ - return tr("%1 GB").arg(total/1048576.0, 0, 'f', 2); - } -} - -/** Returns the width in pixels of label using the current painter's - * font. */ -int -GraphFrame::labelWidth(const QString &label) -{ - int width = 0; - QFontMetrics fm = fontMetrics(); - - for (int i = 0; i < label.length(); i++) - width += fm.charWidth(label, i); - return width; -} - -/** Paints the scale on the graph. */ -void -GraphFrame::paintScale() -{ - QString label[4]; - int width[4]; - int top = _rec.y(); - int bottom = _rec.height(); - int scaleWidth = 0; - qreal pos; - qreal markStep = _maxValue * .25; - qreal paintStep = (bottom - (bottom/8)) / 4; - - /* Compute each of the y-axis labels */ - for (int i = 0; i < 4; i++) { - pos = bottom - ((i+1) * paintStep); - label[i] = tr("%1 KB/s").arg(markStep*(i+1), 0, 'f', 2); - width[i] = labelWidth(label[i]); - scaleWidth = qMax(scaleWidth, 2+width[i]); - } - - /* Include a 5px margin between the y-axis and its labels */ - _scaleWidth = scaleWidth + 5; - - /* Draw the y-axis labels and horizontal marks in their correctly scaled - * locations */ - for (int i = 0; i < 4; i++) { - pos = bottom - ((i+1) * paintStep); - _painter->setPen(SCALE_COLOR); - _painter->drawText(QPointF(_scaleWidth-width[i]-5, pos), label[i]); - - _painter->setPen(GRID_COLOR); - _painter->drawLine(QPointF(_scaleWidth, pos), - QPointF(_rec.width(), pos)); - } - - /* Draw the y-axis */ - _painter->drawLine(_scaleWidth, top, _scaleWidth, bottom); -} - diff -Nru vidalia-0.1.13/src/vidalia/bwgraph/GraphFrame.cpp vidalia-0.2.8/src/vidalia/bwgraph/GraphFrame.cpp --- vidalia-0.1.13/src/vidalia/bwgraph/GraphFrame.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/bwgraph/GraphFrame.cpp 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,321 @@ +/* +** 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.vidalia-project.net/. 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 GraphFrame.cpp +** \version $Id: GraphFrame.cpp 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Graphs a series of send and receive data points +*/ + +#include "GraphFrame.h" + +#include + + +/** Default contructor */ +GraphFrame::GraphFrame(QWidget *parent) +: QFrame(parent) +{ + /* Create Graph Frame related objects */ + _recvData = new QList(); + _sendData = new QList(); + _painter = new QPainter(); + _graphStyle = SolidLine; + + /* Initialize graph values */ + _recvData->prepend(0); + _sendData->prepend(0); + _maxPoints = getNumPoints(); + _showRecv = true; + _showSend = true; + _maxValue = MIN_SCALE; + _scaleWidth = 0; +} + +/** Default destructor */ +GraphFrame::~GraphFrame() +{ + delete _painter; + delete _recvData; + delete _sendData; +} + +/** Gets the width of the desktop, which is the maximum number of points + * we can plot in the graph. */ +int +GraphFrame::getNumPoints() +{ + QDesktopWidget *desktop = QApplication::desktop(); + int width = desktop->width(); + return width; +} + +/** Adds new data points to the graph. */ +void +GraphFrame::addPoints(qreal recv, qreal send) +{ + /* If maximum number of points plotted, remove oldest */ + if (_sendData->size() == _maxPoints) { + _sendData->removeLast(); + _recvData->removeLast(); + } + + /* Add the points to their respective lists */ + _sendData->prepend(send); + _recvData->prepend(recv); + + /* Add to the total counters */ + _totalSend += send; + _totalRecv += recv; + + /* Check for a new maximum value */ + if (send > _maxValue) _maxValue = send; + if (recv > _maxValue) _maxValue = recv; + + this->update(); +} + +/** Clears the graph. */ +void +GraphFrame::resetGraph() +{ + _recvData->clear(); + _sendData->clear(); + _recvData->prepend(0); + _sendData->prepend(0); + _maxValue = MIN_SCALE; + _totalSend = 0; + _totalRecv = 0; + this->update(); +} + +/** Toggles display of respective graph lines and counters. */ +void +GraphFrame::setShowCounters(bool showRecv, bool showSend) +{ + _showRecv = showRecv; + _showSend = showSend; + this->update(); +} + +/** Overloads default QWidget::paintEvent. Draws the actual + * bandwidth graph. */ +void +GraphFrame::paintEvent(QPaintEvent *event) +{ + Q_UNUSED(event); + + /* Set current graph dimensions */ + _rec = this->frameRect(); + + /* Start the painter */ + _painter->begin(this); + + /* We want antialiased lines and text */ + _painter->setRenderHint(QPainter::Antialiasing); + _painter->setRenderHint(QPainter::TextAntialiasing); + + /* Fill in the background */ + _painter->fillRect(_rec, QBrush(BACK_COLOR)); + _painter->drawRect(_rec); + + /* Paint the scale */ + paintScale(); + /* Plot the send/receive data */ + paintData(); + /* Paint the send/recv totals */ + paintTotals(); + + /* Stop the painter */ + _painter->end(); +} + +/** Paints an integral and an outline of that integral for each data set (send + * and/or receive) that is to be displayed. The integrals will be drawn first, + * followed by the outlines, since we want the area of overlapping integrals + * to blend, but not the outlines of those integrals. */ +void +GraphFrame::paintData() +{ + QVector recvPoints, sendPoints; + + /* Convert the bandwidth data points to graph points */ + recvPoints = pointsFromData(_recvData); + sendPoints = pointsFromData(_sendData); + + if (_graphStyle == AreaGraph) { + /* Plot the bandwidth data as area graphs */ + if (_showRecv) + paintIntegral(recvPoints, RECV_COLOR, 0.6); + if (_showSend) + paintIntegral(sendPoints, SEND_COLOR, 0.4); + } + + /* Plot the bandwidth as solid lines. If the graph style is currently an + * area graph, we end up outlining the integrals. */ + if (_showRecv) + paintLine(recvPoints, RECV_COLOR); + if (_showSend) + paintLine(sendPoints, SEND_COLOR); +} + +/** Returns a list of points on the bandwidth graph based on the supplied set + * of send or receive values. */ +QVector +GraphFrame::pointsFromData(QList* list) +{ + QVector points; + int x = _rec.width(); + int y = _rec.height(); + qreal scale = (y - (y/10)) / _maxValue; + qreal currValue; + + /* Translate all data points to points on the graph frame */ + points << QPointF(x, y); + for (int i = 0; i < list->size(); i++) { + currValue = y - (list->at(i) * scale); + if (x - SCROLL_STEP < _scaleWidth) { + points << QPointF(_scaleWidth, currValue); + break; + } + points << QPointF(x, currValue); + x -= SCROLL_STEP; + } + points << QPointF(_scaleWidth, y); + return points; +} + +/** Plots an integral using the data points in points. The area will be + * filled in using color and an alpha-blending level of alpha + * (default is opaque). */ +void +GraphFrame::paintIntegral(QVector points, QColor color, qreal alpha) +{ + /* Save the current brush, plot the integral, and restore the old brush */ + QBrush oldBrush = _painter->brush(); + color.setAlphaF(alpha); + _painter->setBrush(QBrush(color)); + _painter->drawPolygon(points.data(), points.size()); + _painter->setBrush(oldBrush); +} + +/** Iterates the input list and draws a line on the graph in the appropriate + * color. */ +void +GraphFrame::paintLine(QVector points, QColor color, Qt::PenStyle lineStyle) +{ + /* Save the current brush, plot the line, and restore the old brush */ + QPen oldPen = _painter->pen(); + _painter->setPen(QPen(color, lineStyle)); + _painter->drawPolyline(points.data(), points.size()); + _painter->setPen(oldPen); +} + +/** Paints selected total indicators on the graph. */ +void +GraphFrame::paintTotals() +{ + int x = _scaleWidth + FONT_SIZE, y = 0; + int rowHeight = FONT_SIZE; + +#if !defined(Q_WS_MAC) + /* On Mac, we don't need vertical spacing between the text rows. */ + rowHeight += 5; +#endif + + /* If total received is selected */ + if (_showRecv) { + y = rowHeight; + _painter->setPen(RECV_COLOR); + _painter->drawText(x, y, + tr("Recv: ") + totalToStr(_totalRecv) + + " ("+tr("%1 KB/s").arg(_recvData->first(), 0, 'f', 2)+")"); + } + + /* If total sent is selected */ + if (_showSend) { + y += rowHeight; + _painter->setPen(SEND_COLOR); + _painter->drawText(x, y, + tr("Sent: ") + totalToStr(_totalSend) + + " ("+tr("%1 KB/s").arg(_sendData->first(), 0, 'f', 2)+")"); + } +} + +/** Returns a formatted string with the correct size suffix. */ +QString +GraphFrame::totalToStr(qreal total) +{ + /* Determine the correct size suffix */ + if (total < 1024) { + /* Use KB suffix */ + return tr("%1 KB").arg(total, 0, 'f', 2); + } else if (total < 1048576) { + /* Use MB suffix */ + return tr("%1 MB").arg(total/1024.0, 0, 'f', 2); + } else { + /* Use GB suffix */ + return tr("%1 GB").arg(total/1048576.0, 0, 'f', 2); + } +} + +/** Returns the width in pixels of label using the current painter's + * font. */ +int +GraphFrame::labelWidth(const QString &label) +{ + int width = 0; + QFontMetrics fm = fontMetrics(); + + for (int i = 0; i < label.length(); i++) + width += fm.charWidth(label, i); + return width; +} + +/** Paints the scale on the graph. */ +void +GraphFrame::paintScale() +{ + QString label[4]; + int width[4]; + int top = _rec.y(); + int bottom = _rec.height(); + int scaleWidth = 0; + qreal pos; + qreal markStep = _maxValue * .25; + qreal paintStep = (bottom - (bottom/8)) / 4; + + /* Compute each of the y-axis labels */ + for (int i = 0; i < 4; i++) { + pos = bottom - ((i+1) * paintStep); + label[i] = tr("%1 KB/s").arg(markStep*(i+1), 0, 'f', 2); + width[i] = labelWidth(label[i]); + scaleWidth = qMax(scaleWidth, 2+width[i]); + } + + /* Include a 5px margin between the y-axis and its labels */ + _scaleWidth = scaleWidth + 5; + + /* Draw the y-axis labels and horizontal marks in their correctly scaled + * locations */ + for (int i = 0; i < 4; i++) { + pos = bottom - ((i+1) * paintStep); + _painter->setPen(SCALE_COLOR); + _painter->drawText(QPointF(_scaleWidth-width[i]-5, pos), label[i]); + + _painter->setPen(GRID_COLOR); + _painter->drawLine(QPointF(_scaleWidth, pos), + QPointF(_rec.width(), pos)); + } + + /* Draw the y-axis */ + _painter->drawLine(_scaleWidth, top, _scaleWidth, bottom); +} + diff -Nru vidalia-0.1.13/src/vidalia/bwgraph/graphframe.h vidalia-0.2.8/src/vidalia/bwgraph/graphframe.h --- vidalia-0.1.13/src/vidalia/bwgraph/graphframe.h 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/bwgraph/graphframe.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,118 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 graphframe.h -** \version $Id: graphframe.h 2980 2008-08-17 04:14:25Z edmanm $ -** \brief Graphs a series of send and receive data points -*/ - -#ifndef _GRAPHFRAME_H -#define _GRAPHFRAME_H - -#include -#include -#include -#include -#include -#include - -#define HOR_SPC 2 /** Space between data points */ -#define MIN_SCALE 10 /** 10 kB/s is the minimum scale */ -#define SCROLL_STEP 4 /** Horizontal change on graph update */ - -#define BACK_COLOR Qt::black -#define SCALE_COLOR Qt::green -#define GRID_COLOR Qt::darkGreen -#define RECV_COLOR Qt::cyan -#define SEND_COLOR Qt::yellow - -#define FONT_SIZE 11 - - -class GraphFrame : public QFrame -{ - Q_OBJECT - -public: - /** Bandwidth graph style. */ - enum GraphStyle { - SolidLine = 0, /**< Plot bandwidth as solid lines. */ - AreaGraph /**< Plot bandwidth as alpha blended area graphs. */ - }; - - /** Default Constructor */ - GraphFrame(QWidget *parent = 0); - /** Default Destructor */ - ~GraphFrame(); - - /** Add data points. */ - void addPoints(qreal recv, qreal send); - /** Clears the graph. */ - void resetGraph(); - /** Toggles display of data counters. */ - void setShowCounters(bool showRecv, bool showSend); - /** Sets the graph style used to display bandwidth data. */ - void setGraphStyle(GraphStyle style) { _graphStyle = style; } - -protected: - /** Overloaded QWidget::paintEvent() */ - void paintEvent(QPaintEvent *event); - -private: - /** Returns the width in pixels of label using the current painter's - * font. */ - int labelWidth(const QString &label); - /** Gets the width of the desktop, the max # of points. */ - int getNumPoints(); - /** Paints an integral and an outline of that integral for each data set - * (send and/or receive) that is to be displayed. */ - void paintData(); - /** Paints the send/receive totals. */ - void paintTotals(); - /** Paints the scale in the graph. */ - void paintScale(); - /** Returns a formatted string representation of total. */ - QString totalToStr(qreal total); - /** Returns a list of points on the bandwidth graph based on the supplied set - * of send or receive values. */ - QVector pointsFromData(QList* list); - /** Paints a line with the data in points. */ - void paintLine(QVector points, QColor color, - Qt::PenStyle lineStyle = Qt::SolidLine); - /** Paints an integral using the supplied data. */ - void paintIntegral(QVector points, QColor color, qreal alpha = 1.0); - - /** Style with which the bandwidth data will be graphed. */ - GraphStyle _graphStyle; - /** A QPainter object that handles drawing the various graph elements. */ - QPainter* _painter; - /** Holds the received data points. */ - QList *_recvData; - /** Holds the sent data points. */ - QList *_sendData; - /** The current dimensions of the graph. */ - QRect _rec; - /** The maximum data value plotted. */ - qreal _maxValue; - /** The maximum number of points to store. */ - int _maxPoints; - /** The total data sent/recv. */ - qreal _totalSend; - qreal _totalRecv; - /** Show the respective lines and counters. */ - bool _showRecv; - bool _showSend; - /** Width (in pixels) of the scale marker area on the left side of the - * graph. */ - int _scaleWidth; -}; - -#endif diff -Nru vidalia-0.1.13/src/vidalia/bwgraph/GraphFrame.h vidalia-0.2.8/src/vidalia/bwgraph/GraphFrame.h --- vidalia-0.1.13/src/vidalia/bwgraph/GraphFrame.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/bwgraph/GraphFrame.h 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,118 @@ +/* +** 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.vidalia-project.net/. 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 GraphFrame.h +** \version $Id: GraphFrame.h 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Graphs a series of send and receive data points +*/ + +#ifndef _GRAPHFRAME_H +#define _GRAPHFRAME_H + +#include +#include +#include +#include +#include +#include + +#define HOR_SPC 2 /** Space between data points */ +#define MIN_SCALE 10 /** 10 kB/s is the minimum scale */ +#define SCROLL_STEP 4 /** Horizontal change on graph update */ + +#define BACK_COLOR Qt::black +#define SCALE_COLOR Qt::green +#define GRID_COLOR Qt::darkGreen +#define RECV_COLOR Qt::cyan +#define SEND_COLOR Qt::yellow + +#define FONT_SIZE 11 + + +class GraphFrame : public QFrame +{ + Q_OBJECT + +public: + /** Bandwidth graph style. */ + enum GraphStyle { + SolidLine = 0, /**< Plot bandwidth as solid lines. */ + AreaGraph /**< Plot bandwidth as alpha blended area graphs. */ + }; + + /** Default Constructor */ + GraphFrame(QWidget *parent = 0); + /** Default Destructor */ + ~GraphFrame(); + + /** Add data points. */ + void addPoints(qreal recv, qreal send); + /** Clears the graph. */ + void resetGraph(); + /** Toggles display of data counters. */ + void setShowCounters(bool showRecv, bool showSend); + /** Sets the graph style used to display bandwidth data. */ + void setGraphStyle(GraphStyle style) { _graphStyle = style; } + +protected: + /** Overloaded QWidget::paintEvent() */ + void paintEvent(QPaintEvent *event); + +private: + /** Returns the width in pixels of label using the current painter's + * font. */ + int labelWidth(const QString &label); + /** Gets the width of the desktop, the max # of points. */ + int getNumPoints(); + /** Paints an integral and an outline of that integral for each data set + * (send and/or receive) that is to be displayed. */ + void paintData(); + /** Paints the send/receive totals. */ + void paintTotals(); + /** Paints the scale in the graph. */ + void paintScale(); + /** Returns a formatted string representation of total. */ + QString totalToStr(qreal total); + /** Returns a list of points on the bandwidth graph based on the supplied set + * of send or receive values. */ + QVector pointsFromData(QList* list); + /** Paints a line with the data in points. */ + void paintLine(QVector points, QColor color, + Qt::PenStyle lineStyle = Qt::SolidLine); + /** Paints an integral using the supplied data. */ + void paintIntegral(QVector points, QColor color, qreal alpha = 1.0); + + /** Style with which the bandwidth data will be graphed. */ + GraphStyle _graphStyle; + /** A QPainter object that handles drawing the various graph elements. */ + QPainter* _painter; + /** Holds the received data points. */ + QList *_recvData; + /** Holds the sent data points. */ + QList *_sendData; + /** The current dimensions of the graph. */ + QRect _rec; + /** The maximum data value plotted. */ + qreal _maxValue; + /** The maximum number of points to store. */ + int _maxPoints; + /** The total data sent/recv. */ + qreal _totalSend; + qreal _totalRecv; + /** Show the respective lines and counters. */ + bool _showRecv; + bool _showSend; + /** Width (in pixels) of the scale marker area on the left side of the + * graph. */ + int _scaleWidth; +}; + +#endif diff -Nru vidalia-0.1.13/src/vidalia/CMakeLists.txt vidalia-0.2.8/src/vidalia/CMakeLists.txt --- vidalia-0.1.13/src/vidalia/CMakeLists.txt 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/CMakeLists.txt 2010-02-25 04:03:32.000000000 +0000 @@ -1,5 +1,5 @@ ## -## $Id: CMakeLists.txt 3564 2009-02-23 02:17:48Z edmanm $ +## $Id: CMakeLists.txt 4227 2010-02-25 04:03:32Z edmanm $ ## ## 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 @@ -14,9 +14,38 @@ include_directories( ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/about + ${CMAKE_CURRENT_SOURCE_DIR}/bwgraph ${CMAKE_CURRENT_SOURCE_DIR}/config ${CMAKE_CURRENT_SOURCE_DIR}/help/browser -) + ${CMAKE_CURRENT_SOURCE_DIR}/log + ${CMAKE_CURRENT_SOURCE_DIR}/network + ${MARBLE_INCLUDE_DIR} +) + +if (USE_BREAKPAD AND BREAKPAD_INCLUDE_DIR) + include_directories(${BREAKPAD_INCLUDE_DIR}) +endif(USE_BREAKPAD AND BREAKPAD_INCLUDE_DIR) + +if (USE_MARBLE) + if (APPLE OR WIN32) + ## + ## XXX: The Marble build system on OS X currently doesn't actually install the + ## required include files to /usr/local/include or similar. Instead, we have + ## to pluck them directly from the source tree. Ick. + ## + include_directories( + ${MARBLE_INCLUDE_DIR}/AbstractLayer + ${MARBLE_INCLUDE_DIR}/geodata + ${MARBLE_INCLUDE_DIR}/geodata/data + ${MARBLE_INCLUDE_DIR}/geodata/handlers + ${MARBLE_INCLUDE_DIR}/geodata/parser + ${MARBLE_INCLUDE_DIR}/geodata/scene + ${MARBLE_INCLUDE_DIR}/Projections + ) + endif(APPLE OR WIN32) +endif(USE_MARBLE) + configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/res/vidalia_win.rc.in ${CMAKE_CURRENT_SOURCE_DIR}/res/vidalia_win.rc @@ -31,191 +60,240 @@ ## About dialog sources set(vidalia_SRCS - about/aboutdialog.cpp + about/AboutDialog.cpp + about/LicenseDialog.cpp ) qt4_wrap_cpp(vidalia_SRCS - about/aboutdialog.h + about/AboutDialog.h + about/LicenseDialog.h ) ## Bandwidth graph sources set(vidalia_SRCS ${vidalia_SRCS} - bwgraph/bwgraph.cpp - bwgraph/graphframe.cpp + bwgraph/BandwidthGraph.cpp + bwgraph/GraphFrame.cpp ) qt4_wrap_cpp(vidalia_SRCS - bwgraph/bwgraph.h - bwgraph/graphframe.h + bwgraph/BandwidthGraph.h + bwgraph/GraphFrame.h ) ## Configuration dialog sources set(vidalia_SRCS ${vidalia_SRCS} - config/abstracttorsettings.cpp - config/advancedpage.cpp - config/appearancepage.cpp - config/configdialog.cpp - config/configpagestack.cpp - config/domainvalidator.cpp - config/exitpolicy.cpp - config/generalpage.cpp - config/ipvalidator.cpp - config/networkpage.cpp - config/networksettings.cpp - config/nicknamevalidator.cpp - config/policy.cpp - config/portvalidator.cpp - config/serverpage.cpp - config/serversettings.cpp - config/service.cpp - config/servicelist.cpp - config/servicepage.cpp - config/servicesettings.cpp - config/torsettings.cpp - config/vidaliasettings.cpp - config/vsettings.cpp + config/AbstractTorSettings.cpp + config/AdvancedPage.cpp + config/AppearancePage.cpp + config/BridgeDownloader.cpp + config/BridgeDownloaderProgressDialog.cpp + config/BridgeUsageDialog.cpp + config/ConfigDialog.cpp + config/ConfigPageStack.cpp + config/DomainValidator.cpp + config/ExitPolicy.cpp + config/GeneralPage.cpp + config/IpValidator.cpp + config/NetworkPage.cpp + config/NetworkSettings.cpp + config/NicknameValidator.cpp + config/Policy.cpp + config/PortValidator.cpp + config/ServerPage.cpp + config/ServerSettings.cpp + config/Service.cpp + config/ServiceList.cpp + config/ServicePage.cpp + config/ServiceSettings.cpp + config/TorSettings.cpp + config/VidaliaSettings.cpp + config/VSettings.cpp ) qt4_wrap_cpp(vidalia_SRCS - config/abstracttorsettings.h - config/advancedpage.h - config/appearancepage.h - config/configdialog.h - config/configpage.h - config/configpagestack.h - config/domainvalidator.h - config/generalpage.h - config/networkpage.h - config/networksettings.h - config/nicknamevalidator.h - config/portvalidator.h - config/serverpage.h - config/serversettings.h - config/servicepage.h - config/torsettings.h - config/vidaliasettings.h - config/vsettings.h + config/AbstractTorSettings.h + config/AdvancedPage.h + config/AppearancePage.h + config/BridgeDownloader.h + config/BridgeDownloaderProgressDialog.h + config/BridgeUsageDialog.h + config/ConfigDialog.h + config/ConfigPage.h + config/ConfigPageStack.h + config/DomainValidator.h + config/GeneralPage.h + config/NetworkPage.h + config/NetworkSettings.h + config/NicknameValidator.h + config/PortValidator.h + config/ServerPage.h + config/ServerSettings.h + config/ServicePage.h + config/TorSettings.h + config/VidaliaSettings.h + config/VSettings.h ) if (USE_MINIUPNPC) include_directories(${MINIUPNPC_INCLUDE_DIR}) set(vidalia_SRCS ${vidalia_SRCS} - config/upnpcontrol.cpp - config/upnpcontrolthread.cpp - config/upnptestdialog.cpp + config/UPNPControl.cpp + config/UPNPControlThread.cpp + config/UPNPTestDialog.cpp ) qt4_wrap_cpp(vidalia_SRCS - config/upnpcontrol.h - config/upnpcontrolthread.h - config/upnptestdialog.h + config/UPNPControl.h + config/UPNPControlThread.h + config/UPNPTestDialog.h ) endif(USE_MINIUPNPC) ## Help browser sources set(vidalia_SRCS ${vidalia_SRCS} - help/browser/helpbrowser.cpp - help/browser/helptextbrowser.cpp + help/browser/HelpBrowser.cpp + help/browser/HelpTextBrowser.cpp ) qt4_wrap_cpp(vidalia_SRCS - help/browser/helpbrowser.h - help/browser/helptextbrowser.h + help/browser/HelpBrowser.h + help/browser/HelpTextBrowser.h ) ## Message log sources set(vidalia_SRCS ${vidalia_SRCS} - log/logfile.cpp - log/logheaderview.cpp - log/logmessagecolumndelegate.cpp - log/logtreeitem.cpp - log/logtreewidget.cpp - log/messagelog.cpp + log/LogFile.cpp + log/LogHeaderView.cpp + log/LogMessageColumnDelegate.cpp + log/LogTreeItem.cpp + log/LogTreeWidget.cpp + log/MessageLog.cpp + log/StatusEventItem.cpp + log/StatusEventItemDelegate.cpp + log/StatusEventWidget.cpp ) qt4_wrap_cpp(vidalia_SRCS - log/logfile.h - log/logheaderview.h - log/logtreewidget.h - log/messagelog.h + log/LogFile.h + log/LogHeaderView.h + log/LogTreeWidget.h + log/MessageLog.h + log/StatusEventItemDelegate.h + log/StatusEventWidget.h ) ## Network map sources set(vidalia_SRCS ${vidalia_SRCS} - network/circuititem.cpp - network/circuitlistwidget.cpp - network/geoipcache.cpp - network/geoipcacheitem.cpp - network/geoip.cpp - network/geoiprequest.cpp - network/geoipresolver.cpp - network/geoipresponse.cpp - network/netviewer.cpp - network/routerdescriptorview.cpp - network/routerlistitem.cpp - network/routerlistwidget.cpp - network/streamitem.cpp - network/tormapwidget.cpp - network/zimageview.cpp + network/CircuitItem.cpp + network/CircuitListWidget.cpp + network/GeoIpCache.cpp + network/GeoIpCacheItem.cpp + network/GeoIp.cpp + network/GeoIpRequest.cpp + network/GeoIpResolver.cpp + network/GeoIpResponse.cpp + network/NetViewer.cpp + network/RouterDescriptorView.cpp + network/RouterInfoDialog.cpp + network/RouterListItem.cpp + network/RouterListWidget.cpp + network/StreamItem.cpp ) qt4_wrap_cpp(vidalia_SRCS - network/circuitlistwidget.h - network/geoipresolver.h - network/netviewer.h - network/routerdescriptorview.h - network/routerlistwidget.h - network/tormapwidget.h - network/zimageview.h + network/CircuitListWidget.h + network/GeoIpCache.h + network/GeoIpResolver.h + network/NetViewer.h + network/RouterDescriptorView.h + network/RouterInfoDialog.h + network/RouterListWidget.h ) - -## Choose the correct tray icon implementation for the current platform -set(vidalia_SRCS ${vidalia_SRCS} tray/trayicon.cpp) -qt4_wrap_cpp(vidalia_SRCS tray/trayicon.h) -if(APPLE) - set(vidalia_SRCS ${vidalia_SRCS} tray/trayicon_mac.cpp) - qt4_wrap_cpp(vidalia_SRCS tray/trayicon_mac.h) -else(APPLE) - ## Use Qt's QSystemTrayIcon implementation - set(vidalia_SRCS ${vidalia_SRCS} tray/trayicon_qt.cpp) - qt4_wrap_cpp(vidalia_SRCS tray/trayicon_qt.h) -endif(APPLE) +if (USE_MARBLE) + set(vidalia_SRCS ${vidalia_SRCS} + network/TorMapWidget.cpp + network/TorMapWidgetInputHandler.cpp + network/TorMapWidgetPopupMenu.cpp + ) + qt4_wrap_cpp(vidalia_SRCS + network/TorMapWidget.h + network/TorMapWidgetInputHandler.h + network/TorMapWidgetPopupMenu.h + ) +else(USE_MARBLE) + set(vidalia_SRCS ${vidalia_SRCS} + network/TorMapImageView.cpp + network/ZImageView.cpp + ) + qt4_wrap_cpp(vidalia_SRCS + network/TorMapImageView.h + network/ZImageView.h + ) +endif(USE_MARBLE) ## Main Vidalia sources set(vidalia_SRCS ${vidalia_SRCS} main.cpp - vidalia.cpp - languagesupport.cpp - mainwindow.cpp - vclicklabel.cpp - vidaliawindow.cpp - vmessagebox.cpp - helperprocess.cpp - controlpasswordinputdialog.cpp + Vidalia.cpp + LanguageSupport.cpp + MainWindow.cpp + VClickLabel.cpp + VidaliaWindow.cpp + VMessageBox.cpp + HelperProcess.cpp + ControlPasswordInputDialog.cpp ) qt4_wrap_cpp(vidalia_SRCS - vidalia.h - mainwindow.h - vclicklabel.h - vidaliawindow.h - vmessagebox.h - helperprocess.h - controlpasswordinputdialog.h + Vidalia.h + MainWindow.h + VClickLabel.h + VidaliaWindow.h + VMessageBox.h + HelperProcess.h + ControlPasswordInputDialog.h ) +if (USE_BREAKPAD) + set(vidalia_SRCS ${vidalia_SRCS} + CrashReporter.cpp + ) +endif(USE_BREAKPAD) ## Specify all the Qt Designer .ui files qt4_wrap_ui(vidalia_SRCS - controlpasswordinputdialog.ui - mainwindow.ui - about/aboutdialog.ui - bwgraph/bwgraph.ui - config/advancedpage.ui - config/appearancepage.ui - config/configdialog.ui - config/generalpage.ui - config/networkpage.ui - config/serverpage.ui - config/servicepage.ui - help/browser/helpbrowser.ui - log/messagelog.ui - network/netviewer.ui + ControlPasswordInputDialog.ui + MainWindow.ui + about/AboutDialog.ui + about/LicenseDialog.ui + bwgraph/BandwidthGraph.ui + config/AdvancedPage.ui + config/AppearancePage.ui + config/BridgeDownloaderProgressDialog.ui + config/BridgeUsageDialog.ui + config/ConfigDialog.ui + config/GeneralPage.ui + config/NetworkPage.ui + config/ServerPage.ui + config/ServicePage.ui + help/browser/HelpBrowser.ui + log/MessageLog.ui + network/NetViewer.ui + network/RouterInfoDialog.ui ) + if (USE_MINIUPNPC) - qt4_wrap_ui(vidalia_SRCS config/upnptestdialog.ui) + qt4_wrap_ui(vidalia_SRCS config/UPNPTestDialog.ui) endif(USE_MINIUPNPC) +if (USE_AUTOUPDATE) + set(vidalia_SRCS ${vidalia_SRCS} + PackageInfo.cpp + UpdateProcess.cpp + UpdateProgressDialog.cpp + UpdatesAvailableDialog.cpp + ) + qt4_wrap_cpp(vidalia_SRCS + UpdateProcess.h + UpdateProgressDialog.h + UpdatesAvailableDialog.h + ) + qt4_wrap_ui(vidalia_SRCS + UpdateProgressDialog.ui + UpdatesAvailableDialog.ui + ) +endif(USE_AUTOUPDATE) + ## Add the resource files (icons, etc.) qt4_add_resources(vidalia_SRCS res/vidalia.qrc @@ -223,6 +301,35 @@ ${CMAKE_CURRENT_BINARY_DIR}/i18n/vidalia_i18n.qrc ) +## Specify the map data Marble will need +set(marble_DATA + landcolors.leg + seacolors.leg + maps/earth/bluemarble/bluemarble.dgml + maps/earth/citylights/citylights.dgml + maps/earth/srtm/srtm.dgml + maps/earth/srtm/srtm.jpg + mwdbii/DATELINE.PNT + mwdbii/PAUST.PNT + mwdbii/PBORDER.PNT + mwdbii/PCANPROV.PNT + mwdbii/PCOAST.PNT + mwdbii/PDIFFBORDER.PNT + mwdbii/PGLACIER.PNT + mwdbii/PISLAND.PNT + mwdbii/PLAKE.PNT + mwdbii/PLAKEISLAND.PNT + mwdbii/PMEXICO.PNT + mwdbii/PUSA48.DIFF.PNT + mwdbii/PUSA48.PNT + mwdbii/RIVER.PNT + placemarks/baseplacemarks.cache + placemarks/boundaryplacemarks.cache + placemarks/elevplacemarks.cache + stars/stars.dat + svg/worldmap.svg +) + ## Set the appropriate executable target for the current platform if (APPLE) ## Set the output file name (make it uppercase on OS X) @@ -234,27 +341,99 @@ set(MACOSX_BUNDLE_SHORT_VERSION_STRING ${VERSION}) set(MACOSX_BUNDLE_LONG_VERSION_STRING "Version ${VERSION}") set(MACOSX_BUNDLE_ICON_FILE vidalia.icns) - + set(MACOSX_BUNDLE_GUI_IDENTIFIER "net.vidalia-project.vidalia") + set(MACOSX_BUNDLE_INFO_STRING "Vidalia ${VERSION}") + ## Put everything inside the application bundle set(CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}/) add_executable(${vidalia_BIN} MACOSX_BUNDLE ${vidalia_SRCS}) + ## Get the location of the app bundle for the current configuration + get_target_property(VIDALIA_EXECUTABLE ${vidalia_BIN} LOCATION) + get_filename_component(MACOSX_BUNDLE_DIRECTORY ${VIDALIA_EXECUTABLE} PATH) + get_filename_component(MACOSX_BUNDLE_DIRECTORY "${MACOSX_BUNDLE_DIRECTORY}/../../" ABSOLUTE) + ## Include the bundle resource files add_custom_command(TARGET ${vidalia_BIN} POST_BUILD - COMMAND mkdir - ARGS -p ${CMAKE_CURRENT_BINARY_DIR}/Vidalia.app/Contents/Resources + COMMAND ${CMAKE_COMMAND} + ARGS -E make_directory ${MACOSX_BUNDLE_DIRECTORY}/Contents/Resources COMMAND cp ARGS ${CMAKE_CURRENT_SOURCE_DIR}/res/icons/*.icns - ${CMAKE_CURRENT_BINARY_DIR}/Vidalia.app/Contents/Resources/ + ${MACOSX_BUNDLE_DIRECTORY}/Contents/Resources/ ) + + if (USE_MARBLE) + ## Copy the Marble data into the bundle + foreach(it ${marble_DATA}) + get_filename_component(outdir ${it} PATH) + get_filename_component(outfile ${it} NAME) + set(outdir ${MACOSX_BUNDLE_DIRECTORY}/Contents/Resources/data/${outdir}) + + add_custom_command(TARGET ${vidalia_BIN} POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E make_directory ${outdir} + COMMAND ${CMAKE_COMMAND} + ARGS -E copy_if_different + ${MARBLE_DATA_DIR}/${it} ${outdir}/${outfile} + ) + endforeach(it) + + ## Create the Marble plugins directory and copy in any wanted plugins + if (MARBLE_PLUGINS) + add_custom_command(TARGET ${vidalia_BIN} POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E make_directory + ${MACOSX_BUNDLE_DIRECTORY}/Contents/Resources/plugins + ) + foreach(it ${MARBLE_PLUGINS}) + add_custom_command(TARGET ${vidalia_BIN} POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E copy_if_different ${it} + ${MACOSX_BUNDLE_DIRECTORY}/Contents/Resources/plugins/ + ) + endforeach(it) + endif(MARBLE_PLUGINS) + endif(USE_MARBLE) else(APPLE) ## Set the output file name set(vidalia_BIN vidalia) - + if (WIN32) ## Create a Windows binary - win32_wrap_rc(vidalia_SRCS res/vidalia_win.rc) + win32_add_rc(vidalia_SRCS res/vidalia_win.rc) add_executable(${vidalia_BIN} WIN32 ${vidalia_SRCS}) + + ## Copy the Marble data into the data/ directory under the binary + if (USE_MARBLE) + foreach(it ${marble_DATA}) + get_filename_component(outdir ${it} PATH) + get_filename_component(outfile ${it} NAME) + + add_custom_command(TARGET ${vidalia_BIN} POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/${outdir} + COMMAND ${CMAKE_COMMAND} + ARGS -E copy_if_different ${MARBLE_DATA_DIR}/${it} + ${CMAKE_CURRENT_BINARY_DIR}/data/${it} + ) + endforeach(it) + + ## Create the Marble plugins directory and copy in any wanted plugins + if (MARBLE_PLUGINS) + add_custom_command(TARGET ${vidalia_BIN} POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/plugins/marble + ) + foreach(it ${MARBLE_PLUGINS}) + add_custom_command(TARGET ${vidalia_BIN} POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E copy_if_different ${it} + ${CMAKE_CURRENT_BINARY_DIR}/plugins/marble/ + ) + endforeach(it) + endif(MARBLE_PLUGINS) + endif(USE_MARBLE) + else (WIN32) ## Non-Windows, non-Mac add_executable(${vidalia_BIN} ${vidalia_SRCS}) @@ -272,6 +451,15 @@ if (USE_MINIUPNPC) target_link_libraries(${vidalia_BIN} miniupnpc) endif(USE_MINIUPNPC) +if (USE_BREAKPAD) + target_link_libraries(${vidalia_BIN} ${BREAKPAD_LIBRARIES}) +endif(USE_BREAKPAD) +if (USE_MARBLE) + target_link_libraries(${vidalia_BIN} + ${MARBLE_LIBRARIES} + ${QT_QTSVG_LIBRARY} + ) +endif(USE_MARBLE) if (WIN32) target_link_libraries(${vidalia_BIN} @@ -304,3 +492,9 @@ DESTINATION share/icons/hicolor/128x128/apps) endif(NOT WIN32 AND NOT APPLE) +## Remember the location of the Vidalia binary so we can use it in +## the Windows packaging scripts +get_target_property(VIDALIA_EXECUTABLE ${vidalia_BIN} LOCATION_RelWithDebInfo) +set(VIDALIA_EXECUTABLE ${VIDALIA_EXECUTABLE} + CACHE STRING "Location of the Vidalia executable." FORCE) + diff -Nru vidalia-0.1.13/src/vidalia/config/abstracttorsettings.cpp vidalia-0.2.8/src/vidalia/config/abstracttorsettings.cpp --- vidalia-0.1.13/src/vidalia/config/abstracttorsettings.cpp 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/abstracttorsettings.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,131 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 abstracttorsettings.cpp -** \version $Id: abstracttorsettings.cpp 2362 2008-02-29 04:30:11Z edmanm $ -** \brief Manages settings that need to be SETCONF'ed to Tor -*/ - -#include "abstracttorsettings.h" - -/** Setting that gets set to true if any settings in the current - * settings group have been changed since the last time apply() was called. */ -#define SETTING_CHANGED "Changed" - - -/** Constructor. All settings will be under the heading group and - * torControl will be used to getconf values from Tor. */ -AbstractTorSettings::AbstractTorSettings(const QString &group, - TorControl *torControl) -: VSettings(group) -{ - _torControl = torControl; - _backupSettings = allSettings(); - - setDefault(SETTING_CHANGED, false); -} - -/** Reverts all settings to their values at the last time apply() was - * called. */ -void -AbstractTorSettings::revert() -{ - remove(""); - foreach (QString key, _backupSettings.keys()) { - setValue(key, _backupSettings.value(key)); - } -} - -/** Returns true if any settings have changed since the last time apply() - * was called. */ -bool -AbstractTorSettings::changedSinceLastApply() const -{ - return localValue(SETTING_CHANGED).toBool(); -} - -/** Sets a value indicating that the server settings have changed since - * apply() was last called. */ -void -AbstractTorSettings::setChanged(bool changed) -{ - VSettings::setValue(SETTING_CHANGED, changed); - if (!changed) - _backupSettings = allSettings(); -} - -/** Returns true if the given QVariant contains an empty value, depending on - * the data type. For example, 0 is considered an empty integer and "" is - * an empty string. */ -bool -AbstractTorSettings::isEmptyValue(const QVariant &value) const -{ - switch (value.type()) { - case QVariant::String: - return (value.toString().isEmpty()); - case QVariant::StringList: - return (value.toStringList().isEmpty()); - case QVariant::UInt: - case QVariant::Int: - return (value.toUInt() == 0); - case QVariant::Invalid: - return true; - default: break; - } - return false; -} - -/** Returns the value associated with key saved in the local - * configuration file. */ -QVariant -AbstractTorSettings::localValue(const QString &key) const -{ - return VSettings::value(key); -} - -/** Returns the value associated with key by querying TOr via - * getconf key. */ -QVariant -AbstractTorSettings::torValue(const QString &key) const -{ - QVariant defaultVal; - QVariant confValue; - - defaultVal = defaultValue(key); - if (_torControl) { - confValue = _torControl->getConf(key); - confValue.convert(defaultVal.type()); - } - return (isEmptyValue(confValue) ? localValue(key) : confValue); -} - -/** If Vidalia is connected to Tor, this returns the value associated with - * key by calling torValue(). Otherwise, this calls localValue() to get - * the locally saved value associated with key. */ -QVariant -AbstractTorSettings::value(const QString &key) const -{ - if (_torControl && _torControl->isConnected() && !changedSinceLastApply()) - return torValue(key); - return localValue(key); -} - -/** Saves the value val for the setting key to the local - * settings file. */ -void -AbstractTorSettings::setValue(const QString &key, const QVariant &value) -{ - if (value != localValue(key)) { - setChanged(true); - VSettings::setValue(key, value); - } -} - diff -Nru vidalia-0.1.13/src/vidalia/config/AbstractTorSettings.cpp vidalia-0.2.8/src/vidalia/config/AbstractTorSettings.cpp --- vidalia-0.1.13/src/vidalia/config/AbstractTorSettings.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/AbstractTorSettings.cpp 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,131 @@ +/* +** 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.vidalia-project.net/. 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 AbstractTorSettings.cpp +** \version $Id: AbstractTorSettings.cpp 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Manages settings that need to be SETCONF'ed to Tor +*/ + +#include "AbstractTorSettings.h" + +/** Setting that gets set to true if any settings in the current + * settings group have been changed since the last time apply() was called. */ +#define SETTING_CHANGED "Changed" + + +/** Constructor. All settings will be under the heading group and + * torControl will be used to getconf values from Tor. */ +AbstractTorSettings::AbstractTorSettings(const QString &group, + TorControl *torControl) +: VSettings(group) +{ + _torControl = torControl; + _backupSettings = allSettings(); + + setDefault(SETTING_CHANGED, false); +} + +/** Reverts all settings to their values at the last time apply() was + * called. */ +void +AbstractTorSettings::revert() +{ + remove(""); + foreach (QString key, _backupSettings.keys()) { + setValue(key, _backupSettings.value(key)); + } +} + +/** Returns true if any settings have changed since the last time apply() + * was called. */ +bool +AbstractTorSettings::changedSinceLastApply() const +{ + return localValue(SETTING_CHANGED).toBool(); +} + +/** Sets a value indicating that the server settings have changed since + * apply() was last called. */ +void +AbstractTorSettings::setChanged(bool changed) +{ + VSettings::setValue(SETTING_CHANGED, changed); + if (!changed) + _backupSettings = allSettings(); +} + +/** Returns true if the given QVariant contains an empty value, depending on + * the data type. For example, 0 is considered an empty integer and "" is + * an empty string. */ +bool +AbstractTorSettings::isEmptyValue(const QVariant &value) const +{ + switch (value.type()) { + case QVariant::String: + return (value.toString().isEmpty()); + case QVariant::StringList: + return (value.toStringList().isEmpty()); + case QVariant::UInt: + case QVariant::Int: + return (value.toUInt() == 0); + case QVariant::Invalid: + return true; + default: break; + } + return false; +} + +/** Returns the value associated with key saved in the local + * configuration file. */ +QVariant +AbstractTorSettings::localValue(const QString &key) const +{ + return VSettings::value(key); +} + +/** Returns the value associated with key by querying TOr via + * getconf key. */ +QVariant +AbstractTorSettings::torValue(const QString &key) const +{ + QVariant defaultVal; + QVariant confValue; + + defaultVal = defaultValue(key); + if (_torControl) { + confValue = _torControl->getConf(key); + confValue.convert(defaultVal.type()); + } + return (isEmptyValue(confValue) ? localValue(key) : confValue); +} + +/** If Vidalia is connected to Tor, this returns the value associated with + * key by calling torValue(). Otherwise, this calls localValue() to get + * the locally saved value associated with key. */ +QVariant +AbstractTorSettings::value(const QString &key) const +{ + if (_torControl && _torControl->isConnected() && !changedSinceLastApply()) + return torValue(key); + return localValue(key); +} + +/** Saves the value val for the setting key to the local + * settings file. */ +void +AbstractTorSettings::setValue(const QString &key, const QVariant &value) +{ + if (value != localValue(key)) { + setChanged(true); + VSettings::setValue(key, value); + } +} + diff -Nru vidalia-0.1.13/src/vidalia/config/abstracttorsettings.h vidalia-0.2.8/src/vidalia/config/abstracttorsettings.h --- vidalia-0.1.13/src/vidalia/config/abstracttorsettings.h 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/abstracttorsettings.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,81 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 abstracttorsettings.h -** \version $Id: abstracttorsettings.h 2362 2008-02-29 04:30:11Z edmanm $ -** \brief Manages settings that need to be SETCONF'ed to Tor -*/ - -#ifndef _ABSTRACTTORSETTINGS_H -#define _ABSTRACTTORSETTINGS_H - -#include -#include "vsettings.h" - - -class AbstractTorSettings : public VSettings -{ - Q_OBJECT - -public: - /** Constructor. All settings will be under the heading group and - * torControl will be used to getconf values from Tor. */ - AbstractTorSettings(const QString &group, TorControl *torControl = 0); - - /** Sets a value indicating that the server settings have changed since - * apply() was last called. */ - void setChanged(bool changed); - /** Returns true if any settings have changed since the last time apply() - * was called. */ - virtual bool changedSinceLastApply() const; - /** Reverts all settings to their values at the last time apply() was - * called. */ - virtual void revert(); - /** Subclasses must implement this to setconf values to apply them - * to a running Tor instance. */ - virtual bool apply(QString *errmsg) = 0; - -protected: - /** If Vidalia is connected to Tor, this returns the value associated with - * key by calling torValue(). Otherwise, this calls localValue() - * to get the locally saved value associated with key. */ - virtual QVariant value(const QString &key) const; - /** Returns the value associated with key saved in the local - * configuration file. */ - virtual QVariant localValue(const QString &key) const; - /** Returns the value associated with key by querying TOr via - * getconf key. */ - virtual QVariant torValue(const QString &key) const; - /** Saves the value val for the setting key to the local - * settings file. */ - virtual void setValue(const QString &key, const QVariant &value); - - /** Returns true if the given QVariant contains an empty value, depending on - * the data type. For example, 0 is considered an empty integer and "" is - * an empty string. */ - bool isEmptyValue(const QVariant &value) const; - -protected: - /** Returns the TorControl object used for reading settings from or writing - * settings to Tor, if one was specified. Returns 0 if no TorControl object - * was given. */ - TorControl* torControl() const { return _torControl; }; - -private: - /** TorControl object used for reading settings from or applying settings to - * Tor. */ - TorControl* _torControl; - /** Collection of settings values at the last time apply() was called. */ - QMap _backupSettings; -}; - -#endif - diff -Nru vidalia-0.1.13/src/vidalia/config/AbstractTorSettings.h vidalia-0.2.8/src/vidalia/config/AbstractTorSettings.h --- vidalia-0.1.13/src/vidalia/config/AbstractTorSettings.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/AbstractTorSettings.h 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,81 @@ +/* +** 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.vidalia-project.net/. 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 AbstractTorSettings.h +** \version $Id: AbstractTorSettings.h 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Manages settings that need to be SETCONF'ed to Tor +*/ + +#ifndef _ABSTRACTTORSETTINGS_H +#define _ABSTRACTTORSETTINGS_H + +#include "VSettings.h" +#include "TorControl.h" + + +class AbstractTorSettings : public VSettings +{ + Q_OBJECT + +public: + /** Constructor. All settings will be under the heading group and + * torControl will be used to getconf values from Tor. */ + AbstractTorSettings(const QString &group, TorControl *torControl = 0); + + /** Sets a value indicating that the server settings have changed since + * apply() was last called. */ + void setChanged(bool changed); + /** Returns true if any settings have changed since the last time apply() + * was called. */ + virtual bool changedSinceLastApply() const; + /** Reverts all settings to their values at the last time apply() was + * called. */ + virtual void revert(); + /** Subclasses must implement this to setconf values to apply them + * to a running Tor instance. */ + virtual bool apply(QString *errmsg) = 0; + +protected: + /** If Vidalia is connected to Tor, this returns the value associated with + * key by calling torValue(). Otherwise, this calls localValue() + * to get the locally saved value associated with key. */ + virtual QVariant value(const QString &key) const; + /** Returns the value associated with key saved in the local + * configuration file. */ + virtual QVariant localValue(const QString &key) const; + /** Returns the value associated with key by querying TOr via + * getconf key. */ + virtual QVariant torValue(const QString &key) const; + /** Saves the value val for the setting key to the local + * settings file. */ + virtual void setValue(const QString &key, const QVariant &value); + + /** Returns true if the given QVariant contains an empty value, depending on + * the data type. For example, 0 is considered an empty integer and "" is + * an empty string. */ + bool isEmptyValue(const QVariant &value) const; + +protected: + /** Returns the TorControl object used for reading settings from or writing + * settings to Tor, if one was specified. Returns 0 if no TorControl object + * was given. */ + TorControl* torControl() const { return _torControl; }; + +private: + /** TorControl object used for reading settings from or applying settings to + * Tor. */ + TorControl* _torControl; + /** Collection of settings values at the last time apply() was called. */ + QMap _backupSettings; +}; + +#endif + diff -Nru vidalia-0.1.13/src/vidalia/config/advancedpage.cpp vidalia-0.2.8/src/vidalia/config/advancedpage.cpp --- vidalia-0.1.13/src/vidalia/config/advancedpage.cpp 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/advancedpage.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,299 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 advancedpage.cpp -** \version $Id: advancedpage.cpp 3291 2008-11-10 01:18:11Z edmanm $ -** \brief Advanced Tor and Vidalia configuration options -*/ - -#include -#include -#include -#include -#include -#include - -#include "ipvalidator.h" -#include "advancedpage.h" - -#if defined(Q_WS_WIN) -#include -#endif - - -/** Constructor */ -AdvancedPage::AdvancedPage(QWidget *parent) -: ConfigPage(parent, tr("Advanced")) -{ - /* Invoke the Qt Designer generated object setup routine */ - ui.setupUi(this); - - /* Create TorSettings object */ - _settings = new TorSettings(Vidalia::torControl()); - - /* Set validators for the control port and IP address fields */ - ui.lineControlAddress->setValidator(new IPValidator(this)); - ui.lineControlPort->setValidator(new QIntValidator(1, 65535, this)); - - /* Bind event to actions */ - connect(ui.btnBrowseTorConfig, SIGNAL(clicked()), this, SLOT(browseTorConfig())); - connect(ui.btnBrowseTorDataDirectory, SIGNAL(clicked()), - this, SLOT(browseTorDataDirectory())); - connect(ui.cmbAuthMethod, SIGNAL(currentIndexChanged(int)), - this, SLOT(authMethodChanged(int))); - connect(ui.chkRandomPassword, SIGNAL(toggled(bool)), - ui.linePassword, SLOT(setDisabled(bool))); - - /* Hide platform specific features */ -#if defined(Q_WS_WIN) -#if 0 - ui.grpService->setVisible(TorService::isSupported()); -#endif -#endif -} - -/** Destructor */ -AdvancedPage::~AdvancedPage() -{ - delete _settings; -} - -/** Applies the network configuration settings to Tor. Returns true if the - * settings were applied successfully. Otherwise, errmsg is set - * and false is returned. */ -bool -AdvancedPage::apply(QString &errmsg) -{ - return _settings->apply(&errmsg); -} - -/** Reverts the Tor configuration settings to their values at the last - * time they were successfully applied to Tor. */ -bool -AdvancedPage::changedSinceLastApply() -{ - return _settings->changedSinceLastApply(); -} - -/** Returns true if the user has changed their advanced Tor settings since - * the last time they were applied to Tor. */ -void -AdvancedPage::revert() -{ - return _settings->revert(); -} - -/** Saves all settings for this page. */ -bool -AdvancedPage::save(QString &errmsg) -{ - /* Validate the control listener address */ - QHostAddress controlAddress(ui.lineControlAddress->text()); - if (controlAddress.isNull()) { - errmsg = tr("'%1' is not a valid IP address.") - .arg(ui.lineControlAddress->text()); - return false; - } - - /* Validate the selected authentication options */ - TorSettings::AuthenticationMethod authMethod = - indexToAuthMethod(ui.cmbAuthMethod->currentIndex()); - if (authMethod == TorSettings::PasswordAuth - && ui.linePassword->text().isEmpty() - && !ui.chkRandomPassword->isChecked()) { - errmsg = tr("You selected 'Password' authentication, but did not " - "specify a password."); - return false; - } - - /* Only remember the torrc and datadir values if Vidalia started Tor, or - * if the user changed the displayed values. */ - if (!Vidalia::torControl()->isVidaliaRunningTor()) { - QString torrc = ui.lineTorConfig->text(); - if (torrc != _settings->getTorrc()) - _settings->setTorrc(torrc); - - QString dataDir = ui.lineTorDataDirectory->text(); - if (dataDir != _settings->getDataDirectory()) - _settings->setDataDirectory(dataDir); - } else { - _settings->setTorrc(ui.lineTorConfig->text()); - _settings->setDataDirectory(ui.lineTorDataDirectory->text()); - } - - _settings->setControlAddress(controlAddress); - _settings->setControlPort(ui.lineControlPort->text().toUShort()); - - _settings->setAuthenticationMethod(authMethod); - _settings->setUseRandomPassword(ui.chkRandomPassword->isChecked()); - if (authMethod == TorSettings::PasswordAuth - && !ui.chkRandomPassword->isChecked()) - _settings->setControlPassword(ui.linePassword->text()); - -#if 0 -#if defined(Q_WS_WIN) - /* Install or uninstall the Tor service as necessary */ - setupService(ui.chkUseService->isChecked()); -#endif -#endif - - return true; -} - -/** Loads previously saved settings. */ -void -AdvancedPage::load() -{ - ui.lineControlAddress->setText(_settings->getControlAddress().toString()); - ui.lineControlPort->setText(QString::number(_settings->getControlPort())); - ui.lineTorConfig->setText(_settings->getTorrc()); - ui.lineTorDataDirectory->setText(_settings->getDataDirectory()); - - ui.cmbAuthMethod->setCurrentIndex( - authMethodToIndex(_settings->getAuthenticationMethod())); - ui.chkRandomPassword->setChecked(_settings->useRandomPassword()); - if (!ui.chkRandomPassword->isChecked()) - ui.linePassword->setText(_settings->getControlPassword()); - -#if 0 -#if defined(Q_WS_WIN) - TorService s; - ui.chkUseService->setChecked(s.isInstalled()); -#endif -#endif -} - -/** Called when the user selects a different authentication method from the - * combo box. */ -void -AdvancedPage::authMethodChanged(int index) -{ - bool usePassword = (indexToAuthMethod(index) == TorSettings::PasswordAuth); - ui.linePassword->setEnabled(usePassword && !ui.chkRandomPassword->isChecked()); - ui.chkRandomPassword->setEnabled(usePassword); -} - -/** Returns the authentication method for the given index. */ -TorSettings::AuthenticationMethod -AdvancedPage::indexToAuthMethod(int index) -{ - switch (index) { - case 0: return TorSettings::NullAuth; - case 1: return TorSettings::CookieAuth; - case 2: return TorSettings::PasswordAuth; - default: break; - } - return TorSettings::UnknownAuth; -} - -/** Returns the index in the authentication methods combo box for the given - * authentication method. */ -int -AdvancedPage::authMethodToIndex(TorSettings::AuthenticationMethod method) -{ - switch (method) { - case TorSettings::NullAuth: return 0; - case TorSettings::CookieAuth: return 1; - default: break; - } - return 2; -} - -/** Open a QFileDialog to browse for Tor config file. */ -void -AdvancedPage::browseTorConfig() -{ - /* Prompt the user to select a file or create a new one */ - QString filename = QFileDialog::getOpenFileName(this, - tr("Select Tor Configuration File"), - QFileInfo(ui.lineTorConfig->text()).fileName()); - - /* Make sure a filename was selected */ - if (filename.isEmpty()) { - return; - } - - /* Check if the file exists */ - QFile torrcFile(filename); - if (!QFileInfo(filename).exists()) { - /* The given file does not exist. Should we create it? */ - int response = VMessageBox::question(this, - tr("File Not Found"), - tr("%1 does not exist. Would you like to create it?") - .arg(filename), - VMessageBox::Yes, VMessageBox::No); - - if (response == VMessageBox::No) { - /* Don't create it. Just bail. */ - return; - } - /* Attempt to create the specified file */ - QString errmsg; - if (!touch_file(filename, false, &errmsg)) { - VMessageBox::warning(this, - tr("Failed to Create File"), - tr("Unable to create %1 [%2]").arg(filename) - .arg(errmsg), - VMessageBox::Ok); - return; - } - } - ui.lineTorConfig->setText(filename); -} - -/** Opens a QFileDialog for the user to browse to or create a directory for - * Tor's DataDirectory. */ -void -AdvancedPage::browseTorDataDirectory() -{ - QString dataDir = QFileDialog::getExistingDirectory(this, - tr("Select a Directory to Use for Tor Data"), - ui.lineTorDataDirectory->text()); - - if (!dataDir.isEmpty()) - ui.lineTorDataDirectory->setText(dataDir); -} - -#if 0 -#if defined(Q_WS_WIN) -/** Installs or removes the Tor service as necessary. */ -void -AdvancedPage::setupService(bool useService) -{ - TorService service; - bool isInstalled = service.isInstalled(); - - if (!useService && isInstalled) { - /* Uninstall if we don't want to use it anymore */ - Vidalia::torControl()->stop(); - - if (!service.remove()) { - VMessageBox::critical(this, - tr("Unable to remove Tor Service"), - tr("Vidalia was unable to remove the Tor service.\n\n" - "You may need to remove it manually."), - VMessageBox::Ok, VMessageBox::Cancel); - } - } else if (useService && !isInstalled) { - /* Install if we want to start using a service */ - if (!service.install(_settings->getExecutable(), - _settings->getTorrc(), - _settings->getControlPort())) { - VMessageBox::critical(this, - tr("Unable to install Tor Service"), - tr("Vidalia was unable to install the Tor service."), - VMessageBox::Ok, VMessageBox::Cancel); - } - } -} -#endif -#endif - diff -Nru vidalia-0.1.13/src/vidalia/config/AdvancedPage.cpp vidalia-0.2.8/src/vidalia/config/AdvancedPage.cpp --- vidalia-0.1.13/src/vidalia/config/AdvancedPage.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/AdvancedPage.cpp 2009-08-10 16:20:25.000000000 +0100 @@ -0,0 +1,308 @@ +/* +** 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.vidalia-project.net/. 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 AdvancedPage.cpp +** \version $Id: AdvancedPage.cpp 4023 2009-08-10 15:20:25Z edmanm $ +** \brief Advanced Tor and Vidalia configuration options +*/ + +#include "AdvancedPage.h" +#include "Vidalia.h" +#include "VMessageBox.h" +#include "IpValidator.h" + +#include "file.h" + +#if defined(Q_WS_WIN) +#include "TorService.h" +#endif + +#include +#include +#include + + +/** Constructor */ +AdvancedPage::AdvancedPage(QWidget *parent) + : ConfigPage(parent, "Advanced") +{ + /* Invoke the Qt Designer generated object setup routine */ + ui.setupUi(this); + + /* Create TorSettings object */ + _settings = new TorSettings(Vidalia::torControl()); + + /* Set validators for the control port and IP address fields */ + ui.lineControlAddress->setValidator(new IpValidator(this)); + ui.lineControlPort->setValidator(new QIntValidator(1, 65535, this)); + + /* Bind event to actions */ + connect(ui.btnBrowseTorConfig, SIGNAL(clicked()), this, SLOT(browseTorConfig())); + connect(ui.btnBrowseTorDataDirectory, SIGNAL(clicked()), + this, SLOT(browseTorDataDirectory())); + connect(ui.cmbAuthMethod, SIGNAL(currentIndexChanged(int)), + this, SLOT(authMethodChanged(int))); + connect(ui.chkRandomPassword, SIGNAL(toggled(bool)), + ui.linePassword, SLOT(setDisabled(bool))); + + /* Hide platform specific features */ +#if defined(Q_WS_WIN) +#if 0 + ui.grpService->setVisible(TorService::isSupported()); +#endif +#endif +} + +/** Destructor */ +AdvancedPage::~AdvancedPage() +{ + delete _settings; +} + +/** Called when the user changes the UI translation. */ +void +AdvancedPage::retranslateUi() +{ + ui.retranslateUi(this); +} + +/** Applies the network configuration settings to Tor. Returns true if the + * settings were applied successfully. Otherwise, errmsg is set + * and false is returned. */ +bool +AdvancedPage::apply(QString &errmsg) +{ + return _settings->apply(&errmsg); +} + +/** Reverts the Tor configuration settings to their values at the last + * time they were successfully applied to Tor. */ +bool +AdvancedPage::changedSinceLastApply() +{ + return _settings->changedSinceLastApply(); +} + +/** Returns true if the user has changed their advanced Tor settings since + * the last time they were applied to Tor. */ +void +AdvancedPage::revert() +{ + return _settings->revert(); +} + +/** Saves all settings for this page. */ +bool +AdvancedPage::save(QString &errmsg) +{ + /* Validate the control listener address */ + QHostAddress controlAddress(ui.lineControlAddress->text()); + if (controlAddress.isNull()) { + errmsg = tr("'%1' is not a valid IP address.") + .arg(ui.lineControlAddress->text()); + return false; + } + + /* Validate the selected authentication options */ + TorSettings::AuthenticationMethod authMethod = + indexToAuthMethod(ui.cmbAuthMethod->currentIndex()); + if (authMethod == TorSettings::PasswordAuth + && ui.linePassword->text().isEmpty() + && !ui.chkRandomPassword->isChecked()) { + errmsg = tr("You selected 'Password' authentication, but did not " + "specify a password."); + return false; + } + + /* Only remember the torrc and datadir values if Vidalia started Tor, or + * if the user changed the displayed values. */ + if (!Vidalia::torControl()->isVidaliaRunningTor()) { + QString torrc = ui.lineTorConfig->text(); + if (torrc != _settings->getTorrc()) + _settings->setTorrc(torrc); + + QString dataDir = ui.lineTorDataDirectory->text(); + if (dataDir != _settings->getDataDirectory()) + _settings->setDataDirectory(dataDir); + } else { + _settings->setTorrc(ui.lineTorConfig->text()); + _settings->setDataDirectory(ui.lineTorDataDirectory->text()); + } + + _settings->setControlAddress(controlAddress); + _settings->setControlPort(ui.lineControlPort->text().toUShort()); + + _settings->setAuthenticationMethod(authMethod); + _settings->setUseRandomPassword(ui.chkRandomPassword->isChecked()); + if (authMethod == TorSettings::PasswordAuth + && !ui.chkRandomPassword->isChecked()) + _settings->setControlPassword(ui.linePassword->text()); + +#if 0 +#if defined(Q_WS_WIN) + /* Install or uninstall the Tor service as necessary */ + setupService(ui.chkUseService->isChecked()); +#endif +#endif + + return true; +} + +/** Loads previously saved settings. */ +void +AdvancedPage::load() +{ + ui.lineControlAddress->setText(_settings->getControlAddress().toString()); + ui.lineControlPort->setText(QString::number(_settings->getControlPort())); + ui.lineTorConfig->setText(_settings->getTorrc()); + ui.lineTorDataDirectory->setText(_settings->getDataDirectory()); + + ui.cmbAuthMethod->setCurrentIndex( + authMethodToIndex(_settings->getAuthenticationMethod())); + ui.chkRandomPassword->setChecked(_settings->useRandomPassword()); + if (!ui.chkRandomPassword->isChecked()) + ui.linePassword->setText(_settings->getControlPassword()); + +#if 0 +#if defined(Q_WS_WIN) + TorService s; + ui.chkUseService->setChecked(s.isInstalled()); +#endif +#endif +} + +/** Called when the user selects a different authentication method from the + * combo box. */ +void +AdvancedPage::authMethodChanged(int index) +{ + bool usePassword = (indexToAuthMethod(index) == TorSettings::PasswordAuth); + ui.linePassword->setEnabled(usePassword && !ui.chkRandomPassword->isChecked()); + ui.chkRandomPassword->setEnabled(usePassword); +} + +/** Returns the authentication method for the given index. */ +TorSettings::AuthenticationMethod +AdvancedPage::indexToAuthMethod(int index) +{ + switch (index) { + case 0: return TorSettings::NullAuth; + case 1: return TorSettings::CookieAuth; + case 2: return TorSettings::PasswordAuth; + default: break; + } + return TorSettings::UnknownAuth; +} + +/** Returns the index in the authentication methods combo box for the given + * authentication method. */ +int +AdvancedPage::authMethodToIndex(TorSettings::AuthenticationMethod method) +{ + switch (method) { + case TorSettings::NullAuth: return 0; + case TorSettings::CookieAuth: return 1; + default: break; + } + return 2; +} + +/** Open a QFileDialog to browse for Tor config file. */ +void +AdvancedPage::browseTorConfig() +{ + /* Prompt the user to select a file or create a new one */ + QString filename = QFileDialog::getOpenFileName(this, + tr("Select Tor Configuration File"), + QFileInfo(ui.lineTorConfig->text()).filePath(), + tr("Tor Configuration File (torrc);;All Files (*)")); + + /* Make sure a filename was selected */ + if (filename.isEmpty()) { + return; + } + + /* Check if the file exists */ + QFile torrcFile(filename); + if (!QFileInfo(filename).exists()) { + /* The given file does not exist. Should we create it? */ + int response = VMessageBox::question(this, + tr("File Not Found"), + tr("%1 does not exist. Would you like to create it?") + .arg(filename), + VMessageBox::Yes, VMessageBox::No); + + if (response == VMessageBox::No) { + /* Don't create it. Just bail. */ + return; + } + /* Attempt to create the specified file */ + QString errmsg; + if (!touch_file(filename, false, &errmsg)) { + VMessageBox::warning(this, + tr("Failed to Create File"), + tr("Unable to create %1 [%2]").arg(filename) + .arg(errmsg), + VMessageBox::Ok); + return; + } + } + ui.lineTorConfig->setText(filename); +} + +/** Opens a QFileDialog for the user to browse to or create a directory for + * Tor's DataDirectory. */ +void +AdvancedPage::browseTorDataDirectory() +{ + QString dataDir = QFileDialog::getExistingDirectory(this, + tr("Select a Directory to Use for Tor Data"), + ui.lineTorDataDirectory->text()); + + if (!dataDir.isEmpty()) + ui.lineTorDataDirectory->setText(dataDir); +} + +#if 0 +#if defined(Q_WS_WIN) +/** Installs or removes the Tor service as necessary. */ +void +AdvancedPage::setupService(bool useService) +{ + TorService service; + bool isInstalled = service.isInstalled(); + + if (!useService && isInstalled) { + /* Uninstall if we don't want to use it anymore */ + Vidalia::torControl()->stop(); + + if (!service.remove()) { + VMessageBox::critical(this, + tr("Unable to remove Tor Service"), + tr("Vidalia was unable to remove the Tor service.\n\n" + "You may need to remove it manually."), + VMessageBox::Ok, VMessageBox::Cancel); + } + } else if (useService && !isInstalled) { + /* Install if we want to start using a service */ + if (!service.install(_settings->getExecutable(), + _settings->getTorrc(), + _settings->getControlPort())) { + VMessageBox::critical(this, + tr("Unable to install Tor Service"), + tr("Vidalia was unable to install the Tor service."), + VMessageBox::Ok, VMessageBox::Cancel); + } + } +} +#endif +#endif + diff -Nru vidalia-0.1.13/src/vidalia/config/advancedpage.h vidalia-0.2.8/src/vidalia/config/advancedpage.h --- vidalia-0.1.13/src/vidalia/config/advancedpage.h 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/advancedpage.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,84 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 advancedpage.h -** \version $Id: advancedpage.h 2598 2008-05-25 21:19:18Z edmanm $ -** \brief Advanced Tor and Vidalia configuration options -*/ - -#ifndef _ADVANCEDPAGE_H -#define _ADVANCEDPAGE_H - -#include -#include - -#include "configpage.h" -#include "ui_advancedpage.h" - - -class AdvancedPage : public ConfigPage -{ - Q_OBJECT - -public: - /** Default Constructor */ - AdvancedPage(QWidget *parent = 0); - /** Default Destructor */ - ~AdvancedPage(); - /** Saves the changes on this page */ - bool save(QString &errmsg); - /** Loads the settings for this page */ - void load(); - - /** Applies the network configuration settings to Tor. Returns true if the - * settings were applied successfully. Otherwise, errmsg is set - * and false is returned. */ - bool apply(QString &errmsg); - /** Reverts the Tor configuration settings to their values at the last - * time they were successfully applied to Tor. */ - void revert(); - /** Returns true if the user has changed their advanced Tor settings since - * the last time they were applied to Tor. */ - bool changedSinceLastApply(); - -private slots: - /** Called when the user selects a different authentication method from the - * combo box. */ - void authMethodChanged(int index); - /** Called when the user clicks "Browse" to choose location of Tor config - * file */ - void browseTorConfig(); - /** Called when the user clicks "Browse" to choose the location of Tor's - * data directory. */ - void browseTorDataDirectory(); - -private: - /** Returns the authentication method for the given index. */ - TorSettings::AuthenticationMethod indexToAuthMethod(int index); - /** Returns the index in the authentication methods combo box for the given - * authentication method. */ - int authMethodToIndex(TorSettings::AuthenticationMethod method); - -#if 0 -#if defined(Q_WS_WIN) - /** Installs or removes the Tor service as necessary */ - void setupService(bool useService); -#endif -#endif - - /** A TorSettings object used to save/load settings */ - TorSettings* _settings; - /** Qt Designer generated object */ - Ui::AdvancedPage ui; -}; - -#endif - diff -Nru vidalia-0.1.13/src/vidalia/config/AdvancedPage.h vidalia-0.2.8/src/vidalia/config/AdvancedPage.h --- vidalia-0.1.13/src/vidalia/config/AdvancedPage.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/AdvancedPage.h 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,86 @@ +/* +** 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.vidalia-project.net/. 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 AdvancedPage.h +** \version $Id: AdvancedPage.h 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Advanced Tor and Vidalia configuration options +*/ + +#ifndef _ADVANCEDPAGE_H +#define _ADVANCEDPAGE_H + +#include "ui_AdvancedPage.h" +#include "ConfigPage.h" +#include "TorSettings.h" + +#include + + +class AdvancedPage : public ConfigPage +{ + Q_OBJECT + +public: + /** Default Constructor */ + AdvancedPage(QWidget *parent = 0); + /** Default Destructor */ + ~AdvancedPage(); + /** Saves the changes on this page */ + bool save(QString &errmsg); + /** Loads the settings for this page */ + void load(); + + /** Applies the network configuration settings to Tor. Returns true if the + * settings were applied successfully. Otherwise, errmsg is set + * and false is returned. */ + bool apply(QString &errmsg); + /** Reverts the Tor configuration settings to their values at the last + * time they were successfully applied to Tor. */ + void revert(); + /** Returns true if the user has changed their advanced Tor settings since + * the last time they were applied to Tor. */ + bool changedSinceLastApply(); + /** Called when the user changes the UI translation. */ + virtual void retranslateUi(); + +private slots: + /** Called when the user selects a different authentication method from the + * combo box. */ + void authMethodChanged(int index); + /** Called when the user clicks "Browse" to choose location of Tor config + * file */ + void browseTorConfig(); + /** Called when the user clicks "Browse" to choose the location of Tor's + * data directory. */ + void browseTorDataDirectory(); + +private: + /** Returns the authentication method for the given index. */ + TorSettings::AuthenticationMethod indexToAuthMethod(int index); + /** Returns the index in the authentication methods combo box for the given + * authentication method. */ + int authMethodToIndex(TorSettings::AuthenticationMethod method); + +#if 0 +#if defined(Q_WS_WIN) + /** Installs or removes the Tor service as necessary */ + void setupService(bool useService); +#endif +#endif + + /** A TorSettings object used to save/load settings */ + TorSettings* _settings; + /** Qt Designer generated object */ + Ui::AdvancedPage ui; +}; + +#endif + diff -Nru vidalia-0.1.13/src/vidalia/config/advancedpage.ui vidalia-0.2.8/src/vidalia/config/advancedpage.ui --- vidalia-0.1.13/src/vidalia/config/advancedpage.ui 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/advancedpage.ui 1970-01-01 01:00:00.000000000 +0100 @@ -1,353 +0,0 @@ - - AdvancedPage - - - - 0 - 0 - 507 - 543 - - - - Qt::NoContextMenu - - - - 9 - - - 6 - - - - - Qt::NoContextMenu - - - Control Port - - - - 9 - - - 6 - - - - - 0 - - - 2 - - - - - Authentication: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Address: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - 0 - - - 2 - - - - - - 120 - 0 - - - - QComboBox::AdjustToContents - - - - None - - - - - Cookie - - - - - Password - - - - - - - - QLineEdit::Password - - - - - - - Randomly Generate - - - - - - - Qt::Horizontal - - - - 0 - 20 - - - - - - - - - - 0 - - - 6 - - - - - - 120 - 16777215 - - - - 16 - - - Qt::AlignRight - - - - - - - : - - - - - - - - 75 - 0 - - - - - 75 - 16777215 - - - - 5 - - - - - - - Qt::Horizontal - - - QSizePolicy::Expanding - - - - 40 - 20 - - - - - - - - - - 0 - - - 6 - - - - - - - - - - - - Qt::NoContextMenu - - - Tor Configuration File - - - - 9 - - - 6 - - - - - true - - - 4 - - - Qt::NoContextMenu - - - Start the Tor software with the specified configuration file (torrc) - - - - - - - true - - - - 0 - 0 - - - - Qt::NoContextMenu - - - Select path to your configuration file - - - Browse - - - - - - - - - - Qt::NoContextMenu - - - Data Directory - - - - 9 - - - 6 - - - - - true - - - 4 - - - Qt::NoContextMenu - - - Store data for the Tor software in the following directory - - - - - - - true - - - - 0 - 0 - - - - Qt::NoContextMenu - - - Select the directory used to store data for the Tor software - - - Browse - - - - - - - - - - Qt::Vertical - - - - 489 - 141 - - - - - - - - lineControlAddress - lineControlPort - cmbAuthMethod - linePassword - chkRandomPassword - lineTorConfig - btnBrowseTorConfig - lineTorDataDirectory - btnBrowseTorDataDirectory - - - - diff -Nru vidalia-0.1.13/src/vidalia/config/AdvancedPage.ui vidalia-0.2.8/src/vidalia/config/AdvancedPage.ui --- vidalia-0.1.13/src/vidalia/config/AdvancedPage.ui 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/AdvancedPage.ui 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,353 @@ + + AdvancedPage + + + + 0 + 0 + 507 + 543 + + + + Qt::NoContextMenu + + + + 9 + + + 6 + + + + + Qt::NoContextMenu + + + Control Port + + + + 9 + + + 6 + + + + + 0 + + + 2 + + + + + Authentication: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Address: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + 0 + + + 2 + + + + + + 120 + 0 + + + + QComboBox::AdjustToContents + + + + None + + + + + Cookie + + + + + Password + + + + + + + + QLineEdit::Password + + + + + + + Randomly Generate + + + + + + + Qt::Horizontal + + + + 0 + 20 + + + + + + + + + + 0 + + + 6 + + + + + + 120 + 16777215 + + + + 16 + + + Qt::AlignRight + + + + + + + : + + + + + + + + 75 + 0 + + + + + 75 + 16777215 + + + + 5 + + + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 40 + 20 + + + + + + + + + + 0 + + + 6 + + + + + + + + + + + + Qt::NoContextMenu + + + Tor Configuration File + + + + 9 + + + 6 + + + + + true + + + 4 + + + Qt::NoContextMenu + + + Start the Tor software with the specified configuration file (torrc) + + + + + + + true + + + + 0 + 0 + + + + Qt::NoContextMenu + + + Select path to your configuration file + + + Browse + + + + + + + + + + Qt::NoContextMenu + + + Data Directory + + + + 9 + + + 6 + + + + + true + + + 4 + + + Qt::NoContextMenu + + + Store data for the Tor software in the following directory + + + + + + + true + + + + 0 + 0 + + + + Qt::NoContextMenu + + + Select the directory used to store data for the Tor software + + + Browse + + + + + + + + + + Qt::Vertical + + + + 489 + 141 + + + + + + + + lineControlAddress + lineControlPort + cmbAuthMethod + linePassword + chkRandomPassword + lineTorConfig + btnBrowseTorConfig + lineTorDataDirectory + btnBrowseTorDataDirectory + + + + diff -Nru vidalia-0.1.13/src/vidalia/config/appearancepage.cpp vidalia-0.2.8/src/vidalia/config/appearancepage.cpp --- vidalia-0.1.13/src/vidalia/config/appearancepage.cpp 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/appearancepage.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,73 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 appearancepage.cpp -** \version $Id: appearancepage.cpp 2362 2008-02-29 04:30:11Z edmanm $ -** \brief Displays Vidalia language and style settings -*/ - -#include -#include "appearancepage.h" - - -/** Default Constructor */ -AppearancePage::AppearancePage(QWidget *parent) -: ConfigPage(parent, tr("Appearance")) -{ - /* Invoke Designer-generated object setup routine */ - ui.setupUi(this); - - /* Create VidaliaSettings object */ - _settings = new VidaliaSettings(); - - /* Populate combo boxes */ - foreach (QString code, LanguageSupport::languageCodes()) { - ui.cmboLanguage->addItem(LanguageSupport::languageName(code), - code); - } - foreach (QString style, QStyleFactory::keys()) { - ui.cmboStyle->addItem(style, style.toLower()); - } -} - -/** Destructor */ -AppearancePage::~AppearancePage() -{ - delete _settings; -} - -/** Saves the changes on this page */ -bool -AppearancePage::save(QString &errmsg) -{ - Q_UNUSED(errmsg); - QString languageCode = - LanguageSupport::languageCode(ui.cmboLanguage->currentText()); - - _settings->setLanguageCode(languageCode); - _settings->setInterfaceStyle(ui.cmboStyle->currentText()); - - /* Set to new style */ - Vidalia::setStyle(ui.cmboStyle->currentText()); - return true; -} - -/** Loads the settings for this page */ -void -AppearancePage::load() -{ - int index = ui.cmboLanguage->findData(_settings->getLanguageCode()); - ui.cmboLanguage->setCurrentIndex(index); - - index = ui.cmboStyle->findData(Vidalia::style().toLower()); - ui.cmboStyle->setCurrentIndex(index); -} - diff -Nru vidalia-0.1.13/src/vidalia/config/AppearancePage.cpp vidalia-0.2.8/src/vidalia/config/AppearancePage.cpp --- vidalia-0.1.13/src/vidalia/config/AppearancePage.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/AppearancePage.cpp 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,89 @@ +/* +** 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.vidalia-project.net/. 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 AppearancePage.cpp +** \version $Id: AppearancePage.cpp 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Displays Vidalia language and style settings +*/ + +#include "AppearancePage.h" +#include "Vidalia.h" +#include "VMessageBox.h" + + +/** Default Constructor */ +AppearancePage::AppearancePage(QWidget *parent) + : ConfigPage(parent, "Appearance") +{ + /* Invoke Designer-generated object setup routine */ + ui.setupUi(this); + + /* Create VidaliaSettings object */ + _settings = new VidaliaSettings(); + + /* Populate combo boxes */ + foreach (QString code, LanguageSupport::languageCodes()) { + ui.cmboLanguage->addItem(LanguageSupport::languageName(code), + code); + } + foreach (QString style, QStyleFactory::keys()) { + ui.cmboStyle->addItem(style, style.toLower()); + } +} + +/** Destructor */ +AppearancePage::~AppearancePage() +{ + delete _settings; +} + +/** Called when the user changes the UI translation. */ +void +AppearancePage::retranslateUi() +{ + ui.retranslateUi(this); +} + +/** Saves the changes on this page */ +bool +AppearancePage::save(QString &errmsg) +{ + QString prevLanguage = _settings->getLanguageCode(); + QString languageCode = + LanguageSupport::languageCode(ui.cmboLanguage->currentText()); + + /* Set the new language */ + if (prevLanguage != languageCode) { + if (! Vidalia::retranslateUi(languageCode)) { + errmsg = tr("Vidalia was unable to load the selected " + "language translation."); + return false; + } + _settings->setLanguageCode(languageCode); + } + + /* Set the new style */ + Vidalia::setStyle(ui.cmboStyle->currentText()); + _settings->setInterfaceStyle(ui.cmboStyle->currentText()); + return true; +} + +/** Loads the settings for this page */ +void +AppearancePage::load() +{ + int index = ui.cmboLanguage->findData(_settings->getLanguageCode()); + ui.cmboLanguage->setCurrentIndex(index); + + index = ui.cmboStyle->findData(Vidalia::style().toLower()); + ui.cmboStyle->setCurrentIndex(index); +} + diff -Nru vidalia-0.1.13/src/vidalia/config/appearancepage.h vidalia-0.2.8/src/vidalia/config/appearancepage.h --- vidalia-0.1.13/src/vidalia/config/appearancepage.h 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/appearancepage.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,51 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 appearancepage.h -** \version $Id: appearancepage.h 2362 2008-02-29 04:30:11Z edmanm $ -** \brief Displays Vidalia language and style settings -*/ - -#ifndef _APPEARANCEPAGE_H -#define _APPEARANCEPAGE_H - -#include -#include - -#include -#include - -#include "configpage.h" -#include "ui_appearancepage.h" - -class AppearancePage : public ConfigPage -{ - Q_OBJECT - -public: - /** Default Constructor */ - AppearancePage(QWidget *parent = 0); - /** Default Destructor */ - ~AppearancePage(); - /** Saves the changes on this page */ - bool save(QString &errmsg); - /** Loads the settings for this page */ - void load(); - -private: - /** A VidaliaSettings object used for saving/loading settings */ - VidaliaSettings* _settings; - - /** Qt Designer generated object */ - Ui::AppearancePage ui; -}; - -#endif diff -Nru vidalia-0.1.13/src/vidalia/config/AppearancePage.h vidalia-0.2.8/src/vidalia/config/AppearancePage.h --- vidalia-0.1.13/src/vidalia/config/AppearancePage.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/AppearancePage.h 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,53 @@ +/* +** 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.vidalia-project.net/. 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 AppearancePage.h +** \version $Id: AppearancePage.h 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Displays Vidalia language and style settings +*/ + +#ifndef _APPEARANCEPAGE_H +#define _APPEARANCEPAGE_H + +#include "ui_AppearancePage.h" +#include "VidaliaSettings.h" +#include "LanguageSupport.h" +#include "ConfigPage.h" + +#include +#include + + +class AppearancePage : public ConfigPage +{ + Q_OBJECT + +public: + /** Default Constructor */ + AppearancePage(QWidget *parent = 0); + /** Default Destructor */ + ~AppearancePage(); + /** Saves the changes on this page */ + bool save(QString &errmsg); + /** Loads the settings for this page */ + void load(); + /** Called when the user changes the UI translation. */ + virtual void retranslateUi(); + +private: + /** A VidaliaSettings object used for saving/loading settings */ + VidaliaSettings* _settings; + + /** Qt Designer generated object */ + Ui::AppearancePage ui; +}; + +#endif diff -Nru vidalia-0.1.13/src/vidalia/config/appearancepage.ui vidalia-0.2.8/src/vidalia/config/appearancepage.ui --- vidalia-0.1.13/src/vidalia/config/appearancepage.ui 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/appearancepage.ui 1970-01-01 01:00:00.000000000 +0100 @@ -1,162 +0,0 @@ - - - - - AppearancePage - - - - 0 - 0 - 494 - 395 - - - - Qt::NoContextMenu - - - - 9 - - - 6 - - - - - Qt::NoContextMenu - - - Language - - - - 9 - - - 6 - - - - - - 150 - 0 - - - - Qt::NoContextMenu - - - Choose the language used in Vidalia - - - false - - - - 24 - 16 - - - - - - - - Qt::Horizontal - - - - 300 - 16 - - - - - - - - Qt::NoContextMenu - - - Changes to language will only take effect after restarting Vidalia! - - - - - - - - - - Qt::NoContextMenu - - - - - - Style - - - - 9 - - - 6 - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 150 - 0 - - - - Qt::NoContextMenu - - - Choose Vidalia's interface style - - - false - - - - - - - - - - Qt::Vertical - - - - 476 - 161 - - - - - - - - - - diff -Nru vidalia-0.1.13/src/vidalia/config/AppearancePage.ui vidalia-0.2.8/src/vidalia/config/AppearancePage.ui --- vidalia-0.1.13/src/vidalia/config/AppearancePage.ui 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/AppearancePage.ui 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,130 @@ + + AppearancePage + + + + 0 + 0 + 500 + 395 + + + + Qt::NoContextMenu + + + + + + Qt::NoContextMenu + + + Language + + + + + + + 150 + 0 + + + + Qt::NoContextMenu + + + Choose the language used in Vidalia + + + false + + + + 24 + 16 + + + + + + + + Qt::Horizontal + + + + 300 + 16 + + + + + + + + + + + Qt::NoContextMenu + + + + + + Style + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 150 + 0 + + + + Qt::NoContextMenu + + + Choose Vidalia's interface style + + + false + + + + + + + + + + Qt::Vertical + + + + 476 + 161 + + + + + + + + + diff -Nru vidalia-0.1.13/src/vidalia/config/BridgeDownloader.cpp vidalia-0.2.8/src/vidalia/config/BridgeDownloader.cpp --- vidalia-0.1.13/src/vidalia/config/BridgeDownloader.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/BridgeDownloader.cpp 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,162 @@ +/* +** 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.vidalia-project.net/. 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 BridgeDownloader.cpp +** \version $Id: BridgeDownloader.cpp 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Downloads a list of new bridge addresses via HTTPS +*/ + +#include "BridgeDownloader.h" +#include "Vidalia.h" + +#include + +#define BRIDGEDB_HOST "bridges.torproject.org" +#define BRIDGEDB_PORT 443 + + +BridgeDownloader::BridgeDownloader(QObject *parent) + : QObject(parent), + _requestId(0) +{ + _https = new QHttp(BRIDGEDB_HOST, QHttp::ConnectionModeHttps, + BRIDGEDB_PORT, this); + + connect(_https, SIGNAL(stateChanged(int)), + this, SLOT(httpsStateChanged(int))); + connect(_https, SIGNAL(requestFinished(int, bool)), + this, SLOT(httpsRequestFinished(int, bool))); + connect(_https, SIGNAL(dataReadProgress(int, int)), + this, SIGNAL(downloadProgress(int, int))); + connect(_https, SIGNAL(sslErrors(QList)), + this, SLOT(sslErrors(QList))); +} + +void +BridgeDownloader::setProxy(const QString &host, int port, + const QString &username, const QString &password) +{ + _https->setProxy(host, port, username, password); +} + +bool +BridgeDownloader::downloadBridges(BridgeDownloadMethod method) +{ + if (! isMethodSupported(method)) + return false; + + switch (method) { + case DownloadMethodHttps: + startHttpsDownload(); + break; + + default: + break; + } + return true; +} + +bool +BridgeDownloader::isMethodSupported(BridgeDownloadMethod method) +{ + switch (method) { + case DownloadMethodHttps: + return QSslSocket::supportsSsl(); + + default: + break; + } + return false; +} + +void +BridgeDownloader::startHttpsDownload() +{ + emit statusChanged(tr("Starting HTTPS bridge request...")); + emit downloadProgress(0, 0); + + _requestId = _https->get("/?format=plain"); + vInfo("Sending an HTTPS bridge request to %1:%2 (id %3).").arg(BRIDGEDB_HOST) + .arg(BRIDGEDB_PORT) + .arg(_requestId); +} + +void +BridgeDownloader::cancelBridgeRequest() +{ + _https->abort(); +} + +void +BridgeDownloader::httpsStateChanged(int state) +{ + switch (state) { + case QHttp::Connecting: + emit statusChanged(tr("Connecting to %1:%2...").arg(BRIDGEDB_HOST) + .arg(BRIDGEDB_PORT)); + break; + + case QHttp::Sending: + emit statusChanged(tr("Sending an HTTPS request for bridges...")); + break; + + case QHttp::Reading: + emit statusChanged(tr("Downloading a list of bridges...")); + break; + + default: + break; + } +} + +void +BridgeDownloader::httpsRequestFinished(int id, bool error) +{ + if (id != _requestId) + return; + + if (error) { + QString errorString = _https->errorString(); + vWarn("Bridge request failed (id %1): %2").arg(id).arg(errorString); + + emit bridgeRequestFailed(errorString); + } else { + QByteArray response = _https->readAll(); + vInfo("Bridge request complete (id %1): received %2 bytes.").arg(id) + .arg(response.size()); + + QStringList bridges, lines = QString(response).split("\n"); + foreach (QString line, lines) { + line = line.trimmed(); + if (line.startsWith("bridge ", Qt::CaseInsensitive)) + bridges << line; + } + emit bridgeRequestFinished(bridges); + } + _https->close(); +} + +void +BridgeDownloader::sslErrors(const QList &sslErrors) +{ + QString errorString; + QStringList errorStrings; + + vWarn("%1 SSL error(s) when requesting bridge information (id %2):") + .arg(sslErrors.size()) + .arg(_requestId); + foreach (QSslError sslError, sslErrors) { + errorString = sslError.errorString(); + errorStrings << errorString; + vWarn(" SSL Error: %1").arg(errorString); + } +} + diff -Nru vidalia-0.1.13/src/vidalia/config/BridgeDownloader.h vidalia-0.2.8/src/vidalia/config/BridgeDownloader.h --- vidalia-0.1.13/src/vidalia/config/BridgeDownloader.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/BridgeDownloader.h 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,126 @@ +/* +** 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.vidalia-project.net/. 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 BridgeDownloader.h +** \version $Id: BridgeDownloader.h 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Downloads a list of new bridge addresses via HTTPS +*/ + +#ifndef _BRIDGEDOWNLOADER_H +#define _BRIDGEDOWNLOADER_H + +#include +#include +#include + + +class BridgeDownloader : public QObject +{ + Q_OBJECT + +public: + /** Available bridge download methods. */ + enum BridgeDownloadMethod { + DownloadMethodHttps, /** Download via an HTTPS connection. */ + }; + + /** Default constructor. + */ + BridgeDownloader(QObject *parent = 0); + + /** Initiates a request for a set of bridges using the specified + * download method. Returns true if the request was initiated + * successfully, or false on error. + */ + bool downloadBridges(BridgeDownloadMethod method); + + /** Enables HTTPS proxy support, using the proxy server host on + * port port. A username and password can also + * optionally be supplied, if required by the proxy. + */ + void setProxy(const QString &host, int port, + const QString &username = QString(), + const QString &password = QString()); + + /** Returns true if method is supported by the currently + * available Qt libraries. + */ + static bool isMethodSupported(BridgeDownloadMethod method); + +public slots: + /** Cancels any pending bridge download requests. + */ + void cancelBridgeRequest(); + +signals: + /** Emitted when the underlying QHttp object reads data from an HTTPS + * response. done indicates how many bytes out of total + * have been read so far. Note that total may be 0 if the expected + * total size of the response is not known. + */ + void downloadProgress(int done, int total); + + /** Emitted when the status of the bridge request changes. status + * describes the new current state of the request. + */ + void statusChanged(const QString &status); + + /** Emitted when the previous request for bridge addresses completes + * successfully. The QStringList bridges contains a (possibly empty) + * list of bridge addresses parsed from the received response. + */ + void bridgeRequestFinished(const QStringList &bridges); + + /** Emitted when the previous request for bridge addresses fails. The + * QString error is a human-readable string describing the error + * encountered. + */ + void bridgeRequestFailed(const QString &error); + +private slots: + /** Called when the state of the underlying QHttp object changes. A + * statusChanged() signal is emitted with the appropriate text + * describing the new state of the request. + */ + void httpsStateChanged(int state); + + /** Called when the underlying QHttp object used to make the bridge + * request completes. error is set to false if the request was + * successful, or true if the request failed. If id does not + * match the request ID previously returned by QHttp::get(), then the + * signal is ignored since it is the result of a close() or abort() + * request. + */ + void httpsRequestFinished(int id, bool error); + + /** Called when the HTTPS connection encounters one or more + * sslErrors. Currently the errors are just logged and + * bridgeRequestFailed() is not emitted, since QHttp will also + * emit + */ + void sslErrors(const QList &sslErrors); + +private: + /** Initiates an HTTPS connection to bridges.torproject.org to start + * downloading a set of bridges. + */ + void startHttpsDownload(); + + /** Used to connect to the bridge database, send an HTTPS request for + * new bridge addresses and then read the response. */ + QHttp* _https; + + /** Unique numeric identifier of the current bridge request. */ + int _requestId; +}; + +#endif + diff -Nru vidalia-0.1.13/src/vidalia/config/BridgeDownloaderProgressDialog.cpp vidalia-0.2.8/src/vidalia/config/BridgeDownloaderProgressDialog.cpp --- vidalia-0.1.13/src/vidalia/config/BridgeDownloaderProgressDialog.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/BridgeDownloaderProgressDialog.cpp 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,91 @@ +/* +** 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.vidalia-project.net/. 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 BridgeDownloaderProgressDialog.cpp +** \version $Id: BridgeDownloaderProgressDialog.cpp 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Displays the progress of a request for bridge addresses +*/ + +#include "BridgeDownloaderProgressDialog.h" + +#include + + +BridgeDownloaderProgressDialog::BridgeDownloaderProgressDialog(QWidget *parent) + : QDialog(parent) +{ + ui.setupUi(this); + + connect(ui.buttonBox, SIGNAL(clicked(QAbstractButton *)), + this, SLOT(buttonClicked(QAbstractButton *))); + + setModal(true); +} + +void +BridgeDownloaderProgressDialog::setVisible(bool visible) +{ + if (visible) { + ui.progressBar->setRange(0, 0); + ui.buttonBox->setStandardButtons(QDialogButtonBox::Cancel); + } + QDialog::setVisible(visible); +} + +void +BridgeDownloaderProgressDialog::setStatus(const QString &status) +{ + ui.lblStatus->setText(status); +} + +void +BridgeDownloaderProgressDialog::setDownloadProgress(int done, int total) +{ + ui.progressBar->setRange(0, total); + ui.progressBar->setValue(done); +} + +void +BridgeDownloaderProgressDialog::bridgeRequestFinished(const QStringList &bridges) +{ + Q_UNUSED(bridges); + + accept(); +} + +void +BridgeDownloaderProgressDialog::bridgeRequestFailed(const QString &error) +{ + ui.lblStatus->setText(tr("Unable to download bridges: %1").arg(error)); + + ui.progressBar->setRange(0, 1); + ui.progressBar->setValue(1); + + ui.buttonBox->setStandardButtons(QDialogButtonBox::Cancel + | QDialogButtonBox::Retry + | QDialogButtonBox::Help); +} + +void +BridgeDownloaderProgressDialog::buttonClicked(QAbstractButton *button) +{ + int standardButton = ui.buttonBox->standardButton(button); + if (standardButton == QDialogButtonBox::Retry) { + setStatus(tr("Retrying bridge request...")); + setDownloadProgress(0, 0); + ui.buttonBox->setStandardButtons(QDialogButtonBox::Cancel); + + QTimer::singleShot(1000, this, SIGNAL(retry())); + } else { + done(standardButton); + } +} + diff -Nru vidalia-0.1.13/src/vidalia/config/BridgeDownloaderProgressDialog.h vidalia-0.2.8/src/vidalia/config/BridgeDownloaderProgressDialog.h --- vidalia-0.1.13/src/vidalia/config/BridgeDownloaderProgressDialog.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/BridgeDownloaderProgressDialog.h 2009-06-23 23:53:29.000000000 +0100 @@ -0,0 +1,84 @@ +/* +** 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.vidalia-project.net/. 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 BridgeDownloaderProgressDialog.h +** \version $Id: BridgeDownloaderProgressDialog.h 3879 2009-06-23 22:53:29Z edmanm $ +** \brief Displays the progress of a request for bridge addresses +*/ + +#ifndef _BRIDGEDOWNLOADERPROGRESSDIALOG_H +#define _BRIDGEDOWNLOADERPROGRESSDIALOG_H + +#include "ui_BridgeDownloaderProgressDialog.h" + +#include + + +class BridgeDownloaderProgressDialog : public QDialog +{ + Q_OBJECT + +public: + /** Default constructor. + */ + BridgeDownloaderProgressDialog(QWidget *parent = 0); + +public slots: + /** Sets the status message text in the dialog to status. + */ + void setStatus(const QString &status); + + /** Updates the bridge download progress bar to value out of + * maximum steps. If value and maximum are both 0, + * then a "busy" progress bar is displayed. + */ + void setDownloadProgress(int value, int maximum); + + /** Called when the bridge download completes successfully and discards + * the progress dialog with an Accept result code. bridges + * contains the list of bridges downloaded, but is currently ignored. + */ + void bridgeRequestFinished(const QStringList &bridges); + + /** Called when the bridge download fails. The string error + * provides a human-readable description of the reason the download + * failed, which is displayed for the user. + */ + void bridgeRequestFailed(const QString &error); + +signals: + /** Emitted when the user clicks the "Retry" button after a previous + * bridge request has failed. + */ + void retry(); + +protected: + /** Overloaded method called when the progress dialog is first shown in + * order to initialize the progress bar, status text and dialog button + * box. + */ + virtual void setVisible(bool visible); + +private slots: + /** Called when button is clicked in the progress dialog's + * QDialogButtonBox. Dismisses the dialog and sets the result code to + * the QDialogButtonBox::StandardButton enum value indicated by + * button. + */ + void buttonClicked(QAbstractButton *button); + +private: + /**< Qt Designer generated object. */ + Ui::BridgeDownloaderProgressDialog ui; +}; + +#endif + diff -Nru vidalia-0.1.13/src/vidalia/config/BridgeDownloaderProgressDialog.ui vidalia-0.2.8/src/vidalia/config/BridgeDownloaderProgressDialog.ui --- vidalia-0.1.13/src/vidalia/config/BridgeDownloaderProgressDialog.ui 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/BridgeDownloaderProgressDialog.ui 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,73 @@ + + + BridgeDownloaderProgressDialog + + + + 0 + 0 + 366 + 105 + + + + Downloading Bridges + + + + :/images/32x32/network-workgroup.png:/images/32x32/network-workgroup.png + + + true + + + + + + + + + :/images/48x48/network-workgroup.png + + + + + + + + + + true + + + + + + + 0 + + + false + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel + + + + + + + + + + diff -Nru vidalia-0.1.13/src/vidalia/config/BridgeUsageDialog.cpp vidalia-0.2.8/src/vidalia/config/BridgeUsageDialog.cpp --- vidalia-0.1.13/src/vidalia/config/BridgeUsageDialog.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/BridgeUsageDialog.cpp 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,81 @@ +/* +** 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.vidalia-project.net/. 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 BridgeUsageDialog.cpp +** \version $Id: BridgeUsageDialog.cpp 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Displays a summary of bridge usage information, including client +** geographic location history. +*/ + +#include "BridgeUsageDialog.h" +#include "CountryInfo.h" + +#include +#include +#include + + +BridgeUsageDialog::BridgeUsageDialog(QWidget *parent) + : QDialog(parent) +{ + ui.setupUi(this); + ui.treeClientSummary->setHeaderLabels(QStringList() << QString("") + << tr("Country") + << tr("# Clients")); +} + +void +BridgeUsageDialog::showEvent(QShowEvent *e) +{ + QHeaderView *header = ui.treeClientSummary->header(); + header->setResizeMode(0, QHeaderView::ResizeToContents); + header->resizeSection(1, 220); + header->setResizeMode(2, QHeaderView::ResizeToContents); + + QDialog::showEvent(e); +} + +void +BridgeUsageDialog::update(const QDateTime &timeStarted, + const QHash &countrySummary) +{ + QTreeWidgetItem *item; + int minClients, maxClients; + QString countryName; + QPixmap flag; + + /* Set the header with the TimeStarted value converted to local time */ + ui.lblClientSummary->setText(tr("Clients from the following countries have " + "used your relay since %1") + .arg(timeStarted.toLocalTime().toString())); + + /* Populate the table of client country statistics */ + foreach (QString countryCode, countrySummary.keys()) { + maxClients = countrySummary.value(countryCode); + minClients = maxClients-7; + + flag = QPixmap(":/images/flags/" + countryCode.toLower() + ".png"); + if (flag.isNull()) + flag = QPixmap(":/images/flags/unknown.png"); + + countryName = CountryInfo::countryName(countryCode); + if (countryName.isEmpty()) + countryName = countryCode; + + item = new QTreeWidgetItem(); + item->setIcon(0, QIcon(flag)); + item->setText(1, countryName); + item->setText(2, QString("%1-%2").arg(minClients).arg(maxClients)); + ui.treeClientSummary->addTopLevelItem(item); + } + ui.treeClientSummary->sortItems(2, Qt::DescendingOrder); +} + diff -Nru vidalia-0.1.13/src/vidalia/config/BridgeUsageDialog.h vidalia-0.2.8/src/vidalia/config/BridgeUsageDialog.h --- vidalia-0.1.13/src/vidalia/config/BridgeUsageDialog.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/BridgeUsageDialog.h 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,53 @@ +/* +** 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.vidalia-project.net/. 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 BridgeUsageDialog.h +** \version $Id: BridgeUsageDialog.h 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Displays a summary of bridge usage information, including client +** geographic location history. +*/ + +#ifndef _BRIDGEUSAGEDIALOG_H +#define _BRIDGEUSAGEDIALOG_H + +#include "ui_BridgeUsageDialog.h" + +#include +#include +#include + + +class BridgeUsageDialog : public QDialog +{ + Q_OBJECT + +public: + /** Default constructor. + */ + BridgeUsageDialog(QWidget *parent = 0); + + /** Updates the dialog with current bridge usage information. + */ + void update(const QDateTime &timeStarted, + const QHash &countrySummary); + +protected: + /** Called when the dialog is displayed. Adjusts the size of the column + * headers. + */ + void showEvent(QShowEvent *e); + +private: + Ui::BridgeUsageDialog ui; +}; + +#endif + diff -Nru vidalia-0.1.13/src/vidalia/config/BridgeUsageDialog.ui vidalia-0.2.8/src/vidalia/config/BridgeUsageDialog.ui --- vidalia-0.1.13/src/vidalia/config/BridgeUsageDialog.ui 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/BridgeUsageDialog.ui 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,110 @@ + + BridgeUsageDialog + + + + 0 + 0 + 444 + 408 + + + + Bridge Usage Summary + + + + + + Client Summary + + + + + + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + + + + + false + + + true + + + + + + + + + Country + + + + + # Clients + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Close + + + + + + + + + buttonBox + accepted() + BridgeUsageDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + BridgeUsageDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff -Nru vidalia-0.1.13/src/vidalia/config/configdialog.cpp vidalia-0.2.8/src/vidalia/config/configdialog.cpp --- vidalia-0.1.13/src/vidalia/config/configdialog.cpp 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/configdialog.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,274 +0,0 @@ -/**************************************************************** - * Vidalia is distributed under the following license: - * - * Copyright (C) 2006, Matt Edman, Justin Hipple - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - ****************************************************************/ - -/** - * \file configdialog.cpp - * \version $Id: configdialog.cpp 3005 2008-08-20 23:51:02Z edmanm $ - * \brief Contains a series of Vidalia and Tor configuration pages - */ - -#include -#include -#include -#include -#include - -#include "configdialog.h" - -/* Images for toolbar icons */ -#define IMAGE_GENERAL ":/images/32x32/preferences-system.png" -#define IMAGE_NETWORK ":/images/32x32/preferences-system-network.png" -#define IMAGE_SERVER ":/images/32x32/preferences-system-network-sharing.png" -#define IMAGE_APPEARANCE ":/images/32x32/preferences-desktop-locale.png" -#define IMAGE_ADVANCED ":/images/32x32/applications-system.png" -#define IMAGE_HELP ":/images/32x32/system-help.png" -#define IMAGE_SERVICE ":/images/32x32/services.png" - -/** Constructor */ -ConfigDialog::ConfigDialog(QWidget* parent) -: VidaliaWindow("ConfigDialog", parent) -{ - /* Invoke the Qt Designer generated QObject setup routine */ - ui.setupUi(this); - - /* Override the QDialogButtonBox button text so we can use our own - * translations. */ - QPushButton *button = ui.buttonBox->button(QDialogButtonBox::Ok); - if (button) { - Vidalia::createShortcut(QKeySequence(Qt::Key_Return), - this, button, SLOT(click())); - } - button = ui.buttonBox->button(QDialogButtonBox::Cancel); - if (button) { - Vidalia::createShortcut("Esc", this, button, SLOT(click())); - Vidalia::createShortcut("Ctrl+W", this, button, SLOT(click())); - } - - /* Connect the button box signals to the appropriate slots */ - connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(saveChanges())); - connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(close())); - connect(ui.buttonBox, SIGNAL(helpRequested()), this, SLOT(help())); - connect(Vidalia::torControl(), SIGNAL(authenticated()), - this, SLOT(applyChanges())); - - /* Create the config pages and actions */ - QActionGroup *grp = new QActionGroup(this); - ui.stackPages->add(new GeneralPage(ui.stackPages), - createPageAction(QIcon(IMAGE_GENERAL), - tr("General"), grp)); - - ui.stackPages->add(new NetworkPage(ui.stackPages), - createPageAction(QIcon(IMAGE_NETWORK), - tr("Network"), grp)); - - ui.stackPages->add(new ServerPage(ui.stackPages), - createPageAction(QIcon(IMAGE_SERVER), - tr("Sharing"), grp)); - - ui.stackPages->add(new ServicePage(ui.stackPages), - createPageAction(QIcon(IMAGE_SERVICE), - tr("Services"), grp)); - - ui.stackPages->add(new AppearancePage(ui.stackPages), - createPageAction(QIcon(IMAGE_APPEARANCE), - tr("Appearance"), grp)); - - ui.stackPages->add(new AdvancedPage(ui.stackPages), - createPageAction(QIcon(IMAGE_ADVANCED), - tr("Advanced"), grp)); - - foreach (ConfigPage *page, ui.stackPages->pages()) { - connect(page, SIGNAL(helpRequested(QString)), - this, SLOT(help(QString))); - } - - /* Create the toolbar */ - ui.toolBar->addActions(grp->actions()); - ui.toolBar->addSeparator(); - connect(grp, SIGNAL(triggered(QAction *)), - ui.stackPages, SLOT(showPage(QAction *))); - - /* Create and bind the Help button */ - QAction *helpAct = new QAction(QIcon(IMAGE_HELP), tr("Help"), ui.toolBar); - addAction(helpAct, SLOT(help())); - - /* Select the first action */ - grp->actions()[0]->setChecked(true); - -#if defined(Q_WS_WIN) - helpAct->setShortcut(QString("F1")); -#else - helpAct->setShortcut(QString("Ctrl+?")); -#endif -} - -/** Creates a new action associated with a config page. */ -QAction* -ConfigDialog::createPageAction(QIcon img, QString text, QActionGroup *group) -{ - QAction *action = new QAction(img, text, group); - action->setCheckable(true); - return action; -} - -/** Adds the given action to the toolbar and hooks its triggered() signal to - * the specified slot (if given). */ -void -ConfigDialog::addAction(QAction *action, const char *slot) -{ - ui.toolBar->addAction(action); - connect(action, SIGNAL(triggered()), this, slot); -} - -/** Shows the config dialog with focus set to the given page. */ -void -ConfigDialog::showWindow(Page page) -{ - /* Load saved settings */ - loadSettings(); - /* Show the dialog. */ - VidaliaWindow::showWindow(); - /* Set the focus to the specified page. */ - ui.stackPages->setCurrentIndex((int)page); -} - -/** Loads the saved ConfigDialog settings. */ -void -ConfigDialog::loadSettings() -{ - /* Call each config page's load() method to load its data */ - foreach (ConfigPage *page, ui.stackPages->pages()) { - page->load(); - } -} - -/** Saves changes made to settings. If Tor is running and Vidalia is - * connected, we will also attempt to apply the changes to Tor. */ -void -ConfigDialog::saveChanges() -{ - QString errmsg; - - /* Call each config page's save() method to save its data */ - foreach (ConfigPage *page, ui.stackPages->pages()) { - if (!page->save(errmsg)) { - /* Display the offending page */ - ui.stackPages->setCurrentPage(page); - - /* Show the user what went wrong */ - VMessageBox::warning(this, - tr("Error Saving Settings"), - p(tr("Vidalia was unable to save your %1 settings.") - .arg(page->title())) + p(errmsg), - VMessageBox::Ok); - - /* Don't process the rest of the pages */ - return; - } - } - if (Vidalia::torControl()->isConnected()) - applyChanges(); - else - close(); -} - -/** Called after Vidalia has authenticated to Tor and applies any changes - * made since the last time they were applied. */ -void -ConfigDialog::applyChanges() -{ - QString errmsg; - bool appliedChanges = false; - - foreach (ConfigPage *page, ui.stackPages->pages()) { - if (!page->changedSinceLastApply()) - continue; - if (!page->apply(errmsg)) { - /* Failed to apply the changes to Tor */ - int ret = VMessageBox::warning(this, - tr("Error Applying Settings"), - p(tr("Vidalia was unable to apply your %1 settings " - "to Tor.").arg(page->title())) - + p(errmsg), - VMessageBox::ShowSettings|VMessageBox::Default, - VMessageBox::Cancel|VMessageBox::Escape); - if (ret == VMessageBox::ShowSettings) { - /* Show the user the page with the bad settings */ - showWindow(); - ui.stackPages->setCurrentPage(page); - } else { - /* The user clicked 'Cancel', so revert the failed settings */ - page->revert(); - close(); - } - return; - } - appliedChanges = true; - } - if (appliedChanges) - saveConf(); - close(); -} - -/** Sends Tor a SAVECONF to write its configuration to disk. If the SAVECONF - * is successful, then all settings are considered to be applied. */ -void -ConfigDialog::saveConf() -{ - TorControl *tc = Vidalia::torControl(); - if (tc->saveConf()) { - ServerSettings(tc).setChanged(false); - NetworkSettings(tc).setChanged(false); - TorSettings(tc).setChanged(false); - } -} - -/** Shows help information for whichever settings page the user is currently - * viewing. */ -void -ConfigDialog::help() -{ - Page currentPage = static_cast(ui.stackPages->currentIndex()); - - switch (currentPage) { - case Network: - help("config.network"); break; - case Server: - help("server"); break; - case Appearance: - help("config.appearance"); break; - case Advanced: - help("config.advanced"); break; - case Service: - help("config.services"); break; - default: - help("config.general"); break; - } -} - -/** Called when a ConfigPage in the dialog requests help on a specific - * topic. */ -void -ConfigDialog::help(const QString &topic) -{ - emit helpRequested(topic); -} - diff -Nru vidalia-0.1.13/src/vidalia/config/ConfigDialog.cpp vidalia-0.2.8/src/vidalia/config/ConfigDialog.cpp --- vidalia-0.1.13/src/vidalia/config/ConfigDialog.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/ConfigDialog.cpp 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,300 @@ +/* +** 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.vidalia-project.net/. 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 ConfigDialog.cpp +** \version $Id: ConfigDialog.cpp 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Contains a series of Vidalia and Tor configuration pages +*/ + +#include "ConfigDialog.h" +#include "GeneralPage.h" +#include "NetworkPage.h" +#include "ServerPage.h" +#include "AdvancedPage.h" +#include "AppearancePage.h" +#include "ServicePage.h" +#include "VMessageBox.h" +#include "ServerSettings.h" +#include "NetworkSettings.h" +#include "Vidalia.h" + +#include "html.h" + + +/* Images for toolbar icons */ +#define IMAGE_GENERAL ":/images/32x32/preferences-system.png" +#define IMAGE_NETWORK ":/images/32x32/preferences-system-network.png" +#define IMAGE_SERVER ":/images/32x32/preferences-system-network-sharing.png" +#define IMAGE_APPEARANCE ":/images/32x32/preferences-desktop-locale.png" +#define IMAGE_ADVANCED ":/images/32x32/applications-system.png" +#define IMAGE_HELP ":/images/32x32/system-help.png" +#define IMAGE_SERVICE ":/images/32x32/services.png" + + +/** Constructor */ +ConfigDialog::ConfigDialog(QWidget* parent) +: VidaliaWindow("ConfigDialog", parent) +{ + /* Invoke the Qt Designer generated QObject setup routine */ + ui.setupUi(this); + + /* Override the QDialogButtonBox button text so we can use our own + * translations. */ + QPushButton *button = ui.buttonBox->button(QDialogButtonBox::Ok); + if (button) { + Vidalia::createShortcut(QKeySequence(Qt::Key_Return), + this, button, SLOT(click())); + } + button = ui.buttonBox->button(QDialogButtonBox::Cancel); + if (button) { + Vidalia::createShortcut("Esc", this, button, SLOT(click())); + Vidalia::createShortcut("Ctrl+W", this, button, SLOT(click())); + } + + /* Connect the button box signals to the appropriate slots */ + connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(saveChanges())); + connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(close())); + connect(ui.buttonBox, SIGNAL(helpRequested()), this, SLOT(help())); + connect(Vidalia::torControl(), SIGNAL(authenticated()), + this, SLOT(applyChanges())); + + /* Create the config pages and actions */ + QActionGroup *grp = new QActionGroup(this); + GeneralPage *generalPage = new GeneralPage(ui.stackPages); + ui.stackPages->add(generalPage, + createPageAction(QIcon(IMAGE_GENERAL), + tr("General"), "General", grp)); + connect(generalPage, SIGNAL(checkForUpdates()), + this, SLOT(onCheckForUpdates())); + + ui.stackPages->add(new NetworkPage(ui.stackPages), + createPageAction(QIcon(IMAGE_NETWORK), + tr("Network"), "Network", grp)); + + ui.stackPages->add(new ServerPage(ui.stackPages), + createPageAction(QIcon(IMAGE_SERVER), + tr("Sharing"), "Sharing", grp)); + + ui.stackPages->add(new ServicePage(ui.stackPages), + createPageAction(QIcon(IMAGE_SERVICE), + tr("Services"), "Services", grp)); + + ui.stackPages->add(new AppearancePage(ui.stackPages), + createPageAction(QIcon(IMAGE_APPEARANCE), + tr("Appearance"), "Appearance", grp)); + + ui.stackPages->add(new AdvancedPage(ui.stackPages), + createPageAction(QIcon(IMAGE_ADVANCED), + tr("Advanced"), "Advanced", grp)); + + foreach (ConfigPage *page, ui.stackPages->pages()) { + connect(page, SIGNAL(helpRequested(QString)), + this, SLOT(help(QString))); + } + + /* Create the toolbar */ + ui.toolBar->addActions(grp->actions()); + ui.toolBar->addSeparator(); + connect(grp, SIGNAL(triggered(QAction *)), + ui.stackPages, SLOT(showPage(QAction *))); + + /* Create and bind the Help button */ + QAction *helpAct = new QAction(QIcon(IMAGE_HELP), tr("Help"), ui.toolBar); + helpAct->setData("Help"); + addAction(helpAct, SLOT(help())); + + /* Select the first action */ + grp->actions()[0]->setChecked(true); + +#if defined(Q_WS_WIN) + helpAct->setShortcut(QString("F1")); +#else + helpAct->setShortcut(QString("Ctrl+?")); +#endif +} + +/** Creates a new action associated with a config page. */ +QAction* +ConfigDialog::createPageAction(const QIcon &img, const QString &text, + const QString &data, QActionGroup *group) +{ + QAction *action = new QAction(img, text, group); + action->setData(data); + action->setCheckable(true); + return action; +} + +/** Adds the given action to the toolbar and hooks its triggered() signal to + * the specified slot (if given). */ +void +ConfigDialog::addAction(QAction *action, const char *slot) +{ + ui.toolBar->addAction(action); + connect(action, SIGNAL(triggered()), this, slot); +} + +/** Shows the config dialog with focus set to the given page. */ +void +ConfigDialog::showWindow(Page page) +{ + /* Load saved settings */ + loadSettings(); + /* Show the dialog. */ + VidaliaWindow::showWindow(); + /* Set the focus to the specified page. */ + ui.stackPages->setCurrentIndex((int)page); +} + +/** Called when the user changes the UI translation. */ +void +ConfigDialog::retranslateUi() +{ + ui.retranslateUi(this); + foreach (ConfigPage *page, ui.stackPages->pages()) { + page->retranslateUi(); + } + foreach (QAction *action, ui.toolBar->actions()) { + action->setText(tr(qPrintable(action->data().toString()), "ConfigDialog")); + } + ui.buttonBox->setStandardButtons(ui.buttonBox->standardButtons()); +} + +/** Loads the saved ConfigDialog settings. */ +void +ConfigDialog::loadSettings() +{ + /* Call each config page's load() method to load its data */ + foreach (ConfigPage *page, ui.stackPages->pages()) { + page->load(); + } +} + +/** Saves changes made to settings. If Tor is running and Vidalia is + * connected, we will also attempt to apply the changes to Tor. */ +void +ConfigDialog::saveChanges() +{ + QString errmsg; + + /* Call each config page's save() method to save its data */ + foreach (ConfigPage *page, ui.stackPages->pages()) { + if (!page->save(errmsg)) { + /* Display the offending page */ + ui.stackPages->setCurrentPage(page); + + /* Show the user what went wrong */ + VMessageBox::warning(this, + tr("Error Saving Settings"), + p(tr("Vidalia was unable to save your %1 settings.") + .arg(tr(qPrintable(page->title()), "ConfigDialog"))) + p(errmsg), + VMessageBox::Ok); + + /* Don't process the rest of the pages */ + return; + } + } + if (Vidalia::torControl()->isConnected()) + applyChanges(); + else + close(); +} + +/** Called after Vidalia has authenticated to Tor and applies any changes + * made since the last time they were applied. */ +void +ConfigDialog::applyChanges() +{ + QString errmsg; + bool appliedChanges = false; + + foreach (ConfigPage *page, ui.stackPages->pages()) { + if (!page->changedSinceLastApply()) + continue; + if (!page->apply(errmsg)) { + /* Failed to apply the changes to Tor */ + int ret = VMessageBox::warning(this, + tr("Error Applying Settings"), + p(tr("Vidalia was unable to apply your %1 settings " + "to Tor.").arg(page->title())) + + p(errmsg), + VMessageBox::ShowSettings|VMessageBox::Default, + VMessageBox::Cancel|VMessageBox::Escape); + if (ret == VMessageBox::ShowSettings) { + /* Show the user the page with the bad settings */ + showWindow(); + ui.stackPages->setCurrentPage(page); + } else { + /* The user clicked 'Cancel', so revert the failed settings */ + page->revert(); + close(); + } + return; + } + appliedChanges = true; + } + if (appliedChanges) + saveConf(); + close(); +} + +/** Sends Tor a SAVECONF to write its configuration to disk. If the SAVECONF + * is successful, then all settings are considered to be applied. */ +void +ConfigDialog::saveConf() +{ + TorControl *tc = Vidalia::torControl(); + if (tc->saveConf()) { + ServerSettings(tc).setChanged(false); + NetworkSettings(tc).setChanged(false); + TorSettings(tc).setChanged(false); + } +} + +/** Shows help information for whichever settings page the user is currently + * viewing. */ +void +ConfigDialog::help() +{ + Page currentPage = static_cast(ui.stackPages->currentIndex()); + + switch (currentPage) { + case Network: + help("config.network"); break; + case Server: + help("server"); break; + case Appearance: + help("config.appearance"); break; + case Advanced: + help("config.advanced"); break; + case Service: + help("config.services"); break; + default: + help("config.general"); break; + } +} + +/** Stub method that relays the checkForUpdates() signal from the General + * settings page to the owner of the config dialog (MainWindow). */ +void +ConfigDialog::onCheckForUpdates() +{ + emit checkForUpdates(); +} + + +/** Called when a ConfigPage in the dialog requests help on a specific + * topic. */ +void +ConfigDialog::help(const QString &topic) +{ + emit helpRequested(topic); +} + diff -Nru vidalia-0.1.13/src/vidalia/config/configdialog.h vidalia-0.2.8/src/vidalia/config/configdialog.h --- vidalia-0.1.13/src/vidalia/config/configdialog.h 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/configdialog.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,87 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 configdialog.h -** \version $Id: configdialog.h 2504 2008-04-12 18:23:28Z edmanm $ -** \brief Contains a series of Vidalia and Tor configuration pages -*/ - -#ifndef _CONFIGDIALOG_H -#define _CONFIGDIALOG_H - -#include -#include -#include - -#include "generalpage.h" -#include "networkpage.h" -#include "serverpage.h" -#include "advancedpage.h" -#include "appearancepage.h" -#include "servicepage.h" - -#include "ui_configdialog.h" - - -class ConfigDialog : public VidaliaWindow -{ - Q_OBJECT - -public: - /** Config dialog pages. */ - enum Page { - General = 0, /** General configuration page. */ - Network, /** Network configuration page. */ - Server, /** Server configuration page. */ - Appearance, /** Appearance configuration page. */ - Advanced, /** Advanced configuration page. */ - Service /** Service Configuration page */ - }; - - /** Default Constructor */ - ConfigDialog(QWidget *parent = 0); - -public slots: - /** Shows the config dialog with focus set to the given page. */ - void showWindow(Page page = General); - -private slots: - /** Called when user clicks "Save Settings". Saves their settings to - * Vidalia's configuration file. */ - void saveChanges(); - /** Called after Vidalia has authenticated to Tor and applies any changes - * made since the last time they were applied. */ - void applyChanges(); - /** Sends Tor a SAVECONF to write its configuration to disk. If the - * SAVECONF is successful, then all settings are considered to be - * applied. */ - void saveConf(); - /** Called when a ConfigPage in the dialog requests help on a specific - * topic. */ - void help(const QString &topic); - /** Shows general help information for whichever settings page the user is - * currently viewing. */ - void help(); - -private: - /** Loads the current configuration settings */ - void loadSettings(); - /** Creates a new action for a config page. */ - QAction* createPageAction(QIcon img, QString text, QActionGroup *group); - /** Adds a new action to the toolbar. */ - void addAction(QAction *action, const char *slot = 0); - - /** Qt Designer generated object */ - Ui::ConfigDialog ui; -}; - -#endif - diff -Nru vidalia-0.1.13/src/vidalia/config/ConfigDialog.h vidalia-0.2.8/src/vidalia/config/ConfigDialog.h --- vidalia-0.1.13/src/vidalia/config/ConfigDialog.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/ConfigDialog.h 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,93 @@ +/* +** 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.vidalia-project.net/. 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 ConfigDialog.h +** \version $Id: ConfigDialog.h 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Contains a series of Vidalia and Tor configuration pages +*/ + +#ifndef _CONFIGDIALOG_H +#define _CONFIGDIALOG_H + +#include "ui_ConfigDialog.h" +#include "VidaliaWindow.h" + +#include +#include + + +class ConfigDialog : public VidaliaWindow +{ + Q_OBJECT + +public: + /** Config dialog pages. */ + enum Page { + General = 0, /** General configuration page. */ + Network, /** Network configuration page. */ + Server, /** Server configuration page. */ + Appearance, /** Appearance configuration page. */ + Advanced, /** Advanced configuration page. */ + Service /** Service Configuration page */ + }; + + /** Default Constructor */ + ConfigDialog(QWidget *parent = 0); + +public slots: + /** Shows the config dialog with focus set to the given page. */ + void showWindow(Page page = General); + +signals: + /** Emitted when the user clicks "Check Now" to initiate a check + * for software updates. */ + void checkForUpdates(); + +protected: + /** Called when the user changes the UI translation. */ + virtual void retranslateUi(); + +private slots: + /** Called when user clicks "Save Settings". Saves their settings to + * Vidalia's configuration file. */ + void saveChanges(); + /** Called after Vidalia has authenticated to Tor and applies any changes + * made since the last time they were applied. */ + void applyChanges(); + /** Sends Tor a SAVECONF to write its configuration to disk. If the + * SAVECONF is successful, then all settings are considered to be + * applied. */ + void saveConf(); + /** Called when a ConfigPage in the dialog requests help on a specific + * topic. */ + void help(const QString &topic); + /** Shows general help information for whichever settings page the user is + * currently viewing. */ + void help(); + /** Stub method that relays the checkForUpdates() signal from the General + * settings page to the owner of the config dialog (MainWindow). */ + void onCheckForUpdates(); + +private: + /** Loads the current configuration settings */ + void loadSettings(); + /** Creates a new action for a config page. */ + QAction* createPageAction(const QIcon &img, const QString &text, + const QString &data, QActionGroup *group); + /** Adds a new action to the toolbar. */ + void addAction(QAction *action, const char *slot = 0); + + /** Qt Designer generated object */ + Ui::ConfigDialog ui; +}; + +#endif + diff -Nru vidalia-0.1.13/src/vidalia/config/configdialog.ui vidalia-0.2.8/src/vidalia/config/configdialog.ui --- vidalia-0.1.13/src/vidalia/config/configdialog.ui 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/configdialog.ui 1970-01-01 01:00:00.000000000 +0100 @@ -1,563 +0,0 @@ - - ConfigDialog - - - - 0 - 0 - 600 - 400 - - - - Qt::NoContextMenu - - - Settings - - - :/images/32x32/preferences-system.png - - - - 48 - 48 - - - - Qt::ToolButtonTextUnderIcon - - - - - 9 - - - 6 - - - - - - - - - - 0 - 0 - 0 - - - - - - - 208 - 208 - 208 - - - - - - - 255 - 255 - 255 - - - - - - - 247 - 247 - 247 - - - - - - - 120 - 120 - 120 - - - - - - - 160 - 160 - 160 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 240 - 240 - 240 - - - - - - - 0 - 0 - 0 - - - - - - - 10 - 36 - 106 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 255 - - - - - - - 255 - 0 - 255 - - - - - - - 247 - 247 - 247 - - - - - - - - - 0 - 0 - 0 - - - - - - - 208 - 208 - 208 - - - - - - - 255 - 255 - 255 - - - - - - - 247 - 247 - 247 - - - - - - - 120 - 120 - 120 - - - - - - - 160 - 160 - 160 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 240 - 240 - 240 - - - - - - - 0 - 0 - 0 - - - - - - - 212 - 208 - 200 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 255 - - - - - - - 255 - 0 - 255 - - - - - - - 247 - 247 - 247 - - - - - - - - - 120 - 120 - 120 - - - - - - - 208 - 208 - 208 - - - - - - - 255 - 255 - 255 - - - - - - - 247 - 247 - 247 - - - - - - - 120 - 120 - 120 - - - - - - - 160 - 160 - 160 - - - - - - - 120 - 120 - 120 - - - - - - - 255 - 255 - 255 - - - - - - - 120 - 120 - 120 - - - - - - - 240 - 240 - 240 - - - - - - - 240 - 240 - 240 - - - - - - - 0 - 0 - 0 - - - - - - - 10 - 36 - 106 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 255 - - - - - - - 255 - 0 - 255 - - - - - - - 247 - 247 - 247 - - - - - - - - Qt::NoContextMenu - - - - - 0 - 0 - 100 - 30 - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok - - - - - - - - - Qt::NoContextMenu - - - false - - - Qt::Horizontal - - - 4 - - - - - - ConfigPageStack - QStackedPageWidget -
config/configpagestack.h
-
-
- - - - -
diff -Nru vidalia-0.1.13/src/vidalia/config/ConfigDialog.ui vidalia-0.2.8/src/vidalia/config/ConfigDialog.ui --- vidalia-0.1.13/src/vidalia/config/ConfigDialog.ui 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/ConfigDialog.ui 2009-12-12 05:36:59.000000000 +0000 @@ -0,0 +1,94 @@ + + ConfigDialog + + + + 0 + 0 + 600 + 400 + + + + Qt::NoContextMenu + + + Settings + + + :/images/32x32/preferences-system.png + + + + 48 + 48 + + + + Qt::ToolButtonTextUnderIcon + + + + + 9 + + + 6 + + + + + Qt::NoContextMenu + + + + + 0 + 0 + 100 + 30 + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok + + + + + + + + + Qt::NoContextMenu + + + false + + + Qt::Horizontal + + + 4 + + + + + + ConfigPageStack + QStackedPageWidget +
config/ConfigPageStack.h
+
+
+ + + + +
diff -Nru vidalia-0.1.13/src/vidalia/config/configpage.h vidalia-0.2.8/src/vidalia/config/configpage.h --- vidalia-0.1.13/src/vidalia/config/configpage.h 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/configpage.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,69 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 configpage.h -** \version $Id: configpage.h 2362 2008-02-29 04:30:11Z edmanm $ -** \brief Pure-virtual class for a configuration page -*/ - -#ifndef _CONFIGPAGE_H -#define _CONFIGPAGE_H - -#include - - -class ConfigPage : public QWidget -{ - Q_OBJECT - -public: - /** Default Constructor */ - ConfigPage(QWidget *parent = 0, const QString title = QString()) - : QWidget(parent), _title(title) {} - - /** Returns the title of this configuration page. */ - QString title() const { return _title; } - - /** Pure virtual method. Subclassed pages load their config settings here. */ - virtual void load() = 0; - /** Pure virtual method. Subclassed pages save their config settings here - * and return true if everything was saved successfully. */ - virtual bool save(QString &errmsg) = 0; - - /** Subclassed pages can overload this method to return true if they - * contain settings that have been modified since they were last applied to - * Tor. The default implementation always returns false. */ - virtual bool changedSinceLastApply() { - return false; - } - /** Subclassed pages can overload this method to apply any settings to - * Tor that have been modified since they were last applied (e.g., the - * changes were made while Tor was not running). Returns true if the changes - * were applied successfully. */ - virtual bool apply(QString &errmsg) { - Q_UNUSED(errmsg); - return true; - } - /** Subclassed pages can overload this method to revert any cancelled - * settings. */ - virtual void revert() {} - -signals: - /** Signal emitted when a ConfigPage requests help information on a given - * topic. */ - void helpRequested(const QString &topic); - -private: - QString _title; /**< Title of this configuration page. */ -}; - -#endif - diff -Nru vidalia-0.1.13/src/vidalia/config/ConfigPage.h vidalia-0.2.8/src/vidalia/config/ConfigPage.h --- vidalia-0.1.13/src/vidalia/config/ConfigPage.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/ConfigPage.h 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,71 @@ +/* +** 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.vidalia-project.net/. 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 ConfigPage.h +** \version $Id: ConfigPage.h 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Pure-virtual class for a configuration page +*/ + +#ifndef _CONFIGPAGE_H +#define _CONFIGPAGE_H + +#include + + +class ConfigPage : public QWidget +{ + Q_OBJECT + +public: + /** Default Constructor */ + ConfigPage(QWidget *parent = 0, const QString title = QString()) + : QWidget(parent), _title(title) {} + + /** Returns the title of this configuration page. */ + QString title() const { return _title; } + + /** Pure virtual method. Subclassed pages load their config settings here. */ + virtual void load() = 0; + /** Pure virtual method. Subclassed pages save their config settings here + * and return true if everything was saved successfully. */ + virtual bool save(QString &errmsg) = 0; + + /** Subclassed pages can overload this method to return true if they + * contain settings that have been modified since they were last applied to + * Tor. The default implementation always returns false. */ + virtual bool changedSinceLastApply() { + return false; + } + /** Subclassed pages can overload this method to apply any settings to + * Tor that have been modified since they were last applied (e.g., the + * changes were made while Tor was not running). Returns true if the changes + * were applied successfully. */ + virtual bool apply(QString &errmsg) { + Q_UNUSED(errmsg); + return true; + } + /** Subclassed pages can overload this method to revert any cancelled + * settings. */ + virtual void revert() {} + + virtual void retranslateUi() {} + +signals: + /** Signal emitted when a ConfigPage requests help information on a given + * topic. */ + void helpRequested(const QString &topic); + +private: + QString _title; /**< Title of this configuration page. */ +}; + +#endif + diff -Nru vidalia-0.1.13/src/vidalia/config/configpagestack.cpp vidalia-0.2.8/src/vidalia/config/configpagestack.cpp --- vidalia-0.1.13/src/vidalia/config/configpagestack.cpp 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/configpagestack.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,70 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 configpagestack.cpp -** \version $Id: configpagestack.cpp 2367 2008-03-01 22:11:52Z edmanm $ -** \brief A collection of configuration pages -*/ - -#include -#include "configpagestack.h" - - -/** Default constructor. */ -ConfigPageStack::ConfigPageStack(QWidget *parent) -: QStackedWidget(parent) -{ -} - -/** Adds a page to the stack. */ -void -ConfigPageStack::add(ConfigPage *page, QAction *action) -{ - _pages.insert(action, page); - insertWidget(count(), page); -} - -/** Sets the current config page and checks its action. */ -void -ConfigPageStack::setCurrentPage(ConfigPage *page) -{ - foreach (QAction *action, _pages.keys(page)) { - action->setChecked(true); - } - setCurrentWidget(page); -} - -/** Sets the current config page index and checks its action. */ -void -ConfigPageStack::setCurrentIndex(int index) -{ - setCurrentPage((ConfigPage *)widget(index)); -} - -/** Shows the config page associated with the activated action. */ -void -ConfigPageStack::showPage(QAction *pageAction) -{ - setCurrentWidget(_pages.value(pageAction)); -} - -/** Returns a list of all pages in the stack. The order of the pages in the - * returned QList is the same as the order in which the pages were initially - * added to the stack. */ -QList -ConfigPageStack::pages() const -{ - QList pages; - for (int i = 0; i < count(); i++) - pages << dynamic_cast(widget(i)); - return pages; -} - diff -Nru vidalia-0.1.13/src/vidalia/config/ConfigPageStack.cpp vidalia-0.2.8/src/vidalia/config/ConfigPageStack.cpp --- vidalia-0.1.13/src/vidalia/config/ConfigPageStack.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/ConfigPageStack.cpp 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,71 @@ +/* +** 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.vidalia-project.net/. 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 ConfigPageStack.cpp +** \version $Id: ConfigPageStack.cpp 3735 2009-04-28 20:28:01Z edmanm $ +** \brief A collection of configuration pages +*/ + +#include "ConfigPageStack.h" + +#include + + +/** Default constructor. */ +ConfigPageStack::ConfigPageStack(QWidget *parent) +: QStackedWidget(parent) +{ +} + +/** Adds a page to the stack. */ +void +ConfigPageStack::add(ConfigPage *page, QAction *action) +{ + _pages.insert(action, page); + insertWidget(count(), page); +} + +/** Sets the current config page and checks its action. */ +void +ConfigPageStack::setCurrentPage(ConfigPage *page) +{ + foreach (QAction *action, _pages.keys(page)) { + action->setChecked(true); + } + setCurrentWidget(page); +} + +/** Sets the current config page index and checks its action. */ +void +ConfigPageStack::setCurrentIndex(int index) +{ + setCurrentPage((ConfigPage *)widget(index)); +} + +/** Shows the config page associated with the activated action. */ +void +ConfigPageStack::showPage(QAction *pageAction) +{ + setCurrentWidget(_pages.value(pageAction)); +} + +/** Returns a list of all pages in the stack. The order of the pages in the + * returned QList is the same as the order in which the pages were initially + * added to the stack. */ +QList +ConfigPageStack::pages() const +{ + QList pages; + for (int i = 0; i < count(); i++) + pages << dynamic_cast(widget(i)); + return pages; +} + diff -Nru vidalia-0.1.13/src/vidalia/config/configpagestack.h vidalia-0.2.8/src/vidalia/config/configpagestack.h --- vidalia-0.1.13/src/vidalia/config/configpagestack.h 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/configpagestack.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,56 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 configpagestack.h -** \version $Id: configpagestack.h 2367 2008-03-01 22:11:52Z edmanm $ -** \brief A collection of configuration pages -*/ - -#ifndef _CONFIGPAGESTACK_H -#define _CONFIGPAGESTACK_H - -#include -#include - -#include "configpage.h" - - -class ConfigPageStack : public QStackedWidget -{ - Q_OBJECT - -public: - /** Constructor. */ - ConfigPageStack(QWidget *parent = 0); - - /** Adds a configuration page to the stack. */ - void add(ConfigPage *page, QAction *action); - /** Sets the current config page and checks its action. */ - void setCurrentPage(ConfigPage *page); - /** Sets the current config page index and checks its action. */ - void setCurrentIndex(int index); - - /** Returns a list of all pages in the stack. The order of the pages in the - * returned QList is the same as the order in which the pages were - * initially added to the stack. */ - QList pages() const; - -public slots: - /** Displays the page associated with the activated action. */ - void showPage(QAction *pageAction); - -private: - /** Maps an action to a config page. */ - QHash _pages; -}; - -#endif - diff -Nru vidalia-0.1.13/src/vidalia/config/ConfigPageStack.h vidalia-0.2.8/src/vidalia/config/ConfigPageStack.h --- vidalia-0.1.13/src/vidalia/config/ConfigPageStack.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/ConfigPageStack.h 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,56 @@ +/* +** 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.vidalia-project.net/. 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 ConfigPageStack.h +** \version $Id: ConfigPageStack.h 3735 2009-04-28 20:28:01Z edmanm $ +** \brief A collection of configuration pages +*/ + +#ifndef _CONFIGPAGESTACK_H +#define _CONFIGPAGESTACK_H + +#include "ConfigPage.h" + +#include +#include + + +class ConfigPageStack : public QStackedWidget +{ + Q_OBJECT + +public: + /** Constructor. */ + ConfigPageStack(QWidget *parent = 0); + + /** Adds a configuration page to the stack. */ + void add(ConfigPage *page, QAction *action); + /** Sets the current config page and checks its action. */ + void setCurrentPage(ConfigPage *page); + /** Sets the current config page index and checks its action. */ + void setCurrentIndex(int index); + + /** Returns a list of all pages in the stack. The order of the pages in the + * returned QList is the same as the order in which the pages were + * initially added to the stack. */ + QList pages() const; + +public slots: + /** Displays the page associated with the activated action. */ + void showPage(QAction *pageAction); + +private: + /** Maps an action to a config page. */ + QHash _pages; +}; + +#endif + diff -Nru vidalia-0.1.13/src/vidalia/config/domainvalidator.cpp vidalia-0.2.8/src/vidalia/config/domainvalidator.cpp --- vidalia-0.1.13/src/vidalia/config/domainvalidator.cpp 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/domainvalidator.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,30 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 domainvalidator.cpp -** \version $Id: domainvalidator.cpp 2362 2008-02-29 04:30:11Z edmanm $ -** \brief Validates that a given domain name is (probably) valid -*/ - -#include "domainvalidator.h" - - -/** Regular expression to validate that input is a valid IP address. */ -#define DOMAIN_REGEXP \ -"^([a-zA-Z0-9]([a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])?\\.)+[a-zA-Z]{2,6}$" - - -/** Constructor. */ -DomainValidator::DomainValidator(QObject *parent) -: QRegExpValidator(QRegExp(DOMAIN_REGEXP), parent) -{ -} - diff -Nru vidalia-0.1.13/src/vidalia/config/DomainValidator.cpp vidalia-0.2.8/src/vidalia/config/DomainValidator.cpp --- vidalia-0.1.13/src/vidalia/config/DomainValidator.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/DomainValidator.cpp 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,30 @@ +/* +** 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.vidalia-project.net/. 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 DomainValidator.cpp +** \version $Id: DomainValidator.cpp 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Validates that a given domain name is (probably) valid +*/ + +#include "DomainValidator.h" + + +/** Regular expression to validate that input is a valid IP address. */ +#define DOMAIN_REGEXP \ +"^([a-zA-Z0-9]([a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])?\\.)+[a-zA-Z]{2,6}$" + + +/** Constructor. */ +DomainValidator::DomainValidator(QObject *parent) +: QRegExpValidator(QRegExp(DOMAIN_REGEXP), parent) +{ +} + diff -Nru vidalia-0.1.13/src/vidalia/config/domainvalidator.h vidalia-0.2.8/src/vidalia/config/domainvalidator.h --- vidalia-0.1.13/src/vidalia/config/domainvalidator.h 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/domainvalidator.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,33 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 domainvalidator.h -** \version $Id: domainvalidator.h 2362 2008-02-29 04:30:11Z edmanm $ -** \brief Validates that a given domain name is (probably) valid -*/ - -#ifndef _DOMAINVALIDATOR_H -#define _DOMAINVALIDATOR_H - -#include - - -class DomainValidator : public QRegExpValidator -{ - Q_OBJECT - -public: - /** Constructor. */ - DomainValidator(QObject *parent); -}; - -#endif - diff -Nru vidalia-0.1.13/src/vidalia/config/DomainValidator.h vidalia-0.2.8/src/vidalia/config/DomainValidator.h --- vidalia-0.1.13/src/vidalia/config/DomainValidator.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/DomainValidator.h 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,33 @@ +/* +** 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.vidalia-project.net/. 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 DomainValidator.h +** \version $Id: DomainValidator.h 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Validates that a given domain name is (probably) valid +*/ + +#ifndef _DOMAINVALIDATOR_H +#define _DOMAINVALIDATOR_H + +#include + + +class DomainValidator : public QRegExpValidator +{ + Q_OBJECT + +public: + /** Constructor. */ + DomainValidator(QObject *parent); +}; + +#endif + diff -Nru vidalia-0.1.13/src/vidalia/config/exitpolicy.cpp vidalia-0.2.8/src/vidalia/config/exitpolicy.cpp --- vidalia-0.1.13/src/vidalia/config/exitpolicy.cpp 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/exitpolicy.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,165 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 exitpolicy.cpp -** \version $Id: exitpolicy.cpp 2362 2008-02-29 04:30:11Z edmanm $ -** \brief Collection of Policy objects representing an exit policy -*/ - -#include - -#include "exitpolicy.h" - - -/** Default constructor. */ -ExitPolicy::ExitPolicy() -{ -} - -/** Constructor. Creates an exit policy based on the given type. */ -ExitPolicy::ExitPolicy(SpecialExitPolicy exitPolicy) -{ - if (exitPolicy == Middleman) { - _exitPolicy << Policy(Policy::RejectAll); - } else if (exitPolicy == Default) { - _exitPolicy << Policy("reject *:25") - << Policy("reject *:119") - << Policy("reject *:135-139") - << Policy("reject *:445") - << Policy("reject *:465") - << Policy("reject *:587") - << Policy("reject *:1214") - << Policy("reject *:4661-4666") - << Policy("reject *:6346-6429") - << Policy("reject *:6699") - << Policy("reject *:6881-6999") - << Policy("accept *:*"); - } -} - -/** Parses the given string for a comma-delimited list of policies and - * adds them to this this policy. */ -ExitPolicy::ExitPolicy(QString exitPolicy) -{ - if (!exitPolicy.isEmpty()) { - QStringList policyList = exitPolicy.split(","); - foreach(QString policy, policyList) { - addPolicy(Policy(policy)); - } - } -} - -/** Adds a policy to this exit policy. */ -void -ExitPolicy::addPolicy(Policy policy) -{ - if (!contains(policy)) { - _exitPolicy << policy; - } -} - -/** Removes a policy from this exit policy. */ -void -ExitPolicy::removePolicy(Policy policy) -{ - for (int i = 0; i < _exitPolicy.size(); i++) { - if (policy == _exitPolicy.at(i)) { - _exitPolicy.removeAt(i); - return; - } - } -} - -/** Adds the ports specified in portList to a list of ports accepted - * by this exit policy. Ports may be given either individually or as ranges. */ -void -ExitPolicy::addAcceptedPorts(QStringList portList) -{ - foreach (QString port, portList) { - addPolicy(Policy("accept *:" + port)); - } -} - -/** Returns true if this exit policy accepts all ports specified in - * portList. Ports in portList may be given either individually - * or in ranges (e.g., "6660-6669"). */ -bool -ExitPolicy::acceptsPorts(QStringList portList) -{ - foreach (QString port, portList) { - if (!contains(Policy("accept *:" + port))) { - return false; - } - } - return true; -} - -/** Adds the ports specified in portList to a list of ports rejected - * by this exit policy. Ports may be given either individually or as ranges. */ -void -ExitPolicy::addRejectedPorts(QStringList portList) -{ - foreach (QString port, portList) { - addPolicy(Policy("reject *:" + port)); - } -} - -/** Returns true if this exit policy rejects all ports specified in - * portList. Ports in portList may be given either individually - * or in ranges (e.g., "6660-6669"). */ -bool -ExitPolicy::rejectsPorts(QStringList portList) -{ - foreach (QString port, portList) { - if (!contains(Policy("reject *:" + port))) { - return false; - } - } - return true; -} - -/** Returns true if this exit policy contains the given policy. */ -bool -ExitPolicy::contains(Policy policy) -{ - Policy acceptAll(Policy::AcceptAll); - Policy rejectAll(Policy::RejectAll); - - /* Check for this policy item in the explicitly defined policies */ - foreach (Policy p, _exitPolicy) { - if (p.matches(policy)) { - return true; - } - if ((p == acceptAll) || (p == rejectAll)) { - /* This exit policy replaces the default policy, so stop checking */ - return false; - } - } - /* Now check the default exit policy */ - foreach (Policy p, ExitPolicy(Default).policyList()) { - if (p.matches(policy)) { - return true; - } - } - return false; -} - -/** Converts the exit policy to a format Tor understands. */ -QString -ExitPolicy::toString() -{ - QStringList policyList; - foreach (Policy policy, _exitPolicy) { - policyList << policy.toString(); - } - return policyList.join(","); -} - diff -Nru vidalia-0.1.13/src/vidalia/config/ExitPolicy.cpp vidalia-0.2.8/src/vidalia/config/ExitPolicy.cpp --- vidalia-0.1.13/src/vidalia/config/ExitPolicy.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/ExitPolicy.cpp 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,165 @@ +/* +** 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.vidalia-project.net/. 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 ExitPolicy.cpp +** \version $Id: ExitPolicy.cpp 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Collection of Policy objects representing an exit policy +*/ + +#include "ExitPolicy.h" + +#include + + +/** Default constructor. */ +ExitPolicy::ExitPolicy() +{ +} + +/** Constructor. Creates an exit policy based on the given type. */ +ExitPolicy::ExitPolicy(SpecialExitPolicy exitPolicy) +{ + if (exitPolicy == Middleman) { + _exitPolicy << Policy(Policy::RejectAll); + } else if (exitPolicy == Default) { + _exitPolicy << Policy("reject *:25") + << Policy("reject *:119") + << Policy("reject *:135-139") + << Policy("reject *:445") + << Policy("reject *:465") + << Policy("reject *:587") + << Policy("reject *:1214") + << Policy("reject *:4661-4666") + << Policy("reject *:6346-6429") + << Policy("reject *:6699") + << Policy("reject *:6881-6999") + << Policy("accept *:*"); + } +} + +/** Parses the given string for a comma-delimited list of policies and + * adds them to this this policy. */ +ExitPolicy::ExitPolicy(QString exitPolicy) +{ + if (!exitPolicy.isEmpty()) { + QStringList policyList = exitPolicy.split(","); + foreach(QString policy, policyList) { + addPolicy(Policy(policy)); + } + } +} + +/** Adds a policy to this exit policy. */ +void +ExitPolicy::addPolicy(Policy policy) +{ + if (!contains(policy)) { + _exitPolicy << policy; + } +} + +/** Removes a policy from this exit policy. */ +void +ExitPolicy::removePolicy(Policy policy) +{ + for (int i = 0; i < _exitPolicy.size(); i++) { + if (policy == _exitPolicy.at(i)) { + _exitPolicy.removeAt(i); + return; + } + } +} + +/** Adds the ports specified in portList to a list of ports accepted + * by this exit policy. Ports may be given either individually or as ranges. */ +void +ExitPolicy::addAcceptedPorts(QStringList portList) +{ + foreach (QString port, portList) { + addPolicy(Policy("accept *:" + port)); + } +} + +/** Returns true if this exit policy accepts all ports specified in + * portList. Ports in portList may be given either individually + * or in ranges (e.g., "6660-6669"). */ +bool +ExitPolicy::acceptsPorts(QStringList portList) +{ + foreach (QString port, portList) { + if (!contains(Policy("accept *:" + port))) { + return false; + } + } + return true; +} + +/** Adds the ports specified in portList to a list of ports rejected + * by this exit policy. Ports may be given either individually or as ranges. */ +void +ExitPolicy::addRejectedPorts(QStringList portList) +{ + foreach (QString port, portList) { + addPolicy(Policy("reject *:" + port)); + } +} + +/** Returns true if this exit policy rejects all ports specified in + * portList. Ports in portList may be given either individually + * or in ranges (e.g., "6660-6669"). */ +bool +ExitPolicy::rejectsPorts(QStringList portList) +{ + foreach (QString port, portList) { + if (!contains(Policy("reject *:" + port))) { + return false; + } + } + return true; +} + +/** Returns true if this exit policy contains the given policy. */ +bool +ExitPolicy::contains(Policy policy) +{ + Policy acceptAll(Policy::AcceptAll); + Policy rejectAll(Policy::RejectAll); + + /* Check for this policy item in the explicitly defined policies */ + foreach (Policy p, _exitPolicy) { + if (p.matches(policy)) { + return true; + } + if ((p == acceptAll) || (p == rejectAll)) { + /* This exit policy replaces the default policy, so stop checking */ + return false; + } + } + /* Now check the default exit policy */ + foreach (Policy p, ExitPolicy(Default).policyList()) { + if (p.matches(policy)) { + return true; + } + } + return false; +} + +/** Converts the exit policy to a format Tor understands. */ +QString +ExitPolicy::toString() +{ + QStringList policyList; + foreach (Policy policy, _exitPolicy) { + policyList << policy.toString(); + } + return policyList.join(","); +} + diff -Nru vidalia-0.1.13/src/vidalia/config/exitpolicy.h vidalia-0.2.8/src/vidalia/config/exitpolicy.h --- vidalia-0.1.13/src/vidalia/config/exitpolicy.h 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/exitpolicy.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,77 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 exitpolicy.h -** \version $Id: exitpolicy.h 2362 2008-02-29 04:30:11Z edmanm $ -** \brief Collection of Policy objects representing an exit policy -*/ - -#ifndef _EXITPOLICY_H -#define _EXITPOLICY_H - -#include -#include -#include - -#include "policy.h" - - -class ExitPolicy -{ -public: - /** Special exit policy types. */ - enum SpecialExitPolicy { - Default, /**< Specifies the default exit policy. */ - Middleman /**< Specifies a middleman-only exit policy. */ - }; - - /** Default constructor. */ - ExitPolicy(); - /** Creates an exit policy of the given special type. */ - ExitPolicy(SpecialExitPolicy exitPolicy); - /** Creates an exit policy from the given comma-delimited list of policies. */ - ExitPolicy(QString exitPolicy); - - /** Adds the ports specified in portList to a list of ports accepted - * by this exit policy. Ports may be given either individually or as ranges. */ - void addAcceptedPorts(QStringList portList); - /** Returns true if this exit policy accepts all ports specified in - * portList. Ports in portList may be given either individually - * or as ranges. */ - bool acceptsPorts(QStringList portList); - /** Adds the ports specified in portList to a list of ports rejected - * by this exit policy. Ports may be given either individually or as ranges. */ - void addRejectedPorts(QStringList portList); - /** Returns true if this exit policy rejects all ports specified in - * portList. Ports in portList may be given either individually - * or as ranges. */ - bool rejectsPorts(QStringList portList); - - /** Adds a rule to the exit policy. */ - void addPolicy(Policy policy); - /** Removes a rule from the exit policy. */ - void removePolicy(Policy policy); - /** Checks if the current exit policy contains the given rule. */ - bool contains(Policy policy); - - /** Returns the list of policies for this exit policy. */ - QList policyList() { return _exitPolicy; } - - /** Converts the exit policy to a format Tor understands. */ - QString toString(); - -private: - /** A collection of policies forming the exit policy. */ - QList _exitPolicy; -}; - -#endif - diff -Nru vidalia-0.1.13/src/vidalia/config/ExitPolicy.h vidalia-0.2.8/src/vidalia/config/ExitPolicy.h --- vidalia-0.1.13/src/vidalia/config/ExitPolicy.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/ExitPolicy.h 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,77 @@ +/* +** 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.vidalia-project.net/. 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 ExitPolicy.h +** \version $Id: ExitPolicy.h 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Collection of Policy objects representing an exit policy +*/ + +#ifndef _EXITPOLICY_H +#define _EXITPOLICY_H + +#include "Policy.h" + +#include +#include +#include + + +class ExitPolicy +{ +public: + /** Special exit policy types. */ + enum SpecialExitPolicy { + Default, /**< Specifies the default exit policy. */ + Middleman /**< Specifies a middleman-only exit policy. */ + }; + + /** Default constructor. */ + ExitPolicy(); + /** Creates an exit policy of the given special type. */ + ExitPolicy(SpecialExitPolicy exitPolicy); + /** Creates an exit policy from the given comma-delimited list of policies. */ + ExitPolicy(QString exitPolicy); + + /** Adds the ports specified in portList to a list of ports accepted + * by this exit policy. Ports may be given either individually or as ranges. */ + void addAcceptedPorts(QStringList portList); + /** Returns true if this exit policy accepts all ports specified in + * portList. Ports in portList may be given either individually + * or as ranges. */ + bool acceptsPorts(QStringList portList); + /** Adds the ports specified in portList to a list of ports rejected + * by this exit policy. Ports may be given either individually or as ranges. */ + void addRejectedPorts(QStringList portList); + /** Returns true if this exit policy rejects all ports specified in + * portList. Ports in portList may be given either individually + * or as ranges. */ + bool rejectsPorts(QStringList portList); + + /** Adds a rule to the exit policy. */ + void addPolicy(Policy policy); + /** Removes a rule from the exit policy. */ + void removePolicy(Policy policy); + /** Checks if the current exit policy contains the given rule. */ + bool contains(Policy policy); + + /** Returns the list of policies for this exit policy. */ + QList policyList() { return _exitPolicy; } + + /** Converts the exit policy to a format Tor understands. */ + QString toString(); + +private: + /** A collection of policies forming the exit policy. */ + QList _exitPolicy; +}; + +#endif + diff -Nru vidalia-0.1.13/src/vidalia/config/generalpage.cpp vidalia-0.2.8/src/vidalia/config/generalpage.cpp --- vidalia-0.1.13/src/vidalia/config/generalpage.cpp 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/generalpage.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,135 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 generalpage.cpp -** \version $Id: generalpage.cpp 2484 2008-04-05 04:09:20Z edmanm $ -** \brief General Tor and Vidalia configuration options -*/ - -#include -#include "generalpage.h" - - -/** Constructor */ -GeneralPage::GeneralPage(QWidget *parent) -: ConfigPage(parent, tr("General")) -{ - /* Invoke the Qt Designer generated object setup routine */ - ui.setupUi(this); - - /* Create settings objects */ - _vidaliaSettings = new VidaliaSettings; - _torSettings = new TorSettings; - - /* Bind event to actions */ - connect(ui.btnBrowseTorExecutable, SIGNAL(clicked()), - this, SLOT(browseTorExecutable())); - connect(ui.btnBrowseProxyExecutable, SIGNAL(clicked()), - this, SLOT(browseProxyExecutable())); - - /* Hide platform specific features */ -#ifndef Q_WS_WIN - ui.chkRunVidaliaAtSystemStartup->setVisible(false); -#endif -} - -/** Destructor */ -GeneralPage::~GeneralPage() -{ - delete _vidaliaSettings; - delete _torSettings; -} - -/** Displays a file dialog allowing the user to browse for an executable - * file. caption will be displayed in the dialog's title bar and - * file, if specified, is the default file selected in the dialog. - */ -QString -GeneralPage::browseExecutable(const QString &caption, const QString &file) -{ -#if defined(Q_OS_WIN32) - QString filter = tr("Executables (*.exe)"); -#else - QString filter = ""; -#endif - - QString filePath = QFileDialog::getOpenFileName(this, caption, file, filter); - return QDir::convertSeparators(filePath); -} - -/** Open a QFileDialog to browse for a Tor executable file. */ -void -GeneralPage::browseTorExecutable() -{ - QString filePath = browseExecutable(tr("Select Path to Tor"), - ui.lineTorExecutable->text()); - if (! filePath.isEmpty()) - ui.lineTorExecutable->setText(filePath); -} - -/** Open a QFileDialog to browse for a proxy executable file. */ -void -GeneralPage::browseProxyExecutable() -{ - QString filePath = browseExecutable(tr("Select Proxy Executable"), - ui.lineProxyExecutable->text()); - - if (! filePath.isEmpty()) - ui.lineProxyExecutable->setText(filePath); -} - -/** Saves all settings for this page */ -bool -GeneralPage::save(QString &errmsg) -{ - QString torExecutable = ui.lineTorExecutable->text(); - if (torExecutable.isEmpty()) { - errmsg = tr("You must specify the name of your Tor executable."); - return false; - } - if (ui.chkRunProxyAtVidaliaStartup->isChecked()) { - bool ok; - QStringList proxyArgs = string_parse_arguments( - ui.lineProxyExecutableArguments->text(), &ok); - if (! ok) { - errmsg = tr("The proxy arguments specified are not properly formatted."); - return false; - } - _vidaliaSettings->setProxyExecutable(ui.lineProxyExecutable->text()); - _vidaliaSettings->setProxyExecutableArguments(proxyArgs); - } - - _torSettings->setExecutable(torExecutable); - _vidaliaSettings->setRunTorAtStart(ui.chkRunTorAtVidaliaStartup->isChecked()); - _vidaliaSettings->setRunVidaliaOnBoot( - ui.chkRunVidaliaAtSystemStartup->isChecked()); - _vidaliaSettings->setRunProxyAtStart( - ui.chkRunProxyAtVidaliaStartup->isChecked()); - - return true; -} - -/** Loads previously saved settings */ -void -GeneralPage::load() -{ - ui.chkRunVidaliaAtSystemStartup->setChecked( - _vidaliaSettings->runVidaliaOnBoot()); - - ui.lineTorExecutable->setText(_torSettings->getExecutable()); - ui.chkRunTorAtVidaliaStartup->setChecked(_vidaliaSettings->runTorAtStart()); - - ui.lineProxyExecutable->setText(_vidaliaSettings->getProxyExecutable()); - ui.lineProxyExecutableArguments->setText( - string_format_arguments(_vidaliaSettings->getProxyExecutableArguments())); - ui.chkRunProxyAtVidaliaStartup->setChecked(_vidaliaSettings->runProxyAtStart()); -} - diff -Nru vidalia-0.1.13/src/vidalia/config/GeneralPage.cpp vidalia-0.2.8/src/vidalia/config/GeneralPage.cpp --- vidalia-0.1.13/src/vidalia/config/GeneralPage.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/GeneralPage.cpp 2009-09-24 03:28:18.000000000 +0100 @@ -0,0 +1,150 @@ +/* +** 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.vidalia-project.net/. 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 GeneralPage.cpp +** \version $Id: GeneralPage.cpp 4132 2009-09-24 02:28:18Z edmanm $ +** \brief General Tor and Vidalia configuration options +*/ + +#include "config.h" +#include "GeneralPage.h" + +#include "stringutil.h" + +#include + + +/** Constructor */ +GeneralPage::GeneralPage(QWidget *parent) +: ConfigPage(parent, "General") +{ + /* Invoke the Qt Designer generated object setup routine */ + ui.setupUi(this); + + /* Create settings objects */ + _vidaliaSettings = new VidaliaSettings; + _torSettings = new TorSettings; + + /* Bind event to actions */ + connect(ui.btnBrowseTorExecutable, SIGNAL(clicked()), + this, SLOT(browseTorExecutable())); + connect(ui.btnBrowseProxyExecutable, SIGNAL(clicked()), + this, SLOT(browseProxyExecutable())); + connect(ui.btnUpdateNow, SIGNAL(clicked()), this, SLOT(updateNow())); + +#if !defined(Q_OS_WIN32) + /* Hide platform specific features */ + ui.chkRunVidaliaAtSystemStartup->setVisible(false); + ui.lineHorizontalSeparator->setVisible(false); +#endif +#if !defined(USE_AUTOUPDATE) + ui.grpSoftwareUpdates->setVisible(false); +#endif +} + +/** Destructor */ +GeneralPage::~GeneralPage() +{ + delete _vidaliaSettings; + delete _torSettings; +} + +/** Called when the user changes the UI translation. */ +void +GeneralPage::retranslateUi() +{ + ui.retranslateUi(this); +} + +/** Displays a file dialog allowing the user to browse for an executable + * file. caption will be displayed in the dialog's title bar and + * file, if specified, is the default file selected in the dialog. + */ +QString +GeneralPage::browseExecutable(const QString &caption, const QString &file) +{ +#if defined(Q_OS_WIN32) + QString filter = tr("Executables (*.exe)"); +#else + QString filter = ""; +#endif + + QString filePath = QFileDialog::getOpenFileName(this, caption, file, filter); + return QDir::convertSeparators(filePath); +} + +/** Open a QFileDialog to browse for a Tor executable file. */ +void +GeneralPage::browseTorExecutable() +{ + QString filePath = browseExecutable(tr("Select Path to Tor"), + ui.lineTorExecutable->text()); + if (! filePath.isEmpty()) + ui.lineTorExecutable->setText(filePath); +} + +/** Open a QFileDialog to browse for a proxy executable file. */ +void +GeneralPage::browseProxyExecutable() +{ + QString filePath = browseExecutable(tr("Select Proxy Executable"), + ui.lineProxyExecutable->text()); + + if (! filePath.isEmpty()) + ui.lineProxyExecutable->setText(filePath); +} + +/** Saves all settings for this page */ +bool +GeneralPage::save(QString &errmsg) +{ + QString torExecutable = ui.lineTorExecutable->text(); + if (torExecutable.isEmpty()) { + errmsg = tr("You must specify the name of your Tor executable."); + return false; + } + if (ui.chkRunProxyAtTorStartup->isChecked()) { + _vidaliaSettings->setProxyExecutable(ui.lineProxyExecutable->text()); + _vidaliaSettings->setProxyExecutableArguments( + ui.lineProxyExecutableArguments->text()); + } + + _torSettings->setExecutable(torExecutable); + _vidaliaSettings->setRunTorAtStart(ui.chkRunTorAtVidaliaStartup->isChecked()); + _vidaliaSettings->setRunVidaliaOnBoot( + ui.chkRunVidaliaAtSystemStartup->isChecked()); + _vidaliaSettings->setRunProxyAtStart( + ui.chkRunProxyAtTorStartup->isChecked()); + return true; +} + +/** Loads previously saved settings */ +void +GeneralPage::load() +{ + ui.chkRunVidaliaAtSystemStartup->setChecked( + _vidaliaSettings->runVidaliaOnBoot()); + + ui.lineTorExecutable->setText(_torSettings->getExecutable()); + ui.chkRunTorAtVidaliaStartup->setChecked(_vidaliaSettings->runTorAtStart()); + + ui.lineProxyExecutable->setText(_vidaliaSettings->getProxyExecutable()); + ui.lineProxyExecutableArguments->setText( + _vidaliaSettings->getProxyExecutableArguments()); + ui.chkRunProxyAtTorStartup->setChecked(_vidaliaSettings->runProxyAtStart()); +} + +void +GeneralPage::updateNow() +{ + emit checkForUpdates(); +} + diff -Nru vidalia-0.1.13/src/vidalia/config/generalpage.h vidalia-0.2.8/src/vidalia/config/generalpage.h --- vidalia-0.1.13/src/vidalia/config/generalpage.h 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/generalpage.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,63 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 generalpage.h -** \version $Id: generalpage.h 2484 2008-04-05 04:09:20Z edmanm $ -** \brief General Tor and Vidalia configuration options -*/ - -#ifndef _GENERALPAGE_H -#define _GENERALPAGE_H - -#include -#include -#include - -#include "configpage.h" -#include "ui_generalpage.h" - -class GeneralPage : public ConfigPage -{ - Q_OBJECT - -public: - /** Default Constructor */ - GeneralPage(QWidget *parent = 0); - /** Default Destructor */ - ~GeneralPage(); - /** Saves the changes on this page */ - bool save(QString &errmsg); - /** Loads the settings for this page */ - void load(); - -private slots: - /** Open a QFileDialog to browse for a Tor executable file. */ - void browseTorExecutable(); - /** Open a QFileDialog to browse for a proxy executable file. */ - void browseProxyExecutable(); - -private: - /** Displays a file dialog allowing the user to browse for an executable - * file. caption will be displayed in the dialog's title bar and - * file, if specified, is the default file selected in the dialog. */ - QString browseExecutable(const QString &caption, - const QString &file = QString()); - - /** A VidaliaSettings object used for saving/loading vidalia settings */ - VidaliaSettings *_vidaliaSettings; - /** A TorSettings ovject used for saving/loading tor settings */ - TorSettings *_torSettings; - /** Qt Designer generated object */ - Ui::GeneralPage ui; -}; - -#endif - diff -Nru vidalia-0.1.13/src/vidalia/config/GeneralPage.h vidalia-0.2.8/src/vidalia/config/GeneralPage.h --- vidalia-0.1.13/src/vidalia/config/GeneralPage.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/GeneralPage.h 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,72 @@ +/* +** 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.vidalia-project.net/. 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 GeneralPage.h +** \version $Id: GeneralPage.h 3735 2009-04-28 20:28:01Z edmanm $ +** \brief General Tor and Vidalia configuration options +*/ + +#ifndef _GENERALPAGE_H +#define _GENERALPAGE_H + +#include "ui_GeneralPage.h" +#include "ConfigPage.h" +#include "VidaliaSettings.h" +#include "TorSettings.h" + +#include + + +class GeneralPage : public ConfigPage +{ + Q_OBJECT + +public: + /** Default Constructor */ + GeneralPage(QWidget *parent = 0); + /** Default Destructor */ + ~GeneralPage(); + /** Saves the changes on this page */ + bool save(QString &errmsg); + /** Loads the settings for this page */ + void load(); + /** Called when the user changes the UI translation. */ + virtual void retranslateUi(); + +signals: + /** Emitted when the user clicks the "Check Now" button. */ + void checkForUpdates(); + +private slots: + /** Open a QFileDialog to browse for a Tor executable file. */ + void browseTorExecutable(); + /** Open a QFileDialog to browse for a proxy executable file. */ + void browseProxyExecutable(); + /** Initiate an immediate check for software updates. */ + void updateNow(); + +private: + /** Displays a file dialog allowing the user to browse for an executable + * file. caption will be displayed in the dialog's title bar and + * file, if specified, is the default file selected in the dialog. */ + QString browseExecutable(const QString &caption, + const QString &file = QString()); + + /** A VidaliaSettings object used for saving/loading vidalia settings */ + VidaliaSettings *_vidaliaSettings; + /** A TorSettings ovject used for saving/loading tor settings */ + TorSettings *_torSettings; + /** Qt Designer generated object */ + Ui::GeneralPage ui; +}; + +#endif + diff -Nru vidalia-0.1.13/src/vidalia/config/generalpage.ui vidalia-0.2.8/src/vidalia/config/generalpage.ui --- vidalia-0.1.13/src/vidalia/config/generalpage.ui 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/generalpage.ui 1970-01-01 01:00:00.000000000 +0100 @@ -1,181 +0,0 @@ - - GeneralPage - - - - 0 - 0 - 496 - 288 - - - - Qt::NoContextMenu - - - - 6 - - - - - Start Vidalia when my system starts - - - - - - - - 0 - 0 - - - - Qt::NoContextMenu - - - Tor Executable - - - - 6 - - - - - - - - - - - - Browse - - - - - - - - - Start the Tor software when Vidalia starts - - - - - - - - - - - - Start a proxy application when Vidalia starts - - - true - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - Proxy Executable - - - - - - - - true - - - - - - - true - - - Browse - - - - - - - - - - - true - - - Command Line Arguments: - - - - - - - - - true - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - chkRunProxyAtVidaliaStartup - toggled(bool) - grpProxyExecutable - setVisible(bool) - - - 247 - 138 - - - 247 - 208 - - - - - diff -Nru vidalia-0.1.13/src/vidalia/config/GeneralPage.ui vidalia-0.2.8/src/vidalia/config/GeneralPage.ui --- vidalia-0.1.13/src/vidalia/config/GeneralPage.ui 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/GeneralPage.ui 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,219 @@ + + GeneralPage + + + + 0 + 0 + 492 + 402 + + + + + 0 + 0 + + + + Qt::NoContextMenu + + + + 6 + + + + + Start Vidalia when my system starts + + + + + + + Qt::Horizontal + + + + + + + + 0 + 0 + + + + Qt::NoContextMenu + + + Tor + + + + + + Start the Tor software when Vidalia starts + + + + + + + + + + + + Browse + + + + + + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + Proxy Application (optional) + + + + + + Start a proxy application when Tor starts + + + true + + + + + + + + + true + + + + + + + true + + + Browse + + + + + + + + + + + true + + + Proxy Application Arguments: + + + + + + + + + true + + + + + + + + + + Software Updates + + + + + + Check for new software updates automatically + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Check Now + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + diff -Nru vidalia-0.1.13/src/vidalia/config/ipvalidator.cpp vidalia-0.2.8/src/vidalia/config/ipvalidator.cpp --- vidalia-0.1.13/src/vidalia/config/ipvalidator.cpp 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/ipvalidator.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,51 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 ipvalidator.cpp -** \version $Id: ipvalidator.cpp 2362 2008-02-29 04:30:11Z edmanm $ -** \brief Validates an entered IP address -*/ - -#include "ipvalidator.h" - -/** Regular expression to validate that input is a valid IP address. */ -#define IP_REGEXP "\\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)"\ - "\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)"\ - "\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)"\ - "\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b" - -#define MATCH_ALL "*" /**< Match all IP addresses. */ - - -/** Constructor. */ -IPValidator::IPValidator(QObject *parent) -: QRegExpValidator(QRegExp(IP_REGEXP), parent) -{ -} - -/** Validates the given input is either a valid IP or a "*". */ -QValidator::State -IPValidator::validate(QString &input, int &pos) const -{ - if (input == MATCH_ALL) { - return QValidator::Acceptable; - } - return QRegExpValidator::validate(input, pos); -} - -/** Validates the given input from position 0. */ -QValidator::State -IPValidator::validate(QString &input) const -{ - int discard = 0; - return validate(input, discard); -} - diff -Nru vidalia-0.1.13/src/vidalia/config/IpValidator.cpp vidalia-0.2.8/src/vidalia/config/IpValidator.cpp --- vidalia-0.1.13/src/vidalia/config/IpValidator.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/IpValidator.cpp 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,51 @@ +/* +** 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.vidalia-project.net/. 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 IpValidator.cpp +** \version $Id: IpValidator.cpp 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Validates an entered IP address +*/ + +#include "IpValidator.h" + +/** Regular expression to validate that input is a valid IP address. */ +#define IP_REGEXP "\\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)"\ + "\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)"\ + "\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)"\ + "\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b" + +#define MATCH_ALL "*" /**< Match all IP addresses. */ + + +/** Constructor. */ +IpValidator::IpValidator(QObject *parent) +: QRegExpValidator(QRegExp(IP_REGEXP), parent) +{ +} + +/** Validates the given input is either a valid IP or a "*". */ +QValidator::State +IpValidator::validate(QString &input, int &pos) const +{ + if (input == MATCH_ALL) { + return QValidator::Acceptable; + } + return QRegExpValidator::validate(input, pos); +} + +/** Validates the given input from position 0. */ +QValidator::State +IpValidator::validate(QString &input) const +{ + int discard = 0; + return validate(input, discard); +} + diff -Nru vidalia-0.1.13/src/vidalia/config/ipvalidator.h vidalia-0.2.8/src/vidalia/config/ipvalidator.h --- vidalia-0.1.13/src/vidalia/config/ipvalidator.h 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/ipvalidator.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,35 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 ipvalidator.h -** \version $Id: ipvalidator.h 2362 2008-02-29 04:30:11Z edmanm $ -** \brief Validates an entered IP address -*/ - -#ifndef _IPVALIDATOR_H -#define _IPVALIDATOR_H - -#include - - -class IPValidator : public QRegExpValidator -{ -public: - /** Constructor. */ - IPValidator(QObject *parent); - /** Validates the given input from position 0. */ - QValidator::State validate(QString &input) const; - /** Validates the given input is either a valid IP or a "*". */ - QValidator::State validate(QString &input, int &pos) const; -}; - -#endif - diff -Nru vidalia-0.1.13/src/vidalia/config/IpValidator.h vidalia-0.2.8/src/vidalia/config/IpValidator.h --- vidalia-0.1.13/src/vidalia/config/IpValidator.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/IpValidator.h 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,35 @@ +/* +** 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.vidalia-project.net/. 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 IpValidator.h +** \version $Id: IpValidator.h 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Validates an entered IP address +*/ + +#ifndef _IPVALIDATOR_H +#define _IPVALIDATOR_H + +#include + + +class IpValidator : public QRegExpValidator +{ +public: + /** Constructor. */ + IpValidator(QObject *parent); + /** Validates the given input from position 0. */ + QValidator::State validate(QString &input) const; + /** Validates the given input is either a valid IP or a "*". */ + QValidator::State validate(QString &input, int &pos) const; +}; + +#endif + diff -Nru vidalia-0.1.13/src/vidalia/config/networkpage.cpp vidalia-0.2.8/src/vidalia/config/networkpage.cpp --- vidalia-0.1.13/src/vidalia/config/networkpage.cpp 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/networkpage.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,357 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 networkpage.cpp -** \version $Id: networkpage.cpp 2403 2008-03-13 04:34:19Z edmanm $ -** \brief Network and firewall configuration options -*/ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "networkpage.h" -#include "domainvalidator.h" - -#define IMG_COPY ":/images/22x22/edit-copy.png" - - -/** Constructor */ -NetworkPage::NetworkPage(QWidget *parent) -: ConfigPage(parent, tr("Network")) -{ - /* Invoke the Qt Designer generated object setup routine */ - ui.setupUi(this); - - connect(ui.btnAddBridge, SIGNAL(clicked()), this, SLOT(addBridge())); - connect(ui.btnRemoveBridge, SIGNAL(clicked()), this, SLOT(removeBridge())); - connect(ui.btnCopyBridge, SIGNAL(clicked()), - this, SLOT(copySelectedBridgesToClipboard())); - connect(ui.listBridges, SIGNAL(customContextMenuRequested(QPoint)), - this, SLOT(bridgeContextMenuRequested(QPoint))); - connect(ui.listBridges, SIGNAL(itemSelectionChanged()), - this, SLOT(bridgeSelectionChanged())); - connect(ui.lineBridge, SIGNAL(returnPressed()), this, SLOT(addBridge())); - connect(Vidalia::torControl(), SIGNAL(authenticated()), - this, SLOT(onAuthenticated())); - connect(Vidalia::torControl(), SIGNAL(disconnected()), - this, SLOT(onDisconnected())); - connect(ui.lblHelpFindBridges, SIGNAL(linkActivated(QString)), - this, SLOT(onLinkActivated(QString))); - - ui.lblNoBridgeSupport->setVisible(false); - ui.lineHttpProxyAddress->setValidator(new DomainValidator(this)); - ui.lineHttpProxyPort->setValidator(new QIntValidator(1, 65535, this)); - - vApp->createShortcut(QKeySequence(QKeySequence::Copy), - ui.listBridges, this, - SLOT(copySelectedBridgesToClipboard())); - -#if defined(Q_WS_MAC) - /* On OS X, the network page looks better without frame titles. Everywhere - * else needs titles or else there's a break in the frame border. */ - ui.grpProxySettings->setTitle(""); - ui.grpFirewallSettings->setTitle(""); - ui.grpBridgeSettings->setTitle(""); -#endif -} - -/** Applies the network configuration settings to Tor. Returns true if the * - * settings were applied successfully. Otherwise, errmsg is set and * - * false is returned. */ -bool -NetworkPage::apply(QString &errmsg) -{ - return NetworkSettings(Vidalia::torControl()).apply(&errmsg); -} - -/** Returns true if the user has changed their server settings since the * - * last time they were applied to Tor. */ -bool -NetworkPage::changedSinceLastApply() -{ - return NetworkSettings(Vidalia::torControl()).changedSinceLastApply(); -} - -/** Reverts the server configuration settings to their values at the last * - * time they were successfully applied to Tor. */ -void -NetworkPage::revert() -{ - NetworkSettings settings(Vidalia::torControl()); - settings.revert(); -} - -/** Called when Vidalia has connected and authenticated to Tor. This will - * check Tor's version number and, if it's too old, will disable the bridge - * settings UI and show a message indicating the user's Tor is too old. */ -void -NetworkPage::onAuthenticated() -{ - quint32 torVersion = Vidalia::torControl()->getTorVersion(); - if (torVersion < 0x020003) { - ui.grpBridgeSettings->setEnabled(false); - ui.lblNoBridgeSupport->setVisible(true); - } -} - -/** Called when Vidalia disconnects from Tor. This will reenable the bridge - * settings (if they were previously disabled) and hide the warning message - * indicating the user's Tor does not support bridges. */ -void -NetworkPage::onDisconnected() -{ - ui.grpBridgeSettings->setEnabled(true); - ui.lblNoBridgeSupport->setVisible(false); -} - -/** Called when a link in a label is clicked. url is the target of - * the clicked link. */ -void -NetworkPage::onLinkActivated(const QString &url) -{ - emit helpRequested(url); -} - -/** Verifies that bridge is a valid bridge identifier and places a - * normalized identifier in out. The normalized identifier will have - * all spaces removed from the fingerprint portion (if any) and all - * hexadecimal characters converted to uppercase. Returns true if - * bridge is a valid bridge identifier, false otherwise. */ -bool -NetworkPage::validateBridge(const QString &bridge, QString *out) -{ - QString temp = bridge; - if (temp.startsWith("bridge ", Qt::CaseInsensitive)) - temp = temp.remove(0, 7); /* remove "bridge " */ - - QStringList parts = temp.split(" ", QString::SkipEmptyParts); - if (parts.isEmpty()) - return false; - - QString s = parts.at(0); - if (s.contains(":")) { - if (s.endsWith(":")) - return false; - - int index = s.indexOf(":"); - QString host = s.mid(0, index); - QString port = s.mid(index + 1); - if (QHostAddress(host).isNull() - || QHostAddress(host).protocol() != QAbstractSocket::IPv4Protocol - || port.toUInt() < 1 - || port.toUInt() > 65535) - return false; - temp = s; - if (parts.size() > 1) { - QString fp = static_cast(parts.mid(1)).join(""); - if (fp.length() != 40 || !string_is_hex(fp)) - return false; - temp += " " + fp.toUpper(); - } - } else { - QString fp = parts.join(""); - if (fp.length() != 40 || !string_is_hex(fp)) - return false; - temp = fp.toUpper(); - } - *out = temp; - return true; -} - -/** Adds a bridge to the bridge list box. */ -void -NetworkPage::addBridge() -{ - QString bridge; - QString input = ui.lineBridge->text().trimmed(); - - if (input.isEmpty()) - return; - if (!validateBridge(input, &bridge)) { - VMessageBox::warning(this, - tr("Invalid Bridge"), - tr("The specified bridge identifier is not valid."), - VMessageBox::Ok|VMessageBox::Default); - return; - } - if (!ui.listBridges->findItems(bridge, Qt::MatchFixedString).isEmpty()) - return; /* duplicate bridge */ - - ui.listBridges->addItem(bridge); - ui.lineBridge->clear(); -} - -/** Removes one or more selected bridges from the bridge list box. */ -void -NetworkPage::removeBridge() -{ - qDeleteAll(ui.listBridges->selectedItems()); -} - -/** Copies all selected bridges to the clipboard. */ -void -NetworkPage::copySelectedBridgesToClipboard() -{ - QString contents; - - foreach (QListWidgetItem *item, ui.listBridges->selectedItems()) { -#if defined(Q_WS_WIN) - contents += item->text() + "\r\n"; -#else - contents += item->text() + "\n"; -#endif - } - if (!contents.isEmpty()) - vApp->clipboard()->setText(contents.trimmed()); -} - -/** Called when the user right-clicks on a bridge and displays a context - * menu. */ -void -NetworkPage::bridgeContextMenuRequested(const QPoint &pos) -{ - QMenu menu(this); - - QListWidgetItem *item = ui.listBridges->itemAt(pos); - if (!item) - return; - - QAction *copyAction = - new QAction(QIcon(IMG_COPY), tr("Copy (Ctrl+C)"), &menu); - connect(copyAction, SIGNAL(triggered()), - this, SLOT(copySelectedBridgesToClipboard())); - - menu.addAction(copyAction); - menu.exec(ui.listBridges->mapToGlobal(pos)); -} - -/** Called when the user changes which bridges they have selected. */ -void -NetworkPage::bridgeSelectionChanged() -{ - bool enabled = !ui.listBridges->selectedItems().isEmpty(); - ui.btnCopyBridge->setEnabled(enabled); - ui.btnRemoveBridge->setEnabled(enabled); -} - -/** Saves changes made to settings on the Firewall settings page. */ -bool -NetworkPage::save(QString &errmsg) -{ - NetworkSettings settings(Vidalia::torControl()); - QStringList bridgeList; - QList reachablePorts; - bool ok; - - if (ui.chkUseProxy->isChecked() - && (ui.lineHttpProxyAddress->text().isEmpty() - || ui.lineHttpProxyPort->text().isEmpty())) { - errmsg = tr("You must specify both an IP address or hostname and a " - "port number to configure Tor to use a proxy to access " - "the Internet."); - return false; - } - if (ui.chkFascistFirewall->isChecked() - && ui.lineReachablePorts->text().isEmpty()) { - errmsg = tr("You must specify one or more ports to which your " - "firewall allows you to connect."); - return false; - } - - /* Save the HTTP/HTTPS proxy settings */ - settings.setUseHttpProxy(ui.chkUseProxy->isChecked()); - settings.setUseHttpsProxy(ui.chkProxyUseHttps->isChecked()); - if (!ui.lineHttpProxyAddress->text().isEmpty()) { - QString proxy = ui.lineHttpProxyAddress->text(); - if (!ui.lineHttpProxyPort->text().isEmpty()) - proxy += ":" + ui.lineHttpProxyPort->text(); - - settings.setHttpProxy(proxy); - settings.setHttpsProxy(proxy); - } else { - settings.setHttpProxy(""); - settings.setHttpsProxy(""); - } - - if (!ui.lineHttpProxyUsername->text().isEmpty() || - !ui.lineHttpProxyPassword->text().isEmpty()) { - QString auth = ui.lineHttpProxyUsername->text() + ":" + - ui.lineHttpProxyPassword->text(); - settings.setHttpProxyAuthenticator(auth); - settings.setHttpsProxyAuthenticator(auth); - } else { - settings.setHttpProxyAuthenticator(""); - settings.setHttpsProxyAuthenticator(""); - } - - /* Save the reachable port settings */ - settings.setFascistFirewall(ui.chkFascistFirewall->isChecked()); - foreach (QString portString, - ui.lineReachablePorts->text().split(",", QString::SkipEmptyParts)) { - quint32 port = portString.toUInt(&ok); - if (!ok || port < 1 || port > 65535) { - errmsg = tr("'%1' is not a valid port number.").arg(portString); - return false; - } - reachablePorts << (quint16)port; - } - settings.setReachablePorts(reachablePorts); - - /* Save the bridge settings */ - settings.setUseBridges(ui.chkUseBridges->isChecked()); - for (int i = 0; i < ui.listBridges->count(); i++) - bridgeList << ui.listBridges->item(i)->text(); - settings.setBridgeList(bridgeList); - - return true; -} - -/** Loads previously saved settings */ -void -NetworkPage::load() -{ - NetworkSettings settings(Vidalia::torControl()); - QStringList reachablePortStrings; - - /* Load HTTP/HTTPS proxy settings */ - ui.chkUseProxy->setChecked(settings.getUseHttpProxy()); - ui.chkProxyUseHttps->setChecked(settings.getUseHttpsProxy()); - QStringList proxy = settings.getHttpProxy().split(":"); - QStringList proxyAuth = settings.getHttpProxyAuthenticator().split(":"); - if (proxy.size() >= 1) - ui.lineHttpProxyAddress->setText(proxy.at(0)); - if (proxy.size() >= 2) - ui.lineHttpProxyPort->setText(proxy.at(1)); - if (proxyAuth.size() >= 1) - ui.lineHttpProxyUsername->setText(proxyAuth.at(0)); - if (proxyAuth.size() >= 2) - ui.lineHttpProxyPassword->setText(proxyAuth.at(1)); - - /* Load firewall settings */ - ui.chkFascistFirewall->setChecked(settings.getFascistFirewall()); - QList reachablePorts = settings.getReachablePorts(); - foreach (quint16 port, reachablePorts) { - reachablePortStrings << QString::number(port); - } - ui.lineReachablePorts->setText(reachablePortStrings.join(",")); - - /* Load bridge settings */ - ui.chkUseBridges->setChecked(settings.getUseBridges()); - ui.listBridges->clear(); - ui.listBridges->addItems(settings.getBridgeList()); -} - diff -Nru vidalia-0.1.13/src/vidalia/config/NetworkPage.cpp vidalia-0.2.8/src/vidalia/config/NetworkPage.cpp --- vidalia-0.1.13/src/vidalia/config/NetworkPage.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/NetworkPage.cpp 2009-10-04 18:39:14.000000000 +0100 @@ -0,0 +1,481 @@ +/* +** 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.vidalia-project.net/. 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 NetworkPage.cpp +** \version $Id: NetworkPage.cpp 4141 2009-10-04 17:39:14Z edmanm $ +** \brief Network and firewall configuration options +*/ + +#include "NetworkPage.h" +#include "NetworkSettings.h" +#include "VMessageBox.h" +#include "Vidalia.h" +#include "BridgeDownloaderProgressDialog.h" +#include "DomainValidator.h" + +#include "stringutil.h" + +#include +#include +#include +#include +#include +#include + +#define IMG_COPY ":/images/22x22/edit-copy.png" + + +/** Constructor */ +NetworkPage::NetworkPage(QWidget *parent) +: ConfigPage(parent, "Network") +{ + /* Invoke the Qt Designer generated object setup routine */ + ui.setupUi(this); + + connect(ui.btnAddBridge, SIGNAL(clicked()), this, SLOT(addBridge())); + connect(ui.btnRemoveBridge, SIGNAL(clicked()), this, SLOT(removeBridge())); + connect(ui.btnCopyBridge, SIGNAL(clicked()), + this, SLOT(copySelectedBridgesToClipboard())); + connect(ui.listBridges, SIGNAL(customContextMenuRequested(QPoint)), + this, SLOT(bridgeContextMenuRequested(QPoint))); + connect(ui.listBridges, SIGNAL(itemSelectionChanged()), + this, SLOT(bridgeSelectionChanged())); + connect(ui.lineBridge, SIGNAL(returnPressed()), this, SLOT(addBridge())); + connect(ui.lblHelpFindBridges, SIGNAL(linkActivated(QString)), + this, SLOT(onLinkActivated(QString))); + connect(ui.btnFindBridges, SIGNAL(clicked()), this, SLOT(findBridges())); + connect(ui.cmboProxyType, SIGNAL(currentIndexChanged(int)), + this, SLOT(proxyTypeChanged(int))); + + ui.lineProxyAddress->setValidator(new DomainValidator(this)); + ui.lineProxyPort->setValidator(new QIntValidator(1, 65535, this)); + + vApp->createShortcut(QKeySequence(QKeySequence::Copy), + ui.listBridges, this, + SLOT(copySelectedBridgesToClipboard())); + + if (! BridgeDownloader::isMethodSupported(BridgeDownloader::DownloadMethodHttps)) { + ui.btnFindBridges->setVisible(false); + ui.lblHelpFindBridges->setText( + tr("How can I find bridges?")); + _bridgeDownloader = 0; + } else { + _bridgeDownloader = new BridgeDownloader(this); + connect(_bridgeDownloader, SIGNAL(bridgeRequestFinished(QStringList)), + this, SLOT(bridgeRequestFinished(QStringList))); + } + +#if defined(Q_WS_MAC) + /* On OS X, the network page looks better without frame titles. Everywhere + * else needs titles or else there's a break in the frame border. */ + ui.grpProxySettings->setTitle(""); + ui.grpFirewallSettings->setTitle(""); + ui.grpBridgeSettings->setTitle(""); +#endif +} + +/** Called when the user changes the UI translation. */ +void +NetworkPage::retranslateUi() +{ + ui.retranslateUi(this); +} + +/** Applies the network configuration settings to Tor. Returns true if the * + * settings were applied successfully. Otherwise, errmsg is set and * + * false is returned. */ +bool +NetworkPage::apply(QString &errmsg) +{ + return NetworkSettings(Vidalia::torControl()).apply(&errmsg); +} + +/** Returns true if the user has changed their server settings since the * + * last time they were applied to Tor. */ +bool +NetworkPage::changedSinceLastApply() +{ + return NetworkSettings(Vidalia::torControl()).changedSinceLastApply(); +} + +/** Reverts the server configuration settings to their values at the last * + * time they were successfully applied to Tor. */ +void +NetworkPage::revert() +{ + NetworkSettings settings(Vidalia::torControl()); + settings.revert(); +} + +/** Called when a link in a label is clicked. url is the target of + * the clicked link. */ +void +NetworkPage::onLinkActivated(const QString &url) +{ + emit helpRequested(url); +} + +/** Verifies that bridge is a valid bridge identifier and places a + * normalized identifier in out. The normalized identifier will have + * all spaces removed from the fingerprint portion (if any) and all + * hexadecimal characters converted to uppercase. Returns true if + * bridge is a valid bridge identifier, false otherwise. */ +bool +NetworkPage::validateBridge(const QString &bridge, QString *out) +{ + QString temp = bridge; + if (temp.startsWith("bridge ", Qt::CaseInsensitive)) + temp = temp.remove(0, 7); /* remove "bridge " */ + + QStringList parts = temp.split(" ", QString::SkipEmptyParts); + if (parts.isEmpty()) + return false; + + QString s = parts.at(0); + QRegExp re("(\\d{1,3}\\.){3}\\d{1,3}(:\\d{1,5})?"); + if (re.exactMatch(s)) { + if (s.endsWith(":")) + return false; + + int index = s.indexOf(":"); + QString host = s.mid(0, index); + if (QHostAddress(host).isNull() + || QHostAddress(host).protocol() != QAbstractSocket::IPv4Protocol) { + return false; + } + if (index > 0) { + QString port = s.mid(index + 1); + if (port.toUInt() < 1 || port.toUInt() > 65535) + return false; + } + + temp = s; + if (parts.size() > 1) { + QString fp = static_cast(parts.mid(1)).join(""); + if (fp.length() != 40 || !string_is_hex(fp)) + return false; + temp += " " + fp.toUpper(); + } + } else { + return false; + } + *out = temp; + return true; +} + +/** Adds a bridge to the bridge list box. */ +void +NetworkPage::addBridge() +{ + QString bridge; + QString input = ui.lineBridge->text().trimmed(); + + if (input.isEmpty()) + return; + if (!validateBridge(input, &bridge)) { + VMessageBox::warning(this, + tr("Invalid Bridge"), + tr("The specified bridge identifier is not valid."), + VMessageBox::Ok|VMessageBox::Default); + return; + } + if (!ui.listBridges->findItems(bridge, Qt::MatchFixedString).isEmpty()) + return; /* duplicate bridge */ + + ui.listBridges->addItem(bridge); + ui.lineBridge->clear(); +} + +/** Removes one or more selected bridges from the bridge list box. */ +void +NetworkPage::removeBridge() +{ + qDeleteAll(ui.listBridges->selectedItems()); +} + +/** Copies all selected bridges to the clipboard. */ +void +NetworkPage::copySelectedBridgesToClipboard() +{ + QString contents; + + foreach (QListWidgetItem *item, ui.listBridges->selectedItems()) { +#if defined(Q_WS_WIN) + contents += item->text() + "\r\n"; +#else + contents += item->text() + "\n"; +#endif + } + if (!contents.isEmpty()) + vApp->clipboard()->setText(contents.trimmed()); +} + +/** Called when the user right-clicks on a bridge and displays a context + * menu. */ +void +NetworkPage::bridgeContextMenuRequested(const QPoint &pos) +{ + QMenu menu(this); + + QListWidgetItem *item = ui.listBridges->itemAt(pos); + if (!item) + return; + + QAction *copyAction = + new QAction(QIcon(IMG_COPY), tr("Copy (Ctrl+C)"), &menu); + connect(copyAction, SIGNAL(triggered()), + this, SLOT(copySelectedBridgesToClipboard())); + + menu.addAction(copyAction); + menu.exec(ui.listBridges->mapToGlobal(pos)); +} + +/** Called when the user changes which bridges they have selected. */ +void +NetworkPage::bridgeSelectionChanged() +{ + bool enabled = !ui.listBridges->selectedItems().isEmpty(); + ui.btnCopyBridge->setEnabled(enabled); + ui.btnRemoveBridge->setEnabled(enabled); +} + +/** Saves changes made to settings on the Firewall settings page. */ +bool +NetworkPage::save(QString &errmsg) +{ + NetworkSettings settings(Vidalia::torControl()); + QString addr; + QString user, pass; + NetworkSettings::ProxyType proxy = NetworkSettings::NoProxy; + QStringList bridgeList; + QList reachablePorts; + bool ok; + + if (ui.chkUseProxy->isChecked()) { + if (ui.lineProxyAddress->text().isEmpty() + || ui.lineProxyPort->text().isEmpty()) { + errmsg = tr("You must specify both an IP address or hostname and a " + "port number to configure Tor to use a proxy to access " + "the Internet."); + return false; + } + if (ui.cmboProxyType->currentIndex() < 0) { + errmsg = tr("You must select the proxy type."); + return false; + } + } + if (ui.chkFascistFirewall->isChecked() + && ui.lineReachablePorts->text().isEmpty()) { + errmsg = tr("You must specify one or more ports to which your " + "firewall allows you to connect."); + return false; + } + + if (ui.chkUseProxy->isChecked()) { + if (!ui.lineProxyAddress->text().isEmpty()) { + addr = ui.lineProxyAddress->text(); + if (!ui.lineProxyPort->text().isEmpty()) + addr += ":" + ui.lineProxyPort->text(); + } + + user = ui.lineProxyUsername->text(); + pass = ui.lineProxyPassword->text(); + + QVariant data; + int type; + + data = ui.cmboProxyType->itemData(ui.cmboProxyType->currentIndex()); + Q_ASSERT(data.isValid()); + type = data.toInt(); + Q_ASSERT(type >= NetworkSettings::ProxyTypeMin && + type <= NetworkSettings::ProxyTypeMax); + proxy = static_cast(type); + } + + settings.setProxyType(proxy); + settings.setProxyAddress(addr); + settings.setProxyUsername(user); + settings.setProxyPassword(pass); + + /* Save the reachable port settings */ + settings.setFascistFirewall(ui.chkFascistFirewall->isChecked()); + foreach (QString portString, + ui.lineReachablePorts->text().split(",", QString::SkipEmptyParts)) { + quint32 port = portString.toUInt(&ok); + if (!ok || port < 1 || port > 65535) { + errmsg = tr("'%1' is not a valid port number.").arg(portString); + return false; + } + reachablePorts << (quint16)port; + } + settings.setReachablePorts(reachablePorts); + + /* Save the bridge settings */ + settings.setUseBridges(ui.chkUseBridges->isChecked()); + for (int i = 0; i < ui.listBridges->count(); i++) + bridgeList << ui.listBridges->item(i)->text(); + settings.setBridgeList(bridgeList); + + return true; +} + +/** Loads previously saved settings */ +void +NetworkPage::load() +{ + NetworkSettings settings(Vidalia::torControl()); + QStringList reachablePortStrings; + NetworkSettings::ProxyType proxyType; + + /* Load proxy settings */ + proxyType = settings.getProxyType(); + ui.chkUseProxy->setChecked(proxyType != NetworkSettings::NoProxy); + QStringList proxy = settings.getProxyAddress().split(":"); + if (proxy.size() >= 1) + ui.lineProxyAddress->setText(proxy.at(0)); + if (proxy.size() >= 2) + ui.lineProxyPort->setText(proxy.at(1)); + ui.lineProxyUsername->setText(settings.getProxyUsername()); + ui.lineProxyPassword->setText(settings.getProxyPassword()); + + /* SOCKS options are only available on Tor >= 0.2.2.1-alpha, so don't show + * them if Tor is running and its version is less than that. */ + ui.cmboProxyType->clear(); + if (!vApp->torControl()->isRunning() + || vApp->torControl()->getTorVersion() >= 0x020201) { + ui.cmboProxyType->addItem(tr("SOCKS 4"), NetworkSettings::Socks4Proxy); + ui.cmboProxyType->addItem(tr("SOCKS 5"), NetworkSettings::Socks5Proxy); + } else if (proxyType == NetworkSettings::Socks4Proxy + || proxyType == NetworkSettings::Socks5Proxy) { + /* Disable proxy if the settings include a SOCKS proxy and our version of + * Tor is not compatible. */ + proxyType = NetworkSettings::NoProxy; + ui.chkUseProxy->setChecked(false); + } + ui.cmboProxyType->addItem(tr("HTTP"), NetworkSettings::HttpProxy); + ui.cmboProxyType->addItem(tr("HTTP / HTTPS"), + NetworkSettings::HttpHttpsProxy); + + ui.cmboProxyType->setCurrentIndex(ui.cmboProxyType->findData(proxyType)); + + /* Load firewall settings */ + ui.chkFascistFirewall->setChecked(settings.getFascistFirewall()); + QList reachablePorts = settings.getReachablePorts(); + foreach (quint16 port, reachablePorts) { + reachablePortStrings << QString::number(port); + } + ui.lineReachablePorts->setText(reachablePortStrings.join(",")); + + /* Load bridge settings */ + ui.chkUseBridges->setChecked(settings.getUseBridges()); + ui.listBridges->clear(); + ui.listBridges->addItems(settings.getBridgeList()); +} + +/** Called when the user clicks the "Find Bridges Now" button. + * Attempts to establish an HTTPS connection to bridges.torproject.org + * and download one or more bridge addresses. */ +void +NetworkPage::findBridges() +{ + BridgeDownloaderProgressDialog *dlg = new BridgeDownloaderProgressDialog(this); + + connect(_bridgeDownloader, SIGNAL(statusChanged(QString)), + dlg, SLOT(setStatus(QString))); + connect(_bridgeDownloader, SIGNAL(downloadProgress(int, int)), + dlg, SLOT(setDownloadProgress(int, int))); + connect(_bridgeDownloader, SIGNAL(bridgeRequestFailed(QString)), + dlg, SLOT(bridgeRequestFailed(QString))); + connect(_bridgeDownloader, SIGNAL(bridgeRequestFinished(QStringList)), + dlg, SLOT(bridgeRequestFinished(QStringList))); + connect(dlg, SIGNAL(retry()), this, SLOT(startBridgeRequest())); + + startBridgeRequest(); + switch (dlg->exec()) { + case QDialogButtonBox::Cancel: + _bridgeDownloader->cancelBridgeRequest(); + break; + + case QDialogButtonBox::Help: + emit helpRequested("bridges.finding"); + break; + } + + delete dlg; +} + +/** Starts a new request for additional bridge addresses. */ +void +NetworkPage::startBridgeRequest() +{ + if (ui.chkUseProxy->isChecked() && + ui.cmboProxyType->currentIndex() == NetworkSettings::HttpHttpsProxy) { + _bridgeDownloader->setProxy(ui.lineProxyAddress->text(), + ui.lineProxyPort->text().toUInt(), + ui.lineProxyUsername->text(), + ui.lineProxyPassword->text()); + } + + _bridgeDownloader->downloadBridges(BridgeDownloader::DownloadMethodHttps); +} + +/** Called when a previous bridge request initiated by the findBridges() + * method has completed. bridges contains a list of all bridges + * received. */ +void +NetworkPage::bridgeRequestFinished(const QStringList &bridges) +{ + bool foundNewBridges = false; + QString normalized; + + foreach (QString bridge, bridges) { + if (! validateBridge(bridge, &normalized)) + continue; + + QString address = normalized.split(" ").at(0); + if (ui.listBridges->findItems(address, Qt::MatchContains).isEmpty()) { + ui.listBridges->addItem(normalized); + foundNewBridges = true; + } + } + + if (! foundNewBridges) { + QMessageBox dlg(this); + dlg.setIcon(QMessageBox::Information); + dlg.setText(tr("No new bridges are currently available. You can either " + "wait a while and try again, or try another method of " + "finding new bridges.")); + dlg.setInformativeText(tr("Click Help to see other methods of finding " + "new bridges.")); + dlg.setStandardButtons(QMessageBox::Ok | QMessageBox::Help); + + if (dlg.exec() == QMessageBox::Help) + emit helpRequested("bridges.finding"); + } +} + +/** Disable proxy username and password fields when the user wants to use + * a SOCKS 4 proxy. */ +void +NetworkPage::proxyTypeChanged(int selection) +{ + QVariant data = ui.cmboProxyType->itemData(selection); + + if (data.isValid() + && data.toInt() == NetworkSettings::Socks4Proxy) { + ui.lineProxyUsername->setEnabled(false); + ui.lineProxyPassword->setEnabled(false); + } else { + ui.lineProxyUsername->setEnabled(true); + ui.lineProxyPassword->setEnabled(true); + } +} + diff -Nru vidalia-0.1.13/src/vidalia/config/networkpage.h vidalia-0.2.8/src/vidalia/config/networkpage.h --- vidalia-0.1.13/src/vidalia/config/networkpage.h 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/networkpage.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,88 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 networkpage.h -** \version $Id: networkpage.h 2362 2008-02-29 04:30:11Z edmanm $ -** \brief Network and firewall configuration options -*/ - -#ifndef _NETWORKPAGE_H -#define _NETWORKPAGE_H - -#include -#include - -#include "configpage.h" -#include "ui_networkpage.h" - - -class NetworkPage : public ConfigPage -{ - Q_OBJECT - -public: - /** Default Constructor */ - NetworkPage(QWidget *parent = 0); - - /** Saves the changes on this page */ - bool save(QString &errmsg); - /** Loads the settings for this page */ - void load(); - - /** Applies the network configuration settings to Tor. Returns true if the - * settings were applied successfully. Otherwise, errmsg is set and - * false is returned. */ - bool apply(QString &errmsg); - /** Reverts the server configuration settings to their values at the last - * time they were successfully applied to Tor. */ - void revert(); - /** Returns true if the user has changed their server settings since the - * last time they were applied to Tor. */ - bool changedSinceLastApply(); - -private slots: - /** Adds a bridge to the bridge list box. */ - void addBridge(); - /** Removes one or more selected bridges from the bridge list box. */ - void removeBridge(); - /** Copies all selected bridges to the clipboard. */ - void copySelectedBridgesToClipboard(); - /** Called when the user right-clicks on a bridge and displays a context - * menu. */ - void bridgeContextMenuRequested(const QPoint &pos); - /** Called when the user changes which bridges they have selected. */ - void bridgeSelectionChanged(); - /** Called when Vidalia has connected and authenticated to Tor. This will - * check Tor's version number and, if it's too old, will disable the bridge - * settings UI and show a message indicating the user's Tor is too old. */ - void onAuthenticated(); - /** Called when Vidalia disconnects from Tor. This will reenable the bridge - * settings (if they were previously disabled) and hide the warning message - * indicating the user's Tor does not support bridges. */ - void onDisconnected(); - /** Called when a link in a label is clicked. url is the target of - * the clicked link.*/ - void onLinkActivated(const QString &url); - -private: - /** Verifies that bridge is a valid bridge identifier and places a - * normalized identifier in out. The normalized identifier will have - * all spaces removed from the fingerprint portion (if any) and all - * hexadecimal characters converted to uppercase. Returns true if - * bridge is a valid bridge identifier, false otherwise. */ - bool validateBridge(const QString &bridge, QString *out); - - /** Qt Designer generated object */ - Ui::NetworkPage ui; -}; - -#endif - diff -Nru vidalia-0.1.13/src/vidalia/config/NetworkPage.h vidalia-0.2.8/src/vidalia/config/NetworkPage.h --- vidalia-0.1.13/src/vidalia/config/NetworkPage.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/NetworkPage.h 2009-10-03 22:49:21.000000000 +0100 @@ -0,0 +1,101 @@ +/* +** 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.vidalia-project.net/. 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 NetworkPage.h +** \version $Id: NetworkPage.h 4140 2009-10-03 21:49:21Z edmanm $ +** \brief Network and firewall configuration options +*/ + +#ifndef _NETWORKPAGE_H +#define _NETWORKPAGE_H + +#include "ui_NetworkPage.h" +#include "ConfigPage.h" +#include "Vidalia.h" +#include "BridgeDownloader.h" + +#include + + +class NetworkPage : public ConfigPage +{ + Q_OBJECT + +public: + /** Default Constructor */ + NetworkPage(QWidget *parent = 0); + + /** Saves the changes on this page */ + bool save(QString &errmsg); + /** Loads the settings for this page */ + void load(); + + /** Applies the network configuration settings to Tor. Returns true if the + * settings were applied successfully. Otherwise, errmsg is set and + * false is returned. */ + bool apply(QString &errmsg); + /** Reverts the server configuration settings to their values at the last + * time they were successfully applied to Tor. */ + void revert(); + /** Returns true if the user has changed their server settings since the + * last time they were applied to Tor. */ + bool changedSinceLastApply(); + /** Called when the user changes the UI translation. */ + virtual void retranslateUi(); + +private slots: + /** Adds a bridge to the bridge list box. */ + void addBridge(); + /** Removes one or more selected bridges from the bridge list box. */ + void removeBridge(); + /** Copies all selected bridges to the clipboard. */ + void copySelectedBridgesToClipboard(); + /** Called when the user right-clicks on a bridge and displays a context + * menu. */ + void bridgeContextMenuRequested(const QPoint &pos); + /** Called when the user changes which bridges they have selected. */ + void bridgeSelectionChanged(); + /** Called when a link in a label is clicked. url is the target of + * the clicked link.*/ + void onLinkActivated(const QString &url); + /** Called when the user clicks the "Find Bridges Now" button. Calls + * startBridgeRequest() to start a new request for additional bridge + * addresses, and displays a progress dialog for the user. */ + void findBridges(); + /** Starts a new request for additional bridge addresses. */ + void startBridgeRequest(); + /** Called when a previous bridge request initiated by the findBridges() + * method has completed. bridges contains a list of all bridges + * received. */ + void bridgeRequestFinished(const QStringList &bridges); + + /** Disable proxy username and password fields when the user wants to use + * a SOCKS 4 proxy. */ + void proxyTypeChanged(int selection); + +private: + /** Verifies that bridge is a valid bridge identifier and places a + * normalized identifier in out. The normalized identifier will have + * all spaces removed from the fingerprint portion (if any) and all + * hexadecimal characters converted to uppercase. Returns true if + * bridge is a valid bridge identifier, false otherwise. */ + bool validateBridge(const QString &bridge, QString *out); + + /** Helper class used to facilitate downloading one or more bridge + * addresses. */ + BridgeDownloader* _bridgeDownloader; + + /** Qt Designer generated object */ + Ui::NetworkPage ui; +}; + +#endif + diff -Nru vidalia-0.1.13/src/vidalia/config/networkpage.ui vidalia-0.2.8/src/vidalia/config/networkpage.ui --- vidalia-0.1.13/src/vidalia/config/networkpage.ui 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/networkpage.ui 1970-01-01 01:00:00.000000000 +0100 @@ -1,513 +0,0 @@ - - NetworkPage - - - - 0 - 0 - 568 - 539 - - - - Qt::NoContextMenu - - - - 9 - - - 6 - - - - - Check if your local network requires a proxy to access the Internet - - - I use a proxy to access the Internet - - - true - - - - - - - - 5 - 1 - 0 - 0 - - - - - 0 - 136 - - - - - 16777215 - 136 - - - - Proxy Settings - - - - 9 - - - 6 - - - - - HTTP Proxy: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Username: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Use this proxy for HTTPS also - - - - - - - 0 - - - 6 - - - - - - - - Password: - - - - - - - QLineEdit::Password - - - - - - - - - 0 - - - 6 - - - - - - - - Port: - - - - - - - - 75 - 16777215 - - - - 5 - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - Qt::NoContextMenu - - - Check to only connect to relays using ports allowed by your firewall - - - My firewall only lets me connect to certain ports - - - true - - - - - - - - 5 - 1 - 0 - 0 - - - - - 0 - 75 - - - - Firewall Settings - - - - 9 - - - 6 - - - - - Allowed Ports: - - - - - - - - - - 80, 443 - - - - - - - - - - Check to encrypt directory requests and, optionally, use bridge relays to access the Tor network - - - My ISP blocks connections to the Tor network - - - true - - - - - - - - 5 - 5 - 0 - 0 - - - - - 0 - 200 - - - - Bridge Settings - - - - 9 - - - 6 - - - - - The Tor software you are currently running does not support bridges. <br>Directory connections will still be encrypted. - - - Qt::AlignCenter - - - true - - - - - - - 0 - - - 6 - - - - - Add a Bridge: - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - 13 - - - <a href="bridges.finding">How do I find a bridge?</a> - - - - - - - - - 0 - - - 6 - - - - - 0 - - - 6 - - - - - 100 - - - - - - - Qt::CustomContextMenu - - - QAbstractItemView::ExtendedSelection - - - - - - - - - 0 - - - 6 - - - - - - - - :/images/22x22/list-add.png - - - - - - - false - - - Remove the selected bridges from the list - - - - - - :/images/22x22/list-remove.png - - - - - - - false - - - Copy the selected bridges to the clipboard - - - - - - :/images/22x22/edit-copy.png - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - chkUseProxy - lineHttpProxyAddress - lineHttpProxyPort - lineHttpProxyUsername - lineHttpProxyPassword - chkProxyUseHttps - chkFascistFirewall - lineReachablePorts - chkUseBridges - lineBridge - btnAddBridge - btnRemoveBridge - btnCopyBridge - listBridges - - - - - - - chkFascistFirewall - toggled(bool) - grpFirewallSettings - setVisible(bool) - - - 222 - 21 - - - 222 - 82 - - - - - chkUseProxy - toggled(bool) - grpProxySettings - setVisible(bool) - - - 222 - 143 - - - 222 - 216 - - - - - chkUseBridges - toggled(bool) - grpBridgeSettings - setVisible(bool) - - - 283 - 302 - - - 283 - 419 - - - - - diff -Nru vidalia-0.1.13/src/vidalia/config/NetworkPage.ui vidalia-0.2.8/src/vidalia/config/NetworkPage.ui --- vidalia-0.1.13/src/vidalia/config/NetworkPage.ui 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/NetworkPage.ui 2009-10-03 22:49:21.000000000 +0100 @@ -0,0 +1,527 @@ + + + NetworkPage + + + + 0 + 0 + 616 + 659 + + + + Qt::NoContextMenu + + + + 6 + + + 9 + + + + + Check if your local network requires a proxy to access the Internet + + + I use a proxy to access the Internet + + + true + + + + + + + + 0 + 0 + + + + + 0 + 136 + + + + + 16777215 + 136 + + + + Proxy Settings + + + + 9 + + + 6 + + + + + Address: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + 6 + + + 0 + + + + + + + + Port: + + + + + + + + 75 + 16777215 + + + + 5 + + + + + + + + + Username: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + 6 + + + 0 + + + + + + + + Password: + + + + + + + QLineEdit::Password + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Type: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + + Qt::NoContextMenu + + + Check to only connect to relays using ports allowed by your firewall + + + My firewall only lets me connect to certain ports + + + true + + + + + + + + 0 + 0 + + + + + 0 + 75 + + + + Firewall Settings + + + + 6 + + + 9 + + + + + Allowed Ports: + + + + + + + + + + 80, 443 + + + + + + + + + + Check to encrypt directory requests and, optionally, use bridge relays to access the Tor network + + + My ISP blocks connections to the Tor network + + + true + + + + + + + + 0 + 0 + + + + + 0 + 200 + + + + Bridge Settings + + + + 6 + + + 9 + + + + + 6 + + + 0 + + + + + Add a Bridge: + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + 6 + + + 0 + + + + + 6 + + + 0 + + + + + 100 + + + + + + + Qt::CustomContextMenu + + + QAbstractItemView::ExtendedSelection + + + + + + + + + 6 + + + 0 + + + + + + + + + :/images/22x22/list-add.png:/images/22x22/list-add.png + + + + + + + false + + + Remove the selected bridges from the list + + + + + + + :/images/22x22/list-remove.png:/images/22x22/list-remove.png + + + + + + + false + + + Copy the selected bridges to the clipboard + + + + + + + :/images/22x22/edit-copy.png:/images/22x22/edit-copy.png + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + Find Bridges Now + + + + + + + PointingHandCursor + + + <a href="bridges.finding">How else can I find bridges?</a> + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + chkUseProxy + lineProxyAddress + lineProxyPort + lineProxyUsername + lineProxyPassword + chkFascistFirewall + lineReachablePorts + chkUseBridges + lineBridge + btnAddBridge + btnRemoveBridge + btnCopyBridge + listBridges + + + + + + + chkFascistFirewall + toggled(bool) + grpFirewallSettings + setVisible(bool) + + + 222 + 21 + + + 222 + 82 + + + + + chkUseProxy + toggled(bool) + grpProxySettings + setVisible(bool) + + + 222 + 143 + + + 222 + 216 + + + + + chkUseBridges + toggled(bool) + grpBridgeSettings + setVisible(bool) + + + 283 + 302 + + + 283 + 419 + + + + + diff -Nru vidalia-0.1.13/src/vidalia/config/networksettings.cpp vidalia-0.2.8/src/vidalia/config/networksettings.cpp --- vidalia-0.1.13/src/vidalia/config/networksettings.cpp 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/networksettings.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,301 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 networksettings.cpp -** \version $Id: networksettings.cpp 3299 2008-11-15 02:59:57Z edmanm $ -** \brief Settings for configuring an HTTP/HTTPS proxy or bridges -*/ - -#include "networksettings.h" - -#define SETTING_FASCIST_FIREWALL "FascistFirewall" -#define SETTING_REACHABLE_ADDRESSES "ReachableAddresses" -#define SETTING_USE_HTTP_PROXY "UseHttpProxy" -#define SETTING_HTTP_PROXY "HttpProxy" -#define SETTING_HTTP_PROXY_AUTH "HttpProxyAuthenticator" -#define SETTING_USE_HTTPS_PROXY "UseHttpsProxy" -#define SETTING_HTTPS_PROXY "HttpsProxy" -#define SETTING_HTTPS_PROXY_AUTH "HttpsProxyAuthenticator" -#define SETTING_USE_BRIDGES "UseBridges" -#define SETTING_BRIDGE_LIST "Bridge" -#define SETTING_UPDATE_BRIDGES "UpdateBridgesFromAuthority" -#define SETTING_TUNNEL_DIR_CONNS "TunnelDirConns" -#define SETTING_PREFER_TUNNELED_DIR_CONNS "PreferTunneledDirConns" - - -/** Default constructor */ -NetworkSettings::NetworkSettings(TorControl *torControl) -: AbstractTorSettings("Network", torControl) -{ - setDefault(SETTING_USE_HTTP_PROXY, false); - setDefault(SETTING_HTTP_PROXY, ""); - setDefault(SETTING_HTTP_PROXY_AUTH, ""); - setDefault(SETTING_USE_HTTPS_PROXY, true); - setDefault(SETTING_HTTPS_PROXY, ""); - setDefault(SETTING_HTTPS_PROXY_AUTH, ""); - setDefault(SETTING_USE_BRIDGES, false); - setDefault(SETTING_BRIDGE_LIST, QStringList()); - setDefault(SETTING_FASCIST_FIREWALL, false); - setDefault(SETTING_TUNNEL_DIR_CONNS, true); - setDefault(SETTING_REACHABLE_ADDRESSES, - QStringList() << "*:80" << "*:443"); -} - -/** Applies the current network configuration settings to Tor. If - * errmsg is specified and an error occurs while applying the settings, - * it will be set to a string describing the error. */ -bool -NetworkSettings::apply(QString *errmsg) -{ - QMultiHash conf; - quint32 torVersion = torControl()->getTorVersion(); - - conf.insert(SETTING_REACHABLE_ADDRESSES, - (getFascistFirewall() ? - localValue(SETTING_REACHABLE_ADDRESSES).toStringList().join(",") : "")); - - if (getUseHttpProxy()) - conf.insert(SETTING_HTTP_PROXY, localValue(SETTING_HTTP_PROXY).toString()); - else - conf.insert(SETTING_HTTP_PROXY, ""); - conf.insert(SETTING_HTTP_PROXY_AUTH, - localValue(SETTING_HTTP_PROXY_AUTH).toString()); - - if (getUseHttpProxy() && getUseHttpsProxy()) - conf.insert(SETTING_HTTPS_PROXY, localValue(SETTING_HTTPS_PROXY).toString()); - else - conf.insert(SETTING_HTTPS_PROXY, ""); - conf.insert(SETTING_HTTPS_PROXY_AUTH, - localValue(SETTING_HTTPS_PROXY_AUTH).toString()); - - if (getUseBridges()) { - /* We want to always enable TunnelDirConns and friends when using - * bridge relays. */ - conf.insert(SETTING_TUNNEL_DIR_CONNS, "1"); - conf.insert(SETTING_PREFER_TUNNELED_DIR_CONNS, "1"); - } else if (torVersion <= 0x020021) { - /* TunnelDirConns is enabled by default on Tor >= 0.2.0.22-rc, so don't - * disable it if our Tor is recent enough. */ - conf.insert(SETTING_TUNNEL_DIR_CONNS, "0"); - conf.insert(SETTING_PREFER_TUNNELED_DIR_CONNS, "0"); - } - - if (torVersion >= 0x020003) { - /* Do the bridge stuff only on Tor >= 0.2.0.3-alpha */ - QStringList bridges = localValue(SETTING_BRIDGE_LIST).toStringList(); - if (getUseBridges() && !bridges.isEmpty()) { - conf.insert(SETTING_USE_BRIDGES, "1"); - conf.insert(SETTING_UPDATE_BRIDGES, "1"); - foreach (QString bridge, bridges) { - conf.insert(SETTING_BRIDGE_LIST, bridge); - } - } else { - conf.insert(SETTING_USE_BRIDGES, "0"); - conf.insert(SETTING_BRIDGE_LIST, ""); - conf.insert(SETTING_UPDATE_BRIDGES, "0"); - } - } - return torControl()->setConf(conf, errmsg); -} - -/** Returns true if we need to set ReachableAddresses because we're behind a - * restrictive firewall that limits the ports Tor can connect to. */ -bool -NetworkSettings::getFascistFirewall() -{ - return localValue(SETTING_FASCIST_FIREWALL).toBool(); -} - -/** Sets to fascistFirewall whether Tor should only create outgoing - * connections to the list of ports specified in setReachablePorts(). - * \sa setReachablePorts() */ -void -NetworkSettings::setFascistFirewall(bool fascistFirewall) -{ - setValue(SETTING_FASCIST_FIREWALL, fascistFirewall); -} - -/** Returns a list of ports to be specified in ReachableAddresses. */ -QList -NetworkSettings::getReachablePorts() -{ - QList reachablePorts; - QStringList lineList; - bool ok; - - lineList = value(SETTING_REACHABLE_ADDRESSES).toStringList(); - foreach (QString line, lineList) { - foreach (QString address, line.split(",", QString::SkipEmptyParts)) { - QStringList parts = address.split(":"); - if (parts.size() >= 2) { - quint16 port = parts.at(1).toUInt(&ok); - if (ok) - reachablePorts << port; - } - } - } - return reachablePorts; -} - -/** Sets the list of ports that will be specified in ReachableAddresses to - * reachablePorts. */ -void -NetworkSettings::setReachablePorts(const QList &reachablePorts) -{ - if (!reachablePorts.isEmpty()) { - QStringList portList; - foreach (quint16 port, reachablePorts) { - portList << "*:" + QString::number(port); - } - setValue(SETTING_REACHABLE_ADDRESSES, portList); - } -} - -/** Returns true if Tor should make all its directory requests through a - * proxy. */ -bool -NetworkSettings::getUseHttpProxy() -{ - return localValue(SETTING_USE_HTTP_PROXY).toBool(); -} - -/** Sets to useHttpProxy whether Tor should make all its directory - * requests through the proxy specified to setHttpProxy(). - * \sa setHttpProxy() */ -void -NetworkSettings::setUseHttpProxy(bool useHttpProxy) -{ - setValue(SETTING_USE_HTTP_PROXY, useHttpProxy); -} - -/** Returns the proxy used for making Tor's directory requests, in the form - * of host[:port]. */ -QString -NetworkSettings::getHttpProxy() -{ - return value(SETTING_HTTP_PROXY).toString(); -} - -/** Sets the proxy used for making Tor's directory requests. proxy - * should be in the form host[:port]. If :port is not - * specified, then Tor will use its default of port 80. */ -void -NetworkSettings::setHttpProxy(const QString &proxy) -{ - setValue(SETTING_HTTP_PROXY, proxy); -} - -/** Returns the authentication information Tor should use to authenticate to - * an Http proxy. The returned value is in the form - * username:password. */ -QString -NetworkSettings::getHttpProxyAuthenticator() -{ - return value(SETTING_HTTP_PROXY_AUTH).toString(); -} - -/** Sets the authentication information required by an Http proxy. - * authenticator should be in the form username:password. */ -void -NetworkSettings::setHttpProxyAuthenticator(const QString &auth) -{ - setValue(SETTING_HTTP_PROXY_AUTH, auth); -} - -/** Returns true if Tor should make all its OR connections through a - * proxy. */ -bool -NetworkSettings::getUseHttpsProxy() -{ - return localValue(SETTING_USE_HTTPS_PROXY).toBool(); -} - -/** Sets to useHttpsProxy whether Tor should make all its OR - * connections through the proxy specified to setHttpsProxy(). - * \sa setHttpsProxy() */ -void -NetworkSettings::setUseHttpsProxy(bool useHttpsProxy) -{ - setValue(SETTING_USE_HTTPS_PROXY, useHttpsProxy); -} - -/** Returns the proxy used for making Tor's OR connections, in the form - * of host[:port]. */ -QString -NetworkSettings::getHttpsProxy() -{ - return value(SETTING_HTTPS_PROXY).toString(); -} - -/** Sets the proxy used for making Tor's OR connections. proxy - * should be in the form host[:port]. If :port is not - * specified, then Tor will use its default of port 443. */ -void -NetworkSettings::setHttpsProxy(const QString &proxy) -{ - setValue(SETTING_HTTPS_PROXY, proxy); -} - -/** Returns the authentication information Tor should use to authenticate to - * an Https proxy. The returned value is in the form - * username:password. */ -QString -NetworkSettings::getHttpsProxyAuthenticator() -{ - return value(SETTING_HTTPS_PROXY_AUTH).toString(); -} - -/** Sets the authentication information required by an Https proxy. - * authenticator should be in the form username:password. */ -void -NetworkSettings::setHttpsProxyAuthenticator(const QString &auth) -{ - setValue(SETTING_HTTPS_PROXY_AUTH, auth); -} - -/** Returns true if Tor should try to use bridge nodes to access the Tor - * network. */ -bool -NetworkSettings::getUseBridges() -{ - return value(SETTING_USE_BRIDGES).toBool(); -} - -/** Sets to useBridges whether Tor should try to use bridge nodes - * to access the Tor network. */ -void -NetworkSettings::setUseBridges(bool useBridges) -{ - setValue(SETTING_USE_BRIDGES, useBridges); -} - -/** Returns a list of bridge nodes Tor should use. */ -QStringList -NetworkSettings::getBridgeList() -{ - return value(SETTING_BRIDGE_LIST).toStringList(); -} - -/** Sets to bridgeList the list of bridge nodes Tor should use. */ -void -NetworkSettings::setBridgeList(const QStringList &bridgeList) -{ - setValue(SETTING_BRIDGE_LIST, bridgeList); -} - -/** Returns true if Tor is configured to try to tunnel its directory - * connections through a one-hop circuit. */ -bool -NetworkSettings::getTunnelDirConns() -{ - return value(SETTING_TUNNEL_DIR_CONNS).toBool(); -} - diff -Nru vidalia-0.1.13/src/vidalia/config/NetworkSettings.cpp vidalia-0.2.8/src/vidalia/config/NetworkSettings.cpp --- vidalia-0.1.13/src/vidalia/config/NetworkSettings.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/NetworkSettings.cpp 2009-10-03 22:49:21.000000000 +0100 @@ -0,0 +1,340 @@ +/* +** 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.vidalia-project.net/. 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 NetworkSettings.cpp +** \version $Id: NetworkSettings.cpp 4140 2009-10-03 21:49:21Z edmanm $ +** \brief Settings for configuring an HTTP/HTTPS proxy or bridges +*/ + +#include "NetworkSettings.h" + +#define SETTING_FASCIST_FIREWALL "FascistFirewall" +#define SETTING_REACHABLE_ADDRESSES "ReachableAddresses" + +/* Vidalia-specific proxy options */ +#define SETTING_PROXY_TYPE "ProxyType" +#define SETTING_PROXY_ADDRESS "ProxyAddress" +#define SETTING_PROXY_USERNAME "ProxyUsername" +#define SETTING_PROXY_PASSWORD "ProxyPassword" + +/* Tor's proxy options */ +#define SETTING_HTTP_PROXY "HttpProxy" +#define SETTING_HTTP_PROXY_AUTH "HttpProxyAuthenticator" +#define SETTING_HTTPS_PROXY "HttpsProxy" +#define SETTING_HTTPS_PROXY_AUTH "HttpsProxyAuthenticator" +#define SETTING_SOCKS4_PROXY "Socks4Proxy" +#define SETTING_SOCKS5_PROXY "Socks5Proxy" +#define SETTING_SOCKS5_USERNAME "Socks5ProxyUsername" +#define SETTING_SOCKS5_PASSWORD "Socks5ProxyPassword" + +#define SETTING_USE_BRIDGES "UseBridges" +#define SETTING_BRIDGE_LIST "Bridge" +#define SETTING_UPDATE_BRIDGES "UpdateBridgesFromAuthority" +#define SETTING_TUNNEL_DIR_CONNS "TunnelDirConns" +#define SETTING_PREFER_TUNNELED_DIR_CONNS "PreferTunneledDirConns" + + +/** Default constructor */ +NetworkSettings::NetworkSettings(TorControl *torControl) +: AbstractTorSettings("Network", torControl) +{ + setDefault(SETTING_PROXY_TYPE, NoProxy); + setDefault(SETTING_PROXY_ADDRESS, ""); + setDefault(SETTING_PROXY_USERNAME, ""); + setDefault(SETTING_PROXY_PASSWORD, ""); + setDefault(SETTING_USE_BRIDGES, false); + setDefault(SETTING_BRIDGE_LIST, QStringList()); + setDefault(SETTING_FASCIST_FIREWALL, false); + setDefault(SETTING_TUNNEL_DIR_CONNS, true); + setDefault(SETTING_REACHABLE_ADDRESSES, + QStringList() << "*:80" << "*:443"); +} + +/** Applies the current network configuration settings to Tor. If + * errmsg is specified and an error occurs while applying the settings, + * it will be set to a string describing the error. */ +bool +NetworkSettings::apply(QString *errmsg) +{ + QMultiHash conf; + quint32 torVersion = torControl()->getTorVersion(); + + conf.insert(SETTING_REACHABLE_ADDRESSES, + (getFascistFirewall() ? + localValue(SETTING_REACHABLE_ADDRESSES).toStringList().join(",") : "")); + + QString socks4, socks5, http, https; + QString addr, user, pass, auth; + + addr = localValue(SETTING_PROXY_ADDRESS).toString(); + user = localValue(SETTING_PROXY_USERNAME).toString(); + pass = localValue(SETTING_PROXY_PASSWORD).toString(); + + if (!user.isEmpty() || !pass.isEmpty()) + auth = QString("%1:%2").arg(user).arg(pass); + + switch (getProxyType()) { + case NoProxy: + break; + case Socks4Proxy: + socks4 = addr; + break; + case Socks5Proxy: + socks5 = addr; + break; + case HttpProxy: + http = addr; + break; + case HttpHttpsProxy: + http = addr; + https = http; + break; + } + + if (torVersion >= 0x020201) { + /* SOCKS support was implemented in 0.2.2.1 */ + conf.insert(SETTING_SOCKS4_PROXY, socks4); + conf.insert(SETTING_SOCKS5_PROXY, socks5); + conf.insert(SETTING_SOCKS5_USERNAME, user); + conf.insert(SETTING_SOCKS5_PASSWORD, pass); + } + + conf.insert(SETTING_HTTP_PROXY, http); + conf.insert(SETTING_HTTPS_PROXY, https); + conf.insert(SETTING_HTTP_PROXY_AUTH, auth); + conf.insert(SETTING_HTTPS_PROXY_AUTH, auth); + + if (getUseBridges()) { + /* We want to always enable TunnelDirConns and friends when using + * bridge relays. */ + conf.insert(SETTING_TUNNEL_DIR_CONNS, "1"); + conf.insert(SETTING_PREFER_TUNNELED_DIR_CONNS, "1"); + } else if (torVersion <= 0x020021) { + /* TunnelDirConns is enabled by default on Tor >= 0.2.0.22-rc, so don't + * disable it if our Tor is recent enough. */ + conf.insert(SETTING_TUNNEL_DIR_CONNS, "0"); + conf.insert(SETTING_PREFER_TUNNELED_DIR_CONNS, "0"); + } + + if (torVersion >= 0x020003) { + /* Do the bridge stuff only on Tor >= 0.2.0.3-alpha */ + QStringList bridges = localValue(SETTING_BRIDGE_LIST).toStringList(); + if (getUseBridges() && !bridges.isEmpty()) { + conf.insert(SETTING_USE_BRIDGES, "1"); + conf.insert(SETTING_UPDATE_BRIDGES, "1"); + foreach (QString bridge, bridges) { + conf.insert(SETTING_BRIDGE_LIST, bridge); + } + } else { + conf.insert(SETTING_USE_BRIDGES, "0"); + conf.insert(SETTING_BRIDGE_LIST, ""); + conf.insert(SETTING_UPDATE_BRIDGES, "0"); + } + } + return torControl()->setConf(conf, errmsg); +} + +/** Returns true if we need to set ReachableAddresses because we're behind a + * restrictive firewall that limits the ports Tor can connect to. */ +bool +NetworkSettings::getFascistFirewall() +{ + return localValue(SETTING_FASCIST_FIREWALL).toBool(); +} + +/** Sets to fascistFirewall whether Tor should only create outgoing + * connections to the list of ports specified in setReachablePorts(). + * \sa setReachablePorts() */ +void +NetworkSettings::setFascistFirewall(bool fascistFirewall) +{ + setValue(SETTING_FASCIST_FIREWALL, fascistFirewall); +} + +/** Returns a list of ports to be specified in ReachableAddresses. */ +QList +NetworkSettings::getReachablePorts() +{ + QList reachablePorts; + QStringList lineList; + bool ok; + + lineList = value(SETTING_REACHABLE_ADDRESSES).toStringList(); + foreach (QString line, lineList) { + foreach (QString address, line.split(",", QString::SkipEmptyParts)) { + QStringList parts = address.split(":"); + if (parts.size() >= 2) { + quint16 port = parts.at(1).toUInt(&ok); + if (ok) + reachablePorts << port; + } + } + } + return reachablePorts; +} + +/** Sets the list of ports that will be specified in ReachableAddresses to + * reachablePorts. */ +void +NetworkSettings::setReachablePorts(const QList &reachablePorts) +{ + if (!reachablePorts.isEmpty()) { + QStringList portList; + foreach (quint16 port, reachablePorts) { + portList << "*:" + QString::number(port); + } + setValue(SETTING_REACHABLE_ADDRESSES, portList); + } +} + +/** Returns the proxy type Tor is using, or NoProxy if it makes direct + * connections. */ +NetworkSettings::ProxyType +NetworkSettings::getProxyType() +{ + QString type = value(SETTING_PROXY_TYPE).toString(); + return proxyTypeFromString(type); +} + +/** Set the type of proxy Tor should use to type. */ +void +NetworkSettings::setProxyType(ProxyType type) +{ + setValue(SETTING_PROXY_TYPE, proxyTypeToString(type)); +} + +/** Returns the address of the proxy server Tor makes connections through. */ +QString +NetworkSettings::getProxyAddress() +{ + return value(SETTING_PROXY_ADDRESS).toString(); +} + +/** Sets the proxy address and port to addr. */ +void +NetworkSettings::setProxyAddress(const QString &addr) +{ + setValue(SETTING_PROXY_ADDRESS, addr); +} + +/** Returns the username used to login to the proxy server. */ +QString +NetworkSettings::getProxyUsername() +{ + return value(SETTING_PROXY_USERNAME).toString(); +} + +/** Sets the proxy server username to user. */ +void +NetworkSettings::setProxyUsername(const QString &user) +{ + setValue(SETTING_PROXY_USERNAME, user); +} + +/** Returns the password used to login to the proxy server. */ +QString +NetworkSettings::getProxyPassword() +{ + return value(SETTING_PROXY_PASSWORD).toString(); +} + +/** Sets the proxy server password to pass. */ +void +NetworkSettings::setProxyPassword(const QString &pass) +{ + setValue(SETTING_PROXY_PASSWORD, pass); +} + +/** Returns true if Tor should try to use bridge nodes to access the Tor + * network. */ +bool +NetworkSettings::getUseBridges() +{ + return value(SETTING_USE_BRIDGES).toBool(); +} + +/** Sets to useBridges whether Tor should try to use bridge nodes + * to access the Tor network. */ +void +NetworkSettings::setUseBridges(bool useBridges) +{ + setValue(SETTING_USE_BRIDGES, useBridges); +} + +/** Returns a list of bridge nodes Tor should use. */ +QStringList +NetworkSettings::getBridgeList() +{ + return value(SETTING_BRIDGE_LIST).toStringList(); +} + +/** Sets to bridgeList the list of bridge nodes Tor should use. */ +void +NetworkSettings::setBridgeList(const QStringList &bridgeList) +{ + setValue(SETTING_BRIDGE_LIST, bridgeList); +} + +/** Returns true if Tor is configured to try to tunnel its directory + * connections through a one-hop circuit. */ +bool +NetworkSettings::getTunnelDirConns() +{ + return value(SETTING_TUNNEL_DIR_CONNS).toBool(); +} + +/** Converts the ProxyType type to a string to store in the + * configuration file. */ +QString +NetworkSettings::proxyTypeToString(ProxyType type) +{ + QString ret; + + switch (type) { + case Socks4Proxy: + ret = "socks4"; + break; + case Socks5Proxy: + ret = "socks5"; + break; + case HttpProxy: + ret = "http"; + break; + case HttpHttpsProxy: + ret = "httphttps"; + break; + case NoProxy: + default: + ret = "none"; + break; + } + + return ret; +} + +/** Converts the proxy type string type to its ProxyType counterpart. */ +NetworkSettings::ProxyType +NetworkSettings::proxyTypeFromString(const QString &type) +{ + QString str = type.toLower(); + + if (str == "socks4") + return Socks4Proxy; + if (str == "socks5") + return Socks5Proxy; + if (str == "http") + return HttpProxy; + if (str == "httphttps") + return HttpHttpsProxy; + + return NoProxy; +} + diff -Nru vidalia-0.1.13/src/vidalia/config/networksettings.h vidalia-0.2.8/src/vidalia/config/networksettings.h --- vidalia-0.1.13/src/vidalia/config/networksettings.h 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/networksettings.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,119 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 networksettings.h -** \version $Id: networksettings.h 2362 2008-02-29 04:30:11Z edmanm $ -** \brief Settings for configuring an HTTP/HTTPS proxy or bridges -*/ - -#ifndef _NETWORKSETTINGS_H -#define _NETWORKSETTINGS_H - -#include -#include - -#include "abstracttorsettings.h" - - -class NetworkSettings : public AbstractTorSettings -{ - Q_OBJECT - -public: - /** Default constructor. */ - NetworkSettings(TorControl *torControl); - - /** Applies the current network configuration settings to Tor. If - * * errmsg is specified and an error occurs while applying the - * settings, it will be set to a string describing the error. */ - bool apply(QString *errmsg = 0); - - /** Returns true if we need to set ReachableAddresses because we're behind a - * restrictive firewall that limits the ports Tor can connect to. */ - bool getFascistFirewall(); - /** Sets to fascistFirewall whether Tor should only create outgoing - * connections to the list of ports specified to setReachablePorts(). - * \sa setReachablePorts() */ - void setFascistFirewall(bool fascistFirewall); - - /** Returns a list of ports to be specified in ReachableAddresses. */ - QList getReachablePorts(); - /** Sets the list of ports that will be specified in ReachableAddresses to - * reachablePorts. */ - void setReachablePorts(const QList &reachablePorts); - - /** Returns true if Tor should make all its directory requests through a - * proxy. */ - bool getUseHttpProxy(); - /** Sets to useHttpProxy whether Tor should make all its directory - * requests through the proxy specified to setHttpProxy() - * \sa setHttpProxy() */ - void setUseHttpProxy(bool useHttpProxy); - - /** Returns the proxy used for making Tor's directory requests, in the form - * of host[:port]. */ - QString getHttpProxy(); - /** Sets the proxy used for making Tor's directory requests. proxy - * should be in the form host[:port]. If :port is not - * specified, then Tor will use its default of port 80. */ - void setHttpProxy(const QString &proxy); - - /** Returns the authentication information Tor should use to authenticate to - * an Http proxy. The returned value is in the form - * username:password. */ - QString getHttpProxyAuthenticator(); - /** Sets the authentication information required by an Http proxy. - * authenticator should be in the form username:password. */ - void setHttpProxyAuthenticator(const QString &authenticator); - - /** Returns true if Tor should make all its OR connections through a - * proxy. */ - bool getUseHttpsProxy(); - /** Sets to useHttpsProxy whether Tor should make all its OR - * connections through the proxy specified to setHttpsProxy. - * \sa setHttpsProxy() */ - void setUseHttpsProxy(bool useHttpsProxy); - - /** Returns the proxy used for making Tor's OR connections, in the form - * of host[:port]. */ - QString getHttpsProxy(); - /** Sets the proxy used for making Tor's OR connections. proxy - * should be in the form host[:port]. If :port is not - * specified, then Tor will use its default of port 443. */ - void setHttpsProxy(const QString &proxy); - - /** Returns the authentication information Tor should use to authenticate to - * an Https proxy. The returned value is in the form - * username:password. */ - QString getHttpsProxyAuthenticator(); - /** Sets the authentication information required by an Https proxy. - * authenticator should be in the form username:password. */ - void setHttpsProxyAuthenticator(const QString &authenticator); - - /** Returns true if Tor should try to use bridge nodes to access the Tor - * network. */ - bool getUseBridges(); - /** Sets to useBridges whether Tor should try to use bridge nodes - * to access the Tor network. */ - void setUseBridges(bool useBridges); - - /** Returns a list of bridge nodes Tor should use. */ - QStringList getBridgeList(); - /** Sets to bridgeList the list of bridge nodes Tor should use. */ - void setBridgeList(const QStringList &bridgeList); - - /** Returns true if Tor is configured to try to tunnel its directory - * connections through a one-hop circuit. */ - bool getTunnelDirConns(); -}; - -#endif - diff -Nru vidalia-0.1.13/src/vidalia/config/NetworkSettings.h vidalia-0.2.8/src/vidalia/config/NetworkSettings.h --- vidalia-0.1.13/src/vidalia/config/NetworkSettings.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/NetworkSettings.h 2009-10-03 22:49:21.000000000 +0100 @@ -0,0 +1,112 @@ +/* +** 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.vidalia-project.net/. 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 NetworkSettings.h +** \version $Id: NetworkSettings.h 4140 2009-10-03 21:49:21Z edmanm $ +** \brief Settings for configuring an HTTP/HTTPS proxy or bridges +*/ + +#ifndef _NETWORKSETTINGS_H +#define _NETWORKSETTINGS_H + +#include "AbstractTorSettings.h" + +#include +#include + + +class NetworkSettings : public AbstractTorSettings +{ + Q_OBJECT + +public: + enum ProxyType + { + ProxyTypeMin = -1, + NoProxy = -1, /**< Have Tor connect directly to the Internet. */ + Socks4Proxy = 0, /**< Use a SOCKS 4 proxy for OR connections. */ + Socks5Proxy = 1, /**< Use a SOCKS 5 proxy for OR connections. */ + HttpProxy = 2, /**< Use an HTTP proxy for non-tunneled dir fetches. */ + HttpHttpsProxy = 3, /**< Use HTTP proxy for both dir and OR connections. */ + ProxyTypeMax = 3 + }; + +public: + /** Default constructor. */ + NetworkSettings(TorControl *torControl); + + /** Applies the current network configuration settings to Tor. If + * * errmsg is specified and an error occurs while applying the + * settings, it will be set to a string describing the error. */ + bool apply(QString *errmsg = 0); + + /** Returns true if we need to set ReachableAddresses because we're behind a + * restrictive firewall that limits the ports Tor can connect to. */ + bool getFascistFirewall(); + /** Sets to fascistFirewall whether Tor should only create outgoing + * connections to the list of ports specified to setReachablePorts(). + * \sa setReachablePorts() */ + void setFascistFirewall(bool fascistFirewall); + + /** Returns a list of ports to be specified in ReachableAddresses. */ + QList getReachablePorts(); + /** Sets the list of ports that will be specified in ReachableAddresses to + * reachablePorts. */ + void setReachablePorts(const QList &reachablePorts); + + /** Returns the proxy type Tor is using, or NoProxy if it makes direct + * connections. */ + ProxyType getProxyType(); + /** Set the type of proxy Tor should use to type. */ + void setProxyType(ProxyType type); + + /** Returns the address of the proxy server Tor makes connections through. */ + QString getProxyAddress(); + /** Sets the proxy address and port to addr. */ + void setProxyAddress(const QString &addr); + + /** Returns the username used to login to the proxy server. */ + QString getProxyUsername(); + /** Sets the proxy server username to user. */ + void setProxyUsername(const QString &user); + + /** Returns the password used to login to the proxy server. */ + QString getProxyPassword(); + /** Sets the proxy server password to pass. */ + void setProxyPassword(const QString &pass); + + /** Returns true if Tor should try to use bridge nodes to access the Tor + * network. */ + bool getUseBridges(); + /** Sets to useBridges whether Tor should try to use bridge nodes + * to access the Tor network. */ + void setUseBridges(bool useBridges); + + /** Returns a list of bridge nodes Tor should use. */ + QStringList getBridgeList(); + /** Sets to bridgeList the list of bridge nodes Tor should use. */ + void setBridgeList(const QStringList &bridgeList); + + /** Returns true if Tor is configured to try to tunnel its directory + * connections through a one-hop circuit. */ + bool getTunnelDirConns(); + +private: + /** Converts the ProxyType type to a string to store in the + * configuration file. */ + QString proxyTypeToString(ProxyType type); + + /** Converts the proxy type string type to its ProxyType counterpart. */ + ProxyType proxyTypeFromString(const QString &type); +}; + +#endif + diff -Nru vidalia-0.1.13/src/vidalia/config/nicknamevalidator.cpp vidalia-0.2.8/src/vidalia/config/nicknamevalidator.cpp --- vidalia-0.1.13/src/vidalia/config/nicknamevalidator.cpp 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/nicknamevalidator.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,44 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 nicknamevalidator.cpp -** \version $Id: nicknamevalidator.cpp 2362 2008-02-29 04:30:11Z edmanm $ -** \brief Validates that a server nickname contains only valid characters -*/ - -#include -#include "nicknamevalidator.h" - -/** Set of characters that are valid in a server's nickname. */ -#define VALID_NICKNAME_CHARS \ - "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" - - -/** Constructor. */ -NicknameValidator::NicknameValidator(QObject *parent) -: QValidator(parent) -{ -} - -/** Validates the given input contains only valid nickname characters starting - * at the specified position. */ -QValidator::State -NicknameValidator::validate(QString &input, int &pos) const -{ - Q_UNUSED(pos); - - /* Make sure the input only contains valid characters. If any characters - * were removed, then we know the input contained invalid characters. */ - QString validString = ensure_valid_chars(input, VALID_NICKNAME_CHARS); - return (validString.length() == input.length() ? QValidator::Acceptable - : QValidator::Invalid); -} - diff -Nru vidalia-0.1.13/src/vidalia/config/NicknameValidator.cpp vidalia-0.2.8/src/vidalia/config/NicknameValidator.cpp --- vidalia-0.1.13/src/vidalia/config/NicknameValidator.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/NicknameValidator.cpp 2009-04-28 21:28:01.000000000 +0100 @@ -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.vidalia-project.net/. 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 NicknameValidator.cpp +** \version $Id: NicknameValidator.cpp 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Validates that a server nickname contains only valid characters +*/ + +#include "NicknameValidator.h" +#include "stringutil.h" + +/** Set of characters that are valid in a server's nickname. */ +#define VALID_NICKNAME_CHARS \ + "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" + + +/** Constructor. */ +NicknameValidator::NicknameValidator(QObject *parent) + : QValidator(parent) +{ +} + +/** Validates the given input contains only valid nickname characters starting + * at the specified position. */ +QValidator::State +NicknameValidator::validate(QString &input, int &pos) const +{ + Q_UNUSED(pos); + + /* Make sure the input only contains valid characters. If any characters + * were removed, then we know the input contained invalid characters. */ + QString validString = ensure_valid_chars(input, VALID_NICKNAME_CHARS); + return (validString.length() == input.length() ? QValidator::Acceptable + : QValidator::Invalid); +} + diff -Nru vidalia-0.1.13/src/vidalia/config/nicknamevalidator.h vidalia-0.2.8/src/vidalia/config/nicknamevalidator.h --- vidalia-0.1.13/src/vidalia/config/nicknamevalidator.h 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/nicknamevalidator.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,35 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 nicknamevalidator.h -** \version $Id: nicknamevalidator.h 2362 2008-02-29 04:30:11Z edmanm $ -** \brief Validates that a server nickname contains only valid characters -*/ - -#ifndef _NICKNAMEVALIDATOR_H -#define _NICKNAMEVALIDATOR_H - -#include - - -class NicknameValidator : public QValidator -{ - Q_OBJECT - -public: - /** Constructor. */ - NicknameValidator(QObject *parent); - /** Validates the given input at the specified position. */ - QValidator::State validate(QString &input, int &pos) const; -}; - -#endif - diff -Nru vidalia-0.1.13/src/vidalia/config/NicknameValidator.h vidalia-0.2.8/src/vidalia/config/NicknameValidator.h --- vidalia-0.1.13/src/vidalia/config/NicknameValidator.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/NicknameValidator.h 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,35 @@ +/* +** 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.vidalia-project.net/. 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 NicknameValidator.h +** \version $Id: NicknameValidator.h 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Validates that a server nickname contains only valid characters +*/ + +#ifndef _NICKNAMEVALIDATOR_H +#define _NICKNAMEVALIDATOR_H + +#include + + +class NicknameValidator : public QValidator +{ + Q_OBJECT + +public: + /** Constructor. */ + NicknameValidator(QObject *parent); + /** Validates the given input at the specified position. */ + QValidator::State validate(QString &input, int &pos) const; +}; + +#endif + diff -Nru vidalia-0.1.13/src/vidalia/config/policy.cpp vidalia-0.2.8/src/vidalia/config/policy.cpp --- vidalia-0.1.13/src/vidalia/config/policy.cpp 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/policy.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,196 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 policy.cpp -** \version $Id: policy.cpp 2362 2008-02-29 04:30:11Z edmanm $ -** \brief Exit policy parsing -*/ - -#include - -#include "policy.h" - - -/** Default constructor. Creates an AcceptAll policy. */ -Policy::Policy() -{ - _action = Accept; - _address = QHostAddress::Any; - _fromPort = _toPort = 0; - _mask = 0; -} - -/** Constructor. Creates a new Policy object from the given string. */ -Policy::Policy(QString policy) -{ - /* Set the defaults */ - _action = Accept; - _address = QHostAddress::Any; - _fromPort = _toPort = 0; - _mask = 0; - - /* Parse the given string to override the defaults. */ - fromString(policy); -} - -/** Constructor. Creates a new Policy object from the string parts. */ -Policy::Policy(QString action, QString address, QString ports) -{ - /* Set the defaults */ - _action = Accept; - _address = QHostAddress::Any; - _fromPort = _toPort = 0; - _mask = 0; - - fromString(action + " " + address + ":" + ports); -} - -/** Constructor. Creates a new Policy object depending on the specified - * special policy type. */ -Policy::Policy(SpecialPolicy policy) -{ - _action = (policy == AcceptAll ? Accept : Reject); - _address = QHostAddress::Any; - _fromPort = _toPort = 0; - _mask = 0; -} - -/** Constructor. Creates a new policy object based on the given rules. */ -Policy::Policy(Action action, QHostAddress addr, uchar mask, - quint16 fromPort, quint16 toPort) -{ - _action = action; - _address = addr; - _mask = mask; - _fromPort = fromPort; - _toPort = (toPort >= fromPort ? toPort : fromPort); -} - -/** Returns true if this policy is identical to policy. */ -bool -Policy::operator==(const Policy &policy) const -{ - return ((this->_action == policy._action) && - (this->_address == policy._address) && - (this->_mask == policy._mask) && - (this->_fromPort == policy._fromPort) && - (this->_toPort == policy._toPort)); -} - -/** Returns true if this policy matches policy. For example, if this - * policy is "reject *:6660-6669" and policy is "reject *:6662-6664", - * this will return true. For strict comparison, use the == operator. */ -bool -Policy::matches(const Policy &policy) const -{ - /* This doesn't take into account addr/mask matches yet */ - return ((this->_action == policy._action) && - (this->_address == policy._address) && - (this->_mask == policy._mask) && - (this->_fromPort <= policy._fromPort) && - (this->_toPort >= policy._toPort)); -} - -/** Parses the given exit policy string. */ -void -Policy::fromString(QString policy) -{ - /* Separate the action and the address/mask/port info */ - QStringList ruleParts = policy.split(" "); - _action = toAction(ruleParts.at(0)); - - /* If some address/mask/port stuff was specified, parse it. */ - if (ruleParts.size() > 1) { - QStringList addrParts = ruleParts.at(1).split(":"); - - /* Parse the address and mask (if specified) */ - QString addr = addrParts.at(0); - _address.setAddress(addr.mid(0, addr.indexOf("/"))); - if (_address.isNull()) { - _address = QHostAddress::Any; - } - if (addr.contains("/")) { - _mask = addr.mid(addr.indexOf("/")+1).toUInt(); - } - - /* Parse the specified port range (if specified) */ - if (addrParts.size() > 1) { - QString ports = addrParts.at(1); - _fromPort = ports.mid(0, ports.indexOf("-")).toUInt(); - if (ports.contains("-")) { - _toPort = ports.mid(ports.indexOf("-")+1).toUInt(); - } else { - _toPort = _fromPort; - } - } - } -} - -/** Converts this policy to a form Tor understands. The format is: - * "accept|reject ADDR[/MASK][:PORT]" - * - * PORT can be a single port number, an interval of ports "FROM_PORT-TO_PORT", - * or "*". If PORT is omitted, that means "*" - */ -QString -Policy::toString() const -{ - QString act = (_action == Accept ? "accept" : "reject"); - return act + " " + address() + ":" + ports(); -} - -/** Converts the given action to a string. This function tolerates both the - * translated and untranslated forms of the string "accept" and "reject". */ -Policy::Action -Policy::toAction(QString action) -{ - action = action.toLower(); - if (action == tr("accept") || action == "accept") { - return Accept; - } - return Reject; -} - -/** Returns the action associated with this policy. NOTE: This string will be - * translated to whatever the current language setting is. */ -QString -Policy::action() const -{ - return (_action == Accept ? tr("accept") : tr("reject")); -} - -/** Returns the address (and mask, if specified) for this policy. */ -QString -Policy::address() const -{ - QString addrString; - - if (_mask) { - addrString = _address.toString() + "/" + QString::number(_mask); - } else if (_address == QHostAddress::Any || _address.isNull()) { - addrString = "*"; - } else { - addrString = _address.toString(); - } - return addrString; -} - -/** Returns the port (or port range, if specified) for this policy. */ -QString -Policy::ports() const -{ - QString ports = (_fromPort ? QString::number(_fromPort) : "*"); - if (_fromPort && (_toPort > _fromPort)) { - ports += "-" + QString::number(_toPort); - } - return ports; -} - diff -Nru vidalia-0.1.13/src/vidalia/config/Policy.cpp vidalia-0.2.8/src/vidalia/config/Policy.cpp --- vidalia-0.1.13/src/vidalia/config/Policy.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/Policy.cpp 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,196 @@ +/* +** 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.vidalia-project.net/. 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 Policy.cpp +** \version $Id: Policy.cpp 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Exit policy parsing +*/ + +#include "Policy.h" + +#include + + +/** Default constructor. Creates an AcceptAll policy. */ +Policy::Policy() +{ + _action = Accept; + _address = QHostAddress::Any; + _fromPort = _toPort = 0; + _mask = 0; +} + +/** Constructor. Creates a new Policy object from the given string. */ +Policy::Policy(QString policy) +{ + /* Set the defaults */ + _action = Accept; + _address = QHostAddress::Any; + _fromPort = _toPort = 0; + _mask = 0; + + /* Parse the given string to override the defaults. */ + fromString(policy); +} + +/** Constructor. Creates a new Policy object from the string parts. */ +Policy::Policy(QString action, QString address, QString ports) +{ + /* Set the defaults */ + _action = Accept; + _address = QHostAddress::Any; + _fromPort = _toPort = 0; + _mask = 0; + + fromString(action + " " + address + ":" + ports); +} + +/** Constructor. Creates a new Policy object depending on the specified + * special policy type. */ +Policy::Policy(SpecialPolicy policy) +{ + _action = (policy == AcceptAll ? Accept : Reject); + _address = QHostAddress::Any; + _fromPort = _toPort = 0; + _mask = 0; +} + +/** Constructor. Creates a new policy object based on the given rules. */ +Policy::Policy(Action action, QHostAddress addr, uchar mask, + quint16 fromPort, quint16 toPort) +{ + _action = action; + _address = addr; + _mask = mask; + _fromPort = fromPort; + _toPort = (toPort >= fromPort ? toPort : fromPort); +} + +/** Returns true if this policy is identical to policy. */ +bool +Policy::operator==(const Policy &policy) const +{ + return ((this->_action == policy._action) && + (this->_address == policy._address) && + (this->_mask == policy._mask) && + (this->_fromPort == policy._fromPort) && + (this->_toPort == policy._toPort)); +} + +/** Returns true if this policy matches policy. For example, if this + * policy is "reject *:6660-6669" and policy is "reject *:6662-6664", + * this will return true. For strict comparison, use the == operator. */ +bool +Policy::matches(const Policy &policy) const +{ + /* This doesn't take into account addr/mask matches yet */ + return ((this->_action == policy._action) && + (this->_address == policy._address) && + (this->_mask == policy._mask) && + (this->_fromPort <= policy._fromPort) && + (this->_toPort >= policy._toPort)); +} + +/** Parses the given exit policy string. */ +void +Policy::fromString(QString policy) +{ + /* Separate the action and the address/mask/port info */ + QStringList ruleParts = policy.split(" "); + _action = toAction(ruleParts.at(0)); + + /* If some address/mask/port stuff was specified, parse it. */ + if (ruleParts.size() > 1) { + QStringList addrParts = ruleParts.at(1).split(":"); + + /* Parse the address and mask (if specified) */ + QString addr = addrParts.at(0); + _address.setAddress(addr.mid(0, addr.indexOf("/"))); + if (_address.isNull()) { + _address = QHostAddress::Any; + } + if (addr.contains("/")) { + _mask = addr.mid(addr.indexOf("/")+1).toUInt(); + } + + /* Parse the specified port range (if specified) */ + if (addrParts.size() > 1) { + QString ports = addrParts.at(1); + _fromPort = ports.mid(0, ports.indexOf("-")).toUInt(); + if (ports.contains("-")) { + _toPort = ports.mid(ports.indexOf("-")+1).toUInt(); + } else { + _toPort = _fromPort; + } + } + } +} + +/** Converts this policy to a form Tor understands. The format is: + * "accept|reject ADDR[/MASK][:PORT]" + * + * PORT can be a single port number, an interval of ports "FROM_PORT-TO_PORT", + * or "*". If PORT is omitted, that means "*" + */ +QString +Policy::toString() const +{ + QString act = (_action == Accept ? "accept" : "reject"); + return act + " " + address() + ":" + ports(); +} + +/** Converts the given action to a string. This function tolerates both the + * translated and untranslated forms of the string "accept" and "reject". */ +Policy::Action +Policy::toAction(QString action) +{ + action = action.toLower(); + if (action == tr("accept") || action == "accept") { + return Accept; + } + return Reject; +} + +/** Returns the action associated with this policy. NOTE: This string will be + * translated to whatever the current language setting is. */ +QString +Policy::action() const +{ + return (_action == Accept ? tr("accept") : tr("reject")); +} + +/** Returns the address (and mask, if specified) for this policy. */ +QString +Policy::address() const +{ + QString addrString; + + if (_mask) { + addrString = _address.toString() + "/" + QString::number(_mask); + } else if (_address == QHostAddress::Any || _address.isNull()) { + addrString = "*"; + } else { + addrString = _address.toString(); + } + return addrString; +} + +/** Returns the port (or port range, if specified) for this policy. */ +QString +Policy::ports() const +{ + QString ports = (_fromPort ? QString::number(_fromPort) : "*"); + if (_fromPort && (_toPort > _fromPort)) { + ports += "-" + QString::number(_toPort); + } + return ports; +} + diff -Nru vidalia-0.1.13/src/vidalia/config/policy.h vidalia-0.2.8/src/vidalia/config/policy.h --- vidalia-0.1.13/src/vidalia/config/policy.h 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/policy.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,81 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 policy.h -** \version $Id: policy.h 2362 2008-02-29 04:30:11Z edmanm $ -** \brief Exit policy parsing -*/ - -#ifndef _POLICY_H -#define _POLICY_H - -#include -#include -#include - - -class Policy -{ - Q_DECLARE_TR_FUNCTIONS(Policy) - -public: - /** A set of possible actions for a policy */ - enum Action { - Accept, /**< Connections matching this policy will be accepted. */ - Reject /**< Connections matching this policy will be rejected. */ - }; - /** Special rule types. */ - enum SpecialPolicy { - AcceptAll, /**< Accepts all connections. Equivalent to "accept *:*". */ - RejectAll /**< Rejects all connections. Equivalent to "reject *:*". */ - }; - - /** Default constructor. Creates an AcceptAll policy. */ - Policy(); - /** Parses the given policy, represented as a string. */ - Policy(QString policy); - /** Parses the given portions of a policy string. */ - Policy(QString action, QString address, QString ports); - /** Creates a policy of the given special type. */ - Policy(SpecialPolicy policy); - /** Creates a policy using the specified information. */ - Policy(Action action, QHostAddress addr, uchar mask, - quint16 fromPort, quint16 toPort = 0); - - /** Returns true if this policy matches policy. */ - bool matches(const Policy &policy) const; - /** Returns true if this policy is identical to policy. */ - bool operator==(const Policy &policy) const; - - /** Parses the given policy string. */ - void fromString(QString policy); - /** Converts this policy to a format Tor understands. */ - QString toString() const; - /** Converts a string action to an Action enum value. */ - static Action toAction(QString action); - - /** Returns the action taken when this policy matches an address. */ - QString action() const; - /** Returns the host address (including mask, if set) for this policy. */ - QString address() const; - /** Returns the port or port range for this policy. */ - QString ports() const; - -private: - Action _action; /**< The action to take for this policy. */ - QHostAddress _address; /**< Addresses to which this policy applies. */ - quint16 _fromPort; /**< Start of a port range. */ - quint16 _toPort; /**< End of a port range. */ - uchar _mask; /**< Address mask. */ -}; - -#endif - diff -Nru vidalia-0.1.13/src/vidalia/config/Policy.h vidalia-0.2.8/src/vidalia/config/Policy.h --- vidalia-0.1.13/src/vidalia/config/Policy.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/Policy.h 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,81 @@ +/* +** 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.vidalia-project.net/. 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 Policy.h +** \version $Id: Policy.h 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Exit policy parsing +*/ + +#ifndef _POLICY_H +#define _POLICY_H + +#include +#include +#include + + +class Policy +{ + Q_DECLARE_TR_FUNCTIONS(Policy) + +public: + /** A set of possible actions for a policy */ + enum Action { + Accept, /**< Connections matching this policy will be accepted. */ + Reject /**< Connections matching this policy will be rejected. */ + }; + /** Special rule types. */ + enum SpecialPolicy { + AcceptAll, /**< Accepts all connections. Equivalent to "accept *:*". */ + RejectAll /**< Rejects all connections. Equivalent to "reject *:*". */ + }; + + /** Default constructor. Creates an AcceptAll policy. */ + Policy(); + /** Parses the given policy, represented as a string. */ + Policy(QString policy); + /** Parses the given portions of a policy string. */ + Policy(QString action, QString address, QString ports); + /** Creates a policy of the given special type. */ + Policy(SpecialPolicy policy); + /** Creates a policy using the specified information. */ + Policy(Action action, QHostAddress addr, uchar mask, + quint16 fromPort, quint16 toPort = 0); + + /** Returns true if this policy matches policy. */ + bool matches(const Policy &policy) const; + /** Returns true if this policy is identical to policy. */ + bool operator==(const Policy &policy) const; + + /** Parses the given policy string. */ + void fromString(QString policy); + /** Converts this policy to a format Tor understands. */ + QString toString() const; + /** Converts a string action to an Action enum value. */ + static Action toAction(QString action); + + /** Returns the action taken when this policy matches an address. */ + QString action() const; + /** Returns the host address (including mask, if set) for this policy. */ + QString address() const; + /** Returns the port or port range for this policy. */ + QString ports() const; + +private: + Action _action; /**< The action to take for this policy. */ + QHostAddress _address; /**< Addresses to which this policy applies. */ + quint16 _fromPort; /**< Start of a port range. */ + quint16 _toPort; /**< End of a port range. */ + uchar _mask; /**< Address mask. */ +}; + +#endif + diff -Nru vidalia-0.1.13/src/vidalia/config/portvalidator.cpp vidalia-0.2.8/src/vidalia/config/portvalidator.cpp --- vidalia-0.1.13/src/vidalia/config/portvalidator.cpp 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/portvalidator.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,39 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 portvalidator.cpp -** \version $Id: portvalidator.cpp 2362 2008-02-29 04:30:11Z edmanm $ -** \brief Validates that a number is a valid port number -*/ - -#include "portvalidator.h" - -#define MIN_PORT 1 /**< Minimum valid port. */ -#define MAX_PORT 65535 /**< Maximum valid port. */ -#define MATCH_ALL "*" /**< Matches all ports. */ - - -/** Constructor. */ -PortValidator::PortValidator(QObject *parent) -: QIntValidator(MIN_PORT, MAX_PORT, parent) -{ -} - -/** Validates that the given port is either a valid port or a "*". */ -QValidator::State -PortValidator::validate(QString &input, int &pos) const -{ - if (input == MATCH_ALL) { - return QValidator::Acceptable; - } - return QIntValidator::validate(input, pos); -} - diff -Nru vidalia-0.1.13/src/vidalia/config/PortValidator.cpp vidalia-0.2.8/src/vidalia/config/PortValidator.cpp --- vidalia-0.1.13/src/vidalia/config/PortValidator.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/PortValidator.cpp 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,39 @@ +/* +** 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.vidalia-project.net/. 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 PortValidator.cpp +** \version $Id: PortValidator.cpp 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Validates that a number is a valid port number +*/ + +#include "PortValidator.h" + +#define MIN_PORT 1 /**< Minimum valid port. */ +#define MAX_PORT 65535 /**< Maximum valid port. */ +#define MATCH_ALL "*" /**< Matches all ports. */ + + +/** Constructor. */ +PortValidator::PortValidator(QObject *parent) + : QIntValidator(MIN_PORT, MAX_PORT, parent) +{ +} + +/** Validates that the given port is either a valid port or a "*". */ +QValidator::State +PortValidator::validate(QString &input, int &pos) const +{ + if (input == MATCH_ALL) { + return QValidator::Acceptable; + } + return QIntValidator::validate(input, pos); +} + diff -Nru vidalia-0.1.13/src/vidalia/config/portvalidator.h vidalia-0.2.8/src/vidalia/config/portvalidator.h --- vidalia-0.1.13/src/vidalia/config/portvalidator.h 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/portvalidator.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,35 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 portvalidator.h -** \version $Id: portvalidator.h 2362 2008-02-29 04:30:11Z edmanm $ -** \brief Validates that a number is a valid port number -*/ - -#ifndef _PORTVALIDATOR_H -#define _PORTVALIDATOR_H - -#include - - -class PortValidator : public QIntValidator -{ - Q_OBJECT - -public: - /** Constructor. */ - PortValidator(QObject *parent); - /** Validates that the given port is either a valid port or a "*". */ - QValidator::State validate(QString &input, int &pos) const; -}; - -#endif - diff -Nru vidalia-0.1.13/src/vidalia/config/PortValidator.h vidalia-0.2.8/src/vidalia/config/PortValidator.h --- vidalia-0.1.13/src/vidalia/config/PortValidator.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/PortValidator.h 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,35 @@ +/* +** 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.vidalia-project.net/. 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 PortValidator.h +** \version $Id: PortValidator.h 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Validates that a number is a valid port number +*/ + +#ifndef _PORTVALIDATOR_H +#define _PORTVALIDATOR_H + +#include + + +class PortValidator : public QIntValidator +{ + Q_OBJECT + +public: + /** Constructor. */ + PortValidator(QObject *parent); + /** Validates that the given port is either a valid port or a "*". */ + QValidator::State validate(QString &input, int &pos) const; +}; + +#endif + diff -Nru vidalia-0.1.13/src/vidalia/config/serverpage.cpp vidalia-0.2.8/src/vidalia/config/serverpage.cpp --- vidalia-0.1.13/src/vidalia/config/serverpage.cpp 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/serverpage.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,524 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 serverpage.cpp -** \version $Id: serverpage.cpp 2685 2008-06-10 05:22:58Z edmanm $ -** \brief Tor server configuration options -*/ - -#include -#include -#include -#include -#include - -#include "configdialog.h" -#include "serverpage.h" -#include "ipvalidator.h" -#include "portvalidator.h" -#include "domainvalidator.h" -#include "nicknamevalidator.h" - -#if defined(USE_MINIUPNPC) -#include "upnptestdialog.h" -#endif - -/* These are completely made up values (in bytes/sec). */ -#define CABLE256_AVG_RATE (32*1024) -#define CABLE256_MAX_RATE (64*1024) -#define CABLE512_AVG_RATE (64*1024) -#define CABLE512_MAX_RATE (128*1024) -#define CABLE768_AVG_RATE (96*1024) -#define CABLE768_MAX_RATE (192*1024) -#define T1_AVG_RATE (192*1024) -#define T1_MAX_RATE (384*1024) -#define HIGHBW_AVG_RATE (5120*1024) -#define HIGHBW_MAX_RATE (10240*1024) -/** Minimum allowed bandwidth rate (20KB) */ -#define MIN_BANDWIDTH_RATE 20 -/** Maximum bandwidth rate. This is limited to 2147483646 bytes, - * or 2097151 kilobytes. (2147483646/1024) */ -#define MAX_BANDWIDTH_RATE 2097151 - -/** Ports represented by the "Websites" checkbox. (80) */ -#define PORTS_HTTP (QStringList() << "80") -/** Ports represented by the "Secure Websites" checkbox. (443) */ -#define PORTS_HTTPS (QStringList() << "443") -/** Ports represented by the "Retrieve Mail" checkbox. (110,143,993,995) */ -#define PORTS_MAIL (QStringList() << "110" << "143" << "993" << "995") -/** Ports represented by the "Instant Messaging" checkbox. - * (703,1863,5050,5190,5222,8300,8888) */ -#define PORTS_IM (QStringList() << "706" << "1863" << "5050" << "5190" \ - << "5222" << "5223" << "8300" << "8888") -/** Ports represented by the "Internet Relay Chat" checkbox. - * (6660-6669,6697) */ -#define PORTS_IRC (QStringList() << "6660-6669" << "6697") - - -/** Constructor */ -ServerPage::ServerPage(QWidget *parent) -: ConfigPage(parent, tr("Server")) -{ - /* Invoke the Qt Designer generated object setup routine */ - ui.setupUi(this); - - /* Create ServerSettings object */ - _settings = new ServerSettings(Vidalia::torControl()); - - /* Bind events to actions */ - connect(ui.btnRateHelp, SIGNAL(clicked()), this, SLOT(bandwidthHelp())); - connect(ui.btnExitHelp, SIGNAL(clicked()), this, SLOT(exitPolicyHelp())); - connect(ui.btnUpnpHelp, SIGNAL(clicked()), this, SLOT(upnpHelp())); - connect(ui.cmboRate, SIGNAL(currentIndexChanged(int)), - this, SLOT(rateChanged(int))); - connect(ui.lineAvgRateLimit, SIGNAL(editingFinished()), - this, SLOT(customRateChanged())); - connect(ui.lineMaxRateLimit, SIGNAL(editingFinished()), - this, SLOT(customRateChanged())); - connect(ui.rdoClientMode, SIGNAL(toggled(bool)), - this, SLOT(serverModeChanged(bool))); - connect(ui.rdoServerMode, SIGNAL(toggled(bool)), - this, SLOT(serverModeChanged(bool))); - connect(ui.rdoBridgeMode, SIGNAL(toggled(bool)), - this, SLOT(serverModeChanged(bool))); - connect(Vidalia::torControl(), SIGNAL(authenticated()), - this, SLOT(onAuthenticated())); - connect(Vidalia::torControl(), SIGNAL(disconnected()), - this, SLOT(onDisconnected())); - connect(ui.btnCopyBridgeIdentity, SIGNAL(clicked()), - this, SLOT(copyBridgeIdentity())); - - /* Set validators for address, mask and various port number fields */ - ui.lineServerNickname->setValidator(new NicknameValidator(this)); - ui.lineServerPort->setValidator(new QIntValidator(1, 65535, this)); - ui.lineDirPort->setValidator(new QIntValidator(1, 65535, this)); - ui.lineAvgRateLimit->setValidator( - new QIntValidator(MIN_BANDWIDTH_RATE, MAX_BANDWIDTH_RATE, this)); - ui.lineMaxRateLimit->setValidator( - new QIntValidator(MIN_BANDWIDTH_RATE, MAX_BANDWIDTH_RATE, this)); - -#if defined(USE_MINIUPNPC) - connect(ui.btnTestUpnp, SIGNAL(clicked()), this, SLOT(testUpnp())); -#else - ui.chkEnableUpnp->setVisible(false); - ui.btnTestUpnp->setVisible(false); -#endif -} - -/** Destructor */ -ServerPage::~ServerPage() -{ - delete _settings; -} - -/** Called when Vidalia has authenticated to Tor. If the user's Tor is not - * recent enough, this disables the bridge server option and displays a - * warning if the user had previously configured Tor as a bridge. */ -void -ServerPage::onAuthenticated() -{ - quint32 torVersion = Vidalia::torControl()->getTorVersion(); - if (torVersion < 0x020008) { - ui.rdoBridgeMode->setEnabled(false); - if (ui.rdoBridgeMode->isChecked()) { - int ret = VMessageBox::warning(this, - tr("Bridge Support Unavailable"), - p(tr("You have configured Tor to act as a bridge relay " - "for censored users, but your version of Tor does not " - "support bridges.")) + - p(tr("Please upgrade your Tor software or configure Tor to " - "act as a normal Tor relay.")), - VMessageBox::ShowSettings|VMessageBox::Default, - VMessageBox::Cancel); - if (ret == VMessageBox::ShowSettings) { - ConfigDialog *dialog = dynamic_cast(window()); - if (dialog) - dialog->showWindow(ConfigDialog::Server); - } - } - } -} - -/** Called when Vidalia disconnects from Tor. This method reenables the bridge - * server option. */ -void -ServerPage::onDisconnected() -{ - ui.rdoBridgeMode->setEnabled(true); -} - -/** Copies the user's bridge relay identity to the clipboard. */ -void -ServerPage::copyBridgeIdentity() -{ - QString bridge = ui.lblBridgeIdentity->text(); - if (!bridge.isEmpty()) - vApp->clipboard()->setText(bridge); -} - -/** Loads the user's bridge relay identity into the appropriate widgets. If - * the user's bridge is not running, then "Not Running" will be displayed. - * Otherwise, either the bridge's "address:port", "fingerprint", or - * "address:port fingerprint" will be displayed, depending on whether our - * GETCONF and GETINFO commands are successful. */ -void -ServerPage::loadBridgeIdentity() -{ - TorControl *tc = Vidalia::torControl(); - QString bridge, address, orPort, fingerprint; - - if (tc->isConnected()) { - tc->getInfo("address", address); - tc->getInfo("fingerprint", fingerprint); - tc->getConf("ORPort", orPort); - - if (!address.isEmpty() && !orPort.isEmpty() && orPort != "0") - bridge = address + ":" + orPort + " "; - if (!fingerprint.isEmpty()) - bridge += fingerprint; - bridge = bridge.trimmed(); - } - - ui.lblBridgeIdentity->setText(bridge.isEmpty() - ? tr("Your bridge relay is not running.") - : bridge); - ui.lblYourBridgeRelayIs->setEnabled(!bridge.isEmpty()); - ui.lblBridgeIdentity->setEnabled(!bridge.isEmpty()); - ui.btnCopyBridgeIdentity->setEnabled(!bridge.isEmpty()); -} - -/** Called when the user toggles any one of the server mode radio buttons - * and hides or displays the server configuration tabs appropriately. */ -void -ServerPage::serverModeChanged(bool enabled) -{ - Q_UNUSED(enabled); - bool bridgeEnabled = ui.rdoBridgeMode->isChecked(); - - /* Show the tab menu only if the user is running a normal relay or a bridge - * relay. */ - ui.tabsMenu->setVisible(ui.rdoServerMode->isChecked() || bridgeEnabled); - - /* Disable the Exit Policies tab when bridge relay mode is selected */ - ui.tabsMenu->setTabEnabled(2, !bridgeEnabled); - - /* Display the widgets that show the user their bridge identity if bridge - * relay mode is selected. */ - ui.lblYourBridgeRelayIs->setVisible(bridgeEnabled); - ui.lblBridgeIdentity->setVisible(bridgeEnabled); - ui.btnCopyBridgeIdentity->setVisible(bridgeEnabled); -} - -/** Returns true if the user has changed their server settings since the - * last time they were applied to Tor. */ -bool -ServerPage::changedSinceLastApply() -{ - return _settings->changedSinceLastApply(); -} - -/** Applies the server configuration settings to Tor. Returns true if the - * settings were applied successfully. Otherwise, errmsg is - * set and false is returned. */ -bool -ServerPage::apply(QString &errmsg) -{ - return _settings->apply(&errmsg); -} - -/** Returns true if the user has changed their server settings since the - * last time they were applied to Tor. */ -void -ServerPage::revert() -{ - _settings->revert(); -} - -/** Saves changes made to settings on the Server settings page. */ -bool -ServerPage::save(QString &errmsg) -{ - /* Force the bandwidth rate limits to validate */ - customRateChanged(); - - if (ui.rdoServerMode->isChecked() || ui.rdoBridgeMode->isChecked()) { - /* A server must have an ORPort and a nickname */ - if (ui.lineServerPort->text().isEmpty() || - ui.lineServerNickname->text().isEmpty()) { - errmsg = tr("You must specify at least a relay nickname and port."); - return false; - } - /* If the bandwidth rates aren't set, use some defaults before saving */ - if (ui.lineAvgRateLimit->text().isEmpty()) { - ui.lineAvgRateLimit->setText(QString::number(2097152/1024) /* 2MB */); - } - if (ui.lineMaxRateLimit->text().isEmpty()) { - ui.lineMaxRateLimit->setText(QString::number(5242880/1024) /* 5MB */); - } - } - - /* "Server" is enabled whether we're a bridge or normal relay. "Bridge" is - * only enabled if we're a bridge (obviously). */ - _settings->setServerEnabled(ui.rdoServerMode->isChecked() - || ui.rdoBridgeMode->isChecked()); - _settings->setBridgeEnabled(ui.rdoBridgeMode->isChecked()); - - /* Save the rest of the server settings. */ - _settings->setDirectoryMirror(ui.chkMirrorDirectory->isChecked()); - _settings->setNickname(ui.lineServerNickname->text()); - _settings->setORPort(ui.lineServerPort->text().toUInt()); - _settings->setDirPort(ui.lineDirPort->text().toUInt()); - _settings->setContactInfo(ui.lineServerContact->text()); - saveBandwidthLimits(); - saveExitPolicies(); - -#if defined(USE_MINIUPNPC) - _settings->setUpnpEnabled(ui.chkEnableUpnp->isChecked()); -#endif - - return true; -} - -/** Loads previously saved settings */ -void -ServerPage::load() -{ - if (_settings->isBridgeEnabled()) - ui.rdoBridgeMode->setChecked(true); - else if (_settings->isServerEnabled()) - ui.rdoServerMode->setChecked(true); - else - ui.rdoClientMode->setChecked(true); - - ui.lineServerNickname->setText(_settings->getNickname()); - ui.lineServerPort->setText(QString::number(_settings->getORPort())); - ui.lineDirPort->setText(QString::number(_settings->getDirPort())); - ui.lineServerContact->setText(_settings->getContactInfo()); - ui.chkMirrorDirectory->setChecked(_settings->isDirectoryMirror()); - - loadBandwidthLimits(); - loadExitPolicies(); - loadBridgeIdentity(); - -#if defined(USE_MINIUPNPC) - ui.chkEnableUpnp->setChecked(_settings->isUpnpEnabled()); -#endif -} - -/** Shows exit policy related help information */ -void -ServerPage::exitPolicyHelp() -{ - emit helpRequested("server.exitpolicy"); -} - -/** Shows the bandwidth rate limiting help information */ -void -ServerPage::bandwidthHelp() -{ - emit helpRequested("server.bandwidth"); -} - -/** Loads the server's bandwidth average and burst limits. */ -void -ServerPage::loadBandwidthLimits() -{ - quint32 avgRate = _settings->getBandwidthAvgRate(); - quint32 maxRate = _settings->getBandwidthBurstRate(); - - if (avgRate == CABLE256_AVG_RATE && - maxRate == CABLE256_MAX_RATE) { - /* Cable/DSL 256 Kbps */ - ui.cmboRate->setCurrentIndex(CableDsl256); - } else if (avgRate == CABLE512_AVG_RATE && - maxRate == CABLE512_MAX_RATE) { - /* Cable/DSL 512 Kbps */ - ui.cmboRate->setCurrentIndex(CableDsl512); - } else if (avgRate == CABLE768_AVG_RATE && - maxRate == CABLE768_MAX_RATE) { - /* Cable/DSL 768 Kbps */ - ui.cmboRate->setCurrentIndex(CableDsl768); - } else if (avgRate == T1_AVG_RATE && - maxRate == T1_MAX_RATE) { - /* T1/Cable/DSL 1.5 Mbps */ - ui.cmboRate->setCurrentIndex(T1CableDsl1500); - } else if (avgRate == HIGHBW_AVG_RATE && - maxRate == HIGHBW_MAX_RATE) { - /* > 1.5 Mbps */ - ui.cmboRate->setCurrentIndex(GreaterThan1500); - } else { - /* Custom bandwidth limits */ - ui.cmboRate->setCurrentIndex(CustomBwLimits); - } - /* Fill in the custom bandwidth limit boxes */ - ui.lineAvgRateLimit->setText(QString::number(avgRate/1024)); - ui.lineMaxRateLimit->setText(QString::number(maxRate/1024)); -} - -/** Saves the server's bandwidth average and burst limits. */ -void -ServerPage::saveBandwidthLimits() -{ - quint32 avgRate, maxRate; - - switch (ui.cmboRate->currentIndex()) { - case CableDsl256: /* Cable/DSL 256 Kbps */ - avgRate = CABLE256_AVG_RATE; - maxRate = CABLE256_MAX_RATE; - break; - case CableDsl512: /* Cable/DSL 512 Kbps */ - avgRate = CABLE512_AVG_RATE; - maxRate = CABLE512_MAX_RATE; - break; - case CableDsl768: /* Cable/DSL 768 Kbps */ - avgRate = CABLE768_AVG_RATE; - maxRate = CABLE768_MAX_RATE; - break; - case T1CableDsl1500: /* T1/Cable/DSL 1.5 Mbps */ - avgRate = T1_AVG_RATE; - maxRate = T1_MAX_RATE; - break; - case GreaterThan1500: /* > 1.5 Mbps */ - avgRate = HIGHBW_AVG_RATE; - maxRate = HIGHBW_MAX_RATE; - break; - default: /* Custom bandwidth limits */ - avgRate = (quint32)(ui.lineAvgRateLimit->text().toUInt()*1024); - maxRate = (quint32)(ui.lineMaxRateLimit->text().toUInt()*1024); - break; - } - _settings->setBandwidthAvgRate(avgRate); - _settings->setBandwidthBurstRate(maxRate); -} - -/** */ -void -ServerPage::loadExitPolicies() -{ - ExitPolicy exitPolicy = _settings->getExitPolicy(); - - if (exitPolicy.contains(Policy(Policy::RejectAll))) { - /* If the policy ends with reject *:*, check if the policy explicitly - * accepts these ports */ - ui.chkWebsites->setChecked(exitPolicy.acceptsPorts(PORTS_HTTP)); - ui.chkSecWebsites->setChecked(exitPolicy.acceptsPorts(PORTS_HTTPS)); - ui.chkMail->setChecked(exitPolicy.acceptsPorts(PORTS_MAIL)); - ui.chkIRC->setChecked(exitPolicy.acceptsPorts(PORTS_IRC)); - ui.chkIM->setChecked(exitPolicy.acceptsPorts(PORTS_IM)); - ui.chkMisc->setChecked(false); - } else { - /* If the exit policy ends with accept *:*, check if the policy explicitly - * rejects these ports */ - ui.chkWebsites->setChecked(!exitPolicy.rejectsPorts(PORTS_HTTP)); - ui.chkSecWebsites->setChecked(!exitPolicy.rejectsPorts(PORTS_HTTPS)); - ui.chkMail->setChecked(!exitPolicy.rejectsPorts(PORTS_MAIL)); - ui.chkIRC->setChecked(!exitPolicy.rejectsPorts(PORTS_IRC)); - ui.chkIM->setChecked(!exitPolicy.rejectsPorts(PORTS_IM)); - ui.chkMisc->setChecked(true); - } -} - -/** */ -void -ServerPage::saveExitPolicies() -{ - ExitPolicy exitPolicy; - bool rejectUnchecked = ui.chkMisc->isChecked(); - - /* If misc is checked, then reject unchecked items and leave the default exit - * policy alone. Else, accept only checked items and end with reject *:*, - * replacing the default exit policy. */ - if (ui.chkWebsites->isChecked() && !rejectUnchecked) { - exitPolicy.addAcceptedPorts(PORTS_HTTP); - } else if (!ui.chkWebsites->isChecked() && rejectUnchecked) { - exitPolicy.addRejectedPorts(PORTS_HTTP); - } - if (ui.chkSecWebsites->isChecked() && !rejectUnchecked) { - exitPolicy.addAcceptedPorts(PORTS_HTTPS); - } else if (!ui.chkSecWebsites->isChecked() && rejectUnchecked) { - exitPolicy.addRejectedPorts(PORTS_HTTPS); - } - if (ui.chkMail->isChecked() && !rejectUnchecked) { - exitPolicy.addAcceptedPorts(PORTS_MAIL); - } else if (!ui.chkMail->isChecked() && rejectUnchecked) { - exitPolicy.addRejectedPorts(PORTS_MAIL); - } - if (ui.chkIRC->isChecked() && !rejectUnchecked) { - exitPolicy.addAcceptedPorts(PORTS_IRC); - } else if (!ui.chkIRC->isChecked() && rejectUnchecked) { - exitPolicy.addRejectedPorts(PORTS_IRC); - } - if (ui.chkIM->isChecked() && !rejectUnchecked) { - exitPolicy.addAcceptedPorts(PORTS_IM); - } else if (!ui.chkIM->isChecked() && rejectUnchecked) { - exitPolicy.addRejectedPorts(PORTS_IM); - } - if (!ui.chkMisc->isChecked()) { - exitPolicy.addPolicy(Policy(Policy::RejectAll)); - } - _settings->setExitPolicy(exitPolicy); -} - -/** Called when the user selects a new value from the rate combo box. */ -void -ServerPage::rateChanged(int index) -{ - /* If the "Custom" option is selected, show the custom bandwidth - * limits form. */ - ui.frmCustomRate->setVisible(index == CustomBwLimits); -} - -/** Called when the user edits the long-term average or maximum bandwidth limit. - * This ensures that the average bandwidth rate is greater than MIN_RATE - * (20KB/s) and that the max rate is greater than the average rate. */ -void -ServerPage::customRateChanged() -{ - /* Make sure the average rate isn't too low or too high */ - quint32 avgRate = (quint32)ui.lineAvgRateLimit->text().toUInt(); - if (avgRate < MIN_BANDWIDTH_RATE) { - ui.lineAvgRateLimit->setText(QString::number(MIN_BANDWIDTH_RATE)); - } - if (avgRate > MAX_BANDWIDTH_RATE) { - ui.lineAvgRateLimit->setText(QString::number(MAX_BANDWIDTH_RATE)); - } - /* Ensure the max burst rate is greater than the average rate but less than - * the maximum allowed rate. */ - quint32 burstRate = (quint32)ui.lineMaxRateLimit->text().toUInt(); - if (avgRate > burstRate) { - ui.lineMaxRateLimit->setText(QString::number(avgRate)); - } - if (burstRate > MAX_BANDWIDTH_RATE) { - ui.lineMaxRateLimit->setText(QString::number(MAX_BANDWIDTH_RATE)); - } -} - -/** Tests automatic port forwarding using UPnP. */ -void -ServerPage::testUpnp() -{ -#if defined(USE_MINIUPNPC) - UPNPTestDialog dlg(ui.lineServerPort->text().toUInt(), - ui.lineDirPort->text().toUInt(), this); - - connect(&dlg, SIGNAL(help()), this, SLOT(upnpHelp())); - - dlg.exec(); -#endif -} - -/** Called when the user clicks the UPnP test dialog's help button. */ -void -ServerPage::upnpHelp() -{ - emit helpRequested("server.upnp"); -} - diff -Nru vidalia-0.1.13/src/vidalia/config/ServerPage.cpp vidalia-0.2.8/src/vidalia/config/ServerPage.cpp --- vidalia-0.1.13/src/vidalia/config/ServerPage.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/ServerPage.cpp 2009-10-12 01:59:22.000000000 +0100 @@ -0,0 +1,612 @@ +/* +** 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.vidalia-project.net/. 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 ServerPage.cpp +** \version $Id: ServerPage.cpp 4143 2009-10-12 00:59:22Z edmanm $ +** \brief Tor server configuration options +*/ + +#include "config.h" +#include "ServerPage.h" +#include "Vidalia.h" +#include "VMessageBox.h" +#include "ConfigDialog.h" +#include "IpValidator.h" +#include "PortValidator.h" +#include "DomainValidator.h" +#include "NicknameValidator.h" +#include "BridgeUsageDialog.h" + +#include "html.h" +#include "stringutil.h" + +#if defined(USE_MINIUPNPC) +#include "UPNPTestDialog.h" +#endif + + +#include +#include + +/* These are completely made up values (in bytes/sec). */ +#define CABLE256_AVG_RATE (32*1024) +#define CABLE256_MAX_RATE (64*1024) +#define CABLE512_AVG_RATE (64*1024) +#define CABLE512_MAX_RATE (128*1024) +#define CABLE768_AVG_RATE (96*1024) +#define CABLE768_MAX_RATE (192*1024) +#define T1_AVG_RATE (192*1024) +#define T1_MAX_RATE (384*1024) +#define HIGHBW_AVG_RATE (5120*1024) +#define HIGHBW_MAX_RATE (10240*1024) +/** Minimum allowed bandwidth rate (20KB) */ +#define MIN_BANDWIDTH_RATE 20 +/** Maximum bandwidth rate. This is limited to 2147483646 bytes, + * or 2097151 kilobytes. (2147483646/1024) */ +#define MAX_BANDWIDTH_RATE 2097151 + +/** Ports represented by the "Websites" checkbox. (80) */ +#define PORTS_HTTP (QStringList() << "80") +/** Ports represented by the "Secure Websites" checkbox. (443) */ +#define PORTS_HTTPS (QStringList() << "443") +/** Ports represented by the "Retrieve Mail" checkbox. (110,143,993,995) */ +#define PORTS_MAIL (QStringList() << "110" << "143" << "993" << "995") +/** Ports represented by the "Instant Messaging" checkbox. + * (703,1863,5050,5190,5222,8300,8888) */ +#define PORTS_IM (QStringList() << "706" << "1863" << "5050" << "5190" \ + << "5222" << "5223" << "8300" << "8888") +/** Ports represented by the "Internet Relay Chat" checkbox. + * (6660-6669,6697,7000-7001) */ +#define PORTS_IRC (QStringList() << "6660-6669" << "6697" << "7000-7001") + + +/** Constructor */ +ServerPage::ServerPage(QWidget *parent) +: ConfigPage(parent, "Server") +{ + /* Invoke the Qt Designer generated object setup routine */ + ui.setupUi(this); + + /* Create ServerSettings object */ + _settings = new ServerSettings(Vidalia::torControl()); + + /* Bind events to actions */ + connect(ui.btnRateHelp, SIGNAL(clicked()), this, SLOT(bandwidthHelp())); + connect(ui.btnExitHelp, SIGNAL(clicked()), this, SLOT(exitPolicyHelp())); + connect(ui.btnUpnpHelp, SIGNAL(clicked()), this, SLOT(upnpHelp())); + connect(ui.cmboRate, SIGNAL(currentIndexChanged(int)), + this, SLOT(rateChanged(int))); + connect(ui.lineAvgRateLimit, SIGNAL(editingFinished()), + this, SLOT(customRateChanged())); + connect(ui.lineMaxRateLimit, SIGNAL(editingFinished()), + this, SLOT(customRateChanged())); + connect(ui.rdoClientMode, SIGNAL(toggled(bool)), + this, SLOT(serverModeChanged(bool))); + connect(ui.rdoServerMode, SIGNAL(toggled(bool)), + this, SLOT(serverModeChanged(bool))); + connect(ui.rdoBridgeMode, SIGNAL(toggled(bool)), + this, SLOT(serverModeChanged(bool))); + connect(Vidalia::torControl(), SIGNAL(authenticated()), + this, SLOT(onAuthenticated())); + connect(Vidalia::torControl(), SIGNAL(disconnected()), + this, SLOT(onDisconnected())); + connect(ui.btnCopyBridgeIdentity, SIGNAL(clicked()), + this, SLOT(copyBridgeIdentity())); + connect(ui.lblBridgeUsage, SIGNAL(linkActivated(QString)), + this, SLOT(linkActivated(QString))); + + /* Set validators for address, mask and various port number fields */ + ui.lineServerNickname->setValidator(new NicknameValidator(this)); + ui.lineServerPort->setValidator(new QIntValidator(1, 65535, this)); + ui.lineDirPort->setValidator(new QIntValidator(1, 65535, this)); + ui.lineAvgRateLimit->setValidator( + new QIntValidator(MIN_BANDWIDTH_RATE, MAX_BANDWIDTH_RATE, this)); + ui.lineMaxRateLimit->setValidator( + new QIntValidator(MIN_BANDWIDTH_RATE, MAX_BANDWIDTH_RATE, this)); + +#if defined(USE_MINIUPNPC) + connect(ui.btnTestUpnp, SIGNAL(clicked()), this, SLOT(testUpnp())); +#else + ui.chkEnableUpnp->setVisible(false); + ui.btnTestUpnp->setVisible(false); +#endif +} + +/** Destructor */ +ServerPage::~ServerPage() +{ + delete _settings; +} + +/** Called when the user changes the UI translation. */ +void +ServerPage::retranslateUi() +{ + ui.retranslateUi(this); +} + +/** Called when Vidalia has authenticated to Tor. If the user's Tor is not + * recent enough, this disables the bridge server option and displays a + * warning if the user had previously configured Tor as a bridge. */ +void +ServerPage::onAuthenticated() +{ + quint32 torVersion = Vidalia::torControl()->getTorVersion(); + if (torVersion < 0x020008) { + ui.rdoBridgeMode->setEnabled(false); + if (ui.rdoBridgeMode->isChecked()) { + int ret = VMessageBox::warning(this, + tr("Bridge Support Unavailable"), + p(tr("You have configured Tor to act as a bridge relay " + "for censored users, but your version of Tor does not " + "support bridges.")) + + p(tr("Please upgrade your Tor software or configure Tor to " + "act as a normal Tor relay.")), + VMessageBox::ShowSettings|VMessageBox::Default, + VMessageBox::Cancel); + if (ret == VMessageBox::ShowSettings) { + ConfigDialog *dialog = dynamic_cast(window()); + if (dialog) + dialog->showWindow(ConfigDialog::Server); + } + } + } +} + +/** Called when Vidalia disconnects from Tor. This method reenables the bridge + * server option. */ +void +ServerPage::onDisconnected() +{ + ui.rdoBridgeMode->setEnabled(true); +} + +/** Copies the user's bridge relay identity to the clipboard. */ +void +ServerPage::copyBridgeIdentity() +{ + QString bridge = ui.lblBridgeIdentity->text(); + if (!bridge.isEmpty()) + vApp->clipboard()->setText(bridge); +} + +/** Loads the user's bridge relay identity into the appropriate widgets. If + * the user's bridge is not running, then "Not Running" will be displayed. + * Otherwise, either the bridge's "address:port", "fingerprint", or + * "address:port fingerprint" will be displayed, depending on whether our + * GETCONF and GETINFO commands are successful. */ +void +ServerPage::loadBridgeIdentity() +{ + TorControl *tc = Vidalia::torControl(); + QString bridge, address, orPort, fingerprint; + + if (tc->isConnected()) { + tc->getInfo("address", address); + tc->getInfo("fingerprint", fingerprint); + tc->getConf("ORPort", orPort); + + if (!address.isEmpty() && !orPort.isEmpty() && orPort != "0") + bridge = address + ":" + orPort + " "; + if (!fingerprint.isEmpty()) + bridge += fingerprint; + bridge = bridge.trimmed(); + } + + ui.lblBridgeIdentity->setText(bridge.isEmpty() + ? tr("Your bridge relay is not running.") + : bridge); + ui.lblYourBridgeRelayIs->setEnabled(!bridge.isEmpty()); + ui.lblBridgeIdentity->setEnabled(!bridge.isEmpty()); + ui.btnCopyBridgeIdentity->setEnabled(!bridge.isEmpty()); +} + +/** Called when the user toggles any one of the server mode radio buttons + * and hides or displays the server configuration tabs appropriately. */ +void +ServerPage::serverModeChanged(bool enabled) +{ + Q_UNUSED(enabled); + bool bridgeEnabled = ui.rdoBridgeMode->isChecked(); + + /* Show the tab menu only if the user is running a normal relay or a bridge + * relay. */ + ui.tabsMenu->setVisible(ui.rdoServerMode->isChecked() || bridgeEnabled); + + /* Disable the Exit Policies tab when bridge relay mode is selected */ + ui.tabsMenu->setTabEnabled(2, !bridgeEnabled); + + /* Display the widgets that show the user their bridge identity if bridge + * relay mode is selected. */ + ui.lblYourBridgeRelayIs->setVisible(bridgeEnabled); + ui.lblBridgeIdentity->setVisible(bridgeEnabled); + ui.btnCopyBridgeIdentity->setVisible(bridgeEnabled); + ui.chkPublishBridgeAddress->setVisible(bridgeEnabled); + ui.lblBridgeUsage->setVisible(bridgeEnabled + && Vidalia::torControl()->isConnected()); +} + +/** Returns true if the user has changed their server settings since the + * last time they were applied to Tor. */ +bool +ServerPage::changedSinceLastApply() +{ + return _settings->changedSinceLastApply(); +} + +/** Applies the server configuration settings to Tor. Returns true if the + * settings were applied successfully. Otherwise, errmsg is + * set and false is returned. */ +bool +ServerPage::apply(QString &errmsg) +{ + return _settings->apply(&errmsg); +} + +/** Returns true if the user has changed their server settings since the + * last time they were applied to Tor. */ +void +ServerPage::revert() +{ + _settings->revert(); +} + +/** Saves changes made to settings on the Server settings page. */ +bool +ServerPage::save(QString &errmsg) +{ + /* Force the bandwidth rate limits to validate */ + customRateChanged(); + + if (ui.rdoServerMode->isChecked() || ui.rdoBridgeMode->isChecked()) { + /* A server must have an ORPort and a nickname */ + if (ui.lineServerPort->text().isEmpty() || + ui.lineServerNickname->text().isEmpty()) { + errmsg = tr("You must specify at least a relay nickname and port."); + return false; + } + /* If the bandwidth rates aren't set, use some defaults before saving */ + if (ui.lineAvgRateLimit->text().isEmpty()) { + ui.lineAvgRateLimit->setText(QString::number(2097152/1024) /* 2MB */); + } + if (ui.lineMaxRateLimit->text().isEmpty()) { + ui.lineMaxRateLimit->setText(QString::number(5242880/1024) /* 5MB */); + } + } + + /* "Server" is enabled whether we're a bridge or normal relay. "Bridge" is + * only enabled if we're a bridge (obviously). */ + _settings->setServerEnabled(ui.rdoServerMode->isChecked() + || ui.rdoBridgeMode->isChecked()); + _settings->setBridgeEnabled(ui.rdoBridgeMode->isChecked()); + if (ui.rdoBridgeMode->isChecked()) + _settings->setPublishServerDescriptor(ui.chkPublishBridgeAddress->isChecked()); + + /* Save the rest of the server settings. */ + _settings->setDirectoryMirror(ui.chkMirrorDirectory->isChecked()); + _settings->setNickname(ui.lineServerNickname->text()); + _settings->setORPort(ui.lineServerPort->text().toUInt()); + _settings->setDirPort(ui.lineDirPort->text().toUInt()); + _settings->setContactInfo(ui.lineServerContact->text()); + saveBandwidthLimits(); + saveExitPolicies(); + +#if defined(USE_MINIUPNPC) + _settings->setUpnpEnabled(ui.chkEnableUpnp->isChecked()); +#endif + + return true; +} + +/** Loads previously saved settings */ +void +ServerPage::load() +{ + if (_settings->isBridgeEnabled()) + ui.rdoBridgeMode->setChecked(true); + else if (_settings->isServerEnabled()) + ui.rdoServerMode->setChecked(true); + else + ui.rdoClientMode->setChecked(true); + + ui.lineServerNickname->setText(_settings->getNickname()); + ui.lineServerPort->setText(QString::number(_settings->getORPort())); + ui.lineDirPort->setText(QString::number(_settings->getDirPort())); + ui.lineServerContact->setText(_settings->getContactInfo()); + ui.chkMirrorDirectory->setChecked(_settings->isDirectoryMirror()); + ui.lblBridgeUsage->setVisible(_settings->isBridgeEnabled() + && Vidalia::torControl()->isConnected()); + ui.chkPublishBridgeAddress->setChecked(_settings->publishServerDescriptor()); + + loadBandwidthLimits(); + loadExitPolicies(); + loadBridgeIdentity(); + +#if defined(USE_MINIUPNPC) + ui.chkEnableUpnp->setChecked(_settings->isUpnpEnabled()); +#endif +} + +/** Shows exit policy related help information */ +void +ServerPage::exitPolicyHelp() +{ + emit helpRequested("server.exitpolicy"); +} + +/** Shows the bandwidth rate limiting help information */ +void +ServerPage::bandwidthHelp() +{ + emit helpRequested("server.bandwidth"); +} + +/** Loads the server's bandwidth average and burst limits. */ +void +ServerPage::loadBandwidthLimits() +{ + quint32 avgRate = _settings->getBandwidthAvgRate(); + quint32 maxRate = _settings->getBandwidthBurstRate(); + + if (avgRate == CABLE256_AVG_RATE && + maxRate == CABLE256_MAX_RATE) { + /* Cable/DSL 256 Kbps */ + ui.cmboRate->setCurrentIndex(CableDsl256); + } else if (avgRate == CABLE512_AVG_RATE && + maxRate == CABLE512_MAX_RATE) { + /* Cable/DSL 512 Kbps */ + ui.cmboRate->setCurrentIndex(CableDsl512); + } else if (avgRate == CABLE768_AVG_RATE && + maxRate == CABLE768_MAX_RATE) { + /* Cable/DSL 768 Kbps */ + ui.cmboRate->setCurrentIndex(CableDsl768); + } else if (avgRate == T1_AVG_RATE && + maxRate == T1_MAX_RATE) { + /* T1/Cable/DSL 1.5 Mbps */ + ui.cmboRate->setCurrentIndex(T1CableDsl1500); + } else if (avgRate == HIGHBW_AVG_RATE && + maxRate == HIGHBW_MAX_RATE) { + /* > 1.5 Mbps */ + ui.cmboRate->setCurrentIndex(GreaterThan1500); + } else { + /* Custom bandwidth limits */ + ui.cmboRate->setCurrentIndex(CustomBwLimits); + } + /* Fill in the custom bandwidth limit boxes */ + ui.lineAvgRateLimit->setText(QString::number(avgRate/1024)); + ui.lineMaxRateLimit->setText(QString::number(maxRate/1024)); +} + +/** Saves the server's bandwidth average and burst limits. */ +void +ServerPage::saveBandwidthLimits() +{ + quint32 avgRate, maxRate; + + switch (ui.cmboRate->currentIndex()) { + case CableDsl256: /* Cable/DSL 256 Kbps */ + avgRate = CABLE256_AVG_RATE; + maxRate = CABLE256_MAX_RATE; + break; + case CableDsl512: /* Cable/DSL 512 Kbps */ + avgRate = CABLE512_AVG_RATE; + maxRate = CABLE512_MAX_RATE; + break; + case CableDsl768: /* Cable/DSL 768 Kbps */ + avgRate = CABLE768_AVG_RATE; + maxRate = CABLE768_MAX_RATE; + break; + case T1CableDsl1500: /* T1/Cable/DSL 1.5 Mbps */ + avgRate = T1_AVG_RATE; + maxRate = T1_MAX_RATE; + break; + case GreaterThan1500: /* > 1.5 Mbps */ + avgRate = HIGHBW_AVG_RATE; + maxRate = HIGHBW_MAX_RATE; + break; + default: /* Custom bandwidth limits */ + avgRate = (quint32)(ui.lineAvgRateLimit->text().toUInt()*1024); + maxRate = (quint32)(ui.lineMaxRateLimit->text().toUInt()*1024); + break; + } + _settings->setBandwidthAvgRate(avgRate); + _settings->setBandwidthBurstRate(maxRate); +} + +/** */ +void +ServerPage::loadExitPolicies() +{ + ExitPolicy exitPolicy = _settings->getExitPolicy(); + + if (exitPolicy.contains(Policy(Policy::RejectAll))) { + /* If the policy ends with reject *:*, check if the policy explicitly + * accepts these ports */ + ui.chkWebsites->setChecked(exitPolicy.acceptsPorts(PORTS_HTTP)); + ui.chkSecWebsites->setChecked(exitPolicy.acceptsPorts(PORTS_HTTPS)); + ui.chkMail->setChecked(exitPolicy.acceptsPorts(PORTS_MAIL)); + ui.chkIRC->setChecked(exitPolicy.acceptsPorts(PORTS_IRC)); + ui.chkIM->setChecked(exitPolicy.acceptsPorts(PORTS_IM)); + ui.chkMisc->setChecked(false); + } else { + /* If the exit policy ends with accept *:*, check if the policy explicitly + * rejects these ports */ + ui.chkWebsites->setChecked(!exitPolicy.rejectsPorts(PORTS_HTTP)); + ui.chkSecWebsites->setChecked(!exitPolicy.rejectsPorts(PORTS_HTTPS)); + ui.chkMail->setChecked(!exitPolicy.rejectsPorts(PORTS_MAIL)); + ui.chkIRC->setChecked(!exitPolicy.rejectsPorts(PORTS_IRC)); + ui.chkIM->setChecked(!exitPolicy.rejectsPorts(PORTS_IM)); + ui.chkMisc->setChecked(true); + } +} + +/** */ +void +ServerPage::saveExitPolicies() +{ + ExitPolicy exitPolicy; + bool rejectUnchecked = ui.chkMisc->isChecked(); + + /* If misc is checked, then reject unchecked items and leave the default exit + * policy alone. Else, accept only checked items and end with reject *:*, + * replacing the default exit policy. */ + if (ui.chkWebsites->isChecked() && !rejectUnchecked) { + exitPolicy.addAcceptedPorts(PORTS_HTTP); + } else if (!ui.chkWebsites->isChecked() && rejectUnchecked) { + exitPolicy.addRejectedPorts(PORTS_HTTP); + } + if (ui.chkSecWebsites->isChecked() && !rejectUnchecked) { + exitPolicy.addAcceptedPorts(PORTS_HTTPS); + } else if (!ui.chkSecWebsites->isChecked() && rejectUnchecked) { + exitPolicy.addRejectedPorts(PORTS_HTTPS); + } + if (ui.chkMail->isChecked() && !rejectUnchecked) { + exitPolicy.addAcceptedPorts(PORTS_MAIL); + } else if (!ui.chkMail->isChecked() && rejectUnchecked) { + exitPolicy.addRejectedPorts(PORTS_MAIL); + } + if (ui.chkIRC->isChecked() && !rejectUnchecked) { + exitPolicy.addAcceptedPorts(PORTS_IRC); + } else if (!ui.chkIRC->isChecked() && rejectUnchecked) { + exitPolicy.addRejectedPorts(PORTS_IRC); + } + if (ui.chkIM->isChecked() && !rejectUnchecked) { + exitPolicy.addAcceptedPorts(PORTS_IM); + } else if (!ui.chkIM->isChecked() && rejectUnchecked) { + exitPolicy.addRejectedPorts(PORTS_IM); + } + if (!ui.chkMisc->isChecked()) { + exitPolicy.addPolicy(Policy(Policy::RejectAll)); + } + _settings->setExitPolicy(exitPolicy); +} + +/** Called when the user selects a new value from the rate combo box. */ +void +ServerPage::rateChanged(int index) +{ + /* If the "Custom" option is selected, show the custom bandwidth + * limits form. */ + ui.frmCustomRate->setVisible(index == CustomBwLimits); +} + +/** Called when the user edits the long-term average or maximum bandwidth limit. + * This ensures that the average bandwidth rate is greater than MIN_RATE + * (20KB/s) and that the max rate is greater than the average rate. */ +void +ServerPage::customRateChanged() +{ + /* Make sure the average rate isn't too low or too high */ + quint32 avgRate = (quint32)ui.lineAvgRateLimit->text().toUInt(); + if (avgRate < MIN_BANDWIDTH_RATE) { + ui.lineAvgRateLimit->setText(QString::number(MIN_BANDWIDTH_RATE)); + } + if (avgRate > MAX_BANDWIDTH_RATE) { + ui.lineAvgRateLimit->setText(QString::number(MAX_BANDWIDTH_RATE)); + } + /* Ensure the max burst rate is greater than the average rate but less than + * the maximum allowed rate. */ + quint32 burstRate = (quint32)ui.lineMaxRateLimit->text().toUInt(); + if (avgRate > burstRate) { + ui.lineMaxRateLimit->setText(QString::number(avgRate)); + } + if (burstRate > MAX_BANDWIDTH_RATE) { + ui.lineMaxRateLimit->setText(QString::number(MAX_BANDWIDTH_RATE)); + } +} + +/** Tests automatic port forwarding using UPnP. */ +void +ServerPage::testUpnp() +{ +#if defined(USE_MINIUPNPC) + UPNPTestDialog dlg(ui.lineServerPort->text().toUInt(), + ui.lineDirPort->text().toUInt(), this); + + connect(&dlg, SIGNAL(help()), this, SLOT(upnpHelp())); + + dlg.exec(); +#endif +} + +/** Called when the user clicks the UPnP test dialog's help button. */ +void +ServerPage::upnpHelp() +{ + emit helpRequested("server.upnp"); +} + +/** Called when the user clicks on a QLabel containing a hyperlink. */ +void +ServerPage::linkActivated(const QString &url) +{ + if (!url.compare("#bridgeUsage")) + displayBridgeUsage(); +} + +/** Retrieves bridge usage history from Tor, parses and validates it, and + * then displays it in a new dialog. */ +void +ServerPage::displayBridgeUsage() +{ + QString info; + + info = Vidalia::torControl()->getInfo("status/clients-seen").toString(); + if (info.isEmpty()) { + QMessageBox dlg(QMessageBox::Information, tr("No Recent Usage"), + tr("No clients have used your relay recently."), + QMessageBox::Ok, this); + dlg.setInformativeText(tr("Leave your relay running so clients have " + "a better chance of finding and using it.")); + dlg.exec(); + } else { + QDateTime timeStarted; + QHash countrySummary; + QHash keyvals; + BridgeUsageDialog dlg(this); + bool ok; + + keyvals = string_parse_keyvals(info, &ok); + if (!ok || !keyvals.contains("TimeStarted") + || !keyvals.contains("CountrySummary")) + goto err; + + timeStarted = QDateTime::fromString(keyvals.value("TimeStarted"), + "yyyy-MM-dd HH:mm:ss"); + if (!timeStarted.isValid()) + goto err; + + foreach (QString pair, keyvals.value("CountrySummary").split(",")) { + QStringList parts = pair.split("="); + if (parts.size() != 2) + goto err; + + countrySummary.insert(parts.at(0).toUpper(), parts.at(1).toInt(&ok)); + if (!ok) + goto err; + } + + dlg.update(timeStarted, countrySummary); + dlg.exec(); + } + return; + +err: + QMessageBox dlg(QMessageBox::Warning, tr("Bridge History"), + tr("Vidalia was unable to retrieve your bridge's usage " + "history."), QMessageBox::Ok, this); + dlg.setInformativeText(tr("Tor returned an improperly formatted " + "response when Vidalia requested your " + "bridge's usage history.")); + dlg.setDetailedText(tr("The returned response was: %1").arg(info)); + dlg.exec(); +} + diff -Nru vidalia-0.1.13/src/vidalia/config/serverpage.h vidalia-0.2.8/src/vidalia/config/serverpage.h --- vidalia-0.1.13/src/vidalia/config/serverpage.h 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/serverpage.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,120 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 serverpage.h -** \version $Id: serverpage.h 2684 2008-06-10 04:50:15Z edmanm $ -** \brief Tor server configuration options -*/ - -#ifndef _SERVERPAGE_H -#define _SERVERPAGE_H - -#include -#include -#include -#include -#include -#include - -#include "configpage.h" -#include "ui_serverpage.h" - - -class ServerPage : public ConfigPage -{ - Q_OBJECT - -public: - /** Default Constructor */ - ServerPage(QWidget *parent = 0); - /** Default Destructor */ - ~ServerPage(); - /** Saves the changes on this page */ - bool save(QString &errmsg); - /** Loads the settings for this page */ - void load(); - - /** Applies the server configuration settings to Tor. Returns true if the - * settings were applied successfully. Otherwise, errmsg is set and - * false is returned. */ - bool apply(QString &errmsg); - /** Reverts the server configuration settings to their values at the last - * time they were successfully applied to Tor. */ - void revert(); - /** Returns true if the user has changed their server settings since the - * last time they were applied to Tor. */ - bool changedSinceLastApply(); - -private slots: - /** Called when the user toggles any one of the server mode radio buttons - * and hides or displays the server configuration tabs appropriately. */ - void serverModeChanged(bool enabled); - /** Called when the user clicks the bandwidth help button */ - void bandwidthHelp(); - /** Called when the user clicks the exit policy help button */ - void exitPolicyHelp(); - /** Called when the user selects a new value from the rate combo box */ - void rateChanged(int rate); - /** Called when the user edits the max or average bandwidth limits. */ - void customRateChanged(); - /** Called when Vidalia has authenticated to Tor. If the user's Tor is not - * recent enough, this disables the bridge server option and displays a - * warning if the user had previously configured Tor as a bridge. */ - void onAuthenticated(); - /** Called when Vidalia disconnects from Tor. This method reenables the - * bridge server option. */ - void onDisconnected(); - /** Copies the user's bridge relay identity to the clipboard. */ - void copyBridgeIdentity(); - /** Tests automatic port forwarding with UPnP. */ - void testUpnp(); - /** Called when the user clicks the UPnP test dialog's help button. */ - void upnpHelp(); - -private: - /** Index values of rate values in the bandwidth limits dropdown box. */ - enum BwRateIndex { - CableDsl256 = 0, /**< Cable/DSL 256 Kbps */ - CableDsl512, /**< Cable/DSL 512 Kbps */ - CableDsl768, /**< Cable/DSL 768 Kbps */ - T1CableDsl1500, /**< T1/Cable/DSL 1.5 Mbps */ - GreaterThan1500, /**< > 1.5 Mbps */ - CustomBwLimits /**< Custom bandwidth limits */ - }; - - /** Returns the index of the selected item in lstExitPolicies */ - int selectedIndex(); - - /** Saves the server's bandwidth average and burst limits. */ - void saveBandwidthLimits(); - /** Loads the server's bandwidth average and burst limits. */ - void loadBandwidthLimits(); - /** Saves the server's exit policies. */ - void saveExitPolicies(); - /** Loads the server's exit policies. */ - void loadExitPolicies(); - /** Loads the user's bridge relay identity into the appropriate widgets. If - * the user's bridge is not running, then "Not Running" will be - * displayed. Otherwise, either the bridge's "address:port", "fingerprint", - * or "address:port fingerprint" will be displayed, depending on whether - * our GETCONF and GETINFO commands are successful. */ - void loadBridgeIdentity(); - - /** A ServerSettings object used to get and set information about how a - * local Tor server is configured. */ - ServerSettings* _settings; - - /** Qt Designer generated object */ - Ui::ServerPage ui; -}; - -#endif - diff -Nru vidalia-0.1.13/src/vidalia/config/ServerPage.h vidalia-0.2.8/src/vidalia/config/ServerPage.h --- vidalia-0.1.13/src/vidalia/config/ServerPage.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/ServerPage.h 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,127 @@ +/* +** 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.vidalia-project.net/. 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 ServerPage.h +** \version $Id: ServerPage.h 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Tor server configuration options +*/ + +#ifndef _SERVERPAGE_H +#define _SERVERPAGE_H + +#include "ui_ServerPage.h" +#include "ConfigPage.h" +#include "TorControl.h" +#include "ServerSettings.h" +#include "ExitPolicy.h" +#include "HelpBrowser.h" + +#include +#include + + +class ServerPage : public ConfigPage +{ + Q_OBJECT + +public: + /** Default Constructor */ + ServerPage(QWidget *parent = 0); + /** Default Destructor */ + ~ServerPage(); + /** Saves the changes on this page */ + bool save(QString &errmsg); + /** Loads the settings for this page */ + void load(); + + /** Applies the server configuration settings to Tor. Returns true if the + * settings were applied successfully. Otherwise, errmsg is set and + * false is returned. */ + bool apply(QString &errmsg); + /** Reverts the server configuration settings to their values at the last + * time they were successfully applied to Tor. */ + void revert(); + /** Returns true if the user has changed their server settings since the + * last time they were applied to Tor. */ + bool changedSinceLastApply(); + /** Called when the user changes the UI translation. */ + virtual void retranslateUi(); + +private slots: + /** Called when the user toggles any one of the server mode radio buttons + * and hides or displays the server configuration tabs appropriately. */ + void serverModeChanged(bool enabled); + /** Called when the user clicks the bandwidth help button */ + void bandwidthHelp(); + /** Called when the user clicks the exit policy help button */ + void exitPolicyHelp(); + /** Called when the user selects a new value from the rate combo box */ + void rateChanged(int rate); + /** Called when the user edits the max or average bandwidth limits. */ + void customRateChanged(); + /** Called when Vidalia has authenticated to Tor. If the user's Tor is not + * recent enough, this disables the bridge server option and displays a + * warning if the user had previously configured Tor as a bridge. */ + void onAuthenticated(); + /** Called when Vidalia disconnects from Tor. This method reenables the + * bridge server option. */ + void onDisconnected(); + /** Copies the user's bridge relay identity to the clipboard. */ + void copyBridgeIdentity(); + /** Tests automatic port forwarding with UPnP. */ + void testUpnp(); + /** Called when the user clicks the UPnP test dialog's help button. */ + void upnpHelp(); + /** Called when the user clicks on a QLabel containing a hyperlink. */ + void linkActivated(const QString &url); + +private: + /** Index values of rate values in the bandwidth limits dropdown box. */ + enum BwRateIndex { + CableDsl256 = 0, /**< Cable/DSL 256 Kbps */ + CableDsl512, /**< Cable/DSL 512 Kbps */ + CableDsl768, /**< Cable/DSL 768 Kbps */ + T1CableDsl1500, /**< T1/Cable/DSL 1.5 Mbps */ + GreaterThan1500, /**< > 1.5 Mbps */ + CustomBwLimits /**< Custom bandwidth limits */ + }; + + /** Returns the index of the selected item in lstExitPolicies */ + int selectedIndex(); + + /** Saves the server's bandwidth average and burst limits. */ + void saveBandwidthLimits(); + /** Loads the server's bandwidth average and burst limits. */ + void loadBandwidthLimits(); + /** Saves the server's exit policies. */ + void saveExitPolicies(); + /** Loads the server's exit policies. */ + void loadExitPolicies(); + /** Loads the user's bridge relay identity into the appropriate widgets. If + * the user's bridge is not running, then "Not Running" will be + * displayed. Otherwise, either the bridge's "address:port", "fingerprint", + * or "address:port fingerprint" will be displayed, depending on whether + * our GETCONF and GETINFO commands are successful. */ + void loadBridgeIdentity(); + /** Retrieves bridge usage history from Tor, parses and validates it, and + * then displays it in a new dialog. */ + void displayBridgeUsage(); + + /** A ServerSettings object used to get and set information about how a + * local Tor server is configured. */ + ServerSettings* _settings; + + /** Qt Designer generated object */ + Ui::ServerPage ui; +}; + +#endif + diff -Nru vidalia-0.1.13/src/vidalia/config/serverpage.ui vidalia-0.2.8/src/vidalia/config/serverpage.ui --- vidalia-0.1.13/src/vidalia/config/serverpage.ui 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/serverpage.ui 1970-01-01 01:00:00.000000000 +0100 @@ -1,1144 +0,0 @@ - - ServerPage - - - - 0 - 0 - 489 - 351 - - - - Qt::NoContextMenu - - - - 9 - - - 6 - - - - - Run as a client only - - - - - - - Relay traffic for the Tor network - - - - - - - Help censored users reach the Tor network - - - - - - - Qt::NoContextMenu - - - QFrame::NoFrame - - - QFrame::Plain - - - - 0 - - - 6 - - - - - - 7 - 7 - 0 - 0 - - - - 0 - - - - Basic Settings - - - - 9 - - - 6 - - - - - Qt::NoContextMenu - - - Relay Port: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 0 - - - 0 - - - - - - - Qt::NoContextMenu - - - Enable to mirror the relay directory - - - Mirror the Relay Directory - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Qt::NoContextMenu - - - - - - Attempt to automatically configure port forwarding - - - - - - - 0 - - - - - Qt::NoContextMenu - - - Test - - - - - - - Qt::NoContextMenu - - - Show help topic on port forwarding - - - - - - :/images/22x22/system-help.png - - - - 22 - 22 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - 4 - - - Qt::NoContextMenu - - - Email address at which you may be reached if there is a -problem with your relay. You might also include your PGP or GPG fingerprint. - - - - - - - 0 - - - 6 - - - - - false - - - - 0 - 0 - 0 - 0 - - - - Qt::NoContextMenu - - - Directory Port: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - false - - - - 0 - 0 - 0 - 0 - - - - - 50 - 16777215 - - - - 4 - - - Qt::NoContextMenu - - - Directory Port Number - - - - - - - - - Qt::NoContextMenu - - - Contact Info: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 0 - - - - - - - Qt::Horizontal - - - - 321 - 20 - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Qt::Horizontal - - - - 41 - 20 - - - - - - - - 4 - - - Qt::NoContextMenu - - - Name of your relay - - - - - - 19 - - - - - - - - 0 - 0 - 0 - 0 - - - - - 50 - 16777215 - - - - 4 - - - Qt::NoContextMenu - - - Port on which users and other relays can communicate with your relay - - - - - - - Qt::NoContextMenu - - - Nickname: - - - Qt::AutoText - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 0 - - - 0 - - - - - - - - Bandwidth Limits - - - - 9 - - - 6 - - - - - - 5 - 5 - 0 - 0 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - Qt::NoContextMenu - - - For Internet connections with fast download speed but slow upload, please list your upload speed here. - - - true - - - - - - - 0 - - - 6 - - - - - Qt::NoContextMenu - - - Select the entry that most closely resembles your Internet connection - - - 10 - - - QComboBox::AdjustToContents - - - - Cable/DSL 256 Kbps - - - - - Cable/DSL 512 Kbps - - - - - Cable/DSL 768 Kbps - - - - - T1/Cable/DSL 1.5 Mbps - - - - - > 1.5 Mbps - - - - - Custom - - - - - - - - Qt::NoContextMenu - - - Show help topic on bandwidth rate limits - - - - - - :/images/22x22/system-help.png - - - - 22 - 22 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Qt::NoContextMenu - - - QFrame::NoFrame - - - QFrame::Plain - - - - 9 - - - 6 - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - 0 - - - 6 - - - - - 0 - - - 6 - - - - - - 1 - 5 - 0 - 0 - - - - Average Rate - - - - - - - 0 - - - 6 - - - - - - 1 - 0 - 0 - 0 - - - - - 60 - 22 - - - - Long-term average bandwidth limit - - - 12 - - - Qt::AlignRight - - - - - - - KB/s - - - - - - - - - - - 0 - - - 6 - - - - - - 1 - 5 - 0 - 0 - - - - - 100 - 20 - - - - Maximum Rate - - - - - - - 0 - - - 6 - - - - - - 1 - 0 - 0 - 0 - - - - - 60 - 20 - - - - Peak bandwidth rate limit - - - 12 - - - Qt::AlignRight - - - - - - - KB/s - - - - - - - Qt::Horizontal - - - QSizePolicy::Expanding - - - - 71 - 20 - - - - - - - - - - - - - - Your maximum bandwidth rate must be greater than or equal to your average bandwidth rate. Both values must be at least 20 KB/s. - - - true - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - Exit Policies - - - - 9 - - - 6 - - - - - QFrame::NoFrame - - - QFrame::Plain - - - - 9 - - - 6 - - - - - 0 - - - 6 - - - - - Qt::NoContextMenu - - - Ports 6660 - 6669 and 6697 - - - Internet Relay Chat (IRC) - - - - - - - Qt::NoContextMenu - - - Ports 110, 143, 993 and 995 - - - Retrieve Mail (POP, IMAP) - - - - - - - Qt::NoContextMenu - - - Ports unspecified by other checkboxes - - - Misc Other Services - - - - - - - Qt::NoContextMenu - - - Ports 706, 1863, 5050, 5190, 5222, 5223, 8300 and 8888 - - - Instant Messaging (IM) - - - - - - - Qt::NoContextMenu - - - Port 443 - - - Secure Websites (SSL) - - - - - - - Qt::NoContextMenu - - - Port 80 - - - Websites - - - - - - - - - 0 - - - 6 - - - - - - 32 - 32 - - - - Qt::NoContextMenu - - - Show help topic on exit policies - - - - - - :/images/22x22/system-help.png - - - - 22 - 22 - - - - - - - - Qt::Vertical - - - - 20 - 42 - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - 0 - 0 - 0 - 0 - - - - - 300 - 41 - - - - - 300 - 41 - - - - Qt::NoContextMenu - - - What Internet resources should users be able to access from your relay? - - - true - - - - - - - Tor will still block some outgoing mail and file sharing applications by default to reduce spam and other abuse. - - - true - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - - - 0 - - - QFrame::NoFrame - - - Let others access your bridge by giving them this line: - - - true - - - Qt::TextSelectableByMouse - - - - - - - 0 - - - 6 - - - - - 4 - - - This is the identity of your bridge relay that you can give to other people - - - QFrame::StyledPanel - - - QFrame::Sunken - - - - - - Qt::TextSelectableByMouse - - - - - - - false - - - Copy your bridge relay's identity to the clipboard - - - - - - :/images/22x22/edit-copy.png - - - - - - - - - Qt::Vertical - - - - 420 - 16 - - - - - - - - tabsMenu - lineServerNickname - lineServerContact - lineServerPort - chkMirrorDirectory - lineDirPort - cmboRate - lineAvgRateLimit - lineMaxRateLimit - btnRateHelp - chkWebsites - chkSecWebsites - chkMail - chkIM - chkIRC - chkMisc - btnExitHelp - - - - - - - chkMirrorDirectory - toggled(bool) - lineDirPort - setEnabled(bool) - - - -1 - -1 - - - -1 - -1 - - - - - chkMirrorDirectory - toggled(bool) - lblDirPort - setEnabled(bool) - - - -1 - -1 - - - -1 - -1 - - - - - diff -Nru vidalia-0.1.13/src/vidalia/config/ServerPage.ui vidalia-0.2.8/src/vidalia/config/ServerPage.ui --- vidalia-0.1.13/src/vidalia/config/ServerPage.ui 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/ServerPage.ui 2009-10-12 01:59:22.000000000 +0100 @@ -0,0 +1,1061 @@ + + + ServerPage + + + + 0 + 0 + 546 + 463 + + + + Qt::NoContextMenu + + + + + + Run as a client only + + + + + + + Relay traffic for the Tor network + + + + + + + Help censored users reach the Tor network + + + + + + + Qt::NoContextMenu + + + QFrame::NoFrame + + + QFrame::Plain + + + + 0 + + + + + + 0 + 0 + + + + 0 + + + + Basic Settings + + + + + + Qt::NoContextMenu + + + Relay Port: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 0 + + + 0 + + + + + + + Qt::NoContextMenu + + + Enable to mirror the relay directory + + + Mirror the Relay Directory + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::NoContextMenu + + + + + + Attempt to automatically configure port forwarding + + + + + + + + + Qt::NoContextMenu + + + Test + + + + + + + Qt::NoContextMenu + + + Show help topic on port forwarding + + + + + + + :/images/22x22/system-help.png:/images/22x22/system-help.png + + + + 22 + 22 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + IBeamCursor + + + Qt::NoContextMenu + + + Email address at which you may be reached if there is a +problem with your relay. You might also include your PGP or GPG fingerprint. + + + + + + + + + false + + + + 0 + 0 + + + + Qt::NoContextMenu + + + Directory Port: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + false + + + + 0 + 0 + + + + + 50 + 16777215 + + + + IBeamCursor + + + Qt::NoContextMenu + + + Directory Port Number + + + + + + + + + Qt::NoContextMenu + + + Contact Info: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 0 + + + + + + + Qt::Horizontal + + + + 321 + 20 + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Qt::Horizontal + + + + 41 + 20 + + + + + + + + IBeamCursor + + + Qt::NoContextMenu + + + Name of your relay + + + + + + 19 + + + + + + + + 0 + 0 + + + + + 50 + 16777215 + + + + IBeamCursor + + + Qt::NoContextMenu + + + Port on which users and other relays can communicate with your relay + + + + + + + Qt::NoContextMenu + + + Nickname: + + + Qt::AutoText + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 0 + + + 0 + + + + + + + + Bandwidth Limits + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + Qt::NoContextMenu + + + For Internet connections with fast download speed but slow upload, please list your upload speed here. + + + true + + + + + + + + + Qt::NoContextMenu + + + Select the entry that most closely resembles your Internet connection + + + 10 + + + QComboBox::AdjustToContents + + + + Cable/DSL 256 Kbps + + + + + Cable/DSL 512 Kbps + + + + + Cable/DSL 768 Kbps + + + + + T1/Cable/DSL 1.5 Mbps + + + + + > 1.5 Mbps + + + + + Custom + + + + + + + + Qt::NoContextMenu + + + Show help topic on bandwidth rate limits + + + + + + + :/images/22x22/system-help.png:/images/22x22/system-help.png + + + + 22 + 22 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::NoContextMenu + + + QFrame::NoFrame + + + QFrame::Plain + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + 0 + 0 + + + + Average Rate + + + + + + + + + + 0 + 0 + + + + + 60 + 22 + + + + Long-term average bandwidth limit + + + 12 + + + Qt::AlignRight + + + + + + + KB/s + + + + + + + + + + + + + + 0 + 0 + + + + + 100 + 20 + + + + Maximum Rate + + + + + + + + + + 0 + 0 + + + + + 60 + 20 + + + + Peak bandwidth rate limit + + + 12 + + + Qt::AlignRight + + + + + + + KB/s + + + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 71 + 20 + + + + + + + + + + + + + + Your maximum bandwidth rate must be greater than or equal to your average bandwidth rate. Both values must be at least 20 KB/s. + + + true + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + Exit Policies + + + + + + QFrame::NoFrame + + + QFrame::Plain + + + + + + + + Qt::NoContextMenu + + + Ports 6660 - 6669 and 6697 + + + Internet Relay Chat (IRC) + + + + + + + Qt::NoContextMenu + + + Ports 110, 143, 993 and 995 + + + Retrieve Mail (POP, IMAP) + + + + + + + Qt::NoContextMenu + + + Ports unspecified by other checkboxes + + + Misc Other Services + + + + + + + Qt::NoContextMenu + + + Ports 706, 1863, 5050, 5190, 5222, 5223, 8300 and 8888 + + + Instant Messaging (IM) + + + + + + + Qt::NoContextMenu + + + Port 443 + + + Secure Websites (SSL) + + + + + + + Qt::NoContextMenu + + + Port 80 + + + Websites + + + + + + + + + + + + 32 + 32 + + + + Qt::NoContextMenu + + + Show help topic on exit policies + + + + + + + :/images/22x22/system-help.png:/images/22x22/system-help.png + + + + 22 + 22 + + + + + + + + Qt::Vertical + + + + 20 + 42 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + 0 + 0 + + + + + 300 + 41 + + + + + 300 + 41 + + + + Qt::NoContextMenu + + + What Internet resources should users be able to access from your relay? + + + true + + + + + + + Tor will still block some outgoing mail and file sharing applications by default to reduce spam and other abuse. + + + true + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + + ArrowCursor + + + QFrame::NoFrame + + + Let others access your bridge by giving them this line: + + + true + + + Qt::TextSelectableByMouse + + + + + + + + + IBeamCursor + + + This is the identity of your bridge relay that you can give to other people + + + QFrame::StyledPanel + + + QFrame::Sunken + + + + + + Qt::TextSelectableByMouse + + + + + + + false + + + Copy your bridge relay's identity to the clipboard + + + + + + + :/images/22x22/edit-copy.png:/images/22x22/edit-copy.png + + + + + + + + + + + Automatically distribute my bridge address + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + <a href="#bridgeUsage">Who has used my bridge?</a> + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + + + Qt::Vertical + + + + 420 + 16 + + + + + + + + tabsMenu + lineServerNickname + lineServerContact + lineServerPort + chkMirrorDirectory + lineDirPort + cmboRate + lineAvgRateLimit + lineMaxRateLimit + btnRateHelp + chkWebsites + chkSecWebsites + chkMail + chkIM + chkIRC + chkMisc + btnExitHelp + + + + + + + chkMirrorDirectory + toggled(bool) + lineDirPort + setEnabled(bool) + + + -1 + -1 + + + -1 + -1 + + + + + chkMirrorDirectory + toggled(bool) + lblDirPort + setEnabled(bool) + + + -1 + -1 + + + -1 + -1 + + + + + diff -Nru vidalia-0.1.13/src/vidalia/config/serversettings.cpp vidalia-0.2.8/src/vidalia/config/serversettings.cpp --- vidalia-0.1.13/src/vidalia/config/serversettings.cpp 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/serversettings.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,387 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 serversettings.cpp -** \version $Id: serversettings.cpp 3621 2009-03-16 19:30:44Z edmanm $ -** \brief Settings for running a Tor server -*/ - -#include -#include -#include -#include - -#include "serversettings.h" -#include "torsettings.h" - -#ifdef USE_MINIUPNPC -#include "upnpcontrol.h" -#endif - -/** Define the set of characters that are valid in a nickname. */ -#define VALID_NICKNAME_CHARS \ - "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" -/** Define the maximum length of a server's nickname. */ -#define MAX_NICKNAME_LEN 19 - -/* Server configuration settings */ -#define SETTING_ENABLED "Enabled" -#define SETTING_DIRMIRROR "DirectoryMirror" -#define SETTING_NICKNAME "Nickname" -#define SETTING_ORPORT "ORPort" -#define SETTING_DIRPORT "DirPort" -#define SETTING_CONTACT "ContactInfo" -#define SETTING_EXITPOLICY "ExitPolicy" -#define SETTING_BANDWIDTH_RATE "BandwidthRate" -#define SETTING_BANDWIDTH_BURST "BandwidthBurst" -#define SETTING_BRIDGE_RELAY "BridgeRelay" -#define SETTING_ENABLE_UPNP "EnableUPnP" -#define SETTING_RELAY_BANDWIDTH_RATE "RelayBandwidthRate" -#define SETTING_RELAY_BANDWIDTH_BURST "RelayBandwidthBurst" - - -/** Constructor. - * \param torControl a TorControl object used to read and apply the server - * configuration settings. - */ -ServerSettings::ServerSettings(TorControl *torControl) -: AbstractTorSettings("Server", torControl) -{ - setDefault(SETTING_ENABLED, false); - setDefault(SETTING_DIRMIRROR, true); -#if defined(Q_OS_WIN32) - setDefault(SETTING_ORPORT, 443); -#else - setDefault(SETTING_ORPORT, 9001); -#endif - setDefault(SETTING_DIRPORT, 9030); - setDefault(SETTING_NICKNAME, "Unnamed"); - setDefault(SETTING_CONTACT, ""); - setDefault(SETTING_BANDWIDTH_RATE, 5242880); - setDefault(SETTING_RELAY_BANDWIDTH_RATE, 5242880); - setDefault(SETTING_BANDWIDTH_BURST, 10485760); - setDefault(SETTING_RELAY_BANDWIDTH_BURST, 10485760); - setDefault(SETTING_EXITPOLICY, - ExitPolicy(ExitPolicy::Default).toString()); - setDefault(SETTING_ENABLE_UPNP, false); - setDefault(SETTING_BRIDGE_RELAY, false); -} - -/** Returns a QHash of Tor-recognizable configuratin keys to their current - * values. */ -QHash -ServerSettings::confValues() -{ - QHash conf; - quint32 torVersion = torControl()->getTorVersion(); - - /* Server Nickname */ - conf.insert(SETTING_NICKNAME, - (isServerEnabled() ? localValue(SETTING_NICKNAME).toString() - : "")); - /* Server ORPort */ - conf.insert(SETTING_ORPORT, - (isServerEnabled() ? localValue(SETTING_ORPORT).toString() - : "0")); - /* Server DirPort */ - conf.insert(SETTING_DIRPORT, - (isDirectoryMirror() ? localValue(SETTING_DIRPORT).toString() - : "0")); - /* Server Exit Policy */ - conf.insert(SETTING_EXITPOLICY, - (isBridgeEnabled() ? "reject *:*" - : localValue(SETTING_EXITPOLICY).toString())); - - /* Server bandwidth settings */ - conf.insert((torVersion >= 0x020001 ? SETTING_RELAY_BANDWIDTH_RATE - : SETTING_BANDWIDTH_RATE), - QString::number(localValue(SETTING_BANDWIDTH_RATE).toUInt()) + " bytes"); - conf.insert((torVersion >= 0x020001 ? SETTING_RELAY_BANDWIDTH_BURST - : SETTING_BANDWIDTH_BURST), - QString::number(localValue(SETTING_BANDWIDTH_BURST).toUInt()) + " bytes"); - - /* Server Contact Information */ - QString contact = - localValue(SETTING_CONTACT).toString().trimmed(); - QString defaultContact = defaultValue(SETTING_CONTACT).toString(); - if ((contact == defaultContact) || - (contact == scrub_email_addr(defaultContact))) { - /* Only set the contact info if they put something non-default there */ - contact = ""; - } - conf.insert(SETTING_CONTACT, scrub_email_addr(contact)); - - /* Set if we're a bridge relay */ - conf.insert(SETTING_BRIDGE_RELAY, isBridgeEnabled() ? "1" : "0"); - - return conf; -} - -/** Applies the current server configuration settings to Tor. If errmsg - * is specified and an error occurs while applying the settings, it will be - * set to a string describing the error. */ -bool -ServerSettings::apply(QString *errmsg) -{ - bool rc; - - configurePortForwarding(); - - if (isServerEnabled()) { - rc = torControl()->setConf(confValues(), errmsg); - } else { - QStringList resetKeys; - quint32 torVersion = torControl()->getTorVersion(); - resetKeys << SETTING_ORPORT - << SETTING_NICKNAME - << SETTING_DIRPORT - << SETTING_CONTACT - << SETTING_EXITPOLICY - << SETTING_BRIDGE_RELAY; - if (torVersion >= 0x020001) { - resetKeys << SETTING_RELAY_BANDWIDTH_RATE - << SETTING_RELAY_BANDWIDTH_BURST; - } else { - resetKeys << SETTING_BANDWIDTH_RATE - << SETTING_BANDWIDTH_BURST; - } - rc = torControl()->resetConf(resetKeys, errmsg); - } - return rc; -} - -/* TODO: We should call this periodically, in case the router gets rebooted or forgets its UPnP settings */ -/* TODO: Remove port forwarding when Tor is shutdown or the ORPort changes */ -/* TODO: init_upnp() will block for up to 2 seconds. We should fire off a thread */ - -/** Configure UPnP device to forward DirPort and ORPort. If enable is -true, will forward ORPort and DirPort; otherwise will remove exising -port mappings */ -void -ServerSettings::configurePortForwarding() -{ -#ifdef USE_MINIUPNPC - quint16 ORPort, DirPort; - - // This is how the tickbox should control UPNP - if (!isUpnpEnabled()) - return; - - ORPort = getORPort(); - if (!isServerEnabled()) - ORPort = 0; - - DirPort = getDirPort(); - if (!isServerEnabled() || !isDirectoryMirror()) - DirPort = 0; - - UPNPControl *control = UPNPControl::instance(); - control->setDesiredState(DirPort, ORPort); -#endif -} - -void -ServerSettings::cleanupPortForwarding() -{ -#ifdef USE_MINIUPNPC - UPNPControl::cleanup(); -#endif -} - -/** Virtual method called when we retrieve a server-related setting from Tor. - * Currently this just translates BandwidthFoo to RelayBandwidthFoo when - * appropriate. */ -QVariant -ServerSettings::torValue(const QString &key) const -{ - if (torControl()->getTorVersion() >= 0x020001) { - if (key == SETTING_BANDWIDTH_RATE) - return AbstractTorSettings::torValue(SETTING_RELAY_BANDWIDTH_RATE); - else if (key == SETTING_BANDWIDTH_BURST) - return AbstractTorSettings::torValue(SETTING_RELAY_BANDWIDTH_BURST); - } - return AbstractTorSettings::torValue(key); -} - -/** Enables or disables running Tor as a server. - * \param enable Whether to enable or disable the Tor server. - */ -void -ServerSettings::setServerEnabled(bool enable) -{ - setValue(SETTING_ENABLED, enable); -} - -/** Returns true if Tor is currently configured to run as a Tor server. If Tor - * is running, we will check whether it has an ORPort defined. Otherwise, we - * will use our saved settings. */ -bool -ServerSettings::isServerEnabled() -{ - QString orPort; - if (torControl()->isConnected() && !changedSinceLastApply()) { - if (torControl()->getConf(SETTING_ORPORT, orPort)) - return (orPort.toUInt() > 0); - } - return localValue(SETTING_ENABLED).toBool(); -} - -/** Sets to enabled whether Tor should be a bridge node when acting as - * a server. */ -void -ServerSettings::setBridgeEnabled(bool enabled) -{ - setValue(SETTING_BRIDGE_RELAY, enabled); -} - -/** Returns true if Tor is configured to act as a bridge node. */ -bool -ServerSettings::isBridgeEnabled() -{ - return value(SETTING_BRIDGE_RELAY).toBool() && isServerEnabled(); -} - -/** Sets the server's ORPort. */ -void -ServerSettings::setORPort(quint16 orPort) -{ - setValue(SETTING_ORPORT, orPort); -} - -/** Gets the server's current ORPort setting. */ -quint16 -ServerSettings::getORPort() -{ - return (quint16)value(SETTING_ORPORT).toUInt(); -} - -/** Sets the server's current DirPort. */ -void -ServerSettings::setDirPort(quint16 dirPort) -{ - setValue(SETTING_DIRPORT, dirPort); -} - -/** Gets the server's current DirPort. */ -quint16 -ServerSettings::getDirPort() -{ - return (quint16)value(SETTING_DIRPORT).toUInt(); -} - -/** Sets the server's nickname. */ -void -ServerSettings::setNickname(QString nickname) -{ - setValue(SETTING_NICKNAME, nickname); -} - -/** Gets the server's nickname. */ -QString -ServerSettings::getNickname() -{ - QString nickname = value(SETTING_NICKNAME).toString(); - /* Ensure the nickname contains only valid characters and is not too long. */ - return ensure_valid_chars(nickname, - VALID_NICKNAME_CHARS).left(MAX_NICKNAME_LEN); -} - -/** Sets the server's contact information. */ -void -ServerSettings::setContactInfo(QString contact) -{ - setValue(SETTING_CONTACT, contact); -} - -/** Gets the server's contact information. */ -QString -ServerSettings::getContactInfo() -{ - return value(SETTING_CONTACT).toString(); -} - -/** Returns whether this server will act as a directory mirror or not. */ -bool -ServerSettings::isDirectoryMirror() -{ - return localValue(SETTING_DIRMIRROR).toBool(); -} - -/** Sets whether this server will act as a directory mirror. */ -void -ServerSettings::setDirectoryMirror(bool mirror) -{ - setValue(SETTING_DIRMIRROR, mirror); -} - -/** Returns the exit policy for this server. */ -ExitPolicy -ServerSettings::getExitPolicy() -{ - return ExitPolicy(value(SETTING_EXITPOLICY).toString()); -} - -/** Sets the exit policy for this server. */ -void -ServerSettings::setExitPolicy(ExitPolicy &exitPolicy) -{ - setValue(SETTING_EXITPOLICY, exitPolicy.toString()); -} - -/** Returns the long-term average bandwidth rate (in KB/s) for this server. */ -quint32 -ServerSettings::getBandwidthAvgRate() -{ - return value(SETTING_BANDWIDTH_RATE).toUInt(); -} - -/** Sets the long-term average bandwidth rate (in KB/s) for this server. */ -void -ServerSettings::setBandwidthAvgRate(quint32 rate) -{ - setValue(SETTING_BANDWIDTH_RATE, rate); -} - -/** Returns the maximum bandwidth burst rate (in KB/s) for this server. */ -quint32 -ServerSettings::getBandwidthBurstRate() -{ - return value(SETTING_BANDWIDTH_BURST).toUInt(); -} - -/** Sets the maximum bandwidth burst rate (in KB/s) for this server. */ -void -ServerSettings::setBandwidthBurstRate(quint32 rate) -{ - setValue(SETTING_BANDWIDTH_BURST, rate); -} - -/** Returns true if UPnP support is available and enabled. */ -bool -ServerSettings::isUpnpEnabled() -{ -#if defined(USE_MINIUPNPC) - return localValue(SETTING_ENABLE_UPNP).toBool(); -#else - return false; -#endif -} - -/** Sets whether Vidalia should try to configure port forwarding using UPnP. - * If Vidalia was compiled without UPnP support, this method has no effect. */ -void -ServerSettings::setUpnpEnabled(bool enabled) -{ -#if defined(USE_MINIUPNPC) - setValue(SETTING_ENABLE_UPNP, enabled); -#endif -} - diff -Nru vidalia-0.1.13/src/vidalia/config/ServerSettings.cpp vidalia-0.2.8/src/vidalia/config/ServerSettings.cpp --- vidalia-0.1.13/src/vidalia/config/ServerSettings.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/ServerSettings.cpp 2009-10-12 01:59:22.000000000 +0100 @@ -0,0 +1,417 @@ +/* +** 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.vidalia-project.net/. 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 ServerSettings.cpp +** \version $Id: ServerSettings.cpp 4143 2009-10-12 00:59:22Z edmanm $ +** \brief Settings for running a Tor server +*/ + +#include "config.h" +#include "ServerSettings.h" +#include "TorSettings.h" +#ifdef USE_MINIUPNPC +#include "UPNPControl.h" +#endif + +#include "net.h" +#include "stringutil.h" + +#include + +/** Define the set of characters that are valid in a nickname. */ +#define VALID_NICKNAME_CHARS \ + "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" +/** Define the maximum length of a server's nickname. */ +#define MAX_NICKNAME_LEN 19 + +/* Server configuration settings */ +#define SETTING_ENABLED "Enabled" +#define SETTING_DIRMIRROR "DirectoryMirror" +#define SETTING_NICKNAME "Nickname" +#define SETTING_ORPORT "ORPort" +#define SETTING_DIRPORT "DirPort" +#define SETTING_CONTACT "ContactInfo" +#define SETTING_EXITPOLICY "ExitPolicy" +#define SETTING_BANDWIDTH_RATE "BandwidthRate" +#define SETTING_BANDWIDTH_BURST "BandwidthBurst" +#define SETTING_BRIDGE_RELAY "BridgeRelay" +#define SETTING_ENABLE_UPNP "EnableUPnP" +#define SETTING_RELAY_BANDWIDTH_RATE "RelayBandwidthRate" +#define SETTING_RELAY_BANDWIDTH_BURST "RelayBandwidthBurst" +#define SETTING_PUBLISH_SERVER_DESCRIPTOR "PublishServerDescriptor" + + +/** Constructor. + * \param torControl a TorControl object used to read and apply the server + * configuration settings. + */ +ServerSettings::ServerSettings(TorControl *torControl) +: AbstractTorSettings("Server", torControl) +{ + setDefault(SETTING_ENABLED, false); + setDefault(SETTING_DIRMIRROR, true); +#if defined(Q_OS_WIN32) + setDefault(SETTING_ORPORT, 443); +#else + setDefault(SETTING_ORPORT, 9001); +#endif + setDefault(SETTING_DIRPORT, 9030); + setDefault(SETTING_NICKNAME, "Unnamed"); + setDefault(SETTING_CONTACT, ""); + setDefault(SETTING_BANDWIDTH_RATE, 5242880); + setDefault(SETTING_RELAY_BANDWIDTH_RATE, 5242880); + setDefault(SETTING_BANDWIDTH_BURST, 10485760); + setDefault(SETTING_RELAY_BANDWIDTH_BURST, 10485760); + setDefault(SETTING_EXITPOLICY, + ExitPolicy(ExitPolicy::Default).toString()); + setDefault(SETTING_ENABLE_UPNP, false); + setDefault(SETTING_BRIDGE_RELAY, false); + setDefault(SETTING_PUBLISH_SERVER_DESCRIPTOR, "1"); +} + +/** Returns a QHash of Tor-recognizable configuratin keys to their current + * values. */ +QHash +ServerSettings::confValues() +{ + QHash conf; + quint32 torVersion = torControl()->getTorVersion(); + + /* Server Nickname */ + conf.insert(SETTING_NICKNAME, + (isServerEnabled() ? localValue(SETTING_NICKNAME).toString() + : "")); + /* Server ORPort */ + conf.insert(SETTING_ORPORT, + (isServerEnabled() ? localValue(SETTING_ORPORT).toString() + : "0")); + /* Server DirPort */ + conf.insert(SETTING_DIRPORT, + (isDirectoryMirror() ? localValue(SETTING_DIRPORT).toString() + : "0")); + /* Server Exit Policy */ + conf.insert(SETTING_EXITPOLICY, + (isBridgeEnabled() ? "reject *:*" + : localValue(SETTING_EXITPOLICY).toString())); + + /* Server bandwidth settings */ + conf.insert((torVersion >= 0x020001 ? SETTING_RELAY_BANDWIDTH_RATE + : SETTING_BANDWIDTH_RATE), + QString::number(localValue(SETTING_BANDWIDTH_RATE).toUInt()) + " bytes"); + conf.insert((torVersion >= 0x020001 ? SETTING_RELAY_BANDWIDTH_BURST + : SETTING_BANDWIDTH_BURST), + QString::number(localValue(SETTING_BANDWIDTH_BURST).toUInt()) + " bytes"); + + /* Server Contact Information */ + QString contact = + localValue(SETTING_CONTACT).toString().trimmed(); + QString defaultContact = defaultValue(SETTING_CONTACT).toString(); + if ((contact == defaultContact) || + (contact == scrub_email_addr(defaultContact))) { + /* Only set the contact info if they put something non-default there */ + contact = ""; + } + conf.insert(SETTING_CONTACT, scrub_email_addr(contact)); + + /* Set if we're a bridge relay */ + if (isBridgeEnabled()) { + conf.insert(SETTING_BRIDGE_RELAY, "1"); + conf.insert(SETTING_PUBLISH_SERVER_DESCRIPTOR, + publishServerDescriptor() ? "1" : "0"); + } else { + conf.insert(SETTING_BRIDGE_RELAY, "0"); + conf.insert(SETTING_PUBLISH_SERVER_DESCRIPTOR, "1"); + } + return conf; +} + +/** Applies the current server configuration settings to Tor. If errmsg + * is specified and an error occurs while applying the settings, it will be + * set to a string describing the error. */ +bool +ServerSettings::apply(QString *errmsg) +{ + bool rc; + + configurePortForwarding(); + + if (isServerEnabled()) { + rc = torControl()->setConf(confValues(), errmsg); + } else { + QStringList resetKeys; + quint32 torVersion = torControl()->getTorVersion(); + resetKeys << SETTING_ORPORT + << SETTING_NICKNAME + << SETTING_DIRPORT + << SETTING_CONTACT + << SETTING_EXITPOLICY + << SETTING_BRIDGE_RELAY + << SETTING_PUBLISH_SERVER_DESCRIPTOR; + if (torVersion >= 0x020001) { + resetKeys << SETTING_RELAY_BANDWIDTH_RATE + << SETTING_RELAY_BANDWIDTH_BURST; + } else { + resetKeys << SETTING_BANDWIDTH_RATE + << SETTING_BANDWIDTH_BURST; + } + rc = torControl()->resetConf(resetKeys, errmsg); + } + return rc; +} + +/* TODO: We should call this periodically, in case the router gets rebooted or forgets its UPnP settings */ +/* TODO: Remove port forwarding when Tor is shutdown or the ORPort changes */ +/* TODO: init_upnp() will block for up to 2 seconds. We should fire off a thread */ + +/** Configure UPnP device to forward DirPort and ORPort. If enable is + * true, will forward ORPort and DirPort; otherwise will remove exising + * port mappings */ +void +ServerSettings::configurePortForwarding() +{ +#ifdef USE_MINIUPNPC + quint16 ORPort, DirPort; + + // This is how the tickbox should control UPNP + if (!isUpnpEnabled()) + return; + + ORPort = getORPort(); + if (!isServerEnabled()) + ORPort = 0; + + DirPort = getDirPort(); + if (!isServerEnabled() || !isDirectoryMirror()) + DirPort = 0; + + UPNPControl *control = UPNPControl::instance(); + control->setDesiredState(DirPort, ORPort); +#endif +} + +void +ServerSettings::cleanupPortForwarding() +{ +#ifdef USE_MINIUPNPC + UPNPControl::cleanup(); +#endif +} + +/** Virtual method called when we retrieve a server-related setting from Tor. + * Currently this just translates BandwidthFoo to RelayBandwidthFoo when + * appropriate. */ +QVariant +ServerSettings::torValue(const QString &key) const +{ + if (torControl()->getTorVersion() >= 0x020001) { + if (key == SETTING_BANDWIDTH_RATE) + return AbstractTorSettings::torValue(SETTING_RELAY_BANDWIDTH_RATE); + else if (key == SETTING_BANDWIDTH_BURST) + return AbstractTorSettings::torValue(SETTING_RELAY_BANDWIDTH_BURST); + } + return AbstractTorSettings::torValue(key); +} + +/** Enables or disables running Tor as a server. + * \param enable Whether to enable or disable the Tor server. + */ +void +ServerSettings::setServerEnabled(bool enable) +{ + setValue(SETTING_ENABLED, enable); +} + +/** Returns true if Tor is currently configured to run as a Tor server. If Tor + * is running, we will check whether it has an ORPort defined. Otherwise, we + * will use our saved settings. */ +bool +ServerSettings::isServerEnabled() +{ + QString orPort; + if (torControl()->isConnected() && !changedSinceLastApply()) { + if (torControl()->getConf(SETTING_ORPORT, orPort)) + return (orPort.toUInt() > 0); + } + return localValue(SETTING_ENABLED).toBool(); +} + +/** Sets to enabled whether Tor should be a bridge node when acting as + * a server. */ +void +ServerSettings::setBridgeEnabled(bool enabled) +{ + setValue(SETTING_BRIDGE_RELAY, enabled); +} + +/** Returns true if Tor is configured to act as a bridge node. */ +bool +ServerSettings::isBridgeEnabled() +{ + return value(SETTING_BRIDGE_RELAY).toBool() && isServerEnabled(); +} + +/** Sets the server's ORPort. */ +void +ServerSettings::setORPort(quint16 orPort) +{ + setValue(SETTING_ORPORT, orPort); +} + +/** Gets the server's current ORPort setting. */ +quint16 +ServerSettings::getORPort() +{ + return (quint16)value(SETTING_ORPORT).toUInt(); +} + +/** Sets the server's current DirPort. */ +void +ServerSettings::setDirPort(quint16 dirPort) +{ + setValue(SETTING_DIRPORT, dirPort); +} + +/** Gets the server's current DirPort. */ +quint16 +ServerSettings::getDirPort() +{ + return (quint16)value(SETTING_DIRPORT).toUInt(); +} + +/** Sets the server's nickname. */ +void +ServerSettings::setNickname(QString nickname) +{ + setValue(SETTING_NICKNAME, nickname); +} + +/** Gets the server's nickname. */ +QString +ServerSettings::getNickname() +{ + QString nickname = value(SETTING_NICKNAME).toString(); + /* Ensure the nickname contains only valid characters and is not too long. */ + return ensure_valid_chars(nickname, + VALID_NICKNAME_CHARS).left(MAX_NICKNAME_LEN); +} + +/** Sets the server's contact information. */ +void +ServerSettings::setContactInfo(QString contact) +{ + setValue(SETTING_CONTACT, contact); +} + +/** Gets the server's contact information. */ +QString +ServerSettings::getContactInfo() +{ + return value(SETTING_CONTACT).toString(); +} + +/** Returns whether this server will act as a directory mirror or not. */ +bool +ServerSettings::isDirectoryMirror() +{ + return localValue(SETTING_DIRMIRROR).toBool(); +} + +/** Sets whether this server will act as a directory mirror. */ +void +ServerSettings::setDirectoryMirror(bool mirror) +{ + setValue(SETTING_DIRMIRROR, mirror); +} + +/** Returns the exit policy for this server. */ +ExitPolicy +ServerSettings::getExitPolicy() +{ + return ExitPolicy(value(SETTING_EXITPOLICY).toString()); +} + +/** Sets the exit policy for this server. */ +void +ServerSettings::setExitPolicy(ExitPolicy &exitPolicy) +{ + setValue(SETTING_EXITPOLICY, exitPolicy.toString()); +} + +/** Returns the long-term average bandwidth rate (in KB/s) for this server. */ +quint32 +ServerSettings::getBandwidthAvgRate() +{ + return value(SETTING_BANDWIDTH_RATE).toUInt(); +} + +/** Sets the long-term average bandwidth rate (in KB/s) for this server. */ +void +ServerSettings::setBandwidthAvgRate(quint32 rate) +{ + setValue(SETTING_BANDWIDTH_RATE, rate); +} + +/** Returns the maximum bandwidth burst rate (in KB/s) for this server. */ +quint32 +ServerSettings::getBandwidthBurstRate() +{ + return value(SETTING_BANDWIDTH_BURST).toUInt(); +} + +/** Sets the maximum bandwidth burst rate (in KB/s) for this server. */ +void +ServerSettings::setBandwidthBurstRate(quint32 rate) +{ + setValue(SETTING_BANDWIDTH_BURST, rate); +} + +/** Sets whether the user's server descriptor will be published or not. + * Currently this only affects publishing of bridge descriptors. If the + * user is running a normal relay, its descriptor will always be + * published regardless of this setting. */ +void +ServerSettings::setPublishServerDescriptor(bool publish) +{ + if (publish) + setValue(SETTING_PUBLISH_SERVER_DESCRIPTOR, "1"); + else + setValue(SETTING_PUBLISH_SERVER_DESCRIPTOR, "0"); +} + +/** Returns true if the user's server descriptor will be published to the + * appropriate authorities. */ +bool +ServerSettings::publishServerDescriptor() const +{ + return (value(SETTING_PUBLISH_SERVER_DESCRIPTOR).toString() != "0"); +} + +/** Returns true if UPnP support is available and enabled. */ +bool +ServerSettings::isUpnpEnabled() +{ +#if defined(USE_MINIUPNPC) + return localValue(SETTING_ENABLE_UPNP).toBool(); +#else + return false; +#endif +} + +/** Sets whether Vidalia should try to configure port forwarding using UPnP. + * If Vidalia was compiled without UPnP support, this method has no effect. */ +void +ServerSettings::setUpnpEnabled(bool enabled) +{ +#if defined(USE_MINIUPNPC) + setValue(SETTING_ENABLE_UPNP, enabled); +#endif +} + diff -Nru vidalia-0.1.13/src/vidalia/config/serversettings.h vidalia-0.2.8/src/vidalia/config/serversettings.h --- vidalia-0.1.13/src/vidalia/config/serversettings.h 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/serversettings.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,107 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 serversettings.h -** \version $Id: serversettings.h 2638 2008-06-01 23:42:53Z edmanm $ -** \brief Settings for running a Tor server -*/ - -#ifndef _SERVERSETTINGS_H -#define _SERVERSETTINGS_H - -#include "abstracttorsettings.h" -#include "exitpolicy.h" - - -class ServerSettings : public AbstractTorSettings -{ - Q_OBJECT - -public: - /** Constructor */ - ServerSettings(TorControl *torControl); - - /** Applies changese to Tor. */ - bool apply(QString *errmsg = 0); - - /** Enables running Tor as a server. */ - void setServerEnabled(bool enable); - /** Returns true if Tor is running as a server. */ - bool isServerEnabled(); - - /** Sets to enabled whether Tor should be a bridge node when acting - * as a server. */ - void setBridgeEnabled(bool enable); - /** Returns true if Tor is configured to act as a bridge node. */ - bool isBridgeEnabled(); - - /** Sets the server's ORPort value. */ - void setORPort(quint16 orPort); - /** Gets the server's ORPort value. */ - quint16 getORPort(); - - /** Sets the server's DirPort value. */ - void setDirPort(quint16 dirPort); - /** Gets the server's DirPort value. */ - quint16 getDirPort(); - - /** Sets the server's nickname. */ - void setNickname(QString nickname); - /** Gets the server's nickname. */ - QString getNickname(); - - /** Sets the server operator's contact information. */ - void setContactInfo(QString info); - /** Gets the server operator's contact information. */ - QString getContactInfo(); - - /** Enables or disables the server to act as a directory mirror. */ - void setDirectoryMirror(bool mirror); - /** Returns true if the server will mirror the directory. */ - bool isDirectoryMirror(); - /** Sets the exit policy for this server. */ - void setExitPolicy(ExitPolicy &policy); - /** Gets the exit policy for this server. */ - ExitPolicy getExitPolicy(); - - /** Sets the long-term average bandwidth rate (in KB/s) of this server. */ - void setBandwidthAvgRate(quint32 rate); - /** Gets the long-term average bandwidth rate (in KB/s) of this server. */ - quint32 getBandwidthAvgRate(); - - /** Sets the maximum burst rate (in B/s) of this server. */ - void setBandwidthBurstRate(quint32 rate); - /** Gets the maximum burst rate (in B/s) of this server. */ - quint32 getBandwidthBurstRate(); - - /** Configure port forwarding. */ - void configurePortForwarding(); - - void cleanupPortForwarding(); - - /** Returns true if UPnP support is enabled. */ - bool isUpnpEnabled(); - /** Sets whether Vidalia should try to configure port forwarding using UPnP. */ - void setUpnpEnabled(bool enabled); - -protected: - /** Virtual method called when we retrieve a server-related setting from Tor. - * Currently this just translates BandwidthFoo to RelayBandwidthFoo when - * appropriate. */ - virtual QVariant torValue(const QString &key) const; - -private: - /** Returns Tor-recognizable configuration keys and current values. */ - QHash confValues(); -}; - -#endif - diff -Nru vidalia-0.1.13/src/vidalia/config/ServerSettings.h vidalia-0.2.8/src/vidalia/config/ServerSettings.h --- vidalia-0.1.13/src/vidalia/config/ServerSettings.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/ServerSettings.h 2009-10-12 01:59:22.000000000 +0100 @@ -0,0 +1,116 @@ +/* +** 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.vidalia-project.net/. 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 ServerSettings.h +** \version $Id: ServerSettings.h 4143 2009-10-12 00:59:22Z edmanm $ +** \brief Settings for running a Tor server +*/ + +#ifndef _SERVERSETTINGS_H +#define _SERVERSETTINGS_H + +#include "AbstractTorSettings.h" +#include "ExitPolicy.h" + + +class ServerSettings : public AbstractTorSettings +{ + Q_OBJECT + +public: + /** Constructor */ + ServerSettings(TorControl *torControl); + + /** Applies changese to Tor. */ + bool apply(QString *errmsg = 0); + + /** Enables running Tor as a server. */ + void setServerEnabled(bool enable); + /** Returns true if Tor is running as a server. */ + bool isServerEnabled(); + + /** Sets to enabled whether Tor should be a bridge node when acting + * as a server. */ + void setBridgeEnabled(bool enable); + /** Returns true if Tor is configured to act as a bridge node. */ + bool isBridgeEnabled(); + + /** Sets the server's ORPort value. */ + void setORPort(quint16 orPort); + /** Gets the server's ORPort value. */ + quint16 getORPort(); + + /** Sets the server's DirPort value. */ + void setDirPort(quint16 dirPort); + /** Gets the server's DirPort value. */ + quint16 getDirPort(); + + /** Sets the server's nickname. */ + void setNickname(QString nickname); + /** Gets the server's nickname. */ + QString getNickname(); + + /** Sets the server operator's contact information. */ + void setContactInfo(QString info); + /** Gets the server operator's contact information. */ + QString getContactInfo(); + + /** Enables or disables the server to act as a directory mirror. */ + void setDirectoryMirror(bool mirror); + /** Returns true if the server will mirror the directory. */ + bool isDirectoryMirror(); + /** Sets the exit policy for this server. */ + void setExitPolicy(ExitPolicy &policy); + /** Gets the exit policy for this server. */ + ExitPolicy getExitPolicy(); + + /** Sets the long-term average bandwidth rate (in KB/s) of this server. */ + void setBandwidthAvgRate(quint32 rate); + /** Gets the long-term average bandwidth rate (in KB/s) of this server. */ + quint32 getBandwidthAvgRate(); + + /** Sets the maximum burst rate (in B/s) of this server. */ + void setBandwidthBurstRate(quint32 rate); + /** Gets the maximum burst rate (in B/s) of this server. */ + quint32 getBandwidthBurstRate(); + + /** Sets whether the user's server descriptor will be published or not. + * Currently this only affects publishing of bridge descriptors. If the + * user is running a normal relay, its descriptor will always be + * published regardless of this setting. */ + void setPublishServerDescriptor(bool publish); + /** Returns true if the user's server descriptor will be published to + * the appropriate authorities. */ + bool publishServerDescriptor() const; + + /** Configure port forwarding. */ + void configurePortForwarding(); + + void cleanupPortForwarding(); + + /** Returns true if UPnP support is enabled. */ + bool isUpnpEnabled(); + /** Sets whether Vidalia should try to configure port forwarding using UPnP. */ + void setUpnpEnabled(bool enabled); + +protected: + /** Virtual method called when we retrieve a server-related setting from Tor. + * Currently this just translates BandwidthFoo to RelayBandwidthFoo when + * appropriate. */ + virtual QVariant torValue(const QString &key) const; + +private: + /** Returns Tor-recognizable configuration keys and current values. */ + QHash confValues(); +}; + +#endif + diff -Nru vidalia-0.1.13/src/vidalia/config/service.cpp vidalia-0.2.8/src/vidalia/config/service.cpp --- vidalia-0.1.13/src/vidalia/config/service.cpp 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/service.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,118 +0,0 @@ -/* -** 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.vidalia-project.net/. No part of Vidalia, including this file, -** may be copied, modified, propagated, or distributed except according to the -** terms described in the LICENSE file. -*/ - -#include "service.h" - -/** Default Constructor */ -Service::Service() { -} - -/** Constructor to create a new Service with initial settings */ -Service::Service(QString serviceAddress, QString virtualPort, - QString physicalAddressPort, QString serviceDirectory, bool enabled) -{ - - _serviceAddress = serviceAddress; - _virtualPort = virtualPort; - _physicalAddressPort = physicalAddressPort; - _serviceDirectory = serviceDirectory; - _enabled = enabled; -} - -/** Destructor */ -Service::~Service() -{ -} - -/** Sets the deploy status of a service */ -void Service::setEnabled(bool enabled) -{ - _enabled = enabled; -} - -/** Sets the adress of a service */ -void Service::setServiceAddress(QString serviceAddress) -{ - _serviceAddress = serviceAddress; -} - -/** Sets the virtualPort of a service */ -void Service::setVirtualPort(QString virtualPort) -{ - _virtualPort = virtualPort; -} - -/** Sets the physical Adress and the local port of a service */ -void Service::setPhysicalAddressPort(QString physicalAddressPort) -{ - _physicalAddressPort = physicalAddressPort; -} - -/** Sets the service directory of a service */ -void Service::setServiceDirectory(QString serviceDirectory) -{ - _serviceDirectory = serviceDirectory; -} - -/** Sets the additional options of a service e.g. excludeNodes */ -void Service::setAdditionalServiceOptions(QString options) -{ - _additionalServiceOptions = options; -} - -/** Writes service class data from myObj to the QDataStream - * out. */ -QDataStream&operator<<(QDataStream &out, const Service &myObj) -{ - out << myObj.serviceAddress(); - out << myObj.virtualPort(); - out << myObj.physicalAddressPort(); - out << myObj.serviceDirectory(); - out << myObj.enabled(); - out << myObj.additionalServiceOptions(); - - return out; -} - -/** Reads service class data in from the QDataStream in and - populates * the myObj object accordingly. */ -QDataStream&operator>>(QDataStream &in, Service &myObj) -{ - QString serviceAddress; - QString virtualPort; - QString physicalAddressPort; - QString serviceDirectory; - bool enabled; - QString additionalServiceOptions; - - /* Read in from the data stream */ - in >> serviceAddress >> virtualPort >> physicalAddressPort - >> serviceDirectory >> enabled >> additionalServiceOptions; - - /* Set the appropriate class member variables */ - myObj.setServiceAddress(serviceAddress); - myObj.setVirtualPort(virtualPort); - myObj.setPhysicalAddressPort(physicalAddressPort); - myObj.setServiceDirectory(serviceDirectory); - myObj.setEnabled(enabled); - myObj.setAdditionalServiceOptions(additionalServiceOptions); - - /* Return the updated data stream */ - return in; -} - -/** Creates a string by concatenating the values of the service. */ -QString -Service::toString() -{ - return _serviceAddress +"#"+ _virtualPort +"#"+ _physicalAddressPort + - "#"+ _serviceDirectory +"#"+ _enabled + "#"+ _additionalServiceOptions; -} - diff -Nru vidalia-0.1.13/src/vidalia/config/Service.cpp vidalia-0.2.8/src/vidalia/config/Service.cpp --- vidalia-0.1.13/src/vidalia/config/Service.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/Service.cpp 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,119 @@ +/* +** 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.vidalia-project.net/. No part of Vidalia, including this file, +** may be copied, modified, propagated, or distributed except according to the +** terms described in the LICENSE file. +*/ + +#include "Service.h" + + +/** Default Constructor */ +Service::Service() +{ +} + +/** Constructor to create a new Service with initial settings */ +Service::Service(QString serviceAddress, QString virtualPort, + QString physicalAddressPort, QString serviceDirectory, bool enabled) +{ + _serviceAddress = serviceAddress; + _virtualPort = virtualPort; + _physicalAddressPort = physicalAddressPort; + _serviceDirectory = serviceDirectory; + _enabled = enabled; +} + +/** Destructor */ +Service::~Service() +{ +} + +/** Sets the deploy status of a service */ +void Service::setEnabled(bool enabled) +{ + _enabled = enabled; +} + +/** Sets the adress of a service */ +void Service::setServiceAddress(QString serviceAddress) +{ + _serviceAddress = serviceAddress; +} + +/** Sets the virtualPort of a service */ +void Service::setVirtualPort(QString virtualPort) +{ + _virtualPort = virtualPort; +} + +/** Sets the physical Adress and the local port of a service */ +void Service::setPhysicalAddressPort(QString physicalAddressPort) +{ + _physicalAddressPort = physicalAddressPort; +} + +/** Sets the service directory of a service */ +void Service::setServiceDirectory(QString serviceDirectory) +{ + _serviceDirectory = serviceDirectory; +} + +/** Sets the additional options of a service e.g. excludeNodes */ +void Service::setAdditionalServiceOptions(QString options) +{ + _additionalServiceOptions = options; +} + +/** Writes service class data from myObj to the QDataStream + * out. */ +QDataStream&operator<<(QDataStream &out, const Service &myObj) +{ + out << myObj.serviceAddress(); + out << myObj.virtualPort(); + out << myObj.physicalAddressPort(); + out << myObj.serviceDirectory(); + out << myObj.enabled(); + out << myObj.additionalServiceOptions(); + + return out; +} + +/** Reads service class data in from the QDataStream in and + populates * the myObj object accordingly. */ +QDataStream&operator>>(QDataStream &in, Service &myObj) +{ + QString serviceAddress; + QString virtualPort; + QString physicalAddressPort; + QString serviceDirectory; + bool enabled; + QString additionalServiceOptions; + + /* Read in from the data stream */ + in >> serviceAddress >> virtualPort >> physicalAddressPort + >> serviceDirectory >> enabled >> additionalServiceOptions; + + /* Set the appropriate class member variables */ + myObj.setServiceAddress(serviceAddress); + myObj.setVirtualPort(virtualPort); + myObj.setPhysicalAddressPort(physicalAddressPort); + myObj.setServiceDirectory(serviceDirectory); + myObj.setEnabled(enabled); + myObj.setAdditionalServiceOptions(additionalServiceOptions); + + /* Return the updated data stream */ + return in; +} + +/** Creates a string by concatenating the values of the service. */ +QString +Service::toString() +{ + return _serviceAddress +"#"+ _virtualPort +"#"+ _physicalAddressPort + + "#"+ _serviceDirectory +"#"+ _enabled + "#"+ _additionalServiceOptions; +} + diff -Nru vidalia-0.1.13/src/vidalia/config/service.h vidalia-0.2.8/src/vidalia/config/service.h --- vidalia-0.1.13/src/vidalia/config/service.h 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/service.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,80 +0,0 @@ -/* -** 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.vidalia-project.net/. No part of Vidalia, including this file, -** may be copied, modified, propagated, or distributed except according to the -** terms described in the LICENSE file. -*/ - -#ifndef SERVICE_H_ -#define SERVICE_H_ - -#include -#include -#include - -class Service -{ -public: - - /** Default constructor. */ - Service(); - /** Constructor to create a new Service with initial settings */ - Service(QString serviceAddress, QString virtualPort, - QString physicalAddressPort, QString serviceDirectory, bool enabled); - /** Destructor */ - virtual ~Service(); - /** Returns the service Adress of the service */ - QString serviceAddress() const { return _serviceAddress; } - /** Returns the listeningPort of the service */ - QString virtualPort() const { return _virtualPort; } - /** Returns the physical Adresse and the local Port of the service */ - QString physicalAddressPort() const { return _physicalAddressPort; } - /** Returns the service directory of the service */ - QString serviceDirectory() const { return _serviceDirectory; } - /** Returns the deployed status of a service */ - bool enabled() const { return _enabled; } - /** Returns the additional options of a service e.g. excludeNodes */ - QString additionalServiceOptions() const - { return _additionalServiceOptions; } - /** Sets the adress of a service */ - void setServiceAddress(QString serviceAddress); - /** Sets the listening port of a service */ - void setVirtualPort(QString virtualPort); - /** Sets the physical Adress and the local Port of a service */ - void setPhysicalAddressPort(QString physicalAddressPort); - /** Sets the service directory of a service */ - void setServiceDirectory(QString serviceDirectory); - /** Sets the deployed status a service */ - void setEnabled(bool enabled); - /** Sets the additional options of a service e.g. excludeNodes */ - void setAdditionalServiceOptions(QString options); - /** Writes service class data from myObj to the QDataStream - * out. */ - friend QDataStream& operator<<(QDataStream &out, const Service &myObj); - /** Reads service class data in from the QDataStream in and - populates * the myObj object accordingly. */ - friend QDataStream& operator>>(QDataStream &in, Service &myObj); - /** this method creates a string by concatenating the values of the service */ - QString toString(); - -private: - /** The adress of the service */ - QString _serviceAddress; - /** The listening Port of the service */ - QString _virtualPort; - /** The physical Adress and the local port of teh service */ - QString _physicalAddressPort; - /** the directory of the service */ - QString _serviceDirectory; - /** The Enabled status of the service */ - bool _enabled; - /** Some additional service options, not configured/displayed by Vidalia */ - QString _additionalServiceOptions; - -}; -Q_DECLARE_METATYPE(Service); -#endif /*SERIVCE_H_*/ - diff -Nru vidalia-0.1.13/src/vidalia/config/Service.h vidalia-0.2.8/src/vidalia/config/Service.h --- vidalia-0.1.13/src/vidalia/config/Service.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/Service.h 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,80 @@ +/* +** 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.vidalia-project.net/. No part of Vidalia, including this file, +** may be copied, modified, propagated, or distributed except according to the +** terms described in the LICENSE file. +*/ + +#ifndef _SERVICE_H +#define _SERVICE_H + +#include +#include +#include + + +class Service +{ +public: + /** Default constructor. */ + Service(); + /** Constructor to create a new Service with initial settings */ + Service(QString serviceAddress, QString virtualPort, + QString physicalAddressPort, QString serviceDirectory, bool enabled); + /** Destructor */ + virtual ~Service(); + /** Returns the service Adress of the service */ + QString serviceAddress() const { return _serviceAddress; } + /** Returns the listeningPort of the service */ + QString virtualPort() const { return _virtualPort; } + /** Returns the physical Adresse and the local Port of the service */ + QString physicalAddressPort() const { return _physicalAddressPort; } + /** Returns the service directory of the service */ + QString serviceDirectory() const { return _serviceDirectory; } + /** Returns the deployed status of a service */ + bool enabled() const { return _enabled; } + /** Returns the additional options of a service e.g. excludeNodes */ + QString additionalServiceOptions() const + { return _additionalServiceOptions; } + /** Sets the adress of a service */ + void setServiceAddress(QString serviceAddress); + /** Sets the listening port of a service */ + void setVirtualPort(QString virtualPort); + /** Sets the physical Adress and the local Port of a service */ + void setPhysicalAddressPort(QString physicalAddressPort); + /** Sets the service directory of a service */ + void setServiceDirectory(QString serviceDirectory); + /** Sets the deployed status a service */ + void setEnabled(bool enabled); + /** Sets the additional options of a service e.g. excludeNodes */ + void setAdditionalServiceOptions(QString options); + /** Writes service class data from myObj to the QDataStream + * out. */ + friend QDataStream& operator<<(QDataStream &out, const Service &myObj); + /** Reads service class data in from the QDataStream in and + populates * the myObj object accordingly. */ + friend QDataStream& operator>>(QDataStream &in, Service &myObj); + /** this method creates a string by concatenating the values of the service */ + QString toString(); + +private: + /** The adress of the service */ + QString _serviceAddress; + /** The listening Port of the service */ + QString _virtualPort; + /** The physical Adress and the local port of teh service */ + QString _physicalAddressPort; + /** the directory of the service */ + QString _serviceDirectory; + /** The Enabled status of the service */ + bool _enabled; + /** Some additional service options, not configured/displayed by Vidalia */ + QString _additionalServiceOptions; + +}; +Q_DECLARE_METATYPE(Service); +#endif /*SERIVCE_H_*/ + diff -Nru vidalia-0.1.13/src/vidalia/config/servicelist.cpp vidalia-0.2.8/src/vidalia/config/servicelist.cpp --- vidalia-0.1.13/src/vidalia/config/servicelist.cpp 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/servicelist.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,55 +0,0 @@ -/* -** 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.vidalia-project.net/. No part of Vidalia, including this file, -** may be copied, modified, propagated, or distributed except according to the -** terms described in the LICENSE file. -*/ - -#include "servicelist.h" - -/** Default constructor. */ -ServiceList::ServiceList() -{ -} - -/** Constructor to create a new Servicelist with initial settings */ -void ServiceList::addService(Service service) -{ - _services.append(service); -} - -/** Destructor */ -ServiceList::~ServiceList() -{ -} - -/* Sets the serviceList */ -void ServiceList::setServices(QList services) -{ - _services = services; -} - -/** Writes ServiceList class data from myObj to the QDataStream - * out. */ -QDataStream&operator<<(QDataStream &out, const ServiceList &myObj) -{ - out << myObj.services(); /* Write the services*/ - return out; -} - -/** Reads ServiceList class data in from the QDataStream in and - populates * the myObj object accordingly. */ -QDataStream&operator>>(QDataStream &in, ServiceList &myObj) -{ - QList services; - /* Read in from the data stream */ - in >> services; - /* Set the appropriate class member variables */ - myObj.setServices(services); - /* Return the updated data stream */ - return in; -} - diff -Nru vidalia-0.1.13/src/vidalia/config/ServiceList.cpp vidalia-0.2.8/src/vidalia/config/ServiceList.cpp --- vidalia-0.1.13/src/vidalia/config/ServiceList.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/ServiceList.cpp 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,56 @@ +/* +** 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.vidalia-project.net/. No part of Vidalia, including this file, +** may be copied, modified, propagated, or distributed except according to the +** terms described in the LICENSE file. +*/ + +#include "ServiceList.h" + + +/** Default constructor. */ +ServiceList::ServiceList() +{ +} + +/** Constructor to create a new Servicelist with initial settings */ +void ServiceList::addService(Service service) +{ + _services.append(service); +} + +/** Destructor */ +ServiceList::~ServiceList() +{ +} + +/* Sets the serviceList */ +void ServiceList::setServices(QList services) +{ + _services = services; +} + +/** Writes ServiceList class data from myObj to the QDataStream + * out. */ +QDataStream&operator<<(QDataStream &out, const ServiceList &myObj) +{ + out << myObj.services(); /* Write the services*/ + return out; +} + +/** Reads ServiceList class data in from the QDataStream in and + populates * the myObj object accordingly. */ +QDataStream&operator>>(QDataStream &in, ServiceList &myObj) +{ + QList services; + /* Read in from the data stream */ + in >> services; + /* Set the appropriate class member variables */ + myObj.setServices(services); + /* Return the updated data stream */ + return in; +} + diff -Nru vidalia-0.1.13/src/vidalia/config/servicelist.h vidalia-0.2.8/src/vidalia/config/servicelist.h --- vidalia-0.1.13/src/vidalia/config/servicelist.h 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/servicelist.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,46 +0,0 @@ -/* -** 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.vidalia-project.net/. No part of Vidalia, including this file, -** may be copied, modified, propagated, or distributed except according to the -** terms described in the LICENSE file. -*/ - -#ifndef SERVICELIST_H_ -#define SERVICELIST_H_ -#include -#include -class ServiceList -{ -public: - - /** Default constructor. */ - ServiceList(); - /** Destructor */ - virtual ~ServiceList(); - /** Returns the list of services */ - void addService(Service service); - /** Sets the lists of services */ - void setServices(QList services); - /** Returns the list of services */ - QList services() const { - return _services; - } - /** Writes ServiceList class data from myObj to the QDataStream - * out. */ - friend QDataStream& operator<<(QDataStream &out, const ServiceList &myObj); - /** Reads ServiceList class data in from the QDataStream in and - populates * the myObj object accordingly. */ - friend QDataStream& operator>>(QDataStream &in, ServiceList &myObj); - -private: - - /** The list of Services */ - QList _services; - -}; -Q_DECLARE_METATYPE(ServiceList); -#endif /*SERVICELIST_H_*/ - diff -Nru vidalia-0.1.13/src/vidalia/config/ServiceList.h vidalia-0.2.8/src/vidalia/config/ServiceList.h --- vidalia-0.1.13/src/vidalia/config/ServiceList.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/ServiceList.h 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,51 @@ +/* +** 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.vidalia-project.net/. No part of Vidalia, including this file, +** may be copied, modified, propagated, or distributed except according to the +** terms described in the LICENSE file. +*/ + +#ifndef _SERVICELIST_H +#define _SERVICELIST_H + +#include "Service.h" + +#include + + +class ServiceList +{ +public: + + /** Default constructor. */ + ServiceList(); + /** Destructor */ + virtual ~ServiceList(); + /** Returns the list of services */ + void addService(Service service); + /** Sets the lists of services */ + void setServices(QList services); + /** Returns the list of services */ + QList services() const { + return _services; + } + /** Writes ServiceList class data from myObj to the QDataStream + * out. */ + friend QDataStream& operator<<(QDataStream &out, const ServiceList &myObj); + /** Reads ServiceList class data in from the QDataStream in and + populates * the myObj object accordingly. */ + friend QDataStream& operator>>(QDataStream &in, ServiceList &myObj); + +private: + + /** The list of Services */ + QList _services; + +}; +Q_DECLARE_METATYPE(ServiceList); + +#endif + diff -Nru vidalia-0.1.13/src/vidalia/config/servicepage.cpp vidalia-0.2.8/src/vidalia/config/servicepage.cpp --- vidalia-0.1.13/src/vidalia/config/servicepage.cpp 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/servicepage.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,602 +0,0 @@ -/* -** 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.vidalia-project.net/. No part of Vidalia, including this file, -** may be copied, modified, propagated, or distributed except according to the -** terms described in the LICENSE file. -*/ - -#include -#include -#include -#include -#include -#include -#include -#include "configdialog.h" -#include "ipvalidator.h" -#include "service.h" -#include "servicelist.h" -#include "domainvalidator.h" -#include "ipvalidator.h" - -/** Constructor */ -ServicePage::ServicePage(QWidget *parent) -: ConfigPage(parent, tr("Services")) -{ - /* Invoke the Qt Designer generated object setup routine */ - ui.setupUi(this); - /* A QMap, mapping from the row number to the Entity for - * all services */ - _services = new QMap(); - /* A QMap, mapping from the directory path to the Entity for - * all Tor services */ - _torServices = new QMap(); - - ui.serviceWidget->horizontalHeader()->resizeSection(0, 150); - ui.serviceWidget->horizontalHeader()->resizeSection(1, 89); - ui.serviceWidget->horizontalHeader()->resizeSection(2, 100); - ui.serviceWidget->horizontalHeader()->resizeSection(3, 120); - ui.serviceWidget->horizontalHeader()->resizeSection(4, 60); - ui.serviceWidget->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch); - ui.serviceWidget->horizontalHeader()->setResizeMode(1, QHeaderView::Stretch); - ui.serviceWidget->horizontalHeader()->setResizeMode(2, QHeaderView::Stretch); - ui.serviceWidget->horizontalHeader()->setResizeMode(3, QHeaderView::Stretch); - ui.serviceWidget->verticalHeader()->hide(); - - connect(ui.addButton, SIGNAL(clicked()), this, SLOT(addService())); - connect(ui.removeButton, SIGNAL(clicked()), this, SLOT(removeService())); - connect(ui.copyButton, SIGNAL(clicked()), this, SLOT(copyToClipboard())); - connect(ui.browseButton, SIGNAL(clicked()), this, SLOT(browseDirectory())); - connect(ui.serviceWidget, SIGNAL(itemClicked(QTableWidgetItem*)), - this, SLOT(serviceSelectionChanged())); - connect(ui.serviceWidget, SIGNAL(itemChanged(QTableWidgetItem*)), - this, SLOT(valueChanged())); -} - -/** Destructor */ -ServicePage::~ServicePage() -{ - delete _services; - delete _torServices; -} - -/** Saves changes made to settings on the Server settings page. */ -bool -ServicePage::save(QString &errmsg) -{ - ServiceSettings serviceSettings(Vidalia::torControl()); - QList serviceList; - QList publishedServices; - int index = 0; - - while(index < ui.serviceWidget->rowCount()) { - QString address = ui.serviceWidget->item(index,0)->text(); - QString virtualPort = ui.serviceWidget->item(index,1)->text(); - QString physicalAddress = ui.serviceWidget->item(index,2)->text(); - QString directoryPath = ui.serviceWidget->item(index,3)->text(); - bool enabled = _services->value(index).enabled(); - Service temp(address, virtualPort, physicalAddress, directoryPath, - enabled); - temp.setAdditionalServiceOptions( - _services->value(ui.serviceWidget->currentRow()).additionalServiceOptions()); - serviceList.push_back(temp); - if(enabled) { - publishedServices.push_back(temp); - } - index++; - } - - bool save = checkBeforeSaving(serviceList); - if(save) { - ServiceList sList; - if(serviceList.size() > 0) { - sList.setServices(serviceList); - } else { - _services = new QMap(); - sList.setServices(_services->values()); - } - serviceSettings.setServices(sList); - if(publishedServices.size() > 0) { - startServicesInTor(publishedServices); - } else { - QString errmsg1 = tr("Error while trying to unpublish all services"); - QString &errmsg = errmsg1; - serviceSettings.unpublishAllServices(&errmsg); - } - return true; - } else { - errmsg = tr("Please configure at least a service directory and a virtual " - "port for each service you want to save. Remove the other ones."); - return false; - } -} - -/** this method checks if either all services have minimal - * configuration or not */ -bool -ServicePage::checkBeforeSaving(QList serviceList) -{ - bool result = true; - foreach(Service s, serviceList) { - if(s.serviceDirectory().isEmpty() || s.virtualPort().isEmpty()) { - result = false; - break; - } - } - return result; -} - -/** this method generates the configuration string for a list of services */ -void -ServicePage::startServicesInTor(QList services) -{ - ServiceSettings serviceSettings(Vidalia::torControl()); - QString serviceConfString; - QString errmsg = "Error while trying to publish services."; - QListIterator it(services); - - while(it.hasNext()) { - Service temp = it.next(); - serviceConfString.append("hiddenservicedir=" + - string_escape(temp.serviceDirectory()) + " "); - serviceConfString.append("hiddenserviceport=" + - string_escape(temp.virtualPort() + - (temp.physicalAddressPort().isEmpty() ? "" : " " + - temp.physicalAddressPort()))); - serviceConfString.append(" " + temp.additionalServiceOptions()); - } - serviceSettings.applyServices(serviceConfString, &errmsg); -} - -/** Loads previously saved settings */ -void -ServicePage::load() -{ - ServiceSettings serviceSettings(Vidalia::torControl()); - QList torServiceList; - - ui.removeButton->setEnabled(false); - ui.copyButton->setEnabled(false); - ui.browseButton->setEnabled(false); - // get all services - _services->clear(); - _torServices->clear(); - - QString torConfigurationString = serviceSettings.getHiddenServiceDirectories(); - torServiceList = extractSingleServices(torConfigurationString); - QList completeList = torServiceList; - // the services stored with vidalia - ServiceList serviceList = serviceSettings.getServices(); - QList serviceSettingsList = serviceList.services(); - QListIterator it(serviceSettingsList); - // check whether a service is already in the list because he is published - while(it.hasNext()) { - Service temp = it.next(); - if(isServicePublished(temp, torServiceList) == false) { - completeList.push_back(temp); - } - } - // generate the _services data structure used during vidalia session - QListIterator it2(completeList); - int index = 0; - while (it2.hasNext()) { - Service tempService = it2.next(); - _services->insert(index, tempService); - index++; - } - initServiceTable(_services); -} - -/** this method returns a list of services by parsing the configuration - * string given by the tor controller */ -QList -ServicePage::extractSingleServices(QString conf) -{ - QList list; - QStringList strList = conf.split("250 HiddenServiceDir"); - strList.removeFirst(); - QListIterator it(strList); - //for each service directory splitted string = service - while(it.hasNext()) { - QString temp = it.next(); - list.push_back(generateService(temp)); - } - return list; -} - -/** this return a Service by parseing the configuration string - * of Tor and storeing its values into the object */ -Service -ServicePage::generateService(QString s) -{ - QString additionalOptions = s; - // remove directory - int index = additionalOptions.indexOf("250",1); - additionalOptions.remove(0, index+4); - // remove the first appearance of the port - int startindex = additionalOptions.indexOf("hiddenserviceport", 0, - Qt::CaseInsensitive); - int endindex = additionalOptions.indexOf("250", startindex); - if(endindex != -1) { - additionalOptions.remove(startindex, (endindex-startindex)+4); - //remove all appearances of "250" - while(additionalOptions.contains("250")) { - int i = additionalOptions.indexOf("250", 0); - additionalOptions.remove(i, 4); - } - // prepare for correct quotation - if (!additionalOptions.endsWith('\n')) { - additionalOptions.append("\n"); - } - //quote the values - int j = additionalOptions.indexOf("=", 0); - while(j != -1) { - additionalOptions.insert(j+1, "\""); - int end = additionalOptions.indexOf("\n", j); - additionalOptions.insert(end, "\""); - j = additionalOptions.indexOf("=", end); - } - //replace the line brakes with a space and create one single line - additionalOptions.replace(QString("\n"), QString(" ")); - } else { - additionalOptions = ""; - } - - QString address, virtualPort, physAddressPort, serviceDir; - // service directory - QStringList strList = s.split("\n"); - QString tempServiceDir = strList.first().trimmed(); - serviceDir = tempServiceDir.remove(0, 1); - //virtual port - QStringList strList2 = s.split("HiddenServicePort"); - strList2.removeFirst(); - QStringList strList3 = strList2.first().split("\n"); - QStringList strList4 = strList3.first().split(" "); - if(strList4.size() > 0) { - QString tempVirtualPort = strList4.first(); - virtualPort = tempVirtualPort.remove(0, 1); - strList4.removeFirst(); - //physical address:port - if(!strList4.isEmpty()) { - physAddressPort = strList4.first().trimmed(); - } - } else { - QString tempVirtualPort = strList3.first(); - virtualPort = tempVirtualPort.remove(0, 1); - } - //get .onion address - QString serviceHostnameDir = serviceDir; - serviceHostnameDir.append("/"); - serviceHostnameDir.append("hostname"); - QFile file(serviceHostnameDir); - if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { - address = "[Directory not found]"; - } else { - QTextStream in(&file); - QString hostname; - while (!in.atEnd()) { - hostname.append(in.readLine()); - } - address = hostname; - } - Service service(address, virtualPort, physAddressPort, serviceDir, true); - service.setAdditionalServiceOptions(additionalOptions); - _torServices->insert(serviceDir, service); - return service; -} - -/** this method checks either a service is published or not */ -bool -ServicePage::isServicePublished(Service service, QList torServices) -{ - QListIterator it(torServices); - while(it.hasNext()) { - Service temp = it.next(); - if(temp.serviceDirectory().compare(service.serviceDirectory()) == 0) { - return true; - } - } - return false; -} - -/** this method creates/displays the values for each service - * shown in the service listing */ -void -ServicePage::initServiceTable(QMap* services) -{ - // clean the widget - int rows = ui.serviceWidget->rowCount(); - for(int i = 0; i < rows; i++) { - ui.serviceWidget->removeRow(0); - } - //for each service - int index = 0; - while(index < services->size()) { - Service tempService = services->value(index); - ui.serviceWidget->insertRow(index); - QTableWidgetItem *cboxitem = new QTableWidgetItem(); - cboxitem->setFlags(Qt::ItemIsSelectable); - QTableWidgetItem *addressitem = new QTableWidgetItem(); - addressitem->setFlags(Qt::ItemIsSelectable); - if(tempService.serviceAddress().length() < 0) { - addressitem->setText(tempService.serviceAddress()); - } else { - QString serviceHostnameDir = tempService.serviceDirectory(); - serviceHostnameDir.append("/"); - serviceHostnameDir.append("hostname"); - QFile file(serviceHostnameDir); - if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { - addressitem->setText("[Directory not found]"); - } else { - QTextStream in(&file); - QString hostname; - while (!in.atEnd()) { - hostname.append(in.readLine()); - } - addressitem->setText(hostname); - tempService.setServiceAddress(hostname); - } - } - addressitem->setData(32, addressitem->text()); - QTableWidgetItem *serviceDir = - new QTableWidgetItem(tempService.serviceDirectory(), 0); - serviceDir->setData(32, tempService.serviceDirectory()); - QTableWidgetItem* virtualportitem = - new QTableWidgetItem(tempService.virtualPort(), 0); - virtualportitem->setData(32, tempService.virtualPort()); - QTableWidgetItem* targetitem = - new QTableWidgetItem(tempService.physicalAddressPort(),0); - targetitem->setData(32, tempService.physicalAddressPort()); - if(tempService.enabled()) { - cboxitem->setCheckState(Qt::Checked); - serviceDir->setFlags(Qt::ItemIsSelectable); - } else { - cboxitem->setCheckState(Qt::Unchecked); - } - cboxitem->setTextAlignment(Qt::AlignCenter); - ui.serviceWidget->setItem(index, 0, addressitem); - ui.serviceWidget->setItem(index, 1, virtualportitem); - ui.serviceWidget->setItem(index, 2, targetitem); - ui.serviceWidget->setItem(index, 3, serviceDir); - ui.serviceWidget->setItem(index, 4, cboxitem); - index++; - } -} - -/** this method is called when the user clicks the "Add"-Button - * it generates a new empty table entrie(row) */ -void -ServicePage::addService() -{ - int rows = ui.serviceWidget->rowCount(); - ui.serviceWidget->insertRow(rows); - QTableWidgetItem *address = new QTableWidgetItem("["+tr("Created by Tor")+"]"); - address->setFlags(Qt::ItemIsSelectable); - QTableWidgetItem *dummy = new QTableWidgetItem(); - QTableWidgetItem *dummy2 = new QTableWidgetItem(); - QTableWidgetItem *dummy3 = new QTableWidgetItem(); - QTableWidgetItem *cboxitem = new QTableWidgetItem(); - cboxitem->setFlags(Qt::ItemIsSelectable); - cboxitem->setCheckState(Qt::Checked); - ui.serviceWidget->setItem(rows, 0, address); - ui.serviceWidget->setItem(rows, 1, dummy); - ui.serviceWidget->setItem(rows, 2, dummy2); - ui.serviceWidget->setItem(rows, 3, dummy3); - ui.serviceWidget->setItem(rows, 4, cboxitem); - Service s; - s.setEnabled(true); - _services->insert(rows, s); -} - -/** this method is called when the user clicks the "Remove"-Button - * it removes a service/row of the service listing */ -void -ServicePage::removeService() -{ - int rows = ui.serviceWidget->rowCount(); - int selrow = ui.serviceWidget->currentRow(); - if(selrow < 0 || selrow >= _services->size()) { - VMessageBox::warning(this, tr("Error"), tr("Please select a Service."), - VMessageBox::Ok); - return; - } else { - ui.serviceWidget->removeRow(selrow); - //decrease all other service keys - for(int i = 0; i < (rows-selrow-1); i++) { - int index = i+selrow; - Service s = _services->take(index+1); - _services->insert(index, s); - } - } - serviceSelectionChanged(); -} - -/** this method is called when the user clicks on the "Copy"-Button, it - * copies the .onion-Address of the selected service into the clipboard */ -void -ServicePage::copyToClipboard() -{ - int selrow = ui.serviceWidget->currentRow(); - if(selrow < 0 || selrow >= _services->size()) { - VMessageBox::warning(this, tr("Error"), tr("Please select a Service."), - VMessageBox::Ok); - return; - } else { - QString onionAddress = ui.serviceWidget->item(selrow,0)->text(); - QClipboard *clipboard = QApplication::clipboard(); - QString clipboardText; - QTableWidgetItem* selectedItem = ui.serviceWidget->item(selrow,0); - clipboardText.append(selectedItem->text()); - clipboard->setText(clipboardText); - } -} - -/** this method is called when the user clicks on the "Brows"-Button it opens - * a QFileDialog to choose a service directory */ -void -ServicePage::browseDirectory() -{ - int selrow = ui.serviceWidget->currentRow(); - if(selrow < 0 || selrow >= _services->size()) { - VMessageBox::warning(this, tr("Error"), tr("Please select a Service."), - VMessageBox::Ok); - return; - } else { - QString dirname = - QFileDialog::getExistingDirectory(this, - tr("Select Service Directory"), "", - QFileDialog::ShowDirsOnly - | QFileDialog::DontResolveSymlinks); - - if (dirname.isEmpty()) { - return; - } - ui.serviceWidget->item(selrow,3)->setText(dirname); - Service s = _services->take(selrow); - s.setServiceDirectory(dirname); - _services->insert(selrow, s); - } -} - -/** this method is called when the selects an other tablewidgetitem */ -void -ServicePage::serviceSelectionChanged() -{ - bool emptyTable = false; - if(ui.serviceWidget->rowCount() > 0) { - ui.removeButton->setEnabled(true); - ui.copyButton->setEnabled(true); - ui.browseButton->setEnabled(true); - } else { - ui.removeButton->setEnabled(false); - ui.copyButton->setEnabled(false); - ui.browseButton->setEnabled(false); - emptyTable = true; - } - int currentRow = ui.serviceWidget->currentRow(); - if(emptyTable == false) { - QTableWidgetItem* item = ui.serviceWidget->item(currentRow, 0); - if(item != NULL) { - bool b = item->text().contains(".onion"); - ui.copyButton->setEnabled(b); - } - } - - QString selDir = _services->value(ui.serviceWidget->currentRow()). - serviceDirectory(); - QList strList = _torServices->keys(); - if(selDir.length() > 0) { - QListIterator it(strList); - while(it.hasNext()) { - QString temp = it.next(); - if(selDir.compare(temp) == 0) { - ui.browseButton->setEnabled(false); - break; - } - } - } - // if the user has clicked on the checkbox cell - if(ui.serviceWidget->currentColumn() == 4) { - Service service = _services->take(currentRow); - QTableWidgetItem* item = ui.serviceWidget->item(currentRow,4); - if(service.enabled()) { - item->setCheckState(Qt::Unchecked); - service.setEnabled(false); - } else { - item->setCheckState(Qt::Checked); - service.setEnabled(true); - } - _services->insert(currentRow, service); - } -} - -/** this method is called when the user finished editing a cell and it provides - * that only valid values are set */ -void -ServicePage::valueChanged() -{ - int pos = 0; - QIntValidator* portValidator = new QIntValidator(1, 65535, this); - DomainValidator* domainValidator = new DomainValidator(this); - IPValidator* ipValidator = new IPValidator(this); - QTableWidgetItem* item = ui.serviceWidget->currentItem(); - if (item == NULL || item->text() == NULL || item->text().length() == 0) { - // nothing to validate here - return; - } - QString text = item->text(); - switch (item->column()) { - case 1: // virtual port - if(portValidator->validate(text, pos) == QValidator::Acceptable) { - // correct data; buffer value in user role 32 - item->setData(32, text); - } else { - //incorrect data; restore value from user role 32 - VMessageBox::warning(this, tr("Error"), - tr("Virtual Port may only contain valid port numbers [1..65535]."), - VMessageBox::Ok); - item->setText(item->data(32).toString()); - } - break; - case 2: // target - if(text.contains(":")) { - // check for
: - QStringList strList = text.split(":"); - if (strList.size() != 2) { - goto invalid; - } - QString address = strList.at(0); - QString port = strList.at(1); - if((address.compare("localhost") != 0 && - ipValidator->validate(address, pos) != QValidator::Acceptable && - domainValidator->validate(address, pos) != QValidator::Acceptable) || - portValidator->validate(port, pos) != QValidator::Acceptable) { - goto invalid; - } - } else { // either
or - if (text.compare("localhost") != 0 && - ipValidator->validate(text, pos) != QValidator::Acceptable && - domainValidator->validate(text, pos) != QValidator::Acceptable && - portValidator->validate(text, pos) != QValidator::Acceptable) { - goto invalid; - } - } - goto valid; - invalid: - VMessageBox::warning(this, tr("Error"), - tr("Target may only contain address:port, address, or port."), - VMessageBox::Ok); - item->setText(item->data(32).toString()); - break; - valid: - item->setData(32, text); - break; - case 3: // service directory - // compare with directories of other enabled services - for (int index = 0; index < ui.serviceWidget->rowCount(); index++) { - // skip own row - if(index == item->row()) { - continue; - } - QTableWidgetItem* compareWith = ui.serviceWidget->item(index, 3); - if(compareWith != NULL) { - QString actualDir = compareWith->text(); - if(actualDir.length() > 0 && text.compare(actualDir) == 0) { - // service directory already in use - VMessageBox::warning(this, tr("Error"), - tr("Directory already in use by another service."), - VMessageBox::Ok); - item->setText(item->data(32).toString()); - return; - } - } - } - // correct data; buffer value in user role 32 - item->setData(32, text); - break; - } -} - diff -Nru vidalia-0.1.13/src/vidalia/config/ServicePage.cpp vidalia-0.2.8/src/vidalia/config/ServicePage.cpp --- vidalia-0.1.13/src/vidalia/config/ServicePage.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/ServicePage.cpp 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,613 @@ +/* +** 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.vidalia-project.net/. No part of Vidalia, including this file, +** may be copied, modified, propagated, or distributed except according to the +** terms described in the LICENSE file. +*/ + +#include "ServicePage.h" +#include "Service.h" +#include "ServiceList.h" +#include "VMessageBox.h" +#include "ConfigDialog.h" +#include "IpValidator.h" +#include "DomainValidator.h" +#include "Vidalia.h" + +#include "stringutil.h" +#include "file.h" + +#include +#include +#include +#include + + +/** Constructor */ +ServicePage::ServicePage(QWidget *parent) +: ConfigPage(parent, "Services") +{ + /* Invoke the Qt Designer generated object setup routine */ + ui.setupUi(this); + /* A QMap, mapping from the row number to the Entity for + * all services */ + _services = new QMap(); + /* A QMap, mapping from the directory path to the Entity for + * all Tor services */ + _torServices = new QMap(); + + ui.serviceWidget->horizontalHeader()->resizeSection(0, 150); + ui.serviceWidget->horizontalHeader()->resizeSection(1, 89); + ui.serviceWidget->horizontalHeader()->resizeSection(2, 100); + ui.serviceWidget->horizontalHeader()->resizeSection(3, 120); + ui.serviceWidget->horizontalHeader()->resizeSection(4, 60); + ui.serviceWidget->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch); + ui.serviceWidget->horizontalHeader()->setResizeMode(1, QHeaderView::Stretch); + ui.serviceWidget->horizontalHeader()->setResizeMode(2, QHeaderView::Stretch); + ui.serviceWidget->horizontalHeader()->setResizeMode(3, QHeaderView::Stretch); + ui.serviceWidget->verticalHeader()->hide(); + + connect(ui.addButton, SIGNAL(clicked()), this, SLOT(addService())); + connect(ui.removeButton, SIGNAL(clicked()), this, SLOT(removeService())); + connect(ui.copyButton, SIGNAL(clicked()), this, SLOT(copyToClipboard())); + connect(ui.browseButton, SIGNAL(clicked()), this, SLOT(browseDirectory())); + connect(ui.serviceWidget, SIGNAL(itemClicked(QTableWidgetItem*)), + this, SLOT(serviceSelectionChanged())); + connect(ui.serviceWidget, SIGNAL(itemChanged(QTableWidgetItem*)), + this, SLOT(valueChanged())); +} + +/** Destructor */ +ServicePage::~ServicePage() +{ + delete _services; + delete _torServices; +} + +/** Called when the user changes the UI translation. */ +void +ServicePage::retranslateUi() +{ + ui.retranslateUi(this); +} + +/** Saves changes made to settings on the Server settings page. */ +bool +ServicePage::save(QString &errmsg) +{ + ServiceSettings serviceSettings(Vidalia::torControl()); + QList serviceList; + QList publishedServices; + int index = 0; + + while(index < ui.serviceWidget->rowCount()) { + QString address = ui.serviceWidget->item(index,0)->text(); + QString virtualPort = ui.serviceWidget->item(index,1)->text(); + QString physicalAddress = ui.serviceWidget->item(index,2)->text(); + QString directoryPath = ui.serviceWidget->item(index,3)->text(); + bool enabled = _services->value(index).enabled(); + Service temp(address, virtualPort, physicalAddress, directoryPath, + enabled); + temp.setAdditionalServiceOptions( + _services->value(ui.serviceWidget->currentRow()).additionalServiceOptions()); + serviceList.push_back(temp); + if(enabled) { + publishedServices.push_back(temp); + } + index++; + } + + bool save = checkBeforeSaving(serviceList); + if(save) { + ServiceList sList; + if(serviceList.size() > 0) { + sList.setServices(serviceList); + } else { + _services = new QMap(); + sList.setServices(_services->values()); + } + serviceSettings.setServices(sList); + if(publishedServices.size() > 0) { + startServicesInTor(publishedServices); + } else { + QString errmsg1 = tr("Error while trying to unpublish all services"); + QString &errmsg = errmsg1; + serviceSettings.unpublishAllServices(&errmsg); + } + return true; + } else { + errmsg = tr("Please configure at least a service directory and a virtual " + "port for each service you want to save. Remove the other ones."); + return false; + } +} + +/** this method checks if either all services have minimal + * configuration or not */ +bool +ServicePage::checkBeforeSaving(QList serviceList) +{ + bool result = true; + foreach(Service s, serviceList) { + if(s.serviceDirectory().isEmpty() || s.virtualPort().isEmpty()) { + result = false; + break; + } + } + return result; +} + +/** this method generates the configuration string for a list of services */ +void +ServicePage::startServicesInTor(QList services) +{ + ServiceSettings serviceSettings(Vidalia::torControl()); + QString serviceConfString; + QString errmsg = "Error while trying to publish services."; + QListIterator it(services); + + while(it.hasNext()) { + Service temp = it.next(); + serviceConfString.append("hiddenservicedir=" + + string_escape(temp.serviceDirectory()) + " "); + serviceConfString.append("hiddenserviceport=" + + string_escape(temp.virtualPort() + + (temp.physicalAddressPort().isEmpty() ? "" : " " + + temp.physicalAddressPort()))); + serviceConfString.append(" " + temp.additionalServiceOptions()); + } + serviceSettings.applyServices(serviceConfString, &errmsg); +} + +/** Loads previously saved settings */ +void +ServicePage::load() +{ + ServiceSettings serviceSettings(Vidalia::torControl()); + QList torServiceList; + + ui.removeButton->setEnabled(false); + ui.copyButton->setEnabled(false); + ui.browseButton->setEnabled(false); + // get all services + _services->clear(); + _torServices->clear(); + + QString torConfigurationString = serviceSettings.getHiddenServiceDirectories(); + torServiceList = extractSingleServices(torConfigurationString); + QList completeList = torServiceList; + // the services stored with vidalia + ServiceList serviceList = serviceSettings.getServices(); + QList serviceSettingsList = serviceList.services(); + QListIterator it(serviceSettingsList); + // check whether a service is already in the list because he is published + while(it.hasNext()) { + Service temp = it.next(); + if(isServicePublished(temp, torServiceList) == false) { + completeList.push_back(temp); + } + } + // generate the _services data structure used during vidalia session + QListIterator it2(completeList); + int index = 0; + while (it2.hasNext()) { + Service tempService = it2.next(); + _services->insert(index, tempService); + index++; + } + initServiceTable(_services); +} + +/** this method returns a list of services by parsing the configuration + * string given by the tor controller */ +QList +ServicePage::extractSingleServices(QString conf) +{ + QList list; + QStringList strList = conf.split("250 HiddenServiceDir"); + strList.removeFirst(); + QListIterator it(strList); + //for each service directory splitted string = service + while(it.hasNext()) { + QString temp = it.next(); + list.push_back(generateService(temp)); + } + return list; +} + +/** this return a Service by parseing the configuration string + * of Tor and storeing its values into the object */ +Service +ServicePage::generateService(QString s) +{ + QString additionalOptions = s; + // remove directory + int index = additionalOptions.indexOf("250",1); + additionalOptions.remove(0, index+4); + // remove the first appearance of the port + int startindex = additionalOptions.indexOf("hiddenserviceport", 0, + Qt::CaseInsensitive); + int endindex = additionalOptions.indexOf("250", startindex); + if(endindex != -1) { + additionalOptions.remove(startindex, (endindex-startindex)+4); + //remove all appearances of "250" + while(additionalOptions.contains("250")) { + int i = additionalOptions.indexOf("250", 0); + additionalOptions.remove(i, 4); + } + // prepare for correct quotation + if (!additionalOptions.endsWith('\n')) { + additionalOptions.append("\n"); + } + //quote the values + int j = additionalOptions.indexOf("=", 0); + while(j != -1) { + additionalOptions.insert(j+1, "\""); + int end = additionalOptions.indexOf("\n", j); + additionalOptions.insert(end, "\""); + j = additionalOptions.indexOf("=", end); + } + //replace the line brakes with a space and create one single line + additionalOptions.replace(QString("\n"), QString(" ")); + } else { + additionalOptions = ""; + } + + QString address, virtualPort, physAddressPort, serviceDir; + // service directory + QStringList strList = s.split("\n"); + QString tempServiceDir = strList.first().trimmed(); + serviceDir = tempServiceDir.remove(0, 1); + //virtual port + QStringList strList2 = s.split("HiddenServicePort"); + strList2.removeFirst(); + QStringList strList3 = strList2.first().split("\n"); + QStringList strList4 = strList3.first().split(" "); + if(strList4.size() > 0) { + QString tempVirtualPort = strList4.first(); + virtualPort = tempVirtualPort.remove(0, 1); + strList4.removeFirst(); + //physical address:port + if(!strList4.isEmpty()) { + physAddressPort = strList4.first().trimmed(); + } + } else { + QString tempVirtualPort = strList3.first(); + virtualPort = tempVirtualPort.remove(0, 1); + } + //get .onion address + QString serviceHostnameDir = serviceDir; + serviceHostnameDir.append("/"); + serviceHostnameDir.append("hostname"); + QFile file(serviceHostnameDir); + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { + address = "[Directory not found]"; + } else { + QTextStream in(&file); + QString hostname; + while (!in.atEnd()) { + hostname.append(in.readLine()); + } + address = hostname; + } + Service service(address, virtualPort, physAddressPort, serviceDir, true); + service.setAdditionalServiceOptions(additionalOptions); + _torServices->insert(serviceDir, service); + return service; +} + +/** this method checks either a service is published or not */ +bool +ServicePage::isServicePublished(Service service, QList torServices) +{ + QListIterator it(torServices); + while(it.hasNext()) { + Service temp = it.next(); + if(temp.serviceDirectory().compare(service.serviceDirectory()) == 0) { + return true; + } + } + return false; +} + +/** this method creates/displays the values for each service + * shown in the service listing */ +void +ServicePage::initServiceTable(QMap* services) +{ + // clean the widget + int rows = ui.serviceWidget->rowCount(); + for(int i = 0; i < rows; i++) { + ui.serviceWidget->removeRow(0); + } + //for each service + int index = 0; + while(index < services->size()) { + Service tempService = services->value(index); + ui.serviceWidget->insertRow(index); + QTableWidgetItem *cboxitem = new QTableWidgetItem(); + cboxitem->setFlags(Qt::ItemIsSelectable); + QTableWidgetItem *addressitem = new QTableWidgetItem(); + addressitem->setFlags(Qt::ItemIsSelectable); + if(tempService.serviceAddress().length() < 0) { + addressitem->setText(tempService.serviceAddress()); + } else { + QString serviceHostnameDir = tempService.serviceDirectory(); + serviceHostnameDir.append("/"); + serviceHostnameDir.append("hostname"); + QFile file(serviceHostnameDir); + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { + addressitem->setText("[Directory not found]"); + } else { + QTextStream in(&file); + QString hostname; + while (!in.atEnd()) { + hostname.append(in.readLine()); + } + addressitem->setText(hostname); + tempService.setServiceAddress(hostname); + } + } + addressitem->setData(32, addressitem->text()); + QTableWidgetItem *serviceDir = + new QTableWidgetItem(tempService.serviceDirectory(), 0); + serviceDir->setData(32, tempService.serviceDirectory()); + QTableWidgetItem* virtualportitem = + new QTableWidgetItem(tempService.virtualPort(), 0); + virtualportitem->setData(32, tempService.virtualPort()); + QTableWidgetItem* targetitem = + new QTableWidgetItem(tempService.physicalAddressPort(),0); + targetitem->setData(32, tempService.physicalAddressPort()); + if(tempService.enabled()) { + cboxitem->setCheckState(Qt::Checked); + serviceDir->setFlags(Qt::ItemIsSelectable); + } else { + cboxitem->setCheckState(Qt::Unchecked); + } + cboxitem->setTextAlignment(Qt::AlignCenter); + ui.serviceWidget->setItem(index, 0, addressitem); + ui.serviceWidget->setItem(index, 1, virtualportitem); + ui.serviceWidget->setItem(index, 2, targetitem); + ui.serviceWidget->setItem(index, 3, serviceDir); + ui.serviceWidget->setItem(index, 4, cboxitem); + index++; + } +} + +/** this method is called when the user clicks the "Add"-Button + * it generates a new empty table entrie(row) */ +void +ServicePage::addService() +{ + int rows = ui.serviceWidget->rowCount(); + ui.serviceWidget->insertRow(rows); + QTableWidgetItem *address = new QTableWidgetItem("["+tr("Created by Tor")+"]"); + address->setFlags(Qt::ItemIsSelectable); + QTableWidgetItem *dummy = new QTableWidgetItem(); + QTableWidgetItem *dummy2 = new QTableWidgetItem(); + QTableWidgetItem *dummy3 = new QTableWidgetItem(); + QTableWidgetItem *cboxitem = new QTableWidgetItem(); + cboxitem->setFlags(Qt::ItemIsSelectable); + cboxitem->setCheckState(Qt::Checked); + ui.serviceWidget->setItem(rows, 0, address); + ui.serviceWidget->setItem(rows, 1, dummy); + ui.serviceWidget->setItem(rows, 2, dummy2); + ui.serviceWidget->setItem(rows, 3, dummy3); + ui.serviceWidget->setItem(rows, 4, cboxitem); + Service s; + s.setEnabled(true); + _services->insert(rows, s); +} + +/** this method is called when the user clicks the "Remove"-Button + * it removes a service/row of the service listing */ +void +ServicePage::removeService() +{ + int rows = ui.serviceWidget->rowCount(); + int selrow = ui.serviceWidget->currentRow(); + if(selrow < 0 || selrow >= _services->size()) { + VMessageBox::warning(this, tr("Error"), tr("Please select a Service."), + VMessageBox::Ok); + return; + } else { + ui.serviceWidget->removeRow(selrow); + //decrease all other service keys + for(int i = 0; i < (rows-selrow-1); i++) { + int index = i+selrow; + Service s = _services->take(index+1); + _services->insert(index, s); + } + } + serviceSelectionChanged(); +} + +/** this method is called when the user clicks on the "Copy"-Button, it + * copies the .onion-Address of the selected service into the clipboard */ +void +ServicePage::copyToClipboard() +{ + int selrow = ui.serviceWidget->currentRow(); + if(selrow < 0 || selrow >= _services->size()) { + VMessageBox::warning(this, tr("Error"), tr("Please select a Service."), + VMessageBox::Ok); + return; + } else { + QString onionAddress = ui.serviceWidget->item(selrow,0)->text(); + QClipboard *clipboard = QApplication::clipboard(); + QString clipboardText; + QTableWidgetItem* selectedItem = ui.serviceWidget->item(selrow,0); + clipboardText.append(selectedItem->text()); + clipboard->setText(clipboardText); + } +} + +/** this method is called when the user clicks on the "Brows"-Button it opens + * a QFileDialog to choose a service directory */ +void +ServicePage::browseDirectory() +{ + int selrow = ui.serviceWidget->currentRow(); + if(selrow < 0 || selrow >= _services->size()) { + VMessageBox::warning(this, tr("Error"), tr("Please select a Service."), + VMessageBox::Ok); + return; + } else { + QString dirname = + QFileDialog::getExistingDirectory(this, + tr("Select Service Directory"), "", + QFileDialog::ShowDirsOnly + | QFileDialog::DontResolveSymlinks); + + if (dirname.isEmpty()) { + return; + } + ui.serviceWidget->item(selrow,3)->setText(dirname); + Service s = _services->take(selrow); + s.setServiceDirectory(dirname); + _services->insert(selrow, s); + } +} + +/** this method is called when the selects an other tablewidgetitem */ +void +ServicePage::serviceSelectionChanged() +{ + bool emptyTable = false; + if(ui.serviceWidget->rowCount() > 0) { + ui.removeButton->setEnabled(true); + ui.copyButton->setEnabled(true); + ui.browseButton->setEnabled(true); + } else { + ui.removeButton->setEnabled(false); + ui.copyButton->setEnabled(false); + ui.browseButton->setEnabled(false); + emptyTable = true; + } + int currentRow = ui.serviceWidget->currentRow(); + if(emptyTable == false) { + QTableWidgetItem* item = ui.serviceWidget->item(currentRow, 0); + if(item != NULL) { + bool b = item->text().contains(".onion"); + ui.copyButton->setEnabled(b); + } + } + + QString selDir = _services->value(ui.serviceWidget->currentRow()). + serviceDirectory(); + QList strList = _torServices->keys(); + if(selDir.length() > 0) { + QListIterator it(strList); + while(it.hasNext()) { + QString temp = it.next(); + if(selDir.compare(temp) == 0) { + ui.browseButton->setEnabled(false); + break; + } + } + } + // if the user has clicked on the checkbox cell + if(ui.serviceWidget->currentColumn() == 4) { + Service service = _services->take(currentRow); + QTableWidgetItem* item = ui.serviceWidget->item(currentRow,4); + if(service.enabled()) { + item->setCheckState(Qt::Unchecked); + service.setEnabled(false); + } else { + item->setCheckState(Qt::Checked); + service.setEnabled(true); + } + _services->insert(currentRow, service); + } +} + +/** this method is called when the user finished editing a cell and it provides + * that only valid values are set */ +void +ServicePage::valueChanged() +{ + int pos = 0; + QIntValidator* portValidator = new QIntValidator(1, 65535, this); + DomainValidator* domainValidator = new DomainValidator(this); + IpValidator* ipValidator = new IpValidator(this); + QTableWidgetItem* item = ui.serviceWidget->currentItem(); + if (item == NULL || item->text() == NULL || item->text().length() == 0) { + // nothing to validate here + return; + } + QString text = item->text(); + switch (item->column()) { + case 1: // virtual port + if(portValidator->validate(text, pos) == QValidator::Acceptable) { + // correct data; buffer value in user role 32 + item->setData(32, text); + } else { + //incorrect data; restore value from user role 32 + VMessageBox::warning(this, tr("Error"), + tr("Virtual Port may only contain valid port numbers [1..65535]."), + VMessageBox::Ok); + item->setText(item->data(32).toString()); + } + break; + case 2: // target + if(text.contains(":")) { + // check for
: + QStringList strList = text.split(":"); + if (strList.size() != 2) { + goto invalid; + } + QString address = strList.at(0); + QString port = strList.at(1); + if((address.compare("localhost") != 0 && + ipValidator->validate(address, pos) != QValidator::Acceptable && + domainValidator->validate(address, pos) != QValidator::Acceptable) || + portValidator->validate(port, pos) != QValidator::Acceptable) { + goto invalid; + } + } else { // either
or + if (text.compare("localhost") != 0 && + ipValidator->validate(text, pos) != QValidator::Acceptable && + domainValidator->validate(text, pos) != QValidator::Acceptable && + portValidator->validate(text, pos) != QValidator::Acceptable) { + goto invalid; + } + } + goto valid; + invalid: + VMessageBox::warning(this, tr("Error"), + tr("Target may only contain address:port, address, or port."), + VMessageBox::Ok); + item->setText(item->data(32).toString()); + break; + valid: + item->setData(32, text); + break; + case 3: // service directory + // compare with directories of other enabled services + for (int index = 0; index < ui.serviceWidget->rowCount(); index++) { + // skip own row + if(index == item->row()) { + continue; + } + QTableWidgetItem* compareWith = ui.serviceWidget->item(index, 3); + if(compareWith != NULL) { + QString actualDir = compareWith->text(); + if(actualDir.length() > 0 && text.compare(actualDir) == 0) { + // service directory already in use + VMessageBox::warning(this, tr("Error"), + tr("Directory already in use by another service."), + VMessageBox::Ok); + item->setText(item->data(32).toString()); + return; + } + } + } + // correct data; buffer value in user role 32 + item->setData(32, text); + break; + } +} + diff -Nru vidalia-0.1.13/src/vidalia/config/servicepage.h vidalia-0.2.8/src/vidalia/config/servicepage.h --- vidalia-0.1.13/src/vidalia/config/servicepage.h 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/servicepage.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,76 +0,0 @@ -/* -** 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.vidalia-project.net/. No part of Vidalia, including this file, -** may be copied, modified, propagated, or distributed except according to the -** terms described in the LICENSE file. -*/ - -#ifndef _SERVICEPAGE_H -#define _SERVICEPAGE_H - -#include -#include -#include -#include -#include -#include "configpage.h" -#include "ui_servicepage.h" - -class ServicePage : public ConfigPage -{ - Q_OBJECT - -public: - /** Default Constructor */ - ServicePage(QWidget *parent = 0); - /** Default Destructor */ - ~ServicePage(); - /** Saves the changes on this page */ - bool save(QString &errmsg); - /** Loads the settings for this page */ - void load(); - /** Initialize the service table */ - void initServiceTable(QMap* _services); - -private slots: - /** Called whenever the user clicks on the 'add' button. */ - void addService(); - /** Called whenever the user clicks on the 'remove' button. */ - void removeService(); - /** Called whenever the user clicks on the 'copy' button. */ - void copyToClipboard(); - /** Called whenever the user clicks on the 'browse' button. */ - void browseDirectory(); - /** Called whenever the user selects a different service. */ - void serviceSelectionChanged(); - /** Returns a list of services by parsing the configuration string given - * by the Tor controller. */ - QList extractSingleServices(QString conf); - /** Returns a Service by parsing the configuration string from Tor and - * storing its values into the Service object. */ - Service generateService(QString serviceString); - /** Starts all services in services, with Tor. */ - void startServicesInTor(QList services); - /** Returns true if service is published. */ - bool isServicePublished(Service service, QList torServices); - /** Returns true if all services have the required minimal configuration. */ - bool checkBeforeSaving(QList services); - /** Called when the user finished editing a cell and checks that only valid - * values are set. */ - void valueChanged(); - -private: - /** A QMap, mapping from the row number in the table to the service Entity */ - QMap* _services; - /** A QList, consisting of all running services before vidalia starts */ - QMap* _torServices; - - /** Qt Designer generated object */ - Ui::ServicePage ui; -}; - -#endif - diff -Nru vidalia-0.1.13/src/vidalia/config/ServicePage.h vidalia-0.2.8/src/vidalia/config/ServicePage.h --- vidalia-0.1.13/src/vidalia/config/ServicePage.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/ServicePage.h 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,80 @@ +/* +** 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.vidalia-project.net/. No part of Vidalia, including this file, +** may be copied, modified, propagated, or distributed except according to the +** terms described in the LICENSE file. +*/ + +#ifndef _SERVICEPAGE_H +#define _SERVICEPAGE_H + +#include "ui_ServicePage.h" +#include "ConfigPage.h" +#include "TorSettings.h" +#include "ServiceSettings.h" +#include "ExitPolicy.h" +#include "HelpBrowser.h" + +#include "TorControl.h" + + +class ServicePage : public ConfigPage +{ + Q_OBJECT + +public: + /** Default Constructor */ + ServicePage(QWidget *parent = 0); + /** Default Destructor */ + ~ServicePage(); + /** Saves the changes on this page */ + bool save(QString &errmsg); + /** Loads the settings for this page */ + void load(); + /** Initialize the service table */ + void initServiceTable(QMap* _services); + /** Called when the user changes the UI translation. */ + virtual void retranslateUi(); + +private slots: + /** Called whenever the user clicks on the 'add' button. */ + void addService(); + /** Called whenever the user clicks on the 'remove' button. */ + void removeService(); + /** Called whenever the user clicks on the 'copy' button. */ + void copyToClipboard(); + /** Called whenever the user clicks on the 'browse' button. */ + void browseDirectory(); + /** Called whenever the user selects a different service. */ + void serviceSelectionChanged(); + /** Returns a list of services by parsing the configuration string given + * by the Tor controller. */ + QList extractSingleServices(QString conf); + /** Returns a Service by parsing the configuration string from Tor and + * storing its values into the Service object. */ + Service generateService(QString serviceString); + /** Starts all services in services, with Tor. */ + void startServicesInTor(QList services); + /** Returns true if service is published. */ + bool isServicePublished(Service service, QList torServices); + /** Returns true if all services have the required minimal configuration. */ + bool checkBeforeSaving(QList services); + /** Called when the user finished editing a cell and checks that only valid + * values are set. */ + void valueChanged(); + +private: + /** A QMap, mapping from the row number in the table to the service Entity */ + QMap* _services; + /** A QList, consisting of all running services before vidalia starts */ + QMap* _torServices; + + /** Qt Designer generated object */ + Ui::ServicePage ui; +}; + +#endif + diff -Nru vidalia-0.1.13/src/vidalia/config/servicepage.ui vidalia-0.2.8/src/vidalia/config/servicepage.ui --- vidalia-0.1.13/src/vidalia/config/servicepage.ui 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/servicepage.ui 1970-01-01 01:00:00.000000000 +0100 @@ -1,166 +0,0 @@ - - ServicePage - - - - 0 - 0 - 600 - 400 - - - - - 600 - 400 - - - - Form - - - - - - - 0 - 0 - - - - Provided Hidden Services - - - - - - - 0 - 0 - - - - QAbstractItemView::SingleSelection - - - QAbstractItemView::SelectRows - - - Qt::ElideLeft - - - true - - - - Onion Address - - - - - Virtual Port - - - - - Target - - - - - Directory Path - - - - - Enabled - - - - - - - - Add new service to list - - - - - - :/images/22x22/list-add.png - - - - - - - Remove selected service from list - - - - - - :/images/22x22/list-remove.png - - - - - - - Copy onion address of selected service to clipboard - - - - - - :/images/22x22/edit-copy.png - - - - - - - Browse in local file system and choose directory for selected service - - - - - - :/images/22x22/folder.png - - - - - - - Qt::Vertical - - - - 21 - 46 - - - - - - - - - - - Qt::Vertical - - - - 20 - 141 - - - - - - - - - diff -Nru vidalia-0.1.13/src/vidalia/config/ServicePage.ui vidalia-0.2.8/src/vidalia/config/ServicePage.ui --- vidalia-0.1.13/src/vidalia/config/ServicePage.ui 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/ServicePage.ui 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,166 @@ + + ServicePage + + + + 0 + 0 + 600 + 400 + + + + + 600 + 400 + + + + Form + + + + + + + 0 + 0 + + + + Provided Hidden Services + + + + + + + 0 + 0 + + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + + + Qt::ElideLeft + + + true + + + + Onion Address + + + + + Virtual Port + + + + + Target + + + + + Directory Path + + + + + Enabled + + + + + + + + Add new service to list + + + + + + :/images/22x22/list-add.png + + + + + + + Remove selected service from list + + + + + + :/images/22x22/list-remove.png + + + + + + + Copy onion address of selected service to clipboard + + + + + + :/images/22x22/edit-copy.png + + + + + + + Browse in local file system and choose directory for selected service + + + + + + :/images/22x22/folder.png + + + + + + + Qt::Vertical + + + + 21 + 46 + + + + + + + + + + + Qt::Vertical + + + + 20 + 141 + + + + + + + + + diff -Nru vidalia-0.1.13/src/vidalia/config/servicesettings.cpp vidalia-0.2.8/src/vidalia/config/servicesettings.cpp --- vidalia-0.1.13/src/vidalia/config/servicesettings.cpp 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/servicesettings.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,166 +0,0 @@ -/* -** 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.vidalia-project.net/. No part of Vidalia, including this file, -** may be copied, modified, propagated, or distributed except according to the -** terms described in the LICENSE file. -*/ - -#include -#include "servicesettings.h" -#include "torsettings.h" - -/* Service Settings */ -#define SETTING_SERVICE_VIRTUAL_PORT "Service/VirtualPort" -#define SETTING_SERVICE_ADDRESS "Service/ServiceAddress" -#define SETTING_SERVICE_PHYSICAL_ADDRESS "Service/ServicePhysicalAddress" -#define SETTING_SERVICE_ENABLED "Service/Enabled" -#define SETTING_TOR_SERVICES "Service/Services" - -/** Constructor. - * \param torControl a TorControl object used to read and apply the Service - * configuration settings. - */ -ServiceSettings::ServiceSettings(TorControl *torControl) -{ - _torControl = torControl; - setDefault(SETTING_SERVICE_VIRTUAL_PORT , 0); - setDefault(SETTING_SERVICE_PHYSICAL_ADDRESS, "127.0.0.1:0"); - setDefault(SETTING_SERVICE_ENABLED, "true"); -} - -/** Set ServiceList to serialise it */ -void -ServiceSettings::setServices(ServiceList service) -{ - QStringList serviceList; - if(service.services().size() > 0) { - QList services = service.services(); - foreach (Service tempService, services) { - serviceList << tempService.toString(); - } - } - setValue(SETTING_TOR_SERVICES, serviceList); -} - -/** Get serialised ServiceList */ -ServiceList -ServiceSettings::getServices() -{ - QString address,virtualPort,physAddrPort,serviceDir,enabledS,additionalData; - bool enabled = false; - QStringList stringList; - ServiceList services; - - stringList = value(SETTING_TOR_SERVICES).toStringList(); - foreach (QString s, stringList) { - QStringList skippedList = s.split("#"); - address = skippedList.first(); - skippedList.removeFirst(); - virtualPort = skippedList.first(); - skippedList.removeFirst(); - physAddrPort = skippedList.first(); - skippedList.removeFirst(); - serviceDir = skippedList.first(); - skippedList.removeFirst(); - enabledS = skippedList.first(); - skippedList.removeFirst(); - additionalData = skippedList.first(); - if(enabledS.compare("x1") == 0) { - enabled = true; - } - Service service(address, virtualPort, physAddrPort, serviceDir, enabled); - service.setAdditionalServiceOptions(additionalData); - services.addService(service); - } - return services; -} - -/** Returns the virtual port for a specific service*/ -QString -ServiceSettings::getVirtualPort() -{ - QString port = value(SETTING_SERVICE_VIRTUAL_PORT).toString(); - return port; -} - -/** Set the virtual port for a specific service*/ -void -ServiceSettings::setVirtualPort(QString servicePort) -{ - setValue(SETTING_SERVICE_VIRTUAL_PORT, servicePort); -} - -/** Returns the .onion - service address for a specific service */ -QString -ServiceSettings::getServiceAddress() -{ - QString addr = value(SETTING_SERVICE_ADDRESS).toString(); - return addr; -} - -/** Set the .onion - service address or hostname for a specific service */ -void -ServiceSettings::setServiceAddress(QString addr) -{ - setValue(SETTING_SERVICE_ADDRESS, addr); -} - -/** Returns the physical address for a specific service */ -QString -ServiceSettings::getPhysicalAddressPort() -{ - QString addr = value(SETTING_SERVICE_PHYSICAL_ADDRESS).toString(); - return addr; -} - -/** Set the physical address or hostname for a specific service */ -void -ServiceSettings::setPhysicalAddressPort(QString addr) -{ - setValue(SETTING_SERVICE_PHYSICAL_ADDRESS, addr); -} - -/** Returns if the Service is enabled */ -bool -ServiceSettings::isEnabled() -{ - return value(SETTING_SERVICE_ENABLED).toBool(); -} - -/** Set the service enabled */ -void -ServiceSettings::setEnabled(bool boolean) -{ - setValue(SETTING_SERVICE_ENABLED, boolean); -} - -/** Get all service directories from Tor */ -QString -ServiceSettings::getHiddenServiceDirectories() -{ - /*XXX: Domenik: Why does this always try to getconf hiddenserviceoptions - * even if the socket is not connected? */ - QString value = _torControl->getHiddenServiceConf("hiddenserviceoptions"); - return value; -} - -/** Set all services the user wants to start and send it to the - * Tor Controller*/ -void -ServiceSettings::applyServices(QString value, QString *errmsg) -{ - _torControl->setConf(value, errmsg); - _torControl->saveConf(errmsg); -} - -/** Unpublish all HiddenServices */ -void -ServiceSettings::unpublishAllServices(QString *errmsg) -{ - _torControl->resetConf("HiddenServiceDir", errmsg); - _torControl->saveConf(errmsg); -} - diff -Nru vidalia-0.1.13/src/vidalia/config/ServiceSettings.cpp vidalia-0.2.8/src/vidalia/config/ServiceSettings.cpp --- vidalia-0.1.13/src/vidalia/config/ServiceSettings.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/ServiceSettings.cpp 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,167 @@ +/* +** 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.vidalia-project.net/. No part of Vidalia, including this file, +** may be copied, modified, propagated, or distributed except according to the +** terms described in the LICENSE file. +*/ + +#include "ServiceSettings.h" +#include "TorSettings.h" + +#include "stringutil.h" + +/* Service Settings */ +#define SETTING_SERVICE_VIRTUAL_PORT "Service/VirtualPort" +#define SETTING_SERVICE_ADDRESS "Service/ServiceAddress" +#define SETTING_SERVICE_PHYSICAL_ADDRESS "Service/ServicePhysicalAddress" +#define SETTING_SERVICE_ENABLED "Service/Enabled" +#define SETTING_TOR_SERVICES "Service/Services" + +/** Constructor. + * \param torControl a TorControl object used to read and apply the Service + * configuration settings. + */ +ServiceSettings::ServiceSettings(TorControl *torControl) +{ + _torControl = torControl; + setDefault(SETTING_SERVICE_VIRTUAL_PORT , 0); + setDefault(SETTING_SERVICE_PHYSICAL_ADDRESS, "127.0.0.1:0"); + setDefault(SETTING_SERVICE_ENABLED, "true"); +} + +/** Set ServiceList to serialise it */ +void +ServiceSettings::setServices(ServiceList service) +{ + QStringList serviceList; + if(service.services().size() > 0) { + QList services = service.services(); + foreach (Service tempService, services) { + serviceList << tempService.toString(); + } + } + setValue(SETTING_TOR_SERVICES, serviceList); +} + +/** Get serialised ServiceList */ +ServiceList +ServiceSettings::getServices() +{ + QString address,virtualPort,physAddrPort,serviceDir,enabledS,additionalData; + bool enabled = false; + QStringList stringList; + ServiceList services; + + stringList = value(SETTING_TOR_SERVICES).toStringList(); + foreach (QString s, stringList) { + QStringList skippedList = s.split("#"); + address = skippedList.first(); + skippedList.removeFirst(); + virtualPort = skippedList.first(); + skippedList.removeFirst(); + physAddrPort = skippedList.first(); + skippedList.removeFirst(); + serviceDir = skippedList.first(); + skippedList.removeFirst(); + enabledS = skippedList.first(); + skippedList.removeFirst(); + additionalData = skippedList.first(); + if(enabledS.compare("x1") == 0) { + enabled = true; + } + Service service(address, virtualPort, physAddrPort, serviceDir, enabled); + service.setAdditionalServiceOptions(additionalData); + services.addService(service); + } + return services; +} + +/** Returns the virtual port for a specific service*/ +QString +ServiceSettings::getVirtualPort() +{ + QString port = value(SETTING_SERVICE_VIRTUAL_PORT).toString(); + return port; +} + +/** Set the virtual port for a specific service*/ +void +ServiceSettings::setVirtualPort(QString servicePort) +{ + setValue(SETTING_SERVICE_VIRTUAL_PORT, servicePort); +} + +/** Returns the .onion - service address for a specific service */ +QString +ServiceSettings::getServiceAddress() +{ + QString addr = value(SETTING_SERVICE_ADDRESS).toString(); + return addr; +} + +/** Set the .onion - service address or hostname for a specific service */ +void +ServiceSettings::setServiceAddress(QString addr) +{ + setValue(SETTING_SERVICE_ADDRESS, addr); +} + +/** Returns the physical address for a specific service */ +QString +ServiceSettings::getPhysicalAddressPort() +{ + QString addr = value(SETTING_SERVICE_PHYSICAL_ADDRESS).toString(); + return addr; +} + +/** Set the physical address or hostname for a specific service */ +void +ServiceSettings::setPhysicalAddressPort(QString addr) +{ + setValue(SETTING_SERVICE_PHYSICAL_ADDRESS, addr); +} + +/** Returns if the Service is enabled */ +bool +ServiceSettings::isEnabled() +{ + return value(SETTING_SERVICE_ENABLED).toBool(); +} + +/** Set the service enabled */ +void +ServiceSettings::setEnabled(bool boolean) +{ + setValue(SETTING_SERVICE_ENABLED, boolean); +} + +/** Get all service directories from Tor */ +QString +ServiceSettings::getHiddenServiceDirectories() +{ + /*XXX: Domenik: Why does this always try to getconf hiddenserviceoptions + * even if the socket is not connected? */ + QString value = _torControl->getHiddenServiceConf("hiddenserviceoptions"); + return value; +} + +/** Set all services the user wants to start and send it to the + * Tor Controller*/ +void +ServiceSettings::applyServices(QString value, QString *errmsg) +{ + _torControl->setConf(value, errmsg); + _torControl->saveConf(errmsg); +} + +/** Unpublish all HiddenServices */ +void +ServiceSettings::unpublishAllServices(QString *errmsg) +{ + _torControl->resetConf("HiddenServiceDir", errmsg); + _torControl->saveConf(errmsg); +} + diff -Nru vidalia-0.1.13/src/vidalia/config/servicesettings.h vidalia-0.2.8/src/vidalia/config/servicesettings.h --- vidalia-0.1.13/src/vidalia/config/servicesettings.h 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/servicesettings.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,60 +0,0 @@ -/* -** 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.vidalia-project.net/. No part of Vidalia, including this file, -** may be copied, modified, propagated, or distributed except according to the -** terms described in the LICENSE file. -*/ - -#ifndef _SERVICESETTINGS_H -#define _SERVICESETTINGS_H - -#include -#include -#include "vidaliasettings.h" -#include "exitpolicy.h" - -/* XXX: Domenik: Shouldn't this inherit AbstractTorSettings like the rest of - * the settings classes? */ -class ServiceSettings : private VidaliaSettings -{ -public: - /** Constructor */ - ServiceSettings(TorControl *torControl); - /** Returns the service port for a specific service*/ - QString getVirtualPort(); - /** Set the service port for a specific service*/ - void setVirtualPort(QString servicePort); - /** Returns the .onion - service address for a specific service */ - QString getServiceAddress(); - /** Set the .onion - service address for a specific service */ - void setServiceAddress(QString serviceAddress); - /** Returns the service address or hostname for a specific service */ - QString getPhysicalAddressPort(); - /** Set the service address or hostname for a specific service */ - void setPhysicalAddressPort(QString physicalAddress); - /** Returns if the Service is enabled */ - bool isEnabled(); - /** Set the service enabled */ - void setEnabled(bool enabled); - /** Returns a ServiceList containing all services */ - ServiceList getServices(); - /** Set ServiceList to serialise it */ - void setServices(ServiceList services); - /** Get Service Directories */ - QString getHiddenServiceDirectories(); - /** Set all services the user wants to start and send it to the - * Tor Controller */ - void applyServices(QString value, QString *errmsg); - /** Unpublish all services */ - void unpublishAllServices(QString *errmsg); - -private: - /** A TorControl object used to talk to Tor. */ - TorControl* _torControl; -}; - -#endif - diff -Nru vidalia-0.1.13/src/vidalia/config/ServiceSettings.h vidalia-0.2.8/src/vidalia/config/ServiceSettings.h --- vidalia-0.1.13/src/vidalia/config/ServiceSettings.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/ServiceSettings.h 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,61 @@ +/* +** 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.vidalia-project.net/. No part of Vidalia, including this file, +** may be copied, modified, propagated, or distributed except according to the +** terms described in the LICENSE file. +*/ + +#ifndef _SERVICESETTINGS_H +#define _SERVICESETTINGS_H + +#include +#include +#include +#include + + +/* XXX: Domenik: Shouldn't this inherit AbstractTorSettings like the rest of + * the settings classes? */ +class ServiceSettings : private VidaliaSettings +{ +public: + /** Constructor */ + ServiceSettings(TorControl *torControl); + /** Returns the service port for a specific service*/ + QString getVirtualPort(); + /** Set the service port for a specific service*/ + void setVirtualPort(QString servicePort); + /** Returns the .onion - service address for a specific service */ + QString getServiceAddress(); + /** Set the .onion - service address for a specific service */ + void setServiceAddress(QString serviceAddress); + /** Returns the service address or hostname for a specific service */ + QString getPhysicalAddressPort(); + /** Set the service address or hostname for a specific service */ + void setPhysicalAddressPort(QString physicalAddress); + /** Returns if the Service is enabled */ + bool isEnabled(); + /** Set the service enabled */ + void setEnabled(bool enabled); + /** Returns a ServiceList containing all services */ + ServiceList getServices(); + /** Set ServiceList to serialise it */ + void setServices(ServiceList services); + /** Get Service Directories */ + QString getHiddenServiceDirectories(); + /** Set all services the user wants to start and send it to the + * Tor Controller */ + void applyServices(QString value, QString *errmsg); + /** Unpublish all services */ + void unpublishAllServices(QString *errmsg); + +private: + /** A TorControl object used to talk to Tor. */ + TorControl* _torControl; +}; + +#endif + diff -Nru vidalia-0.1.13/src/vidalia/config/torsettings.cpp vidalia-0.2.8/src/vidalia/config/torsettings.cpp --- vidalia-0.1.13/src/vidalia/config/torsettings.cpp 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/torsettings.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,339 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 torsettings.cpp -** \version $Id: torsettings.cpp 3755 2009-05-02 02:57:49Z edmanm $ -** \brief Settings used for starting and running Tor -*/ - -#include -#include -#include -#include - -#if defined(Q_OS_WIN32) -#include -#include -#endif - -#include "torsettings.h" - -/* Tor Settings */ -#define SETTING_TOR_EXECUTABLE "TorExecutable" -#define SETTING_TORRC "Torrc" -#define SETTING_CONTROL_ADDR "ControlAddr" -#define SETTING_CONTROL_PORT "ControlPort" -#define SETTING_AUTH_TOKEN "AuthToken" -#define SETTING_TOR_USER "User" -#define SETTING_TOR_GROUP "Group" -#define SETTING_DATA_DIRECTORY "DataDirectory" -#define SETTING_AUTH_METHOD "AuthenticationMethod" -#define SETTING_CONTROL_PASSWORD "ControlPassword" -#define SETTING_USE_RANDOM_PASSWORD "UseRandomPassword" - -/** Default to using hashed password authentication */ -#define DEFAULT_AUTH_METHOD PasswordAuth - -/* Arguments we can pass to Tor on the command-line */ -#define TOR_ARG_CONTROL_PORT "ControlPort" -#define TOR_ARG_TORRC "-f" -#define TOR_ARG_DATA_DIRECTORY "DataDirectory" -#define TOR_ARG_HASHED_PASSWORD "HashedControlPassword" -#define TOR_ARG_COOKIE_AUTH "CookieAuthentication" - -/** Generate random control passwords of 16 characters */ -#define PASSWORD_LEN 16 - - -/** Default constructor */ -TorSettings::TorSettings(TorControl *torControl) -: AbstractTorSettings("Tor", torControl) -{ -#if defined(Q_OS_WIN32) - QString programFiles = win32_program_files_folder(); - if (QFileInfo(programFiles + "\\Vidalia Bundle\\Tor\\tor.exe").exists()) - setDefault(SETTING_TOR_EXECUTABLE, - programFiles + "\\Vidalia Bundle\\Tor\\tor.exe"); - else - setDefault(SETTING_TOR_EXECUTABLE, programFiles + "\\Tor\\tor.exe"); -#else - setDefault(SETTING_TOR_EXECUTABLE, "tor"); -#endif - - setDefault(SETTING_TORRC, Vidalia::dataDirectory() + "/torrc"); - setDefault(SETTING_CONTROL_ADDR, "127.0.0.1"); - setDefault(SETTING_CONTROL_PORT, 9051); - setDefault(SETTING_AUTH_METHOD, toString(DEFAULT_AUTH_METHOD)); - setDefault(SETTING_DATA_DIRECTORY, ""); - setDefault(SETTING_CONTROL_PASSWORD, ""); - setDefault(SETTING_USE_RANDOM_PASSWORD, true); -} - -/** Applies any changes to Tor's control port or authentication settings. */ -bool -TorSettings::apply(QString *errmsg) -{ - QHash conf; - QString hashedPassword; - - conf.insert(SETTING_CONTROL_PORT, - localValue(SETTING_CONTROL_PORT).toString()); - - AuthenticationMethod authMethod = - toAuthenticationMethod(localValue(SETTING_AUTH_METHOD).toString()); - switch (authMethod) { - case CookieAuth: - conf.insert(TOR_ARG_COOKIE_AUTH, "1"); - conf.insert(TOR_ARG_HASHED_PASSWORD, ""); - break; - case PasswordAuth: - hashedPassword = useRandomPassword() - ? hashPassword(randomPassword()) - : hashPassword(getControlPassword()); - if (hashedPassword.isEmpty()) { - if (errmsg) - *errmsg = tr("Failed to hash the control password."); - return false; - } - conf.insert(TOR_ARG_COOKIE_AUTH, "0"); - conf.insert(TOR_ARG_HASHED_PASSWORD, hashedPassword); - break; - default: - conf.insert(TOR_ARG_COOKIE_AUTH, "0"); - conf.insert(TOR_ARG_HASHED_PASSWORD, ""); - } - return torControl()->setConf(conf, errmsg); -} - -/** Gets the location of Tor's data directory. */ -QString -TorSettings::getDataDirectory() const -{ - return QDir::convertSeparators(value(SETTING_DATA_DIRECTORY).toString()); -} - -/** Sets the location to use as Tor's data directory. */ -void -TorSettings::setDataDirectory(const QString &dataDirectory) -{ - setValue(SETTING_DATA_DIRECTORY, dataDirectory); -} - -/** Returns a fully-qualified path to Tor's executable, including the - * executable name. */ -QString -TorSettings::getExecutable() const -{ - QString tor = localValue(SETTING_TOR_EXECUTABLE).toString(); - if (tor.isEmpty()) /* Don't let the Tor executable name be empty */ - tor = defaultValue(SETTING_TOR_EXECUTABLE).toString(); - return QDir::convertSeparators(tor); -} - -/** Sets the location and name of Tor's executable to the given string. */ -void -TorSettings::setExecutable(const QString &torExecutable) -{ - setValue(SETTING_TOR_EXECUTABLE, torExecutable); -} - -/** Returns the torrc that will be used when starting Tor. */ -QString -TorSettings::getTorrc() const -{ - QString torrc; - TorControl *tc = torControl(); - if (tc && tc->isConnected() && tc->getInfo("config-file", torrc)) - return QDir::convertSeparators(torrc); - return QDir::convertSeparators(localValue(SETTING_TORRC).toString()); -} - -/** Sets the torrc that will be used when starting Tor. - * \param torrc The torrc to use. - */ -void -TorSettings::setTorrc(const QString &torrc) -{ - setValue(SETTING_TORRC, torrc); -} - -/** Get the address or hostname used to connect to Tor */ -QHostAddress -TorSettings::getControlAddress() const -{ - QString addr = localValue(SETTING_CONTROL_ADDR).toString(); - return QHostAddress(addr); -} - -/** Set the address or hostname used to connect to Tor */ -void -TorSettings::setControlAddress(const QHostAddress &addr) -{ - setValue(SETTING_CONTROL_ADDR, addr.toString()); -} - -/** Get the control port used to connect to Tor */ -quint16 -TorSettings::getControlPort() const -{ - return (quint16)value(SETTING_CONTROL_PORT).toInt(); -} - -/** Set the control port used to connect to Tor */ -void -TorSettings::setControlPort(quint16 port) -{ - setValue(SETTING_CONTROL_PORT, port); -} - -/** Returns the plaintext (i.e., not hashed) control password used when - * authenticating to Tor. */ -QString -TorSettings::getControlPassword() const -{ - return localValue(SETTING_CONTROL_PASSWORD).toString(); -} - -/** Sets the control password used when starting Tor with - * HashedControlPassword to password. */ -void -TorSettings::setControlPassword(const QString &password) -{ - setValue(SETTING_CONTROL_PASSWORD, password); -} - -/** Returns true if a new, random control password is to be used each time Tor - * is started. */ -bool -TorSettings::useRandomPassword() const -{ - return localValue(SETTING_USE_RANDOM_PASSWORD).toBool(); -} - -/** Sets whether or not to generate and use a random control password each - * time Tor is started. */ -void -TorSettings::setUseRandomPassword(bool useRandomPassword) -{ - setValue(SETTING_USE_RANDOM_PASSWORD, useRandomPassword); -} - -/** Returns the current authentication method used when connecting to Tor. */ -TorSettings::AuthenticationMethod -TorSettings::getAuthenticationMethod() const -{ - AuthenticationMethod type = UnknownAuth; - TorControl *tc = torControl(); - - if (tc && tc->isConnected()) { - QHash conf; - conf.insert(TOR_ARG_COOKIE_AUTH, ""); - conf.insert(TOR_ARG_HASHED_PASSWORD, ""); - if (tc->getConf(conf)) { - if (conf.value(TOR_ARG_COOKIE_AUTH) == "1") - type = CookieAuth; - else if (!conf.value(TOR_ARG_HASHED_PASSWORD).isEmpty()) - type = PasswordAuth; - } - } - if (type == UnknownAuth) - type = toAuthenticationMethod(localValue(SETTING_AUTH_METHOD).toString()); - return (type == UnknownAuth ? DEFAULT_AUTH_METHOD : type); -} - -/** Sets the authentication method used when starting Tor to method. */ -void -TorSettings::setAuthenticationMethod(AuthenticationMethod method) -{ - setValue(SETTING_AUTH_METHOD, toString(method)); -} - -/** Returns the string description of the authentication method specified by - * method. The authentication method string is stored in Vidalia's - * configuration file. */ -QString -TorSettings::toString(AuthenticationMethod method) const -{ - switch (method) { - case NullAuth: return "none"; - case PasswordAuth: return "password"; - case CookieAuth: return "cookie"; - default: break; - } - return "unknown"; -} - -/** Returns the AuthenticationMethod enum value for the string - * description of the authentication method given in authMethod. */ -TorSettings::AuthenticationMethod -TorSettings::toAuthenticationMethod(const QString &authMethod) const -{ - QString str = authMethod.toLower(); - if (str == toString(NullAuth)) - return NullAuth; - else if (str == toString(PasswordAuth)) - return PasswordAuth; - else if (str == toString(CookieAuth)) - return CookieAuth; - return UnknownAuth; -} - -/** Generates a random control password consisting of PASSWORD_LEN characters. */ -QString -TorSettings::randomPassword() -{ - return crypto_rand_string(PASSWORD_LEN); -} - -/** Returns the hash of password as given by the command "tor - * --hash-password foo". */ -QString -TorSettings::hashPassword(const QString &password) -{ - TorSettings settings; - QProcess tor; - QString dataDirectory, line; - QStringList args; - - QStringList env = QProcess::systemEnvironment(); -#if !defined(Q_OS_WIN32) - /* Add "/usr/sbin" to an existing $PATH, so this works on Debian too. */ - for (int i = 0; i < env.size(); i++) { - QString envVar = env.at(i); - if (envVar.startsWith("PATH=")) - env.replace(i, envVar += ":/usr/sbin"); - } -#endif - tor.setEnvironment(env); - - /* Tor writes its state file even if all we're doing is --hash-password. So - * if the user has configured a non-default data directory, then include - * that in the list of command line arguments. */ - dataDirectory = settings.getDataDirectory(); - if (!dataDirectory.isEmpty()) - args << "DataDirectory" << dataDirectory; - args << "--hash-password" << password; - - /* Run Tor, tell it to hash the given password, and then wait for it to - * finish. */ - tor.start(settings.getExecutable(), args); - if (!tor.waitForStarted() || !tor.waitForFinished()) - return QString(); - - /* The hashed password will (hopefully) be the line that starts with "16:" */ - while (tor.canReadLine()) { - line = tor.readLine(); - if (line.startsWith("16:")) - return line.trimmed(); - } - return QString(); -} - diff -Nru vidalia-0.1.13/src/vidalia/config/TorSettings.cpp vidalia-0.2.8/src/vidalia/config/TorSettings.cpp --- vidalia-0.1.13/src/vidalia/config/TorSettings.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/TorSettings.cpp 2009-06-27 02:57:05.000000000 +0100 @@ -0,0 +1,390 @@ +/* +** 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.vidalia-project.net/. 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 TorSettings.cpp +** \version $Id: TorSettings.cpp 3901 2009-06-27 01:57:05Z edmanm $ +** \brief Settings used for starting and running Tor +*/ + +#include "TorSettings.h" +#include "Vidalia.h" +#include "crypto.h" +#include "file.h" +#include "stringutil.h" +#if defined(Q_OS_WIN32) +#include "win32.h" +#include +#endif + +#include +#include + +/* Tor Settings */ +#define SETTING_TOR_EXECUTABLE "TorExecutable" +#define SETTING_TORRC "Torrc" +#define SETTING_CONTROL_ADDR "ControlAddr" +#define SETTING_CONTROL_PORT "ControlPort" +#define SETTING_AUTH_TOKEN "AuthToken" +#define SETTING_TOR_USER "User" +#define SETTING_TOR_GROUP "Group" +#define SETTING_DATA_DIRECTORY "DataDirectory" +#define SETTING_AUTH_METHOD "AuthenticationMethod" +#define SETTING_CONTROL_PASSWORD "ControlPassword" +#define SETTING_USE_RANDOM_PASSWORD "UseRandomPassword" +#define SETTING_WARN_PLAINTEXT_PORTS "WarnPlaintextPorts" +#define SETTING_REJECT_PLAINTEXT_PORTS "RejectPlaintextPorts" + +/** Default to using hashed password authentication */ +#define DEFAULT_AUTH_METHOD PasswordAuth + +/* Arguments we can pass to Tor on the command-line */ +#define TOR_ARG_CONTROL_PORT "ControlPort" +#define TOR_ARG_TORRC "-f" +#define TOR_ARG_DATA_DIRECTORY "DataDirectory" +#define TOR_ARG_HASHED_PASSWORD "HashedControlPassword" +#define TOR_ARG_COOKIE_AUTH "CookieAuthentication" + +/** Generate random control passwords of 16 characters */ +#define PASSWORD_LEN 16 + + +/** Default constructor */ +TorSettings::TorSettings(TorControl *torControl) +: AbstractTorSettings("Tor", torControl) +{ +#if defined(Q_OS_WIN32) + QString programFiles = win32_program_files_folder(); + if (QFileInfo(programFiles + "\\Vidalia Bundle\\Tor\\tor.exe").exists()) + setDefault(SETTING_TOR_EXECUTABLE, + programFiles + "\\Vidalia Bundle\\Tor\\tor.exe"); + else + setDefault(SETTING_TOR_EXECUTABLE, programFiles + "\\Tor\\tor.exe"); +#else + setDefault(SETTING_TOR_EXECUTABLE, "tor"); +#endif + + setDefault(SETTING_TORRC, Vidalia::dataDirectory() + "/torrc"); + setDefault(SETTING_CONTROL_ADDR, "127.0.0.1"); + setDefault(SETTING_CONTROL_PORT, 9051); + setDefault(SETTING_AUTH_METHOD, toString(DEFAULT_AUTH_METHOD)); + setDefault(SETTING_DATA_DIRECTORY, ""); + setDefault(SETTING_CONTROL_PASSWORD, ""); + setDefault(SETTING_USE_RANDOM_PASSWORD, true); + setDefault(SETTING_WARN_PLAINTEXT_PORTS, QList() << 23 << 109 + << 110 << 143); + setDefault(SETTING_REJECT_PLAINTEXT_PORTS, QList()); +} + +/** Applies any changes to Tor's control port or authentication settings. */ +bool +TorSettings::apply(QString *errmsg) +{ + QHash conf; + QString hashedPassword; + + conf.insert(SETTING_CONTROL_PORT, + localValue(SETTING_CONTROL_PORT).toString()); + + AuthenticationMethod authMethod = + toAuthenticationMethod(localValue(SETTING_AUTH_METHOD).toString()); + switch (authMethod) { + case CookieAuth: + conf.insert(TOR_ARG_COOKIE_AUTH, "1"); + conf.insert(TOR_ARG_HASHED_PASSWORD, ""); + break; + case PasswordAuth: + hashedPassword = useRandomPassword() + ? hashPassword(randomPassword()) + : hashPassword(getControlPassword()); + if (hashedPassword.isEmpty()) { + if (errmsg) + *errmsg = tr("Failed to hash the control password."); + return false; + } + conf.insert(TOR_ARG_COOKIE_AUTH, "0"); + conf.insert(TOR_ARG_HASHED_PASSWORD, hashedPassword); + break; + default: + conf.insert(TOR_ARG_COOKIE_AUTH, "0"); + conf.insert(TOR_ARG_HASHED_PASSWORD, ""); + } + + conf.insert(SETTING_WARN_PLAINTEXT_PORTS, + localValue(SETTING_WARN_PLAINTEXT_PORTS).toStringList().join(",")); + conf.insert(SETTING_REJECT_PLAINTEXT_PORTS, + localValue(SETTING_REJECT_PLAINTEXT_PORTS).toStringList().join(",")); + + return torControl()->setConf(conf, errmsg); +} + +/** Gets the location of Tor's data directory. */ +QString +TorSettings::getDataDirectory() const +{ + return QDir::convertSeparators(value(SETTING_DATA_DIRECTORY).toString()); +} + +/** Sets the location to use as Tor's data directory. */ +void +TorSettings::setDataDirectory(const QString &dataDirectory) +{ + setValue(SETTING_DATA_DIRECTORY, dataDirectory); +} + +/** Returns a fully-qualified path to Tor's executable, including the + * executable name. */ +QString +TorSettings::getExecutable() const +{ + QString tor = localValue(SETTING_TOR_EXECUTABLE).toString(); + if (tor.isEmpty()) /* Don't let the Tor executable name be empty */ + tor = defaultValue(SETTING_TOR_EXECUTABLE).toString(); + return QDir::convertSeparators(tor); +} + +/** Sets the location and name of Tor's executable to the given string. */ +void +TorSettings::setExecutable(const QString &torExecutable) +{ + setValue(SETTING_TOR_EXECUTABLE, torExecutable); +} + +/** Returns the torrc that will be used when starting Tor. */ +QString +TorSettings::getTorrc() const +{ + QString torrc; + TorControl *tc = torControl(); + if (tc && tc->isConnected() && tc->getInfo("config-file", torrc)) + return QDir::convertSeparators(torrc); + return QDir::convertSeparators(localValue(SETTING_TORRC).toString()); +} + +/** Sets the torrc that will be used when starting Tor. + * \param torrc The torrc to use. + */ +void +TorSettings::setTorrc(const QString &torrc) +{ + setValue(SETTING_TORRC, torrc); +} + +/** Get the address or hostname used to connect to Tor */ +QHostAddress +TorSettings::getControlAddress() const +{ + QString addr = localValue(SETTING_CONTROL_ADDR).toString(); + return QHostAddress(addr); +} + +/** Set the address or hostname used to connect to Tor */ +void +TorSettings::setControlAddress(const QHostAddress &addr) +{ + setValue(SETTING_CONTROL_ADDR, addr.toString()); +} + +/** Get the control port used to connect to Tor */ +quint16 +TorSettings::getControlPort() const +{ + return (quint16)value(SETTING_CONTROL_PORT).toInt(); +} + +/** Set the control port used to connect to Tor */ +void +TorSettings::setControlPort(quint16 port) +{ + setValue(SETTING_CONTROL_PORT, port); +} + +/** Returns the plaintext (i.e., not hashed) control password used when + * authenticating to Tor. */ +QString +TorSettings::getControlPassword() const +{ + return localValue(SETTING_CONTROL_PASSWORD).toString(); +} + +/** Sets the control password used when starting Tor with + * HashedControlPassword to password. */ +void +TorSettings::setControlPassword(const QString &password) +{ + setValue(SETTING_CONTROL_PASSWORD, password); +} + +/** Returns true if a new, random control password is to be used each time Tor + * is started. */ +bool +TorSettings::useRandomPassword() const +{ + return localValue(SETTING_USE_RANDOM_PASSWORD).toBool(); +} + +/** Sets whether or not to generate and use a random control password each + * time Tor is started. */ +void +TorSettings::setUseRandomPassword(bool useRandomPassword) +{ + setValue(SETTING_USE_RANDOM_PASSWORD, useRandomPassword); +} + +/** Returns the current authentication method used when connecting to Tor. */ +TorSettings::AuthenticationMethod +TorSettings::getAuthenticationMethod() const +{ + AuthenticationMethod type = UnknownAuth; + TorControl *tc = torControl(); + + if (tc && tc->isConnected()) { + QHash conf; + conf.insert(TOR_ARG_COOKIE_AUTH, ""); + conf.insert(TOR_ARG_HASHED_PASSWORD, ""); + if (tc->getConf(conf)) { + if (conf.value(TOR_ARG_COOKIE_AUTH) == "1") + type = CookieAuth; + else if (!conf.value(TOR_ARG_HASHED_PASSWORD).isEmpty()) + type = PasswordAuth; + } + } + if (type == UnknownAuth) + type = toAuthenticationMethod(localValue(SETTING_AUTH_METHOD).toString()); + return (type == UnknownAuth ? DEFAULT_AUTH_METHOD : type); +} + +/** Sets the authentication method used when starting Tor to method. */ +void +TorSettings::setAuthenticationMethod(AuthenticationMethod method) +{ + setValue(SETTING_AUTH_METHOD, toString(method)); +} + +/** Returns the current list of ports that will cause Tor to issue a warning + * when the user tries to connect to one of them. */ +QList +TorSettings::getWarnPlaintextPorts() const +{ + QList out; + QList ports; + + ports = value(SETTING_WARN_PLAINTEXT_PORTS).toList(); + foreach (QVariant port, ports) { + out << port.toUInt(); + } + return out; +} + +/** Sets the list of ports that will cause Tor to issue a warning when the + * user tries to connect to one of them. */ +void +TorSettings::setWarnPlaintextPorts(const QList &ports) +{ + QList warnList; + foreach (quint16 port, ports) { + warnList << QVariant(port); + } + setValue(SETTING_WARN_PLAINTEXT_PORTS, warnList); +} + +/** Returns the current list of ports that will cause Tor to reject the + * connection when the user tries to connect to one of them. */ +QList +TorSettings::getRejectPlaintextPorts() const +{ + QList out; + QList ports; + + ports = value(SETTING_REJECT_PLAINTEXT_PORTS).toList(); + foreach (QVariant port, ports) { + out << port.toUInt(); + } + return out; +} + +/** Sets the list of ports that will cause Tor to reject the connection + * when the user tries to connect to one of them. */ +void +TorSettings::setRejectPlaintextPorts(const QList &ports) +{ + QList rejectList; + foreach (quint16 port, ports) { + rejectList << QVariant(port); + } + setValue(SETTING_REJECT_PLAINTEXT_PORTS, rejectList); +} + +/** Returns the string description of the authentication method specified by + * method. The authentication method string is stored in Vidalia's + * configuration file. */ +QString +TorSettings::toString(AuthenticationMethod method) const +{ + switch (method) { + case NullAuth: return "none"; + case PasswordAuth: return "password"; + case CookieAuth: return "cookie"; + default: break; + } + return "unknown"; +} + +/** Returns the AuthenticationMethod enum value for the string + * description of the authentication method given in authMethod. */ +TorSettings::AuthenticationMethod +TorSettings::toAuthenticationMethod(const QString &authMethod) const +{ + QString str = authMethod.toLower(); + if (str == toString(NullAuth)) + return NullAuth; + else if (str == toString(PasswordAuth)) + return PasswordAuth; + else if (str == toString(CookieAuth)) + return CookieAuth; + return UnknownAuth; +} + +/** Generates a random control password consisting of PASSWORD_LEN characters. */ +QString +TorSettings::randomPassword() +{ + return crypto_rand_string(PASSWORD_LEN); +} + +/** Returns the hash of password as given by the command "tor + * --hash-password foo". */ +QString +TorSettings::hashPassword(const QString &password) +{ + QByteArray salt; + + /* Generate an 8 octet salt value. Bail if we fail to generate enough + * random bytes (unlikely). */ + while (salt.size() < 8) { + QByteArray bytes = crypto_rand_bytes(8-salt.size()); + if (bytes.isNull()) + return QString(); + salt.append(bytes); + } + + /* Generate the salted hash of the specified password. 96 is the one-octet + * RFC 2440 coded count value hardcoded into Tor. Specifies that we should + * hash 64K worth of data. */ + QByteArray key = crypto_secret_to_key(password, salt, 96); + if (key.isNull()) + return QString(); + salt.append(96); /* Append the coded count value to the salt */ + + /* Convert the result to hexadecimal and put it in the format Tor wants. */ + return QString("16:%1%2").arg(base16_encode(salt)) + .arg(base16_encode(key)); +} + diff -Nru vidalia-0.1.13/src/vidalia/config/torsettings.h vidalia-0.2.8/src/vidalia/config/torsettings.h --- vidalia-0.1.13/src/vidalia/config/torsettings.h 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/torsettings.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,107 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 torsettings.h -** \version $Id: torsettings.h 3291 2008-11-10 01:18:11Z edmanm $ -** \brief Settings used for starting and running Tor -*/ - -#ifndef _TORSETTINGS_H -#define _TORSETTINGS_H - -#include - -#include "abstracttorsettings.h" - - -/** Manages Tor-specific settings, such as location, command-line arguments, - * and control interface information. */ -class TorSettings : public AbstractTorSettings -{ - Q_OBJECT - -public: - /** Available Tor authentication methods. */ - enum AuthenticationMethod { - NullAuth, /**< No authentication. */ - CookieAuth, /**< Use a "magic" cookie for authentication. */ - PasswordAuth, /**< Use a hashed password for authentication. */ - UnknownAuth /**< Unknown authentication method. */ - }; - - /** Default constructor. */ - TorSettings(TorControl *torControl = 0); - /** Applies any changes to Tor's control port or authentication settings. */ - bool apply(QString *errmsg = 0); - - /** Gets the name and path of Tor's executable. */ - QString getExecutable() const; - /** Sets the name and path of Tor's executable. */ - void setExecutable(const QString &torExecutable); - - /** Gets the location of Tor's data directory. */ - QString getDataDirectory() const; - /** Sets the location to use for Tor's data directory. */ - void setDataDirectory(const QString &dataDir); - - /** Gets the torrc to use when starting Tor. */ - QString getTorrc() const; - /** Sets the torrc to use when starting Tor. */ - void setTorrc(const QString &torrc); - - /** Get Tor's control interface address. */ - QHostAddress getControlAddress() const; - /** Set Tor's control interface address. */ - void setControlAddress(const QHostAddress &addr); - - /** Get the control port. */ - quint16 getControlPort() const; - /** Set the control port. */ - void setControlPort(quint16 port); - - /** Returns the plaintext (i.e., not hashed) control password used when - * authenticating to Tor. */ - QString getControlPassword() const; - /** Sets the control password used when starting Tor with - * HashedControlPassword to password. */ - void setControlPassword(const QString &password); - - /** Returns true if a new, random control password is to be used each time - * Tor is started. */ - bool useRandomPassword() const; - /** Sets whether or not to generate and use a random control password each - * time Tor is started. */ - void setUseRandomPassword(bool useRandomPassword); - - /** Returns the current authentication method used when connecting to Tor.*/ - AuthenticationMethod getAuthenticationMethod() const; - /** Sets the authentication method used when starting Tor to method.*/ - void setAuthenticationMethod(AuthenticationMethod method); - - /** Generates a random control password consisting of PASSWORD_LEN - * characters. */ - static QString randomPassword(); - /** Returns the hash of password as given by the command - * "tor --hash-password foo". */ - static QString hashPassword(const QString &password); - -private: - /** Returns the AuthenticationMethod enum value for the string - * description of the authentication method given in authMethod. */ - AuthenticationMethod toAuthenticationMethod(const QString &authMethod) const; - /** Returns the string description of the authentication method specified by - * method. The authentication method string is stored in Vidalia's - * configuration file. */ - QString toString(AuthenticationMethod type) const; -}; - -#endif - diff -Nru vidalia-0.1.13/src/vidalia/config/TorSettings.h vidalia-0.2.8/src/vidalia/config/TorSettings.h --- vidalia-0.1.13/src/vidalia/config/TorSettings.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/TorSettings.h 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,121 @@ +/* +** 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.vidalia-project.net/. 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 TorSettings.h +** \version $Id: TorSettings.h 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Settings used for starting and running Tor +*/ + +#ifndef _TORSETTINGS_H +#define _TORSETTINGS_H + +#include "AbstractTorSettings.h" + +#include + + +/** Manages Tor-specific settings, such as location, command-line arguments, + * and control interface information. */ +class TorSettings : public AbstractTorSettings +{ + Q_OBJECT + +public: + /** Available Tor authentication methods. */ + enum AuthenticationMethod { + NullAuth, /**< No authentication. */ + CookieAuth, /**< Use a "magic" cookie for authentication. */ + PasswordAuth, /**< Use a hashed password for authentication. */ + UnknownAuth /**< Unknown authentication method. */ + }; + + /** Default constructor. */ + TorSettings(TorControl *torControl = 0); + /** Applies any changes to Tor's control port or authentication settings. */ + bool apply(QString *errmsg = 0); + + /** Gets the name and path of Tor's executable. */ + QString getExecutable() const; + /** Sets the name and path of Tor's executable. */ + void setExecutable(const QString &torExecutable); + + /** Gets the location of Tor's data directory. */ + QString getDataDirectory() const; + /** Sets the location to use for Tor's data directory. */ + void setDataDirectory(const QString &dataDir); + + /** Gets the torrc to use when starting Tor. */ + QString getTorrc() const; + /** Sets the torrc to use when starting Tor. */ + void setTorrc(const QString &torrc); + + /** Get Tor's control interface address. */ + QHostAddress getControlAddress() const; + /** Set Tor's control interface address. */ + void setControlAddress(const QHostAddress &addr); + + /** Get the control port. */ + quint16 getControlPort() const; + /** Set the control port. */ + void setControlPort(quint16 port); + + /** Returns the plaintext (i.e., not hashed) control password used when + * authenticating to Tor. */ + QString getControlPassword() const; + /** Sets the control password used when starting Tor with + * HashedControlPassword to password. */ + void setControlPassword(const QString &password); + + /** Returns true if a new, random control password is to be used each time + * Tor is started. */ + bool useRandomPassword() const; + /** Sets whether or not to generate and use a random control password each + * time Tor is started. */ + void setUseRandomPassword(bool useRandomPassword); + + /** Returns the current authentication method used when connecting to Tor.*/ + AuthenticationMethod getAuthenticationMethod() const; + /** Sets the authentication method used when starting Tor to method.*/ + void setAuthenticationMethod(AuthenticationMethod method); + + /** Returns the current list of ports that will cause Tor to issue a warning + * when the user tries to connect to one of them. */ + QList getWarnPlaintextPorts() const; + /** Sets the list of ports that will cause Tor to issue a warning when the + * user tries to connect to one of them. */ + void setWarnPlaintextPorts(const QList &ports); + + /** Returns the current list of ports that will cause Tor to reject the + * connection when the user tries to connect to one of them. */ + QList getRejectPlaintextPorts() const; + /** Sets the list of ports that will cause Tor to reject the connection + * when the user tries to connect to one of them. */ + void setRejectPlaintextPorts(const QList &ports); + + /** Generates a random control password consisting of PASSWORD_LEN + * characters. */ + static QString randomPassword(); + /** Returns the hash of password as given by the command + * "tor --hash-password foo". */ + static QString hashPassword(const QString &password); + +private: + /** Returns the AuthenticationMethod enum value for the string + * description of the authentication method given in authMethod. */ + AuthenticationMethod toAuthenticationMethod(const QString &authMethod) const; + /** Returns the string description of the authentication method specified by + * method. The authentication method string is stored in Vidalia's + * configuration file. */ + QString toString(AuthenticationMethod type) const; +}; + +#endif + diff -Nru vidalia-0.1.13/src/vidalia/config/upnpcontrol.cpp vidalia-0.2.8/src/vidalia/config/upnpcontrol.cpp --- vidalia-0.1.13/src/vidalia/config/upnpcontrol.cpp 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/upnpcontrol.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,164 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 upnpcontrol.cpp -** \version $Id: upnpcontrol.cpp 2638 2008-06-01 23:42:53Z edmanm $ -** \brief Singleton object for interacting with UPNP device -*/ - -#include "upnpcontrol.h" - -#include -#include - -#ifdef Q_OS_WIN32 -#include -#endif - -#include "upnpcontrolthread.h" - -/** UPNPControl singleton instance. */ -UPNPControl* UPNPControl::_instance = 0; - -/** Returns a pointer to this object's singleton instance. */ -UPNPControl* UPNPControl::instance() -{ - if (0 == _instance) - _instance = new UPNPControl; - return _instance; -} - -/** Constructor. Initializes and starts a thread in which all blocking UPnP - * operations will be performed. */ -UPNPControl::UPNPControl() -{ - _forwardedORPort = 0; - _forwardedDirPort = 0; - _error = UnknownError; - _state = IdleState; - - qRegisterMetaType("UPNPControl::UPNPError"); - qRegisterMetaType("UPNPControl::UPNPState"); - - _mutex = new QMutex(); - _controlThread = new UPNPControlThread(this); - _controlThread->start(); -} - -/** Destructor. cleanup() should be called before the object is destroyed. - * \sa cleanup() - */ -UPNPControl::~UPNPControl() -{ - delete _mutex; - delete _controlThread; -} - -/** Terminates the UPnP control thread and frees memory allocated to this - * object's singleton instance. */ -void -UPNPControl::cleanup() -{ - _instance->_controlThread->stop(); - delete _instance; - _instance = 0; -} - -/** Sets desiredDirPort and desiredOrPort to the currently - * forwarded DirPort and ORPort values. */ -void -UPNPControl::getDesiredState(quint16 *desiredDirPort, quint16 *desiredOrPort) -{ - _mutex->lock(); - *desiredDirPort = _forwardedDirPort; - *desiredOrPort = _forwardedORPort; - _mutex->unlock(); -} - -/** Sets the desired DirPort and ORPort port mappings to desiredDirPort - * and desiredOrPort, respectively. */ -void -UPNPControl::setDesiredState(quint16 desiredDirPort, quint16 desiredOrPort) -{ - _mutex->lock(); - _forwardedDirPort = desiredDirPort; - _forwardedORPort = desiredOrPort; - _mutex->unlock(); - - _controlThread->wakeup(); -} - -/** Sets the most recent UPnP-related error to error and emits the - * error() signal. */ -void -UPNPControl::setError(UPNPError upnpError) -{ - _mutex->lock(); - _error = upnpError; - _mutex->unlock(); - - emit error(upnpError); -} - -/** Sets the current UPnP state to state and emits the stateChanged() - * signal. */ -void -UPNPControl::setState(UPNPState state) -{ - _mutex->lock(); - _state = state; - _mutex->unlock(); - - emit stateChanged(state); -} - -/** Returns the type of error that occurred last. */ -UPNPControl::UPNPError -UPNPControl::error() const -{ - QMutexLocker locker(_mutex); - return _error; -} - -/** Returns a QString describing the type of error that occurred last. */ -QString -UPNPControl::errorString() const -{ - UPNPError error = this->error(); - - switch (error) { - case Success: - return tr("Success"); - case NoUPNPDevicesFound: - return tr("No UPnP-enabled devices found"); - case NoValidIGDsFound: - return tr("No valid UPnP-enabled Internet gateway devices found"); - case WSAStartupFailed: - return tr("WSAStartup failed"); - case AddPortMappingFailed: - return tr("Failed to add a port mapping"); - case GetPortMappingFailed: - return tr("Failed to retrieve a port mapping"); - case DeletePortMappingFailed: - return tr("Failed to remove a port mapping"); - default: - return tr("Unknown error"); - } -} - -/** Returns the number of milliseconds to wait for devices to respond - * when attempting to discover UPnP-enabled IGDs. */ -int -UPNPControl::discoverTimeout() const -{ - return UPNPControlThread::UPNPCONTROL_DISCOVER_TIMEOUT; -} - diff -Nru vidalia-0.1.13/src/vidalia/config/UPNPControl.cpp vidalia-0.2.8/src/vidalia/config/UPNPControl.cpp --- vidalia-0.1.13/src/vidalia/config/UPNPControl.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/UPNPControl.cpp 2009-05-31 01:12:09.000000000 +0100 @@ -0,0 +1,165 @@ +/* +** 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.vidalia-project.net/. 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 UPNPControl.cpp +** \version $Id: UPNPControl.cpp 3803 2009-05-31 00:12:09Z edmanm $ +** \brief Singleton object for interacting with UPNP device +*/ + +#include "UPNPControl.h" +#include "UPNPControlThread.h" + +#include +#include + +#ifdef Q_OS_WIN32 +#include +#endif + + +/** UPNPControl singleton instance. */ +UPNPControl* UPNPControl::_instance = 0; + +/** Returns a pointer to this object's singleton instance. */ +UPNPControl* UPNPControl::instance() +{ + if (0 == _instance) { + _instance = new UPNPControl(); + _instance->_controlThread->start(); + } + return _instance; +} + +/** Constructor. Initializes and starts a thread in which all blocking UPnP + * operations will be performed. */ +UPNPControl::UPNPControl() +{ + _forwardedORPort = 0; + _forwardedDirPort = 0; + _error = UnknownError; + _state = IdleState; + + qRegisterMetaType("UPNPControl::UPNPError"); + qRegisterMetaType("UPNPControl::UPNPState"); + + _mutex = new QMutex(); + _controlThread = new UPNPControlThread(this); +} + +/** Destructor. cleanup() should be called before the object is destroyed. + * \sa cleanup() + */ +UPNPControl::~UPNPControl() +{ + delete _mutex; + delete _controlThread; +} + +/** Terminates the UPnP control thread and frees memory allocated to this + * object's singleton instance. */ +void +UPNPControl::cleanup() +{ + _instance->_controlThread->stop(); + delete _instance; + _instance = 0; +} + +/** Sets desiredDirPort and desiredOrPort to the currently + * forwarded DirPort and ORPort values. */ +void +UPNPControl::getDesiredState(quint16 *desiredDirPort, quint16 *desiredOrPort) +{ + _mutex->lock(); + *desiredDirPort = _forwardedDirPort; + *desiredOrPort = _forwardedORPort; + _mutex->unlock(); +} + +/** Sets the desired DirPort and ORPort port mappings to desiredDirPort + * and desiredOrPort, respectively. */ +void +UPNPControl::setDesiredState(quint16 desiredDirPort, quint16 desiredOrPort) +{ + _mutex->lock(); + _forwardedDirPort = desiredDirPort; + _forwardedORPort = desiredOrPort; + _mutex->unlock(); + + _controlThread->wakeup(); +} + +/** Sets the most recent UPnP-related error to error and emits the + * error() signal. */ +void +UPNPControl::setError(UPNPError upnpError) +{ + _mutex->lock(); + _error = upnpError; + _mutex->unlock(); + + emit error(upnpError); +} + +/** Sets the current UPnP state to state and emits the stateChanged() + * signal. */ +void +UPNPControl::setState(UPNPState state) +{ + _mutex->lock(); + _state = state; + _mutex->unlock(); + + emit stateChanged(state); +} + +/** Returns the type of error that occurred last. */ +UPNPControl::UPNPError +UPNPControl::error() const +{ + QMutexLocker locker(_mutex); + return _error; +} + +/** Returns a QString describing the type of error that occurred last. */ +QString +UPNPControl::errorString() const +{ + UPNPError error = this->error(); + + switch (error) { + case Success: + return tr("Success"); + case NoUPNPDevicesFound: + return tr("No UPnP-enabled devices found"); + case NoValidIGDsFound: + return tr("No valid UPnP-enabled Internet gateway devices found"); + case WSAStartupFailed: + return tr("WSAStartup failed"); + case AddPortMappingFailed: + return tr("Failed to add a port mapping"); + case GetPortMappingFailed: + return tr("Failed to retrieve a port mapping"); + case DeletePortMappingFailed: + return tr("Failed to remove a port mapping"); + default: + return tr("Unknown error"); + } +} + +/** Returns the number of milliseconds to wait for devices to respond + * when attempting to discover UPnP-enabled IGDs. */ +int +UPNPControl::discoverTimeout() const +{ + return UPNPControlThread::UPNPCONTROL_DISCOVER_TIMEOUT; +} + diff -Nru vidalia-0.1.13/src/vidalia/config/upnpcontrol.h vidalia-0.2.8/src/vidalia/config/upnpcontrol.h --- vidalia-0.1.13/src/vidalia/config/upnpcontrol.h 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/upnpcontrol.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,114 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 upnpcontrol.h -** \version $Id: upnpcontrol.h 2638 2008-06-01 23:42:53Z edmanm $ -** \brief Singleton object for interacting with UPNP device -*/ - -#ifndef _UPNPCONTROL_H -#define _UPNPCONTROL_H - -#include -#include - -/* Forward declaration to make it build */ -class UPNPControlThread; - - -class UPNPControl : public QObject -{ - Q_OBJECT - -public: - /** UPnP-related error values. */ - enum UPNPError { - Success, - NoUPNPDevicesFound, - NoValidIGDsFound, - WSAStartupFailed, - AddPortMappingFailed, - GetPortMappingFailed, - DeletePortMappingFailed, - UnknownError - }; - /** UPnP port forwarding state. */ - enum UPNPState { - IdleState, - ErrorState, - DiscoverState, - UpdatingORPortState, - UpdatingDirPortState, - ForwardingCompleteState - }; - - /** Returns a pointer to this object's singleton instance. */ - static UPNPControl* instance(); - /** Terminates the UPnP control thread and frees memory allocated to this - * object's singleton instance. */ - static void cleanup(); - /** Sets desiredDirPort and desiredOrPort to the currently - * forwarded DirPort and ORPort values. */ - void getDesiredState(quint16 *desiredDirPort, quint16 *desiredOrPort); - /** Sets the desired DirPort and ORPort port mappings to - * desiredDirPort and desiredOrPort, respectively. */ - void setDesiredState(quint16 desiredDirPort, quint16 desiredOrPort); - - /** Returns the type of error that occurred last. */ - UPNPError error() const; - /** Returns a QString describing the type of error that occurred last. */ - QString errorString() const; - - /** Returns the number of milliseconds to wait for devices to respond - * when attempting to discover UPnP-enabled IGDs. */ - int discoverTimeout() const; - -signals: - /** Emitted when the UPnP control thread status changes. */ - void stateChanged(UPNPControl::UPNPState state); - - /** Emitted when a UPnP error occurs. */ - void error(UPNPControl::UPNPError error); - -protected: - /** Constructor. Initializes and starts a thread in which all blocking UPnP - * operations will be performed. */ - UPNPControl(); - /** Destructor. cleanup() should be called before the object is destroyed. */ - ~UPNPControl(); - - /** Sets the most recent UPnP-related error to error and emits the - * error() signal. - * \sa error - */ - void setError(UPNPError error); - - /** Sets the current UPnP state to state and emits the stateChanged() - * signal. - * \sa stateChanged - */ - void setState(UPNPState state); - -private: - static UPNPControl* _instance; /**< UPNPControl singleton instance. */ - - quint16 _forwardedORPort; /**< Currently forwarded ORPort. */ - quint16 _forwardedDirPort; /**< Currently forwarded DirPort. */ - QMutex* _mutex; /**< Mutex around variables shared with UPNPControlThread. */ - UPNPError _error; /**< Most recent UPNP error. */ - UPNPState _state; /**< Current UPNP status. */ - - friend class UPNPControlThread; - UPNPControlThread* _controlThread; /**< Thread used for UPnP operations. */ -}; - -#endif - diff -Nru vidalia-0.1.13/src/vidalia/config/UPNPControl.h vidalia-0.2.8/src/vidalia/config/UPNPControl.h --- vidalia-0.1.13/src/vidalia/config/UPNPControl.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/UPNPControl.h 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,114 @@ +/* +** 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.vidalia-project.net/. 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 UPNPControl.h +** \version $Id: UPNPControl.h 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Singleton object for interacting with UPNP device +*/ + +#ifndef _UPNPCONTROL_H +#define _UPNPCONTROL_H + +#include +#include + +/* Forward declaration to make it build */ +class UPNPControlThread; + + +class UPNPControl : public QObject +{ + Q_OBJECT + +public: + /** UPnP-related error values. */ + enum UPNPError { + Success, + NoUPNPDevicesFound, + NoValidIGDsFound, + WSAStartupFailed, + AddPortMappingFailed, + GetPortMappingFailed, + DeletePortMappingFailed, + UnknownError + }; + /** UPnP port forwarding state. */ + enum UPNPState { + IdleState, + ErrorState, + DiscoverState, + UpdatingORPortState, + UpdatingDirPortState, + ForwardingCompleteState + }; + + /** Returns a pointer to this object's singleton instance. */ + static UPNPControl* instance(); + /** Terminates the UPnP control thread and frees memory allocated to this + * object's singleton instance. */ + static void cleanup(); + /** Sets desiredDirPort and desiredOrPort to the currently + * forwarded DirPort and ORPort values. */ + void getDesiredState(quint16 *desiredDirPort, quint16 *desiredOrPort); + /** Sets the desired DirPort and ORPort port mappings to + * desiredDirPort and desiredOrPort, respectively. */ + void setDesiredState(quint16 desiredDirPort, quint16 desiredOrPort); + + /** Returns the type of error that occurred last. */ + UPNPError error() const; + /** Returns a QString describing the type of error that occurred last. */ + QString errorString() const; + + /** Returns the number of milliseconds to wait for devices to respond + * when attempting to discover UPnP-enabled IGDs. */ + int discoverTimeout() const; + +signals: + /** Emitted when the UPnP control thread status changes. */ + void stateChanged(UPNPControl::UPNPState state); + + /** Emitted when a UPnP error occurs. */ + void error(UPNPControl::UPNPError error); + +protected: + /** Constructor. Initializes and starts a thread in which all blocking UPnP + * operations will be performed. */ + UPNPControl(); + /** Destructor. cleanup() should be called before the object is destroyed. */ + ~UPNPControl(); + + /** Sets the most recent UPnP-related error to error and emits the + * error() signal. + * \sa error + */ + void setError(UPNPError error); + + /** Sets the current UPnP state to state and emits the stateChanged() + * signal. + * \sa stateChanged + */ + void setState(UPNPState state); + +private: + static UPNPControl* _instance; /**< UPNPControl singleton instance. */ + + quint16 _forwardedORPort; /**< Currently forwarded ORPort. */ + quint16 _forwardedDirPort; /**< Currently forwarded DirPort. */ + QMutex* _mutex; /**< Mutex around variables shared with UPNPControlThread. */ + UPNPError _error; /**< Most recent UPNP error. */ + UPNPState _state; /**< Current UPNP status. */ + + friend class UPNPControlThread; + UPNPControlThread* _controlThread; /**< Thread used for UPnP operations. */ +}; + +#endif + diff -Nru vidalia-0.1.13/src/vidalia/config/upnpcontrolthread.cpp vidalia-0.2.8/src/vidalia/config/upnpcontrolthread.cpp --- vidalia-0.1.13/src/vidalia/config/upnpcontrolthread.cpp 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/upnpcontrolthread.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,338 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 upnpcontrolthread.cpp -** \version $Id: upnpcontrolthread.cpp 2638 2008-06-01 23:42:53Z edmanm $ -** \brief Thread for configuring UPnP in the background -*/ - -#include "upnpcontrolthread.h" - -#include -#include -#include -#include -#include -#include -#include - -#ifdef Q_OS_WIN32 -#include -#endif - -#include "upnpcontrol.h" - -#define UPNPCONTROL_REINIT_MSEC 300000 // 5 minutes -#define UPNPCONTROL_MAX_WAIT_MSEC 60000 // 1 minute - - -/** Constructor. control will be used for retrieving the desired port - * forwarding state. */ -UPNPControlThread::UPNPControlThread(UPNPControl *control) -{ - _upnpInitialized = QTime(); - _keepRunning = true; - _control = control; - - _dirPort = 0; - _orPort = 0; - - _waitCondition = new QWaitCondition(); - _waitMutex = new QMutex(); -} - -/** Destructor. The UPnP control thread must be stopped prior to destroying - * this object. - * \sa stop() - */ -UPNPControlThread::~UPNPControlThread() -{ - delete _waitCondition; - delete _waitMutex; -} - -/** Thread entry point. The thread has a main loop that periodically wakes up - * and updates the configured port mappings. Upon exiting, all port mappings - * will be removed. */ -void -UPNPControlThread::run() -{ - bool shouldExit = false; - - forever { - /* TODO: Check for switching OR/Dir port */ - /* TODO: Check for router losing state */ - - configurePorts(); - - /* Wait for something to happen */ - _waitMutex->lock(); - if (_keepRunning) { - /* We should continue */ - UPNPControl::instance()->setState(UPNPControl::IdleState); - _waitCondition->wait(_waitMutex, UPNPCONTROL_MAX_WAIT_MSEC); - - /* Maybe we were asked to exit while waiting */ - shouldExit = !_keepRunning; - _waitMutex->unlock(); - if (shouldExit) - break; - } else { - /* We should exit */ - _waitMutex->unlock(); - break; - } - } - - /* Remove the existing port forwards */ - updatePort(_dirPort, 0); - updatePort(_orPort, 0); -} - -/** Sets up port forwarding according the previously-configured desired state. - * The desired state is set using UPNPControl's setDesiredState() method. - * \sa UPNPControl::setDesiredState - */ -void -UPNPControlThread::configurePorts() { - quint16 desiredDirPort, desiredOrPort; - bool force_init = false; - UPNPControl::UPNPError retval = UPNPControl::Success; - - /* Get desired state */ - _control->getDesiredState(&desiredDirPort, &desiredOrPort); - - /* If it's been a while since we initialized the router, or time has gone - backward, then maybe the router has gone away or forgotten the forwards. - Reset UPnP state, and re-do the port forwarding */ - if (_upnpInitialized.isNull() || // Is this the first time we have used UPNP? - _upnpInitialized>QTime::currentTime() || // Has time gone backwards? - _upnpInitialized.addMSecs(UPNPCONTROL_REINIT_MSEC)setState(UPNPControl::UpdatingDirPortState); - retval = updatePort(_dirPort, desiredDirPort); - if (retval == UPNPControl::Success) - _dirPort = desiredDirPort; - else - goto err; - } - - /* Configure ORPort */ - if (desiredOrPort != _orPort) { - UPNPControl::instance()->setState(UPNPControl::UpdatingORPortState); - retval = updatePort(_orPort, desiredOrPort); - if (retval == UPNPControl::Success) - _orPort = desiredOrPort; - else - goto err; - } - } else { - /* Add the mapping even if they exist already */ - UPNPControl::instance()->setState(UPNPControl::UpdatingDirPortState); - retval = updatePort(0, desiredDirPort); - if (retval == UPNPControl::Success) - _dirPort = desiredDirPort; - else - goto err; - - UPNPControl::instance()->setState(UPNPControl::UpdatingORPortState); - retval = updatePort(0, desiredOrPort); - if (retval == UPNPControl::Success) - _orPort = desiredOrPort; - else goto err; - } - - UPNPControl::instance()->setState(UPNPControl::ForwardingCompleteState); - return; - -err: - UPNPControl::instance()->setError(retval); - UPNPControl::instance()->setState(UPNPControl::ErrorState); -} - -/** Terminates the UPnP control thread's run() loop. - * \sa run() - */ -void -UPNPControlThread::stop() -{ - /* Lock access to _keepRunning */ - _waitMutex->lock(); - - /* Ask the thread to stop */ - _keepRunning = false; - - /* Wake it up if needed */ - _waitCondition->wakeAll(); - - /* Unlock shared state */ - _waitMutex->unlock(); - - /* Wait for it to finish */ - wait(); -} - -/** Wakes up the UPnP control thread's run() loop. - * \sa run() - */ -void -UPNPControlThread::wakeup() -{ - _waitMutex->lock(); - _waitCondition->wakeAll(); - _waitMutex->unlock(); -} - -/** Updates the port mapping for oldPort, changing it to - * newPort. */ -UPNPControl::UPNPError -UPNPControlThread::updatePort(quint16 oldPort, quint16 newPort) -{ - UPNPControl::UPNPError retval; - -#ifdef Q_OS_WIN32 - // Workaround from http://trolltech.com/developer/knowledgebase/579 - WSAData wsadata; - if (WSAStartup(MAKEWORD(2,0), &wsadata) != 0) { - vWarn("WSAStartup failure while updating UPnP port forwarding"); - return UPNPControl::WSAStartupFailed; - } -#endif - - if (_upnpInitialized.isNull() && (oldPort != 0 || newPort != 0)) { - retval = initializeUPNP(); - if (retval == UPNPControl::Success) - _upnpInitialized = QTime::currentTime(); - else - _upnpInitialized = QTime(); - } else { - retval = UPNPControl::Success; - } - - if (retval == UPNPControl::Success && oldPort != 0) - retval = disablePort(oldPort); - - if (retval == UPNPControl::Success && newPort != 0) - retval = forwardPort(newPort); - -#ifdef Q_OS_WIN32 - WSACleanup(); -#endif - - return retval; -} - -/** Discovers UPnP-enabled IGDs on the network. Based on - * http://miniupnp.free.fr/files/download.php?file=xchat-upnp20061022.patch - * This method will block for UPNPCONTROL_DISCOVER_TIMEOUT milliseconds. */ -UPNPControl::UPNPError -UPNPControlThread::initializeUPNP() -{ - struct UPNPDev *devlist; - int retval; - - memset(&urls, 0, sizeof(struct UPNPUrls)); - memset(&data, 0, sizeof(struct IGDdatas)); - - UPNPControl::instance()->setState(UPNPControl::DiscoverState); - - devlist = upnpDiscover(UPNPCONTROL_DISCOVER_TIMEOUT, NULL, NULL); - if (NULL == devlist) { - vWarn("upnpDiscover returned: NULL"); - return UPNPControl::NoUPNPDevicesFound; - } - - retval = UPNP_GetValidIGD(devlist, &urls, &data, lanaddr, sizeof(lanaddr)); - - vInfo("GetValidIGD returned: %1").arg(retval); - - freeUPNPDevlist(devlist); - - if (retval != 1 && retval != 2) - return UPNPControl::NoValidIGDsFound; - - return UPNPControl::Success; -} - -/** Adds a port forwarding mapping from external:port to - * internal:port. Returns 0 on success, or non-zero on failure. */ -UPNPControl::UPNPError -UPNPControlThread::forwardPort(quint16 port) -{ - int retval; - - char sPort[6]; - - char intClient[16]; - char intPort[6]; - - // Convert the port number to a string - snprintf(sPort, sizeof(sPort), "%d", port); - - // Add the port mapping of external:port -> internal:port - retval = UPNP_AddPortMapping(urls.controlURL, data.servicetype, - sPort, sPort, lanaddr, "Tor relay", "TCP"); - if(UPNPCOMMAND_SUCCESS != retval) { - vWarn("AddPortMapping(%1, %2, %3) failed with code %4") - .arg(sPort).arg(sPort).arg(lanaddr).arg(retval); - return UPNPControl::AddPortMappingFailed; - } - - // Check if the port mapping was accepted - retval = UPNP_GetSpecificPortMappingEntry(urls.controlURL, data.servicetype, - sPort, "TCP", intClient, intPort); - if(UPNPCOMMAND_SUCCESS != retval) { - vWarn("GetSpecificPortMappingEntry() failed with code %1").arg(retval); - return UPNPControl::GetPortMappingFailed; - } - - if(! intClient[0]) { - vWarn("GetSpecificPortMappingEntry failed."); - return UPNPControl::GetPortMappingFailed; - } - - // Output the mapping - vInfo("(external):%1 -> %2:%3").arg(sPort).arg(intClient).arg(intPort); - - return UPNPControl::Success; -} - -/** Removes the port mapping for port. Returns 0 on success or non-zero - * on failure. */ -UPNPControl::UPNPError -UPNPControlThread::disablePort(quint16 port) -{ - char sPort[6]; - - // Convert the port number to a string - snprintf(sPort, sizeof(sPort), "%d", port); - - // Remove the mapping - int retval = UPNP_DeletePortMapping(urls.controlURL, data.servicetype, - sPort, "TCP"); - if(UPNPCOMMAND_SUCCESS != retval) { - vWarn("DeletePortMapping() failed with code %1").arg(retval); - return UPNPControl::DeletePortMappingFailed; - } - - // Output the cancelled mapping - vInfo("(external):%1 -> <>").arg(sPort); - - return UPNPControl::Success; -} - diff -Nru vidalia-0.1.13/src/vidalia/config/UPNPControlThread.cpp vidalia-0.2.8/src/vidalia/config/UPNPControlThread.cpp --- vidalia-0.1.13/src/vidalia/config/UPNPControlThread.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/UPNPControlThread.cpp 2010-04-10 00:18:46.000000000 +0100 @@ -0,0 +1,332 @@ +/* +** 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.vidalia-project.net/. 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 UPNPControlThread.cpp +** \version $Id: UPNPControlThread.cpp 4252 2010-04-09 23:18:46Z edmanm $ +** \brief Thread for configuring UPnP in the background +*/ + +#include "UPNPControlThread.h" +#include "UPNPControl.h" +#include "Vidalia.h" + +#include +#include +#include +#include +#include +#include + +#define UPNPCONTROL_REINIT_MSEC 300000 // 5 minutes +#define UPNPCONTROL_MAX_WAIT_MSEC 60000 // 1 minute + + +/** Constructor. control will be used for retrieving the desired port + * forwarding state. */ +UPNPControlThread::UPNPControlThread(UPNPControl *control) +{ + _upnpInitialized = QTime(); + _keepRunning = true; + _control = control; + + _dirPort = 0; + _orPort = 0; + + _waitCondition = new QWaitCondition(); + _waitMutex = new QMutex(); +} + +/** Destructor. The UPnP control thread must be stopped prior to destroying + * this object. + * \sa stop() + */ +UPNPControlThread::~UPNPControlThread() +{ + delete _waitCondition; + delete _waitMutex; +} + +/** Thread entry point. The thread has a main loop that periodically wakes up + * and updates the configured port mappings. Upon exiting, all port mappings + * will be removed. */ +void +UPNPControlThread::run() +{ + bool shouldExit = false; + + forever { + /* TODO: Check for switching OR/Dir port */ + /* TODO: Check for router losing state */ + + configurePorts(); + + /* Wait for something to happen */ + _waitMutex->lock(); + if (_keepRunning) { + /* We should continue */ + UPNPControl::instance()->setState(UPNPControl::IdleState); + _waitCondition->wait(_waitMutex, UPNPCONTROL_MAX_WAIT_MSEC); + + /* Maybe we were asked to exit while waiting */ + shouldExit = !_keepRunning; + _waitMutex->unlock(); + if (shouldExit) + break; + } else { + /* We should exit */ + _waitMutex->unlock(); + break; + } + } + + /* Remove the existing port forwards */ + updatePort(_dirPort, 0); + updatePort(_orPort, 0); +} + +/** Sets up port forwarding according the previously-configured desired state. + * The desired state is set using UPNPControl's setDesiredState() method. + * \sa UPNPControl::setDesiredState + */ +void +UPNPControlThread::configurePorts() +{ + quint16 desiredDirPort, desiredOrPort; + bool force_init = false; + UPNPControl::UPNPError retval = UPNPControl::Success; + + /* Get desired state */ + _control->getDesiredState(&desiredDirPort, &desiredOrPort); + + /* If it's been a while since we initialized the router, or time has gone + backward, then maybe the router has gone away or forgotten the forwards. + Reset UPnP state, and re-do the port forwarding */ + if (_upnpInitialized.isNull() || // Is this the first time we have used UPNP? + _upnpInitialized>QTime::currentTime() || // Has time gone backwards? + _upnpInitialized.addMSecs(UPNPCONTROL_REINIT_MSEC)setState(UPNPControl::UpdatingDirPortState); + retval = updatePort(_dirPort, desiredDirPort); + if (retval == UPNPControl::Success) + _dirPort = desiredDirPort; + else + goto err; + } + + /* Configure ORPort */ + if (desiredOrPort != _orPort) { + UPNPControl::instance()->setState(UPNPControl::UpdatingORPortState); + retval = updatePort(_orPort, desiredOrPort); + if (retval == UPNPControl::Success) + _orPort = desiredOrPort; + else + goto err; + } + } else { + /* Add the mapping even if they exist already */ + UPNPControl::instance()->setState(UPNPControl::UpdatingDirPortState); + retval = updatePort(0, desiredDirPort); + if (retval == UPNPControl::Success) + _dirPort = desiredDirPort; + else + goto err; + + UPNPControl::instance()->setState(UPNPControl::UpdatingORPortState); + retval = updatePort(0, desiredOrPort); + if (retval == UPNPControl::Success) + _orPort = desiredOrPort; + else goto err; + } + + UPNPControl::instance()->setState(UPNPControl::ForwardingCompleteState); + return; + +err: + UPNPControl::instance()->setError(retval); + UPNPControl::instance()->setState(UPNPControl::ErrorState); +} + +/** Terminates the UPnP control thread's run() loop. + * \sa run() + */ +void +UPNPControlThread::stop() +{ + /* Lock access to _keepRunning */ + _waitMutex->lock(); + + /* Ask the thread to stop */ + _keepRunning = false; + + /* Wake it up if needed */ + _waitCondition->wakeAll(); + + /* Unlock shared state */ + _waitMutex->unlock(); + + /* Wait for it to finish */ + wait(); +} + +/** Wakes up the UPnP control thread's run() loop. + * \sa run() + */ +void +UPNPControlThread::wakeup() +{ + _waitMutex->lock(); + _waitCondition->wakeAll(); + _waitMutex->unlock(); +} + +/** Updates the port mapping for oldPort, changing it to + * newPort. */ +UPNPControl::UPNPError +UPNPControlThread::updatePort(quint16 oldPort, quint16 newPort) +{ + UPNPControl::UPNPError retval; + +#ifdef Q_OS_WIN32 + // Workaround from http://trolltech.com/developer/knowledgebase/579 + WSAData wsadata; + if (WSAStartup(MAKEWORD(2,0), &wsadata) != 0) { + vWarn("WSAStartup failure while updating UPnP port forwarding"); + return UPNPControl::WSAStartupFailed; + } +#endif + + if (_upnpInitialized.isNull() && (oldPort != 0 || newPort != 0)) { + retval = initializeUPNP(); + if (retval == UPNPControl::Success) + _upnpInitialized = QTime::currentTime(); + else + _upnpInitialized = QTime(); + } else { + retval = UPNPControl::Success; + } + + if (retval == UPNPControl::Success && oldPort != 0) + retval = disablePort(oldPort); + + if (retval == UPNPControl::Success && newPort != 0) + retval = forwardPort(newPort); + +#ifdef Q_OS_WIN32 + WSACleanup(); +#endif + + return retval; +} + +/** Discovers UPnP-enabled IGDs on the network. Based on + * http://miniupnp.free.fr/files/download.php?file=xchat-upnp20061022.patch + * This method will block for UPNPCONTROL_DISCOVER_TIMEOUT milliseconds. */ +UPNPControl::UPNPError +UPNPControlThread::initializeUPNP() +{ + struct UPNPDev *devlist; + int retval; + + memset(&urls, 0, sizeof(struct UPNPUrls)); + memset(&data, 0, sizeof(struct IGDdatas)); + + UPNPControl::instance()->setState(UPNPControl::DiscoverState); + + devlist = upnpDiscover(UPNPCONTROL_DISCOVER_TIMEOUT, NULL, NULL, 0); + if (NULL == devlist) { + vWarn("upnpDiscover returned: NULL"); + return UPNPControl::NoUPNPDevicesFound; + } + + retval = UPNP_GetValidIGD(devlist, &urls, &data, lanaddr, sizeof(lanaddr)); + + vInfo("GetValidIGD returned: %1").arg(retval); + + freeUPNPDevlist(devlist); + + if (retval != 1 && retval != 2) + return UPNPControl::NoValidIGDsFound; + + return UPNPControl::Success; +} + +/** Adds a port forwarding mapping from external:port to + * internal:port. Returns 0 on success, or non-zero on failure. */ +UPNPControl::UPNPError +UPNPControlThread::forwardPort(quint16 port) +{ + QString sPort; + int retval; + + char intClient[16]; + char intPort[6]; + + // Convert the port number to a string + sPort = QString::number(port); + + // Add the port mapping of external:port -> internal:port + retval = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype, + qPrintable(sPort), qPrintable(sPort), lanaddr, + "Tor relay", "TCP", NULL); + if(UPNPCOMMAND_SUCCESS != retval) { + vWarn("AddPortMapping(%1, %2, %3) failed with code %4") + .arg(sPort).arg(sPort).arg(lanaddr).arg(retval); + return UPNPControl::AddPortMappingFailed; + } + + // Check if the port mapping was accepted + retval = UPNP_GetSpecificPortMappingEntry(urls.controlURL, data.first.servicetype, + qPrintable(sPort), "TCP", + intClient, intPort); + if(UPNPCOMMAND_SUCCESS != retval) { + vWarn("GetSpecificPortMappingEntry() failed with code %1").arg(retval); + return UPNPControl::GetPortMappingFailed; + } + + if(! intClient[0]) { + vWarn("GetSpecificPortMappingEntry failed."); + return UPNPControl::GetPortMappingFailed; + } + + // Output the mapping + vInfo("(external):%1 -> %2:%3").arg(sPort).arg(intClient).arg(intPort); + + return UPNPControl::Success; +} + +/** Removes the port mapping for port. Returns 0 on success or non-zero + * on failure. */ +UPNPControl::UPNPError +UPNPControlThread::disablePort(quint16 port) +{ + QString sPort = QString::number(port); + + // Remove the mapping + int retval = UPNP_DeletePortMapping(urls.controlURL, data.first.servicetype, + qPrintable(sPort), "TCP", NULL); + if(UPNPCOMMAND_SUCCESS != retval) { + vWarn("DeletePortMapping() failed with code %1").arg(retval); + return UPNPControl::DeletePortMappingFailed; + } + + // Output the cancelled mapping + vInfo("(external):%1 -> <>").arg(sPort); + + return UPNPControl::Success; +} + diff -Nru vidalia-0.1.13/src/vidalia/config/upnpcontrolthread.h vidalia-0.2.8/src/vidalia/config/upnpcontrolthread.h --- vidalia-0.1.13/src/vidalia/config/upnpcontrolthread.h 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/upnpcontrolthread.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,90 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 upnpcontrolthread.h -** \version $Id: upnpcontrolthread.h 2638 2008-06-01 23:42:53Z edmanm $ -** \brief Thread for configuring UPnP in the background -*/ - -#ifndef _UPNPCONTROLTHREAD_H -#define _UPNPCONTROLTHREAD_H - -#include -#include -#include -#include -#include "upnpcontrol.h" - -#define STATICLIB -#include -#include -#include - - -class UPNPControlThread : public QThread -{ - Q_OBJECT - -public: - /** Specifies the number of milliseconds to wait for devices to respond - * when attempting to discover UPnP-enabled IGDs. */ - static const int UPNPCONTROL_DISCOVER_TIMEOUT = 2000; - - /** Constructor. control will be used for retrieving the desired port - * forwarding state. */ - UPNPControlThread(UPNPControl *control); - /** Destructor. The UPnP control thread must be stopped prior to destroying - * this object. */ - ~UPNPControlThread(); - /** Terminates the UPnP control thread's run() loop. */ - void stop(); - /** Wakes up the UPnP control thread's run() loop. */ - void wakeup(); - -protected: - /** Thread entry point. The thread has a main loop that periodically wakes - * up and updates the configured port mappings. Upon exiting, all port - * mappings will be removed. */ - void run(); - -private: - /** Sets up port forwarding according the previously-configured desired - * state. The desired state is set using UPNPControl's setDesiredState() - * method. */ - void configurePorts(); - /** Discovers UPnP-enabled IGDs on the network. This method will block for - * UPNPCONTROL_DISCOVER_TIMEOUT milliseconds. */ - UPNPControl::UPNPError initializeUPNP(); - /** Updates the port mapping for oldPort, changing it to - * newPort. */ - UPNPControl::UPNPError updatePort(quint16 oldPort, quint16 newPort); - /** Adds a port forwarding mapping from external:port to - * internal:port. Returns 0 on success, or non-zero on failure. */ - UPNPControl::UPNPError forwardPort(quint16 port); - /** Removes the port mapping for port. Returns 0 on success or - * non-zero on failure. */ - UPNPControl::UPNPError disablePort(quint16 port); - - QTime _upnpInitialized; /**< Time at which the UPnP state was last set. */ - bool _keepRunning; /**< True if the control thread should keep running. */ - UPNPControl *_control; /**< Stores desired UPnP state. */ - QWaitCondition *_waitCondition; /**< Used to wake up the control thread. */ - QMutex *_waitMutex; /**< Mutex around shared variables. */ - quint16 _dirPort; /**< Desired DirPort. */ - quint16 _orPort; /**< Desired ORPort. */ - - /* Used by miniupnpc library */ - struct UPNPUrls urls; - struct IGDdatas data; - char lanaddr[16]; -}; -#endif - diff -Nru vidalia-0.1.13/src/vidalia/config/UPNPControlThread.h vidalia-0.2.8/src/vidalia/config/UPNPControlThread.h --- vidalia-0.1.13/src/vidalia/config/UPNPControlThread.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/UPNPControlThread.h 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,92 @@ +/* +** 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.vidalia-project.net/. 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 UPNPControlThread.h +** \version $Id: UPNPControlThread.h 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Thread for configuring UPnP in the background +*/ + +#ifndef _UPNPCONTROLTHREAD_H +#define _UPNPCONTROLTHREAD_H + +#include "UPNPControl.h" + +#define STATICLIB +#include +#include +#include +#undef STATICLIB + +#include +#include +#include +#include + + +class UPNPControlThread : public QThread +{ + Q_OBJECT + +public: + /** Specifies the number of milliseconds to wait for devices to respond + * when attempting to discover UPnP-enabled IGDs. */ + static const int UPNPCONTROL_DISCOVER_TIMEOUT = 2000; + + /** Constructor. control will be used for retrieving the desired port + * forwarding state. */ + UPNPControlThread(UPNPControl *control); + /** Destructor. The UPnP control thread must be stopped prior to destroying + * this object. */ + ~UPNPControlThread(); + /** Terminates the UPnP control thread's run() loop. */ + void stop(); + /** Wakes up the UPnP control thread's run() loop. */ + void wakeup(); + +protected: + /** Thread entry point. The thread has a main loop that periodically wakes + * up and updates the configured port mappings. Upon exiting, all port + * mappings will be removed. */ + void run(); + +private: + /** Sets up port forwarding according the previously-configured desired + * state. The desired state is set using UPNPControl's setDesiredState() + * method. */ + void configurePorts(); + /** Discovers UPnP-enabled IGDs on the network. This method will block for + * UPNPCONTROL_DISCOVER_TIMEOUT milliseconds. */ + UPNPControl::UPNPError initializeUPNP(); + /** Updates the port mapping for oldPort, changing it to + * newPort. */ + UPNPControl::UPNPError updatePort(quint16 oldPort, quint16 newPort); + /** Adds a port forwarding mapping from external:port to + * internal:port. Returns 0 on success, or non-zero on failure. */ + UPNPControl::UPNPError forwardPort(quint16 port); + /** Removes the port mapping for port. Returns 0 on success or + * non-zero on failure. */ + UPNPControl::UPNPError disablePort(quint16 port); + + QTime _upnpInitialized; /**< Time at which the UPnP state was last set. */ + bool _keepRunning; /**< True if the control thread should keep running. */ + UPNPControl *_control; /**< Stores desired UPnP state. */ + QWaitCondition *_waitCondition; /**< Used to wake up the control thread. */ + QMutex *_waitMutex; /**< Mutex around shared variables. */ + quint16 _dirPort; /**< Desired DirPort. */ + quint16 _orPort; /**< Desired ORPort. */ + + /* Used by miniupnpc library */ + struct UPNPUrls urls; + struct IGDdatas data; + char lanaddr[16]; +}; +#endif + diff -Nru vidalia-0.1.13/src/vidalia/config/upnptestdialog.cpp vidalia-0.2.8/src/vidalia/config/upnptestdialog.cpp --- vidalia-0.1.13/src/vidalia/config/upnptestdialog.cpp 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/upnptestdialog.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,168 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 upnptestdialog.cpp -** \version $Id: upnptestdialog.cpp 2684 2008-06-10 04:50:15Z edmanm $ -** \brief Dialog that displays the progress of a UPnP configuration test -*/ - -#include "upnptestdialog.h" - - -/** Default constructor. orPort and dirPort specify the ports - * used to test UPnP port forwarding. The original UPnP state will be restored - * when the test dialog is closed. */ -UPNPTestDialog::UPNPTestDialog(quint16 orPort, quint16 dirPort, QWidget *parent) - : QDialog(parent), _orPort(orPort), _dirPort(dirPort) -{ - ui.setupUi(this); - _upnp = UPNPControl::instance(); - - ui.buttonBox->setStandardButtons(QDialogButtonBox::Close - | QDialogButtonBox::Help); - - ui.progressBar->setValue(0); - ui.progressBar->setFormat(""); - ui.progressBar->setMinimum(0); - ui.progressBar->setMaximum(_upnp->discoverTimeout()/500 + 4); - - _discoverTimer.setInterval(500); - connect(&_discoverTimer, SIGNAL(timeout()), this, SLOT(discoverTimeout())); - connect(ui.buttonBox, SIGNAL(clicked(QAbstractButton*)), - this, SLOT(clicked(QAbstractButton*))); - - _upnp->getDesiredState(&_oldDirPort, &_oldOrPort); -} - -/** Shows or hides the dialog based on visible. The UPnP test will be - * started when the dialog is first shown. */ -void -UPNPTestDialog::setVisible(bool visible) -{ - QWidget::setVisible(visible); - - if (visible) - startTest(); - else - _upnp->setDesiredState(_oldDirPort, _oldOrPort); -} - -/** Initiates a UPnP test. */ -void -UPNPTestDialog::startTest() -{ - ui.buttonBox->setEnabled(false); - ui.progressBar->setValue(0); - - connect(UPNPControl::instance(), SIGNAL(stateChanged(UPNPControl::UPNPState)), - this, SLOT(upnpStateChanged(UPNPControl::UPNPState))); - - UPNPControl::instance()->setDesiredState(_dirPort, _orPort); -} - -/** Called when the UPnP test successfully enables port forwarding. Enables - * the Close button, allowing the user to exit the test dialog. */ -void -UPNPTestDialog::testSuccessful() -{ - ui.buttonBox->setEnabled(true); - ui.buttonBox->setStandardButtons(QDialogButtonBox::Close - | QDialogButtonBox::Help); - - disconnect(UPNPControl::instance(), 0, this, 0); -} - -/** Called when the UPnP test fails due to an error. Enables the Close and - * Retry buttons, allowing the user to either rerun the test or give up. */ -void -UPNPTestDialog::testFailed() -{ - ui.buttonBox->setEnabled(true); - ui.buttonBox->setStandardButtons(QDialogButtonBox::Retry - | QDialogButtonBox::Close - | QDialogButtonBox::Help); - - disconnect(UPNPControl::instance(), 0, this, 0); -} - -/** Updates the progress bar to indicate the device discovery portion of the - * test is still in progress. */ -void -UPNPTestDialog::discoverTimeout() -{ - ui.progressBar->setValue(ui.progressBar->value()+1); -} - -/** Updates the test UI based on the UPnP state. */ -void -UPNPTestDialog::upnpStateChanged(UPNPControl::UPNPState state) -{ - switch (state) { - case UPNPControl::DiscoverState: - _discoverTimer.start(); - ui.progressBar->setValue(ui.progressBar->value()+1); - ui.lblCurrentState->setText(tr("Discovering UPnP-enabled devices")); - break; - - case UPNPControl::UpdatingDirPortState: - ui.progressBar->setValue(ui.progressBar->value()+1); - ui.lblCurrentState->setText(tr("Updating directory port mapping")); - break; - - case UPNPControl::UpdatingORPortState: - ui.progressBar->setValue(ui.progressBar->value()+1); - ui.lblCurrentState->setText(tr("Updating relay port mapping")); - break; - - case UPNPControl::ForwardingCompleteState: - ui.progressBar->setValue(ui.progressBar->maximum()); - ui.lblCurrentState->setText(tr("Test completed successfully!")); - testSuccessful(); - break; - - case UPNPControl::ErrorState: - ui.progressBar->setValue(ui.progressBar->maximum()); - ui.lblCurrentState->setText(UPNPControl::instance()->errorString()); - testFailed(); - break; - - default: - break; - } - if (state != UPNPControl::DiscoverState) - _discoverTimer.stop(); -} - -/** Called when a user clicks on a button in the dialog's button box. If Retry - * is clicked, another UPnP test will be conducted. If Close is clicked, then - * the dialog is closed and the original UPnP state restored. */ -void -UPNPTestDialog::clicked(QAbstractButton *button) -{ - switch (ui.buttonBox->standardButton(button)) { - case QDialogButtonBox::Retry: - startTest(); - break; - - case QDialogButtonBox::Close: - done(0); - break; - - case QDialogButtonBox::Help: - emit help(); - done(0); - break; - - default: - break; - } -} - diff -Nru vidalia-0.1.13/src/vidalia/config/UPNPTestDialog.cpp vidalia-0.2.8/src/vidalia/config/UPNPTestDialog.cpp --- vidalia-0.1.13/src/vidalia/config/UPNPTestDialog.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/UPNPTestDialog.cpp 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,168 @@ +/* +** 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.vidalia-project.net/. 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 UPNPTestDialog.cpp +** \version $Id: UPNPTestDialog.cpp 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Dialog that displays the progress of a UPnP configuration test +*/ + +#include "UPNPTestDialog.h" + + +/** Default constructor. orPort and dirPort specify the ports + * used to test UPnP port forwarding. The original UPnP state will be restored + * when the test dialog is closed. */ +UPNPTestDialog::UPNPTestDialog(quint16 orPort, quint16 dirPort, QWidget *parent) + : QDialog(parent), _orPort(orPort), _dirPort(dirPort) +{ + ui.setupUi(this); + _upnp = UPNPControl::instance(); + + ui.buttonBox->setStandardButtons(QDialogButtonBox::Close + | QDialogButtonBox::Help); + + ui.progressBar->setValue(0); + ui.progressBar->setFormat(""); + ui.progressBar->setMinimum(0); + ui.progressBar->setMaximum(_upnp->discoverTimeout()/500 + 4); + + _discoverTimer.setInterval(500); + connect(&_discoverTimer, SIGNAL(timeout()), this, SLOT(discoverTimeout())); + connect(ui.buttonBox, SIGNAL(clicked(QAbstractButton*)), + this, SLOT(clicked(QAbstractButton*))); + + _upnp->getDesiredState(&_oldDirPort, &_oldOrPort); +} + +/** Shows or hides the dialog based on visible. The UPnP test will be + * started when the dialog is first shown. */ +void +UPNPTestDialog::setVisible(bool visible) +{ + QWidget::setVisible(visible); + + if (visible) + startTest(); + else + _upnp->setDesiredState(_oldDirPort, _oldOrPort); +} + +/** Initiates a UPnP test. */ +void +UPNPTestDialog::startTest() +{ + ui.buttonBox->setEnabled(false); + ui.progressBar->setValue(0); + + connect(UPNPControl::instance(), SIGNAL(stateChanged(UPNPControl::UPNPState)), + this, SLOT(upnpStateChanged(UPNPControl::UPNPState))); + + UPNPControl::instance()->setDesiredState(_dirPort, _orPort); +} + +/** Called when the UPnP test successfully enables port forwarding. Enables + * the Close button, allowing the user to exit the test dialog. */ +void +UPNPTestDialog::testSuccessful() +{ + ui.buttonBox->setEnabled(true); + ui.buttonBox->setStandardButtons(QDialogButtonBox::Close + | QDialogButtonBox::Help); + + disconnect(UPNPControl::instance(), 0, this, 0); +} + +/** Called when the UPnP test fails due to an error. Enables the Close and + * Retry buttons, allowing the user to either rerun the test or give up. */ +void +UPNPTestDialog::testFailed() +{ + ui.buttonBox->setEnabled(true); + ui.buttonBox->setStandardButtons(QDialogButtonBox::Retry + | QDialogButtonBox::Close + | QDialogButtonBox::Help); + + disconnect(UPNPControl::instance(), 0, this, 0); +} + +/** Updates the progress bar to indicate the device discovery portion of the + * test is still in progress. */ +void +UPNPTestDialog::discoverTimeout() +{ + ui.progressBar->setValue(ui.progressBar->value()+1); +} + +/** Updates the test UI based on the UPnP state. */ +void +UPNPTestDialog::upnpStateChanged(UPNPControl::UPNPState state) +{ + switch (state) { + case UPNPControl::DiscoverState: + _discoverTimer.start(); + ui.progressBar->setValue(ui.progressBar->value()+1); + ui.lblCurrentState->setText(tr("Discovering UPnP-enabled devices")); + break; + + case UPNPControl::UpdatingDirPortState: + ui.progressBar->setValue(ui.progressBar->value()+1); + ui.lblCurrentState->setText(tr("Updating directory port mapping")); + break; + + case UPNPControl::UpdatingORPortState: + ui.progressBar->setValue(ui.progressBar->value()+1); + ui.lblCurrentState->setText(tr("Updating relay port mapping")); + break; + + case UPNPControl::ForwardingCompleteState: + ui.progressBar->setValue(ui.progressBar->maximum()); + ui.lblCurrentState->setText(tr("Test completed successfully!")); + testSuccessful(); + break; + + case UPNPControl::ErrorState: + ui.progressBar->setValue(ui.progressBar->maximum()); + ui.lblCurrentState->setText(UPNPControl::instance()->errorString()); + testFailed(); + break; + + default: + break; + } + if (state != UPNPControl::DiscoverState) + _discoverTimer.stop(); +} + +/** Called when a user clicks on a button in the dialog's button box. If Retry + * is clicked, another UPnP test will be conducted. If Close is clicked, then + * the dialog is closed and the original UPnP state restored. */ +void +UPNPTestDialog::clicked(QAbstractButton *button) +{ + switch (ui.buttonBox->standardButton(button)) { + case QDialogButtonBox::Retry: + startTest(); + break; + + case QDialogButtonBox::Close: + done(0); + break; + + case QDialogButtonBox::Help: + emit help(); + done(0); + break; + + default: + break; + } +} + diff -Nru vidalia-0.1.13/src/vidalia/config/upnptestdialog.h vidalia-0.2.8/src/vidalia/config/upnptestdialog.h --- vidalia-0.1.13/src/vidalia/config/upnptestdialog.h 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/upnptestdialog.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,89 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 upnptestdialog.h -** \version $Id: upnptestdialog.h 2684 2008-06-10 04:50:15Z edmanm $ -** \brief Dialog that displays the progress of a UPnP configuration test -*/ - -#ifndef _UPNPTESTDIALOG_H -#define _UPNPTESTDIALOG_H - -#include -#include -#include - -#include "ui_upnptestdialog.h" -#include "upnpcontrol.h" - - -class UPNPTestDialog : public QDialog -{ - Q_OBJECT - -public: - /** Default constructor. orPort and dirPort specify the ports - * used to test UPnP port forwarding. The original UPnP state will be - * restored when the test dialog is closed. */ - UPNPTestDialog(quint16 orPort, quint16 dirPort, QWidget *parent = 0); - -signals: - /** Emitted when the user clicks the 'Help' button requesting the help topic - * on port forwarding. */ - void help(); - -protected slots: - /** Shows or hides the dialog based on visible. The UPnP test will be - * started when the dialog is first shown. */ - void setVisible(bool visible); - - /** Called when a user clicks on a button in the dialog's button box. If - * Retry is clicked, another UPnP test will be conducted. If Close is clicked, - * then the dialog is closed and the original UPnP state restored. */ - void clicked(QAbstractButton *button); - - /** Updates the test UI based on the UPnP state. */ - void upnpStateChanged(UPNPControl::UPNPState state); - - /** Updates the progress bar to indicate the device discovery portion of the - * test is still in progress. */ - void discoverTimeout(); - -protected: - /** Initiates a UPnP test. */ - void startTest(); - - /** Called when the UPnP test successfully enables port forwarding. Enables - * the Close button, allowing the user to exit the test dialog. */ - void testSuccessful(); - - /** Called when the UPnP test fails due to an error. Enables the Close and - * Retry buttons, allowing the user to either rerun the test or give up. */ - void testFailed(); - -private: - /** Pointer to the UPNPControl singleton instance. */ - UPNPControl *_upnp; - - /** Timer used to update the progress bar while during the device discovery - * portion of the test. */ - QTimer _discoverTimer; - - quint16 _oldOrPort; /**< Original (pre-test) forwarded ORPort. */ - quint16 _oldDirPort; /**< Original (pre-test) forwarded DirPort. */ - quint16 _orPort; /**< ORPort used during the test. */ - quint16 _dirPort; /**< DirPort used during the test. */ - - Ui::UPNPTestDialog ui; -}; - -#endif - diff -Nru vidalia-0.1.13/src/vidalia/config/UPNPTestDialog.h vidalia-0.2.8/src/vidalia/config/UPNPTestDialog.h --- vidalia-0.1.13/src/vidalia/config/UPNPTestDialog.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/UPNPTestDialog.h 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,89 @@ +/* +** 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.vidalia-project.net/. 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 UPNPTestDialog.h +** \version $Id: UPNPTestDialog.h 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Dialog that displays the progress of a UPnP configuration test +*/ + +#ifndef _UPNPTESTDIALOG_H +#define _UPNPTESTDIALOG_H + +#include "ui_UPNPTestDialog.h" +#include "UPNPControl.h" + +#include +#include +#include + + +class UPNPTestDialog : public QDialog +{ + Q_OBJECT + +public: + /** Default constructor. orPort and dirPort specify the ports + * used to test UPnP port forwarding. The original UPnP state will be + * restored when the test dialog is closed. */ + UPNPTestDialog(quint16 orPort, quint16 dirPort, QWidget *parent = 0); + +signals: + /** Emitted when the user clicks the 'Help' button requesting the help topic + * on port forwarding. */ + void help(); + +protected slots: + /** Shows or hides the dialog based on visible. The UPnP test will be + * started when the dialog is first shown. */ + void setVisible(bool visible); + + /** Called when a user clicks on a button in the dialog's button box. If + * Retry is clicked, another UPnP test will be conducted. If Close is clicked, + * then the dialog is closed and the original UPnP state restored. */ + void clicked(QAbstractButton *button); + + /** Updates the test UI based on the UPnP state. */ + void upnpStateChanged(UPNPControl::UPNPState state); + + /** Updates the progress bar to indicate the device discovery portion of the + * test is still in progress. */ + void discoverTimeout(); + +protected: + /** Initiates a UPnP test. */ + void startTest(); + + /** Called when the UPnP test successfully enables port forwarding. Enables + * the Close button, allowing the user to exit the test dialog. */ + void testSuccessful(); + + /** Called when the UPnP test fails due to an error. Enables the Close and + * Retry buttons, allowing the user to either rerun the test or give up. */ + void testFailed(); + +private: + /** Pointer to the UPNPControl singleton instance. */ + UPNPControl *_upnp; + + /** Timer used to update the progress bar while during the device discovery + * portion of the test. */ + QTimer _discoverTimer; + + quint16 _oldOrPort; /**< Original (pre-test) forwarded ORPort. */ + quint16 _oldDirPort; /**< Original (pre-test) forwarded DirPort. */ + quint16 _orPort; /**< ORPort used during the test. */ + quint16 _dirPort; /**< DirPort used during the test. */ + + Ui::UPNPTestDialog ui; +}; + +#endif + diff -Nru vidalia-0.1.13/src/vidalia/config/upnptestdialog.ui vidalia-0.2.8/src/vidalia/config/upnptestdialog.ui --- vidalia-0.1.13/src/vidalia/config/upnptestdialog.ui 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/upnptestdialog.ui 1970-01-01 01:00:00.000000000 +0100 @@ -1,100 +0,0 @@ - - UPNPTestDialog - - - - 0 - 0 - 389 - 150 - - - - Testing UPnP Support - - - :/images/48x48/modem.png - - - true - - - - - 30 - 110 - 341 - 32 - - - - Qt::Horizontal - - - QDialogButtonBox::Close|QDialogButtonBox::Retry - - - false - - - - - - 20 - 60 - 351 - 23 - - - - 24 - - - - - - 20 - 10 - 51 - 48 - - - - - - - :/images/48x48/modem.png - - - - - - 20 - 90 - 351 - 20 - - - - Qt::Horizontal - - - - - - 80 - 30 - 291 - 16 - - - - Testing Universal Plug & Play Support - - - - - - - - diff -Nru vidalia-0.1.13/src/vidalia/config/UPNPTestDialog.ui vidalia-0.2.8/src/vidalia/config/UPNPTestDialog.ui --- vidalia-0.1.13/src/vidalia/config/UPNPTestDialog.ui 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/UPNPTestDialog.ui 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,100 @@ + + UPNPTestDialog + + + + 0 + 0 + 389 + 150 + + + + Testing UPnP Support + + + :/images/48x48/modem.png + + + true + + + + + 30 + 110 + 341 + 32 + + + + Qt::Horizontal + + + QDialogButtonBox::Close|QDialogButtonBox::Retry + + + false + + + + + + 20 + 60 + 351 + 23 + + + + 24 + + + + + + 20 + 10 + 51 + 48 + + + + + + + :/images/48x48/modem.png + + + + + + 20 + 90 + 351 + 20 + + + + Qt::Horizontal + + + + + + 80 + 30 + 291 + 16 + + + + Testing Universal Plug & Play Support + + + + + + + + diff -Nru vidalia-0.1.13/src/vidalia/config/vidaliasettings.cpp vidalia-0.2.8/src/vidalia/config/vidaliasettings.cpp --- vidalia-0.1.13/src/vidalia/config/vidaliasettings.cpp 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/vidaliasettings.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,265 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 vidaliasettings.cpp -** \version $Id: vidaliasettings.cpp 3511 2009-02-05 00:56:16Z edmanm $ -** \brief General Vidalia settings, such as language and interface style -*/ - -#include -#include -#include -#include -#include - -#include "vidaliasettings.h" - -#if defined(Q_WS_WIN) -#include -#endif - -#define SETTING_LANGUAGE "LanguageCode" -#define SETTING_STYLE "InterfaceStyle" -#define SETTING_RUN_TOR_AT_START "RunTorAtStart" -#define SETTING_DATA_DIRECTORY "DataDirectory" -#define SETTING_SHOW_MAINWINDOW_AT_START "ShowMainWindowAtStart" -#define SETTING_BROWSER_EXECUTABLE "BrowserExecutable" -#define SETTING_BROWSER_DIRECTORY "BrowserDirectory" -#define SETTING_IM_EXECUTABLE "IMExecutable" -#define SETTING_RUN_PROXY_AT_START "RunProxyAtStart" -#define SETTING_PROXY_EXECUTABLE "ProxyExecutable" -#define SETTING_PROXY_EXECUTABLE_ARGUMENTS "ProxyExecutableArguments" - -#if defined(Q_OS_WIN32) -#define STARTUP_REG_KEY "Software\\Microsoft\\Windows\\CurrentVersion\\Run" -#define VIDALIA_REG_KEY "Vidalia" -#endif - - -/** Default Constructor */ -VidaliaSettings::VidaliaSettings() -{ -#if defined(Q_WS_MAC) - setDefault(SETTING_STYLE, "macintosh (aqua)"); -#else - static QStringList styles = QStyleFactory::keys(); -#if defined(Q_WS_WIN) - if (styles.contains("windowsvista", Qt::CaseInsensitive)) - setDefault(SETTING_STYLE, "windowsvista"); - else -#endif - { - if (styles.contains("cleanlooks", Qt::CaseInsensitive)) - setDefault(SETTING_STYLE, "cleanlooks"); - else - setDefault(SETTING_STYLE, "plastique"); - } -#endif - - setDefault(SETTING_LANGUAGE, LanguageSupport::defaultLanguageCode()); - setDefault(SETTING_RUN_TOR_AT_START, true); - setDefault(SETTING_SHOW_MAINWINDOW_AT_START, true); - setDefault(SETTING_BROWSER_EXECUTABLE, ""); - setDefault(SETTING_IM_EXECUTABLE, ""); - setDefault(SETTING_RUN_PROXY_AT_START, false); - setDefault(SETTING_PROXY_EXECUTABLE, ""); - setDefault(SETTING_PROXY_EXECUTABLE_ARGUMENTS, QStringList()); -} - -/** Gets the currently preferred language code for Vidalia. */ -QString -VidaliaSettings::getLanguageCode() -{ - return value(SETTING_LANGUAGE).toString(); -} - -/** Sets the preferred language code. */ -void -VidaliaSettings::setLanguageCode(QString languageCode) -{ - setValue(SETTING_LANGUAGE, languageCode); -} - -/** Gets the interface style key (e.g., "windows", "motif", etc.) */ -QString -VidaliaSettings::getInterfaceStyle() -{ - return value(SETTING_STYLE).toString(); -} - -/** Sets the interface style key. */ -void -VidaliaSettings::setInterfaceStyle(QString styleKey) -{ - setValue(SETTING_STYLE, styleKey); -} - -/** Returns true if Tor is to be run when Vidalia starts. */ -bool -VidaliaSettings::runTorAtStart() -{ - return value(SETTING_RUN_TOR_AT_START).toBool(); -} - -/** If run is set to true, then Tor will be run when Vidalia starts. */ -void -VidaliaSettings::setRunTorAtStart(bool run) -{ - setValue(SETTING_RUN_TOR_AT_START, run); -} - -/** Returns true if Vidalia's main window should be visible when the - * application starts. */ -bool -VidaliaSettings::showMainWindowAtStart() -{ - return value(SETTING_SHOW_MAINWINDOW_AT_START).toBool(); -} - -/** Sets whether to show Vidalia's main window when the application starts. */ -void -VidaliaSettings::setShowMainWindowAtStart(bool show) -{ - setValue(SETTING_SHOW_MAINWINDOW_AT_START, show); -} - - -/** Returns true if Vidalia is set to run on system boot. */ -bool -VidaliaSettings::runVidaliaOnBoot() -{ -#if defined(Q_WS_WIN) - if (!win32_registry_get_key_value(STARTUP_REG_KEY, VIDALIA_REG_KEY).isEmpty()) { - return true; - } else { - return false; - } -#else - /* Platforms other than windows aren't supported yet */ - return false; -#endif -} - -/** If run is set to true, then Vidalia will run on system boot. */ -void -VidaliaSettings::setRunVidaliaOnBoot(bool run) -{ -#if defined(Q_WS_WIN) - if (run) { - win32_registry_set_key_value(STARTUP_REG_KEY, VIDALIA_REG_KEY, - QString("\"" + - QDir::convertSeparators(QCoreApplication::applicationFilePath())) + - "\""); - } else { - win32_registry_remove_key(STARTUP_REG_KEY, VIDALIA_REG_KEY); - } -#else - /* Platforms othe rthan windows aren't supported yet */ - Q_UNUSED(run); - return; -#endif -} - -/** If browserDirectory is empty, returns a fully-qualified path to - * the web browser, including the executable name. If browserDirectory - * is set, then returns the basename of the configured web browser */ -QString -VidaliaSettings::getBrowserExecutable() const -{ - return QDir::convertSeparators(value(SETTING_BROWSER_EXECUTABLE).toString()); -} - -/** Sets the location and name of the web browser executable to the given string. - * If set to the empty string, the browser will not be started. */ -void -VidaliaSettings::setBrowserExecutable(const QString &browserExecutable) -{ - setValue(SETTING_BROWSER_EXECUTABLE, browserExecutable); -} - -/** Returns a fully-qualified path to the web browser directory */ -QString -VidaliaSettings::getBrowserDirectory() const -{ - return QDir::convertSeparators(value(SETTING_BROWSER_DIRECTORY).toString()); -} - -/** Sets the location and name of the web browser directory to the given string. - * If set to the empty string, the browser will not be started. */ -void -VidaliaSettings::setBrowserDirectory(const QString &browserDirectory) -{ - setValue(SETTING_BROWSER_DIRECTORY, browserDirectory); -} - -/** Returns a fully-qualified path to the IM client, including the - * executable name. */ -QString -VidaliaSettings::getIMExecutable() const -{ - return QDir::convertSeparators(value(SETTING_IM_EXECUTABLE).toString()); -} - -/** Sets the location and name of the IM client executable to the given string. - * If set to the empty string, the client will not be started. */ -void -VidaliaSettings::setIMExecutable(const QString &IMExecutable) -{ - setValue(SETTING_IM_EXECUTABLE, IMExecutable); -} - -/** Returns true if Vidalia should start a proxy application when it - * starts. */ -bool -VidaliaSettings::runProxyAtStart() -{ - return value(SETTING_RUN_PROXY_AT_START).toBool(); -} - -/** Set whether to run a proxy application when Vidalia starts. */ -void -VidaliaSettings::setRunProxyAtStart(bool run) -{ - setValue(SETTING_RUN_PROXY_AT_START, run); -} - -/** Returns a fully-qualified path to the proxy server, including the - * executable name. */ -QString -VidaliaSettings::getProxyExecutable() const -{ - return QDir::convertSeparators(value(SETTING_PROXY_EXECUTABLE).toString()); -} - -/** Sets the location and name of the proxy server executable to the given - * string. If set to the empty string, the proxy will not be started. */ -void -VidaliaSettings::setProxyExecutable(const QString &proxyExecutable) -{ - setValue(SETTING_PROXY_EXECUTABLE, proxyExecutable); -} - -/** Returns a list containing additional command line arguments to be passed - * to ProxyExecutable */ -QStringList -VidaliaSettings::getProxyExecutableArguments() const -{ - return value(SETTING_PROXY_EXECUTABLE_ARGUMENTS).toStringList(); -} - -/** Sets the additional arguments to be passed to Proxy Executable */ -void -VidaliaSettings::setProxyExecutableArguments(const QStringList - &proxyExecutableArguments) -{ - setValue(SETTING_PROXY_EXECUTABLE_ARGUMENTS, proxyExecutableArguments); -} - diff -Nru vidalia-0.1.13/src/vidalia/config/VidaliaSettings.cpp vidalia-0.2.8/src/vidalia/config/VidaliaSettings.cpp --- vidalia-0.1.13/src/vidalia/config/VidaliaSettings.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/VidaliaSettings.cpp 2009-09-24 03:28:18.000000000 +0100 @@ -0,0 +1,296 @@ +/* +** 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.vidalia-project.net/. 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 VidaliaSettings.cpp +** \version $Id: VidaliaSettings.cpp 4132 2009-09-24 02:28:18Z edmanm $ +** \brief General Vidalia settings, such as language and interface style +*/ + +#include "VidaliaSettings.h" +#include "LanguageSupport.h" +#include "Vidalia.h" +#if defined(Q_WS_WIN) +#include "win32.h" +#endif + +#include +#include +#include + +#define SETTING_LANGUAGE "LanguageCode" +#define SETTING_STYLE "InterfaceStyle" +#define SETTING_RUN_TOR_AT_START "RunTorAtStart" +#define SETTING_DATA_DIRECTORY "DataDirectory" +#define SETTING_SHOW_MAINWINDOW_AT_START "ShowMainWindowAtStart" +#define SETTING_BROWSER_EXECUTABLE "BrowserExecutable" +#define SETTING_BROWSER_DIRECTORY "BrowserDirectory" +#define SETTING_IM_EXECUTABLE "IMExecutable" +#define SETTING_RUN_PROXY_AT_START "RunProxyAtStart" +#define SETTING_PROXY_EXECUTABLE "ProxyExecutable" +#define SETTING_PROXY_EXECUTABLE_ARGUMENTS "ProxyExecutableArguments" +#define SETTING_CHECK_FOR_UPDATES "CheckForUpdates" +#define SETTING_LAST_UPDATE_CHECK "LastUpdateCheck" + +#if defined(Q_OS_WIN32) +#define STARTUP_REG_KEY "Software\\Microsoft\\Windows\\CurrentVersion\\Run" +#define VIDALIA_REG_KEY "Vidalia" +#endif + + +/** Default Constructor */ +VidaliaSettings::VidaliaSettings() +{ +#if defined(Q_WS_MAC) + setDefault(SETTING_STYLE, "macintosh (aqua)"); +#else + static QStringList styles = QStyleFactory::keys(); +#if defined(Q_WS_WIN) + if (styles.contains("windowsvista", Qt::CaseInsensitive)) + setDefault(SETTING_STYLE, "windowsvista"); + else +#endif + { + if (styles.contains("cleanlooks", Qt::CaseInsensitive)) + setDefault(SETTING_STYLE, "cleanlooks"); + else + setDefault(SETTING_STYLE, "plastique"); + } +#endif + + setDefault(SETTING_LANGUAGE, LanguageSupport::defaultLanguageCode()); + setDefault(SETTING_RUN_TOR_AT_START, true); + setDefault(SETTING_SHOW_MAINWINDOW_AT_START, true); + setDefault(SETTING_BROWSER_EXECUTABLE, ""); + setDefault(SETTING_IM_EXECUTABLE, ""); + setDefault(SETTING_RUN_PROXY_AT_START, false); + setDefault(SETTING_PROXY_EXECUTABLE, ""); + setDefault(SETTING_PROXY_EXECUTABLE_ARGUMENTS, QString()); +#if defined(Q_WS_WIN) + setDefault(SETTING_CHECK_FOR_UPDATES, true); +#else + setDefault(SETTING_CHECK_FOR_UPDATES, false); +#endif + setDefault(SETTING_LAST_UPDATE_CHECK, QDateTime()); +} + +/** Gets the currently preferred language code for Vidalia. */ +QString +VidaliaSettings::getLanguageCode() +{ + return value(SETTING_LANGUAGE).toString(); +} + +/** Sets the preferred language code. */ +void +VidaliaSettings::setLanguageCode(QString languageCode) +{ + setValue(SETTING_LANGUAGE, languageCode); +} + +/** Gets the interface style key (e.g., "windows", "motif", etc.) */ +QString +VidaliaSettings::getInterfaceStyle() +{ + return value(SETTING_STYLE).toString(); +} + +/** Sets the interface style key. */ +void +VidaliaSettings::setInterfaceStyle(QString styleKey) +{ + setValue(SETTING_STYLE, styleKey); +} + +/** Returns true if Tor is to be run when Vidalia starts. */ +bool +VidaliaSettings::runTorAtStart() +{ + return value(SETTING_RUN_TOR_AT_START).toBool(); +} + +/** If run is set to true, then Tor will be run when Vidalia starts. */ +void +VidaliaSettings::setRunTorAtStart(bool run) +{ + setValue(SETTING_RUN_TOR_AT_START, run); +} + +/** Returns true if Vidalia's main window should be visible when the + * application starts. */ +bool +VidaliaSettings::showMainWindowAtStart() +{ + return value(SETTING_SHOW_MAINWINDOW_AT_START).toBool(); +} + +/** Sets whether to show Vidalia's main window when the application starts. */ +void +VidaliaSettings::setShowMainWindowAtStart(bool show) +{ + setValue(SETTING_SHOW_MAINWINDOW_AT_START, show); +} + + +/** Returns true if Vidalia is set to run on system boot. */ +bool +VidaliaSettings::runVidaliaOnBoot() +{ +#if defined(Q_WS_WIN) + if (!win32_registry_get_key_value(STARTUP_REG_KEY, VIDALIA_REG_KEY).isEmpty()) { + return true; + } else { + return false; + } +#else + /* Platforms other than windows aren't supported yet */ + return false; +#endif +} + +/** If run is set to true, then Vidalia will run on system boot. */ +void +VidaliaSettings::setRunVidaliaOnBoot(bool run) +{ +#if defined(Q_WS_WIN) + if (run) { + win32_registry_set_key_value(STARTUP_REG_KEY, VIDALIA_REG_KEY, + QString("\"" + + QDir::convertSeparators(QCoreApplication::applicationFilePath())) + + "\""); + } else { + win32_registry_remove_key(STARTUP_REG_KEY, VIDALIA_REG_KEY); + } +#else + /* Platforms othe rthan windows aren't supported yet */ + Q_UNUSED(run); + return; +#endif +} + +/** If browserDirectory is empty, returns a fully-qualified path to + * the web browser, including the executable name. If browserDirectory + * is set, then returns the basename of the configured web browser */ +QString +VidaliaSettings::getBrowserExecutable() const +{ + return QDir::convertSeparators(value(SETTING_BROWSER_EXECUTABLE).toString()); +} + +/** Sets the location and name of the web browser executable to the given string. + * If set to the empty string, the browser will not be started. */ +void +VidaliaSettings::setBrowserExecutable(const QString &browserExecutable) +{ + setValue(SETTING_BROWSER_EXECUTABLE, browserExecutable); +} + +/** Returns a fully-qualified path to the web browser directory */ +QString +VidaliaSettings::getBrowserDirectory() const +{ + return QDir::convertSeparators(value(SETTING_BROWSER_DIRECTORY).toString()); +} + +/** Sets the location and name of the web browser directory to the given string. + * If set to the empty string, the browser will not be started. */ +void +VidaliaSettings::setBrowserDirectory(const QString &browserDirectory) +{ + setValue(SETTING_BROWSER_DIRECTORY, browserDirectory); +} + +/** Returns a fully-qualified path to the IM client, including the + * executable name. */ +QString +VidaliaSettings::getIMExecutable() const +{ + return QDir::convertSeparators(value(SETTING_IM_EXECUTABLE).toString()); +} + +/** Sets the location and name of the IM client executable to the given string. + * If set to the empty string, the client will not be started. */ +void +VidaliaSettings::setIMExecutable(const QString &IMExecutable) +{ + setValue(SETTING_IM_EXECUTABLE, IMExecutable); +} + +/** Returns true if Vidalia should start a proxy application when it + * starts. */ +bool +VidaliaSettings::runProxyAtStart() +{ + return value(SETTING_RUN_PROXY_AT_START).toBool(); +} + +/** Set whether to run a proxy application when Vidalia starts. */ +void +VidaliaSettings::setRunProxyAtStart(bool run) +{ + setValue(SETTING_RUN_PROXY_AT_START, run); +} + +/** Returns a fully-qualified path to the proxy server, including the + * executable name. */ +QString +VidaliaSettings::getProxyExecutable() const +{ + return QDir::convertSeparators(value(SETTING_PROXY_EXECUTABLE).toString()); +} + +/** Sets the location and name of the proxy server executable to the given + * string. If set to the empty string, the proxy will not be started. */ +void +VidaliaSettings::setProxyExecutable(const QString &proxyExecutable) +{ + setValue(SETTING_PROXY_EXECUTABLE, proxyExecutable); +} + +/** Returns a string containing additional command line arguments to be passed + * to ProxyExecutable */ +QString +VidaliaSettings::getProxyExecutableArguments() const +{ + return value(SETTING_PROXY_EXECUTABLE_ARGUMENTS).toString(); +} + +/** Sets the additional arguments to be passed to Proxy Executable */ +void +VidaliaSettings::setProxyExecutableArguments(const QString + &proxyExecutableArguments) +{ + setValue(SETTING_PROXY_EXECUTABLE_ARGUMENTS, proxyExecutableArguments); +} + +bool +VidaliaSettings::isAutoUpdateEnabled() const +{ + return value(SETTING_CHECK_FOR_UPDATES).toBool(); +} + +void +VidaliaSettings::setAutoUpdateEnabled(bool enabled) +{ + setValue(SETTING_CHECK_FOR_UPDATES, enabled); +} + +QDateTime +VidaliaSettings::lastCheckedForUpdates() const +{ + return value(SETTING_LAST_UPDATE_CHECK).toDateTime(); +} + +void +VidaliaSettings::setLastCheckedForUpdates(const QDateTime &checkedAt) +{ + setValue(SETTING_LAST_UPDATE_CHECK, checkedAt); +} + diff -Nru vidalia-0.1.13/src/vidalia/config/vidaliasettings.h vidalia-0.2.8/src/vidalia/config/vidaliasettings.h --- vidalia-0.1.13/src/vidalia/config/vidaliasettings.h 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/vidaliasettings.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,106 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 vidaliasettings.h -** \version $Id: vidaliasettings.h 3511 2009-02-05 00:56:16Z edmanm $ -** \brief General Vidalia settings, such as language and interface style -*/ - -#ifndef _VIDALIASETTINGS_H -#define _VIDALIASETTINGS_H - -#include "vsettings.h" - - -/** Handles saving and restoring Vidalia's settings, such as the - * location of Tor, the control port, etc. - * - * NOTE: Qt 4.1 documentation states that constructing a QSettings object is - * "very fast", so we shouldn't need to create a global instance of this - * class. - */ -class VidaliaSettings : public VSettings -{ - Q_OBJECT - -public: - /** Default constructor. */ - VidaliaSettings(); - - /** Gets the currently preferred language code for Vidalia. */ - QString getLanguageCode(); - /** Saves the preferred language code. */ - void setLanguageCode(QString languageCode); - - /** Gets the interface style key (e.g., "windows", "motif", etc.) */ - QString getInterfaceStyle(); - /** Sets the interface style key. */ - void setInterfaceStyle(QString styleKey); - - /** Returns true if Vidalia should start Tor when it starts. */ - bool runTorAtStart(); - /** Set whether to run Tor when Vidalia starts. */ - void setRunTorAtStart(bool run); - - /** Returns true if Vidalia's main window should be visible when the - * application starts. */ - bool showMainWindowAtStart(); - /** Sets whether to show Vidalia's main window when the application starts. */ - void setShowMainWindowAtStart(bool show); - - /** Returns true if Vidalia should start on system boot. */ - bool runVidaliaOnBoot(); - /** Set whether to run Vidalia on system boot. */ - void setRunVidaliaOnBoot(bool run); - - /** If browserDirectory is empty, returns a fully-qualified path to - * the web browser, including the executable name. If browserDirectory - * is set, then returns the basename of the configured web browser */ - QString getBrowserExecutable() const; - /** Sets the location and name of the web browser executable to the given - * string. If set to the empty string, the browser will not be started. */ - void setBrowserExecutable(const QString &browserExecutable); - - /** Returns a fully-qualified path to the web browser directory */ - QString getBrowserDirectory() const; - /** Sets the location and name of the web browser directory to the given string. - * If set to the empty string, the browser will not be started. */ - void setBrowserDirectory(const QString &browserDirectory); - - /** Returns a fully-qualified path to the IM client, including the - * executable name. */ - QString getIMExecutable() const; - /** Sets the location and name of the IM client executable to the given - * string. If set to the empty string, the client will not be started. */ - void setIMExecutable(const QString &IMExecutable); - - /** Returns true if Vidalia should start a proxy application when it - * starts. */ - bool runProxyAtStart(); - /** Set whether to run a proxy application when Vidalia starts. */ - void setRunProxyAtStart(bool run); - - /** Returns a fully-qualified path to the proxy server, including the - * executable name. */ - QString getProxyExecutable() const; - /** Sets the location and name of the proxy server executable to the given - * string. If set to the empty string, the proxy will not be started. */ - void setProxyExecutable(const QString &proxyExecutable); - - /** Returns a list containing additional command line arguments to be - * passed to ProxyExecutable */ - QStringList getProxyExecutableArguments() const; - /** Sets the additional arguments to be passed to Proxy Executable */ - void setProxyExecutableArguments(const QStringList &proxyExecutableArguments); -}; - -#endif - diff -Nru vidalia-0.1.13/src/vidalia/config/VidaliaSettings.h vidalia-0.2.8/src/vidalia/config/VidaliaSettings.h --- vidalia-0.1.13/src/vidalia/config/VidaliaSettings.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/VidaliaSettings.h 2009-09-24 03:28:18.000000000 +0100 @@ -0,0 +1,121 @@ +/* +** 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.vidalia-project.net/. 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 VidaliaSettings.h +** \version $Id: VidaliaSettings.h 4132 2009-09-24 02:28:18Z edmanm $ +** \brief General Vidalia settings, such as language and interface style +*/ + +#ifndef _VIDALIASETTINGS_H +#define _VIDALIASETTINGS_H + +#include "VSettings.h" + +#include + + +/** Handles saving and restoring Vidalia's settings, such as the + * location of Tor, the control port, etc. + * + * NOTE: Qt 4.1 documentation states that constructing a QSettings object is + * "very fast", so we shouldn't need to create a global instance of this + * class. + */ +class VidaliaSettings : public VSettings +{ + Q_OBJECT + +public: + /** Default constructor. */ + VidaliaSettings(); + + /** Gets the currently preferred language code for Vidalia. */ + QString getLanguageCode(); + /** Saves the preferred language code. */ + void setLanguageCode(QString languageCode); + + /** Gets the interface style key (e.g., "windows", "motif", etc.) */ + QString getInterfaceStyle(); + /** Sets the interface style key. */ + void setInterfaceStyle(QString styleKey); + + /** Returns true if Vidalia should start Tor when it starts. */ + bool runTorAtStart(); + /** Set whether to run Tor when Vidalia starts. */ + void setRunTorAtStart(bool run); + + /** Returns true if Vidalia's main window should be visible when the + * application starts. */ + bool showMainWindowAtStart(); + /** Sets whether to show Vidalia's main window when the application starts. */ + void setShowMainWindowAtStart(bool show); + + /** Returns true if Vidalia should start on system boot. */ + bool runVidaliaOnBoot(); + /** Set whether to run Vidalia on system boot. */ + void setRunVidaliaOnBoot(bool run); + + /** If browserDirectory is empty, returns a fully-qualified path to + * the web browser, including the executable name. If browserDirectory + * is set, then returns the basename of the configured web browser */ + QString getBrowserExecutable() const; + /** Sets the location and name of the web browser executable to the given + * string. If set to the empty string, the browser will not be started. */ + void setBrowserExecutable(const QString &browserExecutable); + + /** Returns a fully-qualified path to the web browser directory */ + QString getBrowserDirectory() const; + /** Sets the location and name of the web browser directory to the given string. + * If set to the empty string, the browser will not be started. */ + void setBrowserDirectory(const QString &browserDirectory); + + /** Returns a fully-qualified path to the IM client, including the + * executable name. */ + QString getIMExecutable() const; + /** Sets the location and name of the IM client executable to the given + * string. If set to the empty string, the client will not be started. */ + void setIMExecutable(const QString &IMExecutable); + + /** Returns true if Vidalia should start a proxy application when it + * starts. */ + bool runProxyAtStart(); + /** Set whether to run a proxy application when Vidalia starts. */ + void setRunProxyAtStart(bool run); + + /** Returns a fully-qualified path to the proxy server, including the + * executable name. */ + QString getProxyExecutable() const; + /** Sets the location and name of the proxy server executable to the given + * string. If set to the empty string, the proxy will not be started. */ + void setProxyExecutable(const QString &proxyExecutable); + + /** Returns a list containing additional command line arguments to be + * passed to ProxyExecutable */ + QString getProxyExecutableArguments() const; + /** Sets the additional arguments to be passed to Proxy Executable */ + void setProxyExecutableArguments(const QString &proxyExecutableArguments); + + /** Returns true if Vidalia should automatically check for software updates. + */ + bool isAutoUpdateEnabled() const; + /** Sets to enabled whether Vidalia should automatically check for + * software updates or not. */ + void setAutoUpdateEnabled(bool enabled); + + /** Returns the time at which Vidalia last checked for software updates. */ + QDateTime lastCheckedForUpdates() const; + /** Sets to checkedAt the time at which Vidalia last checked for + * available software updates. */ + void setLastCheckedForUpdates(const QDateTime &checkedAt); +}; + +#endif + diff -Nru vidalia-0.1.13/src/vidalia/config/vsettings.cpp vidalia-0.2.8/src/vidalia/config/vsettings.cpp --- vidalia-0.1.13/src/vidalia/config/vsettings.cpp 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/vsettings.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,90 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 vsettings.cpp -** \version $Id: vsettings.cpp 2362 2008-02-29 04:30:11Z edmanm $ -** \brief Stores and retrieves settings from Vidalia's configuration file. -*/ - -#include - -#include "vsettings.h" - -/** The file in which all settings will read and written. */ -#define SETTINGS_FILE (Vidalia::dataDirectory() + "/vidalia.conf") - - -/** Constructor */ -VSettings::VSettings(const QString settingsGroup) -: QSettings(SETTINGS_FILE, QSettings::IniFormat) -{ - if (!settingsGroup.isEmpty()) - beginGroup(settingsGroup); -} - -/** Returns the saved value associated with key. If no value has been - * set, the default value is returned. - * \sa setDefault - */ -QVariant -VSettings::value(const QString &key, const QVariant &defaultVal) const -{ - return QSettings::value(key, defaultVal.isNull() ? defaultValue(key) - : defaultVal); -} - -/** Sets the value associated with key to val. */ -void -VSettings::setValue(const QString &key, const QVariant &val) -{ - if (val == defaultValue(key)) - QSettings::remove(key); - else if (val != value(key)) - QSettings::setValue(key, val); -} - -/** Sets the default setting for key to val. */ -void -VSettings::setDefault(const QString &key, const QVariant &val) -{ - _defaults.insert(key, val); -} - -/** Returns the default setting value associated with key. If - * key has no default value, then an empty QVariant is returned. */ -QVariant -VSettings::defaultValue(const QString &key) const -{ - if (_defaults.contains(key)) - return _defaults.value(key); - return QVariant(); -} - -/** Resets all of Vidalia's settings. */ -void -VSettings::reset() -{ - /* Static method, so we have to create a QSettings object. */ - QSettings settings(SETTINGS_FILE, QSettings::IniFormat); - settings.clear(); -} - -/** Returns a map of all currently saved settings at the last appyl() point. */ -QMap -VSettings::allSettings() const -{ - QMap settings; - foreach (QString key, allKeys()) { - settings.insert(key, value(key)); - } - return settings; -} - diff -Nru vidalia-0.1.13/src/vidalia/config/VSettings.cpp vidalia-0.2.8/src/vidalia/config/VSettings.cpp --- vidalia-0.1.13/src/vidalia/config/VSettings.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/VSettings.cpp 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,106 @@ +/* +** 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.vidalia-project.net/. 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 VSettings.cpp +** \version $Id: VSettings.cpp 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Stores and retrieves settings from Vidalia's configuration file. +*/ + +#include "VSettings.h" +#include "Vidalia.h" + +#include + +/** The file in which all settings will read and written. */ +#define SETTINGS_FILE (Vidalia::dataDirectory() + "/vidalia.conf") + + +/** Constructor */ +VSettings::VSettings(const QString settingsGroup) +: QSettings(SETTINGS_FILE, QSettings::IniFormat) +{ + if (!settingsGroup.isEmpty()) + beginGroup(settingsGroup); +} + +/** Returns the location of Vidalia's configuration settings file. */ +QString +VSettings::settingsFile() +{ + return SETTINGS_FILE; +} + +/** Returns true if Vidalia's configuration settings file already exists. */ +bool +VSettings::settingsFileExists() +{ + QFileInfo fi(settingsFile()); + return fi.exists(); +} + +/** Returns the saved value associated with key. If no value has been + * set, the default value is returned. + * \sa setDefault + */ +QVariant +VSettings::value(const QString &key, const QVariant &defaultVal) const +{ + return QSettings::value(key, defaultVal.isNull() ? defaultValue(key) + : defaultVal); +} + +/** Sets the value associated with key to val. */ +void +VSettings::setValue(const QString &key, const QVariant &val) +{ + if (val == defaultValue(key)) + QSettings::remove(key); + else if (val != value(key)) + QSettings::setValue(key, val); +} + +/** Sets the default setting for key to val. */ +void +VSettings::setDefault(const QString &key, const QVariant &val) +{ + _defaults.insert(key, val); +} + +/** Returns the default setting value associated with key. If + * key has no default value, then an empty QVariant is returned. */ +QVariant +VSettings::defaultValue(const QString &key) const +{ + if (_defaults.contains(key)) + return _defaults.value(key); + return QVariant(); +} + +/** Resets all of Vidalia's settings. */ +void +VSettings::reset() +{ + /* Static method, so we have to create a QSettings object. */ + QSettings settings(SETTINGS_FILE, QSettings::IniFormat); + settings.clear(); +} + +/** Returns a map of all currently saved settings at the last appyl() point. */ +QMap +VSettings::allSettings() const +{ + QMap settings; + foreach (QString key, allKeys()) { + settings.insert(key, value(key)); + } + return settings; +} + diff -Nru vidalia-0.1.13/src/vidalia/config/vsettings.h vidalia-0.2.8/src/vidalia/config/vsettings.h --- vidalia-0.1.13/src/vidalia/config/vsettings.h 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/vsettings.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,62 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 vsettings.h -** \version $Id: vsettings.h 2362 2008-02-29 04:30:11Z edmanm $ -** \brief Stores and retrieves settings from Vidalia's configuration file. -*/ - -#ifndef _VSETTINGS_H -#define _VSETTINGS_H - -#include -#include - - -class VSettings : public QSettings -{ - Q_OBJECT - -public: - /** Default constructor. The optional parameter group can be used to - * set a prefix that will be prepended to keys specified to VSettings in - * value() and setValue(). */ - VSettings(const QString group = QString()); - - /** Resets all of Vidalia's settings. */ - static void reset(); - - /** Returns the saved value associated with key. If no value has been - * set, the default value is returned. - * \sa setDefault - */ - virtual QVariant value(const QString &key, - const QVariant &defaultVal = QVariant()) const; - /** Sets the value associated with key to val. */ - virtual void setValue(const QString &key, const QVariant &val); - -protected: - /** Sets the default setting for key to val. */ - void setDefault(const QString &key, const QVariant &val); - /** Returns the default setting value associated with key. If - * key has no default value, then an empty QVariant is returned. */ - QVariant defaultValue(const QString &key) const; - /** Returns a map of all currently saved settings at the last apply() - * point. */ - QMap allSettings() const; - -private: - /** Association of setting key names to default setting values. */ - QHash _defaults; -}; - -#endif - diff -Nru vidalia-0.1.13/src/vidalia/config/VSettings.h vidalia-0.2.8/src/vidalia/config/VSettings.h --- vidalia-0.1.13/src/vidalia/config/VSettings.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/config/VSettings.h 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,67 @@ +/* +** 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.vidalia-project.net/. 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 vsettings.h +** \version $Id: VSettings.h 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Stores and retrieves settings from Vidalia's configuration file. +*/ + +#ifndef _VSETTINGS_H +#define _VSETTINGS_H + +#include +#include + + +class VSettings : public QSettings +{ + Q_OBJECT + +public: + /** Default constructor. The optional parameter group can be used to + * set a prefix that will be prepended to keys specified to VSettings in + * value() and setValue(). */ + VSettings(const QString group = QString()); + + /** Returns the location of Vidalia's configuration settings file. */ + static QString settingsFile(); + /** Returns true if Vidalia's configuration settings file already exists. */ + static bool settingsFileExists(); + + /** Resets all of Vidalia's settings. */ + static void reset(); + + /** Returns the saved value associated with key. If no value has been + * set, the default value is returned. + * \sa setDefault + */ + virtual QVariant value(const QString &key, + const QVariant &defaultVal = QVariant()) const; + /** Sets the value associated with key to val. */ + virtual void setValue(const QString &key, const QVariant &val); + +protected: + /** Sets the default setting for key to val. */ + void setDefault(const QString &key, const QVariant &val); + /** Returns the default setting value associated with key. If + * key has no default value, then an empty QVariant is returned. */ + QVariant defaultValue(const QString &key) const; + /** Returns a map of all currently saved settings at the last apply() + * point. */ + QMap allSettings() const; + +private: + /** Association of setting key names to default setting values. */ + QHash _defaults; +}; + +#endif + diff -Nru vidalia-0.1.13/src/vidalia/controlpasswordinputdialog.cpp vidalia-0.2.8/src/vidalia/controlpasswordinputdialog.cpp --- vidalia-0.1.13/src/vidalia/controlpasswordinputdialog.cpp 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/controlpasswordinputdialog.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,104 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 controlpasswordinputdialog.cpp -** \version $Id: controlpasswordinputdialog.cpp 3276 2008-11-03 00:08:59Z edmanm $ -** \brief Prompts the user to enter their control port password, and gives -** them the option to save or attempt to reset it. -*/ - -#include - -#include "controlpasswordinputdialog.h" - - -ControlPasswordInputDialog::ControlPasswordInputDialog(QWidget *parent) - : QDialog(parent) -{ - ui.setupUi(this); - setSizeGripEnabled(false); - setAttribute(Qt::WA_DeleteOnClose, false); - - ui.buttonBox->setStandardButtons(QDialogButtonBox::Ok - | QDialogButtonBox::Cancel - | QDialogButtonBox::Reset - | QDialogButtonBox::Help); - - connect(ui.buttonBox, SIGNAL(clicked(QAbstractButton*)), - this, SLOT(clicked(QAbstractButton*))); - connect(ui.linePassword, SIGNAL(textEdited(QString)), - this, SLOT(passwordEdited(QString))); - - /* The dialog starts with an empty password field */ - passwordEdited(QString()); -} - -void -ControlPasswordInputDialog::setResetEnabled(bool enabled) -{ - if (enabled) { - ui.buttonBox->setStandardButtons(ui.buttonBox->standardButtons() - | QDialogButtonBox::Reset); - } else { - ui.buttonBox->setStandardButtons(ui.buttonBox->standardButtons() - & ~QDialogButtonBox::Reset); - - } -} - -QString -ControlPasswordInputDialog::password() const -{ - return ui.linePassword->text(); -} - -bool -ControlPasswordInputDialog::isSavePasswordChecked() const -{ - return ui.chkSavePassword->isChecked(); -} - -void -ControlPasswordInputDialog::passwordEdited(const QString &text) -{ - QPushButton *okButton = ui.buttonBox->button(QDialogButtonBox::Ok); - if (okButton) - okButton->setEnabled(! text.isEmpty()); -} - -void -ControlPasswordInputDialog::clicked(QAbstractButton *button) -{ - QDialogButtonBox::StandardButton btn = ui.buttonBox->standardButton(button); - switch (btn) { - case QDialogButtonBox::Ok: - case QDialogButtonBox::Reset: - case QDialogButtonBox::Cancel: - done(btn); - break; - - case QDialogButtonBox::Help: - emit helpRequested("troubleshooting.password"); - break; - - default: - break; - } -} - -void -ControlPasswordInputDialog::setVisible(bool visible) -{ - if (visible) - resize(minimumSizeHint()); - QDialog::setVisible(visible); -} - diff -Nru vidalia-0.1.13/src/vidalia/ControlPasswordInputDialog.cpp vidalia-0.2.8/src/vidalia/ControlPasswordInputDialog.cpp --- vidalia-0.1.13/src/vidalia/ControlPasswordInputDialog.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/ControlPasswordInputDialog.cpp 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,103 @@ +/* +** 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.vidalia-project.net/. 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 ControlPasswordInputDialog.cpp +** \version $Id: ControlPasswordInputDialog.cpp 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Prompts the user to enter their control port password, and gives +** them the option to save or attempt to reset it. +*/ + +#include "ControlPasswordInputDialog.h" + +#include + + +ControlPasswordInputDialog::ControlPasswordInputDialog(QWidget *parent) + : QDialog(parent) +{ + ui.setupUi(this); + setSizeGripEnabled(false); + setAttribute(Qt::WA_DeleteOnClose, false); + + ui.buttonBox->setStandardButtons(QDialogButtonBox::Ok + | QDialogButtonBox::Cancel + | QDialogButtonBox::Reset + | QDialogButtonBox::Help); + + connect(ui.buttonBox, SIGNAL(clicked(QAbstractButton*)), + this, SLOT(clicked(QAbstractButton*))); + connect(ui.linePassword, SIGNAL(textEdited(QString)), + this, SLOT(passwordEdited(QString))); + + /* The dialog starts with an empty password field */ + passwordEdited(QString()); +} + +void +ControlPasswordInputDialog::setResetEnabled(bool enabled) +{ + if (enabled) { + ui.buttonBox->setStandardButtons(ui.buttonBox->standardButtons() + | QDialogButtonBox::Reset); + } else { + ui.buttonBox->setStandardButtons(ui.buttonBox->standardButtons() + & ~QDialogButtonBox::Reset); + } +} + +QString +ControlPasswordInputDialog::password() const +{ + return ui.linePassword->text(); +} + +bool +ControlPasswordInputDialog::isSavePasswordChecked() const +{ + return ui.chkSavePassword->isChecked(); +} + +void +ControlPasswordInputDialog::passwordEdited(const QString &text) +{ + QPushButton *okButton = ui.buttonBox->button(QDialogButtonBox::Ok); + if (okButton) + okButton->setEnabled(! text.isEmpty()); +} + +void +ControlPasswordInputDialog::clicked(QAbstractButton *button) +{ + QDialogButtonBox::StandardButton btn = ui.buttonBox->standardButton(button); + switch (btn) { + case QDialogButtonBox::Ok: + case QDialogButtonBox::Reset: + case QDialogButtonBox::Cancel: + done(btn); + break; + + case QDialogButtonBox::Help: + emit helpRequested("troubleshooting.password"); + break; + + default: + break; + } +} + +void +ControlPasswordInputDialog::setVisible(bool visible) +{ + if (visible) + resize(minimumSizeHint()); + QDialog::setVisible(visible); +} + diff -Nru vidalia-0.1.13/src/vidalia/controlpasswordinputdialog.h vidalia-0.2.8/src/vidalia/controlpasswordinputdialog.h --- vidalia-0.1.13/src/vidalia/controlpasswordinputdialog.h 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/controlpasswordinputdialog.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,78 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 controlpasswordinputdialog.h -** \version $Id: controlpasswordinputdialog.h 3276 2008-11-03 00:08:59Z edmanm $ -** \brief Prompts the user to enter their control port password, and gives -** them the option to save or attempt to reset it. -*/ - -#ifndef _CONTROLPASSWORDINPUTDIALOG_H -#define _CONTROLPASSWORDINPUTDIALOG_H - -#include -#include - -#include "ui_controlpasswordinputdialog.h" - - -class ControlPasswordInputDialog : public QDialog -{ - Q_OBJECT - -public: - /** Default constructor. - */ - ControlPasswordInputDialog(QWidget *parent = 0); - - /** Returns the password entered in the dialog. If the dialog was dismissed - * with the "Cancel" button, then the returned QString will be empty. - */ - QString password() const; - - /** Returns true if the "Remember my password" checkbox was checked at the - * time the dialog was dismissed. - */ - bool isSavePasswordChecked() const; - - /** If enabled is true, then the "Reset" button will be visible on - * the password input dialog. Otherwise, the "Reset" button will be hidden. - */ - void setResetEnabled(bool enabled); - -signals: - /** Emitted when the user clicks on the "Help" dialog button. - */ - void helpRequested(const QString &topic); - -protected slots: - /** Called when one of the QDialogButtonBox's buttons is clicked. The dialog - * is closed if button is the "Ok", "Cancel", or "Reset" button, and - * the clicked button's QDialogButtonBox::StandardButton enum value is - * returned as the dialog's result code. - */ - void clicked(QAbstractButton *button); - - /** Called when the user changes the password QLineEdit. If the password is - * empty, then the "Ok" button will be disabled. Otherwise, it is enabled. - */ - void passwordEdited(const QString &text); - -protected: - /** Adjusts the size of the input dialog when it is displayed. */ - virtual void setVisible(bool visible); - -private: - Ui::ControlPasswordInputDialog ui; /**< Qt Designer generated object. */ -}; - -#endif - diff -Nru vidalia-0.1.13/src/vidalia/ControlPasswordInputDialog.h vidalia-0.2.8/src/vidalia/ControlPasswordInputDialog.h --- vidalia-0.1.13/src/vidalia/ControlPasswordInputDialog.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/ControlPasswordInputDialog.h 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,78 @@ +/* +** 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.vidalia-project.net/. 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 ControlPasswordInputDialog.h +** \version $Id: ControlPasswordInputDialog.h 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Prompts the user to enter their control port password, and gives +** them the option to save or attempt to reset it. +*/ + +#ifndef _CONTROLPASSWORDINPUTDIALOG_H +#define _CONTROLPASSWORDINPUTDIALOG_H + +#include "ui_ControlPasswordInputDialog.h" + +#include +#include + + +class ControlPasswordInputDialog : public QDialog +{ + Q_OBJECT + +public: + /** Default constructor. + */ + ControlPasswordInputDialog(QWidget *parent = 0); + + /** Returns the password entered in the dialog. If the dialog was dismissed + * with the "Cancel" button, then the returned QString will be empty. + */ + QString password() const; + + /** Returns true if the "Remember my password" checkbox was checked at the + * time the dialog was dismissed. + */ + bool isSavePasswordChecked() const; + + /** If enabled is true, then the "Reset" button will be visible on + * the password input dialog. Otherwise, the "Reset" button will be hidden. + */ + void setResetEnabled(bool enabled); + +signals: + /** Emitted when the user clicks on the "Help" dialog button. + */ + void helpRequested(const QString &topic); + +protected slots: + /** Called when one of the QDialogButtonBox's buttons is clicked. The dialog + * is closed if button is the "Ok", "Cancel", or "Reset" button, and + * the clicked button's QDialogButtonBox::StandardButton enum value is + * returned as the dialog's result code. + */ + void clicked(QAbstractButton *button); + + /** Called when the user changes the password QLineEdit. If the password is + * empty, then the "Ok" button will be disabled. Otherwise, it is enabled. + */ + void passwordEdited(const QString &text); + +protected: + /** Adjusts the size of the input dialog when it is displayed. */ + virtual void setVisible(bool visible); + +private: + Ui::ControlPasswordInputDialog ui; /**< Qt Designer generated object. */ +}; + +#endif + diff -Nru vidalia-0.1.13/src/vidalia/controlpasswordinputdialog.ui vidalia-0.2.8/src/vidalia/controlpasswordinputdialog.ui --- vidalia-0.1.13/src/vidalia/controlpasswordinputdialog.ui 2009-05-25 21:48:31.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/controlpasswordinputdialog.ui 1970-01-01 01:00:00.000000000 +0100 @@ -1,128 +0,0 @@ - - ControlPasswordInputDialog - - - Qt::WindowModal - - - - 0 - 0 - 350 - 192 - - - - - 0 - 0 - - - - - 350 - 0 - - - - Password Required - - - - :/images/32x32/dialog-password.png:/images/32x32/dialog-password.png - - - false - - - true - - - - - - QLayout::SetDefaultConstraint - - - - - - 48 - 48 - - - - - - - :/images/48x48/dialog-password.png - - - Qt::AlignHCenter|Qt::AlignTop - - - - - - - - 1 - 1 - - - - - 0 - 0 - - - - Vidalia has connected to a running Tor process that requires a password. Please enter your control password: - - - Qt::PlainText - - - true - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - true - - - - - - - Remember my password - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok|QDialogButtonBox::Reset - - - - - - - QLineEdit::Password - - - - - - - - - - - - diff -Nru vidalia-0.1.13/src/vidalia/ControlPasswordInputDialog.ui vidalia-0.2.8/src/vidalia/ControlPasswordInputDialog.ui --- vidalia-0.1.13/src/vidalia/ControlPasswordInputDialog.ui 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/ControlPasswordInputDialog.ui 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,128 @@ + + ControlPasswordInputDialog + + + Qt::WindowModal + + + + 0 + 0 + 350 + 192 + + + + + 0 + 0 + + + + + 350 + 0 + + + + Password Required + + + + :/images/32x32/dialog-password.png:/images/32x32/dialog-password.png + + + false + + + true + + + + + + QLayout::SetDefaultConstraint + + + + + + 48 + 48 + + + + + + + :/images/48x48/dialog-password.png + + + Qt::AlignHCenter|Qt::AlignTop + + + + + + + + 1 + 1 + + + + + 0 + 0 + + + + Vidalia has connected to a running Tor process that requires a password. Please enter your control password: + + + Qt::PlainText + + + true + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + + + + + Remember my password + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok|QDialogButtonBox::Reset + + + + + + + QLineEdit::Password + + + + + + + + + + + + diff -Nru vidalia-0.1.13/src/vidalia/CrashReporter.cpp vidalia-0.2.8/src/vidalia/CrashReporter.cpp --- vidalia-0.1.13/src/vidalia/CrashReporter.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/CrashReporter.cpp 2009-06-23 23:53:29.000000000 +0100 @@ -0,0 +1,408 @@ +/* +** 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.vidalia-project.net/. No part of Vidalia, including this file, +** may be copied, modified, propagated, or distributed except according to the +** terms described in the LICENSE file. +*/ +/* +** The append_string() function in this file is derived from the implementation +** of strlcat() by Todd C. Miller. It is licensed as follows: +** +** Copyright (c) 1998 Todd C. Miller +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, +** INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY +** AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +** THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +** OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +** OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/* +** \file CrashReporter.h +** \version $Id$ +** \brief General routines to install a Breakpad-based exception handler and +** set options related to launching the crash reporting application. +*/ + +#include "CrashReporter.h" +#include "stringutil.h" + +#if defined(Q_OS_WIN32) +#include +#elif defined(Q_OS_MAC) +#include +#elif defined(Q_OS_LINUX) +#include +#elif defined(Q_OS_SOLARIS) +#include +#endif + +#include +#include +#include +#include + +#include + + +namespace CrashReporter +{ +#if defined(Q_OS_WIN32) +typedef wchar_t _char_t; +typedef HANDLE _file_handle_t; +#define PATH_SEPARATOR TEXT("\\") +# ifdef _USE_32BIT_TIME_T +# define TIME_TO_STRING(buf, buflen, t) \ + _ltoa_s(t, buf, buflen, 10) +# else +# define TIME_TO_STRING(buf, buflen, t) \ + _i64toa_s(t, buf, buflen, 10) +# endif +#else +typedef char _char_t; +typedef int _file_handle_t; +#define PATH_SEPARATOR "/" +#define TEXT(x) (x) +#define TIME_TO_STRING(buf, buflen, t) \ + snprintf(buf, buflen, "%ld", t) +#endif + +/** Pointer to the Breakpad-installed exception handler called if Vidalia + * crashes. + * \sa install_exception_handler() + */ +static google_breakpad::ExceptionHandler *exceptionHandler = 0; + +/** If true, the crash reporting application will be displayed when the + * Breakpad-installed exception handler is called. Otherwise, the system + * will handle the exception itself. + * \sa set_crash_reporter() + */ +static bool showCrashReporter = false; + +/** Absolute path of the crash reporting application that will be launched + * from the exception handler. + * \sa set_crash_reporter() + */ +static _char_t crashReporterExecutable[MAX_PATH_LEN + 1] = TEXT(""); + +/** Version information for the application being monitored for crashes. + * The version will be written to the extra information file alongside + * the minidump. + */ +static char buildVersion[MAX_VERSION_LEN + 1] = ""; + +/** Path and filename of the application to restart after displaying + * the crash reporting dialog. The contents of this string are encoded + * in UTF-8. + * \sa set_restart_options() + */ +static char restartExecutable[MAX_CMD_LEN + 1] = ""; + +/** Additional arguments to use when restarting the crashed application. + * The contents of this string are encoded in UTF-8. + * \sa set_restart_options() + */ +static char restartExecutableArgs[MAX_CMD_LEN + 1] = ""; + + +/** Records the time at which install_exception_handler() is called, which + * is usually as early as possible during application startup. This is used + * in minidump_callback() to determine how long the application was running + * before it crashed. + * \sa install_exception_handler() + * \sa minidump_callback() + */ +static time_t startupTime = 0; + + +/** Slightly modified version of the strlcat() implementation by Todd C. + * Miller (see the top of this file or the LICENSE file for license details), + * that supports arguments of either wchar_t* on Windows or the usual char* + * everywhere else but retains the semantics of strlcat(). + */ +static size_t +append_string(_char_t *dst, const _char_t *src, size_t siz) +{ + _char_t *d = dst; + const _char_t *s = src; + size_t n = siz; + size_t dlen; + + /* Find the end of dst and adjust bytes left but don't go past end */ + while (n-- != 0 && *d != TEXT('\0')) + d++; + dlen = d - dst; + n = siz - dlen; + + if (n == 0) +#if defined(Q_OS_WIN32) + return (dlen + wcslen(s)); +#else + return(dlen + strlen(s)); +#endif + + while (*s != TEXT('\0')) { + if (n != 1) { + *d++ = *s; + n--; + } + s++; + } + *d = TEXT('\0'); + + return(dlen + (s - src)); /* count does not include NUL */ +} + +/** Writes the formatted string "key=val\n" to the file handle + * specified by hFile. On Windows, hFile is a HANDLE. Everywhere + * else, hFile is an int. + */ +static void +write_keyval_to_file(_file_handle_t hFile, const char *key, const char *val) +{ +#if defined(Q_OS_WIN32) + DWORD dwWritten; + WriteFile(hFile, key, strlen(key), &dwWritten, NULL); + WriteFile(hFile, "=", 1, &dwWritten, NULL); + WriteFile(hFile, val, strlen(val), &dwWritten, NULL); + WriteFile(hFile, "\n", 1, &dwWritten, NULL); +#else + write(hFile, key, strlen(key)); + write(hFile, "=", 1); + write(hFile, val, strlen(val)); + write(hFile, "\n", 1); +#endif +} + +/** Writes to a file extra information used by the crash reporting + * application such as how long the application was running before it + * crashed, the application to restart, as well as any extra arguments. + * The contents of the file are formatted as a series of "Key=Val\n" pairs. + * The written file has the same path and base filename as the minidump + * file, with ".info" appended to the end. Returns true if the file was + * created succesfully. Otherwise, returns false. + */ +static bool +write_extra_dump_info(const _char_t *path, const _char_t *id, time_t crashTime) +{ + static const char *KeyBuildVersion = "BuildVersion"; + static const char *KeyCrashTime = "CrashTime"; + static const char *KeyStartupTime = "StartupTime"; + static const char *KeyRestartExecutable = "RestartExecutable"; + static const char *KeyRestartExecutableArgs = "RestartExecutableArgs"; + + _char_t extraInfoPath[MAX_PATH_LEN] = TEXT(""); + append_string(extraInfoPath, path, MAX_PATH_LEN); + append_string(extraInfoPath, PATH_SEPARATOR, MAX_PATH_LEN); + append_string(extraInfoPath, id, MAX_PATH_LEN); + size_t len = append_string(extraInfoPath, TEXT(".dmp.info"), MAX_PATH_LEN); + if (len >= MAX_PATH_LEN) + return false; + +#if defined(Q_OS_WIN32) + HANDLE hFile = CreateFile(extraInfoPath, GENERIC_WRITE, 0, NULL, + CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + if (hFile == INVALID_HANDLE_VALUE) + return false; +#else + /* TODO: Implement for non-Windowses */ +#endif + + char crashTimeString[24], startupTimeString[24]; + TIME_TO_STRING(crashTimeString, 24, crashTime); + TIME_TO_STRING(startupTimeString, 24, startupTime); + + write_keyval_to_file(hFile, KeyBuildVersion, buildVersion); + write_keyval_to_file(hFile, KeyCrashTime, crashTimeString); + write_keyval_to_file(hFile, KeyStartupTime, startupTimeString); + write_keyval_to_file(hFile, KeyRestartExecutable, restartExecutable); + write_keyval_to_file(hFile, KeyRestartExecutableArgs, restartExecutableArgs); + +#if defined(Q_OS_WIN32) + CloseHandle(hFile); +#else + /* TODO: Implement for non-Windowses */ + /* close(hFile); */ +#endif + return true; +} + +/** Breakpad-installed exception handler. This function gets called in the + * event of a crash. If showCrashReporter is true, this will execute + * the crash reporting application, passing it the name and location of the + * generated minidump, the absolute path to the (now crashed) Vidalia + * executable, and any arguments that may be needed to restart Vidalia. + */ +bool +minidump_callback(const _char_t *path, // Path to the minidump file + const _char_t *id, // Minidump UUID + void *context, // Callback context +#if defined(Q_OS_WIN32) + EXCEPTION_POINTERS *exInfo, + MDRawAssertionInfo *assertionInfo, +#endif + bool succeeded) +{ + if (! succeeded || ! showCrashReporter) + return false; + + /* Write the extra dump info, such as application uptime, executable to + * restart, and any necessary restart arguments. */ + write_extra_dump_info(path, id, time(NULL)); + + /* Format the command line used to launch the crash reporter */ + _char_t commandLine[MAX_CMD_LEN] = TEXT(""); + append_string(commandLine, TEXT("\""), MAX_CMD_LEN); + append_string(commandLine, crashReporterExecutable, MAX_CMD_LEN); + append_string(commandLine, TEXT("\" \""), MAX_CMD_LEN); + append_string(commandLine, path, MAX_CMD_LEN); + append_string(commandLine, PATH_SEPARATOR, MAX_CMD_LEN); + append_string(commandLine, id, MAX_CMD_LEN); + size_t len = append_string(commandLine, TEXT(".dmp\""), MAX_CMD_LEN); + if (len >= MAX_CMD_LEN) + return false; + + /* Launch the crash reporter with the name and location of the minidump */ +#if defined(Q_OS_WIN32) + PROCESS_INFORMATION pi; + STARTUPINFOW si; + + ZeroMemory(&pi, sizeof(pi)); + ZeroMemory(&si, sizeof(si)); + si.cb = sizeof(si); + si.dwFlags = STARTF_USESHOWWINDOW; + si.wShowWindow = SW_SHOWDEFAULT; + + BOOL rc = CreateProcess(NULL, (LPWSTR)commandLine, NULL, NULL, FALSE, 0, + NULL, NULL, &si, &pi); + if (rc) { + CloseHandle(pi.hThread); + CloseHandle(pi.hProcess); + } + TerminateProcess(GetCurrentProcess(), 1); + return true; +#else + /* TODO: Implement for non-Windowses */ + return false; +#endif +} + +bool +install_exception_handler(const QString &dumpPath) +{ + /* Create a directory for the crash dumps if it doesn't already exist */ + QDir dumpDir(dumpPath); + if (! dumpDir.exists() && ! dumpDir.mkdir(".")) + return false; + + /* Create the exception handler and specify where the dumps should go */ + exceptionHandler = new google_breakpad::ExceptionHandler( +#if defined(Q_OS_WIN32) + dumpDir.absolutePath().toStdWString(), +#else + dumpDir.absolutePath().toStdString(), +#endif + NULL, + minidump_callback, + NULL, +#if defined(Q_OS_WIN32) + google_breakpad::ExceptionHandler::HANDLER_ALL); +#else + true); +#endif + if (! exceptionHandler) + return false; + + startupTime = time(NULL); + return true; +} + +void +remove_exception_handler(void) +{ + if (exceptionHandler) { + delete exceptionHandler; + exceptionHandler = 0; + } +} + +bool +set_crash_reporter(const QString &crashReporter) +{ +#if defined(Q_OS_WIN32) + if (crashReporter.length() <= CrashReporter::MAX_PATH_LEN) { + crashReporter.toWCharArray(crashReporterExecutable); + crashReporterExecutable[crashReporter.length()] = L'\0'; +#else + QByteArray utf8 = crashReporter.toUtf8(); + if (utf8.length() <= CrashReporter::MAX_PATH_LEN) { + memcpy(crashReporterExecutable, utf8.constData(), utf8.length()); + crashReporterExecutable[utf8.length()] = '\0'; +#endif + showCrashReporter = true; + } else { + /* If the given path is longer than MAX_PATH_LEN, no crash reporting + * application will be set since the user's platform wouldn't be able to + * execute it anyway. + */ + showCrashReporter = false; + } + return showCrashReporter; +} + +bool +set_restart_options(const QString &executable, const QStringList &arguments) +{ + QByteArray exe = executable.toUtf8(); + if (exe.length() > MAX_CMD_LEN) + return false; + + QByteArray args = string_format_arguments(arguments).toUtf8(); + if (args.length() > MAX_CMD_LEN) + return false; + + memcpy(restartExecutable, exe.constData(), exe.length()); + restartExecutable[exe.length()] = '\0'; + + memcpy(restartExecutableArgs, args.constData(), args.length()); + restartExecutableArgs[args.length()] = '\0'; + + return true; +} + +bool +set_build_version(const QString &version) +{ + if (version.length() > MAX_VERSION_LEN) + return false; + + QByteArray ascii = version.toAscii(); + memcpy(buildVersion, ascii.constData(), ascii.length()); + buildVersion[ascii.length()] = '\0'; + + return true; +} + +} + diff -Nru vidalia-0.1.13/src/vidalia/CrashReporter.h vidalia-0.2.8/src/vidalia/CrashReporter.h --- vidalia-0.1.13/src/vidalia/CrashReporter.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/CrashReporter.h 2009-06-23 23:53:29.000000000 +0100 @@ -0,0 +1,96 @@ +/* +** 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.vidalia-project.net/. 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 CrashReporter.h +** \version $Id$ +** \brief General routines to install a Breakpad-based exception handler and +** set options related to launching the crash reporting application. +*/ + +#ifndef _CRASHREPORTER_H +#define _CRASHREPORTER_H + +class QString; +class QStringList; + + +namespace CrashReporter +{ + /** Defines the maximum length of the absolute path plus filename of the + * crash reporting executable displayed when the exception handler is + * called. + */ +#if defined(Q_OS_WIN32) + static const int MAX_PATH_LEN = 260; +#else + static const int MAX_PATH_LEN = 4096; /* Is there a better value for this? */ +#endif + + /** Defines the maximum length of the command line arguments used to restart + * the crashed application by the crash reporter. The maximum command line + * length is based on Windows' 32K character command line limit, according + * to the MSDN documents. + */ + static const int MAX_CMD_LEN = 32768; + + /** Defines the maximum length of a build version string that can be set + * by set_build_version(). + * \sa set_build_version() + */ + static const int MAX_VERSION_LEN = 64; + + /** Installs the Breakpad exception handler and sets the static global + * variables used by the exception handler to launch the crash reporting + * application. Minidumps will be writen to dumpPath, which will + * be created if it doesn't already exist. + * \sa remove_exception_handler() + */ + bool install_exception_handler(const QString &dumpPath); + + /** Removes the application's exception handler previously created by + * install_exception_handler(). If no exception handler was previously created, + * no action will be taken. + * \sa install_exception_handler() + */ + void remove_exception_handler(void); + + /** Sets crashReporter as the executable that gets called when the + * exception handler catches a crash. If crashReporter contains one + * or more spaces, the given path will be wrapped in quotes. The caller is + * responsible for ensuring that crashReporter is no greater than + * CrashReporter::MAX_PATH_LEN (including added quotes). Returns true if + * the crash reporting application was set successfully, or false if + * crashReporter was too long. + */ + bool set_crash_reporter(const QString &crashReporter); + + /** Sets the executable and args that will be passed to the + * crash reporting application, so it can restart the crashed application + * with the same arguments as before it crashed. If the executable + * path or any of args contains a space, they will be quoted before + * being passed to the crash reporting application. The path to the + * generated minidump, crash reporting application, executable to restart + * and any arguments must fit within MAX_CMD_LEN, including any added + * quotes. + * \sa set_crash_reporter() + */ + bool set_restart_options(const QString &executable, + const QStringList &arguments); + + /** Sets version as the build version identifier written to the + * extra information file alongside a minidump. The version string must + * be no longer than CrashReporter::MAX_VERSION_LEN. + */ + bool set_build_version(const QString &version); +} + +#endif + diff -Nru vidalia-0.1.13/src/vidalia/help/browser/helpbrowser.cpp vidalia-0.2.8/src/vidalia/help/browser/helpbrowser.cpp --- vidalia-0.1.13/src/vidalia/help/browser/helpbrowser.cpp 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/help/browser/helpbrowser.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,442 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 helpbrowser.cpp -** \version $Id: helpbrowser.cpp 3622 2009-03-16 19:45:20Z edmanm $ -** \brief Displays a list of help topics and content -*/ - -#include -#include -#include - -#include "helpbrowser.h" - - -#define LEFT_PANE_INDEX 0 -#define NO_STRETCH 0 -#define MINIMUM_PANE_SIZE 1 - -/* Names of elements and attributes in the XML file */ -#define ELEMENT_CONTENTS "Contents" -#define ELEMENT_TOPIC "Topic" -#define ATTRIBUTE_TOPIC_ID "id" -#define ATTRIBUTE_TOPIC_HTML "html" -#define ATTRIBUTE_TOPIC_NAME "name" -#define ATTRIBUTE_TOPIC_SECTION "section" - -/* Define two roles used to store data associated with a topic item */ -#define ROLE_TOPIC_ID Qt::UserRole -#define ROLE_TOPIC_QRC_PATH (Qt::UserRole+1) - - -/** Constuctor. This will probably do more later */ -HelpBrowser::HelpBrowser(QWidget *parent) - : VidaliaWindow("HelpBrowser", parent) -{ - VidaliaSettings settings; - - /* Invoke Qt Designer generated QObject setup routine */ - ui.setupUi(this); -#if defined(Q_WS_MAC) - ui.actionHome->setShortcut(QString("Shift+Ctrl+H")); -#endif - - /* Pressing 'Esc' or 'Ctrl+W' will close the window */ - ui.actionClose->setShortcut(QString("Esc")); - Vidalia::createShortcut("Ctrl+W", this, ui.actionClose, SLOT(trigger())); - - /* Hide Search frame */ - ui.frmFind->setHidden(true); - - /* Set the splitter pane sizes so that only the txtBrowser pane expands - * and set to arbitrary sizes (the minimum sizes will take effect */ - QList sizes; - sizes.append(MINIMUM_PANE_SIZE); - sizes.append(MINIMUM_PANE_SIZE); - ui.splitter->setSizes(sizes); - ui.splitter->setStretchFactor(LEFT_PANE_INDEX, NO_STRETCH); - - connect(ui.treeContents, - SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), - this, SLOT(contentsItemChanged(QTreeWidgetItem*,QTreeWidgetItem*))); - - connect(ui.treeSearch, - SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), - this, SLOT(searchItemChanged(QTreeWidgetItem*,QTreeWidgetItem*))); - - /* Connect the navigation actions to their slots */ - connect(ui.actionHome, SIGNAL(triggered()), ui.txtBrowser, SLOT(home())); - connect(ui.actionBack, SIGNAL(triggered()), ui.txtBrowser, SLOT(backward())); - connect(ui.actionForward, SIGNAL(triggered()), ui.txtBrowser, SLOT(forward())); - connect(ui.txtBrowser, SIGNAL(backwardAvailable(bool)), - ui.actionBack, SLOT(setEnabled(bool))); - connect(ui.txtBrowser, SIGNAL(forwardAvailable(bool)), - ui.actionForward, SLOT(setEnabled(bool))); - connect(ui.btnFindNext, SIGNAL(clicked()), this, SLOT(findNext())); - connect(ui.btnFindPrev, SIGNAL(clicked()), this, SLOT(findPrev())); - connect(ui.btnSearch, SIGNAL(clicked()), this, SLOT(search())); - - /* Load the help topics from XML */ - loadContentsFromXml(":/help/" + language() + "/contents.xml"); - - /* Show the first help topic in the tree */ - ui.treeContents->setCurrentItem(ui.treeContents->topLevelItem(0)); - ui.treeContents->setItemExpanded(ui.treeContents->topLevelItem(0), true); -} - -/** Returns the language in which help topics should appear, or English - * ("en") if no translated help files exist for the current GUI language. */ -QString -HelpBrowser::language() -{ - QString lang = Vidalia::language(); - if (!QDir(":/help/" + lang).exists()) - lang = "en"; - return lang; -} - -/** Load the contents of the help topics tree from the specified XML file. */ -void -HelpBrowser::loadContentsFromXml(QString xmlFile) -{ - QString errorString; - QFile file(xmlFile); - QDomDocument document; - - /* Load the XML contents into the DOM document */ - if (!document.setContent(&file, true, &errorString)) { - ui.txtBrowser->setPlainText(tr("Error Loading Help Contents: ")+errorString); - return; - } - /* Load the DOM document contents into the tree view */ - if (!loadContents(&document, errorString)) { - ui.txtBrowser->setPlainText(tr("Error Loading Help Contents: ")+errorString); - return; - } -} - -/** Load the contents of the help topics tree from the given DOM document. */ -bool -HelpBrowser::loadContents(const QDomDocument *document, QString &errorString) -{ - /* Grab the root document element and make sure it's the right one */ - QDomElement root = document->documentElement(); - if (root.tagName() != ELEMENT_CONTENTS) { - errorString = tr("Supplied XML file is not a valid Contents document."); - return false; - } - _elementList << root; - - /* Create the home item */ - QTreeWidgetItem *home = createTopicTreeItem(root, 0); - ui.treeContents->addTopLevelItem(home); - - /* Process all top-level help topics */ - QDomElement child = root.firstChildElement(ELEMENT_TOPIC); - while (!child.isNull()) { - parseHelpTopic(child, home); - child = child.nextSiblingElement(ELEMENT_TOPIC); - } - return true; -} - -/** Parse a Topic element and handle all its children recursively. */ -void -HelpBrowser::parseHelpTopic(const QDomElement &topicElement, - QTreeWidgetItem *parent) -{ - /* Check that we have a valid help topic */ - if (isValidTopicElement(topicElement)) { - /* Save this element for later (used for searching) */ - _elementList << topicElement; - - /* Create and populate the new topic item in the tree */ - QTreeWidgetItem *topic = createTopicTreeItem(topicElement, parent); - - /* Process all its child elements */ - QDomElement child = topicElement.firstChildElement(ELEMENT_TOPIC); - while (!child.isNull()) { - parseHelpTopic(child, topic); - child = child.nextSiblingElement(ELEMENT_TOPIC); - } - } -} - -/** Returns true if the given Topic element has the necessary attributes. */ -bool -HelpBrowser::isValidTopicElement(const QDomElement &topicElement) -{ - return (topicElement.hasAttribute(ATTRIBUTE_TOPIC_ID) && - topicElement.hasAttribute(ATTRIBUTE_TOPIC_NAME) && - topicElement.hasAttribute(ATTRIBUTE_TOPIC_HTML)); -} - -/** Builds a resource path to an html file associated with the given help - * topic. If the help topic needs an achor, the anchor will be formatted and - * appended. */ -QString -HelpBrowser::getResourcePath(const QDomElement &topicElement) -{ - QString link = language() + "/" + topicElement.attribute(ATTRIBUTE_TOPIC_HTML); - if (topicElement.hasAttribute(ATTRIBUTE_TOPIC_SECTION)) { - link += "#" + topicElement.attribute(ATTRIBUTE_TOPIC_SECTION); - } - return link; -} - -/** Creates a new element to be inserted into the topic tree. */ -QTreeWidgetItem* -HelpBrowser::createTopicTreeItem(const QDomElement &topicElement, - QTreeWidgetItem *parent) -{ - QTreeWidgetItem *topic = new QTreeWidgetItem(parent); - topic->setText(0, topicElement.attribute(ATTRIBUTE_TOPIC_NAME)); - topic->setData(0, ROLE_TOPIC_ID, topicElement.attribute(ATTRIBUTE_TOPIC_ID)); - topic->setData(0, ROLE_TOPIC_QRC_PATH, getResourcePath(topicElement)); - return topic; -} - -/** Called when the user selects a different item in the content topic tree */ -void -HelpBrowser::contentsItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *prev) -{ - QList selected = ui.treeSearch->selectedItems(); - /* Deselect the selection in the search tree */ - if (!selected.isEmpty()) { - ui.treeSearch->setItemSelected(selected[0], false); - } - currentItemChanged(current, prev); -} - -/** Called when the user selects a different item in the content topic tree */ -void -HelpBrowser::searchItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *prev) -{ - QList selected = ui.treeContents->selectedItems(); - /* Deselect the selection in the contents tree */ - if (!selected.isEmpty()) { - ui.treeContents->setItemSelected(selected[0], false); - } - - /* Change to selected page */ - currentItemChanged(current, prev); - - /* Highlight search phrase */ - QTextCursor found; - QTextDocument::FindFlags flags = QTextDocument::FindWholeWords; - found = ui.txtBrowser->document()->find(_lastSearch, 0, flags); - if (!found.isNull()) { - ui.txtBrowser->setTextCursor(found); - } -} - -/** Called when the user selects a different item in the tree. */ -void -HelpBrowser::currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *prev) -{ - Q_UNUSED(prev); - if (current) { - ui.txtBrowser->setSource(QUrl(current->data(0, - ROLE_TOPIC_QRC_PATH).toString())); - } - _foundBefore = false; -} - -/** Searches for a topic in the topic tree. Returns a pointer to that topics - * item in the topic tree if it is found, 0 otherwise. */ -QTreeWidgetItem* -HelpBrowser::findTopicItem(QTreeWidgetItem *startItem, QString topic) -{ - /* If startItem is null, then we don't know where to start searching. */ - if (!startItem) - return 0; - - /* Parse the first subtopic in the topic id. */ - QString subtopic = topic.mid(0, topic.indexOf(".")).toLower(); - - /* Search through all children of startItem and look for a subtopic match */ - for (int i = 0; i < startItem->childCount(); i++) { - QTreeWidgetItem *item = startItem->child(i); - - if (subtopic == item->data(0, ROLE_TOPIC_ID).toString().toLower()) { - /* Found a subtopic match, so expand this item */ - ui.treeContents->setItemExpanded(item, true); - if (!topic.contains(".")) { - /* Found the exact topic */ - return item; - } - /* Search recursively for the next subtopic */ - return findTopicItem(item, topic.mid(topic.indexOf(".")+1)); - } - } - return 0; -} - -/** Shows the help browser. If a sepcified topic was given, the search for - * that topic's ID (e.g., "log.basic") and display the appropriate page. */ -void -HelpBrowser::showTopic(QString topic) -{ - /* Search for the topic in the contents tree */ - QTreeWidgetItem *item = - findTopicItem(ui.treeContents->topLevelItem(0), topic); - - if (item) { - /* Item was found, so show its location in the hierarchy and select its - * tree item. */ - QTreeWidgetItem* selected = ui.treeContents->selectedItems()[0]; - if (selected) { - ui.treeContents->setItemSelected(selected, false); - } - ui.treeContents->setItemExpanded(ui.treeContents->topLevelItem(0), true); - ui.treeContents->setItemSelected(item, true); - currentItemChanged(item, selected); - } -} - -/** Called when the user clicks "Find Next". */ -void -HelpBrowser::findNext() -{ - find(true); -} - -/** Called when the user clicks "Find Previous". */ -void -HelpBrowser::findPrev() -{ - find(false); -} - -/** Searches the current page for the phrase in the Find box. - * Highlights the first instance found in the document - * \param forward true search forward if true, backward if false - **/ -void -HelpBrowser::find(bool forward) -{ - /* Don't bother searching if there is no search phrase */ - if (ui.lineFind->text().isEmpty()) { - return; - } - - QTextDocument::FindFlags flags = 0; - QTextCursor cursor = ui.txtBrowser->textCursor(); - QString searchPhrase = ui.lineFind->text(); - - /* Clear status bar */ - this->statusBar()->clearMessage(); - - /* Set search direction and other flags */ - if (!forward) { - flags |= QTextDocument::FindBackward; - } - if (ui.chkbxMatchCase->isChecked()) { - flags |= QTextDocument::FindCaseSensitively; - } - if (ui.chkbxWholePhrase->isChecked()) { - flags |= QTextDocument::FindWholeWords; - } - - /* Check if search phrase is the same as the previous */ - if (searchPhrase != _lastFind) { - _foundBefore = false; - } - _lastFind = searchPhrase; - - /* Set the cursor to the appropriate start location if necessary */ - if (!cursor.hasSelection()) { - if (forward) { - cursor.movePosition(QTextCursor::Start); - } else { - cursor.movePosition(QTextCursor::End); - } - ui.txtBrowser->setTextCursor(cursor); - } - - /* Search the page */ - QTextCursor found; - found = ui.txtBrowser->document()->find(searchPhrase, cursor, flags); - - /* If found, move the cursor to the location */ - if (!found.isNull()) { - ui.txtBrowser->setTextCursor(found); - /* If not found, display appropriate error message */ - } else { - if (_foundBefore) { - if (forward) - this->statusBar()->showMessage(tr("Search reached end of document")); - else - this->statusBar()->showMessage(tr("Search reached start of document")); - } else { - this->statusBar()->showMessage(tr("Text not found in document")); - } - } - - /* Even if not found this time, may have been found previously */ - _foundBefore |= !found.isNull(); -} - -/** Searches all help pages for the phrase the Search box. - * Fills treeSearch with documents containing matches and sets the - * status bar text appropriately. - */ -void -HelpBrowser::search() -{ - /* Clear the list */ - ui.treeSearch->clear(); - - /* Don't search if invalid document or blank search phrase */ - if (ui.lineSearch->text().isEmpty()) { - return; - } - - HelpTextBrowser browser; - QTextCursor found; - QTextDocument::FindFlags flags = QTextDocument::FindWholeWords; - - _lastSearch = ui.lineSearch->text(); - - /* Search through all the pages looking for the phrase */ - for (int i=0; i < _elementList.size(); ++i) { - /* Load page data into browser */ - browser.setSource(QUrl(getResourcePath(_elementList[i]))); - - /* Search current document */ - found = browser.document()->find(ui.lineSearch->text(), 0, flags); - - /* If found, add page to tree */ - if (!found.isNull()) { - ui.treeSearch->addTopLevelItem(createTopicTreeItem(_elementList[i], 0)); - } - } - - /* Set the status bar text */ - this->statusBar()->showMessage(tr("Found %1 results") - .arg(ui.treeSearch->topLevelItemCount())); -} - -/** Overrides the default show method */ -void -HelpBrowser::showWindow(QString topic) -{ - - /* Bring the window to the top */ - VidaliaWindow::showWindow(); - - /* If a topic was specified, then go ahead and display it. */ - if (!topic.isEmpty()) { - showTopic(topic); - } -} - diff -Nru vidalia-0.1.13/src/vidalia/help/browser/HelpBrowser.cpp vidalia-0.2.8/src/vidalia/help/browser/HelpBrowser.cpp --- vidalia-0.1.13/src/vidalia/help/browser/HelpBrowser.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/help/browser/HelpBrowser.cpp 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,459 @@ +/* +** 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.vidalia-project.net/. 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 HelpBrowser.cpp +** \version $Id: HelpBrowser.cpp 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Displays a list of help topics and content +*/ + +#include "HelpBrowser.h" +#include "Vidalia.h" + +#include +#include + +#define LEFT_PANE_INDEX 0 +#define NO_STRETCH 0 +#define MINIMUM_PANE_SIZE 1 + +/* Names of elements and attributes in the XML file */ +#define ELEMENT_CONTENTS "Contents" +#define ELEMENT_TOPIC "Topic" +#define ATTRIBUTE_TOPIC_ID "id" +#define ATTRIBUTE_TOPIC_HTML "html" +#define ATTRIBUTE_TOPIC_NAME "name" +#define ATTRIBUTE_TOPIC_SECTION "section" + +/* Define two roles used to store data associated with a topic item */ +#define ROLE_TOPIC_ID Qt::UserRole +#define ROLE_TOPIC_QRC_PATH (Qt::UserRole+1) + + +/** Constuctor. This will probably do more later */ +HelpBrowser::HelpBrowser(QWidget *parent) + : VidaliaWindow("HelpBrowser", parent) +{ + VidaliaSettings settings; + + /* Invoke Qt Designer generated QObject setup routine */ + ui.setupUi(this); +#if defined(Q_WS_MAC) + ui.actionHome->setShortcut(QString("Shift+Ctrl+H")); +#endif + + /* Pressing 'Esc' or 'Ctrl+W' will close the window */ + ui.actionClose->setShortcut(QString("Esc")); + Vidalia::createShortcut("Ctrl+W", this, ui.actionClose, SLOT(trigger())); + + /* Hide Search frame */ + ui.frmFind->setHidden(true); + + /* Set the splitter pane sizes so that only the txtBrowser pane expands + * and set to arbitrary sizes (the minimum sizes will take effect */ + QList sizes; + sizes.append(MINIMUM_PANE_SIZE); + sizes.append(MINIMUM_PANE_SIZE); + ui.splitter->setSizes(sizes); + ui.splitter->setStretchFactor(LEFT_PANE_INDEX, NO_STRETCH); + + connect(ui.treeContents, + SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), + this, SLOT(contentsItemChanged(QTreeWidgetItem*,QTreeWidgetItem*))); + + connect(ui.treeSearch, + SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), + this, SLOT(searchItemChanged(QTreeWidgetItem*,QTreeWidgetItem*))); + + /* Connect the navigation actions to their slots */ + connect(ui.actionHome, SIGNAL(triggered()), ui.txtBrowser, SLOT(home())); + connect(ui.actionBack, SIGNAL(triggered()), ui.txtBrowser, SLOT(backward())); + connect(ui.actionForward, SIGNAL(triggered()), ui.txtBrowser, SLOT(forward())); + connect(ui.txtBrowser, SIGNAL(backwardAvailable(bool)), + ui.actionBack, SLOT(setEnabled(bool))); + connect(ui.txtBrowser, SIGNAL(forwardAvailable(bool)), + ui.actionForward, SLOT(setEnabled(bool))); + connect(ui.btnFindNext, SIGNAL(clicked()), this, SLOT(findNext())); + connect(ui.btnFindPrev, SIGNAL(clicked()), this, SLOT(findPrev())); + connect(ui.btnSearch, SIGNAL(clicked()), this, SLOT(search())); + + /* Load the help topics from XML */ + loadContentsFromXml(":/help/" + language() + "/contents.xml"); + + /* Show the first help topic in the tree */ + ui.treeContents->setCurrentItem(ui.treeContents->topLevelItem(0)); + ui.treeContents->setItemExpanded(ui.treeContents->topLevelItem(0), true); +} + +/** Called when the user changes the UI translation. */ +void +HelpBrowser::retranslateUi() +{ + ui.retranslateUi(this); + ui.treeContents->clear(); + loadContentsFromXml(":/help/" + language() + "/contents.xml"); + ui.treeContents->setItemExpanded(ui.treeContents->topLevelItem(0), true); + ui.treeContents->setCurrentItem(ui.treeContents->topLevelItem(0)); + ui.treeContents->setItemExpanded(ui.treeContents->topLevelItem(0), true); +} + +/** Returns the language in which help topics should appear, or English + * ("en") if no translated help files exist for the current GUI language. */ +QString +HelpBrowser::language() +{ + QString lang = Vidalia::language(); + if (!QDir(":/help/" + lang).exists()) + lang = "en"; + return lang; +} + +/** Load the contents of the help topics tree from the specified XML file. */ +void +HelpBrowser::loadContentsFromXml(QString xmlFile) +{ + QString errorString; + QFile file(xmlFile); + QDomDocument document; + + /* Load the XML contents into the DOM document */ + if (!document.setContent(&file, true, &errorString)) { + ui.txtBrowser->setPlainText(tr("Error Loading Help Contents: ")+errorString); + return; + } + /* Load the DOM document contents into the tree view */ + if (!loadContents(&document, errorString)) { + ui.txtBrowser->setPlainText(tr("Error Loading Help Contents: ")+errorString); + return; + } +} + +/** Load the contents of the help topics tree from the given DOM document. */ +bool +HelpBrowser::loadContents(const QDomDocument *document, QString &errorString) +{ + /* Grab the root document element and make sure it's the right one */ + QDomElement root = document->documentElement(); + if (root.tagName() != ELEMENT_CONTENTS) { + errorString = tr("Supplied XML file is not a valid Contents document."); + return false; + } + _elementList << root; + + /* Create the home item */ + QTreeWidgetItem *home = createTopicTreeItem(root, 0); + ui.treeContents->addTopLevelItem(home); + + /* Process all top-level help topics */ + QDomElement child = root.firstChildElement(ELEMENT_TOPIC); + while (!child.isNull()) { + parseHelpTopic(child, home); + child = child.nextSiblingElement(ELEMENT_TOPIC); + } + return true; +} + +/** Parse a Topic element and handle all its children recursively. */ +void +HelpBrowser::parseHelpTopic(const QDomElement &topicElement, + QTreeWidgetItem *parent) +{ + /* Check that we have a valid help topic */ + if (isValidTopicElement(topicElement)) { + /* Save this element for later (used for searching) */ + _elementList << topicElement; + + /* Create and populate the new topic item in the tree */ + QTreeWidgetItem *topic = createTopicTreeItem(topicElement, parent); + + /* Process all its child elements */ + QDomElement child = topicElement.firstChildElement(ELEMENT_TOPIC); + while (!child.isNull()) { + parseHelpTopic(child, topic); + child = child.nextSiblingElement(ELEMENT_TOPIC); + } + } +} + +/** Returns true if the given Topic element has the necessary attributes. */ +bool +HelpBrowser::isValidTopicElement(const QDomElement &topicElement) +{ + return (topicElement.hasAttribute(ATTRIBUTE_TOPIC_ID) && + topicElement.hasAttribute(ATTRIBUTE_TOPIC_NAME) && + topicElement.hasAttribute(ATTRIBUTE_TOPIC_HTML)); +} + +/** Builds a resource path to an html file associated with the given help + * topic. If the help topic needs an achor, the anchor will be formatted and + * appended. */ +QString +HelpBrowser::getResourcePath(const QDomElement &topicElement) +{ + QString link = language() + "/" + topicElement.attribute(ATTRIBUTE_TOPIC_HTML); + if (topicElement.hasAttribute(ATTRIBUTE_TOPIC_SECTION)) { + link += "#" + topicElement.attribute(ATTRIBUTE_TOPIC_SECTION); + } + return link; +} + +/** Creates a new element to be inserted into the topic tree. */ +QTreeWidgetItem* +HelpBrowser::createTopicTreeItem(const QDomElement &topicElement, + QTreeWidgetItem *parent) +{ + QTreeWidgetItem *topic = new QTreeWidgetItem(parent); + QString label = topicElement.attribute(ATTRIBUTE_TOPIC_NAME); + + topic->setText(0, label); + topic->setToolTip(0, label); + topic->setData(0, ROLE_TOPIC_ID, topicElement.attribute(ATTRIBUTE_TOPIC_ID)); + topic->setData(0, ROLE_TOPIC_QRC_PATH, getResourcePath(topicElement)); + + return topic; +} + +/** Called when the user selects a different item in the content topic tree */ +void +HelpBrowser::contentsItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *prev) +{ + QList selected = ui.treeSearch->selectedItems(); + /* Deselect the selection in the search tree */ + if (!selected.isEmpty()) { + ui.treeSearch->setItemSelected(selected[0], false); + } + currentItemChanged(current, prev); +} + +/** Called when the user selects a different item in the content topic tree */ +void +HelpBrowser::searchItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *prev) +{ + QList selected = ui.treeContents->selectedItems(); + /* Deselect the selection in the contents tree */ + if (!selected.isEmpty()) { + ui.treeContents->setItemSelected(selected[0], false); + } + + /* Change to selected page */ + currentItemChanged(current, prev); + + /* Highlight search phrase */ + QTextCursor found; + QTextDocument::FindFlags flags = QTextDocument::FindWholeWords; + found = ui.txtBrowser->document()->find(_lastSearch, 0, flags); + if (!found.isNull()) { + ui.txtBrowser->setTextCursor(found); + } +} + +/** Called when the user selects a different item in the tree. */ +void +HelpBrowser::currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *prev) +{ + Q_UNUSED(prev); + if (current) { + ui.txtBrowser->setSource(QUrl(current->data(0, + ROLE_TOPIC_QRC_PATH).toString())); + } + _foundBefore = false; +} + +/** Searches for a topic in the topic tree. Returns a pointer to that topics + * item in the topic tree if it is found, 0 otherwise. */ +QTreeWidgetItem* +HelpBrowser::findTopicItem(QTreeWidgetItem *startItem, QString topic) +{ + /* If startItem is null, then we don't know where to start searching. */ + if (!startItem) + return 0; + + /* Parse the first subtopic in the topic id. */ + QString subtopic = topic.mid(0, topic.indexOf(".")).toLower(); + + /* Search through all children of startItem and look for a subtopic match */ + for (int i = 0; i < startItem->childCount(); i++) { + QTreeWidgetItem *item = startItem->child(i); + + if (subtopic == item->data(0, ROLE_TOPIC_ID).toString().toLower()) { + /* Found a subtopic match, so expand this item */ + ui.treeContents->setItemExpanded(item, true); + if (!topic.contains(".")) { + /* Found the exact topic */ + return item; + } + /* Search recursively for the next subtopic */ + return findTopicItem(item, topic.mid(topic.indexOf(".")+1)); + } + } + return 0; +} + +/** Shows the help browser. If a sepcified topic was given, then search for + * that topic's ID (e.g., "log.basic") and display the appropriate page. */ +void +HelpBrowser::showTopic(QString topic) +{ + /* Search for the topic in the contents tree */ + QTreeWidgetItem *item = + findTopicItem(ui.treeContents->topLevelItem(0), topic); + QTreeWidgetItem *selected = 0; + + if (item) { + /* Item was found, so show its location in the hierarchy and select its + * tree item. */ + if (ui.treeContents->selectedItems().size()) { + selected = ui.treeContents->selectedItems()[0]; + if (selected) + ui.treeContents->setItemSelected(selected, false); + } + ui.treeContents->setItemExpanded(ui.treeContents->topLevelItem(0), true); + ui.treeContents->setItemSelected(item, true); + currentItemChanged(item, selected); + } +} + +/** Called when the user clicks "Find Next". */ +void +HelpBrowser::findNext() +{ + find(true); +} + +/** Called when the user clicks "Find Previous". */ +void +HelpBrowser::findPrev() +{ + find(false); +} + +/** Searches the current page for the phrase in the Find box. + * Highlights the first instance found in the document + * \param forward true search forward if true, backward if false + **/ +void +HelpBrowser::find(bool forward) +{ + /* Don't bother searching if there is no search phrase */ + if (ui.lineFind->text().isEmpty()) { + return; + } + + QTextDocument::FindFlags flags = 0; + QTextCursor cursor = ui.txtBrowser->textCursor(); + QString searchPhrase = ui.lineFind->text(); + + /* Clear status bar */ + this->statusBar()->clearMessage(); + + /* Set search direction and other flags */ + if (!forward) { + flags |= QTextDocument::FindBackward; + } + if (ui.chkbxMatchCase->isChecked()) { + flags |= QTextDocument::FindCaseSensitively; + } + if (ui.chkbxWholePhrase->isChecked()) { + flags |= QTextDocument::FindWholeWords; + } + + /* Check if search phrase is the same as the previous */ + if (searchPhrase != _lastFind) { + _foundBefore = false; + } + _lastFind = searchPhrase; + + /* Set the cursor to the appropriate start location if necessary */ + if (!cursor.hasSelection()) { + if (forward) { + cursor.movePosition(QTextCursor::Start); + } else { + cursor.movePosition(QTextCursor::End); + } + ui.txtBrowser->setTextCursor(cursor); + } + + /* Search the page */ + QTextCursor found; + found = ui.txtBrowser->document()->find(searchPhrase, cursor, flags); + + /* If found, move the cursor to the location */ + if (!found.isNull()) { + ui.txtBrowser->setTextCursor(found); + /* If not found, display appropriate error message */ + } else { + if (_foundBefore) { + if (forward) + this->statusBar()->showMessage(tr("Search reached end of document")); + else + this->statusBar()->showMessage(tr("Search reached start of document")); + } else { + this->statusBar()->showMessage(tr("Text not found in document")); + } + } + + /* Even if not found this time, may have been found previously */ + _foundBefore |= !found.isNull(); +} + +/** Searches all help pages for the phrase the Search box. + * Fills treeSearch with documents containing matches and sets the + * status bar text appropriately. + */ +void +HelpBrowser::search() +{ + /* Clear the list */ + ui.treeSearch->clear(); + + /* Don't search if invalid document or blank search phrase */ + if (ui.lineSearch->text().isEmpty()) { + return; + } + + HelpTextBrowser browser; + QTextCursor found; + QTextDocument::FindFlags flags = QTextDocument::FindWholeWords; + + _lastSearch = ui.lineSearch->text(); + + /* Search through all the pages looking for the phrase */ + for (int i=0; i < _elementList.size(); ++i) { + /* Load page data into browser */ + browser.setSource(QUrl(getResourcePath(_elementList[i]))); + + /* Search current document */ + found = browser.document()->find(ui.lineSearch->text(), 0, flags); + + /* If found, add page to tree */ + if (!found.isNull()) { + ui.treeSearch->addTopLevelItem(createTopicTreeItem(_elementList[i], 0)); + } + } + + /* Set the status bar text */ + this->statusBar()->showMessage(tr("Found %1 results") + .arg(ui.treeSearch->topLevelItemCount())); +} + +/** Overrides the default show method */ +void +HelpBrowser::showWindow(QString topic) +{ + + /* Bring the window to the top */ + VidaliaWindow::showWindow(); + + /* If a topic was specified, then go ahead and display it. */ + if (!topic.isEmpty()) { + showTopic(topic); + } +} + diff -Nru vidalia-0.1.13/src/vidalia/help/browser/helpbrowser.h vidalia-0.2.8/src/vidalia/help/browser/helpbrowser.h --- vidalia-0.1.13/src/vidalia/help/browser/helpbrowser.h 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/help/browser/helpbrowser.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,96 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 helpbrowser.h -** \version $Id: helpbrowser.h 2362 2008-02-29 04:30:11Z edmanm $ -** \brief Displays a list of help topics and content -*/ - -#ifndef _HELPBROWSER_H -#define _HELPBROWSER_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "ui_helpbrowser.h" - -class HelpBrowser : public VidaliaWindow -{ - Q_OBJECT - -public: - /** Default constructor **/ - HelpBrowser(QWidget *parent = 0); - -public slots: - /** Overrides the default QWidget::show() */ - void showWindow(QString topic = QString()); - -private slots: - /** Called when the user clicks "Find Next" */ - void findNext(); - /** Called when the user clicks "Find Previous" */ - void findPrev(); - /** Called when the user starts a search */ - void search(); - /** Called when the user selects a different item in the contents tree */ - void contentsItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *prev); - /** Called when the user selects a different item in the search tree */ - void searchItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *prev); - -private: - /** Returns the language in which help topics should appear, or English - * ("en") if no translated help files exist for the current GUI language. */ - QString language(); - /** Load the contents of the help topics tree from the specified XML file. */ - void loadContentsFromXml(QString xmlFile); - /** Load the contents of the help topics tree from the given DOM document. */ - bool loadContents(const QDomDocument *document, QString &errorString); - /** Parse a Topic element and handle all its children. */ - void parseHelpTopic(const QDomElement &element, QTreeWidgetItem *parent); - /** Returns true if the given Topic element has the necessary attributes. */ - bool isValidTopicElement(const QDomElement &topicElement); - /** Builds a resource path to an html file associated with a help topic. */ - QString getResourcePath(const QDomElement &topicElement); - /** Searches the current page for the phrase in the Find box */ - void find(bool forward); - /** Creates a new item to be placed in the topic tree. */ - QTreeWidgetItem* createTopicTreeItem(const QDomElement &topicElement, - QTreeWidgetItem *parent); - /** Called when the user selects a different item in the tree. */ - void currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *prev); - /** Finds a topic in the topic tree. */ - QTreeWidgetItem* findTopicItem(QTreeWidgetItem *startItem, QString topic); - /** Shows the help browser and finds a specific a topic in the browser. */ - void showTopic(QString topic); - - /** List of DOM elements representing topics. */ - QList _elementList; - /** Last phrase used for 'Find' */ - QString _lastFind; - /** Last phrase searched on */ - QString _lastSearch; - /** Indicates if phrase was previously found on current page */ - bool _foundBefore; - - /** Qt Designer generated QObject */ - Ui::HelpBrowser ui; -}; - -#endif - diff -Nru vidalia-0.1.13/src/vidalia/help/browser/HelpBrowser.h vidalia-0.2.8/src/vidalia/help/browser/HelpBrowser.h --- vidalia-0.1.13/src/vidalia/help/browser/HelpBrowser.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/help/browser/HelpBrowser.h 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,101 @@ +/* +** 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.vidalia-project.net/. 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 HelpBrowser.h +** \version $Id: HelpBrowser.h 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Displays a list of help topics and content +*/ + +#ifndef _HELPBROWSER_H +#define _HELPBROWSER_H + +#include "ui_HelpBrowser.h" +#include "VidaliaWindow.h" + +#include +#include +#include +#include +#include +#include +#include +#include + + +class HelpBrowser : public VidaliaWindow +{ + Q_OBJECT + +public: + /** Default constructor **/ + HelpBrowser(QWidget *parent = 0); + +public slots: + /** Overrides the default QWidget::show() */ + void showWindow(QString topic = QString()); + +protected: + /** Called when the user changes the UI translation. */ + virtual void retranslateUi(); + +private slots: + /** Called when the user clicks "Find Next" */ + void findNext(); + /** Called when the user clicks "Find Previous" */ + void findPrev(); + /** Called when the user starts a search */ + void search(); + /** Called when the user selects a different item in the contents tree */ + void contentsItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *prev); + /** Called when the user selects a different item in the search tree */ + void searchItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *prev); + +private: + /** Returns the language in which help topics should appear, or English + * ("en") if no translated help files exist for the current GUI language. */ + QString language(); + /** Load the contents of the help topics tree from the specified XML file. */ + void loadContentsFromXml(QString xmlFile); + /** Load the contents of the help topics tree from the given DOM document. */ + bool loadContents(const QDomDocument *document, QString &errorString); + /** Parse a Topic element and handle all its children. */ + void parseHelpTopic(const QDomElement &element, QTreeWidgetItem *parent); + /** Returns true if the given Topic element has the necessary attributes. */ + bool isValidTopicElement(const QDomElement &topicElement); + /** Builds a resource path to an html file associated with a help topic. */ + QString getResourcePath(const QDomElement &topicElement); + /** Searches the current page for the phrase in the Find box */ + void find(bool forward); + /** Creates a new item to be placed in the topic tree. */ + QTreeWidgetItem* createTopicTreeItem(const QDomElement &topicElement, + QTreeWidgetItem *parent); + /** Called when the user selects a different item in the tree. */ + void currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *prev); + /** Finds a topic in the topic tree. */ + QTreeWidgetItem* findTopicItem(QTreeWidgetItem *startItem, QString topic); + /** Shows the help browser and finds a specific a topic in the browser. */ + void showTopic(QString topic); + + /** List of DOM elements representing topics. */ + QList _elementList; + /** Last phrase used for 'Find' */ + QString _lastFind; + /** Last phrase searched on */ + QString _lastSearch; + /** Indicates if phrase was previously found on current page */ + bool _foundBefore; + + /** Qt Designer generated QObject */ + Ui::HelpBrowser ui; +}; + +#endif + diff -Nru vidalia-0.1.13/src/vidalia/help/browser/helpbrowser.ui vidalia-0.2.8/src/vidalia/help/browser/helpbrowser.ui --- vidalia-0.1.13/src/vidalia/help/browser/helpbrowser.ui 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/help/browser/helpbrowser.ui 1970-01-01 01:00:00.000000000 +0100 @@ -1,684 +0,0 @@ - - - - - HelpBrowser - - - - 0 - 0 - 703 - 583 - - - - - 5 - 5 - 0 - 0 - - - - - 0 - 0 - - - - Qt::NoContextMenu - - - Vidalia Help - - - :/images/32x32/system-help.png - - - - - - true - - - Qt::ToolButtonTextUnderIcon - - - - - 9 - - - 6 - - - - - - 5 - 0 - 0 - 0 - - - - - 450 - 79 - - - - - 16777215 - 79 - - - - Qt::NoContextMenu - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 9 - - - 6 - - - - - 0 - - - 6 - - - - - - 5 - 5 - 0 - 0 - - - - - 0 - 0 - - - - - 24 - 24 - - - - Qt::NoContextMenu - - - - - - :/images/32x32/window-close.png - - - - 22 - 22 - - - - Qt::ToolButtonIconOnly - - - true - - - - - - - Qt::NoContextMenu - - - Find: - - - lineFind - - - - - - - Qt::NoContextMenu - - - - - - - - - Qt::NoContextMenu - - - Find Previous - - - :/images/22x22/go-up-search.png - - - - - - - Qt::NoContextMenu - - - Find Next - - - :/images/22x22/go-down-search.png - - - - - - - 0 - - - 6 - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Qt::NoContextMenu - - - Case sensitive - - - - - - - Qt::NoContextMenu - - - Whole words only - - - - - - - - - - - - Qt::NoContextMenu - - - Qt::Horizontal - - - - Qt::NoContextMenu - - - QTabWidget::North - - - QTabWidget::Rounded - - - - Contents - - - - 6 - - - 6 - - - - - - 5 - 7 - 1 - 0 - - - - - 200 - 0 - - - - - 16777215 - 16777215 - - - - Qt::WheelFocus - - - Qt::NoContextMenu - - - QAbstractItemView::SelectItems - - - true - - - - Help Topics - - - - - - - - - Search - - - - 6 - - - 6 - - - - - 0 - - - 6 - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Qt::NoContextMenu - - - Search - - - - - - - - - Qt::NoContextMenu - - - Searching for: - - - lineSearch - - - - - - - - 5 - 7 - 1 - 0 - - - - - 200 - 0 - - - - - 16777215 - 16777215 - - - - Qt::WheelFocus - - - Qt::NoContextMenu - - - QAbstractItemView::SelectItems - - - true - - - - Found Documents - - - - - - - - Qt::NoContextMenu - - - - - - - - - - 7 - 7 - 100 - 0 - - - - Qt::NoContextMenu - - - true - - - - - - - - - - 0 - 561 - 703 - 22 - - - - - - - 62 - 52 - - - - Qt::NoContextMenu - - - false - - - Qt::Horizontal - - - Qt::ToolButtonTextUnderIcon - - - 4 - - - - - - - - - - - :/images/32x32/go-previous.png - - - Back - - - Move to previous page (Backspace) - - - Backspace - - - - - :/images/32x32/go-next.png - - - Forward - - - Move to next page (Shift+Backspace) - - - Shift+Backspace - - - - - :/images/32x32/go-home.png - - - Home - - - Move to the Home page (Ctrl+H) - - - Ctrl+H - - - - - :/images/32x32/edit-find.png - - - true - - - Find - - - Find - - - Find - - - Search for a word or phrase on current page (Ctrl+F) - - - Ctrl+F - - - - - :/images/32x32/window-close.png - - - Close - - - Close Vidalia Help - - - Esc - - - - - - - HelpTextBrowser - QTextBrowser -
help/browser/helptextbrowser.h
- 0 - -
-
- - tabsMenu - btnCloseFind - lineFind - btnFindNext - btnFindPrev - chkbxMatchCase - chkbxWholePhrase - treeContents - txtBrowser - lineSearch - btnSearch - treeSearch - - - - - - - actionFind - triggered() - lineFind - setFocus() - - - -1 - -1 - - - 200 - 108 - - - - - btnCloseFind - clicked() - actionFind - toggle() - - - 34 - 107 - - - 243 - 108 - - - - - actionFind - toggled(bool) - frmFind - setVisible(bool) - - - -1 - -1 - - - 243 - 108 - - - - - actionClose - triggered() - HelpBrowser - close() - - - -1 - -1 - - - 317 - 248 - - - - - lineFind - returnPressed() - btnFindNext - click() - - - 293 - 108 - - - 539 - 108 - - - - - lineSearch - returnPressed() - btnSearch - click() - - - 153 - 245 - - - 244 - 277 - - - - -
diff -Nru vidalia-0.1.13/src/vidalia/help/browser/HelpBrowser.ui vidalia-0.2.8/src/vidalia/help/browser/HelpBrowser.ui --- vidalia-0.1.13/src/vidalia/help/browser/HelpBrowser.ui 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/help/browser/HelpBrowser.ui 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,684 @@ + + + + + HelpBrowser + + + + 0 + 0 + 703 + 583 + + + + + 5 + 5 + 0 + 0 + + + + + 0 + 0 + + + + Qt::NoContextMenu + + + Vidalia Help + + + :/images/32x32/system-help.png + + + + + + true + + + Qt::ToolButtonTextUnderIcon + + + + + 9 + + + 6 + + + + + + 5 + 0 + 0 + 0 + + + + + 450 + 79 + + + + + 16777215 + 79 + + + + Qt::NoContextMenu + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 9 + + + 6 + + + + + 0 + + + 6 + + + + + + 5 + 5 + 0 + 0 + + + + + 0 + 0 + + + + + 24 + 24 + + + + Qt::NoContextMenu + + + + + + :/images/32x32/window-close.png + + + + 22 + 22 + + + + Qt::ToolButtonIconOnly + + + true + + + + + + + Qt::NoContextMenu + + + Find: + + + lineFind + + + + + + + Qt::NoContextMenu + + + + + + + + + Qt::NoContextMenu + + + Find Previous + + + :/images/22x22/go-up-search.png + + + + + + + Qt::NoContextMenu + + + Find Next + + + :/images/22x22/go-down-search.png + + + + + + + 0 + + + 6 + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::NoContextMenu + + + Case sensitive + + + + + + + Qt::NoContextMenu + + + Whole words only + + + + + + + + + + + + Qt::NoContextMenu + + + Qt::Horizontal + + + + Qt::NoContextMenu + + + QTabWidget::North + + + QTabWidget::Rounded + + + + Contents + + + + 6 + + + 6 + + + + + + 5 + 7 + 1 + 0 + + + + + 200 + 0 + + + + + 16777215 + 16777215 + + + + Qt::WheelFocus + + + Qt::NoContextMenu + + + QAbstractItemView::SelectItems + + + true + + + + Help Topics + + + + + + + + + Search + + + + 6 + + + 6 + + + + + 0 + + + 6 + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::NoContextMenu + + + Search + + + + + + + + + Qt::NoContextMenu + + + Searching for: + + + lineSearch + + + + + + + + 5 + 7 + 1 + 0 + + + + + 200 + 0 + + + + + 16777215 + 16777215 + + + + Qt::WheelFocus + + + Qt::NoContextMenu + + + QAbstractItemView::SelectItems + + + true + + + + Found Documents + + + + + + + + Qt::NoContextMenu + + + + + + + + + + 7 + 7 + 100 + 0 + + + + Qt::NoContextMenu + + + true + + + + + + + + + + 0 + 561 + 703 + 22 + + + + + + + 62 + 52 + + + + Qt::NoContextMenu + + + false + + + Qt::Horizontal + + + Qt::ToolButtonTextUnderIcon + + + 4 + + + + + + + + + + + :/images/32x32/go-previous.png + + + Back + + + Move to previous page (Backspace) + + + Backspace + + + + + :/images/32x32/go-next.png + + + Forward + + + Move to next page (Shift+Backspace) + + + Shift+Backspace + + + + + :/images/32x32/go-home.png + + + Home + + + Move to the Home page (Ctrl+H) + + + Ctrl+H + + + + + :/images/32x32/edit-find.png + + + true + + + Find + + + Find + + + Find + + + Search for a word or phrase on current page (Ctrl+F) + + + Ctrl+F + + + + + :/images/32x32/window-close.png + + + Close + + + Close Vidalia Help + + + Esc + + + + + + + HelpTextBrowser + QTextBrowser +
help/browser/HelpTextBrowser.h
+ 0 + +
+
+ + tabsMenu + btnCloseFind + lineFind + btnFindNext + btnFindPrev + chkbxMatchCase + chkbxWholePhrase + treeContents + txtBrowser + lineSearch + btnSearch + treeSearch + + + + + + + actionFind + triggered() + lineFind + setFocus() + + + -1 + -1 + + + 200 + 108 + + + + + btnCloseFind + clicked() + actionFind + toggle() + + + 34 + 107 + + + 243 + 108 + + + + + actionFind + toggled(bool) + frmFind + setVisible(bool) + + + -1 + -1 + + + 243 + 108 + + + + + actionClose + triggered() + HelpBrowser + close() + + + -1 + -1 + + + 317 + 248 + + + + + lineFind + returnPressed() + btnFindNext + click() + + + 293 + 108 + + + 539 + 108 + + + + + lineSearch + returnPressed() + btnSearch + click() + + + 153 + 245 + + + 244 + 277 + + + + +
diff -Nru vidalia-0.1.13/src/vidalia/help/browser/helptextbrowser.cpp vidalia-0.2.8/src/vidalia/help/browser/helptextbrowser.cpp --- vidalia-0.1.13/src/vidalia/help/browser/helptextbrowser.cpp 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/help/browser/helptextbrowser.cpp 1970-01-01 01:00:00.000000000 +0100 @@ -1,98 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 helptextbrowser.cpp -** \version $Id: helptextbrowser.cpp 2679 2008-06-10 03:07:10Z edmanm $ -** \brief Displays an HTML-based help document -*/ - -#include -#include -#include -#include -#include -#include - -#include "helptextbrowser.h" - - -/** Default constructor. */ -HelpTextBrowser::HelpTextBrowser(QWidget *parent) - : QTextBrowser(parent) -{ - setOpenExternalLinks(false); -} - -/** Loads a resource into the browser. If it is an HTML resource, we'll load - * it as UTF-8, so the special characters in our translations appear properly. */ -QVariant -HelpTextBrowser::loadResource(int type, const QUrl &name) -{ - /* If it's an HTML file, we'll handle it ourselves */ - if (type == QTextDocument::HtmlResource) { - QString helpPath = ":/help/"; - - /* Fall back to English if there is no translation of the specified help - * page in the current language. */ - if (!name.path().contains("/")) { - QString language = Vidalia::language(); - if (!QDir(":/help/" + language).exists()) - language = "en"; - helpPath += language + "/"; - } - - QFile file(helpPath + name.path()); - if (!file.open(QIODevice::ReadOnly)) { - return tr("Error opening help file: ") + name.path(); - } - return QString::fromUtf8(file.readAll()); - } - /* Everything else, just let QTextBrowser take care of it. */ - return QTextBrowser::loadResource(type, name); -} - - -/** Called when the displayed document is changed. If url specifies - * an external link, then the user will be prompted for whether they want to - * open the link in their default browser or not. */ -void -HelpTextBrowser::setSource(const QUrl &url) -{ - if (url.scheme() != "qrc" && !url.isRelative()) { - /* External link. Prompt the user for a response. */ - int ret = VMessageBox::question(this, - tr("Opening External Link"), - p(tr("Vidalia can open the link you selected in your default " - "Web browser. If your browser is not currently " - "configured to use Tor then the request will not be " - "anonymous.")) + - p(tr("Do you want Vidalia to open the link in your Web " - "browser?")), - VMessageBox::Yes|VMessageBox::Default, - VMessageBox::Cancel|VMessageBox::Cancel); - - if (ret == VMessageBox::Cancel) - return; - - bool ok = QDesktopServices::openUrl(url); - if (!ok) { - VMessageBox::information(this, - tr("Unable to Open Link"), - tr("Vidalia was unable to open the selected link in your Web browser. " - "You can still copy the URL and paste it into your browser."), - VMessageBox::Ok); - } - } else { - /* Internal link. Just load it like normal. */ - QTextBrowser::setSource(url); - } -} - diff -Nru vidalia-0.1.13/src/vidalia/help/browser/HelpTextBrowser.cpp vidalia-0.2.8/src/vidalia/help/browser/HelpTextBrowser.cpp --- vidalia-0.1.13/src/vidalia/help/browser/HelpTextBrowser.cpp 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/help/browser/HelpTextBrowser.cpp 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,99 @@ +/* +** 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.vidalia-project.net/. 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 HelpTextBrowser.cpp +** \version $Id: HelpTextBrowser.cpp 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Displays an HTML-based help document +*/ + +#include "HelpTextBrowser.h" +#include "VMessageBox.h" +#include "Vidalia.h" + +#include "html.h" + +#include +#include +#include + + +/** Default constructor. */ +HelpTextBrowser::HelpTextBrowser(QWidget *parent) + : QTextBrowser(parent) +{ + setOpenExternalLinks(false); +} + +/** Loads a resource into the browser. If it is an HTML resource, we'll load + * it as UTF-8, so the special characters in our translations appear properly. */ +QVariant +HelpTextBrowser::loadResource(int type, const QUrl &name) +{ + /* If it's an HTML file, we'll handle it ourselves */ + if (type == QTextDocument::HtmlResource) { + QString helpPath = ":/help/"; + + /* Fall back to English if there is no translation of the specified help + * page in the current language. */ + if (!name.path().contains("/")) { + QString language = Vidalia::language(); + if (!QDir(":/help/" + language).exists()) + language = "en"; + helpPath += language + "/"; + } + + QFile file(helpPath + name.path()); + if (!file.open(QIODevice::ReadOnly)) { + return tr("Error opening help file: ") + name.path(); + } + return QString::fromUtf8(file.readAll()); + } + /* Everything else, just let QTextBrowser take care of it. */ + return QTextBrowser::loadResource(type, name); +} + + +/** Called when the displayed document is changed. If url specifies + * an external link, then the user will be prompted for whether they want to + * open the link in their default browser or not. */ +void +HelpTextBrowser::setSource(const QUrl &url) +{ + if (url.scheme() != "qrc" && !url.isRelative()) { + /* External link. Prompt the user for a response. */ + int ret = VMessageBox::question(this, + tr("Opening External Link"), + p(tr("Vidalia can open the link you selected in your default " + "Web browser. If your browser is not currently " + "configured to use Tor then the request will not be " + "anonymous.")) + + p(tr("Do you want Vidalia to open the link in your Web " + "browser?")), + VMessageBox::Yes|VMessageBox::Default, + VMessageBox::Cancel|VMessageBox::Cancel); + + if (ret == VMessageBox::Cancel) + return; + + bool ok = QDesktopServices::openUrl(url); + if (!ok) { + VMessageBox::information(this, + tr("Unable to Open Link"), + tr("Vidalia was unable to open the selected link in your Web browser. " + "You can still copy the URL and paste it into your browser."), + VMessageBox::Ok); + } + } else { + /* Internal link. Just load it like normal. */ + QTextBrowser::setSource(url); + } +} + diff -Nru vidalia-0.1.13/src/vidalia/help/browser/helptextbrowser.h vidalia-0.2.8/src/vidalia/help/browser/helptextbrowser.h --- vidalia-0.1.13/src/vidalia/help/browser/helptextbrowser.h 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/help/browser/helptextbrowser.h 1970-01-01 01:00:00.000000000 +0100 @@ -1,42 +0,0 @@ -/* -** 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.vidalia-project.net/. 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 helptextbrowser.h -** \version $Id: helptextbrowser.h 2679 2008-06-10 03:07:10Z edmanm $ -** \brief Displays an HTML-based help document -*/ - -#ifndef _HELPTEXTBROWSER_H -#define _HELPTEXTBROWSER_H - -#include -#include - - -class HelpTextBrowser : public QTextBrowser -{ - Q_OBJECT - -public: - /** Default constructor. */ - HelpTextBrowser(QWidget *parent = 0); - /** Loads a resource into the browser. */ - QVariant loadResource(int type, const QUrl &name); - -public slots: - /** Called when the displayed document is changed. If url specifies - * an external link, then the user will be prompted for whether they want to - * open the link in their default browser or not. */ - virtual void setSource(const QUrl &url); -}; - -#endif - diff -Nru vidalia-0.1.13/src/vidalia/help/browser/HelpTextBrowser.h vidalia-0.2.8/src/vidalia/help/browser/HelpTextBrowser.h --- vidalia-0.1.13/src/vidalia/help/browser/HelpTextBrowser.h 1970-01-01 01:00:00.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/help/browser/HelpTextBrowser.h 2009-04-28 21:28:01.000000000 +0100 @@ -0,0 +1,42 @@ +/* +** 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.vidalia-project.net/. 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 HelpTextBrowser.h +** \version $Id: HelpTextBrowser.h 3735 2009-04-28 20:28:01Z edmanm $ +** \brief Displays an HTML-based help document +*/ + +#ifndef _HELPTEXTBROWSER_H +#define _HELPTEXTBROWSER_H + +#include +#include + + +class HelpTextBrowser : public QTextBrowser +{ + Q_OBJECT + +public: + /** Default constructor. */ + HelpTextBrowser(QWidget *parent = 0); + /** Loads a resource into the browser. */ + QVariant loadResource(int type, const QUrl &name); + +public slots: + /** Called when the displayed document is changed. If url specifies + * an external link, then the user will be prompted for whether they want to + * open the link in their default browser or not. */ + virtual void setSource(const QUrl &url); +}; + +#endif + diff -Nru vidalia-0.1.13/src/vidalia/help/content/contents.dtd vidalia-0.2.8/src/vidalia/help/content/contents.dtd --- vidalia-0.1.13/src/vidalia/help/content/contents.dtd 2009-05-25 21:48:30.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/help/content/contents.dtd 1970-01-01 01:00:00.000000000 +0100 @@ -1,51 +0,0 @@ - - - - - - - - - - diff -Nru vidalia-0.1.13/src/vidalia/help/content/en/contents.xml vidalia-0.2.8/src/vidalia/help/content/en/contents.xml --- vidalia-0.1.13/src/vidalia/help/content/en/contents.xml 2009-05-25 21:48:29.000000000 +0100 +++ vidalia-0.2.8/src/vidalia/help/content/en/contents.xml 2008-09-25 05:58:06.000000000 +0100 @@ -1,5 +1,5 @@