Compare commits

...

7 Commits

5 changed files with 93 additions and 2 deletions

5
.gitignore vendored
View File

@ -1,2 +1,5 @@
pylinphone/
*.swp
*.swo
pylinphone/
__pycache__/

51
history.py Normal file
View File

@ -0,0 +1,51 @@
import sqlite3, time
class History():
def __init__(self):
self.__db = sqlite3.connect('history.sqlite', check_same_thread=False)
self.__c = self.__db.cursor()
self.__c.execute("""
CREATE TABLE IF NOT EXISTS numbers (
id INTEGER PRIMARY KEY AUTOINCREMENT,
number TEXT UNIQUE NOT NULL
);
""")
self.__c.execute("""
CREATE TABLE IF NOT EXISTS call_history (
call_id INTEGER PRIMARY KEY AUTOINCREMENT,
number_id INTEGER NOT NULL,
direction INTEGER NOT NULL,
time INTEGER NOT NULL,
duration INTEGER,
accepted INTEGER,
FOREIGN KEY(number_id) REFERENCES numbers(id)
);
""")
self.__db.commit()
def log_call(self, number, incoming):
call_time = int(time.time())
try:
self.__c.execute("INSERT INTO numbers(number) VALUES(?)", (number,))
number_id = self.__c.lastrowid
except sqlite3.IntegrityError:
number_id = self.__c.execute("SELECT id FROM numbers WHERE number=?", (number,)).fetchone()[0]
self.__c.execute("INSERT INTO call_history(direction, time, number_id) VALUES(?, ?, ?);", (int(incoming), call_time, number_id))
new_call_history_id = self.__c.lastrowid
self.__db.commit()
return new_call_history_id
def accept_call(self, call_id):
self.update_call_acception(call_id, True)
def decline_call(self, call_id):
self.update_call_acception(call_id, False)
def update_call_acception(self, call_id, accepted):
self.__c.execute("UPDATE call_history SET accepted=? WHERE call_id=?;", (accepted, call_id))
self.__db.commit()
def set_call_duration(self, call_id, duration):
self.__c.execute("UPDATE call_history SET duration=? WHERE call_id=?;", (duration, call_id))
self.__db.commit()

View File

@ -2,6 +2,7 @@ import time
import threading
import subprocess
from pylinphone.pylinphone import LinphoneCommunicationSocket
from history import History
class PhoneProxyConfiguration(object):
@ -51,6 +52,7 @@ class PhoneInterface(object):
self.__config = config
self.__core = LinphoneCommunicationSocket("/var/tmp/debian-sid/tmp/linphone")
self.__history = History()
self.__core.onLinphoneCallIncomingReceived = self.on_LinphoneCallIncomingReceived
self.__core.onLinphoneCallOutgoingRinging = self.on_LinphoneCallOutgoingRinging
@ -92,16 +94,21 @@ class PhoneInterface(object):
def on_LinphoneCallIncomingReceived(self, event):
self.run_callbacks(PhoneEvent.CallIncoming)
self.current_call_id = event.call_id
self.current_history_id = self.__history.log_call(self.get_remote_number(), True)
def on_LinphoneCallOutgoingRinging(self, event):
self.run_callbacks(PhoneEvent.CallRinging)
self.current_history_id = self.__history.log_call(self.get_remote_number(), False)
def on_LinphoneCallConnected(self, event):
self.call_connected_time = time.time()
self.run_callbacks(PhoneEvent.CallAccepted)
def on_LinphoneCallEnd(self, event):
self.__history.set_call_duration(self.current_history_id, int(time.time() - self.call_connected_time))
self.run_callbacks(PhoneEvent.CallEnded)
self.current_call_id = None
self.current_history_id = None
def __pollthread(self):
while self.__running:
@ -142,9 +149,11 @@ class PhoneInterface(object):
self.__core.call(number)
def accept_call(self):
self.__history.accept_call(self.current_history_id)
self.__core.answer(self.current_call_id)
def decline_call(self):
self.__history.decline_call(self.current_history_id)
self.__core.decline_call(self.__core.current_call)
def end_call(self):

