Merge lp:~boiko/telepathy-ofono/fix_python_errors into lp:telepathy-ofono/legacy
- fix_python_errors
- Merge into legacy
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 |
Related bugs: |
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.
PS Jenkins bot (ps-jenkins) wrote : | # |
Sergio Schvezov (sergiusens) wrote : | # |
Do you intent not to fix these?
./tpofono/
./tpofono/
./tpofono/
./tpofono/
./tpofono/
./tpofono/
./tpofono/
./tpofono/
./tpofono/
./tpofono/
./tpofono/
./tpofono/
./tpofono/
./tpofono/
./tpofono/
./tpofono/
./tpofono/
./tpofono/
./tpofono/
./tpofono/
./tpofono/
./tpofono/
./tpofono/
./tpofono/
./tpofono/
./tpofono/
./tpofono/
./tpofono/
./tpofono/
./tpofono/
./tpofono/
./tpofono/
./tpofono/
./tpofono/
./tpofono/
./tpofono/
./tpofono/
./tpofono/
./tpofono/
- 88. By Gustavo Pichorim Boiko
-
Fix more errors reported by pep8 from raring.
Gustavo Pichorim Boiko (boiko) wrote : | # |
> Do you intent not to fix these?
I have fixed all but the long lines ones.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:88
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
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.
Preview Diff
1 | === modified file 'debian/changelog' |
2 | --- debian/changelog 2013-02-20 19:47:34 +0000 |
3 | +++ debian/changelog 2013-03-28 19:50:24 +0000 |
4 | @@ -1,3 +1,9 @@ |
5 | +telepathy-ofono (0.25) quantal; urgency=low |
6 | + |
7 | + * Fix python errors reported by pyflakes and pep8 (LP: #1124783) |
8 | + |
9 | + -- Gustavo Pichorim Boiko <gustavo.boiko@canonical.com> Tue, 26 Mar 2013 18:13:32 -0300 |
10 | + |
11 | telepathy-ofono (0.24) quantal; urgency=low |
12 | |
13 | * Watch for changes in modem interfaces and only use modems that already have |
14 | |
15 | === modified file 'tpofono/__init__.py' |
16 | --- tpofono/__init__.py 2013-02-19 20:09:40 +0000 |
17 | +++ tpofono/__init__.py 2013-03-28 19:50:24 +0000 |
18 | @@ -16,5 +16,7 @@ |
19 | # You should have received a copy of the GNU General Public License |
20 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
21 | |
22 | -from connection_manager import * |
23 | -from debug import * |
24 | +from connection_manager import oFonoConnectionManager |
25 | +from debug import oFonoDebug |
26 | + |
27 | +__all__ = ['oFonoConnectionManager', 'oFonoDebug'] |
28 | |
29 | === modified file 'tpofono/aliasing.py' |
30 | --- tpofono/aliasing.py 2013-02-19 20:09:40 +0000 |
31 | +++ tpofono/aliasing.py 2013-03-28 19:50:24 +0000 |
32 | @@ -26,6 +26,7 @@ |
33 | |
34 | logger = logging.getLogger('oFono.Aliasing') |
35 | |
36 | + |
37 | class oFonoAliasing( |
38 | telepathy.server.ConnectionInterfaceAliasing): |
39 | |
40 | @@ -58,15 +59,6 @@ |
41 | handle.pending_alias = alias |
42 | continue |
43 | |
44 | - new_alias = alias.encode("utf-8") |
45 | - old_alias = contact.infos.get(ContactGeneral.ANNOTATIONS, {}).\ |
46 | - get(ContactAnnotations.NICKNAME, None) |
47 | - if new_alias == old_alias: |
48 | - continue |
49 | - |
50 | - infos = {ContactGeneral.ANNOTATIONS : |
51 | - {ContactAnnotations.NICKNAME : new_alias} |
52 | - } |
53 | #TODO: update contact info |
54 | else: |
55 | logger.info("Self alias changed to '%s'" % alias) |
56 | @@ -77,14 +69,14 @@ |
57 | handle = self.handle(telepathy.HANDLE_TYPE_CONTACT, handle_id) |
58 | logger.info("Getting the alias for the handle name %s" % handle.name) |
59 | return handle.name |
60 | - |
61 | + |
62 | if (handle == self._self_handle): |
63 | return handle.name |
64 | |
65 | #self.fill_contact_info(handle_id) |
66 | if not handle_id in self.contactInfo: |
67 | return handle.name |
68 | - |
69 | + |
70 | alias = None |
71 | contact = self.contactInfo[handle_id] |
72 | if len(contact['alias']) != 0: |
73 | @@ -110,19 +102,3 @@ |
74 | alias = contact.display_name |
75 | alias = unicode(alias, 'utf-8')""" |
76 | return alias |
77 | - |
78 | - def _contact_alias_changed(self, contact): |
79 | - alias = None |
80 | - |
81 | - handle = self.ensure_contact_handle(contact) |
82 | - if handle != self._self_handle: |
83 | - alias = contact.infos.get(ContactGeneral.ANNOTATIONS, {}).\ |
84 | - get(ContactAnnotations.NICKNAME, None) |
85 | - |
86 | - if alias == "" or alias is None: |
87 | - alias = contact.display_name |
88 | - |
89 | - alias = unicode(alias, 'utf-8') |
90 | - logger.info("Contact %s alias changed to '%s'" % (unicode(handle), alias)) |
91 | - self.AliasesChanged([(handle, alias)]) |
92 | - |
93 | |
94 | === modified file 'tpofono/call/__init__.py' |
95 | --- tpofono/call/__init__.py 2013-02-19 20:09:40 +0000 |
96 | +++ tpofono/call/__init__.py 2013-03-28 19:50:24 +0000 |
97 | @@ -16,3 +16,5 @@ |
98 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
99 | |
100 | from content import oFonoCallContent |
101 | + |
102 | +__all__ = ['oFonoCallContent'] |
103 | |
104 | === modified file 'tpofono/call/content.py' |
105 | --- tpofono/call/content.py 2013-02-19 20:09:40 +0000 |
106 | +++ tpofono/call/content.py 2013-03-28 19:50:24 +0000 |
107 | @@ -16,21 +16,21 @@ |
108 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
109 | |
110 | import logging |
111 | -import weakref |
112 | import dbus |
113 | |
114 | import telepathy |
115 | -from telepathy.interfaces import CALL_CONTENT, CALL_CONTENT_INTERFACE_DTMF |
116 | +from telepathy.interfaces import CALL_CONTENT |
117 | from telepathy._generated.Call_Content import CallContent |
118 | from telepathy._generated.Call_Content_Interface_DTMF import CallContentInterfaceDTMF |
119 | |
120 | -__all__ = ['oFonoCallContent.py'] |
121 | +__all__ = ['oFonoCallContent'] |
122 | |
123 | logger = logging.getLogger('oFono.CallContent') |
124 | |
125 | -class oFonoCallContent(CallContent, |
126 | - telepathy.server.DBusProperties, |
127 | - CallContentInterfaceDTMF): |
128 | + |
129 | +class oFonoCallContent(CallContent, |
130 | + telepathy.server.DBusProperties, |
131 | + CallContentInterfaceDTMF): |
132 | |
133 | def __init__(self, channel, name, contentType, conn, object_path=None, bus_name=None): |
134 | CallContent.__init__(self, conn, object_path=object_path, bus_name=bus_name) |
135 | @@ -46,7 +46,7 @@ |
136 | 'Name': CALL_CONTENT, |
137 | 'Type': CALL_CONTENT, |
138 | 'Disposition': CALL_CONTENT, |
139 | - 'Interfaces' : CALL_CONTENT, |
140 | + 'Interfaces': CALL_CONTENT, |
141 | }) |
142 | |
143 | self._implement_property_get(CALL_CONTENT, { |
144 | @@ -54,13 +54,13 @@ |
145 | 'Type': lambda: dbus.UInt32(self._type), |
146 | 'Disposition': lambda: dbus.UInt32(self._disposition), |
147 | 'Streams': lambda: dbus.Array([], signature="o"), |
148 | - 'Interfaces' : lambda: dbus.Array(self._interfaces, signature="s"), |
149 | + 'Interfaces': lambda: dbus.Array(self._interfaces, signature="s"), |
150 | }) |
151 | |
152 | def Remove(self): |
153 | self._channel.removeContent(self) |
154 | self.remove_from_connection() |
155 | - self._channel = None |
156 | + self._channel = None |
157 | |
158 | def StartTone(self, event): |
159 | logger.info("StartTone called") |
160 | @@ -76,10 +76,9 @@ |
161 | else: |
162 | # convert number to ascii value |
163 | ofonoEvent = event + 48 |
164 | - |
165 | + |
166 | self._channel._conn.SendTones(chr(ofonoEvent)) |
167 | |
168 | def StopTone(self): |
169 | logger.info("StopTone called") |
170 | pass |
171 | - |
172 | |
173 | === modified file 'tpofono/capabilities.py' |
174 | --- tpofono/capabilities.py 2013-02-19 20:09:40 +0000 |
175 | +++ tpofono/capabilities.py 2013-03-28 19:50:24 +0000 |
176 | @@ -25,23 +25,24 @@ |
177 | |
178 | logger = logging.getLogger('oFono.Capabilities') |
179 | |
180 | + |
181 | class oFonoCapabilities( |
182 | telepathy.server.ConnectionInterfaceCapabilities, |
183 | telepathy.server.ConnectionInterfaceContactCapabilities): |
184 | |
185 | text_chat_class = \ |
186 | ({telepathy.CHANNEL_INTERFACE + '.ChannelType': |
187 | - telepathy.CHANNEL_TYPE_TEXT, |
188 | + telepathy.CHANNEL_TYPE_TEXT, |
189 | telepathy.CHANNEL_INTERFACE + '.TargetHandleType': |
190 | - dbus.UInt32(telepathy.HANDLE_TYPE_CONTACT)}, |
191 | + dbus.UInt32(telepathy.HANDLE_TYPE_CONTACT)}, |
192 | [telepathy.CHANNEL_INTERFACE + '.TargetHandle', |
193 | telepathy.CHANNEL_INTERFACE + '.TargetID']) |
194 | |
195 | audio_chat_class = \ |
196 | ({telepathy.CHANNEL_INTERFACE + '.ChannelType': |
197 | - telepathy.CHANNEL_TYPE_CALL, |
198 | + telepathy.CHANNEL_TYPE_CALL, |
199 | telepathy.CHANNEL_INTERFACE + '.TargetHandleType': |
200 | - dbus.UInt32(telepathy.HANDLE_TYPE_CONTACT)}, |
201 | + dbus.UInt32(telepathy.HANDLE_TYPE_CONTACT)}, |
202 | [telepathy.CHANNEL_INTERFACE + '.TargetHandle', |
203 | telepathy.CHANNEL_INTERFACE + '.TargetID', |
204 | telepathy.CHANNEL_TYPE_CALL + '.InitialAudio']) |
205 | @@ -52,9 +53,7 @@ |
206 | |
207 | self._update_capabilities_calls = [] |
208 | |
209 | - |
210 | ### Capabilities interface ----------------------------------------------- |
211 | - |
212 | def _get_capabilities(self, contact): |
213 | gen_caps = 0 |
214 | spec_caps = 0 |
215 | @@ -90,9 +89,7 @@ |
216 | if diff is not None: |
217 | self.CapabilitiesChanged([diff]) |
218 | |
219 | - |
220 | ### ContactCapabilities interface ---------------------------------------- |
221 | - |
222 | def AdvertiseCapabilities(self, add, remove): |
223 | return telepathy.server.ConnectionInterfaceCapabilities.\ |
224 | AdvertiseCapabilities(self, add, remove) |
225 | @@ -106,7 +103,7 @@ |
226 | # Signal. |
227 | if changed: |
228 | updated = dbus.Dictionary({self._self_handle: self._contact_caps[self._self_handle]}, |
229 | - signature='ua(a{sv}as)') |
230 | + signature='ua(a{sv}as)') |
231 | self.ContactCapabilitiesChanged(updated) |
232 | |
233 | def _get_contact_capabilities(self, contact): |
234 | @@ -120,14 +117,12 @@ |
235 | caps = {} |
236 | for handle in handles: |
237 | caps[handle] = self._get_contact_capabilities(handle.contact) |
238 | - self._contact_caps[handle.id] = caps[handle] # update global dict |
239 | + self._contact_caps[handle.id] = caps[handle] # update global dict |
240 | |
241 | ret = dbus.Dictionary(caps, signature='ua(a{sv}as)') |
242 | self.ContactCapabilitiesChanged(ret) |
243 | |
244 | - |
245 | ### Initialization ------------------------------------------------------- |
246 | - |
247 | def _populate_capabilities(self): |
248 | """ Add the default capabilities to all contacts in our |
249 | contacts list.""" |
250 | |
251 | === modified file 'tpofono/channel/__init__.py' |
252 | --- tpofono/channel/__init__.py 2013-02-19 20:09:40 +0000 |
253 | +++ tpofono/channel/__init__.py 2013-03-28 19:50:24 +0000 |
254 | @@ -21,23 +21,22 @@ |
255 | |
256 | import telepathy |
257 | |
258 | -from tpofono.handle import oFonoHandleFactory |
259 | - |
260 | __all__ = ['oFonoChannel'] |
261 | |
262 | logger = logging.getLogger('oFono.Channel') |
263 | |
264 | + |
265 | class oFonoChannel(object): |
266 | def __init__(self, conn, props): |
267 | # If we have InitiatorHandle set in our new channel, use that, |
268 | if telepathy.CHANNEL_INTERFACE + '.InitiatorHandle' in props: |
269 | self._initiator = conn.handle(telepathy.HANDLE_TYPE_CONTACT, |
270 | - props[telepathy.CHANNEL_INTERFACE + '.InitiatorHandle']) |
271 | + props[telepathy.CHANNEL_INTERFACE + '.InitiatorHandle']) |
272 | |
273 | # otherwise use InitiatorID. |
274 | elif telepathy.CHANNEL_INTERFACE + '.InitiatorID' in props: |
275 | self._initiator = conn.ensure_handle(telepathy.HANDLE_TYPE_CONTACT, |
276 | - props[telepathy.CHANNEL_INTERFACE + '.InitiatorID']) |
277 | + props[telepathy.CHANNEL_INTERFACE + '.InitiatorID']) |
278 | |
279 | # If we don't have either of the above but we requested the channel, |
280 | # then we're the initiator. |
281 | @@ -51,11 +50,11 @@ |
282 | # Don't implement the initiator properties if we don't have one. |
283 | if self._initiator: |
284 | self._implement_property_get(telepathy.CHANNEL_INTERFACE, { |
285 | - 'InitiatorHandle': lambda: dbus.UInt32(self._initiator.id), |
286 | - 'InitiatorID': lambda: self._initiator.name |
287 | - }) |
288 | + 'InitiatorHandle': lambda: dbus.UInt32(self._initiator.id), |
289 | + 'InitiatorID': lambda: self._initiator.name |
290 | + }) |
291 | |
292 | self._add_immutable_properties({ |
293 | - 'InitiatorHandle': telepathy.CHANNEL_INTERFACE, |
294 | - 'InitiatorID': telepathy.CHANNEL_INTERFACE, |
295 | - }) |
296 | + 'InitiatorHandle': telepathy.CHANNEL_INTERFACE, |
297 | + 'InitiatorID': telepathy.CHANNEL_INTERFACE, |
298 | + }) |
299 | |
300 | === modified file 'tpofono/channel/call.py' |
301 | --- tpofono/channel/call.py 2013-02-19 20:09:40 +0000 |
302 | +++ tpofono/channel/call.py 2013-03-28 19:50:24 +0000 |
303 | @@ -16,7 +16,6 @@ |
304 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
305 | |
306 | import logging |
307 | -import weakref |
308 | import dbus |
309 | |
310 | import telepathy |
311 | @@ -25,7 +24,7 @@ |
312 | from tpofono.ofono.ofonocall import oFonoCall |
313 | from tpofono.call import oFonoCallContent |
314 | |
315 | -from telepathy.interfaces import CHANNEL_INTERFACE, CHANNEL_TYPE_CALL, CALL_INTERFACE_MUTE, CHANNEL_INTERFACE_HOLD |
316 | +from telepathy.interfaces import CHANNEL_TYPE_CALL, CALL_INTERFACE_MUTE, CHANNEL_INTERFACE_HOLD |
317 | from telepathy.constants import LOCAL_MUTE_STATE_UNMUTED, LOCAL_MUTE_STATE_MUTED, LOCAL_HOLD_STATE_REASON_REQUESTED, LOCAL_HOLD_STATE_UNHELD, LOCAL_HOLD_STATE_HELD |
318 | from telepathy._generated.Call_Interface_Mute import CallInterfaceMute |
319 | from telepathy._generated.Channel_Interface_Hold import ChannelInterfaceHold |
320 | @@ -34,7 +33,7 @@ |
321 | |
322 | logger = logging.getLogger('oFono.CallChannel') |
323 | |
324 | -# FIXME: we need to implement also Call1.Interface.Mute |
325 | + |
326 | class oFonoCallChannel( |
327 | oFonoChannel, |
328 | telepathy.server.ChannelTypeCall, |
329 | @@ -47,7 +46,7 @@ |
330 | def __init__(self, conn, manager, call_object, handle, props, object_path=None): |
331 | oFonoCall.__init__(self, call_object) |
332 | telepathy.server.ChannelTypeCall.__init__(self, conn, manager, props, |
333 | - object_path=object_path) |
334 | + object_path=object_path) |
335 | oFonoChannel.__init__(self, conn, props) |
336 | ChannelInterfaceHold.__init__(self) |
337 | |
338 | @@ -57,7 +56,7 @@ |
339 | self._handle = handle |
340 | self._memberFlags = 0 |
341 | self._localMuteState = LOCAL_MUTE_STATE_UNMUTED |
342 | - self._holdState = LOCAL_HOLD_STATE_UNHELD |
343 | + self._holdState = LOCAL_HOLD_STATE_UNHELD |
344 | self._requested = props.get(telepathy.CHANNEL_INTERFACE + ".Requested", True) |
345 | self._initialAudio = props.get(CHANNEL_TYPE_CALL + '.InitialAudio', True) |
346 | self._initialVideo = props.get(CHANNEL_TYPE_CALL + '.InitialVideo', False) |
347 | @@ -66,7 +65,7 @@ |
348 | self._speakerMode = False |
349 | self._incoming = self.isCallIncoming() |
350 | self._localHangupRequested = False |
351 | - |
352 | + |
353 | self._conn.SetMuted(False) |
354 | |
355 | logger.info("Call is incoming: %d" % self._incoming) |
356 | @@ -117,29 +116,29 @@ |
357 | self.setCallState(telepathy.CALL_STATE_INITIALISED, 0, telepathy.CALL_STATE_CHANGE_REASON_PROGRESS_MADE, 0) |
358 | |
359 | def SetRinging(self): |
360 | - logger.info("SetRinging called"); |
361 | + logger.info("SetRinging called") |
362 | if self._incoming and self._state == telepathy.CALL_STATE_INITIALISED: |
363 | - self.setCallState(self._state, self._conn.self_handle.id, |
364 | - telepathy.CALL_STATE_CHANGE_REASON_USER_REQUESTED, telepathy.CALL_FLAG_LOCALLY_RINGING) |
365 | + self.setCallState(self._state, self._conn.self_handle.id, |
366 | + telepathy.CALL_STATE_CHANGE_REASON_USER_REQUESTED, telepathy.CALL_FLAG_LOCALLY_RINGING) |
367 | # FIXME: we need to return the Not Available error for some cases. |
368 | # check this documentation: http://telepathy.freedesktop.org/spec/Channel_Type_Call.html#Method:SetRinging |
369 | |
370 | def SetQueued(self): |
371 | - logger.info("SetQueued called"); |
372 | + logger.info("SetQueued called") |
373 | # TODO: implement |
374 | |
375 | def Accept(self): |
376 | - logger.info("Accept called"); |
377 | + logger.info("Accept called") |
378 | if self._incoming: |
379 | self.setCallState(telepathy.CALL_STATE_ACCEPTED, self._conn.self_handle.id, |
380 | - telepathy.CALL_STATE_CHANGE_REASON_USER_REQUESTED, 0); |
381 | + telepathy.CALL_STATE_CHANGE_REASON_USER_REQUESTED, 0) |
382 | if self.isCallWaiting(): |
383 | self._conn.HoldAndAnswer() |
384 | else: |
385 | self.Answer() |
386 | |
387 | def Hangup(self, Reason, Detailed_Hangup_Reason, Message): |
388 | - logger.info("Hangup called"); |
389 | + logger.info("Hangup called") |
390 | |
391 | # check if this call is active or ringing |
392 | if self._state == telepathy.CALL_STATE_ACTIVE or self._state == telepathy.CALL_STATE_ACCEPTED or self._state == telepathy.CALL_STATE_INITIALISED: |
393 | @@ -148,7 +147,7 @@ |
394 | oFonoCall.Hangup(self) |
395 | |
396 | def AddContent(self, Content_Name, Content_Type, InitialDirection): |
397 | - logger.info("AddContent called"); |
398 | + logger.info("AddContent called") |
399 | path = "%s/content%d" % (self._object_path, self.__call_content_id) |
400 | content = oFonoCallContent(self, Content_Name, Content_Type, self._conn._name, object_path=path) |
401 | self.__call_content_id += 1 |
402 | @@ -157,23 +156,23 @@ |
403 | |
404 | def GetCallStateDetails(self): |
405 | details = dbus.Dictionary({}, signature="sv") |
406 | - logger.info("GetCallStateDetails called"); |
407 | + logger.info("GetCallStateDetails called") |
408 | return details |
409 | |
410 | def GetCallStateReason(self): |
411 | - logger.info("GetCallStateReason called"); |
412 | + logger.info("GetCallStateReason called") |
413 | return (dbus.UInt32(self._stateActor), dbus.UInt32(self._stateReason), dbus.String(""), dbus.String("")) |
414 | |
415 | def GetCallMembers(self): |
416 | members = dbus.Dictionary({}, signature="uu") |
417 | - logger.info("GetCallMembers called"); |
418 | + logger.info("GetCallMembers called") |
419 | members[dbus.UInt32(self._handle.id)] = dbus.UInt32(self._memberFlags) |
420 | return members |
421 | |
422 | def GetMemberIdentifiers(self): |
423 | identifiers = dbus.Dictionary({}, signature="us") |
424 | identifiers[dbus.UInt32(self._handle.id)] = self._handle.name |
425 | - logger.info("GetMemberIdentifiers called"); |
426 | + logger.info("GetMemberIdentifiers called") |
427 | return identifiers |
428 | |
429 | def Close(self): |
430 | @@ -193,7 +192,7 @@ |
431 | pass |
432 | |
433 | def removeContent(self, content): |
434 | - self.ContentRemoved(content, (dbus.UInt32(self._conn.self_handle.id), dbus.UInt32(telepathy.CALL_STATE_CHANGE_REASON_USER_REQUESTED), dbus.String(""), dbus.String(""))) |
435 | + self.ContentRemoved(content, (dbus.UInt32(self._conn.self_handle.id), dbus.UInt32(telepathy.CALL_STATE_CHANGE_REASON_USER_REQUESTED), dbus.String(""), dbus.String(""))) |
436 | del self._content[self._content.index(content)] |
437 | |
438 | def setCallState(self, state, actor, reason, flags): |
439 | @@ -203,19 +202,19 @@ |
440 | self._flags = flags |
441 | |
442 | # signature='uu(uuss)a{sv}') |
443 | - self.CallStateChanged(dbus.UInt32(self._state), dbus.UInt32(self._flags), |
444 | - (dbus.UInt32(self._stateActor), dbus.UInt32(self._stateReason), dbus.String(""), dbus.String("")), |
445 | - dbus.Dictionary({}, signature="sv")) |
446 | + self.CallStateChanged(dbus.UInt32(self._state), dbus.UInt32(self._flags), |
447 | + (dbus.UInt32(self._stateActor), dbus.UInt32(self._stateReason), dbus.String(""), dbus.String("")), |
448 | + dbus.Dictionary({}, signature="sv")) |
449 | |
450 | def setMemberFlags(self, member, flags, actor=0, reason=telepathy.CALL_STATE_CHANGE_REASON_UNKNOWN): |
451 | # FIXME: handle multiple contacts |
452 | self._memberFlags = flags |
453 | |
454 | # signature='a{uu}a{us}au(uuss)') |
455 | - self.CallMembersChanged(dbus.Dictionary({dbus.UInt32(self._handle.id) : dbus.UInt32(self._memberFlags)}, signature="uu"), |
456 | - dbus.Dictionary({dbus.UInt32(self._handle.id) : dbus.String(self._handle.name)}, signature="us"), |
457 | - dbus.Array([], signature="u"), |
458 | - (dbus.UInt32(actor), dbus.UInt32(reason), dbus.String(""), dbus.String(""))) |
459 | + self.CallMembersChanged(dbus.Dictionary({dbus.UInt32(self._handle.id): dbus.UInt32(self._memberFlags)}, signature="uu"), |
460 | + dbus.Dictionary({dbus.UInt32(self._handle.id): dbus.String(self._handle.name)}, signature="us"), |
461 | + dbus.Array([], signature="u"), |
462 | + (dbus.UInt32(actor), dbus.UInt32(reason), dbus.String(""), dbus.String(""))) |
463 | |
464 | ### oFono Call Interface ### |
465 | def oFonoCallStateChanged(self): |
466 | @@ -235,7 +234,7 @@ |
467 | if (self._holdState == LOCAL_HOLD_STATE_UNHELD): |
468 | self.HoldStateChanged(LOCAL_HOLD_STATE_HELD, LOCAL_HOLD_STATE_REASON_REQUESTED) |
469 | self._holdState = LOCAL_HOLD_STATE_HELD |
470 | - self.setCallState(telepathy.CALL_STATE_ACTIVE, self._handle.id, telepathy.CALL_STATE_CHANGE_REASON_USER_REQUESTED, telepathy.CALL_FLAG_LOCALLY_HELD) |
471 | + self.setCallState(telepathy.CALL_STATE_ACTIVE, self._handle.id, telepathy.CALL_STATE_CHANGE_REASON_USER_REQUESTED, telepathy.CALL_FLAG_LOCALLY_HELD) |
472 | elif self.isCallForeground(): |
473 | # the call was accepted/unheld |
474 | logger.info("The call is active") |
475 | @@ -251,14 +250,15 @@ |
476 | # incoming call stopped ringing |
477 | self.setCallState(telepathy.CALL_STATE_ENDED, self._handle.id, telepathy.CALL_STATE_CHANGE_REASON_NO_ANSWER, 0) |
478 | self.Close() |
479 | - else: # handle outgoing call |
480 | + else: |
481 | + # handle outgoing call |
482 | if self.isCallHeld(): |
483 | # put on hold |
484 | logger.info("The call is on hold") |
485 | if (self._holdState == LOCAL_HOLD_STATE_UNHELD): |
486 | self.HoldStateChanged(LOCAL_HOLD_STATE_HELD, LOCAL_HOLD_STATE_REASON_REQUESTED) |
487 | self._holdState = LOCAL_HOLD_STATE_HELD |
488 | - self.setCallState(telepathy.CALL_STATE_ACTIVE, self._handle.id, telepathy.CALL_STATE_CHANGE_REASON_USER_REQUESTED, telepathy.CALL_FLAG_LOCALLY_HELD) |
489 | + self.setCallState(telepathy.CALL_STATE_ACTIVE, self._handle.id, telepathy.CALL_STATE_CHANGE_REASON_USER_REQUESTED, telepathy.CALL_FLAG_LOCALLY_HELD) |
490 | elif self.isCallForeground(): |
491 | if self._state == telepathy.CALL_STATE_ACCEPTED: |
492 | logger.info("The call is waiting for answer") |
493 | @@ -271,7 +271,7 @@ |
494 | self._holdState = LOCAL_HOLD_STATE_UNHELD |
495 | # set this call as accepted before active, so the duration field is correctly set in tp-logger |
496 | if self._state != telepathy.CALL_STATE_ACTIVE: |
497 | - self.setCallState(telepathy.CALL_STATE_ACCEPTED, self._handle.id, telepathy.CALL_STATE_CHANGE_REASON_USER_REQUESTED, 0); |
498 | + self.setCallState(telepathy.CALL_STATE_ACCEPTED, self._handle.id, telepathy.CALL_STATE_CHANGE_REASON_USER_REQUESTED, 0) |
499 | self.setCallState(telepathy.CALL_STATE_ACTIVE, self._handle.id, telepathy.CALL_STATE_CHANGE_REASON_USER_REQUESTED, 0) |
500 | elif self.isCallRinging(): |
501 | logger.info("The call is ringing") |
502 | @@ -286,20 +286,20 @@ |
503 | |
504 | def RequestMuted(self, muted): |
505 | logger.info("RequestMuted called") |
506 | - if (self._localMuteState != LOCAL_MUTE_STATE_MUTED and muted == True): |
507 | + if (self._localMuteState != LOCAL_MUTE_STATE_MUTED and muted): |
508 | self._localMuteState = LOCAL_MUTE_STATE_MUTED |
509 | self.MuteStateChanged(self._localMuteState) |
510 | self._conn.SetMuted(True) |
511 | - elif (self._localMuteState != LOCAL_MUTE_STATE_UNMUTED and muted == False): |
512 | + elif (self._localMuteState != LOCAL_MUTE_STATE_UNMUTED and not muted): |
513 | self._localMuteState = LOCAL_MUTE_STATE_UNMUTED |
514 | self.MuteStateChanged(self._localMuteState) |
515 | self._conn.SetMuted(False) |
516 | |
517 | def RequestHold(self, hold): |
518 | logger.info("RequestHold called") |
519 | - if (self._holdState != LOCAL_HOLD_STATE_HELD and hold == True): |
520 | + if (self._holdState != LOCAL_HOLD_STATE_HELD and hold): |
521 | self._conn.SwapCalls() |
522 | - elif (self._holdState != LOCAL_HOLD_STATE_UNHELD and hold == False): |
523 | + elif (self._holdState != LOCAL_HOLD_STATE_UNHELD and not hold): |
524 | self._conn.SwapCalls() |
525 | |
526 | def GetHoldState(self): |
527 | @@ -331,4 +331,3 @@ |
528 | # TODO: implement speaker mode |
529 | #oFonoCall.turnOnSpeaker(self, active, False) |
530 | pass |
531 | - |
532 | |
533 | === modified file 'tpofono/channel/text.py' |
534 | --- tpofono/channel/text.py 2013-02-19 20:09:40 +0000 |
535 | +++ tpofono/channel/text.py 2013-03-28 19:50:24 +0000 |
536 | @@ -18,11 +18,9 @@ |
537 | # You should have received a copy of the GNU General Public License |
538 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
539 | |
540 | -import gobject |
541 | import logging |
542 | import weakref |
543 | import time |
544 | -import re |
545 | |
546 | import dbus |
547 | import telepathy |
548 | @@ -36,6 +34,7 @@ |
549 | |
550 | logger = logging.getLogger('oFono.TextChannel') |
551 | |
552 | + |
553 | class oFonoTextChannel( |
554 | oFonoChannel, |
555 | telepathy.server.ChannelTypeText, |
556 | @@ -51,22 +50,22 @@ |
557 | self._pending_messages2 = {} |
558 | |
559 | telepathy.server.ChannelTypeText.__init__(self, conn, manager, props, |
560 | - object_path=object_path) |
561 | + object_path=object_path) |
562 | oFonoChannel.__init__(self, conn, props) |
563 | ChannelInterfaceMessages.__init__(self) |
564 | |
565 | self._implement_property_get(CHANNEL_INTERFACE_MESSAGES, { |
566 | - 'SupportedContentTypes': lambda: ["text/plain"] , |
567 | + 'SupportedContentTypes': lambda: ["text/plain"], |
568 | 'MessagePartSupportFlags': lambda: 0, |
569 | 'DeliveryReportingSupport': lambda: telepathy.DELIVERY_REPORTING_SUPPORT_FLAG_RECEIVE_FAILURES, |
570 | 'PendingMessages': lambda: dbus.Array(self._pending_messages2.values(), signature='aa{sv}') |
571 | - }) |
572 | + }) |
573 | |
574 | self._add_immutables({ |
575 | 'SupportedContentTypes': CHANNEL_INTERFACE_MESSAGES, |
576 | 'MessagePartSupportFlags': CHANNEL_INTERFACE_MESSAGES, |
577 | 'DeliveryReportingSupport': CHANNEL_INTERFACE_MESSAGES, |
578 | - }) |
579 | + }) |
580 | |
581 | def _send_text_message(self, message_type, text): |
582 | "Send a simple text message, return true if sent correctly" |
583 | @@ -88,11 +87,8 @@ |
584 | def MessageSentCallback(self, objectPath, status): |
585 | if status == self._conn.PROPERTY_STATUS_SENT: |
586 | return |
587 | - timestamp = int(time.time()) |
588 | if objectPath in self.sentMessages: |
589 | - message = self.sentMessages.pop(objectPath) |
590 | - message_type = message["message_type"] |
591 | - text = message["text"] |
592 | + self.sentMessages.pop(objectPath) |
593 | headers = {} |
594 | body = {} |
595 | delivery = {'message-sender': self._handle_id, |
596 | @@ -103,12 +99,14 @@ |
597 | self.MessageReceived(msg) |
598 | |
599 | def _signal_text_sent(self, timestamp, message_type, text): |
600 | - headers = {'message-sent' : timestamp, |
601 | - 'message-type' : message_type |
602 | - } |
603 | - body = {'content-type': 'text/plain', |
604 | - 'content': text |
605 | - } |
606 | + headers = { |
607 | + 'message-sent': timestamp, |
608 | + 'message-type': message_type |
609 | + } |
610 | + body = { |
611 | + 'content-type': 'text/plain', |
612 | + 'content': text |
613 | + } |
614 | message = [headers, body] |
615 | self.Sent(timestamp, message_type, text) |
616 | self.MessageSent(message, 0, '') |
617 | @@ -116,17 +114,19 @@ |
618 | def _signal_text_received(self, sender, text, id, timestamp, scrollback): |
619 | type = telepathy.CHANNEL_TEXT_MESSAGE_TYPE_NORMAL |
620 | self.Received(id, timestamp, sender.id, type, 0, text) |
621 | - headers = dbus.Dictionary({dbus.String('message-received') : dbus.UInt64(timestamp), |
622 | - dbus.String('pending-message-id') : dbus.UInt32(id), |
623 | - dbus.String('message-token') : dbus.String(id), |
624 | - dbus.String('message-sender') : dbus.UInt32(sender), |
625 | - dbus.String('message-type') : dbus.UInt32(type), |
626 | - dbus.String('scrollback') : dbus.Boolean(scrollback) |
627 | - }, signature='sv') |
628 | + headers = dbus.Dictionary({ |
629 | + dbus.String('message-received'): dbus.UInt64(timestamp), |
630 | + dbus.String('pending-message-id'): dbus.UInt32(id), |
631 | + dbus.String('message-token'): dbus.String(id), |
632 | + dbus.String('message-sender'): dbus.UInt32(sender), |
633 | + dbus.String('message-type'): dbus.UInt32(type), |
634 | + dbus.String('scrollback'): dbus.Boolean(scrollback) |
635 | + }, signature='sv') |
636 | |
637 | - body = dbus.Dictionary({dbus.String('content-type'): dbus.String('text/plain'), |
638 | - dbus.String('content'): dbus.String(text) |
639 | - }, signature='sv') |
640 | + body = dbus.Dictionary({ |
641 | + dbus.String('content-type'): dbus.String('text/plain'), |
642 | + dbus.String('content'): dbus.String(text) |
643 | + }, signature='sv') |
644 | message = dbus.Array([headers, body], signature='a{sv}') |
645 | self.MessageReceived(message) |
646 | |
647 | @@ -154,7 +154,7 @@ |
648 | raise telepathy.NotImplemented("Unhandled message type") |
649 | text = None |
650 | for part in message: |
651 | - if part.get("content-type", None) == "text/plain": |
652 | + if part.get("content-type", None) == "text/plain": |
653 | text = part['content'] |
654 | break |
655 | if text is None: |
656 | @@ -165,7 +165,7 @@ |
657 | self._signal_text_sent(timestamp, message_type, text) |
658 | |
659 | def AcknowledgePendingMessages(self, ids): |
660 | - readIds = [] |
661 | + readIds = [] |
662 | for id in ids: |
663 | if id in self._pending_messages2: |
664 | del self._pending_messages2[id] |
665 | |
666 | === modified file 'tpofono/channel_manager.py' |
667 | --- tpofono/channel_manager.py 2013-02-19 20:09:40 +0000 |
668 | +++ tpofono/channel_manager.py 2013-03-28 19:50:24 +0000 |
669 | @@ -17,16 +17,12 @@ |
670 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
671 | |
672 | import logging |
673 | -import weakref |
674 | from string import ascii_letters, digits |
675 | |
676 | -import dbus |
677 | import telepathy |
678 | -from telepathy.interfaces import CHANNEL_TYPE_CALL |
679 | |
680 | from tpofono.channel.text import oFonoTextChannel |
681 | from tpofono.channel.call import oFonoCallChannel |
682 | -from tpofono.handle import oFonoHandleFactory |
683 | |
684 | __all__ = ['oFonoChannelManager'] |
685 | |
686 | @@ -34,6 +30,7 @@ |
687 | |
688 | _ASCII_ALNUM = ascii_letters + digits |
689 | |
690 | + |
691 | class oFonoChannelManager(telepathy.server.ChannelManager): |
692 | __text_channel_id = 1 |
693 | __call_channel_id = 1 |
694 | @@ -58,7 +55,7 @@ |
695 | # Normal 1-1 chat |
696 | if handle.get_type() == telepathy.HANDLE_TYPE_CONTACT: |
697 | channel = oFonoTextChannel(self._conn, self, conversation, handle, props, |
698 | - object_path=path) |
699 | + object_path=path) |
700 | else: |
701 | raise telepathy.NotImplemented('Only contacts are allowed') |
702 | |
703 | @@ -70,8 +67,6 @@ |
704 | if handle.get_type() != telepathy.HANDLE_TYPE_CONTACT: |
705 | raise telepathy.NotImplemented('Only contacts are allowed') |
706 | |
707 | - contact = handle.contact |
708 | - |
709 | logger.debug('New call channel') |
710 | |
711 | path = "CallChannel/%d" % self.__call_channel_id |
712 | @@ -86,7 +81,7 @@ |
713 | break |
714 | |
715 | # if it is not found, call the number |
716 | - if call == None: |
717 | + if call is None: |
718 | logger.info("No existing call found, calling ofono now") |
719 | call = self._conn.Call(handle.name) |
720 | |
721 | @@ -110,4 +105,3 @@ |
722 | if channel._call == objectPath: |
723 | return channel |
724 | return None |
725 | - |
726 | |
727 | === modified file 'tpofono/connection.py' |
728 | --- tpofono/connection.py 2013-02-20 18:45:38 +0000 |
729 | +++ tpofono/connection.py 2013-03-28 19:50:24 +0000 |
730 | @@ -17,19 +17,13 @@ |
731 | # You should have received a copy of the GNU General Public License |
732 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
733 | |
734 | -import weakref |
735 | import logging |
736 | |
737 | import dbus |
738 | import telepathy |
739 | -import hashlib |
740 | -import datetime |
741 | from datetime import datetime |
742 | -from datetime import timedelta |
743 | import time |
744 | |
745 | -from telepathy.interfaces import CONNECTION, CHANNEL_TYPE_CALL |
746 | - |
747 | from tpofono.aliasing import oFonoAliasing |
748 | from tpofono.capabilities import oFonoCapabilities |
749 | from tpofono.handle import oFonoHandleFactory |
750 | @@ -51,17 +45,16 @@ |
751 | |
752 | |
753 | class oFonoConnection(telepathy.server.Connection, |
754 | - telepathy.server.ConnectionInterfaceRequests, |
755 | - oFonoAliasing, |
756 | -# oFonoAvatars, |
757 | - oFonoCapabilities, |
758 | - oFonoContacts, |
759 | - oFonoCalls, |
760 | - oFonoCallVolume, |
761 | - oFonoMessages, |
762 | - oFonoPresence, |
763 | - oFonoVoicemail, |
764 | - oFonoManager): |
765 | + telepathy.server.ConnectionInterfaceRequests, |
766 | + oFonoAliasing, |
767 | + oFonoCapabilities, |
768 | + oFonoContacts, |
769 | + oFonoCalls, |
770 | + oFonoCallVolume, |
771 | + oFonoMessages, |
772 | + oFonoPresence, |
773 | + oFonoVoicemail, |
774 | + oFonoManager): |
775 | |
776 | phone = None |
777 | createdChannels = [] |
778 | @@ -75,13 +68,13 @@ |
779 | |
780 | try: |
781 | self.myModem = None |
782 | - self._account = "ofono" #unicode(parameters['account']) |
783 | + self._account = "ofono" # unicode(parameters['account']) |
784 | self._channel_manager = oFonoChannelManager(self, protocol) |
785 | self._manager = manager |
786 | |
787 | # Call parent initializers |
788 | telepathy.server.Connection.__init__(self, 'ofono', self._account, |
789 | - 'ofono', protocol) |
790 | + 'ofono', protocol) |
791 | telepathy.server.ConnectionInterfaceRequests.__init__(self) |
792 | oFonoAliasing.__init__(self) |
793 | #oFonoAvatars.__init__(self) |
794 | @@ -94,12 +87,12 @@ |
795 | oFonoVoicemail.__init__(self) |
796 | |
797 | # FIXME: re-add the org.ofono.MessageWaiting interface once it is available again |
798 | - oFonoManager.__init__(self, [ "org.ofono.MessageManager", "org.ofono.VoiceCallManager", "org.ofono.CallVolume" ]) |
799 | + oFonoManager.__init__(self, ["org.ofono.MessageManager", "org.ofono.VoiceCallManager", "org.ofono.CallVolume"]) |
800 | # NOTE: comment the line above and uncomment the one below to test telepathy-ofono using ofono-phonesim |
801 | #oFonoManager.__init__(self, [ "org.ofono.MessageManager", "org.ofono.VoiceCallManager" ]) |
802 | |
803 | self_handle = self.create_handle(telepathy.HANDLE_TYPE_CONTACT, |
804 | - self._account) |
805 | + self._account) |
806 | self.set_self_handle(self_handle) |
807 | |
808 | self._implement_property_get(telepathy.CONNECTION, { |
809 | @@ -108,8 +101,7 @@ |
810 | |
811 | logger.info("Connection to the account %s created" % self._account) |
812 | |
813 | - except Exception, e: |
814 | - import traceback |
815 | + except: |
816 | logger.exception("Failed to create Connection") |
817 | raise |
818 | |
819 | @@ -136,7 +128,7 @@ |
820 | """Create new handle with given type and name.""" |
821 | handle_id = self.get_handle_id() |
822 | handle = oFonoHandleFactory(self, handle_type, handle_id, |
823 | - handle_name, **kwargs) |
824 | + handle_name, **kwargs) |
825 | if handle is None: |
826 | raise telepathy.NotAvailable('Handle type unsupported %d' % handle_type) |
827 | logger.info("New Handle %s" % unicode(handle)) |
828 | @@ -157,7 +149,7 @@ |
829 | """Normalize handle name so the name is consistent everywhere.""" |
830 | if not self.is_valid_handle_name(handle_type, handle_name): |
831 | raise telepathy.InvalidHandle('TargetID %s not valid for type %d' % |
832 | - (name, handle_type)) |
833 | + (handle_name, handle_type)) |
834 | if handle_type == telepathy.HANDLE_TYPE_CONTACT: |
835 | return handle_name.lower().strip() |
836 | return handle_name |
837 | @@ -195,7 +187,7 @@ |
838 | alias = parsedVcard.fn.value |
839 | else: |
840 | alias = handle.name |
841 | - |
842 | + |
843 | self.contactInfo[handle_id] = {} |
844 | self.contactInfo[handle_id]['alias'] = alias |
845 | |
846 | @@ -211,7 +203,7 @@ |
847 | logger.info("Connecting") |
848 | self.StatusChanged(telepathy.CONNECTION_STATUS_CONNECTING, telepathy.CONNECTION_STATUS_REASON_REQUESTED) |
849 | self.StatusChanged(telepathy.CONNECTION_STATUS_CONNECTED, telepathy.CONNECTION_STATUS_REASON_REQUESTED) |
850 | - if self.myModem != None: |
851 | + if self.myModem is not None: |
852 | self.SetOnline(True) |
853 | else: |
854 | self.SetOnline(False) |
855 | @@ -236,20 +228,18 @@ |
856 | telepathy.CHANNEL_INTERFACE + '.TargetHandle': handle.get_id(), |
857 | telepathy.CHANNEL_INTERFACE + '.TargetHandleType': handle.get_type(), |
858 | telepathy.CHANNEL_INTERFACE + '.Requested': suppress_handler |
859 | - } |
860 | + } |
861 | |
862 | if initiator_handle is not None: |
863 | if initiator_handle.get_type() is not telepathy.HANDLE_TYPE_NONE: |
864 | - props[telepathy.CHANNEL_INTERFACE + '.InitiatorHandle'] = \ |
865 | - initiator_handle.get_id() |
866 | + props[telepathy.CHANNEL_INTERFACE + '.InitiatorHandle'] = initiator_handle.get_id() |
867 | |
868 | return props |
869 | |
870 | - |
871 | @dbus.service.method(telepathy.CONNECTION, in_signature='suub', |
872 | - out_signature='o', async_callbacks=('_success', '_error')) |
873 | + out_signature='o', async_callbacks=('_success', '_error')) |
874 | def RequestChannel(self, type, handle_type, handle_id, suppress_handler, |
875 | - _success, _error): |
876 | + _success, _error): |
877 | self.check_connected() |
878 | channel_manager = self._channel_manager |
879 | |
880 | @@ -281,10 +271,10 @@ |
881 | call = oFonoCall(objectPath, properties) |
882 | if call.isCallIncoming() or call.isCallWaiting(): |
883 | props = self._generate_props(telepathy.CHANNEL_TYPE_CALL, |
884 | - handle, False, initiator_handle=handle) |
885 | + handle, False, initiator_handle=handle) |
886 | else: |
887 | props = self._generate_props(telepathy.CHANNEL_TYPE_CALL, |
888 | - handle, False, initiator_handle=self.self_handle) |
889 | + handle, False, initiator_handle=self.self_handle) |
890 | |
891 | # check if this channel was already created |
892 | if self._channel_manager.existing_channel(props): |
893 | @@ -297,7 +287,7 @@ |
894 | def ModemAdded(self, modem): |
895 | logger.info("Got modem %s", modem.objectPath) |
896 | # check if we already have a modem |
897 | - if self.myModem != None: |
898 | + if self.myModem is not None: |
899 | return |
900 | |
901 | self.myModem = modem |
902 | @@ -340,14 +330,14 @@ |
903 | text = message |
904 | timestamp = datetime.strptime(props["SentTime"][:-5], "%Y-%m-%dT%H:%M:%S") |
905 | timestamp = time.mktime(timestamp.timetuple()) |
906 | - |
907 | + |
908 | # FIXME: do not use timestamp as ID |
909 | - id = int (timestamp) |
910 | + id = int(timestamp) |
911 | handle = self.ensure_contact_handle(number) |
912 | props = self._generate_props(telepathy.CHANNEL_TYPE_TEXT, |
913 | - handle, False) |
914 | + handle, False) |
915 | channel = self._channel_manager.channel_for_props(props, |
916 | - signal=True) |
917 | + signal=True) |
918 | channel._signal_text_received(handle, text, id, timestamp, scrollback) |
919 | |
920 | @dbus.service.signal(dbus_interface=CANONICAL_IFACE_TELEPHONY, |
921 | @@ -374,4 +364,3 @@ |
922 | in_signature='', out_signature='i') |
923 | def VoicemailCount(self): |
924 | return oFonoVoicemail.VoicemailCount(self) |
925 | - |
926 | |
927 | === modified file 'tpofono/connection_manager.py' |
928 | --- tpofono/connection_manager.py 2013-02-19 20:09:40 +0000 |
929 | +++ tpofono/connection_manager.py 2013-03-28 19:50:24 +0000 |
930 | @@ -18,7 +18,6 @@ |
931 | |
932 | import telepathy |
933 | import gobject |
934 | -import dbus |
935 | import logging |
936 | |
937 | from tpofono.protocol import oFonoProtocol |
938 | @@ -30,7 +29,7 @@ |
939 | |
940 | class oFonoConnectionManager(telepathy.server.ConnectionManager): |
941 | """oFono connection manager |
942 | - |
943 | + |
944 | Implements the org.freedesktop.Telepathy.ConnectionManager interface""" |
945 | |
946 | def __init__(self, shutdown_func=None): |
947 | @@ -48,7 +47,7 @@ |
948 | len(self._connections) == 0: |
949 | self._shutdown() |
950 | return False |
951 | - result = telepathy.server.ConnectionManager.disconnected(self, conn) |
952 | + telepathy.server.ConnectionManager.disconnected(self, conn) |
953 | gobject.timeout_add_seconds(5, shutdown) |
954 | |
955 | def quit(self): |
956 | |
957 | === modified file 'tpofono/contacts.py' |
958 | --- tpofono/contacts.py 2013-02-19 20:09:40 +0000 |
959 | +++ tpofono/contacts.py 2013-03-28 19:50:24 +0000 |
960 | @@ -17,7 +17,6 @@ |
961 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
962 | |
963 | import logging |
964 | -import time |
965 | |
966 | import telepathy |
967 | import telepathy.errors |
968 | @@ -27,29 +26,29 @@ |
969 | |
970 | logger = logging.getLogger('oFono.Contacts') |
971 | |
972 | + |
973 | class oFonoContacts( |
974 | telepathy.server.ConnectionInterfaceContacts): |
975 | |
976 | attributes = { |
977 | - telepathy.CONNECTION : 'contact-id', |
978 | - telepathy.CONNECTION_INTERFACE_ALIASING : 'alias', |
979 | -# telepathy.CONNECTION_INTERFACE_AVATARS : 'token', |
980 | - telepathy.CONNECTION_INTERFACE_CAPABILITIES : 'caps', |
981 | - telepathy.CONNECTION_INTERFACE_CONTACT_CAPABILITIES : 'capabilities', |
982 | - telepathy.CONNECTION_INTERFACE_SIMPLE_PRESENCE : 'presence' |
983 | - } |
984 | + telepathy.CONNECTION: 'contact-id', |
985 | + telepathy.CONNECTION_INTERFACE_ALIASING: 'alias', |
986 | + telepathy.CONNECTION_INTERFACE_CAPABILITIES: 'caps', |
987 | + telepathy.CONNECTION_INTERFACE_CONTACT_CAPABILITIES: 'capabilities', |
988 | + telepathy.CONNECTION_INTERFACE_SIMPLE_PRESENCE: 'presence' |
989 | + } |
990 | |
991 | def __init__(self): |
992 | telepathy.server.ConnectionInterfaceContacts.__init__(self) |
993 | |
994 | dbus_interface = telepathy.CONNECTION_INTERFACE_CONTACTS |
995 | |
996 | - self._implement_property_get(dbus_interface, \ |
997 | - {'ContactAttributeInterfaces' : self.get_contact_attribute_interfaces}) |
998 | + self._implement_property_get(dbus_interface, |
999 | + {'ContactAttributeInterfaces': self.get_contact_attribute_interfaces}) |
1000 | |
1001 | # Overwrite the dbus attribute to get the sender argument |
1002 | @dbus.service.method(telepathy.CONNECTION_INTERFACE_CONTACTS, in_signature='auasb', |
1003 | - out_signature='a{ua{sv}}', sender_keyword='sender') |
1004 | + out_signature='a{ua{sv}}', sender_keyword='sender') |
1005 | def GetContactAttributes(self, handles, interfaces, hold, sender): |
1006 | #InspectHandle already checks we're connected, the handles and handle type. |
1007 | supported_interfaces = set() |
1008 | @@ -66,19 +65,19 @@ |
1009 | ret[handle] = dbus.Dictionary(signature='sv') |
1010 | |
1011 | functions = { |
1012 | - telepathy.CONNECTION : |
1013 | - lambda x: zip(x, self.InspectHandles(handle_type, x)), |
1014 | - telepathy.CONNECTION_INTERFACE_ALIASING : |
1015 | - lambda x: self.GetAliases(x).items(), |
1016 | -# telepathy.CONNECTION_INTERFACE_AVATARS : |
1017 | -# lambda x: self.GetKnownAvatarTokens(x).items(), |
1018 | - telepathy.CONNECTION_INTERFACE_CAPABILITIES : |
1019 | - lambda x: self.GetCapabilities(x).items(), |
1020 | - telepathy.CONNECTION_INTERFACE_CONTACT_CAPABILITIES : |
1021 | - lambda x: self.GetContactCapabilities(x).items(), |
1022 | - telepathy.CONNECTION_INTERFACE_SIMPLE_PRESENCE : |
1023 | - lambda x: self.GetPresences(x).items() |
1024 | - } |
1025 | + telepathy.CONNECTION: |
1026 | + lambda x: zip(x, self.InspectHandles(handle_type, x)), |
1027 | + telepathy.CONNECTION_INTERFACE_ALIASING: |
1028 | + lambda x: self.GetAliases(x).items(), |
1029 | +# telepathy.CONNECTION_INTERFACE_AVATARS: |
1030 | +# lambda x: self.GetKnownAvatarTokens(x).items(), |
1031 | + telepathy.CONNECTION_INTERFACE_CAPABILITIES: |
1032 | + lambda x: self.GetCapabilities(x).items(), |
1033 | + telepathy.CONNECTION_INTERFACE_CONTACT_CAPABILITIES: |
1034 | + lambda x: self.GetContactCapabilities(x).items(), |
1035 | + telepathy.CONNECTION_INTERFACE_SIMPLE_PRESENCE: |
1036 | + lambda x: self.GetPresences(x).items() |
1037 | + } |
1038 | |
1039 | #Hold handles if needed |
1040 | if hold: |
1041 | |
1042 | === modified file 'tpofono/debug.py' |
1043 | --- tpofono/debug.py 2013-02-19 20:09:40 +0000 |
1044 | +++ tpofono/debug.py 2013-03-28 19:50:24 +0000 |
1045 | @@ -18,6 +18,7 @@ |
1046 | |
1047 | import telepathy |
1048 | |
1049 | + |
1050 | class oFonoDebug(telepathy.server.Debug): |
1051 | """oFono debug interface |
1052 | |
1053 | |
1054 | === modified file 'tpofono/handle.py' |
1055 | --- tpofono/handle.py 2013-02-19 20:09:40 +0000 |
1056 | +++ tpofono/handle.py 2013-03-28 19:50:24 +0000 |
1057 | @@ -25,6 +25,7 @@ |
1058 | |
1059 | logger = logging.getLogger('oFono.Handle') |
1060 | |
1061 | + |
1062 | def oFonoHandleFactory(connection, type, id, name, **kwargs): |
1063 | mapping = {telepathy.HANDLE_TYPE_CONTACT: oFonoContactHandle} |
1064 | handle = mapping[type](connection, id, name, **kwargs) |
1065 | @@ -38,7 +39,7 @@ |
1066 | self._conn = weakref.proxy(connection) |
1067 | |
1068 | def __unicode__(self): |
1069 | - type_mapping = {telepathy.HANDLE_TYPE_CONTACT : 'Contact'} |
1070 | + type_mapping = {telepathy.HANDLE_TYPE_CONTACT: 'Contact'} |
1071 | type_str = type_mapping.get(self.type, '') |
1072 | return "<oFono%sHandle id=%u name='%s'>" % \ |
1073 | (type_str, self.id, self.name) |
1074 | @@ -56,4 +57,3 @@ |
1075 | @property |
1076 | def contact(self): |
1077 | return self._contact |
1078 | - |
1079 | |
1080 | === modified file 'tpofono/ofono/__init__.py' |
1081 | --- tpofono/ofono/__init__.py 2013-02-19 20:09:40 +0000 |
1082 | +++ tpofono/ofono/__init__.py 2013-03-28 19:50:24 +0000 |
1083 | @@ -25,3 +25,11 @@ |
1084 | from ofonovoicemail import oFonoVoicemail |
1085 | from ofonomodem import oFonoModem |
1086 | from ofonomanager import oFonoManager |
1087 | + |
1088 | +__all__ = ['oFonoCall', |
1089 | + 'oFonoCalls', |
1090 | + 'oFonoCallVolume', |
1091 | + 'oFonoMessages', |
1092 | + 'oFonoVoicemail', |
1093 | + 'oFonoModem', |
1094 | + 'oFonoManager'] |
1095 | |
1096 | === modified file 'tpofono/ofono/ofonocall.py' |
1097 | --- tpofono/ofono/ofonocall.py 2013-02-19 20:09:40 +0000 |
1098 | +++ tpofono/ofono/ofonocall.py 2013-03-28 19:50:24 +0000 |
1099 | @@ -17,12 +17,12 @@ |
1100 | |
1101 | import logging |
1102 | import dbus |
1103 | -import gobject |
1104 | |
1105 | -__all__ = ['oFonoCall.py'] |
1106 | +__all__ = ['oFonoCall'] |
1107 | |
1108 | logger = logging.getLogger('oFono.Call') |
1109 | |
1110 | + |
1111 | class oFonoCall: |
1112 | PROPERTY_KEY_STATE = "State" |
1113 | PROPERTY_KEY_LINE_IDENTIFICATION = "LineIdentification" |
1114 | @@ -61,7 +61,7 @@ |
1115 | if prop == self.PROPERTY_KEY_STATE: |
1116 | self.StatePropertyChanged(value) |
1117 | |
1118 | - def StatePropertyChanged(self, state, notify = True): |
1119 | + def StatePropertyChanged(self, state, notify=True): |
1120 | self.isRinging = state == self.PROPERTY_STATE_INCOMING |
1121 | self.isHeld = state == self.PROPERTY_STATE_HELD |
1122 | self.isAlerting = state == self.PROPERTY_STATE_ALERTING |
1123 | @@ -109,4 +109,3 @@ |
1124 | |
1125 | def isCallWaiting(self): |
1126 | return self.isWaiting |
1127 | - |
1128 | |
1129 | === modified file 'tpofono/ofono/ofonocalls.py' |
1130 | --- tpofono/ofono/ofonocalls.py 2013-02-19 20:09:40 +0000 |
1131 | +++ tpofono/ofono/ofonocalls.py 2013-03-28 19:50:24 +0000 |
1132 | @@ -21,11 +21,10 @@ |
1133 | |
1134 | import logging |
1135 | import dbus |
1136 | -import gobject |
1137 | -from ofonomanager import oFonoManager |
1138 | |
1139 | logger = logging.getLogger('oFonoCalls') |
1140 | |
1141 | + |
1142 | class oFonoCalls: |
1143 | def __init__(self): |
1144 | self.props = {} |
1145 | @@ -76,7 +75,7 @@ |
1146 | def oFonoCallRemoved(self, objectPath): |
1147 | # TODO: check if this code actually works |
1148 | if objectPath in self.calls: |
1149 | - props = self.calls.pop(objectPath) |
1150 | + self.calls.pop(objectPath) |
1151 | self.CallRemoved(objectPath) |
1152 | |
1153 | def CallAdded(self, objectPath, properties): |
1154 | |
1155 | === modified file 'tpofono/ofono/ofonocallvolume.py' |
1156 | --- tpofono/ofono/ofonocallvolume.py 2013-02-19 20:09:40 +0000 |
1157 | +++ tpofono/ofono/ofonocallvolume.py 2013-03-28 19:50:24 +0000 |
1158 | @@ -21,15 +21,15 @@ |
1159 | |
1160 | import logging |
1161 | import dbus |
1162 | -import gobject |
1163 | -from ofonomanager import oFonoManager |
1164 | |
1165 | logger = logging.getLogger('oFonoCallVolume') |
1166 | |
1167 | + |
1168 | class oFonoCallVolume: |
1169 | PROPERTY_KEY_SPEAKER_VOLUME = "SpeakerVolume" |
1170 | PROPERTY_KEY_MICROPHONE_VOUME = "MicrophoneVolume" |
1171 | PROPERTY_KEY_MUTED = "Muted" |
1172 | + |
1173 | def __init__(self): |
1174 | self.props = {} |
1175 | |
1176 | |
1177 | === modified file 'tpofono/ofono/ofonomanager.py' |
1178 | --- tpofono/ofono/ofonomanager.py 2013-02-20 18:15:06 +0000 |
1179 | +++ tpofono/ofono/ofonomanager.py 2013-03-28 19:50:24 +0000 |
1180 | @@ -25,8 +25,10 @@ |
1181 | |
1182 | logger = logging.getLogger('oFonoManager') |
1183 | |
1184 | + |
1185 | class oFonoManager(): |
1186 | ofono_manager_proxy = None |
1187 | + |
1188 | def __init__(self, modem_interfaces): |
1189 | self.modem_interfaces = modem_interfaces |
1190 | self.modems = [] |
1191 | @@ -46,7 +48,7 @@ |
1192 | |
1193 | # parse modems |
1194 | modems = self.GetModems() |
1195 | - for modem in self.GetModems(): |
1196 | + for modem in modems: |
1197 | self.oFonoModemAdded(modem[0], modem[1]) |
1198 | |
1199 | except: |
1200 | @@ -97,4 +99,3 @@ |
1201 | |
1202 | def ModemRemoved(self, modem): |
1203 | pass |
1204 | - |
1205 | |
1206 | === modified file 'tpofono/ofono/ofonomessages.py' |
1207 | --- tpofono/ofono/ofonomessages.py 2013-02-19 20:09:40 +0000 |
1208 | +++ tpofono/ofono/ofonomessages.py 2013-03-28 19:50:24 +0000 |
1209 | @@ -20,11 +20,10 @@ |
1210 | |
1211 | import logging |
1212 | import dbus |
1213 | -import gobject |
1214 | -from ofonomanager import oFonoManager |
1215 | |
1216 | logger = logging.getLogger('oFonoMessages') |
1217 | |
1218 | + |
1219 | class oFonoMessages: |
1220 | |
1221 | PROPERTY_KEY_STATUS = "State" |
1222 | @@ -77,4 +76,3 @@ |
1223 | objectPath = self.ofono_message_proxy.SendMessage(to, message) |
1224 | self.pendingMessages[objectPath] = textChannel |
1225 | return objectPath |
1226 | - |
1227 | |
1228 | === modified file 'tpofono/ofono/ofonomodem.py' |
1229 | --- tpofono/ofono/ofonomodem.py 2013-02-20 18:15:06 +0000 |
1230 | +++ tpofono/ofono/ofonomodem.py 2013-03-28 19:50:24 +0000 |
1231 | @@ -18,10 +18,11 @@ |
1232 | import logging |
1233 | import dbus |
1234 | |
1235 | -__all__ = ['oFonoModem.py'] |
1236 | +__all__ = ['oFonoModem'] |
1237 | |
1238 | logger = logging.getLogger('oFono.Modem') |
1239 | |
1240 | + |
1241 | class oFonoModem: |
1242 | def __init__(self, manager, objectPath, properties): |
1243 | self._manager = manager |
1244 | |
1245 | === modified file 'tpofono/ofono/ofonovoicemail.py' |
1246 | --- tpofono/ofono/ofonovoicemail.py 2013-02-19 20:09:40 +0000 |
1247 | +++ tpofono/ofono/ofonovoicemail.py 2013-03-28 19:50:24 +0000 |
1248 | @@ -21,15 +21,15 @@ |
1249 | |
1250 | import logging |
1251 | import dbus |
1252 | -import gobject |
1253 | -from ofonomanager import oFonoManager |
1254 | |
1255 | logger = logging.getLogger('oFonoVoicemail') |
1256 | |
1257 | + |
1258 | class oFonoVoicemail: |
1259 | PROPERTY_KEY_VOICEMAIL_WAITING = "VoicemailWaiting" |
1260 | PROPERTY_KEY_VOICEMAIL_MESSAGE_COUNT = "VoicemailMessageCount" |
1261 | PROPERTY_KEY_VOICEMAIL_NUMBER = "VoicemailMailboxNumber" |
1262 | + |
1263 | def __init__(self): |
1264 | self.voicemailProps = {} |
1265 | |
1266 | @@ -39,7 +39,11 @@ |
1267 | logger.info("Using modem %s" % modem.objectPath) |
1268 | ofono_object = self.bus.get_object('org.ofono', modem.objectPath) |
1269 | self.ofono_voicemail_proxy = dbus.Interface(ofono_object, interface) |
1270 | - self.bus.add_signal_receiver(self.PropertyChanged, 'PropertyChanged', interface, 'org.ofono', modem.objectPath) |
1271 | + self.bus.add_signal_receiver(self.PropertyChanged, |
1272 | + 'PropertyChanged', |
1273 | + interface, |
1274 | + 'org.ofono', |
1275 | + modem.objectPath) |
1276 | self.voicemailProps = self.ofono_voicemail_proxy.GetProperties() |
1277 | except: |
1278 | # bus not available yet |
1279 | |
1280 | === modified file 'tpofono/presence.py' |
1281 | --- tpofono/presence.py 2013-02-19 20:09:40 +0000 |
1282 | +++ tpofono/presence.py 2013-03-28 19:50:24 +0000 |
1283 | @@ -20,14 +20,13 @@ |
1284 | # http://telepathy.freedesktop.org/spec.html#org.freedesktop.Telepathy.Connection.Interface.SimplePresence |
1285 | |
1286 | import logging |
1287 | -import time |
1288 | |
1289 | import dbus |
1290 | import telepathy |
1291 | import telepathy.constants |
1292 | import telepathy.errors |
1293 | |
1294 | -__all__ = ['oFonoConnection'] |
1295 | +__all__ = ['oFonoPresence'] |
1296 | |
1297 | logger = logging.getLogger('oFono.Presence') |
1298 | |
1299 | @@ -39,9 +38,9 @@ |
1300 | |
1301 | self._implement_property_get( |
1302 | telepathy.CONNECTION_INTERFACE_SIMPLE_PRESENCE, { |
1303 | - 'Statuses' : lambda: { |
1304 | - "available":(telepathy.CONNECTION_PRESENCE_TYPE_AVAILABLE, True, False), |
1305 | - "offline":(telepathy.CONNECTION_PRESENCE_TYPE_OFFLINE, True, False) |
1306 | + 'Statuses': lambda: { |
1307 | + "available": (telepathy.CONNECTION_PRESENCE_TYPE_AVAILABLE, True, False), |
1308 | + "offline": (telepathy.CONNECTION_PRESENCE_TYPE_OFFLINE, True, False) |
1309 | } |
1310 | }) |
1311 | self._selfPresence = "offline" |
1312 | @@ -60,7 +59,7 @@ |
1313 | return self.get_simple_presences(contacts) |
1314 | |
1315 | def SetPresence(self, status, message): |
1316 | - logger.info("Setting Presence to '%s'" % presence) |
1317 | + logger.info("Setting Presence to '%s'" % status) |
1318 | logger.info("Setting Personal message to '%s'" % message) |
1319 | |
1320 | message = message.encode("utf-8") |
1321 | @@ -82,7 +81,7 @@ |
1322 | presence_type = telepathy.CONNECTION_PRESENCE_TYPE_OFFLINE |
1323 | |
1324 | presences[handle] = dbus.Struct((presence_type, presence, |
1325 | - personal_message), signature='uss') |
1326 | + personal_message), signature='uss') |
1327 | return presences |
1328 | |
1329 | def _presence_changed(self, handle, presence, personal_message): |
1330 | @@ -93,4 +92,3 @@ |
1331 | personal_message = "" |
1332 | |
1333 | self.PresencesChanged({handle: (presence_type, presence, personal_message)}) |
1334 | - |
1335 | |
1336 | === modified file 'tpofono/protocol.py' |
1337 | --- tpofono/protocol.py 2013-02-19 20:09:40 +0000 |
1338 | +++ tpofono/protocol.py 2013-03-28 19:50:24 +0000 |
1339 | @@ -27,6 +27,7 @@ |
1340 | |
1341 | logger = logging.getLogger('oFono.Protocol') |
1342 | |
1343 | + |
1344 | class oFonoProtocol(telepathy.server.Protocol): |
1345 | |
1346 | _proto = "ofono" |
1347 | @@ -48,12 +49,12 @@ |
1348 | ] |
1349 | |
1350 | _supported_interfaces = [ |
1351 | - telepathy.CONNECTION_INTERFACE_ALIASING, |
1352 | - telepathy.CONNECTION_INTERFACE_CAPABILITIES, |
1353 | - telepathy.CONNECTION_INTERFACE_CONTACT_CAPABILITIES, |
1354 | - telepathy.CONNECTION_INTERFACE_CONTACTS, |
1355 | - telepathy.CONNECTION_INTERFACE_REQUESTS, |
1356 | - ] |
1357 | + telepathy.CONNECTION_INTERFACE_ALIASING, |
1358 | + telepathy.CONNECTION_INTERFACE_CAPABILITIES, |
1359 | + telepathy.CONNECTION_INTERFACE_CONTACT_CAPABILITIES, |
1360 | + telepathy.CONNECTION_INTERFACE_CONTACTS, |
1361 | + telepathy.CONNECTION_INTERFACE_REQUESTS, |
1362 | + ] |
1363 | |
1364 | def __init__(self, connection_manager): |
1365 | telepathy.server.Protocol.__init__(self, connection_manager, 'ofono') |
PASSED: Continuous integration, rev:87 jenkins. qa.ubuntu. com/job/ telepathy- ofono-ci/ 1/ jenkins. qa.ubuntu. com/job/ telepathy- ofono-quantal- armhf-ci/ 1 jenkins. qa.ubuntu. com/job/ telepathy- ofono-quantal- i386-ci/ 1 jenkins. qa.ubuntu. com/job/ telepathy- ofono-raring- armhf-ci/ 1 jenkins. qa.ubuntu. com/job/ telepathy- ofono-raring- i386-ci/ 1
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins: 8080/job/ telepathy- ofono-ci/ 1/rebuild
http://