# Somehow senders can be configured.
# e.g. sms-exetel needs username, password, sender strings.
# press-and-hold on the send button allows a sender to be selected.
-#
+#
#
# Send an SMS message using some backend.
-#
+#
#
# TODO:
# 'del' to return to 'list' view
# new message becomes non-new when replied to
# '<list>' button doesn't select, but just makes choice.
# 'new' becomes 'select' when <list> has been pressed.
-# DONE Start in 'read', preferrably 'new'
+# DONE Start in 'read', preferrably 'new'
# DONE always report status from send
# DONE draft/new/recv/sent/all - 5 groups
# DONE allow scrolling through list
# Writing recognistion code
import math
-
def LoadDict(dict):
# Upper case.
# Where they are like lowercase, we either double
dict.add("<right>","S(4)1,7.S(7)7,1") # "<down>"
dict.add("<newline>", "S(4)2,6")
-
class DictSegment:
# Each segment has for elements:
# direction: Right Straight Left (R=cw, L=ccw)
cnt += m
return cnt
-
class Dictionary:
# The dictionary hold all the pattern for symbols and
# performs lookup
if pos == "bot": return bot
return mid
-
class Point:
# This represents a point in the path and all the points leading
# up to it. It allows us to find the direction and curvature from
y = 1
return y*3 + x
-
def different(*args):
cur = 0
for i in args:
t += t1 + '.'
return t[:-1]
-
class text_input:
def __init__(self, page, callout):
def set_colour(self, col):
self.colour = col
-
+
def press(self, c, ev):
if not self.active:
return
print "Failed to match pattern:", patn
return sym
-
-
-
-
########################################################################
-
-
class FingerText(gtk.TextView):
def __init__(self):
gtk.TextView.__init__(self)
def insert_at_cursor(self, text):
self.get_buffer().insert_at_cursor(text)
-
+
class FingerEntry(gtk.Entry):
def __init__(self):
gtk.Entry.__init__(self)
self.connect("expose-event", self.redraw)
self.connect("configure-event", self.reconfig)
-
+
self.connect("button_release_event", self.release)
self.connect("button_press_event", self.press)
self.set_events(gtk.gdk.EXPOSURE_MASK
self.queue_draw()
-
def set_book(self, book):
self.book = book
self.width, self.lineheight)
self.draw_sms(self.smslist[i], (i - self.top) * self.lineheight)
-
def draw_sms(self, sms, yoff):
-
+
self.modify_font(self.smallfont)
tm = time.strftime("%Y-%m-%d %H:%M:%S", sms.time[0:6]+(0,0,0))
then = time.mktime(sms.time[0:6]+(0,0,-1))
self.top = 0
self.refresh()
-
+
def release(self,w,ev):
pass
cnt += 1
name = name[0:-1]
return book_lookup(book, name, cnt)
-
-
def book_name(book, num):
if len(num) < 8:
self.set_title("SendSMS")
self.store = store
self.connect('destroy', self.close_win)
-
+
self.selecting = False
self.viewing = False
self.book = None
l.modify_font(self.button_font)
l.show()
h.pack_start(l, expand=False)
-
+
self.numentry = FingerEntry()
h.pack_start(self.numentry)
self.numentry.modify_font(self.button_font)
h.pack_end(b, expand=False)
l = gtk.Label('search:') ; l.show()
h.pack_start(l, expand=False)
-
+
e = gtk.Entry() ; e.show()
self.search_entry = e
h.pack_start(e)
self.listview.assign_colour('bg-0', 'yellow')
self.listview.assign_colour('bg-1', 'pink')
self.listview.assign_colour('bg-selected', 'white')
-
+
self.listbox = gtk.VBox()
self.listbox.add(self.listview)
v.add(self.listbox)
self.listbox.show()
-
bb = gtk.HBox() ; bb.show()
bb.set_size_request(-1,80)
bb.set_homogeneous(True)
self.buttonA = self.add_button(bb, 'Sent', self.rotate_list, 'A')
self.buttonB = self.add_button(bb, 'Recv', self.rotate_list, 'B')
-
self.last_response = gtk.Label('')
self.listbox.pack_end(self.last_response, expand = False)
self.listview.set_book(self.book)
e = name_lookup(self.book, n)
if e and e[1]:
- self.to_label.set_text(e[1] +
+ self.to_label.set_text(e[1] +
' '+
e[0])
self.number = e[0]
else:
self.cutbuffer = w.get_text()
w.set_text('')
-
+
def paste(self, *a):
w = self.get_toplevel().get_focus()
if w == None:
for l in p.stdout:
if l:
line = l
-
+
s = SMSmesg(to = recipient, text = mesg)
if rv or line[0:2] != 'OK':
self.reply.child.set_text('Open')
else:
self.reply.child.set_text('Reply')
-
+
def open(self, *a):
if self.viewing:
if len(self.listview.smslist) < 1:
s = self.listview.smslist[self.listview.selected]
if s.state == 'NEW':
self.store.setstate(s, None)
-
+
self.numentry.set_text(s.correspondent)
self.message.get_buffer().set_text(s.text)
self.draft_button.child.set_text('SaveDraft')
elif target == 'Recv' and e.source != 'LOCAL':
l.append(e)
return l
-
+
def rotate_list(self, w=None, ev=None, which = None, target=None):
# lists are:
# All, Recv, New, Sent, Draft
if target == 'New':
self.buttonA.child.set_text('All')
self.buttonB.child.set_text('Recv')
-
+
self.display_list = target
self.listview.reset_list()
c.set_with_data([(gtk.gdk.SELECTION_TYPE_STRING, 0, 0)],
clip_get_data, clip_clear_data, None)
-
-
def main(args):
for p in ['/data','/media/card','/var/tmp']:
if os.path.exists(p):