View File

@ -2,6 +2,10 @@ waehlscheibe_diameter=80;
fingerhole_diameter=13;
fingerhole_clearance=2.5;
//circle(d=waehlscheibe_diameter-fingerhole_diameter*2-fingerhole_clearance*4, $fn=100);
//Wählscheibe
difference() {
circle(d=waehlscheibe_diameter, $fn=100);
circle(d=waehlscheibe_diameter-fingerhole_diameter*2-fingerhole_clearance*4, $fn=100);
@ -12,4 +16,4 @@ difference() {
}
}
}
}
}

View File

@ -0,0 +1,24 @@
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="44mm" height="44mm" viewBox="-22 -22 44 44" xmlns="http://www.w3.org/2000/svg" version="1.1">
<title>OpenSCAD Model</title>
<path d="
M 22,-0 L 21.9566,-1.38139 L 21.8265,-2.75733 L 21.6103,-4.12239 L 21.3088,-5.47118 L 20.9232,-6.79837
L 20.4551,-8.09874 L 19.9062,-9.36714 L 19.2787,-10.5986 L 18.5752,-11.7882 L 17.7984,-12.9313 L 16.9513,-14.0233
L 16.0373,-15.06 L 15.06,-16.0373 L 14.0233,-16.9513 L 12.9313,-17.7984 L 11.7882,-18.5752 L 10.5986,-19.2787
L 9.36714,-19.9062 L 8.09874,-20.4551 L 6.79837,-20.9232 L 5.47118,-21.3088 L 4.12239,-21.6103 L 2.75733,-21.8265
L 1.38139,-21.9566 L 0,-22 L -1.38139,-21.9566 L -2.75733,-21.8265 L -4.12239,-21.6103 L -5.47118,-21.3088
L -6.79837,-20.9232 L -8.09874,-20.4551 L -9.36714,-19.9062 L -10.5986,-19.2787 L -11.7882,-18.5752 L -12.9313,-17.7984
L -14.0233,-16.9513 L -15.06,-16.0373 L -16.0373,-15.06 L -16.9513,-14.0233 L -17.7984,-12.9313 L -18.5752,-11.7882
L -19.2787,-10.5986 L -19.9062,-9.36714 L -20.4551,-8.09874 L -20.9232,-6.79837 L -21.3088,-5.47118 L -21.6103,-4.12239
L -21.8265,-2.75733 L -21.9566,-1.38139 L -22,0 L -21.9566,1.38139 L -21.8265,2.75733 L -21.6103,4.12239
L -21.3088,5.47118 L -20.9232,6.79837 L -20.4551,8.09874 L -19.9062,9.36714 L -19.2787,10.5986 L -18.5752,11.7882
L -17.7984,12.9313 L -16.9513,14.0233 L -16.0373,15.06 L -15.06,16.0373 L -14.0233,16.9513 L -12.9313,17.7984
L -11.7882,18.5752 L -10.5986,19.2787 L -9.36714,19.9062 L -8.09874,20.4551 L -6.79837,20.9232 L -5.47118,21.3088
L -4.12239,21.6103 L -2.75733,21.8265 L -1.38139,21.9566 L -0,22 L 1.38139,21.9566 L 2.75733,21.8265
L 4.12239,21.6103 L 5.47118,21.3088 L 6.79837,20.9232 L 8.09874,20.4551 L 9.36714,19.9062 L 10.5986,19.2787
L 11.7882,18.5752 L 12.9313,17.7984 L 14.0233,16.9513 L 15.06,16.0373 L 16.0373,15.06 L 16.9513,14.0233
L 17.7984,12.9313 L 18.5752,11.7882 L 19.2787,10.5986 L 19.9062,9.36714 L 20.4551,8.09874 L 20.9232,6.79837
L 21.3088,5.47118 L 21.6103,4.12239 L 21.8265,2.75733 L 21.9566,1.38139 z
" stroke="black" fill="lightgray" stroke-width="0.5"/>
</svg>

After

Width:  |  Height:  |  Size: 2.2 KiB