diff options
author | Jack Zielke <kg4gjy@takeovertheworld.org> | 2009-05-26 05:19:45 (GMT) |
---|---|---|
committer | Jack Zielke <kg4gjy@takeovertheworld.org> | 2009-05-26 05:19:45 (GMT) |
commit | af07e062dae12e1829def7aff83e6adb6f30069e (patch) | |
tree | 69fc96f09613fa1d7f663c4d9dc2ac1b0e90b97d | |
parent | 5c3d687cd64e5f29c01702a0e01939e5ee4c4c6c (diff) |
version 11 - auto generate passwords, better bolding (NWS messages)
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | activity/activity.info | 2 | ||||
-rwxr-xr-x | aprs.py | 93 |
3 files changed, 84 insertions, 12 deletions
@@ -9,3 +9,4 @@ October 18 2008 - version 7 - no journal, ack bugfix October 18 2008 - version 8 - no journal, 8.2.0 update November 9 2008 - version 9 - journal works, message text in bold, scroll bugfix November 22 2008 - version 10 - changed journal, old messages are bolded on load +December 29 2008 - version 11 - auto generate passwords, better bolding (NWS messages) diff --git a/activity/activity.info b/activity/activity.info index d609e41..2f265b0 100644 --- a/activity/activity.info +++ b/activity/activity.info @@ -1,6 +1,6 @@ [Activity] name = APRS-XO -activity_version = 10 +activity_version = 11 service_name = org.laptop.APRSXO icon = activity-aprs-xo exec = sugar-activity aprs.APRSActivity @@ -164,7 +164,7 @@ class APRSActivity(activity.Activity): identbox.pack_start(identlabel, False, False, 0) identlabel.show() - bottomidentbox = gtk.HBox(False, 10) + bottomidentbox = gtk.HBox(False, 5) calllabel1 = gtk.Label("Callsign: ") calllabel1.set_alignment(1, 0.5) @@ -192,11 +192,34 @@ class APRSActivity(activity.Activity): bottomidentbox.pack_start(self.passtext, False, False, 0) self.passtext.show() + self.passbutton = gtk.CheckButton() + self.passbutton.set_active(True) + self.passbutton.connect("toggled", self.hide_password, "password") + bottomidentbox.pack_start(self.passbutton, False, False, 0) + self.passbutton.show() + + passbuttonbox = gtk.VBox(False, 0) + + passlabel3 = gtk.Label("Hide") + passlabel3.set_alignment(0.5, 0.5) + passlabel3.modify_font(smallfont) + passbuttonbox.pack_start(passlabel3, False, False, 0) + passlabel3.show() + + passlabel4 = gtk.Label("Password") + passlabel4.set_alignment(0, 0.5) + passlabel4.modify_font(smallfont) + passbuttonbox.pack_start(passlabel4, False, False, 0) + passlabel4.show() + + bottomidentbox.pack_start(passbuttonbox, False, False, 0) + passbuttonbox.show() + identbox.pack_start(bottomidentbox, False, False, 0) bottomidentbox.show() passlabel2 = gtk.Label("optional") - passlabel2.set_alignment(0.74, 0) + passlabel2.set_alignment(0.71, 0) passlabel2.modify_font(smallfont) identbox.pack_start(passlabel2, False, False, 0) passlabel2.show() @@ -427,7 +450,7 @@ class APRSActivity(activity.Activity): self.messageview.set_justification(gtk.JUSTIFY_LEFT) self.messageview.modify_font(smallfont) - self.messagebuffer.set_text("Welcome to APRS-XO.\n\nThis program sends your position information to a server that\nwill display your location on a webpage. This program requires an active Internet connection to work.\n\nSelect an APRS Site\nSelecting a button will copy the URI to the clipboard.\n\nIndentifiers\nEnter your callsign and optionally an aprsd password.\n\nStation Comment\nData in the Station Comment field will appear after your\nlocation information on the website.") + self.messagebuffer.set_text("Welcome to APRS-XO.\n\nThis program sends your position information to a server that\nwill display your location on a webpage. This program requires an active Internet connection to work.\n\nSelect an APRS Site\nSelecting a button will copy the URI to the clipboard.\n\nIndentifiers\nEnter your callsign. If you leave the password blank it will be\nautomatically generated.\n\nStation Comment\nData in the Station Comment field will appear after your\nlocation information on the website.") # tags for easier reading of messages self.messagebold = self.messagebuffer.create_tag("bold", weight=pango.WEIGHT_BOLD) @@ -730,11 +753,11 @@ class APRSActivity(activity.Activity): self.messagebuffer.insert(iter, text) if (bold): bold_end = iter.copy() - bold_start = iter.copy() bold_end.forward_to_line_end() - bold_start = bold_end.backward_search(">", gtk.TEXT_SEARCH_TEXT_ONLY) - bold_start[0].forward_chars(2) - self.messagebuffer.apply_tag(self.messagebold, bold_start[0], bold_end) + bold_start = bold_end.copy() + bold_start.backward_chars(len(text)) + bold_start = bold_start.forward_search(">", gtk.TEXT_SEARCH_TEXT_ONLY) + self.messagebuffer.apply_tag(self.messagebold, bold_start[1], bold_end) if (not self.messageview.is_focus()): self.messagebuffer.move_mark_by_name("end", self.messagebuffer.get_end_iter()) @@ -786,6 +809,7 @@ class APRSActivity(activity.Activity): O = random.randrange(0, 9) if (self.calltext.get_text() == ""): self.calltext.set_text("X%s-%d%d" % (self.ziptext.get_text(), A, O)) + self.passtext.set_text("-1") try: (lat, lon, junk) = response.split(',', 2) except: @@ -879,6 +903,8 @@ class APRSActivity(activity.Activity): if (self.lonmmtext.get_text() == "mm"): self.lonmmtext.set_text(" ") self.calltext.set_text(self.calltext.get_text().upper()) + if (self.passtext.get_text() == ""): + self.passtext.set_text(self.aprspass(self.calltext.get_text())) self.beaconbutton.set_active(beaconchecked) self.validating = False @@ -908,6 +934,10 @@ class APRSActivity(activity.Activity): JournalData['beacon'] = 'True' else: JournalData['beacon'] = 'False' + if (self.passbutton.get_active()): + JournalData['hidepass'] = 'True' + else: + JournalData['hidepass'] = 'False' callsignlist = [] model = self.messagecombo.get_model() @@ -949,6 +979,7 @@ class APRSActivity(activity.Activity): lon = "W" stationtext = "" beacon = "True" + hidepass = "True" try: f = open(file_path, 'r') JournalData = json.read(f.read()) @@ -980,6 +1011,8 @@ class APRSActivity(activity.Activity): stationtext = JournalData['stationtext'] if JournalData.has_key('beacon'): beacon = JournalData['beacon'] + if JournalData.has_key('hidepass'): + hidepass = JournalData['hidepass'] except: pass finally: @@ -1018,6 +1051,10 @@ class APRSActivity(activity.Activity): self.beaconbutton.set_active(True) else: self.beaconbutton.set_active(False) + if (hidepass == "True"): + self.passbutton.set_active(True) + else: + self.passbutton.set_active(False) def msg_check(self, data): mycall = self.calltext.get_text().upper() @@ -1420,13 +1457,47 @@ class APRSActivity(activity.Activity): self.message_write("%s\n" % line) iter = self.messagebuffer.get_iter_at_line(self.messagebuffer.get_line_count() - 2) bold_end = iter.copy() - bold_start = iter.copy() bold_end.forward_to_line_end() + bold_start = bold_end.copy() + bold_start.backward_chars(len(line)) + bold_start = bold_start.forward_search(">", gtk.TEXT_SEARCH_TEXT_ONLY) bold_end = bold_end.backward_search("<", gtk.TEXT_SEARCH_TEXT_ONLY) - bold_start = bold_end[0].backward_search(">", gtk.TEXT_SEARCH_TEXT_ONLY) - bold_start[0].forward_chars(2) - self.messagebuffer.apply_tag(self.messagebold, bold_start[0], bold_end[0]) + self.messagebuffer.apply_tag(self.messagebold, bold_start[1], bold_end[0]) else: self.message_write("%s\n" % line, True) else: self.message_write("%s\n" % line) + + def aprspass(self, callsign): + # Note: The doHash(char*) function is Copyright Steve Dimse 1998 + # As of April 11 2000 Steve Dimse has released this code to the open source aprs community + + # remove SSID, trim callsign, convert to upper case + cuthere = callsign.find("-") + if (cuthere != -1): + callsign = callsign[:cuthere] + realcall = callsign[:10].upper() + + if (realcall == "NOCALL"): + return "-1" + + # initialize hash + hash = 0x73e2 + i = 0 + length = len(realcall) + + # hash callsign two bytes at a time + while (i < length): + hash ^= ord(realcall[i])<<8 + if (i+1 < length): + hash ^= ord(realcall[i+1]) + i += 2 + + # convert to string and mask off the high bit so number is always positive + return str(hash & 0x7fff) + + def hide_password(self, widget, data=None): + if (widget.get_active()): + self.passtext.set_visibility(False) + else: + self.passtext.set_visibility(True) |