[Nym3-commit] r294 - in trunk/nym3: . Client
jr at conuropsis.org
jr at conuropsis.org
Sun Jun 12 01:47:14 CEST 2005
Author: jr
Date: 2005-06-12 01:47:13 +0200 (Sun, 12 Jun 2005)
New Revision: 294
Modified:
trunk/nym3/Client/Main.py
trunk/nym3/TODO
Log:
add journal references capabilities and a way to resend commands
Modified: trunk/nym3/Client/Main.py
===================================================================
--- trunk/nym3/Client/Main.py 2005-06-11 13:49:53 UTC (rev 293)
+++ trunk/nym3/Client/Main.py 2005-06-11 23:47:13 UTC (rev 294)
@@ -164,10 +164,23 @@
def build_mbox_index(account):
"""Builds the index of the mbox of the given account. Returns a hash
- containing the correspondance index -> mid, index has a str"""
+ containing the correspondance index -> mid, index as a str"""
mbox, index = account.get_mbox()
return dict([(str(i), j) for (i, j) in enumerate(index)])
+def build_journal_index(ui, config, account):
+ """Builds the index of the journal of the given account. Returns a hash
+ containing the correspondance index -> seqno, index as a str"""
+ journal = account.get_journal()
+ secring = decode_secring(config, ui)
+ key = secring.get_key(account['journalKey'])
+ l = []
+ for seqno in journal.keys():
+ clear = _cr.pk_decrypt(journal[seqno], key)
+ m, t = pickle.loads(clear)
+ l.append((seqno, m, t))
+ l.sort(journal_time_cmp)
+ return dict([(str(i), s) for (i, (s, m, t)) in enumerate(l)])
def is_hex_mid(s):
try:
@@ -488,6 +501,29 @@
idKey = _cr.pk_decode_private_key(secring.get_key(account['idKey']))
account.sendControl([getmsg], idKey)
+def resend_command(ui, config, nickname = None, seqnolist = None):
+ #TODO avoid the double input of passwd (in build_journal_index and
+ #decode_secring)
+ account = get_account_from_nickname(ui, config, nickname,
+ "No nickname given, abort\nUse -n <nickname>")
+ try:
+ #TODO ! this works only because seqNoLength == midLength
+ #modify the sugnature of decode message to take the length of
+ #the items to decode as an argument?
+ seqnolist = decode_message_references(seqnolist, ['journal'],
+ {'journal': (build_journal_index, (ui, config, account))})
+ except DecodeException, inst:
+ ui.display(str(inst))
+ sys.exit(1)
+ secring = decode_secring(config, ui)
+ key = secring.get_key(account['journalKey'])
+ for seqno in seqnolist:
+ clear = _cr.pk_decrypt(journal[seqno], key)
+ m, t = pickle.loads(clear)
+ account.send(m)
+ account.record(seqno, m)
+ ui.display("resend message seqno: %s" % binascii.hexlify(seqno))
+
def SendSurb(ui, config, nickname = None, number = 42):
account = get_account_from_nickname(ui, config, nickname,
"No nickname given, abort\nUse -n <nickname>")
@@ -589,8 +625,6 @@
#TODO display the content of the command
#ui.display()
-
-
def export(ui, config, nickname, output = None, args = []):
account = get_account_from_nickname(ui, config, nickname,
"No nickname given, abort\nUse -n <nickname>")
@@ -792,6 +826,18 @@
list_journal(ui, config, options.nickname)
sys.exit(0)
+ if args[1] == "resend-command":
+ parser = OptionParser()
+ parser.add_option("-n", "--nickname", action = "store",
+ dest = "nickname", help = "The nickname "
+ "of the account whose emails to request")
+ (options, args) = parser.parse_args(args[2:])
+ ui = CLI()
+ config = Config.Config()
+ resend_command(ui, config, options.nickname, args)
+ sys.exit(0)
+
+
if args[1] == "export":
parser = OptionParser()
parser.add_option("-n", "--nickname", action = "store",
Modified: trunk/nym3/TODO
===================================================================
--- trunk/nym3/TODO 2005-06-11 13:49:53 UTC (rev 293)
+++ trunk/nym3/TODO 2005-06-11 23:47:13 UTC (rev 294)
@@ -11,7 +11,7 @@
- use clean_surbs once in a while [server]
- periodically scans for emails that need to be relayed [server]
- use `email' lib to fiddle with an email to relay [server]
- - provide a `list-journal' command and a way to resend commands [client]
+ o provide a `list-journal' command and a way to resend commands [client]
doc:
- add doc strings in __init__.py in every module.
More information about the Nym3-commit
mailing list