Merge lp:~boiko/telepathy-ofono/fix_python_errors into lp:telepathy-ofono/legacy

Proposed by Gustavo Pichorim Boiko
Status: Merged
Approved by: Renato Araujo Oliveira Filho
Approved revision: 88
Merged at revision: 85
Proposed branch: lp:~boiko/telepathy-ofono/fix_python_errors
Merge into: lp:telepathy-ofono/legacy
Diff against target: 1365 lines (+205/-236)
25 files modified
debian/changelog (+6/-0)
tpofono/__init__.py (+4/-2)
tpofono/aliasing.py (+3/-27)
tpofono/call/__init__.py (+2/-0)
tpofono/call/content.py (+10/-11)
tpofono/capabilities.py (+7/-12)
tpofono/channel/__init__.py (+9/-10)
tpofono/channel/call.py (+34/-35)
tpofono/channel/text.py (+28/-28)
tpofono/channel_manager.py (+3/-9)
tpofono/connection.py (+30/-41)
tpofono/connection_manager.py (+2/-3)
tpofono/contacts.py (+23/-24)
tpofono/debug.py (+1/-0)
tpofono/handle.py (+2/-2)
tpofono/ofono/__init__.py (+8/-0)
tpofono/ofono/ofonocall.py (+3/-4)
tpofono/ofono/ofonocalls.py (+2/-3)
tpofono/ofono/ofonocallvolume.py (+2/-2)
tpofono/ofono/ofonomanager.py (+3/-2)
tpofono/ofono/ofonomessages.py (+1/-3)
tpofono/ofono/ofonomodem.py (+2/-1)
tpofono/ofono/ofonovoicemail.py (+7/-3)
tpofono/presence.py (+6/-8)
tpofono/protocol.py (+7/-6)
To merge this branch: bzr merge lp:~boiko/telepathy-ofono/fix_python_errors
Reviewer Review Type Date Requested Status
Renato Araujo Oliveira Filho (community) Approve
PS Jenkins bot continuous-integration Approve
Sergio Schvezov Needs Information
Review via email: mp+155615@code.launchpad.net

Commit message

Fix python errors reported by pyflakes and pep8.

Description of the change

Fix python errors reported by pyflakes and pep8.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Sergio Schvezov (sergiusens) wrote :
Download full text (15.2 KiB)

Do you intent not to fix these?
./tpofono/capabilities.py:35:15: E127 continuation line over-indented for visual indent
./tpofono/capabilities.py:37:15: E127 continuation line over-indented for visual indent
./tpofono/capabilities.py:43:15: E127 continuation line over-indented for visual indent
./tpofono/capabilities.py:45:15: E127 continuation line over-indented for visual indent
./tpofono/capabilities.py:105:80: E501 line too long (97 > 79 characters)
./tpofono/capabilities.py:106:17: E128 continuation line under-indented for visual indent
./tpofono/channel_manager.py:44:80: E501 line too long (91 > 79 characters)
./tpofono/channel_manager.py:45:80: E501 line too long (91 > 79 characters)
./tpofono/channel_manager.py:57:80: E501 line too long (85 > 79 characters)
./tpofono/channel_manager.py:58:17: E128 continuation line under-indented for visual indent
./tpofono/channel_manager.py:88:80: E501 line too long (88 > 79 characters)
./tpofono/channel_manager.py:102:80: E501 line too long (82 > 79 characters)
./tpofono/channel_manager.py:104:80: E501 line too long (82 > 79 characters)
./tpofono/connection.py:48:9: E128 continuation line under-indented for visual indent
./tpofono/connection.py:49:9: E128 continuation line under-indented for visual indent
./tpofono/connection.py:50:1: E128 continuation line under-indented for visual indent
./tpofono/connection.py:51:9: E128 continuation line under-indented for visual indent
./tpofono/connection.py:52:9: E128 continuation line under-indented for visual indent
./tpofono/connection.py:53:9: E128 continuation line under-indented for visual indent
./tpofono/connection.py:54:9: E128 continuation line under-indented for visual indent
./tpofono/connection.py:55:9: E128 continuation line under-indented for visual indent
./tpofono/connection.py:56:9: E128 continuation line under-indented for visual indent
./tpofono/connection.py:57:9: E128 continuation line under-indented for visual indent
./tpofono/connection.py:58:9: E128 continuation line under-indented for visual indent
./tpofono/connection.py:78:21: E128 continuation line under-indented for visual indent
./tpofono/connection.py:90:80: E501 line too long (93 > 79 characters)
./tpofono/connection.py:91:80: E501 line too long (123 > 79 characters)
./tpofono/connection.py:92:80: E501 line too long (115 > 79 characters)
./tpofono/connection.py:93:80: E501 line too long (102 > 79 characters)
./tpofono/connection.py:96:21: E128 continuation line under-indented for visual indent
./tpofono/connection.py:132:17: E128 continuation line under-indented for visual indent
./tpofono/connection.py:134:80: E501 line too long (84 > 79 characters)
./tpofono/connection.py:153:17: E128 continuation line under-indented for visual indent
./tpofono/connection.py:199:80: E501 line too long (142 > 79 characters)
./tpofono/connection.py:205:80: E501 line too long (116 > 79 characters)
./tpofono/connection.py:206:80: E501 line too long (115 > 79 characters)
./tpofono/connection.py:226:80: E501 line too long (93 > 79 characters)
./tpofono/connection.py:230:80: E501 line too long (81 > 79 characters)
./tpofono/connection.py:232:13: E123 closing bracket does not match indentation of o...

review: Needs Information
88. By Gustavo Pichorim Boiko

Fix more errors reported by pep8 from raring.

Revision history for this message
Gustavo Pichorim Boiko (boiko) wrote :

> Do you intent not to fix these?

I have fixed all but the long lines ones.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Renato Araujo Oliveira Filho (renatofilho) wrote :

