move dbus_support to common; try to do exceptions for D-Bus [Dimitur please have a look]
This commit is contained in:
parent
9659b03732
commit
1f6e5bcd7e
|
@ -21,6 +21,8 @@ import sys
|
|||
from common import gajim
|
||||
from common import exceptions
|
||||
|
||||
_GAJIM_ERROR_IFACE = 'org.gajim.dbus.Error'
|
||||
|
||||
try:
|
||||
import dbus
|
||||
import dbus.service
|
||||
|
@ -94,4 +96,13 @@ def get_interface(interface, path):
|
|||
|
||||
def get_notifications_interface():
|
||||
'''Returns the notifications interface.'''
|
||||
return get_interface('org.freedesktop.Notifications','/org/freedesktop/Notifications')
|
||||
return get_interface('org.freedesktop.Notifications',
|
||||
'/org/freedesktop/Notifications')
|
||||
|
||||
if supported:
|
||||
class MissingArgument(dbus.DBusException):
|
||||
_dbus_error_name = _GAJIM_ERROR_IFACE + '.MissingArgument'
|
||||
|
||||
class InvalidArgument(dbus.DBusException):
|
||||
'''Raised when one of the provided arguments is invalid.'''
|
||||
_dbus_error_name = _GAJIM_ERROR_IFACE + '.InvalidArgument'
|
|
@ -2,16 +2,10 @@
|
|||
##
|
||||
## Contributors for this file:
|
||||
## - Yann Le Boulanger <asterix@lagaule.org>
|
||||
## - Nikos Kouremenos <kourem@gmail.com>
|
||||
## -
|
||||
##
|
||||
## Copyright (C) 2003-2004 Yann Le Boulanger <asterix@lagaule.org>
|
||||
## Vincent Hanquez <tab@snarc.org>
|
||||
## Copyright (C) 2005 Yann Le Boulanger <asterix@lagaule.org>
|
||||
## Vincent Hanquez <tab@snarc.org>
|
||||
## Nikos Kouremenos <kourem@gmail.com>
|
||||
## Dimitur Kirov <dkirov@gmail.com>
|
||||
## Travis Shirk <travis@pobox.com>
|
||||
## Norman Rasmussen <norman@rasmussen.co.za>
|
||||
## Copyright (C) 2005-2006 Yann Le Boulanger <asterix@lagaule.org>
|
||||
## Nikos Kouremenos <kourem@gmail.com>
|
||||
##
|
||||
## This program is free software; you can redistribute it and/or modify
|
||||
## it under the terms of the GNU General Public License as published
|
||||
|
|
|
@ -25,7 +25,7 @@ import gtkgui_helpers
|
|||
from common import gajim
|
||||
from common import helpers
|
||||
|
||||
import dbus_support
|
||||
from common import dbus_support
|
||||
if dbus_support.supported:
|
||||
import dbus
|
||||
import dbus.glib
|
||||
|
|
|
@ -23,7 +23,7 @@ from common import helpers
|
|||
from time import time
|
||||
from dialogs import AddNewContactWindow, NewChatDialog
|
||||
|
||||
import dbus_support
|
||||
from common import dbus_support
|
||||
if dbus_support.supported:
|
||||
import dbus
|
||||
if dbus_support:
|
||||
|
@ -228,7 +228,7 @@ class SignalObject(dbus.service.Object):
|
|||
message to 'jid', using account(optional) 'account' '''
|
||||
jid, account = self._get_real_arguments(args, 2)
|
||||
if not jid:
|
||||
# FIXME: raise exception for missing argument (dbus0.35+)
|
||||
raise MissingArgument
|
||||
return None
|
||||
jid = self._get_real_jid(jid, account)
|
||||
|
||||
|
@ -277,7 +277,7 @@ class SignalObject(dbus.service.Object):
|
|||
status, message, account = self._get_real_arguments(args, 3)
|
||||
if status not in ('offline', 'online', 'chat',
|
||||
'away', 'xa', 'dnd', 'invisible'):
|
||||
# FIXME: raise exception for bad status (dbus0.35)
|
||||
raise InvalidArgument
|
||||
return None
|
||||
if account:
|
||||
gobject.idle_add(gajim.interface.roster.send_status, account,
|
||||
|
@ -305,7 +305,7 @@ class SignalObject(dbus.service.Object):
|
|||
if not isinstance(jid, unicode):
|
||||
jid = unicode(jid)
|
||||
if not jid:
|
||||
# FIXME: raise exception for missing argument (0.3+)
|
||||
raise MissingArgument
|
||||
return None
|
||||
jid = self._get_real_jid(jid, account)
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ from chat_control import ChatControl
|
|||
from groupchat_control import GroupchatControl
|
||||
from groupchat_control import PrivateChatControl
|
||||
|
||||
import dbus_support
|
||||
from common import dbus_support
|
||||
if dbus_support.supported:
|
||||
from music_track_listener import MusicTrackListener
|
||||
|
||||
|
|
Loading…
Reference in New Issue