Skip to content

Commit

Permalink
1. handle unicode and non-unicode subloder names in RPC functions; 2.…
Browse files Browse the repository at this point in the history
… Fix exception 3. Fix crash when GTK is cmpiled with assertions; closes #20, closes #18
  • Loading branch information
Dmitry Redkin committed Nov 23, 2019
1 parent aaa2320 commit ccc930d
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 14 deletions.
34 changes: 29 additions & 5 deletions browsebutton/core.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -122,17 +122,41 @@ def get_config(self):
def serverlog(self, line):
log.debug(line)

@export
def make_current_locale(self, string, name):
if isinstance(string, str):
log.debug("RBB:" + name + " is str = " + string)
try:
uni = string.decode(UTF8)
log.debug("RBB:" + name + " decoded from utf8 = "+ string)
except:
log.debug("RBB:" + name + " IS NOT UTF8!!!")
try:
uni = string.decode(CURRENT_LOCALE)
log.debug("RBB:" + name + " decoded from CURRENT_LOCALE = "+ string)
except:
log.info("RBB:" + name + " IS UNDECODABLE!!! dont know what to do...")
return string
elif isinstance(string, unicode):
log.debug("RBB:" + name + " is Unicode")
uni = string
string = uni.encode(CURRENT_LOCALE)
log.debug("RBB:" + name + " encoded to CURRENT_LOCALE = "+ string)
return string

@export
def get_folder_list(self, folder, subfolder):
"""Returns the list of subfolders for specified folder on server"""
log.debug("RBB:CURRENT_LOCALE is "+CURRENT_LOCALE)
error = ""
log.debug("RBB:original folder="+folder)
log.debug("RBB:original subfolder="+subfolder)
folder = self.make_current_locale(folder, "folder")
if folder == "":
folder = os.path.expanduser("~")
else:
folder = folder.encode(CURRENT_LOCALE)
log.debug("RBB:native folder"+folder)
log.debug("RBB:orig subfolder"+subfolder)
subfolder = subfolder.encode(CURRENT_LOCALE)

subfolder = self.make_current_locale(subfolder, "subfolder")

newfolder = os.path.join(folder,subfolder)
absolutepath = os.path.normpath(newfolder)

Expand Down
18 changes: 11 additions & 7 deletions browsebutton/gtkui.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,11 @@ def disable(self):
component.get("Preferences").remove_page("Browse Button")
component.get("PluginManager").deregister_hook("on_apply_prefs", self.on_apply_prefs)
component.get("PluginManager").deregister_hook("on_show_prefs", self.on_show_prefs)
for name in self.buttons.keys() :
self.deleteButton(self.buttons[name]['widget'])
self.buttons[name]['widget'] = None
self.handleError()
if self.buttons is not None:
for name in self.buttons.keys() :
self.deleteButton(self.buttons[name]['widget'])
self.buttons[name]['widget'] = None
self.handleError()

def handleError(self):
if self.error is not None:
Expand Down Expand Up @@ -251,15 +252,18 @@ def addMoveMenu(self):
menu.set_label("Move Storage")
menu.show()
menu.connect("activate", self.on_menu_activated, None)
count = 0
position = 0
#Remove the original move button
for item in torrentmenu.get_children():
count = count + 1
position = position + 1
if item.get_name() == "menuitem_move":
torrentmenu.remove(item)
break
#Insert into original "move" position
torrentmenu.insert(menu,count)
if position < len(torrentmenu.get_children()):
torrentmenu.insert(menu,count)
else:
torrentmenu.append(menu)

def on_menu_activated(self, widget=None, data=None):
client.core.get_torrent_status(component.get("TorrentView").get_selected_torrent(), ["save_path"]).addCallback(self.show_move_storage_dialog)
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
__plugin_name__ = "browsebutton"
__author__ = "dredkin"
__author_email__ = "[email protected]"
__version__ = "0.1.10"
__version__ = "0.1.11"
__url__ = "https://github.com/dredkin/deluge-rbb/releases"
__license__ = "GPLv3"
__description__ = "Browse Button for Client/Server Mode"
Expand All @@ -61,7 +61,7 @@

packages=[__plugin_name__.lower()],
package_data = __pkg_data__,

entry_points="""
[deluge.plugin.core]
%s = %s:CorePlugin
Expand Down

0 comments on commit ccc930d

Please sign in to comment.