diff --git a/plugins/NetworkHealth/plugin.py b/plugins/NetworkHealth/plugin.py new file mode 100644 index 000000000..b96d0cb72 --- /dev/null +++ b/plugins/NetworkHealth/plugin.py @@ -0,0 +1,42 @@ +class plugin_NetworkHealth: + def __init__(self, path, deluge_core, deluge_interface): + self.parent = deluge_interface # Using this, you can access the Deluge client + self.core = deluge_core + self.location = path + + self.counter = 30 + self.maxCount = self.counter + + def config(self): + pass + + def unload(self): + pass + + def update(self): + session_info = self.core.get_state() + if not session_info['has_incoming_connections'] and \ + session_info['num_peers'] > 1: + message = "[No incoming connections]" + self.counter = self.counter - 1 + if self.counter < 0: + # self.parent.addMessage("No incoming connections: you may be behind a firewall or router. Perhaps you need to forward the relevant ports.", "W") + self.counter = self.maxCount*2 + self.maxCount = self.counter + else: + message = "[Health: OK]" + self.counter = self.maxCount + + self.parent.statusbar_temp_msg = self.parent.statusbar_temp_msg + ' ' + message + +### Register plugin with Deluge +register_plugin("Network Health Monitor", # The name of the plugin + plugin_NetworkHealth, # The plugin's class + "0.2", # The plugin's version number + "Network Health Monitor plugin\n\nWritten by Kripkenstein", # A description of the plugin + config=False, # If the plugin can be configured + default=False, # If the plugin should be loaded by default + requires="0.5.0", # Required version of Deluge + interface="gtk", # Required Deluge interface + required_plugins=None # Any plugins that must be loaded before this + ) diff --git a/plugins/PopupNotifications/PopupNotifierConfig.glade b/plugins/PopupNotifications/PopupNotifierConfig.glade new file mode 100644 index 000000000..89be9613b --- /dev/null +++ b/plugins/PopupNotifications/PopupNotifierConfig.glade @@ -0,0 +1,147 @@ + + + + + + + Popup Notifier Configuration + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + True + False + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST + True + False + False + + + + True + False + 0 + + + + True + GTK_BUTTONBOX_EDGE + + + + True + True + True + gtk-cancel + True + GTK_RELIEF_NORMAL + True + 0 + + + + + + True + True + True + gtk-ok + True + GTK_RELIEF_NORMAL + True + 1 + + + + + 0 + False + True + GTK_PACK_END + + + + + + True + True + 0 + + + + True + Notifications of the following Severity Level and above will be displayed: + False + False + GTK_JUSTIFY_CENTER + True + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + 40 + False + 0 + + + 0 + False + False + + + + + + True + GTK_UPDATE_CONTINUOUS + False + 1 1 4 1 1 0 + + + 0 + True + True + + + + + + True + + False + False + GTK_JUSTIFY_CENTER + True + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + 0 + True + True + + + + + + + diff --git a/plugins/PopupNotifications/PopupNotifierMessage.glade b/plugins/PopupNotifications/PopupNotifierMessage.glade new file mode 100644 index 000000000..dab4eee01 --- /dev/null +++ b/plugins/PopupNotifications/PopupNotifierMessage.glade @@ -0,0 +1,132 @@ + + + + + + + True + Popup Notification + GTK_WINDOW_POPUP + GTK_WIN_POS_NONE + False + True + False + True + False + False + GDK_WINDOW_TYPE_HINT_SPLASHSCREEN + GDK_GRAVITY_NORTH_WEST + True + True + + + + True + False + 0 + + + + True + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + True + GTK_SHADOW_IN + + + + True + False + 0 + + + + True + gtk-dialog-warning + 4 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + True + True + False + False + True + GTK_JUSTIFY_LEFT + GTK_WRAP_WORD + False + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0 + True + True + + + + + + + + + 0 + True + True + + + + + + True + True + gtk-close + True + GTK_RELIEF_NORMAL + True + + + + 0 + False + False + + + + + + + diff --git a/plugins/PopupNotifications/plugin.py b/plugins/PopupNotifications/plugin.py new file mode 100644 index 000000000..a13a2d581 --- /dev/null +++ b/plugins/PopupNotifications/plugin.py @@ -0,0 +1,114 @@ +# Popup Notifier plugin + +class plugin_PopupNotifier: + def __init__(self, path, deluge_core, deluge_interface): +# print "PopupNotifierI being created now" + self.parent = deluge_interface + self.location = path + import dcommon, dgtk, pref + try: + import pynotify + self.pynotify = pynotify # We must save this, because as a plugin, our globals will die + except: + dgtk.show_popup_warning(self. parent.window, "PopupNotifier: not all necessary dependencies are installed. To install them, on Ubuntu run: apt-get python-notify notification-daemon") + return + + if not self.pynotify.init("Deluge"): + dgtk.show_popup_warning(self. parent.window, "PopupNotifier: Cannot initialize pynotify, no notifications will be shown.") + + self.severities = { "I": 1, "W": 2, "C": 3, "F": 4 } + + self.severityTexts = { + self.severities["I"]: "Informative - can be easily ignored", + self.severities["W"]: "Warning - may be of interest", + self.severities["C"]: "Critical - should never be ignored", + self.severities["F"]: "Fatal - normal operation will probably not continue" } + + self.severityToUrgency = { "I": pynotify.URGENCY_LOW, + "W": pynotify.URGENCY_NORMAL, + "C": pynotify.URGENCY_NORMAL, + "F": pynotify.URGENCY_CRITICAL } + + self.config = pref.Preferences(dcommon.CONFIG_DIR + '/popupnotify.conf') + + userSeverity = self.config.get('plugin_popupnotifier_severity', default=self.severities["W"]) + + self.minSeverity = int(userSeverity) + + if self.minSeverity is None: + self.minSeverity = self.severities['I'] + + self.icon = "file://" + dccommon.get_pixmap("deluge32.png") + + # Connect signal in the parent + # self.handlerID = self.parent.messageList.connect("insert-text", self.signal) + + def unload(self): +# print "PopupNotifierI is shutting down now" + # self.parent.messageList.disconnect(self.handlerID) + pass + + def update(self): +# print "PopupNotifier Updating..." + pass + + def signal(self, textbuffer, iter, text, length): +# print "Signal occured, need to show: ", text + severity = text[0] + if self.severities[severity] >= self.minSeverity: + startIndex = text.find("] ")+2 + note = self.pynotify.Notification("Deluge", text[startIndex:], self.icon) + note.set_urgency(self.severityToUrgency[severity]) + if not note.show(): + print "Failed to send notification:", text + + def configure(self): + self.gladefile = self.location + "/PopupNotifierConfig.glade" + self.wTree = gtk.glade.XML(self.gladefile, "PopupNotifierConfig") + self.dlg = self.wTree.get_widget("PopupNotifierConfig") + + self.severitySelector = self.wTree.get_widget("severity_selector") + self.severitySelector.set_value(self.minSeverity) + self.severitySelector.connect("change-value", self.dlgChangeValue) + + self.severityDescriptor = self.wTree.get_widget("severity_descriptor") +# self.descriptorTextBuffer = gtk.TextBuffer() +# self.severityDescriptor.set_buffer(self.descriptorTextBuffer) + + self.dlgShowText() + + # Show and run + + self.dlg.show_all() + + if self.dlg.run() == 1: + self.minSeverity = int(self.severitySelector.get_value()) + self.config.set('plugin_popupnotifier_severity', self.minSeverity) +# else: +# print "Cancelled" + + self.dlg.destroy() + self.config.save_to_file() + + def dlgChangeValue(self, range, scroll, value): + self.severitySelector.set_value(round(value)) + self.dlgShowText() + return True + + def dlgShowText(self): + severity = int(self.severitySelector.get_value()) + self.severityDescriptor.set_text(self.severityTexts[severity]) + + +### MAIN + +register_plugin("Popup Notifier", # The name of the plugin + plugin_PopupNotifier, # The plugin's class + "0.2", # The plugin's version number + "Popup Notifier plugin\n\nWritten by Kripkenstein", # A description of the plugin + config=True, # If the plugin can be configured + default=False, # If the plugin should be loaded by default + requires="0.5.0", # Required version of Deluge + interface="gtk", # Required Deluge interface + required_plugins=None # Any plugins that must be loaded before this + )