InlineNotify.py :  » Network » emesene » emesene-1.6.2 » plugins_base » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Network » emesene 
emesene » emesene 1.6.2 » plugins_base » InlineNotify.py
# -*- coding: utf-8 -*-

import gtk
import gobject

import Plugin
import desktop
from emesenelib.common import escape
from emesenelib.common import unescape
from Parser import PangoDataType

ERROR = ''

class MainClass(Plugin.Plugin):
    '''Main plugin class'''
    
    description = _('Notifies various events through messages in your conversation')
    authors = {'Tito': 'tito@webtito.be'}
    website = 'http://perso.webtito.be'
    displayName = _('Inline notifications')
    name = 'InlineNotify'
    
    def __init__(self, controller, msn):
        '''Contructor'''
        Plugin.Plugin.__init__(self, controller, msn, 1000)
        self.controller = controller
        self.description = _('Notifies various events through messages in your conversation')
        self.authors = {'Tito': 'tito@webtito.be'}
        self.website = 'http://perso.webtito.be'
        self.displayName = _('Inline notifications')
        self.name = 'InlineNotify'

        self.enabled = False
        self.config = controller.config
        self.config.readPluginConfig(self.name)
        
        self.signals = {}
        self.signals['nick-changed'] = self.nick
        self.signals['contact-status-change'] = self.status
        self.signals['display-picture-changed'] = self.avatar
        self.signals['personal-message-changed'] = self.personal
        self.ids = []
        
        self.status = {
            'NLN' : _('online'),
            'AWY' : _('away'),
            'BSY' : _('busy'),
            'BRB' : _('be right back'),
            'PHN' : _('on the phone'),
            'LUN' : _('gone to lunch'),
            'IDL' : _('idle'),
            'FLN' : _('offline') }
        
    def start(self):
        self.enabled = True
        for (key, value) in self.signals.iteritems():
            self.ids.append(self.msn.connect(key, value))
    
    def stop(self):
        for identifier in self.ids:
            self.msn.disconnect(identifier)
        self.ids = []
        self.enabled = False
        return True
    
    def check(self):
        return (True, 'Ok')
    
    def nick(self, msnp, mail, nick):
        result = self.controller.conversationManager.getOpenConversation(mail)
        if result != None:
            window, conversation = result
            alias = self.controller.contacts.get_display_name(mail)
            if alias != nick: mail = alias
            text = _('%(mail)s is now called %(nick)s') % {'mail': mail, 'nick': nick}
            conversation.appendOutputText(None, text, 'information')
    
    def status(self, msnp, mail, status):
        result = self.controller.conversationManager.getOpenConversation(mail)
        if result != None:
            window, conversation = result
            nick = self.controller.contacts.get_display_name(mail)
            text = _('%(nick)s is now %(status)s') % {'nick' : nick, 'status' : self.status[status]}
            conversation.appendOutputText(None, text, 'information')
    
    def avatar(self, mnsp, p2p, msnobj, mail):
        result = self.controller.conversationManager.getOpenConversation(mail)
        if result != None:
            window, conversation = result
            nick = self.controller.contacts.get_display_name(mail)
            text = _('%s has a new avatar') % nick
            conversation.appendOutputText(None, text, 'information')
    
    def personal(self, msnp, mail, pm):
        result = self.controller.conversationManager.getOpenConversation(mail)
        if result != None:
            window, conversation = result
            nick = self.controller.contacts.get_display_name(mail)
            if pm != '': text = _('%(nick)s has a new personal message : %(message)s') % {'nick' : nick, 'message' : pm}
            else: text = _('%s doesn\'t have personal message anymore') % nick
            conversation.appendOutputText(None, text, 'information')
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.