Add home directory to config path --> 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
patch aa141d8d814fb6fda062d68c9250359ca41438ec
Author: Enrique D. Bosch <presidev@AT@gmail.com>
Date: Wed Jun 8 15:35:03 CEST 2016
* Fix style and operators of some expressions
hunk ./idlebiff 160
- 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 413
- elseif { $idle==1 } { idle_cycle $con 1 } \
+ elseif { $idle == 1 } { idle_cycle $con 1 } \
hunk ./idlebiff 451
- if { $r<1 && [ eof $con ] } \
+ if { $r < 1 && [ eof $con ] } \
hunk ./idlebiff 472
- if { $conf(tls_ca_subject)!="" && $type=="verify" && $ca(subject)==$ca(issuer) } \
+ if { $conf(tls_ca_subject) ne "" && $type eq "verify" && $ca(subject) eq $ca(issuer) } \
hunk ./idlebiff 493
- 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 734e04efcdbee633dd1621cd32d7327e62819e6c
Author: Enrique D. Bosch <presidev@AT@gmail.com>
Date: Wed Jun 8 11:34:39 CEST 2016
* Strip unused braces and lines
hunk ./idlebiff 93
- if { $size_not_same } { error }
+ if $size_not_same { error }
hunk ./idlebiff 117
-# if { $conf(tip) } { tooltip::tooltip .frame.canvas }
-# set current $img_chk
hunk ./idlebiff 119
-proc get_password { bad } \
+proc get_password bad \
hunk ./idlebiff 146
-proc update_img { img } \
+proc update_img img \
hunk ./idlebiff 212
-proc recon { con } \
+proc recon con \
hunk ./idlebiff 241
-proc ok_tagged { linea } \
+proc ok_tagged linea \
hunk ./idlebiff 246
-proc ok_untagged { linea } \
+proc ok_untagged linea \
hunk ./idlebiff 251
-proc no_tagged { linea } \
+proc no_tagged linea \
hunk ./idlebiff 269
-proc logout { con } \
+proc logout con \
hunk ./idlebiff 275
-proc cleanup { con } \
+proc cleanup con \
hunk ./idlebiff 288
-proc enter_idle { con } \
+proc enter_idle con \
hunk ./idlebiff 293
-proc exit_idle { con } \
+proc exit_idle con \
hunk ./idlebiff 298
-proc enter_mailbox { con } \
+proc enter_mailbox con \
hunk ./idlebiff 305
-proc exit_mailbox { con } \
+proc exit_mailbox con \
hunk ./idlebiff 310
-proc ask_unseen { con } \
+proc ask_unseen con \
hunk ./idlebiff 343
-proc init_idle { con } \
+proc init_idle con \
hunk ./idlebiff 355
-proc parse_greeting { con } \
+proc parse_greeting con \
hunk ./idlebiff 362
-proc parse_noop { con } \
+proc parse_noop con \
hunk ./idlebiff 373
-proc parse_login { con } \
+proc parse_login con \
hunk ./idlebiff 392
-proc parse_cap { con } \
+proc parse_cap con \
hunk ./idlebiff 406
-proc parse_idle_check { con } \
+proc parse_idle_check con \
hunk ./idlebiff 417
-proc parse_unseen { linea } \
+proc parse_unseen linea \
hunk ./idlebiff 438
-proc read_line { con } \
+proc read_line con \
hunk ./idlebiff 458
-proc parse_cert_subject { sub } \
+proc parse_cert_subject sub \
patch 7cf737ec305ade9759d13a9fa2f5ef70b6158c45
Author: Enrique D. Bosch <presidev@AT@gmail.com>
Date: Wed Jun 8 00:14:13 CEST 2016
* Add an option (tls_ca_subject) to check the subject of the root certificate, to avoid attacks with leaf certificates generated by compromissed or malicious certificate authorities, this is a key pinning mechanism
hunk ./.idlebiffrc 25
+tls_ca_subject=
hunk ./idlebiff 30
-namespace eval static { variable tag 1 }
+namespace eval static \
+{
+ variable tag 1
+ variable ccsp 0
+ array set ccsu {}
+}
+
hunk ./idlebiff 460
+proc parse_cert_subject { sub } \
+{
+ set cst [ split [ string map { , = / = } $sub ] = ]
+ foreach v $cst { lappend cstp [ string trim $v ] }
+ return $cstp
+}
+
+proc tls_cb { type channel depth cert status error } \
+{
+ variable ::shared::conf
+ variable ::static::ccsu
+ variable ::static::ccsp
+
+ array set ca $cert
+ if { $conf(tls_ca_subject)!="" && $type=="verify" && $ca(subject)==$ca(issuer) } \
+ {
+ 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) ] || $csu($i)!=$ccsu($i) } { error cert } }
+ }
+}
hunk ./idlebiff 504
- -cipher \"$conf(tls_ciphers)\""
+ -cipher \"$conf(tls_ciphers)\" \
+ -command tls_cb"
patch 80544e6a2108d1f5387f5fd676b89c934181460d
Author: Enrique D. Bosch <presidev@AT@gmail.com>
Date: Wed Jun 8 00:00:48 CEST 2016
* Improve parser of configuration file
hunk ./idlebiff 160
- if { [ string range [ string trim $lin ] 0 0 ] == "#" } { continue }
- set lconf [ split $lin = ]
- lassign $lconf key val
+ if { [ string index [ string trim $lin ] 0 ] == "#" } { continue }
+ set sep [ string first = $lin ]
+ set key [ string range $lin 0 [ expr $sep - 1 ] ]
+ set val [ string range $lin [ expr $sep + 1 ] end ]
patch 7338b38e3656d3cfd65724e679fefc686d08e9b2
Author: Enrique D. Bosch <presidev@AT@gmail.com>
Date: Sun Jun 5 23:26:38 CEST 2016
* Fix options passed to tls (were not having effect)
hunk ./idlebiff 464
- ::tls::init -ssl2 0 -ssl3 0 -tls1 1 [ list $tls1x ] \
- -cafile "$conf(tls_ca_file)" \
- -cadir "$conf(tls_ca_dir)" \
- -certfile "$conf(tls_client_cert)" \
- -keyfile "$conf(tls_client_key)" \
+ set sock "::tls::socket -ssl2 0 -ssl3 0 -tls1 1 $tls1x \
+ -cafile \"$conf(tls_ca_file)\" \
+ -cadir \"$conf(tls_ca_dir)\" \
+ -certfile \"$conf(tls_client_cert)\" \
+ -keyfile \"$conf(tls_client_key)\" \
hunk ./idlebiff 470
- -require "$conf(tls_validate_cert)" \
- -cipher "$conf(tls_ciphers)"
- set sock ::tls::socket [_$_]
+ -require \"$conf(tls_validate_cert)\" \
+ -cipher \"$conf(tls_ciphers)\""
patch b0cebeb0d05720d8b145fc479b09238a463a26cf
Author: Enrique D. Bosch <presidev@AT@gmail.com>
Date: Sat Jun 4 17:05:02 CEST 2016
* Improve capabilities parse routine
hunk ./idlebiff 34
- variable idlecap 0
- variable logindiscap 0
- variable esearchcap 0
+ array set cap \
+ {
+ idle 0
+ logindisabled 0
+ esearch 0
+ }
hunk ./idlebiff 254
- variable ::shared::logindiscap
-
- if $logindiscap { error logindisabled }
+ variable ::shared::cap
+
+ if $cap(logindisabled) { error logindisabled }
hunk ./idlebiff 307
- variable ::shared::esearchcap
-
- if $esearchcap { imap_command_tagged $con "SEARCH RETURN (COUNT) UNSEEN" } \
- else { imap_command_tagged $con "SEARCH UNSEEN" }
+ variable ::shared::cap
+
+ if $cap(esearch) { imap_command_tagged $con "SEARCH RETURN (COUNT) UNSEEN" } \
+ else { imap_command_tagged $con "SEARCH UNSEEN" }
hunk ./idlebiff 313
-proc check_cap_logindis { linea } \
+proc check_cap { linea capname } \
hunk ./idlebiff 315
- variable ::shared::logindiscap
-
- if !$logindiscap { set logindiscap [ regexp -nocase -lineanchor {.*capability .*logindisabled(?: .*|].*|$)} $linea ] }
+ variable ::shared::cap
+
+ if !$cap($capname) \
+ {
+ set rexp ".*capability .*${capname}(?: .*|].*|$)"
+ set cap($capname) [ regexp -nocase -lineanchor $rexp $linea ]
+ }
hunk ./idlebiff 324
-proc check_cap_idle { linea } \
-{
- variable ::shared::idlecap
-
- if !$idlecap { set idlecap [ regexp -nocase -lineanchor {.*capability .*idle(?: .*|].*|$)} $linea ] }
-}
-
-proc check_cap_esearch { linea } \
-{
- variable ::shared::esearchcap
-
- if !$esearchcap { set esearchcap [ regexp -nocase -lineanchor {.*capability .*esearch(?: .*|].*|$)} $linea ] }
-}
-
hunk ./idlebiff 353
- check_cap_logindis $linea
+ check_cap $linea logindisabled
hunk ./idlebiff 359
-
hunk ./idlebiff 360
- check_cap_logindis $linea
+ check_cap $linea logindisabled
hunk ./idlebiff 370
- variable ::shared::idlecap
+ variable ::shared::cap
hunk ./idlebiff 373
- check_cap_idle $linea
- check_cap_esearch $linea
+ check_cap $linea idle
+ check_cap $linea esearch
hunk ./idlebiff 377
- if $idlecap { init_idle $con } \
+ if $cap(idle) { init_idle $con } \
hunk ./idlebiff 389
- variable ::shared::idlecap
+ variable ::shared::cap
hunk ./idlebiff 392
- check_cap_idle $linea
- check_cap_esearch $linea
+ check_cap $linea idle
+ check_cap $linea esearch
hunk ./idlebiff 396
- if $idlecap { init_idle $con } \
+ if $cap(idle) { init_idle $con } \
hunk ./idlebiff 418
- variable ::shared::esearchcap
-
- if $esearchcap { set rexpr {^\*\s+esearch\s+\(tag\s*[^)]*\)\s+count\s+(.*)$} } \
- else { set rexpr {^\*\s+search\s+(.*)$} }
+ variable ::shared::cap
+
+ if $cap(esearch) { set rexpr {^\*\s+esearch\s+\(tag\s*[^)]*\)\s+count\s+(.*)$} } \
+ else { set rexpr {^\*\s+search\s+(.*)$} }
hunk ./idlebiff 424
- if !$esearchcap { set res [ llength $res ] }
+ if !$cap(esearch) { set res [ llength $res ] }
patch c673de820d8f38ff45a5ee81cdd1a48c1ae5a229
Author: Enrique D. Bosch <presidev@AT@gmail.com>
Date: Wed Jun 1 01:36:58 CEST 2016
* Fix regular expressions for capabilities
hunk ./idlebiff 314
- if !$logindiscap { set logindiscap [ regexp -nocase {.*capability .* logindisabled .*} $linea ] }
+ if !$logindiscap { set logindiscap [ regexp -nocase -lineanchor {.*capability .*logindisabled(?: .*|].*|$)} $linea ] }
hunk ./idlebiff 321
- if !$idlecap { set idlecap [ regexp -nocase {.*capability .* idle .*} $linea ] }
+ if !$idlecap { set idlecap [ regexp -nocase -lineanchor {.*capability .*idle(?: .*|].*|$)} $linea ] }
hunk ./idlebiff 328
- if !$esearchcap { set esearchcap [ regexp -nocase {.*capability .* esearch .*} $linea ] }
+ if !$esearchcap { set esearchcap [ regexp -nocase -lineanchor {.*capability .*esearch(?: .*|].*|$)} $linea ] }
patch e5c973637923fda8b5c042f0135d08965c6ac2de
Author: Enrique D. Bosch <presidev@AT@gmail.com>
Date: Tue May 31 17:06:39 CEST 2016
* Support extension to SEARCH (RFC-4731) when available (via ESEARCH capability) to make UNSEEN queries more efficient
hunk ./idlebiff 36
+ variable esearchcap 0
hunk ./idlebiff 304
- imap_command_tagged $con "SEARCH UNSEEN"
+ variable ::shared::esearchcap
+
+ if $esearchcap { imap_command_tagged $con "SEARCH RETURN (COUNT) UNSEEN" } \
+ else { imap_command_tagged $con "SEARCH UNSEEN" }
hunk ./idlebiff 324
+proc check_cap_esearch { linea } \
+{
+ variable ::shared::esearchcap
+
+ if !$esearchcap { set esearchcap [ regexp -nocase {.*capability .* esearch .*} $linea ] }
+}
+
hunk ./idlebiff 382
+ check_cap_esearch $linea
hunk ./idlebiff 401
+ check_cap_esearch $linea
hunk ./idlebiff 426
-
- if [ regexp -lineanchor -nocase {^\*\s+search\s+(.*)$} $linea -> msg_list ] \
+ variable ::shared::esearchcap
+
+ if $esearchcap { set rexpr {^\*\s+esearch\s+\(tag\s*[^)]*\)\s+count\s+(.*)$} } \
+ else { set rexpr {^\*\s+search\s+(.*)$} }
+ if [ regexp -lineanchor -nocase $rexpr $linea -> res ] \
hunk ./idlebiff 432
- set new_messages [ llength $msg_list ]
+ if !$esearchcap { set res [ llength $res ] }
+ set new_messages $res
patch ff24551724e04c3827a8d24ee5495dd643bc65ee
Author: Enrique D. Bosch <presidev@AT@gmail.com>
Date: Mon May 30 20:53:02 CEST 2016
* Use SEARCH command instead of STATUS for UNSEEN query as it's more efficient and correct according to RFC-3501
hunk ./idlebiff 303
- variable ::shared::conf
-
- imap_command_tagged $con "STATUS $conf(mailbox) (UNSEEN)"
+ imap_command_tagged $con "SEARCH UNSEEN"
hunk ./idlebiff 329
- if $check \
- { [_$_]
- exit_mailbox $con
- ask_unseen $con
- enter_mailbox $con
- }
+ if $check { ask_unseen $con }
hunk ./idlebiff 340
+ enter_mailbox $con
hunk ./idlebiff 342
- enter_mailbox $con
hunk ./idlebiff 414
- append statusexp {^\*\s+status\s+} {"*} $conf(mailbox) {"*} {\s+\(unseen\s+(\d+)\).*$}
- if [ regexp -lineanchor -nocase $statusexp $linea -> new_messages ] \
+ if [ regexp -lineanchor -nocase {^\*\s+search\s+(.*)$} $linea -> msg_list ] \
hunk ./idlebiff 416
+ set new_messages [ llength $msg_list ]
patch f60229b708e75d0875fccec0e71aa2867c3872c7
Author: Enrique D. Bosch <presidev@AT@gmail.com>
Date: Sun May 29 11:22:47 CEST 2016
* Extract unseen parse code to a new function
hunk ./idlebiff 346
- fileevent $con readable { parse_idle $con }
+ fileevent $con readable { parse_idle_check $con }
hunk ./idlebiff 403
-proc parse_idle { con } \
+proc parse_idle_check { con } \
hunk ./idlebiff 406
- variable ::shared::msgs
+
+ set linea [ read_line $con ]
+ set prim [ string range $linea 0 0 ]
+ if { $prim eq "+" } { set idle 1 } \
+ elseif { $idle==1 } { idle_cycle $con 1 } \
+ else { parse_unseen $linea }
+}
+
+proc parse_unseen { linea } \
+{
hunk ./idlebiff 421
- set linea [ read_line $con ]
- set prim [ string range $linea 0 0 ]
- if { $prim eq "+" } { set idle 1 } \
- elseif { $idle==1 } { idle_cycle $con 1 } \
- else \
+ append statusexp {^\*\s+status\s+} {"*} $conf(mailbox) {"*} {\s+\(unseen\s+(\d+)\).*$}
+ if [ regexp -lineanchor -nocase $statusexp $linea -> new_messages ] \
hunk ./idlebiff 424
- append statusexp {^\*\s+status\s+} {"*} $conf(mailbox) {"*} {\s+\(unseen\s+(\d+)\).*$}
- if [ regexp -lineanchor -nocase $statusexp $linea -> new_messages ] \
- {
- if { $new_messages > 0 } \
- { set current $img_up } \
- else { set current $img_down }
- update_img $current
- }
- }
+ if { $new_messages > 0 } \
+ { set current $img_up } \
+ else { set current $img_down }
+ update_img $current
+ } [_$_]
patch bc029232d2b2f3bd50e9f633610be6dbddee31a7
Author: Enrique D. Bosch <presidev@AT@gmail.com>
Date: Sun May 29 02:25:34 CEST 2016
* Add home directory to config path
hunk ./idlebiff 152
- if { $argn==1 } { set config $arg } else { set config .idlebiffrc }
+ if { $argn==1 } { set config $arg } else { set config "$::env(HOME)/.idlebiffrc" }