mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 06:22:22 -04:00
fix custom proxy support
This commit is contained in:
parent
dfe7f5bf16
commit
a134338f5a
3 changed files with 19 additions and 65 deletions
|
@ -86,9 +86,6 @@ class Preferences(QDialog):
|
||||||
self.connect(self.form.syncDeauth, SIGNAL("clicked()"),
|
self.connect(self.form.syncDeauth, SIGNAL("clicked()"),
|
||||||
self.onSyncDeauth)
|
self.onSyncDeauth)
|
||||||
self.form.proxyHost.setText(self.prof['proxyHost'])
|
self.form.proxyHost.setText(self.prof['proxyHost'])
|
||||||
self.form.proxyPort.setValue(self.prof['proxyPort'])
|
|
||||||
self.form.proxyUser.setText(self.prof['proxyUser'])
|
|
||||||
self.form.proxyPass.setText(self.prof['proxyPass'])
|
|
||||||
|
|
||||||
def _hideAuth(self):
|
def _hideAuth(self):
|
||||||
self.form.syncDeauth.setShown(False)
|
self.form.syncDeauth.setShown(False)
|
||||||
|
@ -104,9 +101,6 @@ Not currently enabled; click the sync button in the main window to enable."""))
|
||||||
self.prof['autoSync'] = self.form.syncOnProgramOpen.isChecked()
|
self.prof['autoSync'] = self.form.syncOnProgramOpen.isChecked()
|
||||||
self.prof['syncMedia'] = self.form.syncMedia.isChecked()
|
self.prof['syncMedia'] = self.form.syncMedia.isChecked()
|
||||||
self.prof['proxyHost'] = unicode(self.form.proxyHost.text())
|
self.prof['proxyHost'] = unicode(self.form.proxyHost.text())
|
||||||
self.prof['proxyPort'] = int(self.form.proxyPort.value())
|
|
||||||
self.prof['proxyUser'] = unicode(self.form.proxyUser.text())
|
|
||||||
self.prof['proxyPass'] = unicode(self.form.proxyPass.text())
|
|
||||||
|
|
||||||
# Backup
|
# Backup
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
|
@ -12,6 +12,8 @@ from anki.db import DB
|
||||||
from anki.utils import isMac, isWin, intTime, checksum
|
from anki.utils import isMac, isWin, intTime, checksum
|
||||||
from anki.lang import langs
|
from anki.lang import langs
|
||||||
from aqt.utils import showWarning, fontForPlatform
|
from aqt.utils import showWarning, fontForPlatform
|
||||||
|
from httplib2 import ProxyInfo
|
||||||
|
import anki.sync
|
||||||
import aqt.forms
|
import aqt.forms
|
||||||
|
|
||||||
metaConf = dict(
|
metaConf = dict(
|
||||||
|
@ -51,10 +53,7 @@ profileConf = dict(
|
||||||
syncKey=None,
|
syncKey=None,
|
||||||
syncMedia=True,
|
syncMedia=True,
|
||||||
autoSync=True,
|
autoSync=True,
|
||||||
proxyHost='',
|
proxyHost='', # despite the name, stores full URL
|
||||||
proxyPort=8080,
|
|
||||||
proxyUser='',
|
|
||||||
proxyPass='',
|
|
||||||
proxyType=3,
|
proxyType=3,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -140,6 +139,20 @@ computer."""))
|
||||||
if name != "_global":
|
if name != "_global":
|
||||||
self.name = name
|
self.name = name
|
||||||
self.profile = prof
|
self.profile = prof
|
||||||
|
# export proxy settings
|
||||||
|
if prof['proxyHost'] == "off":
|
||||||
|
# force off; override environment
|
||||||
|
anki.sync.HTTP_PROXY = None
|
||||||
|
elif prof['proxyHost']:
|
||||||
|
url = prof['proxyHost']
|
||||||
|
if url.lower().startswith("https"):
|
||||||
|
method = "https"
|
||||||
|
else:
|
||||||
|
method = "http"
|
||||||
|
anki.sync.HTTP_PROXY = ProxyInfo.from_url(url, method)
|
||||||
|
else:
|
||||||
|
# use environment
|
||||||
|
anki.sync.HTTP_PROXY = ProxyInfo.from_environment()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
|
|
|
@ -251,7 +251,7 @@
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_13">
|
<widget class="QLabel" name="label_13">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string><b>Proxy</b><br>If your system needs a proxy to access the internet, enter your details below. Leave "Host" blank to disable proxy support.</string>
|
<string><b>Proxy</b><br>If your system needs a proxy to access the internet, enter your details below.</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="wordWrap">
|
<property name="wordWrap">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
|
@ -266,63 +266,13 @@
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="label_14">
|
<widget class="QLabel" name="label_14">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Host</string>
|
<string>URL</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="QLineEdit" name="proxyHost"/>
|
<widget class="QLineEdit" name="proxyHost"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="2">
|
|
||||||
<widget class="QLabel" name="label_15">
|
|
||||||
<property name="text">
|
|
||||||
<string>Port</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="3">
|
|
||||||
<widget class="QSpinBox" name="proxyPort">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>60</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="minimum">
|
|
||||||
<number>1</number>
|
|
||||||
</property>
|
|
||||||
<property name="maximum">
|
|
||||||
<number>65535</number>
|
|
||||||
</property>
|
|
||||||
<property name="value">
|
|
||||||
<number>8080</number>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="QLabel" name="label_19">
|
|
||||||
<property name="text">
|
|
||||||
<string>Username</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="1">
|
|
||||||
<widget class="QLineEdit" name="proxyUser"/>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="0">
|
|
||||||
<widget class="QLabel" name="label_20">
|
|
||||||
<property name="text">
|
|
||||||
<string>Password</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="1">
|
|
||||||
<widget class="QLineEdit" name="proxyPass">
|
|
||||||
<property name="echoMode">
|
|
||||||
<enum>QLineEdit::Password</enum>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
@ -486,9 +436,6 @@
|
||||||
<tabstop>syncOnProgramOpen</tabstop>
|
<tabstop>syncOnProgramOpen</tabstop>
|
||||||
<tabstop>syncDeauth</tabstop>
|
<tabstop>syncDeauth</tabstop>
|
||||||
<tabstop>proxyHost</tabstop>
|
<tabstop>proxyHost</tabstop>
|
||||||
<tabstop>proxyPort</tabstop>
|
|
||||||
<tabstop>proxyUser</tabstop>
|
|
||||||
<tabstop>proxyPass</tabstop>
|
|
||||||
<tabstop>numBackups</tabstop>
|
<tabstop>numBackups</tabstop>
|
||||||
<tabstop>buttonBox</tabstop>
|
<tabstop>buttonBox</tabstop>
|
||||||
<tabstop>tabWidget</tabstop>
|
<tabstop>tabWidget</tabstop>
|
||||||
|
|
Loading…
Reference in a new issue