def __init__(self):
hildondesktop.StatusMenuItem.__init__(self)
# Set members
- self.Debug = False
self.configDir = "/home/user/.config/CallNotify/"
self.configFile = "conf.txt"
+ self.Debug = False
+ self.dbg("debugging started")
self.readConfigurationFile()
self.msgType = ""
self.toShow = True
self.stop = False
- self.path = "/home/user/.rtcom-eventlogger/el.db"
+ self.path = "/home/user/.rtcom-eventlogger/el-v1.db"
self.missed = self.getMissedCallsCount(False)
self.missedSMS = self.getMissedCallsCount(True)
self.missedLastCall = self.missed
def checkForConfigFile(self):
self.dbg('checkForConfigFile started')
+ os.umask(0)
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 = open(self.configDir+self.configFile,'w+')
+ a.write('y;y;y;5.0\n')
a.close()
+ # set proper permissions
+ os.system("chmod 766 " + self.configDir)
+ os.system("chmod 766" + self.configDir+self.configFile)
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()
-
+ try:
+ 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].replace(',','.'))
+ f.close()
+ except:
+ os.remove(self.configDir+self.configFile)
+ self.checkForConfigFile()
+
def saveConfigurationFile(self):
self.dbg('saveConfigurationFile started')
f = open(self.configDir+self.configFile, "w")
def handleMissedCall(self):
self.dbg('handleMissedCall started')
+ #self.dbg('self.missedLastCall: ' + self.missedLastCall)
+ #self.dbg('self.getMissedCallsCount(False): ' + self.getMissedCallsCount(False))
if self.missedLastCall != self.getMissedCallsCount(False):
if self.msgType == "SMS":
self.msgType = "Both"
return True
def getMissedCallsCount(self, isSms):
- self.dbg('getMissedCallsCount started. agrs: ' + str(isSms))
- eType = 3
- if isSms:
- eType=7
- conn = sqlite3.connect(self.path)
- cur = conn.cursor()
- cur.execute("select count(id) from Events where event_type_id = " + str(eType))
+ self.dbg('getMissedCallsCount started. agrs: ' + str(isSms))
+ conn = sqlite3.connect(self.path)
+ cur = conn.cursor()
+ if isSms:
+ #Nokia changed the event number from 7 to 11 and also combined the incomming and outgoing sms's
+ cur.execute("select count(id) from Events where event_type_id = 7 and outgoing = 0")
+ else:
+ #Nokia changed the event from 3 to 2
+ cur.execute("select count(id) from Events where event_type_id = 3 and outgoing = 0")
return cur.fetchone()[0]
def show(self):
hd_plugin_type = CallNotify
+
+# Uncomment from "if __name__..." to "gtk.main()" if running from CLI as:
+# "run-standalone.sh python CallNotify.py"
+
+#if __name__=="__main__":
+# gobject.type_register(hd_plugin_type)
+# obj = gobject.new(hd_plugin_type, plugin_id="plugid_id")
+# obj.show_all()
+# gtk.main()
+