Ability to register new incoming network events (based on exisiting one) added. Modify-only network events are possible (eg. add some text each message, but don't create any new global event). Events creation can be chained. Examples of new network events classes are in New Events Example plugin. Events from src/gajim.py now all go through Global Events Dispatcher and only through it (easy to modify, in chain, data passed with them).
88 lines
No EOL
2.7 KiB
Python
88 lines
No EOL
2.7 KiB
Python
# -*- coding: utf-8 -*-
|
|
##
|
|
## This file is part of Gajim.
|
|
##
|
|
## Gajim is free software; you can redistribute it and/or modify
|
|
## it under the terms of the GNU General Public License as published
|
|
## by the Free Software Foundation; version 3 only.
|
|
##
|
|
## Gajim is distributed in the hope that it will be useful,
|
|
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
## GNU General Public License for more details.
|
|
##
|
|
## You should have received a copy of the GNU General Public License
|
|
## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
|
##
|
|
'''
|
|
Events notifications using Snarl
|
|
|
|
Fancy events notifications under Windows using Snarl infrastructure.
|
|
|
|
:note: plugin is at proof-of-concept state.
|
|
|
|
:author: Mateusz Biliński <mateusz@bilinski.it>
|
|
:since: 15th August 2008
|
|
:copyright: Copyright (2008) Mateusz Biliński <mateusz@bilinski.it>
|
|
:license: GPL
|
|
'''
|
|
|
|
import new
|
|
from pprint import pformat
|
|
|
|
#import PySnarl
|
|
|
|
from common import gajim
|
|
from plugins import GajimPlugin
|
|
from plugins.helpers import log_calls, log
|
|
from common import ged
|
|
|
|
class SnarlNotificationsPlugin(GajimPlugin):
|
|
name = u'Snarl Notifications'
|
|
short_name = u'snarl_notifications'
|
|
version = u'0.1'
|
|
description = u'''Shows events notification using Snarl (http://www.fullphat.net/) under Windows. Snarl needs to be installed in system.
|
|
PySnarl bindings are used (http://code.google.com/p/pysnarl/).'''
|
|
authors = [u'Mateusz Biliński <mateusz@bilinski.it>']
|
|
homepage = u'http://blog.bilinski.it'
|
|
|
|
@log_calls('SnarlNotificationsPlugin')
|
|
def init(self):
|
|
self.config_dialog = None
|
|
#self.gui_extension_points = {}
|
|
#self.config_default_values = {}
|
|
|
|
self.events_handlers = {'NewMessage' : (ged.POSTCORE, self.newMessage)}
|
|
|
|
def activate(self):
|
|
pass
|
|
|
|
def deactivate(self):
|
|
pass
|
|
|
|
def newMessage(self, args):
|
|
event_name = "NewMessage"
|
|
data = args
|
|
account = data[0]
|
|
jid = data[1][0]
|
|
jid_without_resource = gajim.get_jid_without_resource(jid)
|
|
msg = data[1][1]
|
|
msg_type = data[1][4]
|
|
if msg_type == 'chat':
|
|
nickname = gajim.get_contact_name_from_jid(account,
|
|
jid_without_resource)
|
|
elif msg_type == 'pm':
|
|
nickname = gajim.get_resource_from_jid(jid)
|
|
|
|
print "Event '%s' occured. Arguments: %s\n\n===\n"%(event_name, pformat(args))
|
|
print "Event '%s' occured. Arguments: \naccount = %s\njid = %s\nmsg = %s\nnickname = %s"%(
|
|
event_name, account, jid, msg, nickname)
|
|
|
|
|
|
#if PySnarl.snGetVersion() != False:
|
|
#(major, minor) = PySnarl.snGetVersion()
|
|
#print "Found Snarl version",str(major)+"."+str(minor),"running."
|
|
#PySnarl.snShowMessage(nickname, msg[:20]+'...')
|
|
#else:
|
|
#print "Sorry Snarl does not appear to be running"
|
|
|