commit c177c8c3c830eceaf8ba7a4dee2fced7a3f8d776
parent 2280d712cfe88bbfd4551b38f83ad91db46f52b4
Author: Jaromil <jaromil@dyne.org>
Date: Thu, 7 Apr 2016 09:27:56 +0200
fixed imap query system, added imap console
Diffstat:
4 files changed, 52 insertions(+), 36 deletions(-)
diff --git a/src/jaro b/src/jaro
@@ -811,35 +811,47 @@ main() {
imap)
imapcmd="$1"
case $1 in
- getsize)
- read_account $account
- ask_password
- bytes_total=`imap_get_size "$2"`
- exitcode=$?
- notice "Size of account $login on $imap"
- act "$bytes_total bytes"
- mib_total=$(( $bytes_total / 1048576 ))
- act "$mib_total MB (MiB)"
- ;;
- listfolders)
- read_account $account
- ask_password
- folders=(`imap_list_folders`)
- exitcode=$?
- notice "List of folders for $login on $imap"
- for f in $folders; do print - "$f"; done \
- | save_replay $subcommand | column
-
- ;;
- # interactive)
- # read_account
- # ask_password
- # imap_interactive_shell
- # exitcode=$?
- # ;;
- *)
- error "imap needs a subcommand: getsize or listfolders"
- ;;
+ console)
+ read_account $account
+ host=${imap:-$host}
+ ask_password
+ func "$login $password"
+ cat <<EOF | run_imap_query
+B00000 CAPABILITY
+B00001 LOGIN "${login}" "${password}"
+EOF
+ ;;
+ getsize)
+ read_account $account
+ host=${imap:-$host}
+ ask_password
+ bytes_total=`imap_get_size "$2"`
+ exitcode=$?
+ notice "Size of account $login on $imap"
+ act "$bytes_total bytes"
+ mib_total=$(( $bytes_total / 1048576 ))
+ act "$mib_total MB (MiB)"
+ ;;
+ listfolders)
+ read_account $account
+ host=${imap:-$host}
+ ask_password
+ folders=(`imap_list_folders`)
+ exitcode=$?
+ notice "List of folders for $login on $imap"
+ for f in $folders; do print - "$f"; done \
+ | save_replay $subcommand | column
+
+ ;;
+ # interactive)
+ # read_account
+ # ask_password
+ # imap_interactive_shell
+ # exitcode=$?
+ # ;;
+ *)
+ error "imap needs a subcommand: getsize or listfolders"
+ ;;
esac
;;
diff --git a/src/zlibs/accounts b/src/zlibs/accounts
@@ -75,11 +75,14 @@ read_account() {
# check required fields
# falling back to old host/port conf directives
+ imap=${imap:-$host}
+ host=${host:-$imap}
- { test -z $imap } && { imap=$host }
- { test -z $smtp } && { smtp=$imap }
- { test -z $imap_port } && { imap_port=$port }
- { test -z $smtp_port } && { smtp_port=$imap_port }
+ smtp=${smtp:-$host}
+ smtp=${smtp:-$imap}
+
+ imap_port=${imap_port:-$port}
+ smtp_port=${smtp_port:-$imap_port}
# fill in defaults
{ test -z $name } && { name="$type" }
diff --git a/src/zlibs/imap b/src/zlibs/imap
@@ -4,7 +4,7 @@
#
# a tool to easily and privately handle your e-mail communication
#
-# Copyleft (C) 2010-2014 Denis Roio <jaromil@dyne.org>
+# Copyleft (C) 2010-2016 Denis Roio <jaromil@dyne.org>
#
# This source code is free software; you can redistribute it and/or
# modify it under the terms of the GNU Public License as published by
@@ -32,10 +32,10 @@ run_imap_query() {
nc ${imap} ${imap_port} -q 10 2>&1
elif [ "$_trans" = "tls" ]; then
func "running tls imap query via openssl, encrypted"
- openssl s_client -crlf -quiet -connect ${imap}:${imap_port} 2>&1
+ openssl s_client -crlf -quiet -connect ${imap}:${imap_port} 2>&1
elif [ "$_trans" = "ssl" ]; then
func "running ssl imap query via openssl, encrypted"
- openssl s_client -starttls imap -quiet -connect ${imap}:${imap_port} 2>&1
+ openssl s_client -starttls imap -quiet -connect ${imap}:${imap_port} 2>&1
else
error "unknown transport \"$_trans\" for a imap query"
fi
diff --git a/src/zlibs/keyring b/src/zlibs/keyring
@@ -41,6 +41,7 @@ EOF
# up to the caller to unset it after use
ask_password() {
fn ask_password
+
req=(login host email account)
ckreq || return 1