services/presence/server_plugin: Use non-deprecated handle type constants.

(CONNECTION_HANDLE_TYPE_foo is deprecated in favour of HANDLE_TYPE_foo.)
Also rewrap imports to be 80 characters wide.
This commit is contained in:
Simon McVittie 2007-05-24 11:05:52 +01:00
parent e7e6c28394
commit f69e06247f

View File

@ -27,15 +27,16 @@ import os
import sys import sys
import psutils import psutils
from telepathy.client import ConnectionManager, ManagerRegistry, Connection, Channel from telepathy.client import (ConnectionManager, ManagerRegistry, Connection,
from telepathy.interfaces import ( Channel)
CONN_MGR_INTERFACE, CONN_INTERFACE, CHANNEL_TYPE_CONTACT_LIST, CHANNEL_INTERFACE_GROUP, CONN_INTERFACE_ALIASING, from telepathy.interfaces import (CONN_MGR_INTERFACE, CONN_INTERFACE,
CONN_INTERFACE_AVATARS, CONN_INTERFACE_PRESENCE, CHANNEL_TYPE_TEXT, CHANNEL_TYPE_STREAMED_MEDIA, CHANNEL_TYPE_CONTACT_LIST, CHANNEL_INTERFACE_GROUP,
PROPERTIES_INTERFACE) CONN_INTERFACE_ALIASING, CONN_INTERFACE_AVATARS, CONN_INTERFACE_PRESENCE,
from telepathy.constants import ( CHANNEL_TYPE_TEXT, CHANNEL_TYPE_STREAMED_MEDIA, PROPERTIES_INTERFACE)
CONNECTION_HANDLE_TYPE_NONE, CONNECTION_HANDLE_TYPE_CONTACT, from telepathy.constants import (HANDLE_TYPE_CONTACT,
CONNECTION_STATUS_CONNECTED, CONNECTION_STATUS_DISCONNECTED, CONNECTION_STATUS_CONNECTING, HANDLE_TYPE_LIST, HANDLE_TYPE_CONTACT, HANDLE_TYPE_ROOM,
CONNECTION_HANDLE_TYPE_LIST, CONNECTION_HANDLE_TYPE_CONTACT, CONNECTION_HANDLE_TYPE_ROOM, CONNECTION_STATUS_CONNECTED, CONNECTION_STATUS_DISCONNECTED,
CONNECTION_STATUS_CONNECTING,
CONNECTION_STATUS_REASON_AUTHENTICATION_FAILED, CONNECTION_STATUS_REASON_AUTHENTICATION_FAILED,
PROPERTY_FLAG_WRITE) PROPERTY_FLAG_WRITE)
@ -246,7 +247,7 @@ class ServerPlugin(gobject.GObject):
if item[CONN_INTERFACE].GetProtocol() != _PROTOCOL: if item[CONN_INTERFACE].GetProtocol() != _PROTOCOL:
continue continue
if item[CONN_INTERFACE].GetStatus() == CONNECTION_STATUS_CONNECTED: if item[CONN_INTERFACE].GetStatus() == CONNECTION_STATUS_CONNECTED:
test_handle = item[CONN_INTERFACE].RequestHandles(CONNECTION_HANDLE_TYPE_CONTACT, [our_name])[0] test_handle = item[CONN_INTERFACE].RequestHandles(HANDLE_TYPE_CONTACT, [our_name])[0]
if item[CONN_INTERFACE].GetSelfHandle() != test_handle: if item[CONN_INTERFACE].GetSelfHandle() != test_handle:
continue continue
return item return item
@ -311,9 +312,9 @@ class ServerPlugin(gobject.GObject):
name -- publish/subscribe, for the type of channel name -- publish/subscribe, for the type of channel
""" """
handle = self._conn[CONN_INTERFACE].RequestHandles( handle = self._conn[CONN_INTERFACE].RequestHandles(
CONNECTION_HANDLE_TYPE_LIST, [name])[0] HANDLE_TYPE_LIST, [name])[0]
chan_path = self._conn[CONN_INTERFACE].RequestChannel( chan_path = self._conn[CONN_INTERFACE].RequestChannel(
CHANNEL_TYPE_CONTACT_LIST, CONNECTION_HANDLE_TYPE_LIST, CHANNEL_TYPE_CONTACT_LIST, HANDLE_TYPE_LIST,
handle, True) handle, True)
channel = Channel(self._conn.service_name, chan_path) channel = Channel(self._conn.service_name, chan_path)
# hack # hack
@ -472,7 +473,7 @@ class ServerPlugin(gobject.GObject):
return return
self._conn[CONN_INTERFACE].RequestChannel(CHANNEL_TYPE_TEXT, self._conn[CONN_INTERFACE].RequestChannel(CHANNEL_TYPE_TEXT,
CONNECTION_HANDLE_TYPE_ROOM, handles[0], True, HANDLE_TYPE_ROOM, handles[0], True,
reply_handler=lambda *args: self._join_activity_create_channel_cb(activity_id, signal, handles[0], userdata, *args), reply_handler=lambda *args: self._join_activity_create_channel_cb(activity_id, signal, handles[0], userdata, *args),
error_handler=lambda e: self._join_error_cb(activity_id, signal, userdata, 'RequestChannel(TEXT, ROOM, %r, True)' % handles[0], e)) error_handler=lambda e: self._join_error_cb(activity_id, signal, userdata, 'RequestChannel(TEXT, ROOM, %r, True)' % handles[0], e))
@ -486,7 +487,7 @@ class ServerPlugin(gobject.GObject):
if not handle: if not handle:
# FIXME: figure out why the server can't figure this out itself # FIXME: figure out why the server can't figure this out itself
room_jid = activity_id + "@conference." + self._account["server"] room_jid = activity_id + "@conference." + self._account["server"]
self._conn[CONN_INTERFACE].RequestHandles(CONNECTION_HANDLE_TYPE_ROOM, [room_jid], self._conn[CONN_INTERFACE].RequestHandles(HANDLE_TYPE_ROOM, [room_jid],
reply_handler=lambda *args: self._join_activity_get_channel_cb(activity_id, signal, userdata, *args), reply_handler=lambda *args: self._join_activity_get_channel_cb(activity_id, signal, userdata, *args),
error_handler=lambda *args: self._join_error_cb(activity_id, signal, userdata, 'RequestHandles([%u])' % room_jid, *args)) error_handler=lambda *args: self._join_error_cb(activity_id, signal, userdata, 'RequestHandles([%u])' % room_jid, *args))
else: else:
@ -706,7 +707,7 @@ class ServerPlugin(gobject.GObject):
return return
props['nick'] = aliases[0] props['nick'] = aliases[0]
jid = self._conn[CONN_INTERFACE].InspectHandles(CONNECTION_HANDLE_TYPE_CONTACT, [handle])[0] jid = self._conn[CONN_INTERFACE].InspectHandles(HANDLE_TYPE_CONTACT, [handle])[0]
self._online_contacts[handle] = jid self._online_contacts[handle] = jid
self.emit("contact-online", handle, props) self.emit("contact-online", handle, props)
@ -770,7 +771,7 @@ class ServerPlugin(gobject.GObject):
self._online_contacts[handle] = None self._online_contacts[handle] = None
if handle == self._conn[CONN_INTERFACE].GetSelfHandle(): if handle == self._conn[CONN_INTERFACE].GetSelfHandle():
jid = self._conn[CONN_INTERFACE].InspectHandles(CONNECTION_HANDLE_TYPE_CONTACT, [handle])[0] jid = self._conn[CONN_INTERFACE].InspectHandles(HANDLE_TYPE_CONTACT, [handle])[0]
self._online_contacts[handle] = jid self._online_contacts[handle] = jid
# ignore network events for Owner property changes since those # ignore network events for Owner property changes since those
# are handled locally # are handled locally
@ -815,7 +816,7 @@ class ServerPlugin(gobject.GObject):
if not online and status == "offline": if not online and status == "offline":
# weren't online in the first place... # weren't online in the first place...
continue continue
jid = self._conn[CONN_INTERFACE].InspectHandles(CONNECTION_HANDLE_TYPE_CONTACT, [handle])[0] jid = self._conn[CONN_INTERFACE].InspectHandles(HANDLE_TYPE_CONTACT, [handle])[0]
olstr = "ONLINE" olstr = "ONLINE"
if not online: olstr = "OFFLINE" if not online: olstr = "OFFLINE"
_logger.debug("Handle %s (%s) was %s, status now '%s'." % (handle, jid, olstr, status)) _logger.debug("Handle %s (%s) was %s, status now '%s'." % (handle, jid, olstr, status))
@ -909,7 +910,7 @@ class ServerPlugin(gobject.GObject):
suppress_handler): suppress_handler):
"""Handle creation of a new channel """Handle creation of a new channel
""" """
if (handle_type == CONNECTION_HANDLE_TYPE_ROOM and if (handle_type == HANDLE_TYPE_ROOM and
channel_type == CHANNEL_TYPE_TEXT): channel_type == CHANNEL_TYPE_TEXT):
def ready(channel): def ready(channel):
@ -948,7 +949,7 @@ class ServerPlugin(gobject.GObject):
Channel(self._conn.service_name, object_path, Channel(self._conn.service_name, object_path,
ready_handler=ready) ready_handler=ready)
elif (handle_type == CONNECTION_HANDLE_TYPE_CONTACT and elif (handle_type == HANDLE_TYPE_CONTACT and
channel_type in (CHANNEL_TYPE_TEXT, channel_type in (CHANNEL_TYPE_TEXT,
CHANNEL_TYPE_STREAMED_MEDIA)): CHANNEL_TYPE_STREAMED_MEDIA)):
self.emit("private-invitation", object_path) self.emit("private-invitation", object_path)