From: Pali Rohár Date: Fri, 22 Jun 2012 12:11:04 +0000 (+0200) Subject: Imported Upstream version 0.0.4 X-Git-Url: https://vcs.maemo.org/git/?a=commitdiff_plain;h=a96bedea20d84d06075775ed9f5af9b162700d1b;hp=bf99946e1c1e13566ef0a2585f6b076a96b77921;p=callnotify Imported Upstream version 0.0.4 --- diff --git a/debian/changelog b/debian/changelog index 1e77328..3464c6b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,7 @@ -callnotify (0.0.3-1) stable; urgency=low +callnotify (0.0.4-1) stable; urgency=low - * Sending SMS to yourself will not rise notification - * Better cleanup after update/remove. + * A very simple and ugly GUI has been added to the status menu. + * User can define sound and vibration notification in a set interval + * Config file at /home/user/.config/CallNotify/conf.txt - -- Omer Agmon Sun, 28 Mar 2010 20:51:53 +0000 + -- Omer Agmon Tue, 30 Mar 2010 21:43:31 +0000 diff --git a/debian/copyright b/debian/copyright index d8a123c..d11d616 100644 --- a/debian/copyright +++ b/debian/copyright @@ -1,5 +1,5 @@ This package was py2debianized(0.5.3) by Omer Agmon on -Sun, 28 Mar 2010 20:51:53 +0000. +Tue, 30 Mar 2010 21:43:31 +0000. It was downloaded from diff --git a/debian/rules b/debian/rules index 6c38520..d466b90 100755 --- a/debian/rules +++ b/debian/rules @@ -63,6 +63,10 @@ install: build mkdir -p "$(CURDIR)/debian/callnotify/usr/share/CallNotify/" cp -a "src/usr/share/CallNotify/5.png" "$(CURDIR)/debian/callnotify/usr/share/CallNotify/5.png" mkdir -p "$(CURDIR)/debian/callnotify/usr/share/CallNotify/" + cp -a "src/usr/share/CallNotify/call.png" "$(CURDIR)/debian/callnotify/usr/share/CallNotify/call.png" + mkdir -p "$(CURDIR)/debian/callnotify/usr/share/CallNotify/" + cp -a "src/usr/share/CallNotify/missed.wav" "$(CURDIR)/debian/callnotify/usr/share/CallNotify/missed.wav" + mkdir -p "$(CURDIR)/debian/callnotify/usr/share/CallNotify/" cp -a "src/usr/share/CallNotify/more.png" "$(CURDIR)/debian/callnotify/usr/share/CallNotify/more.png" mkdir -p "$(CURDIR)/debian/callnotify/usr/share/CallNotify/" cp -a "src/usr/share/CallNotify/sms.png" "$(CURDIR)/debian/callnotify/usr/share/CallNotify/sms.png" diff --git a/src/usr/lib/hildon-desktop/CallNotify.py b/src/usr/lib/hildon-desktop/CallNotify.py index d0c9989..798b1df 100644 --- a/src/usr/lib/hildon-desktop/CallNotify.py +++ b/src/usr/lib/hildon-desktop/CallNotify.py @@ -1,54 +1,228 @@ import gtk import gobject -import hildondesktop +import hildon, hildondesktop import sqlite3 import time import dbus import osso -import atexit +import atexit, os, datetime from dbus.mainloop.glib import DBusGMainLoop class CallNotify(hildondesktop.StatusMenuItem): def __init__(self): hildondesktop.StatusMenuItem.__init__(self) - - self.path = "/home/user/.rtcom-eventlogger/el.db" - - # Prevent multiple timers to refresh the status icon - self.stop = False - - # Load images - self.loadImages() + # Set members + self.Debug = False + self.configDir = "/home/user/.config/CallNotify/" + self.configFile = "conf.txt" + self.readConfigurationFile() self.msgType = "" self.toShow = True + self.stop = False + self.path = "/home/user/.rtcom-eventlogger/el.db" self.missed = self.getMissedCallsCount(False) self.missedSMS = self.getMissedCallsCount(True) self.missedLastCall = self.missed self.missedLastSMS = self.missedSMS - self.mainLoop = None + self.mainLoop = None + self.soundFile = "/usr/share/CallNotify/missed.wav" + self.dbg('constructor') + + # Load images + self.loadImages() + # 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) + #device.set_display_event_cb(self.state_cb) + # Check missed calls notification + self.tmr_main = gobject.timeout_add(5000, self.handleMissedCall) + self.tmrset = True # add d-bus listener for removing notification after viewing missed call # Doing timeout_add with return False instead of explicitly raising a thread gobject.timeout_add(500, self.startDbusListeners) - atexit.register(self.cleanup) + #atexit.register(self.cleanup) + + # add GUI buttons + self.addGUI() + dbg('constructor end') + + def addGUI(self): + # add GUI buttons + label = gtk.Label("Call Notify") + button = gtk.Button() + button.add(label) + button.connect("clicked", self.openSettingsDialog) + self.add(button) + self.show_all() + self.dbg('addGUI end') + + def checkForConfigFile(self): + self.dbg('checkForConfigFile started') + if not os.path.exists(self.configDir): + os.mkdir(self.configDir) + if not os.path.exists(self.configDir+self.configFile): + a = open(self.configDir+self.configFile,'w') + a.write('y;y;y;5') + a.close() - def cleanup(): - gobject.source_remove(self.tmr_main) - gobject.source_remove(self.tmr_ptr) + + def readConfigurationFile(self): + self.dbg('readConfigurationFile started') + self.checkForConfigFile() + f = open(self.configDir+self.configFile, 'r') + raw_set = f.readline().rsplit(';') + self.visual = raw_set[0] in ('y') + self.sound = raw_set[1] in ('y') + self.vibration = raw_set[2] in ('y') + self.interval = float(raw_set[3]) + f.close() + + def saveConfigurationFile(self): + self.dbg('saveConfigurationFile started') + f = open(self.configDir+self.configFile, "w") + conf = '' + if self.visual: + conf += 'y;' + else: + conf += 'n;' + + if self.sound: + conf += 'y;' + else: + conf +='n;' + + if self.vibration: + conf += 'y;' + else: + conf += 'n;' + + conf += str(self.interval) + + f.write(conf) + f.close() + + def openSettingsDialog(self, widget, data=None): + self.dbg('openSettingsDialog started') + self.dialog = gtk.Dialog(title="Call Notify Settings") + self.dialog.set_size_request(800,300) + #self.dialog.connect("response", self.dialogClosed) + self.readConfigurationFile() + # Visual + + b2 = gtk.CheckButton(label="Visual Notification On") + b2.connect("clicked", self.notificationActivate) + b2.set_active(self.visual) + self.dialog.vbox.add(b2) + + # Sound + + b3 = gtk.CheckButton(label="Sound Notification On") + b3.connect("clicked", self.soundActivate) + b3.set_active(self.sound) + self.dialog.vbox.add(b3) + + # Vibration + + b4 = gtk.CheckButton(label="Vibrate Notification On") + b4.connect("clicked", self.vibrateActivate) + b4.set_active(self.vibration) + self.dialog.vbox.add(b4) + + # Slider + + Adj = gtk.Adjustment(self.interval, lower=0, upper=60, step_incr=5, page_incr=5) + Adj.connect("value_changed", self.intervalChanged) + Adj.set_value(self.interval) + + Slider = gtk.HScale(adjustment=Adj) + self.dialog.vbox.add(Slider) + + # Manual reset + + b5 = gtk.Button(label="Manually reset notification") + b5.connect("clicked", self.resetNotification) + self.dialog.vbox.add(b5) + + # Save Button + + bSave = gtk.Button(label="Save") + bSave.connect("clicked", self.saveSettings) + self.dialog.action_area.add(bSave) + + # Cancel Button + + bCancel = gtk.Button(label="Cancel") + bCancel.connect("clicked", self.cancelDialog) + self.dialog.vbox.add(bCancel) + + self.dialog.show_all() + + def intervalChanged(self, adj): + self.dbg('intervalChanged started') + self.interval = adj.value + + def saveSettings(self, widget, data=None): + self.dbg('saveSettings started') + self.saveConfigurationFile() + + def dialogClosed(self, dialog, response_id): + self.dbg('dialogClosed started') + + def cancelDialog(self, widget, data=None): + self.dbg('cancelDialog started') + self.dialog.destroy() + + def resetNotification(self, widget, data=None): + self.dbg('resetNotification started') + self.stop_notification(self) + + def soundActivate(self, widget, data=None): + self.dbg('soundActivate started') + self.sound = widget.get_active() #not(self.sound) + + def notificationActivate(self,widget, data=None): + self.dbg('notificationActivate started') + self.visual = widget.get_active() #not(self.visual) + + def vibrateActivate(self, widget, data=None): + self.dbg('vibrateActivate started') + self.vibration = widget.get_active() #not(self.vibrate) + + + def playSound(self): + self.dbg('playSound started') + if self.sound: + hildon.hildon_play_system_sound(self.soundFile) + #pygame.time.delay(1000) + if self.vibration: + bb = 'run-standalone.sh dbus-send --print-reply --system --dest=com.nokia.mce /com/nokia/mce/request com.nokia.mce.request.req_vibrator_pattern_activate string:' + "\'PatternIncomingCall\'" + bb = str(bb) + b = os.popen(bb) + b.close() + bb = 'run-standalone.sh dbus-send --print-reply --system --dest=com.nokia.mce /com/nokia/mce/request com.nokia.mce.request.req_vibrator_pattern_deactivate string:' + "\'PatternIncomingCall\'" + b = os.popen(bb) + b.close() + return True + + + def cleanup(self): + self.dbg('cleanup started') + gobject.source_remove(self.tmr_main) + gobject.source_remove(self.tmr_ptr) + gobject.source_remove(self.tmr_ptr2) + self.mainLoop.quit() def loadImages(self): + self.dbg('loadImages started') # Load phone image #self.pixbuf = gtk.gdk.pixbuf_new_from_file_at_size("/home/user/phone.png",18,18) icon_theme = gtk.icon_theme_get_default() - self.callPicture = icon_theme.load_icon("general_call", 18, gtk.ICON_LOOKUP_NO_SVG) + self.callPicture = gtk.gdk.pixbuf_new_from_file_at_size("/usr/share/CallNotify/call.png",18,18) + #icon_theme.load_icon("general_call", 18, gtk.ICON_LOOKUP_NO_SVG) self.smsPicture = gtk.gdk.pixbuf_new_from_file_at_size("/usr/share/CallNotify/sms.png",18,18) # Load 5 numbers and the "+5" @@ -62,21 +236,32 @@ class CallNotify(hildondesktop.StatusMenuItem): 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 + def state_cb(self, state, a): + self.dbg('state_cb started') + if state == osso.device_state.OSSO_DISPLAY_OFF: + try: + #gobject.source_remove(self.tmr_main) + self.tmrset = False + #gobject.source_remove(self.tmr_ptr) + + #gobject.source_remove(self.tmr_ptr2) + except: + pass + elif state == osso.device_state.OSSO_DISPLAY_ON: + if not tmrset: + pass + #self.tmr_main = gobject.timeout_add(5000, self.handleMissedCall) + #self.handleMissedCall() + return False # Method to define the way to add dbus signal receiver def smsrec(self): - self.stop_notification(self) + self.dbg('smsrec started') + self.stop_notification(self) def startDbusListeners(self): + self.dbg('startDbusListeners started') DBusGMainLoop(set_as_default=True) bus = dbus.SessionBus() #bus.add_signal_receiver(self.stop_notification, "NotificationClosed", "org.freedesktop.Notifications", "org.freedesktop.Notifications", "/org/freedesktop/Notifications") @@ -91,19 +276,22 @@ class CallNotify(hildondesktop.StatusMenuItem): return False 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) + self.dbg('snsReceived started') + 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) + self.dbg('smsRead started') + self.stop_notification(a) def handleMissedCall(self): + self.dbg('handleMissedCall started') if self.missedLastCall != self.getMissedCallsCount(False): if self.msgType == "SMS": self.msgType = "Both" @@ -114,18 +302,24 @@ class CallNotify(hildondesktop.StatusMenuItem): return True def stop_notification(self, a): - self.set_status_area_icon(None) - gobject.source_remove(self.tmr_ptr) - self.set_status_area_icon(None) - # Reset the notification (get recent missed call count) - self.missed = self.getMissedCallsCount(False) - self.missedSMS = self.getMissedCallsCount(True) - self.missedLastCall = self.missed - self.missedLastSMS = self.missedSMS - self.stop = False - self.msgType = "" + self.dbg('stop_notification started') + try: + self.set_status_area_icon(None) + # Reset the notification (get recent missed call count) + self.missed = self.getMissedCallsCount(False) + self.missedSMS = self.getMissedCallsCount(True) + self.missedLastCall = self.missed + self.missedLastSMS = self.missedSMS + self.stop = False + self.msgType = "" + gobject.source_remove(self.tmr_ptr) + gobject.source_remove(self.tmr_ptr2) + except: + pass + def theLoop(self): + self.dbg('theLoop started') missedCalls = self.getMissedCallsCount(False) if self.missedLastCall != missedCalls: self.show() @@ -133,6 +327,7 @@ class CallNotify(hildondesktop.StatusMenuItem): return True def getMissedCallsCount(self, isSms): + self.dbg('getMissedCallsCount started. agrs: ' + str(isSms)) eType = 3 if isSms: eType=7 @@ -142,12 +337,15 @@ class CallNotify(hildondesktop.StatusMenuItem): return cur.fetchone()[0] def show(self): + self.dbg('show started') # blink the icon every 1 second - if not(self.stop): - self.tmr_ptr = gobject.timeout_add(1000, self.blinkIcon) + if not(self.stop) and self.visual: self.stop = True + self.tmr_ptr = gobject.timeout_add(1000, self.blinkIcon) + self.tmr_ptr2 = gobject.timeout_add(int(self.interval*1000*60), self.playSound) def blinkIcon(self): + self.dbg('blinkIcon started') if self.toShow: self.toShow = False img = self.callPicture @@ -172,6 +370,14 @@ class CallNotify(hildondesktop.StatusMenuItem): self.toShow = True self.set_status_area_icon(img) return True + + def dbg(self, txt): + if self.Debug: + f = open(self.configDir+'log.txt', 'a') + f.write(str(datetime.datetime.now()) + ': '+ txt) + f.write('\n') + + f.close() hd_plugin_type = CallNotify diff --git a/src/usr/share/CallNotify/call.png b/src/usr/share/CallNotify/call.png new file mode 100644 index 0000000..af83c5e Binary files /dev/null and b/src/usr/share/CallNotify/call.png differ diff --git a/src/usr/share/CallNotify/missed.wav b/src/usr/share/CallNotify/missed.wav new file mode 100644 index 0000000..73ff62b Binary files /dev/null and b/src/usr/share/CallNotify/missed.wav differ