def __init__(self, connection_manager, proto):
        escaped_name = proto.replace("-", "_")
        bus_name = connection_manager._name
        object_path = connection_manager._object_path + "/" + escaped_name

        _Protocol.__init__(self, bus_name, object_path)

        self._proto = proto
        self._interfaces = set()

        DBusProperties.__init__(self)
        self._implement_property_get(
            PROTOCOL, {
                'EnglishName': lambda: self.english_name,
                'Icon': lambda: self.icon,
                'VCardField': lambda: self.vcard_field,
                'Interfaces': lambda: self.interfaces,
                'ConnectionInterfaces': lambda: self.connection_interfaces,
                'RequestableChannelClasses': lambda: self.requestable_channels,
                'Parameters': lambda: self.parameters,
                'AuthenticationTypes': lambda: self.authentication_types,
            })

        self._add_immutable_properties({
            'EnglishName': PROTOCOL,
            'Icon': PROTOCOL,
            'VCardField': PROTOCOL,
            'Interfaces': PROTOCOL,
            'ConnectionInterfaces': PROTOCOL,
            'RequestableChannelClasses': PROTOCOL,
            'Parameters': PROTOCOL
        })
Example #2
0
    def __init__(self):
        _ConnectionInterfaceContacts.__init__(self)
        DBusProperties.__init__(self)

        self._implement_property_get(CONNECTION_INTERFACE_CONTACTS, {
            'ContactAttributeInterfaces': self.get_contact_attribute_interfaces,
        })
    def __init__(self, connection_manager, proto):
        escaped_name = proto.replace("-", "_")
        bus_name = connection_manager._name
        object_path = connection_manager._object_path + "/" + escaped_name

        _Protocol.__init__(self, bus_name, object_path)

        self._proto = proto
        self._interfaces = set()

        DBusProperties.__init__(self)
        self._implement_property_get(PROTOCOL, {
                'EnglishName': lambda: self.english_name,
                'Icon': lambda: self.icon,
                'VCardField': lambda: self.vcard_field,
                'Interfaces': lambda: self.interfaces,
                'ConnectionInterfaces': lambda: self.connection_interfaces,
                'RequestableChannelClasses': lambda: self.requestable_channels,
                'Parameters': lambda: self.parameters,
                'AuthenticationTypes': lambda: self.authentication_types,
                })

        self._add_immutable_properties({
                'EnglishName': PROTOCOL,
                'Icon': PROTOCOL,
                'VCardField': PROTOCOL,
                'Interfaces': PROTOCOL,
                'ConnectionInterfaces': PROTOCOL,
                'RequestableChannelClasses': PROTOCOL,
                'Parameters': PROTOCOL
                })
Example #4
0
    def __init__(self):
        """
        Initialise the connection manager.
        """
        name = 'glitter'
        bus_name = 'org.freedesktop.Telepathy.ConnectionManager.%s' % name
        object_path = '/org/freedesktop/Telepathy/ConnectionManager/%s' % name
        _ConnectionManager.__init__(
            self,
            dbus.service.BusName(bus_name, dbus.Bus(), do_not_queue=True),
            object_path)

        self._interfaces = set(CONNECTION_INTERFACE_CONTACT_LIST)
        self._connections = set()
         # proto name => Connection constructor
        self._protos = {'gitter': GitterConnection}
          # proto name => Protocol object
        self._protocols = {'gitter': GitterProtocol}

        DBusProperties.__init__(self)
        self._implement_property_get(CONN_MGR_INTERFACE, {
                'Interfaces': lambda: dbus.Array(self._interfaces, signature='s'),
                'Protocols': lambda: dbus.Dictionary(self._protocol_properties,
                                                     signature='sa{sv}')
                })
Example #5
0
    def __init__(self):
        _ConnectionInterfaceBalance.__init__(self)
        DBusProperties.__init__(self)

        self._implement_property_get(CONNECTION_INTERFACE_BALANCE, {
            'AccountBalance': lambda: dbus.Struct(self._get_account_balance(), signature='ius'),
            'ManageCreditURI': lambda: dbus.String(self._get_manage_credit_uri()),
        })
