[Tkabber-dev] r2128 - in trunk/tkabber-plugins: . otr

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Sun Feb 2 13:43:14 MSK 2014


Author: sergei
Date: 2014-02-02 13:43:14 +0400 (Sun, 02 Feb 2014)
New Revision: 2128

Modified:
   trunk/tkabber-plugins/ChangeLog
   trunk/tkabber-plugins/otr/auth.tcl
   trunk/tkabber-plugins/otr/key.tcl
   trunk/tkabber-plugins/otr/otr.tcl
Log:
	* otr/otr.tcl, otr/auth.tcl, otr/key.otr: Copy keys fingerprints to
	  clipboard in authentication dialog, in manage key dialog, in
	  edit authentication dialog.


Modified: trunk/tkabber-plugins/ChangeLog
===================================================================
--- trunk/tkabber-plugins/ChangeLog	2014-02-02 07:14:13 UTC (rev 2127)
+++ trunk/tkabber-plugins/ChangeLog	2014-02-02 09:43:14 UTC (rev 2128)
@@ -3,6 +3,10 @@
 	* otr/key.tcl, otr/tclotr/key.tcl: Moved key generation procedure to
 	  the otr::key package.
 
+	* otr/otr.tcl, otr/auth.tcl, otr/key.otr: Copy keys fingerprints to
+	  clipboard in authentication dialog, in manage key dialog, in
+	  edit authentication dialog.
+
 2014-01-31  Sergei Golovan <sgolovan at nes.ru>
 
 	* otr/otr.tcl: Fixed typo in creating OTR button for normal message

Modified: trunk/tkabber-plugins/otr/auth.tcl
===================================================================
--- trunk/tkabber-plugins/otr/auth.tcl	2014-02-02 07:14:13 UTC (rev 2127)
+++ trunk/tkabber-plugins/otr/auth.tcl	2014-02-02 09:43:14 UTC (rev 2128)
@@ -319,10 +319,20 @@
 		   -command [namespace code [list set_delete $w $l $index 1]]
     $m add command -label [::msgcat::mc "Unmark for deletion"] \
 		   -command [namespace code [list set_delete $w $l $index 0]]
+    $m add command -label [::msgcat::mc "Copy to clipboard"] \
+		   -command [namespace code [list copy_to_clipboard $w $l $index]]
 
     tk_popup $m [winfo pointerx .] [winfo pointery .]
 }
 
