Merge branch 'Feature/win32_associate_magnet' into develop

This commit is contained in:
Chase Sterling 2014-09-23 20:23:00 -04:00
commit a26c5eb56e
3 changed files with 29 additions and 5 deletions

View File

@ -33,6 +33,7 @@
* #378: Allow showing a pieces bar instead of a regular progress bar in a * #378: Allow showing a pieces bar instead of a regular progress bar in a
torrent's status tab. torrent's status tab.
* #2093: Make torrent opening compatible with all unicode paths. * #2093: Make torrent opening compatible with all unicode paths.
* #1084: Fix magnet association button on Windows
==== WebUI ==== ==== WebUI ====
* Server (deluge-web) now daemonizes by default, use -d or --do-not-daemonize to disable. * Server (deluge-web) now daemonizes by default, use -d or --do-not-daemonize to disable.

View File

@ -12,6 +12,7 @@ import cPickle
import logging import logging
import os import os
import shutil import shutil
import sys
import gtk import gtk
import pygtk import pygtk
@ -158,7 +159,29 @@ def associate_magnet_links(overwrite=False):
Returns: Returns:
bool: True if association was set bool: True if association was set
""" """
if not deluge.common.windows_check():
if deluge.common.windows_check():
import _winreg
try:
hkey = _winreg.OpenKey(_winreg.HKEY_CLASSES_ROOT, "Magnet")
except WindowsError:
overwrite = True
else:
_winreg.CloseKey(hkey)
if overwrite:
deluge_exe = os.path.join(os.path.dirname(sys.executable), "deluge.exe")
magnet_key = _winreg.CreateKey(_winreg.HKEY_CLASSES_ROOT, "Magnet")
_winreg.SetValue(magnet_key, "", _winreg.REG_SZ, "URL:Magnet Protocol")
_winreg.SetValueEx(magnet_key, "URL Protocol", 0, _winreg.REG_SZ, "")
_winreg.SetValueEx(magnet_key, "BrowserFlags", 0, _winreg.REG_DWORD, 0x8)
_winreg.SetValue(magnet_key, "DefaultIcon", _winreg.REG_SZ, "{},0".format(deluge_exe))
_winreg.SetValue(magnet_key, r"shell\open\command", _winreg.REG_SZ, '"{}" "%1"'.format(deluge_exe))
_winreg.CloseKey(magnet_key)
# Don't try associate magnet on OSX see: #2420
elif not deluge.common.osx_check():
# gconf method is only available in a GNOME environment # gconf method is only available in a GNOME environment
try: try:
import gconf import gconf

View File

@ -161,11 +161,11 @@ SectionEnd
# Create magnet uri association # Create magnet uri association
Section "Create magnet uri link association for Deluge" Section3 Section "Create magnet uri link association for Deluge" Section3
DeleteRegKey HKCR "magnet" DeleteRegKey HKCR "Magnet"
WriteRegStr HKCR "magnet" "" "URL:magnet protocol" WriteRegStr HKCR "Magnet" "" "URL:Magnet Protocol"
WriteRegStr HKCR "magnet" "URL Protocol" "" WriteRegStr HKCR "Magnet" "URL Protocol" ""
WriteRegStr HKCR "magnet\shell\open\command" "" '"$INSTDIR\deluge.exe" "%1"' WriteRegStr HKCR "Magnet\shell\open\command" "" '"$INSTDIR\deluge.exe" "%1"'
SectionEnd SectionEnd