Tkabber

Check-in [8fd4536226]
Login

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

Overview
Comment:Read the logged messages not only for the JID which chat window is being opened, but also for all JIDs in a metacontact it belongs. This option is disabled by default. Since the metacontacts info isn't cached locally, this feature doesn't work for windows which open when saved state is restored on Tkabber start.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 8fd45362267f2630091b6503d73d21713c36b385
User & Date: sgolovan 2016-01-12 07:50:38
Context
2016-01-13
08:13
Fixed bug with names of temporary arrays clash. check-in: 0deb65402d user: sgolovan tags: trunk
2016-01-12
07:50
Read the logged messages not only for the JID which chat window is being opened, but also for all JIDs in a metacontact it belongs. This option is disabled by default. Since the metacontacts info isn't cached locally, this feature doesn't work for windows which open when saved state is restored on Tkabber start. check-in: 8fd4536226 user: sgolovan tags: trunk
2016-01-07
17:21
Relaxed the strategy of replay attack prevention: don't add own JID but a recipient's JID, and don't add extra info to the presence updates. Removed the loginconf(sslkeyfile) option, so now if someone wants to use a client sertificate, he'll have to bundle the private key together with the certificate itself. Updated Russian and Ukrainian translations. check-in: 434acd66d1 user: sgolovan tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ChangeLog.










1
2
3
4
5
6
7









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

	* plugins/general/gpgme.tcl: Relaxed the strategy of replay attack
	  prevention: don't add own JID but a recipient's JID, and don't add
	  extra info to the presence updates.

	* login.tcl: Removed the loginconf(sslkeyfile) option, so now if
>
>
>
>
>
>
>
>
>







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

	* plugins/chat/log_on_open.tcl, plugins/chat/logger.tcl: Read the
	  logged messages not only for the JID which chat window is being
	  opened, but also for all JIDs in a metacontact it belongs. This
	  option is disabled by default. Since the metacontacts info isn't
	  cached locally, this feature doesn't work for windows which open
	  when saved state is restored on Tkabber start.

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

	* plugins/general/gpgme.tcl: Relaxed the strategy of replay attack
	  prevention: don't add own JID but a recipient's JID, and don't add
	  extra info to the presence updates.

	* login.tcl: Removed the loginconf(sslkeyfile) option, so now if

Changes to plugins/chat/log_on_open.tcl.

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
52
53
54
55
56
57
58
        -type integer -group Chat
    custom::defvar options(max_interval) 24 \
        [::msgcat::mc "Maximum interval length in hours for which log\
                       messages should be shown in newly opened chat\
                       window (if set to negative then the interval is\
                       unlimited)."] \
        -type integer -group Chat








}