Example #6
0
    def __init__(self):
        _ConnectionInterfaceContactGroups.__init__(self)
        DBusProperties.__init__(self)

        self._implement_property_get(CONNECTION_INTERFACE_CONTACT_GROUPS, {
            'DisjointGroups': lambda: dbus.Boolean(self._get_disjoint_groups()),
            'GroupStorage': lambda: dbus.UInt32(self._get_group_storage()),
            'Groups': lambda: dbus.Array(self._get_groups(), signature='s'),
        })
Example #7
0
    def __init__(self, proto, account, manager=None, protocol=None):
        """
        Parameters:
        proto - the name of the protcol this conection should be handling.
        account - a protocol-specific account name
        manager - the name of the connection manager
        """

        if manager is None:
            import warnings
            warnings.warn(
                'The manager parameter to Connection.__init__ '
                'should be supplied', DeprecationWarning)
            manager = 'python'

        clean_account = _escape_as_identifier(account)
        bus_name = u'org.freedesktop.Telepathy.Connection.%s.%s.%s' % \
                (manager, proto, clean_account)
        bus_name = dbus.service.BusName(bus_name, bus=dbus.SessionBus())

        object_path = '/org/freedesktop/Telepathy/Connection/%s/%s/%s' % \
                (manager, proto, clean_account)
        _Connection.__init__(self, bus_name, object_path)

        # monitor clients dying so we can release handles
        dbus.SessionBus().add_signal_receiver(self.name_owner_changed_callback,
                                              'NameOwnerChanged',
                                              'org.freedesktop.DBus',
                                              'org.freedesktop.DBus',
                                              '/org/freedesktop/DBus')

        self._interfaces = set()

        DBusProperties.__init__(self)
        self._implement_property_get(
            CONN_INTERFACE, {
                'SelfHandle':
                lambda: dbus.UInt32(self.GetSelfHandle()),
                'Interfaces':
                lambda: dbus.Array(self.GetInterfaces(), signature='s'),
                'Status':
                lambda: dbus.UInt32(self.GetStatus())
            })

        self._proto = proto  # Protocol name
        self._protocol = protocol  # Protocol object

        self._status = CONNECTION_STATUS_DISCONNECTED

        self._self_handle = NoneHandle()
        self._handles = weakref.WeakValueDictionary()
        self._next_handle_id = 1
        self._client_handles = {}

        self._channels = set()
        self._next_channel_id = 0
    def __init__(self):
        _ConnectionInterfaceRequests.__init__(self)
        DBusProperties.__init__(self)

        self._implement_property_get(CONNECTION_INTERFACE_REQUESTS,
            {'Channels': lambda: dbus.Array(self._get_channels(),
                signature='(oa{sv})'),
            'RequestableChannelClasses': lambda: dbus.Array(
                self._channel_manager.get_requestable_channel_classes(),
                signature='(a{sv}as)')})
Example #9
0
    def __init__(self):
        _ConnectionInterfaceRequests.__init__(self)
        DBusProperties.__init__(self)

        self._implement_property_get(CONNECTION_INTERFACE_REQUESTS,
            {'Channels': lambda: dbus.Array(self._get_channels(),
                signature='(oa{sv})'),
            'RequestableChannelClasses': lambda: dbus.Array(
                self._channel_manager.get_requestable_channel_classes(),
                signature='(a{sv}as)')})
Example #10
0
    def __init__(self):
        _ConnectionInterfaceContactInfo.__init__(self)
        DBusProperties.__init__(self)

        self._implement_property_get(CONNECTION_INTERFACE_CONTACT_INFO, {
            'ContactInfoFlags': lambda: dbus.UInt32(self._get_contact_info_flags()),
            'SupportedFields': lambda: dbus.Array(
                map(lambda field: dbus.Struct((field[0],dbus.Array(field[1], signature='s'), field[3], field[4]), signature='sasuu'), self._get_supported_fields()), 
                signature='sasuu'),
        })
