Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/gajim-plugins.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYann Leboulanger <asterix@lagaule.org>2017-09-27 23:21:20 +0300
committerYann Leboulanger <asterix@lagaule.org>2017-09-27 23:21:20 +0300
commit72db56fda87344dcc9ccbed3cbfc58a5ec6ccd8d (patch)
treef678b3724f7c1d12c70c95f4b2d1706817f3e43d /url_shortener
parent3e7571db91e63a15f269d0cba64948a88314d3c2 (diff)
remove not ported plugins
Diffstat (limited to 'url_shortener')
-rw-r--r--url_shortener/__init__.py1
-rw-r--r--url_shortener/config_dialog.ui112
-rw-r--r--url_shortener/manifest.ini12
-rw-r--r--url_shortener/url_shortener.pngbin373 -> 0 bytes
-rw-r--r--url_shortener/url_shortener.py232
5 files changed, 0 insertions, 357 deletions
diff --git a/url_shortener/__init__.py b/url_shortener/__init__.py
deleted file mode 100644
index 3592535..0000000
--- a/url_shortener/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from url_shortener import UrlShortenerPlugin
diff --git a/url_shortener/config_dialog.ui b/url_shortener/config_dialog.ui
deleted file mode 100644
index d1424ec..0000000
--- a/url_shortener/config_dialog.ui
+++ /dev/null
@@ -1,112 +0,0 @@
-<?xml version="1.0"?>
-<interface>
- <requires lib="gtk+" version="2.16"/>
- <!-- interface-naming-policy toplevel-contextual -->
- <object class="GtkWindow" id="window1">
- <child>
- <object class="GtkVBox" id="vbox1">
- <property name="visible">True</property>
- <property name="orientation">vertical</property>
- <child>
- <object class="GtkFrame" id="frame1">
- <property name="visible">True</property>
- <property name="label_xalign">0</property>
- <property name="shadow_type">none</property>
- <child>
- <object class="GtkTable" id="table1">
- <property name="visible">True</property>
- <property name="n_rows">2</property>
- <property name="n_columns">2</property>
- <child>
- <object class="GtkSpinButton" id="max_chars">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="invisible_char">&#x25CF;</property>
- <property name="width_chars">6</property>
- <property name="snap_to_ticks">True</property>
- <property name="numeric">True</property>
- <signal name="value_changed" handler="avatar_size_value_changed"/>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="y_options"/>
- </packing>
- </child>
- <child>
- <object class="GtkSpinButton" id="in_max_chars">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="invisible_char">&#x25CF;</property>
- <property name="width_chars">6</property>
- <property name="snap_to_ticks">True</property>
- <property name="numeric">True</property>
- <signal name="value_changed" handler="on_in_max_chars_value_changed"/>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="y_options">GTK_EXPAND</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="incoming message">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="xpad">13</property>
- <property name="label" translatable="yes">incoming message</property>
- <property name="track_visited_links">False</property>
- </object>
- <packing>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="y_options">GTK_EXPAND</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="avatar_size_lebel">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="xpad">12</property>
- <property name="label" translatable="yes">outgoing message</property>
- <property name="track_visited_links">False</property>
- </object>
- <packing>
- <property name="y_options">GTK_EXPAND</property>
- </packing>
- </child>
- </object>
- </child>
- <child type="label">
- <object class="GtkLabel" id="label1">
- <property name="visible">True</property>
- <property name="label" translatable="yes">&lt;b&gt;The maximum length not be shortened links(chars):&lt;/b&gt;</property>
- <property name="use_markup">True</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="padding">6</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkCheckButton" id="shorten_outgoing">
- <property name="label" translatable="yes">shorten links in outgoing messages</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="active">True</property>
- <property name="draw_indicator">True</property>
- <signal name="toggled" handler="shorten_outgoing_toggled"/>
- </object>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- </child>
- </object>
-</interface>
diff --git a/url_shortener/manifest.ini b/url_shortener/manifest.ini
deleted file mode 100644
index b23ec79..0000000
--- a/url_shortener/manifest.ini
+++ /dev/null
@@ -1,12 +0,0 @@
-[info]
-name: Url Shortener
-short_name: url_shortener
-version: 0.3.5
-description: Plugin that allows users to shorten a long URL in messages.
- For example, you can turn this link:
- https://trac.gajim.org/timeline
- Into this link:
- http://bit.ly/THy6ZK
-authors: Denis Fomin <fominde@gmail.com>
-homepage: http://trac-plugins.gajim.org/wiki/UrlShortenerPlugin
-max_gajim_version: 0.15.9
diff --git a/url_shortener/url_shortener.png b/url_shortener/url_shortener.png
deleted file mode 100644
index fa1faa5..0000000
--- a/url_shortener/url_shortener.png
+++ /dev/null
Binary files differ
diff --git a/url_shortener/url_shortener.py b/url_shortener/url_shortener.py
deleted file mode 100644
index bd47efe..0000000
--- a/url_shortener/url_shortener.py
+++ /dev/null
@@ -1,232 +0,0 @@
-# -*- coding: utf-8 -*-
-
-import gtk
-import json
-import urllib
-import urllib2
-from common import app
-from common import ged
-from plugins import GajimPlugin
-from plugins.helpers import log_calls
-from plugins.gui import GajimPluginConfigDialog
-
-APIKEY = 'R_fcba926fc7978bd19acbca73ec82b2be'
-USER = 'dicson'
-
-class UrlShortenerPlugin(GajimPlugin):
- @log_calls('UrlShortenerPlugin')
- def init(self):
- self.description = _('Plugin that allows users to shorten a long URL '
- 'in received messages.\n'
- 'For example, you can turn this link:\n'
- 'https://trac.gajim.org/timeline\n'
- 'Into this link:\n'
- 'http://bit.ly/THy6ZK')
- self.config_dialog = UrlShortenerPluginConfigDialog(self)
- self.gui_extension_points = {
- 'chat_control_base': (self.connect_with_chat_control,
- self.disconnect_from_chat_control),
- 'print_special_text': (self.print_special_text,
- self.print_special_text1),}
- self.config_default_values = {
- 'MAX_CHARS': (50, ('MAX_CHARS(30-...)')),
- 'IN_MAX_CHARS': (50, ('MAX_CHARS(30-...)')),
- 'SHORTEN_OUTGOING': (False, ''),}
- self.events_handlers = {'message-outgoing': (ged.OUT_PRECORE,
- self.handle_outgoing_msg),
- 'gc-message-outgoing': (ged.OUT_PRECORE,
- self.handle_outgoing_msg)}
- self.chat_control = None
- self.controls = []
-
- def handle_outgoing_msg(self, event):
- if not self.active:
- return
- if not event.message:
- return
- if not self.config['SHORTEN_OUTGOING']:
- return
- if hasattr(event, 'shortened'):
- return
-
- iterator = app.interface.basic_pattern_re.finditer(event.message)
- for match in iterator:
- start, end = match.span()
- link = event.message[start:end]
- if len(link) < self.config['MAX_CHARS']:
- continue
- short_link = None
- try:
- params = urllib.urlencode({'longUrl': link,
- 'login': USER,
- 'apiKey': APIKEY,
- 'format': 'json'})
- req = urllib2.Request('http://api.bit.ly/v3/shorten?%s' % params)
- response = urllib2.urlopen(req)
- j = json.load(response)
- if j['status_code'] == 200:
- short_link = j['data']['url']
- except urllib2.HTTPError, e:
- pass
- if short_link:
- event.message = event.message.replace(link, short_link)
- event.callback_args[1] = event.message
- event.shortened = True
-
- @log_calls('UrlShortenerPlugin')
- def connect_with_chat_control(self, chat_control):
- self.chat_control = chat_control
- control = Base(self, self.chat_control)
- self.controls.append(control)
-
- @log_calls('UrlShortenerPlugin')
- def disconnect_from_chat_control(self, chat_control):
- for control in self.controls:
- control.disconnect_from_chat_control()
- self.controls = []
-
- def print_special_text(self, tv, special_text, other_tags, graphics=True,
- additional_data={}):
- for control in self.controls:
- if control.chat_control.conv_textview != tv:
- continue
- control.print_special_text(special_text, other_tags, graphics=True)
-
- def print_special_text1(self, chat_control, special_text, other_tags=None,
- graphics=True, additional_data={}):
- for control in self.controls:
- if control.chat_control == chat_control:
- control.disconnect_from_chat_control()
- self.controls.remove(control)
-
-
-class Base(object):
- def __init__(self, plugin, chat_control):
- self.plugin = plugin
- self.chat_control = chat_control
- self.textview = self.chat_control.conv_textview
-
- self.id_ = self.textview.tv.connect('motion_notify_event',
- self.on_textview_motion_notify_event)
- self.chat_control.handlers[self.id_] = self.textview.tv
-
- def print_special_text(self, special_text, other_tags, graphics=True):
- if not self.plugin.active:
- return
- is_xhtml_link = None
- text_is_valid_uri = False
- buffer_ = self.textview.tv.get_buffer()
-
- # Detect XHTML-IM link
- ttt = buffer_.get_tag_table()
- tags_ = [(ttt.lookup(t) if isinstance(t, str) else t) for t in other_tags]
- for t in tags_:
- is_xhtml_link = getattr(t, 'href', None)
- if is_xhtml_link:
- break
- # Check if we accept this as an uri
- schemes = app.config.get('uri_schemes').split()
- for scheme in schemes:
- if special_text.startswith(scheme):
- text_is_valid_uri = True
- if special_text.startswith('www.') or special_text.startswith('ftp.') \
- or text_is_valid_uri and not is_xhtml_link:
- if len(special_text) < self.plugin.config['IN_MAX_CHARS']:
- return
- end_iter = buffer_.get_end_iter()
- mark = buffer_.create_mark(None, end_iter, True)
- app.thread_interface(self.insert_hyperlink, [mark, special_text,
- ttt])
- self.textview.plugin_modified = True
-
- def insert_hyperlink(self, mark, special_text, ttt):
- try:
- params = urllib.urlencode({'longUrl': special_text,
- 'login': USER,
- 'apiKey': APIKEY,
- 'format': 'json'})
- req = urllib2.Request('http://api.bit.ly/v3/shorten?%s' % params)
- response = urllib2.urlopen(req)
- j = json.load(response)
- if j['status_code'] == 200:
- special_text = j['data']['url']
- except urllib2.HTTPError, e:
- pass
-
- buffer_ = mark.get_buffer()
- end_iter = buffer_.get_iter_at_mark(mark)
- buffer_.insert_with_tags(end_iter, special_text, ttt.lookup('url'))
-
- def on_textview_motion_notify_event(self, widget, event):
- pointer_x, pointer_y = self.textview.tv.window.get_pointer()[0:2]
- x, y = self.textview.tv.window_to_buffer_coords(gtk.TEXT_WINDOW_TEXT,
- pointer_x, pointer_y)
- tags = self.textview.tv.get_iter_at_location(x, y).get_tags()
- tag_table = self.textview.tv.get_buffer().get_tag_table()
- buffer_ = self.textview.tv.get_buffer()
- for tag in tags:
- if tag != tag_table.lookup('url'):
- continue
- it = self.textview.tv.get_iter_at_location(x, y)
- st = it.copy()
- st.backward_to_tag_toggle(tag_table.lookup('url'))
- it.forward_to_tag_toggle(tag_table.lookup('url'))
- text = buffer_.get_text(st, it, include_hidden_chars=True)
- if text.startswith('http://bit.ly/'):
- try:
- params = urllib.urlencode({'shortUrl': text,
- 'login': USER,
- 'apiKey': APIKEY,
- 'format': 'json'})
- req = urllib2.Request('http://api.bit.ly/v3/expand?%s' \
- % params)
- response = urllib2.urlopen(req)
- j = json.load(response)
- if j['status_code'] != 200:
- raise Exception('%s'%j['status_txt'])
- txt = j['data']['expand'][0]['long_url']
- self.textview.tv.set_tooltip_text(txt)
- self.textview.on_textview_motion_notify_event(widget, event)
- return
- except Exception, e:
- break
-
- self.textview.tv.set_tooltip_text('')
- self.textview.on_textview_motion_notify_event(widget, event)
-
- def disconnect_from_chat_control(self):
- pass
-
-
-class UrlShortenerPluginConfigDialog(GajimPluginConfigDialog):
- def init(self):
- self.GTK_BUILDER_FILE_PATH = self.plugin.local_file_path(
- 'config_dialog.ui')
- self.xml = gtk.Builder()
- self.xml.set_translation_domain('gajim_plugins')
- self.xml.add_objects_from_file(self.GTK_BUILDER_FILE_PATH, ['vbox1'])
- self.max_chars_spinbutton = self.xml.get_object('max_chars')
- self.max_chars_spinbutton.get_adjustment().set_all(30, 30, 99999, 1,
- 10, 0)
- self.in_max_chars_spinbutton = self.xml.get_object('in_max_chars')
- self.in_max_chars_spinbutton.get_adjustment().set_all(30, 30, 99999, 1,
- 10, 0)
- self.shorten_outgoing = self.xml.get_object('shorten_outgoing')
- hbox = self.xml.get_object('vbox1')
- self.child.pack_start(hbox)
-
- self.xml.connect_signals(self)
-
- def on_run(self):
- self.max_chars_spinbutton.set_value(self.plugin.config['MAX_CHARS'])
- self.in_max_chars_spinbutton.set_value(self.plugin.config['IN_MAX_CHARS'])
- self.shorten_outgoing.set_active(self.plugin.config['SHORTEN_OUTGOING'])
-
- def avatar_size_value_changed(self, spinbutton):
- self.plugin.config['MAX_CHARS'] = spinbutton.get_value()
-
- def on_in_max_chars_value_changed(self, spinbutton):
- self.plugin.config['IN_MAX_CHARS'] = spinbutton.get_value()
-
- def shorten_outgoing_toggled(self, checkbutton):
- self.plugin.config['SHORTEN_OUTGOING'] = checkbutton.get_active()