summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaromil <jaromil@dyne.org>2017-03-14 07:03:03 (GMT)
committer Jaromil <jaromil@dyne.org>2017-03-14 07:03:03 (GMT)
commit5337b3a3eb059bedc6a0c5adad80582201f5cfa2 (patch)
tree688ef8c180467f690225a70a0e90c2aaf2dbeefc
parent16a454b77e5b0e23899e7d499cebe2b598c02f31 (diff)
attempts at having interactive imap consoleimap-console
-rwxr-xr-xsrc/jaro35
-rwxr-xr-xsrc/zlibs/imap32
2 files changed, 57 insertions, 10 deletions
diff --git a/src/jaro b/src/jaro
index 5875da9..476fcfa 100755
--- a/src/jaro
+++ b/src/jaro
@@ -850,17 +850,32 @@ s/\*/\\*/g
imap)
imapcmd="$1"
+ read_account $account
+ host=${imap:-$host}
+ ask_password
+
case $1 in
- console)
- read_account $account
- host=${imap:-$host}
- ask_password
- func "$login $password"
- cat <<EOF | run_imap_query
-B00000 CAPABILITY
-B00001 LOGIN "${login}" "${password}"
+ -) imap_console ;;
+
+ headlines)
+ local folder=${2:-"INBOX"}
+ rawheads=""
+ cat <<EOF | imap_run_command
+SELECT "$folder"
+FETCH 1:* (body[header.fields (from subject date)])
EOF
- ;;
+
+# | awk '
+# BEGIN { out=0 }
+# /^CMD_/ { next }
+# /^*/ { out=1; next }
+# /^)/ { out=0; next }
+# { if(out==1) print $0 }'
+
+ for i in ${(f)rawheads}; do
+ act $i
+ done
+ ;;
getsize)
read_account $account
host=${imap:-$host}
@@ -890,7 +905,7 @@ EOF
# exitcode=$?
# ;;
*)
- error "imap needs a subcommand: getsize or listfolders"
+ error "imap needs a subcommand: getsize, listfolders or command"
;;
esac
;;
diff --git a/src/zlibs/imap b/src/zlibs/imap
index b8edab8..63cd986 100755
--- a/src/zlibs/imap
+++ b/src/zlibs/imap
@@ -58,6 +58,38 @@ check_imap() {
return 1 }
}
+imap_console() {
+ fn imap_console $*
+ check_imap && return 1
+ rlwrap -I -z /usr/share/rlwrap/filters/count_in_prompt openssl s_client -crlf -quiet -connect ${imap}:${imap_port}
+}
+imap_run_command() {
+ fn imap_run_command $*
+ check_imap && return 1
+ local rawcmd
+ local cmd
+ rawcmd=`cat`
+ c=2
+ for i in ${(f)rawcmd}; do
+ [[ "$i" = "" ]] && continue
+ cmd+="CMD_$c $i\r\n"
+ (( c = $c + 1 ))
+ done
+ [[ "$cmd" = "" ]] && {
+ error "No command specified, aborting operation."
+ return 1 }
+ func "imap commands:
+$cmd
+CMD_$c LOGOUT"
+ cat <<EOF | run_imap_query
+CMD_0 CAPABILITY
+CMD_1 LOGIN "${login}" "${password}"
+${cmd}CMD_$c LOGOUT
+EOF
+
+}
+
+
imap_list_folders() {
fn imap_list_folders $*
check_imap && return 1