Example #11
0
    def __init__(self, connection, manager, props, object_path=None):
        """
        Initialise the base channel object.

        Parameters:
        connection - the parent Connection object
        props - initial channel properties
        """
        self._conn = connection
        self._chan_manager = manager

        object_path = self._conn.get_channel_path(object_path)
        _Channel.__init__(self, self._conn._name, object_path)

        self._type = props[CHANNEL_INTERFACE + '.ChannelType']
        self._requested = props[CHANNEL_INTERFACE + '.Requested']

        tht = props.get(CHANNEL_INTERFACE + '.TargetHandleType',
                        HANDLE_TYPE_NONE)

        if tht == HANDLE_TYPE_NONE:
            self._handle = NoneHandle()
        else:
            self._handle = self._conn.handle(
                props[CHANNEL_INTERFACE + '.TargetHandleType'],
                props[CHANNEL_INTERFACE + '.TargetHandle'])

        self._interfaces = set()

        DBusProperties.__init__(self)
        self._implement_property_get(
            CHANNEL_INTERFACE, {
                'ChannelType':
                lambda: dbus.String(self.GetChannelType()),
                'Interfaces':
                lambda: dbus.Array(self.GetInterfaces(), signature='s'),
                'TargetHandle':
                lambda: dbus.UInt32(self._handle.get_id()),
                'TargetHandleType':
                lambda: dbus.UInt32(self._handle.get_type()),
                'TargetID':
                lambda: dbus.String(self._handle.get_name()),
                'Requested':
                lambda: self._requested
            })

        self._add_immutable_properties({
            'ChannelType': CHANNEL_INTERFACE,
            'TargetHandle': CHANNEL_INTERFACE,
            'Interfaces': CHANNEL_INTERFACE,
            'TargetHandleType': CHANNEL_INTERFACE,
            'TargetID': CHANNEL_INTERFACE,
            'Requested': CHANNEL_INTERFACE
        })
Example #12
0
    def __init__(self):
        _ConnectionInterfaceContactList.__init__(self)
        DBusProperties.__init__(self)

        self._implement_property_get(CONNECTION_INTERFACE_CONTACT_LIST, {
            'ContactListState': lambda: dbus.UInt32(self._get_contact_list_state()),
            'ContactListPersists': lambda: dbus.Boolean(self._get_contact_list_persists()),
            'CanChangeContactList': lambda: dbus.Boolean(self._get_can_change_contact_list()),
            'RequestUsesMessage': lambda: dbus.Boolean(self._get_request_uses_message()),
            'DownloadAtConnection': lambda: dbus.Boolean(self._get_download_at_connection()),
        })
Example #13
0
    def __init__(self, proto, account, manager=None, protocol=None):
        """
        Parameters:
        proto - the name of the protcol this conection should be handling.
        account - a protocol-specific account name
        manager - the name of the connection manager
        """

        if manager is None:
            import warnings
            warnings.warn('The manager parameter to Connection.__init__ '
                          'should be supplied', DeprecationWarning)
            manager = 'python'

        clean_account = _escape_as_identifier(account)
        bus_name = u'org.freedesktop.Telepathy.Connection.%s.%s.%s' % \
                (manager, proto, clean_account)
        bus_name = dbus.service.BusName(bus_name, bus=dbus.SessionBus())

        object_path = '/org/freedesktop/Telepathy/Connection/%s/%s/%s' % \
                (manager, proto, clean_account)
        _Connection.__init__(self, bus_name, object_path)

        # monitor clients dying so we can release handles
        dbus.SessionBus().add_signal_receiver(self.name_owner_changed_callback,
                                              'NameOwnerChanged',
                                              'org.freedesktop.DBus',
                                              'org.freedesktop.DBus',
                                              '/org/freedesktop/DBus')

        self._interfaces = set()

        DBusProperties.__init__(self)
        self._implement_property_get(CONN_INTERFACE, {
                'SelfHandle': lambda: dbus.UInt32(self.GetSelfHandle()),
                'Interfaces': lambda: dbus.Array(self.GetInterfaces(), signature='s'),
                'Status': lambda: dbus.UInt32(self.GetStatus()),
                'HasImmortalHandles': lambda: True,
                 })

        self._proto = proto # Protocol name
        self._protocol = protocol # Protocol object

        self._status = CONNECTION_STATUS_DISCONNECTED

        self._self_handle = NoneHandle()
        self._handles = {}
        self._next_handle_id = 1
        self._client_handles = {}

        self._channels = set()
        self._next_channel_id = 0
