Compare commits
No commits in common. "history" and "pylinphone" have entirely different histories.
history
...
pylinphone
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -1,5 +1,2 @@
|
||||||
*.swp
|
|
||||||
*.swo
|
|
||||||
pylinphone/
|
pylinphone/
|
||||||
__pycache__/
|
*.swp
|
||||||
|
|
||||||
|
|
51
history.py
51
history.py
|
@ -1,51 +0,0 @@
|
||||||
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()
|
|
|
@ -2,7 +2,6 @@ import time
|
||||||
import threading
|
import threading
|
||||||
import subprocess
|
import subprocess
|
||||||
from pylinphone.pylinphone import LinphoneCommunicationSocket
|
from pylinphone.pylinphone import LinphoneCommunicationSocket
|
||||||
from history import History
|
|
||||||
|
|
||||||
|
|
||||||
class PhoneProxyConfiguration(object):
|
class PhoneProxyConfiguration(object):
|
||||||
|
@ -52,7 +51,6 @@ class PhoneInterface(object):
|
||||||
|
|
||||||
self.__config = config
|
self.__config = config
|
||||||
self.__core = LinphoneCommunicationSocket("/var/tmp/debian-sid/tmp/linphone")
|
self.__core = LinphoneCommunicationSocket("/var/tmp/debian-sid/tmp/linphone")
|
||||||
self.__history = History()
|
|
||||||
|
|
||||||
self.__core.onLinphoneCallIncomingReceived = self.on_LinphoneCallIncomingReceived
|
self.__core.onLinphoneCallIncomingReceived = self.on_LinphoneCallIncomingReceived
|
||||||
self.__core.onLinphoneCallOutgoingRinging = self.on_LinphoneCallOutgoingRinging
|
self.__core.onLinphoneCallOutgoingRinging = self.on_LinphoneCallOutgoingRinging
|
||||||
|
@ -94,21 +92,16 @@ class PhoneInterface(object):
|
||||||
def on_LinphoneCallIncomingReceived(self, event):
|
def on_LinphoneCallIncomingReceived(self, event):
|
||||||
self.run_callbacks(PhoneEvent.CallIncoming)
|
self.run_callbacks(PhoneEvent.CallIncoming)
|
||||||
self.current_call_id = event.call_id
|
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):
|
def on_LinphoneCallOutgoingRinging(self, event):
|
||||||
self.run_callbacks(PhoneEvent.CallRinging)
|
self.run_callbacks(PhoneEvent.CallRinging)
|
||||||
self.current_history_id = self.__history.log_call(self.get_remote_number(), False)
|
|
||||||
|
|
||||||
def on_LinphoneCallConnected(self, event):
|
def on_LinphoneCallConnected(self, event):
|
||||||
self.call_connected_time = time.time()
|
|
||||||
self.run_callbacks(PhoneEvent.CallAccepted)
|
self.run_callbacks(PhoneEvent.CallAccepted)
|
||||||
|
|
||||||
def on_LinphoneCallEnd(self, event):
|
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.run_callbacks(PhoneEvent.CallEnded)
|
||||||
self.current_call_id = None
|
self.current_call_id = None
|
||||||
self.current_history_id = None
|
|
||||||
|
|
||||||
def __pollthread(self):
|
def __pollthread(self):
|
||||||
while self.__running:
|
while self.__running:
|
||||||
|
@ -149,11 +142,9 @@ class PhoneInterface(object):
|
||||||
self.__core.call(number)
|
self.__core.call(number)
|
||||||
|
|
||||||
def accept_call(self):
|
def accept_call(self):
|
||||||
self.__history.accept_call(self.current_history_id)
|
|
||||||
self.__core.answer(self.current_call_id)
|
self.__core.answer(self.current_call_id)
|
||||||
|
|
||||||
def decline_call(self):
|
def decline_call(self):
|
||||||
self.__history.decline_call(self.current_history_id)
|
|
||||||
self.__core.decline_call(self.__core.current_call)
|
self.__core.decline_call(self.__core.current_call)
|
||||||
|
|
||||||
def end_call(self):
|
def end_call(self):
|
||||||
|
|
|
@ -2,10 +2,6 @@ waehlscheibe_diameter=80;
|
||||||
fingerhole_diameter=13;
|
fingerhole_diameter=13;
|
||||||
fingerhole_clearance=2.5;
|
fingerhole_clearance=2.5;
|
||||||
|
|
||||||
|
|
||||||
//circle(d=waehlscheibe_diameter-fingerhole_diameter*2-fingerhole_clearance*4, $fn=100);
|
|
||||||
|
|
||||||
//Wählscheibe
|
|
||||||
difference() {
|
difference() {
|
||||||
circle(d=waehlscheibe_diameter, $fn=100);
|
circle(d=waehlscheibe_diameter, $fn=100);
|
||||||
circle(d=waehlscheibe_diameter-fingerhole_diameter*2-fingerhole_clearance*4, $fn=100);
|
circle(d=waehlscheibe_diameter-fingerhole_diameter*2-fingerhole_clearance*4, $fn=100);
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
<?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>
|
|
Before Width: | Height: | Size: 2.2 KiB |
Loading…
Reference in a new issue