Commit 9ce1c5b9 authored by Philipp Hörist's avatar Philipp Hörist

Use absolute imports on all plugins

This is necessary because Gajim is with 0.16.11 a python package
parent 507bf9a9
...@@ -26,11 +26,11 @@ Block some incoming messages ...@@ -26,11 +26,11 @@ Block some incoming messages
from gi.repository import Gtk from gi.repository import Gtk
import nbxmpp import nbxmpp
from common import gajim, ged from gajim.common import app, ged
from plugins import GajimPlugin from gajim.plugins import GajimPlugin
from plugins.helpers import log, log_calls from gajim.plugins.helpers import log, log_calls
from plugins.gui import GajimPluginConfigDialog from gajim.plugins.gui import GajimPluginConfigDialog
class AntiSpamPlugin(GajimPlugin): class AntiSpamPlugin(GajimPlugin):
...@@ -101,7 +101,7 @@ class AntiSpamPlugin(GajimPlugin): ...@@ -101,7 +101,7 @@ class AntiSpamPlugin(GajimPlugin):
@log_calls('AntiSpamPlugin') @log_calls('AntiSpamPlugin')
def _nec_subscribe_presence_received(self, obj): def _nec_subscribe_presence_received(self, obj):
if self.config['block_subscription_requests'] and \ if self.config['block_subscription_requests'] and \
not gajim.contacts.get_contacts(obj.conn.name, obj.jid): not app.contacts.get_contacts(obj.conn.name, obj.jid):
log.info('discarding subscription request from %s' % obj.jid) log.info('discarding subscription request from %s' % obj.jid)
return True return True
...@@ -118,7 +118,7 @@ class AntiSpamPlugin(GajimPlugin): ...@@ -118,7 +118,7 @@ class AntiSpamPlugin(GajimPlugin):
if len(answer) == 0: if len(answer) == 0:
return False return False
block_conference = self.config['antispam_for_conference'] block_conference = self.config['antispam_for_conference']
is_conference = gajim.contacts.is_gc_contact(obj.conn.name, obj.fjid) is_conference = app.contacts.is_gc_contact(obj.conn.name, obj.fjid)
if not block_conference and is_conference: if not block_conference and is_conference:
return False return False
jid = obj.jid if not is_conference else obj.fjid jid = obj.jid if not is_conference else obj.fjid
...@@ -127,7 +127,7 @@ class AntiSpamPlugin(GajimPlugin): ...@@ -127,7 +127,7 @@ class AntiSpamPlugin(GajimPlugin):
# There are two methods to see who wrote you and not passed filter: # There are two methods to see who wrote you and not passed filter:
# 1. Using XML console # 1. Using XML console
# 2. Running Gajim with log info messages and see logs (probably gajim.log file) # 2. Running Gajim with log info messages and see logs (probably gajim.log file)
if is_conference or not gajim.contacts.get_contacts(obj.conn.name, jid): if is_conference or not app.contacts.get_contacts(obj.conn.name, jid):
if not self.contain_answer(obj.msgtxt, answer): if not self.contain_answer(obj.msgtxt, answer):
if is_conference and jid in self.config['conference_white_list']: if is_conference and jid in self.config['conference_white_list']:
return False return False
...@@ -164,7 +164,7 @@ class AntiSpamPlugin(GajimPlugin): ...@@ -164,7 +164,7 @@ class AntiSpamPlugin(GajimPlugin):
receipt.setTag('received', namespace='urn:xmpp:receipts', attrs={'id': obj.id_}) receipt.setTag('received', namespace='urn:xmpp:receipts', attrs={'id': obj.id_})
if obj.thread_id: if obj.thread_id:
receipt.setThread(obj.thread_id) receipt.setThread(obj.thread_id)
gajim.connections[obj.conn.name].connection.send(receipt, now=True) app.connections[obj.conn.name].connection.send(receipt, now=True)
question = self.config['msgtxt_question'] question = self.config['msgtxt_question']
log.info('Anti_spam enabled for %s, question: %s', jid, question) log.info('Anti_spam enabled for %s, question: %s', jid, question)
message = _('Antispam enabled. Please answer the question. The message must only ' + \ message = _('Antispam enabled. Please answer the question. The message must only ' + \
...@@ -176,7 +176,7 @@ class AntiSpamPlugin(GajimPlugin): ...@@ -176,7 +176,7 @@ class AntiSpamPlugin(GajimPlugin):
else: # for 'normal' type else: # for 'normal' type
stanza = nbxmpp.Message(to=jid, body=message, subject='Antispam enabled', typ=obj.mtype) stanza = nbxmpp.Message(to=jid, body=message, subject='Antispam enabled', typ=obj.mtype)
gajim.connections[obj.conn.name].connection.send(stanza, now=True) app.connections[obj.conn.name].connection.send(stanza, now=True)
def contain_answer(self, msg, answer): def contain_answer(self, msg, answer):
return answer in msg.split('\n') return answer in msg.split('\n')
......
[info] [info]
name: Anti Spam name: Anti Spam
short_name: anti_spam short_name: anti_spam
version: 1.4.3 version: 1.4.4
description: Block some incoming messages. description: Block some incoming messages.
authors = Yann Leboulanger <asterix@lagaule.org> authors = Yann Leboulanger <asterix@lagaule.org>
Denis Fomin <fominde@gmail.com> Denis Fomin <fominde@gmail.com>
Ilya Kanyukov <ilya.kanukov@gmail.com> Ilya Kanyukov <ilya.kanukov@gmail.com>
homepage = https://dev.gajim.org/gajim/gajim-plugins/wikis/AntiSpamPlugin homepage = https://dev.gajim.org/gajim/gajim-plugins/wikis/AntiSpamPlugin
min_gajim_version: 0.16.10 min_gajim_version: 0.16.11
[info] [info]
name: Banner Tweaks name: Banner Tweaks
short_name: banner_tweaks short_name: banner_tweaks
version: 0.1.2 version: 0.1.3
description: Allows user to tweak chat window banner appearance (eg. make it compact). description: Allows user to tweak chat window banner appearance (eg. make it compact).
authors = Mateusz Biliński <mateusz@bilinski.it> authors = Mateusz Biliński <mateusz@bilinski.it>
homepage = http://trac-plugins.gajim.org/wiki/BannerTweaksPlugin homepage = http://trac-plugins.gajim.org/wiki/BannerTweaksPlugin
min_gajim_version: 0.16.10 min_gajim_version: 0.16.11
...@@ -33,13 +33,13 @@ import sys ...@@ -33,13 +33,13 @@ import sys
from gi.repository import Gtk from gi.repository import Gtk
from gi.repository import GObject from gi.repository import GObject
import message_control from gajim import message_control
from common import gajim from gajim.common import app
from common import helpers from gajim.common import helpers
from plugins import GajimPlugin from gajim.plugins import GajimPlugin
from plugins.helpers import log, log_calls from gajim.plugins.helpers import log, log_calls
from plugins.gui import GajimPluginConfigDialog from gajim.plugins.gui import GajimPluginConfigDialog
class BannerTweaksPlugin(GajimPlugin): class BannerTweaksPlugin(GajimPlugin):
...@@ -67,13 +67,13 @@ class BannerTweaksPlugin(GajimPlugin): ...@@ -67,13 +67,13 @@ class BannerTweaksPlugin(GajimPlugin):
@log_calls('BannerTweaksPlugin') @log_calls('BannerTweaksPlugin')
def activate(self): def activate(self):
self.config['old_chat_avatar_height'] = gajim.config.get( self.config['old_chat_avatar_height'] = app.config.get(
'chat_avatar_height') 'chat_avatar_height')
#gajim.config.set('chat_avatar_height', 28) #gajim.config.set('chat_avatar_height', 28)
@log_calls('BannerTweaksPlugin') @log_calls('BannerTweaksPlugin')
def deactivate(self): def deactivate(self):
gajim.config.set('chat_avatar_height', self.config[ app.config.set('chat_avatar_height', self.config[
'old_chat_avatar_height']) 'old_chat_avatar_height'])
@log_calls('BannerTweaksPlugin') @log_calls('BannerTweaksPlugin')
...@@ -122,14 +122,14 @@ class BannerTweaksPlugin(GajimPlugin): ...@@ -122,14 +122,14 @@ class BannerTweaksPlugin(GajimPlugin):
# except if we are talking to two different resources of the same # except if we are talking to two different resources of the same
# contact # contact
acct_info = '' acct_info = ''
for account in gajim.contacts.get_accounts(): for account in app.contacts.get_accounts():
if account == chat_control.account: if account == chat_control.account:
continue continue
if acct_info: # We already found a contact with same nick if acct_info: # We already found a contact with same nick
break break
for jid in gajim.contacts.get_jid_list(account): for jid in app.contacts.get_jid_list(account):
other_contact_ = \ other_contact_ = \
gajim.contacts.get_first_contact_from_jid(account, jid) app.contacts.get_first_contact_from_jid(account, jid)
if other_contact_.get_shown_name() == \ if other_contact_.get_shown_name() == \
chat_control.contact.get_shown_name(): chat_control.contact.get_shown_name():
acct_info = ' (%s)' % \ acct_info = ' (%s)' % \
...@@ -140,7 +140,7 @@ class BannerTweaksPlugin(GajimPlugin): ...@@ -140,7 +140,7 @@ class BannerTweaksPlugin(GajimPlugin):
if self.config['banner_small_fonts']: if self.config['banner_small_fonts']:
font_attrs = font_attrs_small font_attrs = font_attrs_small
st = gajim.config.get('displayed_chat_state_notifications') st = app.config.get('displayed_chat_state_notifications')
cs = contact.chatstate cs = contact.chatstate
if cs and st in ('composing_only', 'all'): if cs and st in ('composing_only', 'all'):
if contact.show == 'offline': if contact.show == 'offline':
......
[info] [info]
name: Birthday reminder name: Birthday reminder
short_name: birthday_reminder short_name: birthday_reminder
version: 0.0.3 version: 0.0.4
description: Birthday reminder plugin. Reminder before 5,3,1 and birthday days. description: Birthday reminder plugin. Reminder before 5,3,1 and birthday days.
authors: Evgeniy Popov <evgeniypopov@gmail.com> authors: Evgeniy Popov <evgeniypopov@gmail.com>
homepage: http://trac-plugins.gajim.org/wiki/BirthdayReminderPlugin homepage: http://trac-plugins.gajim.org/wiki/BirthdayReminderPlugin
min_gajim_version: 0.16.11
...@@ -4,13 +4,13 @@ import datetime ...@@ -4,13 +4,13 @@ import datetime
from xml.dom.minidom import * from xml.dom.minidom import *
from gi.repository import GObject from gi.repository import GObject
from plugins import GajimPlugin from gajim.plugins import GajimPlugin
from plugins.helpers import log_calls from gajim.plugins.helpers import log_calls
from notify import popup from gajim.notify import popup
from common import configpaths from gajim.common import configpaths
from common import gajim from gajim.common import app
from common import ged from gajim.common import ged
class BirthDayPlugin(GajimPlugin): class BirthDayPlugin(GajimPlugin):
...@@ -30,8 +30,8 @@ class BirthDayPlugin(GajimPlugin): ...@@ -30,8 +30,8 @@ class BirthDayPlugin(GajimPlugin):
def check_birthdays(self, account=None): def check_birthdays(self, account=None):
def show_popup(account, jid): def show_popup(account, jid):
contact_instances = gajim.contacts.get_contacts(account, jid) contact_instances = app.contacts.get_contacts(account, jid)
contact = gajim.contacts.get_highest_prio_contact_from_contacts( contact = app.contacts.get_highest_prio_contact_from_contacts(
contact_instances) contact_instances)
if contact: if contact:
nick = GObject.markup_escape_text(contact.get_shown_name()) nick = GObject.markup_escape_text(contact.get_shown_name())
...@@ -44,7 +44,7 @@ class BirthDayPlugin(GajimPlugin): ...@@ -44,7 +44,7 @@ class BirthDayPlugin(GajimPlugin):
popup('Send message', contact.jid, account, msg_type='', \ popup('Send message', contact.jid, account, msg_type='', \
path_to_image=image, title=title, text=text + ' ' + nick) path_to_image=image, title=title, text=text + ' ' + nick)
accounts = gajim.contacts.get_accounts() accounts = app.contacts.get_accounts()
vcards = [] vcards = []
date_dict = {} date_dict = {}
for jid in glob.glob(self.vcard_path + '*@*'): for jid in glob.glob(self.vcard_path + '*@*'):
......
...@@ -3,12 +3,12 @@ ...@@ -3,12 +3,12 @@
from gi.repository import GObject from gi.repository import GObject
from plugins import GajimPlugin from gajim.plugins import GajimPlugin
from plugins.helpers import log_calls from gajim.plugins.helpers import log_calls
from common import ged from gajim.common import ged
from common import gajim from gajim.common import app
from common import helpers from gajim.common import helpers
import gtkgui_helpers from gajim import gtkgui_helpers
import unicodedata import unicodedata
def paragraph_direction_mark(text): def paragraph_direction_mark(text):
...@@ -44,7 +44,7 @@ class ChatstatePlugin(GajimPlugin): ...@@ -44,7 +44,7 @@ class ChatstatePlugin(GajimPlugin):
if not self.active: if not self.active:
return return
contact = gajim.contacts.get_contact_from_full_jid(obj.conn.name, contact = app.contacts.get_contact_from_full_jid(obj.conn.name,
obj.fjid) obj.fjid)
if not contact: if not contact:
return return
...@@ -53,12 +53,12 @@ class ChatstatePlugin(GajimPlugin): ...@@ -53,12 +53,12 @@ class ChatstatePlugin(GajimPlugin):
if chatstate not in self.chatstates.keys(): if chatstate not in self.chatstates.keys():
return return
self.model = gajim.interface.roster.model self.model = app.interface.roster.model
child_iters = gajim.interface.roster._get_contact_iter(obj.jid, child_iters = app.interface.roster._get_contact_iter(obj.jid,
obj.conn.name, contact, self.model) obj.conn.name, contact, self.model)
name = GObject.markup_escape_text(contact.get_shown_name()) name = GObject.markup_escape_text(contact.get_shown_name())
contact_instances = gajim.contacts.get_contacts(obj.conn.name, contact_instances = app.contacts.get_contacts(obj.conn.name,
contact.jid) contact.jid)
# Show resource counter # Show resource counter
...@@ -74,7 +74,7 @@ class ChatstatePlugin(GajimPlugin): ...@@ -74,7 +74,7 @@ class ChatstatePlugin(GajimPlugin):
if chatstate != 'gone': if chatstate != 'gone':
color = self.chatstates[chatstate] color = self.chatstates[chatstate]
name = '<span foreground="%s">%s</span>' % (color, name) name = '<span foreground="%s">%s</span>' % (color, name)
if contact.status and gajim.config.get( if contact.status and app.config.get(
'show_status_msgs_in_roster'): 'show_status_msgs_in_roster'):
status = contact.status.strip() status = contact.status.strip()
if status != '': if status != '':
...@@ -87,17 +87,17 @@ class ChatstatePlugin(GajimPlugin): ...@@ -87,17 +87,17 @@ class ChatstatePlugin(GajimPlugin):
@log_calls('ChatstatePlugin') @log_calls('ChatstatePlugin')
def activate(self): def activate(self):
color = gtkgui_helpers.get_fade_color(gajim.interface.roster.tree, color = gtkgui_helpers.get_fade_color(app.interface.roster.tree,
False, False) False, False)
self.status_color = '#%04x%04x%04x' % (color.red, color.green, self.status_color = '#%04x%04x%04x' % (color.red, color.green,
color.blue) color.blue)
theme = gajim.config.get('roster_theme') theme = app.config.get('roster_theme')
self.chatstates = {'active': gajim.config.get('inmsgcolor'), self.chatstates = {'active': app.config.get('inmsgcolor'),
'composing': gajim.config.get_per('themes', theme, 'composing': app.config.get_per('themes', theme,
'state_composing_color'), 'state_composing_color'),
'inactive': gajim.config.get_per('themes', theme, 'inactive': app.config.get_per('themes', theme,
'state_inactive_color'), 'state_inactive_color'),
'paused': gajim.config.get_per('themes', theme, 'paused': app.config.get_per('themes', theme,
'state_paused_color'), 'state_paused_color'),
'gone': None, } 'gone': None, }
self.active = True self.active = True
......
[info] [info]
name: Chatstate in roster name: Chatstate in roster
short_name: chatstate short_name: chatstate
version: 0.5.2 version: 0.5.3
description: Chat State Notifications in roster. description: Chat State Notifications in roster.
Font color of the contact varies depending on the chat state. Font color of the contact varies depending on the chat state.
The plugin does not work if you use custom font color for contacts in roster. The plugin does not work if you use custom font color for contacts in roster.
authors = Denis Fomin <fominde@gmail.com> authors = Denis Fomin <fominde@gmail.com>
homepage = http://trac-plugins.gajim.org/wiki/ChatstatePlugin homepage = http://trac-plugins.gajim.org/wiki/ChatstatePlugin
min_gajim_version: 0.16.10 min_gajim_version: 0.16.11
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
from gi.repository import Gtk from gi.repository import Gtk
from gi.repository import Gdk from gi.repository import Gdk
from common import gajim from gajim.common import app
from plugins import GajimPlugin from gajim.plugins import GajimPlugin
from plugins.helpers import log_calls from gajim.plugins.helpers import log_calls
class ClickableNicknames(GajimPlugin): class ClickableNicknames(GajimPlugin):
...@@ -23,7 +23,7 @@ class ClickableNicknames(GajimPlugin): ...@@ -23,7 +23,7 @@ class ClickableNicknames(GajimPlugin):
self.gc_controls = {} self.gc_controls = {}
self.tag_names = [] self.tag_names = []
colors = gajim.config.get('gc_nicknames_colors') colors = app.config.get('gc_nicknames_colors')
colors = colors.split(':') colors = colors.split(':')
for i, color in enumerate(colors): for i, color in enumerate(colors):
tagname = 'gc_nickname_color_' + str(i) tagname = 'gc_nickname_color_' + str(i)
...@@ -31,7 +31,7 @@ class ClickableNicknames(GajimPlugin): ...@@ -31,7 +31,7 @@ class ClickableNicknames(GajimPlugin):
@log_calls('ClickableNicknamesPlugin') @log_calls('ClickableNicknamesPlugin')
def activate(self): def activate(self):
for gc_control in gajim.interface.msg_win_mgr.get_controls('gc'): for gc_control in app.interface.msg_win_mgr.get_controls('gc'):
# TODO support minimized groupchat # TODO support minimized groupchat
if gc_control not in self.gc_controls.keys(): if gc_control not in self.gc_controls.keys():
control = Base(self, gc_control) control = Base(self, gc_control)
...@@ -118,18 +118,18 @@ class Base(object): ...@@ -118,18 +118,18 @@ class Base(object):
end_iter.forward_char() end_iter.forward_char()
buffer_ = self.textview.tv.get_buffer() buffer_ = self.textview.tv.get_buffer()
word = buffer_.get_text(begin_iter, end_iter, True) word = buffer_.get_text(begin_iter, end_iter, True)
nick = word.rstrip().rstrip(gajim.config.get('after_nickname')) nick = word.rstrip().rstrip(app.config.get('after_nickname'))
if nick.startswith('* '): if nick.startswith('* '):
nick = nick.lstrip('* ').split(' ')[0] nick = nick.lstrip('* ').split(' ')[0]
nick = nick.lstrip(gajim.config.get('before_nickname')) nick = nick.lstrip(app.config.get('before_nickname'))
nicks = gajim.contacts.get_nick_list(self.chat_control.account, nicks = app.contacts.get_nick_list(self.chat_control.account,
self.chat_control.room_jid) self.chat_control.room_jid)
if nick[1:] not in nicks: if nick[1:] not in nicks:
return return
message_buffer = self.chat_control.msg_textview.get_buffer() message_buffer = self.chat_control.msg_textview.get_buffer()
if message_buffer.get_char_count() < 1: if message_buffer.get_char_count() < 1:
nick = nick + gajim.config.get('gc_refer_to_nick_char') nick = nick + app.config.get('gc_refer_to_nick_char')
else: else:
start, end = message_buffer.get_bounds() start, end = message_buffer.get_bounds()
if message_buffer.get_text(start, end, True)[-1] != ' ': if message_buffer.get_text(start, end, True)[-1] != ' ':
......
[info] [info]
name: Clickable Nicknames name: Clickable Nicknames
short_name: clickable_nicknames short_name: clickable_nicknames
version: 0.3 version: 0.4
description: Clickable nicknames in the conversation textview. description: Clickable nicknames in the conversation textview.
authors: Andrey Musikhin <melomansegfault@gmail.com> authors: Andrey Musikhin <melomansegfault@gmail.com>
Denis Fomin <fominde@gmail.com> Denis Fomin <fominde@gmail.com>
homepage: http://trac-plugins.gajim.org/wiki/ClickableNicknamesPlugin homepage: http://trac-plugins.gajim.org/wiki/ClickableNicknamesPlugin
min_gajim_version: 0.16.10 min_gajim_version: 0.16.11
...@@ -5,12 +5,12 @@ from gi.repository import Gtk ...@@ -5,12 +5,12 @@ from gi.repository import Gtk
from gi.repository import GdkPixbuf from gi.repository import GdkPixbuf
import os import os
from plugins.gui import GajimPluginConfigDialog from gajim.plugins.gui import GajimPluginConfigDialog
from plugins import GajimPlugin from gajim.plugins import GajimPlugin
from plugins.helpers import log_calls from gajim.plugins.helpers import log_calls
from common import ged from gajim.common import ged
from common import gajim from gajim.common import app
import cell_renderer_image import gajim.cell_renderer_image
clients = { clients = {
'http://gajim.org': ['gajim.png', 'Gajim'], 'http://gajim.org': ['gajim.png', 'Gajim'],
...@@ -230,7 +230,7 @@ class ClientsIconsPlugin(GajimPlugin): ...@@ -230,7 +230,7 @@ class ClientsIconsPlugin(GajimPlugin):
vcard_table): vcard_table):
if not self.config['show_in_tooltip']: if not self.config['show_in_tooltip']:
return return
if len(contacts) == 1 and contacts[0].jid in gajim.get_our_jids(): if len(contacts) == 1 and contacts[0].jid in app.get_our_jids():
return return
if contacts[0].is_groupchat(): if contacts[0].is_groupchat():
return return
...@@ -386,9 +386,9 @@ class ClientsIconsPlugin(GajimPlugin): ...@@ -386,9 +386,9 @@ class ClientsIconsPlugin(GajimPlugin):
chat_control.model.set_sort_column_id(1, Gtk.SortType.ASCENDING) chat_control.model.set_sort_column_id(1, Gtk.SortType.ASCENDING)
chat_control.list_treeview.set_model(chat_control.model) chat_control.list_treeview.set_model(chat_control.model)
# draw roster # draw roster
for nick in gajim.contacts.get_nick_list(chat_control.account, for nick in app.contacts.get_nick_list(chat_control.account,
chat_control.room_jid): chat_control.room_jid):
gc_contact = gajim.contacts.get_gc_contact(chat_control.account, gc_contact = app.contacts.get_gc_contact(chat_control.account,
chat_control.room_jid, nick) chat_control.room_jid, nick)
iter_ = chat_control.add_contact_to_roster(nick, gc_contact.show, iter_ = chat_control.add_contact_to_roster(nick, gc_contact.show,
gc_contact.role, gc_contact.affiliation, gc_contact.status, gc_contact.role, gc_contact.affiliation, gc_contact.status,
...@@ -430,7 +430,7 @@ class ClientsIconsPlugin(GajimPlugin): ...@@ -430,7 +430,7 @@ class ClientsIconsPlugin(GajimPlugin):
@log_calls('ClientsIconsPlugin') @log_calls('ClientsIconsPlugin')
def activate(self): def activate(self):
self.active = None self.active = None
roster = gajim.interface.roster roster = app.interface.roster
col = Gtk.TreeViewColumn() col = Gtk.TreeViewColumn()
roster.nb_ext_renderers += 1 roster.nb_ext_renderers += 1
self.renderer_num = 10 + roster.nb_ext_renderers self.renderer_num = 10 + roster.nb_ext_renderers
...@@ -459,7 +459,7 @@ class ClientsIconsPlugin(GajimPlugin): ...@@ -459,7 +459,7 @@ class ClientsIconsPlugin(GajimPlugin):
@log_calls('ClientsIconsPlugin') @log_calls('ClientsIconsPlugin')
def deactivate(self): def deactivate(self):
self.active = None self.active = None
roster = gajim.interface.roster roster = app.interface.roster
roster.nb_ext_renderers -= 1 roster.nb_ext_renderers -= 1
col = roster.tree.get_column(0) col = roster.tree.get_column(0)