+proc auth::copy_to_clipboard {w l index} {
+    set data [$l get $index]
+    clipboard clear
+    clipboard append [string range [lindex $data 1] 1 end-1]
+    clipboard append " "
+    clipboard append [string range [lindex $data 2] 1 end-1]
+}
+
 proc auth::set_authenticated {w l index val} {
     if {$val} {
 	set auth " [::msgcat::mc Yes] "

Modified: trunk/tkabber-plugins/otr/key.tcl
===================================================================
--- trunk/tkabber-plugins/otr/key.tcl	2014-02-02 07:14:13 UTC (rev 2127)
+++ trunk/tkabber-plugins/otr/key.tcl	2014-02-02 09:43:14 UTC (rev 2128)
@@ -187,6 +187,8 @@
     bind $w <Destroy> +[list unset -nocomplain [namespace current]::help]
     bind $w <Destroy> +[list unset -nocomplain [namespace current]::fingerprint]
 
+    bind $w <<Copy>> [namespace code [list add_to_clipboard]]
+
     message $f.header -text [::msgcat::mc "Manage OTR long term DSA private key for your JID"] \
 		      -width 12c
     grid $f.header -row 0 -column 0 -columnspan 2 -sticky nsew
@@ -230,6 +232,26 @@
     $w draw
 }
 
+# key::add_to_clipboard --
+#
+#	Add the current fingerprint to clipboard.
+#
+# Arguments:
+#	None
+#
+# Result:
+#	Empty string.
+#
+# Side effects:
+#	The current DSA key fingerprint is put to clipboard.
+
+proc key::add_to_clipboard {} {
+    variable fingerprint
+
+    clipboard clear
+    clipboard append $fingerprint
+}
+
 # key::fill_dialog --
 #
 #	Private procedure which showa an appropriate help message and

Modified: trunk/tkabber-plugins/otr/otr.tcl
===================================================================
--- trunk/tkabber-plugins/otr/otr.tcl	2014-02-02 07:14:13 UTC (rev 2127)
+++ trunk/tkabber-plugins/otr/otr.tcl	2014-02-02 09:43:14 UTC (rev 2128)
@@ -538,11 +538,8 @@
     $w add -text [::msgcat::mc "Cancel"] \
 	   -command [list destroy $w]
 
-    bind $w <Destroy> [list unset -nocomplain [namespace current]::ctx(status,$xlib,$jid)]
-    bind $w <Destroy> +[list unset -nocomplain [namespace current]::ctx(progress,$xlib,$jid)]
-    bind $w <Destroy> +[list unset -nocomplain [namespace current]::ctx(authmethod,$xlib,$jid)]
-    bind $w <Destroy> +[list unset -nocomplain [namespace current]::ctx(ihave,$xlib,$jid)]
-    bind $w <Destroy> +[list unset -nocomplain [namespace current]::ctx(smpdialog,$xlib,$jid)]
+    bind $w <Destroy> [namespace code [clear_dialog [double% $xlib] [double% $jid]]]
+    bind $w <<Copy>> [namespace code [add_to_clipboard [double% $xlib] [double% $jid]]]
 
     set f [$w getframe]
 
@@ -657,6 +654,27 @@
     $w draw
 }
 
+proc otr::clear_dialog {xlib jid} {
+    variable ctx
+
+    unset -nocomplain ctx(status,$xlib,$jid)
+    unset -nocomplain ctx(progress,$xlib,$jid)
+    unset -nocomplain ctx(authmethod,$xlib,$jid)
+    unset -nocomplain ctx(ihave,$xlib,$jid)
+    unset -nocomplain ctx(smpdialog,$xlib,$jid)
+}
+
+proc otr::add_to_clipboard {xlib jid} {
+    variable ctx
+
+    clipboard clear
+    if {![once_only $xlib $jid]} return
+
+    clipboard append [::otr::fingerprint $ctx($xlib,$jid) 1]
+    clipboard append \n
+    clipboard append [::otr::fingerprint $ctx($xlib,$jid) 0]
+}
+
 proc otr::smp_dialog_switch_page {w xlib jid name1 name2 op} {
     variable ctx
 
@@ -756,9 +774,7 @@
     $w add -text [::msgcat::mc "Cancel"] \
 	   -command [list destroy $w]
 
-    bind $w <Destroy> [list unset -nocomplain [namespace current]::ctx(status,$xlib,$jid)]
-    bind $w <Destroy> +[list unset -nocomplain [namespace current]::ctx(progress,$xlib,$jid)]
-    bind $w <Destroy> +[list unset -nocomplain [namespace current]::ctx(smpdialog,$xlib,$jid)]
+    bind $w <Destroy> [namespace code [clear_dialog [double% $xlib] [double% $jid]]]
 
     set f [$w getframe]
 
@@ -813,9 +829,7 @@
     $w add -text [::msgcat::mc "Cancel"] \
 	   -command [list destroy $w]
 
-    bind $w <Destroy> [list unset -nocomplain [namespace current]::ctx(status,$xlib,$jid)]
-    bind $w <Destroy> +[list unset -nocomplain [namespace current]::ctx(progress,$xlib,$jid)]
-    bind $w <Destroy> +[list unset -nocomplain [namespace current]::ctx(smpdialog,$xlib,$jid)]
+    bind $w <Destroy> [namespace code [clear_dialog [double% $xlib] [double% $jid]]]
 
     set f [$w getframe]
 



More information about the Tkabber-dev mailing list