Skip to content

Commit

Permalink
port from tor-control-status tor_status to anon-connection-wizard
Browse files Browse the repository at this point in the history
  • Loading branch information
adrelanos committed Jun 7, 2021
1 parent 9a17fb2 commit b0aef88
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
16 changes: 10 additions & 6 deletions usr/lib/python3/dist-packages/sdwdate_gui/sdwdate_gui.py
Expand Up @@ -13,9 +13,9 @@
import re
import glob

tor_control_panel_installed = os.path.exists('/usr/bin/tor-control-panel')
if tor_control_panel_installed:
from tor_control_panel import tor_status
anon_connection_wizard_installed = os.path.exists('/usr/bin/anon-connection-wizard')
if anon_connection_wizard_installed:
from anon_connection_wizard import tor_status


class SdwdateTrayIcon(QtWidgets.QSystemTrayIcon):
Expand Down Expand Up @@ -61,7 +61,7 @@ def __init__(self, parent=None):
self.setIcon(QtGui.QIcon(self.icon[self.status_list.index('busy')]))
self.setToolTip('Time Synchronisation Monitor \n Click for menu.')

if tor_control_panel_installed:
if anon_connection_wizard_installed:
self.tor_watcher = QFileSystemWatcher([self.tor_path, self.torrc_path])
self.tor_watcher.directoryChanged.connect(self.tor_status_changed)
else:
Expand All @@ -85,7 +85,7 @@ def show_menu(self, event):
def create_menu(self):
advanced_icon = QtGui.QIcon(self.icon_path + 'advancedsettings.ico')

if tor_control_panel_installed:
if anon_connection_wizard_installed:
icon = QtGui.QIcon(self.tor_icon[self.tor_status_list.index(self.tor_status)])
action = QtWidgets.QAction(icon, 'Show Tor status', self)
action.triggered.connect(lambda: self.show_message('tor'))
Expand Down Expand Up @@ -133,7 +133,7 @@ def update_menu(self):
sdwdate_icon = QtGui.QIcon(self.icon[self.status_list.index(self.sdwdate_status)])
tor_icon = QtGui.QIcon(self.tor_icon[self.tor_status_list.index(self.tor_status)])

if tor_control_panel_installed:
if anon_connection_wizard_installed:
self.menu.actions()[0].setIcon(tor_icon)
self.menu.actions()[3].setIcon(sdwdate_icon)
else:
Expand Down Expand Up @@ -233,6 +233,10 @@ def status_changed(self):
self.parse_sdwdate_status(status['icon'], status['message'])

def tor_status_changed(self):
if not anon_connection_wizard_installed:
## tor_status() unavailable.
return

try:
tor_is_enabled = tor_status.tor_status() == 'tor_enabled'
tor_is_running = os.path.exists(self.tor_running_path)
Expand Down
16 changes: 10 additions & 6 deletions usr/lib/python3/dist-packages/sdwdate_gui/sdwdate_gui_qubes.py
Expand Up @@ -13,9 +13,9 @@
import re
import glob

tor_control_panel_installed = os.path.exists('/usr/bin/tor-control-panel')
if tor_control_panel_installed:
from tor_control_panel import tor_status
anon_connection_wizard_installed = os.path.exists('/usr/bin/anon-connection-wizard')
if anon_connection_wizard_installed:
from anon_connection_wizard import tor_status


class AnonVmWatcher(QThread):
Expand Down Expand Up @@ -110,7 +110,7 @@ def __init__(self, parent=None):

self.setToolTip('Time Synchronisation Monitor \n Click for menu.')

if tor_control_panel_installed:
if anon_connection_wizard_installed:
self.tor_watcher = QFileSystemWatcher([self.tor_path, self.torrc_path])
self.tor_watcher.directoryChanged.connect(self.tor_status_changed)
else:
Expand Down Expand Up @@ -155,11 +155,11 @@ def create_sub_menu(self, menu):
if menu.title() == self.name:
icon = QtGui.QIcon(self.tor_icon[self.tor_status_list.index(self.tor_status)])
action = QtWidgets.QAction(icon, 'Show Tor status', self)
action.setEnabled(tor_control_panel_installed)
action.setEnabled(anon_connection_wizard_installed)
action.triggered.connect(lambda: self.show_message(menu.title(), 'tor'))
menu.addAction(action)
action = QtWidgets.QAction(advanced_icon, 'Tor control panel', self)
action.setEnabled(tor_control_panel_installed)
action.setEnabled(anon_connection_wizard_installed)
action.triggered.connect(self.show_tor_status)
menu.addAction(action)
menu.addSeparator()
Expand Down Expand Up @@ -393,6 +393,10 @@ def status_changed(self):
self.parse_sdwdate_status(self.name, status['icon'], status['message'])

def tor_status_changed(self):
if not anon_connection_wizard_installed:
## tor_status() unavailable.
return

try:
tor_is_enabled = tor_status.tor_status() == 'tor_enabled'
tor_is_running = os.path.exists(self.tor_running_path)
Expand Down

0 comments on commit b0aef88

Please sign in to comment.