[Tkabber-dev] [tclxmpp commit] r95 - * xmpp/zlib.tcl: Added a hack which doesn't allow to load xmpp::zlib

codesite-noreply at google.com codesite-noreply at google.com
Fri Mar 27 22:14:30 MSK 2009


Author: sgolovan
Date: Fri Mar 27 12:10:38 2009
New Revision: 95

Modified:
    trunk/ChangeLog
    trunk/xmpp/zlib.tcl

Log:
	* xmpp/zlib.tcl: Added a hack which doesn't allow to load xmpp::zlib
	  package if zlib from Ztcl can't be found. Also, moved zlib command to
	  ::xmpp::transport::zlib namespace because it isn't standard, so if,
	  for example, http package tries to get compressed data it fails.


Modified: trunk/ChangeLog
==============================================================================
--- trunk/ChangeLog	(original)
+++ trunk/ChangeLog	Fri Mar 27 12:10:38 2009
@@ -1,3 +1,10 @@
+2009-03-27  Sergei Golovan  <sgolovan at nes.ru>
+
+	* xmpp/zlib.tcl: Added a hack which doesn't allow to load xmpp::zlib
+	  package if zlib from Ztcl can't be found. Also, moved zlib command to
+	  ::xmpp::transport::zlib namespace because it isn't standard, so if,
+	  for example, http package tries to get compressed data it fails.
+
  2009-03-22  Sergei Golovan  <sgolovan at nes.ru>

  	* xmpp/negotiate.tcl: Added the possibility of unregistering features.

Modified: trunk/xmpp/zlib.tcl
==============================================================================
--- trunk/xmpp/zlib.tcl	(original)
+++ trunk/xmpp/zlib.tcl	Fri Mar 27 12:10:38 2009
@@ -10,7 +10,30 @@
  #
  # $Id$

-package require zlib 1.0
+namespace eval ::xmpp::transport::zlib {}
+
+if {[llength [info commands ::zlib]] == 0} {
+    package require zlib 1.0
+
+    if {[catch {::zlib info version}]} {
+        return -code error "Package zlib from Ztcl cannot be found"
+    }
+
+    rename ::zlib ::xmpp::transport::zlib::zlib
+} else {
+    rename ::zlib ::zlib:saved
+
+    if {[catch {package require zlib 1.0} msg]} {
+        rename ::zlib:saved ::zlib
+        return -code error $msg
+    } elseif {[catch {::zlib info version}]} {
+        rename ::zlib:saved ::zlib
+        return -code error "Package zlib from Ztcl cannot be found"
+    }
+
+    rename ::zlib ::xmpp::transport::zlib::zlib
+    rename ::zlib:saved ::zlib
+}

  package require pconnect
  package require xmpp::transport


More information about the Tkabber-dev mailing list