Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Zielke <kg4gjy@takeovertheworld.org>2009-05-26 05:14:12 (GMT)
committer Jack Zielke <kg4gjy@takeovertheworld.org>2009-05-26 05:14:12 (GMT)
commit7468a2bc8bf2e4d328fd519f49fe650a89eb92fd (patch)
tree4b2a5c7c1630f49ffb626df45ec650ab3083bce2
parent9ada452201520759bd6ec5e46a5064f5c63e638f (diff)
version 2 - no journal, can not send messages, gui update
-rw-r--r--NEWS1
-rw-r--r--activity/activity.info2
-rwxr-xr-xaprs.py185
3 files changed, 126 insertions, 62 deletions
diff --git a/NEWS b/NEWS
index 6929339..c75c936 100644
--- a/NEWS
+++ b/NEWS
@@ -1,2 +1,3 @@
September 14 2008 - version 0 started
September 20 2008 - version 1 - no journal, no messaging
+September 22 2008 - version 2 - no journal, can not send messages, gui update
diff --git a/activity/activity.info b/activity/activity.info
index 8ae84e0..cf8dd05 100644
--- a/activity/activity.info
+++ b/activity/activity.info
@@ -1,6 +1,6 @@
[Activity]
name = APRS
-activity_version= 1
+activity_version= 2
service_name = org.laptop.APRS
icon = activity-aprs
exec = sugar-activity aprs.APRSActivity
diff --git a/aprs.py b/aprs.py
index 0ec7ed5..901b28a 100755
--- a/aprs.py
+++ b/aprs.py
@@ -34,6 +34,8 @@ HOST = 'rotate.aprs2.net'
PORT = 14580
RECV_BUFFER = 4096
+MAXLINES = 50
+
bundle = ActivityBundle(activity.get_bundle_path())
VERSION = bundle.get_activity_version()
del bundle
@@ -53,8 +55,9 @@ class APRSActivity(activity.Activity):
self.validating = False
titlefont = pango.FontDescription('Sans bold 8')
+ mediumfont = pango.FontDescription('Sans 6.5')
smallfont = pango.FontDescription('Sans 6')
- verysmallfont = pango.FontDescription('Sans 3')
+ verysmallfont = pango.FontDescription('Sans 4')
firstName = profile.get_nick_name().split(None, 1)[0].capitalize()
toolbox = activity.ActivityToolbox(self)
@@ -72,8 +75,8 @@ class APRSActivity(activity.Activity):
leftwin = gtk.VBox(False, 10)
# Top 'about' box
- aboutbox = gtk.VBox(False, 10)
- aboutbox.set_border_width(10)
+ aboutbox = gtk.VBox(False, 8)
+ aboutbox.set_border_width(8)
topaboutbox = gtk.VBox(False, 0)
@@ -85,18 +88,20 @@ class APRSActivity(activity.Activity):
titlelabel.show()
aboutlabel1 = gtk.Label("This amateur radio program will update your position")
aboutlabel1.set_alignment(0, 0.8)
+ aboutlabel1.modify_font(mediumfont)
titlebox.pack_start(aboutlabel1, False, False, 0)
aboutlabel1.show()
topaboutbox.pack_start(titlebox, False, False, 0)
titlebox.show()
aboutlabel2 = gtk.Label("& status on all of the global APRS web pages once every 10 minutes.")
aboutlabel2.set_alignment(0, 0)
+ aboutlabel2.modify_font(mediumfont)
topaboutbox.pack_start(aboutlabel2, False, False, 0)
aboutlabel2.show()
aboutbox.pack_start(topaboutbox, False, False, 0)
topaboutbox.show()
- sitebox = gtk.HBox(False, 10)
+ sitebox = gtk.HBox(False, 8)
sitelabel = gtk.Label("Select an APRS site:")
sitelabel.set_alignment(0, 0.4)
sitebox.pack_start(sitelabel, False, False, 0)
@@ -126,7 +131,8 @@ class APRSActivity(activity.Activity):
infobox = gtk.VBox(False, 4)
# more info radio box?
- infolabel = gtk.Label("Without a ham license you can only communicate with other XO's on the Internet.\nWith a ham license you can communicate worldwide with wireless and radio.")
+# infolabel = gtk.Label("Without a ham license you can only communicate with other XO's on the Internet.\nWith a ham license you can communicate worldwide with wireless and radio.")
+ infolabel = gtk.Label("With a ham license you can communicate worldwide with wireless and radio.\nWithout a ham license you can only communicate with other XO's on the\nInternet.")
infolabel.set_alignment(0, 0)
infolabel.modify_font(smallfont)
infobox.pack_start(infolabel, False, False, 0)
@@ -143,10 +149,11 @@ class APRSActivity(activity.Activity):
separator.show()
# identifiers box
- identbox = gtk.HBox(False, 10)
+ identbox = gtk.HBox(False, 4)
+ identbox.set_border_width(8)
- leftidentbox = gtk.VBox(False, 10)
- leftidentbox.set_border_width(10)
+ leftidentbox = gtk.VBox(False, 4)
+# leftidentbox.set_border_width(8)
identlabel = gtk.Label("Identifiers")
identlabel.set_alignment(0, 0)
identlabel.modify_font(titlefont)
@@ -188,8 +195,8 @@ class APRSActivity(activity.Activity):
identbox.pack_start(leftidentbox, False, False, 0)
leftidentbox.show()
- rightidentbox = gtk.VBox(False, 10)
- rightidentbox.set_border_width(10)
+ rightidentbox = gtk.VBox(False, 4)
+# rightidentbox.set_border_width(8)
toprightidentbox = gtk.HBox(False, 4)
namelabel = gtk.Label("First Name: ")
@@ -240,29 +247,32 @@ class APRSActivity(activity.Activity):
separator.show()
# station box
- stationbox = gtk.VBox(False, 10)
- stationbox.set_border_width(10)
+ stationbox = gtk.VBox(False, 8)
+ stationbox.set_border_width(8)
- topstationbox = gtk.HBox(False, 10)
+# topstationbox = gtk.HBox(False, 8)
stationlabel = gtk.Label("Station Text")
- stationlabel.set_alignment(0, 0.5)
+ stationlabel.set_alignment(0, 0)
stationlabel.modify_font(titlefont)
- topstationbox.pack_start(stationlabel, False, False, 0)
+# topstationbox.pack_start(stationlabel, False, False, 0)
+ stationbox.pack_start(stationlabel, False, False, 0)
stationlabel.show()
self.stationtext = gtk.Entry()
self.stationtext.set_max_length(36)
self.stationtext.set_width_chars(36)
self.stationtext.connect("changed", self.disable_beacon)
- topstationbox.pack_start(self.stationtext, False, False, 0)
+# topstationbox.pack_start(self.stationtext, False, False, 0)
+ stationbox.pack_start(self.stationtext, False, False, 0)
self.stationtext.show()
- stationbox.pack_start(topstationbox, False, False, 0)
- topstationbox.show()
+# stationbox.pack_start(topstationbox, False, False, 0)
+# topstationbox.show()
- stationhelp = gtk.Label("Enter up to 36 characters, most important first since some displays\ncan only see the first 20 or 28.")
+ stationhelp = gtk.Label("Enter up to 36 characters, most important first since some\ndisplays can only see the first 20 or 28.")
stationhelp.set_alignment(0, 0)
+# stationhelp.modify_font(mediumfont)
stationbox.pack_start(stationhelp, False, False, 0)
stationhelp.show()
@@ -274,10 +284,10 @@ class APRSActivity(activity.Activity):
separator.show()
# position box
- positbox = gtk.VBox(False, 10)
- positbox.set_border_width(10)
+ positbox = gtk.VBox(False, 8)
+ positbox.set_border_width(8)
- toppositbox = gtk.HBox(False, 30)
+ toppositbox = gtk.HBox(False, 0)
topleftpositbox = gtk.VBox(False, 4)
@@ -386,16 +396,16 @@ class APRSActivity(activity.Activity):
toppositbox.pack_start(topleftpositbox, False, False, 0)
topleftpositbox.show()
- toprightpositbox = gtk.VBox(False, 4)
+ toprightpositbox = gtk.VBox(False, 0)
loclabel = gtk.Label("Location Type:")
loclabel.set_alignment(0, 0)
toprightpositbox.pack_start(loclabel, False, False, 0)
loclabel.show()
- locbox = gtk.HBox(False, 4)
+ locbox = gtk.HBox(False, 0)
- leftlocbox = gtk.VBox(False, 4)
+ leftlocbox = gtk.VBox(False, 0)
locbutton = gtk.RadioButton(None, "home")
locbutton.connect("toggled", self.set_location, "home")
@@ -416,7 +426,7 @@ class APRSActivity(activity.Activity):
locbox.pack_start(leftlocbox, False, False, 0)
leftlocbox.show()
- rightlocbox = gtk.VBox(False, 4)
+ rightlocbox = gtk.VBox(False, 0)
locbutton = gtk.RadioButton(locbutton, "club")
locbutton.connect("toggled", self.set_location, "club")
@@ -445,8 +455,9 @@ class APRSActivity(activity.Activity):
positbox.pack_start(toppositbox, False, False, 0)
toppositbox.show()
- positlabel2 = gtk.Label("If you do not know your LAT/LONG then your\nzip code will be used to place you on the map.")
+ positlabel2 = gtk.Label("If you do not know your LAT/LONG then your zip code will be used to\nplace you on the map.")
positlabel2.set_alignment(0, 0)
+ positlabel2.modify_font(mediumfont)
positbox.pack_start(positlabel2, False, False, 0)
positlabel2.show()
@@ -460,6 +471,8 @@ class APRSActivity(activity.Activity):
# defined here so clear and connect buttons have access
statusview = gtk.TextView()
self.statusbuffer = statusview.get_buffer()
+ messageview = gtk.TextView()
+ self.messagebuffer = messageview.get_buffer()
connectbutton = gtk.Button()
connectbutton.set_label("Connect")
@@ -472,12 +485,13 @@ class APRSActivity(activity.Activity):
leftwin.show()
rightwin = gtk.VBox(False, 4)
+ rightwin.set_border_width(4)
rightwintopbox = gtk.HBox(False, 4)
clearbutton = gtk.Button()
clearbutton.set_label(" Clear ")
- clearbutton.connect("clicked", self.clear_status)
+ clearbutton.connect("clicked", self.clear_message)
rightwintopbox.pack_start(clearbutton, False, False, 20)
clearbutton.show()
@@ -490,23 +504,22 @@ class APRSActivity(activity.Activity):
rightwin.pack_start(rightwintopbox, False, False, 0)
rightwintopbox.show()
- statusview.set_editable(False)
- statusview.set_cursor_visible(True)
- statusview.set_wrap_mode(gtk.WRAP_CHAR)
- statusview.set_justification(gtk.JUSTIFY_LEFT)
- statusview.modify_font(smallfont)
+ messageview.set_editable(False)
+ messageview.set_cursor_visible(True)
+ messageview.set_wrap_mode(gtk.WRAP_CHAR)
+ messageview.set_justification(gtk.JUSTIFY_LEFT)
+ messageview.modify_font(smallfont)
- self.statusbuffer.set_text("Welcome to APRS-XO.\n\nThis program sends your position information to a\nserver that will then display your location on\na webpage. This program requires an active\nInternet connection to work.\n\nSelect an APRS Site\nSelecting a button will copy the URI to the\nclipboard.\n\nIndentifiers\nIf you are not a ham radio operator enter your\nfirst name and zip code.\n\nIf you are a ham radio operator enter your first\nname, call sign, and position data. If position\nis unknown, leave the call sign field blank and\nenter your 5 digit zip code.\n\nStation Text\nData in the Station Text field will appear\nafter your location information on the website.\n\nBeacon\nWhen selected, sends location data every 10\nminutes. The beacon will automatically stop\nwhen you edit personal information. Must be\nmanually reselected after edit completion.\n\nAPRS Copyright (c) Bob Bruninga WB4APR\n\n")
+# self.messagebuffer.set_text("Welcome to APRS-XO.\n\nThis program sends your position information to a server\nthat will then display your location on a webpage. This\nprogram requires an active Internet connection to work.\n\nSelect an APRS Site\nSelecting a button will copy the URI to the clipboard.\n\nIndentifiers\nIf you are not a ham radio operator enter your first name\nand zip code.\n\nIf you are a ham radio operator enter your first name,\ncallsign, and position data. If position is unknown, leave\nthe callsign field blank and enter your 5 digit zip code.\n\nStation Text\nData in the Station Text field will appear after your location\ninformation on the website.\n\nBeacon\nWhen selected, sends location data every 10 minutes. The\nbeacon will automatically stop when you edit personal\ninformation. Must be manually reselected after edit\ncompletion.\n\nAPRS Copyright (c) Bob Bruninga WB4APR\n\n")
+ self.messagebuffer.set_text("Welcome to APRS-XO.\n\nThis program sends your position information to a server\nthat will then display your location on a webpage. This\nprogram requires an active Internet connection to work.\n\nSelect an APRS Site\nSelecting a button will copy the URI to the clipboard.\n\nIndentifiers\nIf you are not a ham radio operator enter your first name\nand zip code.\n\nIf you are a ham radio operator enter your first name,\ncallsign, and position data. If position is unknown, leave\nthe callsign field blank and enter your 5 digit zip code.")
- self.statuswindow = gtk.ScrolledWindow()
- self.statuswindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_ALWAYS)
- self.statuswindow.add_with_viewport(statusview)
- statusview.show()
- rightwin.pack_start(self.statuswindow, True, True, 0)
- self.statuswindow.show()
+ self.messagewindow = gtk.ScrolledWindow()
+ self.messagewindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_ALWAYS)
+ self.messagewindow.add_with_viewport(messageview)
+ messageview.show()
+ rightwin.pack_start(self.messagewindow, True, True, 0)
+ self.messagewindow.show()
- # when messaging is enabled, put a textview for messages above the status textview
- # move the messagebox between them.
messagebox = gtk.HBox(False, 4)
self.messagecombo = gtk.combo_box_entry_new_text()
@@ -524,7 +537,7 @@ class APRSActivity(activity.Activity):
self.messagetext = gtk.Entry()
self.messagetext.set_max_length(67)
- self.messagetext.set_width_chars(23)
+ self.messagetext.set_width_chars(27)
self.messagetext.modify_font(smallfont)
self.messagetext.connect("activate", self.send_message, self.messagetext)
messagebox.pack_start(self.messagetext, False, False, 0)
@@ -539,11 +552,26 @@ class APRSActivity(activity.Activity):
rightwin.pack_start(messagebox, False, False, 0)
messagebox.show()
+ statusview.set_editable(False)
+ statusview.set_cursor_visible(True)
+ statusview.set_wrap_mode(gtk.WRAP_CHAR)
+ statusview.set_justification(gtk.JUSTIFY_LEFT)
+ statusview.modify_font(smallfont)
+
+ self.statusbuffer.set_text("Station Text\nData in the Station Text field will appear after your location\ninformation on the website.\n\nBeacon\nWhen selected, sends location data every 10 minutes. The\nbeacon will automatically stop when you edit personal\ninformation. Must be manually reselected after edit\ncompletion.\n\nAPRS Copyright (c) Bob Bruninga WB4APR\n\n")
+
+ self.statuswindow = gtk.ScrolledWindow()
+ self.statuswindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_ALWAYS)
+ self.statuswindow.add_with_viewport(statusview)
+ statusview.show()
+ rightwin.pack_start(self.statuswindow, True, True, 0)
+ self.statuswindow.show()
+
self.rawbox = gtk.HBox(False, 6)
self.rawtext = gtk.Entry()
self.rawtext.set_max_length(128)
- self.rawtext.set_width_chars(34)
+ self.rawtext.set_width_chars(38)
self.rawtext.modify_font(smallfont)
self.rawtext.connect("activate", self.raw_send)
self.rawbox.pack_start(self.rawtext, False, False, 0)
@@ -557,20 +585,28 @@ class APRSActivity(activity.Activity):
rightwin.pack_start(self.rawbox, False, False, 0)
# only show if aprsd says you are verified
- #rawbox.show()
+ # changed to always available
+ self.rawbox.show()
win.pack_start(rightwin, False, False, 0)
rightwin.show()
win.show()
- def clear_status(self, button):
- self.statusbuffer.delete(self.statusbuffer.get_start_iter(), self.statusbuffer.get_end_iter())
+ def clear_status(self, button=None):
+# self.statusbuffer.delete(self.statusbuffer.get_start_iter(), self.statusbuffer.get_end_iter())
+ self.statusbuffer.set_text("")
+
+ def clear_message(self, button=None):
+# self.messagebuffer.delete(self.messagebuffer.get_start_iter(), self.messagebuffer.get_end_iter())
+ self.messagebuffer.set_text("")
def connect_aprs(self, button):
- if (self.validate_data() == False):
- return False
if (self.sock == None):
+ self.clear_message()
+ self.clear_status()
+ if (self.validate_data() == False):
+ return False
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.status_write("Connecting ")
iplist = socket.gethostbyname_ex(HOST)[2]
@@ -590,7 +626,11 @@ class APRSActivity(activity.Activity):
response = self.sock.recv(RECV_BUFFER)
self.status_write("%s" % response)
if (response.find("javAPRSSrvr") == -1):
- self.status_write("invalid response.")
+ self.status_write("invalid response.\n")
+ self.disconnect_aprs(button)
+
+ if (response.find("Port Full") != -1):
+ self.status_write("Port Full.\n")
self.disconnect_aprs(button)
# hidden feature
@@ -605,10 +645,10 @@ class APRSActivity(activity.Activity):
response = self.sock.recv(RECV_BUFFER)
self.status_write("%s" % response)
if (response.find("# logresp") == -1):
- self.status_write("invalid response.")
+ self.status_write("invalid response.\n")
self.disconnect_aprs(button)
- if (response.find("unverified") == -1):
- self.rawbox.show()
+# if (response.find("unverified") == -1):
+# self.rawbox.show()
self.input_watch = gobject.io_add_watch(self.sock, gobject.IO_IN, self.recv_data)
@@ -637,7 +677,7 @@ class APRSActivity(activity.Activity):
self.status_write("Disconnected\n")
button.set_label("Connect")
button.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#00b20d"))
- self.rawbox.hide()
+# self.rawbox.hide()
def recv_data(self, sock, condition):
while 1:
@@ -650,7 +690,18 @@ class APRSActivity(activity.Activity):
self.status_write("Server closed connection.\n")
return False
else:
- self.status_write(recv_data)
+# self.status_write(recv_data)
+
+ # for now just cut the line at the first ":"
+ cuthere = recv_data.find(":")
+ self.status_write("%s\n" % recv_data[:cuthere+1])
+
+ # some incoming lines end in \n and some do not
+ if (recv_data[-1:] == "\n"):
+ self.status_write("%s\n" % recv_data[cuthere+1:])
+ else:
+ self.status_write("%s\n\n" % recv_data[cuthere+1:])
+
self.msg_check(recv_data)
return True
@@ -675,7 +726,7 @@ class APRSActivity(activity.Activity):
self.status_write("Problem sending message\n")
self.sock = None
return False
- self.status_write("%s" % text)
+ self.status_write("%s\n" % text)
return True
def send_ack(self, msg):
@@ -684,9 +735,18 @@ class APRSActivity(activity.Activity):
def status_write(self, text):
self.statusbuffer.insert(self.statusbuffer.get_end_iter(), text)
+ statuslines = self.statusbuffer.get_line_count()
+ if (statuslines > MAXLINES):
+ deletehere = self.statusbuffer.get_iter_at_line(statuslines - MAXLINES)
+ self.statusbuffer.delete(self.statusbuffer.get_start_iter(), deletehere)
adjustment = self.statuswindow.get_vadjustment()
adjustment.set_value(adjustment.upper)
+ def message_write(self, text):
+ self.messagebuffer.insert(self.messagebuffer.get_end_iter(), text)
+ adjustment = self.messagewindow.get_vadjustment()
+ adjustment.set_value(adjustment.upper)
+
def set_location(self, widget, data=None):
self.location = data
@@ -869,6 +929,7 @@ class APRSActivity(activity.Activity):
def msg_check(self, data):
# a quick "does it look like a message?" check
+ # this check will only find messages that require acks
firstcheck = data.find("::")
secondcheck = data.find("{")
if (firstcheck != -1 and secondcheck != -1):
@@ -881,13 +942,15 @@ class APRSActivity(activity.Activity):
else:
sequence = data[secondcheck+1:sequence_end]
fromcall = data[:data.find(">")]
- message = ":%s:ack%s" % (fromcall, sequence)
- self.send_data(message)
+ message = data[firstcheck+12:secondcheck]
+ self.message_write("%s> %s" % (fromcall, message))
+ ackmessage = ":%s:ack%s" % (fromcall, sequence)
+ self.send_data(ackmessage)
id = "%s-%s" % (fromcall, sequence)
if (id in self.sent_acks):
- self.timers.append(gobject.timeout_add(30 * 1000, self.send_ack, message))
- self.timers.append(gobject.timeout_add(60 * 1000, self.send_ack, message))
- self.timers.append(gobject.timeout_add(120 * 1000, self.send_ack, message))
+ self.timers.append(gobject.timeout_add(30 * 1000, self.send_ack, ackmessage))
+ self.timers.append(gobject.timeout_add(60 * 1000, self.send_ack, ackmessage))
+ self.timers.append(gobject.timeout_add(120 * 1000, self.send_ack, ackmessage))
self.sent_acks[id] = time.time() # to help a cleanup thread later
self.sent_acks[fromcall] = sequence # to help with reply acks later