* Fix reading file sound.txt if is empty
* Default volume level is now max (1.0)
* Sleep for 1s between starting and stopping vibrate
* Change timeout before which is missed icon shown from 60s to 20s
* Fix calling chmod commands
* Remove whitespaces
class CallNotify(hildondesktop.StatusMenuItem):
def __init__(self):
hildondesktop.StatusMenuItem.__init__(self)
class CallNotify(hildondesktop.StatusMenuItem):
def __init__(self):
hildondesktop.StatusMenuItem.__init__(self)
self.soundCall = self.soundFile
self.soundSMS = self.soundFile
self.soundBoth = self.soundFile
self.soundCall = self.soundFile
self.soundSMS = self.soundFile
self.soundBoth = self.soundFile
self.readConfigurationFile()
self.dbg('constructor')
# Load images
self.loadImages()
self.readConfigurationFile()
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)
# Register to handle screen off/on events
osso_c = osso.Context("osso_test_device_on", "0.0.1", False)
device = osso.DeviceState(osso_c)
# 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)
# 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)
-
- if self.Debug:
- hildon.hildon_play_system_sound(self.soundFile)
self.dbg('constructor end')
self.dbg('constructor end')
def checkForConfigFile(self):
self.dbg('checkForConfigFile started')
os.umask(0)
def checkForConfigFile(self):
self.dbg('checkForConfigFile started')
os.umask(0)
a.write('\n')
a.close()
# set proper permissions
a.write('\n')
a.close()
# set proper permissions
- os.system("chmod 766 " + self.configDir)
- os.system("chmod 766" + self.configDir+self.configFile)
- os.system("chmod 766" + self.configDir+self.configSoundFile)
+ os.system("chmod 755 " + self.configDir)
+ os.system("chmod 644 " + self.configDir+self.configFile)
+ os.system("chmod 644 " + self.configDir+self.configSoundFile)
def readConfigurationFile(self):
def readConfigurationFile(self):
self.vibration = raw_set[2] in ('y')
self.interval = float(raw_set[3].replace(',','.'))
f.close()
self.vibration = raw_set[2] in ('y')
self.interval = float(raw_set[3].replace(',','.'))
f.close()
# read sound config file
f = open(self.configDir+self.configSoundFile, 'r')
line = f.readline()
# check if specific missed call, SMS or common sound was defined in config file
# read sound config file
f = open(self.configDir+self.configSoundFile, 'r')
line = f.readline()
# check if specific missed call, SMS or common sound was defined in config file
- if line:
- self.soundCall = line.rstrip()
+ if line.strip():
+ self.soundCall = line.strip()
+ self.dbg('soundCall changed to: '+self.soundCall)
self.soundSMS = line.rstrip()
self.soundSMS = line.rstrip()
+ self.dbg('soundSMS changed to: '+self.soundSMS)
- if line:
- self.soundBoth = line.rstrip()
+ if line.strip():
+ self.soundBoth = line.strip()
+ self.dbg('soundBoth changed to: '+self.soundBoth)
- if line:
- self.volume = float(line.rstrip())
+ if line.strip():
+ self.volume = float(line.strip())
+ self.dbg('volume changed to: '+self.volume)
f.close()
except:
os.remove(self.configDir+self.configFile)
os.remove(self.configDir+self.configSoundFile)
self.checkForConfigFile()
f.close()
except:
os.remove(self.configDir+self.configFile)
os.remove(self.configDir+self.configSoundFile)
self.checkForConfigFile()
def playSound(self):
self.dbg('playSound started')
profiled = dbus.Interface(dbus.SessionBus().get_object("com.nokia.profiled", "/com/nokia/profiled"), "com.nokia.profiled")
def playSound(self):
self.dbg('playSound started')
profiled = dbus.Interface(dbus.SessionBus().get_object("com.nokia.profiled", "/com/nokia/profiled"), "com.nokia.profiled")
Playbin2().play(self.soundFile, self.volume)
if self.vibration and profiled.get_value("", "vibrating.alert.enabled") == "On":
Playbin2().play(self.soundFile, self.volume)
if self.vibration and profiled.get_value("", "vibrating.alert.enabled") == "On":
mce.req_vibrator_pattern_activate("PatternIncomingCall")
mce.req_vibrator_pattern_activate("PatternIncomingCall")
mce.req_vibrator_pattern_deactivate("PatternIncomingCall")
return True
mce.req_vibrator_pattern_deactivate("PatternIncomingCall")
return True
def loadImages(self):
self.dbg('loadImages started')
icon_theme = gtk.icon_theme_get_default()
self.callPicture = gtk.gdk.pixbuf_new_from_file_at_size("/usr/share/CallNotify/call.png",18,18)
self.smsPicture = gtk.gdk.pixbuf_new_from_file_at_size("/usr/share/CallNotify/sms.png",18,18)
def loadImages(self):
self.dbg('loadImages started')
icon_theme = gtk.icon_theme_get_default()
self.callPicture = gtk.gdk.pixbuf_new_from_file_at_size("/usr/share/CallNotify/call.png",18,18)
self.smsPicture = gtk.gdk.pixbuf_new_from_file_at_size("/usr/share/CallNotify/sms.png",18,18)
-
- # Load 5 numbers and the "+5"
+
+ # Load 5 numbers and the "+5"
self.imgList = []
self.imgList.append(gtk.gdk.pixbuf_new_from_file_at_size("/usr/share/CallNotify/1.png",18,18))
self.imgList.append(gtk.gdk.pixbuf_new_from_file_at_size("/usr/share/CallNotify/2.png",18,18))
self.imgList = []
self.imgList.append(gtk.gdk.pixbuf_new_from_file_at_size("/usr/share/CallNotify/1.png",18,18))
self.imgList.append(gtk.gdk.pixbuf_new_from_file_at_size("/usr/share/CallNotify/2.png",18,18))
self.imgList.append(gtk.gdk.pixbuf_new_from_file_at_size("/usr/share/CallNotify/4.png",18,18))
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))
self.imgList.append(gtk.gdk.pixbuf_new_from_file_at_size("/usr/share/CallNotify/4.png",18,18))
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))
def startDbusListeners(self):
self.dbg('startDbusListeners started')
DBusGMainLoop(set_as_default=True)
def startDbusListeners(self):
self.dbg('startDbusListeners started')
DBusGMainLoop(set_as_default=True)
def newEvent(self, a, b, c, d, e, f):
self.dbg('newEvent started')
# On NewEvent the notifications.db is not immediately filled, thus check the event after one minute waiting
def newEvent(self, a, b, c, d, e, f):
self.dbg('newEvent started')
# On NewEvent the notifications.db is not immediately filled, thus check the event after one minute waiting
- self.tmr_main = gobject.timeout_add(60000, self.handleMissed)
+ self.tmr_main = gobject.timeout_add(20000, self.handleMissed)
return True
def notificationClosed(self, a):
self.dbg('notificationClosed started')
self.stop_notification(a)
return True
def notificationClosed(self, a):
self.dbg('notificationClosed started')
self.stop_notification(a)
def pendingMessagesRemoved(self, a):
self.dbg('pendingMessagesRemoved started')
self.stop_notification(self)
def pendingMessagesRemoved(self, a):
self.dbg('pendingMessagesRemoved started')
self.stop_notification(self)
elif missedSMS and not missedCall:
self.msgType = "SMS"
self.dbg('***********handleMissed SMS started***********: ' + str(missedSMS))
elif missedSMS and not missedCall:
self.msgType = "SMS"
self.dbg('***********handleMissed SMS started***********: ' + str(missedSMS))
if missedCall or missedSMS:
self.show()
if missedCall or missedSMS:
self.show()
# Execute the function only once on NewEvent
return False
# Execute the function only once on NewEvent
return False
def stop_notification(self, a):
self.dbg('stop_notification started')
try:
def stop_notification(self, a):
self.dbg('stop_notification started')
try:
#self.dbg('get missed SMSs: ' + str(missed))
#else:
#self.dbg('get missed Calls: ' + str(missed))
#self.dbg('get missed SMSs: ' + str(missed))
#else:
#self.dbg('get missed Calls: ' + str(missed))
return missed
def show(self):
return missed
def show(self):
if self.visual:
self.tmr_ptr = gobject.timeout_add(1000, self.blinkIcon)
self.tmr_ptr2 = gobject.timeout_add(int(self.interval*1000*60), self.playSound)
if self.visual:
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:
def blinkIcon(self):
# self.dbg('blinkIcon started')
if self.toShow:
self.toShow = True
self.set_status_area_icon(img)
return True
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')
def dbg(self, txt):
if self.Debug:
f = open(self.configDir+'log.txt', 'a')
hd_plugin_type = CallNotify
hd_plugin_type = CallNotify