Improve/fix reconnection functionality --> to head
patch d280db07c18bbe0bee399bd33a23c813c6215823
Author: Enrique D. Bosch <presidev@AT@gmail.com>
Date: Tue Dec 4 23:41:31 CET 2018
* Add support for SNI
hunk ./idlebiff 651
+ if {[ info exists conf(sni) ]} { set sni "-servername $conf(sni)" } \
+ else { set sni {} }
hunk ./idlebiff 661
+ $sni \
patch a960193b96b178a92741ceb58850f17b29629c95
Author: Enrique D. Bosch <presidev@AT@gmail.com>
Date: Tue Dec 4 21:12:31 CET 2018
* Simplify parser of configuration file
hunk ./idlebiff 185
- set sep [ string first = $lin ]
- set key [ string range $lin 0 [ - $sep 1 ] ]
- set val [ string range $lin [ + $sep 1 ] end ]
+ set lconf [ split $lin = ]
+ set val [ join [ lassign $lconf key ] = ]
patch 3994fdd764ce973cd13650e4fd820083d9e8b2b5
Author: Enrique D. Bosch <presidev@AT@gmail.com>
Date: Tue Dec 4 20:53:19 CET 2018
* Add title to password dialog
hunk ./idlebiff 148
+ wm title .tl {idlebiff: password}
patch e8534a5cb083b3d82aff297783e2c5d2d683c8d3
Author: Enrique D. Bosch <presidev@AT@gmail.com>
Date: Mon Sep 17 16:50:09 CEST 2018
* Reset client keepalive when server keepalive (untagged "OK still here" like response) is detected
hunk ./idlebiff 515
+ variable ::shared::ka
+ variable ::shared::conf
hunk ./idlebiff 521
- elseif { $idle } { if {[ eq $prim * ]} { idle_cycle $con 1 } } \
+ elseif { $idle } \
+ {
+ if {[ eq $prim * ]} \
+ {
+ if {[ ok_untagged $linea ]} \
+ {
+ after cancel $ka
+ set ka [ after ${conf(keepalive)}000 { idle_cycle $con 0 } ]
+ } \
+ else { idle_cycle $con 1 } \
+ } \
+ } \
patch 0b7e378659f9aec5eff13490775050929649bda2
Author: Enrique D. Bosch <presidev@AT@gmail.com>
Date: Sat Sep 8 21:34:57 CEST 2018
* Set icon to hourglass when the connection is lost and reconnecting
hunk ./idlebiff 234
+ update_img $::shared::img_chk
hunk ./idlebiff 271
+ variable ::shared::img_chk
hunk ./idlebiff 274
+ update_img $img_chk
patch 459541a83671f7510008f6add9eed8e5502ea6d3
Author: Enrique D. Bosch <presidev@AT@gmail.com>
Date: Thu Sep 6 01:00:58 CEST 2018
* Move reset idle to exit_idle
hunk ./idlebiff 356
- if { $idle } \
- {
- set idle 0
- exit_idle $con
- }
+ if { $idle } { exit_idle $con }
hunk ./idlebiff 374
+ variable ::shared::idle
+
+ set idle 0
hunk ./idlebiff 423
- variable ::shared::idle
hunk ./idlebiff 427
- set idle 0
patch bd7e29cb071eb7be716e9bb785540882402845f3
Author: Enrique D. Bosch <presidev@AT@gmail.com>
Date: Wed Sep 5 19:21:16 CEST 2018
* Set icon to hourglass when checking mail (searching) and waiting for logout
hunk ./idlebiff 351
+ variable ::shared::img_chk
hunk ./idlebiff 354
+ update_img $img_chk
hunk ./idlebiff 396
-
+ variable ::shared::img_chk
+
+ update_img $img_chk
patch 54015fb789a93e0b2f72a72ded21190f68fc4f59
Author: Enrique D. Bosch <presidev@AT@gmail.com>
Date: Tue Sep 4 21:38:00 CEST 2018
* Replace question mark icon with hourglass
binary ./check.png
patch 0e5aa389db90fbbc6e6b9515acd3aa92c94731a7
Author: Enrique D. Bosch <presidev@AT@gmail.com>
Date: Tue Sep 4 19:32:19 CEST 2018
* Move non-logout code to cleanup function
hunk ./idlebiff 337
- variable ::shared::ka
- variable ::shared::idle
hunk ./idlebiff 339
- after cancel $ka
- if { $idle } \
- {
- set idle 0
- exit_idle $con
- }
hunk ./idlebiff 350
+ variable ::shared::ka
+ variable ::shared::idle
+
+ after cancel $ka
+ if { $idle } \
+ {
+ set idle 0
+ exit_idle $con
+ }
patch 3eb89bff44a913b4c504d590cf62cd9c47dd3936
Author: Enrique D. Bosch <presidev@AT@gmail.com>
Date: Tue Sep 4 19:17:08 CEST 2018
* For logout, exit from idle mode only when it is
hunk ./idlebiff 342
- set idle 0
- exit_idle $con
+ if { $idle } \
+ {
+ set idle 0
+ exit_idle $con
+ }
patch 7eb7e2ff46a284866aa04fa8679ec731279c63c7
Author: Enrique D. Bosch <presidev@AT@gmail.com>
Date: Sun Sep 2 21:20:08 CEST 2018
* Implement correctly LOGOUT command according to RFC 3501, add logout_timeout config option
hunk ./.idlebiffrc 16
+timeout_logout=2
hunk ./idlebiff 33
+proc setappend { var args } { upvar 1 $var v; set v [ join $args {} ] }
hunk ./idlebiff 44
- variable tag 1
+ variable ntag 1
hunk ./idlebiff 77
+ variable tag
hunk ./idlebiff 284
- if {[ catch { puts $con $com } ]} \
+ set r [ catch { puts $con $com } ]
+ if {[ eq $com LOGOUT ]} return
+ if { $r } \
hunk ./idlebiff 296
- variable ::static::tag
-
- if {[ == $tag 10000 ]} { set tag 1 }
- append tcom $prefix [ format %04d $tag ] { } $com
+ variable ::static::ntag
+ variable ::shared::tag
+
+ if {[ == $ntag 10000 ]} { set ntag 1 }
+ setappend tag $prefix [ format %04d $ntag ]
+ append tcom $tag { } $com
hunk ./idlebiff 303
- incr tag
+ incr ntag
hunk ./idlebiff 306
-proc ok_tagged linea \
+proc ok_tagged { linea { tag {A\d+} } } \
hunk ./idlebiff 308
- append rexp {^} A {\d+ ok.*$}
+ append rexp {^} $tag { ok.*$}
hunk ./idlebiff 337
+ variable ::shared::ka
+ variable ::shared::idle
+ variable ::shared::conf
+
+ after cancel $ka
+ set idle 0
+ exit_idle $con
+ fileevent $con readable { parse_logout $con }
+ after ${conf(timeout_logout)}000 \
+ {
+ close $con
+ exit 0
+ }
hunk ./idlebiff 351
- close $con
hunk ./idlebiff 356
- exit 0
hunk ./idlebiff 543
+}
+
+proc parse_logout con \
+{
+ variable ::shared::conf
+ variable ::shared::tag
+
+ if {[ catch { gets $con linea } ]} return
+ if { $conf(imap_trace) } { puts "S: $linea" }
+ if {[ ok_tagged $linea $tag ]} \
+ {
+ close $con
+ exit 0
+ }
patch dc30edb7135409c41683a29f0a23684e7805693c
Author: Enrique D. Bosch <presidev@AT@gmail.com>
Date: Sun Sep 2 19:44:50 CEST 2018
* Use defaulted argument in imap_command_tagged function, ifempty function not necessary
hunk ./idlebiff 33
-proc ifempty { str alt } { if {[ eq $str {} ]} { return $alt } else { return $str } }
hunk ./idlebiff 290
-proc imap_command_tagged { con com args } \
+proc imap_command_tagged { con com { prefix A } } \
hunk ./idlebiff 295
- append tcom [ ifempty $args A ] [ format %04d $tag ] { } $com
+ append tcom $prefix [ format %04d $tag ] { } $com
patch 1fa87126792bb5a286620f7604fe9c0affd81637
Author: Enrique D. Bosch <presidev@AT@gmail.com>
Date: Fri Aug 31 22:07:57 CEST 2018
* Simplify ifempty function
hunk ./idlebiff 33
-proc ifempty { str alt } \
-{
- return [ expr { [ eq $str {} ] ? $alt : $str } ]
-}
+proc ifempty { str alt } { if {[ eq $str {} ]} { return $alt } else { return $str } }
patch c10ef6fde35c32a02b4d6ceb7731589dd6e207a0
Author: Enrique D. Bosch <presidev@AT@gmail.com>
Date: Fri Aug 31 21:32:14 CEST 2018
* Simplify interface for imap_command_tagged function
hunk ./idlebiff 33
+proc ifempty { str alt } \
+{
+ return [ expr { [ eq $str {} ] ? $alt : $str } ]
+}
+
hunk ./idlebiff 294
-proc imap_command_tagged { con prefix com } \
+proc imap_command_tagged { con com args } \
hunk ./idlebiff 299
- append tcom $prefix [ format %04d $tag ] { } $com
+ append tcom [ ifempty $args A ] [ format %04d $tag ] { } $com
hunk ./idlebiff 304
-proc ok_tagged { linea prefix } \
+proc ok_tagged linea \
hunk ./idlebiff 306
- append rexp {^} $prefix {\d+ ok.*$}
+ append rexp {^} A {\d+ ok.*$}
hunk ./idlebiff 330
- imap_command_tagged $con A "LOGIN $conf(user) $conf(pass)"
+ imap_command_tagged $con "LOGIN $conf(user) $conf(pass)"
hunk ./idlebiff 335
- imap_command_tagged $con A LOGOUT
+ imap_command_tagged $con LOGOUT
hunk ./idlebiff 354
- imap_command_tagged $con A IDLE
+ imap_command_tagged $con IDLE
hunk ./idlebiff 366
- imap_command_tagged $con A "EXAMINE $conf(mailbox)"
+ imap_command_tagged $con "EXAMINE $conf(mailbox)"
hunk ./idlebiff 371
- imap_command_tagged $con A CLOSE
+ imap_command_tagged $con CLOSE
hunk ./idlebiff 378
- imap_command_tagged $con A $search
+ imap_command_tagged $con $search
hunk ./idlebiff 445
- imap_command_tagged $con A CAPABILITY
+ imap_command_tagged $con CAPABILITY
hunk ./idlebiff 456
- if {[ ok_tagged $linea A ]} \
+ if {[ ok_tagged $linea ]} \
hunk ./idlebiff 472
- if {[ ok_tagged $linea A ]} \
+ if {[ ok_tagged $linea ]} \
hunk ./idlebiff 478
- imap_command_tagged $con A CAPABILITY
+ imap_command_tagged $con CAPABILITY
hunk ./idlebiff 488
- if {[ ok_tagged $linea A ]} { init_idle $con }
+ if {[ ok_tagged $linea ]} { init_idle $con }
hunk ./idlebiff 518
- if {[ and $search_resp [ ok_tagged $linea A ] ]} \
+ if {[ and $search_resp [ ok_tagged $linea ] ]} \
hunk ./idlebiff 625
- if { $conf(initial_noop) } { imap_command_tagged $con N NOOP }
+ if { $conf(initial_noop) } { imap_command_tagged $con NOOP N }
patch 564fe5aa95af90b3fb9e3d522c114fecd249b914
Author: Enrique D. Bosch <presidev@AT@gmail.com>
Date: Fri Aug 31 00:48:30 CEST 2018
* Set some defaults for missing config options
hunk ./idlebiff 33
+proc check_conf_and_set_default { opt default } \
+{
+ variable ::shared::conf
+
+ if {![ info exists conf($opt) ]} { set conf($opt) $default }
+}
+
hunk ./idlebiff 63
- variable criteria
hunk ./idlebiff 190
- variable ::shared::conf
- variable ::shared::criteria
hunk ./idlebiff 192
- if {[ info exists conf(criteria) ]} { if {[ ne $conf(criteria) {} ]} { set criteria $conf(criteria) } } \
- else { set criteria UNSEEN }
+ check_conf_and_set_default criteria UNSEEN
+ check_conf_and_set_default nodecor 1
+ check_conf_and_set_default tip 0
+ check_conf_and_set_default tls 0
+ check_conf_and_set_default tls_validate_cert 1
+ check_conf_and_set_default initial_noop 0
+ check_conf_and_set_default imap_trace 0
hunk ./idlebiff 207
- variable ::shared::criteria
+ variable ::shared::conf
hunk ./idlebiff 211
- set search "SEARCH RETURN (COUNT) $criteria"
+ set search "SEARCH RETURN (COUNT) $conf(criteria)"
hunk ./idlebiff 216
- set search "SEARCH $criteria"
+ set search "SEARCH $conf(criteria)"
hunk ./idlebiff 609
-} [_$_]
+}
patch 6cb864e02d9646202d1c02fce406e57ba2059f46
Author: Enrique D. Bosch <presidev@AT@gmail.com>
Date: Thu Aug 30 00:52:43 CEST 2018
* Add imap_trace option to show IMAP protocol dialog
hunk ./.idlebiffrc 23
+imap_trace=0
hunk ./idlebiff 267
-# if {[regexp {.*LOGIN.*} $com]} {puts "C: [string range $com 0 10]"} else {puts "C: $com"}
+ variable ::shared::conf
+
+ if { $conf(imap_trace) } \
+ { if {[ regexp {.*LOGIN.*} $com ]} { puts "C: [string range $com 0 10]" } else { puts "C: $com" } }
+
hunk ./idlebiff 520
+ variable ::shared::conf
+
hunk ./idlebiff 540
-# puts "S: $line"
+ if { $conf(imap_trace) } { puts "S: $line" }
+
patch 55c1cbaf4c675e24f783478cf8aaa869449f3c17
Author: Enrique D. Bosch <presidev@AT@gmail.com>
Date: Fri Aug 24 22:40:19 CEST 2018
* Add error wrapper, later can be a window dialog or something
hunk ./idlebiff 103
- if { $size_not_same } { error }
+ if { $size_not_same } { emit_error size }
hunk ./idlebiff 212
+proc emit_error args { error $args }
+
hunk ./idlebiff 307
- if { $cap(logindisabled) } { error logindisabled }
+ if { $cap(logindisabled) } { emit_error logindisabled }
hunk ./idlebiff 403
- if { !$cap(idle) } { error noidle }
+ if { !$cap(idle) } { emit_error noidle }
hunk ./idlebiff 511
- if {[ no_tagged $linea ]} { error search }
+ if {[ no_tagged $linea ]} { emit_error search }
hunk ./idlebiff 565
- if { ![ info exists csu($i) ] } { error cert }
- if {[ ne $csu($i) $ccsu($i) ]} { error cert }
+ if { ![ info exists csu($i) ] } { emit_error cert }
+ if {[ ne $csu($i) $ccsu($i) ]} { emit_error cert }
patch c074e25fdf925ae76c798e8303f50d1509e2ac79
Author: Enrique D. Bosch <presidev@AT@gmail.com>
Date: Thu Sep 7 00:08:44 CEST 2017
* Simplify or, and procs
hunk ./idlebiff 30
-proc and args { set a 1; foreach b $args { set a [ expr $a && $b ]; if { !$a } { return 0 } }; return $a }
-proc or args { set a 0; foreach b $args { set a [ expr $a || $b ]; if { $a } { return 1 } }; return $a }
+proc or args { foreach x $args { if { $x } { return 1 } }; return 0 }
+proc and args { foreach x $args { if { $x } continue { return 0 } }; return 1 }
patch d6716f5f719e0e6b712139717e6df63ca44fd4db
Author: Enrique D. Bosch <presidev@AT@gmail.com>
Date: Tue Sep 5 22:19:09 CEST 2017
* Fix style to avoid double substitution
hunk ./idlebiff 30
-proc and { args } { set a 1; foreach b $args { set a [ expr $a && $b ]; if !$a { return 0 } }; return $a }
-proc or { args } { set a 0; foreach b $args { set a [ expr $a || $b ]; if $a { return 1 } }; return $a }
+proc and args { set a 1; foreach b $args { set a [ expr $a && $b ]; if { !$a } { return 0 } }; return $a }
+proc or args { set a 0; foreach b $args { set a [ expr $a || $b ]; if { $a } { return 1 } }; return $a }
hunk ./idlebiff 71
-proc define_pixmaps { } \
+proc define_pixmaps {} \
hunk ./idlebiff 83
-proc icon { } \
+proc icon {} \
hunk ./idlebiff 103
- if $size_not_same { error }
+ if { $size_not_same } { error }
hunk ./idlebiff 108
- if [ and $conf(pos_x) $conf(pos_y) ] { append geom + $conf(pos_x) + $conf(pos_y) }
+ if {[ and $conf(pos_x) $conf(pos_y) ]} { append geom + $conf(pos_x) + $conf(pos_y) }
hunk ./idlebiff 134
- if $bad { set textbad "WRONG PASSWORD\n" } \
- else { set textbad "" }
- if !$conf(tls) { set nv "\nWARNING: INSECURE CONNECTION" }
+ if { $bad } { set textbad "WRONG PASSWORD\n" } \
+ else { set textbad {} }
+ if { !$conf(tls) } { set nv "\nWARNING: INSECURE CONNECTION" }
hunk ./idlebiff 162
- if $conf(tip) { tooltip::tooltip .frame.canvas $new_messages }
+ if { $conf(tip) } { tooltip::tooltip .frame.canvas $new_messages }
hunk ./idlebiff 165
-proc read_conf { } \
+proc read_conf {} \
hunk ./idlebiff 170
- if [ == $argn 1 ] { set config $arg } else { set config "$::env(HOME)/.idlebiffrc" }
+ if {[ == $argn 1 ]} { set config $arg } else { set config "$::env(HOME)/.idlebiffrc" }
hunk ./idlebiff 172
- while { [ >= [ gets $cf lin ] 0 ] } \
+ while {[ >= [ gets $cf lin ] 0 ]} \
hunk ./idlebiff 174
- if [ == [ string index [ string trim $lin ] 0 ] # ] continue
+ if {[ == [ string index [ string trim $lin ] 0 ] # ]} continue
hunk ./idlebiff 182
-proc set_params { } \
+proc set_params {} \
hunk ./idlebiff 188
- if [ info exists conf(criteria) ] { if [ ne $conf(criteria) "" ] { set criteria $conf(criteria) } } \
+ if {[ info exists conf(criteria) ]} { if {[ ne $conf(criteria) {} ]} { set criteria $conf(criteria) } } \
hunk ./idlebiff 193
-proc set_search_params { } \
+proc set_search_params {} \
hunk ./idlebiff 200
- if $cap(esearch) \
+ if { $cap(esearch) } \
hunk ./idlebiff 212
-proc set_timeout { } \
+proc set_timeout {} \
hunk ./idlebiff 228
-proc cancel_timeout { } \
+proc cancel_timeout {} \
hunk ./idlebiff 233
- if [ info exists tevent($teidi) ] \
+ if {[ info exists tevent($teidi) ]} \
hunk ./idlebiff 243
- if [ catch { set res [ eval "$com [ join $args]" ] } ] \
+ if {[ catch { set res [ eval "$com [ join $args]" ] } ]} \
hunk ./idlebiff 265
-# if [regexp {.*LOGIN.*} $com] {puts "C: [string range $com 0 10]"} else {puts "C: $com"}
- if [ catch { puts $con $com } ] \
+# if {[regexp {.*LOGIN.*} $com]} {puts "C: [string range $com 0 10]"} else {puts "C: $com"}
+ if {[ catch { puts $con $com } ]} \
hunk ./idlebiff 278
- if [ == $tag 10000 ] { set tag 1 }
- append tcom $prefix [ format %04d $tag ] " " $com
+ if {[ == $tag 10000 ]} { set tag 1 }
+ append tcom $prefix [ format %04d $tag ] { } $com
hunk ./idlebiff 305
- if $cap(logindisabled) { error logindisabled }
-
- if $retr { unset conf(pass) }
- if ![ info exists conf(pass) ] { set conf(pass) [ get_password $retr ] }
+ if { $cap(logindisabled) } { error logindisabled }
+
+ if { $retr } { unset conf(pass) }
+ if { ![ info exists conf(pass) ] } { set conf(pass) [ get_password $retr ] }
hunk ./idlebiff 325
-proc force_down { } \
+proc force_down {} \
hunk ./idlebiff 366
- if [ regexp -nocase -lineanchor $rexp_chk $linea ] \
+ if {[ regexp -nocase -lineanchor $rexp_chk $linea ]} \
hunk ./idlebiff 368
- if [ eq $args logindisabled ] { set cap(logindisabled_chk) 1 } \
+ if {[ eq $args logindisabled ]} { set cap(logindisabled_chk) 1 } \
hunk ./idlebiff 372
- if !$cap($capname) \
+ if { !$cap($capname) } \
hunk ./idlebiff 390
- if $check { do_search $con } \
+ if { $check } { do_search $con } \
hunk ./idlebiff 401
- if !$cap(idle) { error noidle }
+ if { !$cap(idle) } { error noidle }
hunk ./idlebiff 415
- if [ ok_untagged $linea ] \
+ if {[ ok_untagged $linea ]} \
hunk ./idlebiff 417
- if $cap(logindisabled_chk) \
+ if { $cap(logindisabled_chk) } \
hunk ./idlebiff 436
- if [ ok_tagged $linea A ] \
+ if {[ ok_tagged $linea A ]} \
hunk ./idlebiff 438
- if $cap(logindisabled_chk) \
+ if { $cap(logindisabled_chk) } \
hunk ./idlebiff 452
- if [ ok_tagged $linea A ] \
+ if {[ ok_tagged $linea A ]} \
hunk ./idlebiff 454
- if $cap(chk) { init_idle $con } \
+ if { $cap(chk) } { init_idle $con } \
hunk ./idlebiff 461
- elseif [ no_tagged $linea ] { login $con 1 }
+ elseif {[ no_tagged $linea ]} { login $con 1 }
hunk ./idlebiff 468
- if [ ok_tagged $linea A ] { init_idle $con }
+ if {[ ok_tagged $linea A ]} { init_idle $con }
hunk ./idlebiff 475
- if [ catch { set linea [ read_line $con ] } ] return
+ if {[ catch { set linea [ read_line $con ] } ]} return
hunk ./idlebiff 477
- if [ eq $prim + ] { set idle 1 } \
- elseif $idle { if [ eq $prim * ] { idle_cycle $con 1 } } \
+ if {[ eq $prim + ]} { set idle 1 } \
+ elseif { $idle } { if {[ eq $prim * ]} { idle_cycle $con 1 } } \
hunk ./idlebiff 493
- if [ regexp -lineanchor -nocase $rexpsearch $linea -> res ] \
+ if {[ regexp -lineanchor -nocase $rexpsearch $linea -> res ]} \
hunk ./idlebiff 495
- if $cap(esearch) { set pmsgs $res } else { incr pmsgs [ llength $res ] }
+ if { $cap(esearch) } { set pmsgs $res } else { incr pmsgs [ llength $res ] }
hunk ./idlebiff 498
- if [ and $search_resp [ ok_tagged $linea A ] ] \
+ if {[ and $search_resp [ ok_tagged $linea A ] ]} \
hunk ./idlebiff 504
- if [ > $new_messages 0 ] \
+ if {[ > $new_messages 0 ]} \
hunk ./idlebiff 509
- if [ no_tagged $linea ] { error search }
+ if {[ no_tagged $linea ]} { error search }
hunk ./idlebiff 515
- if [ catch { set r [ gets $con line ] } ] \
+ if {[ catch { set r [ gets $con line ] } ]} \
hunk ./idlebiff 520
- if [ regexp -lineanchor -nocase {^\* bye(?: .*|$)} $line ] \
+ if {[ regexp -lineanchor -nocase {^\* bye(?: .*|$)} $line ]} \
hunk ./idlebiff 525
- if [ and [ < $r 1 ] [ eof $con ] ] \
+ if {[ and [ < $r 1 ] [ eof $con ] ]} \
hunk ./idlebiff 551
- if [ info exists conf(tls_ca_subject) ] \
+ if {[ info exists conf(tls_ca_subject) ]} \
hunk ./idlebiff 553
- if [ and [ ne $conf(tls_ca_subject) "" ] [ eq $type "verify" ] [ eq $ca(subject) $ca(issuer) ] ] \
+ if {[ and [ ne $conf(tls_ca_subject) {} ] [ eq $type verify ] [ eq $ca(subject) $ca(issuer) ] ]} \
hunk ./idlebiff 556
- if !$ccsp \
+ if { !$ccsp } \
hunk ./idlebiff 563
- if ![ info exists csu($i) ] { error cert }
- if [ ne $csu($i) $ccsu($i) ] { error cert }
+ if { ![ info exists csu($i) ] } { error cert }
+ if {[ ne $csu($i) $ccsu($i) ]} { error cert }
hunk ./idlebiff 570
-proc init_tls { } \
+proc init_tls {} \
hunk ./idlebiff 575
- if $conf(tls) \
+ if { $conf(tls) } \
hunk ./idlebiff 578
- if [ >= $tlsv 1.6.4 ] { set tls1x {-tls1.1 1 -tls1.2 1} } \
+ if {[ >= $tlsv 1.6.4 ]} { set tls1x {-tls1.1 1 -tls1.2 1} } \
hunk ./idlebiff 593
-proc init { } \
+proc init {} \
hunk ./idlebiff 600
- fconfigure $con -blocking 0 -buffering line -translation "crlf crlf"
+ fconfigure $con -blocking 0 -buffering line -translation {crlf crlf}
hunk ./idlebiff 602
- if $conf(initial_noop) { imap_command_tagged $con N NOOP }
+ if { $conf(initial_noop) } { imap_command_tagged $con N NOOP }
patch dd4031d5b1d6adb28dec8dd4ebef7e6da146ce12
Author: Enrique D. Bosch <presidev@AT@gmail.com>
Date: Thu Aug 17 02:18:12 CEST 2017
* Add tag to LOGIN command in debug omiting the credentials (commented)
hunk ./idlebiff 265
-# if [regexp {.*LOGIN.*} $com] {puts "C: LOGIN"} else {puts "C: $com"}
+# if [regexp {.*LOGIN.*} $com] {puts "C: [string range $com 0 10]"} else {puts "C: $com"}
patch 16034f2b6f19369d43dc6b1c91c184734f75185a
Author: Enrique D. Bosch <presidev@AT@gmail.com>
Date: Wed Jan 11 01:00:25 CET 2017
* Change expressions from infix to prefix notation
hunk ./idlebiff 29
+namespace path ::tcl::mathop
+proc and { args } { set a 1; foreach b $args { set a [ expr $a && $b ]; if !$a { return 0 } }; return $a }
+proc or { args } { set a 0; foreach b $args { set a [ expr $a || $b ]; if $a { return 1 } }; return $a }
hunk ./idlebiff 102
- set size_not_same [ expr $png_up_w!=$png_down_w || $png_down_w!=$png_chk_w || $png_up_h!=$png_down_h || $png_down_h!=$png_chk_h ]
+ set size_not_same [ or [ != $png_up_w $png_down_w ] [ != $png_down_w $png_chk_w ] [ != $png_up_h $png_down_h ] [ != $png_down_h $png_chk_h ] ]
hunk ./idlebiff 107
- append geom [ expr $png_up_w + 10 ] x [ expr $png_up_h + 10 ]
- if { $conf(pos_x) && $conf(pos_y) } { append geom + $conf(pos_x) + $conf(pos_y) }
+ append geom [ + $png_up_w 10 ] x [ + $png_up_h 10 ]
+ if [ and $conf(pos_x) $conf(pos_y) ] { append geom + $conf(pos_x) + $conf(pos_y) }
hunk ./idlebiff 170
- if { $argn == 1 } { set config $arg } else { set config "$::env(HOME)/.idlebiffrc" }
+ if [ == $argn 1 ] { set config $arg } else { set config "$::env(HOME)/.idlebiffrc" }
hunk ./idlebiff 172
- while { [ gets $cf lin ] >= 0 } \
+ while { [ >= [ gets $cf lin ] 0 ] } \
hunk ./idlebiff 174
- if { [ string index [ string trim $lin ] 0 ] == "#" } continue
+ if [ == [ string index [ string trim $lin ] 0 ] # ] continue
hunk ./idlebiff 176
- set key [ string range $lin 0 [ expr $sep - 1 ] ]
- set val [ string range $lin [ expr $sep + 1 ] end ]
+ set key [ string range $lin 0 [ - $sep 1 ] ]
+ set val [ string range $lin [ + $sep 1 ] end ]
hunk ./idlebiff 188
- if { [ info exists conf(criteria) ] && $conf(criteria)!="" } { set criteria $conf(criteria) } \
+ if [ info exists conf(criteria) ] { if [ ne $conf(criteria) "" ] { set criteria $conf(criteria) } } \
hunk ./idlebiff 278
- if { $tag == 10000 } { set tag 1 }
+ if [ == $tag 10000 ] { set tag 1 }
hunk ./idlebiff 368
- if { $args eq "logindisabled" } { set cap(logindisabled_chk) 1 } \
+ if [ eq $args logindisabled ] { set cap(logindisabled_chk) 1 } \
hunk ./idlebiff 477
- if { $prim eq "+" } { set idle 1 } \
- elseif $idle { if { $prim eq "*" } { idle_cycle $con 1 } } \
+ if [ eq $prim + ] { set idle 1 } \
+ elseif $idle { if [ eq $prim * ] { idle_cycle $con 1 } } \
hunk ./idlebiff 498
- if { $search_resp && [ ok_tagged $linea A ] } \
+ if [ and $search_resp [ ok_tagged $linea A ] ] \
hunk ./idlebiff 504
- if { $new_messages > 0 } \
+ if [ > $new_messages 0 ] \
hunk ./idlebiff 525
- if { $r < 1 && [ eof $con ] } \
+ if [ and [ < $r 1 ] [ eof $con ] ] \
hunk ./idlebiff 551
- if { $conf(tls_ca_subject) ne "" && $type eq "verify" && $ca(subject) eq $ca(issuer) } \
+ if [ info exists conf(tls_ca_subject) ] \
hunk ./idlebiff 553
- array set csu [ parse_cert_subject $ca(subject) ]
- if !$ccsp \
+ if [ and [ ne $conf(tls_ca_subject) "" ] [ eq $type "verify" ] [ eq $ca(subject) $ca(issuer) ] ] \
hunk ./idlebiff 555
- array set ccsu [ parse_cert_subject $conf(tls_ca_subject) ]
- set ccsp 1
+ array set csu [ parse_cert_subject $ca(subject) ]
+ if !$ccsp \
+ {
+ array set ccsu [ parse_cert_subject $conf(tls_ca_subject) ]
+ set ccsp 1
+ }
+ foreach i [ array names ccsu ] \
+ {
+ if ![ info exists csu($i) ] { error cert }
+ if [ ne $csu($i) $ccsu($i) ] { error cert }
+ }
hunk ./idlebiff 567
- foreach i [ array names ccsu ] \
- { if { ![ info exists csu($i) ] || $csu($i)!=$ccsu($i) } { error cert } }
hunk ./idlebiff 578
- if { "$tlsv" >= "1.6.4" } { set tls1x {-tls1.1 1 -tls1.2 1} } \
+ if [ >= $tlsv 1.6.4 ] { set tls1x {-tls1.1 1 -tls1.2 1} } \
patch 2b11c67e9dd039c4f3bce6bf120363cfc66bd5d4
Author: Enrique D. Bosch <presidev@AT@gmail.com>
Date: Tue Jan 3 20:44:31 CET 2017
* Improve capabilities parsing, remove initial noop by default
hunk ./.idlebiffrc 13
+initial_noop=0
hunk ./idlebiff 44
- idle 0
hunk ./idlebiff 45
+ logindisabled_chk 0
+ chk 0
+ idle 0
hunk ./idlebiff 51
+ variable rexp_chk
hunk ./idlebiff 183
+ variable ::shared::rexp_chk
hunk ./idlebiff 187
+ set rexp_chk {(?: |\[)capability }
hunk ./idlebiff 271
-proc imap_command_tagged { con com } \
+proc imap_command_tagged { con prefix com } \
hunk ./idlebiff 275
- if { $tag == 10000 } { set tag 1 } [_$_]
- append tcom A [ format %04d $tag ] " " $com
+ if { $tag == 10000 } { set tag 1 }
+ append tcom $prefix [ format %04d $tag ] " " $com
hunk ./idlebiff 281
-proc ok_tagged linea \
+proc ok_tagged { linea prefix } \
hunk ./idlebiff 283
- return [ regexp -lineanchor -nocase {^A\d+ ok.*$} $linea ]
+ append rexp {^} $prefix {\d+ ok.*$}
+ return [ regexp -lineanchor -nocase $rexp $linea ]
hunk ./idlebiff 307
- imap_command_tagged $con "LOGIN $conf(user) $conf(pass)"
+ imap_command_tagged $con A "LOGIN $conf(user) $conf(pass)"
hunk ./idlebiff 312
- imap_command_tagged $con LOGOUT
+ imap_command_tagged $con A LOGOUT
hunk ./idlebiff 331
- imap_command_tagged $con IDLE [_$_]
+ imap_command_tagged $con A IDLE
hunk ./idlebiff 343
- imap_command_tagged $con "EXAMINE $conf(mailbox)"
+ imap_command_tagged $con A "EXAMINE $conf(mailbox)"
hunk ./idlebiff 348
- imap_command_tagged $con CLOSE
+ imap_command_tagged $con A CLOSE
hunk ./idlebiff 355
- imap_command_tagged $con $search
+ imap_command_tagged $con A $search
hunk ./idlebiff 358
-proc check_cap { linea capname } \
+proc check_cap { linea args } \
hunk ./idlebiff 361
-
- if !$cap($capname) \
+ variable ::shared::rexp_chk
+
+ if [ regexp -nocase -lineanchor $rexp_chk $linea ] \
hunk ./idlebiff 365
- set rexp ".*capability .*${capname}(?: .*|].*|$)"
- set cap($capname) [ regexp -nocase -lineanchor $rexp $linea ]
+ if { $args eq "logindisabled" } { set cap(logindisabled_chk) 1 } \
+ else { set cap(chk) 1 }
+ foreach capname $args \
+ {
+ if !$cap($capname) \
+ {
+ set rexp_cap " ${capname}(?: |]|$)"
+ set cap($capname) [ regexp -nocase -lineanchor $rexp_cap $linea ]
+ }
+ }
hunk ./idlebiff 396
-
+ variable ::shared::cap
+
+ if !$cap(idle) { error noidle }
hunk ./idlebiff 408
+ variable ::shared::cap
+
hunk ./idlebiff 412
- if [ ok_untagged $linea ] { fileevent $con readable { parse_noop $con } }
+ if [ ok_untagged $linea ] \
+ {
+ if $cap(logindisabled_chk) \
+ {
+ fileevent $con readable { parse_login $con }
+ login $con 0
+ } \
+ else \
+ {
+ fileevent $con readable { parse_logindisabled $con }
+ imap_command_tagged $con A CAPABILITY
+ }
+ }
hunk ./idlebiff 427
-proc parse_noop con \
+proc parse_logindisabled con \
hunk ./idlebiff 429
+ variable ::shared::cap
+
hunk ./idlebiff 433
- if [ ok_tagged $linea ] \
+ if [ ok_tagged $linea A ] \
hunk ./idlebiff 435
- fileevent $con readable { parse_login $con }
- login $con 0
+ if $cap(logindisabled_chk) \
+ {
+ fileevent $con readable { parse_login $con }
+ login $con 0
+ }
hunk ./idlebiff 448
- check_cap $linea idle
- check_cap $linea esearch
- if [ ok_tagged $linea ] \
+ check_cap $linea idle esearch
+ if [ ok_tagged $linea A ] \
hunk ./idlebiff 451
- if $cap(idle) { init_idle $con } \
+ if $cap(chk) { init_idle $con } \
hunk ./idlebiff 455
- imap_command_tagged $con CAPABILITY
+ imap_command_tagged $con A CAPABILITY
hunk ./idlebiff 463
- variable ::shared::cap
-
hunk ./idlebiff 464
- check_cap $linea idle
- check_cap $linea esearch
- if [ ok_tagged $linea ] \
- {
- if $cap(idle) { init_idle $con } \
- else { error no idle capability } \
- } [_$_]
+ check_cap $linea idle esearch
+ if [ ok_tagged $linea A ] { init_idle $con }
hunk ./idlebiff 495
- if { $search_resp && [ ok_tagged $linea ] } \
+ if { $search_resp && [ ok_tagged $linea A ] } \
hunk ./idlebiff 593
- imap_command_tagged $con NOOP
+ if $conf(initial_noop) { imap_command_tagged $con N NOOP }
patch c70c6d824c3dc25edbb1417483f26cbb303dbc80
Author: Enrique D. Bosch <presidev@AT@gmail.com>
Date: Tue Jan 3 19:53:17 CET 2017
* Improve parsing in IDLE mode
hunk ./idlebiff 447
- elseif { $idle == 1 } { idle_cycle $con 1 } \
+ elseif $idle { if { $prim eq "*" } { idle_cycle $con 1 } } \
patch 6c43ff2e14364f2547e281a6e97b9ddbe1645f81
Author: Enrique D. Bosch <presidev@AT@gmail.com>
Date: Tue Dec 13 23:21:49 CET 2016
* Simplify regular expressions
hunk ./idlebiff 195
- set rexpsearch {^\*\s+esearch\s+\(tag\s*[^)]*\)\s+count\s+(.*)$}
+ set rexpsearch {^\* esearch \(tag [^)]*\) count (.*)$}
hunk ./idlebiff 278
- return [ regexp -lineanchor -nocase {^A\d+\s+ok.*$} $linea ]
+ return [ regexp -lineanchor -nocase {^A\d+ ok.*$} $linea ]
hunk ./idlebiff 283
- return [ regexp -lineanchor -nocase {^\*\s+ok.*$} $linea ]
+ return [ regexp -lineanchor -nocase {^\* ok.*$} $linea ]
hunk ./idlebiff 288
- return [ regexp -lineanchor -nocase {^A\d+\s+no.*$} $linea ]
+ return [ regexp -lineanchor -nocase {^A\d+ no.*$} $linea ]
hunk ./idlebiff 489
- if [ regexp -lineanchor -nocase {^\*\s+bye .*$} $line ] \
+ if [ regexp -lineanchor -nocase {^\* bye(?: .*|$)} $line ] \
patch 61926820804dbe5661d868d10142ef8ce839735b
Author: Enrique D. Bosch <presidev@AT@gmail.com>
Date: Tue Dec 13 22:03:31 CET 2016
* Fix end-of-line character handling
hunk ./idlebiff 200
- set rexpsearch {^\*\s+search\s+(.*)$}
+ set rexpsearch {^\* search((?: .*|$))}
hunk ./idlebiff 258
- if [ catch { puts -nonewline $con "$com\r\n" } ] \
+ if [ catch { puts $con $com } ] \
hunk ./idlebiff 563
- fconfigure $con -blocking 0 -buffering line
+ fconfigure $con -blocking 0 -buffering line -translation "crlf crlf"
patch 3d92c90730176e9d354ceba7423397306f7196f3
Author: Enrique D. Bosch <presidev@AT@gmail.com>
Date: Mon Nov 28 00:54:07 CET 2016
* Correct tls_validate_cert config option (was forced to 1 even when set to 0)
hunk ./idlebiff 548
- -request 1 \
+ -request \"$conf(tls_validate_cert)\" \
patch abecc24572d6c212ae41f2d9617b225433422c4c
Author: Enrique D. Bosch <presidev@AT@gmail.com>
Date: Tue Nov 22 23:55:46 CET 2016
* Remove unused variable
hunk ./idlebiff 51
- variable msgs 0
patch 6dd64c777afb2deec0c3dcfacbba3552e409ead6
Author: Enrique D. Bosch <presidev@AT@gmail.com>
Date: Tue Nov 22 23:26:40 CET 2016
* Handle multiline SEARCH responses (according to http://imapwiki.org/ClientImplementation/Search)
hunk ./idlebiff 34
+ variable pmsgs 0
+ variable search_resp 0
hunk ./idlebiff 48
+ variable search
+ variable rexpsearch
hunk ./idlebiff 186
+proc set_search_params { } \
+{
+ variable ::shared::cap
+ variable ::shared::search
+ variable ::shared::rexpsearch
+ variable ::shared::criteria
+
+ if $cap(esearch) \
+ {
+ set search "SEARCH RETURN (COUNT) $criteria"
+ set rexpsearch {^\*\s+esearch\s+\(tag\s*[^)]*\)\s+count\s+(.*)$}
+ } \
+ else \
+ {
+ set search "SEARCH $criteria"
+ set rexpsearch {^\*\s+search\s+(.*)$}
+ }
+}
+
hunk ./idlebiff 348
- variable ::shared::cap
- variable ::shared::criteria
-
- if $cap(esearch) { imap_command_tagged $con "SEARCH RETURN (COUNT) $criteria" } \
- else { imap_command_tagged $con "SEARCH $criteria" }
+ variable ::shared::search
+
+ imap_command_tagged $con $search
hunk ./idlebiff 385
+ set_search_params
hunk ./idlebiff 459
-
- if $cap(esearch) { set rexpr {^\*\s+esearch\s+\(tag\s*[^)]*\)\s+count\s+(.*)$} } \
- else { set rexpr {^\*\s+search\s+(.*)$} }
- if [ regexp -lineanchor -nocase $rexpr $linea -> res ] \
+ variable ::shared::rexpsearch
+ variable ::static::pmsgs
+ variable ::static::search_resp
+
+ if [ regexp -lineanchor -nocase $rexpsearch $linea -> res ] \
hunk ./idlebiff 465
+ if $cap(esearch) { set pmsgs $res } else { incr pmsgs [ llength $res ] }
+ set search_resp 1
+ }
+ if { $search_resp && [ ok_tagged $linea ] } \
+ {
hunk ./idlebiff 471
- if !$cap(esearch) { set res [ llength $res ] }
- set new_messages $res
+ set new_messages $pmsgs
+ set pmsgs 0
+ set search_resp 0
hunk ./idlebiff 478
- } [_$_]
+ }
+ if [ no_tagged $linea ] { error search }
patch 287378ffe6ada32c8197ae2c266578bf469f554e
Author: Enrique D. Bosch <presidev@AT@gmail.com>
Date: Wed Nov 16 23:03:15 CET 2016
* Wait for response of SEARCH (get the number of messages) before sending the IDLE command
hunk ./idlebiff 352
- if $check { do_search $con }
- enter_idle $con
+ if $check { do_search $con } \
+ else { enter_idle $con }
hunk ./idlebiff 365
- enter_idle $con
hunk ./idlebiff 442
+ enter_idle $con
patch 83b5d85caf2a4557ec715816e73d43b4a9b8ac06
Author: Enrique D. Bosch <presidev@AT@gmail.com>
Date: Wed Nov 16 21:33:45 CET 2016
* Add config option "criteria" for IMAP SEARCH criteria (UNSEEN by default)
hunk ./.idlebiffrc 22
+criteria=
hunk ./idlebiff 46
+ variable criteria
hunk ./idlebiff 173
+proc set_params { } \
+{
+ variable ::shared::conf
+ variable ::shared::criteria
+
+ if { [ info exists conf(criteria) ] && $conf(criteria)!="" } { set criteria $conf(criteria) } \
+ else { set criteria UNSEEN }
+}
+
hunk ./idlebiff 323
-proc ask_unseen con \
+proc do_search con \
hunk ./idlebiff 326
-
- if $cap(esearch) { imap_command_tagged $con "SEARCH RETURN (COUNT) UNSEEN" } \
- else { imap_command_tagged $con "SEARCH UNSEEN" }
+ variable ::shared::criteria
+
+ if $cap(esearch) { imap_command_tagged $con "SEARCH RETURN (COUNT) $criteria" } \
+ else { imap_command_tagged $con "SEARCH $criteria" }
hunk ./idlebiff 352
- if $check { ask_unseen $con }
+ if $check { do_search $con }
hunk ./idlebiff 364
- ask_unseen $con
+ do_search $con
hunk ./idlebiff 428
- else { parse_unseen $linea }
+ else { parse_search $con $linea }
hunk ./idlebiff 431
-proc parse_unseen linea \
+proc parse_search { con linea } \
hunk ./idlebiff 540
+set_params
patch 5511dcb92b2c3f22d8aaf1cdcb93de720aa6eee1
Author: Enrique D. Bosch <presidev@AT@gmail.com>
Date: Sat Nov 12 19:01:49 CET 2016
* Remove unnecessary braces
hunk ./idlebiff 164
- if { [ string index [ string trim $lin ] 0 ] == "#" } { continue }
+ if { [ string index [ string trim $lin ] 0 ] == "#" } continue
patch ea4b60e19dd0d98535541f44247b8821d9c16d06
Author: Enrique D. Bosch <presidev@AT@gmail.com>
Date: Fri Sep 9 21:09:18 CEST 2016
* Add output for debugging (commented)
hunk ./idlebiff 225
+# if [regexp {.*LOGIN.*} $com] {puts "C: LOGIN"} else {puts "C: $com"}
hunk ./idlebiff 459
- else { return $line }
+ else \
+ {
+# puts "S: $line"
+ return $line
+ }
patch ebc8d6d2521391e4354381e0396671bb7d41852d
Author: Enrique D. Bosch <presidev@AT@gmail.com>
Date: Fri Sep 9 12:51:40 CEST 2016
* Improve/fix reconnection functionality
hunk ./idlebiff 215
+ variable ::shared::idle
hunk ./idlebiff 218
- close $con
+ set idle 0
+ catch { close $con }
hunk ./idlebiff 412
- set linea [ read_line $con ]
+ if [ catch { set linea [ read_line $con ] } ] return
hunk ./idlebiff 446
- return
+ return -code error
hunk ./idlebiff 451
- return
+ return -code error
hunk ./idlebiff 456
+ return -code error