[Nym3-commit] r210 - trunk/nym3/Client
laurent at conuropsis.org
laurent at conuropsis.org
Sun May 1 16:30:15 CEST 2005
Author: laurent
Date: 2005-05-01 16:30:13 +0200 (Sun, 01 May 2005)
New Revision: 210
Modified:
trunk/nym3/Client/Config.py
trunk/nym3/Client/Main.py
Log:
Add client command SUMMARIZE.
Modified: trunk/nym3/Client/Config.py
===================================================================
--- trunk/nym3/Client/Config.py 2005-04-30 15:40:27 UTC (rev 209)
+++ trunk/nym3/Client/Config.py 2005-05-01 14:30:13 UTC (rev 210)
@@ -43,5 +43,8 @@
self.idkey_length = 2048
self.enckey_length = 2048
+ # Default maximum number of synopsis to request in SUMMARIZE command
+ self.max_syn = 42
+
def load_from_file(self, filename):
pass
Modified: trunk/nym3/Client/Main.py
===================================================================
--- trunk/nym3/Client/Main.py 2005-04-30 15:40:27 UTC (rev 209)
+++ trunk/nym3/Client/Main.py 2005-05-01 14:30:13 UTC (rev 210)
@@ -28,6 +28,7 @@
import sys
import os
import string
+import binascii
import termios
from optparse import OptionParser, make_option
from nym3.Message import SToCCODE
@@ -107,8 +108,8 @@
account['used'] = com.used
#remove from the journal the acknowledged messages
account.acknowledge(com.acks)
- #raise some warnings
- #exec some automatic actions and warn the user
+ # TODO raise some warnings, exec some automatic actions and warn
+ # the user
elif (com.ct() == SToCCODE['Summary']):
pass
elif (com.ct() == SToCCODE['Msg']):
@@ -247,6 +248,36 @@
idKey = _cr.pk_decode_private_key(secring.get_key(account['idKey']))
account.sendControl([relayc], idKey)
+def Summarize(ui, config, nickname = None, max = None, older = None):
+ if not max: max = config.max_syn
+ if older: older = binascii.unhexlify(older)
+ else: older = chr(0) * 20
+
+ if not nickname:
+ ui.display("No nickname given, abort")
+ ui.display("Use -n <nickname>")
+ sys.exit(1)
+ account = None
+ try:
+ account = Account.Account(config, nickname)
+ except Account.NoSuchAccount:
+ ui.display("No account relative to the provided nickname, abort")
+ sys.exit(1)
+ summ = Message.Summarize()
+ summ.fromData(max, older)
+ try:
+ secring = Keyring.Keyring(config.secring_path)
+ ui.display("You need to provide your passphrase to unlock your keyring")
+ while True:
+ passphrase1 = ui.prompthidden("Passphrase")
+ if secring.decrypt(passphrase1): break
+ ui.display("wrong passphrase")
+ except Keyring.NewKeyring:
+ # 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)
+
def main(args):
if len(args) < 2:
print "Usage: WRITEME"
@@ -282,8 +313,7 @@
dest = "nickname", help = "The nickname refering "
"to the account used to send a message")
parser.add_option("-t", "--to", help = "Specify the recipient's "
- "address", action = "store",
- dest = "to")
+ "address", action = "store", dest = "to")
parser.add_option("-i", "--input", action = "store",
dest = "input", help = "The file to read the message "
"from (defaults to stdin)")
@@ -293,6 +323,23 @@
relayMessage(ui, config, options.nickname, options.to, options.input)
sys.exit(0)
+ if args[1] == "summarize":
+ parser = OptionParser()
+ parser.add_option("-n", "--nickname", action = "store",
+ dest = "nickname", help = "The nickname "
+ "of the account whose summaries to request")
+ parser.add_option("-m", "--max", action = "store",
+ dest = "max", help = "Maximum number of summaries"
+ " to request")
+ parser.add_option("-o", "--older", action = "store",
+ dest = "older", help = "Retrieve only summaries "
+ "older than msgid")
+ (options, args) = parser.parse_args(args[2:])
+ ui = CLI()
+ config = Config.Config()
+ Summarize(ui, config, options.nickname, options.max, options.older)
+ sys.exit(0)
+
if args[1] == "process":
parser = OptionParser()
parser.add_option("-i", "--idtag", action = "store",
More information about the Nym3-commit
mailing list