import sqlite3
import time
import dbus
+import osso
from dbus.mainloop.glib import DBusGMainLoop
self.missedSMS = self.getMissedCallsCount(True)
self.missedLastCall = self.missed
self.missedLastSMS = self.missedSMS
- gobject.timeout_add(5000, self.handleMissedCall)
+
+ # Register to handle screen off/on events
+ osso_c = osso.Context("osso_test_device_on", "0.0.1", False)
+ device = osso.DeviceState(osso_c)
+ device.set_display_event_cb(self.state_cb)
+
+ self.tmr_main = gobject.timeout_add(5000, self.handleMissedCall)
# add d-bus listener for removing notification after viewing missed call
# Doing timeout_add with return False instead of explicitly raising a thread
self.imgList.append(gtk.gdk.pixbuf_new_from_file_at_size("/usr/share/CallNotify/5.png",18,18))
self.imgList.append(gtk.gdk.pixbuf_new_from_file_at_size("/usr/share/CallNotify/more.png",18,18))
+ # Screen off event-handler
+ def state_cb(self, state):
+ if state == osso.device_state.OSSO_DISPLAY_OFF:
+ gobject.source_remove(self.tmr_main)
+ gobject.source_remove(self.tmr_ptr)
+ elif state == osso.device_state.OSSO_DISPLAY_ON:
+ self.tmr_main = gobject.timeout_add(5000, self.handleMissedCall)
+ self.show()
+ return False
+
# Method to define the way to add dbus signal receiver
def startDbusListeners(self):
DBusGMainLoop(set_as_default=True)
#bus.add_signal_receiver(self.stop_notification, "NotificationClosed", "org.freedesktop.Notifications", "org.freedesktop.Notifications", "/org/freedesktop/Notifications")
#bus.add_signal_receiver(self.handleMissedCall, "Notify", None, None, None)
#bus.add_signal_receiver(self.handleMissedCall, "MembersChanged", None, None, None)
- bus.add_signal_receiver(self.smsReceived, "Received", "org.freedesktop.Telepathy.Channel.Type.Text", None, None)
+ bus.add_signal_receiver(self.smsReceived, "MessageReceived", None, None, None)
bus.add_signal_receiver(self.smsRead, "NotificationClosed", "org.freedesktop.Notifications", None, "/org/freedesktop/Notifications")
gobject.MainLoop().run()
return False
- def smsReceived(self, a, b, c, d, e, f):
- if self.missedLastSMS == self.getMissedCallsCount(True):
- if self.msgType == "Call":
- self.msgType = "Both"
- else:
- self.msgType = "SMS"
- self.show()
- self.missedLastSMS = self.getMissedCallsCount(True)
+ def smsReceived(self, a):
+ if a[0].has_key('message-type'):
+ if self.missedLastSMS == self.getMissedCallsCount(True):
+ if self.msgType == "Call":
+ self.msgType = "Both"
+ else:
+ self.msgType = "SMS"
+ self.show()
+ self.missedLastSMS = self.getMissedCallsCount(True)
def smsRead(self, a):
self.stop_notification(a)
index = self.getMissedCallsCount(isSMS) - counter - 1
if index >= 5:
index = 5
- if index < 0
+ if index < 0:
index = 0
if self.msgType != "Both":
img = self.imgList[index]