proc log_on_open::show {chatid type} {
    variable options

    if {$type ne "chat" && $type ne "groupchat"} return
    if {$type eq "chat" && !$options(enable_in_chats)} return
    if {$type eq "groupchat" && !$options(enable_in_groupchats)} return

    set xlib [chat::get_xlib $chatid]
    set jid [chat::get_jid $chatid]
    set bare_jid [::xmpp::jid::removeResource $jid]
    set gc [chat::is_groupchat [chat::chatid $xlib $bare_jid]]

    if {!$gc && ![::logger::logs_exist $jid]} {









        set log_jid $bare_jid





    } else {
        set log_jid $jid
    }

    set messages [::logger::get_last_messages $log_jid $type \
                                              $options(max_messages) \
                                              $options(max_interval)]

    foreach msg $messages {
        array unset tmp
        if {[catch {array set tmp $msg}]} continue








>
>
>
>
>
>
>
>














|
>
>
>
>
>
>
>
>
>
|
>
>
>
>
>

|


|







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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
        -type integer -group Chat
    custom::defvar options(max_interval) 24 \
        [::msgcat::mc "Maximum interval length in hours for which log\
                       messages should be shown in newly opened chat\
                       window (if set to negative then the interval is\
                       unlimited)."] \
        -type integer -group Chat
    custom::defvar options(use_metacontacts) 0 \
        [::msgcat::mc "If the chat window that is being opened belongs\
                       to a JID which corresponds to some metacontact\
                       in your roster then messages from all JIDs from\
                       that metacontact will show up in the window.\
                       This option requires enabling metacontacts in your\
                       roster."] \
        -type boolean -group Chat
}

proc log_on_open::show {chatid type} {
    variable options

    if {$type ne "chat" && $type ne "groupchat"} return
    if {$type eq "chat" && !$options(enable_in_chats)} return
    if {$type eq "groupchat" && !$options(enable_in_groupchats)} return

    set xlib [chat::get_xlib $chatid]
    set jid [chat::get_jid $chatid]
    set bare_jid [::xmpp::jid::removeResource $jid]
    set gc [chat::is_groupchat [chat::chatid $xlib $bare_jid]]

    if {!$gc && (![::logger::logs_exist $jid] || \
                 [::xmpp::jid::equal $jid $bare_jid])} {
        set log_jids [list $bare_jid]
        if {$::ifacetk::roster::options(enable_metacontacts) && \
                [llength [info procs ::plugins::metacontacts::*]] > 0 && \
                $options(use_metacontacts)} {
            foreach tag [::plugins::metacontacts::get_all_tags $xlib] {
                set jids [::plugins::metacontacts::get_jids $xlib $tag]
                foreach j $jids {
                    if {[::xmpp::jid::equal $j $bare_jid]} {
                        set log_jids $jids
                        break
                    }
                }
            }
        }
    } else {
        set log_jids [list $jid]
    }

    set messages [::logger::get_last_messages $log_jids $type \
                                              $options(max_messages) \
                                              $options(max_interval)]

    foreach msg $messages {
        array unset tmp
        if {[catch {array set tmp $msg}]} continue

Changes to plugins/chat/logger.tcl.

531
532
533
534
535
536
537
538
539
540
541
542

543
544




545
546
547
548

549
550
551


552
553
554
555
556
557
558
559
560

#############################################################################

proc ::logger::logs_exist {jid} {
    expr {[llength [get_subdirs [jid_to_filename $jid]]] > 0}
}

proc ::logger::get_last_messages {jid type max interval} {
    if {$max == 0 || $interval == 0} {
        return {}
    }


    set logfile [jid_to_filename $jid]
    set months [lsort -decreasing [get_subdirs $logfile]]




    set messages {}
    set curseconds [clock seconds]
    set max1 [expr {$max - 1}]
    foreach m $months {

        catch {
            set messages [lsort -increasing -index 1 \
                                [concat [read_hist_from_file $logfile $m] \


                                        $messages]]
        }
        if {$interval > 0} {
            set idx 0
            foreach msg $messages {
                unset -nocomplain tmp
                array set tmp $msg
                if {[info exists tmp(type)] && $tmp(type) ne $type} continue








|




>
|
|
>
>
>
>



|
>
|
<
|
>
>
|
|







531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555

556
557
558
559
560
561
562
563
564
565
566
567

#############################################################################

proc ::logger::logs_exist {jid} {
    expr {[llength [get_subdirs [jid_to_filename $jid]]] > 0}
}

proc ::logger::get_last_messages {jids type max interval} {
    if {$max == 0 || $interval == 0} {
        return {}
    }

    foreach jid $jids {
        set logfile [jid_to_filename $jid]
        foreach month [get_subdirs $logfile] {
            lappend tmp($month) $logfile
        }
    }

    set messages {}
    set curseconds [clock seconds]
    set max1 [expr {$max - 1}]
    foreach m [lsort -decreasing [array names tmp]] {
        foreach logfile $tmp($m) {
            catch {

                lappend messages {*}[read_hist_from_file $logfile $m]
            }
        }
        set messages [lsort -increasing -index 1 $messages]

        if {$interval > 0} {
            set idx 0
            foreach msg $messages {
                unset -nocomplain tmp
                array set tmp $msg
                if {[info exists tmp(type)] && $tmp(type) ne $type} continue