[Nym3-commit] r325 - trunk/nymbaron/Client

jr at conuropsis.org jr at conuropsis.org
Sat Oct 8 18:59:09 CEST 2005


Author: jr
Date: 2005-10-08 18:59:08 +0200 (Sat, 08 Oct 2005)
New Revision: 325

Modified:
   trunk/nymbaron/Client/Account.py
   trunk/nymbaron/Client/Main.py
Log:
- add a description string to the journal items


Modified: trunk/nymbaron/Client/Account.py
===================================================================
--- trunk/nymbaron/Client/Account.py	2005-10-08 15:40:12 UTC (rev 324)
+++ trunk/nymbaron/Client/Account.py	2005-10-08 16:59:08 UTC (rev 325)
@@ -285,14 +285,14 @@
 	"""Gets the home directory of this account"""
         return self.base_path
 
-    def sendControl(self, l, idKey):
+    def sendControl(self, l, idKey, desc):
 	"""Sends a list of command messages to the nymserver"""
         msg = Message.buildMessage(l)
 	seqno = self.get_seqno()
 	#TODO debugging cruft
 	print "send message: %s" % binascii.hexlify(seqno)
         hdr = self.buildHeader(msg, seqno, idKey)
-	self.record(seqno, hdr + msg)
+	self.record(seqno, hdr + msg, desc)
 	self.send(hdr + msg)
 
     def buildHeader(self, msg, seqno, idKey):
@@ -308,10 +308,10 @@
 	pubring.decrypt("nymbaron")
 	return pubring.get_key(self['admKey'])
     
-    def record(self, seqno, msg):
+    def record(self, seqno, msg, desc):
 	"""Store a control message in the journal"""
 	if self.journal_status == 'unloaded': self._load_journal()
-	clear = pickle.dumps((msg, int(time.time())))
+	clear = pickle.dumps((msg, int(time.time()), desc))
 	key = self.get_admPubKey()
 	self.journal[seqno] = Crypto.nym_encrypt(clear, key)
 	self.journal_status = 'dirty'

Modified: trunk/nymbaron/Client/Main.py
===================================================================
--- trunk/nymbaron/Client/Main.py	2005-10-08 15:40:12 UTC (rev 324)
+++ trunk/nymbaron/Client/Main.py	2005-10-08 16:59:08 UTC (rev 325)
@@ -175,10 +175,10 @@
     l = []
     for seqno in journal.keys():
 	clear = Crypto.nym_decrypt(journal[seqno], key)
-	m, t = pickle.loads(clear)
-	l.append((seqno, m, t))
+	m, t, d = pickle.loads(clear)
+	l.append((seqno, m, t, d))
     l.sort(journal_time_cmp)
-    return dict([(str(i), s) for (i, (s, m, t)) in enumerate(l)])
+    return dict([(str(i), s) for (i, (s, m, t, d)) in enumerate(l)])
 
 def is_hex_mid(s):
     try:
@@ -382,7 +382,7 @@
     newpkc.fromData(idKey, encKey)
     surbc = Message.Surb()
     surbc.fromData(account.generateSurbs(7))
-    account.sendControl([createc, newpkc, surbc], idKey)
+    account.sendControl([createc, newpkc, surbc], idKey, "create an account")
     account['handshake'] = "initiated"
 
 def relayMessage(ui, config, nickname = None, to = None, input = None):
@@ -423,7 +423,7 @@
 	# The Keyring is new. That shouldn't happen
 	raise Exception('Bug keyring?')
     idKey = _cr.pk_decode_private_key(secring.get_key(account['idKey']))
-    account.sendControl([relayc], idKey)
+    account.sendControl([relayc], idKey, "send an email")
 
 def Summarize(ui, config, nickname = None, max = None, older = None):
     if not max: max = config.max_syn
@@ -457,7 +457,7 @@
 	# The Keyring is new. That shouldn't happen
 	raise Exception('Bug keyring?')
     idKey = _cr.pk_decode_private_key(secring.get_key(account['idKey']))
-    account.sendControl([summ], idKey)
+    account.sendControl([summ], idKey, "request summaries")
 
 def Delete(ui, config, nickname = None, midlist = None):
     account = get_account_from_nickname(ui, config, nickname,
@@ -483,7 +483,7 @@
 	# The Keyring is new. That shouldn't happen
 	raise Exception('Bug keyring?')
     idKey = _cr.pk_decode_private_key(secring.get_key(account['idKey']))
-    account.sendControl([delmsg], idKey)
+    account.sendControl([delmsg], idKey, "delete messages")
 
 def Get(ui, config, nickname = None, midlist = None):
     account = get_account_from_nickname(ui, config, nickname,
@@ -509,7 +509,7 @@
 	# The Keyring is new. That shouldn't happen
 	raise Exception('Bug keyring?')
     idKey = _cr.pk_decode_private_key(secring.get_key(account['idKey']))
-    account.sendControl([getmsg], idKey)
+    account.sendControl([getmsg], idKey, "get messages")
 
 def resend_command(ui, config, nickname = None, seqnolist = None):
     account = get_account_from_nickname(ui, config, nickname,
@@ -531,9 +531,9 @@
     journal = account.get_journal()
     for seqno in seqnolist:
 	clear = Crypto.nym_decrypt(journal[seqno], key)
-	m, t = pickle.loads(clear)
+	m, t, d = pickle.loads(clear)
 	account.send(m)
-	account.record(seqno, m)
+	account.record(seqno, m, d)
 	ui.display("resend message seqno: %s" % binascii.hexlify(seqno))
     
 def SendSurb(ui, config, nickname = None, number = None):
@@ -548,7 +548,7 @@
     idKey = _cr.pk_decode_private_key(secring.get_key(account['idKey']))
     surbc = Message.Surb()
     surbc.fromData(account.generateSurbs(number))
-    account.sendControl([surbc], idKey)
+    account.sendControl([surbc], idKey, "send surbs")
 
 def list_syn(ui, config, nickname = None, summarize = True):
     account = get_account_from_nickname(ui, config, nickname,
@@ -580,8 +580,8 @@
 	ui.display(Mail.syn_summary(clear))
 
 def journal_time_cmp(a, b):
-    seqnoa, msga, ta = a
-    seqnob, msgb, tb = b
+    seqnoa, msga, ta, da = a
+    seqnob, msgb, tb, db = b
     return ta < tb
 
 def list_journal(ui, config, nickname = None):
@@ -593,11 +593,11 @@
     l = []
     for seqno in journal.keys():
 	clear = Crypto.nym_decrypt(journal[seqno], key)
-	m, t = pickle.loads(clear)
-	l.append((seqno, m, t))
+	m, t, d = pickle.loads(clear)
+	l.append((seqno, m, t, d))
     l.sort(journal_time_cmp)
-    for i, (s, m, t) in enumerate(l):
-	ui.display("%d %s %s" % (i, binascii.hexlify(s), str(t)))
+    for i, (s, m, t, d) in enumerate(l):
+	ui.display("%d %s %s %s" % (i, binascii.hexlify(s), str(t), d))
 	#TODO display the content of the command
 	#ui.display()
 



More information about the Nym3-commit mailing list