projects
/
theonering
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Yay, renaming
[theonering]
/
src
/
connection.py
diff --git
a/src/connection.py
b/src/connection.py
index
304491d
..
2fd3632
100644
(file)
--- a/
src/connection.py
+++ b/
src/connection.py
@@
-4,7
+4,7
@@
import logging
import telepathy
import constants
import telepathy
import constants
-import gv_backend
+import gvoice
import handle
import channel_manager
import simple_presence
import handle
import channel_manager
import simple_presence
@@
-17,7
+17,8
@@
class TheOneRingConnection(telepathy.server.Connection, simple_presence.SimplePr
MANDATORY_PARAMETERS = {
'account' : 's',
MANDATORY_PARAMETERS = {
'account' : 's',
- 'password' : 's'
+ 'password' : 's',
+ 'forward' : 's',
}
OPTIONAL_PARAMETERS = {
}
}
OPTIONAL_PARAMETERS = {
}
@@
-41,10
+42,12
@@
class TheOneRingConnection(telepathy.server.Connection, simple_presence.SimplePr
parameters['account'].encode('utf-8'),
parameters['password'].encode('utf-8'),
)
parameters['account'].encode('utf-8'),
parameters['password'].encode('utf-8'),
)
+ self._callbackNumber = parameters['forward'].encode('utf-8')
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 = gv_backend.GVDialer(cookieFilePath)
+ self._backend = gvoice.dialer.GVDialer(cookieFilePath)
+ self._addressbook = gvoice.addressbook.Addressbook(self._backend)
self.set_self_handle(handle.create_handle(self, 'connection'))
self.set_self_handle(handle.create_handle(self, 'connection'))
@@
-62,6
+65,10
@@
class TheOneRingConnection(telepathy.server.Connection, simple_presence.SimplePr
return self._backend
@property
return self._backend
@property
+ def addressbook(self):
+ return self._addressbook
+
+ @property
def username(self):
self._credentials[0]
def username(self):
self._credentials[0]
@@
-79,7
+86,8
@@
class TheOneRingConnection(telepathy.server.Connection, simple_presence.SimplePr
)
try:
self._backend.login(*self._credentials)
)
try:
self._backend.login(*self._credentials)
- except gv_backend.NetworkError:
+ self._backend.set_callback_number(self._callbackNumber)
+ except gvoice.dialer.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
@@
-129,7
+137,10
@@
class TheOneRingConnection(telepathy.server.Connection, simple_presence.SimplePr
elif type == telepathy.CHANNEL_TYPE_TEXT:
if handleType != telepathy.HANDLE_TYPE_CONTACT:
raise telepathy.NotImplemented("Only Contacts are allowed")
elif type == telepathy.CHANNEL_TYPE_TEXT:
if handleType != telepathy.HANDLE_TYPE_CONTACT:
raise telepathy.NotImplemented("Only Contacts are allowed")
- contact = handle.contact
+ channel = channelManager.channel_for_text(handle, None, suppressHandler)
+ elif type == telepathy.CHANNEL_TYPE_STREAMED_MEDIA:
+ if handleType != telepathy.HANDLE_TYPE_CONTACT:
+ raise telepathy.NotImplemented("Only Contacts are allowed")
channel = channelManager.channel_for_text(handle, None, suppressHandler)
else:
raise telepathy.NotImplemented("unknown channel type %s" % type)
channel = channelManager.channel_for_text(handle, None, suppressHandler)
else:
raise telepathy.NotImplemented("unknown channel type %s" % type)
@@
-141,7
+152,7
@@
class TheOneRingConnection(telepathy.server.Connection, simple_presence.SimplePr
For org.freedesktop.telepathy.Connection
"""
self.check_connected()
For org.freedesktop.telepathy.Connection
"""
self.check_connected()
- self.check_handleType(handleType)
+ self.check_handle_type(handleType)
handles = []
for name in names:
handles = []
for name in names:
@@
-149,9
+160,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)
@@
-159,16
+169,18
@@
class TheOneRingConnection(telepathy.server.Connection, simple_presence.SimplePr
return handles
def _create_contact_handle(self, name):
return handles
def _create_contact_handle(self, name):
- requestedContactId, requestedContactName = handle.field_split(name)
+ requestedContactId = name
- contacts = self._backend.get_contacts()
+ contacts = self._addressbook.get_contacts()
contactsFound = [
contactsFound = [
- (contactId, contactName) for (contactId, contactName) in contacts
- if contactName == name
+ contactId for contactId in contacts
+ if contactId == requestedContactId
]
if 0 < len(contactsFound):
]
if 0 < len(contactsFound):
- contactId, contactName = contactsFound[0]
- h = handle.create_handle(self, 'contact', contactId, contactName)
+ contactId = contactsFound[0]
+ if len(contactsFound) != 1:
+ _moduleLogger.error("Contact ID was not unique: %s for %s" % (contactId, ))
else:
else:
- h = handle.create_handle(self, 'contact', requestedContactId, requestedContactName)
+ contactId = requestedContactId
+ h = handle.create_handle(self, 'contact', contactId)