Tkabber

Check-in [811798a24b]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Cleaned up the code, removed all kinds of commands for getting idle time except for the [tk inactive].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 811798a24bd94d9f3d2b052cfae4234cde715bac
User & Date: sgolovan 2016-02-04 15:44:52
Context
2016-02-04
15:48
Got rid of [eval] calls. Do not add -castore and -certfile options if they are empty strings. Defined /etc/ssl/certs as a default value for the loginconf(cacertstore) on unix systems. check-in: 6ac686f9b0 user: sgolovan tags: trunk
15:44
Cleaned up the code, removed all kinds of commands for getting idle time except for the [tk inactive]. check-in: 811798a24b user: sgolovan tags: trunk
05:37
Renamed user_avatar_notification_hook to user_avatar_pep_notification_hook to prevent clashing with the avatarcache plugin in contrib. check-in: f14959bebf user: sgolovan tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ChangeLog.

1
2
3
4
5




6
7
8
9
10
11
12
2016-02-04  Sergei Golovan  <sgolovan@nes.ru>

	* plugins/pep/user_avatar.tcl: Renamed user_avatar_notification_hook
	  to user_avatar_pep_notification_hook to prevent clashing with the
	  avatarcache plugin in contrib.





2016-02-01  Sergei Golovan  <sgolovan@nes.ru>

	* plugins/general/gpgme.tcl: Don't draw the signed/encrypted message
	  icon for outgoing messages in groupchats because only drawing
	  incoming messages makes sense there.






>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2016-02-04  Sergei Golovan  <sgolovan@nes.ru>

	* plugins/pep/user_avatar.tcl: Renamed user_avatar_notification_hook
	  to user_avatar_pep_notification_hook to prevent clashing with the
	  avatarcache plugin in contrib.

	* plugins/general/autoaway.tcl, plugins/iq/last.tcl: Cleaned up the
	  code, removed all kinds of commands for getting idle time except
	  for the [tk inactive].

2016-02-01  Sergei Golovan  <sgolovan@nes.ru>

	* plugins/general/gpgme.tcl: Don't draw the signed/encrypted message
	  icon for outgoing messages in groupchats because only drawing
	  incoming messages makes sense there.

Changes to plugins/general/autoaway.tcl.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# autoaway.tcl --
#
#       This file is a part of the Tkabber XMPP client. It's a plugind which
#       switches Tkabber status to away or xa after a specified period of
#       inactivity.

namespace eval autoaway {
    variable options
}

