[Tkabber-dev] r514 - in trunk/plugins/juick: . msgs

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Tue Apr 10 01:05:52 MSK 2012


Author: Totktonada
Date: 2012-04-10 01:05:52 +0400 (Tue, 10 Apr 2012)
New Revision: 514

Added:
   trunk/plugins/juick/msgs/
   trunk/plugins/juick/msgs/ru.msg
   trunk/plugins/juick/tkabber-0.11.1-compatibility.tcl
Removed:
   trunk/plugins/juick/msgs/
Modified:
   trunk/plugins/juick/juick.tcl
Log:
Juick plugin (svn branch):
* Both support Tkabber-0.11.1 and Tkabber-svn.
* Fix aligning.
* Replace tabs with spaces.


Modified: trunk/plugins/juick/juick.tcl
===================================================================
--- trunk/plugins/juick/juick.tcl	2012-03-20 11:03:35 UTC (rev 513)
+++ trunk/plugins/juick/juick.tcl	2012-04-09 21:05:52 UTC (rev 514)
@@ -1,13 +1,21 @@
 package require msgcat
 
-option add *juick.nick			red		widgetDefault
-option add *juick.tag			ForestGreen	widgetDefault
-option add *juick.my			gray		widgetDefault
-option add *juick.number		blue		widgetDefault
-option add *juick.private_foreground	blue		widgetDefault
-option add *juick.private_background	#FF9A15		widgetDefault
-option add *juick.citing		gray35		widgetDefault
+option add *juick.nick                  red            widgetDefault
+option add *juick.tag                   ForestGreen    widgetDefault
+option add *juick.my                    gray           widgetDefault
+option add *juick.number                blue           widgetDefault
+option add *juick.private_foreground    blue           widgetDefault
+option add *juick.private_background    #FF9A15        widgetDefault
+option add *juick.citing                gray35         widgetDefault
 
+if {[string equal $::tkabber_version "0.11.1"]} {
+    set scriptdir [file dirname [info script]]
+
+    catch {source [file join $scriptdir \
+        tkabber-0.11.1-compatibility.tcl]} \
+        source_compatibility_file_result
+}
+
 namespace eval juick {
 variable options
 variable juick_nicknames
@@ -23,23 +31,23 @@
               -loadcommand [namespace code load] \
               -unloadcommand [namespace code unload]
     return
-    }
+}
 
-        custom::defgroup Plugins [::msgcat::mc "Plugins options."] -group Tkabber
+custom::defgroup Plugins [::msgcat::mc "Plugins options."] -group Tkabber
 
-        set group "Juick"
-        custom::defgroup $group \
-                [::msgcat::mc "Juick settings."] \
-                -group Plugins
+set group "Juick"
+custom::defgroup $group \
+        [::msgcat::mc "Juick settings."] \
+        -group Plugins
 
-        custom::defvar options(main_jid) "juick at juick.com/Juick" \
-                [::msgcat::mc "Main Juick JID. This used for forwarding things from other chats."] \
-                -group $group \
-                -type string
-        custom::defvar options(special_update_juick_tab) 1 \
-                [::msgcat::mc "Only private messages and replies to your comments is personal message."] \
-                -group $group \
-                -type boolean
+custom::defvar options(main_jid) "juick at juick.com/Juick" \
+        [::msgcat::mc "Main Juick JID. This used for forwarding things from other chats."] \
+        -group $group \
+        -type string
+custom::defvar options(special_update_juick_tab) 1 \
+        [::msgcat::mc "Only private messages and replies to your comments is personal message."] \
+        -group $group \
+        -type boolean
 
 proc load {} {
     ::richtext::entity_state juick_numbers 1
@@ -437,6 +445,13 @@
     }
 }
 
+# See commented code in juick_commands_comps.
+#variable commands {HELP NICK LOGIN "S " "U " ON OFF "D " "BL " "WL " "PM " VCARD PING INVITE}
+variable commands {HELP NICK LOGIN S U ON OFF D BL WL PM CARD PING INVITE}
+proc correct_command {chatid user body type} {
+   # Maybe once I'll get arount to it 
+}
+
 proc juick_commands_comps {chatid compsvar wordstart line} {
     if {![is_juick $chatid]} return
 
@@ -457,7 +472,7 @@
                 set q 1
                 break
             }
-	    }
+        }
 
         if {!$q} return
 }
@@ -468,13 +483,6 @@
     }
 }
 
-# See commented code in juick_commands_comps.
-#variable commands {HELP NICK LOGIN "S " "U " ON OFF "D " "BL " "WL " "PM " VCARD PING INVITE}
-variable commands {HELP NICK LOGIN S U ON OFF D BL WL PM CARD PING INVITE}
-proc correct_command {chatid user body type} {
-   # Maybe once I'll get arount to it 
-}
-
 # --------------
 # RichText stuff
 

Added: trunk/plugins/juick/msgs/ru.msg
===================================================================
--- trunk/plugins/juick/msgs/ru.msg	                        (rev 0)
+++ trunk/plugins/juick/msgs/ru.msg	2012-04-09 21:05:52 UTC (rev 514)
@@ -0,0 +1,6 @@
+::msgcat::mcset ru "\[J\] Copy thing to clipboard." "\[J\] Скопировать сущность в буфер обмена."
+::msgcat::mcset ru "Whether the Juick plugin is loaded." "Загружено ли расширение для удобной работы с Juick."
+::msgcat::mcset ru "\[J\] Open thing in browser." "\[J\] Открыть сущность в браузере."
+::msgcat::mcset ru "Juick settings." "Параметры расширения для удобной работы с Juick"
+::msgcat::mcset ru "Main Juick JID. This used for forwarding things from other chats." "Главный JID Juick'а. Используется для перенаправления сущностей из других чатов."
+::msgcat::mcset ru "Only private messages and replies to your comments is personal message." "Только приватные сообщения и ответы на ваши комментарии являются персональными сообщениями."

