...
 
Commits (11)
......@@ -479,10 +479,15 @@ class Base(object):
return transfer.getcode()
except UploadAbortedException as error:
log.info('Upload Aborted')
return str(error)
except urllib2.URLError as error:
log.exception('URLError')
errormsg = error.reason
except Exception as error:
gobject.idle_add(progress_window.close_dialog)
log.exception('Error')
return str(error)
errormsg = error
gobject.idle_add(progress_window.close_dialog)
return str(errormsg)
log.info("Uploading file to '%s'..." % str(put.getData()))
log.info("Please download from '%s' later..." % str(get.getData()))
......
[info]
name: HttpUpload
short_name: httpupload
version: 0.4.3
version: 0.4.5
description: This plugin is designed to send a file to a contact or muc by using httpupload.<br/>
Your server must support <a href="http://xmpp.org/extensions/xep-0363.html">XEP-0363: HTTP Upload</a>.<br/>
Conversations supported this.<br/>
......
......@@ -77,8 +77,7 @@ class SQLDatabase():
CREATE TABLE IF NOT EXISTS encryption_state (
id INTEGER PRIMARY KEY AUTOINCREMENT,
jid TEXT UNIQUE,
encryption INTEGER,
timestamp NUMERIC DEFAULT CURRENT_TIMESTAMP
encryption INTEGER
);
'''
......
......@@ -92,6 +92,18 @@
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="edit_button">
<property name="label" translatable="yes" comments="button">Edit</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="edit_button_clicked_cb"/>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="remove_button">
<property name="label" translatable="yes" comments="button">Remove</property>
......@@ -101,7 +113,31 @@
<signal name="clicked" handler="remove_button_clicked_cb"/>
</object>
<packing>
<property name="position">1</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkButton" id="move_up_button">
<property name="label" translatable="yes" comments="button">Move Up</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="move_up_button_clicked_cb"/>
</object>
<packing>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkButton" id="move_down_button">
<property name="label" translatable="yes" comments="button">Move Down</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="move_down_button_clicked_cb"/>
</object>
<packing>
<property name="position">4</property>
</packing>
</child>
</object>
......
[info]
name: Regex Filter
short_name: regex_filter
version: 0.2.4
version: 0.2.6
description: Filter incoming messages using regex.
authors: Yann Leboulanger <asterix@lagaule.org>
homepage: https://dev.gajim.org/gajim/gajim-plugins/wikis/RegexFilterPlugin
......
......@@ -74,6 +74,11 @@ class RegexFilterPlugin(GajimPlugin):
self.config[str(num)] = [search, replace]
self.create_rules()
@log_calls('RegexFilterPlugin')
def edit_rule(self, num, search, replace):
self.config[str(num)] = [search, replace]
self.create_rules()
@log_calls('RegexFilterPlugin')
def remove_rule(self, num):
if num in self.config:
......@@ -82,10 +87,31 @@ class RegexFilterPlugin(GajimPlugin):
return True
return False
@log_calls('RegexFilterPlugin')
def swap_rules(self, oldNum, newNum):
if newNum >= 0 and newNum < len(self.get_rules().items()):
temp = self.config[str(newNum)]
self.config[str(newNum)] = self.config[str(oldNum)]
self.config[str(oldNum)] = temp
self.create_rules()
return True
return False
@log_calls('RegexFilterPlugin')
def get_rules(self):
return self.config
@log_calls('RegexFilterPlugin')
def is_valid_regex(self, string):
if string.strip():
try:
re.compile(string)
return True
except re.error:
None
return False
@log_calls('RegexFilterPlugin')
def _nec_all(self, obj):
if not obj.msgtxt:
......@@ -122,6 +148,8 @@ class FilterCommands(CommandContainer):
"second argument is the replace regex."))
def add_filter(self, search, replace):
plugin = gajim.plugin_manager.get_active_plugin('regex_filter')
if not plugin.is_valid_regex(search):
return _('Invalid regular expression %s' % search)
plugin.add_rule(search, replace)
return _('Added rule to replace %s by %s' % (search, replace))
......
......@@ -29,13 +29,16 @@ class RegexFilterPluginConfigDialog(GajimPluginConfigDialog):
self.xml.connect_signals(self)
def add_button_clicked_cb(self, button, *args):
message = "Add a new filter for incoming messages"
dialog = gtk.MessageDialog(self.parent,
gtk.DIALOG_MODAL|gtk.DIALOG_DESTROY_WITH_PARENT,
gtk.MESSAGE_OTHER,
gtk.BUTTONS_OK_CANCEL,
message)
def open_dialog_window(self, dialog_title, parent=None, values=None):
dialog = gtk.MessageDialog(
parent,
gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
gtk.MESSAGE_OTHER,
gtk.BUTTONS_OK_CANCEL,
None)
dialog.set_position(gtk.WIN_POS_CENTER_ALWAYS)
dialog.set_title(dialog_title)
hbox = gtk.HBox(False, 4)
hbox.show()
......@@ -57,20 +60,47 @@ class RegexFilterPluginConfigDialog(GajimPluginConfigDialog):
dialog.vbox.add(hbox)
if values:
searchEntry.set_text(values[0])
replaceEntry.set_text(values[1])
searchEntry.connect('activate',
lambda _: dialog.response(gtk.RESPONSE_OK))
replaceEntry.connect('activate',
lambda _: dialog.response(gtk.RESPONSE_OK))
dialog.set_default_response(gtk.RESPONSE_OK)
response = dialog.run()
search = searchEntry.get_text().decode('utf8')
replace = replaceEntry.get_text().decode('utf8')
while True:
response = dialog.run()
search = searchEntry.get_text().decode('utf8')
replace = replaceEntry.get_text().decode('utf8')
if response == gtk.RESPONSE_OK:
if self.plugin.is_valid_regex(search):
dialog.destroy()
return [search, replace]
else:
searchEntry.grab_focus()
else:
break
dialog.destroy()
if response == gtk.RESPONSE_OK:
if search.strip():
self.plugin.add_rule(search, replace)
def add_button_clicked_cb(self, button, *args):
title = 'Add new filter rule'
response = self.open_dialog_window(title, self.parent, None)
if response:
self.plugin.add_rule(response[0], response[1])
def edit_button_clicked_cb(self, button, *args):
model, rules = self.rules_view.get_selection().get_selected_rows()
for rule in rules:
it = model.get_iter(rule)
ruleNum, search, replace = model.get(it, 0, 1, 2)
title = 'Edit filter rule #%d' % ruleNum
response = self.open_dialog_window(title, self.parent,
[search, replace])
if response:
self.plugin.edit_rule(ruleNum, response[0], response[1])
def remove_button_clicked_cb(self, button, *args):
model, rules = self.rules_view.get_selection().get_selected_rows()
......@@ -79,3 +109,20 @@ class RegexFilterPluginConfigDialog(GajimPluginConfigDialog):
it = model.get_iter(rule)
ruleNum = model.get(it, 0)
self.plugin.remove_rule("%d" % ruleNum)
def move_up_button_clicked_cb(self, button, *args):
model, rules = self.rules_view.get_selection().get_selected_rows()
for rule in rules:
it = model.get_iter(rule)
ruleNum = model.get(it, 0)
self.plugin.swap_rules("%d" % ruleNum, int("%d" % ruleNum) - 1)
def move_down_button_clicked_cb(self, button, *args):
model, rules = self.rules_view.get_selection().get_selected_rows()
for rule in rules:
it = model.get_iter(rule)
ruleNum = model.get(it, 0)
self.plugin.swap_rules("%d" % ruleNum, int("%d" % ruleNum) + 1)