Tkabber contrib

Check-in [d08be32dce]
Login

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

Overview
Comment:Juick plugin (svn branch): * Optimize 'expr' usage and few indent fixes. * Fix string comparison by 'expr'.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:d08be32dce5b3abff2b3b1999d7325f674d725bc
User & Date: toktonada 2013-07-21 14:59:17
Context
2013-07-21
15:08
Notes plugin: * Fix typo in TODO comment. * Optimize 'expr' usage and few indent fixes. * Fix string comparison by 'expr'. check-in: 71e0f4186f user: toktonada tags: trunk
14:59
Juick plugin (svn branch): * Optimize 'expr' usage and few indent fixes. * Fix string comparison by 'expr'. check-in: d08be32dce user: toktonada tags: trunk
2013-05-31
15:57
Allow "s #dddddd+" command with small letter 's'. check-in: 42962ad511 user: toktonada tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to juick/juick.tcl.

136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
...
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
...
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
...
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
...
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
...
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
...
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688

689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
    ::richtext::entity_state juick 0
    ::richtext::entity_state juick_ligth 0
}

proc is_juick_jid {jid} {
    set jid [::xmpp::jid::removeResource $jid]
    set node [::xmpp::jid::node $jid]
    return [expr [string equal $jid "juick@juick.com"] || \
        [string equal $node "juick%juick.com"]]

#    if {$without_resource} { \
#        return [expr [string equal $jid "juick@juick.com"] \
#           || [regexp "juick%juick.com@.+" $jid]] \
#    } else { \
#       return [expr [string equal $jid "juick@juick.com/Juick"] \
#           || [regexp "juick%juick.com@.+/Juick" $jid]] \
#    }
}

# Determines whether given chatid correspond to Juick
proc is_juick {chatid} {
    set jid [chat::get_jid $chatid]
    return [is_juick_jid $jid]
................................................................................
        $body -> reply_to_nick]

    if {$reply_to_comment} {
        set reply_to_my_comment [string equal \
            [get_juick_nickname $from] $reply_to_nick]
    }

    return [expr $private_msg || $reply_to_my_comment]
}

proc update_juick_tab {chatid from type body x} {
    variable options
    if {![expr [is_juick_jid $from] && [string equal $type "chat"] \
        && $options(special_update_juick_tab)]} \
    {
        ::plugins::update_tab::update $chatid $from $type $body $x
        return
    }

    # See ${PATH_TO_TKABBER}/plugins/chat/update_tab.tcl
    foreach xelem $x {
................................................................................
        tab_set_updated $cw 1 mesg_to_user
    } else {
        tab_set_updated $cw 1 message
    }
}

proc ignore_server_messages {chatid from type body x} {
    if {[is_juick $chatid] && $from == ""} {
        return stop;
    }
}