Example #14
0
    def __init__(self, conn_manager, root=''):
        self.enabled = False
        self._interfaces = set()
        self._messages = []
        object_path = '/org/freedesktop/Telepathy/debug'

        _Debug.__init__(self, conn_manager._name, object_path)
        DBusProperties.__init__(self)
        logging.Handler.__init__(self)

        self._implement_property_get(DEBUG, {'Enabled': lambda: self.enabled})
        logging.getLogger(root).addHandler(self)
        sys.stderr = StdErrWrapper(self, sys.stderr)
Example #15
0
    def __init__(self, conn_manager, root=""):
        self.enabled = False
        self._interfaces = set()
        self._messages = []
        object_path = "/org/freedesktop/Telepathy/debug"

        _Debug.__init__(self, conn_manager._name, object_path)
        DBusProperties.__init__(self)
        logging.Handler.__init__(self)

        self._implement_property_get(DEBUG, {"Enabled": lambda: self.enabled})
        self._implement_property_set(DEBUG, {"Enabled": self._set_enabled})
        logging.getLogger(root).addHandler(self)
Example #16
0
    def __init__(self, conn_manager, root=''):
        self.enabled = False
        self._interfaces = set()
        self._messages = []
        object_path = '/org/freedesktop/Telepathy/debug'

        _Debug.__init__(self, conn_manager._name, object_path)
        DBusProperties.__init__(self)
        logging.Handler.__init__(self)

        self._implement_property_get(DEBUG, {'Enabled': lambda: self.enabled})
        self._implement_property_set(DEBUG, {'Enabled': self._set_enabled})
        logging.getLogger(root).addHandler(self)
    def __init__(self):
        _ChannelInterfaceGroup.__init__(self)
        DBusProperties.__init__(self)

        self._implement_property_get(CHANNEL_INTERFACE_GROUP,
            {'GroupFlags': lambda: dbus.UInt32(self.GetGroupFlags()),
             'Members': lambda: dbus.Array(self.GetMembers(), signature='u'),
             'RemotePendingMembers': lambda: dbus.Array(self.GetRemotePendingMembers(), signature='u'),
             'SelfHandle': lambda: dbus.UInt32(self.GetSelfHandle())})

        self._group_flags = 0
        self._members = set()
        self._local_pending = set()
        self._remote_pending = set()
Example #18
0
    def __init__(self, connection, manager, props, object_path=None):
        """
        Initialise the base channel object.

        Parameters:
        connection - the parent Connection object
        props - initial channel properties
        """
        self._conn = connection
        self._chan_manager = manager

        object_path = self._conn.get_channel_path(object_path)
        _Channel.__init__(self, self._conn._name, object_path)

        self._type = props[CHANNEL_INTERFACE + '.ChannelType']
        self._requested = props.get(CHANNEL_INTERFACE + '.Requested', True)

        tht = props.get(CHANNEL_INTERFACE + '.TargetHandleType', HANDLE_TYPE_NONE)

        if tht == HANDLE_TYPE_NONE:
            self._handle = NoneHandle()
        else:
            self._handle = self._conn.handle(
                props[CHANNEL_INTERFACE + '.TargetHandleType'],
                props[CHANNEL_INTERFACE + '.TargetHandle'])

        self._interfaces = set()

        DBusProperties.__init__(self)
        self._implement_property_get(CHANNEL_INTERFACE,
            {'ChannelType': lambda: dbus.String(self.GetChannelType()),
             'Interfaces': lambda: dbus.Array(self.GetInterfaces(), signature='s'),
             'TargetHandle': lambda: dbus.UInt32(self._handle.get_id()),
             'TargetHandleType': lambda: dbus.UInt32(self._handle.get_type()),
             'TargetID': lambda: dbus.String(self._handle.get_name()),
             'Requested': lambda: self._requested})

        self._add_immutable_properties({
            'ChannelType': CHANNEL_INTERFACE,
            'TargetHandle': CHANNEL_INTERFACE,
            'Interfaces': CHANNEL_INTERFACE,
            'TargetHandleType': CHANNEL_INTERFACE,
            'TargetID': CHANNEL_INTERFACE,
            'Requested': CHANNEL_INTERFACE
            })