[tuxdroid-svn] r327 - in software: . tux_pidgin tux_pidgin/trunk
Status: Beta
Brought to you by:
ks156
From: Thomas_C <c2m...@c2...> - 2007-05-29 17:55:21
|
Author: Thomas_C Date: 2007-05-29 19:54:51 +0200 (Tue, 29 May 2007) New Revision: 327 Added: software/tux_pidgin/ software/tux_pidgin/branches/ software/tux_pidgin/tags/ software/tux_pidgin/trunk/ software/tux_pidgin/trunk/tux_pidgin.py Log: Initial import of Tux_pidgin Added: software/tux_pidgin/trunk/tux_pidgin.py =================================================================== --- software/tux_pidgin/trunk/tux_pidgin.py (rev 0) +++ software/tux_pidgin/trunk/tux_pidgin.py 2007-05-29 17:54:51 UTC (rev 327) @@ -0,0 +1,118 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# ----------------------------------------------------------------------------- +# Tux Droid - Pidgin InterFace +# +# This program 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; either version 2, or (at your option) +# any later version. +# +# This program 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 this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. +# ----------------------------------------------------------------------------- +# $Id: $ +# ----------------------------------------------------------------------------- + +""" +CHANGES +======= +2007/05/26 - version 0.2: + - Tuxdroid speaks with TTS voices that say the contact on pidgin + +2007/05/21 - version 0.1: + - Initial version + +TODO LIST +======== +- Make some actions when a conversation started +- Internationalization +- Improvement of conversion received message (html2text) + +""" + +__author__ = "Thomas CARPENTIER <car...@fr...> & Julien Ruchaud" +__appname__ = "TuxPidgin" +__version__ = "0.2" +__date__ = "2007/05/26" +__license__ = "GPL" + +# ----------------------------------------------- +# Initalization of modules +# uses objects "tux" and "tss" +# ----------------------------------------------- +import sys +sys.path.append('/opt/tuxdroid/api/python') +from tux import * + +# Others +import dbus +import dbus.glib +import dbus.decorators +import gobject +import os +import re +import time + + +# This method is execute when a message is receive +def received_im_msg(account, name, message, conversation, flags): + buddy = purple.PurpleFindBuddy(account, name) + if buddy != 0: + alias = purple.PurpleBuddyGetAlias(buddy) + else: + alias = name + text = "%s says %s" % (alias, message) + text = re.sub("<.*?>", "", text)#html2text + + + tuxspeak(text) + +# This method is excute when a buddy is sign on +def buddy_signed_on(buddyid): + alias = purple.PurpleBuddyGetAlias(buddyid) + + text = "%s is online" % alias + text=text.encode('utf-8') + tux_speak(text) + +# Tux speak the text +def tux_speak(text): + print text + tux.cmd.mouth_open() + tux.tts.select_voice(2,100) + tux.tts.speak(text) + tux.cmd.mouth_close() + +# Main + +bus = dbus.SessionBus() + +try: + obj = bus.get_object("im.pidgin.purple.PurpleService", "/im/pidgin/purple/PurpleObject") + purple = dbus.Interface(obj, "im.pidgin.purple.PurpleInterface") +except dbus.DBusException: + print "Pidgin is not launched" + sys.exit(0) + + + +bus.add_signal_receiver(received_im_msg, + dbus_interface = "im.pidgin.purple.PurpleInterface", + signal_name = "ReceivedImMsg") + +bus.add_signal_receiver(buddy_signed_on, + dbus_interface = "im.pidgin.purple.PurpleInterface", + signal_name = "BuddySignedOn") + +print "TuxPidgin is started" +loop = gobject.MainLoop() +loop.run() |