Simplify or, and procs --> 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 }