proc autoaway::load {} {
    global tcl_platform
    global idle_command

    if {[catch {tk inactive}] || ([tk inactive] < 0)} {
        switch -- $tcl_platform(platform) {
            macintosh {
                set idle_command [namespace current]::AquaIdleTime
            }

            unix {
                if {$::aquaP} {
                    set idle_command [namespace current]::AquaIdleTime
                } elseif {[catch { package require tkXwin }]} {
                    return
                } else {
                    set idle_command tkXwin::idletime
                }
            }
            windows {
                if {![catch { package require tkinactive }]} {
                    set idle_command tkinactive
                } elseif {![catch { package require tclWinidle }]} {
                    set idle_command tclWinidle::idletime
                } else {
                    return
                }
            }
            default {
                return
            }
        }
    } else {
        set idle_command {tk inactive}
    }

    custom::defgroup AutoAway \
        [::msgcat::mc "Options for module that automatically marks\
                       you as away after idle threshold."] \
        -group Tkabber








<
<
<
<
<
<
<
|
<
<
<
<
<
<
<
<
<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







1
2
3
4
5
6
7







8









9



















10
11
12
13
14
15
16
# autoaway.tcl --
#
#       This file is a part of the Tkabber XMPP client. It's a plugind which
#       switches Tkabber status to away or xa after a specified period of
#       inactivity.

namespace eval autoaway {







    if {[catch {tk inactive} idletime] || $idletime < 0} {









        return



















    }

    custom::defgroup AutoAway \
        [::msgcat::mc "Options for module that automatically marks\
                       you as away after idle threshold."] \
        -group Tkabber

118
119
120
121
122
123
124
125
126
127
128
129
130
131
132


133
134
135
136
137
138
139
}

proc autoaway::after_idle_aux {} {
    variable options
    variable savestatus
    variable savetext
    variable savepriority
    global idle_command
    global userstatus textstatus userpriority

    if {$options(awaytime) <= 0 && $options(xatime) <= 0} {
        return
    }

    set idletime [eval $idle_command]



    if {$idletime < $options(awaytime)*60*1000} {
        if {$savestatus ne ""} {
            if {$options(drop_priority) && $userpriority >= 0} {
                set userpriority $savepriority
            }
            set savepriority 0







<






|
>
>







83
84
85
86
87
88
89

90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
}

proc autoaway::after_idle_aux {} {
    variable options
    variable savestatus
    variable savetext
    variable savepriority

    global userstatus textstatus userpriority

    if {$options(awaytime) <= 0 && $options(xatime) <= 0} {
        return
    }

    if {[catch {tk inactive} idletime] || $idletime < 0} {
        return
    }

    if {$idletime < $options(awaytime)*60*1000} {
        if {$savestatus ne ""} {
            if {$options(drop_priority) && $userpriority >= 0} {
                set userpriority $savepriority
            }
            set savepriority 0
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212

proc autoaway::set_status {status} {
    if {[llength [connections]] > 0} {
        ::set_status $status
    }
}

proc autoaway::AquaIdleTime {} {
    catch { set line [read [set fd [open {|ioreg -x -c IOHIDSystem}]]] }
    close $fd

    expr {"0x[lindex [regexp -inline {"HIDIdleTime" = (?:0x|<)([[:xdigit:]]+)} \
                 $line] 1]"/1000000}
}

autoaway::load

# vim:ft=tcl:ts=8:sw=4:sts=4:et







<
<
<
<
<
<
<
<
<
<

161
162
163
164
165
166
167










168

proc autoaway::set_status {status} {
    if {[llength [connections]] > 0} {
        ::set_status $status
    }
}











# vim:ft=tcl:ts=8:sw=4:sts=4:et

Changes to plugins/iq/last.tcl.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# last.tcl --
#
#       This file is a part of the Tkabber XMPP client. It's a plugin
#       which replies to the jabber:iq:last (XEP-0012) requests.

custom::defvar options(reply_iq_last) 1 \
    [::msgcat::mc "Reply to idle time (jabber:iq:last) requests."] \
    -group IQ -type boolean

proc iq_last {xlib from child args} {
    global idle_command
    global userstatus statusdesc textstatus
    variable options

    if {$options(reply_iq_last) && [info exists idle_command]} {
        set seconds [expr {[eval $idle_command]/1000}]
        set status $statusdesc($userstatus)
        if {$textstatus eq ""} {
            set status "$statusdesc($userstatus) ($userstatus)"
        } else {
            set status "$textstatus ($userstatus)"
        }
        return [list result [::xmpp::xml::create query \
                                    -xmlns jabber:iq:last \
                                    -attrs [list seconds $seconds] \
                                    -cdata $status]]
    } else {
        return [list error cancel service-unavailable]
    }
}

::xmpp::iq::register get query jabber:iq:last [namespace current]::iq_last

# vim:ft=tcl:ts=8:sw=4:sts=4:et










<



|
|


|

|













1
2
3
4
5
6
7
8
9
10

11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# last.tcl --
#
#       This file is a part of the Tkabber XMPP client. It's a plugin
#       which replies to the jabber:iq:last (XEP-0012) requests.

custom::defvar options(reply_iq_last) 1 \
    [::msgcat::mc "Reply to idle time (jabber:iq:last) requests."] \
    -group IQ -type boolean

proc iq_last {xlib from child args} {

    global userstatus statusdesc textstatus
    variable options

    if {$options(reply_iq_last) && ![catch {tk inactive} ms] && $ms >= 0} {
        set seconds [expr {$ms/1000}]
        set status $statusdesc($userstatus)
        if {$textstatus eq ""} {
            set status "$statusdesc($userstatus)"
        } else {
            set status "$textstatus ($statusdesc($userstatus))"
        }
        return [list result [::xmpp::xml::create query \
                                    -xmlns jabber:iq:last \
                                    -attrs [list seconds $seconds] \
                                    -cdata $status]]
    } else {
        return [list error cancel service-unavailable]
    }
}

::xmpp::iq::register get query jabber:iq:last [namespace current]::iq_last

# vim:ft=tcl:ts=8:sw=4:sts=4:et