diff --git a/PyTracker/trunk/PyTracker.py b/PyTracker/trunk/PyTracker.py
new file mode 100755
index 0000000..568353b
--- /dev/null
+++ b/PyTracker/trunk/PyTracker.py
@@ -0,0 +1,81 @@
+#!/usr/bin/python
+'''
+authors: edistar
+license: gpl v2 or later
+version 0.2
+'''
+
+from __future__ import with_statement
+import time
+import datetime
+import ecore
+import e_dbus
+import os
+from dbus import SystemBus, Interface
+from optparse import OptionParser
+
+class Main:
+
+ def __init__(self):
+
+ self.GetPath()
+
+# get FSO Usage proxy/iface up to request GPS
+ self.systembus=systembus = SystemBus(mainloop=e_dbus.DBusEcoreMainLoop())
+ self.usage_proxy = self.systembus.get_object('org.freesmartphone.ousaged', '/org/freesmartphone/Usage')
+ self.usage_iface = Interface(self.usage_proxy, 'org.freesmartphone.Usage')
+
+# Request GPS from FSO (which then powers on the GPS chip)
+ self.usage_iface.RequestResource("GPS")
+
+#get gypsy proxy/iface up
+ self.ogpsd_proxy = self.systembus.get_object('org.freesmartphone.ogpsd', '/org/freedesktop/Gypsy')
+ self.course_iface = Interface(self.ogpsd_proxy, 'org.freedesktop.Gypsy.Course')
+ self.pos_iface = Interface(self.ogpsd_proxy, 'org.freedesktop.Gypsy.Position')
+
+# call self.UpdatePosition() when a dbus signal "PositionChanged" comes along the system bus
+ self.pos_iface.connect_to_signal("PositionChanged", self.UpdatePosition)
+
+
+ def UpdatePosition(self, fields, timestamp, lat, lon, alt):
+
+# get UTC time from gypsy timestamp
+ string = str(datetime.datetime.utcfromtimestamp(timestamp))
+ date, time = string.split()
+ utctime = "%sT%sZ" % (date, time)
+
+# write data to file
+ s ="%s,%s,%s,%s\n" % (lat, lon, alt, utctime)
+ with open(self.trackfile,'a') as file:
+ file.write(s)
+
+#debugging output:
+ print s
+
+
+ def Parser(self):
+
+# parse command line options
+ self.parser=OptionParser("usage foo bar")
+ self.parser.add_option("-f", "--file", "-o", "-l", action = "store", dest = "trackfile")
+ (self.options, self.args) = self.parser.parse_args()
+
+
+ def GetPath(self):
+ trackpath = '.'
+ suffix = 'track'
+ self.Parser()
+
+# raises an Exception if the path doesn't exist! :)
+ path, rubbish, suffix = self.trackfile.options.rpartition("/")
+
+ if not os.path.exists(path):
+ raise Exception("path does not exist!")
+
+# sets trackfile path and filename
+ self.trackfile = "%s/%s-%s" % (trackpath, time.strftime(), suffix)
+
+
+
+test=Main()
+ecore.main_loop_begin()
diff --git a/PyTracker/trunk/WriteGPX.py b/PyTracker/trunk/WriteGPX.py
new file mode 100644
index 0000000..b461c30
--- /dev/null
+++ b/PyTracker/trunk/WriteGPX.py
@@ -0,0 +1,41 @@
+#!/usr/bin/python
+'''
+authors: Pau1us
+license: gpl v2 or later
+
+This is a Class to creat *.gpx Files
+Usage:
+open new file: file = WriteGPX(filename)
+write trackpint: file.write(lat, lon, alt, utctime)
+close file: file.close()
+The file musst be closed, otherwise the file will be incomplete
+'''
+
+
+class WriteGPX:
+ def __init__(self, filename):
+ self.filename = filename
+ self.header = '\n\
+\n\
+\n\
+\n'
+ self.footer = '\n\n\n'
+
+ with open(self.filename,'a') as file:
+ file.write(self.header)
+
+ def write(self, lat, lon, ele, time):
+ self.trackpoint = '\n\
+%s\n\
+\n\
+\n' % (lat, lon, ele, time)
+ with open(self.filename,'a') as file:
+ file.write(self.trackpoint)
+
+ def close(self):
+ with open(self.filename,'a') as file:
+ file.write(self.footer)
diff --git a/PyTracker/trunk/client.py b/PyTracker/trunk/client.py
new file mode 100644
index 0000000..07b3a9f
--- /dev/null
+++ b/PyTracker/trunk/client.py
@@ -0,0 +1,87 @@
+# PyTracker Client
+'''
+author: edistar
+license: GPL v3 or later
+version 0.1
+'''
+from __future__ import with_statement
+import datetime
+import ecore
+import e_dbus
+import os
+from socket import *
+from dbus import SystemBus, Interface
+from optparse import OptionParser
+
+class TrackClient:
+ def __init__(self):
+ self.InitSocket('localhost', 49152)
+ self.InitDbusStuff()
+ self.InitUserHash('edistar', 'passwdhash')
+
+ def InitSocket(self, host, port):
+# Set the socket parameters
+# e.g. host = "localhost"
+# e.g. port = 49152
+ self.__addr = (str(host),int(port))
+# Create socket
+ self.__UDPSock = socket(AF_INET,SOCK_DGRAM)
+# Debug message:
+ print "UDP Socket for %s at port %s created" % (host, port)
+
+ def TransmitUDP(self, data):
+ if data:
+ self.__UDPSock.sendto(data,self.__addr)
+# Debug message:
+ print "UDP stream %s sent" % (data)
+
+ def CloseSocket(self):
+ self.__UDPSock.close()
+# Debug message:
+ print "UDP Socket closed"
+
+ def InitDbusStuff(self):
+# get FSO Usage proxy/iface up to request GPS
+ self.systembus=systembus = SystemBus(mainloop=e_dbus.DBusEcoreMainLoop())
+ self.usage_proxy = self.systembus.get_object('org.freesmartphone.ousaged', '/org/freesmartphone/Usage')
+ self.usage_iface = Interface(self.usage_proxy, 'org.freesmartphone.Usage')
+# request GPS from FSO (which then powers on the GPS chip)
+ self.usage_iface.RequestResource("GPS")
+# get gypsy proxy/iface up
+ self.ogpsd_proxy = self.systembus.get_object('org.freesmartphone.ogpsd', '/org/freedesktop/Gypsy')
+ self.course_iface = Interface(self.ogpsd_proxy, 'org.freedesktop.Gypsy.Course')
+ self.pos_iface = Interface(self.ogpsd_proxy, 'org.freedesktop.Gypsy.Position')
+# call self.UpdatePosition() when a dbus signal "PositionChanged" comes along the system bus
+ self.pos_iface.connect_to_signal("PositionChanged", self.UpdateData)
+
+ def UpdateData(self, fields, timestamp, lat, lon, alt):
+# get UTC time from gypsy timestamp
+ string = str(datetime.datetime.utcfromtimestamp(timestamp))
+ date, time = string.split()
+ utctime = "%sT%sZ" % (date, time)
+# prepare data for sending
+ UDPData = "%s,%s,%s,%s" % (lat, lon, alt, utctime)
+ self.SendData(self.__username, self.__pwhash, 'Transmit', UDPData)
+
+ def InitUserHash(self, username, pwhash):
+# set username and password globally in the class
+ self.__username = username
+ self.__pwhash = pwhash
+
+ def SendData(self, username, pwhash, action, data=""):
+# put together and send data to TransmitUDP()
+ senddata = "%s;%s;%s;%s" % (username, pwhash, action, data)
+ self.TransmitUDP(senddata)
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/PyTracker/trunk/server.py b/PyTracker/trunk/server.py
new file mode 100644
index 0000000..038d29a
--- /dev/null
+++ b/PyTracker/trunk/server.py
@@ -0,0 +1,79 @@
+from __future__ import with_statement
+import time
+from socket import *
+
+class TrackServer:
+ def __init__(self):
+ self.InitHashdb("hashfile.txt")
+ self.InitTrackDict()
+
+ def InitHashdb(self, hashfile):
+ self.hashdb=[]
+ with open(hashfile, "r") as file:
+ for line in file:
+ if line:
+ self.hashdb.append((line.split()[0], \
+ line.split()[1]))
+
+ def InitTrackDict(self):
+ self.TrackDict={}
+ for data in self.hashdb:
+ self.TrackDict[data[0]] = ""
+
+ def VerifyUser(self, username, password_hash):
+ for data in self.hashdb:
+ if data[0] == username and data[1] == password_hash:
+ return 1
+ return 0
+
+
+ def Parser(self, stuff):
+# Parses the complete data sent to UDP port
+ try:
+ username, password_hash, action, data = stuff.split()
+# Verifies the user and password
+ if self.VerifyUser(username, password_hash):
+
+ if action == "START":
+ self.NewTrack(username)
+ if action == "STOP":
+ self.CloseTrack(username)
+ if action == "TRANSMIT":
+ self.AddToTrack(username, data)
+ print "Action", action,"received"
+ except:
+ print "Something went wrong.."
+
+ def NewTrack(self, username):
+ self.TrackDict[username] = "/home/edistar/Openmoko/projects/tracking/data/" + username + time.strftime("%Y%m%d%H%M%S")
+ print "Created track", self.TrackDict[username]
+
+ def CloseTrack(self, username):
+ self.TrackDict[username] = ""
+ print "Closed track", self.TrackDict[username]
+
+ def AddToTrack(self, username, data):
+ with open(self.TrackDict[username], "a") as trackfile:
+ trackfile.write(data + "\n")
+ print "Successfully added data to track", self.TrackDict[username]
+
+instance=TrackServer()
+
+# Set the socket parameters
+host = ""
+port = 49152
+buf = 1024
+addr = (host,port)
+
+# Create socket and bind to address
+UDPSock = socket(AF_INET,SOCK_DGRAM)
+UDPSock.bind(addr)
+
+# Create instance of TrackServer
+instance = TrackServer()
+
+#Receive messages
+while 1:
+ data,addr = UDPSock.recvfrom(buf)
+ print "Following data received:", data
+ instance.Parser(data)
diff --git a/PyTracker/trunk/tracking.txt b/PyTracker/trunk/tracking.txt
new file mode 100644
index 0000000..9cfa575
--- /dev/null
+++ b/PyTracker/trunk/tracking.txt
@@ -0,0 +1,16 @@
+ONLY WAY OF DATA TRANSFER:
+CLIENT --> SERVER
+
+PASSWORD_HASH is in md5
+Structure:
+
+(USERNAME,PASSWORD_HASH,ACTION,DATA)
+
+ACTION == ("START" | "TRANSMIT" | "STOP")
+
+DATA == ("" | POSITION, TIME/DATE | "")
+
+POSITION == (LAT, LON, HEIGHT)
+
+Only one track may be open for each user.. so if the user requests START and
+another track is open it gets closed immediately