projects
/
theonering
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Updating to new connection style
[theonering]
/
src
/
connection.py
diff --git
a/src/connection.py
b/src/connection.py
index
da96e44
..
6ff64d8
100644
(file)
--- a/
src/connection.py
+++ b/
src/connection.py
@@
-7,13
+7,12
@@
import constants
import gvoice
import handle
import channel_manager
import gvoice
import handle
import channel_manager
-import simple_presence
_moduleLogger = logging.getLogger("connection")
_moduleLogger = logging.getLogger("connection")
-class TheOneRingConnection(telepathy.server.Connection, simple_presence.SimplePresenceMixin):
+class TheOneRingConnection(telepathy.server.Connection):
MANDATORY_PARAMETERS = {
'account' : 's',
MANDATORY_PARAMETERS = {
'account' : 's',
@@
-46,7
+45,7
@@
class TheOneRingConnection(telepathy.server.Connection, simple_presence.SimplePr
self._channelManager = channel_manager.ChannelManager(self)
cookieFilePath = "%s/cookies.txt" % constants._data_path_
self._channelManager = channel_manager.ChannelManager(self)
cookieFilePath = "%s/cookies.txt" % constants._data_path_
- self._backend = gvoice.dialer.GVDialer(cookieFilePath)
+ self._session = gvoice.session.Session(cookieFilePath)
self.set_self_handle(handle.create_handle(self, 'connection'))
self.set_self_handle(handle.create_handle(self, 'connection'))
@@
-60,8
+59,8
@@
class TheOneRingConnection(telepathy.server.Connection, simple_presence.SimplePr
return self._manager
@property
return self._manager
@property
- def gvoice_backend(self):
- return self._backend
+ def session(self):
+ return self._session
@property
def username(self):
@property
def username(self):
@@
-80,9
+79,9
@@
class TheOneRingConnection(telepathy.server.Connection, simple_presence.SimplePr
telepathy.CONNECTION_STATUS_REASON_REQUESTED
)
try:
telepathy.CONNECTION_STATUS_REASON_REQUESTED
)
try:
- self._backend.login(*self._credentials)
- self._backend.set_callback_number(self._callbackNumber)
- except gvoice.dialer.NetworkError:
+ self.session.login(*self._credentials)
+ self.session.backend.set_callback_number(self._callbackNumber)
+ except gvoice.backend.NetworkError:
self.StatusChanged(
telepathy.CONNECTION_STATUS_DISCONNECTED,
telepathy.CONNECTION_STATUS_REASON_NETWORK_ERROR
self.StatusChanged(
telepathy.CONNECTION_STATUS_DISCONNECTED,
telepathy.CONNECTION_STATUS_REASON_NETWORK_ERROR
@@
-103,7
+102,7
@@
class TheOneRingConnection(telepathy.server.Connection, simple_presence.SimplePr
For org.freedesktop.telepathy.Connection
"""
try:
For org.freedesktop.telepathy.Connection
"""
try:
- self._backend.logout()
+ self.session.logout()
_moduleLogger.info("Disconnected")
except Exception:
_moduleLogger.exception("Disconnecting Failed")
_moduleLogger.info("Disconnected")
except Exception:
_moduleLogger.exception("Disconnecting Failed")
@@
-155,9
+154,8
@@
class TheOneRingConnection(telepathy.server.Connection, simple_presence.SimplePr
if handleType == telepathy.HANDLE_TYPE_CONTACT:
h = self._create_contact_handle(name)
elif handleType == telepathy.HANDLE_TYPE_LIST:
if handleType == telepathy.HANDLE_TYPE_CONTACT:
h = self._create_contact_handle(name)
elif handleType == telepathy.HANDLE_TYPE_LIST:
+ # Support only server side (immutable) lists
h = handle.create_handle(self, 'list', name)
h = handle.create_handle(self, 'list', name)
- elif handleType == telepathy.HANDLE_TYPE_GROUP:
- h = handle.create_handle(self, 'group', name)
else:
raise telepathy.NotAvailable('Handle type unsupported %d' % handleType)
handles.append(h.id)
else:
raise telepathy.NotAvailable('Handle type unsupported %d' % handleType)
handles.append(h.id)
@@
-167,16
+165,16
@@
class TheOneRingConnection(telepathy.server.Connection, simple_presence.SimplePr
def _create_contact_handle(self, name):
requestedContactId = name
def _create_contact_handle(self, name):
requestedContactId = name
- contacts = self._backend.get_contacts()
+ contacts = self.session.addressbook.get_contacts()
contactsFound = [
contactsFound = [
- (contactId, contactName) for (contactId, contactName) in contacts
+ contactId for contactId in contacts
if contactId == requestedContactId
]
if 0 < len(contactsFound):
if contactId == requestedContactId
]
if 0 < len(contactsFound):
- contactId, contactName = contactsFound[0]
+ contactId = contactsFound[0]
if len(contactsFound) != 1:
if len(contactsFound) != 1:
- _moduleLogger.error("Contact ID was not unique: %s for %s" % (contactId, contactName))
+ _moduleLogger.error("Contact ID was not unique: %s for %s" % (contactId, ))
else:
else:
- contactId, contactName = requestedContactId, ""
- h = handle.create_handle(self, 'contact', contactId, contactName)
+ contactId = requestedContactId
+ h = handle.create_handle(self, 'contact', contactId)