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

laurent at conuropsis.org laurent at conuropsis.org
Mon Sep 26 22:09:09 CEST 2005


Author: laurent
Date: 2005-09-26 22:09:08 +0200 (Mon, 26 Sep 2005)
New Revision: 310

Modified:
   trunk/nymbaron/Client/Main.py
Log:
Add direct mixminion message processing capability in the client.


Modified: trunk/nymbaron/Client/Main.py
===================================================================
--- trunk/nymbaron/Client/Main.py	2005-09-26 20:07:49 UTC (rev 309)
+++ trunk/nymbaron/Client/Main.py	2005-09-26 20:09:08 UTC (rev 310)
@@ -44,6 +44,7 @@
 import nymbaron.Client.Keyring as Keyring
 import mixminion.Crypto as _cr
 import mixminion.ClientDirectory as _cl
+import tempfile
 
 usage_string = """Usage: nym3 <command> [arguments]
 where <command> is one of:
@@ -53,6 +54,7 @@
     \tdelete\t\tRequest email deletion
     \tget\t\tRetrieve email
     \tprocess\t\tProcess returning server messages
+    \tmprocess\tProcess returning minion messages
     \tlist-syn\tList already fetched summaries
     \tdump-syn\tDump already fetched summaries
     \tlist-mbox\tList already fetched emails
@@ -62,7 +64,7 @@
     \texport\t\tExport already fetched emails to a file
     \tresend-command\tResend a command that has been sent but not acknowledged
     \t\t\tyet
-    \tldelete\tDelete messages from the local mbox
+    \tldelete\t\tDelete messages from the local mbox
     \tldelete-syn\tDelete synopses from the local synbox"""
 
 class CLI:
@@ -851,6 +853,35 @@
 	ldelete_syn(ui, config, options.nickname, args)
 	sys.exit(0)
 
+    if args[1] == "mprocess":
+	parser = OptionParser()
+	parser.add_option("-f", "--file", action = "store",
+			  dest = "file", help = "The file to read the message"
+			  " from, or stdin if omitted")
+	(options, args) = parser.parse_args(args[2:])
+	ui = CLI()
+	config = Config.Config() # TODO load from file
+	if options.file:
+	    try:
+		f = open(options.file, "r")
+		msg = f.read()
+		f.close()
+	    except IOError:
+		ui.display("Can't read requested file")
+		sys.exit(1)
+	else: msg = sys.stdin.read()
+	(fd, name) = tempfile.mkstemp()
+	os.write(fd, msg)
+	os.close(fd)
+	pp = ui.prompthidden("Please enter your mixminion passphrase")
+	(fdo, nameo) = tempfile.mkstemp()
+	id = minion_decode(name, nameo, pp)
+	tm = Account.TagMap(config.path + os.sep + 'tagmap')
+	# TODO : id is forced lowercase by mixminion.
+	print id
+	nick = tm.nickFromId(id)
+	processMessage(nameo, config, ui, nick)
+	sys.exit(0)
 
 def minion_decode(input, output, passphrase):
     (outr, outw) = os.pipe()



More information about the Nym3-commit mailing list