proc add_number_of_messages_from_juick_to_title {chatid from type body x} {
    variable options
    if {![expr [is_juick_jid $from] && [string equal $type "chat"] \
        && $options(special_update_juick_tab)]} \
    {
        ::ifacetk::add_number_of_messages_to_title $chatid $from $type \
            $body $x
        return
    }

    # See ${PATH_TO_TKABBER}/ifacetk/iface.tcl
................................................................................
            [string equal $xmlns tkabber:x:nolog]} \
        {
            return
        }
    }

    if {[::ifacetk::chat_window_is_active $chatid]} return
    if {$from == ""} return

    variable ::ifacetk::number_msg
    variable ::ifacetk::personal_msg

    incr number_msg($chatid)

    if {[is_personal_juick_message $from $body]} {
................................................................................

    set tags [$cw tag names "@$x,$y"]

    if {[set idx [lsearch -glob $tags JUICK-*]] >= 0} {
        set thing [string range [lindex $tags $idx] 6 end]
    }

    if {$thing == ""} return

    if {![is_juick_jid $jid]} {
        set xlib [chat::get_xlib $chatid]
        set mainchat [chat::chatid $xlib $options(main_jid)]

        if {[chat::is_opened $mainchat]} {
            chat::activate $mainchat
................................................................................
    set thing ""
    set tags [$chatwin tag names "@$x,$y"]

    if {[set idx [lsearch -glob $tags JUICK-*]] >= 0} {
        set thing [string range [lindex $tags $idx] 6 end]
    }

    if {$thing == ""} return

    $m add command -label [::msgcat::mc \
        "\[J\] Copy thing to clipboard."] \
        -command [list [namespace current]::copy_thing $chatwin $thing]

    $m add command -label [::msgcat::mc \
        "\[J\] Open thing in browser."] \
................................................................................
    foreach {s type tags} $chunks {
        if {[lsearch -regexp $type (text)|(citing)|(juick_ligth)] < 0} {
            # pass through
            lappend out $s $type $tags
            continue
        }

        if {[expr [lsearch -exact $type citing]>=0]} {
        lappend tags CITING
        }

        if {[expr [lsearch -exact $type juick_ligth]>=0]} {
        lappend tags JLIGTH
        }

        set index 0; set uStart 0; set uEnd 0
        while {[eval {spot_$what $s $index uStart uEnd}]} {
            if {$uStart - $index > 0} {
                # Write out text before current thing, if any:

                lappend out [string range $s $index \
                    [expr {$uStart - 1}]] $type $tags
            }

            set thing [string range $s $uStart $uEnd]
            # Write out current thing:
            lappend out $thing $what $tags
            set index [expr {$uEnd + 1}]
        }
        # Write out text after the last thing, if any:
        if {[string length $s] - $index > 0} {
        lappend out [string range $s $index end] $type $tags
        }
    }
    set chunks $out
}

proc render_juick {w type thing tags args} {
    if {[expr [lsearch -exact $tags CITING] < 0] && \
        [expr [lsearch -exact $tags JLIGTH] < 0]} \
    {
        if {[string equal [string index $thing 0] "#" ]} {
            set type JNUM
        } elseif {[string equal [string index $thing 0] "*" ]} {
            set type JTAG
        } elseif {[string equal [string index $thing 0] "@" ]} {
            set type JNICK
        }
    } else {
           if {[lsearch -exact $tags CITING] >= 0} {
               set type CITING
           }
           if {[lsearch -exact $tags JLIGTH] >= 0} {







|
|


|
|

|
|







 







|




|
|







 







|
|





|
|







 







|







 







|







 







|







 







|
|


|
|






>
|
|









|






|
|

|

|

|







136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
...
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
...
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
...
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
...
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
...
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
...
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
    ::richtext::entity_state juick 0
    ::richtext::entity_state juick_ligth 0
}

proc is_juick_jid {jid} {
    set jid [::xmpp::jid::removeResource $jid]
    set node [::xmpp::jid::node $jid]
    return [expr {[string equal $jid "juick@juick.com"] || \
        [string equal $node "juick%juick.com"]}]

#    if {$without_resource} { \
#        return [expr {[string equal $jid "juick@juick.com"] \
#           || [regexp "juick%juick.com@.+" $jid]}] \
#    } else { \
#       return [expr {[string equal $jid "juick@juick.com/Juick"] \
#           || [regexp "juick%juick.com@.+/Juick" $jid]}] \
#    }
}

# Determines whether given chatid correspond to Juick
proc is_juick {chatid} {
    set jid [chat::get_jid $chatid]
    return [is_juick_jid $jid]
................................................................................
        $body -> reply_to_nick]

    if {$reply_to_comment} {
        set reply_to_my_comment [string equal \
            [get_juick_nickname $from] $reply_to_nick]
    }

    return [expr {$private_msg || $reply_to_my_comment}]
}

proc update_juick_tab {chatid from type body x} {
    variable options
    if {!([is_juick_jid $from] && [string equal $type "chat"] \
        && $options(special_update_juick_tab))} \
    {
        ::plugins::update_tab::update $chatid $from $type $body $x
        return
    }

    # See ${PATH_TO_TKABBER}/plugins/chat/update_tab.tcl
    foreach xelem $x {
................................................................................
        tab_set_updated $cw 1 mesg_to_user
    } else {
        tab_set_updated $cw 1 message
    }
}

proc ignore_server_messages {chatid from type body x} {
    if {[is_juick $chatid] && $from eq ""} {
        return stop
    }
}

proc add_number_of_messages_from_juick_to_title {chatid from type body x} {
    variable options
    if {!([is_juick_jid $from] && [string equal $type "chat"] \
        && $options(special_update_juick_tab))} \
    {
        ::ifacetk::add_number_of_messages_to_title $chatid $from $type \
            $body $x
        return
    }

    # See ${PATH_TO_TKABBER}/ifacetk/iface.tcl
................................................................................
            [string equal $xmlns tkabber:x:nolog]} \
        {
            return
        }
    }

    if {[::ifacetk::chat_window_is_active $chatid]} return
    if {$from eq ""} return

    variable ::ifacetk::number_msg
    variable ::ifacetk::personal_msg

    incr number_msg($chatid)

    if {[is_personal_juick_message $from $body]} {
................................................................................

    set tags [$cw tag names "@$x,$y"]

    if {[set idx [lsearch -glob $tags JUICK-*]] >= 0} {
        set thing [string range [lindex $tags $idx] 6 end]
    }

    if {$thing eq ""} return

    if {![is_juick_jid $jid]} {
        set xlib [chat::get_xlib $chatid]
        set mainchat [chat::chatid $xlib $options(main_jid)]

        if {[chat::is_opened $mainchat]} {
            chat::activate $mainchat
................................................................................
    set thing ""
    set tags [$chatwin tag names "@$x,$y"]

    if {[set idx [lsearch -glob $tags JUICK-*]] >= 0} {
        set thing [string range [lindex $tags $idx] 6 end]
    }

    if {$thing eq ""} return

    $m add command -label [::msgcat::mc \
        "\[J\] Copy thing to clipboard."] \
        -command [list [namespace current]::copy_thing $chatwin $thing]

    $m add command -label [::msgcat::mc \
        "\[J\] Open thing in browser."] \
................................................................................
    foreach {s type tags} $chunks {
        if {[lsearch -regexp $type (text)|(citing)|(juick_ligth)] < 0} {
            # pass through
            lappend out $s $type $tags
            continue
        }

        if {[lsearch -exact $type citing] >=0} {
            lappend tags CITING
        }

        if {[lsearch -exact $type juick_ligth] >= 0} {
            lappend tags JLIGTH
        }

        set index 0; set uStart 0; set uEnd 0
        while {[eval {spot_$what $s $index uStart uEnd}]} {
            if {$uStart - $index > 0} {
                # Write out text before current thing, if any:
                lappend out \
                    [string range $s $index [expr {$uStart - 1}]] \
                    $type $tags
            }

            set thing [string range $s $uStart $uEnd]
            # Write out current thing:
            lappend out $thing $what $tags
            set index [expr {$uEnd + 1}]
        }
        # Write out text after the last thing, if any:
        if {[string length $s] - $index > 0} {
            lappend out [string range $s $index end] $type $tags
        }
    }
    set chunks $out
}

proc render_juick {w type thing tags args} {
    if {[lsearch -exact $tags CITING] < 0 && \
        [lsearch -exact $tags JLIGTH] < 0} \
    {
        if {[string equal [string index $thing 0] "#"]} {
            set type JNUM
        } elseif {[string equal [string index $thing 0] "*"]} {
            set type JTAG
        } elseif {[string equal [string index $thing 0] "@"]} {
            set type JNICK
        }
    } else {
           if {[lsearch -exact $tags CITING] >= 0} {
               set type CITING
           }
           if {[lsearch -exact $tags JLIGTH] >= 0} {

Changes to juick/tkabber-0.11.1-compatibility.tcl.

5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
...
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
set ::tkabber-0.11.1-compatibility-sentry 1

rename ::hook::add ::hook::add_orig

proc ::hook::add {hook func {seq 50}} {
    if {[string equal $hook roster_push_hook] && \
        [string equal $func "::plugins::juick::request_juick_nick"] && \
        [expr $seq == 99]} \
    {
        ::hook::add_orig roster_item_hook $func $seq
    } else {
        ::hook::add_orig $hook $func $seq
    }
}

................................................................................
}

rename ::message::send_msg ::message::send_msg_tkabber_0_11_1

proc ::message::send_msg {xlib args} {
    set invoke [list ::message::send_msg_tkabber_0_11_1]

    if {[expr [llength $args] % 2] == 0} {
        # tkabber-0.11.1 invoke
        set jid $xlib
        lappend invoke $jid
    } else {
        set jid [lindex $args 0]
        set args [lrange $args 1 end]
        lappend invoke $jid -connection $xlib







|







 







|







5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
...
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
set ::tkabber-0.11.1-compatibility-sentry 1

rename ::hook::add ::hook::add_orig

proc ::hook::add {hook func {seq 50}} {
    if {[string equal $hook roster_push_hook] && \
        [string equal $func "::plugins::juick::request_juick_nick"] && \
        $seq == 99} \
    {
        ::hook::add_orig roster_item_hook $func $seq
    } else {
        ::hook::add_orig $hook $func $seq
    }
}

................................................................................
}

rename ::message::send_msg ::message::send_msg_tkabber_0_11_1

proc ::message::send_msg {xlib args} {
    set invoke [list ::message::send_msg_tkabber_0_11_1]

    if {[llength $args] % 2 == 0} {
        # tkabber-0.11.1 invoke
        set jid $xlib
        lappend invoke $jid
    } else {
        set jid [lindex $args 0]
        set args [lrange $args 1 end]
        lappend invoke $jid -connection $xlib