[whiteboard plugin] raise error when python-pygoocanvas is not installed

This commit is contained in:
Yann Leboulanger 2010-11-01 17:32:27 +01:00
parent ebde7d4333
commit ea0f12b2f5
3 changed files with 16 additions and 3 deletions

View file

@ -2,6 +2,6 @@
name: Whiteboard name: Whiteboard
short_name: whiteboard short_name: whiteboard
version: 0.1 version: 0.1
description: Shows a whiteboard in chat. description: Shows a whiteboard in chat. python-pygoocanvas is required.
authors = Yann Leboulanger <asterix@lagaule.org> authors = Yann Leboulanger <asterix@lagaule.org>
homepage = www.gajim.org homepage = www.gajim.org

View file

@ -31,6 +31,7 @@ Whiteboard plugin.
from common import helpers from common import helpers
from common import gajim from common import gajim
from plugins import GajimPlugin from plugins import GajimPlugin
from plugins.plugin import GajimPluginException
from plugins.helpers import log_calls, log from plugins.helpers import log_calls, log
import common.xmpp import common.xmpp
import gtk import gtk
@ -40,7 +41,7 @@ from common.jingle_session import JingleSession
from common.jingle_content import JingleContent from common.jingle_content import JingleContent
from common.jingle_transport import JingleTransport, TransportType from common.jingle_transport import JingleTransport, TransportType
import dialogs import dialogs
from whiteboard_widget import Whiteboard from whiteboard_widget import Whiteboard, HAS_GOOCANVAS
from common import xmpp from common import xmpp
from common import caps_cache from common import caps_cache
@ -81,6 +82,8 @@ class WhiteboardPlugin(GajimPlugin):
@log_calls('WhiteboardPlugin') @log_calls('WhiteboardPlugin')
def activate(self): def activate(self):
if not HAS_GOOCANVAS:
raise GajimPluginException('python-pygoocanvas is missing!')
if NS_JINGLE_SXE not in gajim.gajim_common_features: if NS_JINGLE_SXE not in gajim.gajim_common_features:
gajim.gajim_common_features.append(NS_JINGLE_SXE) gajim.gajim_common_features.append(NS_JINGLE_SXE)
if NS_SXE not in gajim.gajim_common_features: if NS_SXE not in gajim.gajim_common_features:
@ -155,6 +158,8 @@ class WhiteboardPlugin(GajimPlugin):
@log_calls('WhiteboardPlugin') @log_calls('WhiteboardPlugin')
def _nec_jingle_received(self, obj): def _nec_jingle_received(self, obj):
if not HAS_GOOCANVAS:
return
content_types = set(c[0] for c in obj.contents) content_types = set(c[0] for c in obj.contents)
if 'xhtml' not in content_types: if 'xhtml' not in content_types:
return return
@ -163,6 +168,8 @@ class WhiteboardPlugin(GajimPlugin):
@log_calls('WhiteboardPlugin') @log_calls('WhiteboardPlugin')
def _nec_jingle_connected(self, obj): def _nec_jingle_connected(self, obj):
if not HAS_GOOCANVAS:
return
account = obj.conn.name account = obj.conn.name
ctrl = (gajim.interface.msg_win_mgr.get_control(obj.fjid, account) ctrl = (gajim.interface.msg_win_mgr.get_control(obj.fjid, account)
or gajim.interface.msg_win_mgr.get_control(obj.jid, account)) or gajim.interface.msg_win_mgr.get_control(obj.jid, account))
@ -185,6 +192,8 @@ class WhiteboardPlugin(GajimPlugin):
@log_calls('WhiteboardPlugin') @log_calls('WhiteboardPlugin')
def _nec_raw_message(self, obj): def _nec_raw_message(self, obj):
if not HAS_GOOCANVAS:
return
if obj.stanza.getTag('sxe', namespace=NS_SXE): if obj.stanza.getTag('sxe', namespace=NS_SXE):
account = obj.conn.name account = obj.conn.name

View file

@ -20,7 +20,11 @@
import gtk import gtk
import gtkgui_helpers import gtkgui_helpers
import goocanvas try:
import goocanvas
HAS_GOOCANVAS = True
except:
HAS_GOOCANVAS = False
from common.xmpp import Node from common.xmpp import Node
from common import gajim from common import gajim
from common import i18n from common import i18n