After a chat with Gustavo we decided to keep the "line too long" because this does not worth the effort to fix it, and the code will be ported to qt.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2013-02-20 19:47:34 +0000
+++ debian/changelog 2013-03-28 19:50:24 +0000
@@ -1,3 +1,9 @@
1telepathy-ofono (0.25) quantal; urgency=low
2
3 * Fix python errors reported by pyflakes and pep8 (LP: #1124783)
4
5 -- Gustavo Pichorim Boiko <gustavo.boiko@canonical.com> Tue, 26 Mar 2013 18:13:32 -0300
6
1telepathy-ofono (0.24) quantal; urgency=low7telepathy-ofono (0.24) quantal; urgency=low
28
3 * Watch for changes in modem interfaces and only use modems that already have9 * Watch for changes in modem interfaces and only use modems that already have
410
=== modified file 'tpofono/__init__.py'
--- tpofono/__init__.py 2013-02-19 20:09:40 +0000
+++ tpofono/__init__.py 2013-03-28 19:50:24 +0000
@@ -16,5 +16,7 @@
16# You should have received a copy of the GNU General Public License16# You should have received a copy of the GNU General Public License
17# along with this program. If not, see <http://www.gnu.org/licenses/>.17# along with this program. If not, see <http://www.gnu.org/licenses/>.
1818
19from connection_manager import *19from connection_manager import oFonoConnectionManager
20from debug import *20from debug import oFonoDebug
21
22__all__ = ['oFonoConnectionManager', 'oFonoDebug']
2123
=== modified file 'tpofono/aliasing.py'
--- tpofono/aliasing.py 2013-02-19 20:09:40 +0000
+++ tpofono/aliasing.py 2013-03-28 19:50:24 +0000
@@ -26,6 +26,7 @@
2626
27logger = logging.getLogger('oFono.Aliasing')27logger = logging.getLogger('oFono.Aliasing')
2828
29
29class oFonoAliasing(30class oFonoAliasing(
30 telepathy.server.ConnectionInterfaceAliasing):31 telepathy.server.ConnectionInterfaceAliasing):
3132
@@ -58,15 +59,6 @@
58 handle.pending_alias = alias59 handle.pending_alias = alias
59 continue60 continue
6061
61 new_alias = alias.encode("utf-8")
62 old_alias = contact.infos.get(ContactGeneral.ANNOTATIONS, {}).\
63 get(ContactAnnotations.NICKNAME, None)
64 if new_alias == old_alias:
65 continue
66
67 infos = {ContactGeneral.ANNOTATIONS :
68 {ContactAnnotations.NICKNAME : new_alias}
69 }
70 #TODO: update contact info62 #TODO: update contact info
71 else:63 else:
72 logger.info("Self alias changed to '%s'" % alias)64 logger.info("Self alias changed to '%s'" % alias)
@@ -77,14 +69,14 @@
77 handle = self.handle(telepathy.HANDLE_TYPE_CONTACT, handle_id)69 handle = self.handle(telepathy.HANDLE_TYPE_CONTACT, handle_id)
78 logger.info("Getting the alias for the handle name %s" % handle.name)70 logger.info("Getting the alias for the handle name %s" % handle.name)
79 return handle.name71 return handle.name
80 72
81 if (handle == self._self_handle):73 if (handle == self._self_handle):
82 return handle.name74 return handle.name
8375
84 #self.fill_contact_info(handle_id)76 #self.fill_contact_info(handle_id)
85 if not handle_id in self.contactInfo:77 if not handle_id in self.contactInfo:
86 return handle.name78 return handle.name
87 79
88 alias = None80 alias = None
89 contact = self.contactInfo[handle_id]81 contact = self.contactInfo[handle_id]
90 if len(contact['alias']) != 0:82 if len(contact['alias']) != 0:
@@ -110,19 +102,3 @@
110 alias = contact.display_name102 alias = contact.display_name
111 alias = unicode(alias, 'utf-8')"""103 alias = unicode(alias, 'utf-8')"""
112 return alias104 return alias
113
114 def _contact_alias_changed(self, contact):
115 alias = None
116
117 handle = self.ensure_contact_handle(contact)
118 if handle != self._self_handle:
119 alias = contact.infos.get(ContactGeneral.ANNOTATIONS, {}).\
120 get(ContactAnnotations.NICKNAME, None)
121
122 if alias == "" or alias is None:
123 alias = contact.display_name
124
125 alias = unicode(alias, 'utf-8')
126 logger.info("Contact %s alias changed to '%s'" % (unicode(handle), alias))
127 self.AliasesChanged([(handle, alias)])
128
129105
=== modified file 'tpofono/call/__init__.py'
--- tpofono/call/__init__.py 2013-02-19 20:09:40 +0000
+++ tpofono/call/__init__.py 2013-03-28 19:50:24 +0000
@@ -16,3 +16,5 @@
16# along with this program. If not, see <http://www.gnu.org/licenses/>.16# along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
18from content import oFonoCallContent18from content import oFonoCallContent
19
20__all__ = ['oFonoCallContent']
1921
=== modified file 'tpofono/call/content.py'
--- tpofono/call/content.py 2013-02-19 20:09:40 +0000
+++ tpofono/call/content.py 2013-03-28 19:50:24 +0000
@@ -16,21 +16,21 @@
16# along with this program. If not, see <http://www.gnu.org/licenses/>.16# along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
18import logging18import logging
19import weakref
20import dbus19import dbus
2120
22import telepathy21import telepathy
23from telepathy.interfaces import CALL_CONTENT, CALL_CONTENT_INTERFACE_DTMF22from telepathy.interfaces import CALL_CONTENT
24from telepathy._generated.Call_Content import CallContent23from telepathy._generated.Call_Content import CallContent
25from telepathy._generated.Call_Content_Interface_DTMF import CallContentInterfaceDTMF24from telepathy._generated.Call_Content_Interface_DTMF import CallContentInterfaceDTMF
2625
27__all__ = ['oFonoCallContent.py']26__all__ = ['oFonoCallContent']
2827
29logger = logging.getLogger('oFono.CallContent')28logger = logging.getLogger('oFono.CallContent')
3029
31class oFonoCallContent(CallContent, 30
32 telepathy.server.DBusProperties, 31class oFonoCallContent(CallContent,
33 CallContentInterfaceDTMF):32 telepathy.server.DBusProperties,
33 CallContentInterfaceDTMF):
3434
35 def __init__(self, channel, name, contentType, conn, object_path=None, bus_name=None):35 def __init__(self, channel, name, contentType, conn, object_path=None, bus_name=None):
36 CallContent.__init__(self, conn, object_path=object_path, bus_name=bus_name)36 CallContent.__init__(self, conn, object_path=object_path, bus_name=bus_name)
@@ -46,7 +46,7 @@
46 'Name': CALL_CONTENT,46 'Name': CALL_CONTENT,
47 'Type': CALL_CONTENT,47 'Type': CALL_CONTENT,
48 'Disposition': CALL_CONTENT,48 'Disposition': CALL_CONTENT,
49 'Interfaces' : CALL_CONTENT,49 'Interfaces': CALL_CONTENT,
50 })50 })
5151
52 self._implement_property_get(CALL_CONTENT, {52 self._implement_property_get(CALL_CONTENT, {
@@ -54,13 +54,13 @@
54 'Type': lambda: dbus.UInt32(self._type),54 'Type': lambda: dbus.UInt32(self._type),
55 'Disposition': lambda: dbus.UInt32(self._disposition),55 'Disposition': lambda: dbus.UInt32(self._disposition),
56 'Streams': lambda: dbus.Array([], signature="o"),56 'Streams': lambda: dbus.Array([], signature="o"),
57 'Interfaces' : lambda: dbus.Array(self._interfaces, signature="s"),57 'Interfaces': lambda: dbus.Array(self._interfaces, signature="s"),
58 })58 })
5959
60 def Remove(self):60 def Remove(self):
61 self._channel.removeContent(self)61 self._channel.removeContent(self)
62 self.remove_from_connection()62 self.remove_from_connection()
63 self._channel = None 63 self._channel = None
6464
65 def StartTone(self, event):65 def StartTone(self, event):
66 logger.info("StartTone called")66 logger.info("StartTone called")
@@ -76,10 +76,9 @@
76 else:76 else:
77 # convert number to ascii value77 # convert number to ascii value
78 ofonoEvent = event + 4878 ofonoEvent = event + 48
79 79
80 self._channel._conn.SendTones(chr(ofonoEvent))80 self._channel._conn.SendTones(chr(ofonoEvent))
8181
82 def StopTone(self):82 def StopTone(self):
83 logger.info("StopTone called")83 logger.info("StopTone called")
84 pass84 pass
85
8685
=== modified file 'tpofono/capabilities.py'
--- tpofono/capabilities.py 2013-02-19 20:09:40 +0000
+++ tpofono/capabilities.py 2013-03-28 19:50:24 +0000
@@ -25,23 +25,24 @@
2525
26logger = logging.getLogger('oFono.Capabilities')26logger = logging.getLogger('oFono.Capabilities')
2727
28
28class oFonoCapabilities(29class oFonoCapabilities(
29 telepathy.server.ConnectionInterfaceCapabilities,30 telepathy.server.ConnectionInterfaceCapabilities,
30 telepathy.server.ConnectionInterfaceContactCapabilities):31 telepathy.server.ConnectionInterfaceContactCapabilities):
3132
32 text_chat_class = \33 text_chat_class = \
33 ({telepathy.CHANNEL_INTERFACE + '.ChannelType':34 ({telepathy.CHANNEL_INTERFACE + '.ChannelType':
34 telepathy.CHANNEL_TYPE_TEXT,35 telepathy.CHANNEL_TYPE_TEXT,
35 telepathy.CHANNEL_INTERFACE + '.TargetHandleType':36 telepathy.CHANNEL_INTERFACE + '.TargetHandleType':
36 dbus.UInt32(telepathy.HANDLE_TYPE_CONTACT)},37 dbus.UInt32(telepathy.HANDLE_TYPE_CONTACT)},
37 [telepathy.CHANNEL_INTERFACE + '.TargetHandle',38 [telepathy.CHANNEL_INTERFACE + '.TargetHandle',
38 telepathy.CHANNEL_INTERFACE + '.TargetID'])39 telepathy.CHANNEL_INTERFACE + '.TargetID'])
3940
40 audio_chat_class = \41 audio_chat_class = \
41 ({telepathy.CHANNEL_INTERFACE + '.ChannelType':42 ({telepathy.CHANNEL_INTERFACE + '.ChannelType':
42 telepathy.CHANNEL_TYPE_CALL,43 telepathy.CHANNEL_TYPE_CALL,
43 telepathy.CHANNEL_INTERFACE + '.TargetHandleType':44 telepathy.CHANNEL_INTERFACE + '.TargetHandleType':
44 dbus.UInt32(telepathy.HANDLE_TYPE_CONTACT)},45 dbus.UInt32(telepathy.HANDLE_TYPE_CONTACT)},
45 [telepathy.CHANNEL_INTERFACE + '.TargetHandle',46 [telepathy.CHANNEL_INTERFACE + '.TargetHandle',
46 telepathy.CHANNEL_INTERFACE + '.TargetID',47 telepathy.CHANNEL_INTERFACE + '.TargetID',
47 telepathy.CHANNEL_TYPE_CALL + '.InitialAudio'])48 telepathy.CHANNEL_TYPE_CALL + '.InitialAudio'])
@@ -52,9 +53,7 @@
5253
53 self._update_capabilities_calls = []54 self._update_capabilities_calls = []
5455
55
56 ### Capabilities interface -----------------------------------------------56 ### Capabilities interface -----------------------------------------------
57
58 def _get_capabilities(self, contact):57 def _get_capabilities(self, contact):
59 gen_caps = 058 gen_caps = 0
60 spec_caps = 059 spec_caps = 0
@@ -90,9 +89,7 @@
90 if diff is not None:89 if diff is not None:
91 self.CapabilitiesChanged([diff])90 self.CapabilitiesChanged([diff])
9291
93
94 ### ContactCapabilities interface ----------------------------------------92 ### ContactCapabilities interface ----------------------------------------
95
96 def AdvertiseCapabilities(self, add, remove):93 def AdvertiseCapabilities(self, add, remove):
97 return telepathy.server.ConnectionInterfaceCapabilities.\94 return telepathy.server.ConnectionInterfaceCapabilities.\
98 AdvertiseCapabilities(self, add, remove)95 AdvertiseCapabilities(self, add, remove)
@@ -106,7 +103,7 @@
106 # Signal.103 # Signal.
107 if changed:104 if changed:
108 updated = dbus.Dictionary({self._self_handle: self._contact_caps[self._self_handle]},105 updated = dbus.Dictionary({self._self_handle: self._contact_caps[self._self_handle]},
109 signature='ua(a{sv}as)')106 signature='ua(a{sv}as)')
110 self.ContactCapabilitiesChanged(updated)107 self.ContactCapabilitiesChanged(updated)
111108
112 def _get_contact_capabilities(self, contact):109 def _get_contact_capabilities(self, contact):
@@ -120,14 +117,12 @@
120 caps = {}117 caps = {}
121 for handle in handles:118 for handle in handles:
122 caps[handle] = self._get_contact_capabilities(handle.contact)119 caps[handle] = self._get_contact_capabilities(handle.contact)
123 self._contact_caps[handle.id] = caps[handle] # update global dict120 self._contact_caps[handle.id] = caps[handle] # update global dict
124121
125 ret = dbus.Dictionary(caps, signature='ua(a{sv}as)')122 ret = dbus.Dictionary(caps, signature='ua(a{sv}as)')
126 self.ContactCapabilitiesChanged(ret)123 self.ContactCapabilitiesChanged(ret)
127124
128
129 ### Initialization -------------------------------------------------------125 ### Initialization -------------------------------------------------------
130
131 def _populate_capabilities(self):126 def _populate_capabilities(self):
132 """ Add the default capabilities to all contacts in our127 """ Add the default capabilities to all contacts in our
133 contacts list."""128 contacts list."""
134129
=== modified file 'tpofono/channel/__init__.py'
--- tpofono/channel/__init__.py 2013-02-19 20:09:40 +0000
+++ tpofono/channel/__init__.py 2013-03-28 19:50:24 +0000
@@ -21,23 +21,22 @@
2121
22import telepathy22import telepathy
2323
24from tpofono.handle import oFonoHandleFactory
25
26__all__ = ['oFonoChannel']24__all__ = ['oFonoChannel']
2725
28logger = logging.getLogger('oFono.Channel')26logger = logging.getLogger('oFono.Channel')
2927
28
30class oFonoChannel(object):29class oFonoChannel(object):
31 def __init__(self, conn, props):30 def __init__(self, conn, props):
32 # If we have InitiatorHandle set in our new channel, use that,31 # If we have InitiatorHandle set in our new channel, use that,
33 if telepathy.CHANNEL_INTERFACE + '.InitiatorHandle' in props:32 if telepathy.CHANNEL_INTERFACE + '.InitiatorHandle' in props:
34 self._initiator = conn.handle(telepathy.HANDLE_TYPE_CONTACT,33 self._initiator = conn.handle(telepathy.HANDLE_TYPE_CONTACT,
35 props[telepathy.CHANNEL_INTERFACE + '.InitiatorHandle'])34 props[telepathy.CHANNEL_INTERFACE + '.InitiatorHandle'])
3635
37 # otherwise use InitiatorID.36 # otherwise use InitiatorID.
38 elif telepathy.CHANNEL_INTERFACE + '.InitiatorID' in props:37 elif telepathy.CHANNEL_INTERFACE + '.InitiatorID' in props:
39 self._initiator = conn.ensure_handle(telepathy.HANDLE_TYPE_CONTACT,38 self._initiator = conn.ensure_handle(telepathy.HANDLE_TYPE_CONTACT,
40 props[telepathy.CHANNEL_INTERFACE + '.InitiatorID'])39 props[telepathy.CHANNEL_INTERFACE + '.InitiatorID'])
4140
42 # If we don't have either of the above but we requested the channel,41 # If we don't have either of the above but we requested the channel,
43 # then we're the initiator.42 # then we're the initiator.
@@ -51,11 +50,11 @@
51 # Don't implement the initiator properties if we don't have one.50 # Don't implement the initiator properties if we don't have one.
52 if self._initiator:51 if self._initiator:
53 self._implement_property_get(telepathy.CHANNEL_INTERFACE, {52 self._implement_property_get(telepathy.CHANNEL_INTERFACE, {
54 'InitiatorHandle': lambda: dbus.UInt32(self._initiator.id),53 'InitiatorHandle': lambda: dbus.UInt32(self._initiator.id),
55 'InitiatorID': lambda: self._initiator.name54 'InitiatorID': lambda: self._initiator.name
56 })55 })
5756
58 self._add_immutable_properties({57 self._add_immutable_properties({
59 'InitiatorHandle': telepathy.CHANNEL_INTERFACE,58 'InitiatorHandle': telepathy.CHANNEL_INTERFACE,
60 'InitiatorID': telepathy.CHANNEL_INTERFACE,59 'InitiatorID': telepathy.CHANNEL_INTERFACE,
61 })60 })
6261
=== modified file 'tpofono/channel/call.py'
--- tpofono/channel/call.py 2013-02-19 20:09:40 +0000
+++ tpofono/channel/call.py 2013-03-28 19:50:24 +0000
@@ -16,7 +16,6 @@
16# along with this program. If not, see <http://www.gnu.org/licenses/>.16# along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
18import logging18import logging
19import weakref
20import dbus19import dbus
2120
22import telepathy21import telepathy
@@ -25,7 +24,7 @@
25from tpofono.ofono.ofonocall import oFonoCall24from tpofono.ofono.ofonocall import oFonoCall
26from tpofono.call import oFonoCallContent25from tpofono.call import oFonoCallContent
2726
28from telepathy.interfaces import CHANNEL_INTERFACE, CHANNEL_TYPE_CALL, CALL_INTERFACE_MUTE, CHANNEL_INTERFACE_HOLD27from telepathy.interfaces import CHANNEL_TYPE_CALL, CALL_INTERFACE_MUTE, CHANNEL_INTERFACE_HOLD
29from telepathy.constants import LOCAL_MUTE_STATE_UNMUTED, LOCAL_MUTE_STATE_MUTED, LOCAL_HOLD_STATE_REASON_REQUESTED, LOCAL_HOLD_STATE_UNHELD, LOCAL_HOLD_STATE_HELD28from telepathy.constants import LOCAL_MUTE_STATE_UNMUTED, LOCAL_MUTE_STATE_MUTED, LOCAL_HOLD_STATE_REASON_REQUESTED, LOCAL_HOLD_STATE_UNHELD, LOCAL_HOLD_STATE_HELD
30from telepathy._generated.Call_Interface_Mute import CallInterfaceMute29from telepathy._generated.Call_Interface_Mute import CallInterfaceMute
31from telepathy._generated.Channel_Interface_Hold import ChannelInterfaceHold30from telepathy._generated.Channel_Interface_Hold import ChannelInterfaceHold
@@ -34,7 +33,7 @@
3433
35logger = logging.getLogger('oFono.CallChannel')34logger = logging.getLogger('oFono.CallChannel')
3635
37# FIXME: we need to implement also Call1.Interface.Mute36
38class oFonoCallChannel(37class oFonoCallChannel(
39 oFonoChannel,38 oFonoChannel,
40 telepathy.server.ChannelTypeCall,39 telepathy.server.ChannelTypeCall,
@@ -47,7 +46,7 @@
47 def __init__(self, conn, manager, call_object, handle, props, object_path=None):46 def __init__(self, conn, manager, call_object, handle, props, object_path=None):
48 oFonoCall.__init__(self, call_object)47 oFonoCall.__init__(self, call_object)
49 telepathy.server.ChannelTypeCall.__init__(self, conn, manager, props,48 telepathy.server.ChannelTypeCall.__init__(self, conn, manager, props,
50 object_path=object_path)49 object_path=object_path)
51 oFonoChannel.__init__(self, conn, props)50 oFonoChannel.__init__(self, conn, props)
52 ChannelInterfaceHold.__init__(self)51 ChannelInterfaceHold.__init__(self)
5352
@@ -57,7 +56,7 @@
57 self._handle = handle56 self._handle = handle
58 self._memberFlags = 057 self._memberFlags = 0
59 self._localMuteState = LOCAL_MUTE_STATE_UNMUTED58 self._localMuteState = LOCAL_MUTE_STATE_UNMUTED
60 self._holdState = LOCAL_HOLD_STATE_UNHELD 59 self._holdState = LOCAL_HOLD_STATE_UNHELD
61 self._requested = props.get(telepathy.CHANNEL_INTERFACE + ".Requested", True)60 self._requested = props.get(telepathy.CHANNEL_INTERFACE + ".Requested", True)
62 self._initialAudio = props.get(CHANNEL_TYPE_CALL + '.InitialAudio', True)61 self._initialAudio = props.get(CHANNEL_TYPE_CALL + '.InitialAudio', True)
63 self._initialVideo = props.get(CHANNEL_TYPE_CALL + '.InitialVideo', False)62 self._initialVideo = props.get(CHANNEL_TYPE_CALL + '.InitialVideo', False)
@@ -66,7 +65,7 @@
66 self._speakerMode = False65 self._speakerMode = False
67 self._incoming = self.isCallIncoming()66 self._incoming = self.isCallIncoming()
68 self._localHangupRequested = False67 self._localHangupRequested = False
69 68
70 self._conn.SetMuted(False)69 self._conn.SetMuted(False)
7170
72 logger.info("Call is incoming: %d" % self._incoming)71 logger.info("Call is incoming: %d" % self._incoming)
@@ -117,29 +116,29 @@
117 self.setCallState(telepathy.CALL_STATE_INITIALISED, 0, telepathy.CALL_STATE_CHANGE_REASON_PROGRESS_MADE, 0)116 self.setCallState(telepathy.CALL_STATE_INITIALISED, 0, telepathy.CALL_STATE_CHANGE_REASON_PROGRESS_MADE, 0)
118117
119 def SetRinging(self):118 def SetRinging(self):
120 logger.info("SetRinging called");119 logger.info("SetRinging called")
121 if self._incoming and self._state == telepathy.CALL_STATE_INITIALISED:120 if self._incoming and self._state == telepathy.CALL_STATE_INITIALISED:
122 self.setCallState(self._state, self._conn.self_handle.id, 121 self.setCallState(self._state, self._conn.self_handle.id,
123 telepathy.CALL_STATE_CHANGE_REASON_USER_REQUESTED, telepathy.CALL_FLAG_LOCALLY_RINGING)122 telepathy.CALL_STATE_CHANGE_REASON_USER_REQUESTED, telepathy.CALL_FLAG_LOCALLY_RINGING)
124 # FIXME: we need to return the Not Available error for some cases.123 # FIXME: we need to return the Not Available error for some cases.
125 # check this documentation: http://telepathy.freedesktop.org/spec/Channel_Type_Call.html#Method:SetRinging124 # check this documentation: http://telepathy.freedesktop.org/spec/Channel_Type_Call.html#Method:SetRinging
126125
127 def SetQueued(self):126 def SetQueued(self):
128 logger.info("SetQueued called");127 logger.info("SetQueued called")
129 # TODO: implement128 # TODO: implement
130129
131 def Accept(self):130 def Accept(self):
132 logger.info("Accept called");131 logger.info("Accept called")
133 if self._incoming:132 if self._incoming:
134 self.setCallState(telepathy.CALL_STATE_ACCEPTED, self._conn.self_handle.id,133 self.setCallState(telepathy.CALL_STATE_ACCEPTED, self._conn.self_handle.id,
135 telepathy.CALL_STATE_CHANGE_REASON_USER_REQUESTED, 0);134 telepathy.CALL_STATE_CHANGE_REASON_USER_REQUESTED, 0)
136 if self.isCallWaiting():135 if self.isCallWaiting():
137 self._conn.HoldAndAnswer()136 self._conn.HoldAndAnswer()
138 else:137 else:
139 self.Answer()138 self.Answer()
140139
141 def Hangup(self, Reason, Detailed_Hangup_Reason, Message):140 def Hangup(self, Reason, Detailed_Hangup_Reason, Message):
142 logger.info("Hangup called");141 logger.info("Hangup called")
143142
144 # check if this call is active or ringing143 # check if this call is active or ringing
145 if self._state == telepathy.CALL_STATE_ACTIVE or self._state == telepathy.CALL_STATE_ACCEPTED or self._state == telepathy.CALL_STATE_INITIALISED:144 if self._state == telepathy.CALL_STATE_ACTIVE or self._state == telepathy.CALL_STATE_ACCEPTED or self._state == telepathy.CALL_STATE_INITIALISED:
@@ -148,7 +147,7 @@
148 oFonoCall.Hangup(self)147 oFonoCall.Hangup(self)
149148
150 def AddContent(self, Content_Name, Content_Type, InitialDirection):149 def AddContent(self, Content_Name, Content_Type, InitialDirection):
151 logger.info("AddContent called");150 logger.info("AddContent called")
152 path = "%s/content%d" % (self._object_path, self.__call_content_id)151 path = "%s/content%d" % (self._object_path, self.__call_content_id)
153 content = oFonoCallContent(self, Content_Name, Content_Type, self._conn._name, object_path=path)152 content = oFonoCallContent(self, Content_Name, Content_Type, self._conn._name, object_path=path)
154 self.__call_content_id += 1153 self.__call_content_id += 1
@@ -157,23 +156,23 @@
157156
158 def GetCallStateDetails(self):157 def GetCallStateDetails(self):
159 details = dbus.Dictionary({}, signature="sv")158 details = dbus.Dictionary({}, signature="sv")
160 logger.info("GetCallStateDetails called");159 logger.info("GetCallStateDetails called")
161 return details160 return details
162161
163 def GetCallStateReason(self):162 def GetCallStateReason(self):
164 logger.info("GetCallStateReason called");163 logger.info("GetCallStateReason called")
165 return (dbus.UInt32(self._stateActor), dbus.UInt32(self._stateReason), dbus.String(""), dbus.String(""))164 return (dbus.UInt32(self._stateActor), dbus.UInt32(self._stateReason), dbus.String(""), dbus.String(""))
166165
167 def GetCallMembers(self):166 def GetCallMembers(self):
168 members = dbus.Dictionary({}, signature="uu")167 members = dbus.Dictionary({}, signature="uu")
169 logger.info("GetCallMembers called");168 logger.info("GetCallMembers called")
170 members[dbus.UInt32(self._handle.id)] = dbus.UInt32(self._memberFlags)169 members[dbus.UInt32(self._handle.id)] = dbus.UInt32(self._memberFlags)
171 return members170 return members
172171
173 def GetMemberIdentifiers(self):172 def GetMemberIdentifiers(self):
174 identifiers = dbus.Dictionary({}, signature="us")173 identifiers = dbus.Dictionary({}, signature="us")
175 identifiers[dbus.UInt32(self._handle.id)] = self._handle.name174 identifiers[dbus.UInt32(self._handle.id)] = self._handle.name
176 logger.info("GetMemberIdentifiers called");175 logger.info("GetMemberIdentifiers called")
177 return identifiers176 return identifiers
178177
179 def Close(self):178 def Close(self):
@@ -193,7 +192,7 @@
193 pass192 pass
194193
195 def removeContent(self, content):194 def removeContent(self, content):
196 self.ContentRemoved(content, (dbus.UInt32(self._conn.self_handle.id), dbus.UInt32(telepathy.CALL_STATE_CHANGE_REASON_USER_REQUESTED), dbus.String(""), dbus.String(""))) 195 self.ContentRemoved(content, (dbus.UInt32(self._conn.self_handle.id), dbus.UInt32(telepathy.CALL_STATE_CHANGE_REASON_USER_REQUESTED), dbus.String(""), dbus.String("")))
197 del self._content[self._content.index(content)]196 del self._content[self._content.index(content)]
198197
199 def setCallState(self, state, actor, reason, flags):198 def setCallState(self, state, actor, reason, flags):
@@ -203,19 +202,19 @@
203 self._flags = flags202 self._flags = flags
204203
205 # signature='uu(uuss)a{sv}')204 # signature='uu(uuss)a{sv}')
206 self.CallStateChanged(dbus.UInt32(self._state), dbus.UInt32(self._flags), 205 self.CallStateChanged(dbus.UInt32(self._state), dbus.UInt32(self._flags),
207 (dbus.UInt32(self._stateActor), dbus.UInt32(self._stateReason), dbus.String(""), dbus.String("")), 206 (dbus.UInt32(self._stateActor), dbus.UInt32(self._stateReason), dbus.String(""), dbus.String("")),
208 dbus.Dictionary({}, signature="sv"))207 dbus.Dictionary({}, signature="sv"))
209208
210 def setMemberFlags(self, member, flags, actor=0, reason=telepathy.CALL_STATE_CHANGE_REASON_UNKNOWN):209 def setMemberFlags(self, member, flags, actor=0, reason=telepathy.CALL_STATE_CHANGE_REASON_UNKNOWN):
211 # FIXME: handle multiple contacts210 # FIXME: handle multiple contacts
212 self._memberFlags = flags211 self._memberFlags = flags
213212
214 # signature='a{uu}a{us}au(uuss)')213 # signature='a{uu}a{us}au(uuss)')
215 self.CallMembersChanged(dbus.Dictionary({dbus.UInt32(self._handle.id) : dbus.UInt32(self._memberFlags)}, signature="uu"),214 self.CallMembersChanged(dbus.Dictionary({dbus.UInt32(self._handle.id): dbus.UInt32(self._memberFlags)}, signature="uu"),
216 dbus.Dictionary({dbus.UInt32(self._handle.id) : dbus.String(self._handle.name)}, signature="us"),215 dbus.Dictionary({dbus.UInt32(self._handle.id): dbus.String(self._handle.name)}, signature="us"),
217 dbus.Array([], signature="u"),216 dbus.Array([], signature="u"),
218 (dbus.UInt32(actor), dbus.UInt32(reason), dbus.String(""), dbus.String("")))217 (dbus.UInt32(actor), dbus.UInt32(reason), dbus.String(""), dbus.String("")))
219218
220 ### oFono Call Interface ###219 ### oFono Call Interface ###
221 def oFonoCallStateChanged(self):220 def oFonoCallStateChanged(self):
@@ -235,7 +234,7 @@
235 if (self._holdState == LOCAL_HOLD_STATE_UNHELD):234 if (self._holdState == LOCAL_HOLD_STATE_UNHELD):
236 self.HoldStateChanged(LOCAL_HOLD_STATE_HELD, LOCAL_HOLD_STATE_REASON_REQUESTED)235 self.HoldStateChanged(LOCAL_HOLD_STATE_HELD, LOCAL_HOLD_STATE_REASON_REQUESTED)
237 self._holdState = LOCAL_HOLD_STATE_HELD236 self._holdState = LOCAL_HOLD_STATE_HELD
238 self.setCallState(telepathy.CALL_STATE_ACTIVE, self._handle.id, telepathy.CALL_STATE_CHANGE_REASON_USER_REQUESTED, telepathy.CALL_FLAG_LOCALLY_HELD) 237 self.setCallState(telepathy.CALL_STATE_ACTIVE, self._handle.id, telepathy.CALL_STATE_CHANGE_REASON_USER_REQUESTED, telepathy.CALL_FLAG_LOCALLY_HELD)
239 elif self.isCallForeground():238 elif self.isCallForeground():
240 # the call was accepted/unheld239 # the call was accepted/unheld
241 logger.info("The call is active")240 logger.info("The call is active")
@@ -251,14 +250,15 @@
251 # incoming call stopped ringing250 # incoming call stopped ringing
252 self.setCallState(telepathy.CALL_STATE_ENDED, self._handle.id, telepathy.CALL_STATE_CHANGE_REASON_NO_ANSWER, 0)251 self.setCallState(telepathy.CALL_STATE_ENDED, self._handle.id, telepathy.CALL_STATE_CHANGE_REASON_NO_ANSWER, 0)
253 self.Close()252 self.Close()
254 else: # handle outgoing call253 else:
254 # handle outgoing call
255 if self.isCallHeld():255 if self.isCallHeld():
256 # put on hold256 # put on hold
257 logger.info("The call is on hold")257 logger.info("The call is on hold")
258 if (self._holdState == LOCAL_HOLD_STATE_UNHELD):258 if (self._holdState == LOCAL_HOLD_STATE_UNHELD):
259 self.HoldStateChanged(LOCAL_HOLD_STATE_HELD, LOCAL_HOLD_STATE_REASON_REQUESTED)259 self.HoldStateChanged(LOCAL_HOLD_STATE_HELD, LOCAL_HOLD_STATE_REASON_REQUESTED)
260 self._holdState = LOCAL_HOLD_STATE_HELD260 self._holdState = LOCAL_HOLD_STATE_HELD
261 self.setCallState(telepathy.CALL_STATE_ACTIVE, self._handle.id, telepathy.CALL_STATE_CHANGE_REASON_USER_REQUESTED, telepathy.CALL_FLAG_LOCALLY_HELD) 261 self.setCallState(telepathy.CALL_STATE_ACTIVE, self._handle.id, telepathy.CALL_STATE_CHANGE_REASON_USER_REQUESTED, telepathy.CALL_FLAG_LOCALLY_HELD)
262 elif self.isCallForeground():262 elif self.isCallForeground():
263 if self._state == telepathy.CALL_STATE_ACCEPTED:263 if self._state == telepathy.CALL_STATE_ACCEPTED:
264 logger.info("The call is waiting for answer")264 logger.info("The call is waiting for answer")
@@ -271,7 +271,7 @@
271 self._holdState = LOCAL_HOLD_STATE_UNHELD271 self._holdState = LOCAL_HOLD_STATE_UNHELD
272 # set this call as accepted before active, so the duration field is correctly set in tp-logger272 # set this call as accepted before active, so the duration field is correctly set in tp-logger
273 if self._state != telepathy.CALL_STATE_ACTIVE:273 if self._state != telepathy.CALL_STATE_ACTIVE:
274 self.setCallState(telepathy.CALL_STATE_ACCEPTED, self._handle.id, telepathy.CALL_STATE_CHANGE_REASON_USER_REQUESTED, 0);274 self.setCallState(telepathy.CALL_STATE_ACCEPTED, self._handle.id, telepathy.CALL_STATE_CHANGE_REASON_USER_REQUESTED, 0)
275 self.setCallState(telepathy.CALL_STATE_ACTIVE, self._handle.id, telepathy.CALL_STATE_CHANGE_REASON_USER_REQUESTED, 0)275 self.setCallState(telepathy.CALL_STATE_ACTIVE, self._handle.id, telepathy.CALL_STATE_CHANGE_REASON_USER_REQUESTED, 0)
276 elif self.isCallRinging():276 elif self.isCallRinging():
277 logger.info("The call is ringing")277 logger.info("The call is ringing")
@@ -286,20 +286,20 @@
286286
287 def RequestMuted(self, muted):287 def RequestMuted(self, muted):
288 logger.info("RequestMuted called")288 logger.info("RequestMuted called")
289 if (self._localMuteState != LOCAL_MUTE_STATE_MUTED and muted == True):289 if (self._localMuteState != LOCAL_MUTE_STATE_MUTED and muted):
290 self._localMuteState = LOCAL_MUTE_STATE_MUTED290 self._localMuteState = LOCAL_MUTE_STATE_MUTED
291 self.MuteStateChanged(self._localMuteState)291 self.MuteStateChanged(self._localMuteState)
292 self._conn.SetMuted(True)292 self._conn.SetMuted(True)
293 elif (self._localMuteState != LOCAL_MUTE_STATE_UNMUTED and muted == False):293 elif (self._localMuteState != LOCAL_MUTE_STATE_UNMUTED and not muted):
294 self._localMuteState = LOCAL_MUTE_STATE_UNMUTED294 self._localMuteState = LOCAL_MUTE_STATE_UNMUTED
295 self.MuteStateChanged(self._localMuteState)295 self.MuteStateChanged(self._localMuteState)
296 self._conn.SetMuted(False)296 self._conn.SetMuted(False)
297297
298 def RequestHold(self, hold):298 def RequestHold(self, hold):
299 logger.info("RequestHold called")299 logger.info("RequestHold called")
300 if (self._holdState != LOCAL_HOLD_STATE_HELD and hold == True):300 if (self._holdState != LOCAL_HOLD_STATE_HELD and hold):
301 self._conn.SwapCalls()301 self._conn.SwapCalls()
302 elif (self._holdState != LOCAL_HOLD_STATE_UNHELD and hold == False):302 elif (self._holdState != LOCAL_HOLD_STATE_UNHELD and not hold):
303 self._conn.SwapCalls()303 self._conn.SwapCalls()
304304
305 def GetHoldState(self):305 def GetHoldState(self):
@@ -331,4 +331,3 @@
331 # TODO: implement speaker mode331 # TODO: implement speaker mode
332 #oFonoCall.turnOnSpeaker(self, active, False)332 #oFonoCall.turnOnSpeaker(self, active, False)
333 pass333 pass
334
335334
=== modified file 'tpofono/channel/text.py'
--- tpofono/channel/text.py 2013-02-19 20:09:40 +0000
+++ tpofono/channel/text.py 2013-03-28 19:50:24 +0000
@@ -18,11 +18,9 @@
18# You should have received a copy of the GNU General Public License18# You should have received a copy of the GNU General Public License
19# along with this program. If not, see <http://www.gnu.org/licenses/>.19# along with this program. If not, see <http://www.gnu.org/licenses/>.
2020
21import gobject
22import logging21import logging
23import weakref22import weakref
24import time23import time
25import re
2624
27import dbus25import dbus
28import telepathy26import telepathy
@@ -36,6 +34,7 @@
3634
37logger = logging.getLogger('oFono.TextChannel')35logger = logging.getLogger('oFono.TextChannel')
3836
37
39class oFonoTextChannel(38class oFonoTextChannel(
40 oFonoChannel,39 oFonoChannel,
41 telepathy.server.ChannelTypeText,40 telepathy.server.ChannelTypeText,
@@ -51,22 +50,22 @@
51 self._pending_messages2 = {}50 self._pending_messages2 = {}
5251
53 telepathy.server.ChannelTypeText.__init__(self, conn, manager, props,52 telepathy.server.ChannelTypeText.__init__(self, conn, manager, props,
54 object_path=object_path)53 object_path=object_path)
55 oFonoChannel.__init__(self, conn, props)54 oFonoChannel.__init__(self, conn, props)
56 ChannelInterfaceMessages.__init__(self)55 ChannelInterfaceMessages.__init__(self)
5756
58 self._implement_property_get(CHANNEL_INTERFACE_MESSAGES, {57 self._implement_property_get(CHANNEL_INTERFACE_MESSAGES, {
59 'SupportedContentTypes': lambda: ["text/plain"] ,58 'SupportedContentTypes': lambda: ["text/plain"],
60 'MessagePartSupportFlags': lambda: 0,59 'MessagePartSupportFlags': lambda: 0,
61 'DeliveryReportingSupport': lambda: telepathy.DELIVERY_REPORTING_SUPPORT_FLAG_RECEIVE_FAILURES,60 'DeliveryReportingSupport': lambda: telepathy.DELIVERY_REPORTING_SUPPORT_FLAG_RECEIVE_FAILURES,
62 'PendingMessages': lambda: dbus.Array(self._pending_messages2.values(), signature='aa{sv}')61 'PendingMessages': lambda: dbus.Array(self._pending_messages2.values(), signature='aa{sv}')
63 })62 })
6463
65 self._add_immutables({64 self._add_immutables({
66 'SupportedContentTypes': CHANNEL_INTERFACE_MESSAGES,65 'SupportedContentTypes': CHANNEL_INTERFACE_MESSAGES,
67 'MessagePartSupportFlags': CHANNEL_INTERFACE_MESSAGES,66 'MessagePartSupportFlags': CHANNEL_INTERFACE_MESSAGES,
68 'DeliveryReportingSupport': CHANNEL_INTERFACE_MESSAGES,67 'DeliveryReportingSupport': CHANNEL_INTERFACE_MESSAGES,
69 })68 })
7069
71 def _send_text_message(self, message_type, text):70 def _send_text_message(self, message_type, text):
72 "Send a simple text message, return true if sent correctly"71 "Send a simple text message, return true if sent correctly"
@@ -88,11 +87,8 @@
88 def MessageSentCallback(self, objectPath, status):87 def MessageSentCallback(self, objectPath, status):
89 if status == self._conn.PROPERTY_STATUS_SENT:88 if status == self._conn.PROPERTY_STATUS_SENT:
90 return89 return
91 timestamp = int(time.time())
92 if objectPath in self.sentMessages:90 if objectPath in self.sentMessages:
93 message = self.sentMessages.pop(objectPath)91 self.sentMessages.pop(objectPath)
94 message_type = message["message_type"]
95 text = message["text"]
96 headers = {}92 headers = {}
97 body = {}93 body = {}
98 delivery = {'message-sender': self._handle_id,94 delivery = {'message-sender': self._handle_id,
@@ -103,12 +99,14 @@
103 self.MessageReceived(msg)99 self.MessageReceived(msg)
104100
105 def _signal_text_sent(self, timestamp, message_type, text):101 def _signal_text_sent(self, timestamp, message_type, text):
106 headers = {'message-sent' : timestamp,102 headers = {
107 'message-type' : message_type103 'message-sent': timestamp,
108 }104 'message-type': message_type
109 body = {'content-type': 'text/plain',105 }
110 'content': text106 body = {
111 }107 'content-type': 'text/plain',
108 'content': text
109 }
112 message = [headers, body]110 message = [headers, body]
113 self.Sent(timestamp, message_type, text)111 self.Sent(timestamp, message_type, text)
114 self.MessageSent(message, 0, '')112 self.MessageSent(message, 0, '')
@@ -116,17 +114,19 @@
116 def _signal_text_received(self, sender, text, id, timestamp, scrollback):114 def _signal_text_received(self, sender, text, id, timestamp, scrollback):
117 type = telepathy.CHANNEL_TEXT_MESSAGE_TYPE_NORMAL115 type = telepathy.CHANNEL_TEXT_MESSAGE_TYPE_NORMAL
118 self.Received(id, timestamp, sender.id, type, 0, text)116 self.Received(id, timestamp, sender.id, type, 0, text)
119 headers = dbus.Dictionary({dbus.String('message-received') : dbus.UInt64(timestamp),117 headers = dbus.Dictionary({
120 dbus.String('pending-message-id') : dbus.UInt32(id),118 dbus.String('message-received'): dbus.UInt64(timestamp),
121 dbus.String('message-token') : dbus.String(id),119 dbus.String('pending-message-id'): dbus.UInt32(id),
122 dbus.String('message-sender') : dbus.UInt32(sender),120 dbus.String('message-token'): dbus.String(id),
123 dbus.String('message-type') : dbus.UInt32(type),121 dbus.String('message-sender'): dbus.UInt32(sender),
124 dbus.String('scrollback') : dbus.Boolean(scrollback)122 dbus.String('message-type'): dbus.UInt32(type),
125 }, signature='sv')123 dbus.String('scrollback'): dbus.Boolean(scrollback)
124 }, signature='sv')
126125
127 body = dbus.Dictionary({dbus.String('content-type'): dbus.String('text/plain'),126 body = dbus.Dictionary({
128 dbus.String('content'): dbus.String(text)127 dbus.String('content-type'): dbus.String('text/plain'),
129 }, signature='sv')128 dbus.String('content'): dbus.String(text)
129 }, signature='sv')
130 message = dbus.Array([headers, body], signature='a{sv}')130 message = dbus.Array([headers, body], signature='a{sv}')
131 self.MessageReceived(message)131 self.MessageReceived(message)
132132
@@ -154,7 +154,7 @@
154 raise telepathy.NotImplemented("Unhandled message type")154 raise telepathy.NotImplemented("Unhandled message type")
155 text = None155 text = None
156 for part in message:156 for part in message:
157 if part.get("content-type", None) == "text/plain":157 if part.get("content-type", None) == "text/plain":
158 text = part['content']158 text = part['content']
159 break159 break
160 if text is None:160 if text is None:
@@ -165,7 +165,7 @@
165 self._signal_text_sent(timestamp, message_type, text)165 self._signal_text_sent(timestamp, message_type, text)
166166
167 def AcknowledgePendingMessages(self, ids):167 def AcknowledgePendingMessages(self, ids):
168 readIds = [] 168 readIds = []
169 for id in ids:169 for id in ids:
170 if id in self._pending_messages2:170 if id in self._pending_messages2:
171 del self._pending_messages2[id]171 del self._pending_messages2[id]
172172
=== modified file 'tpofono/channel_manager.py'
--- tpofono/channel_manager.py 2013-02-19 20:09:40 +0000
+++ tpofono/channel_manager.py 2013-03-28 19:50:24 +0000
@@ -17,16 +17,12 @@
17# along with this program. If not, see <http://www.gnu.org/licenses/>.17# along with this program. If not, see <http://www.gnu.org/licenses/>.
1818
19import logging19import logging
20import weakref
21from string import ascii_letters, digits20from string import ascii_letters, digits
2221
23import dbus
24import telepathy22import telepathy
25from telepathy.interfaces import CHANNEL_TYPE_CALL
2623
27from tpofono.channel.text import oFonoTextChannel24from tpofono.channel.text import oFonoTextChannel
28from tpofono.channel.call import oFonoCallChannel25from tpofono.channel.call import oFonoCallChannel
29from tpofono.handle import oFonoHandleFactory
3026
31__all__ = ['oFonoChannelManager']27__all__ = ['oFonoChannelManager']
3228
@@ -34,6 +30,7 @@
3430
35_ASCII_ALNUM = ascii_letters + digits31_ASCII_ALNUM = ascii_letters + digits
3632
33
37class oFonoChannelManager(telepathy.server.ChannelManager):34class oFonoChannelManager(telepathy.server.ChannelManager):
38 __text_channel_id = 135 __text_channel_id = 1
39 __call_channel_id = 136 __call_channel_id = 1
@@ -58,7 +55,7 @@
58 # Normal 1-1 chat55 # Normal 1-1 chat
59 if handle.get_type() == telepathy.HANDLE_TYPE_CONTACT:56 if handle.get_type() == telepathy.HANDLE_TYPE_CONTACT:
60 channel = oFonoTextChannel(self._conn, self, conversation, handle, props,57 channel = oFonoTextChannel(self._conn, self, conversation, handle, props,
61 object_path=path)58 object_path=path)
62 else:59 else:
63 raise telepathy.NotImplemented('Only contacts are allowed')60 raise telepathy.NotImplemented('Only contacts are allowed')
6461
@@ -70,8 +67,6 @@
70 if handle.get_type() != telepathy.HANDLE_TYPE_CONTACT:67 if handle.get_type() != telepathy.HANDLE_TYPE_CONTACT:
71 raise telepathy.NotImplemented('Only contacts are allowed')68 raise telepathy.NotImplemented('Only contacts are allowed')
7269
73 contact = handle.contact
74
75 logger.debug('New call channel')70 logger.debug('New call channel')
7671
77 path = "CallChannel/%d" % self.__call_channel_id72 path = "CallChannel/%d" % self.__call_channel_id
@@ -86,7 +81,7 @@
86 break81 break
8782
88 # if it is not found, call the number83 # if it is not found, call the number
89 if call == None:84 if call is None:
90 logger.info("No existing call found, calling ofono now")85 logger.info("No existing call found, calling ofono now")
91 call = self._conn.Call(handle.name)86 call = self._conn.Call(handle.name)
9287
@@ -110,4 +105,3 @@
110 if channel._call == objectPath:105 if channel._call == objectPath:
111 return channel106 return channel
112 return None107 return None
113
114108
=== modified file 'tpofono/connection.py'
--- tpofono/connection.py 2013-02-20 18:45:38 +0000
+++ tpofono/connection.py 2013-03-28 19:50:24 +0000
@@ -17,19 +17,13 @@
17# You should have received a copy of the GNU General Public License17# You should have received a copy of the GNU General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.18# along with this program. If not, see <http://www.gnu.org/licenses/>.
1919
20import weakref
21import logging20import logging
2221
23import dbus22import dbus
24import telepathy23import telepathy
25import hashlib
26import datetime
27from datetime import datetime24from datetime import datetime
28from datetime import timedelta
29import time25import time
3026
31from telepathy.interfaces import CONNECTION, CHANNEL_TYPE_CALL
32
33from tpofono.aliasing import oFonoAliasing27from tpofono.aliasing import oFonoAliasing
34from tpofono.capabilities import oFonoCapabilities28from tpofono.capabilities import oFonoCapabilities
35from tpofono.handle import oFonoHandleFactory29from tpofono.handle import oFonoHandleFactory
@@ -51,17 +45,16 @@
5145
5246
53class oFonoConnection(telepathy.server.Connection,47class oFonoConnection(telepathy.server.Connection,
54 telepathy.server.ConnectionInterfaceRequests,48 telepathy.server.ConnectionInterfaceRequests,
55 oFonoAliasing,49 oFonoAliasing,
56# oFonoAvatars,50 oFonoCapabilities,
57 oFonoCapabilities,51 oFonoContacts,
58 oFonoContacts,52 oFonoCalls,
59 oFonoCalls,53 oFonoCallVolume,
60 oFonoCallVolume,54 oFonoMessages,
61 oFonoMessages,55 oFonoPresence,
62 oFonoPresence,56 oFonoVoicemail,
63 oFonoVoicemail,57 oFonoManager):
64 oFonoManager):
6558
66 phone = None59 phone = None
67 createdChannels = []60 createdChannels = []
@@ -75,13 +68,13 @@
7568
76 try:69 try:
77 self.myModem = None70 self.myModem = None
78 self._account = "ofono" #unicode(parameters['account'])71 self._account = "ofono" # unicode(parameters['account'])
79 self._channel_manager = oFonoChannelManager(self, protocol)72 self._channel_manager = oFonoChannelManager(self, protocol)
80 self._manager = manager73 self._manager = manager
8174
82 # Call parent initializers75 # Call parent initializers
83 telepathy.server.Connection.__init__(self, 'ofono', self._account,76 telepathy.server.Connection.__init__(self, 'ofono', self._account,
84 'ofono', protocol)77 'ofono', protocol)
85 telepathy.server.ConnectionInterfaceRequests.__init__(self)78 telepathy.server.ConnectionInterfaceRequests.__init__(self)
86 oFonoAliasing.__init__(self)79 oFonoAliasing.__init__(self)
87 #oFonoAvatars.__init__(self)80 #oFonoAvatars.__init__(self)
@@ -94,12 +87,12 @@
94 oFonoVoicemail.__init__(self)87 oFonoVoicemail.__init__(self)
9588
96 # FIXME: re-add the org.ofono.MessageWaiting interface once it is available again89 # FIXME: re-add the org.ofono.MessageWaiting interface once it is available again
97 oFonoManager.__init__(self, [ "org.ofono.MessageManager", "org.ofono.VoiceCallManager", "org.ofono.CallVolume" ])90 oFonoManager.__init__(self, ["org.ofono.MessageManager", "org.ofono.VoiceCallManager", "org.ofono.CallVolume"])
98 # NOTE: comment the line above and uncomment the one below to test telepathy-ofono using ofono-phonesim91 # NOTE: comment the line above and uncomment the one below to test telepathy-ofono using ofono-phonesim
99 #oFonoManager.__init__(self, [ "org.ofono.MessageManager", "org.ofono.VoiceCallManager" ])92 #oFonoManager.__init__(self, [ "org.ofono.MessageManager", "org.ofono.VoiceCallManager" ])
10093
101 self_handle = self.create_handle(telepathy.HANDLE_TYPE_CONTACT,94 self_handle = self.create_handle(telepathy.HANDLE_TYPE_CONTACT,
102 self._account)95 self._account)
103 self.set_self_handle(self_handle)96 self.set_self_handle(self_handle)
10497
105 self._implement_property_get(telepathy.CONNECTION, {98 self._implement_property_get(telepathy.CONNECTION, {
@@ -108,8 +101,7 @@
108101
109 logger.info("Connection to the account %s created" % self._account)102 logger.info("Connection to the account %s created" % self._account)
110103
111 except Exception, e:104 except:
112 import traceback
113 logger.exception("Failed to create Connection")105 logger.exception("Failed to create Connection")
114 raise106 raise
115107
@@ -136,7 +128,7 @@
136 """Create new handle with given type and name."""128 """Create new handle with given type and name."""
137 handle_id = self.get_handle_id()129 handle_id = self.get_handle_id()
138 handle = oFonoHandleFactory(self, handle_type, handle_id,130 handle = oFonoHandleFactory(self, handle_type, handle_id,
139 handle_name, **kwargs)131 handle_name, **kwargs)
140 if handle is None:132 if handle is None:
141 raise telepathy.NotAvailable('Handle type unsupported %d' % handle_type)133 raise telepathy.NotAvailable('Handle type unsupported %d' % handle_type)
142 logger.info("New Handle %s" % unicode(handle))134 logger.info("New Handle %s" % unicode(handle))
@@ -157,7 +149,7 @@
157 """Normalize handle name so the name is consistent everywhere."""149 """Normalize handle name so the name is consistent everywhere."""
158 if not self.is_valid_handle_name(handle_type, handle_name):150 if not self.is_valid_handle_name(handle_type, handle_name):
159 raise telepathy.InvalidHandle('TargetID %s not valid for type %d' %151 raise telepathy.InvalidHandle('TargetID %s not valid for type %d' %
160 (name, handle_type))152 (handle_name, handle_type))
161 if handle_type == telepathy.HANDLE_TYPE_CONTACT:153 if handle_type == telepathy.HANDLE_TYPE_CONTACT:
162 return handle_name.lower().strip()154 return handle_name.lower().strip()
163 return handle_name155 return handle_name
@@ -195,7 +187,7 @@
195 alias = parsedVcard.fn.value187 alias = parsedVcard.fn.value
196 else:188 else:
197 alias = handle.name189 alias = handle.name
198 190
199 self.contactInfo[handle_id] = {}191 self.contactInfo[handle_id] = {}
200 self.contactInfo[handle_id]['alias'] = alias192 self.contactInfo[handle_id]['alias'] = alias
201193
@@ -211,7 +203,7 @@
211 logger.info("Connecting")203 logger.info("Connecting")
212 self.StatusChanged(telepathy.CONNECTION_STATUS_CONNECTING, telepathy.CONNECTION_STATUS_REASON_REQUESTED)204 self.StatusChanged(telepathy.CONNECTION_STATUS_CONNECTING, telepathy.CONNECTION_STATUS_REASON_REQUESTED)
213 self.StatusChanged(telepathy.CONNECTION_STATUS_CONNECTED, telepathy.CONNECTION_STATUS_REASON_REQUESTED)205 self.StatusChanged(telepathy.CONNECTION_STATUS_CONNECTED, telepathy.CONNECTION_STATUS_REASON_REQUESTED)
214 if self.myModem != None:206 if self.myModem is not None:
215 self.SetOnline(True)207 self.SetOnline(True)
216 else:208 else:
217 self.SetOnline(False)209 self.SetOnline(False)
@@ -236,20 +228,18 @@
236 telepathy.CHANNEL_INTERFACE + '.TargetHandle': handle.get_id(),228 telepathy.CHANNEL_INTERFACE + '.TargetHandle': handle.get_id(),
237 telepathy.CHANNEL_INTERFACE + '.TargetHandleType': handle.get_type(),229 telepathy.CHANNEL_INTERFACE + '.TargetHandleType': handle.get_type(),
238 telepathy.CHANNEL_INTERFACE + '.Requested': suppress_handler230 telepathy.CHANNEL_INTERFACE + '.Requested': suppress_handler
239 }231 }
240232
241 if initiator_handle is not None:233 if initiator_handle is not None:
242 if initiator_handle.get_type() is not telepathy.HANDLE_TYPE_NONE:234 if initiator_handle.get_type() is not telepathy.HANDLE_TYPE_NONE:
243 props[telepathy.CHANNEL_INTERFACE + '.InitiatorHandle'] = \235 props[telepathy.CHANNEL_INTERFACE + '.InitiatorHandle'] = initiator_handle.get_id()
244 initiator_handle.get_id()
245236
246 return props237 return props
247238
248
249 @dbus.service.method(telepathy.CONNECTION, in_signature='suub',239 @dbus.service.method(telepathy.CONNECTION, in_signature='suub',
250 out_signature='o', async_callbacks=('_success', '_error'))240 out_signature='o', async_callbacks=('_success', '_error'))
251 def RequestChannel(self, type, handle_type, handle_id, suppress_handler,241 def RequestChannel(self, type, handle_type, handle_id, suppress_handler,
252 _success, _error):242 _success, _error):
253 self.check_connected()243 self.check_connected()
254 channel_manager = self._channel_manager244 channel_manager = self._channel_manager
255245
@@ -281,10 +271,10 @@
281 call = oFonoCall(objectPath, properties)271 call = oFonoCall(objectPath, properties)
282 if call.isCallIncoming() or call.isCallWaiting():272 if call.isCallIncoming() or call.isCallWaiting():
283 props = self._generate_props(telepathy.CHANNEL_TYPE_CALL,273 props = self._generate_props(telepathy.CHANNEL_TYPE_CALL,
284 handle, False, initiator_handle=handle)274 handle, False, initiator_handle=handle)
285 else:275 else:
286 props = self._generate_props(telepathy.CHANNEL_TYPE_CALL,276 props = self._generate_props(telepathy.CHANNEL_TYPE_CALL,
287 handle, False, initiator_handle=self.self_handle)277 handle, False, initiator_handle=self.self_handle)
288278
289 # check if this channel was already created279 # check if this channel was already created
290 if self._channel_manager.existing_channel(props):280 if self._channel_manager.existing_channel(props):
@@ -297,7 +287,7 @@
297 def ModemAdded(self, modem):287 def ModemAdded(self, modem):
298 logger.info("Got modem %s", modem.objectPath)288 logger.info("Got modem %s", modem.objectPath)
299 # check if we already have a modem289 # check if we already have a modem
300 if self.myModem != None:290 if self.myModem is not None:
301 return291 return
302292
303 self.myModem = modem293 self.myModem = modem
@@ -340,14 +330,14 @@
340 text = message330 text = message
341 timestamp = datetime.strptime(props["SentTime"][:-5], "%Y-%m-%dT%H:%M:%S")331 timestamp = datetime.strptime(props["SentTime"][:-5], "%Y-%m-%dT%H:%M:%S")
342 timestamp = time.mktime(timestamp.timetuple())332 timestamp = time.mktime(timestamp.timetuple())
343 333
344 # FIXME: do not use timestamp as ID334 # FIXME: do not use timestamp as ID
345 id = int (timestamp)335 id = int(timestamp)
346 handle = self.ensure_contact_handle(number)336 handle = self.ensure_contact_handle(number)
347 props = self._generate_props(telepathy.CHANNEL_TYPE_TEXT,337 props = self._generate_props(telepathy.CHANNEL_TYPE_TEXT,
348 handle, False)338 handle, False)
349 channel = self._channel_manager.channel_for_props(props,339 channel = self._channel_manager.channel_for_props(props,
350 signal=True)340 signal=True)
351 channel._signal_text_received(handle, text, id, timestamp, scrollback)341 channel._signal_text_received(handle, text, id, timestamp, scrollback)
352342
353 @dbus.service.signal(dbus_interface=CANONICAL_IFACE_TELEPHONY,343 @dbus.service.signal(dbus_interface=CANONICAL_IFACE_TELEPHONY,
@@ -374,4 +364,3 @@
374 in_signature='', out_signature='i')364 in_signature='', out_signature='i')
375 def VoicemailCount(self):365 def VoicemailCount(self):
376 return oFonoVoicemail.VoicemailCount(self)366 return oFonoVoicemail.VoicemailCount(self)
377
378367
=== modified file 'tpofono/connection_manager.py'
--- tpofono/connection_manager.py 2013-02-19 20:09:40 +0000
+++ tpofono/connection_manager.py 2013-03-28 19:50:24 +0000
@@ -18,7 +18,6 @@
1818
19import telepathy19import telepathy
20import gobject20import gobject
21import dbus
22import logging21import logging
2322
24from tpofono.protocol import oFonoProtocol23from tpofono.protocol import oFonoProtocol
@@ -30,7 +29,7 @@
3029
31class oFonoConnectionManager(telepathy.server.ConnectionManager):30class oFonoConnectionManager(telepathy.server.ConnectionManager):
32 """oFono connection manager31 """oFono connection manager
33 32
34 Implements the org.freedesktop.Telepathy.ConnectionManager interface"""33 Implements the org.freedesktop.Telepathy.ConnectionManager interface"""
3534
36 def __init__(self, shutdown_func=None):35 def __init__(self, shutdown_func=None):
@@ -48,7 +47,7 @@
48 len(self._connections) == 0:47 len(self._connections) == 0:
49 self._shutdown()48 self._shutdown()
50 return False49 return False
51 result = telepathy.server.ConnectionManager.disconnected(self, conn)50 telepathy.server.ConnectionManager.disconnected(self, conn)
52 gobject.timeout_add_seconds(5, shutdown)51 gobject.timeout_add_seconds(5, shutdown)
5352
54 def quit(self):53 def quit(self):
5554
=== modified file 'tpofono/contacts.py'
--- tpofono/contacts.py 2013-02-19 20:09:40 +0000
+++ tpofono/contacts.py 2013-03-28 19:50:24 +0000
@@ -17,7 +17,6 @@
17# along with this program. If not, see <http://www.gnu.org/licenses/>.17# along with this program. If not, see <http://www.gnu.org/licenses/>.
1818
19import logging19import logging
20import time
2120
22import telepathy21import telepathy
23import telepathy.errors22import telepathy.errors
@@ -27,29 +26,29 @@
2726
28logger = logging.getLogger('oFono.Contacts')27logger = logging.getLogger('oFono.Contacts')
2928
29
30class oFonoContacts(30class oFonoContacts(
31 telepathy.server.ConnectionInterfaceContacts):31 telepathy.server.ConnectionInterfaceContacts):
3232
33 attributes = {33 attributes = {
34 telepathy.CONNECTION : 'contact-id',34 telepathy.CONNECTION: 'contact-id',
35 telepathy.CONNECTION_INTERFACE_ALIASING : 'alias',35 telepathy.CONNECTION_INTERFACE_ALIASING: 'alias',
36# telepathy.CONNECTION_INTERFACE_AVATARS : 'token',36 telepathy.CONNECTION_INTERFACE_CAPABILITIES: 'caps',
37 telepathy.CONNECTION_INTERFACE_CAPABILITIES : 'caps',37 telepathy.CONNECTION_INTERFACE_CONTACT_CAPABILITIES: 'capabilities',
38 telepathy.CONNECTION_INTERFACE_CONTACT_CAPABILITIES : 'capabilities',38 telepathy.CONNECTION_INTERFACE_SIMPLE_PRESENCE: 'presence'
39 telepathy.CONNECTION_INTERFACE_SIMPLE_PRESENCE : 'presence'39 }
40 }
4140
42 def __init__(self):41 def __init__(self):
43 telepathy.server.ConnectionInterfaceContacts.__init__(self)42 telepathy.server.ConnectionInterfaceContacts.__init__(self)
4443
45 dbus_interface = telepathy.CONNECTION_INTERFACE_CONTACTS44 dbus_interface = telepathy.CONNECTION_INTERFACE_CONTACTS
4645
47 self._implement_property_get(dbus_interface, \46 self._implement_property_get(dbus_interface,
48 {'ContactAttributeInterfaces' : self.get_contact_attribute_interfaces})47 {'ContactAttributeInterfaces': self.get_contact_attribute_interfaces})
4948
50 # Overwrite the dbus attribute to get the sender argument49 # Overwrite the dbus attribute to get the sender argument
51 @dbus.service.method(telepathy.CONNECTION_INTERFACE_CONTACTS, in_signature='auasb',50 @dbus.service.method(telepathy.CONNECTION_INTERFACE_CONTACTS, in_signature='auasb',
52 out_signature='a{ua{sv}}', sender_keyword='sender')51 out_signature='a{ua{sv}}', sender_keyword='sender')
53 def GetContactAttributes(self, handles, interfaces, hold, sender):52 def GetContactAttributes(self, handles, interfaces, hold, sender):
54 #InspectHandle already checks we're connected, the handles and handle type.53 #InspectHandle already checks we're connected, the handles and handle type.
55 supported_interfaces = set()54 supported_interfaces = set()
@@ -66,19 +65,19 @@
66 ret[handle] = dbus.Dictionary(signature='sv')65 ret[handle] = dbus.Dictionary(signature='sv')
6766
68 functions = {67 functions = {
69 telepathy.CONNECTION :68 telepathy.CONNECTION:
70 lambda x: zip(x, self.InspectHandles(handle_type, x)),69 lambda x: zip(x, self.InspectHandles(handle_type, x)),
71 telepathy.CONNECTION_INTERFACE_ALIASING :70 telepathy.CONNECTION_INTERFACE_ALIASING:
72 lambda x: self.GetAliases(x).items(),71 lambda x: self.GetAliases(x).items(),
73# telepathy.CONNECTION_INTERFACE_AVATARS :72# telepathy.CONNECTION_INTERFACE_AVATARS:
74# lambda x: self.GetKnownAvatarTokens(x).items(),73# lambda x: self.GetKnownAvatarTokens(x).items(),
75 telepathy.CONNECTION_INTERFACE_CAPABILITIES :74 telepathy.CONNECTION_INTERFACE_CAPABILITIES:
76 lambda x: self.GetCapabilities(x).items(),75 lambda x: self.GetCapabilities(x).items(),
77 telepathy.CONNECTION_INTERFACE_CONTACT_CAPABILITIES :76 telepathy.CONNECTION_INTERFACE_CONTACT_CAPABILITIES:
78 lambda x: self.GetContactCapabilities(x).items(),77 lambda x: self.GetContactCapabilities(x).items(),
79 telepathy.CONNECTION_INTERFACE_SIMPLE_PRESENCE :78 telepathy.CONNECTION_INTERFACE_SIMPLE_PRESENCE:
80 lambda x: self.GetPresences(x).items()79 lambda x: self.GetPresences(x).items()
81 }80 }
8281
83 #Hold handles if needed82 #Hold handles if needed
84 if hold:83 if hold:
8584
=== modified file 'tpofono/debug.py'
--- tpofono/debug.py 2013-02-19 20:09:40 +0000
+++ tpofono/debug.py 2013-03-28 19:50:24 +0000
@@ -18,6 +18,7 @@
1818
19import telepathy19import telepathy
2020
21
21class oFonoDebug(telepathy.server.Debug):22class oFonoDebug(telepathy.server.Debug):
22 """oFono debug interface23 """oFono debug interface
2324
2425
=== modified file 'tpofono/handle.py'
--- tpofono/handle.py 2013-02-19 20:09:40 +0000
+++ tpofono/handle.py 2013-03-28 19:50:24 +0000
@@ -25,6 +25,7 @@
2525
26logger = logging.getLogger('oFono.Handle')26logger = logging.getLogger('oFono.Handle')
2727
28
28def oFonoHandleFactory(connection, type, id, name, **kwargs):29def oFonoHandleFactory(connection, type, id, name, **kwargs):
29 mapping = {telepathy.HANDLE_TYPE_CONTACT: oFonoContactHandle}30 mapping = {telepathy.HANDLE_TYPE_CONTACT: oFonoContactHandle}
30 handle = mapping[type](connection, id, name, **kwargs)31 handle = mapping[type](connection, id, name, **kwargs)
@@ -38,7 +39,7 @@
38 self._conn = weakref.proxy(connection)39 self._conn = weakref.proxy(connection)
3940
40 def __unicode__(self):41 def __unicode__(self):
41 type_mapping = {telepathy.HANDLE_TYPE_CONTACT : 'Contact'}42 type_mapping = {telepathy.HANDLE_TYPE_CONTACT: 'Contact'}
42 type_str = type_mapping.get(self.type, '')43 type_str = type_mapping.get(self.type, '')
43 return "<oFono%sHandle id=%u name='%s'>" % \44 return "<oFono%sHandle id=%u name='%s'>" % \
44 (type_str, self.id, self.name)45 (type_str, self.id, self.name)
@@ -56,4 +57,3 @@
56 @property57 @property
57 def contact(self):58 def contact(self):
58 return self._contact59 return self._contact
59
6060
=== modified file 'tpofono/ofono/__init__.py'
--- tpofono/ofono/__init__.py 2013-02-19 20:09:40 +0000
+++ tpofono/ofono/__init__.py 2013-03-28 19:50:24 +0000
@@ -25,3 +25,11 @@
25from ofonovoicemail import oFonoVoicemail25from ofonovoicemail import oFonoVoicemail
26from ofonomodem import oFonoModem26from ofonomodem import oFonoModem
27from ofonomanager import oFonoManager27from ofonomanager import oFonoManager
28
29__all__ = ['oFonoCall',
30 'oFonoCalls',
31 'oFonoCallVolume',
32 'oFonoMessages',
33 'oFonoVoicemail',
34 'oFonoModem',
35 'oFonoManager']
2836
=== modified file 'tpofono/ofono/ofonocall.py'
--- tpofono/ofono/ofonocall.py 2013-02-19 20:09:40 +0000
+++ tpofono/ofono/ofonocall.py 2013-03-28 19:50:24 +0000
@@ -17,12 +17,12 @@
1717
18import logging18import logging
19import dbus19import dbus
20import gobject
2120
22__all__ = ['oFonoCall.py']21__all__ = ['oFonoCall']
2322
24logger = logging.getLogger('oFono.Call')23logger = logging.getLogger('oFono.Call')
2524
25
26class oFonoCall:26class oFonoCall:
27 PROPERTY_KEY_STATE = "State"27 PROPERTY_KEY_STATE = "State"
28 PROPERTY_KEY_LINE_IDENTIFICATION = "LineIdentification"28 PROPERTY_KEY_LINE_IDENTIFICATION = "LineIdentification"
@@ -61,7 +61,7 @@
61 if prop == self.PROPERTY_KEY_STATE:61 if prop == self.PROPERTY_KEY_STATE:
62 self.StatePropertyChanged(value)62 self.StatePropertyChanged(value)
6363
64 def StatePropertyChanged(self, state, notify = True):64 def StatePropertyChanged(self, state, notify=True):
65 self.isRinging = state == self.PROPERTY_STATE_INCOMING65 self.isRinging = state == self.PROPERTY_STATE_INCOMING
66 self.isHeld = state == self.PROPERTY_STATE_HELD66 self.isHeld = state == self.PROPERTY_STATE_HELD
67 self.isAlerting = state == self.PROPERTY_STATE_ALERTING67 self.isAlerting = state == self.PROPERTY_STATE_ALERTING
@@ -109,4 +109,3 @@
109109
110 def isCallWaiting(self):110 def isCallWaiting(self):
111 return self.isWaiting111 return self.isWaiting
112
113112
=== modified file 'tpofono/ofono/ofonocalls.py'
--- tpofono/ofono/ofonocalls.py 2013-02-19 20:09:40 +0000
+++ tpofono/ofono/ofonocalls.py 2013-03-28 19:50:24 +0000
@@ -21,11 +21,10 @@
2121
22import logging22import logging
23import dbus23import dbus
24import gobject
25from ofonomanager import oFonoManager
2624
27logger = logging.getLogger('oFonoCalls')25logger = logging.getLogger('oFonoCalls')
2826
27
29class oFonoCalls:28class oFonoCalls:
30 def __init__(self):29 def __init__(self):
31 self.props = {}30 self.props = {}
@@ -76,7 +75,7 @@
76 def oFonoCallRemoved(self, objectPath):75 def oFonoCallRemoved(self, objectPath):
77 # TODO: check if this code actually works76 # TODO: check if this code actually works
78 if objectPath in self.calls:77 if objectPath in self.calls:
79 props = self.calls.pop(objectPath)78 self.calls.pop(objectPath)
80 self.CallRemoved(objectPath)79 self.CallRemoved(objectPath)
8180
82 def CallAdded(self, objectPath, properties):81 def CallAdded(self, objectPath, properties):
8382
=== modified file 'tpofono/ofono/ofonocallvolume.py'
--- tpofono/ofono/ofonocallvolume.py 2013-02-19 20:09:40 +0000
+++ tpofono/ofono/ofonocallvolume.py 2013-03-28 19:50:24 +0000
@@ -21,15 +21,15 @@
2121
22import logging22import logging
23import dbus23import dbus
24import gobject
25from ofonomanager import oFonoManager
2624
27logger = logging.getLogger('oFonoCallVolume')25logger = logging.getLogger('oFonoCallVolume')
2826
27
29class oFonoCallVolume:28class oFonoCallVolume:
30 PROPERTY_KEY_SPEAKER_VOLUME = "SpeakerVolume"29 PROPERTY_KEY_SPEAKER_VOLUME = "SpeakerVolume"
31 PROPERTY_KEY_MICROPHONE_VOUME = "MicrophoneVolume"30 PROPERTY_KEY_MICROPHONE_VOUME = "MicrophoneVolume"
32 PROPERTY_KEY_MUTED = "Muted"31 PROPERTY_KEY_MUTED = "Muted"
32
33 def __init__(self):33 def __init__(self):
34 self.props = {}34 self.props = {}
3535
3636
=== modified file 'tpofono/ofono/ofonomanager.py'
--- tpofono/ofono/ofonomanager.py 2013-02-20 18:15:06 +0000
+++ tpofono/ofono/ofonomanager.py 2013-03-28 19:50:24 +0000
@@ -25,8 +25,10 @@
2525
26logger = logging.getLogger('oFonoManager')26logger = logging.getLogger('oFonoManager')
2727
28
28class oFonoManager():29class oFonoManager():
29 ofono_manager_proxy = None30 ofono_manager_proxy = None
31
30 def __init__(self, modem_interfaces):32 def __init__(self, modem_interfaces):
31 self.modem_interfaces = modem_interfaces33 self.modem_interfaces = modem_interfaces
32 self.modems = []34 self.modems = []
@@ -46,7 +48,7 @@
4648
47 # parse modems49 # parse modems
48 modems = self.GetModems()50 modems = self.GetModems()
49 for modem in self.GetModems():51 for modem in modems:
50 self.oFonoModemAdded(modem[0], modem[1])52 self.oFonoModemAdded(modem[0], modem[1])
5153
52 except:54 except:
@@ -97,4 +99,3 @@
9799
98 def ModemRemoved(self, modem):100 def ModemRemoved(self, modem):
99 pass101 pass
100
101102
=== modified file 'tpofono/ofono/ofonomessages.py'
--- tpofono/ofono/ofonomessages.py 2013-02-19 20:09:40 +0000
+++ tpofono/ofono/ofonomessages.py 2013-03-28 19:50:24 +0000
@@ -20,11 +20,10 @@
2020
21import logging21import logging
22import dbus22import dbus
23import gobject
24from ofonomanager import oFonoManager
2523
26logger = logging.getLogger('oFonoMessages')24logger = logging.getLogger('oFonoMessages')
2725
26
28class oFonoMessages:27class oFonoMessages:
2928
30 PROPERTY_KEY_STATUS = "State"29 PROPERTY_KEY_STATUS = "State"
@@ -77,4 +76,3 @@
77 objectPath = self.ofono_message_proxy.SendMessage(to, message)76 objectPath = self.ofono_message_proxy.SendMessage(to, message)
78 self.pendingMessages[objectPath] = textChannel77 self.pendingMessages[objectPath] = textChannel
79 return objectPath78 return objectPath
80
8179
=== modified file 'tpofono/ofono/ofonomodem.py'
--- tpofono/ofono/ofonomodem.py 2013-02-20 18:15:06 +0000
+++ tpofono/ofono/ofonomodem.py 2013-03-28 19:50:24 +0000
@@ -18,10 +18,11 @@
18import logging18import logging
19import dbus19import dbus
2020
21__all__ = ['oFonoModem.py']21__all__ = ['oFonoModem']
2222
23logger = logging.getLogger('oFono.Modem')23logger = logging.getLogger('oFono.Modem')
2424
25
25class oFonoModem:26class oFonoModem:
26 def __init__(self, manager, objectPath, properties):27 def __init__(self, manager, objectPath, properties):
27 self._manager = manager28 self._manager = manager
2829
=== modified file 'tpofono/ofono/ofonovoicemail.py'
--- tpofono/ofono/ofonovoicemail.py 2013-02-19 20:09:40 +0000
+++ tpofono/ofono/ofonovoicemail.py 2013-03-28 19:50:24 +0000
@@ -21,15 +21,15 @@
2121
22import logging22import logging
23import dbus23import dbus
24import gobject
25from ofonomanager import oFonoManager
2624
27logger = logging.getLogger('oFonoVoicemail')25logger = logging.getLogger('oFonoVoicemail')
2826
27
29class oFonoVoicemail:28class oFonoVoicemail:
30 PROPERTY_KEY_VOICEMAIL_WAITING = "VoicemailWaiting"29 PROPERTY_KEY_VOICEMAIL_WAITING = "VoicemailWaiting"
31 PROPERTY_KEY_VOICEMAIL_MESSAGE_COUNT = "VoicemailMessageCount"30 PROPERTY_KEY_VOICEMAIL_MESSAGE_COUNT = "VoicemailMessageCount"
32 PROPERTY_KEY_VOICEMAIL_NUMBER = "VoicemailMailboxNumber"31 PROPERTY_KEY_VOICEMAIL_NUMBER = "VoicemailMailboxNumber"
32
33 def __init__(self):33 def __init__(self):
34 self.voicemailProps = {}34 self.voicemailProps = {}
3535
@@ -39,7 +39,11 @@
39 logger.info("Using modem %s" % modem.objectPath)39 logger.info("Using modem %s" % modem.objectPath)
40 ofono_object = self.bus.get_object('org.ofono', modem.objectPath)40 ofono_object = self.bus.get_object('org.ofono', modem.objectPath)
41 self.ofono_voicemail_proxy = dbus.Interface(ofono_object, interface)41 self.ofono_voicemail_proxy = dbus.Interface(ofono_object, interface)
42 self.bus.add_signal_receiver(self.PropertyChanged, 'PropertyChanged', interface, 'org.ofono', modem.objectPath)42 self.bus.add_signal_receiver(self.PropertyChanged,
43 'PropertyChanged',
44 interface,
45 'org.ofono',
46 modem.objectPath)
43 self.voicemailProps = self.ofono_voicemail_proxy.GetProperties()47 self.voicemailProps = self.ofono_voicemail_proxy.GetProperties()
44 except:48 except:
45 # bus not available yet49 # bus not available yet
4650
=== modified file 'tpofono/presence.py'
--- tpofono/presence.py 2013-02-19 20:09:40 +0000
+++ tpofono/presence.py 2013-03-28 19:50:24 +0000
@@ -20,14 +20,13 @@
20# http://telepathy.freedesktop.org/spec.html#org.freedesktop.Telepathy.Connection.Interface.SimplePresence20# http://telepathy.freedesktop.org/spec.html#org.freedesktop.Telepathy.Connection.Interface.SimplePresence
2121
22import logging22import logging
23import time
2423
25import dbus24import dbus
26import telepathy25import telepathy
27import telepathy.constants26import telepathy.constants
28import telepathy.errors27import telepathy.errors
2928
30__all__ = ['oFonoConnection']29__all__ = ['oFonoPresence']
3130
32logger = logging.getLogger('oFono.Presence')31logger = logging.getLogger('oFono.Presence')
3332
@@ -39,9 +38,9 @@
3938
40 self._implement_property_get(39 self._implement_property_get(
41 telepathy.CONNECTION_INTERFACE_SIMPLE_PRESENCE, {40 telepathy.CONNECTION_INTERFACE_SIMPLE_PRESENCE, {
42 'Statuses' : lambda: {41 'Statuses': lambda: {
43 "available":(telepathy.CONNECTION_PRESENCE_TYPE_AVAILABLE, True, False),42 "available": (telepathy.CONNECTION_PRESENCE_TYPE_AVAILABLE, True, False),
44 "offline":(telepathy.CONNECTION_PRESENCE_TYPE_OFFLINE, True, False)43 "offline": (telepathy.CONNECTION_PRESENCE_TYPE_OFFLINE, True, False)
45 }44 }
46 })45 })
47 self._selfPresence = "offline"46 self._selfPresence = "offline"
@@ -60,7 +59,7 @@
60 return self.get_simple_presences(contacts)59 return self.get_simple_presences(contacts)
6160
62 def SetPresence(self, status, message):61 def SetPresence(self, status, message):
63 logger.info("Setting Presence to '%s'" % presence)62 logger.info("Setting Presence to '%s'" % status)
64 logger.info("Setting Personal message to '%s'" % message)63 logger.info("Setting Personal message to '%s'" % message)
6564
66 message = message.encode("utf-8")65 message = message.encode("utf-8")
@@ -82,7 +81,7 @@
82 presence_type = telepathy.CONNECTION_PRESENCE_TYPE_OFFLINE81 presence_type = telepathy.CONNECTION_PRESENCE_TYPE_OFFLINE
8382
84 presences[handle] = dbus.Struct((presence_type, presence,83 presences[handle] = dbus.Struct((presence_type, presence,
85 personal_message), signature='uss')84 personal_message), signature='uss')
86 return presences85 return presences
8786
88 def _presence_changed(self, handle, presence, personal_message):87 def _presence_changed(self, handle, presence, personal_message):
@@ -93,4 +92,3 @@
93 personal_message = ""92 personal_message = ""
9493
95 self.PresencesChanged({handle: (presence_type, presence, personal_message)})94 self.PresencesChanged({handle: (presence_type, presence, personal_message)})
96
9795
=== modified file 'tpofono/protocol.py'
--- tpofono/protocol.py 2013-02-19 20:09:40 +0000
+++ tpofono/protocol.py 2013-03-28 19:50:24 +0000
@@ -27,6 +27,7 @@
2727
28logger = logging.getLogger('oFono.Protocol')28logger = logging.getLogger('oFono.Protocol')
2929
30
30class oFonoProtocol(telepathy.server.Protocol):31class oFonoProtocol(telepathy.server.Protocol):
3132
32 _proto = "ofono"33 _proto = "ofono"
@@ -48,12 +49,12 @@
48 ]49 ]
4950
50 _supported_interfaces = [51 _supported_interfaces = [
51 telepathy.CONNECTION_INTERFACE_ALIASING,52 telepathy.CONNECTION_INTERFACE_ALIASING,
52 telepathy.CONNECTION_INTERFACE_CAPABILITIES,53 telepathy.CONNECTION_INTERFACE_CAPABILITIES,
53 telepathy.CONNECTION_INTERFACE_CONTACT_CAPABILITIES,54 telepathy.CONNECTION_INTERFACE_CONTACT_CAPABILITIES,
54 telepathy.CONNECTION_INTERFACE_CONTACTS,55 telepathy.CONNECTION_INTERFACE_CONTACTS,
55 telepathy.CONNECTION_INTERFACE_REQUESTS,56 telepathy.CONNECTION_INTERFACE_REQUESTS,
56 ]57 ]
5758
58 def __init__(self, connection_manager):59 def __init__(self, connection_manager):
59 telepathy.server.Protocol.__init__(self, connection_manager, 'ofono')60 telepathy.server.Protocol.__init__(self, connection_manager, 'ofono')

Subscribers

People subscribed via source and target branches