Added: trunk/plugins/juick/tkabber-0.11.1-compatibility.tcl
===================================================================
--- trunk/plugins/juick/tkabber-0.11.1-compatibility.tcl	                        (rev 0)
+++ trunk/plugins/juick/tkabber-0.11.1-compatibility.tcl	2012-04-09 21:05:52 UTC (rev 514)
@@ -0,0 +1,215 @@
+if {[info exist ::tkabber-0.11.1-compatibility-sentry]} {
+    return
+}
+
+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
+    }
+}
+
+proc ::hook::remove {hook func {seq 50}} {
+    variable $hook
+
+    set idx [lsearch -exact [set $hook] [list $func $seq]]
+    set $hook [lreplace [set $hook] $idx $idx]
+}
+
+proc ::plugins::is_registered {name} {
+    variable juick_plugin_loaded
+
+    if {![info exists juick_plugin_loaded]} {
+        set juick_plugin_loaded 0
+    }
+
+    return $juick_plugin_loaded
+}
+
+proc ::plugins::register {name args} {
+    variable juick_plugin_loaded
+
+    if {$juick_plugin_loaded} {
+        return
+    }
+
+    set juick_plugin_loaded 1
+
+    foreach {key val} $args {
+        switch -- $key {
+            -source {
+                source $val
+            }
+            -loadcommand {
+                eval $val
+            }
+        }
+    }
+}
+
+proc ::chat::get_xlib {chatid} {
+    ::chat::get_connid $chatid
+}
+
+namespace eval ::xmpp::jid {}
+
+proc ::xmpp::jid::node {jid} {
+    set a [string first @ $jid]
+    if {$a < 0} {
+        return
+    } else {
+        set b [string first / $jid]
+        if {$b >= 0 && $a > $b} {
+            return
+        } else {
+            string range $jid 0 [incr a -1]
+        }
+    }
+}
+
+proc ::xmpp::jid::server {jid} {
+    set a [string first @ $jid]
+    set b [string first / $jid]
+
+    if {$a < 0} {
+        if {$b < 0} {
+            return $jid
+        } else {
+            string range $jid 0 [incr b -1]
+        }
+    } else {
+        if {$b < 0} {
+            string range $jid [incr a] end
+        } elseif {$a >= $b} {
+            string range $jid 0 [incr b -1]
+        } else {
+            string range $jid [incr a] [incr b -1]
+        }
+    }
+}
+
+proc ::xmpp::jid::removeResource {jid} {
+    set node     [node $jid]
+    set server   [server $jid]
+
+    if {[string equal $node ""]} {
+        set jid $server
+    } else {
+        set jid $node@$server
+    }
+
+    return $jid
+}
+
+namespace eval ::xmpp::xml {}
+
+proc ::xmpp::xml::split {xmldata tagVar xmlnsVar attrsVar \
+                        cdataVar subelsVar} {
+    upvar 1 $tagVar tag $xmlnsVar xmlns $attrsVar attrs $cdataVar cdata \
+            $subelsVar subels
+
+    jlib::wrapper:splitxml $xmldata tag attrs isempty cdata subels
+
+    foreach {key val} $attrs {
+        switch -- $key {
+            xmlns {
+                set xmlns $val
+            }
+        }
+    }
+}
+
+
+proc ::xmpp::xml::create {tag args} {
+    set invoke [list jlib::wrapper:createtag $tag -vars]
+
+    foreach {key val} $args {
+        switch -- $key {
+            -xmlns {
+                lappend invoke [list xmlns $val]
+            }
+            -attrs {
+                lappend invoke $val
+            }
+        }
+    }
+
+    eval $invoke
+}
+
+proc ::xmpp::sendIQ {xlib type args} {
+    set invoke [list jlib::send_iq $type]
+    set xmldata {}
+    set newargs {}
+
+    foreach {key val} $args {
+        switch -- $key {
+            -query {
+                set xmldata $val
+            }
+            -to {
+                lappend newargs $key $val
+            }
+            -command {
+                lappend newargs $key \
+                    [list [namespace current]::sendIQAnswer $val]
+            }
+        }
+    }
+
+    lappend invoke $xmldata
+    lappend invoke -connection $xlib
+
+    foreach arg $newargs {
+        lappend invoke $arg
+    }
+
+    eval $invoke
+}
+
+proc ::xmpp::sendIQAnswer {cmd res child} {
+    if {[string equal $res OK]} {
+        set res ok
+    }
+
+    uplevel #0 $cmd [list $res $child]
+}
+
+proc ::xmpp::xml::getAttr {attrList attrName} {
+    ::jlib::wrapper:getattr $attrList $attrName
+}
+
+proc ::chat::activate {chatid} {
+    raise_win [winid $chatid]
+    focus -force [input_win $chatid]
+}
+
+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
+    }
+
+    foreach {key val} $args {
+        lappend invoke $key $val
+    }
+
+    eval $invoke
+}



More information about the Tkabber-dev mailing list