[Tkabber-dev] r1520 - in trunk/tkabber: . doc examples/configs ifacetk msgs plugins/chat plugins/filetransfer plugins/general plugins/iq plugins/pep plugins/richtext plugins/roster plugins/search plugins/si plugins/unix

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Fri Oct 17 21:16:09 MSD 2008


Author: sergei
Date: 2008-10-17 21:16:09 +0400 (Fri, 17 Oct 2008)
New Revision: 1520

Added:
   trunk/tkabber/idna.tcl
   trunk/tkabber/namespaces.tcl
Removed:
   trunk/tkabber/ckabber.tcl
   trunk/tkabber/ifaceck/
   trunk/tkabber/jabberlib/
   trunk/tkabber/plugins/iq/oob.tcl
   trunk/tkabber/tclxml/
Modified:
   trunk/tkabber/
   trunk/tkabber/ChangeLog
   trunk/tkabber/chats.tcl
   trunk/tkabber/datagathering.tcl
   trunk/tkabber/disco.tcl
   trunk/tkabber/doc/tkabber.xml
   trunk/tkabber/examples/configs/badlop-config.tcl
   trunk/tkabber/examples/configs/mtr-config.tcl
   trunk/tkabber/examples/configs/teo-config.tcl
   trunk/tkabber/filetransfer.tcl
   trunk/tkabber/filters.tcl
   trunk/tkabber/gpgme.tcl
   trunk/tkabber/iface.tcl
   trunk/tkabber/ifacetk/iface.tcl
   trunk/tkabber/ifacetk/ilogin.tcl
   trunk/tkabber/ifacetk/iroster.tcl
   trunk/tkabber/iq.tcl
   trunk/tkabber/itemedit.tcl
   trunk/tkabber/joingrdialog.tcl
   trunk/tkabber/login.tcl
   trunk/tkabber/messages.tcl
   trunk/tkabber/msgs/ru.msg
   trunk/tkabber/msgs/uk.msg
   trunk/tkabber/muc.tcl
   trunk/tkabber/negotiate.tcl
   trunk/tkabber/pep.tcl
   trunk/tkabber/pixmaps.tcl
   trunk/tkabber/plugins/chat/bookmark_highlighted.tcl
   trunk/tkabber/plugins/chat/chatstate.tcl
   trunk/tkabber/plugins/chat/clear.tcl
   trunk/tkabber/plugins/chat/complete_last_nick.tcl
   trunk/tkabber/plugins/chat/completion.tcl
   trunk/tkabber/plugins/chat/disco.tcl
   trunk/tkabber/plugins/chat/draw_normal_message.tcl
   trunk/tkabber/plugins/chat/draw_timestamp.tcl
   trunk/tkabber/plugins/chat/draw_xhtml_message.tcl
   trunk/tkabber/plugins/chat/events.tcl
   trunk/tkabber/plugins/chat/info_commands.tcl
   trunk/tkabber/plugins/chat/irc_commands.tcl
   trunk/tkabber/plugins/chat/log_on_open.tcl
   trunk/tkabber/plugins/chat/logger.tcl
   trunk/tkabber/plugins/chat/me_command.tcl
   trunk/tkabber/plugins/chat/muc_ignore.tcl
   trunk/tkabber/plugins/chat/nick_colors.tcl
   trunk/tkabber/plugins/chat/open_chat.tcl
   trunk/tkabber/plugins/chat/send_message.tcl
   trunk/tkabber/plugins/chat/update_tab.tcl
   trunk/tkabber/plugins/filetransfer/http.tcl
   trunk/tkabber/plugins/filetransfer/si.tcl
   trunk/tkabber/plugins/general/autoaway.tcl
   trunk/tkabber/plugins/general/avatars.tcl
   trunk/tkabber/plugins/general/caps.tcl
   trunk/tkabber/plugins/general/challenge.tcl
   trunk/tkabber/plugins/general/clientinfo.tcl
   trunk/tkabber/plugins/general/copy_jid.tcl
   trunk/tkabber/plugins/general/headlines.tcl
   trunk/tkabber/plugins/general/jitworkaround.tcl
   trunk/tkabber/plugins/general/message_archive.tcl
   trunk/tkabber/plugins/general/offline.tcl
   trunk/tkabber/plugins/general/rawxml.tcl
   trunk/tkabber/plugins/general/remote.tcl
   trunk/tkabber/plugins/general/session.tcl
   trunk/tkabber/plugins/general/sound.tcl
   trunk/tkabber/plugins/general/stats.tcl
   trunk/tkabber/plugins/general/subscribe_gateway.tcl
   trunk/tkabber/plugins/general/xaddress.tcl
   trunk/tkabber/plugins/general/xcommands.tcl
   trunk/tkabber/plugins/iq/browse.tcl
   trunk/tkabber/plugins/iq/last.tcl
   trunk/tkabber/plugins/iq/ping.tcl
   trunk/tkabber/plugins/iq/time.tcl
   trunk/tkabber/plugins/iq/time2.tcl
   trunk/tkabber/plugins/iq/version.tcl
   trunk/tkabber/plugins/pep/user_activity.tcl
   trunk/tkabber/plugins/pep/user_location.tcl
   trunk/tkabber/plugins/pep/user_mood.tcl
   trunk/tkabber/plugins/pep/user_tune.tcl
   trunk/tkabber/plugins/richtext/emoticons.tcl
   trunk/tkabber/plugins/roster/annotations.tcl
   trunk/tkabber/plugins/roster/backup.tcl
   trunk/tkabber/plugins/roster/bkup_annotations.tcl
   trunk/tkabber/plugins/roster/bkup_conferences.tcl
   trunk/tkabber/plugins/roster/cache_categories.tcl
   trunk/tkabber/plugins/roster/conferenceinfo.tcl
   trunk/tkabber/plugins/roster/conferences.tcl
   trunk/tkabber/plugins/roster/fetch_nicknames.tcl
   trunk/tkabber/plugins/roster/roster_delimiter.tcl
   trunk/tkabber/plugins/roster/rosterx.tcl
   trunk/tkabber/plugins/search/logger.tcl
   trunk/tkabber/plugins/si/ibb.tcl
   trunk/tkabber/plugins/si/iqibb.tcl
   trunk/tkabber/plugins/si/socks5.tcl
   trunk/tkabber/plugins/unix/wmdock.tcl
   trunk/tkabber/presence.tcl
   trunk/tkabber/privacy.tcl
   trunk/tkabber/private.tcl
   trunk/tkabber/pubsub.tcl
   trunk/tkabber/register.tcl
   trunk/tkabber/roster.tcl
   trunk/tkabber/search.tcl
   trunk/tkabber/si.tcl
   trunk/tkabber/splash.tcl
   trunk/tkabber/tkabber.tcl
   trunk/tkabber/userinfo.tcl
   trunk/tkabber/utils.tcl
   trunk/tkabber/xmppmime.tcl
Log:
	* *: Massive update caused by moving to an external XMPP library
	  TclXMPP (http://code.google.com/p/tclxmpp/).

	* tclxmpp: Added map to external repository
	  http://tclxmpp.googlecode.com/svn/trunk/

	* ckabber.tcl, ifaceck/*: Removed.



Property changes on: trunk/tkabber
___________________________________________________________________
Added: svn:externals
   + tclxmpp http://tclxmpp.googlecode.com/svn/trunk/


Modified: trunk/tkabber/ChangeLog
===================================================================
--- trunk/tkabber/ChangeLog	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/ChangeLog	2008-10-17 17:16:09 UTC (rev 1520)
@@ -10,7 +10,14 @@
 
 	* tkabber.tcl: Pushed version number to 0.11.1-svn.
 
+	* *: Massive update caused by moving to an external XMPP library
+	  TclXMPP (http://code.google.com/p/tclxmpp/).
 
+	* tclxmpp: Added map to external repository
+	  http://tclxmpp.googlecode.com/svn/trunk/
+
+	* ckabber.tcl, ifaceck/*: Removed.
+
 2008-10-11  Sergei Golovan  <sgolovan at nes.ru>
 
 	* AUTHORS: Fixed authors list.

Modified: trunk/tkabber/chats.tcl
===================================================================
--- trunk/tkabber/chats.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/chats.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -47,15 +47,15 @@
 proc chat::open_chat_dialog {} {
     variable open_chat_jid
     variable open_chat_list
-    variable open_chat_connid
+    variable open_chat_xlib
 
-    if {[lempty [jlib::connections]]} return
+    if {[lempty [connections]]} return
 
     set gw .open_chat
     catch { destroy $gw }
 
-    set connid [lindex [jlib::connections] 0]
-    set open_chat_connid [jlib::connection_jid $connid]
+    set xlib [lindex [connections] 0]
+    set open_chat_xlib [connection_jid $xlib]
 
     Dialog $gw -title [::msgcat::mc "Open chat"] -separator 1 -anchor e \
 	    -default 0 -cancel 1
@@ -72,13 +72,13 @@
     grid $gf.ljid -row 0 -column 0 -sticky e
     grid $gf.jid  -row 0 -column 1 -sticky ew
 
-    if {[llength [jlib::connections]] > 1} {
+    if {[llength [connections]] > 1} {
 	set connections {}
-	foreach c [jlib::connections] {
-	    lappend connections [jlib::connection_jid $c]
+	foreach c [connections] {
+	    lappend connections [connection_jid $c]
 	}
 	label $gf.lconnection -text [::msgcat::mc "Connection:"]
-	ComboBox $gf.connection -textvariable [namespace current]::open_chat_connid \
+	ComboBox $gf.connection -textvariable [namespace current]::open_chat_xlib \
 				-values $connections
 
 	grid $gf.lconnection -row 1 -column 0 -sticky e
@@ -94,21 +94,23 @@
 proc chat::open_chat {gw} {
     variable open_chat_jid
     variable open_chat_list
-    variable open_chat_connid
+    variable open_chat_xlib
 
     destroy $gw
 
-    foreach c [jlib::connections] {
-	if {[jlib::connection_jid $c] == $open_chat_connid} {
-	    set connid $c
+    if {[llength [connections]] == 0} return
+
+    foreach c [connections] {
+	if {[connection_jid $c] == $open_chat_xlib} {
+	    set xlib $c
 	}
     }
-    if {![info exists connid]} {
-	set connid [jlib::route $open_chat_jid]
+    if {![info exists xlib]} {
+	set xlib [lindex [connections] 0]
     }
 
     set open_chat_list [update_combo_list $open_chat_list $open_chat_jid 20]
-    open_to_user $connid $open_chat_jid
+    open_to_user $xlib $open_chat_jid
 }
 
 # chat::close --
@@ -119,19 +121,19 @@
     ifacetk::destroy_win [winid $chatid]
 }
 
-proc chat::get_nick {connid jid type} {
+proc chat::get_nick {xlib jid type} {
     variable chats
 
     set nick $jid
     switch -- $type {
 	chat {
 	    set group [node_and_server_from_jid $jid]
-	    set chatid1 [chatid $connid $group]
+	    set chatid1 [chatid $xlib $group]
 	    if {[is_groupchat $chatid1]} {
 		set nick [resource_from_jid $jid]
 	    } else {
-		set nick [roster::itemconfig $connid \
-			      [roster::find_jid $connid $jid] -name]
+		set nick [roster::itemconfig $xlib \
+			      [roster::find_jid $xlib $jid] -name]
 		if {$nick == ""} {
 		    if {[node_from_jid $jid] != ""} {
 			set nick [node_from_jid $jid]
@@ -149,10 +151,10 @@
 }
 
 proc chat::winid {chatid} {
-    set connid [get_connid $chatid]
+    set xlib [get_xlib $chatid]
     set jid [get_jid $chatid]
     set tag [jid_to_tag $jid]
-    return .chat_${connid}_$tag
+    return .chat_[string map {: #} $xlib]_$tag
 }
 
 proc chat::winid_to_chatid {winid} {
@@ -160,11 +162,11 @@
     expr {[info exists chat_id($winid)] ? $chat_id($winid) : ""}
 }
 
-proc chat::chatid {connid jid} {
-    return [list $connid $jid]
+proc chat::chatid {xlib jid} {
+    return [list $xlib $jid]
 }
 
-proc chat::get_connid {chatid} {
+proc chat::get_xlib {chatid} {
     return [lindex $chatid 0]
 }
 
@@ -174,26 +176,49 @@
 
 ###############################################################################
 
-proc client:message \
-     {connid from id type is_subject subject body err thread priority x} {
+proc client:message {xlib from type x args} {
+    set id ""
+    set body ""
+    set is_subject 0
+    set subject ""
+    set thread ""
+    set priority ""
+    set err {}
+    foreach {key val} $args {
+	switch -- $key {
+	    -id {
+		set id $val
+	    }
+	    -body {
+		set body $val
+	    }
+	    -subject {
+		set is_subject 1
+		set subject $val
+	    }
+	    -error {
+		set err $val
+	    }
+	}
+    }
 
-    debugmsg chat "MESSAGE: $connid; $from; $id; $type; $is_subject;\
+    debugmsg chat "MESSAGE: $xlib; $from; $id; $type; $is_subject;\
 		   $subject; $body; $err; $thread; $priority; $x"
 
-    hook::run rewrite_message_hook connid from id type is_subject \
+    hook::run rewrite_message_hook xlib from id type is_subject \
 				   subject body err thread priority x
 
-    debugmsg chat "REWRITTEN MESSAGE: $connid; $from; $id; $type; $is_subject;\
+    debugmsg chat "REWRITTEN MESSAGE: $xlib; $from; $id; $type; $is_subject;\
 		   $subject; $body; $err; $thread; $priority; $x"
 
-    hook::run process_message_hook $connid $from $id $type $is_subject \
+    hook::run process_message_hook $xlib $from $id $type $is_subject \
 				   $subject $body $err $thread $priority $x
 }
 
 ###############################################################################
 
 proc chat::rewrite_message \
-     {vconnid vfrom vid vtype vis_subject vsubject \
+     {vxlib vfrom vid vtype vis_subject vsubject \
       vbody verr vthread vpriority vx} {
     upvar 2 $vfrom from
     upvar 2 $vtype type
@@ -211,10 +236,10 @@
 ###############################################################################
 
 proc chat::process_message_fallback \
-     {connid from id type is_subject subject body err thread priority x} {
+     {xlib from id type is_subject subject body err thread priority x} {
     variable chats
 
-    set chatid [chatid $connid $from]
+    set chatid [chatid $xlib $from]
 
     switch -- $type {
 	chat {
@@ -224,7 +249,7 @@
 	    set chats(id,$chatid) $id
 	}
 	groupchat {
-	    set chatid [chatid $connid [node_and_server_from_jid $from]]
+	    set chatid [chatid $xlib [node_and_server_from_jid $from]]
 
 	    if {![is_groupchat $chatid]} return
 
@@ -265,7 +290,7 @@
 
     chat::add_message $chatid $from $type $body $x
     if {[llength $x] > 0} {
-        message::show_dialog $connid $from $id $type $subject $body $thread $priority $x 0
+        message::show_dialog $xlib $from $id $type $subject $body $thread $priority $x 0
     }
 }
 
@@ -275,10 +300,10 @@
 ###############################################################################
 
 proc chat::window_titles {chatid} {
-    set connid [get_connid $chatid]
+    set xlib [get_xlib $chatid]
     set jid [get_jid $chatid]
-    set chatname [roster::itemconfig $connid \
-		      [roster::find_jid $connid $jid] -name]
+    set chatname [roster::itemconfig $xlib \
+		      [roster::find_jid $xlib $jid] -name]
     if {$chatname != ""} {
 	set tabtitlename $chatname
 	set titlename $chatname
@@ -287,7 +312,7 @@
 	if {[is_groupchat $chatid]} {
 	    set tabtitlename [node_from_jid $jid]
 	} else {
-	    set tabtitlename [get_nick $connid $jid chat]
+	    set tabtitlename [get_nick $xlib $jid chat]
 	}
 	if {$tabtitlename == ""} {
 	    set tabtitlename $titlename
@@ -296,18 +321,18 @@
     return [list $tabtitlename [format [::msgcat::mc "Chat with %s"] $titlename]]
 }
 
-proc chat::reconnect_groupchats {connid} {
+proc chat::reconnect_groupchats {xlib} {
     variable chats
     global grouproster
 	
-    foreach chatid [opened $connid] {
+    foreach chatid [opened $xlib] {
 	if {[is_groupchat $chatid]} {
 	    if {[info exists ::muc::muc_password($chatid)]} {
 		set password $::muc::muc_password($chatid)
 	    } else {
 		set password ""
 	    }
-	    muc::join_group $connid \
+	    muc::join_group $xlib \
 			    [get_jid $chatid] \
 			    [get_our_groupchat_nick $chatid] \
 			    $password
@@ -319,11 +344,11 @@
 
 hook::add connected_hook [namespace current]::chat::reconnect_groupchats 99
 
-proc chat::disconnect_groupchats {connid} {
+proc chat::disconnect_groupchats {xlib} {
     variable chats
     global statusdesc
 
-    foreach chatid [opened $connid] {
+    foreach chatid [opened $xlib] {
 	if {![winfo exists [chat_win $chatid]]} return
 
 	set jid [get_jid $chatid]
@@ -337,7 +362,7 @@
 
 	if {[winfo exists $cw.status.icon]} {
 	    $cw.status.icon configure \
-		-image [ifacetk::roster::get_jid_icon $connid $jid unavailable] \
+		-image [ifacetk::roster::get_jid_icon $xlib $jid unavailable] \
 		-helptext ""
 	}
 
@@ -359,10 +384,10 @@
     global grouproster
     global statusdesc
 
-    set connid [get_connid $chatid]
+    set xlib [get_xlib $chatid]
     set jid [get_jid $chatid]
     set jid [tolower_node_and_domain $jid]
-    set chatid [chatid $connid $jid]
+    set chatid [chatid $xlib $jid]
 
     set cw [winid $chatid]
 
@@ -416,14 +441,14 @@
     frame $cw.status
     pack $cw.status -side top -fill x
     if {[cequal $type chat]} {
-	set status [get_user_status $connid $jid]
+	set status [get_user_status $xlib $jid]
 	Label $cw.status.icon \
-	    -image [ifacetk::roster::get_jid_icon $connid $jid $status] \
-	    -helptext [get_user_status_desc $connid $jid]
+	    -image [ifacetk::roster::get_jid_icon $xlib $jid $status] \
+	    -helptext [get_user_status_desc $xlib $jid]
 	pack $cw.status.icon -side left
 	if {$options(display_status_description)} {
 	    Label $cw.status.desc -text "($statusdesc($status))" \
-		-helptext [get_user_status_desc $connid $jid]
+		-helptext [get_user_status_desc $xlib $jid]
 	    pack $cw.status.desc -side left
 	}
     }
@@ -576,14 +601,14 @@
 proc chat::dropovercmd {chatid target source event x y op type data} {
     variable chats
 
-    set chat_connid [get_connid $chatid]
-    lassign $data jid_connid jid
+    set chat_xlib [get_xlib $chatid]
+    lassign $data jid_xlib jid
 
     if {$source != ".roster.canvas" || \
 	    ![info exists chats(status,$chatid)] || \
 	    $chats(status,$chatid) == "disconnected" || \
-	    $chat_connid != $jid_connid || \
-	    ![::roster::itemconfig $jid_connid $jid -isuser]} {
+	    $chat_xlib != $jid_xlib || \
+	    ![::roster::itemconfig $jid_xlib $jid -isuser]} {
 	DropSite::setcursor dot
 	return 0
     } else {
@@ -596,21 +621,21 @@
 
 proc chat::dropcmd {chatid target source x y op type data} {
     set group [get_jid $chatid]
-    lassign $data connid jid
+    lassign $data xlib jid
     set reason [::msgcat::mc "Please join %s" $group]
 
     if {[muc::is_compatible $group]} {
-	muc::invite_muc $connid $group $jid $reason
+	muc::invite_muc $xlib $group $jid $reason
     } else {
-	muc::invite_xconference $connid $group $jid $reason
+	muc::invite_xconference $xlib $group $jid $reason
     }
 }
 
 ###############################################################################
 
 proc chat::user_singleclick {chatid cjid} {
-    lassign $cjid connid jid
-    set nick [get_nick $connid $jid groupchat]
+    lassign $cjid xlib jid
+    set nick [get_nick $xlib $jid groupchat]
     hook::run groupchat_roster_user_singleclick_hook $chatid $nick
 }
 
@@ -634,19 +659,19 @@
 
     remove_from_opened $chatid
 
-    set connid [get_connid $chatid]
+    set xlib [get_xlib $chatid]
     set jid [get_jid $chatid]
 
     set cw [winid $chatid]
     unset chat_id($cw)
 
     if {[is_groupchat $chatid]} {
-	muc::leave_group $connid $jid [get_our_groupchat_nick $chatid] \
+	muc::leave_group $xlib $jid [get_our_groupchat_nick $chatid] \
 			 $chats(exit_status,$chatid)
 	set chats(status,$chatid) disconnected
-	client:presence $connid $jid unavailable "" {}
-	foreach jid [get_jids_of_user $connid $jid] {
-	    client:presence $connid $jid unavailable "" {}
+	client:presence $xlib $jid unavailable "" {}
+	foreach jid [get_jids_of_user $xlib $jid] {
+	    client:presence $xlib $jid unavailable "" {}
 	}
     }
 
@@ -656,10 +681,10 @@
 
 ##############################################################################
 
-proc chat::trace_room_nickname_change {connid group nick new_nick} {
+proc chat::trace_room_nickname_change {xlib group nick new_nick} {
     set from $group/$nick
     set to $group/$new_nick
-    set chatid [::chat::chatid $connid $from]
+    set chatid [::chat::chatid $xlib $from]
     set ix [lsearch -exact [::chat::opened] $chatid]
     if {$ix < 0} return
 
@@ -676,7 +701,7 @@
 	for the new nick of the room occupant"]
     ::plugins::urls::render_url $cw url $tooltip {} \
 	-title [::msgcat::mc "Open new conversation"] \
-	-command [list [namespace current]::open_to_user $connid $to]
+	-command [list [namespace current]::open_to_user $xlib $to]
     $cw insert end \n
     $cw config -state disabled
 }
@@ -685,8 +710,8 @@
 
 ##############################################################################
 
-proc chat::check_connid {connid chatid} {
-    if {[get_connid $chatid] == $connid} {
+proc chat::check_xlib {xlib chatid} {
+    if {[get_xlib $chatid] == $xlib} {
 	return 1
     } else {
 	return 0
@@ -695,13 +720,13 @@
 
 ##############################################################################
 
-proc chat::opened {{connid {}}} {
+proc chat::opened {{xlib {}}} {
     variable chats
 
     if {![info exists chats(opened)]} {
 	return {}
-    } elseif {$connid != {}} {
-	return [lfilter [list [namespace current]::check_connid $connid] \
+    } elseif {$xlib != {}} {
+	return [lfilter [list [namespace current]::check_xlib $xlib] \
 			$chats(opened)]
     } else {
 	return $chats(opened)
@@ -791,10 +816,10 @@
 proc chat::create_user_menu {m chatid} {
     menu $m -tearoff 0
 
-    set connid [get_connid $chatid]
+    set xlib [get_xlib $chatid]
     set jid [get_jid $chatid]
 
-    hook::run chat_create_user_menu_hook $m $connid $jid
+    hook::run chat_create_user_menu_hook $m $xlib $jid
 
     return $m
 }
@@ -802,15 +827,15 @@
 proc chat::create_conference_menu {m chatid} {
     menu $m -tearoff 0
 
-    set connid [get_connid $chatid]
+    set xlib [get_xlib $chatid]
     set jid [get_jid $chatid]
 
-    hook::run chat_create_conference_menu_hook $m $connid $jid
+    hook::run chat_create_conference_menu_hook $m $xlib $jid
 
     return $m
 }
 
-proc chat::add_separator {m connid jid} {
+proc chat::add_separator {m xlib jid} {
     $m add separator
 }
 
@@ -826,9 +851,9 @@
 proc chat::send_message {cw chatid type} {
     set iw $cw.input
 
-    set connid [get_connid $chatid]
+    set xlib [get_xlib $chatid]
 
-    if {[catch { set user [jlib::connection_user $connid] }]} {
+    if {[catch { set user [connection_user $xlib] }]} {
 	set user ""
     }
 
@@ -889,9 +914,9 @@
     hook::run draw_message_post_hook $chatid $from $type $body $x
 }
 
-proc chat::add_open_to_user_menu_item {m connid jid} {
+proc chat::add_open_to_user_menu_item {m xlib jid} {
     $m add command -label [::msgcat::mc "Start chat"] \
-	-command [list chat::open_to_user $connid $jid]
+	-command [list chat::open_to_user $xlib $jid]
 }
 
 hook::add roster_create_groupchat_user_menu_hook \
@@ -903,7 +928,7 @@
 hook::add search_popup_menu_hook \
     [namespace current]::chat::add_open_to_user_menu_item 10
 
-proc chat::open_to_user {connid user args} {
+proc chat::open_to_user {xlib user args} {
     set msg ""
     foreach {opt val} $args {
 	switch -- $opt {
@@ -911,11 +936,11 @@
 	}
     }
 
-    if {$connid == ""} {
-	set connid [jlib::route $user]
+    if {$xlib == ""} {
+	set xlib [lindex [connections] 0]
     }
 
-    set jid [get_jid_of_user $connid $user]
+    set jid [get_jid_of_user $xlib $user]
 
     if {[cequal $jid ""]} {
 	set jid $user
@@ -923,7 +948,7 @@
 
     set jid [tolower_node_and_domain $jid]
 
-    set chatid [chatid $connid $jid]
+    set chatid [chatid $xlib $jid]
     set cw [winid $chatid]
     if {![winfo exists $cw]} {
 	chat::open_window $chatid chat
@@ -933,20 +958,20 @@
 
     if {![cequal $msg ""]} {
 	debugmsg chat "SEND_MESSAGE ON OPEN:\
-	    [list $chatid] [jlib::connection_user $connid] [list $msg] chat"
+	    [list $chatid] [connection_user $xlib] [list $msg] chat"
 
 	set chatw [chat_win $chatid]
 	$chatw mark set start_message "end -1 chars"
 	$chatw mark gravity start_message left
 
-	hook::run chat_send_message_hook $chatid [jlib::connection_user $connid] \
+	hook::run chat_send_message_hook $chatid [connection_user $xlib] \
 	    $msg chat
     }
 }
 
 ###############################################################################
 
-proc chat::change_presence {connid jid type x args} {
+proc chat::change_presence {xlib jid type x args} {
     global grouproster
     variable chats
     variable options
@@ -967,22 +992,22 @@
     }
 
     set group [node_and_server_from_jid $jid]
-    set chatid [chatid $connid $group]
+    set chatid [chatid $xlib $group]
 
     if {[is_opened $chatid]} {
 	if {[is_groupchat $chatid]} {
-	    debugmsg chat "ST: $connid $jid $status"
+	    debugmsg chat "ST: $xlib $jid $status"
 	    if {[resource_from_jid $jid] == ""} {
 		return
 	    }
-	    set nick [get_nick $connid $jid groupchat]
+	    set nick [get_nick $xlib $jid groupchat]
 	    if {[cequal $status unavailable] || [cequal $status error]} {
 		if {$status == "error" && [is_our_jid $chatid $jid]} {
 		    add_message $chatid $group error \
 			[format [::msgcat::mc "Error %s"] \
-			     [get_jid_presence_info status $connid $jid]] {}
+			     [get_jid_presence_info status $xlib $jid]] {}
 			set chats(status,$chatid) disconnected
-			client:presence $connid $group unavailable "" {}
+			client:presence $xlib $group unavailable "" {}
 		}
 		if {$status == "unavailable" && [is_our_jid $chatid $jid]} {
 		    if {[muc::is_compatible $group] || \
@@ -990,7 +1015,7 @@
 			add_message $chatid $group error \
 			    [::msgcat::mc "Disconnected"] {}
 			set chats(status,$chatid) disconnected
-			client:presence $connid $group unavailable "" {}
+			client:presence $xlib $group unavailable "" {}
 		    }
 		}
 		debugmsg chat "$jid UNAVAILABLE"
@@ -1005,7 +1030,7 @@
 		if {$chats(status,$chatid) == "disconnected" && \
 			[is_our_jid $chatid $jid]} {
 		    set chats(status,$chatid) connected
-		    client:presence $connid $group "" "" {}
+		    client:presence $xlib $group "" "" {}
 		}
 		set userswin [users_win $chatid]
 		if {![lcontain $grouproster(users,$chatid) $jid]} {
@@ -1029,11 +1054,11 @@
 
     # This case traces both chat and private groupchat conversations:
     if {$options(gen_status_change_msgs)} {
-	set chatid [chatid $connid $jid]
+	set chatid [chatid $xlib $jid]
 	if {[is_opened $chatid]} {
-	    set msg [get_nick $connid $jid chat]
-	    append msg " " [::get_long_status_desc [::get_user_status $connid $jid]]
-	    set desc [::get_user_status_desc $connid $jid]
+	    set msg [get_nick $xlib $jid chat]
+	    append msg " " [::get_long_status_desc [::get_user_status $xlib $jid]]
+	    set desc [::get_user_status_desc $xlib $jid]
 	    if {$desc != {}} {
 		append msg " ($desc)"
 	    }
@@ -1041,27 +1066,27 @@
 	}
     }
 
-    set cw [winid [chatid $connid $jid]]
+    set cw [winid [chatid $xlib $jid]]
 
     if {[winfo exists $cw.status.icon]} {
 	$cw.status.icon configure \
-	    -image [ifacetk::roster::get_jid_icon $connid $jid $status] \
-	    -helptext [get_user_status_desc $connid $jid]
+	    -image [ifacetk::roster::get_jid_icon $xlib $jid $status] \
+	    -helptext [get_user_status_desc $xlib $jid]
     }
 
     if {[winfo exists $cw.status.desc]} {
-	$cw.status.desc configure -text "($statusdesc([get_user_status $connid $jid]))" \
-	    -helptext [get_user_status_desc $connid $jid]
+	$cw.status.desc configure -text "($statusdesc([get_user_status $xlib $jid]))" \
+	    -helptext [get_user_status_desc $xlib $jid]
     }
 
     set user [node_and_server_from_jid $jid]
-    set cw [winid [chatid $connid $user]]
+    set cw [winid [chatid $xlib $user]]
 
     if {[winfo exists $cw.status.icon]} {
 	$cw.status.icon configure \
 	    -image [ifacetk::roster::get_jid_icon \
-			$connid $user [get_user_status $connid $user]] \
-	    -helptext [get_user_status_desc $connid $user]
+			$xlib $user [get_user_status $xlib $user]] \
+	    -helptext [get_user_status_desc $xlib $user]
     }
 }
 
@@ -1072,7 +1097,7 @@
 proc chat::redraw_roster {group} {
     global grouproster
 
-    set connid [get_connid $group]
+    set xlib [get_xlib $group]
     set userswin [users_win $group]
 
     set grouproster(users,$group) [lsort $grouproster(users,$group)]
@@ -1080,15 +1105,15 @@
 
     set levels {}
     foreach jid $grouproster(users,$group) {
-	if {[info exists ::muc::users(role,$connid,$jid)]} {
-	    if {$::muc::users(role,$connid,$jid) == ""} {
+	if {[info exists ::muc::users(role,$xlib,$jid)]} {
+	    if {$::muc::users(role,$xlib,$jid) == ""} {
 		set level a[::msgcat::mc "Users"]
 		lappend levels $level
 		lappend levelusers($level) $jid
 	    } else {
-		if {$::muc::users(role,$connid,$jid) != "" && \
-			$::muc::users(role,$connid,$jid) != "none"} {
-		    set level $::muc::users(role,$connid,$jid)
+		if {$::muc::users(role,$xlib,$jid) != "" && \
+			$::muc::users(role,$xlib,$jid) != "none"} {
+		    set level $::muc::users(role,$xlib,$jid)
 		    switch -- $level {
 			moderator   {set level 4[::msgcat::mc "Moderators"]}
 			participant {set level 5[::msgcat::mc "Participants"]}
@@ -1125,7 +1150,7 @@
 	    [crange $level 1 end] [crange $level 1 end] 0
 	set jid_nicks {}
 	foreach jid $levelusers($level) {
-	    lappend jid_nicks [list $jid [get_nick $connid $jid groupchat]]
+	    lappend jid_nicks [list $jid [get_nick $xlib $jid groupchat]]
 	}
 	set jid_nicks [lsort -index 1 -dictionary $jid_nicks]
 
@@ -1134,16 +1159,16 @@
 	    set status $grouproster(status,$group,$jid)
 
 	    ifacetk::roster::addline $userswin jid $nick \
-		[list $connid $jid] [crange $level 1 end] 0
+		[list $xlib $jid] [crange $level 1 end] 0
 	    ifacetk::roster::changeicon $userswin \
-		[list $connid $jid] roster/user/$status
+		[list $xlib $jid] roster/user/$status
 	    if {$::plugins::nickcolors::options(use_colored_roster_nicks)} {
 		ifacetk::roster::changeforeground $userswin \
-		    [list $connid $jid] $status \
+		    [list $xlib $jid] $status \
 		    [plugins::nickcolors::get_color $nick]
 	    } else {
 		ifacetk::roster::changeforeground $userswin \
-		    [list $connid $jid] $status
+		    [list $xlib $jid] $status
 	    }
 	}
     }
@@ -1188,13 +1213,12 @@
 
 proc chat::change_subject {chatid} {
     set cw [winid $chatid]
-    set connid [get_connid $chatid]
+    set xlib [get_xlib $chatid]
     set jid [get_jid $chatid]
 
     set subject [$cw.status.subject get]
 
-    message::send_msg $jid -connection $connid \
-	-type groupchat -subject $subject
+    message::send_msg $xlib $jid -type groupchat -subject $subject
 }
 
 proc chat::set_subject_balloon {chatid} {
@@ -1231,7 +1255,7 @@
 proc chat::our_jid {chatid} {
     variable chats
 
-    set connid [get_connid $chatid]
+    set xlib [get_xlib $chatid]
     set jid [get_jid $chatid]
     switch -- $chats(type,$chatid) {
 	groupchat {
@@ -1239,11 +1263,11 @@
 	}
 	chat {
 	    set group [node_and_server_from_jid $jid]
-	    set groupid [chatid $connid $group]
+	    set groupid [chatid $xlib $group]
 	    if {[is_groupchat $groupid]} {
 		return $group/[get_our_groupchat_nick $groupid]
 	    } else {
-		return [jlib::connection_jid $connid]
+		return [connection_jid $xlib]
 	    }
 	}
     }
@@ -1252,9 +1276,9 @@
 
 ###############################################################################
 
-proc chat::add_invite_menu_item {m connid jid} {
+proc chat::add_invite_menu_item {m xlib jid} {
     $m add command -label [::msgcat::mc "Invite to conference..."] \
-	   -command [list chat::invite_dialog $jid 0 -connection $connid]
+	   -command [list chat::invite_dialog $xlib $jid 0]
 }
 
 hook::add chat_create_user_menu_hook \
@@ -1268,9 +1292,9 @@
 hook::add search_popup_menu_hook \
     [namespace current]::chat::add_invite_menu_item 20
 
-proc chat::add_invite2_menu_item {m connid jid} {
+proc chat::add_invite2_menu_item {m xlib jid} {
     $m add command -label [::msgcat::mc "Invite users..."] \
-	   -command [list chat::invite_dialog2 $jid 0 -connection $connid]
+	   -command [list chat::invite_dialog2 $xlib $jid 0]
 }
 
 hook::add chat_create_conference_menu_hook \
@@ -1278,21 +1302,12 @@
 
 ###############################################################################
 
-proc chat::invite_dialog {user {ignore_muc 0} args} {
+proc chat::invite_dialog {xlib user {ignore_muc 0} args} {
     variable chats
     global invite_gc
 
-    foreach {opt val} $args {
-	switch -- $opt {
-	    -connection { set connid $val }
-	}
-    }
-    if {![info exists connid]} {
-	set connid [jlib::route $user]
-    }
+    set jid [get_jid_of_user $xlib $user]
 
-    set jid [get_jid_of_user $connid $user]
-
     if {[cequal $jid ""]} {
         set jid $user
     }
@@ -1303,7 +1318,7 @@
     if {[catch { set nick [roster::get_label $user] }]} {
 	if {[catch {set nick [roster::get_label \
 				  [node_and_server_from_jid $user]] }]} {
-	    if {[catch { set nick [chat::get_nick $connid \
+	    if {[catch { set nick [chat::get_nick $xlib \
 						  $user groupchat] }]} {
 		set nick $user
 	    }
@@ -1312,7 +1327,7 @@
 
     set titles {}
     set jids {}
-    foreach chatid [lsort [lfilter [namespace current]::is_groupchat [opened $connid]]] {
+    foreach chatid [lsort [lfilter [namespace current]::is_groupchat [opened $xlib]]] {
 	lappend jids $chatid [get_jid $chatid]
         lappend titles $chatid [node_from_jid [get_jid $chatid]]
     }
@@ -1320,7 +1335,7 @@
         MessageDlg ${gw}_err -aspect 50000 -icon info \
 	    -message \
 		[format [::msgcat::mc "No conferences for %s in progress..."] \
-		    [jlib::connection_jid $connid]] \
+		    [connection_jid $xlib]] \
 	    -type user \
 	    -buttons ok -default 0 -cancel 0
         return
@@ -1333,19 +1348,10 @@
 	invite_gc $titles $jids
 }
 
-proc chat::invite_dialog2 {jid ignore_muc args} {
+proc chat::invite_dialog2 {xlib jid ignore_muc args} {
     variable chats
     global invite_gc
 
-    foreach {opt val} $args {
-	switch -- $opt {
-	    -connection { set connid $val }
-	}
-    }
-    if {![info exists connid]} {
-	set connid [jlib::route $jid]
-    }
-
     set gw .invite
     catch { destroy $gw }
 
@@ -1353,17 +1359,17 @@
 
     set choices {}
     set balloons {}
-    foreach choice [roster::get_jids $connid] {
-	if {![cequal [roster::itemconfig $connid $choice -category] conference]} {
-	    lappend choices [list $connid $choice] [roster::get_label $connid $choice]
-	    lappend balloons [list $connid $choice] $choice
+    foreach choice [roster::get_jids $xlib] {
+	if {![cequal [roster::itemconfig $xlib $choice -category] conference]} {
+	    lappend choices [list $xlib $choice] [roster::get_label $xlib $choice]
+	    lappend balloons [list $xlib $choice] $choice
 	} 
     } 
     if {[llength $choices] == 0} {
         MessageDlg ${gw}_err -aspect 50000 -icon info \
 	    -message \
 		[format [::msgcat::mc "No users in %s roster..."] \
-		     [jlib::connection_jid $connid]] \
+		     [connection_jid $xlib]] \
 	    -type user \
 	    -buttons ok -default 0 -cancel 0
 	return
@@ -1405,8 +1411,8 @@
 
 #############################################################################
 
-proc chat::restore_window {cjid type nick connid jid} {
-    set chatid [chatid $connid $cjid]
+proc chat::restore_window {cjid type nick xlib jid} {
+    set chatid [chatid $xlib $cjid]
 
     if {$type == "groupchat"} {
 	set_our_groupchat_nick $chatid $nick
@@ -1436,7 +1442,7 @@
 	if {[info exists chat_id($path)]} {
 	    set chatid $chat_id($path)
 
-	    set connid [get_connid $chatid]
+	    set xlib [get_xlib $chatid]
 	    set jid [get_jid $chatid]
 	    set type $chats(type,$chatid)
 
@@ -1446,9 +1452,9 @@
 		set nick ""
 	    }
 
-	    set user [jlib::connection_requested_user $connid]
-	    set server [jlib::connection_requested_server $connid]
-	    set resource [jlib::connection_requested_resource $connid]
+	    set user [connection_requested_user $xlib]
+	    set server [connection_requested_server $xlib]
+	    set resource [connection_requested_resource $xlib]
 
 	    lappend session [list $prio $user $server $resource \
 		[list [namespace current]::restore_window $jid $type $nick] \

Deleted: trunk/tkabber/ckabber.tcl
===================================================================
--- trunk/tkabber/ckabber.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/ckabber.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -1,174 +0,0 @@
-#!/bin/sh
-# the next line restarts using the correct interpreter \
-exec cwsh "$0" -name ckabber "$@"
-
-# $Id: ckabber.tcl
-
-set interface ck
-namespace eval ifaceck {}
-
-lappend auto_path [file dirname [info script]]
-
-package require msgcat
-if {[info exists ::env(LC_MESSAGES)]} {
-    ::msgcat::mclocale $::env(LC_MESSAGES)
-}
-
-set configdir [file join ~ .tkabber]
-catch {set configdir [file normalize $configdir]}
-
-set tkabber_version 0.9.7-alpha-20031223
-set toolkit_version "Tcl/Ck [info patchlevel]"
-
-
-if {$tcl_platform(platform) == "unix"} {
-    set debug_lvls {jlib warning}
-} else {
-    set debug_lvls {}
-}
-
-proc debugmsg {level msg} {
-    global debug_lvls
-
-    if {[lsearch -exact $debug_lvls $level] >= 0} {
-	# puts "$level: $msg"
-    }
-}
-
-proc rescmd {id res ls} {
-    puts "RESULT: $id $res $ls"
-}
-
-set rootdir [file dirname [info script]]
-proc fullpath {args} {
-    global rootdir
-    return [eval file join $rootdir $args]
-}
-
-proc pixmap {args} {
-    # TODO
-}
-
-proc load_source {args} {
-    set fullpath [eval fullpath $args]
-
-    debugmsg tkabber "Loading $fullpath"
-    uplevel #0 source $fullpath
-}
-
-load_source ifaceck widgets.tcl
-
-proc quit {{status 0}} {
-    hook::run quit_hook
-
-    destroy .
-    exit $status
-}
-
-namespace eval ssj {}
-load_source hooks.tcl
-
-load_source default.tcl
-
-hook::add postload_hook postload
-hook::add finload_hook finload
-
-if {[file exists [file join $::configdir config.tcl]]} {
-    source [file join $::configdir config.tcl]
-}
-
-if {(![info exists load_default_xrdb] || $load_default_xrdb)} {
-    option readfile [fullpath ifaceck default.xrdb] widgetDefault
-}
-
-::msgcat::mcload [file join $rootdir msgs]
-foreach pr [::msgcat::mcpreferences] {
-    set f [file join $rootdir msgs "$pr.rc"]
-    if {[file exists $f]} {
-	option read $f
-	break
-    }
-}
-unset pr f
-
-if {[catch { package require Tclx }]} {
-    load_source Tclx.tcl
-}
-
-package require jabberlib 0.8.4
-load_source xmppmime.tcl
-
-foreach {opt val} $argv {
-    switch -- $opt {
-	-mime {set mime_file $val}
-	-user {set loginconf(user) $val}
-	-password {set loginconf(password) $val}
-	-resource {set loginconf(resource) $val}
-	-port {set loginconf(port) $val}
-	-autologin {set autologin $val}
-	-chat {xmppmime::send_event [list chat $val]}
-	-message {xmppmime::send_event [list message $val]}
-	-conference {xmppmime::send_event [list groupchat $val]}
-    }
-}
-
-if {[info exists mime_file]} {
-    xmppmime::load $mime_file
-}
-if {[xmppmime::is_done]} exit
-
-#if {![info exists show_splash_window] || $show_splash_window} {
-#    load_source splash.tcl
-#}
-
-
-proc ::LOG {text} {
-    debugmsg jlib $text
-}
-
-proc ::HTTP_LOG {text} {
-    debugmsg http $text
-}
-
-load_source custom.tcl
-load_source utils.tcl
-load_source plugins.tcl
-#load_source balloon.tcl
-load_source presence.tcl
-#load_source iq.tcl
-load_source roster.tcl
-#load_source itemedit.tcl
-#load_source sound.tcl
-#load_source messages.tcl
-load_source chats.tcl
-#load_source joingrdialog.tcl
-#load_source muc.tcl
-#load_source emoticons.tcl
-load_source login.tcl
-#load_source browser.tcl
-#load_source disco.tcl
-#load_source userinfo.tcl
-#load_source datagathering.tcl
-#load_source negotiate.tcl
-#load_source mclistbox mclistbox.tcl
-#load_source search.tcl
-#load_source register.tcl
-#load_source filetransfer.tcl
-#load_source filters.tcl
-#load_source privacy.tcl
-load_source gpgme.tcl
-#load_source bwidget_workarounds.tcl
-#load_source aniemoteicons aniemoteicons.tcl
-
-#plugins::load [file join plugins general]
-#plugins::load [file join plugins $tcl_platform(platform)]
-#plugins::load_dir [file join $::configdir plugins]
-
-load_source ifaceck iface.tcl
-
-hook::run postload_hook
-
-load_source iface.tcl
-
-hook::run finload_hook
-

Modified: trunk/tkabber/datagathering.tcl
===================================================================
--- trunk/tkabber/datagathering.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/datagathering.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -40,21 +40,20 @@
     grid columnconfig $g 1 -weight 1 -minsize 0
 
     foreach item $items {
-	jlib::wrapper:splitxml $item tag vars isempty chdata children
-	set xmlns [jlib::wrapper:getattr $vars xmlns]
+	::xmpp::xml::split $item tag xmlns attrs cdata subels
 	if {$xmlns == "jabber:x:data" || $xmlns == "jabber:iq:data"} {
-	    return [fill_fields_x $g $children]
+	    return [fill_fields_x $g $subels]
 	}
     }
 
     set focus ""
     set fields {}
     foreach item $items {
-	jlib::wrapper:splitxml $item tag vars isempty chdata children
+	::xmpp::xml::split $item tag xmlns attrs cdata subels
 
 	switch -- $tag {
 	    instructions {
-		message $g.instructions$row -text $chdata -width 10c
+		message $g.instructions$row -text $cdata -width 10c
 		grid $g.instructions$row -row $row -column 0 -columnspan 2 \
 		    -sticky w -pady 2m
 		incr row
@@ -62,11 +61,11 @@
 	    registered -
 	    x {}
 	    default {
-                lappend fields $tag $chdata
+                lappend fields $tag $cdata
 	    }
 	}
     }
-    foreach {tag chdata} $fields {
+    foreach {tag cdata} $fields {
 	lappend data(varlist,$g) $tag
 
 	if {[info exists field_labels($tag)]} {
@@ -97,8 +96,8 @@
 	    }
 	}
 
-	if {$chdata != {}} {
-	    set data(var,$tag,$g) $chdata
+	if {$cdata != {}} {
+	    set data(var,$tag,$g) $cdata
 	}
 
 	grid $g.l$row -row $row -column 0 -sticky e
@@ -126,8 +125,7 @@
 
     if {[info exists data(varlist,$g)]} {
 	foreach var $data(varlist,$g) {
-	    lappend restags [jlib::wrapper:createtag $var \
-				 -chdata $data(var,$var,$g)]
+	    lappend restags [::xmpp::xml::create $var -cdata $data(var,$var,$g)]
 	}
     }
 
@@ -153,8 +151,7 @@
 	instructions -
 	title {
 	    if {[info exists params(-value)]} {
-		return [jlib::wrapper:createtag $type \
-			    -chdata $params(-value)]
+		return [::xmpp::xml::create $type -cdata $params(-value)]
 	    } else {
 		error "You must define -value"
 	    }
@@ -184,25 +181,25 @@
 
 	    set subtags  {}
 	    if {[info exists params(-descr)]} {
-		lappend subtags [jlib::wrapper:createtag descr \
-				     -chdata $params(-descr)]
+		lappend subtags [::xmpp::xml::create descr \
+				     -cdata $params(-descr)]
 	    }
 	    if {[info exists params(-required)] && $params(-required)} {
-		lappend subtags [jlib::wrapper:createtag required]
+		lappend subtags [::xmpp::xml::create required]
 	    }
 	    if {[lcontain {jid-multi text-multi list-multi hidden fixed} $type]} {
 		if {[info exists params(-values)]} {
 		    foreach value $params(-values) {
-			lappend subtags [jlib::wrapper:createtag value \
-					     -chdata $value]
+			lappend subtags [::xmpp::xml::create value \
+					     -cdata $value]
 		    }
 		} elseif {[lcontain {jid-multi hidden fixed} $type]} {
 		    error "You must define -values"
 		}
 	    } else {	    
 		if {[info exists params(-value)]} {
-		    lappend subtags [jlib::wrapper:createtag value \
-					 -chdata $params(-value)]
+		    lappend subtags [::xmpp::xml::create value \
+					 -cdata $params(-value)]
 		}
 	    }
 		
@@ -211,20 +208,18 @@
 		    foreach option $params(-options) {
 			lassign $option name label
 			lappend subtags \
-			    [jlib::wrapper:createtag option \
-				 -vars [list label $label] \
-				 -subtags \
-				 [list [jlib::wrapper:createtag value \
-					    -chdata $name]]]
+			    [::xmpp::xml::create option \
+				 -attrs [list label $label] \
+				 -subelement [::xmpp::xml::create value \
+							-cdata $name]]
 		    }
 		} else {
 		    error "You must define -options"
 		}
 	    }
 	    
-	    return [jlib::wrapper:createtag field \
-			-vars $vars \
-			-subtags $subtags]	    
+	    return [::xmpp::xml::create field -attrs $vars \
+					      -subelements $subtags]	    
 	}
 	
 	default {
@@ -244,24 +239,24 @@
 
     set result {}
     foreach item $items {
-	jlib::wrapper:splitxml $item tag vars isempty chdata children
+	::xmpp::xml::split $item tag xmlns attrs cdata subels
 	if {$tag != "field"} {
 	    continue
 	}
-	set type [jlib::wrapper:getattr $vars type]
+	set type [::xmpp::xml::getAttr $attrs type]
 	if {!$report_hidden && $type == "hidden"} {
 	    continue
 	}
-	set var [jlib::wrapper:getattr $vars var]
+	set var [::xmpp::xml:getAttr $attrs var]
 	if {$var == ""} {
 	    continue
 	}
-	set label [jlib::wrapper:getattr $vars label]
+	set label [::xmpp::xml::getAttr $attrs label]
 	set values {}
-	foreach child $children {
-	    jlib::wrapper:splitxml $child tag1 vars1 isempty1 chdata1 children1
-	    if {$tag1 == "value"} {
-		lappend values $chdata1
+	foreach subel $subels {
+	    ::xmpp::xml::split $subel stag sxmlns sattrs scdata ssubels
+	    if {$stag == "value"} {
+		lappend values $scdata
 	    }
 	}
 	lappend result [list $var $type $label $values]
@@ -288,22 +283,22 @@
 
 proc data::render_media {g row media_list} {
     foreach item $media_list {
-	jlib::wrapper:splitxml $item tag vars isempty chdata children
+	::xmpp::xml::split $item tag xmlns attrs cdata subels
 	set unsupported 1
-	foreach child $children {
-	    jlib::wrapper:splitxml $child tag1 vars1 isempty1 chdata1 children1
-	    switch -- $tag1 {
+	foreach subel $subels {
+	    ::xmpp::xml::split $subel stag sxmlns sattrs scdata ssubels
+	    switch -- $stag {
 		uri {
-		    render_url $g.mediauri$row $chdata1 $chdata1 -bg [get_conf $g -bg]
+		    render_url $g.mediauri$row $scdata $scdata -bg [get_conf $g -bg]
 		    grid $g.mediauri$row -row $row -column 1 -sticky ew
 		    set unsupported 0
 		    incr row
 		}
 		data {
-		    set type [jlib::wrapper:getattr $vars1 type]
+		    set type [::xmpp::xml::getAttr $sattrs type]
 		    switch -glob -- $type {
 			image/* {
-			    if {![catch {image create photo -data [base64::decode $chdata1]} img]} {
+			    if {![catch {image create photo -data [base64::decode $scdata]} img]} {
 				label $g.mediaimg$row -image $img
 				bind $g.mediaimg$row <Destroy> [list image delete $img]
 				grid $g.mediaimg$row -row $row -column 1 -sticky ew
@@ -335,18 +330,18 @@
     set focus ""
 
     foreach item $items {
-	jlib::wrapper:splitxml $item tag vars isempty chdata children
+	::xmpp::xml::split $item tag xmlns attrs cdata subels
 
 	switch -- $tag {
 	    instructions {
 		#add_label $g $row [::msgcat::mc "Instructions"]
-		message $g.instructions$row -text $chdata -width 15c
+		message $g.instructions$row -text $cdata -width 15c
 		grid $g.instructions$row -row $row -column 0 \
 		    -columnspan 2 -sticky w -pady 2m
 		incr row
 	    }
 	    field {
-		set widget [fill_field_x $g $row $tag $vars $chdata $children]
+		set widget [fill_field_x $g $row $tag $attrs $cdata $subels]
 		if {$focus == ""} {
 		    set focus $widget
 		}
@@ -355,8 +350,8 @@
 	    title {
 		set top [winfo toplevel $g]
 		if {$top != "."} {
-		    wm title $top $chdata
-		    wm iconname $top $chdata
+		    wm title $top $cdata
+		    wm iconname $top $cdata
 		}
 	    }
 	    default {
@@ -372,45 +367,45 @@
 }
 
 
-proc data::fill_field_x {g row tag vars chdata children} {
+proc data::fill_field_x {g row tag attrs cdata subels} {
     variable data
 
     set required 0
     set desc {}
     set options {}
     set vals {}
-    set var   [jlib::wrapper:getattr $vars var]
-    set type  [jlib::wrapper:getattr $vars type]
+    set var   [::xmpp::xml::getAttr $attrs var]
+    set type  [::xmpp::xml::getAttr $attrs type]
     if {$type == ""} {
 	set type text-single
     }
-    set label [jlib::wrapper:getattr $vars label]
+    set label [::xmpp::xml::getAttr $attrs label]
     set data(var,$var,$g) ""
     set widget ""
     set media_list {}
 
-    foreach item $children {
-	jlib::wrapper:splitxml $item tag1 vars1 isempty1 chdata1 children1
+    foreach item $subels {
+	::xmpp::xml::split $item stag sxmlns sattrs scdata ssubels
 	switch -- $tag1 {
 	    required {set required 1}
 	    value {
-		set data(var,$var,$g) $chdata1
-		lappend vals $chdata1
+		set data(var,$var,$g) $scdata
+		lappend vals $scdata
 	    }
-	    desc {set desc $chdata1}
+	    desc {set desc $scdata}
 	    option {
-		set lab [jlib::wrapper:getattr $vars1 label]
-		foreach item $children1 {
-		    jlib::wrapper:splitxml $item \
-			tag2 vars2 isempty2 chdata2 children2
-		    switch -- $tag2 {
-			value {set val $chdata2}
+		set lab [::xmpp::xml::getAttr $sattrs label]
+		foreach item $ssubels {
+		    ::xmpp::xml::split $item \
+			sstag ssxmlns ssattrs sscdata sssubels
+		    switch -- $sstag {
+			value {set val $sscdata}
 		    }
 		}
 		lappend options $lab $val
 	    }
 	    media {
-		if {[jlib::wrapper:getattr $vars1 xmlns] == $::NS(media-element)} {
+		if {$sxmlns == $::NS(media-element)} {
 		    lappend media_list $item
 		}
 	    }
@@ -584,28 +579,26 @@
 	if {[info exists data(multi,$var,$g)]} {
 	    set vartags {}
 	    foreach val $data(var,$var,$g) {
-	        lappend vartags [jlib::wrapper:createtag value \
-	        		     -chdata $val]
+	        lappend vartags [::xmpp::xml::create value -cdata $val]
 	    }
 	} elseif {[info exists data(text,$var,$g)]} {
 	    set data(var,$var,$g) [$data(text,$var,$g) get 1.0 "end -1c"]
 	    set vartags {}
 	    foreach val [split $data(var,$var,$g) \n] {
-	        lappend vartags [jlib::wrapper:createtag value \
-	        		     -chdata $val]
+	        lappend vartags [::xmpp::xml::create value -cdata $val]
 	    }
 	} else {
-	    set vartags [list [jlib::wrapper:createtag value \
-	        		   -chdata $data(var,$var,$g)]]
+	    set vartag [::xmpp::xml::create value -cdata $data(var,$var,$g)]
 	}
-	lappend restags [jlib::wrapper:createtag field \
-			     -vars [list var $var] \
-			     -subtags $vartags]
+	lappend restags [::xmpp::xml::create field \
+					     -attrs [list var $var] \
+					     -subelement $vartag]
     }
 
-    set restag [list [jlib::wrapper:createtag x \
-			  -vars [list xmlns jabber:x:data type submit] \
-			  -subtags $restags]]
+    set restag [list [::xmpp::xml::create x \
+					  -xmlns jabber:x:data \
+					  -attrs [list type submit] \
+					  -subelements $restags]]
 
     return $restag
 }
@@ -682,36 +675,27 @@
 
 ###############################################################################
 
-proc data::request_data {xmlns jid node args} {
-
-    foreach {key val} $args {
-	switch -- $key {
-	    -connection { set connid $val }
-	}
+proc data::request_data {xmlns xlib jid node args} {
+    if {$node == ""} {
+	set vars {}
+    } else {
+	set vars [list node $node]
     }
-    if {![info exists connid]} {
-	return -code error "data::request_data error: -connection required"
-    }
 
-    set vars [list xmlns $xmlns]
-    if {$node != ""} {
-	lappend vars node $node
-    }
-
-    jlib::send_iq get \
-	[jlib::wrapper:createtag query \
-	     -vars $vars] \
+    ::xmpp::sendIQ $xlib get \
+	-query [::xmpp::xml::create query \
+				    -xmlns $xmlns \
+				    -attrs $vars] \
 	-to $jid \
-	-connection $connid \
-	-command [list [namespace current]::receive_data $connid $xmlns $jid $node]
+	-command [list [namespace current]::receive_data $xlib $xmlns $jid $node]
 }
 
-proc data::receive_data {connid xmlns jid node res child} {
-    if {[string equal $res DISCONNECT]} {
+proc data::receive_data {xlib xmlns jid node res child} {
+    if {[string equal $res abort]} {
 	return
     }
 
-    if {[string equal $res ERR]} {
+    if {[string equal $res error]} {
 	set ew .data_err
 	if {[winfo exists $ew]} {
 	    destroy $ew
@@ -725,58 +709,54 @@
 
     switch -- $xmlns {
 	jabber:iq:data {
-	    set children [list $child]
+	    set subels [list $child]
 	}
 	default {
-	    jlib::wrapper:splitxml $child tag vars isempty chdata children
+	    ::xmpp::xml::split $child tag xmlns attrs cdata subels
 	}
     }
 
-    data::draw_window $children \
-	[list [namespace current]::send_data $connid $xmlns $jid $node] \
-	[list [namespace current]::cancel_data $connid $xmlns $jid $node]
+    data::draw_window $subels \
+	[list [namespace current]::send_data $xlib $xmlns $jid $node] \
+	[list [namespace current]::cancel_data $xlib $xmlns $jid $node]
 }
 
-proc data::cancel_data {connid xmlns jid node w} {
-    send_data $connid $xmlns $jid $node $w \
-	      [list [jlib::wrapper:createtag x \
-			 -vars [list xmlns jabber:x:data \
-				     type cancel]]]
+proc data::cancel_data {xlib xmlns jid node w} {
+    send_data $xlib $xmlns $jid $node $w \
+	      [list [::xmpp::xml::create x \
+			    -xmlns jabber:x:data \
+			    -attrs [list type cancel]]]
 }
 
-proc data::send_data {connid xmlns jid node w restags} {
+proc data::send_data {xlib xmlns jid node w restags} {
     switch -- $xmlns {
 	jabber:iq:data {
-	    set child [lindex $restags 0]
-	    jlib::wrapper:splitxml $child tag vars isempty chdata children
-
-	    array set arr $vars
-	    set arr(xmlns) $xmlns
-	    set vars [array get arr]
+	    ::xmpp::xml::split [lindex $restags 0] tag xmlns1 attrs cdata subels
 	}
 	default {
-	    set children $restags
-	    set vars [list xmlns $xmlns]
+	    set subels $restags
+	    set attrs {}
 	}
     }
 
     if {$node != ""} {
-        lappend vars node $node
+        lappend attrs node $node
     }
 
     destroy $w.error.msg
     $w.bbox itemconfigure 0 -state disabled
 
-    jlib::send_iq set [jlib::wrapper:createtag query \
-			   -vars $vars \
-			   -subtags $children] \
-	-to $jid \
-	-connection $connid \
-	-command [list [namespace current]::test_error_res $w]
+    ::xmpp::sendIQ $xlib set \
+	    -query [::xmpp::xml::create query \
+					-xmlns $xmlns \
+					-attrs $attrs \
+					-subelements $subels] \
+	    -to $jid \
+	    -command [list [namespace current]::test_error_res $w]
 }
 
 proc data::test_error_res {w res child} {
-    if {[string equal $res OK]} {
+    if {[string equal $res ok]} {
 	destroy $w
 	return
     }

Modified: trunk/tkabber/disco.tcl
===================================================================
--- trunk/tkabber/disco.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/disco.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -19,34 +19,32 @@
 
 ##############################################################################
 
-proc disco::request_items {jid node args} {
+proc disco::request_items {xlib jid args} {
     variable disco
 
+    set node ""
     set handler {}
     set cache no
 
     foreach {attr val} $args {
 	switch -- $attr {
-	    -handler    {set handler $val}
-	    -cache      {set cache $val}
-	    -connection {set connid $val}
+	    -node    {set node $val}
+	    -command {set handler $val}
+	    -cache   {set cache $val}
 	}
     }
-    if {![info exists connid]} {
-	return -code error "disco::request_items: -connection is mandatory"
-    }
 
     switch -- $cache {
 	first -
 	only -
 	yes {
-	    if {[info exists disco(items,$connid,$jid,$node)]} {
-		set items $disco(items,$connid,$jid,$node)
+	    if {[info exists disco(items,$xlib,$jid,$node)]} {
+		set items $disco(items,$xlib,$jid,$node)
 		if {$handler != ""} {
-		    eval $handler [list OK $items]
+		    eval $handler [list ok $items]
 		}
 		if {$cache != "first"} {
-		    return [list OK $items]
+		    return [list ok $items]
 		}
 	    } elseif {$cache == "only"} {
 		return NO
@@ -54,96 +52,94 @@
 	}
     }
 
-    set vars [list xmlns $::NS(disco_items)]
+    set vars {}
     if {$node != ""} {
 	lappend vars node $node
     }
 
-    jlib::send_iq get \
-	    [jlib::wrapper:createtag query \
-		 -vars $vars] \
+    ::xmpp::sendIQ $xlib get \
+	-query [::xmpp::xml::create query \
+				    -xmlns $::NS(disco_items) \
+				    -attrs $vars] \
 	-to $jid \
-	-connection $connid \
 	-command [list [namespace current]::parse_items \
-		       $connid $jid $node $handler]
+		       $xlib $jid $node $handler]
 }
 
-proc disco::parse_items {connid jid node handler res child} {
+proc disco::parse_items {xlib jid node handler res child} {
     variable disco
 
-    if {![string equal $res OK]} {
+    if {![string equal $res ok]} {
 	if {$handler != ""} {
-	    eval $handler [list ERR $child]
+	    eval $handler [list error $child]
 	}
-	hook::run disco_items_hook $connid $jid $node ERR $child
+	hook::run disco_items_hook $xlib $jid $node error $child
 	return
     }
 
     set items {}
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata childrens
+    ::xmpp::xml::split $child tag xmlns attrs cdata subels
 
-    foreach ch $childrens {
-	jlib::wrapper:splitxml $ch tag1 vars1 isempty1 chdata1 childrens1
-	switch -- $tag1 {
+    foreach ch $subels {
+	::xmpp::xml::split $ch stag sxmlns sattrs scdata ssubels
+	switch -- $stag {
 	    item {
-		set ijid  [jlib::wrapper:getattr $vars1 jid]
-		set inode  [jlib::wrapper:getattr $vars1 node]
-		set name  [jlib::wrapper:getattr $vars1 name]
+		set ijid  [::xmpp::xml::getAttr $sattrs jid]
+		set inode [::xmpp::xml::getAttr $sattrs node]
+		set name  [::xmpp::xml::getAttr $sattrs name]
 		lappend items [list jid $ijid node $inode name $name]
-		set disco(jidname,$connid,$ijid,$inode) $name
+		set disco(jidname,$xlib,$ijid,$inode) $name
 	    }
 	}
     }
 
-    set disco(items,$connid,$jid,$node) $items
+    set disco(items,$xlib,$jid,$node) $items
 
     debugmsg disco "ITEMS: [list $items]"
 
     if {$handler != ""} {
-	eval $handler [list OK $items]
+	eval $handler [list ok $items]
     }
 
-    hook::run disco_items_hook $connid $jid $node OK $items
+    hook::run disco_items_hook $xlib $jid $node ok $items
 }
 
 ##############################################################################
 
-proc disco::request_info {jid node args} {
+proc disco::request_info {xlib jid args} {
     variable disco
 
+    set node ""
     set handler {}
     set cache no
 
     foreach {attr val} $args {
 	switch -- $attr {
-	    -handler    {set handler $val}
-	    -cache      {set cache $val}
-	    -connection {set connid $val}
+	    -node    {set node $val}
+	    -command {set handler $val}
+	    -cache   {set cache $val}
 	}
     }
-    if {![info exists connid]} {
-	return -code error "disco::request_items: -connection is mandatory"
-    }
 
-    # disco(info,featured_nodes,$connid,$jid,$node) isn't cached because it
+    # disco(info,featured_nodes,$xlib,$jid,$node) isn't cached because it
     # isn't really reported. It's for internal use only.
-    set disco(info,featured_nodes,$connid,$jid,$node) {}
+    set disco(info,featured_nodes,$xlib,$jid,$node) {}
 
     switch -- $cache {
 	first -
 	only -
 	yes {
-	    if {[info exists disco(info,identities,$connid,$jid,$node)] && \
-		    [info exists disco(info,identities,$connid,$jid,$node)]} {
-		set identities $disco(info,identities,$connid,$jid,$node)
-		set features   $disco(info,features,$connid,$jid,$node)
-		set extras     $disco(info,extras,$connid,$jid,$node)
+	    if {[info exists disco(info,identities,$xlib,$jid,$node)] && \
+		    [info exists disco(info,identities,$xlib,$jid,$node)]} {
+		set identities $disco(info,identities,$xlib,$jid,$node)
+		set features   $disco(info,features,$xlib,$jid,$node)
+		set extras     $disco(info,extras,$xlib,$jid,$node)
 		if {$handler != ""} {
-		    eval $handler [list OK $identities $features $extras]
+		    eval $handler [list ok $identities $features $extras]
 		}
 		if {$cache != "first"} {
-		    return [list OK $identities $features $extras]
+		    return [list ok $identities $features $extras]
 		}
 	    } elseif {$cache == "only"} {
 		return NO
@@ -151,29 +147,29 @@
 	}
     }
 
-    set vars [list xmlns $::NS(disco_info)]
+    set vars {}
     if {$node != ""} {
 	lappend vars node $node
     }
 
-    jlib::send_iq get \
-	[jlib::wrapper:createtag query \
-	     -vars $vars] \
+    ::xmpp::sendIQ $xlib get \
+	-query [::xmpp::xml::create query \
+			-xmlns $::NS(disco_info) \
+			-attrs $vars] \
 	-to $jid \
-	-connection $connid \
 	-command [list [namespace current]::parse_info \
-		       $connid $jid $node $handler]
+		       $xlib $jid $node $handler]
 }
 
-proc disco::parse_info {connid jid node handler res child} {
+proc disco::parse_info {xlib jid node handler res child} {
     variable disco
     variable additional_nodes
 
-    if {![string equal $res OK]} {
+    if {![string equal $res ok]} {
 	if {$handler != ""} {
-	    eval $handler [list ERR $child {} {}]
+	    eval $handler [list error $child {} {}]
 	}
-	hook::run disco_info_hook $connid $jid $node ERR $child {} {} {}
+	hook::run disco_info_hook $xlib $jid $node error $child {} {} {}
 	return
     }
 
@@ -182,92 +178,91 @@
     set extras {}
     set featured_nodes {}
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
+    ::xmpp::xml::split $child tag xmlns attrs cdata subels
 
-    foreach ch $children {
-	jlib::wrapper:splitxml $ch tag1 vars1 isempty1 chdata1 children1
-	switch -- $tag1 {
+    foreach ch $subels {
+	::xmpp::xml::split $ch stag sxmlns sattrs scdata ssubels
+	switch -- $stag {
 	    identity {
 		lappend identities \
-		    [list \
-			 category [jlib::wrapper:getattr $vars1 category] \
-			 name [jlib::wrapper:getattr $vars1 name] \
-			 type [jlib::wrapper:getattr $vars1 type]]
+		    [list category [::xmpp::xml::getAttr $sattrs category] \
+			  name [::xmpp::xml::getAttr $sattrs name] \
+			  type [::xmpp::xml::getAttr $sattrs type]]
 	    }
 	    feature {
-		set var [jlib::wrapper:getattr $vars1 var]
+		set var [::xmpp::xml::getAttr $sattrs var]
 		if {$var == ""} {
-		    set var [jlib::wrapper:getattr $vars1 type]
+		    set var [::xmpp::xml::getAttr $sattrs type]
 		}
 		lappend features [list var $var]
 		if {($node == "") && [info exists additional_nodes($var)]} {
 		    lappend featured_nodes \
 			    [concat [list jid $jid] $additional_nodes($var)]
-		    set inode [jlib::wrapper:getattr $additional_nodes($var) node]
-		    set iname [jlib::wrapper:getattr $additional_nodes($var) name]
-		    if {![info exists disco(jidname,$connid,$jid,$inode)]} {
-			set disco(jidname,$connid,$jid,$inode) $iname
+		    set inode [::xmpp::xml::getAttr $additional_nodes($var) node]
+		    set iname [::xmpp::xml::getAttr $additional_nodes($var) name]
+		    if {![info exists disco(jidname,$xlib,$jid,$inode)]} {
+			set disco(jidname,$xlib,$jid,$inode) $iname
 		    }
 		}
 	    }
 	    default {
-		if {[jlib::wrapper:getattr $vars1 xmlns] == $::NS(data) && \
-			[jlib::wrapper:getattr $vars1 type] == "result"} {
-		    lappend extras [data::parse_xdata_results $children1 -hidden 1]
+		if {[::xmpp::xml::getAttr $sattrs xmlns] == $::NS(data) && \
+			[::xmpp::xml::getAttr $sattrs type] == "result"} {
+		    lappend extras [data::parse_xdata_results $ssubels -hidden 1]
 		}
 	    }
 	}
     }
 
-    set disco(info,identities,$connid,$jid,$node) $identities
-    set disco(info,features,$connid,$jid,$node) $features
-    set disco(info,extras,$connid,$jid,$node) $extras
-    set disco(info,featured_nodes,$connid,$jid,$node) [lrmdups $featured_nodes]
+    set disco(info,identities,$xlib,$jid,$node) $identities
+    set disco(info,features,$xlib,$jid,$node) $features
+    set disco(info,extras,$xlib,$jid,$node) $extras
+    set disco(info,featured_nodes,$xlib,$jid,$node) [lrmdups $featured_nodes]
 
     debugmsg disco \
 	"INFO: IDENTITIES [list $identities] FEATURES [list $features]\
 	 EXTRAS [list $extras] FEATURED NODES [list [lrmdups $featured_nodes]]"
 
     if {$handler != ""} {
-	eval $handler [list OK $identities $features $extras]
+	eval $handler [list ok $identities $features $extras]
     }
-    hook::run disco_info_hook $connid $jid $node OK $identities $features \
+    hook::run disco_info_hook $xlib $jid $node ok $identities $features \
 			      $extras [lrmdups $featured_nodes]
 }
 
 ###############################################################################
 
-proc disco::get_jid_name {connid jid node} {
+proc disco::get_jid_name {xlib jid node} {
     variable disco
-    if {[info exists disco(jidname,$connid,$jid,$node)]} {
-	return $disco(jidname,$connid,$jid,$node)
+    if {[info exists disco(jidname,$xlib,$jid,$node)]} {
+	return $disco(jidname,$xlib,$jid,$node)
     } else {
 	return ""
     }
 }
 
-proc disco::get_jid_identities {connid jid node} {
+proc disco::get_jid_identities {xlib jid node} {
     variable disco
-    if {[info exists disco(info,identities,$connid,$jid,$node)]} {
-	return $disco(info,identities,$connid,$jid,$node)
+    if {[info exists disco(info,identities,$xlib,$jid,$node)]} {
+	return $disco(info,identities,$xlib,$jid,$node)
     } else {
 	return {}
     }
 }
 
-proc disco::get_jid_features {connid jid node} {
+proc disco::get_jid_features {xlib jid node} {
     variable disco
-    if {[info exists disco(info,features,$connid,$jid,$node)]} {
-	return $disco(info,features,$connid,$jid,$node)
+    if {[info exists disco(info,features,$xlib,$jid,$node)]} {
+	return $disco(info,features,$xlib,$jid,$node)
     } else {
 	return {}
     }
 }
 
-proc disco::get_jid_items {connid jid node} {
+proc disco::get_jid_items {xlib jid node} {
     variable disco
-    if {[info exists disco(items,$connid,$jid,$node)]} {
-	return $disco(items,$connid,$jid,$node)
+    if {[info exists disco(items,$xlib,$jid,$node)]} {
+	return $disco(items,$xlib,$jid,$node)
     } else {
 	return {}
     }
@@ -283,95 +278,101 @@
 
 ###############################################################################
 
-proc disco::info_query_get_handler {connid from lang child} {
+proc disco::info_query_get_handler {xlib from child args} {
     variable supported_nodes
     variable node_handlers
     variable supported_features
     variable feature_handlers
     variable extra_handlers
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
-    set node [jlib::wrapper:getattr $vars node]
+    ::xmpp::xml::split $child tag xmlns attrs cdata subels
+    set node [::xmpp::xml::getAttr $attrs node]
 
+    set lang [::xmpp::xml::getAttr $args -lang en]
+
     if {![string equal $node ""]} {
 	if {![info exists supported_nodes($node)]} {
 	    # Probably temporary node
 	    set res {error cancel not-allowed}
 	    hook::run disco_node_reply_hook \
-		      res info $node $connid $from $lang $child
+		      res info $node $xlib $from $lang $child
 	    return $res
 	} else {
 	    # Permanent node
 	    set restags [eval $node_handlers($node) \
-			      [list info $connid $from $lang $child]]
+			      [list info $xlib $from $lang $child]]
 	    if {[string equal [lindex $restags 0] error]} {
 		return $restags
 	    } else {
-		set res [jlib::wrapper:createtag query \
-			     -vars [list xmlns $::NS(disco_info) node $node] \
-			     -subtags $restags]
+		set res [::xmpp::xml::create query \
+			     -xmlns $::NS(disco_info) \
+			     -attrs [list node $node] \
+			     -subelements $restags]
 	    }
 	}
     } else {
 	set restags {}
 
-	lappend restags [jlib::wrapper:createtag identity \
-			     -vars [list category client \
-					 type     pc \
-					 name     Tkabber]]
+	lappend restags [::xmpp::xml::create identity \
+				    -attrs [list category client \
+						 type     pc \
+						 name     Tkabber]]
 
 	foreach h $extra_handlers {
-	    lappend restags [eval $h [list $connid $from $lang]]
+	    lappend restags [eval $h [list $xlib $from $lang]]
 	}
 
-	foreach ns [lsort [concat $::iq::supported_ns $supported_features]] {
-	    lappend restags [jlib::wrapper:createtag feature \
-				 -vars [list var $ns]]
+	foreach ns [lsort [concat [::xmpp::iq::registered $xlib] \
+				  $supported_features]] {
+	    lappend restags [::xmpp::xml::create feature -attrs [list var $ns]]
 	}
     
-	set res [jlib::wrapper:createtag query \
-		     -vars [list xmlns $::NS(disco_info)] \
-		     -subtags $restags]
+	set res [::xmpp::xml::create query \
+			-xmlns $::NS(disco_info) \
+			-subelements $restags]
     }
     return [list result $res]
 }
 
-iq::register_handler get query $::NS(disco_info) \
-    [namespace current]::disco::info_query_get_handler
+::xmpp::iq::register get query $::NS(disco_info) \
+		     [namespace current]::disco::info_query_get_handler
 
 ###############################################################################
 
-proc disco::items_query_get_handler {connid from lang child} {
+proc disco::items_query_get_handler {xlib from child args} {
     variable supported_nodes
     variable node_handlers
     variable root_nodes
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
-    set node [jlib::wrapper:getattr $vars node]
+    ::xmpp::xml::split $child tag xmlns attrs cdata subels
+    set node [::xmpp::xml::getAttr $attrs node]
 
+    set lang [::xmpp::xml::getAttr $args -lang en]
+
     if {![string equal $node ""]} {
 	if {![info exists supported_nodes($node)]} {
 	    # Probably temporary node
 	    set res {error cancel not-allowed}
 	    hook::run disco_node_reply_hook \
-		      res items $node $connid $from $lang $child
+		      res items $node $xlib $from $lang $child
 	    return $res
 	} else {
 	    # Permanent node
 	    set restags [eval $node_handlers($node) \
-			      [list items $connid $from $lang $child]]
+			      [list items $xlib $from $lang $child]]
 	    if {[string equal [lindex $restags 0] error]} {
 		return $restags
 	    } else {
-		set res [jlib::wrapper:createtag query \
-			     -vars [list xmlns $::NS(disco_items) node $node] \
-			     -subtags $restags]
+		set res [::xmpp::xml::create query \
+			     -xmlns $::NS(disco_items) \
+			     -attrs [list node $node] \
+			     -subelements $restags]
 	    }
 	}
     } else {
 	set restags {}
 
-	set myjid [my_jid $connid $from]
+	set myjid [my_jid $xlib $from]
 
 	foreach node $root_nodes {
 	    set vars [list jid $myjid]
@@ -381,18 +382,17 @@
 	    if {![string equal $node ""]} {
 		lappend vars node $node
 	    }
-	    lappend restags [jlib::wrapper:createtag item \
-				 -vars $vars]
+	    lappend restags [::xmpp::xml::create item -attrs $vars]
 	}
 
-	set res [jlib::wrapper:createtag query \
-		     -vars [list xmlns $::NS(disco_items)] \
-		     -subtags $restags]
+	set res [::xmpp::xml::create query \
+			    -xmlns $::NS(disco_items) \
+			    -subelements $restags]
     }
     return [list result $res]
 }
 
-iq::register_handler get query $::NS(disco_items) \
+::xmpp::iq::register get query $::NS(disco_items) \
     [namespace current]::disco::items_query_get_handler
 
 ###############################################################################
@@ -448,25 +448,21 @@
 
 ###############################################################################
 
-proc disco::publish_items {jid node action items args} {
+proc disco::publish_items {xlib jid node action items args} {
 
     set command ""
     foreach {key val} $args {
 	switch -- {
-	    -connection { set connid $val }
 	    -command { set command $val }
 	}
     }
-    if {![info exists connid]} {
-	return "disco::publish_items: option -connection required"
-    }
 
-    jlib::send_iq set \
-	[jlib::wrapper:createtag query \
-	     -vars [list xmlns $::NS(disco#publish) node $node] \
-	     -subtags $items] \
+    ::xmpp::sendIQ $xlib set \
+	-query [::xmpp::xml::create query \
+			-xmlns $::NS(disco#publish) \
+			-attrs [list node $node] \
+			-subelements $items] \
 	-to $jid \
-	-connection $connid \
 	-command [list [namespace current]::publish_items_result $command]
 
 }
@@ -509,19 +505,19 @@
     variable node_list
     variable browser
 
-    if {[llength [jlib::connections]] == 0} return
+    if {[llength [connections]] == 0} return
 
     foreach {opt val} $args {
 	switch -- $opt {
-	    -connection { set connid $val }
+	    -connection { set xlib $val }
 	}
     }
-    if {![info exists connid]} {
-	set connid [lindex [jlib::connections] 0]
+    if {![info exists xlib]} {
+	set xlib [lindex [connections] 0]
     }
 
     if {$jid == ""} {
-	set curjid($winid) [jlib::connection_server $connid]
+	set curjid($winid) [connection_server $xlib]
     } else {
 	set curjid($winid) $jid
     }
@@ -529,7 +525,7 @@
     set w .disco_$winid
     set wid $winid
     incr winid
-    set browser(connid,$w) $connid
+    set browser(xlib,$w) $xlib
 
     add_win $w -title [::msgcat::mc "Service Discovery"] \
 	-tabtitle [::msgcat::mc "Discovery"] \
@@ -625,20 +621,20 @@
 	lappend browser(required,$bw) $jid
 	set browser(required,$bw) [lrmdups $browser(required,$bw)]
 
-	disco::request_info $jid $node -connection $browser(connid,$bw)
-	disco::request_items $jid $node -connection $browser(connid,$bw)
+	disco::request_info $browser(xlib,$bw) $jid -node $node
+	disco::request_items $browser(xlib,$bw) $jid -node $node
     }
 }
 
 proc disco::browser::info_receive \
-     {connid jid node res identities features extras featured_nodes} {
+     {xlib jid node res identities features extras featured_nodes} {
     variable browser
 
     if {![info exists browser(opened)]} return
 
     foreach w $browser(opened) {
 	if {[winfo exists $w] && [lcontain $browser(required,$w) $jid]} {
-	    draw_info $w $connid $jid $node $res $identities \
+	    draw_info $w $xlib $jid $node $res $identities \
 		      $features $extras $featured_nodes
 	}
     }
@@ -648,20 +644,20 @@
     [namespace current]::disco::browser::info_receive
 
 proc disco::browser::draw_info \
-     {w connid jid node res identities features extras featured_nodes} {
+     {w xlib jid node res identities features extras featured_nodes} {
     variable browser
     variable config
 
     set tw $browser(tree,$w)
 
-    set name [disco::get_jid_name $connid $jid $node]
+    set name [disco::get_jid_name $xlib $jid $node]
     set tnode [jid_to_tag [list $jid $node]]
     set parent_tag [jid_to_tag [list $jid $node]]
-    set data [list item $connid $jid $node]
+    set data [list item $xlib $jid $node]
     if {![$tw exists $tnode] || [llength [$tw nodes $tnode]] == 0} {
 	set nitems 0
     } else {
-	set nitems [llength [disco::get_jid_items $connid $jid $node]]
+	set nitems [llength [disco::get_jid_items $xlib $jid $node]]
     }
     set desc [item_desc $jid $node $name $nitems]
     set icon ""
@@ -669,10 +665,9 @@
     add_line $tw $parent_tag $tnode $icon $desc $data \
 	-fill $config(fill)
 
-    if {$res != "OK"} {
+    if {$res != "ok"} {
 	set tnode [jid_to_tag "error info $jid $node"]
-	set data [list error_info $connid $jid]
-	#set name     [jlib::wrapper:getattr $identity name]
+	set data [list error_info $xlib $jid]
 	set desc [format [::msgcat::mc "Error getting info: %s"] \
 		      [error_to_string $identities]]
 	set icon ""
@@ -693,10 +688,10 @@
     foreach identity $identities {
 	set tnode [jid_to_tag "identity $identity $jid $node"]
 	lappend identitynodes $tnode
-	set name     [jlib::wrapper:getattr $identity name]
-	set category [jlib::wrapper:getattr $identity category]
-	set type     [jlib::wrapper:getattr $identity type]
-	set data [list identity $connid $jid $node $category $type]
+	set name     [::xmpp::xml::getAttr $identity name]
+	set category [::xmpp::xml::getAttr $identity category]
+	set type     [::xmpp::xml::getAttr $identity type]
+	set data [list identity $xlib $jid $node $category $type]
 	set desc "$name ($category/$type)"
 	set icon [item_icon $category $type]
 	
@@ -712,7 +707,7 @@
 	    if {$type == "hidden"} continue
 	    set tnode [jid_to_tag "extra $var $jid $node"]
 	    lappend extranodes $tnode
-	    set data [list extra $var $connid $jid $node]
+	    set data [list extra $var $xlib $jid $node]
 	    set value [join $values ", "]
 	    if {$label != ""} {
 		set desc "$label ($var): $value"
@@ -729,10 +724,10 @@
     set featurenodes {}
 
     foreach feature $features {
-	set var [jlib::wrapper:getattr $feature var]
+	set var [::xmpp::xml::getAttr $feature var]
 	set tnode [jid_to_tag "feature $feature $jid $node"]
 	lappend featurenodes $tnode
-	set data [list feature $connid $jid $node $feature $category $type]
+	set data [list feature $xlib $jid $node $feature $category $type]
 	set desc $var
 	if {[info exists browser(feature_handler_desc,$var)]} {
 	    catch { array unset tmp }
@@ -752,16 +747,16 @@
     # Draw all implicit item nodes, which are not received explicitly
     # (don't overwrite node because it can have different name)
     foreach item $featured_nodes {
-	set ijid [jlib::wrapper:getattr $item jid]
-	set node [jlib::wrapper:getattr $item node]
+	set ijid [::xmpp::xml::getAttr $item jid]
+	set node [::xmpp::xml::getAttr $item node]
 
-	set name [jlib::wrapper:getattr $item name]
+	set name [::xmpp::xml::getAttr $item name]
 	set tnode [jid_to_tag [list $ijid $node]]
-	set data [list item $connid $ijid $node]
+	set data [list item $xlib $ijid $node]
 	if {![$tw exists $tnode] || [llength [$tw nodes $tnode]] == 0} {
 	    set nitems 0
 	} else {
-	    set nitems [llength [disco::get_jid_items $connid $ijid $node]]
+	    set nitems [llength [disco::get_jid_items $xlib $ijid $node]]
 	}
 	set desc [item_desc $ijid $node $name $nitems]
 	set icon ""
@@ -779,14 +774,14 @@
     reorder_node $tw $parent_tag
 }
 
-proc disco::browser::items_receive {connid jid node res items} {
+proc disco::browser::items_receive {xlib jid node res items} {
     variable browser
 
     if {![info exists browser(opened)]} return
 
     foreach w $browser(opened) {
 	if {[winfo exists $w] && [lcontain $browser(required,$w) $jid]} {
-	    draw_items $w $connid $jid $node $res $items
+	    draw_items $w $xlib $jid $node $res $items
 	}
     }
 }
@@ -794,7 +789,7 @@
 hook::add disco_items_hook \
     [namespace current]::disco::browser::items_receive
 
-proc disco::browser::draw_items {w connid jid node res items} {
+proc disco::browser::draw_items {w xlib jid node res items} {
     variable browser
     variable config
 
@@ -802,13 +797,13 @@
 
     set parent_tag [jid_to_tag [list $jid $node]]
 
-    set name [disco::get_jid_name $connid $jid $node]
+    set name [disco::get_jid_name $xlib $jid $node]
     set tnode [jid_to_tag [list $jid $node]]
-    set data [list item $connid $jid $node]
+    set data [list item $xlib $jid $node]
     if {![$tw exists $tnode] || [llength [$tw nodes $tnode]] == 0} {
 	set nitems 0
     } else {
-	set nitems [llength [disco::get_jid_items $connid $jid $node]]
+	set nitems [llength [disco::get_jid_items $xlib $jid $node]]
     }
     set desc [item_desc $jid $node $name $nitems]
     set icon ""
@@ -816,15 +811,14 @@
     add_line $tw $parent_tag $tnode $icon $desc $data \
 	-fill $config(fill)
 
-    if {$res != "OK"} {
+    if {$res != "ok"} {
 	# HACK
-	if {[info exists ::disco::disco(info,featured_nodes,$connid,$jid,$node)] && \
-	    ![lempty $::disco::disco(info,featured_nodes,$connid,$jid,$node)]} {
+	if {[info exists ::disco::disco(info,featured_nodes,$xlib,$jid,$node)] && \
+	    ![lempty $::disco::disco(info,featured_nodes,$xlib,$jid,$node)]} {
 	    set items {}
 	} else {
 	    set tnode [jid_to_tag "error items $jid $node"]
-	    set data [list error_items $connid $jid]
-	    #set name     [jlib::wrapper:getattr $identity name]
+	    set data [list error_items $xlib $jid]
 	    set desc [::msgcat::mc "Error getting items: %s" \
 				   [error_to_string $items]]
 	    set icon ""
@@ -843,25 +837,25 @@
     # (if the service's features change then this node list may be
     # incorrect)
     set itemnodes {}
-    if {[info exists ::disco::disco(info,featured_nodes,$connid,$jid,$node)]} {
-	foreach item $::disco::disco(info,featured_nodes,$connid,$jid,$node) {
-	    set ijid [jlib::wrapper:getattr $item jid]
-	    set inode [jlib::wrapper:getattr $item node]
+    if {[info exists ::disco::disco(info,featured_nodes,$xlib,$jid,$node)]} {
+	foreach item $::disco::disco(info,featured_nodes,$xlib,$jid,$node) {
+	    set ijid [::xmpp::xml::getAttr $item jid]
+	    set inode [::xmpp::xml::getAttr $item node]
 	    lappend itemnodes [jid_to_tag [list $ijid $inode]]
 	}
     }
 
     foreach item $items {
-	set ijid [jlib::wrapper:getattr $item jid]
-	set node [jlib::wrapper:getattr $item node]
+	set ijid [::xmpp::xml::getAttr $item jid]
+	set node [::xmpp::xml::getAttr $item node]
 
-	set name [jlib::wrapper:getattr $item name]
+	set name [::xmpp::xml::getAttr $item name]
 	set tnode [jid_to_tag [list $ijid $node]]
-	set data [list item $connid $ijid $node]
+	set data [list item $xlib $ijid $node]
 	if {![$tw exists $tnode] || [llength [$tw nodes $tnode]] == 0} {
 	    set nitems 0
 	} else {
-	    set nitems [llength [disco::get_jid_items $connid $ijid $node]]
+	    set nitems [llength [disco::get_jid_items $xlib $ijid $node]]
 	}
 	set desc [item_desc $ijid $node $name $nitems]
 	set icon ""
@@ -880,17 +874,16 @@
     browser_action $browser(sort,$w,$parent_tag) $w $parent_tag
 }
 
-proc disco::browser::negotiate_feature {tw connid jid parent type} {
+proc disco::browser::negotiate_feature {tw xlib jid parent type} {
     variable config
 
-    lassign [negotiate::send_request $connid $jid $type] res opts
+    lassign [negotiate::send_request $xlib $jid $type] res opts
 
     if {![winfo exists $tw]} return
 
-    if {$res != "OK"} {
+    if {$res != "ok"} {
 	set node [jid_to_tag "error negotiate $parent"]
-	set data [list error_negotiate $parent $connid $jid]
-	#set name     [jlib::wrapper:getattr $identity name]
+	set data [list error_negotiate $parent $xlib $jid]
 	set desc [format [::msgcat::mc "Error negotiate: %s"] \
 		      [error_to_string $opts]]
 	set icon ""
@@ -1033,26 +1026,24 @@
     set data2 [lassign $data type]
     switch -- $type {
 	item {
-	    lassign $data2 connid jid node
+	    lassign $data2 xlib jid node
 	    goto $bw $jid $node
 	}
 	feature {
-	    lassign $data2 connid jid node feature category subtype
-	    set var [jlib::wrapper:getattr $feature var]
+	    lassign $data2 xlib jid node feature category subtype
+	    set var [::xmpp::xml::getAttr $feature var]
 	    debugmsg disco $jid
 	    if {$var != ""} {
 		if {[info exists browser(feature_handler,$var)]} {
 		    if {$browser(feature_handler_node,$var)} {
-			eval $browser(feature_handler,$var) [list $jid $node \
-			    -category $category -type $subtype \
-			    -connection $connid]
+			eval $browser(feature_handler,$var) [list $xlib $jid $node \
+			    -category $category -type $subtype]
 		    } else {
-			eval $browser(feature_handler,$var) [list $jid \
-			    -category $category -type $subtype \
-			    -connection $connid]
+			eval $browser(feature_handler,$var) [list $xlib $jid \
+			    -category $category -type $subtype]
 		    }
 		} else {
-		    negotiate_feature $tw $connid $jid $tnode $var
+		    negotiate_feature $tw $xlib $jid $tnode $var
 		}
 	    }
 	}
@@ -1153,9 +1144,9 @@
 	foreach sn [$tw nodes $tnode] {
 	    $tw delete $sn
 	}
-	lassign [$tw itemcget $tnode -data] type connid jid node
+	lassign [$tw itemcget $tnode -data] type xlib jid node
 	if {$type == "item"} {
-	    set name [disco::get_jid_name $connid $jid $node]
+	    set name [disco::get_jid_name $xlib $jid $node]
 	    set desc [item_desc $jid $node $name 0]
 	    $tw itemconfigure $tnode -text $desc
 	}
@@ -1184,10 +1175,10 @@
 		set data [lassign [$tw itemcget $child -data] type]
 		switch -- $type {
 		    item {
-			lassign $data connid jid node
+			lassign $data xlib jid node
 			lappend items \
 			    [list $child \
-				  [disco::get_jid_name $connid $jid $node]]
+				  [disco::get_jid_name $xlib $jid $node]]
 		    }
 		}
             }
@@ -1210,7 +1201,7 @@
 		set data [lassign [$tw itemcget $child -data] type]
 		switch -- $type {
 		    item {
-			lassign $data connid jid node
+			lassign $data xlib jid node
 			if {$node != {}} {
 			    lappend items_with_nodes \
 				[list $child "$jid\u0000$node"]
@@ -1248,7 +1239,7 @@
 	return [list $bw:$node ""]
     }
 
-    lassign $data type connid jid category subtype name version
+    lassign $data type xlib jid category subtype name version
     if {$type == "jid"} {
 	return [list $bw:$node \
 		     [item_balloon_text $jid $category $subtype $name $version]]
@@ -1268,7 +1259,7 @@
 proc disco::browser::get_category_type {t tnode} {
     foreach child [$t nodes $tnode] {
 	set data [$t itemcget $child -data]
-        set data2 [lassign $data type connid jid node]
+        set data2 [lassign $data type xlib jid node]
 	if {$type == "identity"} {
 	    return $data2
 	}
@@ -1278,7 +1269,7 @@
 
 proc disco::browser::draginitcmd {bw t tnode top} {
     set data [$t itemcget $tnode -data]
-    set data2 [lassign $data type connid jid node]
+    set data2 [lassign $data type xlib jid node]
 
     if {$type == "item"} {
 	if {[set img [$t itemcget $tnode -image]] != ""} {
@@ -1294,11 +1285,11 @@
 
 	    if {![info exists category] || ($category != "conference")} {
 		# For other JIDs use heuristics from roster code.
-		lassign [roster::get_category_and_subtype $connid $jid] category type
+		lassign [roster::get_category_and_subtype $xlib $jid] category type
 	    }
 	}
 
-	return [list JID {copy} [list $connid $jid $category $type "" ""]]
+	return [list JID {copy} [list $xlib $jid $category $type "" ""]]
     } else {
 	return {}
     }
@@ -1331,8 +1322,8 @@
     $bw.navigate.node.e delete 0 end
     $bw.navigate.node.e insert 0 $newnode
 
-    disco::request_info $newjid $newnode -connection $browser(connid,$bw)
-    disco::request_items $newjid $newnode -connection $browser(connid,$bw)
+    disco::request_info $browser(xlib,$bw) $newjid -node $newnode
+    disco::request_items $browser(xlib,$bw) $newjid -node $newnode
 }
 
 proc disco::browser::history_add {bw jid} {

Modified: trunk/tkabber/doc/tkabber.xml
===================================================================
--- trunk/tkabber/doc/tkabber.xml	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/doc/tkabber.xml	2008-10-17 17:16:09 UTC (rev 1520)
@@ -732,7 +732,7 @@
 
 # debugging output
 
-set debug_lvls {jlib warning}
+set debug_lvls {xmpp warning}
 
 
 # splash window

Modified: trunk/tkabber/examples/configs/badlop-config.tcl
===================================================================
--- trunk/tkabber/examples/configs/badlop-config.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/examples/configs/badlop-config.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -125,7 +125,7 @@
 
 # Join groupchats automatically at the start (other available option: -nick <yournick>)
 #proc connload {connid} {
-#	join_group jabber at conference.jabber.org -connection $connid }
+#	join_group $connid jabber at conference.jabber.org }
 #hook::add connected_hook connload 1000
 
 

Modified: trunk/tkabber/examples/configs/mtr-config.tcl
===================================================================
--- trunk/tkabber/examples/configs/mtr-config.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/examples/configs/mtr-config.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -395,9 +395,9 @@
     return
 
     foreach g [list xmpp] {
-        join_group ${g}@ietf.xmpp.org -nick mrose -connection $connid
+        join_group $connid ${g}@ietf.xmpp.org -nick mrose
     }
-    join_group wgchairs at conference.psg.com -nick mrose -connection $connid
+    join_group $connid wgchairs at conference.psg.com -nick mrose
 }
 
 hook::add connected_hook config_connload 1000

Modified: trunk/tkabber/examples/configs/teo-config.tcl
===================================================================
--- trunk/tkabber/examples/configs/teo-config.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/examples/configs/teo-config.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -70,8 +70,6 @@
     exec galeon -w $url &
 }
 
-#hook::add connected_hook {join_group talks at conference.jupiter.golovan.ru teo} 100
-
 proc postload {} {
 
 # Set initial roster options

Modified: trunk/tkabber/filetransfer.tcl
===================================================================
--- trunk/tkabber/filetransfer.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/filetransfer.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -115,14 +115,13 @@
 
 ###############################################################################
 
-proc ft::create_menu {m connid jid} {
+proc ft::create_menu {m xlib jid} {
     variable protocols
 
     if {![lempty $protocols(names)]} {
 	$m add command -label [::msgcat::mc "Send file..."] \
 		       -command [list [namespace current]::send_file_dialog \
-				      $jid \
-				      -connection $connid]
+				      $xlib $jid]
     }
 }
 
@@ -142,29 +141,18 @@
 # Draw a send file dialog
 #
 
-proc ft::send_file_dialog {jid args} {
+proc ft::send_file_dialog {xlib jid args} {
     variable winid
     variable options
     variable protocols
 
-    foreach {opt val} $args {
-	switch -- $opt {
-	    -connection { set connid $val }
-	}
-    }
-
-    if {![info exists connid]} {
-	error "[namespace current]::send_file_dialog: -connection option\
-	       is mandatory"
-    }
-
     set token [namespace current]::[incr winid]
     upvar #0 $token state
 
     set w .sfd$winid
     set state(w) $w
     set state(jid) $jid
-    set state(connid) $connid
+    set state(xlib) $xlib
 
     Dialog $w -title [format [::msgcat::mc "Send file to %s"] $jid] \
 	      -separator 1 -anchor e -modal none \
@@ -309,7 +297,7 @@
     if {![info exists state(w)] || ![winfo exists $state(w)]} return
 
     switch -- $res {
-	ERR {
+	error {
 	    if {$state(size) > 0} {
 		set state(progress) 0
 	    }
@@ -318,7 +306,7 @@
 	    catch {close $state(fd)}
 	    $state(w) itemconfigure 0 -state normal
 	}
-	PROGRESS {
+	progress {
 	    if {$state(size) > 0} {
 		set state(progress) $msg
 	    }

Modified: trunk/tkabber/filters.tcl
===================================================================
--- trunk/tkabber/filters.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/filters.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -96,10 +96,10 @@
 	return
     }
 
-    jlib::send_iq get \
-	[jlib::wrapper:createtag item \
-	     -vars {xmlns jabber:iq:filter}] \
-	-connection [jlib::route ""] \
+    set xlib [lindex [connections] 0]
+
+    ::xmpp::sendIQ $xlib get \
+	-query [::xmpp::xml::create item -xmlns jabber:iq:filter] \
 	-command [list filters::recv]
 }
 
@@ -111,7 +111,7 @@
 
     debugmsg filters "$res $child"
 
-    if {![cequal $res OK]} {
+    if {![string equal $res ok]} {
 	MessageDlg .filters_err -aspect 50000 -icon error \
 	    -message [format [::msgcat::mc "Requesting filter rules: %s"] \
 			  [error_to_string $child]] \
@@ -150,10 +150,10 @@
     array unset rule
     set rulelist {}
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
+    ::xmpp::xml::split $child tag xmlns attrs cdata subels
 
-    if {[cequal [jlib::wrapper:getattr $vars xmlns] jabber:iq:filter]} {
-	foreach child $children {
+    if {[string equal $xmlns jabber:iq:filter]} {
+	foreach child $subels {
 	    process_rule $child
 	}
     }
@@ -166,13 +166,13 @@
     variable rf
     variable rulelist
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
+    ::xmpp::xml::split $child tag xmlns attrs cdata subels
 
-    set rname [jlib::wrapper:getattr $vars name]
+    set rname [::xmpp::xml::getAttr $attrs name]
     $rf insert end $rname
     lappend rulelist $rname
 
-    foreach data $children {
+    foreach data $subels {
 	process_rule_data $rname $data
     }
 }
@@ -180,9 +180,9 @@
 proc filters::process_rule_data {name child} {
     variable rule
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
+    ::xmpp::xml::split $child tag xmlns attrs cdata subels
 
-    lappend rule($name) $tag $chdata
+    lappend rule($name) $tag $cdata
     debugmsg filters [array get rule]
 }
 
@@ -416,21 +416,23 @@
     foreach rname $rulelist {
 	set rtags {}
 	foreach {tag val} $rule($rname) {
-	    lappend rtags [jlib::wrapper:createtag $tag -chdata $val]
+	    lappend rtags [::xmpp::xml::create $tag -cdata $val]
 	}
 
-	lappend result [jlib::wrapper:createtag rule \
-			    -vars [list name $rname] \
-			    -subtags $rtags]
+	lappend result [::xmpp::xml::create rule \
+			    -attrs [list name $rname] \
+			    -subelements $rtags]
     }
 
     debugmsg filters $result
-    jlib::send_iq set \
-	[jlib::wrapper:createtag item \
-	     -vars {xmlns jabber:iq:filter} \
-	     -subtags $result] \
-	-connection [jlib::route ""] \
 
+    set xlib [lindex [connections] 0]
+
+    ::xmpp::sendIQ $xlib set \
+	    -query [::xmpp::xml::create item \
+			    -xmlns jabber:iq:filter \
+			    -subelements $result]
+
     destroy .filters
 }
 

Modified: trunk/tkabber/gpgme.tcl
===================================================================
--- trunk/tkabber/gpgme.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/gpgme.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -11,14 +11,14 @@
     set chatw [chat::chat_win $chatid]
 
     foreach xe $x {
-	jlib::wrapper:splitxml $xe tag vars isempty cdata children
+	::xmpp::xml::split $xe tag xmlns attrs cdata subels
 
-	if {![cequal [jlib::wrapper:getattr $vars xmlns] $::NS(encrypted)]} {
+	if {![string equal $xmlns $::NS(encrypted)]} {
 	    continue
 	}
 
-	if {[cequal $cdata ""] || \
-	    [cequal [info commands ::ssj::encrypted:input] ""]} {
+	if {[string equal $cdata ""] || \
+	    [string equal [info commands ::ssj::encrypted:input] ""]} {
 	    $chatw image create end -image gpg/badencrypted
 	} else {
 	    $chatw image create end -image gpg/encrypted
@@ -31,7 +31,7 @@
 
 #############################################################################
 
-proc ::ssj::process_x_encrypted {rowvar bodyvar f x connid from id type replyP} {
+proc ::ssj::process_x_encrypted {rowvar bodyvar f x xlib from id type replyP} {
     upvar 2 $rowvar row
     upvar 2 $bodyvar body
 
@@ -40,8 +40,7 @@
     }
 
     foreach xa $x {
-	jlib::wrapper:splitxml $xa tag vars isempty cdata children
-	set xmlns [jlib::wrapper:getattr $vars xmlns]
+	::xmpp::xml::split $xa tag xmlns attrs cdata subels
 
 	if {$xmlns != $::NS(encrypted)} continue
 
@@ -51,8 +50,8 @@
 	    destroy $lb
 	}
 
-	if {[cequal $cdata ""] || \
-	    [cequal [info commands ::ssj::encrypted:input] ""]} {
+	if {[string equal $cdata ""] || \
+	    [string equal [info commands ::ssj::encrypted:input] ""]} {
 	    Label $lb -image gpg/badencrypted
 	} else {
 	    Label $lb -image gpg/encrypted
@@ -143,34 +142,34 @@
 }
 
 
-proc ::ssj::once_only {connid {armorP 0}} {
+proc ::ssj::once_only {xlib {armorP 0}} {
     global env gpgPkg
     variable options
     variable ctx
 
-    debugmsg ssj "ONCE_ONLY $connid"
+    debugmsg ssj "ONCE_ONLY $xlib"
 
-    if {[info exists ctx($connid)] && ![cequal $ctx($connid) ""]} {
-        $ctx($connid) -operation set   \
+    if {[info exists ctx($xlib)] && ![cequal $ctx($xlib) ""]} {
+        $ctx($xlib) -operation set   \
 		      -property  armor \
 		      -value     $armorP
 
         return
     }
 
-    set ctx($connid) [${gpgPkg}::context]
-    $ctx($connid) -operation set   \
+    set ctx($xlib) [${gpgPkg}::context]
+    $ctx($xlib) -operation set   \
 		  -property  armor \
 		  -value     $armorP
 
 
     if {![info exists env(GPG_AGENT_INFO)]} {
-        $ctx($connid) -operation set                 \
+        $ctx($xlib) -operation set                 \
 		      -property  passphrase-callback \
-		      -value     [list ::ssj::passphrase $connid]
+		      -value     [list ::ssj::passphrase $xlib]
     }
 
-    set pattern [jlib::connection_bare_jid $connid]
+    set pattern [connection_bare_jid $xlib]
 
     set firstP 1
     if {$options(key) != ""} {
@@ -180,16 +179,16 @@
     }
     lappend patterns $pattern ""
     foreach p $patterns {
-        set command [list $ctx($connid) -operation start-key -secretonly true]
+        set command [list $ctx($xlib) -operation start-key -secretonly true]
         if {![cequal $p ""]} {
             lappend command -patterns [list $p]
         }
         eval $command
 
         for {set keys {}} \
-            {![cequal [set key [$ctx($connid) -operation next-key]] ""]} \
+            {![cequal [set key [$ctx($xlib) -operation next-key]] ""]} \
             {lappend keys $key} {}
-        $ctx($connid) -operation done-key
+        $ctx($xlib) -operation done-key
 
         if {[llength $keys] > 0} {
             break
@@ -207,7 +206,7 @@
 
         1 {
             if {$firstP} {
-                e4meP $connid $keys
+                e4meP $xlib $keys
                 return
             }
         }
@@ -216,13 +215,13 @@
         }
     }
 
-    set dw .selectkey$connid
+    set dw .selectkey$xlib
     catch {destroy $dw}
 
     set titles {}
     set balloons {}
     foreach key $keys {
-	set key_info [$ctx($connid) -operation info-key -key $key]
+	set key_info [$ctx($xlib) -operation info-key -key $key]
         foreach {k v} $key_info {
 	    if {[string equal $k email]} {
 		lappend titles $key $v
@@ -230,7 +229,7 @@
 		break
 	    }
 	}
-        foreach {k v} [$ctx($connid) -operation info-key -key $key] {
+        foreach {k v} [$ctx($xlib) -operation info-key -key $key] {
 	    if {![string equal $k subkeys]} {
 		continue
 	    }
@@ -248,9 +247,9 @@
     }
 
     CbDialog $dw [::msgcat::mc "Select Key for Signing %s Traffic" $pattern] \
-        [list [::msgcat::mc "Select"] "::ssj::once_only_aux $dw $connid" \
+        [list [::msgcat::mc "Select"] "::ssj::once_only_aux $dw $xlib" \
 	      [::msgcat::mc "Cancel"] "destroy $dw"] \
-	::ssj::selectkey$connid $titles $balloons \
+	::ssj::selectkey$xlib $titles $balloons \
 	-modal local
 }
 
@@ -274,12 +273,12 @@
     return $text
 }
 
-proc ::ssj::once_only_aux {dw connid} {
-    variable selectkey$connid
+proc ::ssj::once_only_aux {dw xlib} {
+    variable selectkey$xlib
 
     set keys {}
-    foreach key [array names selectkey$connid] {
-        if {[set selectkey${connid}($key)]} {
+    foreach key [array names selectkey$xlib] {
+        if {[set selectkey${xlib}($key)]} {
             lappend keys $key
         }
     }
@@ -287,12 +286,12 @@
     destroy $dw
 
     if {[llength $keys] > 0} {
-        e4meP $connid $keys
+        e4meP $xlib $keys
     }
 }
 
 
-proc ::ssj::passphrase {connid data} {
+proc ::ssj::passphrase {xlib data} {
     variable passphrase
     variable options
 
@@ -317,7 +316,7 @@
         return $passphrase($keyid)
     }
 
-    set pw .passphrase$connid
+    set pw .passphrase$xlib
     if {[winfo exists $pw]} {
         destroy $pw
     }
@@ -358,9 +357,9 @@
 
     label $pf.lpassword -text [::msgcat::mc "Passphrase:"]
     entry $pf.password  \
-	  -textvariable ::ssj::passphrase($connid,$keyid) \
+	  -textvariable ::ssj::passphrase($xlib,$keyid) \
           -show *
-    set passphrase($connid,$keyid) ""
+    set passphrase($xlib,$keyid) ""
 
     grid $pf.lkeyid    -row 0 -column 0 -sticky e
     grid $pf.keyid     -row 0 -column 1 -sticky ew
@@ -380,8 +379,8 @@
     destroy $pw
 
     if {!$abort} {
-	set passphrase($keyid) $passphrase($connid,$keyid)
-	unset passphrase($connid,$keyid)
+	set passphrase($keyid) $passphrase($xlib,$keyid)
+	unset passphrase($xlib,$keyid)
         return $passphrase($keyid)
     }
 }
@@ -402,7 +401,7 @@
     return "-----BEGIN PGP MESSAGE-----\n\n$text\n-----END PGP MESSAGE-----"
 }
 
-proc ::ssj::signed:input {connid from signature data what} {
+proc ::ssj::signed:input {xlib from signature data what} {
     variable ctx
     variable j2k
     variable s2e
@@ -410,17 +409,17 @@
     variable gpg_error_id
     variable options
 
-    once_only $connid
+    once_only $xlib
 
-    if {[catch {$ctx($connid) -operation verify \
+    if {[catch {$ctx($xlib) -operation verify \
 			      -input     [binary format a* [encoding convertto utf-8 $data]]  \
 			      -signature [armor:decode $signature]} result]} {
-        debugmsg ssj "verify processing error ($connid): $result ($from)"
+        debugmsg ssj "verify processing error ($xlib): $result ($from)"
 
-        if {![info exists warnings(verify-traffic,$connid)]} {
+        if {![info exists warnings(verify-traffic,$xlib)]} {
 
-            set warnings(verify-traffic,$connid) 1
-            after idle [list NonmodalMessageDlg .verify_error$connid -aspect 50000 -icon error \
+            set warnings(verify-traffic,$xlib) 1
+            after idle [list NonmodalMessageDlg .verify_error$xlib -aspect 50000 -icon error \
                 -message [::msgcat::mc "Error in signature verification software: %s." \
 				       $result]]
         }
@@ -430,7 +429,7 @@
         return [array get params]
     }
 
-    debugmsg ssj "VERIFY: $connid $from ($data); $result"
+    debugmsg ssj "VERIFY: $xlib $from ($data); $result"
 
     array set params $result
     set result $params(status)
@@ -441,7 +440,7 @@
         array set sparams $signature
 
         if {[info exists sparams(key)]} {
-            set sparams(key) [$ctx($connid) -operation info-key -key $sparams(key)]
+            set sparams(key) [$ctx($xlib) -operation info-key -key $sparams(key)]
             foreach {k v} $sparams(key) {
 		switch -- $k {
 		    keyid {
@@ -486,7 +485,7 @@
 }
 
 
-proc ::ssj::signed:output {connid data args} {
+proc ::ssj::signed:output {xlib data args} {
     variable ctx
     variable options
     variable warnings
@@ -496,14 +495,14 @@
         return
     }
 
-    once_only $connid 1
+    once_only $xlib 1
 
-    if {[catch {$ctx($connid) -operation sign  \
+    if {[catch {$ctx($xlib) -operation sign  \
 			      -input     [binary format a* [encoding convertto utf-8 $data]] \
 			      -mode      detach} result]} {
         set options(sign-traffic) 0
 
-        debugmsg ssj "signature processing error ($connid): $result ($data)"
+        debugmsg ssj "signature processing error ($xlib): $result ($data)"
 
         if {[llength $args] == 0} {
             set buttons ok
@@ -532,7 +531,7 @@
     set result [armor:encode $result]
 
     debugmsg ssj "SIGN: $data; $result"
-    whichkeys $connid sign
+    whichkeys $xlib sign
 
     return $result
 }
@@ -600,8 +599,8 @@
     return [string trimleft $text]
 }
 
-proc ::ssj::signed:Label {lb connid jid pinfo} {
-    if {[set rjid [muc::get_real_jid $connid $jid]] == ""} {
+proc ::ssj::signed:Label {lb xlib jid pinfo} {
+    if {[set rjid [muc::get_real_jid $xlib $jid]] == ""} {
 	set rjid [node_and_server_from_jid $jid]
     } else {
 	set rjid [node_and_server_from_jid $rjid]
@@ -687,19 +686,19 @@
     tk_popup $m [winfo pointerx .] [winfo pointery .]
 }
 
-proc ::ssj::signed:user_menu {m connid jid} {
+proc ::ssj::signed:user_menu {m xlib jid} {
     variable signed
     global curuser
 
     if {[cequal $jid "\$curuser"]} {
 	set jid $curuser
     }
-    if {[info exists signed($connid,$jid)]} {
-	array set params $signed($connid,$jid)
+    if {[info exists signed($xlib,$jid)]} {
+	array set params $signed($xlib,$jid)
 	if {[info exists params(status)] && [cequal $params(status) nokey]} {
 	    $m add command -label [::msgcat::mc "Fetch GPG key"] \
 		-command [list ::ssj::fetchkeys \
-			       $signed($connid,$jid)]
+			       $signed($xlib,$jid)]
 	}
     }
 }
@@ -736,8 +735,8 @@
 ###############################################################################
 
 proc ::ssj::rewrite_message_body \
-     {vconnid vfrom vid vtype vis_subject vsubject vbody verr vthread vpriority vx} {
-    upvar 2 $vconnid connid
+     {vxlib vfrom vid vtype vis_subject vsubject vbody verr vthread vpriority vx} {
+    upvar 2 $vxlib xlib
     upvar 2 $vfrom from
     upvar 2 $vbody body
     upvar 2 $vx x
@@ -745,18 +744,17 @@
     set badenc 0
     set xs {}
     foreach xe $x {
-	jlib::wrapper:splitxml $xe tag vars isempty cdata children
+	::xmpp::xml::split $xe tag xmlns attrs cdata subels
 
-	if {![cequal [jlib::wrapper:getattr $vars xmlns] $::NS(encrypted)]} {
+	if {![string equal $xmlns $::NS(encrypted)]} {
 	    lappend xs $xe
-	} elseif {[cequal $cdata ""]} {
+	} elseif {[string equal $cdata ""]} {
 	    # in case the sender didn't check the exit code from gpg we ignore
 	    # jabber:x:encrypted
-	} elseif {[catch {ssj::encrypted:input $connid $from $cdata} msg]} {
+	} elseif {[catch {ssj::encrypted:input $xlib $from $cdata} msg]} {
 	    set body [::msgcat::mc ">>> Unable to decipher data: %s <<<" $msg]
 	    # Add empty x tag to show problems with gpg
-	    lappend xs [jlib::wrapper:createtag x \
-			    -vars [list xmlns $::NS(encrypted)]]
+	    lappend xs [::xmpp::xml::create x -xmlns $::NS(encrypted)]
 	    set badenc 1
 	} else {
 	    set body $msg
@@ -771,9 +769,9 @@
     # if decryption failed, then remove signature. It can't be correct.
     set xs {}
     foreach xe $x {
-	jlib::wrapper:splitxml $xe tag vars isempty cdata children
+	::xmpp::xml::split $xe tag xmlns attrs cdata subels
 
-	if {![cequal [jlib::wrapper:getattr $vars xmlns] $::NS(signed)]} {
+	if {![string equal $xmlns $::NS(signed)]} {
 	    lappend xs $xe
 	}
     }
@@ -785,16 +783,16 @@
 
 ###############################################################################
 
-proc ::ssj::encrypted:input {connid from data} {
+proc ::ssj::encrypted:input {xlib from data} {
     variable ctx
     variable warnings
     variable gpg_error_id
 
-    once_only $connid
+    once_only $xlib
 
-    if {[catch {$ctx($connid) -operation decrypt \
+    if {[catch {$ctx($xlib) -operation decrypt \
 			      -input     [armor:decode $data]} result]} {
-        debugmsg ssj "decryption processing error ($connid): $result ($from)"
+        debugmsg ssj "decryption processing error ($xlib): $result ($from)"
 
         if {![info exists warnings(decrypt,$from)]} {
             set warnings(decrypt,$from) 1
@@ -807,7 +805,7 @@
         error $result
     }
 
-    debugmsg ssj "DECRYPT: $connid; $from; $result"
+    debugmsg ssj "DECRYPT: $xlib; $from; $result"
 
     array set params $result
     binary scan $params(plaintext) a* temp_utf8
@@ -815,7 +813,7 @@
 }
 
 
-proc ::ssj::encrypted:output {connid data to} {
+proc ::ssj::encrypted:output {xlib data to} {
     global gpgPkg
     variable ctx
     variable e4me
@@ -827,7 +825,7 @@
         return
     }
 
-    if {![encryptP $connid $to]} {
+    if {![encryptP $xlib $to]} {
         return
     }
 
@@ -845,17 +843,17 @@
     $recipient -operation add   \
 	       -name      $name \
                -validity  full
-    foreach signer $e4me($connid) {
+    foreach signer $e4me($xlib) {
         $recipient -operation add \
                    -name      $signer \
                    -validity  full
     }
 
-    once_only $connid 1
+    once_only $xlib 1
 
     set code \
 	[catch {
-	    $ctx($connid) \
+	    $ctx($xlib) \
 		-operation encrypt \
 		-input [binary format a* [encoding convertto utf-8 $data]] \
 		-recipients $recipient
@@ -864,9 +862,9 @@
     rename $recipient {}
 
     if {$code} {
-        debugmsg ssj "encryption processing error ($connid): $result ($data)"
+        debugmsg ssj "encryption processing error ($xlib): $result ($data)"
 
-        set options(encrypt,$connid,$to) 0
+        set options(encrypt,$xlib,$to) 0
         incr gpg_error_id
         if {[MessageDlg .encrypt_error$gpg_error_id \
 		-aspect 50000 \
@@ -887,16 +885,16 @@
     }
     set result [armor:encode $result]
 
-    debugmsg ssj "ENCRYPT: $connid; $data; $result"
+    debugmsg ssj "ENCRYPT: $xlib; $data; $result"
 
     return $result
 }
 
-proc ::ssj::whichkeys {connid what} {
+proc ::ssj::whichkeys {xlib what} {
     variable ctx
     variable warnings
 
-    set s [$ctx($connid) -operation get -property last-op-info]
+    set s [$ctx($xlib) -operation get -property last-op-info]
     if {[cequal $s ""]} {
         return
     }
@@ -921,12 +919,12 @@
 
 #############################################################################
 
-proc ::ssj::prefs {connid jid} {
+proc ::ssj::prefs {xlib jid} {
     variable ctx
     variable options
     variable optionsX
 
-    set w [win_id security_preferences [list $connid $jid]]
+    set w [win_id security_preferences [list $xlib $jid]]
 
     if {[winfo exists $w]} {
         focus -force $w
@@ -938,19 +936,19 @@
 	   -separator 1 -anchor e -default 0 -cancel 1
 
     $w add -text [::msgcat::mc "OK"] \
-	   -command [list ::ssj::prefs_ok $w $connid $jid]
+	   -command [list ::ssj::prefs_ok $w $xlib $jid]
     $w add -text [::msgcat::mc "Cancel"] -command [list destroy $w]
 
     set f [$w getframe]
 
-    if {![info exists options(encrypt,$connid,$jid)]} {
-        set options(encrypt,$connid,$jid) [encryptP $connid $jid]
+    if {![info exists options(encrypt,$xlib,$jid)]} {
+        set options(encrypt,$xlib,$jid) [encryptP $xlib $jid]
     }
 
-    set optionsX(encrypt,$connid,$jid) $options(encrypt,$connid,$jid)
+    set optionsX(encrypt,$xlib,$jid) $options(encrypt,$xlib,$jid)
     checkbutton $f.encrypt \
         -text     [::msgcat::mc "Encrypt traffic"] \
-        -variable ::ssj::optionsX(encrypt,$connid,$jid)
+        -variable ::ssj::optionsX(encrypt,$xlib,$jid)
 
     pack $f.encrypt -side left
     pack [frame $f.f -width 9c -height 2c]
@@ -958,18 +956,18 @@
     $w draw $f.name
 }
 
-proc ::ssj::prefs_ok {w connid jid} {
+proc ::ssj::prefs_ok {w xlib jid} {
     variable options
     variable optionsX
 
-    set options(encrypt,$connid,$jid) $optionsX(encrypt,$connid,$jid)
+    set options(encrypt,$xlib,$jid) $optionsX(encrypt,$xlib,$jid)
 
     destroy $w
 }
 
-proc ::ssj::prefs_user_menu {m connid jid} {
+proc ::ssj::prefs_user_menu {m xlib jid} {
     $m add command -label [::msgcat::mc "Edit security..."] \
-	-command [list ::ssj::prefs $connid $jid]
+	-command [list ::ssj::prefs $xlib $jid]
 }
 
 hook::add chat_create_user_menu_hook ::ssj::prefs_user_menu 78
@@ -985,7 +983,7 @@
     return $options(sign-traffic)
 }
 
-proc ::ssj::encryptP {connid jid} {
+proc ::ssj::encryptP {xlib jid} {
     global gpgPkg
     variable ctx
     variable j2k
@@ -995,7 +993,7 @@
 	return $options(encrypt-traffic)
     }
 
-    lassign [roster::get_category_and_subtype $connid $jid] \
+    lassign [roster::get_category_and_subtype $xlib $jid] \
             category subtype
     switch -- $category {
 	conference -
@@ -1012,10 +1010,10 @@
 
     set bjid [node_and_server_from_jid $jid]
 
-    if {[info exists options(encrypt,$connid,$jid)]} {
-        return $options(encrypt,$connid,$jid)
-    } elseif {[info exists options(encrypt,$connid,$bjid)]} {
-        return $options(encrypt,$connid,$bjid)
+    if {[info exists options(encrypt,$xlib,$jid)]} {
+        return $options(encrypt,$xlib,$jid)
+    } elseif {[info exists options(encrypt,$xlib,$bjid)]} {
+        return $options(encrypt,$xlib,$bjid)
     } elseif {[info exists options(encrypt,$jid)]} {
 	return $options(encrypt,$jid)
     } elseif {[info exists options(encrypt,$bjid)]} {
@@ -1026,11 +1024,11 @@
         return 0
     }
 
-    if {[info exists options(encrypt-tried,$connid,$jid)]} {
-        return $options(encrypt-tried,$connid,$jid)
+    if {[info exists options(encrypt-tried,$xlib,$jid)]} {
+        return $options(encrypt-tried,$xlib,$jid)
     }
 
-    once_only $connid
+    once_only $xlib
 
     if {[info exists j2k($jid)]} {
         set name $j2k($jid)
@@ -1045,42 +1043,42 @@
             -name      $name \
             -validity  full
 
-    if {[catch {$ctx($connid) -operation  encrypt        \
+    if {[catch {$ctx($xlib) -operation  encrypt        \
 			      -input      "Hello world." \
 			      -recipients $recipient}]} {
-        set options(encrypt-tried,$connid,$jid) 0
+        set options(encrypt-tried,$xlib,$jid) 0
     } else {
-        set options(encrypt-tried,$connid,$jid) 1
+        set options(encrypt-tried,$xlib,$jid) 1
     }
 
     rename $recipient {}
 
-    return $options(encrypt-tried,$connid,$jid)
+    return $options(encrypt-tried,$xlib,$jid)
 }
 
 #############################################################################
 
-proc ::ssj::e4meP {connid keys} {
+proc ::ssj::e4meP {xlib keys} {
     global gpgPkg
     variable ctx
     variable e4me
     variable signers
 
-    $ctx($connid) -operation set     \
+    $ctx($xlib) -operation set     \
 		  -property  signers \
-		  -value     [set signers($connid) $keys]
+		  -value     [set signers($xlib) $keys]
 
-    set e4me($connid) {}
-    foreach signer $signers($connid) {
+    set e4me($xlib) {}
+    foreach signer $signers($xlib) {
         [set recipient [${gpgPkg}::recipient]] \
                 -operation add     \
                 -name      $signer \
                 -validity  full
 
-        if {![catch {$ctx($connid) -operation  encrypt        \
+        if {![catch {$ctx($xlib) -operation  encrypt        \
 				   -input      "Hello world." \
 				   -recipients $recipient} result]} {
-            lappend e4me($connid) $signer
+            lappend e4me($xlib) $signer
         }
 
         rename $recipient {}
@@ -1095,7 +1093,7 @@
     set options(sign-traffic) [expr {!$options(sign-traffic)}]
 }
 
-proc ::ssj::encrypt:toggleP {{connid ""} {jid ""}} {
+proc ::ssj::encrypt:toggleP {{xlib ""} {jid ""}} {
     variable options
 
     if {[cequal $jid ""]} {
@@ -1103,15 +1101,15 @@
         return
     }
 
-    if {![cequal $connid ""]} {
-	if {![info exists options(encrypt,$connid,$jid)]} {
-	    set options(encrypt,$connid,$jid) [encryptP $connid $jid]
+    if {![cequal $xlib ""]} {
+	if {![info exists options(encrypt,$xlib,$jid)]} {
+	    set options(encrypt,$xlib,$jid) [encryptP $xlib $jid]
 	}
-	set options(encrypt,$connid,$jid) \
-	    [expr {!$options(encrypt,$connid,$jid)}]
+	set options(encrypt,$xlib,$jid) \
+	    [expr {!$options(encrypt,$xlib,$jid)}]
     } else {
 	return -code error \
-	    "::ssj::encrypt:toggleP: connid is empty and jid is not"
+	    "::ssj::encrypt:toggleP: xlib is empty and jid is not"
     }
 }
 
@@ -1130,18 +1128,18 @@
     lappend trace(sign-traffic) $script
 }
 
-proc ::ssj::encrypted:trace {script {connid ""} {jid ""}} {
+proc ::ssj::encrypted:trace {script {xlib ""} {jid ""}} {
     variable options
     variable trace
 
     if {[cequal $jid ""]} {
 	set k encrypt-traffic
     } else {
-	if {![cequal $connid ""]} {
-	    set k encrypt,$connid,$jid
+	if {![cequal $xlib ""]} {
+	    set k encrypt,$xlib,$jid
 	} else {
 	    return -code error \
-		"::ssj::encrypted:trace: connid is empty and jid is not"
+		"::ssj::encrypted:trace: xlib is empty and jid is not"
 	}
     }
     if {![info exists trace($k)]} {
@@ -1169,13 +1167,13 @@
 
 #############################################################################
 
-proc ::ssj::clear_signatures {connid} {
+proc ::ssj::clear_signatures {xlib} {
     variable signed
 
-    if {$connid == {}} {
+    if {$xlib == {}} {
 	catch {array unset signed}
     } else {
-	catch {array unset signed $connid,*}
+	catch {array unset signed $xlib,*}
     }
 }
 
@@ -1183,18 +1181,18 @@
 
 #############################################################################
 
-proc ::ssj::check_signature {connid from type x args} {
+proc ::ssj::check_signature {xlib from type x args} {
     variable signed
 
     switch -- $type {
 	unavailable -
 	available {
-	    catch {unset signed($connid,$from)}
+	    catch {unset signed($xlib,$from)}
 
 	    set signature ""
 	    foreach xs $x {
-		jlib::wrapper:splitxml $xs tag vars isempty cdata children
-		if {[jlib::wrapper:getattr $vars xmlns] == $::NS(signed)} {
+		::xmpp::xml::split $xs tag xmlns attrs cdata subels
+		if {$xmlns == $::NS(signed)} {
 		    set signature $cdata
 		    break
 		}
@@ -1210,8 +1208,8 @@
 		}
 	    }
 
-	    set signed($connid,$from) \
-		[signed:input $connid $from $signature $status \
+	    set signed($xlib,$from) \
+		[signed:input $xlib $from $signature $status \
 		     [::msgcat::mc "Presence information"]]
 	}
     }
@@ -1221,14 +1219,14 @@
 
 #############################################################################
 
-proc ::ssj::make_signature {varname connid status} {
+proc ::ssj::make_signature {varname xlib status} {
     upvar 2 $varname var
-    if {![cequal $status ""] && \
-	    ![catch {signed:output $connid $status} cdata] && \
-	    ![cequal $cdata ""]} {
-	lappend var [jlib::wrapper:createtag x \
-			 -vars [list xmlns $::NS(signed)] \
-			 -chdata $cdata]
+
+    if {![string equal $status ""] && \
+	    ![catch {signed:output $xlib $status} cdata] && \
+	    ![string equal $cdata ""]} {
+	lappend var [::xmpp::xml::create x -xmlns $::NS(signed) \
+					   -cdata $cdata]
     }
     return
 }
@@ -1237,21 +1235,21 @@
 
 #############################################################################
 
-proc ::ssj::userinfo {tab connid jid editable} {
+proc ::ssj::userinfo {tab xlib jid editable} {
     variable signed
 
     if {$editable} return
 
     set bare_jid [node_and_server_from_jid $jid]
-    set chatid [chat::chatid $connid $bare_jid]
+    set chatid [chat::chatid $xlib $bare_jid]
     if {[chat::is_groupchat $chatid]} {
-	if {[info exists signed($connid,$jid)]} {
-	    set jids [list $connid,$jid]
+	if {[info exists signed($xlib,$jid)]} {
+	    set jids [list $xlib,$jid]
 	} else {
 	    set jids [list]
 	}
     } else {
-	set jids [array names signed $connid,$bare_jid/*]
+	set jids [array names signed $xlib,$bare_jid/*]
     }
     if {[llength $jids] > 0} {
 	set presenceinfo [$tab insert end presenceinfo \
@@ -1325,7 +1323,7 @@
 
 #############################################################################
 
-proc ::ssj::message_buttons {mw connid jid} {
+proc ::ssj::message_buttons {mw xlib jid} {
     set bbox1 [ButtonBox $mw.bottom.buttons1 -spacing 0]
 
     set b [$bbox1 add \
@@ -1339,19 +1337,19 @@
 		  -command ::ssj::sign:toggleP]
     signed:trace "$b configure -image \[::ssj::signed:icon\]"
     
-    # TODO reflect changes of connid
+    # TODO reflect changes of xlib
     set b [$bbox1 add \
-		  -image [encrypted:icon $connid $jid] \
+		  -image [encrypted:icon $xlib $jid] \
 		  -helptype balloon \
 		  -helptext [::msgcat::mc "Toggle encryption"] \
 		  -height 24 \
 		  -width 24 \
 		  -relief link \
 		  -bd $::tk_borderwidth \
-		  -command [list ::ssj::encrypt:toggleP $connid $jid]]
+		  -command [list ::ssj::encrypt:toggleP $xlib $jid]]
     encrypted:trace \
-	"$b configure -image \[::ssj::encrypted:icon [list $connid] [list $jid]\]" \
-	$connid $jid
+	"$b configure -image \[::ssj::encrypted:icon [list $xlib] [list $jid]\]" \
+	$xlib $jid
 
     pack $bbox1 -side left -fill x -padx 2m -pady 2m
 }
@@ -1360,7 +1358,7 @@
 
 #############################################################################
 
-proc ::ssj::process_x_signed {rowvar bodyvar f x connid from id type replyP} {
+proc ::ssj::process_x_signed {rowvar bodyvar f x xlib from id type replyP} {
     upvar 2 $rowvar row
     upvar 2 $bodyvar body
 
@@ -1369,13 +1367,12 @@
     }
 
     foreach xa $x {
-	jlib::wrapper:splitxml $xa tag vars isempty chdata children
-	set xmlns [jlib::wrapper:getattr $vars xmlns]
+	::xmpp::xml::split $xa tag xmlns attrs cdata subels
 
 	if {$xmlns != $::NS(signed)} continue
 
 	# in case the sender didn't check the exit code from gpg...
-	if {[cequal $chdata ""]} {
+	if {[string equal $cdata ""]} {
 	    return
 	}
 
@@ -1384,8 +1381,8 @@
 	    destroy $lb
 	}
 
-	signed:Label $lb $connid $from \
-		     [signed:input $connid $from $chdata $body \
+	signed:Label $lb $xlib $from \
+		     [signed:input $xlib $from $cdata $body \
 				   [::msgcat::mc "Message body"]]
 	grid $lb -row 1 -column 2 -sticky e
     }
@@ -1402,9 +1399,9 @@
                    [signP]]
 }
 
-proc ::ssj::encrypted:icon {{connid ""} {jid ""}} {
+proc ::ssj::encrypted:icon {{xlib ""} {jid ""}} {
     return [lindex [list toolbar/gpg-unencrypted toolbar/gpg-encrypted] \
-                   [encryptP $connid $jid]]
+                   [encryptP $xlib $jid]]
 }
 
 #############################################################################
@@ -1415,20 +1412,20 @@
     set chatw [chat::chat_win $chatid]
 
     foreach xe $x {
-        jlib::wrapper:splitxml $xe tag vars isempty chdata children
+        ::xmpp::xml::split $xe tag xmlns attrs cdata subels
 
 	# in case the sender didn't check the exit code from gpg...
-        if {[cequal $chdata ""] || \
-		![cequal [jlib::wrapper:getattr $vars xmlns] $::NS(signed)]} {
+        if {[string equal $cdata ""] || \
+		![string equal $xmlns $::NS(signed)]} {
             continue
         }
 
         incr signedid
-	set connid [chat::get_connid $chatid]
+	set xlib [chat::get_xlib $chatid]
         catch {
             $chatw window create end \
-                  -window [signed:Label $chatw.signed$signedid $connid $from \
-                              [signed:input $connid $from $chdata $body \
+                  -window [signed:Label $chatw.signed$signedid $xlib $from \
+                              [signed:input $xlib $from $cdata $body \
                                   [::msgcat::mc "Message body"]]]
         }
     }
@@ -1439,20 +1436,20 @@
 ###############################################################################
 
 proc ::ssj::chat_window_button {chatid type} {
-    set connid [chat::get_connid $chatid]
+    set xlib [chat::get_xlib $chatid]
     set jid [chat::get_jid $chatid]
     set cw [chat::winid $chatid]
 
     Button $cw.status.encrypted \
 	   -relief flat \
-           -image [encrypted:icon $connid $jid] \
+           -image [encrypted:icon $xlib $jid] \
            -helptype balloon \
            -helptext [::msgcat::mc "Toggle encryption"] \
-           -command [list ::ssj::encrypt:toggleP $connid $jid]
+           -command [list ::ssj::encrypt:toggleP $xlib $jid]
 
     encrypted:trace "$cw.status.encrypted configure \
-		-image \[::ssj::encrypted:icon $connid $jid\]" \
-        $connid $jid
+		-image \[::ssj::encrypted:icon $xlib $jid\]" \
+        $xlib $jid
     pack $cw.status.encrypted -side left -before $cw.status.mb
 }
 
@@ -1505,13 +1502,13 @@
 
 ###############################################################################
 
-proc ::ssj::add_user_popup_info {infovar connid jid} {
+proc ::ssj::add_user_popup_info {infovar xlib jid} {
     variable signed
 
     upvar 0 $infovar info
 
-    if {[info exists signed($connid,$jid)]} {
-	set signed_info [signed:info $signed($connid,$jid)]
+    if {[info exists signed($xlib,$jid)]} {
+	set signed_info [signed:info $signed($xlib,$jid)]
 	append info [::msgcat::mc "\n\tPresence is signed:"]
 	regsub -all {(\n)} "\n$signed_info" "\\1\t    " extra
 	append info $extra

Copied: trunk/tkabber/idna.tcl (from rev 1514, trunk/tkabber/jabberlib/idna.tcl)
===================================================================
--- trunk/tkabber/idna.tcl	                        (rev 0)
+++ trunk/tkabber/idna.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -0,0 +1,147 @@
+#  idna.tcl --
+#  
+#      This file is part of the jabberlib. It provides support for
+#      Internationalizing Domain Names in Applications (IDNA, RFC 3490).
+#      
+#  Copyright (c) 2005 Alexey Shchepin <alexey at sevcom.net>
+#  
+# $Id$
+#
+#  SYNOPSIS
+#      idna::domain_toascii domain
+#
+
+##########################################################################
+
+package provide idna 1.0
+
+##########################################################################
+
+namespace eval idna {}
+
+##########################################################################
+
+proc idna::domain_toascii {domain} {
+    set domain [string tolower $domain]
+    set parts [split $domain "\u002E\u3002\uFF0E\uFF61"]
+    set res {}
+    foreach p $parts {
+	set r [toascii $p]
+	lappend res $r
+    }
+    return [join $res .]
+}
+
+##########################################################################
+
+proc idna::toascii {name} {
+    # TODO: Steps 2, 3 and 5 from RFC3490
+
+    if {![string is ascii $name]} {
+	set name [punycode_encode $name]
+	set name "xn--$name"
+    }
+    return $name
+}
+
+##########################################################################
+
+proc idna::punycode_encode {input} {
+    set base 36
+    set tmin 1
+    set tmax 26
+    set skew 38
+    set damp 700
+    set initial_bias 72
+    set initial_n 0x80
+
+    set n $initial_n
+    set delta 0
+    set out 0
+    set bias $initial_bias
+    set output ""
+    set input_length [string length $input]
+    set nonbasic {}
+
+    for {set j 0} {$j < $input_length} {incr j} {
+	set c [string index $input $j]
+	if {[string is ascii $c]} {
+	    append output $c
+	} else {
+	    lappend nonbasic $c
+	}
+    }
+
+    set nonbasic [lsort -unique $nonbasic]
+
+    set h [set b [string length $output]];
+
+    if {$b > 0} {
+	append output -
+    }
+
+    while {$h < $input_length} {
+	set m [scan [string index $nonbasic 0] %c]
+	set nonbasic [lrange $nonbasic 1 end]
+
+	incr delta [expr {($m - $n) * ($h + 1)}]
+	set n $m
+
+	for {set j 0} {$j < $input_length} {incr j} {
+	    set c [scan [string index $input $j] %c]
+
+	    if {$c < $n} {
+		incr delta
+	    } elseif {$c == $n} {
+		for {set q $delta; set k $base} {1} {incr k $base} {
+		    set t [expr {$k <= $bias ? $tmin :
+				 $k >= $bias + $tmax ? $tmax : $k - $bias}]
+		    if {$q < $t} break;
+		    append output \
+			[punycode_encode_digit \
+			     [expr {$t + ($q - $t) % ($base - $t)}]]
+		    set q [expr {($q - $t) / ($base - $t)}]
+		}
+
+		append output [punycode_encode_digit $q]
+		set bias [punycode_adapt \
+			      $delta [expr {$h + 1}] [expr {$h == $b}]]
+		set delta 0
+		incr h
+	    }
+	}
+	
+	incr delta
+	incr n
+    }
+
+    return $output;
+}
+
+##########################################################################
+
+proc idna::punycode_adapt {delta numpoints firsttime} {
+    set base 36
+    set tmin 1
+    set tmax 26
+    set skew 38
+    set damp 700
+
+    set delta [expr {$firsttime ? $delta / $damp : $delta >> 1}]
+    incr delta [expr {$delta / $numpoints}]
+
+    for {set k 0} {$delta > (($base - $tmin) * $tmax) / 2}  {incr k $base} {
+	set delta [expr {$delta / ($base - $tmin)}];
+    }
+
+    return [expr {$k + ($base - $tmin + 1) * $delta / ($delta + $skew)}]
+}
+
+##########################################################################
+
+proc idna::punycode_encode_digit {d} {
+    return [format %c [expr {$d + 22 + 75 * ($d < 26)}]]
+}
+
+##########################################################################
+

Modified: trunk/tkabber/iface.tcl
===================================================================
--- trunk/tkabber/iface.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/iface.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -22,16 +22,16 @@
 proc ssl_info {} {
     global ssl_certificate_fields
 
-    if {![llength [set conns [jlib::connections]]]} {
-	return {}
-    }
-
     set server_list {}
     set msg_list {}
-    foreach connid $conns {
-	if {[info exists ::jlib::lib($connid,sck)]} {
-	    if {![catch { tls::status $::jlib::lib($connid,sck) } status]} {
-		set server [server_from_jid [jlib::connection_jid $connid]]
+    foreach xlib [connections] {
+
+	# TODO
+	break
+
+	if {[info exists ::jlib::lib($xlib,sck)]} {
+	    if {![catch { tls::status $::jlib::lib($xlib,sck) } status]} {
+		set server [server_from_jid [connection_jid $xlib]]
 		if {[lcontain $server_list $server]} {
 		    continue
 		} else {
@@ -66,21 +66,25 @@
     global tls_warning_info
 
     set state disabled
-    set len [llength [set conns [jlib::connections]]]
+    set len [llength [connections]]
     set fg normal
     if {$len} {
 	set balloon ""
-	foreach connid $conns {
+	foreach xlib [connections] {
+
+	    # TODO
+	    break
+
 	    if {$len > 1} {
-		append balloon "[jlib::connection_jid $connid]: "
+		append balloon "[connection_jid $xlib]: "
 	    }
-	    if {[info exists ::jlib::lib($connid,sck)]} {
-		if {![catch { tls::status $::jlib::lib($connid,sck) } status]} {
-		    if {![info exists tls_warning_info($connid)] ||
-			    [cequal $tls_warning_info($connid) ""]} {
+	    if {[info exists ::jlib::lib($xlib,sck)]} {
+		if {![catch { tls::status $::jlib::lib($xlib,sck) } status]} {
+		    if {![info exists tls_warning_info($xlib)] ||
+			    [cequal $tls_warning_info($xlib) ""]} {
 			append balloon [::msgcat::mc "Enabled\n"]
 		    } else {
-			append balloon $tls_warning_info($connid)
+			append balloon $tls_warning_info($xlib)
 			set fg warning
 		    }
 		    set state normal
@@ -101,7 +105,7 @@
 
 set status_afterid ""
 
-proc client:status {text} {
+proc client:status {xlib text} {
     set_status $text
 }
 

Modified: trunk/tkabber/ifacetk/iface.tcl
===================================================================
--- trunk/tkabber/ifacetk/iface.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/ifacetk/iface.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -176,7 +176,7 @@
 proc ifacetk::save_mainwindowstate {w} {
     variable mainwindowstate
 
-    if {![cequal $w .]} return
+    if {![string equal $w .]} return
 
     set state [wm state .]
     if {$state != $mainwindowstate} {
@@ -225,24 +225,26 @@
 
 proc EncodeTextSelection {txt offset len} {
     set elided ""
-    if {[lcontain [$txt tag names] emphasized] && [$txt tag cget emphasized -elide]} {
+    if {[lsearch -exact [$txt tag names] emphasized] >= 0 && \
+	    [$txt tag cget emphasized -elide]} {
 	set elided emphasized
-    } elseif {[lcontain [$txt tag names] nonemphasized] && [$txt tag cget nonemphasized -elide]} {
+    } elseif {[lsearch -exact [$txt tag names] nonemphasized] >= 0 && \
+	    [$txt tag cget nonemphasized -elide]} {
 	set elided nonemphasized
     }
-    if {[cequal $elided ""]} {
+    if {[string equal $elided ""]} {
 	set ::xselection [eval $txt get [$txt tag ranges sel]]
     } else {
 	lassign [$txt tag ranges sel] selstart selstop
 	set sel $selstart
 	set ::xselection ""
-	while {![cequal [set range [$txt tag nextrange $elided $sel $selstop]] ""]} {
+	while {![string equal [set range [$txt tag nextrange $elided $sel $selstop]] ""]} {
 	    append ::xselection [$txt get $sel [lindex $range 0]]
 	    set sel [lindex $range 1]
 	}
 	append ::xselection [$txt get $sel $selstop]
     }
-    encoding convertto [crange $::xselection $offset [expr $offset + $len - 1]]
+    encoding convertto [string range $::xselection $offset [expr $offset + $len - 1]]
 }
 
 proc EncodeEntrySelection {txt offset len} {
@@ -251,13 +253,13 @@
 	set idx2 [$txt index sel.last]
 	set ::xselection [string range [$txt get] $idx1 $idx2]
 	encoding convertto \
-	    [crange $::xselection $offset [expr $offset + $len - 1]]
+	    [string range $::xselection $offset [expr $offset + $len - 1]]
     } else {
 	set ::xselection ""
     }
 }
 
-if {[cequal $tcl_platform(platform) unix]} {
+if {[string equal $tcl_platform(platform) unix]} {
     proc ::tk::GetSelection {w {sel PRIMARY}} {
         if {![catch {selection get -displayof $w \
 			-selection $sel -type UTF8_STRING} txt]} {
@@ -323,10 +325,10 @@
 		       -command {change_password_dialog}] \
 		  [list command [::msgcat::mc "Edit my info..."] {} {} {} \
 		       -command {
-			    if {[llength [jlib::connections]] > 0} {
-				set connid [lindex [jlib::connections] 0]
-				userinfo::open [jlib::connection_bare_jid $connid] \
-				    -editable 1 -connection $connid
+			    if {[llength [connections]] > 0} {
+				set xlib [lindex [connections] 0]
+				userinfo::open $xlib [connection_bare_jid $xlib] \
+					       -editable 1 \
 			    }}] \
 		  [list cascad [::msgcat::mc "Privacy rules"] {} privacy $ifacetk::options(show_tearoffs) \
 		       [list \
@@ -412,7 +414,7 @@
 		  [list command [::msgcat::mc "Open chat..."] {} {} {} \
 		       -command {chat::open_chat_dialog}] \
 		  [list command [::msgcat::mc "Join group..."] {} {} {}\
-		       -command {join_group_dialog}] \
+		       -command {join_group_dialog ""}] \
 		  [list command [::msgcat::mc "Show user or service info..."] {} {} {} \
 		       -command {userinfo::show_info_dialog}] \
 		  {separator} \
@@ -447,7 +449,7 @@
 	    ]
     
     if {![info exists ::enable_profiling] || !$::enable_profiling || \
-	    ([clength [info commands profile]] == 0)} {
+	    ([string length [info commands profile]] == 0)} {
 	set tmpmenu {}
 	set eatP 0
 	foreach menu [lindex $descmenu 4] {
@@ -469,9 +471,9 @@
 ###############################################################################
 
 proc ifacetk::send_announce_message {resource} {
-    if {[llength [jlib::connections]] == 0} return
+    if {[llength [connections]] == 0} return
 
-    set server [jlib::connection_server [lindex [jlib::connections] 0]]
+    set server [connection_server [lindex [connections] 0]]
 
     if {$resource == "announce/motd/delete"} {
 	message::send_msg "$server/$resource" -type normal
@@ -655,7 +657,7 @@
 	destroy .ssl_info
     }
 
-    if {[lempty [set msg_list [ssl_info]]]} return
+    if {[llength [set msg_list [ssl_info]]] == 0} return
 
     Dialog .ssl_info -title [::msgcat::mc "SSL Info"] -separator 1 -anchor e \
 	-default 0 -cancel 0 -modal none
@@ -697,7 +699,7 @@
 
     lassign [update_ssl_info] state fg balloon
 
-    if {![cequal $fg warning]} {
+    if {![string equal $fg warning]} {
 	label .fake_label
 	set fg [.fake_label cget -foreground]
 	destroy .fake_label
@@ -705,7 +707,7 @@
 	set fg [option get $ssl_ind errorForeground Label]
     }
     $ssl_ind configure -state $state
-    if {[cequal $state normal]} {
+    if {[string equal $state normal]} {
 	$ssl_ind configure -foreground $fg
     }
     DynamicHelp::register $ssl_ind balloon $balloon
@@ -795,7 +797,7 @@
 	[::msgcat::mc "Add new user..."]
     add_toolbar_button toolbar/disco {disco::browser::open_win ""} \
 	[::msgcat::mc "Service Discovery"]
-    add_toolbar_button toolbar/join-conference join_group_dialog \
+    add_toolbar_button toolbar/join-conference {join_group_dialog ""} \
 	[::msgcat::mc "Join group..."]
 
     set idx [add_toolbar_button [ifacetk::online_icon] \
@@ -1012,7 +1014,7 @@
     set c .nb.c
 
     set tags [$c gettags current]
-    if {[lcontain $tags page]} {
+    if {[lsearch -exact $tags page] >= 0} {
 	# page name
 	set data [string range [lindex $tags 1] 2 end]
 	return [list NoteBookPage {move} $data]
@@ -1030,7 +1032,7 @@
     set yc [$c canvasy $y]
 
     set tags [$c gettags [lindex [$c find closest $xc $yc] 0]]
-    if {[lcontain $tags page]} {
+    if {[lsearch -exact $tags page] >= 0} {
 	DropSite::setcursor based_arrow_down
 	return 3
     } else {
@@ -1048,7 +1050,7 @@
     set yc [$c canvasy $y]
 
     set tags [$c gettags [lindex [$c find closest $xc $yc] 0]]
-    if {[lcontain $tags page]} {
+    if {[lsearch -exact $tags page] >= 0} {
 	# page name
 	set data1 [string range [lindex $tags 1] 2 end]
 	.nb move $data [.nb index $data1]
@@ -1072,7 +1074,7 @@
 
 hook::add finload_hook [namespace current]::ifacetk::create_main_window 1
 
-proc ifacetk::allow_presence_change {connid} {
+proc ifacetk::allow_presence_change {xlib} {
     .presence.button configure -state normal
 
     set m [.mainframe getmenu tkabber]
@@ -1080,8 +1082,8 @@
 
 }
 
-proc ifacetk::disallow_presence_change {connid} {
-    if {[llength [jlib::connections]] == 0} {
+proc ifacetk::disallow_presence_change {xlib} {
+    if {[llength [connections]] == 0} {
 	.presence.button configure -state disabled
 
 	set m [.mainframe getmenu tkabber]
@@ -1112,7 +1114,7 @@
 hook::add close_chat_post_hook [namespace current]::ifacetk::on_close_chat_window
 
 proc ifacetk::nbpage {path} {
-    return [crange [win_id tab $path] 1 end]
+    return [string range [win_id tab $path] 1 end]
 }
 
 proc ifacetk::nbpath {page} {
@@ -1221,17 +1223,16 @@
     variable number_msg
     variable personal_msg
 
-    if {![catch {::plugins::mucignore::is_ignored $connid $from $type} ignore] && \
+    if {![catch {::plugins::mucignore::is_ignored $xlib $from $type} ignore] && \
 	    $ignore != ""} {
 	    return
     }
 
     foreach xelem $extras {
-	jlib::wrapper:splitxml $xelem tag vars isempty chdata children
+	::xmpp::xml::split $xelem tag xmlns attrs cdata subels
 	# Don't add number to title if this 'empty' tag is present. It indicates
 	# messages history in chat window.
-	if {[cequal $tag ""] && \
-	    [cequal [jlib::wrapper:getattr $vars xmlns] tkabber:x:nolog]} {
+	if {[string equal $tag ""] && [string equal $xmlns tkabber:x:nolog]} {
 	    return
 	}
     }
@@ -1246,11 +1247,11 @@
     } elseif {$type == "groupchat"} {
 	set jid [chat::get_jid $chatid]
 	set myjid [chat::our_jid $chatid]
-	set mynick [chat::get_nick [chat::get_connid $chatid] $myjid $type]
-	if {![cequal $jid $from] && ![cequal $myjid $from]} {
+	set mynick [chat::get_nick [chat::get_xlib $chatid] $myjid $type]
+	if {![string equal $jid $from] && ![string equal $myjid $from]} {
 	    incr number_msg($chatid)
 	}
-	if {![cequal $jid $from] && ![cequal $myjid $from] && \
+	if {![string equal $jid $from] && ![string equal $myjid $from] && \
 		[check_message $mynick $body]} {
 	    incr personal_msg($chatid)
 	}
@@ -1261,22 +1262,22 @@
 
 hook::add draw_message_hook [namespace current]::ifacetk::add_number_of_messages_to_title 18
 
-proc ifacetk::set_main_window_title_on_connect {connid} {
+proc ifacetk::set_main_window_title_on_connect {xlib} {
     variable main_window_title
 
-    set main_window_title "[jlib::connection_jid $connid] - Tkabber"
+    set main_window_title "[connection_jid $xlib] - Tkabber"
     wm title . $main_window_title
     wm iconname . $main_window_title
 }
 
-proc ifacetk::set_main_window_title_on_disconnect {connid} {
+proc ifacetk::set_main_window_title_on_disconnect {xlib} {
     variable main_window_title
 
-    if {[llength [jlib::connections]] == 0} {
+    if {[llength [connections]] == 0} {
 	set main_window_title "Tkabber"
     } else {
 	set main_window_title \
-	    "[jlib::connection_jid [lindex [jlib::connections] end]] - Tkabber"
+	    "[connection_jid [lindex [connections] end]] - Tkabber"
     }
     wm title . $main_window_title
     wm iconname . $main_window_title
@@ -1491,8 +1492,8 @@
     }
 
     set st [wm state .]
-    if {(![cequal $st normal] && ![cequal $st zoomed]) || \
-	    ([cequal [focus -displayof .] ""])} {
+    if {(![string equal $st normal] && ![string equal $st zoomed]) || \
+	    ([string equal [focus -displayof .] ""])} {
 	set backgroundP 1
     } else {
 	set backgroundP 0
@@ -1600,8 +1601,8 @@
     global tcl_platform
     variable mainwindowstate
 
-    if {[cequal $tcl_platform(platform) windows]} {
-	if {[cequal $mainwindowstate zoomed]} {
+    if {[string equal $tcl_platform(platform) windows]} {
+	if {[string equal $mainwindowstate zoomed]} {
 	    wm state . zoomed
 	}
     }
@@ -1650,15 +1651,6 @@
     $w configure -values $status_history
 }
 
-proc client:errormsg {message} {
-    if {[winfo exists .client_error]} {
-	destroy .client_error
-    }
-    
-    MessageDlg .client_error -aspect 50000 -icon error \
-	-message $message -type user -buttons ok -default 0 -cancel 0
-}
-
 # This proc should be called by WM_SAVE_YOURSELF protocol callback.
 # On Windows (and Tk >= 8.4.13) this means WM_QUERYENDSESSION (so we should quit),
 # on Unix, an X session manager may call this repeatedly.

Modified: trunk/tkabber/ifacetk/ilogin.tcl
===================================================================
--- trunk/tkabber/ifacetk/ilogin.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/ifacetk/ilogin.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -294,33 +294,29 @@
 	grid $l.proxy -row 0 -column 1 -columnspan 3 -sticky w -in $proxy_page
 
 	set col 0
-	foreach type [jlib::capabilities proxy] {
-	    switch -- $type {
-		none {
-		   radiobutton $l.proxy.none -text [::msgcat::mc "None"] \
-			-variable ltmp(proxy) -value none \
+
+	radiobutton $l.proxy.none -text [::msgcat::mc "None"] \
+		    -variable ltmp(proxy) -value none \
+		    -command [list [namespace current]::update_login_entries $l]
+	grid $l.proxy.none -row 0 -column [incr col] -sticky w
+
+	if {![catch {package present pconnect::https}]} {
+	    radiobutton $l.proxy.https -text [::msgcat::mc "HTTPS"] \
+			-variable ltmp(proxy) -value https \
 			-command [list [namespace current]::update_login_entries $l]
-		    grid $l.proxy.none -row 0 -column [incr col] -sticky w
-		}
-		socks4 {
-		   radiobutton $l.proxy.socks4 -text [::msgcat::mc "SOCKS4a"] \
+	    grid $l.proxy.https -row 0 -column [incr col] -sticky w
+	}
+	if {![catch {package present pconnect::socks4}]} {
+	    radiobutton $l.proxy.socks4 -text [::msgcat::mc "SOCKS4a"] \
 			-variable ltmp(proxy) -value socks4 \
 			-command [list [namespace current]::update_login_entries $l]
-		    grid $l.proxy.socks4 -row 0 -column [incr col] -sticky w
-		}
-		socks5 {
-		   radiobutton $l.proxy.socks5 -text [::msgcat::mc "SOCKS5"] \
+	    grid $l.proxy.socks4 -row 0 -column [incr col] -sticky w
+	}
+	if {![catch {package present pconnect::socks5}]} {
+	    radiobutton $l.proxy.socks5 -text [::msgcat::mc "SOCKS5"] \
 			-variable ltmp(proxy) -value socks5 \
 			-command [list [namespace current]::update_login_entries $l]
-		    grid $l.proxy.socks5 -row 0 -column [incr col] -sticky w
-		}
-		https {
-		   radiobutton $l.proxy.https -text [::msgcat::mc "HTTPS"] \
-			-variable ltmp(proxy) -value https \
-			-command [list [namespace current]::update_login_entries $l]
-		    grid $l.proxy.https -row 0 -column [incr col] -sticky w
-		}
-	    }
+	    grid $l.proxy.socks5 -row 0 -column [incr col] -sticky w
 	}
 
 	label $l.lproxyhost -text [::msgcat::mc "Proxy server:"]
@@ -395,7 +391,7 @@
 	destroy $w
     }
 
-    switch -- [llength [jlib::connections]] {
+    switch -- [llength [connections]] {
 	0 {
 	    return
 	}
@@ -406,8 +402,8 @@
     }
 
     set lnames {}
-    foreach connid [jlib::connections] {
-	lappend lnames $connid [jlib::connection_jid $connid]
+    foreach xlib [connections] {
+	lappend lnames $xlib [connection_jid $xlib]
     }
 
     if {[CbDialog $w [::msgcat::mc "Logout"] \
@@ -417,9 +413,9 @@
 	return
     }
 
-    foreach connid [array names logout_conn] {
-	if {[lcontain [jlib::connections] $connid] && $logout_conn($connid)} {
-	    logout $connid
+    foreach xlib [array names logout_conn] {
+	if {[lcontain [connections] $xlib] && $logout_conn($xlib)} {
+	    logout $xlib
 	}
     }
 }

Modified: trunk/tkabber/ifacetk/iroster.tcl
===================================================================
--- trunk/tkabber/ifacetk/iroster.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/ifacetk/iroster.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -149,7 +149,7 @@
 
 hook::add finload_hook [namespace current]::roster::get_group_lists
 
-proc roster::set_group_lists {connid} {
+proc roster::set_group_lists {xlib} {
     variable collapsed_group_list
     variable show_offline_group_list
     variable collapsed
@@ -162,17 +162,17 @@
     set _collapsed_group_list $collapsed_group_list
     set _show_offline_group_list $show_offline_group_list
 
-    if {$connid == {}} {
-	set connidlist [jlib::connections]
+    if {$xlib == {}} {
+	set xliblist [connections]
     } else {
-	set connidlist [list $connid]
+	set xliblist [list $xlib]
     }
 
-    foreach connid $connidlist {
-	if {[catch { set bare_jid [jlib::connection_bare_jid $connid] }]} {
+    foreach xlib $xliblist {
+	if {[catch { set bare_jid [connection_bare_jid $xlib] }]} {
 	    continue
 	}
-	if {[catch { set groups [roster::get_groups $connid -raw 1] }]} {
+	if {[catch { set groups [roster::get_groups $xlib -raw 1] }]} {
 	    continue
 	}
 	if {$options(nested)} {
@@ -191,10 +191,10 @@
 	foreach group $groups {
 	    if {$options(nested)} {
 		set grname [join $group $options(nested_delimiter)]
-		set gid [list $connid $group]
+		set gid [list $xlib $group]
 	    } else {
 		set grname [list $group]
-		set gid [list $connid $grname]
+		set gid [list $xlib $grname]
 	    }
 	    if {[info exists roster(collapsed,$gid)]} {
 		set collapsed($bare_jid,$grname) $roster(collapsed,$gid)
@@ -227,12 +227,11 @@
 
 hook::add predisconnected_hook [namespace current]::roster::set_group_lists
 
-proc roster::process_item {connid jid name groups subsc ask} {
+proc roster::process_item {xlib jid name groups subsc ask} {
     after cancel [namespace parent]::update_chat_titles
     after idle [namespace parent]::update_chat_titles
 }
 
-hook::add roster_item_hook [namespace current]::roster::process_item 90
 hook::add roster_push_hook [namespace current]::roster::process_item 90
 
 proc roster::create_filter_entry {} {
@@ -291,7 +290,7 @@
 
     clear .roster 0
     
-    set connections [jlib::connections]
+    set connections [connections]
     switch -- [llength $connections] {
 	0 {
 	    update_scrollregion .roster
@@ -307,18 +306,18 @@
 	}
     }
 
-    foreach connid $connections {
+    foreach xlib $connections {
         # Suppress display of aliases, but not if "main" JID is unavailable.
         # If main JID is unavailable, perform reordering of aliases.
         # Suppression means that aliases wont get a line in the roster for
 	# themselves, but will be places as children under "main" JID element
 	if {$use_aliases} {
 	    foreach jid [array names aliases] {
-		set status [get_user_status $connid $jid]
+		set status [get_user_status $xlib $jid]
 		if {$status == "unavailable"} {
 		    # Need to look an alternative for main JID,
 		    # which is offline.
-		    set jidstatus [get_user_aliases_status_and_jid $connid $jid]
+		    set jidstatus [get_user_aliases_status_and_jid $xlib $jid]
                     switch -- [lindex $jidstatus 1] {
                         unavailable {
                             # Main JID and all aliases are unavailable.
@@ -352,30 +351,30 @@
         }
         
 	if {$draw_connection} {
-	    if {![info exists roster(collapsed,[list connid $connid])]} {
-		set roster(collapsed,[list connid $connid]) 0
+	    if {![info exists roster(collapsed,[list xlib $xlib])]} {
+		set roster(collapsed,[list xlib $xlib]) 0
 	    }
 	    addline .roster connection \
-		[jlib::connection_jid $connid] \
-		[list connid $connid] [list connid $connid] 0
+		[connection_jid $xlib] \
+		[list xlib $xlib] [list xlib $xlib] 0
 	    
-	    if {$roster(collapsed,[list connid $connid])} {
+	    if {$roster(collapsed,[list xlib $xlib])} {
 		continue
 	    }
 	}
 
-	if {[lempty [::roster::get_jids $connid]]} {
+	if {[lempty [::roster::get_jids $xlib]]} {
 	    continue
 	}
-	set bare_jid [jlib::connection_bare_jid $connid]
+	set bare_jid [connection_bare_jid $xlib]
 	set groups {}
 	array unset jidsingroup
 	array unset jidsundergroup
 	array unset groupsundergroup
-	foreach jid [::roster::get_jids $connid] {
+	foreach jid [::roster::get_jids $xlib] {
 	    if {$options(use_filter) && $options(filter) != ""} {
 		if {[string first [string tolower $options(filter)] \
-				  [string tolower [::roster::get_label $connid $jid]]] < 0} {
+				  [string tolower [::roster::get_label $xlib $jid]]] < 0} {
 		    if {!$options(match_jids) || \
 			    [string first [string tolower $options(filter)] \
 					  [string tolower $jid]] < 0} {
@@ -384,7 +383,7 @@
 		}
 	    }
 	    if {[info exists ignore_jid($jid)]} continue
-	    set jid_groups [::roster::itemconfig $connid $jid -group]
+	    set jid_groups [::roster::itemconfig $xlib $jid -group]
 	    if {![lempty $jid_groups]} {
 		foreach group $jid_groups {
 		    if {$options(nested)} {
@@ -427,13 +426,13 @@
 	}
 	if {$options(chats_group)} {
 	    set cgroup [list $chats_group_name]
-	    foreach chatid [chat::opened $connid] {
+	    foreach chatid [chat::opened $xlib] {
 		set jid [chat::get_jid $chatid]
 		lappend jidsingroup($cgroup) $jid
-		if {[cequal [roster::itemconfig $connid $jid -isuser] ""]} {
-		    roster::itemconfig $connid $jid \
-			-name [chat::get_nick $connid $jid chat]
-		    roster::itemconfig $connid $jid -subsc none
+		if {[cequal [roster::itemconfig $xlib $jid -isuser] ""]} {
+		    roster::itemconfig $xlib $jid \
+			-name [chat::get_nick $xlib $jid chat]
+		    roster::itemconfig $xlib $jid -subsc none
 		}
 	    }
 	    if {[info exists jidsingroup($cgroup)]} {
@@ -444,16 +443,16 @@
 	}
 	if {$options(show_own_resources)} {
 	    set cgroup [list $own_resources_group_name]
-	    set jid [tolower_node_and_domain [::jlib::connection_bare_jid $connid]]
+	    set jid [tolower_node_and_domain [connection_bare_jid $xlib]]
 	    set jidsingroup($cgroup) [list $jid]
 	    set groups [linsert $groups 0 [list [join $cgroup "\u0000"] $cgroup]]
-	    roster::itemconfig $connid $jid -subsc both
+	    roster::itemconfig $xlib $jid -subsc both
 	    set groupsundergroup($cgroup) {}
 	    set jidsundergroup($cgroup) {}
 	}
 	foreach group $groups {
 	    set group [lindex $group 1]
-	    set gid [list $connid $group]
+	    set gid [list $xlib $group]
 	    if {![info exists roster(show_offline,$gid)]} {
 		if {$options(nested)} {
 		    set gname [join $group $options(nested_delimiter)]
@@ -471,7 +470,7 @@
 	    set group [lindex $group 1]
 	    set jidsingroup($group) [lrmdups $jidsingroup($group)]
 	    set groupsundergroup($group) [lrmdups $groupsundergroup($group)]
-	    set gid [list $connid $group]
+	    set gid [list $xlib $group]
 	    if {![info exists roster(collapsed,$gid)]} {
 		if {$options(nested)} {
 		    set gname [join $group $options(nested_delimiter)]
@@ -489,13 +488,13 @@
 	    set show_offline_users 0
 	    set show_offline_group 0
 	    foreach undergroup $groupsundergroup($group) {
-		if {$roster(show_offline,[list $connid $undergroup])} {
+		if {$roster(show_offline,[list $xlib $undergroup])} {
 		    set show_offline_group 1
 		    break
 		}
 	    }
 	    for {set i 0} {$i < $indent} {incr i} {
-		set sgr [list $connid [lrange $group 0 $i]]
+		set sgr [list $xlib [lrange $group 0 $i]]
 		if {$roster(collapsed,$sgr)} {
 		    set collapse 1
 		    break
@@ -513,9 +512,9 @@
 	    set not_users 0
 	    set sub_jids 0
 	    foreach jid [concat $jidsingroup($group) $jidsundergroup($group)] {
-		if {[::roster::itemconfig $connid $jid -isuser]} {
+		if {[::roster::itemconfig $xlib $jid -isuser]} {
 		    incr users
-		    set status [get_user_aliases_status $connid $jid]
+		    set status [get_user_aliases_status $xlib $jid]
 		    set jstat($jid) $status
 		    if {$status != "unavailable"} {
 			incr online
@@ -542,24 +541,24 @@
 	    if {!$roster(collapsed,$gid)} {
 		set jid_names {}
 		foreach jid $jidsingroup($group) {
-		    lappend jid_names [list $jid [::roster::get_label $connid $jid]]
+		    lappend jid_names [list $jid [::roster::get_label $xlib $jid]]
 		}
 		set jid_names [lsort -index 1 -dictionary $jid_names]
 		foreach jid_name $jid_names {
 		    lassign $jid_name jid name
 		    if {$options(chats_group)} {
-			set chatid [chat::chatid $connid $jid]
+			set chatid [chat::chatid $xlib $jid]
 			if {[info exists chat::chats(messages,$chatid)] && \
 				$chat::chats(messages,$chatid) > 0} {
 			    append name " \[$chat::chats(messages,$chatid)\]"
 			}
 		    }
-		    set cjid [list $connid $jid]
+		    set cjid [list $xlib $jid]
 		    if {!$show_only_online || $show_offline_users || $roster(show_offline,$gid) || \
 			    ($options(use_filter) && $options(filter) != "") || \
 			    ![info exists useronline($jid)] || $useronline($jid)} {
-			lassign [::roster::get_category_and_subtype $connid $jid] category type
-			set jids [get_jids_of_user $connid $jid]
+			lassign [::roster::get_category_and_subtype $xlib $jid] category type
+			set jids [get_jids_of_user $xlib $jid]
 			set numjids [llength $jids]
 			if {($numjids > 1) && ($config(subitemtype) > 0) && \
 				$category == "user"} {
@@ -572,21 +571,21 @@
 				set label "$name"
 			    }
 			    addline .roster jid $label $cjid $gid $indent $jids
-			    changeicon .roster $cjid [get_jid_icon $connid $jid]
-			    changeforeground .roster $cjid [get_jid_foreground $connid $jid]
+			    changeicon .roster $cjid [get_jid_icon $xlib $jid]
+			    changeforeground .roster $cjid [get_jid_foreground $xlib $jid]
 			    
 			    if {!$roster(collapsed,$cjid)} {
 				foreach subjid $jids {
 				    set subjid_resource [resource_from_jid $subjid]
 				    if {$subjid_resource != ""} {
 					addline .roster jid2 \
-					    $subjid_resource [list $connid $subjid] \
+					    $subjid_resource [list $xlib $subjid] \
 					    $gid $indent \
 					    [list $subjid]
 					changeicon .roster \
-					    [list $connid $subjid] [get_jid_icon $connid $subjid]
+					    [list $xlib $subjid] [get_jid_icon $xlib $subjid]
 					changeforeground .roster \
-					    [list $connid $subjid] [get_jid_foreground $connid $subjid]
+					    [list $xlib $subjid] [get_jid_foreground $xlib $subjid]
 				    }
 				}
 			    }
@@ -596,9 +595,9 @@
 				if {[info exists jstat($jid)]} {
 				    set status $jstat($jid)
 				} else {
-				    set status [get_user_aliases_status $connid $jid]
+				    set status [get_user_aliases_status $xlib $jid]
 				}
-				set subsc [::roster::itemconfig $connid $jid -subsc]
+				set subsc [::roster::itemconfig $xlib $jid -subsc]
 				if {([cequal $subsc from] || [cequal $subsc none]) && \
 					$status == "unavailable"} {
 				    set status unsubscribed
@@ -609,8 +608,8 @@
 				    $config(${status}foreground)
 			    } else {
 				addline .roster jid $name $cjid $gid $indent $jids
-				changeicon .roster $cjid [get_jid_icon $connid $jid]
-				changeforeground .roster $cjid [get_jid_foreground $connid $jid]
+				changeicon .roster $cjid [get_jid_icon $xlib $jid]
+				changeforeground .roster $cjid [get_jid_foreground $xlib $jid]
 			    }
 			}
 		    }
@@ -638,36 +637,36 @@
     ifacetk::roster::redraw_after_idle
 }
 
-proc roster::get_jids_of_user {connid user} {
+proc roster::get_jids_of_user {xlib user} {
     upvar #0 roster::aliases aliases
     variable use_aliases
 
     if {$use_aliases && [info exists aliases($user)]} {
-	set jids [::get_jids_of_user $connid $user]
+	set jids [::get_jids_of_user $xlib $user]
 	foreach alias $aliases($user) {
-	    set jids [concat $jids [::get_jids_of_user $connid $alias]]
+	    set jids [concat $jids [::get_jids_of_user $xlib $alias]]
 	}
 	return $jids
     } else {
-	return [::get_jids_of_user $connid $user]
+	return [::get_jids_of_user $xlib $user]
     }
 }
 
-proc roster::get_user_aliases_status {connid user} {
-    set jidstatus [get_user_aliases_status_and_jid $connid $user]
+proc roster::get_user_aliases_status {xlib user} {
+    set jidstatus [get_user_aliases_status_and_jid $xlib $user]
     return [lindex $jidstatus 1]
 }
 
-proc roster::get_user_aliases_status_and_jid {connid user} {
+proc roster::get_user_aliases_status_and_jid {xlib user} {
     upvar #0 roster::aliases aliases
     variable use_aliases
 
     if {$use_aliases && [info exists aliases($user)]} {
-	set status [get_user_status $connid $user]
+	set status [get_user_status $xlib $user]
         set jid $user
 
 	foreach alias $aliases($user) {
-	    set new_status [max_status $status [get_user_status $connid $alias]]
+	    set new_status [max_status $status [get_user_status $xlib $alias]]
             if {$status != $new_status} {
                 set status $new_status
                 set jid $alias
@@ -675,20 +674,20 @@
 	}
 	return [list $jid $status]
     } else {
-	return [list $user [get_user_status $connid $user]]
+	return [list $user [get_user_status $xlib $user]]
     }
 }
 
-proc roster::get_jid_foreground {connid jid} {
-    lassign [::roster::get_category_and_subtype $connid $jid] category type
+proc roster::get_jid_foreground {xlib jid} {
+    lassign [::roster::get_category_and_subtype $xlib $jid] category type
 
     switch -- $category {
 	"" -
 	user {
-	    return [get_user_foreground $connid $jid]
+	    return [get_user_foreground $xlib $jid]
 	}
 	conference {
-	    if {[get_jid_status $connid $jid] != "unavailable"} {
+	    if {[get_jid_status $xlib $jid] != "unavailable"} {
 		return available
 	    } else {
 		return unavailable
@@ -697,7 +696,7 @@
 	server  -
 	gateway -
 	service {
-	    return [get_service_foreground $connid $jid $type]
+	    return [get_service_foreground $xlib $jid $type]
 	}
 	default {
 	    return ""
@@ -705,24 +704,24 @@
     }
 }
 
-proc roster::get_service_foreground {connid service type} {
+proc roster::get_service_foreground {xlib service type} {
     switch -- $type {
 	jud {return ""}
 	}
-    if {![cequal [::roster::itemconfig $connid $service -subsc] none]} {
-	return [get_user_status $connid $service]
+    if {![cequal [::roster::itemconfig $xlib $service -subsc] none]} {
+	return [get_user_status $xlib $service]
     } else {
 	return unsubscribed
     }
 }
 
-proc roster::get_user_foreground {connid user} {
-    set status [get_user_aliases_status $connid $user]
+proc roster::get_user_foreground {xlib user} {
+    set status [get_user_aliases_status $xlib $user]
 
-    set subsc [::roster::itemconfig $connid $user -subsc]
+    set subsc [::roster::itemconfig $xlib $user -subsc]
     if {[cequal $subsc ""]} {
-	set subsc [::roster::itemconfig $connid \
-		       [::roster::find_jid $connid $user] -subsc]
+	set subsc [::roster::itemconfig $xlib \
+		       [::roster::find_jid $xlib $user] -subsc]
     }
 
     if {([cequal $subsc from] || [cequal $subsc none]) && \
@@ -733,20 +732,20 @@
     }
 }
 
-proc roster::get_jid_icon {connid jid {status ""}} {
-    lassign [::roster::get_category_and_subtype $connid $jid] category type
+proc roster::get_jid_icon {xlib jid {status ""}} {
+    lassign [::roster::get_category_and_subtype $xlib $jid] category type
 
     switch -- $category {
 	"" -
 	user {
 	    if {$status == ""} {
-		set status [get_user_aliases_status $connid $jid]
+		set status [get_user_aliases_status $xlib $jid]
 	    }
-	    return [get_user_icon $connid $jid $status]
+	    return [get_user_icon $xlib $jid $status]
 	}
 	conference {
 	    if {$status == ""} {
-		set status [get_jid_status $connid $jid]
+		set status [get_jid_status $xlib $jid]
 	    }
 	    if {$status != "unavailable"} {
 		return roster/conference/available
@@ -757,20 +756,20 @@
 	gateway -
 	service {
 	    if {$status == ""} {
-		set status [get_user_status $connid $jid]
+		set status [get_user_status $xlib $jid]
 	    }
-	    return [get_service_icon $connid $jid $type $status]
+	    return [get_service_icon $xlib $jid $type $status]
 	}
 	default {
 	    if {$status == ""} {
-		set status [get_jid_status $connid $jid]
+		set status [get_jid_status $xlib $jid]
 	    }
-	    return [get_user_icon $connid $jid $status]
+	    return [get_user_icon $xlib $jid $status]
 	}
     }
 }
 
-proc roster::get_service_icon {connid service type status} {
+proc roster::get_service_icon {xlib service type status} {
     variable show_transport_icons
 
     if {$show_transport_icons} {
@@ -778,7 +777,7 @@
 	    jud {return services/jud}
 	    sms {return services/sms}
 	}
-	if {![cequal [::roster::itemconfig $connid $service -subsc] none]} {
+	if {![cequal [::roster::itemconfig $xlib $service -subsc] none]} {
 	    if {![catch { image type services/$type/$status }]} {
 		return services/$type/$status
 	    } else {
@@ -788,7 +787,7 @@
 	    return roster/user/unsubscribed
 	}
     } else {
-	if {![cequal [::roster::itemconfig $connid $service -subsc] none]} {
+	if {![cequal [::roster::itemconfig $xlib $service -subsc] none]} {
 	    return roster/user/$status
 	} else {
 	    return roster/user/unsubscribed
@@ -796,20 +795,20 @@
     }
 }
 
-proc roster::get_user_icon {connid user status} {
+proc roster::get_user_icon {xlib user status} {
     variable show_transport_user_icons
 
-    set subsc [::roster::itemconfig $connid $user -subsc]
+    set subsc [::roster::itemconfig $xlib $user -subsc]
     if {[cequal $subsc ""]} {
-	set subsc [::roster::itemconfig $connid \
-	               [::roster::find_jid $connid $user] -subsc]
+	set subsc [::roster::itemconfig $xlib \
+	               [::roster::find_jid $xlib $user] -subsc]
     }
 
     if {!([cequal $subsc from] || [cequal $subsc none]) || \
 	    $status != "unavailable"} {
 	if {$show_transport_user_icons} {
 	    set service [server_from_jid $user]
-	    lassign [::roster::get_category_and_subtype $connid $service] category type
+	    lassign [::roster::get_category_and_subtype $xlib $service] category type
 	    switch -glob -- $category/$type {
 		directory/* -
 		*/jud {
@@ -990,8 +989,8 @@
 
 
     if {[cequal $type jid]} {
-	lassign $jid connid jjid
-	set isuser [::roster::itemconfig $connid $jjid -isuser]
+	lassign $jid xlib jjid
+	set isuser [::roster::itemconfig $xlib $jjid -isuser]
 	if {[cequal $isuser ""]} {
 	    set isuser 1
 	}
@@ -1179,19 +1178,19 @@
 ###############################################################################
 
 proc roster::jid_doubleclick {id} {
-    lassign $id connid jid
-    lassign [::roster::get_category_and_subtype $connid $jid] category subtype
+    lassign $id xlib jid
+    lassign [::roster::get_category_and_subtype $xlib $jid] category subtype
 
-    hook::run roster_jid_doubleclick $connid $jid $category $subtype
+    hook::run roster_jid_doubleclick $xlib $jid $category $subtype
 }
 
 ###############################################################################
 
-proc roster::doubleclick_fallback {connid jid category subtype} {
+proc roster::doubleclick_fallback {xlib jid category subtype} {
     variable options
 
     if {$options(chat_on_doubleclick)} {
-	chat::open_to_user $connid $jid
+	chat::open_to_user $xlib $jid
     } else {
 	message::send_dialog -to $jid
     }
@@ -1212,7 +1211,7 @@
 proc roster::jids_popup_info {id jids} {
     variable use_aliases
 
-    lassign $id connid jid
+    lassign $id xlib jid
 
     if {$jids == {}} {
 	if {$use_aliases && [info exists aliases($jid)]} {
@@ -1225,33 +1224,33 @@
     set text {}
     set i 0
     foreach j $jids {
-	append text "\n[[namespace current]::user_popup_info $connid $j $i]"
+	append text "\n[[namespace current]::user_popup_info $xlib $j $i]"
 	incr i
     }
     set text [string trimleft $text "\n"]
     return $text
 }
 
-proc roster::user_popup_info {connid user i} {
+proc roster::user_popup_info {xlib user i} {
     variable options
     variable user_popup_info
     global statusdesc
 
-    lassign [::roster::get_category_and_subtype $connid $user] category subtype
-    set bare_user [::roster::find_jid $connid $user]
-    lassign [::roster::get_category_and_subtype $connid $bare_user] \
+    lassign [::roster::get_category_and_subtype $xlib $user] category subtype
+    set bare_user [::roster::find_jid $xlib $user]
+    lassign [::roster::get_category_and_subtype $xlib $bare_user] \
 	category1 subtype1
 
     set name $user
     switch -- $category {
 	conference {
-	    set status $statusdesc([get_jid_status $connid $user])
+	    set status $statusdesc([get_jid_status $xlib $user])
 	    set desc ""
 	}
 	user -
 	default {
-	    set status $statusdesc([get_user_status $connid $user])
-	    set desc   [get_user_status_desc $connid $user]
+	    set status $statusdesc([get_user_status $xlib $user])
+	    set desc   [get_user_status_desc $xlib $user]
 	    if {[cequal $category1 conference] && $i > 0} {
 		if {$options(show_conference_user_info)} {
 		    set name "     [resource_from_jid $user]"
@@ -1266,11 +1265,11 @@
 	append status " ($desc)"
     }
 
-    set subsc [::roster::itemconfig $connid $bare_user -subsc]
+    set subsc [::roster::itemconfig $xlib $bare_user -subsc]
     if {($options(show_subscription) && ![cequal $subsc ""]) &&
 	    !([cequal $category1 conference] && [cequal $category user])} {
 	set subsc [format "\n\t[::msgcat::mc {Subscription:}] %s" $subsc]
-	set ask [::roster::itemconfig $connid $bare_user -ask]
+	set ask [::roster::itemconfig $xlib $bare_user -ask]
 	if {![cequal $ask ""]} {
 	    set ask [format "  [::msgcat::mc {Ask:}] %s" $ask]
 	}
@@ -1284,7 +1283,7 @@
     if {!([cequal $category1 conference] && $i > 0) || \
 	    $options(show_conference_user_info)} {
 	hook::run roster_user_popup_info_hook \
-	    [namespace which -variable user_popup_info] $connid $user
+	    [namespace which -variable user_popup_info] $xlib $user
     }
 
     return $user_popup_info
@@ -1296,9 +1295,9 @@
     set show_only_online [expr {!$show_only_online}]
 }
 
-proc roster::is_online {connid jid} {
-    if {[::roster::itemconfig $connid $jid -isuser]} {
-	switch -- [get_user_aliases_status $connid $jid] {
+proc roster::is_online {xlib jid} {
+    if {[::roster::itemconfig $xlib $jid -isuser]} {
+	switch -- [get_user_aliases_status $xlib $jid] {
 	    unavailable {return 0}
 	    default {return 1}
 	}
@@ -1309,15 +1308,15 @@
 
 ###############################################################################
 
-proc roster::add_remove_item_menu_item {m connid jid} {
-    set rjid [roster::find_jid $connid $jid]
+proc roster::add_remove_item_menu_item {m xlib jid} {
+    set rjid [roster::find_jid $xlib $jid]
     if {$rjid == ""} {
 	set state disabled
     } else {
 	set state normal
     }
     $m add command -label [::msgcat::mc "Remove from roster..."] \
-	-command [list ifacetk::roster::remove_item_dialog $connid $rjid] \
+	-command [list ifacetk::roster::remove_item_dialog $xlib $rjid] \
 	-state $state
 }
 
@@ -1332,12 +1331,12 @@
 
 ###############################################################################
 
-proc roster::remove_item_dialog {connid jid} {
+proc roster::remove_item_dialog {xlib jid} {
     set res [MessageDlg .remove_item -aspect 50000 -icon question -type user \
 	-buttons {yes no} -default 0 -cancel 1 \
 	-message [format [::msgcat::mc "Are you sure to remove %s from roster?"] $jid]]
     if {$res == 0} {
-	::roster::remove_item $connid $jid
+	::roster::remove_item $xlib $jid
     }
 }
 
@@ -1372,22 +1371,22 @@
     set tags [$c gettags [lindex [$c find closest $xc $yc] 0]]
 
     if {$options(free_drop) && ![cequal $tags ""]} {
-	lassign [tag_to_jid [crange [lindex $tags 1] 5 end]] connid gr
-	if {$connid == "connid"} {
-	    set connid $gr
+	lassign [tag_to_jid [crange [lindex $tags 1] 5 end]] xlib gr
+	if {$xlib == "xlib"} {
+	    set xlib $gr
 	    set gr {}
 	}
     } elseif {[lcontain $tags group]} {
-	lassign [tag_to_jid [crange [lindex $tags 0] 3 end]] connid gr
-	if {$connid == "connid"} {
-	    set connid $gr
+	lassign [tag_to_jid [crange [lindex $tags 0] 3 end]] xlib gr
+	if {$xlib == "xlib"} {
+	    set xlib $gr
 	    set gr {}
 	}
     } elseif {![cequal $tags ""]} {
-	lassign [tag_to_jid [crange [lindex $tags 1] 5 end]] connid
+	lassign [tag_to_jid [crange [lindex $tags 1] 5 end]] xlib
 	set gr {}
     } else {
-	set connid [lindex [jlib::connections] 0]
+	set xlib [lindex [connections] 0]
 	set gr {}
     }
     if {$options(nested)} {
@@ -1398,11 +1397,11 @@
 
     debugmsg roster "GG: $gr; $tags"
 
-    lassign $data _connid jid category type name version fromgid
+    lassign $data _xlib jid category type name version fromgid
     set subsc ""
 
     if {[info exists fromgid]} {
-	lassign $fromgid fromconnid fromgr 
+	lassign $fromgid fromxlib fromgr 
 	if {$options(nested)} {
 	    set fromgr [join $fromgr $options(nested_delimiter)]
 	} else {
@@ -1410,28 +1409,28 @@
 	}
     }	
 
-    if {![lcontain [::roster::get_jids $connid] $jid]} {
+    if {![lcontain [::roster::get_jids $xlib] $jid]} {
 	if {$gr != {}} {
 	    set groups [list $gr]
 	} else {
 	    set groups {}
 	}
-	::roster::itemconfig $connid $jid -category $category -subtype $type \
+	::roster::itemconfig $xlib $jid -category $category -subtype $type \
 	    -name $name -group $groups
 
-	lassign [::roster::get_category_and_subtype $connid $jid] ccategory ctype
+	lassign [::roster::get_category_and_subtype $xlib $jid] ccategory ctype
 	switch -- $ccategory {
 	    conference {
-		::roster::itemconfig $connid $jid -subsc bookmark
+		::roster::itemconfig $xlib $jid -subsc bookmark
 	    }
 	    user {
-		jlib::send_presence -to $jid -type subscribe -connection $connid
+		::xmpp::sendPresence $xlib -to $jid -type subscribe
 	    }
 	}
     } else {
-	set groups [::roster::itemconfig $connid $jid -group]
+	set groups [::roster::itemconfig $xlib $jid -group]
 
-	if {[info exists fromgid] && ($fromconnid == $connid)} {
+	if {[info exists fromgid] && ($fromxlib == $xlib)} {
 	    set idx [lsearch -exact $groups $fromgr]
 	    if {$idx >= 0} {
 		set groups [lreplace $groups $idx $idx]
@@ -1443,11 +1442,11 @@
 	    debugmsg roster $groups
 	}
 
-	::roster::itemconfig $connid $jid -category $category -subtype $type \
+	::roster::itemconfig $xlib $jid -category $category -subtype $type \
 	    -name $name -group $groups
     }
 
-    ::roster::send_item $connid $jid
+    ::roster::send_item $xlib $jid
 }
 
 proc roster::draginitcmd {target x y top} {
@@ -1462,12 +1461,12 @@
 	set gid [tag_to_jid $grouptag]
 	set tag [crange [lindex $tags 0] 3 end]
 	set cjid [tag_to_jid $tag]
-	lassign $cjid connid jid
+	lassign $cjid xlib jid
 
-	set data [list $connid $jid \
-		      [::roster::itemconfig $connid $jid -category] \
-		      [::roster::itemconfig $connid $jid -subtype] \
-		      [::roster::itemconfig $connid $jid -name] {} \
+	set data [list $xlib $jid \
+		      [::roster::itemconfig $xlib $jid -category] \
+		      [::roster::itemconfig $xlib $jid -subtype] \
+		      [::roster::itemconfig $xlib $jid -name] {} \
 		      $gid]
 
 	debugmsg roster $data
@@ -1482,10 +1481,10 @@
 proc roster::user_singleclick {cjid} {
     variable roster
 
-    lassign $cjid connid jid
+    lassign $cjid xlib jid
 
-    if {[roster::itemconfig $connid $jid -isuser] && \
-	    [llength [get_jids_of_user $connid $jid]] > 1} {
+    if {[roster::itemconfig $xlib $jid -isuser] && \
+	    [llength [get_jids_of_user $xlib $jid]] > 1} {
 	set roster(collapsed,$cjid) [expr {!$roster(collapsed,$cjid)}]
 	redraw_after_idle
     }
@@ -1496,18 +1495,18 @@
 proc roster::popup_menu {id} {
     global curuser
 
-    lassign $id connid jid
+    lassign $id xlib jid
     set curuser $jid
 
-    lassign [::roster::get_category_and_subtype $connid $jid] category subtype
+    lassign [::roster::get_category_and_subtype $xlib $jid] category subtype
 
     switch -- $category {
-	user       {set menu [create_user_menu $connid $jid]}
-	conference {set menu [conference_popup_menu $connid $jid]}
+	user       {set menu [create_user_menu $xlib $jid]}
+	conference {set menu [conference_popup_menu $xlib $jid]}
 	server  -
 	gateway -
-	service    {set menu [service_popup_menu $connid $jid]}
-	default    {set menu [jid_popup_menu $connid $jid]}
+	service    {set menu [service_popup_menu $xlib $jid]}
+	default    {set menu [jid_popup_menu $xlib $jid]}
     }
 
     tk_popup $menu [winfo pointerx .] [winfo pointery .]
@@ -1518,14 +1517,14 @@
 proc roster::group_popup_menu {id} {
     variable options
 
-    lassign $id connid name
+    lassign $id xlib name
     if {$options(nested)} {
 	set name [join $name $options(nested_delimiter)]
     } else {
 	set name [lindex $name 0]
     }
-    if {$connid != "connid"} {
-	tk_popup [create_group_popup_menu $connid $name] \
+    if {$xlib != "xlib"} {
+	tk_popup [create_group_popup_menu $xlib $name] \
 	    [winfo pointerx .] [winfo pointery .]
     }
 }
@@ -1533,27 +1532,27 @@
 ###############################################################################
 
 proc roster::groupchat_popup_menu {id} {
-    lassign $id connid jid
-    tk_popup [create_groupchat_user_menu $connid $jid] \
+    lassign $id xlib jid
+    tk_popup [create_groupchat_user_menu $xlib $jid] \
 	[winfo pointerx .] [winfo pointery .]
 }
 
 ###############################################################################
 
-proc roster::create_user_menu {connid user} {
+proc roster::create_user_menu {xlib user} {
     set m .jidpopupmenu
     if {[winfo exists $m]} { destroy $m }
     menu $m -tearoff 0
 
-    set jids [get_jids_of_user $connid $user]
+    set jids [get_jids_of_user $xlib $user]
 
     switch -- [llength $jids] {
 	0 {
-	    hook::run roster_jid_popup_menu_hook $m $connid $user
+	    hook::run roster_jid_popup_menu_hook $m $xlib $user
 	    return $m
 	}
 	1 {
-	    hook::run roster_jid_popup_menu_hook $m $connid [lindex $jids 0]
+	    hook::run roster_jid_popup_menu_hook $m $xlib [lindex $jids 0]
 	    return $m
 	}
 	default {
@@ -1561,7 +1560,7 @@
 		set m1 .jidpopupmenu[jid_to_tag $jid]
 		if {[winfo exists $m1]} { destroy $m1 }
 		menu $m1 -tearoff 0
-		hook::run roster_jid_popup_menu_hook $m1 $connid $jid
+		hook::run roster_jid_popup_menu_hook $m1 $xlib $jid
 	    }
 
 	    add_menu_submenu $m .jidpopupmenu "" $jids
@@ -1666,19 +1665,19 @@
 
 ###############################################################################
 
-proc roster::add_separator {m connid jid} {
+proc roster::add_separator {m xlib jid} {
     $m add separator
 }
 
 ###############################################################################
 
-proc roster::jid_popup_menu {connid jid} {
+proc roster::jid_popup_menu {xlib jid} {
     if {[winfo exists [set m .jidpopupmenu]]} {
 	destroy $m
     }
     menu $m -tearoff 0
 
-    hook::run roster_jid_popup_menu_hook $m $connid $jid
+    hook::run roster_jid_popup_menu_hook $m $xlib $jid
 
     return $m
 }
@@ -1694,13 +1693,13 @@
 
 ###############################################################################
 
-proc roster::conference_popup_menu {connid jid} {
+proc roster::conference_popup_menu {xlib jid} {
     if {[winfo exists [set m .confpopupmenu]]} {
 	destroy $m
     }
     menu $m -tearoff 0
 
-    hook::run roster_conference_popup_menu_hook $m $connid $jid
+    hook::run roster_conference_popup_menu_hook $m $xlib $jid
 
     return $m
 }
@@ -1714,13 +1713,13 @@
 
 ###############################################################################
 
-proc roster::service_popup_menu {connid jid} {
+proc roster::service_popup_menu {xlib jid} {
     if {[winfo exists [set m .servicepopupmenu]]} {
 	destroy $m
     }
     menu $m -tearoff 0
 
-    hook::run roster_service_popup_menu_hook $m $connid $jid
+    hook::run roster_service_popup_menu_hook $m $xlib $jid
 
     return $m
 }
@@ -1734,13 +1733,13 @@
 
 ###############################################################################
 
-proc roster::create_groupchat_user_menu {connid jid} {
+proc roster::create_groupchat_user_menu {xlib jid} {
     if {[winfo exists [set m .groupchatpopupmenu]]} {
 	destroy $m
     }
     menu $m -tearoff 0
 
-    hook::run roster_create_groupchat_user_menu_hook $m $connid $jid
+    hook::run roster_create_groupchat_user_menu_hook $m $xlib $jid
 
     return $m
 }
@@ -1752,7 +1751,7 @@
 
 ###############################################################################
 
-proc roster::create_group_popup_menu {connid name} {
+proc roster::create_group_popup_menu {xlib name} {
     variable options
     variable chats_group_name
 
@@ -1774,28 +1773,28 @@
     $m add command \
 	-label [::msgcat::mc "Send message to all users in group..."] \
 	-command [list ::message::send_dialog \
-		       -to $name -group 1 -connection $connid]
+		       -to $name -group 1 -connection $xlib]
     $m add command \
 	-label [::msgcat::mc "Resubscribe to all users in group..."] \
-	-command [list ::roster::resubscribe_group $connid $name]
+	-command [list ::roster::resubscribe_group $xlib $name]
 
-    add_group_custom_presence_menu $m $connid $name
+    add_group_custom_presence_menu $m $xlib $name
 
     $m add checkbutton -label [::msgcat::mc "Show offline users"] \
-	-variable [namespace current]::roster(show_offline,[list $connid $oname]) \
+	-variable [namespace current]::roster(show_offline,[list $xlib $oname]) \
 	-command [list [namespace current]::redraw_after_idle]
     $m add command -label [::msgcat::mc "Rename group..."] \
-	-command [list [namespace current]::rename_group_dialog $connid $name] \
+	-command [list [namespace current]::rename_group_dialog $xlib $name] \
 	-state $state
     $m add command -label [::msgcat::mc "Remove group..."] \
-	-command [list [namespace current]::remove_group_dialog $connid $name] \
+	-command [list [namespace current]::remove_group_dialog $xlib $name] \
 	-state $state
     $m add command -label [::msgcat::mc "Remove all users in group..."] \
-	-command [list [namespace current]::remove_users_group_dialog $connid $name]
+	-command [list [namespace current]::remove_users_group_dialog $xlib $name]
 
     set last [$m index end]
 
-    ::hook::run roster_group_popup_menu_hook $m $connid $name
+    ::hook::run roster_group_popup_menu_hook $m $xlib $name
 
     if {[$m index end] > $last} {
 	$m insert [expr $last + 1] separator
@@ -1806,29 +1805,29 @@
 
 ###############################################################################
 
-proc roster::remove_group_dialog {connid name} {
+proc roster::remove_group_dialog {xlib name} {
     set res [MessageDlg .remove_item -aspect 50000 -icon question -type user \
 		 -buttons {yes no} -default 0 -cancel 1 \
 		 -message [format [::msgcat::mc "Are you sure to remove group '%s' from roster?\
 \n(Users which are in this group only, will be in undefined group.)"] $name]]
 
     if {$res == 0} {
-	roster::send_rename_group $connid $name ""
+	roster::send_rename_group $xlib $name ""
     }
 }
 
-proc roster::remove_users_group_dialog {connid name} {
+proc roster::remove_users_group_dialog {xlib name} {
     set res [MessageDlg .remove_item -aspect 50000 -icon question -type user \
 		 -buttons {yes no} -default 0 -cancel 1 \
 		 -message [format [::msgcat::mc "Are you sure to remove all users in group '%s' from roster?\
 \n(Users which are in another groups too, will not be removed from the roster.)"] $name]]
 
     if {$res == 0} {
-	roster::send_remove_users_group $connid $name
+	roster::send_remove_users_group $xlib $name
     }
 }
 
-proc roster::rename_group_dialog {connid name} {
+proc roster::rename_group_dialog {xlib name} {
     global new_roster_group_name
 
     set new_roster_group_name $name
@@ -1842,7 +1841,7 @@
 	-separator 1 -anchor e -default 0 -cancel 1
 
     $w add -text [::msgcat::mc "OK"] -command \
-	[list [namespace current]::confirm_rename_group $w $connid $name]
+	[list [namespace current]::confirm_rename_group $w $xlib $name]
     $w add -text [::msgcat::mc "Cancel"] -command [list destroy $w]
 
     set p [$w getframe]
@@ -1857,16 +1856,16 @@
     $w draw
 }
 
-proc roster::confirm_rename_group {w connid name} {
+proc roster::confirm_rename_group {w xlib name} {
     global new_roster_group_name
     variable roster
 
     destroy $w
 
-    ::roster::send_rename_group $connid $name $new_roster_group_name
+    ::roster::send_rename_group $xlib $name $new_roster_group_name
 
-    set gid [list $connid $name]
-    set newgid [list $connid $new_roster_group_name]
+    set gid [list $xlib $name]
+    set newgid [list $xlib $new_roster_group_name]
 
     if {[info exists roster(collapsed,$gid)]} {
 	set roster(collapsed,$newgid) $roster(collapsed,$gid)
@@ -1915,21 +1914,21 @@
 
 ###############################################################################
 
-proc roster::add_group_custom_presence_menu {m connid name} {
+proc roster::add_group_custom_presence_menu {m xlib name} {
     set mm [menu $m.custom_presence -tearoff 0]
 
     $mm add command -label [::msgcat::mc "Available"] \
-	-command [list roster::send_custom_presence_group $connid $name available]
+	-command [list roster::send_custom_presence_group $xlib $name available]
     $mm add command -label [::msgcat::mc "Free to chat"] \
-	-command [list roster::send_custom_presence_group $connid $name chat]
+	-command [list roster::send_custom_presence_group $xlib $name chat]
     $mm add command -label [::msgcat::mc "Away"] \
-	-command [list roster::send_custom_presence_group $connid $name away]
+	-command [list roster::send_custom_presence_group $xlib $name away]
     $mm add command -label [::msgcat::mc "Extended away"] \
-	-command [list roster::send_custom_presence_group $connid $name xa]
+	-command [list roster::send_custom_presence_group $xlib $name xa]
     $mm add command -label [::msgcat::mc "Do not disturb"] \
-	-command [list roster::send_custom_presence_group $connid $name dnd]
+	-command [list roster::send_custom_presence_group $xlib $name dnd]
     $mm add command -label [::msgcat::mc "Unavailable"] \
-	-command [list roster::send_custom_presence_group $connid $name unavailable]
+	-command [list roster::send_custom_presence_group $xlib $name unavailable]
 
     $m add cascade -label [::msgcat::mc "Send custom presence"] -menu $mm
 }

Modified: trunk/tkabber/iq.tcl
===================================================================
--- trunk/tkabber/iq.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/iq.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -1,95 +1,50 @@
 # $Id$
 
-namespace eval iq {
+namespace eval ::iq {
     variable options
 
-    custom::defgroup IQ [::msgcat::mc "Info/Query options."] -group Tkabber
+    custom::defgroup IQ [::msgcat::mc "Info/Query options."] \
+	-group Tkabber
 
     custom::defvar options(show_iq_requests) 0 \
         [::msgcat::mc "Show IQ requests in the status line."] \
-	-group IQ -type boolean
+	-group IQ \
+	-type boolean
 
     custom::defvar options(shorten_iq_namespaces) 1 \
-        [::msgcat::mc "Strip leading \"http://jabber.org/protocol/\" from IQ namespaces in the status line."] \
-	-group IQ -type boolean
+        [::msgcat::mc "Strip leading \"http://jabber.org/protocol/\"\
+		       from IQ namespaces in the status line."] \
+	-group IQ \
+	-type boolean
 }
 
-proc iq::register_handler {type tag xmlns h} {
-    variable handler
-    variable supported_ns
+proc client:iq {xlib from type queries args} {
+    debugmsg iq "$xlib $from $type $queries $args"
 
-    set handler($type,$tag,$xmlns) $h
-    lappend supported_ns $xmlns
-    set supported_ns [lrmdups $supported_ns]
+    eval [list ::iq::process $xlib $from $type $queries] $args
 }
 
-proc iq::process_iq {connid from useid id type lang child} {
-    variable handler
+proc ::iq::process {xlib from type queries args} {
     variable options
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
+    if {$type != "set" && $type != "get"} return
 
-    set xmlns [jlib::wrapper:getattr $vars xmlns]
+    ::xmpp::xml::split [lindex $queries 0] tag xmlns attrs cdata subels
 
-    if {[info exists handler($type,$tag,$xmlns)]} {
-	set h $handler($type,$tag,$xmlns)
-    } elseif {[info exists handler($type,,$xmlns)]} {
-	set h $handler($type,,$xmlns)
-    }
-
     if {$options(show_iq_requests) && \
 	    ($from != "" && \
-	    !([string equal -nocase $from [jlib::connection_server $connid]] || \
-	      [string equal -nocase $from [jlib::connection_bare_jid $connid]] || \
-	      [string equal -nocase $from [jlib::connection_jid $connid]]))} {
+	    !([::xmpp::jid::equal $from [connection_server $xlib]] || \
+	      [::xmpp::jid::equal $from [connection_bare_jid $xlib]] || \
+	      [::xmpp::jid::equal $from [connection_jid $xlib]]))} {
+
 	set xmlns_short $xmlns
-	if {$options(shorten_iq_namespaces) &&
-		[string first "http://jabber.org/protocol/" $xmlns_short] == 0} {
-	    set xmlns_short [string range $xmlns_short 27 end]
+	if {$options(shorten_iq_namespaces)} {
+	    regexp "^http://jabber.org/protocol/(.*)" $xmlns -> xmlns
 	}
-	set_status [format [::msgcat::mc "%s request from %s"] $xmlns_short $from]
-    }
-    if {[info exists h]} {
-	set res [eval $h [list $connid $from $lang $child]]
 
-	if {$res != {}} {
-	    switch -- [lindex $res 0] {
-		result {
-		    debugmsg iq "IQREPLY: SENDING RESULT: $from; $useid; $id; $child"
-		    jlib::send_iq result [lindex $res 1] \
-			-to $from \
-			-connection $connid \
-			-id $id
-		}
-		error {
-		    debugmsg iq "IQREPLY: SENDING ERROR: $from; $useid; $id; $child"
-		    jlib::send_iq error \
-			[eval stanzaerror::error [lrange $res 1 end] -xml {$child}] \
-			-to $from \
-			-connection $connid \
-			-id $id
-		}
-		ignore {
-		    # Do nothing, swallow the request
-		}
-	    }
-	}
-    } else {
-	debugmsg iq "IQREPLY: SENDING 503: $from; $useid; $id; $child"
-	jlib::send_iq error \
-	    [stanzaerror::error cancel service-unavailable -xml $child] \
-	    -to $from \
-	    -connection $connid \
-	    -id $id
+	set_status [::msgcat::mc "%s request from %s" $xmlns $from]
     }
 }
 
-proc client:iqreply {connid from useid id type lang child} {
-    debugmsg iq "IQREPLY: $from; $useid; $id; $type; $lang; $child"
-
-    iq::process_iq $connid $from $useid $id $type $lang $child
-}
-
-
 plugins::load [file join plugins iq]
 

Modified: trunk/tkabber/itemedit.tcl
===================================================================
--- trunk/tkabber/itemedit.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/itemedit.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -2,9 +2,9 @@
 
 namespace eval itemedit {}
 
-proc itemedit::show_dialog {connid jid} {
+proc itemedit::show_dialog {xlib jid} {
     set allowed_name [jid_to_tag $jid]
-    set w .gredit_${connid}_$allowed_name
+    set w .gredit_${xlib}_$allowed_name
 
     if {[winfo exists $w]} {
 	destroy $w
@@ -16,7 +16,7 @@
 
     set f [$w getframe]
 
-    hook::run roster_itemedit_setup_hook $f $connid $jid
+    hook::run roster_itemedit_setup_hook $f $xlib $jid
 
     set g [[TitleFrame $f.gr -text [format [::msgcat::mc "Edit groups for %s"] $jid]] getframe]
     pack $f.gr -side top -expand yes -fill both
@@ -60,17 +60,17 @@
 
 
     $w add -text [::msgcat::mc "OK"] \
-	-command [list [namespace current]::commit_changes $gcl $connid $jid]
+	-command [list [namespace current]::commit_changes $gcl $xlib $jid]
     $w add -text [::msgcat::mc "Cancel"] -command [list destroy $w]
 
 
-    foreach group [roster::get_groups $connid \
+    foreach group [roster::get_groups $xlib \
 		       -nested $::ifacetk::roster::options(nested) \
 		       -delimiter $::ifacetk::roster::options(nested_delimiter)] {
 	$gal insert end $group
     }
 
-    foreach group [roster::itemconfig $connid $jid -group] {
+    foreach group [roster::itemconfig $xlib $jid -group] {
 	$gcl insert end $group
     }
 
@@ -81,7 +81,7 @@
     $w draw
 }
 
-proc itemedit::edit_item_setup_fallback {f connid jid} {
+proc itemedit::edit_item_setup_fallback {f xlib jid} {
     variable gra_name
 
     set tf [TitleFrame $f.name -text [format [::msgcat::mc "Edit nickname for %s"] $jid]]
@@ -96,18 +96,16 @@
     label $g.lname -text [::msgcat::mc "Nickname:"]
     set gn [entry $g.name -textvariable [namespace current]::gra_name]
 
-    set name [roster::itemconfig $connid $jid -name]
+    set name [roster::itemconfig $xlib $jid -name]
     if {$name == ""} {
         if {[info exists userinfo::userinfo(nickname,$jid)] && \
 		![cequal $userinfo::userinfo(nickname,$jid) ""]} {
 	   set name $userinfo::userinfo(nickname,$jid)
         } else {
 	    set name [node_from_jid $jid]
-	    jlib::send_iq get \
-		[jlib::wrapper:createtag vCard \
-		     -vars [list xmlns vcard-temp]] \
-		-to [node_and_server_from_jid [get_jid_of_user $connid $jid]] \
-		-connection $connid \
+	    ::xmpp::sendIQ $xlib get \
+		-query [::xmpp::xml::create vCard -xmlns vcard-temp] \
+		-to [node_and_server_from_jid [get_jid_of_user $xlib $jid]] \
 		-command [list [namespace current]::fetch_nickname $gn $name $jid]
 	}
     }
@@ -121,15 +119,15 @@
 hook::add roster_itemedit_setup_hook \
     [namespace current]::itemedit::edit_item_setup_fallback 100
 
-proc itemedit::prefs_user_menu {m connid jid} {
-    set rjid [roster::find_jid $connid $jid]
+proc itemedit::prefs_user_menu {m xlib jid} {
+    set rjid [roster::find_jid $xlib $jid]
     if {$rjid == ""} {
 	set state disabled
     } else {
 	set state normal
     }
     $m add command -label [::msgcat::mc "Edit item..."] \
-	-command [list [namespace current]::show_dialog $connid $rjid] \
+	-command [list [namespace current]::show_dialog $xlib $rjid] \
 	-state $state
 }
 
@@ -172,32 +170,32 @@
 }
 
 
-proc itemedit::commit_changes {grlist connid jid} {
-    hook::run roster_itemedit_commit_hook $connid $jid [$grlist get 0 end]
+proc itemedit::commit_changes {grlist xlib jid} {
+    hook::run roster_itemedit_commit_hook $xlib $jid [$grlist get 0 end]
 
     destroy [winfo toplevel $grlist]
 }
 
-proc itemedit::commit_changes_fallback {connid jid groups} {
+proc itemedit::commit_changes_fallback {xlib jid groups} {
     variable gra_name
 
-    roster::itemconfig $connid $jid \
+    roster::itemconfig $xlib $jid \
 	-name $gra_name \
 	-group $groups
-    roster::send_item $connid $jid
+    roster::send_item $xlib $jid
 }
 
 hook::add roster_itemedit_commit_hook \
     [namespace current]::itemedit::commit_changes_fallback 100
 
 proc itemedit::fetch_nickname {name_entry name jid res child} {
-    if {![winfo exists $name_entry] || ![cequal $res OK]} {
+    if {![winfo exists $name_entry] || ![string equal $res ok]} {
 	return
     }
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
+    ::xmpp::xml::split $child tag xmlns attrs cdata subels
 
-    foreach item $children {
+    foreach item $subels {
 	userinfo::parse_vcard_item $jid $item
     }
     if {[info exists userinfo::userinfo(nickname,$jid)] && \

Modified: trunk/tkabber/joingrdialog.tcl
===================================================================
--- trunk/tkabber/joingrdialog.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/joingrdialog.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -49,11 +49,11 @@
     }
 }
 
-proc join_group_dialog {args} {
-    global gr_nick gr_group gr_server gr_connid gr_passwd
+proc join_group_dialog {xlib args} {
+    global gr_nick gr_group gr_server gr_xlib gr_passwd
     global gr_nick_list gr_group_list gr_server_list
 
-    if {[llength [jlib::connections]] == 0} return
+    if {[llength [connections]] == 0} return
 
     set gr_passwd ""
     foreach {opt val} $args {
@@ -62,7 +62,6 @@
 	    -group      {set group $val}
 	    -nick       {set nick $val}
 	    -password   {set gr_passwd $val}
-	    -connection {set connid $val}
 	}
     }
 
@@ -91,23 +90,23 @@
 	set gr_nick $nick
 #	set gr_nick_list [update_combo_list $gr_nick_list $gr_nick 10]
     } else {
-	set gr_nick [get_group_nick ${gr_group}@$gr_server $gr_nick]
+	set gr_nick [get_group_nick [::xmpp::jid::jid $gr_group $gr_server ""] $gr_nick]
     }
-    if {![info exists connid]} {
-	set connid [jlib::route ${gr_group}@$gr_server]
+    if {$xlib == ""} {
+	set xlib [lindex [connections] 0]
     }
-    set gr_connid [jlib::connection_jid $connid]
+    set gr_xlib [connection_jid $xlib]
 
     pack_combo $gf 0 gr_group [::msgcat::mc "Group:"] -values $gr_group_list
     pack_combo $gf 1 gr_server [::msgcat::mc "Server:"] -values $gr_server_list
     pack_combo $gf 2 gr_nick [::msgcat::mc "Nick:"] -values $gr_nick_list
     pack_input $gf 3 gr_passwd [::msgcat::mc "Password:"] -width 30 -show *
 
-    if {[llength [jlib::connections]] > 1} {
-	foreach c [jlib::connections] {
-	    lappend connections [jlib::connection_jid $c]
+    if {[llength [connections]] > 1} {
+	foreach c [connections] {
+	    lappend connections [connection_jid $c]
 	}
-	pack_combo $gf 5 gr_connid [::msgcat::mc "Connection:"] \
+	pack_combo $gf 5 gr_xlib [::msgcat::mc "Connection:"] \
 	    -values $connections
     }
 
@@ -119,7 +118,7 @@
 }
 
 proc join_group1 {gw} {
-    global gr_nick gr_group gr_server gr_connid gr_passwd
+    global gr_nick gr_group gr_server gr_xlib gr_passwd
     global gr_nick_list gr_group_list gr_server_list
 
     destroy $gw
@@ -128,42 +127,41 @@
     set gr_group_list [update_combo_list $gr_group_list $gr_group 20]
     set gr_server_list [update_combo_list $gr_server_list $gr_server 10]
 
-    foreach c [jlib::connections] {
-	if {[jlib::connection_jid $c] == $gr_connid} {
-	    set connid $c
+    foreach c [connections] {
+	if {[connection_jid $c] == $gr_xlib} {
+	    set xlib $c
 	}
     }
-    if {![info exists connid]} {
-	set connid [jlib::route ${gr_group}@$gr_server]
+    if {![info exists xlib]} {
+	set xlib [lindex [connections] 0]
     }
 
-    join_group ${gr_group}@$gr_server \
+    join_group $xlib [::xmpp::jid::jid $gr_group $gr_server ""] \
 	       -nick $gr_nick \
 	       -password $gr_passwd \
-	       -connection $connid
+	       -connection $xlib
 }
 
-proc join_group {jid args} {
+proc join_group {xlib jid args} {
     global gr_nick
 
     set password ""
     foreach {opt val} $args {
 	switch -- $opt {
-	    -connection { set connid $val }
 	    -password   { set password $val }
 	    -nick       { set nick $val }
 	}
     }
-    if {![info exists connid]} {
-	set connid [jlib::route $jid]
+    if {$xlib == ""} {
+	set xlib [lindex [connections] 0]
     }
     if {![info exists nick]} {
 	set nick [get_group_nick $jid $gr_nick]
     }
 
-    set cw [chat::winid [chat::chatid $connid $jid]]
+    set cw [chat::winid [chat::chatid $xlib $jid]]
 
-    muc::join_group $connid $jid $nick $password
+    muc::join_group $xlib $jid $nick $password
 
     raise_win $cw
     focus -force $cw.input
@@ -186,12 +184,12 @@
 ###############################################################################
 
 proc joingroup_disco_node_menu_setup {m bw tnode data parentdata} {
-    lassign $data type connid jid node
-    lassign $parentdata ptype pconnid pjid pnode
+    lassign $data type xlib jid node
+    lassign $parentdata ptype pxlib pjid pnode
     switch -- $type {
 	item {
-	    set identities [disco::get_jid_identities $connid $jid $node]
-	    set pidentities [disco::get_jid_identities $pconnid $pjid $pnode]
+	    set identities [disco::get_jid_identities $xlib $jid $node]
+	    set pidentities [disco::get_jid_identities $pxlib $pjid $pnode]
 
 	    # JID with resource is not a room JID
 	    if {[node_and_server_from_jid $jid] != $jid} return
@@ -201,12 +199,11 @@
 	    }
 
 	    foreach id $identities {
-		if {[jlib::wrapper:getattr $id category] == "conference"} {
+		if {[::xmpp::xml::getAttr $id category] == "conference"} {
 		    $m add command -label [::msgcat::mc "Join group..."] \
-			-command [list join_group_dialog \
+			-command [list join_group_dialog $xlib \
 				       -server [server_from_jid $jid] \
-				       -group [node_from_jid $jid] \
-				       -connection $connid]
+				       -group [node_from_jid $jid]]
 		    break
 		}
 	    }

Modified: trunk/tkabber/login.tcl
===================================================================
--- trunk/tkabber/login.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/login.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -1,34 +1,38 @@
 # $Id$
 
+package require xmpp::dns
+package require xmpp::auth
 
-if {[lcontain [jlib::capabilities transport] tls]} {
+if {[catch {package require xmpp::starttls}]} {
+    set use_tls 0
+} else {
     set use_tls 1
-} else {
-    set use_tls 0
 }
 
-if {[lcontain [jlib::capabilities transport] compress]} {
+if {[catch {package require xmpp::compress}]} {
+    set have_compress 0
+} else {
     set have_compress 1
-} else {
-    set have_compress 0
 }
 
-if {[lcontain [jlib::capabilities auth] sasl]} {
+if {[catch {package require xmpp::sasl}]} {
+    set have_sasl 0
+} else {
     set have_sasl 1
-} else {
-    set have_sasl 0
 }
 
-if {[llength [jlib::capabilities proxy]] > 1} {
+if {[catch {package require pconnect::socks4}] && \
+	[catch {package require pconnect::socks5}] && \
+	[catch {package require pconnect::https}]} {
+    set have_proxy 0
+} else {
     set have_proxy 1
-} else {
-    set have_proxy 0
 }
 
-if {[lcontain [jlib::capabilities transport] http_poll]} {
+if {[catch {package require xmpp::transport::poll}]} {
+    set have_http_poll 0
+} else {
     set have_http_poll 1
-} else {
-    set have_http_poll 0
 }
 
 custom::defgroup Warnings [::msgcat::mc "Warning display options."] \
@@ -108,15 +112,16 @@
 }
 
 if {$have_proxy} {
-    set values {}
-    foreach type [jlib::capabilities proxy] {
-	switch -- $type {
-	    none   {lappend values none   [::msgcat::mc "None"]}
-	    socks4 {lappend values socks4 [::msgcat::mc "SOCKS4a"]}
-	    socks5 {lappend values socks5 [::msgcat::mc "SOCKS5"]}
-	    https  {lappend values https  [::msgcat::mc "HTTPS"]}
-	}
+    set values [list none [::msgcat::mc "None"]]
+    if {![catch {package present pconnect::https}]} {
+	lappend values https [::msgcat::mc "HTTPS"]
     }
+    if {![catch {package present pconnect::socks4}]} {
+	lappend values socks4 [::msgcat::mc "SOCKS4a"]
+    }
+    if {![catch {package present pconnect::socks5}]} {
+	lappend values socks5 [::msgcat::mc "SOCKS5"]
+    }
     custom::defvar loginconf(proxy) none \
 	[::msgcat::mc "Proxy type to connect."] \
 	-group Login -type options \
@@ -166,11 +171,11 @@
 	-group Login -type boolean
     custom::defvar loginconf(numberofpollkeys) 100 \
 	[::msgcat::mc "Number of HTTP poll client security keys to send\
-before creating new key sequence."] \
+		       before creating new key sequence."] \
 	-group Login -type integer
     custom::defvar loginconf(polltimeout) 0 \
 	[::msgcat::mc "Timeout for waiting for HTTP poll responses (if set\
-to zero, Tkabber will wait forever)."] \
+		       to zero, Tkabber will wait forever)."] \
 	-group Login -type integer
     custom::defvar loginconf(pollmin) 6000 \
 	[::msgcat::mc "Minimum poll interval."] \
@@ -214,34 +219,116 @@
 # [::msgcat::mc "Self signed certificate"]
 
 ######################################################################
+
+if {![info exists connections]} {
+    set connections {}
+}
+
+proc connections {} {
+    global connections
+
+    return $connections
+}
+
+proc add_to_connection {xlib} {
+    global connections
+
+    set idx [lsearch -exact $connections $xlib]
+    if {$idx < 0} {
+	lappend connections $xlib
+    }
+}
+
+hook::add connected_hook add_to_connection 1
+
+proc remove_from_connection {xlib} {
+    global connections
+
+    set idx [lsearch -exact $connections $xlib]
+    set connections [lreplace $connections $idx $idx]
+}
+
+hook::add predisconnected_hook remove_from_connection 1000
+
+proc connection_jid {xlib} {
+    global connjid
+    return $connjid($xlib)
+}
+
+proc connection_bare_jid {xlib} {
+    global connjid
+    return [::xmpp::jid::stripResource $connjid($xlib)]
+}
+
+proc connection_user {xlib} {
+    global connjid
+    return [::xmpp::jid::node $connjid($xlib)]
+}
+
+proc connection_server {xlib} {
+    global connjid
+    return [::xmpp::jid::server $connjid($xlib)]
+}
+
+proc connection_resource {xlib} {
+    global connjid
+    return [::xmpp::jid::resource $connjid($xlib)]
+}
+
+proc connection_requested_jid {xlib} {
+    global connrjid
+    return $connrjid($xlib)
+}
+
+proc connection_requested_user {xlib} {
+    global connrjid
+    return [::xmpp::jid::node $connrjid($xlib)]
+}
+
+proc connection_requested_server {xlib} {
+    global connrjid
+    return [::xmpp::jid::server $connrjid($xlib)]
+}
+
+proc connection_requested_resource {xlib} {
+    global connrjid
+    return [::xmpp::jid::resource $connrjid($xlib)]
+}
+
+######################################################################
+
 proc login {logindata} {
     global connect_error
     global login_after_time
     global login_after_id
 
     array set lc $logindata
-    set user $lc(user)@$lc(server)/$lc(resource)
-    if {[info exists login_after_id($user)]} {
-	after cancel $login_after_id($user)
-	unset login_after_id($user)
+
+    set jid [::xmpp::jid::normalize [::xmpp::jid::jid $lc(user) \
+						      $lc(server) \
+						      $lc(resource)]]
+    if {[info exists login_after_id($jid)]} {
+	after cancel $login_after_id($jid)
+	unset login_after_id($jid)
     }
+
     debugmsg login "Starting login"
-    if {[catch {login_connect $logindata} connid] > 0} {
+    if {[catch {login_connect $logindata} xlib] > 0} {
 	# Nasty thing has happened.
-	debugmsg login "Failed to connect: $connid"
+	debugmsg login "Failed to connect: $xlib"
 	if {$lc(connect_forever)} {
 	    login_retry $logindata
 	} else {
 	    if {[winfo exists .connect_err]} {
 		destroy .connect_err
 	    }
-	    if {[info exists connect_error($connid)]} {
-		set msg $connect_error($connid)
+	    if {[info exists connect_error($xlib)]} {
+		set msg $connect_error($xlib)
 	    } else {
-		set msg $connid
+		set msg $xlib
 	    }
 	    set res [MessageDlg .connect_err -width 600 -icon error \
-		-message [format [::msgcat::mc "Failed to connect: %s"] $msg] \
+		-message [::msgcat::mc "Failed to connect: %s" $msg] \
 		-type user -buttons [list abort [::msgcat::mc "Keep trying"]] \
 		-default 0 -cancel 0]
 	    if {$res} {
@@ -253,9 +340,9 @@
 	return
     }
     # OK, connected.
-    debugmsg login "Connect successful ($user) $connid"
+    debugmsg login "Connect successful ($jid) $xlib"
     set login_after_time 15000
-    login_login $logindata $connid
+    login_login $xlib $logindata
 }
 
 proc login_retry {logindata} {
@@ -269,15 +356,18 @@
 	set login_after_time [expr {$login_after_time * 2}]
     }
     array set lc $logindata
-    set user $lc(user)@$lc(server)/$lc(resource)
-    debugmsg login "Scheduling connect retry for $user in ${login_after_time}ms"
-    if {[info exists login_after_id($user)]} {
-	after cancel $login_after_id($user)
+
+    set jid [::xmpp::jid::normalize [::xmpp::jid::jid $lc(user) \
+						      $lc(server) \
+						      $lc(resource)]]
+    debugmsg login "Scheduling connect retry for $jid in ${login_after_time}ms"
+    if {[info exists login_after_id($jid)]} {
+	after cancel $login_after_id($jid)
     }
-    set login_after_id($user) [after $login_after_time [list login $logindata]]
+    set login_after_id($jid) [after $login_after_time [list login $logindata]]
 }
 
-proc client:tls_callback {connid args} {
+proc client:tls_callback {xlib args} {
     global tls_result tls_warnings
     global ssl_certificate_fields
     global tls_warning_info
@@ -292,7 +382,7 @@
 		return 1
 	    }
 	    set info [::msgcat::mc [string totitle $reason 0 0]]
-	    append tls_warning_info($connid) "$info\n"
+	    append tls_warning_info($xlib) "$info\n"
 	    if {!$tls_warnings} {
 		return 1
 	    }
@@ -343,185 +433,291 @@
     }
 }
 
+proc create_xlib {jid} {
+    global connhist connrjid connjid
+
+    set njid [::xmpp::jid::normalize $jid]
+    if {[info exists connhist($njid)]} {
+	if {[lsearch -exact [connections] $connhist($njid)] < 0} {
+	    set xlib $connhist($njid)
+	} else {
+	    set xlib [::xmpp::new -messagecommand    client:message    \
+				  -presencecommand   client:presence   \
+				  -iqcommand         client:iq         \
+				  -disconnectcommand client:disconnect \
+				  -statuscommand     client:status     \
+				  -errorcommand      client:error]
+	}
+    } else {
+	set xlib [::xmpp::new -messagecommand    client:message    \
+			      -presencecommand   client:presence   \
+			      -iqcommand         client:iq         \
+			      -disconnectcommand client:disconnect \
+			      -statuscommand     client:status     \
+			      -errorcommand      client:error]
+	set connhist($njid) $xlib
+    }
+
+    set connrjid($xlib) $jid
+    set connjid($xlib) $jid
+
+    return $xlib
+}
+
 proc login_connect {logindata} {
     global use_tls have_compress have_sasl have_http_poll have_proxy
     global tls_warning_info
+    global reconnect
 
     array set lc $logindata
 
-    set connid [jlib::new -user $lc(user) \
-			  -server $lc(server) \
-			  -resource $lc(resource)]
+    set jid [::xmpp::jid::jid $lc(user) \
+			      $lc(server) \
+			      $lc(resource)]
 
-    set tls_warning_info($connid) ""
+    set xlib [create_xlib $jid]
 
-    set args [list -password $lc(password) \
-		   -allowauthplain $lc(allowauthplain) \
-		   -allowgoogletoken $lc(allowgoogletoken)]
-    if {$have_sasl} {
-	lappend args -usesasl $lc(usesasl)
-    }
+    set tls_warning_info($xlib) ""
+    set reconnect($xlib) true
 
+    set ascii_server [idna::domain_toascii $lc(server)]
+
+    set args {}
+
     if {$have_proxy} {
 	if {($lc(proxy) != "none")} {
-	    lappend args -proxy $lc(proxy)
-	    lappend args -proxyhost $lc(proxyhost)
-	    lappend args -proxyport $lc(proxyport)
-	    lappend args -proxyusername $lc(proxyusername)
-	    lappend args -proxypassword $lc(proxypassword)
-	    lappend args -proxyuseragent $lc(proxyuseragent)
+	    lappend args -proxy     $lc(proxy)
+	    lappend args -host      $lc(proxyhost)
+	    lappend args -port      $lc(proxyport)
+	    lappend args -username  $lc(proxyusername)
+	    lappend args -password  $lc(proxypassword)
+	    lappend args -useragent $lc(proxyuseragent)
 	} else {
 	    lappend args -proxy ""
 	}
     }
 
-    set ascii_server [idna::domain_toascii $lc(server)]
-
     if {$have_http_poll && $lc(usehttppoll)} {
 	if {$lc(pollurl) != ""} {
 	    set url $lc(pollurl)
 	} else {
-	    set url [jlibdns::get_http_poll_url $ascii_server]
+	    set url [lindex [::xmpp::dns::resolveHTTPPoll $ascii_server] 0]
 	}
-	return [eval [list jlib::connect $connid \
-				-transport http_poll \
-				-polltimeout $lc(polltimeout) \
-				-pollint $lc(pollmin) \
-				-pollmin $lc(pollmin) \
-				-pollmax $lc(pollmax) \
-				-httpurl $url \
-				-httpusekeys $lc(usepollkeys) \
-				-httpnumkeys $lc(numberofpollkeys)] $args]
+
+	# TODO: Asynchronous connect
+	eval [list ::xmpp::connect $xlib \
+				   -transport poll \
+				   -timeout   $lc(polltimeout) \
+				   -int       $lc(pollmin) \
+				   -min       $lc(pollmin) \
+				   -max       $lc(pollmax) \
+				   -url       $url \
+				   -usekeys   $lc(usepollkeys) \
+				   -numkeys   $lc(numberofpollkeys)] \
+				   $args
+
+	return $xlib
     } else {
-	if {$have_compress && $lc(stream_options) == "compressed"} {
-	    lappend args -usecompression 1
-	}
-   
 	if {$lc(usealtserver)} {
 	    set hosts {}
 	} else {
-	    set hosts [jlibdns::get_addr_port $ascii_server]
+	    set hosts [::xmpp::dns::resolveXMPPClient $ascii_server]
 	    if {[lempty $hosts]} {
 		set hosts [list [list $ascii_server 5222]]
 	    }
 	}
 	set transport tcp
-	set sslopts {}
-	if {$use_tls} {
-	    switch -- $lc(stream_options) {
-		ssl {
-		    set usestarttls 0
-		    set transport tls
-		    # Do some heuristic.
-		    # Traditionally legacy SSL port is 5223,
-		    # so let's add 1 to all ports from SRV reply
-		    set hosts1 {}
-		    foreach hp $hosts {
-			lappend hosts1 \
-				[list [lindex $hp 0] \
-				      [expr {[lindex $hp 1] + 1}]]
-		    }
-		    set hosts $hosts1
-		}
-		encrypted {
-		    set usestarttls 1
-		}
-		default {
-		    set usestarttls 0
-		}
+	if {$use_tls && $lc(stream_options) == "ssl"} {
+	    set transport tls
+	    # Do some heuristic.
+	    # Traditionally legacy SSL port is 5223,
+	    # so let's add 1 to all ports from SRV reply
+	    set hosts1 {}
+	    foreach hp $hosts {
+		lassign $hp host port
+		lappend hosts1 [list $host [incr port]]
 	    }
-	    set sslopts [list -usestarttls $usestarttls \
-	                      -certfile $lc(sslcertfile) \
-			      -cacertstore $lc(sslcacertstore) \
-			      -keyfile $lc(sslkeyfile)]
+	    set hosts $hosts1
+	    lappend args -certfile $lc(sslcertfile) \
+			 -castore  $lc(sslcacertstore) \
+			 -keyfile  $lc(sslkeyfile) \
+			 -callback [list client:tls_callback $xlib]
 	}
 
 	if {$lc(usealtserver)} {
-	    set hosts [list [list [idna::domain_toascii $lc(altserver)] $lc(altport)]]
+	    set hosts [list [list [idna::domain_toascii $lc(altserver)] \
+			    $lc(altport)]]
 	}
 
-	return [eval [list jlib::connect $connid \
-				-transport $transport \
-				-hosts $hosts] \
-				$sslopts $args]
+	# TODO: Asynchronous connect
+	foreach hp $hosts {
+	    lassign $hp host port
+
+	    set code \
+		[catch {
+		    eval [list ::xmpp::connect $xlib $host $port \
+					       -transport $transport] \
+					       $args
+		 } msg]
+	    set info $::errorInfo
+
+	    if {!$code} {
+		return $xlib
+	    }
+	}
+
+	return -code $code -errorinfo $info $msg
     }
 }
 
 ########################################################################
 
-proc login_login {logindata connid} {
+proc login_login {xlib logindata} {
+    global use_tls have_compress have_sasl
     global loginconf_hist
     global gr_nick gr_server gra_server
 
+    set loginconf_hist($xlib) $logindata
+
     array set lc $logindata
-    set loginconf_hist($connid) $logindata
 
     set gr_nick $lc(user)
     set gr_server conference.$lc(server)
     set gra_server conference.$lc(server)
 
-    jlib::login $connid [list recv_auth_result $connid $logindata]
+    if {($use_tls && $lc(stream_options) == "encrypted") || \
+	    ($have_compress && $lc(stream_options) == "compressed") || \
+	    ($have_sasl && $lc(usesasl))} {
+	::xmpp::openStream $xlib $lc(server) \
+			   -version 1.0 \
+			   -command [list login_login1 $xlib $logindata]
+    } else {
+	::xmpp::openStream $xlib $lc(server) \
+			   -command [list login_login1 $xlib $logindata]
+    }
 }
 
-########################################################################
+proc login_login1 {xlib logindata status sessionid} {
+    global use_tls have_compress
 
-set reconnect_retries 0
+    if {$status != "ok"} {
+	recv_auth_result $xlib $logindata $status $sessionid
+	return
+    }
 
-proc logout {{connid {}}} {
-    global reconnect_retries
-    global login_after_id
+    array set lc $logindata
 
-    debugmsg login "LOGOUT $connid"
+    if {$use_tls && $lc(stream_options) == "encrypted"} {
+	::xmpp::starttls::starttls $xlib \
+			-command  [list login_login2 $xlib $logindata] \
+			-certfile $lc(sslcertfile) \
+			-castore  $lc(sslcacertstore) \
+			-keyfile  $lc(sslkeyfile) \
+			-callback [list client:tls_callback $xlib]
+    } elseif {$have_compress && $lc(stream_options) == "compressed"} {
+	::xmpp::compress::compress $xlib \
+			-command     [list login_login2 $xlib $logindata]
+    } else {
+	login_login2 $xlib $logindata $status $sessionid
+    }
+}
 
-    # TODO
-    foreach user [array names login_after_id] {
-	after cancel $login_after_id($user)
-	unset login_after_id($user)
+proc login_login2 {xlib logindata status sessionid} {
+    global have_sasl
+
+    if {$status != "ok"} {
+	recv_auth_result $xlib $logindata $status $sessionid
+	return
     }
 
-    if {$connid == {}} {
-	foreach connid [jlib::connections] {
-	    disconnected $connid
-	}
+    array set lc $logindata
+
+    if {$lc(allowauthplain)} {
+	set digest auto
     } else {
-	disconnected $connid
+	set digest true
     }
 
-    set reconnect_retries 0
+    if {$lc(allowgoogletoken)} {
+	set disable {}
+    } else {
+	set disable {X-GOOGLE-TOKEN}
+    }
+
+    if {$have_sasl && $lc(usesasl)} {
+	# SASL authentication
+        ::xmpp::sasl::auth $xlib -username $lc(user) \
+                                 -password $lc(password) \
+                                 -resource $lc(resource) \
+				 -digest   $digest \
+				 -disable  $disable \
+				 -command  [list recv_auth_result $xlib \
+								 $logindata]
+    } else {
+	# Non-SASL authentication
+        ::xmpp::auth::auth $xlib -sessionid $sessionid \
+                                 -username  $lc(user) \
+                                 -password  $lc(password) \
+                                 -resource  $lc(resource) \
+				 -digest    $digest \
+				 -command [list recv_auth_result $xlib \
+								 $logindata]
+    }
 }
 
-proc client:disconnect {connid} {
-    logout $connid
+########################################################################
+
+proc logout {{xlib {}}} {
+    debugmsg login "LOGOUT $xlib"
+
+    if {$xlib == {}} {
+	foreach xlib [connections] {
+	    disconnected $xlib
+	}
+    } else {
+	disconnected $xlib
+    }
 }
 
-# TODO
-proc client:reconnect {connid} {
-    global reconnect_retries
+proc client:disconnect {xlib} {
+    global reconnect
     global loginconf_hist
 
-    debugmsg login "RECONNECT $connid"
 
-    disconnected $connid
+    if {$reconnect($xlib)} {
+	debugmsg login "RECONNECT $xlib"
+    } else {
+	debugmsg login "DISCONNECT $xlib"
+    }
 
-    if {[incr reconnect_retries] <= 3} {
-        after 1000 [list login $loginconf_hist($connid)]
+    disconnected $xlib
+
+    if {$reconnect($xlib)} {
+	after 1000 [list login $loginconf_hist($xlib)]
     }
 }
 
-proc connected {connid logindata} {
-    hook::run connected_hook $connid
+proc connected {xlib logindata} {
+    hook::run connected_hook $xlib
 }
 
 # TODO
-proc disconnected {connid} {
+proc disconnected {xlib} {
     global curuserstatus userstatusdesc
+    global login_after_id
 
-    hook::run predisconnected_hook $connid
+    set jid [::xmpp::jid::normalize [connection_requested_jid $xlib]]
+    if {[info exists login_after_id($jid)]} {
+	after cancel $login_after_id($jid)
+	unset login_after_id($jid)
+    }
 
-    jlib::disconnect $connid
-    roster::clean_connection $connid
+    hook::run predisconnected_hook $xlib
 
-    if {[jlib::connections] == {}} {
+    ::xmpp::disconnect $xlib
+    roster::clean $xlib
+
+    if {[connections] == {}} {
 	set_status "Disconnected"
 
 	set curuserstatus unavailable
@@ -529,64 +725,90 @@
 	hook::run change_our_presence_post_hook unavailable
     }
 
-    hook::run disconnected_hook $connid
+    hook::run disconnected_hook $xlib
 }
 
-proc recv_auth_result {connid logindata res args} {
+proc recv_auth_result {xlib logindata res xml} {
+    global connjid
+
     array set lc $logindata
 
-    if {$res == "OK"} {
-	connected $connid $logindata
+    if {$res == "ok"} {
+	set connjid($xlib) $xml
+	connected $xlib $logindata
     } else {
-	if {[winfo exists .auth_err$connid]} {
-	    destroy .auth_err$connid
-	}
-	lassign [error_type_condition [lindex $args 0]] type cond
+	lassign [error_type_condition $xml] type cond
 	if {($type == "sasl") || ($type == "auth" && $cond == "not-authorized")} {
-	    set res [MessageDlg .auth_err$connid -aspect 50000 -icon error \
-			 -message [format \
-			     [::msgcat::mc "Authentication failed: %s\nCreate new account?"] \
-			     [error_to_string [lindex $args 0]]] \
+	    set res [MessageDlg [epath] -aspect 50000 -icon error \
+			 -message [::msgcat::mc "Authentication failed:\
+						 %s\nCreate new account?" \
+						[error_to_string $xml]] \
 			 -type user -buttons {yes no} -default 0 -cancel 1]
 	    if {!$res} {
-		jlib::send_iq set \
-		    [jlib::wrapper:createtag query \
-			 -vars {xmlns jabber:iq:register} \
-			 -subtags [list [jlib::wrapper:createtag username \
-					     -chdata $lc(user)] \
-					[jlib::wrapper:createtag password \
-					     -chdata $lc(password)]]] \
-		    -connection $connid \
-		    -command [list recv_register_result $connid $logindata]
+		::xmpp::sendIQ $xlib set \
+		    -query [::xmpp::xml::create query \
+				-xmlns jabber:iq:register \
+				-subelement [::xmpp::xml::create username \
+						    -cdata $lc(user)] \
+				-subelement [::xmpp::xml::create password \
+						    -cdata $lc(password)]] \
+		    -command [list recv_register_result $xlib $logindata]
 		return
 	    }
 	} else {
-	    MessageDlg .auth_err$connid -aspect 50000 -icon error \
-		-message [format \
-			     [::msgcat::mc "Authentication failed: %s"] \
-			     [error_to_string [lindex $args 0]]] \
+	    MessageDlg [epath] -aspect 50000 -icon error \
+		-message [::msgcat::mc "Authentication failed: %s" \
+				       [error_to_string $xml]] \
 		-type user -buttons {ok} -default 0 -cancel 0
 	}
-	logout $connid
+	logout $xlib
     }
 }
 
-proc recv_register_result {connid logindata res args} {
-    if {$res == "OK"} {
-	jlib::disconnect $connid
+proc recv_register_result {xlib logindata res xml} {
+    if {$res == "ok"} {
+	::xmpp::disconnect $xlib
 	login $logindata
     } else {
-	if {[winfo exists .auth_err$connid]} {
-	    destroy .auth_err$connid
-	}
-	MessageDlg .auth_err$connid -aspect 50000 -icon error \
-	    -message [format [::msgcat::mc "Registration failed: %s"] \
-			  [error_to_string [lindex $args 0]]] \
+	MessageDlg [epath] -aspect 50000 -icon error \
+	    -message [::msgcat::mc "Registration failed: %s" \
+				   [error_to_string $xml]] \
 	    -type user -buttons ok -default 0 -cancel 0
-	logout $connid
+	logout $xlib
     }
 }
 
+proc client:error {xlib condition message} {
+    global reconnect
+
+    if {[winfo exists .client_error]} {
+	destroy .client_error
+    }
+
+    switch -- $condition {
+	bad-format -
+	bad-namespace-prefix -
+	connection-timeout -
+	invalid-from -
+	invalid-id -
+	invalid-namespace -
+	invalid-xml -
+	remote-connection-failed -
+	restricted-xml -
+	unsupported-encoding -
+	unsupported-stanza-type -
+	xml-not-well-formed {
+	    set reconnect($xlib) true
+	}
+	default {
+	    set reconnect($xlib) false
+	}
+    }
+
+    MessageDlg .client_error -aspect 50000 -icon error \
+	-message $message -type user -buttons ok -default 0 -cancel 0
+}
+
 # TODO
 proc change_password_dialog {} {
     global oldpassword newpassword password
@@ -631,7 +853,7 @@
 }
 
 # TODO
-proc send_change_password {} {
+proc send_change_password {xlib} {
     global loginconf
     global oldpassword newpassword password
 
@@ -648,17 +870,14 @@
 	return
     }
 
-    set connid [jlib::route $loginconf(server)]
-
-    jlib::send_iq set \
-	    [jlib::wrapper:createtag query \
-		    -vars {xmlns jabber:iq:register} \
-		    -subtags [list [jlib::wrapper:createtag username \
-					-chdata $loginconf(user)] \
-				   [jlib::wrapper:createtag password \
-					-chdata $password]]] \
+    ::xmpp::sendIQ $xlib set \
+	    -query [::xmpp::xml::create query \
+		    -xmlns jabber:iq:register \
+		    -subtelement [::xmpp::xml::create username \
+					-cdata $loginconf(user)] \
+		    -subelement  [::xmpp::xml::create password \
+					-cdata $password]] \
 	    -to $loginconf(server) \
-	    -connection $connid \
 	    -command recv_change_password_result
 }
 
@@ -667,7 +886,7 @@
     global loginconf
     global newpassword
 
-    if {$res == "OK"} {
+    if {$res == "ok"} {
 	MessageDlg .shpasswd_result -aspect 50000 -icon info \
 		-message [::msgcat::mc "Password is changed"] \
 		-type user -buttons ok -default 0 -cancel 0
@@ -689,7 +908,8 @@
 	set loginconf(password) $newpassword
     } else {
 	MessageDlg .shpasswd_result -aspect 50000 -icon error \
-	    -message [format [::msgcat::mc "Password change failed: %s"] [error_to_string [lindex $args 0]]] \
+	    -message [::msgcat::mc "Password change failed: %s" \
+				   [error_to_string [lindex $args 0]]] \
 	    -type user -buttons ok -default 0 -cancel 0
     }
 }

Modified: trunk/tkabber/messages.tcl
===================================================================
--- trunk/tkabber/messages.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/messages.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -16,10 +16,10 @@
     disco::register_feature jabber:x:oob
 }
 
-proc message::process_message {connid from id type is_subject subject body err thread priority x} {
+proc message::process_message {xlib from id type is_subject subject body err thread priority x} {
     switch -- $type {
 	normal {
-	    show_dialog $connid $from $id $type $subject $body $thread $priority $x
+	    show_dialog $xlib $from $id $type $subject $body $thread $priority $x
 	    return stop
 	}
     }
@@ -29,12 +29,12 @@
 hook::add process_message_hook \
     [namespace current]::message::process_message 98
 
-proc message::show_dialog {connid from id type subject body thread priority x {replyP 1}} {
+proc message::show_dialog {xlib from id type subject body thread priority x {replyP 1}} {
     variable msgid
 
     if {$type == "normal"} {
         ::message_archive::log_message \
-	    $from [jlib::connection_jid $connid] \
+	    $from [connection_jid $xlib] \
             $subject $body $x
     }
 
@@ -58,9 +58,9 @@
     if {$replyP} {
         set bbox [ButtonBox $mw.bottom.buttons -spacing 10 -padx 10]
 	$bbox add -text [::msgcat::mc "Reply"] \
-	    -command [list message::send $mw -connection $connid]
+	    -command [list message::send $mw $xlib]
         $bbox add -text [::msgcat::mc "Chat"] \
-	    -command "chat::open_to_user $connid [list $from]
+	    -command "chat::open_to_user [list $xlib] [list $from]
                       destroy $mw"
         $bbox add -text [::msgcat::mc "Close"] -command [list destroy $mw]
         bind $mw <Control-Return> "ButtonBox::invoke $bbox 0"
@@ -92,16 +92,16 @@
     pack $mw.title -side top -anchor w -fill x -expand yes -in $mw.frame
     grid columnconfigure $mw.title 1 -weight 1
 
-    if {[llength [jlib::connections]] > 1} {
+    if {[llength [connections]] > 1} {
 	label $mw.title.lconnection -text [::msgcat::mc "Received by:"]
-	label $mw.title.connection -text " [jlib::connection_jid $connid]"
+	label $mw.title.connection -text " [connection_jid $xlib]"
 	grid $mw.title.lconnection -row 0 -column 0 -sticky e
 	grid $mw.title.connection  -row 0 -column 1 -sticky w
     }
 
     label $mw.title.lab -text $title
     menubutton $mw.title.mb -text $from -menu $mw.title.mb.menu
-    subject_menu $mw.title.mb.menu $connid $from message
+    subject_menu $mw.title.mb.menu $xlib $from message
     grid $mw.title.lab -row 1 -column 0 -sticky e
     grid $mw.title.mb  -row 1 -column 1 -sticky w
 
@@ -143,7 +143,7 @@
     incr row
     set last $row
     hook::run message_process_x_hook row body \
-	      $mw.rf $x $connid $from $id $type $replyP
+	      $mw.rf $x $xlib $from $id $type $replyP
 
     if {(!$replyP) && ($row == $last)} {
         destroy $mw
@@ -202,7 +202,7 @@
 
         focus $mw.body
 
-	hook::run open_message_post_hook $mw $connid $from
+	hook::run open_message_post_hook $mw $xlib $from
     }
 
     BWidget::place $mw 0 0 center
@@ -215,21 +215,20 @@
     $mw.body insert insert "\n"
 }
 
-proc message::process_x {rowvar bodyvar f x connid from id type replyP} {
+proc message::process_x {rowvar bodyvar f x xlib from id type replyP} {
     upvar 2 $rowvar row
     upvar 2 $bodyvar body
 
     foreach xa $x {
-	jlib::wrapper:splitxml $xa tag vars isempty chdata children
+	::xmpp::xml::split $xa tag xmlns attrs cdata subels
 
-	set xmlns [jlib::wrapper:getattr $vars xmlns]
 	switch -- $xmlns \
 	    jabber:x:oob {
-		set row [process_x_oob $f $children $row $from]
+		set row [process_x_oob $f $subels $row $from]
 	    } \
 	    $::NS(data) {
 		if {![lempty $children]} {
-		    process_x_data $f $connid $from $xa
+		    process_x_data $f $xlib $from $xa
 		}
 	    } \
 	}
@@ -243,12 +242,12 @@
     set desc ""
     set url ""
     foreach item $x {
-        jlib::wrapper:splitxml $item tag vars isempty chdata children   
+        ::xmpp::xml::split $item tag xmlns attrs cdata subels
 
         switch -- $tag {
             desc -
 	    url {
-                set $tag $chdata
+                set $tag $cdata
             }
         }
     }
@@ -269,21 +268,19 @@
     return $row
 }
 
-proc message::process_x_data {f connid from x} {
-    data::draw_window [list $x] [list message::send_x_data $connid $from]
+proc message::process_x_data {f xlib from x} {
+    data::draw_window [list $x] [list message::send_x_data $xlib $from]
 }
 
-proc message::send_x_data {connid to w restags} {
-    #set f $w.fields
-    #set restags [data::get_tags $f]
-    jlib::send_msg $to -xlist $restags -connection $connid
+proc message::send_x_data {xlib to w restags} {
+    ::xmpp::sendMessage $xlib $to -xlist $restags
     destroy $w
 }
 
-proc message::send_dialog_item {m connid jid} {
+proc message::send_dialog_item {m xlib jid} {
     $m add command -label [::msgcat::mc "Send message..."] \
 	-command [list message::send_dialog \
-		       -to $jid -connection $connid]
+		       -to $jid -connection $xlib]
 }
 
 hook::add roster_jid_popup_menu_hook message::send_dialog_item 15
@@ -300,9 +297,9 @@
 proc message::send_dialog {args} {
     variable msgid
     variable message_dest_list
-    variable send_dialog_connid
+    variable send_dialog_xlib
 
-    if {[lempty [jlib::connections]]} return
+    if {[lempty [connections]]} return
 
     set to ""
     set subject ""
@@ -315,28 +312,24 @@
 	    -thread { set thread $val }
 	    -group { set group $val }
 	    -connection {
-		set connid $val
+		set xlib $val
 		set cstate disabled
 	    }
 	}
     }
 
-    if {![info exists connid]} {
-	if {$group} {
-	    set connid [jlib::route ""]
-	} else {
-	    set connid [jlib::route $to]
-	}
+    if {![info exists xlib]} {
+	set xlib [lindex [connections] 0]
     }
 
     set mw .msgsend[incr msgid]
     toplevel $mw -class Message
     wm group $mw .
 
-    set send_dialog_connid($mw) [jlib::connection_jid $connid]
+    set send_dialog_xlib($mw) [connection_jid $xlib]
 
     if {![info exists thread]} {
-	set thread [generate_thread $send_dialog_connid($mw) $to]
+	set thread [generate_thread $send_dialog_xlib($mw) $to]
     }
 
     if {$group} {
@@ -369,7 +362,7 @@
 
     set bbox [ButtonBox $mw.bottom.buttons -spacing 10 -padx 10]
     $bbox add -text [::msgcat::mc "Send"] \
-	-command [list message::send $mw -group $group -connection $connid]
+	-command [list message::send $mw $xlib -group $group]
     $bbox add -text [::msgcat::mc "Cancel"] -command [list destroy $mw]
     bind $mw <Control-Return> "ButtonBox::invoke $bbox 0"
     bind $mw <Escape> "ButtonBox::invoke $bbox 1"
@@ -387,13 +380,13 @@
     grid columnconfigure $mw.f 1 -weight 1
 
     set connections {}
-    if {[llength [jlib::connections]] > 1} {
-	foreach c [jlib::connections] {
-	    lappend connections [jlib::connection_jid $c]
+    if {[llength [connections]] > 1} {
+	foreach c [connections] {
+	    lappend connections [connection_jid $c]
 	}
 	label $mw.f.lconnection -text [::msgcat::mc "From: "]
 	ComboBox $mw.f.connection \
-	    -textvariable [namespace current]::send_dialog_connid($mw) \
+	    -textvariable [namespace current]::send_dialog_xlib($mw) \
 	    -values $connections \
 	    -state $cstate
 
@@ -402,10 +395,10 @@
     }
 
     if {$group} {
-	# TODO reflect changes in connid
+	# TODO reflect changes in xlib
 	label $mw.f.lto -text [::msgcat::mc "Group: "]
 	ComboBox $mw.f.to -text $to \
-	    -values [roster::get_groups $connid \
+	    -values [roster::get_groups $xlib \
 			 -nested $::ifacetk::roster::options(nested) \
 			 -delimiter $::ifacetk::roster::options(nested_delimiter) \
 			 -undefined 1]
@@ -446,52 +439,44 @@
         focus $mw.f.to
     }
 
-    hook::run open_message_post_hook $mw $connid $to
+    hook::run open_message_post_hook $mw $xlib $to
 
     BWidget::place $mw 0 0 center
     wm deiconify $mw
 }
 
 proc message::send0 {mw args} {
-    variable send_dialog_connid
+    variable send_dialog_xlib
     
-    foreach c [jlib::connections] {
-	if {[jlib::connection_jid $c] == $send_dialog_connid($mw)} {
-	    set connid $c
+    foreach c [connections] {
+	if {[connection_jid $c] == $send_dialog_xlib($mw)} {
+	    set xlib $c
 	}
     }
-    unset send_dialog_connid($mw)
+    unset send_dialog_xlib($mw)
 
-    if {![info exists connid]} {
-	eval [list send $mw] $args
-    } else {
-	eval [list send $mw -connection $connid] $args
-    }
+    eval [list send $mw $xlib] $args
 }
 
-proc message::send {mw args} {
+proc message::send {mw xlib args} {
     variable message_dest_list
 
     set group 0
     foreach {opt val} $args {
 	switch -- $opt {
 	    -group { set group $val }
-	    -connection { set connid $val }
 	}
     }
 
     set jid [$mw.f.to cget -text]
     
     if {$group} {
-	set jids [roster::get_group_jids $connid $jid \
+	set jids [roster::get_group_jids $xlib $jid \
 		      -nested $::ifacetk::roster::options(nested) \
 		      -delimiter $::ifacetk::roster::options(nested_delimiter)]
     } else {
 	set message_dest_list [update_combo_list $message_dest_list $jid 20]
 	set jids [list $jid]
-	if {![info exists connid]} {
-	    set connid [jlib::route $jid]
-	}
     }
 
     set thread [$mw.thread cget -text]
@@ -499,28 +484,23 @@
     set body [$mw.body get 1.0 {end -1 chars}]
 
     foreach jid $jids {
-	if {!$group || [::roster::itemconfig $connid $jid -isuser]} {
-	    send_msg $jid -type normal \
-		-subject $subj -body $body -thread $thread \
-		-connection $connid
+	if {!$group || [::roster::itemconfig $xlib $jid -isuser]} {
+	    send_msg $xlib $jid -type normal \
+		-subject $subj -body $body -thread $thread
 	}
     }
 
     destroy $mw
 }
 
-proc message::send_msg {to args} {
+proc message::send_msg {xlib to args} {
     array set params [list -xlist {}]
     array set params $args
 
-    set command [list jlib::send_msg $to]
+    set command [list ::xmpp::sendMessage $xlib $to]
     set xs $params(-xlist)
     unset params(-xlist)
 
-    if {![info exists params(-connection)]} {
-	set params(-connection) [jlib::route $to]
-    }
-
     if {[info exists params(-body)]} {
         set log_body $params(-body)
         foreach tag [list signed encrypted] {
@@ -528,14 +508,14 @@
                 continue
             }
 
-            if {[catch { ssj::${tag}:output $params(-connection) $params(-body) $to } chdata]} {
+            if {[catch { ssj::${tag}:output $xlib $params(-body) $to } chdata]} {
                 debugmsg message "ssj::${tag}:output: $chdata"
                 return [list error ssj]
             }
             
             if {![cequal $chdata ""]} {
-                lappend xs [jlib::wrapper:createtag x \
-                                -vars "xmlns jabber:x:$tag" -chdata $chdata]
+                lappend xs [::xmpp::xml::create x \
+                                -xmlns jabber:x:$tag -cdata $chdata]
                 if {[cequal $tag encrypted]} {
                     set params(-body) [::msgcat::mc "This message is encrypted."]
                 }
@@ -561,7 +541,7 @@
 
     if {(![info exists params(-type)]) || ($params(-type) == "normal") } {
         ::message_archive::log_message \
-	    [jlib::connection_jid $params(-connection)] \
+	    [connection_jid $xlib] \
             $to $log_subject $log_body $xs
     }
 
@@ -576,7 +556,7 @@
 
 ###############################################################################
 
-proc message::show_subscribe_dialog {connid from type x args} {
+proc message::show_subscribe_dialog {xlib from type x args} {
     variable msgid
 
     if {$type != "subscribe"} return
@@ -604,9 +584,9 @@
 
     set bbox [ButtonBox $mw.buttons -spacing 0 -padx 10 -default 0]
     $bbox add -text [::msgcat::mc "Approve subscription"] \
-	      -command [list [namespace current]::subscribe $mw $connid $from]
+	      -command [list [namespace current]::subscribe $mw $xlib $from]
     $bbox add -text [::msgcat::mc "Decline subscription"] \
-	      -command [list [namespace current]::unsubscribe $mw $connid $from]
+	      -command [list [namespace current]::unsubscribe $mw $xlib $from]
     bind $mw <Return> "ButtonBox::invoke $bbox default"
     bind $mw <Escape> "ButtonBox::invoke $bbox 1"
     pack $bbox -side bottom -anchor e -padx 2m -pady 2m
@@ -621,9 +601,9 @@
     pack $mw.subj -side top -anchor w -fill x -expand yes -in $mw.frame
     grid columnconfigure $mw.subj 1 -weight 1
 
-    if {[llength [jlib::connections]] > 1} {
+    if {[llength [connections]] > 1} {
 	label $mw.subj.lconnection -text [::msgcat::mc "Received by:"]
-	label $mw.subj.connection -text " [jlib::connection_jid $connid]"
+	label $mw.subj.connection -text " [connection_jid $xlib]"
 	grid $mw.subj.lconnection -row 0 -column 0 -sticky e
 	grid $mw.subj.connection  -row 0 -column 1 -sticky w
     }
@@ -631,7 +611,7 @@
 
     label $mw.subj.lab -text [::msgcat::mc "Subscription request from:"]
     menubutton $mw.subj.mb -text $from -menu $mw.subj.mb.menu
-    subject_menu $mw.subj.mb.menu $connid $from subscribe
+    subject_menu $mw.subj.mb.menu $xlib $from subscribe
     grid $mw.subj.lab -row 1 -column 0 -sticky e
     grid $mw.subj.mb  -row 1 -column 1 -sticky w
 
@@ -662,7 +642,7 @@
 
 ###############################################################################
 
-proc message::show_unsubscribed_dialog {connid from type x args} {
+proc message::show_unsubscribed_dialog {xlib from type x args} {
     variable msgid
 
     if {$type != "unsubscribed"} return
@@ -677,15 +657,15 @@
 
 ###############################################################################
 
-proc message::subscribe {mw connid jid} {
-    jlib::send_presence -to $jid -type subscribed -connection $connid
+proc message::subscribe {mw xlib jid} {
+    ::xmpp::sendPresence $xlib -to $jid -type subscribed
 
-    switch -- [roster::itemconfig $connid \
+    switch -- [roster::itemconfig $xlib \
 				  [tolower_node_and_domain $jid] -subsc] {
         {}   -
         none -
         from {
-            message::send_subscribe_dialog $jid -connection $connid
+            message::send_subscribe_dialog $jid -connection $xlib
         }
     }
 
@@ -694,14 +674,14 @@
 
 ###############################################################################
 
-proc message::unsubscribe {mw connid jid} {
-    ::roster::remove_item $connid [tolower_node_and_domain $jid]
+proc message::unsubscribe {mw xlib jid} {
+    ::roster::remove_item $xlib [tolower_node_and_domain $jid]
     destroy $mw
 }
 
 ###############################################################################
 
-proc message::destroy_subscription_dialogs {connid jid name groups subsc ask} {
+proc message::destroy_subscription_dialogs {xlib jid name groups subsc ask} {
     switch -- $subsc {
 	both -
 	from {}
@@ -723,14 +703,14 @@
 ###############################################################################
 
 proc message::disco_popup_menu {m bw tnode data parentdata} {
-    lassign $data type connid jid node
+    lassign $data type xlib jid node
     switch -- $type {
 	item {
-	    set identities [disco::get_jid_identities $connid $jid $node]
+	    set identities [disco::get_jid_identities $xlib $jid $node]
 
 	    foreach id $identities {
-		if {[jlib::wrapper:getattr $id category] == "client"} {
-		    subject_menu $m $connid $jid message
+		if {[::xmpp::xml::getAttr $id category] == "client"} {
+		    subject_menu $m $xlib $jid message
 		    break
 		}
 	    }
@@ -743,20 +723,20 @@
 
 ###############################################################################
 
-proc message::subject_menu {m connid jid type} {
+proc message::subject_menu {m xlib jid type} {
     if {[winfo exists $m]} {
         destroy $m          
     }                       
     menu $m -tearoff 0
 
-    hook::run message_dialog_menu_hook $m $connid $jid
+    hook::run message_dialog_menu_hook $m $xlib $jid
 
     return $m
 }   
 
 ###############################################################################
 
-proc message::add_separator {m connid jid} {
+proc message::add_separator {m xlib jid} {
     $m add separator
 }
 
@@ -767,10 +747,10 @@
 
 ###############################################################################
 
-proc message::add_subscribe_menu_item {m connid jid} {
-    set chatid [chat::chatid $connid [node_and_server_from_jid $jid]]
+proc message::add_subscribe_menu_item {m xlib jid} {
+    set chatid [chat::chatid $xlib [node_and_server_from_jid $jid]]
     if {[chat::is_groupchat $chatid]} {
-	set real_jid [muc::get_real_jid $connid $jid]
+	set real_jid [muc::get_real_jid $xlib $jid]
 	if {$real_jid != ""} {
 	    set jid $real_jid
 	    set state normal
@@ -781,13 +761,13 @@
 	set state normal
     }
     set user [node_and_server_from_jid $jid]
-    if {[roster::itemconfig $connid $user -subsc] != ""} {
+    if {[roster::itemconfig $xlib $user -subsc] != ""} {
 	set state disabled
     }
     $m add command -label [::msgcat::mc "Add user to roster..."] \
 		   -state $state \
 		   -command [list message::send_subscribe_dialog $user \
-				  -connection $connid]
+				  -connection $xlib]
 }
 
 hook::add chat_create_user_menu_hook \
@@ -801,24 +781,24 @@
 
 proc message::send_subscribe_dialog {to args} {
     variable msgid
-    variable send_subscribe_connid
+    variable send_subscribe_xlib
 
-    if {[lempty [jlib::connections]]} return
+    if {[lempty [connections]]} return
 
     set cstate normal
 
     foreach {opt val} $args {
 	switch -- $opt {
 	    -connection {
-		set connid $val
+		set xlib $val
 		set cstate disabled
 	    }
 	}
     }
-    if {![info exists connid]} {
-	set connid [jlib::route $to]
+    if {![info exists xlib]} {
+	set xlib [lindex [connections] 0]
     }
-    set send_subscribe_connid [jlib::connection_jid $connid]
+    set send_subscribe_xlib [connection_jid $xlib]
 
     set mw .subscsend[incr msgid]
     toplevel $mw -class Message
@@ -852,13 +832,13 @@
     grid columnconfigure $mw.subj 1 -weight 1
 
     set connections {}
-    if {[llength [jlib::connections]] > 1} {
-	foreach c [jlib::connections] {
-	    lappend connections [jlib::connection_jid $c]
+    if {[llength [connections]] > 1} {
+	foreach c [connections] {
+	    lappend connections [connection_jid $c]
 	}
 	label $mw.subj.lconnection -text [::msgcat::mc "From: "]
 	ComboBox $mw.subj.connection \
-	    -textvariable [namespace current]::send_subscribe_connid \
+	    -textvariable [namespace current]::send_subscribe_xlib \
 	    -values $connections \
 	    -state $cstate
 
@@ -892,46 +872,32 @@
 ###############################################################################
 
 proc message::send_subscribe0 {mw} {
-    variable send_subscribe_connid
+    variable send_subscribe_xlib
 
-    foreach c [jlib::connections] {
-	if {[jlib::connection_jid $c] == $send_subscribe_connid} {
-	    set connid $c
+    foreach c [connections] {
+	if {[connection_jid $c] == $send_subscribe_xlib} {
+	    set xlib $c
 	}
     }
-    if {![info exists connid]} {
-	send_subscribe $mw
-    } else {
-	send_subscribe $mw -connection $connid
-    }
+
+    send_subscribe $mw $xlib
 }
 
 ###############################################################################
 
-proc message::send_subscribe {mw args} {
+proc message::send_subscribe {mw xlib args} {
     set jid [$mw.subj.entry get]
     
-    foreach {opt val} $args {
-	switch -- $opt {
-	    -connection { set connid $val }
-	}
-    }
-    if {![info exists connid]} {
-	set connid [jlib::route $jid]
-    }
+    ::xmpp::sendPresence $xlib -to $jid -type subscribe \
+        -status [$mw.body get 1.0 end]
 
-    jlib::send_presence -to $jid -type subscribe \
-        -stat [$mw.body get 1.0 end] \
-	-connection $connid
-
-    jlib::send_iq set \
-        [jlib::wrapper:createtag query \
-             -vars {xmlns jabber:iq:roster} \
-             -subtags [list [jlib::wrapper:createtag item \
-                                 -vars [list jid $jid]]]] \
+    ::xmpp::sendIQ $xlib set \
+        -query [::xmpp::xml::create query \
+		    -xmlns jabber:iq:roster \
+		    -subelement [::xmpp::xml::create item \
+					-attrs [list jid $jid]]] \
         -command "itemedit::show_dialog \
-                      [list $connid [tolower_node_and_domain $jid]] ;#" \
-	-connection $connid
+                      [list $xlib [tolower_node_and_domain $jid]] ;#"
 
     destroy $mw
 
@@ -939,8 +905,8 @@
 
 ###############################################################################
 
-proc message::resubscribe_menu_item {m connid jid} {
-    set rjid [roster::find_jid $connid $jid]
+proc message::resubscribe_menu_item {m xlib jid} {
+    set rjid [roster::find_jid $xlib $jid]
     if {$rjid == ""} {
 	set state disabled
     } else {
@@ -948,15 +914,13 @@
     }
     set mm [menu $m.subscription -tearoff 0]
     $mm add command -label [::msgcat::mc "Request subscription"] \
-	-command [list jlib::send_presence \
+	-command [list ::xmpp::sendPresence $xlib \
 		      -to $rjid \
-		      -type subscribe \
-		      -connection $connid]
+		      -type subscribe]
     $mm add command -label [::msgcat::mc "Grant subscription"] \
-	-command [list jlib::send_presence \
+	-command [list ::xmpp::sendPresence $xlib \
 		      -to $rjid \
-		      -type subscribed \
-		      -connection $connid]
+		      -type subscribed]
 
     $m add cascad -label [::msgcat::mc "Subscription"] \
 		  -menu $mm \

Modified: trunk/tkabber/msgs/ru.msg
===================================================================
--- trunk/tkabber/msgs/ru.msg	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/msgs/ru.msg	2008-10-17 17:16:09 UTC (rev 1520)
@@ -2218,7 +2218,7 @@
 }
 
 proc ru_format_time {t} {
-    if {[cequal $t ""]} {
+    if {[string equal $t ""]} {
 	return
     }
 

Modified: trunk/tkabber/msgs/uk.msg
===================================================================
--- trunk/tkabber/msgs/uk.msg	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/msgs/uk.msg	2008-10-17 17:16:09 UTC (rev 1520)
@@ -1482,7 +1482,7 @@
     }
 }
 proc uk_format_time {t} {
-    if {[cequal $t ""]} {
+    if {[string equal $t ""]} {
 	return
     }
     set sec [expr {$t % 60}]

Modified: trunk/tkabber/muc.tcl
===================================================================
--- trunk/tkabber/muc.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/muc.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -65,50 +65,50 @@
 
 ###############################################################################
 
-proc muc::add_groupchat_user_menu_items {m connid jid} {
+proc muc::add_groupchat_user_menu_items {m xlib jid} {
     set group [node_and_server_from_jid $jid]
 
     if {![is_compatible $group]} return
 
     set mm [menu $m.muc -tearoff 0]
     $mm add command -label [::msgcat::mc "Whois"] \
-	-command [list muc::whois $connid $jid]
+	-command [list muc::whois $xlib $jid]
     $mm add command -label [::msgcat::mc "Kick"] \
 	-command [list muc::change_item_param \
-		      {role none} down $connid $jid ""]
+		      {role none} down $xlib $jid ""]
     $mm add command -label [::msgcat::mc "Ban"] \
 	-command [list muc::change_item_param \
-		      {affiliation outcast} down $connid $jid ""]
+		      {affiliation outcast} down $xlib $jid ""]
     $mm add command -label [::msgcat::mc "Grant Voice"] \
 	-command [list muc::change_item_param \
-		      {role participant} up $connid $jid ""]
+		      {role participant} up $xlib $jid ""]
     $mm add command -label [::msgcat::mc "Revoke Voice"] \
 	-command [list muc::change_item_param \
-		      {role visitor} down $connid $jid ""]
+		      {role visitor} down $xlib $jid ""]
     $mm add command -label [::msgcat::mc "Grant Membership"] \
 	-command [list muc::change_item_param \
-		      {affiliation member} up $connid $jid ""]
+		      {affiliation member} up $xlib $jid ""]
     $mm add command -label [::msgcat::mc "Revoke Membership"] \
 	-command [list muc::change_item_param \
-		      {affiliation none} down $connid $jid ""]
+		      {affiliation none} down $xlib $jid ""]
     $mm add command -label [::msgcat::mc "Grant Moderator Privileges"] \
 	-command [list muc::change_item_param \
-		      {role moderator} up $connid $jid ""]
+		      {role moderator} up $xlib $jid ""]
     $mm add command -label [::msgcat::mc "Revoke Moderator Privileges"] \
 	-command [list muc::change_item_param \
-		      {role participant} down $connid $jid ""]
+		      {role participant} down $xlib $jid ""]
     $mm add command -label [::msgcat::mc "Grant Admin Privileges"] \
 	-command [list muc::change_item_param \
-		      {affiliation admin} up $connid $jid ""]
+		      {affiliation admin} up $xlib $jid ""]
     $mm add command -label [::msgcat::mc "Revoke Admin Privileges"] \
 	-command [list muc::change_item_param \
-		      {affiliation member} down $connid $jid ""]
+		      {affiliation member} down $xlib $jid ""]
     #$mm add command -label [::msgcat::mc "Grant Owner Privileges"] \
     #    -command [list muc::change_item_param \
-    #    	      {affiliation owner} up $connid $jid ""]
+    #    	      {affiliation owner} up $xlib $jid ""]
     #$mm add command -label [::msgcat::mc "Revoke Owner Privileges"] \
     #    -command [list muc::change_item_param \
-    #		      {affiliation admin} down $connid $jid ""]
+    #		      {affiliation admin} down $xlib $jid ""]
 
     $m add cascade -label [::msgcat::mc "MUC"] -menu $mm
 }
@@ -118,8 +118,8 @@
 
 ###############################################################################
 
-proc muc::create_conference_menu_items {m connid jid} {
-    set chatid [chat::chatid $connid $jid]
+proc muc::create_conference_menu_items {m xlib jid} {
+    set chatid [chat::chatid $xlib $jid]
 
     set idx [expr {[$m index end] + 1}]
 
@@ -169,15 +169,15 @@
 }
 
 proc muc::disco_node_menu_setup {m bw tnode data parentdata} {
-    lassign $data type connid jid node
-    lassign $parentdata ptype pconnid pjid pnode
+    lassign $data type xlib jid node
+    lassign $parentdata ptype pxlib pjid pnode
     switch -- $type {
 	item {
-	    set identities [disco::get_jid_identities $connid $jid $node]
-	    set pidentities [disco::get_jid_identities $pconnid $pjid $pnode]
+	    set identities [disco::get_jid_identities $xlib $jid $node]
+	    set pidentities [disco::get_jid_identities $pxlib $pjid $pnode]
 
-	    set features [disco::get_jid_features $connid $jid $node]
-	    set pfeatures [disco::get_jid_features $pconnid $pjid $pnode]
+	    set features [disco::get_jid_features $xlib $jid $node]
+	    set pfeatures [disco::get_jid_features $pxlib $pjid $pnode]
 
 	    # JID with resource is not a room JID
 	    if {[node_and_server_from_jid $jid] != $jid} return
@@ -194,10 +194,10 @@
 	    }
 
 	    foreach id $identities {
-		if {[jlib::wrapper:getattr $id category] == "conference"} {
+		if {[::xmpp::xml::getAttr $id category] == "conference"} {
 		    foreach f $features {
-			if {[jlib::wrapper:getattr $f var] == $::NS(muc)} {
-			    add_muc_menu_items $m [chat::chatid $connid $jid] end
+			if {[::xmpp::xml::getAttr $f var] == $::NS(muc)} {
+			    add_muc_menu_items $m [chat::chatid $xlib $jid] end
 			    return
 			}
 		    }
@@ -214,7 +214,7 @@
 proc muc::handle_commands {chatid user body type} {
     if {$type != "groupchat"} return
 
-    set connid [chat::get_connid $chatid]
+    set xlib [chat::get_xlib $chatid]
     set group [chat::get_jid $chatid]
     if {[cequal [crange $body 0 5] "/kick "]} {
 	set params {role none}
@@ -226,11 +226,11 @@
 	lassign [parse_nick_reason $body 5] nick reason
     } elseif {[cequal [crange $body 0 6] "/unban "]} {
 	set jid [parse_nick $body 7]
-	unban $connid $group $jid
+	unban $xlib $group $jid
 	return stop
     } elseif {[cequal [crange $body 0 6] "/whois "]} {
 	set nick [parse_nick $body 7]
-	whois $connid $group/$nick
+	whois $xlib $group/$nick
 	return stop
     } elseif {[cequal [crange $body 0 6] "/voice "]} {
 	set params {role participant}
@@ -268,7 +268,7 @@
 	return
     }
     
-    change_item_param $params $dir $connid $group/$nick $reason
+    change_item_param $params $dir $xlib $group/$nick $reason
 
     return stop
 }
@@ -315,23 +315,23 @@
 
 ###############################################################################
 
-proc muc::get_real_jid {connid jid} {
+proc muc::get_real_jid {xlib jid} {
     variable users
 
-    if {[info exists users(jid,$connid,$jid)] && \
-	    $users(jid,$connid,$jid) != ""} {
-	return $users(jid,$connid,$jid)
+    if {[info exists users(jid,$xlib,$jid)] && \
+	    $users(jid,$xlib,$jid) != ""} {
+	return $users(jid,$xlib,$jid)
     } else {
 	return ""
     } 
 }
 
-proc muc::whois {connid user} {
+proc muc::whois {xlib user} {
     set group [node_and_server_from_jid $user]
-    set chatid [chat::chatid $connid $group]
-    set nick [chat::get_nick $connid $user groupchat]
+    set chatid [chat::chatid $xlib $group]
+    set nick [chat::get_nick $xlib $user groupchat]
 
-    set real_jid [get_real_jid $connid $user]
+    set real_jid [get_real_jid $xlib $user]
 
     if {$real_jid != ""} {
 	chat::add_message $chatid $group info \
@@ -360,16 +360,16 @@
     expr {$idx1 - $idx2}
 }
 
-proc muc::change_item_param {params dir connid user reason} {
+proc muc::change_item_param {params dir xlib user reason} {
     variable users
 
     set group [node_and_server_from_jid $user]
-    set chatid [chat::chatid $connid $group]
-    set nick  [chat::get_nick $connid $user groupchat]
+    set chatid [chat::chatid $xlib $group]
+    set nick  [chat::get_nick $xlib $user groupchat]
 
     lassign $params key val
-    if {![catch { set aff $users(affiliation,$connid,$user) }] && \
-	    ![catch { set role $users(role,$connid,$user) }]} {
+    if {![catch { set aff $users(affiliation,$xlib,$user) }] && \
+	    ![catch { set role $users(role,$xlib,$user) }]} {
 	switch -- $key/$dir {
 	    affiliation/up {
 		if {[compare_affs $aff $val] >= 0} {
@@ -411,61 +411,58 @@
 
     set itemsubtags {}
     if {$reason != ""} {
-	lappend itemsubtags [jlib::wrapper:createtag reason \
-				 -chdata $reason]
+	lappend itemsubtags [::xmpp::xml::create reason -cdata $reason]
     }
     set vars [list nick $nick]
     if {$params == {affiliation outcast}} {
 	# For unknown reason banning request MUST be based on
 	# user's bare JID (which may be not known by admin)
-	set real_jid [get_real_jid $connid $user]
+	set real_jid [get_real_jid $xlib $user]
 	if {$real_jid != ""} {
 	    set vars [list jid [node_and_server_from_jid $real_jid]]
 	}
 	
     }
-    set item [jlib::wrapper:createtag item \
-		  -vars [concat $vars $params] \
-		  -subtags $itemsubtags]
+    set item [::xmpp::xml::create item \
+		  -attrs [concat $vars $params] \
+		  -subelements $itemsubtags]
 
-    jlib::send_iq set \
-	[jlib::wrapper:createtag query \
-	     -vars [list xmlns $::NS(muc#admin)] \
-	     -subtags [list $item]] \
+    ::xmpp::sendIQ $xlib set \
+	-query [::xmpp::xml::create query \
+			-xmlns $::NS(muc#admin) \
+			-subelement $item] \
 	-to $group \
-	-connection $connid \
-	-command [list muc::test_error_res "$params $nick" $connid $group]
+	-command [list muc::test_error_res "$params $nick" $xlib $group]
 }
 
 ###############################################################################
 
-proc muc::unban {connid group jid} {
-    jlib::send_iq get \
-	[jlib::wrapper:createtag query \
-	     -vars [list xmlns $::NS(muc#admin)] \
-	     -subtags [list [jlib::wrapper:createtag item \
-				 -vars {affiliation outcast}]]] \
+proc muc::unban {xlib group jid} {
+    ::xmpp::sendIQ $xlib get \
+	-query [::xmpp::xml::create query \
+			-xmlns $::NS(muc#admin) \
+			-subelement [::xmpp::xml::create item \
+					    -attrs {affiliation outcast}]] \
 	-to $group \
-	-connection $connid \
-	-command [list muc::unban_continue $connid $group $jid]
+	-command [list muc::unban_continue $xlib $group $jid]
 }
 
-proc muc::unban_continue {connid group jid res child} {
-    if {$res != "OK"} {
-	chat::add_message [chat::chatid $connid $group] $group error \
+proc muc::unban_continue {xlib group jid res child} {
+    if {$res != "ok"} {
+	chat::add_message [chat::chatid $xlib $group] $group error \
 	    "affiliation none $jid: [error_to_string $child]" {}
 	return
     }
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
+    ::xmpp::xml::split $child tag xmlns attrs cdata subels
 
     set jid [node_and_server_from_jid $jid]
     set found 0
-    foreach item $children {
-	jlib::wrapper:splitxml $item tag1 vars1 isempty1 chdata1 children1
-	switch -- $tag1 {
+    foreach item $subels {
+	::xmpp::xml::split $item stag sxmlns sattrs scdata ssubels
+	switch -- $stag {
 	    item {
-		set jid1 [jlib::wrapper:getattr $vars1 jid]
+		set jid1 [::xmpp::xml::getAttr $sattrs jid]
 		if {$jid == $jid1} {
 		    set found 1
 		    break
@@ -475,38 +472,37 @@
     }
 
     if {!$found} {
-	chat::add_message [chat::chatid $connid $group] $group error \
+	chat::add_message [chat::chatid $xlib $group] $group error \
 	    "affiliation none $jid: User is not banned" {}
 	return
     }
 
-    set item [jlib::wrapper:createtag item \
-		  -vars [list jid $jid affiliation none]]
+    set item [::xmpp::xml::create item \
+		  -attrs [list jid $jid affiliation none]]
 
-    jlib::send_iq set \
-	[jlib::wrapper:createtag query \
-	     -vars [list xmlns $::NS(muc#admin)] \
-	     -subtags [list $item]] \
+    ::xmpp::sendIQ $xlib set \
+	-query [::xmpp::xml::create query \
+			-xmlns $::NS(muc#admin) \
+			-subelement $item] \
 	-to $group \
-	-connection $connid \
-	-command [list muc::test_unban_res $connid $group $jid]
+	-command [list muc::test_unban_res $xlib $group $jid]
 }
 
-proc muc::test_unban_res {connid group jid res child} {
-    if {$res != "OK"} {
-	chat::add_message [chat::chatid $connid $group] $group error \
+proc muc::test_unban_res {xlib group jid res child} {
+    if {$res != "ok"} {
+	chat::add_message [chat::chatid $xlib $group] $group error \
 	    "affiliation none $jid: [error_to_string $child]" {}
 	return
     }
 
-    chat::add_message [chat::chatid $connid $group] $group info \
+    chat::add_message [chat::chatid $xlib $group] $group info \
 	"affiliation none $jid: User is unbanned" {}
 }
 
 ###############################################################################
 
 proc muc::request_destruction_dialog {chatid alt reason} {
-    set connid [chat::get_connid $chatid]
+    set xlib [chat::get_xlib $chatid]
     set group [chat::get_jid $chatid]
 
     set warning \
@@ -523,7 +519,7 @@
 }
 
 proc muc::request_destruction {chatid alt reason} {
-    set connid [chat::get_connid $chatid]
+    set xlib [chat::get_xlib $chatid]
     set group [chat::get_jid $chatid]
 
     if {$alt != ""} {
@@ -532,49 +528,43 @@
 	set vars {}
     }
 
-    jlib::send_iq set \
-	[jlib::wrapper:createtag query \
-	     -vars [list xmlns $::NS(muc#owner)] \
-	     -subtags [list \
-			   [jlib::wrapper:createtag destroy \
-				-vars $vars \
-				-subtags [list \
-					      [jlib::wrapper:createtag reason \
-						   -chdata $reason]]]]] \
+    ::xmpp::sendIQ $xlib set \
+	-query [::xmpp::xml::create query \
+		    -xmlns $::NS(muc#owner) \
+		    -subelement [::xmpp::xml::create destroy \
+					-attrs $vars \
+					-subelement [::xmpp::xml::create reason \
+							    -cdata $reason]]] \
 	-to $group \
-	-connection $connid \
-	-command [list muc::test_error_res "destroy" $connid $group]
+	-command [list muc::test_error_res "destroy" $xlib $group]
 }
 
 ###############################################################################
 
 proc muc::request_list {attr val chatid} {
-    set connid [chat::get_connid $chatid]
+    set xlib [chat::get_xlib $chatid]
     set group [chat::get_jid $chatid]
-    jlib::send_iq get \
-	[jlib::wrapper:createtag query \
-	     -vars [list xmlns $::NS(muc#admin)] \
-	     -subtags [list [jlib::wrapper:createtag item \
-				 -vars [list $attr $val]]]] \
+    ::xmpp::sendIQ $xlib get \
+	-query [::xmpp::xml::create query \
+			-xmlns $::NS(muc#admin) \
+			-subelement [::xmpp::xml::create item \
+					-attrs [list $attr $val]]] \
 	-to $group \
-	-connection $connid \
 	-command [list muc::receive_list $attr $val $chatid]
 }
 
 
 proc muc::receive_list {attr val chatid res child} {
-    set connid [chat::get_connid $chatid]
+    set xlib [chat::get_xlib $chatid]
     set group [chat::get_jid $chatid]
-    if {![cequal $res OK]} {
+    if {![string equal $res ok]} {
 	chat::add_message $chatid $group error \
 	    "$attr $val list: [error_to_string $child]" {}
 	return
     }
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
+    ::xmpp::xml::split $child tag xmlns attrs cdata subels
 
-    #data::draw_window $children [list muc::send_list $role $group]
-
     variable winid
 
     set w .muc_list$winid
@@ -594,7 +584,7 @@
     set sf [ScrollableFrame $w.fields -constrainedwidth yes]
     set f [$sf getframe]
     $sw setwidget $sf
-    fill_list $sf $f $children $attr $val
+    fill_list $sf $f $subels $attr $val
     list_add_item $sf $f $attr $val
  
     $w add -text [::msgcat::mc "Send"] \
@@ -703,18 +693,18 @@
 
     set items2 {}
     foreach item $items {
-	jlib::wrapper:splitxml $item tag vars isempty chdata children
+	::xmpp::xml::split $item tag xmlns attrs cdata subels
 	switch -- $tag {
 	    item {
-		set nick [jlib::wrapper:getattr $vars nick]
-		set jid [jlib::wrapper:getattr $vars jid]
-		set role [jlib::wrapper:getattr $vars role]
-		set affiliation [jlib::wrapper:getattr $vars affiliation]
+		set nick [::xmpp::xml::getAttr $attrs nick]
+		set jid [::xmpp::xml::getAttr $attrs jid]
+		set role [::xmpp::xml::getAttr $attrs role]
+		set affiliation [::xmpp::xml::getAttr $attrs affiliation]
 		set reason ""
-		foreach subitem $children {
-		    jlib::wrapper:splitxml $subitem tag1 vars1 isempty1 chdata1 children1
-		    if {$tag1 == "reason"} {
-			set reason $chdata1
+		foreach subitem $subels {
+		    ::xmpp::xml::split $subitem stag sxmlns sattrs scdata ssubels
+		    if {$stag == "reason"} {
+			set reason $scdata
 		    }
 		}
 		lappend items2 [list $nick $jid $role $affiliation $reason]
@@ -856,12 +846,12 @@
 	    set itemsubtags {}
 	    set reason $listdata($f,reason,$i)
 	    if {$reason != ""} {
-	        lappend itemsubtags [jlib::wrapper:createtag reason \
-	        			 -chdata $reason]
+	        lappend itemsubtags [::xmpp::xml::create reason \
+	        			 -cdata $reason]
 	    }
-	    lappend items [jlib::wrapper:createtag item \
-			       -vars $vars \
-			       -subtags $itemsubtags]
+	    lappend items [::xmpp::xml::create item \
+			       -attrs $vars \
+			       -subelements $itemsubtags]
 	}
     }
 
@@ -883,27 +873,27 @@
 	    set itemsubtags {}
 	    set reason $listdata($f,reason,$i)
 	    if {$reason != ""} {
-	        lappend itemsubtags [jlib::wrapper:createtag reason \
-	        			 -chdata $reason]
+	        lappend itemsubtags [::xmpp::xml::create reason \
+	        			 -cdata $reason]
 	    }
-	    lappend items [jlib::wrapper:createtag item \
-			       -vars $vars \
-			       -subtags $itemsubtags]
+	    lappend items [::xmpp::xml::create item \
+			       -attrs $vars \
+			       -subelements $itemsubtags]
 	}
     }
 
-    set connid [chat::get_connid $chatid]
+    set xlib [chat::get_xlib $chatid]
     set group [chat::get_jid $chatid]
 
     if {$items != {}} {
-	jlib::send_iq set [jlib::wrapper:createtag query \
-			       -vars [list xmlns $::NS(muc#admin)] \
-			       -subtags $items] \
+	::xmpp::sendIQ $xlib set \
+	    -query [::xmpp::xml::create query \
+			       -xmlns $::NS(muc#admin) \
+			       -subelements $items] \
 	    -to $group \
-	    -connection $connid \
 	    -command [list muc::test_error_res \
 			   [::msgcat::mc "Sending %s %s list" $attr $val] \
-			   $connid $group]
+			   $xlib $group]
     }
     destroy $w
 }
@@ -950,78 +940,76 @@
 }
 
 proc muc::request_instant_room {chatid} {
-    jlib::send_iq set \
-	[jlib::wrapper:createtag query \
-	     -vars [list xmlns $::NS(muc#owner)] \
-	     -subtags [list [jlib::wrapper:createtag x \
-				 -vars [list xmlns $::NS(data) \
-					     type submit]]]] \
-	-to [chat::get_jid $chatid] \
-	-connection [chat::get_connid $chatid]
+    ::xmpp::sendIQ [chat::get_xlib $chatid] set \
+	-query [::xmpp::xml::create query \
+			-xmlns $::NS(muc#owner) \
+			-subelement [::xmpp::xml::create x \
+					-xmlns $::NS(data) \
+					-attrs [list type submit]]] \
+	-to [chat::get_jid $chatid]
 }
 
 proc muc::request_config {chatid} {
-    jlib::send_iq get \
-	[jlib::wrapper:createtag query \
-	     -vars [list xmlns $::NS(muc#owner)]] \
+    ::xmpp::sendIQ [chat::get_xlib $chatid] get \
+	-query [::xmpp::xml::create query \
+			-xmlns $::NS(muc#owner)] \
 	-to [chat::get_jid $chatid] \
-	-connection [chat::get_connid $chatid] \
 	-command [list muc::receive_config $chatid]
 }
 
 proc muc::receive_config {chatid res child} {
     set group [chat::get_jid $chatid]
-    if {![cequal $res OK]} {
+    if {![string equal $res ok]} {
 	chat::add_message $chatid $group error \
 	    [::msgcat::mc "Configure form: %s" [error_to_string $child]] \
 	    {}
 	return
     }
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
+    ::xmpp::xml::split $child tag xmlns attrs cdata subels
 
-    data::draw_window $children [list muc::send_config $chatid] \
-				[list muc::cancel_config $chatid]
+    data::draw_window $subels [list muc::send_config $chatid] \
+			      [list muc::cancel_config $chatid]
     return
 }
 
 ###############################################################################
 
 proc muc::send_config {chatid w restags} {
-    set connid [chat::get_connid $chatid]
+    set xlib [chat::get_xlib $chatid]
     set group [chat::get_jid $chatid]
-    jlib::send_iq set [jlib::wrapper:createtag query \
-			   -vars [list xmlns $::NS(muc#owner)] \
-			   -subtags $restags] \
+    ::xmpp::sendIQ $xlib set \
+	-query [::xmpp::xml::create query \
+			   -xmlns $::NS(muc#owner) \
+			   -subelements $restags] \
 	-to $group \
-	-connection $connid \
 	-command [list muc::test_error_res \
-		       [::msgcat::mc "Sending configure form"] $connid $group]
+		       [::msgcat::mc "Sending configure form"] $xlib $group]
     destroy $w
 }
 
 ###############################################################################
 
 proc muc::cancel_config {chatid w} {
-    set connid [chat::get_connid $chatid]
+    set xlib [chat::get_xlib $chatid]
     set group [chat::get_jid $chatid]
-    jlib::send_iq set [jlib::wrapper:createtag query \
-			   -vars [list xmlns $::NS(muc#owner)] \
-			   -subtags [list [jlib::wrapper:createtag x \
-					       -vars [list xmlns jabber:x:data \
-							   type cancel]]]] \
+    ::xmpp::sendIQ $xlib set \
+	-query [::xmpp::xml::create query \
+			   -xmlns $::NS(muc#owner) \
+			   -subelement [::xmpp::xml::create x \
+					       -xmlns jabber:x:data \
+					       -attrs [list type cancel]]] \
 	-to $group \
-	-connection $connid \
 	-command [list muc::test_error_res \
-		       [::msgcat::mc "Cancelling configure form"] $connid $group]
+		       [::msgcat::mc "Cancelling configure form"] $xlib $group]
     destroy $w
 }
 
 ###############################################################################
 
-proc muc::test_error_res {op connid group res child} {
-    if {![cequal $res OK]} {
-	set chatid [chat::chatid $connid $group]
+proc muc::test_error_res {op xlib group res child} {
+    if {![string equal $res ok]} {
+	set chatid [chat::chatid $xlib $group]
 	chat::add_message $chatid $group error \
 	    [format "%s: %s" $op [error_to_string $child]] {}
 	return
@@ -1030,14 +1018,14 @@
 
 ###############################################################################
 
-proc muc::process_presence {connid from type x args} {
+proc muc::process_presence {xlib from type x args} {
     switch -- $type {
 	available -
 	unavailable {
 	    foreach xs $x {
-		jlib::wrapper:splitxml $xs tag vars isempty chdata children
-		if {[jlib::wrapper:getattr $vars xmlns] == $::NS(muc#user)} {
-		    process_muc_user $connid $from $type $children
+		::xmpp::xml::split $xs tag xmlns attrs cdata subels
+		if {$xmlns == $::NS(muc#user)} {
+		    process_muc_user $xlib $from $type $subels
 		    break
 		}
 	    }
@@ -1049,30 +1037,29 @@
 
 ###############################################################################
 
-proc muc::process_muc_user {connid user type childrens} {
+proc muc::process_muc_user {xlib user type children} {
     variable users
     variable options
 
-    foreach child $childrens {
-	jlib::wrapper:splitxml $child tag vars isempty chdata children
+    foreach child $children {
+	::xmpp::xml::split $child tag xmlns attrs cdata subels
 	switch -- $tag {
 	    item {
 		if {$type != "unavailable"} {
-		    set users(jid,$connid,$user) [jlib::wrapper:getattr $vars jid]
-		    track_room_position $connid $user \
-			[jlib::wrapper:getattr $vars role] \
-			[jlib::wrapper:getattr $vars affiliation]
+		    set users(jid,$xlib,$user) [::xmpp::xml::getAttr $attrs jid]
+		    track_room_position $xlib $user \
+			[::xmpp::xml::getAttr $attrs role] \
+			[::xmpp::xml::getAttr $attrs affiliation]
 		} else {
-		    set new_nick [jlib::wrapper:getattr $vars nick]
-		    foreach ch $children {
-			jlib::wrapper:splitxml $ch tag1 vars1 isempty1 \
-			    chdata1 children1
-			switch -- $tag1 {
+		    set new_nick [::xmpp::xml::getAttr $attrs nick]
+		    foreach ch $subels {
+			::xmpp::xml::split $ch stag sxmlns sattrs scdata ssubels
+			switch -- $stag {
 			    reason {
-				set reason $chdata1
+				set reason $scdata
 			    }
 			    actor {
-				set actor [jlib::wrapper:getattr $vars1 jid]
+				set actor [::xmpp::xml::getAttr $sattrs jid]
 			    }
 			}
 		    }
@@ -1080,15 +1067,15 @@
 	    }
 	    destroy {
 		set group [node_and_server_from_jid $user]
-		set chatid [chat::chatid $connid $group]
+		set chatid [chat::chatid $xlib $group]
 		set msg [::msgcat::mc "Room is destroyed"]
-		foreach ch $children {
-		    jlib::wrapper:splitxml $ch tag1 vars1 isempty1 chdata1 children1
-		    if {$tag1 == "reason" && [string trim $chdata1] != ""} {
-			append msg [::msgcat::mc "\nReason: %s" [string trim $chdata1]]
+		foreach ch $subels {
+		    ::xmpp::xml::split $ch stag sxmlns sattrs scdata ssubels
+		    if {$stag == "reason" && [string trim $scdata] != ""} {
+			append msg [::msgcat::mc "\nReason: %s" [string trim $scdata]]
 		    }
 		}
-		set altjid [jlib::wrapper:getattr $vars jid]
+		set altjid [::xmpp::xml::getAttr $attrs jid]
 		if {$altjid != ""} {
 		    append msg [::msgcat::mc "\nAlternative venue: %s" $altjid]
 		}
@@ -1098,9 +1085,9 @@
 		}
 	    }
 	    status {
-		set code [jlib::wrapper:getattr $vars code]
+		set code [::xmpp::xml::getAttr $attrs code]
 		set group [node_and_server_from_jid $user]
-		set chatid [chat::chatid $connid $group]
+		set chatid [chat::chatid $xlib $group]
 		switch -- $code {
 		    201 {
 			chat::add_message \
@@ -1121,8 +1108,8 @@
 		    322 {
 			# 301: ban, 307: kick, 321: loosing membership
 			# 322: room becomes members-only
-			set nick [chat::get_nick $connid $user groupchat]
-			set real_jid [get_real_jid $connid $group/$nick]
+			set nick [chat::get_nick $xlib $user groupchat]
+			set real_jid [get_real_jid $xlib $group/$nick]
 			if {$real_jid != ""} {
 			    set real_jid " ($real_jid)"
 			}
@@ -1161,7 +1148,7 @@
 		    }
 		    303 {
 			# 303: nickname change
-			set nick [chat::get_nick $connid $user groupchat]
+			set nick [chat::get_nick $xlib $user groupchat]
 			if {[info exists new_nick] && $new_nick != ""} {
 			    if {$nick == [get_our_groupchat_nick $chatid]} {
 				set_our_groupchat_nick $chatid $new_nick
@@ -1172,7 +1159,7 @@
 				variable ignore_available   $new_nick
 				variable ignore_unavailable $nick
 
-				set real_jid [get_real_jid $connid $group/$nick]
+				set real_jid [get_real_jid $xlib $group/$nick]
 				if {$real_jid != ""} {
 				    set real_jid " ($real_jid)"
 				}
@@ -1181,7 +1168,8 @@
 				    [::msgcat::mc "%s is now known as %s" \
 					 $nick$real_jid $new_nick] {}
 			    }
-			    ::hook::run room_nickname_changed_hook $connid $group $nick $new_nick
+			    ::hook::run room_nickname_changed_hook \
+					$xlib $group $nick $new_nick
 			}
 		    }
 		}
@@ -1194,7 +1182,7 @@
 proc muc::process_available {chatid nick} {
     variable pending_nicks
 
-    set connid [chat::get_connid $chatid]
+    set xlib [chat::get_xlib $chatid]
     set group [chat::get_jid $chatid]
 
     if {![is_compatible $group] && [is_changing_nick $chatid] && \
@@ -1214,8 +1202,8 @@
     if {[is_compatible $group] && $options(gen_enter_exit_msgs) && \
 	    (![info exists ignore_unavailable] || \
 		 $ignore_unavailable != $nick)} {
-	set connid [chat::get_connid $chatid]
-	set status [get_jid_presence_info status $connid $group/$nick]
+	set xlib [chat::get_xlib $chatid]
+	set status [get_jid_presence_info status $xlib $group/$nick]
 	if {$status != ""} {
 	    set end ": $status"
 	} else {
@@ -1232,7 +1220,7 @@
     variable users
     variable ignore_available
 
-    set connid [::chat::get_connid $chatid]
+    set xlib [::chat::get_xlib $chatid]
     set group [::chat::get_jid $chatid]
 
     if {![is_compatible $group]} return
@@ -1245,7 +1233,7 @@
 	&& (![info exists ignore_available] || $ignore_available != $nick)}]
 
     if {$report_entered} {
-	set real_jid [get_real_jid $connid $jid]
+	set real_jid [get_real_jid $xlib $jid]
 	if {$real_jid != ""} {
 	    set occupant "$nick ($real_jid)"
 	} else {
@@ -1254,21 +1242,21 @@
 	set msg [format [::msgcat::mc "%s has entered"] $occupant]
 	if {$options(gen_muc_position_change_msgs)} {
 	    append msg " " [::msgcat::mc "as %s/%s" \
-		[::msgcat::mc $users(affiliation,$connid,$jid)] \
-		[::msgcat::mc $users(role,$connid,$jid)]]
+		[::msgcat::mc $users(affiliation,$xlib,$jid)] \
+		[::msgcat::mc $users(role,$xlib,$jid)]]
 	}
     }
     catch { unset ignore_available }
 
     if {$options(gen_muc_status_change_msgs)} {
-	set status [::get_user_status $connid $jid]
+	set status [::get_user_status $xlib $jid]
 	if {$report_entered} {
 	    append msg " " [::msgcat::mc "and"] " "
 	} else {
 	    append msg $nick " "
 	}
 	append msg [::get_long_status_desc $status]
-	set desc [::get_user_status_desc $connid $jid]
+	set desc [::get_user_status_desc $xlib $jid]
 	if {$desc != {}} {
 	    append msg " ($desc)"
 	}
@@ -1277,20 +1265,20 @@
     ::chat::add_message $chatid $group groupchat $msg {}
 }
 
-proc muc::track_room_position {connid jid role affiliation} {
+proc muc::track_room_position {xlib jid role affiliation} {
     variable options
     variable users
 
-    upvar 0 users(role,$connid,$jid) _role \
-	users(affiliation,$connid,$jid) _aff
+    upvar 0 users(role,$xlib,$jid) _role \
+	users(affiliation,$xlib,$jid) _aff
 
     set group  [node_and_server_from_jid $jid]
     if {![is_compatible $group]} return
 
-    set chatid [chat::chatid $connid $group]
+    set chatid [chat::chatid $xlib $group]
 
     if {[chat::is_opened $chatid] && $options(gen_muc_position_change_msgs)} {
-	set nick [chat::get_nick $connid $jid groupchat]
+	set nick [chat::get_nick $xlib $jid groupchat]
 
 	set role_changed [expr {![info exists _role] \
 	    || ![string equal $role $_role]}]
@@ -1346,29 +1334,24 @@
 	set tstatus $textstatus
     }
 
-    send_custom_presence $group/$nick $status \
-	-stat $tstatus \
-	-connection [chat::get_connid $chatid] \
+    send_custom_presence [chat::get_xlib $chatid] $group/$nick $status \
+	-status $tstatus \
 	-command [list muc::process_change_nick $chatid]
 }
 
 
-proc muc::process_change_nick {chatid connid from type x args} {
+proc muc::process_change_nick {chatid xlib from type x args} {
     if {![cequal $type error]} {
 	return
     }
 
-#    if {![cequal [lindex [jlib::wrapper:getattr $args -error] 1] conflict]} {
-#	return
-#    }
-
     if {![is_compatible [chat::get_jid $chatid]] && \
 	    [is_changing_nick $chatid]} {
 	variable pending_nicks
 	unset pending_nicks($chatid)
     }
     chat::add_message $chatid [node_and_server_from_jid $from] error \
-	[::msgcat::mc "Error %s" [jlib::wrapper:getattr $args -status]] {}
+	[::msgcat::mc "Error %s" [::xmpp::xml::getAttr $args -status]] {}
     return break
 }
 
@@ -1385,24 +1368,23 @@
 
 ###############################################################################
 
-proc muc::request_negotiation {connid group} {
+proc muc::request_negotiation {xlib group} {
     variable muc_compatible
 
     set muc_compatible($group) 0
 
-    disco::request_info [server_from_jid $group] "" \
-	-connection $connid \
+    disco::request_info $xlib [server_from_jid $group] \
 	-cache yes \
-	-handler [list muc::recv_negotiation1 $connid $group]
+	-command [list muc::recv_negotiation1 $xlib $group]
 }
 
 
-proc muc::recv_negotiation1 {connid group res identities features extras} {
+proc muc::recv_negotiation1 {xlib group res identities features extras} {
     variable muc_compatible
 
-    if {[cequal $res OK]} {
+    if {[string equal $res ok]} {
 	foreach f $features {
-	    set var [jlib::wrapper:getattr $f var]
+	    set var [::xmpp::xml::getAttr $f var]
 	    if {$var == $::NS(muc)} {
 		set muc_compatible($group) 1
 		return
@@ -1410,18 +1392,17 @@
 	}
     }
 
-    disco::request_info $group "" \
-	-connection $connid \
+    disco::request_info $xlib $group \
 	-cache yes \
-	-handler [list muc::recv_negotiation2 $group]
+	-command [list muc::recv_negotiation2 $group]
 }
 
 proc muc::recv_negotiation2 {group res identities features extras} {
     variable muc_compatible
 
-    if {[cequal $res OK]} {
+    if {[string equal $res ok]} {
 	foreach f $features {
-	    set var [jlib::wrapper:getattr $f var]
+	    set var [::xmpp::xml::getAttr $f var]
 	    if {$var == $::NS(muc)} {
 		set muc_compatible($group) 1
 		return
@@ -1444,17 +1425,17 @@
 
 ###############################################################################
 
-proc muc::add_user_popup_info {infovar connid user} {
+proc muc::add_user_popup_info {infovar xlib user} {
     variable users
     upvar 0 $infovar info
 
-    if {[info exists users(jid,$connid,$user)] && \
-	    $users(jid,$connid,$user) != ""} {
-	append info [::msgcat::mc "\n\tJID: %s" $users(jid,$connid,$user)]
+    if {[info exists users(jid,$xlib,$user)] && \
+	    $users(jid,$xlib,$user) != ""} {
+	append info [::msgcat::mc "\n\tJID: %s" $users(jid,$xlib,$user)]
     }
-    if {[info exists users(affiliation,$connid,$user)]} {
+    if {[info exists users(affiliation,$xlib,$user)]} {
 	append info [::msgcat::mc "\n\tAffiliation: %s" \
-			 $users(affiliation,$connid,$user)]
+			 $users(affiliation,$xlib,$user)]
     }
 }
 
@@ -1482,7 +1463,7 @@
 
 ###############################################################################
 
-proc muc::join_group {connid group nick {password ""}} {
+proc muc::join_group {xlib group nick {password ""}} {
     global userstatus textstatus
     global statusdesc
     variable options
@@ -1490,7 +1471,7 @@
     variable muc_password
 
     set group [tolower_node_and_domain $group]
-    set chatid [chat::chatid $connid $group]
+    set chatid [chat::chatid $xlib $group]
 
     if {[info exists chat::chats(status,$chatid)] && \
 	    ![string equal $chat::chats(status,$chatid) disconnected]} {
@@ -1498,18 +1479,18 @@
 	return
     }
 
-    privacy::add_to_special_list $connid conference [server_from_jid $group]
+    privacy::add_to_special_list $xlib conference [server_from_jid $group]
 
     set_our_groupchat_nick $chatid $nick
 
     chat::open_window $chatid groupchat
     update idletasks
 
-    request_negotiation $connid $group
+    request_negotiation $xlib $group
 
     set x_subtags {}
 
-    lappend x_subtags [jlib::wrapper:createtag password -chdata $password]
+    lappend x_subtags [::xmpp::xml::create password -cdata $password]
     set muc_password($chatid) $password
 
     set history_vars {}
@@ -1525,7 +1506,7 @@
 		seconds [expr {[clock seconds] - $timestamps($chatid) + 2}]
     }
     if {![lempty $history_vars]} {
-	lappend x_subtags [jlib::wrapper:createtag history -vars $history_vars]
+	lappend x_subtags [::xmpp::xml::create history -attrs $history_vars]
     }
 
     if {$userstatus == "invisible"} {
@@ -1540,74 +1521,68 @@
 	set tstatus $textstatus
     }
 
-    send_presence $status \
+    send_presence $xlib $status \
 		  -to $group/$nick \
-		  -stat $tstatus \
-		  -connection $connid \
-		  -xlist [list [jlib::wrapper:createtag x \
-				    -vars [list xmlns $::NS(muc)] \
-				    -subtags $x_subtags]]
+		  -status $tstatus \
+		  -xlist [list [::xmpp::xml::create x \
+				    -xmlns $::NS(muc) \
+				    -subelements $x_subtags]]
 }
 
 ###############################################################################
 
-proc muc::leave_group {connid group nick status} {
-    send_presence unavailable \
+proc muc::leave_group {xlib group nick status} {
+    send_presence $xlib unavailable \
 		  -to $group/$nick \
-		  -stat $status \
-		  -connection $connid
+		  -status $status
 }
 
 ###############################################################################
 
-proc muc::invite_muc {connid group jid reason} {
+proc muc::invite_muc {xlib group jid reason} {
     # If $jid is a 'real' JID then invite
     # If $jid is in a conference room try to invite real JID
 
-    set real_jid [get_real_jid $connid $jid]
+    set real_jid [get_real_jid $xlib $jid]
     if {$real_jid == ""} {
 	set real_jid $jid
     }
 
-    message::send_msg $group \
+    message::send_msg $xlib $group \
 	-xlist [list \
-	    [jlib::wrapper:createtag x \
-		 -vars [list xmlns $::NS(muc#user)] \
-		 -subtags [list \
-		     [jlib::wrapper:createtag invite \
-			  -vars [list to $real_jid] \
-			  -subtags [list [jlib::wrapper:createtag reason \
-					      -chdata $reason]]]]]] \
-	-connection $connid
+	    [::xmpp::xml::create x \
+		 -xmlns $::NS(muc#user) \
+		 -subelement [::xmpp::xml::create invite \
+				    -attrs [list to $real_jid] \
+				    -subelement [::xmpp::xml::create reason \
+							-cdata $reason]]]]
 }
 
-proc muc::invite_xconference {connid group jid reason} {
-    message::send_msg $jid \
+proc muc::invite_xconference {xlib group jid reason} {
+    message::send_msg $xlib $jid \
 	-type normal \
 	-subject "Invitation" \
 	-body $reason \
-	-xlist [list [jlib::wrapper:createtag x \
-			  -vars [list xmlns jabber:x:conference \
-				      jid $group]]] \
-	-connection $connid
+	-xlist [list [::xmpp::xml::create x \
+			    -xmlns $::NS(xconference) \
+			    -attrs [list jid $group]]]
 }
 
 ###############################################################################
 
-proc muc::process_invitation {rowvar bodyvar f x connid from id type replyP} {
+proc muc::process_invitation {rowvar bodyvar f x xlib from id type replyP} {
     upvar 2 $rowvar row
     upvar 2 $bodyvar body
 
     foreach xa $x {
-	jlib::wrapper:splitxml $xa tag vars isempty chdata children
-	set xmlns [jlib::wrapper:getattr $vars xmlns]
+	::xmpp::xml::split $xa tag xmlns attrs cdata subels
 
 	switch -- $xmlns \
 	    $::NS(xconference) {
-		set xconference_group [jlib::wrapper:getattr $vars jid]
+		set xconference_group [::xmpp::xml::getAttr $attrs jid]
 		set xconference_password ""
-		if {[cequal $body ""] && ![cequal $chdata ""]} {
-		    set xconference_body $chdata
+		if {[string equal $body ""] && ![string equal $cdata ""]} {
+		    set xconference_body $cdata
 		} else {
 		    set xconference_body $body
 		}
@@ -1615,15 +1590,14 @@
 	    $::NS(muc#user) {
 		set password ""
 		set inviter ""
-		foreach ch $children {
-		    jlib::wrapper:splitxml $ch tag1 vars1 isempty1 \
-			chdata1 children1
+		foreach ch $subels {
+		    ::xmpp::xml::split $ch stag sxmlns sattrs scdata ssubels
 
-		    switch -- $tag1 {
+		    switch -- $stag {
 			invite {
-			    set inviter [jlib::wrapper:getattr $vars1 from]
-			    if {![cequal $inviter ""]} {
-				foreach c [jlib::connections] {
+			    set inviter [::xmpp::xml::getAttr $sattrs from]
+			    if {![string equal $inviter ""]} {
+				foreach c [connections] {
 				    set name \
 					[roster::itemconfig $c \
 					     [roster::find_jid $c $inviter] \
@@ -1639,20 +1613,20 @@
 					  room %s" \
 					 $inviter $from]
 
-				foreach ch1 $children1 {
-				    jlib::wrapper:splitxml $ch1 tag2 vars2 \
-					isempty2 chdata2 children2
-				    if {[cequal $tag2 "reason"]} {
+				foreach sch $ssubels {
+				    ::xmpp::xml::split $sch sstag ssattrs \
+							    sscdata sssubels
+				    if {[string equal $sstag "reason"]} {
 					append muc_body \
 					    [::msgcat::mc "\nReason is: %s" \
-						 $chdata2]
+						 $sscdata]
 				    }
 				}
 			    }
 			    # TODO decline
 			}
 			password {
-			    set password $chdata1
+			    set password $schdata
 			}
 		    }
 		}
@@ -1664,12 +1638,12 @@
     }
 
     if {[info exists muc_group] && $muc_group != ""} {
-	process_x_conference $f $connid $muc_group $muc_password $row
+	process_x_conference $f $xlib $muc_group $muc_password $row
 	incr row
 	set body $muc_body
 	return
     } elseif {[info exists xconference_group] && $xconference_group != ""} {
-	process_x_conference $f $connid $xconference_group \
+	process_x_conference $f $xlib $xconference_group \
 	    $xconference_password $row
 	incr row
 	set body $xconference_body
@@ -1681,7 +1655,7 @@
 
 hook::add message_process_x_hook muc::process_invitation
 
-proc muc::process_x_conference {f connid group password row} {
+proc muc::process_x_conference {f xlib group password row} {
     global gr_nick
 
     label $f.lgroup$row -text [::msgcat::mc "Invited to:"]
@@ -1689,7 +1663,7 @@
 	-command [list ::join_group $group \
 		       -nick [get_group_nick $group $gr_nick] \
 		       -password $password \
-		       -connection $connid]
+		       -connection $xlib]
     
     grid $f.lgroup$row -row $row -column 0 -sticky e
     grid $f.group$row  -row $row -column 1 -sticky ew
@@ -1697,15 +1671,13 @@
 
 ###############################################################################
 
-proc muc::join {jid args} {
+proc muc::join {xlib jid args} {
     global gr_nick
 
     set category conference
-    set newargs {}
     foreach {opt val} $args {
 	switch -- $opt {
 	    -category { set category $val }
-	    -connection { lappend newargs -connection $val }
 	}
     }
 
@@ -1714,11 +1686,9 @@
     }
 
     if {![cequal [node_from_jid $jid] {}]} {
-	eval {::join_group $jid -nick [get_group_nick $jid $gr_nick]} \
-	     $newargs
+	::join_group $xlib $jid -nick [get_group_nick $jid $gr_nick]
     } else {
-	eval {::join_group_dialog -server [server_from_jid $jid] -group {}} \
-	     $newargs
+	::join_group_dialog $xlib -server [server_from_jid $jid] -group {}
     }
 }
 
@@ -1735,11 +1705,7 @@
 ###############################################################################
 
 
-iq::register_handler get query $::NS(muc) muc::iq_reply
-
-###############################################################################
-
-proc muc::disco_reply {type connid from lang child} {
+proc muc::disco_reply {type xlib from lang child} {
     variable options
 
     if {!$options(report_muc_rooms)} {
@@ -1752,11 +1718,11 @@
 	}
 	items {
 	    set res {}
-	    foreach chatid [lfilter chat::is_groupchat [chat::opened $connid]] {
+	    foreach chatid [lfilter chat::is_groupchat [chat::opened $xlib]] {
 		set group [chat::get_jid $chatid]
 		if {[is_compatible $group]} {
-		    lappend res [jlib::wrapper:createtag item \
-				     -vars [list jid $group]]
+		    lappend res [::xmpp::xml::create item \
+				     -attrs [list jid $group]]
 		}
 	    }
 	    return $res

Copied: trunk/tkabber/namespaces.tcl (from rev 1514, trunk/tkabber/jabberlib/namespaces.tcl)
===================================================================
--- trunk/tkabber/namespaces.tcl	                        (rev 0)
+++ trunk/tkabber/namespaces.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -0,0 +1,56 @@
+#  namespaces.tcl --
+#  
+#      This file is part of the jabberlib. It lists Jabber
+#      namespaces registered by JSF.
+#      
+#  Copyright (c) 2005 Sergei Golovan <sgolovan at nes.ru>
+#   
+# $Id$
+
+##########################################################################
+
+package provide namespaces 1.0
+
+##########################################################################
+
+namespace eval :: {
+    array set NS [list \
+	stream	    "http://etherx.jabber.org/streams" \
+	tls	    "urn:ietf:params:xml:ns:xmpp-tls" \
+	sasl	    "urn:ietf:params:xml:ns:xmpp-sasl" \
+	bind	    "urn:ietf:params:xml:ns:xmpp-bind" \
+	session	    "urn:ietf:params:xml:ns:xmpp-session" \
+	iq-auth	    "http://jabber.org/features/iq-auth" \
+	iq-register "http://jabber.org/features/iq-register" \
+	fcompress   "http://jabber.org/features/compress" \
+	compress    "http://jabber.org/protocol/compress" \
+	component   "jabber:component:accept" \
+	auth	    "jabber:iq:auth" \
+	register    "jabber:iq:register" \
+	roster	    "jabber:iq:roster" \
+	signed      "jabber:x:signed" \
+	encrypted   "jabber:x:encrypted" \
+	iqavatar    "jabber:iq:avatar" \
+	xavatar     "jabber:x:avatar" \
+	xconference "jabber:x:conference" \
+	data	    "jabber:x:data" \
+	event       "jabber:x:event" \
+	xroster     "jabber:x:roster" \
+	rosterx     "http://jabber.org/protocol/rosterx" \
+	chatstate   "http://jabber.org/protocol/chatstates" \
+	commands    "http://jabber.org/protocol/commands" \
+	privacy     "jabber:iq:privacy" \
+	private     "jabber:iq:private" \
+	delimiter   "roster:delimiter" \
+	bookmarks   "storage:bookmarks" \
+	tkabber:groups "tkabber:bookmarks:groups" \
+	pubsub      "http://jabber.org/protocol/pubsub" \
+	pubsub#owner "http://jabber.org/protocol/pubsub#owner" \
+	disco#publish "http://jabber.org/protocol/disco#publish" \
+	challenge   "urn:xmpp:tmp:challenge" \
+	media-element "urn:xmpp:tmp:media-element"
+    ]
+}
+
+##########################################################################
+

Modified: trunk/tkabber/negotiate.tcl
===================================================================
--- trunk/tkabber/negotiate.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/negotiate.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -5,28 +5,30 @@
     set seq 0
 }
 
-proc negotiate::get_handler {type connid from lang child} {
+proc negotiate::get_handler {type xlib from child args} {
     variable handler
 
     debugmsg negotiate "$type: [list $from $child]"
 
-    jlib::wrapper:splitxml $child tag vars isempty cdata children
+    ::xmpp::xml::split $child tag xmlns attrs cdata subels
 
+    set lang [::xmpp::xml::getAttr $args -lang en]
+
     set error 1
     set fields {}
-    foreach form $children {
-	jlib::wrapper:splitxml $form tag1 vars1 isempty1 cdata1 children1
-	if {$tag1 == "x" && \
-		[jlib::wrapper:getattr $vars1 xmlns] == $::NS(data) && \
-		[jlib::wrapper:getattr $vars1 type] == "submit"} {
+    foreach form $subels {
+	::xmpp::xml::split $form stag sxmlns sattrs scdata ssubels
+	if {$stag == "x" && \
+		$xmlns == $::NS(data) && \
+		[::xmpp::xml::getAttr $sattrs type] == "submit"} {
 
-		foreach field $children1 {
-		    jlib::wrapper:splitxml $field \
-			    tag2 vars2 isempty2 cdata2 children2
+		foreach field $ssubels {
+		    ::xmpp::xml::split $field \
+			    sstag ssxmlns ssattrs sscdata sssubels
 
-		    if {$tag2 != "field"} continue
+		    if {$sstag != "field"} continue
 
-		    set feature [jlib::wrapper:getattr $vars2 var]
+		    set feature [::xmpp::xml::getAttr $ssattrs var]
 
 		    if {![info exists handler($feature)]} continue
 
@@ -34,7 +36,7 @@
 
 		    # TODO
 		    set opts [eval $handler($feature) \
-				   [list $type $connid $from $lang $children2]]
+				   [list $type $xlib $from $lang $sssubels]]
 
 		    lappend fields $opts
 	    }
@@ -43,19 +45,19 @@
     if {$error} {
 	return [list error cancel feature-not-implemented]
     } else {
-	set res [jlib::wrapper:createtag feature \
-		     -vars [list xmlns $::NS(negotiate)] \
-		     -subtags [list [jlib::wrapper:createtag x \
-					 -vars [list xmlns $::NS(data) \
-						     type result] \
-					 -subtags $fields]]]
+	set res [::xmpp::xml::create feature \
+		     -xmlns $::NS(negotiate) \
+		     -subelement [::xmpp::xml::create x \
+					 -xmlns $::NS(data) \
+					 -attrs [list type result] \
+					 -subelements $fields]]
 	return [list result $res]
     }
 }
 
-iq::register_handler get feature $::NS(negotiate) \
+::xmpp::iq::register get feature $::NS(negotiate) \
 		     [list [namespace current]::negotiate::get_handler get]
-iq::register_handler set feature $::NS(negotiate) \
+::xmpp::iq::register set feature $::NS(negotiate) \
 		     [list [namespace current]::negotiate::get_handler set]
 
 proc negotiate::register_handler {feature h} {
@@ -64,7 +66,7 @@
     set handler($feature) $h
 }
 
-proc negotiate::send_request {connid to feature} {
+proc negotiate::send_request {xlib to feature} {
     variable seq
     variable tmp
 
@@ -72,20 +74,19 @@
 
     set fieldtags {}
     if {$feature != ""} {
-	lappend fieldtags [jlib::wrapper:createtag field \
-			       -vars [list var $feature]]
+	lappend fieldtags [::xmpp::xml::create field \
+				-attrs [list var $feature]]
     }
 
-    jlib::send_iq get \
-	[jlib::wrapper:createtag feature \
-	     -vars [list xmlns $::NS(negotiate)] \
-	     -subtags [list [jlib::wrapper:createtag x \
-				 -vars [list xmlns $::NS(data) \
-					     type  submit] \
-				 -subtags $fieldtags]]] \
+    ::xmpp::sendIQ $xlib get \
+	-query [::xmpp::xml::create feature \
+			-xmlns $::NS(negotiate) \
+			-subelement [::xmpp::xml::create x \
+					    -xmlns $::NS(data) \
+					    -attrs [list type submit] \
+					    -subelements $fieldtags]] \
 	-to $to \
-	-command [list negotiate::recv_request_response $connid $to $i] \
-	-connection $connid
+	-command [list negotiate::recv_request_response $xlib $to $i]
 
     vwait [namespace current]::tmp($i)
     set res $tmp($i)
@@ -93,39 +94,39 @@
     return $res
 }
 
-proc negotiate::recv_request_response {connid jid seq res child} {
+proc negotiate::recv_request_response {xlib jid seq res child} {
     variable tmp
 
-    if {$res != "OK"} {
+    if {$res != "ok"} {
 	set tmp($seq) [list $res $child]
 	return
     }
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
+    ::xmpp::xml::split $child tag xmlns attrs cdata subels
 
     if {$tag == "feature"} {
-	jlib::wrapper:splitxml \
-	    [lindex $children 0] tag1 vars1 isempty1 chdata1 children1
+	::xmpp::xml::split \
+	    [lindex $children 0] stag sxmlns sattrs scdata ssubels
 
-	data::draw_window $children1 \
-	    [list [namespace current]::send_negotiation_form $connid $jid]
+	data::draw_window $ssubels \
+	    [list [namespace current]::send_negotiation_form $xlib $jid]
     }
 
-    set tmp($seq) [list OK {}]
+    set tmp($seq) [list ok {}]
 }
 
-proc negotiate::send_negotiation_form {connid jid w restags} {
+proc negotiate::send_negotiation_form {xlib jid w restags} {
     catch { destroy $w.error.msg }
     $w.bbox itemconfigure 0 -state disabled
 
-    jlib::send_iq set [jlib::wrapper:createtag feature \
-			   -vars [list xmlns $::NS(negotiate)] \
-			   -subtags [jlib::wrapper:createtag x \
-					 -vars [list xmlns $::NS(data) \
-						     type  submit] \
-					 -subtags $restags]] \
+    ::xmpp::sendIQ $xlib set \
+	-query [::xmpp::xml::create feature \
+			-xmlns $::NS(negotiate) \
+			-subelement [::xmpp::xml::create x \
+					-xmlns $::NS(data) \
+					-attrs [list type submit] \
+					-subelements $restags]] \
 	-to $jid \
-	-connection $connid \
 	-command [list data::test_error_res $w]
 }
 

Modified: trunk/tkabber/pep.tcl
===================================================================
--- trunk/tkabber/pep.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/pep.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -15,12 +15,10 @@
 ##########################################################################
 #
 # PEP Creating a node (5)
-# -connection is mandatory
 # -access_model (open, presence (default), roster, whitelist)
 # -roster_groups_allowed (roster group list if access is roster)
-#
 
-proc pep::create_node {node args} {
+proc pep::create_node {xlib node args} {
     variable ns
 
     debugmsg pep [info level 0]
@@ -28,23 +26,14 @@
     set command ""
     set access "presence"
     set groups {}
-    foreach {key val} $args {
-	switch -- $key {
-	    -connection { set connid $val}
-	}
-    }
 
-    if {![info exists connid]} {
-	return -code error "pep::create_node: -connection is mandatory"
-    }
-
     if {$node == ""} {
 	return -code error "pep::create_node: node must not be empty"
     }
 
-    set service [jlib::connection_bare_jid $connid]
+    set service [connection_bare_jid $xlib]
 
-    eval [list pubsub::create_node $service $node] $args
+    eval [list pubsub::create_node $xlib $service $node] $args
 }
 
 ##########################################################################
@@ -53,31 +42,20 @@
 # payload is a list of xml tags
 # node must not be empty
 # itemid may be empty
-# -connection is mandatory
-#
 
-proc pep::publish_item {node itemid args} {
+proc pep::publish_item {xlib node itemid args} {
 
     debugmsg pep [info level 0]
 
     set command ""
-    foreach {key val} $args {
-	switch -- $key {
-	    -connection { set connid $val}
-	}
-    }
 
-    if {![info exists connid]} {
-	return -code error "pep::publish_item: -connection is mandatory"
-    }
-
     if {$node == ""} {
 	return -code error "pep::publish_item: node must not be empty"
     }
 
-    set service [jlib::connection_bare_jid $connid]
+    set service [connection_bare_jid $xlib]
 
-    eval [list pubsub::publish_item $service $node $itemid] $args
+    eval [list pubsub::publish_item $xlib $service $node $itemid] $args
 }
 
 ##########################################################################
@@ -85,24 +63,13 @@
 # Delete item from PEP node "node"
 # node must not be empty
 # itemid must not be empty
-# -connection is mandatory
-#
 
-proc pep::delete_item {node itemid args} {
+proc pep::delete_item {xlib node itemid args} {
 
     debugmsg pep [info level 0]
 
     set command ""
-    foreach {key val} $args {
-	switch -- $key {
-	    -connection { set connid $val}
-	}
-    }
 
-    if {![info exists connid]} {
-	return -code error "pep::delete_item: -connection is mandatory"
-    }
-
     if {$node == ""} {
 	return -code error "pep::delete_item: node must not be empty"
     }
@@ -111,9 +78,9 @@
 	return -code error "pep::delete_item: Item ID must not be empty"
     }
 
-    set service [jlib::connection_bare_jid $connid]
+    set service [connection_bare_jid $xlib]
 
-    eval [list pubsub::delete_item $service $node $itemid] $args
+    eval [list pubsub::delete_item $xlib $service $node $itemid] $args
 }
 
 ##########################################################################
@@ -128,27 +95,16 @@
 #
 # if both options are absent then user's bare JID is included to sub
 # request
-#
 
-proc pep::subscribe {to node args} {
+proc pep::subscribe {xlib to node args} {
 
     debugmsg pep [info level 0]
 
-    foreach {key val} $args {
-	switch -- $key {
-	    -connection { set connid $val}
-	}
-    }
-
-    if {![info exists connid]} {
-	return -code error "pep::subscribe error: -connection is mandatory"
-    }
-
     if {$node == ""} {
 	return -code error "pep::subscribe error: node must not be empty"
     }
 
-    eval [list pubsub::subscribe $to $node] $args
+    eval [list pubsub::subscribe $xlib $to $node] $args
 }
 
 ##########################################################################
@@ -163,28 +119,18 @@
 #
 # if both options are absent then user's bare JID is included to sub
 # request
-#
 
-proc pep::unsubscribe {to node args} {
+proc pep::unsubscribe {xlib to node args} {
 
     debugmsg pep [info level 0]
 
     set command ""
-    foreach {key val} $args {
-	switch -- $key {
-	    -connection { set connid $val}
-	}
-    }
 
-    if {![info exists connid]} {
-	return -code error "pep::unsubscribe error: -connection is mandatory"
-    }
-
     if {$node == ""} {
 	return -code error "pep::unsubscribe error: node must not be empty"
     }
 
-    eval [list pubsub::unsubscribe $to $node] $args
+    eval [list pubsub::unsubscribe $xlib $to $node] $args
 }
 
 ##########################################################################
@@ -192,7 +138,7 @@
 # the roster item for a user with JID $jid.
 # This command automatically creates this submenu if needed.
 
-proc pep::get_roster_menu_pep_submenu {m connid jid} {
+proc pep::get_roster_menu_pep_submenu {m xlib jid} {
     set pm $m.pep
 
     if {![winfo exists $pm]} {

Modified: trunk/tkabber/pixmaps.tcl
===================================================================
--- trunk/tkabber/pixmaps.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/pixmaps.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -91,12 +91,7 @@
 	return
     }
 
-    set parser [jlib::wrapper:new "#" "#" \
-		    [list pixmaps::find_name $var $thdir]]
-    jlib::wrapper:elementstart $parser stream:stream {} {}
-    jlib::wrapper:parser $parser parse $icondef
-    jlib::wrapper:parser $parser configure -final 0
-    jlib::wrapper:free $parser
+    ::xmpp::xml::parseData $icondef [list pixmaps::find_name $var $thdir]
 }
 
 ###############################################################################
@@ -104,7 +99,7 @@
 proc pixmaps::find_name {var dir xmldata} {
     upvar #0 $var themes
 
-    jlib::wrapper:splitxml $xmldata tag vars isempty cdata children
+    ::xmpp::xml::split $xmldata tag xmlns attrs cdata subels
 
     if {$tag == "name"} {
 	set themes($cdata) $dir
@@ -112,8 +107,8 @@
     }
 
     set found 0
-    foreach child $children {
-	if {[find_name $var $dir $child]} {
+    foreach subel $subels {
+	if {[find_name $var $dir $subel]} {
 	    return 1
 	}
     }
@@ -140,25 +135,20 @@
     set icondef [read $f]
     close $f
 
-    set parser [jlib::wrapper:new "#" "#" \
-		    [list pixmaps::parse_icondef $dir]]
-    jlib::wrapper:elementstart $parser stream:stream {} {}
-    jlib::wrapper:parser $parser parse $icondef
-    jlib::wrapper:parser $parser configure -final 0
-    jlib::wrapper:free $parser
+    ::xmpp::xml::parseData $icondef [list pixmaps::parse_icondef $dir]
 }
 
 ###############################################################################
 
 proc pixmaps::parse_icondef {dir xmldata} {
-    jlib::wrapper:splitxml $xmldata tag vars isempty cdata children
+    ::xmpp::xml::split $xmldata tag xmlns attrs cdata subels
 
     if {$tag != "icondef"} {
 	return -code error
     }
 
-    foreach child $children {
-	parse_item $dir $child
+    foreach subel $subels {
+	parse_item $dir $subel
     }
 
 }
@@ -166,11 +156,11 @@
 ###############################################################################
 
 proc pixmaps::parse_item {dir item} {
-    jlib::wrapper:splitxml $item tag vars isempty cdata children
+    ::xmpp::xml::split $item tag xmlns attrs cdata subels
 
     switch -- $tag {
 	icon {
-	    parse_icon $dir $children
+	    parse_icon $dir $subels
 	}
     }
 }
@@ -184,15 +174,15 @@
     set image ""
     set object ""
     foreach item $items {
-	jlib::wrapper:splitxml $item tag vars isempty cdata children
+	::xmpp::xml::split $item tag xmlns attrs cdata subels
 	switch -- $tag {
 	    image {
-		if {[jlib::wrapper:getattr $vars xmlns] == "tkimage"} {
+		if {$xmlns == "tkimage"} {
 		    set image $cdata
 		}
 	    }
 	    object {
-		switch -glob -- [jlib::wrapper:getattr $vars mime] {
+		switch -glob -- [::xmpp::xml::getAttr $attrs mime] {
 		    image/ico {
 			set type ico
 			set object $cdata

Modified: trunk/tkabber/plugins/chat/bookmark_highlighted.tcl
===================================================================
--- trunk/tkabber/plugins/chat/bookmark_highlighted.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/chat/bookmark_highlighted.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -76,11 +76,11 @@
 
     set cw [chat::chat_win $chatid]
 
-    set connid [chat::get_connid $chatid]
+    set xlib [chat::get_xlib $chatid]
     set jid [chat::get_jid $chatid]
     set myjid [chat::our_jid $chatid]
-    set mynick [chat::get_nick $connid $myjid $type]
-    if {[cequal $jid $from] || [cequal $myjid $from] || \
+    set mynick [chat::get_nick $xlib $myjid $type]
+    if {[string equal $jid $from] || [string equal $myjid $from] || \
 	    ![check_message $mynick $body]} {
 	return
     }

Modified: trunk/tkabber/plugins/chat/chatstate.tcl
===================================================================
--- trunk/tkabber/plugins/chat/chatstate.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/chat/chatstate.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -17,7 +17,7 @@
 # Workaround a bug in JIT, which responds with error to chatstate
 # events without a body
 proc chatstate::ignore_error \
-     {connid from id type is_subject subject body err thread priority x} {
+     {xlib from id type is_subject subject body err thread priority x} {
     switch -- $type/$id {
 	error/chatstate {
 	    return stop
@@ -39,8 +39,7 @@
 proc chatstate::process_x {chatid from type body xs} {
     if {$type == "chat"} {
 	foreach x $xs {
-	    jlib::wrapper:splitxml $x tag vars isempty chdata children
-	    set xmlns [jlib::wrapper:getattr $vars xmlns]
+	    ::xmpp::xml::split $x tag xmlns attrs cdata subels
 	    switch -- $xmlns \
 		$::NS(chatstate) {
 		    return [process_x_chatstate \
@@ -57,7 +56,7 @@
     variable options
     variable chatstate
 
-    jlib::wrapper:splitxml $x tag vars isempty chdata children
+    ::xmpp::xml::split $x tag xmlns attrs cdata subels
 
     switch -- $tag {
 	active {
@@ -142,17 +141,16 @@
 	    !$chatstate(composing,$chatid)} return
     if {!$options(enable)} return
 
-    set connid [chat::get_connid $chatid]
+    set xlib [chat::get_xlib $chatid]
     set jid [chat::get_jid $chatid]
 
     set chatstate(composing,$chatid) 0
 
-    if {[get_jid_status $connid $jid] == "unavailable"} return
+    if {[get_jid_status $xlib $jid] == "unavailable"} return
 
-    lappend xlist [jlib::wrapper:createtag composing \
-		       -vars [list xmlns $::NS(chatstate)]]
+    lappend xlist [::xmpp::xml::create composing -xmlns $::NS(chatstate)]
 
-    jlib::send_msg $jid -id chatstate -xlist $xlist -connection $connid
+    ::xmpp::sendMessage $xlib $jid -id chatstate -xlist $xlist
 }
 
 proc chatstate::setup_ui {chatid type} {
@@ -194,8 +192,7 @@
 
     set chatstate(windowactive,$chatid) 1
 
-    lappend var [jlib::wrapper:createtag active \
-		     -vars [list xmlns $::NS(chatstate)]]
+    lappend var [::xmpp::xml::create active -xmlns $::NS(chatstate)]
     return
 }
 
@@ -212,17 +209,16 @@
     if {![chat::is_chat $chatid]} return
     if {!$options(enable)} return
 
-    set connid [chat::get_connid $chatid]
+    set xlib [chat::get_xlib $chatid]
     set jid [chat::get_jid $chatid]
 
     unset chatstate(windowactive,$chatid)
 
-    if {[get_jid_status $connid $jid] == "unavailable"} return
+    if {[get_jid_status $xlib $jid] == "unavailable"} return
 
-    lappend xlist [jlib::wrapper:createtag gone \
-		       -vars [list xmlns $::NS(chatstate)]]
+    lappend xlist [::xmpp::xml::create gone -xmlns $::NS(chatstate)]
 
-    jlib::send_msg $jid -id chatstate -xlist $xlist -connection $connid
+    ::xmpp::sendMessage $xlib $jid -id chatstate -xlist $xlist
 }
 
 hook::add close_chat_post_hook \

Modified: trunk/tkabber/plugins/chat/clear.tcl
===================================================================
--- trunk/tkabber/plugins/chat/clear.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/chat/clear.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -33,8 +33,8 @@
 hook::add generate_completions_hook \
     [namespace current]::clear::clear_command_comp
 
-proc clear::add_chat_menu_item {m connid jid} {
-    set chatid [chat::chatid $connid $jid]
+proc clear::add_chat_menu_item {m xlib jid} {
+    set chatid [chat::chatid $xlib $jid]
     $m add command -label [::msgcat::mc "Clear chat window"] \
 	-command [list [namespace current]::clear_chat_win $chatid]
 }

Modified: trunk/tkabber/plugins/chat/complete_last_nick.tcl
===================================================================
--- trunk/tkabber/plugins/chat/complete_last_nick.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/chat/complete_last_nick.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -2,8 +2,10 @@
 
 namespace eval completion {
     custom::defvar options(completion_expire) 10 \
-	[::msgcat::mc "Number of groupchat messages to expire nick completion according to the last personally addressed message."] \
-	-type integer -group Chat
+	[::msgcat::mc "Number of groupchat messages to expire nick completion\
+		       according to the last personally addressed message."] \
+	-type integer \
+	-group Chat
 }
 
 proc handle_last_nick {chatid from type body x} {
@@ -11,11 +13,11 @@
 
     if {$type != "groupchat"} return
 
-    set connid [chat::get_connid $chatid]
+    set xlib [chat::get_xlib $chatid]
 
-    set nick [chat::get_nick $connid $from $type]
+    set nick [chat::get_nick $xlib $from $type]
     set myjid [chat::our_jid $chatid]
-    set mynick [chat::get_nick $connid $myjid $type]
+    set mynick [chat::get_nick $xlib $myjid $type]
     if {$nick != $mynick} {
 	if {[check_message $mynick $body]} {
 	    set my_last_nick($chatid) $nick

Modified: trunk/tkabber/plugins/chat/completion.tcl
===================================================================
--- trunk/tkabber/plugins/chat/completion.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/chat/completion.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -182,7 +182,7 @@
 proc completion::nick_comps {chatid compsvar wordstart line} {
     if {![chat::is_groupchat $chatid]} return
 
-    set connid [chat::get_connid $chatid]
+    set xlib [chat::get_xlib $chatid]
 
     variable options
     global grouproster
@@ -199,7 +199,7 @@
 
     set nickcomps {}
     foreach jid $grouproster(users,$chatid) {
-	lappend nickcomps $prefix[chat::get_nick $connid $jid groupchat]$suffix
+	lappend nickcomps $prefix[chat::get_nick $xlib $jid groupchat]$suffix
     }
     set nickcomps [lsort -dictionary -unique $nickcomps]
     set comps [concat $nickcomps $comps]

Modified: trunk/tkabber/plugins/chat/disco.tcl
===================================================================
--- trunk/tkabber/plugins/chat/disco.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/chat/disco.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -3,11 +3,11 @@
 namespace eval cdisco {}
 
 proc cdisco::handle_disco_command {chatid user body type} {
-    set connid [chat::get_connid $chatid]
+    set xlib [chat::get_xlib $chatid]
     set jid [chat::get_jid $chatid]
     set bjid [node_and_server_from_jid $jid]
 
-    if {![chat::is_groupchat [chat::chatid $connid $bjid]]} {
+    if {![chat::is_groupchat [chat::chatid $xlib $bjid]]} {
 	set jid $bjid
     }
 
@@ -19,7 +19,7 @@
 	return
     }
 
-    disco::browser::open_win $jid -connection $connid
+    disco::browser::open_win $jid -connection $xlib
     return stop
 }
 
@@ -35,5 +35,5 @@
 }
 
 hook::add generate_completions_hook \
-    [namespace current]::cdisco::disco_command_comp
+	  [namespace current]::cdisco::disco_command_comp
 

Modified: trunk/tkabber/plugins/chat/draw_normal_message.tcl
===================================================================
--- trunk/tkabber/plugins/chat/draw_normal_message.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/chat/draw_normal_message.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -7,9 +7,9 @@
 	set tag they
     }
 
-    set connid [chat::get_connid $chatid]
+    set xlib [chat::get_xlib $chatid]
     set chatw [chat::chat_win $chatid]
-    set nick [chat::get_nick $connid $from $type]
+    set nick [chat::get_nick $xlib $from $type]
     set cw [chat::winid $chatid]
 
     $chatw insert end "<$nick>" [list $tag NICK-$nick] " "
@@ -19,7 +19,7 @@
 
     if {[cequal $type groupchat]} {
 	set myjid [chat::our_jid $chatid]
-	set mynick [chat::get_nick $connid $myjid $type]
+	set mynick [chat::get_nick $xlib $myjid $type]
 
 	::richtext::property_add mynick $mynick
 	::richtext::render_message $chatw $body ""
@@ -29,7 +29,7 @@
 
     $chatw tag add MSG-$nick MSGLEFT "end - 1 char"
 
-    if {![catch {::plugins::mucignore::is_ignored $connid $from $type} ignore] && \
+    if {![catch {::plugins::mucignore::is_ignored $xlib $from $type} ignore] && \
 	    $ignore != ""} {
 	$chatw tag add $ignore {MSGLEFT linestart} {end - 1 char}
     }

Modified: trunk/tkabber/plugins/chat/draw_timestamp.tcl
===================================================================
--- trunk/tkabber/plugins/chat/draw_timestamp.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/chat/draw_timestamp.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -8,9 +8,10 @@
 		   \[%a %b %d %H:%M:%S %Z %Y\] -\
 		   \[Thu Jan 01 03:00:00 MSK 1970\]"] \
     -type string -group Chat
+
 custom::defvar options(delayed_timestamp_format) {[%m/%d %R]} \
     [::msgcat::mc "Format of timestamp in delayed chat messages delayed\
-for more than 24 hours."] \
+		   for more than 24 hours."] \
     -type string -group Chat
 
 proc draw_timestamp {chatid from type body x} {
@@ -18,7 +19,7 @@
 
     set chatw [chat::chat_win $chatid]
 
-    set seconds [jlib::x_delay $x]
+    set seconds [::xmpp::delay::parse $x]
     set seconds1 [expr {[clock seconds] - 24*60*60 + 60}]
     if {$seconds <= $seconds1} {
 	set format $options(delayed_timestamp_format)
@@ -28,4 +29,6 @@
 
     $chatw insert end [clock format $seconds -format $format]
 }
+
 hook::add draw_message_hook [namespace current]::draw_timestamp 9
+

Modified: trunk/tkabber/plugins/chat/draw_xhtml_message.tcl
===================================================================
--- trunk/tkabber/plugins/chat/draw_xhtml_message.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/chat/draw_xhtml_message.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -22,18 +22,17 @@
     if {!$options(enable)} return
 
     foreach xelem $x {
-	jlib::wrapper:splitxml $xelem tag vars isempty chdata children
+	::xmpp::xml::split $xelem tag xmlns attrs cdata subels
 	
-	if {[cequal [jlib::wrapper:getattr $vars xmlns] \
-		 http://jabber.org/protocol/xhtml-im]} {
-	    set xhtml $children
+	if {[string equal $xmlns http://jabber.org/protocol/xhtml-im]} {
+	    set xhtml $subels
 	}
     }
 
     if {![info exists xhtml]} return
 
     foreach el $xhtml {
-	jlib::wrapper:splitxml $el tag vars isempty chdata children
+	::xmpp::xml::split $el tag xmlns attrs cdata subels
 	
 	if {$tag == "body"} {
 	    set body $el
@@ -48,10 +47,10 @@
 	set tag they
     }
 
-    set connid [chat::get_connid $chatid]
+    set xlib [chat::get_xlib $chatid]
 
     set chatw [chat::chat_win $chatid]
-    set nick [chat::get_nick $connid $from $type]
+    set nick [chat::get_nick $xlib $from $type]
 
 
     set cw [chat::winid $chatid]
@@ -60,7 +59,7 @@
 	# TODO
 	$chatw insert end "<$nick>" $tag " "
 	set myjid [chat::our_jid $chatid]
-	set mynick [chat::get_nick $connid $myjid $type]
+	set mynick [chat::get_nick $xlib $myjid $type]
 
 	if {[crange $body 0 [expr [clength $mynick] + 1]] == "${mynick}: "} {
 	    $chatw insert end $mynick me
@@ -112,8 +111,8 @@
 proc xhtml::add_xhtml {cw xhtml} {
     variable state
 
-    jlib::wrapper:splitxml $xhtml name vars isempty chdata childrens
-    set nextchdata [jlib::wrapper:get_subchdata $xhtml]
+    ::xmpp::xml::split $xhtml name attrs cdata subels
+    set nextcdata [::xmpp::xml::getFirstCdata $xhtml]
 
     push
 
@@ -122,7 +121,7 @@
     set suffix ""
     set pre 0
 
-    parse_style [jlib::wrapper:getattr $vars style]
+    parse_style [::xmpp::xml::getAttr $attrs style]
 
     switch -- $name {
 	h1 -
@@ -168,13 +167,13 @@
 	    set state(slant) [expr {!$state(slant)}]
 	}
 	a {
-	    set url [jlib::wrapper:getattr $vars href]
+	    set url [::xmpp::xml::getAttr $attrs href]
 	    lappend tag [get_url_tag $cw $url]
 	}
 	img {
-	    set imgsrc [jlib::wrapper:getattr $vars src]
-	    set imgalt [jlib::wrapper:getattr $vars alt]
-	    set nextchdata "\[$imgalt\]"
+	    set imgsrc [::xmpp::xml::getAttr $attrs src]
+	    set imgalt [::xmpp::xml::getAttr $attrs alt]
+	    set nextcdata "\[$imgalt\]"
 	    lappend tag [get_url_tag $cw $imgsrc]
 	}
 	span {}
@@ -183,14 +182,14 @@
 	    incr state(lmargin2) 32
 	}
 	q {
-	    #set nextchdata "\"[string trim $chdata]\""
-	    #set childrens {}
+	    #set nextcdata "\"[string trim $cdata]\""
+	    #set subels {}
 	    set prefix \"
 	    set suffix \"
 	}
 	pre {
-	    set nextchdata $chdata
-	    set childrens {}
+	    set nextcdata $cdata
+	    set subels {}
 	    set pre 1
 	}
 
@@ -223,48 +222,46 @@
 	    set state(list_style) ol
 	    set state(list_counter) 0
 	}
-
-
     }
 
     # TODO
     set tag [concat $tag [get_tags $cw]]
 
     if {!$pre} {
-	regsub -all {[[:space:]]+} $nextchdata " " formated
+	regsub -all {[[:space:]]+} $nextcdata " " formatted
     } else {
-	set formated [string trim $nextchdata "\n"]
+	set formatted [string trim $nextcdata "\n"]
     }
-    if {$state(afterspace) && [string index $formated 0] == " "} {
-	set formated [crange $formated 1 end]
+    if {$state(afterspace) && [string index $formatted 0] == " "} {
+	set formatted [crange $formatted 1 end]
     }
 
-    if {$formated != ""} {
-	set state(afterspace) [expr {[string index $formated end] == " "}]
+    if {$formatted != ""} {
+	set state(afterspace) [expr {[string index $formatted end] == " "}]
     }
 
     ::richtext::render_message $cw $prefix $tag -nonewline
-    ::richtext::render_message $cw $formated $tag -nonewline
+    ::richtext::render_message $cw $formatted $tag -nonewline
 
-    if {$formated != ""} {
+    if {$formatted != ""} {
 	set state(lastnl) 0
     }
 
-    foreach xelem $childrens {
+    foreach xelem $subels {
 	add_xhtml $cw $xelem
-	set nextchdata [jlib::wrapper:get_fchdata $xelem]
+	set nextcdata [::xmpp::xml::getNextCdata $xelem]
 
-	regsub -all {[[:space:]]+} $nextchdata " " formated
-	if {$state(afterspace) && [string index $formated 0] == " "} {
-	    set formated [crange $formated 1 end]
+	regsub -all {[[:space:]]+} $nextcdata " " formatted
+	if {$state(afterspace) && [string index $formatted 0] == " "} {
+	    set formatted [crange $formatted 1 end]
 	}
 
-	if {$formated != ""} {
-	    set state(afterspace) [expr {[string index $formated end] == " "}]
+	if {$formatted != ""} {
+	    set state(afterspace) [expr {[string index $formatted end] == " "}]
 	}
 
-	::richtext::render_message $cw $formated $tag -nonewline
-	if {$formated != ""} {
+	::richtext::render_message $cw $formatted $tag -nonewline
+	if {$formatted != ""} {
 	    set state(lastnl) 0
 	}
     }

Modified: trunk/tkabber/plugins/chat/events.tcl
===================================================================
--- trunk/tkabber/plugins/chat/events.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/chat/events.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -20,8 +20,7 @@
 
     if {$type == "chat"} {
 	foreach x $xs {
-	    jlib::wrapper:splitxml $x tag vars isempty chdata children
-	    set xmlns [jlib::wrapper:getattr $vars xmlns]
+	    ::xmpp::xml::split $x tag xmlns attrs cdata subels
 	    switch -- $xmlns \
 		$::NS(event) {
 		    return [process_x_event \
@@ -41,21 +40,21 @@
     variable options
     variable events
 
-    set connid [chat::get_connid $chatid]
+    set xlib [chat::get_xlib $chatid]
     set jid [chat::get_jid $chatid]
     set cw [chat::winid $chatid]
 
-    jlib::wrapper:splitxml $x tag vars isempty chdata children
+    ::xmpp::xml::split $x tag xmlns attrs cdata subels
 
     set offline 0
     set delivered 0
     set displayed 0
     set composing 0
     set id 0
-    foreach child $children {
-	jlib::wrapper:splitxml $child \
-	    tag1 vars1 isempty1 chdata1 children1
-	switch -- $tag1 {
+    foreach subel $subels {
+	::xmpp::xml::split $subel stag sxmlns sattrs scdata ssubels
+
+	switch -- $stag {
 	    offline   {set offline 1}
 	    delivered {set delivered 1}
 	    displayed {set displayed 1}
@@ -85,31 +84,31 @@
 
 	if {!$options(enable)} return
 
-	if {[get_jid_status $connid $jid] == "unavailable"} return
+	if {[get_jid_status $xlib $jid] == "unavailable"} return
 
-	lappend eventtags [jlib::wrapper:createtag id \
-			       -chdata $::chat::chats(id,$chatid)]
+	lappend eventtags [::xmpp::xml::create id \
+			       -cdata $::chat::chats(id,$chatid)]
 	if {$delivered} {
-	    lappend eventtags [jlib::wrapper:createtag delivered]
+	    lappend eventtags [::xmpp::xml::create delivered]
 	}
 	if {$displayed} {
 	    if {$::usetabbar} {
 		set page [crange [win_id tab $cw] 1 end]
 		if {[.nb raise] == $page} {
-		    lappend eventtags [jlib::wrapper:createtag displayed]
+		    lappend eventtags [::xmpp::xml::create displayed]
 		    set events(displayed,$chatid) 0
 		}
 	    } else {
-		lappend eventtags [jlib::wrapper:createtag displayed]
+		lappend eventtags [::xmpp::xml::create displayed]
 		set events(displayed,$chatid) 0
 	    }
 	}
 	if {[llength $eventtags] > 1} {
-	    lappend xlist [jlib::wrapper:createtag x \
-			       -vars [list xmlns $::NS(event)] \
-			       -subtags $eventtags]
+	    lappend xlist [::xmpp::xml::create x \
+				-xmlns $::NS(event) \
+				-subelements $eventtags]
 
-	    jlib::send_msg $from -xlist $xlist -connection $connid
+	    ::xmpp::sendMessage $xlib $from -xlist $xlist
 	}
     }
     return
@@ -166,24 +165,24 @@
     if {![info exists events(displayed,$chatid)] || \
 	    !$events(displayed,$chatid)} return
 
-    set connid [chat::get_connid $chatid]
+    set xlib [chat::get_xlib $chatid]
     set jid [chat::get_jid $chatid]
 
     set events(displayed,$chatid) 0
 
     if {!$options(enable)} return
 
-    if {[get_jid_status $connid $jid] == "unavailable"} return
+    if {[get_jid_status $xlib $jid] == "unavailable"} return
 
-    lappend eventtags [jlib::wrapper:createtag id \
-			   -chdata $::chat::chats(id,$chatid)]
-    lappend eventtags [jlib::wrapper:createtag displayed]
+    lappend eventtags [::xmpp::xml::create id \
+			   -cdata $::chat::chats(id,$chatid)]
+    lappend eventtags [::xmpp::xml::create displayed]
 
-    lappend xlist [jlib::wrapper:createtag x \
-		       -vars [list xmlns $::NS(event)] \
-		       -subtags $eventtags]
+    lappend xlist [::xmpp::xml::create x \
+			-xmlns $::NS(event) \
+			-subelements $eventtags]
 
-    jlib::send_msg $jid -xlist $xlist -connection $connid
+    ::xmpp::sendMessage $xlib $jid -xlist $xlist
 }
 
 hook::add raise_chat_tab_hook [namespace current]::events::send_event_on_raise
@@ -197,24 +196,24 @@
     if {![info exists events(composing,$chatid)] || \
 	    !$events(composing,$chatid)} return
 
-    set connid [chat::get_connid $chatid]
+    set xlib [chat::get_xlib $chatid]
     set jid [chat::get_jid $chatid]
 
     set events(composing,$chatid) 0
 
     if {!$options(enable)} return
 
-    if {[get_jid_status $connid $jid] == "unavailable"} return
+    if {[get_jid_status $xlib $jid] == "unavailable"} return
 
-    lappend eventtags [jlib::wrapper:createtag id \
-			   -chdata $::chat::chats(id,$chatid)]
-    lappend eventtags [jlib::wrapper:createtag composing]
+    lappend eventtags [::xmpp::xml::create id \
+			   -cdata $::chat::chats(id,$chatid)]
+    lappend eventtags [::xmpp::xml::create composing]
 
-    lappend xlist [jlib::wrapper:createtag x \
-		       -vars [list xmlns $::NS(event)] \
-		       -subtags $eventtags]
+    lappend xlist [::xmpp::xml::create x \
+			-xmlns $::NS(event) \
+			-subelements $eventtags]
 
-    jlib::send_msg $jid -xlist $xlist -connection $connid
+    ::xmpp::sendMessage $xlib $jid -xlist $xlist
 }
 
 proc events::setup_ui {chatid type} {
@@ -253,13 +252,13 @@
 	return
     }
 
-    lappend events [jlib::wrapper:createtag offline]
-    lappend events [jlib::wrapper:createtag delivered]
-    lappend events [jlib::wrapper:createtag displayed]
-    lappend events [jlib::wrapper:createtag composing]
-    lappend var [jlib::wrapper:createtag x \
-		     -vars [list xmlns $::NS(event)] \
-		     -subtags $events]
+    lappend events [::xmpp::xml::create offline]
+    lappend events [::xmpp::xml::create delivered]
+    lappend events [::xmpp::xml::create displayed]
+    lappend events [::xmpp::xml::create composing]
+    lappend var [::xmpp::xml::create x \
+			-xmlns $::NS(event) \
+			-subelements $events]
     return
 }
 

Modified: trunk/tkabber/plugins/chat/info_commands.tcl
===================================================================
--- trunk/tkabber/plugins/chat/info_commands.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/chat/info_commands.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -79,7 +79,7 @@
 	return
     }
 
-    set connid [chat::get_connid $chatid]
+    set xlib [chat::get_xlib $chatid]
     set jid [chat::get_jid $chatid]
     set jids {}
     set vcard_jids {}
@@ -93,7 +93,7 @@
     } else {
 	if {[cequal $name ""]} {
 	    set bare_jid [node_and_server_from_jid $jid]
-	    set full_jids [::get_jids_of_user $connid $bare_jid]
+	    set full_jids [::get_jids_of_user $xlib $bare_jid]
 	    if {[lsearch $full_jids $jid] >= 0} {
 		set jids [list $jid]
 	    } elseif {[lempty $full_jids]} {
@@ -105,7 +105,7 @@
 	}
     }
     if {[cequal $jids {}]} {
-	lassign [roster_lookup $connid $name] jids vcard_jids
+	lassign [roster_lookup $xlib $name] jids vcard_jids
 	if {[cequal $jids {}]} {
 	    set jids [list $name]
 	}
@@ -116,11 +116,11 @@
 
     if {[cequal $command vcard]} {
 	foreach jid $vcard_jids {
-	    request_vcard $connid $chatid $jid
+	    request_vcard $xlib $chatid $jid
 	}
     } else {
 	foreach jid $jids {
-	    request_iq $command $connid $chatid $jid
+	    request_iq $command $xlib $chatid $jid
 	}
     }
     return stop
@@ -131,14 +131,14 @@
 
 ##############################################################################
 
-proc chatinfo::roster_lookup {connid name} {
+proc chatinfo::roster_lookup {xlib name} {
     set ret {}
     set ret1 {}
-    foreach jid [roster::get_jids $connid] {
-	set rname [roster::get_label $connid $jid]
+    foreach jid [roster::get_jids $xlib] {
+	set rname [roster::get_label $xlib $jid]
 	if {[cequal $rname $name]} {
 	    set bare_jid [node_and_server_from_jid $jid]
-	    set full_jids [::get_jids_of_user $connid $bare_jid]
+	    set full_jids [::get_jids_of_user $xlib $bare_jid]
 	    if {![cequal $full_jids {}]} {
 		set ret [concat $ret $full_jids]
 	    } else {
@@ -169,10 +169,10 @@
 	}
 	if {!$q} return
 
-	set connid [chat::get_connid $chatid]
+	set xlib [chat::get_xlib $chatid]
 	set names {}
-	foreach jid [roster::get_jids $connid] {
-	    lappend names "[roster::get_label $connid $jid] "
+	foreach jid [roster::get_jids $xlib] {
+	    lappend names "[roster::get_label $xlib $jid] "
 	}
 	set comps [concat $comps [lsort -unique $names]]
     }
@@ -183,31 +183,29 @@
 
 ##############################################################################
 
-proc chatinfo::request_iq {type connid chatid jid} {
-    jlib::send_iq get \
-	[jlib::wrapper:createtag query \
-	    -vars [list xmlns jabber:iq:$type]] \
+proc chatinfo::request_iq {type xlib chatid jid} {
+    ::xmpp::sendIQ $xlib get \
+	-query [::xmpp::xml::create query \
+			-xmlns jabber:iq:$type] \
 	-to $jid \
-	-connection $connid \
 	-command [list [namespace current]::parse_info_iq$type $chatid $jid]
 }
 
 ##############################################################################
 
-proc chatinfo::request_vcard {connid chatid jid} {
-    jlib::send_iq get \
-	[jlib::wrapper:createtag vCard \
-	    -vars [list xmlns vcard-temp]] \
+proc chatinfo::request_vcard {xlib chatid jid} {
+    ::xmpp::sendIQ $xlib get \
+	-query [::xmpp::xml::create vCard \
+			-xmlns vcard-temp] \
 	-to $jid \
-	-connection $connid \
 	-command [list [namespace current]::parse_info_vcard $chatid $jid]
 }
 
 ##############################################################################
 
 proc chatinfo::whois {chatid jid} {
-    set connid [chat::get_connid $chatid]
-    set real_jid [muc::get_real_jid $connid $jid]
+    set xlib [chat::get_xlib $chatid]
+    set real_jid [muc::get_real_jid $xlib $jid]
     if {$real_jid != ""} {
 	return " ($real_jid)"
     } else {
@@ -224,16 +222,16 @@
     }
 
     set rjid [whois $chatid $jid]
-    if {![cequal $res OK]} {
+    if {![cequal $res ok]} {
 	chat::add_message $chatid $jid error \
 	    [::msgcat::mc "time %s%s: %s" $jid $rjid [error_to_string $child]] {}
 	return
     }
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
+    ::xmpp::xml::split $child tag xmlns attrs cdata subels
 
-    if {[cequal [jlib::wrapper:getattr $vars xmlns] jabber:iq:time]} {
-	userinfo::parse_iqtime_item $jid $children
+    if {[string equal $xmlns jabber:iq:time]} {
+	userinfo::parse_iqtime_item $jid $subels
     }
     set message [::msgcat::mc "time %s%s:" $jid $rjid]
     foreach {i j} [list time [::msgcat::mc "Time:"] \
@@ -256,18 +254,18 @@
     }
 
     set rjid [whois $chatid $jid]
-    if {![cequal $res OK]} {
+    if {![cequal $res ok]} {
 	chat::add_message $chatid $jid error \
 	    [::msgcat::mc "last %s%s: %s" $jid $rjid [error_to_string $child]] {}
 	return
     }
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
+    ::xmpp::xml::split $child tag xmlns attrs cdata subels
 
-    if {[cequal [jlib::wrapper:getattr $vars xmlns] jabber:iq:last]} {
+    if {[string equal $xmlns jabber:iq:last]} {
 	set ::userinfo::userinfo(lastseconds,$jid) \
-	    [format_time [jlib::wrapper:getattr $vars seconds]]
-	set ::userinfo::userinfo(lastdesc,$jid) $chdata
+	    [format_time [::xmpp::xml::getAttr $attrs seconds]]
+	set ::userinfo::userinfo(lastdesc,$jid) $cdata
     }
     set message [::msgcat::mc "last %s%s:" $jid $rjid]
     foreach {i j} [list lastseconds [::msgcat::mc "Interval:"] \
@@ -289,16 +287,16 @@
     }
 
     set rjid [whois $chatid $jid]
-    if {![cequal $res OK]} {
+    if {![cequal $res ok]} {
 	chat::add_message $chatid $jid error \
 	    [::msgcat::mc "version %s%s: %s" $jid $rjid [error_to_string $child]] {}
 	return
     }
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
+    ::xmpp::xml::split $child tag xmlns attrs cdata subels
 
-    if {[cequal [jlib::wrapper:getattr $vars xmlns] jabber:iq:version]} {
-	userinfo::parse_iqversion_item $jid $children
+    if {[string equal $xmlns jabber:iq:version]} {
+	userinfo::parse_iqversion_item $jid $subels
     }
 
     set message [::msgcat::mc "version %s%s:" $jid $rjid]
@@ -324,15 +322,15 @@
     }
 
     set rjid [whois $chatid $jid]
-    if {![cequal $res OK]} {
+    if {![cequal $res ok]} {
 	chat::add_message $chatid $jid error \
 	    [::msgcat::mc "vcard %s%s: %s" $jid $rjid [error_to_string $child]] {}
 	return
     }
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
+    ::xmpp::xml::split $child tag xmlns attrs cdata subels
 
-    foreach item $children {
+    foreach item $subels {
 	userinfo::parse_vcard_item $jid $item
     }
     set message [::msgcat::mc "vcard %s%s:" $jid $rjid]

Modified: trunk/tkabber/plugins/chat/irc_commands.tcl
===================================================================
--- trunk/tkabber/plugins/chat/irc_commands.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/chat/irc_commands.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -51,7 +51,7 @@
 	return
     }
 
-    set connid [chat::get_connid $chatid]
+    set xlib [chat::get_xlib $chatid]
     set jid [chat::get_jid $chatid]
 
     switch -- $command {
@@ -63,7 +63,7 @@
 		} else {
 		    set password ""
 		}
-		muc::join_group $connid $jid $nick $password
+		muc::join_group $xlib $jid $nick $password
 		debugmsg plugins "NICK -> JOIN: $nick"
 	    } else {
 		muc::change_nick $chatid $nick
@@ -72,8 +72,7 @@
 	}
 	subject {
 	    if {![cequal $type groupchat]} return
-	    message::send_msg $jid -connection $connid \
-		-type groupchat -subject $subject
+	    message::send_msg $xlib $jid -type groupchat -subject $subject
 	    debugmsg plugins "SUBJECT: $subject"
 	}
 	show_subject {
@@ -82,9 +81,9 @@
 	}
 	invite {
 	    if {[cequal $type groupchat]} {
-		muc::invite_muc $connid $jid $to $reason
+		muc::invite_muc $xlib $jid $to $reason
 	    } else {
-		muc::invite_muc $connid $to $jid $reason
+		muc::invite_muc $xlib $to $jid $reason
 	    }
 	    debugmsg plugins "INVITE: $to $reason"
 	}
@@ -97,11 +96,11 @@
 		}
 	    }
 	    if {[catch {
-		     get_our_groupchat_nick [chat::chatid $connid $room]
+		     get_our_groupchat_nick [chat::chatid $xlib $room]
 		 } nick]} {
 		set nick [get_group_nick $room $::gr_nick]
 	    }
-	    muc::join_group $connid \
+	    muc::join_group $xlib \
 			    $room \
 			    $nick \
 			    $password
@@ -110,7 +109,7 @@
 	msg {
 	    if {[cequal $type groupchat] && \
 		    $nick != "" && $body != ""} {
-		chat::open_to_user $connid $jid/$nick -message $body
+		chat::open_to_user $xlib $jid/$nick -message $body
 		debugmsg plugins "MSG: $jid/$nick: $body"
 	    } else {
 		chat::add_message $chatid $jid error \
@@ -159,15 +158,15 @@
 	set prefix $plugins::completion::options(prefix)
 	set suffix $plugins::completion::options(suffix)
         set jidcomps {}
-	set connid [chat::get_connid $chatid]
+	set xlib [chat::get_xlib $chatid]
 	if {[chat::is_groupchat $chatid]} {
-	    foreach jid [roster::get_jids $connid] {
-		if {[roster::itemconfig $connid $jid -isuser]} {
+	    foreach jid [roster::get_jids $xlib] {
+		if {[roster::itemconfig $xlib $jid -isuser]} {
 		    lappend jidcomps $prefix$jid$suffix
 		}
 	    }
 	} else {
-	    foreach chatid1 [lfilter chat::is_groupchat [chat::opened $connid]] {
+	    foreach chatid1 [lfilter chat::is_groupchat [chat::opened $xlib]] {
 		set jid [chat::get_jid $chatid1]
 		lappend jidcomps $prefix$jid$suffix
 	    }

Modified: trunk/tkabber/plugins/chat/log_on_open.tcl
===================================================================
--- trunk/tkabber/plugins/chat/log_on_open.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/chat/log_on_open.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -19,10 +19,10 @@
 
     if {$type != "chat"} return
 
-    set connid [chat::get_connid $chatid]
+    set xlib [chat::get_xlib $chatid]
     set jid [chat::get_jid $chatid]
     set bare_jid [node_and_server_from_jid $jid]
-    set gc [chat::is_groupchat [chat::chatid $connid $bare_jid]]
+    set gc [chat::is_groupchat [chat::chatid $xlib $bare_jid]]
 
     if {!$gc} {
 	set log_jid $bare_jid
@@ -40,10 +40,7 @@
 	set x {}
 	if {[info exists tmp(timestamp)]} {
 	    set seconds [clock scan $tmp(timestamp) -gmt 1]
-	    set date [clock format $seconds -format "%Y%m%dT%H:%M:%S" -gmt 1]
-	    lappend x [jlib::wrapper:createtag x \
-			   -vars [list xmlns "jabber:x:delay" \
-				       stamp $date]]
+	    lappend x [::xmpp::delay::create $seconds]
 	}
 	if {[info exists tmp(jid)]} {
 	    if {$tmp(jid) == ""} {
@@ -51,7 +48,7 @@
 		set from ""
 	    } elseif {(!$gc && [node_and_server_from_jid $tmp(jid)] != $bare_jid) || \
 		 $gc && $tmp(jid) != $jid} {
-		set from [jlib::connection_jid $connid]
+		set from [connection_jid $xlib]
 	    } else {
 		set from $jid
 	    }
@@ -61,8 +58,7 @@
 	# Don't log this message. Request this by creating very special 'empty'
 	# tag which can't be received from the peer.
 	# TODO: Create more elegant mechanism
-	lappend x [jlib::wrapper:createtag "" \
-		       -vars [list xmlns "tkabber:x:nolog"]]
+	lappend x [::xmpp::xml::create "" -xmlns tkabber:x:nolog]
 
 	chat::add_message $chatid $from $type $tmp(body) $x
     }

Modified: trunk/tkabber/plugins/chat/logger.tcl
===================================================================
--- trunk/tkabber/plugins/chat/logger.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/chat/logger.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -57,24 +57,24 @@
 
 #############################################################################
 
-proc ::logger::add_menu_item {state category m connid jid} {
+proc ::logger::add_menu_item {state category m xlib jid} {
     switch -- $category {
 	roster {
-	    set rjid [roster::find_jid $connid $jid]
+	    set rjid [roster::find_jid $xlib $jid]
 	    if {$rjid != ""} {
 		set jid $rjid
 	    }
 	}
 	chat {
 	    set nas [node_and_server_from_jid $jid]
-	    if {![chat::is_groupchat [chat::chatid $connid $nas]]} {
+	    if {![chat::is_groupchat [chat::chatid $xlib $nas]]} {
 		set jid $nas
 	    }
 	}
     }
     $m add command -label [::msgcat::mc "Show history"] \
 	   -state $state \
-           -command [list logger::show_log $jid -connection $connid]
+           -command [list logger::show_log $jid -connection $xlib]
 }
 
 #############################################################################
@@ -196,23 +196,22 @@
     if {$type == "chat" && !$options(log_chat)} return
     if {$type == "groupchat" && !$options(log_groupchat)} return
 
-    set connid [chat::get_connid $chatid]
+    set xlib [chat::get_xlib $chatid]
     set jid [chat::get_jid $chatid]
     set nas [node_and_server_from_jid $jid]
-    if {$type == "chat" && ![chat::is_groupchat [chat::chatid $connid $nas]]} {
+    if {$type == "chat" && ![chat::is_groupchat [chat::chatid $xlib $nas]]} {
 	set jid $nas
     }
 
-    set nick [chat::get_nick $connid $from $type]
+    set nick [chat::get_nick $xlib $from $type]
 
-    set seconds [jlib::x_delay $x]
+    set seconds [::xmpp::delay::parse $x]
     foreach xelem $x {
-	jlib::wrapper:splitxml $xelem tag vars isempty chdata children
+	::xmpp::xml::split $xelem tag xmlns attrs cdata subels
 	
 	# Don't log message if this 'empty' tag is present. It indicates
 	# messages history in chat window.
-	if {[cequal $tag ""] && \
-		[cequal [jlib::wrapper:getattr $vars xmlns] tkabber:x:nolog]} {
+	if {[string equal $tag ""] && [string equal $xmlns tkabber:x:nolog]} {
 	    return
 	}
     }
@@ -253,12 +252,12 @@
 
     foreach {key val} $args {
 	switch -- $key {
-	    -connection { set connid $val }
+	    -connection { set xlib $val }
 	    -subdirs { set subdirs $val }
 	}
     }
-    if {![info exists connid]} {
-	set connid [lindex [jlib::connections] 0]
+    if {![info exists xlib]} {
+	set xlib [lindex [connections] 0]
     }
 
     set logfile [jid_to_filename $jid]
@@ -321,7 +320,7 @@
 					  $mf.mcombo $logfile $l $mynick]]
     pack $mcombo -side left
 
-    hook::run open_log_post_hook $connid $jid $lw
+    hook::run open_log_post_hook $xlib $jid $lw
 
     wm deiconify $lw
 }
@@ -580,14 +579,12 @@
     puts $fd {<?xml version="1.0" encoding="UTF-8"?>}
     puts $fd {<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">}
     puts $fd {<html xmlns="http://www.w3.org/1999/xhtml">}
-    set head [jlib::wrapper:createtag head \
-		  -subtags [list [jlib::wrapper:createtag link \
-				      -vars {
-					  rel stylesheet
-					  type text/css
-					  href tkabber-logs.css
-				      }]]]
-    puts $fd [jlib::wrapper:createxml $head]
+    set head [::xmpp::xml::create head \
+		  -subelement [::xmpp::xml::create link \
+				      -attrs {rel stylesheet
+					      type text/css
+					      href tkabber-logs.css}]]
+    puts $fd [::xmpp::xml::toText $head]
 
 
     foreach vars $hist {
@@ -598,9 +595,9 @@
 	if {[info exists tmp(timestamp)]} {
 	    set seconds [clock scan $tmp(timestamp) -gmt 1]
 	    set timestamp [clock format $seconds -format {[%Y-%m-%d %X]}]
-	    lappend subtags [jlib::wrapper:createtag span \
-				 -vars {class timestamp} \
-				 -chdata $timestamp]
+	    lappend subtags [::xmpp::xml::create span \
+				    -attrs {class timestamp} \
+				    -cdata $timestamp]
 	}
 	if {[info exists tmp(nick)] && $tmp(nick) != ""} {
 	    if {$tmp(nick) == $mynick} {
@@ -614,30 +611,30 @@
 	    } else {
 		set nick "<$tmp(nick)> "
 	    }
-	    lappend subtags [jlib::wrapper:createtag span \
-				 -vars [list class $tag] \
-				 -chdata $nick]
+	    lappend subtags [::xmpp::xml::create span \
+				    -attrs [list class $tag] \
+				    -cdata $nick]
 
 	    if {[info exists tmp(body)]} {
-		lappend subtags [jlib::wrapper:createtag span \
-				     -vars [list class body] \
-				     -chdata "$tmp(body)"]
+		lappend subtags [::xmpp::xml::create span \
+					-attrs {class body} \
+					-cdata "$tmp(body)"]
 	    }
 	} else {
 	    if {[info exists tmp(body)]} {
-		lappend subtags [jlib::wrapper:createtag span \
-				     -vars [list class server] \
-				     -chdata "--- $tmp(body)"]
+		lappend subtags [::xmpp::xml::create span \
+					-attrs {class server} \
+					-cdata "--- $tmp(body)"]
 	    }
 	}
 	#if {![$l compare "end -1 chars linestart" == "end -1 chars"]} {
 	#    puts "\n"
 	#}
-	set msg [jlib::wrapper:createtag div \
-		     -vars [list class message] \
-		     -subtags $subtags]
+	set msg [::xmpp::xml::create div \
+			-attrs {class message} \
+			-subelements $subtags]
 
-	puts $fd [jlib::wrapper:createxml $msg]
+	puts $fd [::xmpp::xml::toText $msg]
     }
     
     puts $fd {</html>}

Modified: trunk/tkabber/plugins/chat/me_command.tcl
===================================================================
--- trunk/tkabber/plugins/chat/me_command.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/chat/me_command.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -10,9 +10,9 @@
 	    set tag they
 	}
 
-	set connid [chat::get_connid $chatid]
+	set xlib [chat::get_xlib $chatid]
 	set chatw [chat::chat_win $chatid]
-	set nick [chat::get_nick $connid $from $type]
+	set nick [chat::get_nick $xlib $from $type]
 	set cw [chat::winid $chatid]
 
 	$chatw insert end "* $nick" [list $tag NICK-$nick] " "
@@ -22,7 +22,7 @@
 
 	if {[cequal $type groupchat]} {
 	    set myjid [chat::our_jid $chatid]
-	    set mynick [chat::get_nick $connid $myjid $type]
+	    set mynick [chat::get_nick $xlib $myjid $type]
 
 	    ::richtext::property_add mynick $mynick
 	    ::richtext::render_message $chatw $body $tag
@@ -32,7 +32,7 @@
 
         $chatw tag add NICKMSG-$nick MSGLEFT "end - 1 char"
 
-	if {![catch {::plugins::mucignore::is_ignored $connid $from $type} ignore] && \
+	if {![catch {::plugins::mucignore::is_ignored $xlib $from $type} ignore] && \
 		$ignore != ""} {
 	    $chatw tag add $ignore {MSGLEFT linestart} {end - 1 char}
 	}

Modified: trunk/tkabber/plugins/chat/muc_ignore.tcl
===================================================================
--- trunk/tkabber/plugins/chat/muc_ignore.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/chat/muc_ignore.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -3,7 +3,7 @@
 #
 # A note on runtime ruleset format:
 # * A hash is used to hold ignore rules at runtime; each key
-#   uniquely refers to its related "connid, room, occupant,
+#   uniquely refers to its related "xlib, room, occupant,
 #   message type" tuple; the existence of a key is used to
 #   determine the fact of some type of a room occupant messages
 #   being ignored.
@@ -126,16 +126,16 @@
     unset tags($roomjid)
 }
 
-# Returns bare JID of the session identified by $connid
-proc mucignore::session_bare_jid {connid} {
-    ::node_and_server_from_jid [::jlib::connection_jid $connid]
+# Returns bare JID of the session identified by $xlib
+proc mucignore::session_bare_jid {xlib} {
+    ::node_and_server_from_jid [connection_jid $xlib]
 }
 
 # Tries to get the real bare JID of the room occupant identified
 # by the $room_occupant_jid; returns that JID if it's available,
 # empty string otherwise.
-proc mucignore::get_real_bare_jid {connid room_occupant_jid} {
-    set real_jid [::muc::get_real_jid $connid $room_occupant_jid]
+proc mucignore::get_real_bare_jid {xlib room_occupant_jid} {
+    set real_jid [::muc::get_real_jid $xlib $room_occupant_jid]
     if {$real_jid != {}} {
 	return [::node_and_server_from_jid $real_jid]
     } else {
@@ -157,10 +157,10 @@
 }
 
 # Creates an ignore rule suitable for using as a key to a hash of rules.
-# The $connid parameter is converted to the session's bare JID first.
+# The $xlib parameter is converted to the session's bare JID first.
 # It's just a convenient wrapper around [mkrulekey].
-proc mucignore::mkrule {connid jid type} {
-    mkrulekey [session_bare_jid $connid] $jid $type
+proc mucignore::mkrule {xlib jid type} {
+    mkrulekey [session_bare_jid $xlib] $jid $type
 }
 
 # Splits given rule into the list of [entity jid type], where:
@@ -173,12 +173,12 @@
     split $rule \u0000
 }
 
-proc mucignore::setup_muc_menu {m connid jid} {
+proc mucignore::setup_muc_menu {m xlib jid} {
     # TODO
     return
     $m add command \
 	-label [::msgcat::mc "Edit MUC ignore rules"] \
-	-command [list [namespace current]::editor::open $connid $jid]
+	-command [list [namespace current]::editor::open $xlib $jid]
 }
 
 proc mucignore::on_init {} {
@@ -189,25 +189,25 @@
         -command [list [namespace current]::editor::open {} {}]
 }
 
-proc mucignore::setup_private_muc_chat_menu {m connid jid} {
+proc mucignore::setup_private_muc_chat_menu {m xlib jid} {
     set room [::node_and_server_from_jid $jid]
-    if {![::chat::is_groupchat [::chat::chatid $connid $room]]} return
+    if {![::chat::is_groupchat [::chat::chatid $xlib $room]]} return
 
-    setup_occupant_menu $m $connid $jid
+    setup_occupant_menu $m $xlib $jid
 }
 
 # Prepares two global variables mirroring the current state of
 # ignoring for the room occupant on which groupchat roster nick
 # the menu is being created. They are used to represent
 # ignore state checkbutton menu entries.
-proc mucignore::setup_occupant_menu {m connid jid} {
+proc mucignore::setup_occupant_menu {m xlib jid} {
     variable ignored
     variable menustate
 
     set our_nick [::get_our_groupchat_nick [
-	::chat::chatid $connid [
+	::chat::chatid $xlib [
 	    ::node_and_server_from_jid $jid]]]
-    set nick [::chat::get_nick $connid $jid groupchat]
+    set nick [::chat::get_nick $xlib $jid groupchat]
 
     if {$nick == $our_nick} {
 	# don't allow to ignore ourselves
@@ -217,8 +217,8 @@
     }
 
     foreach type {groupchat chat} {
-	set menustate($connid,$jid,$type) [
-	    info exists ignored([mkrule $connid $jid $type])]
+	set menustate($xlib,$jid,$type) [
+	    info exists ignored([mkrule $xlib $jid $type])]
     }
 
     set sm [menu $m.mucignore -tearoff 0]
@@ -227,32 +227,32 @@
 	-label [::msgcat::mc "Ignore"]
 
     $sm add checkbutton -label [::msgcat::mc "Ignore groupchat messages"] \
-	-variable [namespace current]::menustate($connid,$jid,groupchat) \
+	-variable [namespace current]::menustate($xlib,$jid,groupchat) \
 	-command [list [namespace current]::menu_toggle_ignoring \
-		       $connid $jid groupchat]
+		       $xlib $jid groupchat]
     $sm add checkbutton -label [::msgcat::mc "Ignore chat messages"] \
-	-variable [namespace current]::menustate($connid,$jid,chat) \
+	-variable [namespace current]::menustate($xlib,$jid,chat) \
 	-command [list [namespace current]::menu_toggle_ignoring \
-		       $connid $jid chat]
+		       $xlib $jid chat]
 
     bind $m <Destroy> +[list \
-	[namespace current]::menu_cleanup_state $connid $jid]
+	[namespace current]::menu_cleanup_state $xlib $jid]
 }
 
-proc mucignore::menu_toggle_ignoring {connid jid type} {
+proc mucignore::menu_toggle_ignoring {xlib jid type} {
     variable menustate
 
-    if {$menustate($connid,$jid,$type)} {
-	occupant_ignore $connid $jid $type
+    if {$menustate($xlib,$jid,$type)} {
+	occupant_ignore $xlib $jid $type
     } else {
-	occupant_attend $connid $jid $type
+	occupant_attend $xlib $jid $type
     }
 }
 
-proc mucignore::menu_cleanup_state {connid jid} {
+proc mucignore::menu_cleanup_state {xlib jid} {
     variable menustate
 
-    array unset menustate $connid,$jid,*
+    array unset menustate $xlib,$jid,*
 }
 
 # Ignores specified room occupant:
@@ -260,21 +260,21 @@
 # * Creates an ignore tag, if needed;
 # * Hides messages tagged with that tag, if any;
 # * Builds and saves current ruleset to the Customize db.
-proc mucignore::occupant_ignore {connid jid args} {
+proc mucignore::occupant_ignore {xlib jid args} {
     variable options
     variable ignored
 
     foreach type $args {
-	set ignored([mkrule $connid $jid $type]) true
+	set ignored([mkrule $xlib $jid $type]) true
 
 	if {$type == "groupchat"} {
 	    ignore_tag_create $jid
-	    room_weed_messages $connid $jid true
+	    room_weed_messages $xlib $jid true
 	}
     }
 
     if {!$options(transient_rules)} {
-	store_rules $connid
+	store_rules $xlib
     }
 }
 
@@ -286,16 +286,16 @@
 #   when she is ignored again, all her messages tagged with
 #   the appropriate ignore tag are again hidden.
 # * Builds and saves current ruleset to the Customize db.
-proc mucignore::occupant_attend {connid jid args} {
+proc mucignore::occupant_attend {xlib jid args} {
     variable options
     variable ignored
 
     foreach type $args {
-	set rule [mkrule $connid $jid $type]
+	set rule [mkrule $xlib $jid $type]
 	if {[info exists ignored($rule)]} {
 	    unset ignored($rule)
 	    if {$type == "groupchat"} {
-		room_weed_messages $connid $jid false
+		room_weed_messages $xlib $jid false
 		# we don't use [ignore_tag_forget] here
 		# so when we switch ignoring back on,
 		# all already marked messagess will be weed out
@@ -304,14 +304,14 @@
     }
 
     if {!$options(transient_rules)} {
-	store_rules $connid
+	store_rules $xlib
     }
 }
 
 # Hides or shows messages tagged as ignored for the $jid, if any.
-proc mucignore::room_weed_messages {connid jid hide} {
+proc mucignore::room_weed_messages {xlib jid hide} {
     set room [::node_and_server_from_jid $jid]
-    set cw [::chat::chat_win [::chat::chatid $connid $room]]
+    set cw [::chat::chat_win [::chat::chatid $xlib $room]]
 
     $cw tag configure [ignore_tag_get $jid] -elide $hide
 }
@@ -321,19 +321,19 @@
 # If the message is groupchat and its sender is blacklisted, it sets
 # the appropriate message property so that other message handlers
 # could treat such message in some special way.
-proc mucignore::process_message {connid from id type args} {
+proc mucignore::process_message {xlib from id type args} {
     variable ignored
 
     if {$type == "chat" && \
-	[info exists ignored([mkrule $connid $from chat])]} {
+	[info exists ignored([mkrule $xlib $from chat])]} {
 	return stop
     }
 }
 
-proc mucignore::is_ignored {connid jid type} {
+proc mucignore::is_ignored {xlib jid type} {
     variable ignored
 
-    if {[info exists ignored([mkrule $connid $jid $type])]} {
+    if {[info exists ignored([mkrule $xlib $jid $type])]} {
 	return [ignore_tag_get $jid]
     } else {
 	return ""
@@ -352,14 +352,14 @@
 
     if {$type != "groupchat"} return
 
-    set connid [::chat::get_connid $chatid]
+    set xlib [::chat::get_xlib $chatid]
     set jid [::chat::get_jid $chatid]
 
-    foreach rule [array names ignored [mkrule $connid $jid/* groupchat]] {
+    foreach rule [array names ignored [mkrule $xlib $jid/* groupchat]] {
 	set junkie [lindex [split_rule $rule] 1]
 	# TODO handle "real JIDs" case...
 	ignore_tag_create $junkie
-	room_weed_messages $connid $junkie true
+	room_weed_messages $xlib $junkie true
     }
 }
 
@@ -375,47 +375,47 @@
 # TODO why does real JID is available when this handler is run with
 #      $type == "unavailable". memory leak in chats.tcl?
 # TODO use chat_user_enter/chat_user_exit instead?
-proc mucignore::catch_junkie_presence {connid from pres args} {
+proc mucignore::catch_junkie_presence {xlib from pres args} {
     variable options
     variable ignored
 
     set room [::node_and_server_from_jid $from]
-    set rjid [get_real_bare_jid $connid $from]
+    set rjid [get_real_bare_jid $xlib $from]
 
     if {$pres == "available"} {
 	debugmsg mucignore "avail: $from; real jid: $rjid"
 	foreach type {groupchat chat} {
 	    if {$rjid != {} && \
-		[info exists ignored([mkrule $connid $room/$rjid $type])]} {
-		rename_rule_jid $connid $room/$rjid $from $type
+		[info exists ignored([mkrule $xlib $room/$rjid $type])]} {
+		rename_rule_jid $xlib $room/$rjid $from $type
 	    }
 	}
 
-	if {[info exists ignored([mkrule $connid $from groupchat])]} {
+	if {[info exists ignored([mkrule $xlib $from groupchat])]} {
 	    ignore_tag_create $from
-	    room_weed_messages $connid $from true
+	    room_weed_messages $xlib $from true
 	}
     } elseif {$pres == "unavailable"} {
 	debugmsg mucignore "unavail: $from; real jid: $rjid"
-	if {[info exists ignored([mkrule $connid $from groupchat])]} {
+	if {[info exists ignored([mkrule $xlib $from groupchat])]} {
 	    ignore_tag_forget $from
 	}
 
 	foreach type {groupchat chat} {
 	    if {$rjid != {} && \
-		[info exists ignored([mkrule $connid $from $type])]} {
-		rename_rule_jid $connid $from $room/$rjid $type
+		[info exists ignored([mkrule $xlib $from $type])]} {
+		rename_rule_jid $xlib $from $room/$rjid $type
 	    }
 	}
     }
 }
 
-proc mucignore::trace_room_nick_change {connid room oldnick newnick} {
+proc mucignore::trace_room_nick_change {xlib room oldnick newnick} {
     variable ignored
 
     foreach type {groupchat chat} {
-	if {[info exists ignored([mkrule $connid $room/$oldnick $type])]} {
-	    rename_rule_jid $connid $room/$oldnick $room/$newnick $type
+	if {[info exists ignored([mkrule $xlib $room/$oldnick $type])]} {
+	    rename_rule_jid $xlib $room/$oldnick $room/$newnick $type
 
 	    if {$type == "groupchat"} {
 		ignore_tag_rebind $room/$oldnick $room/$newnick
@@ -424,11 +424,11 @@
     }
 }
 
-proc mucignore::rename_rule_jid {connid from to type} {
+proc mucignore::rename_rule_jid {xlib from to type} {
     variable ignored
 
-    set oldrule [mkrule $connid $from $type]
-    set newrule [mkrule $connid $to $type]
+    set oldrule [mkrule $xlib $from $type]
+    set newrule [mkrule $xlib $to $type]
 
     set ignored($newrule) [set ignored($oldrule)]
     unset ignored($oldrule)
@@ -438,12 +438,12 @@
 	[string map {\u0000 |} $newrule]"
 }
 
-proc mucignore::explode_room_jid {connid room_occupant_jid vroom voccupant} {
+proc mucignore::explode_room_jid {xlib room_occupant_jid vroom voccupant} {
     upvar 1 $vroom room $voccupant occupant
 
     set room [::node_and_server_from_jid $room_occupant_jid]
 
-    set occupant [get_real_bare_jid $connid $room_occupant_jid]
+    set occupant [get_real_bare_jid $xlib $room_occupant_jid]
     if {$occupant == {}} {
 	set occupant [::resource_from_jid $room_occupant_jid]
     }
@@ -458,7 +458,7 @@
 #     * occupant_1 (nick or real_jid)
 #       * "groupchat" or "chat" or both
 # ...and so on
-proc mucignore::store_rules {connid} {
+proc mucignore::store_rules {xlib} {
     variable ignored
     variable stored_rules
 
@@ -467,7 +467,7 @@
     foreach rule [array names ignored] {
 	lassign [split_rule $rule] entity jid type
 
-	explode_room_jid $connid $jid room occupant
+	explode_room_jid $xlib $jid room occupant
 
 	set entities($entity) 1
 
@@ -550,8 +550,8 @@
 namespace eval mucignore::editor {}
 
 # ...
-# NOTE that both $connid and $jid may be empty at the time of invocation.
-proc mucignore::editor::open {connid jid} {
+# NOTE that both $xlib and $jid may be empty at the time of invocation.
+proc mucignore::editor::open {xlib jid} {
     set w .mucignore_rules_editor
     if {[winfo exists $w]} {
 	return

Modified: trunk/tkabber/plugins/chat/nick_colors.tcl
===================================================================
--- trunk/tkabber/plugins/chat/nick_colors.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/chat/nick_colors.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -156,8 +156,8 @@
 proc nickcolors::check_nick {chatid from type body x} {
     variable NicksInChat
 
-    set connid [chat::get_connid $chatid]
-    set nick [chat::get_nick $connid $from $type]
+    set xlib [chat::get_xlib $chatid]
+    set nick [chat::get_nick $xlib $from $type]
     if {[lsearch -exact $NicksInChat($chatid) $nick] < 0} {
 	lappend NicksInChat($chatid) $nick
 	set_color $chatid $nick [get_color $nick]
@@ -301,13 +301,13 @@
         -command [list [namespace current]::edit_nick_color $chatwin $nick]
 }
 
-proc nickcolors::add_groupchat_user_menu_items {m connid jid} {
+proc nickcolors::add_groupchat_user_menu_items {m xlib jid} {
     variable options
 
     if {$options(use_colored_roster_nicks)} {
-	set chatid [chat::chatid $connid [node_and_server_from_jid $jid]]
+	set chatid [chat::chatid $xlib [node_and_server_from_jid $jid]]
 	set chatwin [chat::chat_win $chatid]
-	set nick [chat::get_nick $connid $jid groupchat]
+	set nick [chat::get_nick $xlib $jid groupchat]
 	$m add command -label [::msgcat::mc "Edit nick color..."] \
 	    -command [list [namespace current]::edit_nick_color $chatwin $nick]
     }

Modified: trunk/tkabber/plugins/chat/open_chat.tcl
===================================================================
--- trunk/tkabber/plugins/chat/open_chat.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/chat/open_chat.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -9,9 +9,9 @@
 	set user [crange $body 6 end]
 	# What if conference nickname contains "@"?
 	if {[string first "@" $user] >= 0} {
-	    chat::open_to_user [chat::get_connid $chatid] $user
+	    chat::open_to_user [chat::get_xlib $chatid] $user
 	} else {
-	    chat::open_to_user [chat::get_connid $chatid] \
+	    chat::open_to_user [chat::get_xlib $chatid] \
 		[chat::get_jid $chatid]/$user
 	}
 	return stop
@@ -30,9 +30,9 @@
 	set prefix $plugins::completion::options(prefix)
 	set suffix $plugins::completion::options(suffix)
         set jidcomps {}
-	set connid [chat::get_connid $chatid]
-	foreach jid [roster::get_jids $connid] {
-	    if {[roster::itemconfig $connid $jid -isuser]} {
+	set xlib [chat::get_xlib $chatid]
+	foreach jid [roster::get_jids $xlib] {
+	    if {[roster::itemconfig $xlib $jid -isuser]} {
 		lappend jidcomps $prefix$jid$suffix
 	    }
 	}

Modified: trunk/tkabber/plugins/chat/send_message.tcl
===================================================================
--- trunk/tkabber/plugins/chat/send_message.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/chat/send_message.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -8,14 +8,13 @@
     } else {
 	incr chat_msg_id
     }
-    set connid [chat::get_connid $chatid]
+    set xlib [chat::get_xlib $chatid]
     set jid [chat::get_jid $chatid]
     set chatw [chat::chat_win $chatid]
 
     if {[hook::is_flag chat_send_message_hook send]} {
-	set command [list message::send_msg $jid \
+	set command [list message::send_msg $xlib $jid \
 			 -id $chat_msg_id \
-			 -connection $connid \
 			 -type $type \
 			 -body $body]
 	if {[info exists ::chat::chats(thread,$chatid)]} {
@@ -23,7 +22,7 @@
 	}
 	set xlist {}
 	hook::run chat_send_message_xlist_hook xlist $chatid $user $body $type
-	if {![lempty $xlist]} {
+	if {[llength $xlist] > 0} {
 	    lappend command -xlist $xlist
 	}
 	lassign [eval $command] status x
@@ -34,9 +33,9 @@
 	set signP 0
 	set encryptP 0
 	foreach xe $x {
-	    jlib::wrapper:splitxml $xe tag vars isempty chdata children
+	    ::xmpp::xml::split $xe tag xmlns attrs cdata subels
 
-	    switch -- [jlib::wrapper:getattr $vars xmlns] \
+	    switch -- $xmlns \
 		$::NS(signed) {
 		    set signP 1
 		} \
@@ -45,7 +44,7 @@
 		}
 	}
 
-	if {![cequal $type groupchat]} {
+	if {![string equal $type groupchat]} {
 	    if {$encryptP} {
 		$chatw image create start_message -image gpg/encrypted
 	    }

Modified: trunk/tkabber/plugins/chat/update_tab.tcl
===================================================================
--- trunk/tkabber/plugins/chat/update_tab.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/chat/update_tab.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -5,22 +5,21 @@
 }
 
 proc update_tab::update {chatid from type body x} {
-    set connid [chat::get_connid $chatid]
+    set xlib [chat::get_xlib $chatid]
     set jid [chat::get_jid $chatid]
     set cw [chat::winid $chatid]
 
     foreach xelem $x {
-	jlib::wrapper:splitxml $xelem tag vars isempty chdata children
+	::xmpp::xml::split $xelem tag xmlns attrs cdata subels
 	
 	# Don't update tab if this 'empty' tag is present. It indicates
 	# messages history in chat window.
-	if {[cequal $tag ""] && \
-		[cequal [jlib::wrapper:getattr $vars xmlns] tkabber:x:nolog]} {
+	if {[string equal $tag ""] && [string equal $xmlns tkabber:x:nolog]} {
 	    return
 	}
     }
 
-    if {![catch {::plugins::mucignore::is_ignored $connid $from $type} ignore] && \
+    if {![catch {::plugins::mucignore::is_ignored $xlib $from $type} ignore] && \
 	    $ignore != ""} {
 	return
     }
@@ -35,7 +34,7 @@
 		tab_set_updated $cw 1 server
 	    } else {
 		set myjid [chat::our_jid $chatid]
-		set mynick [chat::get_nick $connid $myjid $type]
+		set mynick [chat::get_nick $xlib $myjid $type]
 
 		if {[check_message $mynick $body]} {
 		    tab_set_updated $cw 1 mesg_to_user

Modified: trunk/tkabber/plugins/filetransfer/http.tcl
===================================================================
--- trunk/tkabber/plugins/filetransfer/http.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/filetransfer/http.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -48,8 +48,8 @@
 	    set host [info hostname]
 	    set host [lindex [host_info addresses $host] 0]
 	}
-	if {[jlib::socket_ip $state(connid)] != ""} {
-	    set host [jlib::socket_ip $state(connid)]
+	if {[::xmpp::ip $state(xlib)] != ""} {
+	    set host [::xmpp::ip $state(xlib)]
 	}
     }
     set state(host) $host
@@ -62,15 +62,15 @@
 
     set url [cconcat "http://$state(host):$port/" [file tail $state(filename)]]
 
-    jlib::send_iq set [jlib::wrapper:createtag query \
-			   -vars {xmlns jabber:iq:oob} \
-			   -subtags [list [jlib::wrapper:createtag url \
-					       -chdata $url] \
-					  [jlib::wrapper:createtag desc \
-					       -chdata $state(desc)]]] \
+    ::xmpp::sendIQ $state(xlib) set \
+	-query [::xmpp::xml::create query \
+			   -xmlns jabber:iq:oob \
+			   -subelement [::xmpp::xml::create url \
+					       -cdata $url] \
+			   -subelement [::xmpp::xml::create desc \
+					       -cdata $state(desc)]] \
 	-to $state(jid) \
-	-command [list [namespace current]::send_file_error_handler $token] \
-	-connection $state(connid)
+	-command [list [namespace current]::send_file_error_handler $token]
 }
 
 ###############################################################################
@@ -79,9 +79,9 @@
     upvar #0 $token state
 
     if {![info exists state(fd)]} return
-    if {[cequal $res OK]} return
+    if {[cequal $res ok]} return
 
-    eval $state(command) ERR \
+    eval $state(command) error \
 	 [list [::msgcat::mc "Request failed: %s" [error_to_string $child]]]
 }
 
@@ -138,12 +138,12 @@
     set chunk [read $state(fd) $chunk_size]
     if {$chunk != ""} {
 	if {[catch {puts -nonewline $chan $chunk}]} {
-	    eval $state(command) [list ERR "File transfer failed"]
+	    eval $state(command) [list error "File transfer failed"]
 	} else {
-	    eval $state(command) [list PROGRESS [tell $state(fd)]]
+	    eval $state(command) [list progress [tell $state(fd)]]
 	}
     } else {
-	eval $state(command) OK
+	eval $state(command) ok
     }
 }
 
@@ -351,25 +351,27 @@
 
 ###############################################################################
 
-proc http::iq_handler {connid from lang child} {
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
+proc http::iq_handler {xlib from child args} {
+    ::xmpp::xml::split $child tag xmlns attrs cdata subels
 
     set urls ""
     set desc ""
 
-    foreach child $children {
-	jlib::wrapper:splitxml $child tag vars isempty chdata children1
-	switch -- $tag {
-	    url  {lappend urls $chdata}
-	    desc {set desc $chdata}
+    foreach child $subels {
+	::xmpp::xml::split $child stag sxmlns sattrs scdata ssubels
+	switch -- $stag {
+	    url  {lappend urls $scdata}
+	    desc {set desc $scdata}
 	}
     }
 
+    set lang [::xmpp::xml::getAttr $args -lang en]
+
     return [recv_file_dialog $from $lang $urls $desc]
 }
 
-iq::register_handler set query jabber:iq:oob \
-    [namespace current]::http::iq_handler
+::xmpp::iq::register set query jabber:iq:oob \
+		     [namespace current]::http::iq_handler
 
 ###############################################################################
 

Modified: trunk/tkabber/plugins/filetransfer/si.tcl
===================================================================
--- trunk/tkabber/plugins/filetransfer/si.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/filetransfer/si.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -26,14 +26,14 @@
 
     if {![info exists state(fd)]} return
 
-    set state(stream) [si::newout $state(connid) $state(jid)]
+    set state(stream) [si::newout $state(xlib) $state(jid)]
 
-    set profile [jlib::wrapper:createtag file \
-		     -vars [list xmlns $::NS(file-transfer) \
-				 name $state(name) \
-				 size $state(size)] \
-		     -subtags [list [jlib::wrapper:createtag desc \
-					 -chdata $state(desc)]]]
+    set profile [::xmpp::xml::create file \
+			-xmlns $::NS(file-transfer) \
+			-attrs [list name $state(name) \
+				     size $state(size)] \
+			-subelement [::xmpp::xml::create desc \
+					    -cdata $state(desc)]]
 
     si::connect $state(stream) $chunk_size application/octet-stream \
 		$::NS(file-transfer) $profile \
@@ -48,7 +48,7 @@
     if {![info exists state(fd)]} return
 
     if {![lindex $res 0]} {
-	eval $state(command) ERR \
+	eval $state(command) error \
 	     [list [::msgcat::mc "Request failed: %s" [lindex $res 1]]]
 	return
     }
@@ -68,7 +68,7 @@
 	si::send_data $state(stream) $chunk \
 		      [list [namespace current]::send_chunk_response $token]
     } else {
-	eval $state(command) OK
+	eval $state(command) ok
     }
 }
 
@@ -78,12 +78,12 @@
     if {![info exists state(fd)]} return
 
     if {![lindex $res 0]} {
-	eval $state(command) ERR \
+	eval $state(command) error \
 	     [list [::msgcat::mc "Transfer failed: %s" [lindex $res 1]]]
 	return
     }
 
-    eval $state(command) [list PROGRESS [tell $state(fd)]]
+    eval $state(command) [list progress [tell $state(fd)]]
     after idle [list [namespace current]::send_chunk $token]
 }
 
@@ -101,7 +101,7 @@
 ###############################################################################
 ###############################################################################
 
-proc si::recv_file_dialog {connid from lang id name size date hash desc} {
+proc si::recv_file_dialog {xlib from lang id name size date hash desc} {
     variable winid
 
     set token [namespace current]::[incr winid]
@@ -110,7 +110,7 @@
     set w .rfd$winid
     set state(w) $w
 
-    set state(connid) $connid
+    set state(xlib) $xlib
     set state(jid) $from
     set state(lang) $lang
     set state(id) $id
@@ -234,7 +234,7 @@
 
     $state(w) itemconfigure 0 -state disabled
 
-    if {[catch {si::newin $state(connid) $state(jid) $state(id)} stream]} {
+    if {[catch {si::newin $state(xlib) $state(jid) $state(id)} stream]} {
 	# Return error to the sender but leave transfer window with disabled
 	# 'Receive' button and error message.
 	set state(result) [list 0 [list error modify bad-request \
@@ -304,29 +304,30 @@
 ###############################################################################
 ###############################################################################
 
-proc si::si_handler {connid from lang id mimetype child} {
+proc si::si_handler {xlib from lang id mimetype child} {
     debugmsg filetransfer "SI set: [list $from $child]"
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
+    ::xmpp::xml::split $child tag xmlns attrs cdata subels
 
     if {$tag == "file"} {
 	set desc ""
-	foreach item $children {
-	    jlib::wrapper:splitxml $item tag1 vars1 isempty1 chdata1 children1
-	    switch -- $tag1 {
-		desc {set desc $chdata1}
+	foreach item $subels {
+	    ::xmpp::xml::split $item stag sxmlns sattrs scdata ssubels
+
+	    switch -- $stag {
+		desc {set desc $scdata}
 	    }
 	}
 
 	recv_file_dialog \
-	    $connid \
+	    $xlib \
 	    $from \
 	    $lang \
 	    $id \
-	    [jlib::wrapper:getattr $vars name] \
-	    [jlib::wrapper:getattr $vars size] \
-	    [jlib::wrapper:getattr $vars date] \
-	    [jlib::wrapper:getattr $vars hash] \
+	    [::xmpp::xml::getAttr $attrs name] \
+	    [::xmpp::xml::getAttr $attrs size] \
+	    [::xmpp::xml::getAttr $attrs date] \
+	    [::xmpp::xml::getAttr $attrs hash] \
 	    $desc
     } else {
 	return [list error modify bad-request]

Modified: trunk/tkabber/plugins/general/autoaway.tcl
===================================================================
--- trunk/tkabber/plugins/general/autoaway.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/general/autoaway.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -92,7 +92,7 @@
     variable savepriority
     global userstatus textstatus userpriority
 
-    if {[jlib::connections] == {}} {
+    if {[connections] == {}} {
         if {![cequal $savestatus ""]} {
 	    if {$options(drop_priority) && ($userpriority >= 0)} {
 		set userpriority $savepriority

Modified: trunk/tkabber/plugins/general/avatars.tcl
===================================================================
--- trunk/tkabber/plugins/general/avatars.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/general/avatars.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -59,16 +59,16 @@
 
 ##############################################################################
 
-proc ::avatar::get_presence_x {varname connid status} {
+proc ::avatar::get_presence_x {varname xlib status} {
     variable avatar
     variable options
     upvar 2 $varname var
 
     if {$options(announce) && [info exists avatar(userhash)]} {
-	set children [jlib::wrapper:createtag hash -chdata $avatar(userhash)]
-	lappend var [jlib::wrapper:createtag x \
-			 -vars [list xmlns $::NS(xavatar)] \
-			 -subtags [list $children]]
+	lappend var [::xmpp::xml::create x \
+			 -xmlns $::NS(xavatar) \
+			 -subelement [::xmpp::xml::create hash \
+					    -cdata $avatar(userhash)]]
 
     }
     return
@@ -78,14 +78,14 @@
 
 ##############################################################################
 
-proc ::avatar::process_presence {connid from type x args} {
+proc ::avatar::process_presence {xlib from type x args} {
     switch -- $type {
 	available -
 	unavailable {
 	    foreach xs $x {
-		jlib::wrapper:splitxml $xs tag vars isempty chdata children
-		if {[jlib::wrapper:getattr $vars xmlns] == $::NS(xavatar)} {
-		    set_hash $connid $from $children
+		::xmpp::xml::split $xs tag xmlns attrs cdata subels
+		if {$xmlns == $::NS(xavatar)} {
+		    set_hash $xlib $from $subels
 		    break
 		}
 	    }
@@ -97,10 +97,10 @@
 
 ##############################################################################
 
-proc ::avatar::insert_userinfo {tab connid jid editable} {
+proc ::avatar::insert_userinfo {tab xlib jid editable} {
     if {$editable} return
 
-    set avatar_img [get_image $connid [get_jid_of_user $connid $jid]]
+    set avatar_img [get_image $xlib [get_jid_of_user $xlib $jid]]
     if {$avatar_img != ""} {
 	set avatar [$tab insert end avatar -text [::msgcat::mc "Avatar"]]
 
@@ -114,39 +114,39 @@
 
 ##############################################################################
 
-proc ::avatar::set_hash {connid jid children} {
+proc ::avatar::set_hash {xlib jid children} {
     variable avatar
 
-    debugmsg avatar "set hash $connid $jid $children"
+    debugmsg avatar "set hash $xlib $jid $children"
     foreach child $children {
-	jlib::wrapper:splitxml $child tag vars isempty chdata children1
+	::xmpp::xml::split $child tag xmlns attrs cdata subels
 	if {$tag == "hash"} {
-	    set hash $chdata
+	    set hash $cdata
 	}
     }
     if {[info exists hash]} {
-	if {![info exists avatar(hash,$connid,$jid)] || \
-		$hash != $avatar(hash,$connid,$jid)} {
-	    set avatar(hash,$connid,$jid) $hash
-	    set avatar(needupdate,$connid,$jid) 1
+	if {![info exists avatar(hash,$xlib,$jid)] || \
+		$hash != $avatar(hash,$xlib,$jid)} {
+	    set avatar(hash,$xlib,$jid) $hash
+	    set avatar(needupdate,$xlib,$jid) 1
 	}
     }
 }
 
 ##############################################################################
 
-proc ::avatar::get_image {connid jid} {
+proc ::avatar::get_image {xlib jid} {
     variable avatar
 
     debugmsg avatar "$jid; [array name avatar]"
-    if {[info exists avatar(hash,$connid,$jid)]} {
-	if {![info exists avatar(data,$connid,$jid)]} {
-	    image create photo avatar$connid@$jid
-	    get $connid $jid
-	} elseif {$avatar(needupdate,$connid,$jid)} {
-	    get $connid $jid
+    if {[info exists avatar(hash,$xlib,$jid)]} {
+	if {![info exists avatar(data,$xlib,$jid)]} {
+	    image create photo avatar$xlib@$jid
+	    get $xlib $jid
+	} elseif {$avatar(needupdate,$xlib,$jid)} {
+	    get $xlib $jid
 	}
-	return avatar$connid@$jid
+	return avatar$xlib@$jid
     } else {
 	return ""
     }
@@ -154,58 +154,57 @@
 
 ##############################################################################
 
-proc ::avatar::get {connid jid} {
+proc ::avatar::get {xlib jid} {
     variable avatar
 
-    set avatar(needupdate,$connid,$jid) 0
+    set avatar(needupdate,$xlib,$jid) 0
 
-    jlib::send_iq get \
-	[jlib::wrapper:createtag query \
-	     -vars [list xmlns $::NS(iqavatar)]] \
-	-to $jid -command [list avatar::recv $connid $jid] \
-	-connection $connid
+    ::xmpp::sendIQ $xlib get \
+	-query [::xmpp::xml::create query \
+			-xmlns $::NS(iqavatar)] \
+	-to $jid -command [list avatar::recv $xlib $jid]
 }
 
-proc ::avatar::recv {connid jid res child} {
+proc ::avatar::recv {xlib jid res child} {
     variable avatar
 
-    if {![cequal $res OK]} {
-	jlib::send_iq get [jlib::wrapper:createtag query \
-			       -vars {xmlns storage:client:avatar}] \
+    if {![string equal $res ok]} {
+	::xmpp::sendIQ $xlib get \
+	    -query [::xmpp::xml::create query \
+			       -xmlns storage:client:avatar] \
 	    -to [node_and_server_from_jid $jid] \
-	    -command [list avatar::recv_from_serv $connid $jid] \
-	    -connection $connid
+	    -command [list avatar::recv_from_serv $xlib $jid]
 
 	return
     }
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
-    foreach child1 $children {
-	jlib::wrapper:splitxml $child1 tag1 vars1 isempty1 chdata1 childrens1
-	if {$tag1 == "data"} {
+    ::xmpp::xml::split $child tag xmlns attrs cdata subels
+    foreach subel $subels {
+	::xmpp::xml::split $subel stag sxmlns sattrs scdata ssubels
+	if {$stag == "data"} {
 	    catch {
-		set avatar(data,$connid,$jid) [base64::decode $chdata1]
-		avatar$connid@$jid put $chdata1
+		set avatar(data,$xlib,$jid) [base64::decode $scdata]
+		avatar$xlib@$jid put $scdata
 	    }
 	}
     }
 }
 
-proc ::avatar::recv_from_serv {connid jid res child} {
+proc ::avatar::recv_from_serv {xlib jid res child} {
     variable avatar
 
-    if {![cequal $res OK]} {
+    if {![string equal $res ok]} {
 	# TODO
 	return
     }
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
-    foreach child1 $children {
-	jlib::wrapper:splitxml $child1 tag1 vars1 isempty1 chdata1 children1
-	if {$tag1 == "data"} {
+    ::xmpp::xml::split $child tag xmlns attrs cdata subels
+    foreach subel $subels {
+	::xmpp::xml::split $subel stag sxmlns sattrs scdata ssubels
+	if {$stag == "data"} {
 	    catch {
-		set avatar(data,$connid,$jid) [base64::decode $chdata1]
-		avatar$connid@$jid put $chdata1
+		set avatar(data,$xlib,$jid) [base64::decode $scdata]
+		avatar$xlib@$jid put $scdata
 	    }
 	}
     }
@@ -213,21 +212,15 @@
 
 ##############################################################################
 
-proc ::avatar::store_on_server {args} {
+proc ::avatar::store_on_server {{xlib ""}} {
     variable avatar
 
-    if {[llength [jlib::connections]] == 0} return
+    if {[llength [connections]] == 0} return
 
-    foreach {opt val} $args {
-	switch -- $opt {
-	    -connection { set connid $val }
-	}
+    if {$xlib == ""} {
+	set xlib [lindex [connections] 0]
     }
 
-    if {![info exists connid]} {
-	set connid [lindex [jlib::connections] 0]
-    }
-
     if {![info exists avatar(userdata)]} {
 	MessageDlg .avatar_error -aspect 50000 -icon error \
 		-message [::msgcat::mc "No avatar to store"] -type user \
@@ -235,37 +228,31 @@
 	return
     }
 
-    set restags \
-	[list [jlib::wrapper:createtag data \
-		   -chdata $avatar(userdata)]]
-    set res [jlib::wrapper:createtag query \
-		 -vars {xmlns storage:client:avatar} \
-		 -subtags $restags]
-
-    jlib::send_iq set $res -connection $connid
+    ::xmpp::sendIQ $xlib set \
+	-query [::xmpp::xml::create query \
+			-xmlns storage:client:avatar \
+			-subelement [::xmpp::xml::create data \
+					    -cdata $avatar(userdata)]]
 }
 
 ##############################################################################
 
-proc ::avatar::iq_reply {connid from lang child} {
+proc ::avatar::iq_reply {xlib from child args} {
     variable avatar
     variable options
 
     if {$options(share) && [info exists avatar(userdata)]} {
-	set restags \
-	    [list [jlib::wrapper:createtag data \
-		       -chdata $avatar(userdata)]]
-	set res [jlib::wrapper:createtag query \
-		     -vars [list xmlns $::NS(iqavatar)] \
-		     -subtags $restags]
+	set res [::xmpp::xml::create query \
+			-xmlns $::NS(iqavatar) \
+			-subelement [::xmpp::xml::create data \
+					    -cdata $avatar(userdata)]]
+	return [list result $res]
     } else {
 	return [list error cancel service-unavailable]
     }
-
-    return [list result $res]
 }
 
-iq::register_handler get query $::NS(iqavatar) ::avatar::iq_reply
+::xmpp::iq::register get query $::NS(iqavatar) ::avatar::iq_reply
 
 ##############################################################################
 

Modified: trunk/tkabber/plugins/general/caps.tcl
===================================================================
--- trunk/tkabber/plugins/general/caps.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/general/caps.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -101,36 +101,34 @@
     return [base64::encode $binhash]
 }
 
-proc caps::info_to_hash {child hash} {
+proc caps::info_to_hash {info hash} {
     set identities {}
     set features {}
     set extras {}
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
+    ::xmpp::xml::split $info tag xmlns attrs cdata subels
 
-    foreach ch $children {
-	jlib::wrapper:splitxml $ch tag1 vars1 isempty1 chdata1 children1
-	switch -- $tag1 {
+    foreach subel $subels {
+	::xmpp::xml::split $subel stag sxmlns sattrs scdata ssubels
+	switch -- $stag {
 	    identity {
-		set category [jlib::wrapper:getattr $vars1 category]
-		set type [jlib::wrapper:getattr $vars1 type]
-		set lang [jlib::wrapper:getattr $vars1 xml:lang]
-		set name [jlib::wrapper:getattr $vars1 name]
+		set category [::xmpp::xml::getAttr $sattrs category]
+		set type [::xmpp::xml::getAttr $sattrs type]
+		set lang [::xmpp::xml::getAttr $sattrs xml:lang]
+		set name [::xmpp::xml::getAttr $sattrs name]
 		lappend identities $category/$type/$lang/$name
 	    }
 	    feature {
-		set var [jlib::wrapper:getattr $vars1 var]
+		set var [::xmpp::xml::getAttr $sattrs var]
 		if {![string equal $var ""]} {
 		    lappend features $var
 		}
 	    }
 	    x {
-		if {[string equal [jlib::wrapper:getattr $vars1 xmlns] \
-				  $::NS(data)] && \
-			[string equal [jlib::wrapper:getattr $vars1 type] \
-				      result]} {
+		if {[string equal $xmlns $::NS(data)] && \
+		    [string equal [::xmpp::xml::getAttr $sattrs type] result]} {
 		    lappend extras \
-			    [data::parse_xdata_results $children1 -hidden 1]
+			    [data::parse_xdata_results $ssubels -hidden 1]
 		}
 	    }
 	}
@@ -138,7 +136,7 @@
     return [hash $identities $features $extras $hash]
 }
 
-proc caps::get_presence_x {varname connid status} {
+proc caps::get_presence_x {varname xlib status} {
     variable options
     variable caps_node
     upvar 2 $varname var
@@ -146,22 +144,21 @@
     if {!$options(enable)} return
 
     lassign [disco::info_query_get_handler \
-		    $connid "" \
-		    [jlib::get_lang] \
-		    [jlib::wrapper:createtag query \
-			    -vars [list xmlns $::NS(disco_info)]]] \
-	    res child
+		    $xlib "" en \
+		    [::xmpp::xml::create query -xmlns $::NS(disco_info)]] \
+	    status xml
 
-    if {![string equal $res result]} return
+    if {![string equal $status result]} return
 
-    set ver [info_to_hash $child $options(hash)]
+    set ver [info_to_hash $xml $options(hash)]
     if {[string equal $ver ""]} return
 
-    lappend var [jlib::wrapper:createtag c \
-		     -vars [list xmlns $::NS(caps) \
-				 hash $options(hash) \
-				 node http://tkabber.jabber.ru/ \
-				 ver $ver]]
+    lappend var [::xmpp::xml::create c \
+			-xmlns $::NS(caps) \
+			-attrs [list hash $options(hash) \
+				     node http://tkabber.jabber.ru/ \
+				     ver $ver]]
+
     set caps_node http://tkabber.jabber.ru/#$ver
 
     return
@@ -169,24 +166,20 @@
 
 hook::add presence_xlist_hook [namespace current]::caps::get_presence_x
 
-proc caps::disco_reply {varname type node connid from lang child} {
+proc caps::disco_reply {varname type node xlib from lang child} {
     variable caps_node
     upvar 2 $varname res
 
     if {$type != "info" || $node != $caps_node} return
 
     set res [disco::info_query_get_handler \
-		    $connid "" \
-		    [jlib::get_lang] \
-		    [jlib::wrapper:createtag query \
-			    -vars [list xmlns $::NS(disco_info)]]]
+		    $xlib "" en \
+		    [::xmpp::xml::create query -xmlns $::NS(disco_info)]]
+
     if {[string equal [lindex $res 0] result]} {
-	jlib::wrapper:splitxml [lindex $res 1] tag vars isempty chdata children
-	lappend vars node $caps_node
-	lset res 1 [jlib::wrapper:createtag $tag \
-			-vars $vars \
-			-chdata $chdata \
-			-subtags $children]
+	::xmpp::xml::split [lindex $res 1] tag xmlns attrs cdata subels
+	lappend attrs node $caps_node
+	lset res 1 [::xmpp::xml::merge $tag $xmlns $attrs $cdata $subels]
     }
     return stop
 }
@@ -194,80 +187,79 @@
 hook::add disco_node_reply_hook [namespace current]::caps::disco_reply
 
 # TODO match caps hash to a set of features
-proc caps::process_presence {connid from type x args} {
+proc caps::process_presence {xlib from type x args} {
     variable htype
     variable hver
 
     switch -- $type {
 	unavailable {
-	    catch {unset htype($connid,$from)}
-	    catch {unset hver($connid,$from)}
+	    catch {unset htype($xlib,$from)}
+	    catch {unset hver($xlib,$from)}
 	}
 	available {
 	    foreach xs $x {
-		jlib::wrapper:splitxml $xs tag vars isempty chdata children
-		if {[string equal [jlib::wrapper:getattr $vars xmlns] \
-				  $::NS(caps)]} {
-		    set hash [jlib::wrapper:getattr $vars hash]
+		::xmpp::xml::split $xs tag xmlns attrs cdata subels
+		if {[string equal $xmlns $::NS(caps)]} {
+		    set hash [::xmpp::xml::getAttr $attrs hash]
 		    if {[string equal $hash ""]} {
 			set hash sha-1
 		    }
-		    set htype($connid,$from) $hash
-		    set hver($connid,$from) [jlib::wrapper:getattr $vars ver]
+		    set htype($xlib,$from) $hash
+		    set hver($xlib,$from) [::xmpp::xml::getAttr $attrs ver]
 		    return
 		}
 	    }
 	    # Unset caps if they aren't included in <presence/>
-	    catch {unset htype($connid,$from)}
-	    catch {unset hver($connid,$from)}
+	    catch {unset htype($xlib,$from)}
+	    catch {unset hver($xlib,$from)}
 	}
     }
 }
 
 hook::add client_presence_hook [namespace current]::caps::process_presence
 
-proc caps::clean {connid} {
+proc caps::clean {xlib} {
     variable htype
     variable hver
 
-    array unset htype $connid,*
-    array unset hver $connid,*
+    array unset htype $xlib,*
+    array unset hver $xlib,*
 }
 
 hook::add disconnected_hook [namespace current]::caps::clean
 
 proc caps::info_receive \
-     {connid jid node res identities features extras featured_nodes} {
+     {xlib jid node res identities features extras featured_nodes} {
     variable hidentities
     variable hfeatures
     variable htype
     variable hver
 
-    if {![string equal $res OK]} return
-    if {![info exists hver($connid,$jid)]} return
+    if {![string equal $res ok]} return
+    if {![info exists hver($xlib,$jid)]} return
 
     set ids {}
     foreach id $identities {
-	set category [jlib::wrapper:getattr $id category]
-	set type [jlib::wrapper:getattr $id type]
+	set category [::xmpp::xml::getAttr $id category]
+	set type [::xmpp::xml::getAttr $id type]
 	if {![string equal $category ""] && ![string equal $type ""]} {
 	    lappend ids $category/$type
 	}
     }
     set fes {}
     foreach fe $features {
-	set var [jlib::wrapper:getattr $fe var]
+	set var [::xmpp::xml::getAttr $fe var]
 	if {![string equal $var ""]} {
 	    lappend fes $var
 	}
     }
-    if {![string equal [hash $ids $fes $extras $htype($connid,$jid)] \
-		       $hver($connid,$jid)]} {
+    if {![string equal [hash $ids $fes $extras $htype($xlib,$jid)] \
+		       $hver($xlib,$jid)]} {
 	return
     }
 
-    set hidentities($htype($connid,$jid),$hver($connid,$jid)) $ids
-    set hfeatures($htype($connid,$jid),$hver($connid,$jid)) $fes
+    set hidentities($htype($xlib,$jid),$hver($xlib,$jid)) $ids
+    set hfeatures($htype($xlib,$jid),$hver($xlib,$jid)) $fes
 }
 
 hook::add disco_info_hook [namespace current]::caps::info_receive

Modified: trunk/tkabber/plugins/general/challenge.tcl
===================================================================
--- trunk/tkabber/plugins/general/challenge.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/general/challenge.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -7,23 +7,22 @@
 
 ###############################################################################
 
-proc challenge::process_x {rowvar bodyvar f x connid from id type replyP} {
+proc challenge::process_x {rowvar bodyvar f x xlib from id type replyP} {
     upvar 2 $rowvar row
     upvar 2 $bodyvar body
 
     set challenge 0
     foreach xa $x {
-	jlib::wrapper:splitxml $xa tag vars isempty chdata children
+	::xmpp::xml::split $xa tag xmlns attrs cdata subels
 
-	set xmlns [jlib::wrapper:getattr $vars xmlns]
 	if {$xmlns != $::NS(challenge)} continue
 
 	set challenge 1
-	foreach child $children {
-	    jlib::wrapper:splitxml $child tag1 vars1 isempty1 chdata1 children1
-	    set xmlns1 [jlib::wrapper:getattr $vars1 xmlns]
-	    if {$xmlns1 == $::NS(data) && ![lempty $children1]} {
-		if {[catch {process_x_data $f $connid $from $child}]} {
+	foreach subel $subels {
+	    ::xmpp::xml::split $subel stag sxmlns sattrs scdata ssubels
+
+	    if {$sxmlns == $::NS(data) && [llength $ssubels] > 0} {
+		if {[catch {process_x_data $f $xlib $from $subel}]} {
 		    # Cannot process challenge form, so falling back to a
 		    # legacy challenge method if any.
 		    # TODO: Show error message to user.
@@ -42,17 +41,16 @@
 
 hook::add message_process_x_hook [namespace current]::challenge::process_x 10
 
-proc challenge::process_x_data {f connid from x} {
-    data::draw_window [list $x] [list [namespace current]::send_x_data $connid $from]
+proc challenge::process_x_data {f xlib from x} {
+    data::draw_window [list $x] [list [namespace current]::send_x_data $xlib $from]
 }
 
-proc challenge::send_x_data {connid to w restags} {
-    jlib::send_iq set \
-	[jlib::wrapper:createtag challenge \
-	     -vars [list xmlns $::NS(challenge)] \
-	     -subtags $restags] \
-	-to $to \
-	-connection $connid
+proc challenge::send_x_data {xlib to w restags} {
+    ::xmpp::sendIQ $xlib set \
+	[::xmpp::xml::create challenge \
+		    -xmlns $::NS(challenge) \
+		    -subelements $restags] \
+	-to $to
     destroy $w
 }
 

Modified: trunk/tkabber/plugins/general/clientinfo.tcl
===================================================================
--- trunk/tkabber/plugins/general/clientinfo.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/general/clientinfo.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -4,8 +4,8 @@
     set options(autoask) 0
 }
 
-# TODO: connid
-proc clientinfo::add_user_popup_info {infovar connid jid} {
+# TODO: xlib
+proc clientinfo::add_user_popup_info {infovar xlib jid} {
     variable users
     upvar 0 $infovar info
 
@@ -42,7 +42,7 @@
     [namespace current]::clientinfo::add_user_popup_info
 
 
-proc clientinfo::on_presence {connid from type x args} {
+proc clientinfo::on_presence {xlib from type x args} {
     variable options
     variable asked
 
@@ -53,7 +53,7 @@
 	    if {![info exists ::userinfo::userinfo(clientname,$from)] && \
 		    ![info exists asked($from)]} {
 		set asked($from) ""
-		userinfo::request_iq version $connid $from
+		userinfo::request_iq version $xlib $from
 	    }
 	}
     }

Modified: trunk/tkabber/plugins/general/copy_jid.tcl
===================================================================
--- trunk/tkabber/plugins/general/copy_jid.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/general/copy_jid.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -14,14 +14,14 @@
 
 ###############################################################################
 
-proc copy_jid::add_menu_item {m connid jid} {
+proc copy_jid::add_menu_item {m xlib jid} {
     $m add command \
 	   -label [::msgcat::mc "Copy JID to clipboard"] \
 	   -command [list [namespace current]::copy $m $jid]
 }
 
-proc copy_jid::add_muc_menu_item {m connid jid} {
-    set real_jid [::muc::get_real_jid $connid $jid]
+proc copy_jid::add_muc_menu_item {m xlib jid} {
+    set real_jid [::muc::get_real_jid $xlib $jid]
     if {$real_jid != ""} {
 	$m add command \
 	   -label [::msgcat::mc "Copy real JID to clipboard"] \

Modified: trunk/tkabber/plugins/general/headlines.tcl
===================================================================
--- trunk/tkabber/plugins/general/headlines.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/general/headlines.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -46,10 +46,10 @@
 
 #############################################################################
 
-proc headlines::process_message {connid from id type is_subject subject body err thread priority x} {
+proc headlines::process_message {xlib from id type is_subject subject body err thread priority x} {
     switch -- $type {
 	headline {
-	    show $connid $from $type $subject $body $thread $priority $x
+	    show $xlib $from $type $subject $body $thread $priority $x
 	    return stop
 	}
     }
@@ -61,7 +61,7 @@
 
 #############################################################################
 
-proc headlines::get_win {connid from} {
+proc headlines::get_win {xlib from} {
     variable options
 
     switch -- $options(multiple) {
@@ -73,19 +73,19 @@
 
 #############################################################################
 
-proc headlines::get_tree {connid from} {
-    set hw [get_win $connid $from]
+proc headlines::get_tree {xlib from} {
+    set hw [get_win $xlib $from]
     return $hw.tree
 }
 
 #############################################################################
 
-proc headlines::open_window {connid from} {
+proc headlines::open_window {xlib from} {
     global tcl_platform
     variable options
     variable trees
 
-    set hw [get_win $connid $from]
+    set hw [get_win $xlib $from]
 
     if {[winfo exists $hw]} return
 
@@ -105,7 +105,7 @@
         }
     }
 
-    set tw [get_tree $connid $from]
+    set tw [get_tree $xlib $from]
 
     if {[lsearch -exact $trees $tw] < 0} {
         lappend trees $tw
@@ -213,7 +213,7 @@
 
 #############################################################################
 
-proc headlines::show {connid from type subject body thread priority x {data {}}} {
+proc headlines::show {xlib from type subject body thread priority x {data {}}} {
     variable headid
     variable headlines
     variable trees
@@ -224,18 +224,18 @@
 
     set desc ""
     set url ""
-    set seconds [jlib::x_delay $x]
+    set seconds [::xmpp::delay::parse $x]
     foreach extra $x {
-        jlib::wrapper:splitxml $extra tag vars isempty chdata children
-	switch -- [jlib::wrapper:getattr $vars xmlns] {
+        ::xmpp::xml::split $extra tag xmlns attrs cdata subels
+	switch -- $xmlns {
 	    jabber:x:oob {
-		foreach item $children {
-		    jlib::wrapper:splitxml $item tag vars isempty chdata children   
+		foreach item $subels {
+		    ::xmpp::xml::split $item stag sxmlns sattrs scdata ssubels   
 
-		    switch -- $tag {
+		    switch -- $stag {
 			desc -
 			url {
-			    set $tag [string trim $chdata]
+			    set $stag [string trim $scdata]
 			}
 		    }
 		}
@@ -269,13 +269,13 @@
 	set ddesc $desc
     }
 
-    set hw [get_win $connid $from]
+    set hw [get_win $xlib $from]
 
     if {![winfo exists $hw]} {
-	open_window $connid $from
+	open_window $xlib $from
     }
 
-    set tw [get_tree $connid $from]
+    set tw [get_tree $xlib $from]
 
     if {$options(multiple) > 1} {
 	set text $dsubject
@@ -322,7 +322,7 @@
         $tw itemconfigure $anode -fill $options(unseencolor)
     }
 
-    set headlines($anode) [list $connid $from $type $subject $body $thread $priority $x]
+    set headlines($anode) [list $xlib $from $type $subject $body $thread $priority $x]
 
     update $tw $anode
     tab_set_updated $hw 1 message
@@ -825,16 +825,16 @@
 	return
     }
 
-    # TODO: connid
+    # TODO: xlib
     message::send_msg $to -type headline \
 	-subject $props(text) \
 	-body $props(body) \
-	-xlist [list [jlib::wrapper:createtag x \
-			  -vars [list xmlns jabber:x:oob] \
-			  -subtags [list [jlib::wrapper:createtag url \
-			                      -chdata $props(url)] \
-					 [jlib::wrapper:createtag desc \
-					      -chdata $props(text)]]]]
+	-xlist [list [::xmpp::xml::create x \
+			    -xmlns jabber:x:oob \
+			    -subelement [::xmpp::xml::create url \
+						-cdata $props(url)] \
+			    -subelement [::xmpp::xml::create desc \
+						-cdata $props(text)]]]
     set len [llength $send_jids]
     set send_jids [update_combo_list $send_jids $to 10]
     update_menu $menu $len
@@ -854,17 +854,16 @@
     set _send_jids $send_jids
     foreach choice [array names forward_hl] {
 	if {$forward_hl($choice)} {
-	    lassign $choice connid to
-	    message::send_msg $to -type headline \
+	    lassign $choice xlib to
+	    message::send_msg $xlib $to -type headline \
 		-subject $props(text) \
 		-body $props(body) \
-		-xlist [list [jlib::wrapper:createtag x \
-				  -vars [list xmlns jabber:x:oob] \
-				  -subtags [list [jlib::wrapper:createtag url \
-				                      -chdata $props(url)] \
-						 [jlib::wrapper:createtag desc \
-						      -chdata $props(text)]]]] \
-		-connection $connid
+		-xlist [list [::xmpp::xml::create x \
+				    -xmlns jabber:x:oob \
+				    -subelement [::xmpp::xml::create url \
+							-cdata $props(url)] \
+				    -subelement [::xmpp::xml::create desc \
+							-cdata $props(text)]]]
 	    set _send_jids [update_combo_list $_send_jids $to 10]
 	}
     }
@@ -882,7 +881,7 @@
 
     set choices {}
     set balloons {}
-    foreach c [jlib::connections] {
+    foreach c [connections] {
 	foreach choice [roster::get_jids $c] {
 	    if {![string equal [roster::itemconfig $c $choice -category] conference]} {
 		lappend choices [list $c $choice] [roster::get_label $c $choice]
@@ -913,8 +912,8 @@
 
 #############################################################################
 
-proc headlines::restore_window {from connid jid} {
-    open_window $connid $from
+proc headlines::restore_window {from xlib jid} {
+    open_window $xlib $from
 }
 
 #############################################################################

Modified: trunk/tkabber/plugins/general/jitworkaround.tcl
===================================================================
--- trunk/tkabber/plugins/general/jitworkaround.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/general/jitworkaround.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -7,7 +7,7 @@
 
 namespace eval jitworkaround {}
 
-proc jitworkaround::process_subscribed {connid from type x args} {
+proc jitworkaround::process_subscribed {xlib from type x args} {
     variable names
 
     if {$type != "subscribed"} return
@@ -21,40 +21,38 @@
 
     if {$newname == ""} return
 
-    set jid [roster::find_jid $connid $from]
+    set jid [roster::find_jid $xlib $from]
 
     if {$jid == ""} {
-	set names($connid,$from) $newname
-    } elseif {[roster::itemconfig $connid $jid -name] == ""} {
-	roster::itemconfig $connid $jid -name $newname
-	roster::send_item $connid $jid
+	set names($xlib,$from) $newname
+    } elseif {[roster::itemconfig $xlib $jid -name] == ""} {
+	roster::itemconfig $xlib $jid -name $newname
+	roster::send_item $xlib $jid
 	::redraw_roster
     }
 }
 
 hook::add client_presence_hook \
-    [namespace current]::jitworkaround::process_subscribed
+	  [namespace current]::jitworkaround::process_subscribed
 
 ###############################################################################
 
-proc jitworkaround::set_received_name {connid jid name groups subsc ask} {
+proc jitworkaround::set_received_name {xlib jid name groups subsc ask} {
     variable names
 
     if {$subsc == "remove"} return
 
-    if {[info exists names($connid,$jid)]} {
-	if {[roster::itemconfig $connid $jid -name] == ""} {
-	    roster::itemconfig $connid $jid -name $names($connid,$jid)
-	    roster::send_item $connid $jid
+    if {[info exists names($xlib,$jid)]} {
+	if {[roster::itemconfig $xlib $jid -name] == ""} {
+	    roster::itemconfig $xlib $jid -name $names($xlib,$jid)
+	    roster::send_item $xlib $jid
 	}
-	unset names($connid,$jid)
+	unset names($xlib,$jid)
     }
 }
 
-hook::add roster_item_hook \
-    [namespace current]::jitworkaround::set_received_name 60
 hook::add roster_push_hook \
-    [namespace current]::jitworkaround::set_received_name 60
+	  [namespace current]::jitworkaround::set_received_name 60
 
 ###############################################################################
 

Modified: trunk/tkabber/plugins/general/message_archive.tcl
===================================================================
--- trunk/tkabber/plugins/general/message_archive.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/general/message_archive.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -33,7 +33,7 @@
 proc ::message_archive::log_message {from to subject body x} {
     variable archive_file
 
-    set seconds [jlib::x_delay $x]
+    set seconds [::xmpp::delay::parse $x]
     set ts [clock format $seconds -format "%Y%m%dT%H%M%S"]
 
     set fd [open $archive_file a]
@@ -160,11 +160,11 @@
 proc ::message_archive::fill_row {l var} {
     variable messages
 
-    set connections [jlib::connections]
+    set connections [connections]
     if {[lempty $connections]} {
 	set myjid ""
     } else {
-	set myjid [jlib::connection_bare_jid [lindex $connections 0]]
+	set myjid [connection_bare_jid [lindex $connections 0]]
     }
 
     foreach i {N id timestamp dir fromto subject} {

Modified: trunk/tkabber/plugins/general/offline.tcl
===================================================================
--- trunk/tkabber/plugins/general/offline.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/general/offline.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -8,27 +8,26 @@
 
 }
 
-proc offline::request_headers {connid} {
+proc offline::request_headers {xlib} {
     variable options
 
     if {$options(flexible_retrieval)} {
-	jlib::send_iq get \
-	    [jlib::wrapper:createtag offline \
-		 -vars [list xmlns $::NS(offline)]] \
-	    -command [list [namespace current]::receive_headers $connid] \
-	    -connection $connid
+	::xmpp::sendIQ $xlib get \
+	    -query [::xmpp::xml::create offline \
+			    -xmlns $::NS(offline)] \
+	    -command [list [namespace current]::receive_headers $xlib]
     }
 }
 
 hook::add connected_hook [namespace current]::offline::request_headers 9
 
-proc offline::receive_headers {connid res child} {
+proc offline::receive_headers {xlib res child} {
 
-    if {$res != "OK"} {
+    if {$res != "ok"} {
 	return
     }
 
-    fill_tree $connid $child
+    fill_tree $xlib $child
 }
 
 proc offline::open_window {} {
@@ -75,11 +74,11 @@
     bindscroll $tw.c
 }
 
-proc offline::fill_tree {connid child} {
+proc offline::fill_tree {xlib xml} {
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
+    ::xmpp::xml::split $xml tag xmlns attrs cdata subels
 
-    if {[lempty $children]} {
+    if {[llength $subels] == 0} {
 	return
     }
     
@@ -91,16 +90,16 @@
 
     set tw $w.tree
 
-    foreach ch $children {
-	jlib::wrapper:splitxml $ch tag1 vars1 isempty1 chdata1 children1
+    foreach subel $subels {
+	::xmpp::xml::split $subel stag sxmlns sattrs scdata ssubels
 
 	switch -- $tag1 {
 	    item {
-		set node [jlib::wrapper:getattr $vars1 node]
-		set from [jlib::wrapper:getattr $vars1 from]
-		set category [jlib::wrapper:getattr $vars1 category]
-		set type [jlib::wrapper:getattr $vars1 type]
-		add_message $tw $connid $node $from $category $type
+		set node     [::xmpp::xml::getAttr $sattrs node]
+		set from     [::xmpp::xml::getAttr $sattrs from]
+		set category [::xmpp::xml::getAttr $sattrs category]
+		set type     [::xmpp::xml::getAttr $sattrs type]
+		add_message $tw $xlib $node $from $category $type
 	    }
 	}
     }
@@ -108,16 +107,16 @@
 
 package require md5
 
-proc offline::add_message {tw connid node from category type} {
+proc offline::add_message {tw xlib node from category type} {
     variable options
 
-    set jid [jlib::connection_jid $connid]
+    set jid [connection_jid $xlib]
 
     set fnode [str2node $jid]
     if {![$tw exists $fnode]} {
 	$tw insert end root $fnode -text $jid -open 1 \
 	    -fill $options(unseencolor) -image browser/user \
-	    -data [list type jid connid $connid jid $jid unseen 1]
+	    -data [list type jid xlib $xlib jid $jid unseen 1]
     }
 
     set snode [str2node $node]
@@ -129,7 +128,7 @@
 	}
 	$tw insert end $fnode $snode -text "$category$t from $from \[$node\]" -open 1 \
 	    -fill $options(unseencolor) \
-	    -data [list type node connid $connid jid $jid node $node \
+	    -data [list type node xlib $xlib jid $jid node $node \
 			from $from category $category type $type unseen 1]
 	message_update $tw $snode
     }
@@ -199,43 +198,39 @@
 
     switch -glob -- $props(type)/$action {
         node/fetch {
-	    jlib::send_iq get \
-		[jlib::wrapper:createtag offline \
-		     -vars [list xmlns $::NS(offline)] \
-		     -subtags [list [jlib::wrapper:createtag item \
-					 -vars [list action view \
-						     node $props(node)]]]] \
-	    -connection $props(connid) \
-	    -command [list [namespace current]::action_result $action $tw $node]
+	    ::xmpp::sendIQ $props(xlib) get \
+		-query [::xmpp::xml::create offline \
+			    -xmlns $::NS(offline) \
+			    -subelement [::xmpp::xml::create item \
+					    -attrs [list action view \
+							 node $props(node)]]] \
+		-command [list [namespace current]::action_result $action $tw $node]
         }
 
 	node/purge {
-	    jlib::send_iq set \
-		[jlib::wrapper:createtag offline \
-		     -vars [list xmlns $::NS(offline)] \
-		     -subtags [list [jlib::wrapper:createtag item \
-					 -vars [list action remove \
-						     node $props(node)]]]] \
-	    -connection $props(connid) \
-	    -command [list [namespace current]::action_result $action $tw $node]
+	    ::xmpp::sendIQ $props(xlib) set \
+		-query [::xmpp::xml::create offline \
+			    -xmlns $::NS(offline) \
+			    -subelement [::xmpp::xml::create item \
+					    -attrs [list action remove \
+							 node $props(node)]]]] \
+		-command [list [namespace current]::action_result $action $tw $node]
 	}
 
         jid/fetch {
-	    jlib::send_iq get \
-		[jlib::wrapper:createtag offline \
-		     -vars [list xmlns $::NS(offline)] \
-		     -subtags [list [jlib::wrapper:createtag fetch]]] \
-	    -connection $props(connid) \
-	    -command [list [namespace current]::action_result $action $tw $node]
+	    ::xmpp::sendIQ $props(xlib) get \
+		-query [::xmpp::xml::create offline \
+			    -xmlns $::NS(offline) \
+			    -subelement [::xmpp::xml::create fetch]] \
+		-command [list [namespace current]::action_result $action $tw $node]
         }
 
         jid/purge {
-	    jlib::send_iq set \
-		[jlib::wrapper:createtag offline \
-		     -vars [list xmlns $::NS(offline)] \
-		     -subtags [list [jlib::wrapper:createtag purge]]] \
-	    -connection $props(connid) \
-	    -command [list [namespace current]::action_result $action $tw $node]
+	    ::xmpp::sendIQ $props(xlib) set \
+		-query [::xmpp::xml::create offline \
+			    -xmlns $::NS(offline) \
+			    -subelement [::xmpp::xml::create purge]] \
+		-command [list [namespace current]::action_result $action $tw $node]
         }
 
 	jid/fetchunseen {
@@ -245,20 +240,19 @@
 		catch { array unset props1 }
 		if {![catch { array set props1 [$tw itemcget $child -data] }] && \
 			$props1(unseen) > 0} {
-		    lappend items [jlib::wrapper:createtag item \
-				       -vars [list action view \
-						   node $props1(node)]]
+		    lappend items [::xmpp::xml::create item \
+				       -attrs [list action view \
+						    node $props1(node)]]
 		} else {
 		    set q 1
 		}
 	    }
 	    if {$q} {
-		if {![lempty $items]} {
-		    jlib::send_iq get \
-			[jlib::wrapper:createtag offline \
-			     -vars [list xmlns $::NS(offline)] \
-			     -subtags $items] \
-			-connection $props(connid) \
+		if {[llength $items] > 0} {
+		    ::xmpp::sendIQ $props(xlib) get \
+			-query [::xmpp::xml::create offline \
+				    -xmlns $::NS(offline) \
+				    -subelements $items] \
 			-command [list [namespace current]::action_result $action $tw $node]
 		}
 	    } else {
@@ -273,18 +267,17 @@
 		    catch { array unset props1 }
 		    if {![catch { array set props1 [$tw itemcget $child -data] }]} {
 			if {$props1(unseen) == 0} {
-			    lappend items [jlib::wrapper:createtag item \
-					     -vars [list action remove \
-							 node $props1(node)]]
+			    lappend items [::xmpp::xml::create item \
+					     -attrs [list action remove \
+							  node $props1(node)]]
 			}
 		    }
 		}
-		if {![lempty $items]} {
-		    jlib::send_iq set \
-			[jlib::wrapper:createtag offline \
-			     -vars [list xmlns $::NS(offline)] \
-			     -subtags $items] \
-			-connection $props(connid) \
+		if {[llength $items] > 0} {
+		    ::xmpp::sendIQ $props(xlib) set \
+			-query [::xmpp::xml::create offline \
+				    -xmlns $::NS(offline) \
+				    -subelements $items] \
 			-command [list [namespace current]::action_result $action $tw $node]
 		}
 	    } else {
@@ -332,7 +325,7 @@
 proc offline::action_result {action tw node res child} {
     variable options
 
-    if {$res != "OK"} {
+    if {$res != "ok"} {
 	return
     }
 
@@ -362,21 +355,21 @@
 
 	node/purgeseen {
             if {!$props(unseen)} {
-		action_result purge $tw $node OK {}
+		action_result purge $tw $node ok {}
 	    }
 	}
 
         jid/fetch -
 	jid/fetchunseen {
 	    foreach child [$tw nodes $node] {
-		action_result $action $tw $child OK {}
+		action_result $action $tw $child ok {}
 	    }
         }
 
 	jid/purge -
 	jid/purgeseen {
 	    foreach child [$tw nodes $node] {
-		action_result $action $tw $child OK {}
+		action_result $action $tw $child ok {}
 	    }
 	    if {[lempty [$tw nodes $node]]} {
 		$tw delete $node

Modified: trunk/tkabber/plugins/general/rawxml.tcl
===================================================================
--- trunk/tkabber/plugins/general/rawxml.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/general/rawxml.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -35,7 +35,7 @@
 }
 
 
-proc rawxml::handle_inout {connid text prefix tag} {
+proc rawxml::handle_inout {xlib text prefix tag} {
     variable options
     variable pass
 
@@ -51,8 +51,8 @@
 
     set scroll [expr {[lindex [$dump yview] 1] == 1}]
 
-    set id "($connid)"
-    catch {set id "($connid,[jlib::connection_jid $connid])"}
+    set id "($xlib)"
+    catch {set id "($xlib,[connection_jid $xlib])"}
 
     $dump insert end \
 	"$prefix$id:\n" {} \
@@ -69,7 +69,7 @@
     $dump configure -state disabled
 }
 
-proc rawxml::handle_inout_x {connid xml prefix tag} {
+proc rawxml::handle_inout_x {xlib xml prefix tag} {
     variable options
     variable pass
 
@@ -83,8 +83,8 @@
 
     set scroll [expr {[lindex [$dump yview] 1] == 1}]
 
-    set id "($connid)"
-    catch {set id "($connid,[jlib::connection_jid $connid])"}
+    set id "($xlib)"
+    catch {set id "($xlib,[connection_jid $xlib])"}
 
     $dump insert end "$prefix$id:\n"
 
@@ -101,75 +101,66 @@
     $dump configure -state disabled
 }
 
-proc rawxml::pretty_print {t xmldata prefix tag {xmlns jabber:client}} {
+proc rawxml::pretty_print {t xmldata prefix tag {pxmlns jabber:client}} {
     variable options
     variable tabs
 
-    jlib::wrapper:splitxml $xmldata tagname vars isempty chdata subtags
+    ::xmpp::xml::split $xmldata tag xmlns attrs cdata subels
 
-    set vars1 {}
-    foreach {attr value} $vars {
-	if {$attr == "xmlns"} {
-	    if {$value == $xmlns} {
-		continue
-	    } else {
-		set xmlns $value
-	    }
-	}
-	lappend vars1 $attr $value
+    set attrs1 $attrs
+    if {$pxmlns != $xmlns} {
+	lappend attrs1 xmlns $xmlns
     }
 
-    $t insert end "$prefix<" {} $tagname ${tag}tag
-    if {[llength $vars1] != 0} {
-	#set attrprefix ${prefix}[string repeat " " \
-	#			     [expr {[clength $tagname] + 2}]]
-	set arr_index "$prefix<$tagname "
+    $t insert end "$prefix<" {} $tag ${tag}tag
+    if {[llength $attrs1] != 0} {
+	set arr_index "$prefix<$tag "
 	if {![info exists tabs($arr_index)]} {
 	    set tabs($arr_index) [font measure [$t cget -font] $arr_index]
 	}
 	$t tag configure $arr_index -tabs [list $tabs($arr_index)]
 
-	set vars2 [lassign $vars1 attr value]
+	set attrs2 [lassign $attrs1 attr value]
 	$t insert end \
 	    " $attr" ${tag}attr \
 	    "=" {} \
-	    "'[jlib::wrapper:xmlcrypt $value]'" ${tag}value
-	foreach {attr value} $vars2 {
+	    "'[::xmpp::xml::Escape $value]'" ${tag}value
+	foreach {attr value} $attrs2 {
 	    $t insert end \
 		"\n\t$attr" [list ${tag}attr $arr_index]\
 		"=" {} \
-		"'[jlib::wrapper:xmlcrypt $value]'" ${tag}value
+		"'[::xmpp::xml::Escape $value]'" ${tag}value
 	}
     }
-    if {$chdata == "" && [llength $subtags] == 0} {
+    if {$cdata == "" && [llength $subels] == 0} {
 	$t insert end "/>\n"
 	return
     } else {
 	$t insert end ">"
     }
 
-    if {$subtags == {}} {
-	$t insert end [jlib::wrapper:xmlcrypt $chdata] ${tag}cdata
-	$t insert end "</" {} $tagname ${tag}tag ">\n"
+    if {[llength $subels] == 0} {
+	$t insert end [::xmpp::xml::Escape $cdata] ${tag}cdata
+	$t insert end "</" {} $tag ${tag}tag ">\n"
     } else {
 	$t insert end "\n"
-        foreach subdata $subtags {
+        foreach subdata $subels {
 	    pretty_print $t $subdata \
 		$prefix[string repeat " " $options(indent)] $tag \
 		$xmlns
 	}
-	$t insert end "$prefix</" {} $tagname ${tag}tag ">\n"
+	$t insert end "$prefix</" {} $tag ${tag}tag ">\n"
     }
 }
 
-proc ::LOG_INPUT {connid t} \
-    "[namespace current]::rawxml::handle_inout \$connid \$t IN in"
-proc ::LOG_OUTPUT {connid t} \
-    "[namespace current]::rawxml::handle_inout \$connid \$t OUT out"
-proc ::LOG_INPUT_XML {connid x} \
-    "[namespace current]::rawxml::handle_inout_x \$connid \$x IN in"
-proc ::LOG_OUTPUT_XML {connid x} \
-    "[namespace current]::rawxml::handle_inout_x \$connid \$x OUT out"
+proc ::LOG_INPUT {xlib t} \
+    "[namespace current]::rawxml::handle_inout \$xlib \$t IN in"
+proc ::LOG_OUTPUT {xlib t} \
+    "[namespace current]::rawxml::handle_inout \$xlib \$t OUT out"
+proc ::LOG_INPUT_XML {xlib x} \
+    "[namespace current]::rawxml::handle_inout_x \$xlib \$x IN in"
+proc ::LOG_OUTPUT_XML {xlib x} \
+    "[namespace current]::rawxml::handle_inout_x \$xlib \$x OUT out"
 
 proc rawxml::open_window {} {
     set w .rawxml
@@ -302,11 +293,11 @@
     lvarpush history(stack) $xml 1
     set history(pos) 0
 
-    if {[llength [::jlib::connections]] == 0} {
+    if {[llength [connections]] == 0} {
 	return -code error [::msgcat::mc "Not connected"]
     } else {
-	set connid [lindex [::jlib::connections] 0]
-	jlib::outmsg $xml -connection $connid
+	set xlib [lindex [connections] 0]
+	::xmpp::outText $xlib $xml
     }
     $input delete 1.0 end
 }
@@ -354,110 +345,95 @@
     add_template_group root message [::msgcat::mc "Message"]
 
     add_template message [::msgcat::mc "Normal message"] \
-	[jlib::wrapper:createtag message \
-	     -vars {to "" type normal} \
-	     -subtags [list [jlib::wrapper:createtag body -chdata " "]]]
+	[::xmpp::xml::create message \
+	     -attrs {to "" type normal} \
+	     -subelement [::xmpp::xml::create body -cdata " "]]
 
     add_template message [::msgcat::mc "Chat message"] \
-	[jlib::wrapper:createtag message \
-	     -vars {to "" type chat} \
-	     -subtags [list [jlib::wrapper:createtag body -chdata " "]]]
+	[::xmpp::xml::create message \
+	     -attrs {to "" type chat} \
+	     -subelement [::xmpp::xml::create body -cdata " "]]
 
     add_template message [::msgcat::mc "Headline message"] \
-	[jlib::wrapper:createtag message \
-	     -vars {to "" type headline} \
-	     -subtags [list [jlib::wrapper:createtag subject -chdata " "] \
-			    [jlib::wrapper:createtag body -chdata " "] \
-			    [jlib::wrapper:createtag x \
-				 -vars {xmlns jabber:x:oob} \
-				 -subtags [list [jlib::wrapper:createtag url -chdata " "] \
-						[jlib::wrapper:createtag desc -chdata " "]]]]]
+	[::xmpp::xml::create message \
+	     -attrs {to "" type headline} \
+	     -subelement [::xmpp::xml::create subject -cdata " "] \
+	     -subelement [::xmpp::xml::create body -cdata " "] \
+	     -subelement [::xmpp::xml::create x \
+				-xmlns jabber:x:oob \
+				-subelement [::xmpp::xml::create url -cdata " "] \
+				-subelement [::xmpp::xml::create desc -cdata " "]]]
 
     add_template_group root presence [::msgcat::mc "Presence"]
 
     add_template presence [::msgcat::mc "Available presence"] \
-	[jlib::wrapper:createtag presence \
-	     -vars {to ""} \
-	     -subtags [list \
-			   [jlib::wrapper:createtag status -chdata " "] \
-			   [jlib::wrapper:createtag show -chdata " "] \
-			  ]]
+	[::xmpp::xml::create presence \
+	     -attrs {to ""} \
+	     -subelement [::xmpp::xml::create status -cdata " "] \
+	     -subelement [::xmpp::xml::create show -cdata " "]]
 
     add_template presence [::msgcat::mc "Unavailable presence"] \
-	[jlib::wrapper:createtag presence \
-	     -vars {to "" type unavailable} \
-	     -subtags [list \
-			   [jlib::wrapper:createtag status -chdata " "] \
-			  ]]
+	[::xmpp::xml::create presence \
+	     -attrs {to "" type unavailable} \
+	     -subelement [::xmpp::xml::create status -cdata " "]]
 
-
-
-
     add_template_group root iq [::msgcat::mc "IQ"]
 
     add_template iq [::msgcat::mc "Generic IQ"] \
-	[jlib::wrapper:createtag iq \
-	     -vars {to "" type "" id ""} \
-	     -subtags [list \
-			   [jlib::wrapper:createtag query \
-				-vars {xmlns ""}]]]
+	[::xmpp::xml::create iq \
+	     -attrs {to "" type "" id ""} \
+	     -subelement [::xmpp::xml::create query \
+				-xmlns ""]]
 
     add_template iq "jabber:iq:time get" \
-	[jlib::wrapper:createtag iq \
-	     -vars {to "" type get id ""} \
-	     -subtags [list \
-			   [jlib::wrapper:createtag query \
-				-vars {xmlns jabber:iq:time}]]]
+	[::xmpp::xml::create iq \
+	     -attrs {to "" type get id ""} \
+	     -subelement [::xmpp::xml::create query \
+				-xmlns jabber:iq:time]]
 
     add_template iq "jabber:iq:version get" \
-	[jlib::wrapper:createtag iq \
-	     -vars {to "" type get id ""} \
-	     -subtags [list \
-			   [jlib::wrapper:createtag query \
-				-vars {xmlns jabber:iq:version}]]]
+	[::xmpp::xml::create iq \
+	     -attrs {to "" type get id ""} \
+	     -subelement [::xmpp::xml::create query \
+				-xmlns jabber:iq:version]]
 
     add_template iq "jabber:iq:last get" \
-	[jlib::wrapper:createtag iq \
-	     -vars {to "" type get id ""} \
-	     -subtags [list \
-			   [jlib::wrapper:createtag query \
-				-vars {xmlns jabber:iq:last}]]]
+	[::xmpp::xml::create iq \
+	     -attrs {to "" type get id ""} \
+	     -subelement [::xmpp::xml::create query \
+				-xmlns jabber:iq:last]]
 
-
-
     add_template_group iq pubsub [::msgcat::mc "Pub/sub"]
 
     pubsub_template [::msgcat::mc "Create node"] set \
-	[jlib::wrapper:createtag create \
-	     -vars {node ""}]
+	[::xmpp::xml::create create \
+	     -attrs {node ""}]
     pubsub_template [::msgcat::mc "Publish node"] set \
-	[jlib::wrapper:createtag publish \
-	     -vars {node ""} \
-	     -subtags [list [jlib::wrapper:createtag item]]]
+	[::xmpp::xml::create publish \
+	     -attrs {node ""} \
+	     -subelement [::xmpp::xml::create item]]
     pubsub_template [::msgcat::mc "Retract node"] set \
-	[jlib::wrapper:createtag retract \
-	     -vars {node ""} \
-	     -subtags [list [jlib::wrapper:createtag item]]]
+	[::xmpp::xml::create retract \
+	     -attrs {node ""} \
+	     -subelement [::xmpp::xml::create item]]
     pubsub_template [::msgcat::mc "Subscribe to a node"] set \
-	[jlib::wrapper:createtag subscribe \
-	     -vars {node "" jid ""}]
+	[::xmpp::xml::create subscribe \
+	     -attrs {node "" jid ""}]
     pubsub_template [::msgcat::mc "Unsubscribe from a node"] set \
-	[jlib::wrapper:createtag unsubscribe \
-	     -vars {node "" jid ""}]
+	[::xmpp::xml::create unsubscribe \
+	     -attrs {node "" jid ""}]
     pubsub_template [::msgcat::mc "Get items"] get \
-	[jlib::wrapper:createtag items \
-	     -vars {node ""}]
+	[::xmpp::xml::create items \
+	     -attrs {node ""}]
 }
 
 proc rawxml::pubsub_template {name type subtag} {
     add_template pubsub $name \
-	[jlib::wrapper:createtag iq \
-	     -vars [list to "" type $type id ""] \
-	     -subtags [list \
-			   [jlib::wrapper:createtag pubsub \
-				-vars [list xmlns \
-					   http://jabber.org/protocol/pubsub] \
-				-subtags [list $subtag]]]]
+	[::xmpp::xml::create iq \
+	     -attrs [list to "" type $type id ""] \
+	     -subelement [::xmpp::xml::create pubsub \
+				-xmlns http://jabber.org/protocol/pubsub \
+				-subelement $subtag]]
 }
 
 ##############################################################################

Modified: trunk/tkabber/plugins/general/remote.tcl
===================================================================
--- trunk/tkabber/plugins/general/remote.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/general/remote.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -31,7 +31,7 @@
 
 ############################################
 
-proc ::remote::allow_remote_control {connid from} {
+proc ::remote::allow_remote_control {xlib from} {
     variable options
 
     if {!$options(enable)} {
@@ -41,7 +41,7 @@
     set from [string tolower $from]
     set myjid [string tolower \
 		      [node_and_server_from_jid \
-			   [jlib::connection_jid $connid]]]
+			   [connection_jid $xlib]]]
     set bare_from [string tolower [node_and_server_from_jid $from]]
 
     if {$options(accept_from_myjid) && [cequal $myjid $bare_from]} {
@@ -70,26 +70,26 @@
 	[namespace current]::common_command_infoitems_handler $name
 }
 
-proc ::remote::common_command_infoitems_handler {type connid from lang xmllist} {
+proc ::remote::common_command_infoitems_handler {type xlib from lang xmllist} {
     variable commands
 
-    if {![allow_remote_control $connid $from]} {
+    if {![allow_remote_control $xlib $from]} {
 	return {error cancel not-allowed}
     }
 
-    jlib::wrapper:splitxml $xmllist tag vars isempty chdata children
-    set node [jlib::wrapper:getattr $vars node]
+    ::xmpp::xml::split $xmllist tag xmlns attrs cdata subels
+    set node [::xmpp::xml::getAttr $attrs node]
 
     if {![cequal $node ""] && [info exists commands(command,$node)]} {
 	if {[cequal $type info]} {
 	    return \
-		[list [jlib::wrapper:createtag identity \
-			   -vars [list category automation \
-				       type command-node \
-				       name [::trans::trans $lang \
-						 $commands(name,$node)]]] \
-		      [jlib::wrapper:createtag feature \
-			   -vars [list var $::NS(commands)]]]
+		[list [::xmpp::xml::create identity \
+			   -attrs [list category automation \
+				        type command-node \
+				        name [::trans::trans $lang \
+						    $commands(name,$node)]]] \
+		      [::xmpp::xml::create feature \
+			   -attrs [list var $::NS(commands)]]]
 	} else {
 	    return {}
 	}
@@ -98,33 +98,33 @@
     }
 }
 
-proc ::remote::commands_list_handler {type connid from lang xmllist} {
+proc ::remote::commands_list_handler {type xlib from lang xmllist} {
     variable commands
 
-    if {![allow_remote_control $connid $from]} {
+    if {![allow_remote_control $xlib $from]} {
 	return {error cancel not-allowed}
     }
 
-    set myjid [jlib::connection_jid $connid]
+    set myjid [connection_jid $xlib]
 
     switch -- $type {
 	items {
 	    set items {}
 	    foreach node $commands(nodes) {
-		lappend items [jlib::wrapper:createtag item \
-				   -vars [list jid $myjid \
-					       node $node \
-					       name [::trans::trans $lang \
-							 $commands(name,$node)]]]
+		lappend items [::xmpp::xml::create item \
+				   -attrs [list jid $myjid \
+					        node $node \
+					        name [::trans::trans $lang \
+							  $commands(name,$node)]]]
 	    }
 	    return $items
 	}
 	info {
-	    return [list [jlib::wrapper:createtag identity \
-			      -vars [list category automation \
-					  type command-list \
-					  name [::trans::trans $lang \
-						    "Remote control"]]]]
+	    return [list [::xmpp::xml::create identity \
+			      -attrs [list category automation \
+					   type command-list \
+					   name [::trans::trans $lang \
+						     "Remote control"]]]]
 	}
     }
     return {}
@@ -146,12 +146,12 @@
     $commands(command,$node) $session cancel {}
 
     upvar 0 $session state
-    catch {unset sessions($state(connid),$state(from),$state(node),$state(id))}
+    catch {unset sessions($state(xlib),$state(from),$state(node),$state(id))}
 
     catch {unset $session}
 }
 
-proc ::remote::create_session {node connid from lang} {
+proc ::remote::create_session {node xlib from lang} {
     variable commands
     variable sessions
     variable prefix
@@ -159,7 +159,7 @@
     if {![info exists commands(command,$node)]} return
 
     set id [rand 1000000000]
-    while {[info exists sesssions($connid,$from,$node,$id)]} {
+    while {[info exists sesssions($xlib,$from,$node,$id)]} {
 	set id [rand 1000000000]
     }
 
@@ -172,29 +172,31 @@
     upvar 0 $session state
 
     set state(id) $id
-    set state(connid) $connid
+    set state(xlib) $xlib
     set state(from) $from
     set state(node) $node
     set state(lang) $lang
-    set sessions($connid,$from,$node,$id) $session
+    set sessions($xlib,$from,$node,$id) $session
 
     return $session
 }
 
-proc ::remote::command_set_handler {connid from lang child} {
+proc ::remote::command_set_handler {xlib from child args} {
     variable commands
     variable sessions
 
-    if {![allow_remote_control $connid $from]} {
+    if {![allow_remote_control $xlib $from]} {
 	return {error cancel not-allowed}
     }
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
+    ::xmpp::xml::split $child tag xmlns attrs cdata subels
 
-    set node [jlib::wrapper:getattr $vars node]
-    set action [jlib::wrapper:getattr $vars action]
-    set id [jlib::wrapper:getattr $vars sessionid]
+    set node [::xmpp::xml::getAttr $attrs node]
+    set action [::xmpp::xml::getAttr $attrs action]
+    set id [::xmpp::xml::getAttr $attrs sessionid]
 
+    set lang [::xmpp::xml::getAttr $args -lang en]
+
     if {![info exists commands(command,$node)]} {
 	return {error cancel item-not-found}
     }
@@ -202,12 +204,12 @@
     if {[cequal $id ""]} {
 	# We use lang only when create session.
 	# Probably it would be better to use it after every request.
-	set session [create_session $node $connid $from $lang]
+	set session [create_session $node $xlib $from $lang]
     } else {
-	if {![info exists sessions($connid,$from,$node,$id)]} {
+	if {![info exists sessions($xlib,$from,$node,$id)]} {
 	    return [get_error modify bad-request bad-sessionid]
 	}
-	set session $sessions($connid,$from,$node,$id)
+	set session $sessions($xlib,$from,$node,$id)
     }
 
     upvar 0 $session state
@@ -215,11 +217,11 @@
 
     if {[cequal $action cancel]} {
 	clear_session $session $node
-	return [list result [jlib::wrapper:createtag command \
-				 -vars [list xmlns $::NS(commands) \
-					     sessionid $id \
-					     node $node \
-					     status canceled]]]
+	return [list result [::xmpp::xml::create command \
+				 -attrs [list xmlns $::NS(commands) \
+					      sessionid $id \
+					      node $node \
+					      status canceled]]]
     }
 
     set result [$commands(command,$node) $session $action $children]
@@ -243,22 +245,21 @@
 	}
     }
 
-    return [list result [jlib::wrapper:createtag command \
-			     -vars [list xmlns $::NS(commands) \
-					 sessionid $id \
-					 node $node \
-					 status $status] \
-			     -subtags [lrange $result 1 end]]]
+    return [list result [::xmpp::xml::create command \
+			     -xmlns $::NS(commands) \
+			     -attrs [list sessionid $id \
+					  node $node \
+					  status $status] \
+			     -subelements [lrange $result 1 end]]]
 }
 
-iq::register_handler set command $::NS(commands) ::remote::command_set_handler
+::xmpp::iq::register set command $::NS(commands) ::remote::command_set_handler
 
 proc ::remote::get_error {type general {specific ""}} {
     set res [list error $type $general]
     if {![cequal $specific ""]} {
 	lappend res -application-specific \
-	    [jlib::wrapper:createtag $specific \
-		 -vars [list xmlns $::NS(commands)]]
+	    [::xmpp::xml::create $specific -xmlns $::NS(commands)]
     }
     return $res
 }
@@ -354,10 +355,9 @@
 proc ::remote::standart_parseresult {children_b form_type} {
     set result {}
     foreach child $children_b {
-	jlib::wrapper:splitxml $child tag vars isempty chdata children
+	::xmpp::xml::split $child tag xmlns attrs cdata subels
 
-	set xmlns  [jlib::wrapper:getattr $vars xmlns]
-	set type  [jlib::wrapper:getattr $vars type]
+	set type [::xmpp::xml::getAttr $attrs type]
 	if {![cequal $tag x] || ![cequal $xmlns $::NS(data)]} {
 	    continue
 	}
@@ -365,7 +365,7 @@
 	    return [::remote::get_error modify bad-request bad-payload]
 	}
 
-	foreach field [::data::parse_xdata_results $children -hidden 1] {
+	foreach field [::data::parse_xdata_results $subels -hidden 1] {
 	    lassign $field var type label values
 	    if {[cequal $var FORM_TYPE]} {
 		if {![cequal [lindex $values 0] $form_type]} {
@@ -440,10 +440,10 @@
 			-label [::trans::trans $lang "Message"] \
 			-values [split $textstatus "\n"]]
 
-    return [list executing [jlib::wrapper:createtag x \
-				-vars [list xmlns $::NS(data) \
-					    type form] \
-				-subtags $fields]]
+    return [list executing [::xmpp::xml::create x \
+				-xmlns $::NS(data) \
+				-attrs [list type form] \
+				-subelements $fields]]
 
 }
 
@@ -496,9 +496,9 @@
     set userpriority $state(userpriority)
     set userstatus $state(userstatus)
 
-    return [list completed [jlib::wrapper:createtag note \
-				-vars {type info} \
-				-chdata \
+    return [list completed [::xmpp::xml::create note \
+				-attrs {type info} \
+				-cdata \
 				    [::trans::trans $lang \
 					 "Status was changed successfully"]]]
 }
@@ -521,19 +521,19 @@
 
     set options {}
     set lang $state(lang)
-    set connid $state(connid)
-    foreach chatid [lfilter chat::is_groupchat [chat::opened $connid]] {
+    set xlib $state(xlib)
+    foreach chatid [lfilter chat::is_groupchat [chat::opened $xlib]] {
 	set jid [chat::get_jid $chatid]
-	if {![cequal [get_jid_presence_info show $connid $jid] ""]} {
+	if {![cequal [get_jid_presence_info show $xlib $jid] ""]} {
 	    set nick [get_our_groupchat_nick $chatid]
 	    lappend options [list $jid [format [::trans::trans $lang "%s at %s"] \
 					       $nick $jid]]
 	}
     }
     if {[llength $options] == 0} {
-	return [list completed [jlib::wrapper:createtag note \
-				    -vars {type info} \
-				    -chdata [::trans::trans $lang \
+	return [list completed [::xmpp::xml::create note \
+				    -attrs {type info} \
+				    -cdata [::trans::trans $lang \
 						 "No groupchats to leave"]]]
     }
 
@@ -561,10 +561,10 @@
 			-var x-reason \
 			-label [::trans::trans $lang "Reason"]]
 
-    return [list executing [jlib::wrapper:createtag x \
-				-vars [list xmlns $::NS(data) \
-					    type form] \
-				-subtags $fields]]
+    return [list executing [::xmpp::xml::create x \
+				-xmlns $::NS(data) \
+				-attrs [list type form] \
+				-subelements $fields]]
 }
 
 proc ::remote::leave_groupchats::set_step1 {session children} {
@@ -599,33 +599,33 @@
 proc ::remote::leave_groupchats::get_finish {session} {
     upvar 0 $session state
 
-    set args [list -connection $state(connid)]
+    set xlib $state(xlib)
+    set args {}
     set lang $state(lang)
 
-    if {![cequal $state(reason) ""]} {
-	lappend args -stat $state(reason)
+    if {![string equal $state(reason) ""]} {
+	lappend args -status $state(reason)
     }
 
     # "all" workaround, will be removed soon
     if $state(all) {
-	set connid $state(connid)
 	set state(groupchats) ""
 
-	foreach chatid [lfilter chat::is_groupchat [chat::opened $connid]] {
+	foreach chatid [lfilter chat::is_groupchat [chat::opened $xlib]] {
 	    set jid [chat::get_jid $chatid]
-	    if {![cequal [get_jid_presence_info show $connid $jid] ""]} {
+	    if {![string equal [get_jid_presence_info show $xlib $jid] ""]} {
 		lappend state(groupchats) $jid
 	    }
 	}
     }
 
     foreach jid $state(groupchats) {
-	eval [list send_presence unavailable -to $jid] $args
+	eval [list send_presence $xlib unavailable -to $jid] $args
     }
 
-    return [list completed [jlib::wrapper:createtag note \
-				-vars {type info} \
-				-chdata [::trans::trans $lang \
+    return [list completed [::xmpp::xml::create note \
+				-attrs {type info} \
+				-cdata [::trans::trans $lang \
 					     "Groupchats were leaved\
 					      successfully"]]]
 }
@@ -650,14 +650,14 @@
 
     set options {}
     set lang $state(lang)
-    set connid $state(connid)
+    set xlib $state(xlib)
     foreach id [array names unread] {
 	lassign $id type chatid
-	if {![cequal [chat::get_connid $chatid] $connid]} continue
+	if {![cequal [chat::get_xlib $chatid] $xlib]} continue
 
 	set jid [chat::get_jid $chatid]
-	set name [::roster::itemconfig $connid \
-				       [::roster::find_jid $connid $jid] \
+	set name [::roster::itemconfig $xlib \
+				       [::roster::find_jid $xlib $jid] \
 				       -name]
 	if {![cequal $name ""]} {
 	    set name [format "%s (%s)" $name $jid]
@@ -678,9 +678,9 @@
 	lappend options [list $id [format $msg $name $count]]
     }
     if {[llength $options] == 0} {
-	return [list completed [jlib::wrapper:createtag note \
-				    -vars {type info} \
-				    -chdata \
+	return [list completed [::xmpp::xml::create note \
+				    -attrs {type info} \
+				    -cdata \
 					[::trans::trans $lang \
 					     "There are no unread messages"]]]
     }
@@ -708,10 +708,10 @@
 			-required 1 \
 			-options $options]
 
-    return [list executing [jlib::wrapper:createtag x \
-				-vars [list xmlns $::NS(data) \
-					    type form] \
-				-subtags $fields]]
+    return [list executing [::xmpp::xml::create x \
+				-xmlns $::NS(data) \
+				-attrs [list type form] \
+				-subelements $fields]]
 }
 
 proc ::remote::forward::set_step1 {session children} {
@@ -742,9 +742,9 @@
     upvar 0 $session state
     variable unread
 
-    set connid $state(connid)
+    set xlib $state(xlib)
     set lang $state(lang)
-    set oto [jlib::connection_jid $connid]
+    set oto [connection_jid $xlib]
     set target $state(from)
 
     # "all" workaround, will be removed soon
@@ -753,19 +753,19 @@
 
 	foreach id [array names unread] {
 	    lassign $id type chatid
-	    if {![cequal [chat::get_connid $chatid] $connid]} continue
+	    if {![cequal [chat::get_xlib $chatid] $xlib]} continue
 	    lappend state(chats) $id
 	}
     }
 
     foreach id $state(chats) {
-	forward_messages $id $connid $oto $target
+	forward_messages $id $xlib $oto $target
     }
 
     return [list completed \
-		 [jlib::wrapper:createtag note \
-		      -vars {type info} \
-		      -chdata [::trans::trans $lang \
+		 [::xmpp::xml::create note \
+		      -attrs {type info} \
+		      -cdata [::trans::trans $lang \
 				   "Unread messages were forwarded\
 				    successfully"]]]
 }
@@ -776,7 +776,7 @@
 # forwards messages
 # leaves marks that they were forwarded.
 # cleanup arrays
-proc ::remote::forward::forward_messages {id connid oto target} {
+proc ::remote::forward::forward_messages {id xlib oto target} {
     variable unread
     variable msgdata
 
@@ -796,23 +796,20 @@
 	    }
 	}
 
-	lappend x [jlib::wrapper:createtag addresses \
-		       -vars [list xmlns $::NS(xaddress)] \
-		       -subtags [list [jlib::wrapper:createtag address \
-					   -vars [list type ofrom \
-						       jid $ofrom]] \
-				      [jlib::wrapper:createtag address \
-					   -vars [list type oto \
-						       jid $oto]]]]
+	lappend x [::xmpp::xml::create addresses \
+		       -xmlns $::NS(xaddress) \
+		       -subelement [::xmpp::xml::create address \
+					   -attrs [list type ofrom \
+						        jid $ofrom]] \
+		       -subelement [::xmpp::xml::create address \
+					   -attrs [list type oto \
+						        jid $oto]]]
 
-	lappend x [jlib::wrapper:createtag x \
-		       -vars [list xmlns "jabber:x:delay" \
-				   stamp $date]]
+	lappend x [::xmpp::delay::create $date]
 
-	jlib::send_msg $target -body $body \
-			       -type $type \
-			       -xlist $x \
-			       -connection $connid
+	::xmpp::sendMessage $xlib $target -body $body \
+					  -type $type \
+					  -xlist $x
 
 	switch -- $type {
 	    normal {
@@ -850,8 +847,7 @@
     if {![lcontain {chat groupchat} $type]} return
 #    if {![cequal chat $type]} return
 
-    set date [clock format [clock seconds] -format "%Y%m%dT%H:%M:%S" -gmt 1]
-
+    set date [clock seconds]
     set message [list $date $from $body $extras]
     set id [list $type $chatid]
     lappend unread($id) $message
@@ -877,7 +873,7 @@
 
 # store message with type == normal
 proc ::remote::forward::message_process_x \
-     {rowvar bodyvar f x connid from id type replyP} {
+     {rowvar bodyvar f x xlib from id type replyP} {
     upvar 2 $rowvar row
     upvar 2 $bodyvar body
     variable unread
@@ -887,7 +883,7 @@
 	return
     }
 
-    set id [list normal [chat::chatid $connid $from]]
+    set id [list normal [chat::chatid $xlib $from]]
 
     if {![info exists unread($id)]} {
 	set unread($id) {}
@@ -900,7 +896,7 @@
 	 +[list [namespace current]::on_msgwin_destroy $msgwin $id]
     lappend unread($id) $msgwin
 
-    set date [clock format [clock seconds] -format "%Y%m%dT%H:%M:%S" -gmt 1]
+    set date [clock seconds]
     set msgdata($msgwin) [list $date $from $body $x]
 
     return

Modified: trunk/tkabber/plugins/general/session.tcl
===================================================================
--- trunk/tkabber/plugins/general/session.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/general/session.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -60,16 +60,16 @@
     foreach script [lsort -integer -index 0 $session_script_list] {
 	lassign $script priority user server resource command
 
+	set jid [::xmpp::jid::jid $user $server $resource]
+
 	if {($user != "") || ($server != "") || ($resource != "")} {
 	    # HACK. It works if called before any JID is connected
-	    set connid [jlib::new -user $user \
-				  -server $server \
-				  -resource $resource]
+	    set xlib [create_xlib $jid]
 	} else {
-	    set connid ""
+	    set xlib ""
 	}
 
-	after idle [list eval $command [list $connid $user@$server/$resource]]
+	after idle [list eval $command [list $xlib $jid]]
     }
 }
 

Modified: trunk/tkabber/plugins/general/sound.tcl
===================================================================
--- trunk/tkabber/plugins/general/sound.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/general/sound.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -204,15 +204,8 @@
 
     if {[is_mute]} return
 
-    set delayed 0
-    foreach xelem $extras {
-	jlib::wrapper:splitxml $xelem tag vars isempty chdata children
+    set delayed [::xmpp::delay::exists $extras]
 
-	if {[cequal [jlib::wrapper:getattr $vars xmlns] jabber:x:delay]} {
-	    set delayed 1
-	}
-    }
-
     switch -- $type {
 	groupchat {
 	    if {$delayed && $options(mute_groupchat_delayed)} {
@@ -223,7 +216,7 @@
 	    } elseif {[chat::is_our_jid $chatid $from]} {
 		play $sounds(groupchat_my_message)
 	    } else {
-		set mynick [chat::get_nick [chat::get_connid $chatid] \
+		set mynick [chat::get_nick [chat::get_xlib $chatid] \
 					   [chat::our_jid $chatid] $type]
 		if {[check_message $mynick $body]} {
 		    play $sounds(groupchat_their_message_to_me) -1
@@ -237,11 +230,11 @@
 		return
 	    }
 	    foreach xelem $extras {
-		jlib::wrapper:splitxml $xelem tag vars isempty chdata children
+		::xmpp::xml::split $xelem tag xmlns attrs cdata subels
 		# Don't play sound if this 'empty' tag is present. It indicates
 		# messages history in chat window.
-		if {[cequal $tag ""] && \
-		    [cequal [jlib::wrapper:getattr $vars xmlns] tkabber:x:nolog]} {
+		if {[string equal $tag ""] && \
+				    [string equal $xmlns tkabber:x:nolog]} {
 		    return
 		}
 	    }
@@ -289,7 +282,7 @@
     }
 }
 
-proc ::sound::connected_notify {connid} {
+proc ::sound::connected_notify {xlib} {
     variable options
     variable sounds
 
@@ -298,18 +291,18 @@
     play $sounds(connected) 1
 }
 
-proc ::sound::disconnected_notify {connid} {
+proc ::sound::disconnected_notify {xlib} {
     variable options
     variable sounds
 
     if {[is_mute]} return
 
-    if {$connid == {}} {
-	if {[llength [jlib::connections]] > 0} {
+    if {$xlib == {}} {
+	if {[llength [connections]] > 0} {
 	    play $sounds(disconnected) 1
 	}
     } else {
-	if {[lsearch -exact [jlib::connections] $connid] >= 0} {
+	if {[lsearch -exact [connections] $xlib] >= 0} {
 	    play $sounds(disconnected) 1
 	}
     }

Modified: trunk/tkabber/plugins/general/stats.tcl
===================================================================
--- trunk/tkabber/plugins/general/stats.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/general/stats.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -100,84 +100,86 @@
 
 }
 
-proc stats::query_list {jid node args} {
-    set vars [list xmlns $::NS(stats)]
-
+proc stats::query_list {xlib jid node args} {
+    set vars {}
     if {$node != ""} {
 	lappend vars node $node
     }
-    
-    jlib::send_iq get [jlib::wrapper:createtag query \
-			   -vars $vars] \
+
+    if {$xlib == ""} {
+	set xlib [lindex [connections] 0]
+    }
+
+    ::xmpp::sendIQ $xlib get \
+	-query [::xmpp::xml::create query \
+			-xmlns $::NS(stats) \
+			-attrs $vars] \
 	-to $jid \
-	-connection [jlib::route $jid] \
 	-command [list [namespace current]::recv_query_list_result $jid $node]
 }
 
 proc stats::recv_query_list_result {jid node res child} {
     variable data
 
-    if {![cequal $res OK]} {
+    if {![cequal $res ok]} {
 	return
     }
 
     open_window
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
+    ::xmpp::xml::split $child tag xmlns attrs cdata subels
 
-    foreach item $children {
-	jlib::wrapper:splitxml $item tag1 vars1 isempty1 chdata1 children1
+    foreach item $subels {
+	::xmpp::xml::split $item stag sxmlns sattrs scdata ssubels
 
-	if {$tag1 == "stat"} {
-	    set name [jlib::wrapper:getattr $vars1 name]
-	    #puts "$jid $node $name"
+	if {$stag == "stat"} {
+	    set name [::xmpp::xml::getAttr $sattrs name]
 	    add_line $jid $node $name
 	}
     }
 }
 
 proc stats::request_value {jid node name} {
-    set vars [list xmlns $::NS(stats)]
-
+    set vars {}
     if {$node != ""} {
 	lappend vars node $node
     }
     
-    jlib::send_iq get [jlib::wrapper:createtag query \
-			   -vars $vars \
-			   -subtags [list [jlib::wrapper:createtag stat \
-					       -vars [list name $name]]]] \
+    ::xmpp::sendIQ [lindex [connections] 0] get \
+	-query [::xmpp::xml::create query \
+			-xmlns $::NS(stats) \
+			-attrs $vars \
+			-subelement [::xmpp::xml::create stat \
+					    -attrs [list name $name]]] \
 	-to $jid \
-	-connection [jlib::route $jid] \
 	-command [list [namespace current]::recv_values_result $jid $node]
 }
 
 proc stats::recv_values_result {jid node res child} {
     variable data
 
-    if {![cequal $res OK]} {
+    if {![cequal $res ok]} {
 	return
     }
 
     open_window
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
+    ::xmpp::xml::split $child tag xmlns attrs cdata subels
 
-    foreach item $children {
-	jlib::wrapper:splitxml $item tag1 vars1 isempty1 chdata1 children1
+    foreach item $subels {
+	::xmpp::xml::split $item stag sxmlns sattrs scdata ssubels
 
-	if {$tag1 == "stat"} {
-	    set name  [jlib::wrapper:getattr $vars1 name]
-	    set value [jlib::wrapper:getattr $vars1 value]
-	    set units [jlib::wrapper:getattr $vars1 units]
+	if {$stag == "stat"} {
+	    set name  [::xmpp::xml::getAttr $sattrs name]
+	    set value [::xmpp::xml::getAttr $sattrs value]
+	    set units [::xmpp::xml::getAttr $sattrs units]
 
-	    foreach subitem $children1 {
-		jlib::wrapper:splitxml $subitem tag2 vars2 isempty2 \
-		    chdata2 children2
-		if {$tag2 == "error"} {
+	    foreach sitem $ssubels {
+		::xmpp::xml::split $sitem sstag ssxmlns ssattrs sscdata sssubels
+		if {$sstag == "error"} {
 		    set error [error_to_string \
-				   [list [jlib::wrapper:getattr $vars2 code] \
-					$chdata2]]
+				   [list [::xmpp::xml::getAttr $ssattrs code] \
+					 $sscdata]]
 		    break
 		}
 	    }

Modified: trunk/tkabber/plugins/general/subscribe_gateway.tcl
===================================================================
--- trunk/tkabber/plugins/general/subscribe_gateway.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/general/subscribe_gateway.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -7,13 +7,13 @@
 	[namespace current]::add_menu_item 30
 }
 
-proc gateway::add_menu_item {m connid jid} {
+proc gateway::add_menu_item {m xlib jid} {
 
     $m add command -label [::msgcat::mc "Add user to roster..."] \
-	-command [list [namespace current]::subscribe_dialog $connid $jid]
+	-command [list [namespace current]::subscribe_dialog $xlib $jid]
 }
 
-proc gateway::subscribe_dialog {connid service} {
+proc gateway::subscribe_dialog {xlib service} {
     variable msgid
 
     set mw .gwmsg$msgid
@@ -27,7 +27,7 @@
 
     set bbox [ButtonBox $mw.buttons -spacing 0 -padx 10 -default 0]
     $bbox add -text [::msgcat::mc "Subscribe"] \
-        -command [list [namespace current]::send_subscribe $mw $connid $service]
+        -command [list [namespace current]::send_subscribe $mw $xlib $service]
     $bbox add -text [::msgcat::mc "Cancel"] -command [list destroy $mw]
 
     bind $mw <Return> "ButtonBox::invoke $bbox default"
@@ -47,12 +47,11 @@
     variable $mw.prompt fulljid
     bind $mw <Destroy> [list catch [list unset [namespace current]::$mw.prompt]]
 
-    jlib::send_iq get \
-        [jlib::wrapper:createtag query \
-             -vars {xmlns jabber:iq:gateway}] \
+    ::xmpp::sendIQ $xlib get \
+        -query [::xmpp::xml::create query \
+		    -xmlns jabber:iq:gateway] \
 	-to $service \
-        -command [list [namespace current]::configure_prompt $mw.prompt] \
-	-connection $connid
+        -command [list [namespace current]::configure_prompt $mw.prompt]
 
     frame $mw.subj
     label $mw.subj.lab -text [::msgcat::mc "Send subscription to: "]
@@ -83,60 +82,59 @@
     $w configure \
 	-text [::msgcat::mc "Enter screenname of contact you want to add"]
     
-    if {$res != "OK"} {
+    if {$res != "ok"} {
 	return
     }
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
+    ::xmpp::xml::split $child tag xmlns attrs cdata subels
 
-    foreach ch $children {
-	jlib::wrapper:splitxml $ch tag1 vars1 isempty1 chdata1 children1
+    foreach ch $subels {
+	::xmpp::xml::split $ch stag sxmlns sattrs scdata ssubels
 
-	if {($tag1 == "desc") && ($chdata1 != "")} {
-	    $w configure -text $chdata1
+	if {($stag == "desc") && ($scdata != "")} {
+	    $w configure -text $scdata
 	    variable $w screenname
 	    break
 	}
     }
 }
 
-proc gateway::send_subscribe {mw connid service} {
+proc gateway::send_subscribe {mw xlib service} {
     variable $mw.prompt
     
     switch -- [set $mw.prompt] {
 	fulljid {
 	    $mw.subj.entry insert end "@$service"
-	    message::send_subscribe $mw -connection $connid
+	    message::send_subscribe $mw $xlib
 	}
 	screenname {
 	    set screenname [$mw.subj.entry get]
-	    jlib::send_iq set \
-		[jlib::wrapper:createtag query \
-		     -vars {xmlns jabber:iq:gateway} \
-		     -subtags [list [jlib::wrapper:createtag prompt \
-					 -chdata $screenname]]] \
+	    ::xmpp::sendIQ $xlib set \
+		-query [::xmpp::xml::create query \
+			    -xmlns jabber:iq:gateway \
+			    -subelement [::xmpp::xml::create prompt \
+					    -cdata $screenname]] \
 		-to $service \
 		-command [list [namespace current]::gw_send_subscribe $mw \
 			       "$screenname@$service" \
-			       $connid] \
-		-connection $connid
+			       $xlib]
 	}
     }
 }
 
-proc gateway::gw_send_subscribe {mw fallback connid res child} {
+proc gateway::gw_send_subscribe {mw fallback xlib res child} {
 
     set jid $fallback
 
-    if {$res == "OK"} {
-	jlib::wrapper:splitxml $child tag vars isempty chdata children
+    if {$res == "ok"} {
+	::xmpp::xml::split $child tag xmlns attrs cdata subels
 
-	foreach ch $children {
-	    jlib::wrapper:splitxml $ch tag1 vars1 isempty1 chdata1 children1
+	foreach ch $subels {
+	    ::xmpp::xml::split $ch stag sxmlns sattrs scdata ssubels
 
-	    if {($tag1 == "jid" || ($tag1 == "prompt")) && \
-		    ($chdata1 != "")} {
-		set jid $chdata1
+	    if {($stag == "jid" || ($stag == "prompt")) && \
+		    ($scdata != "")} {
+		set jid $scdata
 		break
 	    }
 	}
@@ -144,34 +142,24 @@
     
     $mw.subj.entry delete 0 end
     $mw.subj.entry insert 0 $jid
-    message::send_subscribe $mw -connection $connid
+    message::send_subscribe $mw $xlib
 }
 
 
-proc gateway::convert_jid {jid args} {
+proc gateway::convert_jid {xlib jid args} {
 
-    foreach {opt val} $args {
-	switch -- $opt {
-	    -connection {set connid $val}
-	}
-    }
-    if {![info exists connid]} {
-	return -code error "Option -connection mandatory"
-    }
-
-    jlib::send_iq get \
-        [jlib::wrapper:createtag query \
-             -vars {xmlns jabber:iq:gateway}] \
+    ::xmpp::sendIQ $xlib get \
+        -query [::xmpp::xml::create query \
+		    -xmlns jabber:iq:gateway] \
 	-to $jid \
         -command [list [namespace current]::convert_jid_dialog \
-		       $jid $connid] \
-	-connection $connid
+		       $xlib $jid]
 }
 
-proc gateway::convert_jid_dialog {jid connid res child} {
+proc gateway::convert_jid_dialog {xlib jid res child} {
     variable msgid
 
-    if {$res != "OK"} return
+    if {$res != "ok"} return
 
     set w .gwmsg$msgid
 
@@ -182,19 +170,19 @@
     set f [$w getframe]
 
     $w add -text [::msgcat::mc "Convert"] \
-        -command [list [namespace current]::convert_screenname $w $connid $jid]
+        -command [list [namespace current]::convert_screenname $w $xlib $jid]
     $w add -text [::msgcat::mc "Cancel"] -command [list destroy $w]
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
+    ::xmpp::xml::split $child tag xmlns attrs cdata subels
 
     set row 0
-    foreach ch $children {
-	jlib::wrapper:splitxml $ch tag1 vars1 isempty1 chdata1 children1
+    foreach ch $subels {
+	::xmpp::xml::split $ch stag sxmlns sattrs scdata ssubels
 
-	switch -- $tag1 {
+	switch -- $stag {
 	    desc {
 		if {![winfo exists $f.desc]} {
-		    message $f.desc -text $chdata1 -width 15c
+		    message $f.desc -text $scdata -width 15c
 		    grid $f.desc -row $row -column 0 \
 			-columnspan 2 -sticky w -pady 2m
 		}
@@ -216,39 +204,38 @@
     $w draw $f.prompt
 }
 
-proc gateway::convert_screenname {w connid jid} {
+proc gateway::convert_screenname {w xlib jid} {
     set f [$w getframe]
     set screenname [$f.prompt get]
     
     destroy $w
     
-    jlib::send_iq set \
-	[jlib::wrapper:createtag query \
-	     -vars {xmlns jabber:iq:gateway} \
-	     -subtags [list [jlib::wrapper:createtag prompt \
-				 -chdata $screenname]]] \
+    ::xmpp::sendIQ $xlib set \
+	-query [::xmpp::xml::create query \
+		    -xmlns jabber:iq:gateway \
+		    -subelement [::xmpp::xml::create prompt \
+				    -cdata $screenname]] \
 	-to $jid \
-	-command [list [namespace current]::display_conversion $w $screenname] \
-	-connection $connid
+	-command [list [namespace current]::display_conversion $w $screenname]
 }
 
 proc gateway::display_conversion {w screenname res child} {
 
-    if {$res != "OK"} {
+    if {$res != "ok"} {
 	NonmodalMessageDlg $w -aspect 50000 -icon error \
 	    -message [format [::msgcat::mc "Error while converting screenname: %s."] \
 			  [error_to_string $child]]
     } else {
 	set jid ""
 
-	jlib::wrapper:splitxml $child tag vars isempty chdata children
+	::xmpp::xml::split $child tag xmlns attrs cdata subels
 
-	foreach ch $children {
-	    jlib::wrapper:splitxml $ch tag1 vars1 isempty1 chdata1 children1
+	foreach ch $subels {
+	    ::xmpp::xml::split $ch stag sxmlns sattrs scdata ssubels
 
-	    if {($tag1 == "jid" || ($tag1 == "prompt")) && \
-		    ($chdata1 != "")} {
-		set jid $chdata1
+	    if {($stag == "jid" || ($stag == "prompt")) && \
+		    ($scdata != "")} {
+		set jid $scdata
 		break
 	    }
 	}

Modified: trunk/tkabber/plugins/general/xaddress.tcl
===================================================================
--- trunk/tkabber/plugins/general/xaddress.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/general/xaddress.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -30,29 +30,29 @@
 
 proc ::xaddress::parse_xaddress_fields {xe {elems {}}} {
 
-    jlib::wrapper:splitxml $xe tag vars isempty chdata children
+    ::xmpp::xml::split $xe tag xmlns attrs cdata subels
 
-    if {![cequal [jlib::wrapper:getattr $vars xmlns] $::NS(xaddress)]} {
+    if {![string equal $xmlns $::NS(xaddress)]} {
 	return {}
     }
-    if {![cequal $tag addresses]} {
+    if {![string equal $tag addresses]} {
 	return {}
     }
 
     set res {}
     
-    foreach child $children {
-	jlib::wrapper:splitxml $child tag1 vars1 isempty1 chdata1 children1
+    foreach subel $subels {
+	::xmpp::xml::split $subel stag sxmlns sattrs scdata ssubels
 		
-	if {![cequal $tag1 address]} continue
+	if {![string equal $stag address]} continue
 
-	set type [jlib::wrapper:getattr $vars1 type] 
-	if {![lempty $elems] && ![lcontain $elems $type]} continue
+	set type [::xmpp::xml::getAttr $sattrs type] 
+	if {[llength $elems] > 0 && [lsearch -exact $elems $type] < 0} continue
 
 	set params {}
 	foreach elem {jid node uri descr delivered} {
-	    set value [jlib::wrapper:getattr $vars1 $elem]
-	    if {![cequal $value ""]} {
+	    set value [::xmpp::xml::getAttr $sattrs $elem]
+	    if {![string equal $value ""]} {
 		lappend params $elem $value
 	    }
 	}
@@ -111,20 +111,20 @@
 ######################################################
 # Replace original jid. Read README.xaddress
 proc ::xaddress::modify_from \
-     {vconnid vfrom vid vtype vis_subject vsubject \
+     {vxlib vfrom vid vtype vis_subject vsubject \
       vbody verr vthread vpriority vx} {
     upvar 2 $vfrom from
     upvar 2 $vtype type
     upvar 2 $vx x
 
     # those types are supported at now.
-    if {![lcontain {chat normal groupchat ""} $type]} return
+    if {[lsearch -exact {chat normal groupchat ""} $type] < 0} return
 
     set newx {}
     foreach xe $x {
-	jlib::wrapper:splitxml $xe tag vars isempty chdata children
+	::xmpp::xml::split $xe tag xmlns attrs cdata subels
 	
-	if {[cequal [jlib::wrapper:getattr $vars xmlns] $::NS(xaddress_store)]} {
+	if {[string equal $xmlns $::NS(xaddress_store)]} {
 	    # The other side tries to forge a sender sddress
 	} else {
 	    lappend newx $xe
@@ -134,19 +134,19 @@
     set x $newx
 
     foreach xe $x {
-	jlib::wrapper:splitxml $xe tag vars isempty chdata children
+	::xmpp::xml::split $xe tag xmlns attrs cdata subels
 	
-	if {[cequal [set res [parse_xaddress_fields $xe {ofrom}]] {}]} continue
+	if {[llength [set res [parse_xaddress_fields $xe {ofrom}]]] == 0} continue
 
 	# FIX: now we get only first but what if there are several ofrom fields?
-	lassign $res reason vars1
-	set ofrom [jlib::wrapper:getattr $vars1 jid]
-	if {[cequal $ofrom ""]} return
+	lassign $res reason attrs1
+	set ofrom [::xmpp::xml::getAttr $attrs1 jid]
+	if {[string equal $ofrom ""]} return
 
-	set x [linsert $x 0 [jlib::wrapper:createtag x \
-				 -vars [list xmlns $::NS(xaddress_store) \
-					     from $from \
-					     reason $reason]]]
+	set x [linsert $x 0 [::xmpp::xml::create x \
+				    -xmlns $::NS(xaddress_store) \
+				    -attrs [list from $from \
+						 reason $reason]]]
 	set from $ofrom
 	return
     }
@@ -166,16 +166,15 @@
     set reason ""
 
     foreach xe $x {
-        jlib::wrapper:splitxml $xe tag vars isempty chdata children
-	set xmlns [jlib::wrapper:getattr $vars xmlns]
+	::xmpp::xml::split $xe tag xmlns attrs cdata subels
 	
-	if {[cequal  $xmlns $::NS(xaddress_store)] && [cequal $tag x]} {
-	    set real_from [jlib::wrapper:getattr $vars from]
-	    set reason [jlib::wrapper:getattr $vars reason]
+	if {[string equal $xmlns $::NS(xaddress_store)] && [string equal $tag x]} {
+	    set real_from [::xmpp::xml::getAttr $attrs from]
+	    set reason [::xmpp::xml::getAttr $attrs reason]
 	    continue
 	}
 
-	if {[cequal [set fields [parse_xaddress_fields $xe]] {}]} continue
+	if {[llength [set fields [parse_xaddress_fields $xe]]] == 0} continue
 	
 	incr xaddrinfoid
 	set label \
@@ -191,30 +190,29 @@
     }
 }
 
-hook::add draw_message_hook  ::xaddress::draw_xaddress 6
+hook::add draw_message_hook ::xaddress::draw_xaddress 6
 
 ##########################################################
 # Draw xaddress fields in the new message dialog
 
-proc ::xaddress::process_x_data {rowvar bodyvar f x connid from id type replyP} {
+proc ::xaddress::process_x_data {rowvar bodyvar f x xlib from id type replyP} {
     upvar 2 $rowvar row
     upvar 2 $bodyvar body
     variable names
 
-    if {!$replyP || [cequal $type error]} {
+    if {!$replyP || [string equal $type error]} {
         return
     }
 
     set title [join [lrange [split $f .] 0 end-1] .].title
     
     foreach xe $x {
-        jlib::wrapper:splitxml $xe tag vars isempty chdata children
-	set xmlns [jlib::wrapper:getattr $vars xmlns]
+	::xmpp::xml::split $xe tag xmlns attrs cdata subels
 
 	# if "from" was modified draw reason and real_from
-	if {[cequal  $xmlns $::NS(xaddress_store)] && [cequal $tag x]} {
-	    set real_from [jlib::wrapper:getattr $vars from]
-	    set reason [jlib::wrapper:getattr $vars reason]
+	if {[string equal $xmlns $::NS(xaddress_store)] && [string equal $tag x]} {
+	    set real_from [::xmpp::xml::getAttr $attrs from]
+	    set reason [::xmpp::xml::getAttr $attrs reason]
 
 	    switch -- $reason {
 		ofrom {
@@ -228,7 +226,7 @@
 	    continue
 	}
 	
-	if {[cequal [set fields [parse_xaddress_fields $xe]] {}]} continue
+	if {[llength [set fields [parse_xaddress_fields $xe]]] == 0} continue
 		
 	# draw most important xaddress fields
 	set other_fields {}
@@ -268,7 +266,7 @@
 	}
 	
 	# draw rest in tooltip
-	if {[expr [llength $other_fields] > 0]} {
+	if {[llength $other_fields] > 0} {
 	    
 	    set label \
 		[Label $title.xaddrinfo \

Modified: trunk/tkabber/plugins/general/xcommands.tcl
===================================================================
--- trunk/tkabber/plugins/general/xcommands.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/general/xcommands.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -11,39 +11,34 @@
 
 ##########################################################################
 
-proc xcommands::execute {jid node args} {
+proc xcommands::execute {xlib jid node args} {
     set category automation
     foreach {key val} $args {
 	switch -- $key {
 	    -category { set category $val }
-	    -connection { set connid $val }
 	}
     }
-    if {![info exists connid]} {
-	return -code error "Option -connection is mandatory"
-    }
-
     if {$category != "automation"} return
 
-    set vars [list xmlns $::NS(commands) action execute]
+    set vars [list action execute]
     if {$node != ""} {
 	lappend vars node $node
     }
 
-    jlib::send_iq set \
-	[jlib::wrapper:createtag command \
-	     -vars $vars] \
-	-command [list [namespace current]::execute_result $connid $jid $node] \
-	-to $jid \
-	-connection $connid
+    ::xmpp::sendIQ $xlib set \
+	-query [::xmpp::xml::create command \
+			-xmlns $::NS(commands) \
+			-attrs $vars] \
+	-command [list [namespace current]::execute_result $xlib $jid $node] \
+	-to $jid
 }
 
 ##########################################################################
 
-proc xcommands::execute_result {connid jid node res child} {
+proc xcommands::execute_result {xlib jid node res child} {
     variable winid
 
-    if {[cequal $res ERR]} {
+    if {[string equal $res error]} {
 	incr winid
 	set w .xcommands_err$winid
 
@@ -59,18 +54,18 @@
 	return
     }
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
+    ::xmpp::xml::split $child tag xmlns attrs cdata subels
 
-    set node [jlib::wrapper:getattr $vars node]
-    set sessionid [jlib::wrapper:getattr $vars sessionid]
-    set status [jlib::wrapper:getattr $vars status]
+    set node [::xmpp::xml::getAttr $attrs node]
+    set sessionid [::xmpp::xml::getAttr $attrs sessionid]
+    set status [::xmpp::xml::getAttr $attrs status]
 
-    draw_window $connid $jid $node $sessionid $status $children
+    draw_window $xlib $jid $node $sessionid $status $subels
 }
 
 ##########################################################################
 
-proc xcommands::draw_window {connid jid node sessionid status xmldata} {
+proc xcommands::draw_window {xlib jid node sessionid status xmldata} {
     variable winid
 
     lassign [find_note $xmldata] type note
@@ -115,32 +110,32 @@
 		    ([llength $actions] == 1 && [lcontain $actions complete])} {
 		$w add -text [::msgcat::mc "Submit"] \
 		    -command [list [namespace current]::execute_window \
-				   $w $connid $jid $node $sessionid complete \
+				   $w $xlib $jid $node $sessionid complete \
 				   [list [namespace current]::complete_result]]
 		$w add -text [::msgcat::mc "Cancel"] \
 		    -command [list [namespace current]::cancel_window \
-				   $w $connid $jid $node $sessionid]
+				   $w $xlib $jid $node $sessionid]
 		$w configure -default 0
 		set cancel 1
 	    } else {
 		$w add -text [::msgcat::mc "Prev"] \
 		    -state disabled \
 		    -command [list [namespace current]::execute_window \
-				   $w $connid $jid $node $sessionid prev \
+				   $w $xlib $jid $node $sessionid prev \
 				   [list [namespace current]::next_result]]
 		$w add -text [::msgcat::mc "Next"] \
 		    -state disabled \
 		    -command [list [namespace current]::execute_window \
-				   $w $connid $jid $node $sessionid next \
+				   $w $xlib $jid $node $sessionid next \
 				   [list [namespace current]::next_result]]
 		$w add -text [::msgcat::mc "Finish"] \
 		    -state disabled \
 		    -command [list [namespace current]::execute_window \
-				   $w $connid $jid $node $sessionid complete \
+				   $w $xlib $jid $node $sessionid complete \
 				   [list [namespace current]::complete_result]]
 		$w add -text [::msgcat::mc "Cancel"] \
 		    -command [list [namespace current]::cancel_window \
-				   $w $connid $jid $node $sessionid]
+				   $w $xlib $jid $node $sessionid]
 		set_default_button $w $actions $execute
 		set cancel 3
 		
@@ -179,23 +174,23 @@
 
 ##########################################################################
 
-proc xcommands::execute_window {w connid jid node sessionid action cmd} {
+proc xcommands::execute_window {w xlib jid node sessionid action cmd} {
     # Send requested data and wait for result
 
-    set vars [list xmlns $::NS(commands) sessionid $sessionid action $action]
+    set vars [list sessionid $sessionid action $action]
     if {$node != ""} {
 	lappend vars node $node
     }
 
     set f [$w.fields getframe]
 
-    jlib::send_iq set \
-	[jlib::wrapper:createtag command \
-	     -vars $vars \
-	     -subtags [data::get_tags $f]] \
-	-command [list $cmd $w $connid $jid $node $sessionid] \
-	-to $jid \
-	-connection $connid
+    ::xmpp::sendIQ $xlib set \
+	-query [::xmpp::xml::create command \
+			-xmlns $::NS(commands) \
+			-attrs $vars \
+			-subelements [data::get_tags $f]] \
+	-command [list $cmd $w $xlib $jid $node $sessionid] \
+	-to $jid
 }
 
 ##########################################################################
@@ -271,7 +266,7 @@
 
 ##########################################################################
 
-proc xcommands::next_result {w connid jid node sessionid res child} {
+proc xcommands::next_result {w xlib jid node sessionid res child} {
     variable winid
 
     set f [$w.fields getframe]
@@ -282,7 +277,7 @@
 
     data::cleanup $f
 
-    if {[cequal $res ERR]} {
+    if {[string equal $res error]} {
 	incr winid
 	set w .xcommands_err$winid
 
@@ -299,22 +294,22 @@
     }
 
     # TODO
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
+    ::xmpp::xml::split $child tag xmlns attrs cdata subels
 
-    set node [jlib::wrapper:getattr $vars node]
-    set sessionid [jlib::wrapper:getattr $vars sessionid]
-    set status [jlib::wrapper:getattr $vars status]
+    set node [::xmpp::xml::getAttr $attrs node]
+    set sessionid [::xmpp::xml::getAttr $attrs sessionid]
+    set status [::xmpp::xml::getAttr $attrs status]
 
     destroy $w
-    draw_window $connid $jid $node $sessionid $status $children
+    draw_window $xlib $jid $node $sessionid $status $subels
 }
 
 ##########################################################################
 
-proc xcommands::complete_result {w connid jid node sessionid res child} {
+proc xcommands::complete_result {w xlib jid node sessionid res child} {
     variable winid
 
-    if {[cequal $res ERR]} {
+    if {[string equal $res err]} {
 	incr winid
 	set w .xcommands_err$winid
 
@@ -331,11 +326,11 @@
     }
 
     # TODO
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
+    ::xmpp::xml::split $child tag xmlns attrs cdata subels
 
-    set node [jlib::wrapper:getattr $vars node]
-    set sessionid [jlib::wrapper:getattr $vars sessionid]
-    set status [jlib::wrapper:getattr $vars status]
+    set node [::xmpp::xml::getAttr $attrs node]
+    set sessionid [::xmpp::xml::getAttr $attrs sessionid]
+    set status [::xmpp::xml::getAttr $attrs status]
 
     switch -- $status {
 	executing -
@@ -344,10 +339,10 @@
 	default { return }
     }
 
-    lassign [find_note $children] type note
-    lassign [find_actions $children] actions execute
+    lassign [find_note $subels] type note
+    lassign [find_actions $subels] actions execute
     # Only jabber:x:data payloads are supported
-    set xdata [find_xdata $children]
+    set xdata [find_xdata $subels]
 
     set f [$w.fields getframe]
 
@@ -363,23 +358,24 @@
     set focus [data::fill_fields $f $xdata]
 
     destroy $w
-    draw_window $connid $jid $node $sessionid $status $children
+    draw_window $xlib $jid $node $sessionid $status $subels
 }
 
 ##########################################################################
 
-proc xcommands::cancel_window {w connid jid node sessionid} {
+proc xcommands::cancel_window {w xlib jid node sessionid} {
     # Send cancelling stanza and ignore reply or error
 
-    set vars [list xmlns $::NS(commands) sessionid $sessionid action cancel]
+    set vars [list sessionid $sessionid action cancel]
     if {$node != ""} {
 	lappend vars node $node
     }
 
-    jlib::send_iq set \
-	[jlib::wrapper:createtag command -vars $vars] \
-	-to $jid \
-	-connection $connid
+    ::xmpp::sendIQ $xlib set \
+	-query [::xmpp::xml::create command \
+			-xmlns $::NS(commands) \
+			-attrs $vars] \
+	-to $jid
 
     set f [$w.fields getframe]
     data::cleanup $f
@@ -402,20 +398,20 @@
     set actions {}
     set execute next
     foreach child $xmldata {
-	jlib::wrapper:splitxml $child tag vars isempty chdata children
+	::xmpp::xml::split $child tag xmlns attrs cdata subels
 	if {$tag == "actions"} {
-	    if {[jlib::wrapper:isattr $vars execute]} {
-		set execute [jlib::wrapper:getattr $vars execute]
+	    if {[::xmpp::xml::isAttr $attrs execute]} {
+		set execute [::xmpp::xml::getAttr $attrs execute]
 	    }
-	    foreach child1 $children {
-		jlib::wrapper:splitxml $child1 tag1 vars1 isempty1 chdata1 children1
-		switch -- $tag1 {
+	    foreach subel $subels {
+		::xmpp::xml::split $subel stag sxmlns sattrs scdata ssubels
+		switch -- $stag {
 		    prev -
 		    next -
-		    complete { lappend actions $tag1 }
+		    complete { lappend actions $stag }
 		}
 	    }
-	    if {![lcontain $actions $execute]} {
+	    if {[lsearch -exact $actions $execute] < 0} {
 		set execute next
 	    }
 	}
@@ -428,8 +424,8 @@
 proc xcommands::find_xdata {xmldata} {
     set xdata {}
     foreach child $xmldata {
-	jlib::wrapper:splitxml $child tag vars isempty chdata children
-	if {[jlib::wrapper:getattr $vars xmlns] == $::NS(data)} {
+	::xmpp::xml::split $child tag xmlns attrs cdata subels
+	if {$xmlns == $::NS(data)} {
 	    lappend xdata $child
 	}
     }
@@ -442,10 +438,10 @@
     set note ""
     set type info
     foreach child $xmldata {
-	jlib::wrapper:splitxml $child tag vars isempty chdata children
+	::xmpp::xml::split $child tag xmlns attrs cdata subels
 	if {$tag == "note"} {
-	    set note [string trim $chdata]
-	    set type [jlib::wrapper:getattr $vars type]
+	    set note [string trim $cdata]
+	    set type [::xmpp::xml::getAttr $attrs type]
 	    switch -- $type {
 		info -
 		warn -

Modified: trunk/tkabber/plugins/iq/browse.tcl
===================================================================
--- trunk/tkabber/plugins/iq/browse.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/iq/browse.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -1,22 +1,21 @@
 # $Id$
 
-proc iq_browse_reply {connid from lang child} {
+proc iq_browse_reply {xlib from child args} {
     set restags {}
-    foreach ns [lsort $::iq::supported_ns] {
-	lappend restags [jlib::wrapper:createtag ns \
-			     -chdata $ns]
+    foreach ns [::xmpp::iq::registered $xlib] {
+	lappend restags [::xmpp::xml::create ns -cdata $ns]
     }
     
-    set res [jlib::wrapper:createtag query \
-		 -vars {xmlns    jabber:iq:browse \
-			category user \
-			type     client \
-			name     Tkabber} \
-		 -subtags $restags]
+    set res [::xmpp::xml::create query \
+		    -xmlns jabber:iq:browse \
+		    -attrs {category user \
+			    type     client \
+			    name     Tkabber} \
+		    -subelements $restags]
     
     return [list result $res]
 }
 
-iq::register_handler get {} jabber:iq:browse \
-    [namespace current]::iq_browse_reply
+::xmpp::iq::register get * jabber:iq:browse \
+		     [namespace current]::iq_browse_reply
 

Modified: trunk/tkabber/plugins/iq/last.tcl
===================================================================
--- trunk/tkabber/plugins/iq/last.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/iq/last.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -4,13 +4,11 @@
     [::msgcat::mc "Reply to idle time (jabber:iq:last) requests."] \
     -group IQ -type boolean
 
-proc iq_last {connid from lang child} {
+proc iq_last {xlib from child args} {
     global idle_command
     global userstatus statusdesc textstatus
     variable options
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
-
     if {$options(reply_iq_last) && [info exists idle_command]} {
 	set seconds [expr {[eval $idle_command]/1000}]
 	set status $statusdesc($userstatus)
@@ -19,13 +17,14 @@
 	} else {
 	    set status "$textstatus ($userstatus)"
 	}
-	return [list result [jlib::wrapper:createtag query \
-		    -vars [list xmlns jabber:iq:last seconds $seconds] \
-		    -chdata $status]]
+	return [list result [::xmpp::xml::create query \
+				    -xmlns jabber:iq:last \
+				    -attrs [list seconds $seconds] \
+				    -cdata $status]]
     } else {
 	return [list error cancel service-unavailable]
     }
 }
 
-iq::register_handler get query jabber:iq:last [namespace current]::iq_last
+::xmpp::iq::register get query jabber:iq:last [namespace current]::iq_last
 

Modified: trunk/tkabber/plugins/iq/ping.tcl
===================================================================
--- trunk/tkabber/plugins/iq/ping.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/iq/ping.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -18,20 +18,20 @@
 	-type integer \
 	-command [namespace current]::start_all
 
-    custom::defvar options(pong) 1 \
+    custom::defvar options(pong) 0 \
 	[::msgcat::mc "Reply to ping (urn:xmpp:ping) requests."] \
 	-group IQ \
 	-type boolean
 
     variable sequence
 
-    iq::register_handler get query urn:xmpp:ping [namespace current]::reply
+    ::xmpp::iq::register get query urn:xmpp:ping [namespace current]::reply
     hook::add connected_hook [namespace current]::start
 }
 
 #############################################################################
 
-proc ping::reply {connid from lang child} {
+proc ping::reply {xlib from child args} {
     variable options
 
     if {$options(pong)} {
@@ -48,55 +48,49 @@
 
     if {!$options(ping) || ($options(timeout) <= 0)} return
 
-    foreach connid [jlib::connections] {
-	start $connid
+    foreach xlib [connections] {
+	start $xlib
     }
 }
 
 #############################################################################
 
-proc ping::start {connid} {
+proc ping::start {xlib} {
     variable options
     variable sequence
 
-    after cancel [list [namespace current]::start $connid]
+    after cancel [namespace code [list start $xlib]]
 
     if {!$options(ping) || ($options(timeout) <= 0)} return
 
-    if {![info exists sequence($connid)]} {
-	set sequence($connid) 0
-    } else {
-	incr sequence($connid)
+    if {![info exists sequence($xlib)]} {
+	set sequence($xlib) 0
     }
 
-    jlib::send_iq get \
-	[jlib::wrapper:createtag ping \
-	     -vars [list xmlns urn:xmpp:ping]] \
+    ::xmpp::sendIQ $xlib get \
+	-query [::xmpp::xml::create ping -xmlns urn:xmpp:ping] \
 	-timeout [expr {$options(timeout)*1000}] \
-	-connection $connid \
-	-command [list [namespace current]::result $connid $sequence($connid)]
+	-command [namespace code [list result $xlib [incr sequence($xlib)]]]
 }
 
-proc ping::result {connid seq res child} {
+proc ping::result {xlib seq status xml} {
     variable options
     variable sequence
 
     if {!$options(ping) || ($options(timeout) <= 0)} return
 
-    if {![lcontain [jlib::connections] $connid]} return
+    if {[lsearch -exact [connections] $xlib] < 0} return
 
-    if {$res == "DISCONNECT"} return
+    if {[string equal $status abort]} return
 
-    if {$seq < $sequence($connid)} return
+    if {$seq < $sequence($xlib)} return
 
-    if {$res == "TIMEOUT"} {
-	# TODO
-	jlib::inmsg $connid "" 1
+    if {[string equal $status timeout]} {
+	::xmpp::EndOfFile $xlib
 	return
     }
 
-    after [expr {$options(timeout)*1000}] \
-	  [list [namespace current]::start $connid]
+    after [expr {$options(timeout)*1000}] [namespace code [list start $xlib]]
 }
 
 #############################################################################

Modified: trunk/tkabber/plugins/iq/time.tcl
===================================================================
--- trunk/tkabber/plugins/iq/time.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/iq/time.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -4,28 +4,26 @@
     [::msgcat::mc "Reply to current time (jabber:iq:time) requests."] \
     -group IQ -type boolean
 
-proc iq_time {connid from lang child} {
+proc iq_time {xlib from child args} {
     variable options
 
     if {!$options(reply_iq_time)} {
 	return {error cancel service-unavailable}
     }
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
-
     set curtime [clock seconds]
     set restags \
-	[list [jlib::wrapper:createtag utc \
-		   -chdata [clock format $curtime \
-				-format "%Y%m%dT%T" -gmt true]] \
-	     [jlib::wrapper:createtag tz -chdata \
-		  [timezone $curtime]] \
-	     [jlib::wrapper:createtag display \
-		  -chdata [displaytime $curtime]]]
+	[list [::xmpp::xml::create utc \
+		    -cdata [clock format $curtime \
+				    -format "%Y%m%dT%T" -gmt true]] \
+	     [::xmpp::xml::create tz \
+		    -cdata [timezone $curtime]] \
+	     [::xmpp::xml::create display \
+		    -cdata [displaytime $curtime]]]
     
-    set res [jlib::wrapper:createtag query \
-		 -vars {xmlns jabber:iq:time} \
-		 -subtags $restags]
+    set res [::xmpp::xml::create query \
+		    -xmlns jabber:iq:time \
+		    -subelements $restags]
     
     return [list result $res]
 }
@@ -54,6 +52,5 @@
     }
 }
 
-iq::register_handler get query jabber:iq:time \
-    [namespace current]::iq_time
+::xmpp::iq::register get query jabber:iq:time [namespace current]::iq_time
 

Modified: trunk/tkabber/plugins/iq/time2.tcl
===================================================================
--- trunk/tkabber/plugins/iq/time2.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/iq/time2.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -5,26 +5,24 @@
     [::msgcat::mc "Reply to entity time (urn:xmpp:time) requests."] \
     -group IQ -type boolean
 
-proc xmpp_time {connid from lang child} {
+proc xmpp_time {xlib from child args} {
     variable options
 
     if {!$options(reply_xmpp_time)} {
 	return {error cancel service-unavailable}
     }
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
-
     set curtime [clock seconds]
     set restags \
-	[list [jlib::wrapper:createtag utc \
-		   -chdata [clock format $curtime \
+	[list [::xmpp::xml::create utc \
+		    -cdata [clock format $curtime \
 				  -format "%Y-%m-%dT%TZ" -gmt true]] \
-	      [jlib::wrapper:createtag tzo \
-		   -chdata [timezone_offset]]]
+	      [::xmpp::xml::create tzo \
+		    -cdata [timezone_offset]]]
     
-    set res [jlib::wrapper:createtag time \
-		 -vars {xmlns urn:xmpp:time} \
-		 -subtags $restags]
+    set res [::xmpp::xml::create time \
+		    -xmlns urn:xmpp:time \
+		    -subelements $restags]
     
     return [list result $res]
 }
@@ -43,6 +41,5 @@
     return $S$H:$M
 }
 
-iq::register_handler get time urn:xmpp:time \
-    [namespace current]::xmpp_time
+::xmpp::iq::register get time urn:xmpp:time [namespace current]::xmpp_time
 

Modified: trunk/tkabber/plugins/iq/version.tcl
===================================================================
--- trunk/tkabber/plugins/iq/version.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/iq/version.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -106,7 +106,9 @@
 		4.0  { return {Windows 95} }
 		4.10 { return {Windows 98} }
 		4.90 { return {Windows ME} }
-		default { return [list $tcl_platform(os) $tcl_platform(osVersion)] }
+		default {
+		    return [list $tcl_platform(os) $tcl_platform(osVersion)]
+		}
 	    }
 	}
 	"Windows NT" {
@@ -115,7 +117,9 @@
 		5.1 { return {Windows XP}    }
 		5.2 { return {Windows 2003}  }
 		6.0 { return {Windows Vista} }
-		default { return [list $tcl_platform(os) $tcl_platform(osVersion)] }
+		default {
+		    return [list $tcl_platform(os) $tcl_platform(osVersion)]
+		}
 	    }
 	}
 	default {
@@ -124,7 +128,7 @@
     }
 }
 
-proc iq_version {connid from lang child} {
+proc iq_version {xlib from child args} {
     global tkabber_version toolkit_version tcl_platform
     variable options
 
@@ -132,13 +136,11 @@
 	return {error cancel service-unavailable}
     }
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
+    set restags [list [::xmpp::xml::create name \
+				-cdata Tkabber] \
+		      [::xmpp::xml::create version \
+				-cdata "$tkabber_version ($toolkit_version)"]]
 
-    set restags [list \
-		     [jlib::wrapper:createtag name -chdata Tkabber] \
-		     [jlib::wrapper:createtag version -chdata \
-			  "$tkabber_version ($toolkit_version)"]]
-
     if {$options(reply_iq_os_version)} {
 	switch -glob -- $tcl_platform(os) {
 	    Linux {
@@ -152,37 +154,38 @@
 	    }
 	}
     
-	lappend restags [jlib::wrapper:createtag os -chdata $os]
+	lappend restags [::xmpp::xml::create os -cdata $os]
     }
 
-    set res [jlib::wrapper:createtag query \
-		 -vars {xmlns jabber:iq:version} \
-		 -subtags $restags]
+    set res [::xmpp::xml::create query \
+		    -xmlns jabber:iq:version \
+		    -subelements $restags]
     
     return [list result $res]
 }
 
-iq::register_handler get query jabber:iq:version \
-    [namespace current]::iq_version
+::xmpp::iq::register get query jabber:iq:version \
+		     [namespace current]::iq_version
 
-proc disco_extra_version {connid from lang} {
+proc disco_extra_version {xlib from lang} {
     global tkabber_version toolkit_version tcl_platform
     variable options
 
     set fields \
-	[list [jlib::wrapper:createtag field \
-		   -vars [list var  FORM_TYPE \
-			       type hidden] \
-		   -subtags [list [jlib::wrapper:createtag value -chdata \
-				       urn:xmpp:dataforms:softwareinfo]]] \
-	      [jlib::wrapper:createtag field \
-		   -vars [list var software] \
-		   -subtags [list [jlib::wrapper:createtag value \
-				       -chdata Tkabber]]] \
-	      [jlib::wrapper:createtag field \
-		   -vars [list var software_version] \
-		   -subtags [list [jlib::wrapper:createtag value -chdata \
-				   "$tkabber_version ($toolkit_version)"]]]]
+	[list [::xmpp::xml::create field \
+		   -attrs [list var  FORM_TYPE \
+				type hidden] \
+		   -subelement [::xmpp::xml::create value \
+				    -cdata urn:xmpp:dataforms:softwareinfo]] \
+	      [::xmpp::xml::create field \
+		   -attrs [list var software] \
+		   -subelement [::xmpp::xml::create value \
+				    -cdata Tkabber]] \
+	      [::xmpp::xml::create field \
+		   -attrs [list var software_version] \
+		   -subelement [::xmpp::xml::create value \
+				    -cdata "$tkabber_version\
+					    ($toolkit_version)"]]]
 
     if {$options(reply_iq_os_version)} {
 	switch -glob -- $tcl_platform(os) {
@@ -200,20 +203,20 @@
 	}
     
 	lappend fields \
-		[jlib::wrapper:createtag field \
-		     -vars [list var os] \
-		     -subtags [list [jlib::wrapper:createtag value \
-				         -chdata $os]]] \
-		[jlib::wrapper:createtag field \
-		     -vars [list var os_version] \
-		     -subtags [list [jlib::wrapper:createtag value \
-					 -chdata $os_version]]]
+		[::xmpp::xml::create field \
+		     -attrs [list var os] \
+		     -subelement [::xmpp::xml::create value \
+				        -cdata $os]] \
+		[::xmpp::xml::create field \
+		     -attrs [list var os_version] \
+		     -subelement [::xmpp::xml::create value \
+					-cdata $os_version]]
     }
 
-    return [jlib::wrapper:createtag x \
-		-vars [list xmlns $::NS(data) \
-			    type  result] \
-		-subtags $fields]
+    return [::xmpp::xml::create x \
+		    -xmlns $::NS(data) \
+		    -attrs [list type result] \
+		    -subelements $fields]
 }
 
 hook::add postload_hook \

Modified: trunk/tkabber/plugins/pep/user_activity.tcl
===================================================================
--- trunk/tkabber/plugins/pep/user_activity.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/pep/user_activity.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -157,14 +157,14 @@
     }
 }
 
-proc activity::add_roster_pep_menu_item {m connid jid} {
-    set rjid [roster::find_jid $connid $jid]
+proc activity::add_roster_pep_menu_item {m xlib jid} {
+    set rjid [roster::find_jid $xlib $jid]
 
     if {$rjid == ""} {
  	set rjid [node_and_server_from_jid $jid]
     }
 
-    set pm [pep::get_roster_menu_pep_submenu $m $connid $rjid]
+    set pm [pep::get_roster_menu_pep_submenu $m $xlib $rjid]
 
     set mm [menu $pm.activity -tearoff no]
     $pm add cascade -menu $mm \
@@ -172,40 +172,38 @@
 
     $mm add command \
 	    -label [::msgcat::mc "Subscribe"] \
-	    -command [list [namespace current]::subscribe $connid $rjid]
+	    -command [list [namespace current]::subscribe $xlib $rjid]
     $mm add command \
 	    -label [::msgcat::mc "Unsubscribe"] \
-	    -command [list [namespace current]::unsubscribe $connid $rjid]
+	    -command [list [namespace current]::unsubscribe $xlib $rjid]
 
-    hook::run roster_pep_user_activity_menu_hook $mm $connid $rjid
+    hook::run roster_pep_user_activity_menu_hook $mm $xlib $rjid
 }
 
-proc activity::subscribe {connid jid args} {
+proc activity::subscribe {xlib jid args} {
     variable node
     variable substatus
 
     set to [node_and_server_from_jid $jid]
-    set cmd [linsert $args 0 [namespace current]::subscribe_result $connid $to]
-    pep::subscribe $to $node \
-	    -connection $connid \
+    set cmd [linsert $args 0 [namespace current]::subscribe_result $xlib $to]
+    pep::subscribe $xlib $to $node \
 	    -command $cmd
-    set substatus($connid,$to) sent-subscribe
+    set substatus($xlib,$to) sent-subscribe
 }
 
-proc activity::unsubscribe {connid jid args} {
+proc activity::unsubscribe {xlib jid args} {
     variable node
     variable substatus
 
     set to [node_and_server_from_jid $jid]
-    set cmd [linsert $args 0 [namespace current]::unsubscribe_result $connid $to]
-    pep::unsubscribe $to $node \
-	    -connection $connid \
+    set cmd [linsert $args 0 [namespace current]::unsubscribe_result $xlib $to]
+    pep::unsubscribe $xlib $to $node \
 	    -command $cmd
-    set substatus($connid,$to) sent-unsubscribe
+    set substatus($xlib,$to) sent-unsubscribe
 }
 
-# Err may be one of: OK, ERR and DISCONNECT
-proc activity::subscribe_result {connid jid res child args} {
+# Err may be one of: ok, error and abort
+proc activity::subscribe_result {xlib jid res child args} {
     variable substatus
 
     set cmd ""
@@ -221,11 +219,11 @@
     }
 
     switch -- $res {
-	OK {
-	    set substatus($connid,$jid) from
+	ok {
+	    set substatus($xlib,$jid) from
 	}
-	ERR {
-	    set substatus($connid,$jid) error
+	error {
+	    set substatus($xlib,$jid) error
 	}
 	default {
 	    return
@@ -238,7 +236,7 @@
     }
 }
 
-proc activity::unsubscribe_result {connid jid res child args} {
+proc activity::unsubscribe_result {xlib jid res child args} {
     variable substatus
     variable activity
 
@@ -254,8 +252,8 @@
 	}
     }
 
-    if {[string equal $res OK]} {
-	set substatus($connid,$jid) none
+    if {[string equal $res ok]} {
+	set substatus($xlib,$jid) none
 	array unset activity *,$jid
     }
 
@@ -265,7 +263,7 @@
     }
 }
 
-proc activity::provide_roster_popup_info {var connid user} {
+proc activity::provide_roster_popup_info {var xlib user} {
     variable substatus
     variable activity
     variable m2d
@@ -274,8 +272,8 @@
 
     set jid [node_and_server_from_jid $user]
 
-    if {[info exists activity(activity,$connid,$jid)]} {
-	set m $activity(activity,$connid,$jid)
+    if {[info exists activity(activity,$xlib,$jid)]} {
+	set m $activity(activity,$xlib,$jid)
 	if {[info exists m2d($m)]} {
 	    set status $m2d($m)
 	} else {
@@ -283,7 +281,7 @@
 	    debugmsg pubsub "Failed to found description for user activity \"$m\"\
 			     -- discrepancies with XEP-0108?"
 	}
-	set m $activity(subactivity,$connid,$jid)
+	set m $activity(subactivity,$xlib,$jid)
 	if {[info exists m2d($m)]} {
 	    append status [format " (%s)" $m2d($m)]
 	} elseif {$m != ""} {
@@ -291,20 +289,20 @@
 	    debugmsg pubsub "Failed to found description for user subactivity \"$m\"\
 			     -- discrepancies with XEP-0108?"
 	}
-	if {[info exists activity(text,$connid,$jid)] && $activity(text,$connid,$jid) != ""} {
-	    append status ": " $activity(text,$connid,$jid)
+	if {[info exists activity(text,$xlib,$jid)] && $activity(text,$xlib,$jid) != ""} {
+	    append status ": " $activity(text,$xlib,$jid)
 	}
 	append info [::msgcat::mc "\n\tActivity: %s" $status]
-    } elseif {[info exists substatus($connid,$jid)]} {
+    } elseif {[info exists substatus($xlib,$jid)]} {
 	append info [::msgcat::mc "\n\tUser activity subscription: %s" \
-			    $substatus($connid,$jid)]
+			    $substatus($xlib,$jid)]
     } else {
 	return
     }
 
 }
 
-proc activity::process_activity_notification {connid jid items} {
+proc activity::process_activity_notification {xlib jid items} {
     variable node
     variable activity
 
@@ -315,39 +313,35 @@
     set parsed  false
 
     foreach item $items {
-	jlib::wrapper:splitxml $item tag vars isempty chdata children
+	::xmpp::xml::split $item tag xmlns attrs cdata subels
 
 	switch -- $tag {
 	    retract {
 		set retract true
 	    }
 	    default {
-		foreach iactivity $children {
-		    jlib::wrapper:splitxml $iactivity tag1 vars1 isempty1 \
-			    chdata1 children1
+		foreach iactivity $subels {
+		    ::xmpp::xml::split $iactivity stag sxmlns sattrs scdata ssubels
 
-		    if {![string equal $tag1 activity]} continue
-		    set xmlns [jlib::wrapper:getattr $vars1 xmlns]
-		    if {![string equal $xmlns $node]} continue
+		    if {![string equal $stag activity]} continue
+		    if {![string equal $sxmlns $node]} continue
 
 		    set parsed true
 
-		    foreach i $children1 {
-			jlib::wrapper:splitxml $i tag2 vars2 isempty2 \
-				chdata2 children2
+		    foreach i $ssubels {
+			::xmpp::xml::split $i sstag ssxmlns ssattrs sscdata sssubels
 
-			switch -- $tag2 {
+			switch -- $sstag {
 			    text {
-				set newtext $chdata2
+				set newtext $sscdata
 			    }
 			    default {
-				set newactivity $tag2
+				set newactivity $sstag
 
-				foreach i2 $children2 {
-				    jlib::wrapper:splitxml $i2 tag3 vars3 \
-					    isempty3 chdata3 children3
+				foreach i2 $sssubels {
+				    ::xmpp::xml::split $i2 s3tag s3xmlns s3attrs s3cdata s3subels
 
-				    set newsubactivity $tag3
+				    set newsubactivity $s3tag
 				}
 			    }
 			}
@@ -358,25 +352,25 @@
     }
 
     if {$parsed} {
-	set activity(activity,$connid,$jid) $newactivity
-	set activity(subactivity,$connid,$jid) $newsubactivity
-	set activity(text,$connid,$jid) $newtext
+	set activity(activity,$xlib,$jid) $newactivity
+	set activity(subactivity,$xlib,$jid) $newsubactivity
+	set activity(text,$xlib,$jid) $newtext
 
 	hook::run user_activity_notification_hook \
-		$connid $jid $newactivity $newsubactivity $newtext
+		$xlib $jid $newactivity $newsubactivity $newtext
     } elseif {$retract} {
-	catch {unset activity(activity,$connid,$jid)}
-	catch {unset activity(subactivity,$connid,$jid)}
-	catch {unset activity(text,$connid,$jid)}
+	catch {unset activity(activity,$xlib,$jid)}
+	catch {unset activity(subactivity,$xlib,$jid)}
+	catch {unset activity(text,$xlib,$jid)}
 
-	hook::run user_activity_notification_hook $connid $jid "" "" ""
+	hook::run user_activity_notification_hook $xlib $jid "" "" ""
     }
 }
 
-proc activity::notify_via_status_message {connid jid activity subactivity text} {
+proc activity::notify_via_status_message {xlib jid activity subactivity text} {
     variable m2d
 
-    set contact [::roster::itemconfig $connid $jid -name]
+    set contact [::roster::itemconfig $xlib $jid -name]
     if {$contact == ""} {
 	set contact $jid
     }
@@ -398,7 +392,7 @@
     set_status $msg
 }
 
-proc activity::publish {connid activity subactivity args} {
+proc activity::publish {xlib activity subactivity args} {
     variable node
 
     set text ""
@@ -411,21 +405,20 @@
     }
 
     if {$subactivity == ""} {
-	set content [list [jlib::wrapper:createtag $activity]]
+	set content [list [::xmpp::xml::create $activity]]
     } else {
-	set content [list [jlib::wrapper:createtag $activity \
-				-subtags [list [jlib::wrapper:createtag \
-						    $subactivity]]]]
+	set content [list [::xmpp::xml::create $activity \
+				-subelement [::xmpp::xml::create \
+						    $subactivity]]]
     }
     if {$text != ""} {
-	lappend content [jlib::wrapper:createtag text -chdata $text]
+	lappend content [::xmpp::xml::create text -cdata $text]
     }
 
-    set cmd [list pep::publish_item $node activity \
-		  -connection $connid \
-		  -payload [list [jlib::wrapper:createtag activity \
-				      -vars [list xmlns $node] \
-				      -subtags $content]]]
+    set cmd [list pep::publish_item $xlib $node activity \
+		  -payload [list [::xmpp::xml::create activity \
+				      -xmlns $node \
+				      -subelements $content]]]
 
     if {$callback != ""} {
 	lappend cmd -command $callback
@@ -434,7 +427,7 @@
     eval $cmd
 }
 
-proc activity::unpublish {connid args} {
+proc activity::unpublish {xlib args} {
     variable node
 
     set callback ""
@@ -444,9 +437,8 @@
 	}
     }
 
-    set cmd [list pep::delete_item $node activity \
-		  -notify true \
-		  -connection $connid]
+    set cmd [list pep::delete_item $xlib $node activity \
+		  -notify true]
 
     if {$callback != ""} {
 	lappend cmd -command $callback
@@ -474,7 +466,7 @@
     set mm [pep::get_main_menu_pep_submenu].activity
     set idx [expr {$::ifacetk::options(show_tearoffs) ? 1 : 0}]
 
-    switch -- [llength [jlib::connections]] {
+    switch -- [llength [connections]] {
 	0 {
 	    $mm entryconfigure $idx -state disabled
 	    $mm entryconfigure [incr idx] \
@@ -507,8 +499,8 @@
 	destroy $w
     }
 
-    set connids [jlib::connections]
-    if {[llength $connids] == 0} {
+    set xlibs [connections]
+    if {[llength $xlibs] == 0} {
 	NonmodalMessageDlg [epath] \
 		-aspect 50000 \
 		-icon error \
@@ -527,8 +519,8 @@
     set f [$w getframe]
 
     set connjids [list [::msgcat::mc "All"]]
-    foreach connid $connids {
-	lappend connjids [jlib::connection_jid $connid]
+    foreach xlib $xlibs {
+	lappend connjids [connection_jid $xlib]
     }
     set myjid [lindex $connjids 0]
 
@@ -618,10 +610,10 @@
 	set sub $d2m($subactivityvalue)
     }
 
-    foreach connid [jlib::connections] {
-	if {[string equal $myjid [jlib::connection_jid $connid]] || \
+    foreach xlib [connections] {
+	if {[string equal $myjid [connection_jid $xlib]] || \
 		[string equal $myjid [::msgcat::mc "All"]]} {
-	    publish $connid $d2m($activityvalue) $sub \
+	    publish $xlib $d2m($activityvalue) $sub \
 		    -reason $activityreason \
 		    -command [namespace current]::publish_result
 	    break
@@ -632,10 +624,10 @@
     destroy $w
 }
 
-# $res is one of: OK, ERR, DISCONNECT
+# $res is one of: ok, error, abort
 proc activity::publish_result {res child} {
     switch -- $res {
-	ERR {
+	error {
 	    set error [error_to_string $child]
 	}
 	default {
@@ -658,8 +650,8 @@
 	destroy $w
     }
 
-    set connids [jlib::connections]
-    if {[llength $connids] == 0} {
+    set xlibs [connections]
+    if {[llength $xlibs] == 0} {
 	NonmodalMessageDlg [epath] \
 		-aspect 50000 \
 		-icon error \
@@ -678,8 +670,8 @@
     set f [$w getframe]
 
     set connjids [list [::msgcat::mc "All"]]
-    foreach connid $connids {
-	lappend connjids [jlib::connection_jid $connid]
+    foreach xlib $xlibs {
+	lappend connjids [connection_jid $xlib]
     }
     set myjid [lindex $connjids 0]
 
@@ -695,7 +687,7 @@
 
     grid columnconfigure $f 1 -weight 1
 
-    if {[llength $connids] == 1} {
+    if {[llength $xlibs] == 1} {
 	do_unpublish $w
     } else {
 	$w draw
@@ -705,10 +697,10 @@
 proc activity::do_unpublish {w} {
     variable myjid
 
-    foreach connid [jlib::connections] {
-	if {[string equal $myjid [jlib::connection_jid $connid]] || \
+    foreach xlib [connections] {
+	if {[string equal $myjid [connection_jid $xlib]] || \
 		[string equal $myjid [::msgcat::mc "All"]]} {
-	    unpublish $connid \
+	    unpublish $xlib \
 		    -command [namespace current]::unpublish_result
 	    break
 	}
@@ -718,10 +710,10 @@
     destroy $w
 }
 
-# $res is one of: OK, ERR, DISCONNECT
+# $res is one of: ok, error, abort
 proc activity::unpublish_result {res child} {
     switch -- $res {
-	ERR {
+	error {
 	    if {[lindex [error_type_condition $child] 1] == "item-not-found"} {
 		return
 	    }
@@ -739,7 +731,7 @@
 	    -message [::msgcat::mc "User activity unpublishing failed: %s" $error]
 }
 
-proc activity::provide_userinfo {notebook connid jid editable} {
+proc activity::provide_userinfo {notebook xlib jid editable} {
     variable activity
     variable m2d
     variable ::userinfo::userinfo
@@ -747,22 +739,22 @@
     if {$editable} return
 
     set barejid [node_and_server_from_jid $jid]
-    if {![info exists activity(activity,$connid,$barejid)]} return
+    if {![info exists activity(activity,$xlib,$barejid)]} return
 
-    if {[info exists m2d($activity(activity,$connid,$barejid))]} {
-	set userinfo(activity,$jid) $m2d($activity(activity,$connid,$barejid))
+    if {[info exists m2d($activity(activity,$xlib,$barejid))]} {
+	set userinfo(activity,$jid) $m2d($activity(activity,$xlib,$barejid))
     } else {
-	set userinfo(activity,$jid) $activity(activity,$connid,$barejid)
+	set userinfo(activity,$jid) $activity(activity,$xlib,$barejid)
     }
 
-    if {[info exists m2d($activity(subactivity,$connid,$barejid))]} {
-	set userinfo(subactivity,$jid) $m2d($activity(subactivity,$connid,$barejid))
+    if {[info exists m2d($activity(subactivity,$xlib,$barejid))]} {
+	set userinfo(subactivity,$jid) $m2d($activity(subactivity,$xlib,$barejid))
     } else {
-	set userinfo(subactivity,$jid) $activity(subactivity,$connid,$barejid)
+	set userinfo(subactivity,$jid) $activity(subactivity,$xlib,$barejid)
     }
 
-    if {[info exists activity(text,$connid,$barejid)]} {
-	set userinfo(activityreason,$jid) $activity(text,$connid,$barejid)
+    if {[info exists activity(text,$xlib,$barejid)]} {
+	set userinfo(activityreason,$jid) $activity(text,$xlib,$barejid)
     } else {
 	set userinfo(activityreason,$jid) ""
     }

Modified: trunk/tkabber/plugins/pep/user_location.tcl
===================================================================
--- trunk/tkabber/plugins/pep/user_location.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/pep/user_location.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -69,14 +69,14 @@
     }
 }
 
-proc geoloc::add_roster_pep_menu_item {m connid jid} {
-    set rjid [roster::find_jid $connid $jid]
+proc geoloc::add_roster_pep_menu_item {m xlib jid} {
+    set rjid [roster::find_jid $xlib $jid]
 
     if {$rjid == ""} {
  	set rjid [node_and_server_from_jid $jid]
     }
 
-    set pm [pep::get_roster_menu_pep_submenu $m $connid $rjid]
+    set pm [pep::get_roster_menu_pep_submenu $m $xlib $rjid]
 
     set mm [menu $pm.geoloc -tearoff no]
     $pm add cascade -menu $mm \
@@ -84,40 +84,40 @@
 
     $mm add command \
 	    -label [::msgcat::mc "Subscribe"] \
-	    -command [list [namespace current]::subscribe $connid $rjid]
+	    -command [list [namespace current]::subscribe $xlib $rjid]
     $mm add command \
 	    -label [::msgcat::mc "Unsubscribe"] \
-	    -command [list [namespace current]::unsubscribe $connid $rjid]
+	    -command [list [namespace current]::unsubscribe $xlib $rjid]
 
-    hook::run roster_pep_user_geoloc_menu_hook $mm $connid $rjid
+    hook::run roster_pep_user_geoloc_menu_hook $mm $xlib $rjid
 }
 
-proc geoloc::subscribe {connid jid args} {
+proc geoloc::subscribe {xlib jid args} {
     variable node
     variable substatus
 
     set to [node_and_server_from_jid $jid]
-    set cmd [linsert $args 0 [namespace current]::subscribe_result $connid $to]
+    set cmd [linsert $args 0 [namespace current]::subscribe_result $xlib $to]
     pep::subscribe $to $node \
-	    -connection $connid \
+	    -connection $xlib \
 	    -command $cmd
-    set substatus($connid,$to) sent-subscribe
+    set substatus($xlib,$to) sent-subscribe
 }
 
-proc geoloc::unsubscribe {connid jid args} {
+proc geoloc::unsubscribe {xlib jid args} {
     variable node
     variable substatus
 
     set to [node_and_server_from_jid $jid]
-    set cmd [linsert $args 0 [namespace current]::unsubscribe_result $connid $to]
+    set cmd [linsert $args 0 [namespace current]::unsubscribe_result $xlib $to]
     pep::unsubscribe $to $node \
-	    -connection $connid \
+	    -connection $xlib \
 	    -command $cmd
-    set substatus($connid,$to) sent-unsubscribe
+    set substatus($xlib,$to) sent-unsubscribe
 }
 
-# Err may be one of: OK, ERR and DISCONNECT
-proc geoloc::subscribe_result {connid jid res child args} {
+# Err may be one of: ok, error and abort
+proc geoloc::subscribe_result {xlib jid res child args} {
     variable substatus
 
     set cmd ""
@@ -133,11 +133,11 @@
     }
 
     switch -- $res {
-	OK {
-	    set substatus($connid,$jid) from
+	ok {
+	    set substatus($xlib,$jid) from
 	}
-	ERR {
-	    set substatus($connid,$jid) error
+	error {
+	    set substatus($xlib,$jid) error
 	}
 	default {
 	    return
@@ -150,7 +150,7 @@
     }
 }
 
-proc geoloc::unsubscribe_result {connid jid res child args} {
+proc geoloc::unsubscribe_result {xlib jid res child args} {
     variable substatus
     variable geoloc
     variable fields
@@ -167,10 +167,10 @@
 	}
     }
 
-    if {[string equal $res OK]} {
-	set substatus($connid,$jid) none
+    if {[string equal $res ok]} {
+	set substatus($xlib,$jid) none
 	foreach f $fields {
-	    catch {unset geoloc($f,$connid,$jid)}
+	    catch {unset geoloc($f,$xlib,$jid)}
 	}
     }
 
@@ -180,7 +180,7 @@
     }
 }
 
-proc geoloc::provide_roster_popup_info {var connid user} {
+proc geoloc::provide_roster_popup_info {var xlib user} {
     variable substatus
     variable geoloc
 
@@ -188,20 +188,20 @@
 
     set jid [node_and_server_from_jid $user]
 
-    if {[info exists geoloc(title,$connid,$jid)]} {
+    if {[info exists geoloc(title,$xlib,$jid)]} {
 	append info [::msgcat::mc "\n\tLocation: %s : %s" \
-				  $geoloc(lat,$connid,$jid) \
-				  $geoloc(lon,$connid,$jid)]
-    } elseif {[info exists substatus($connid,$jid)]} {
+				  $geoloc(lat,$xlib,$jid) \
+				  $geoloc(lon,$xlib,$jid)]
+    } elseif {[info exists substatus($xlib,$jid)]} {
 	append info [::msgcat::mc "\n\tUser location subscription: %s" \
-				  $substatus($connid,$jid)]
+				  $substatus($xlib,$jid)]
     } else {
 	return
     }
 
 }
 
-proc geoloc::process_geoloc_notification {connid jid items} {
+proc geoloc::process_geoloc_notification {xlib jid items} {
     variable node
     variable geoloc
     variable fields
@@ -213,27 +213,26 @@
     set parsed  false
 
     foreach item $items {
-	jlib::wrapper:splitxml $item tag vars isempty chdata children
+	::xmpp::xml::split $item tag xmlns attrs cdata subels
 
 	switch -- $tag {
 	    retract {
 		set retract true
 	    }
 	    default {
-		foreach igeoloc $children {
-		    jlib::wrapper:splitxml $igeoloc tag1 vars1 isempty1 chdata1 children1
+		foreach igeoloc $subels {
+		    ::xmpp::xml::split $igeoloc stag sxmlns sattrs scdata ssubels
 
-		    if {![string equal $tag1 geoloc]} continue
-		    set xmlns [jlib::wrapper:getattr $vars1 xmlns]
-		    if {![string equal $xmlns $node]} continue
+		    if {![string equal $stag geoloc]} continue
+		    if {![string equal $sxmlns $node]} continue
 
 		    set parsed true
 
-		    foreach i $children1 {
-			jlib::wrapper:splitxml $i tag2 vars2 isempty2 chdata2 children2
+		    foreach i $ssubels {
+			::xmpp::xml::split $i sstag ssxmlns ssattrs sscdata sssubels
 
-			if {[lsearch -exact $fields $tag2] >= 0} {
-			    set $tag2 $chdata2
+			if {[lsearch -exact $fields $sstag] >= 0} {
+			    set $sstag $sscdata
 			}
 		    }
 		}
@@ -243,19 +242,19 @@
 
     if {$parsed} {
 	foreach f $fields {
-	    set geoloc($f,$connid,$jid) [set $f]
+	    set geoloc($f,$xlib,$jid) [set $f]
 	}
-	hook::run user_geoloc_notification_hook $connid $jid $lat $lon
+	hook::run user_geoloc_notification_hook $xlib $jid $lat $lon
     } elseif {$retract} {
 	foreach f $fields {
-	    catch {unset geoloc($f,$connid,$jid)}
+	    catch {unset geoloc($f,$xlib,$jid)}
 	}
-	hook::run user_geoloc_notification_hook $connid $jid "" ""
+	hook::run user_geoloc_notification_hook $xlib $jid "" ""
     }
 }
 
-proc geoloc::notify_via_status_message {connid jid lat lon} {
-    set contact [::roster::itemconfig $connid $jid -name]
+proc geoloc::notify_via_status_message {xlib jid lat lon} {
+    set contact [::roster::itemconfig $xlib $jid -name]
     if {$contact == ""} {
 	set contact $jid
     }
@@ -270,7 +269,7 @@
     set_status $msg
 }
 
-proc geoloc::publish {connid args} {
+proc geoloc::publish {xlib args} {
     variable node
     variable fields
 
@@ -293,15 +292,15 @@
     set content {}
     foreach f $fields {
 	if {[set $f] != ""} {
-	    lappend content [jlib::wrapper:createtag $f -chdata [set $f]]
+	    lappend content [::xmpp::xml::create $f -cdata [set $f]]
 	}
     }
 
     set cmd [list pep::publish_item $node geoloc \
-		  -connection $connid \
-		  -payload [list [jlib::wrapper:createtag geoloc \
-				      -vars [list xmlns $node] \
-				      -subtags $content]]]
+		  -connection $xlib \
+		  -payload [list [::xmpp::xml::create geoloc \
+					    -xmlns $node] \
+					    -subelements $content]]]
 
     if {$callback != ""} {
 	lappend cmd -command $callback
@@ -310,7 +309,7 @@
     eval $cmd
 }
 
-proc geoloc::unpublish {connid args} {
+proc geoloc::unpublish {xlib args} {
     variable node
 
     set callback ""
@@ -322,7 +321,7 @@
 
     set cmd [list pep::delete_item $node geoloc \
 		  -notify true \
-		  -connection $connid]
+		  -connection $xlib]
 
     if {$callback != ""} {
 	lappend cmd -command $callback
@@ -350,7 +349,7 @@
     set mm [pep::get_main_menu_pep_submenu].geoloc
     set idx [expr {$::ifacetk::options(show_tearoffs) ? 1 : 0}]
 
-    switch -- [llength [jlib::connections]] {
+    switch -- [llength [connections]] {
 	0 {
 	    $mm entryconfigure $idx -state disabled
 	    $mm entryconfigure [incr idx] \
@@ -385,8 +384,8 @@
 	destroy $w
     }
 
-    set connids [jlib::connections]
-    if {[llength $connids] == 0} {
+    set xlibs [connections]
+    if {[llength $xlibs] == 0} {
 	NonmodalMessageDlg [epath] \
 		-aspect 50000 \
 		-icon error \
@@ -405,8 +404,8 @@
     set f [$w getframe]
 
     set connjids [list [::msgcat::mc "All"]]
-    foreach connid $connids {
-	lappend connjids [jlib::connection_jid $connid]
+    foreach xlib $xlibs {
+	lappend connjids [connection_jid $xlib]
     }
     set myjid [lindex $connjids 0]
 
@@ -445,10 +444,10 @@
 	lappend args -$ff [set geoloc$ff]
     }
 
-    foreach connid [jlib::connections] {
-	if {[string equal $myjid [jlib::connection_jid $connid]] || \
+    foreach xlib [connections] {
+	if {[string equal $myjid [connection_jid $xlib]] || \
 		[string equal $myjid [::msgcat::mc "All"]]} {
-	    eval [list publish $connid \
+	    eval [list publish $xlib \
 		       -command [namespace current]::publish_result] \
 		       $args
 	    break
@@ -462,10 +461,10 @@
     destroy $w
 }
 
-# $res is one of: OK, ERR, DISCONNECT
+# $res is one of: ok, err, abort
 proc geoloc::publish_result {res child} {
     switch -- $res {
-	ERR {
+	error {
 	    set error [error_to_string $child]
 	}
 	default {
@@ -488,8 +487,8 @@
 	destroy $w
     }
 
-    set connids [jlib::connections]
-    if {[llength $connids] == 0} {
+    set xlibs [connections]
+    if {[llength $xlibs] == 0} {
 	NonmodalMessageDlg [epath] \
 		-aspect 50000 \
 		-icon error \
@@ -508,8 +507,8 @@
     set f [$w getframe]
 
     set connjids [list [::msgcat::mc "All"]]
-    foreach connid $connids {
-	lappend connjids [jlib::connection_jid $connid]
+    foreach xlib $xlibs {
+	lappend connjids [connection_jid $xlib]
     }
     set myjid [lindex $connjids 0]
 
@@ -525,7 +524,7 @@
 
     grid columnconfigure $f 1 -weight 1
 
-    if {[llength $connids] == 1} {
+    if {[llength $xlibs] == 1} {
 	do_unpublish $w
     } else {
 	$w draw
@@ -535,10 +534,10 @@
 proc geoloc::do_unpublish {w} {
     variable myjid
 
-    foreach connid [jlib::connections] {
-	if {[string equal $myjid [jlib::connection_jid $connid]] || \
+    foreach xlib [connections] {
+	if {[string equal $myjid [connection_jid $xlib]] || \
 		[string equal $myjid [::msgcat::mc "All"]]} {
-	    unpublish $connid \
+	    unpublish $xlib \
 		    -command [namespace current]::unpublish_result
 	    break
 	}
@@ -548,10 +547,10 @@
     destroy $w
 }
 
-# $res is one of: OK, ERR, DISCONNECT
+# $res is one of: ok, error, abort
 proc geoloc::unpublish_result {res child} {
     switch -- $res {
-	ERR {
+	error {
 	    if {[lindex [error_type_condition $child] 1] == "item-not-found"} {
 		return
 	    }
@@ -569,7 +568,7 @@
 	    -message [::msgcat::mc "User location unpublishing failed: %s" $error]
 }
 
-proc geoloc::provide_userinfo {notebook connid jid editable} {
+proc geoloc::provide_userinfo {notebook xlib jid editable} {
     variable geoloc
     variable m2d
     variable ::userinfo::userinfo
@@ -579,10 +578,10 @@
     if {$editable} return
 
     set barejid [node_and_server_from_jid $jid]
-    if {![info exists geoloc(alt,$connid,$barejid)]} return
+    if {![info exists geoloc(alt,$xlib,$barejid)]} return
 
     foreach ff $fields {
-	set userinfo(geoloc$ff,$jid) $geoloc($ff,$connid,$barejid)
+	set userinfo(geoloc$ff,$jid) $geoloc($ff,$xlib,$barejid)
     }
 
     set f [pep::get_userinfo_dialog_pep_frame $notebook]

Modified: trunk/tkabber/plugins/pep/user_mood.tcl
===================================================================
--- trunk/tkabber/plugins/pep/user_mood.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/pep/user_mood.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -117,14 +117,14 @@
     }
 }
 
-proc mood::add_roster_pep_menu_item {m connid jid} {
-    set rjid [roster::find_jid $connid $jid]
+proc mood::add_roster_pep_menu_item {m xlib jid} {
+    set rjid [roster::find_jid $xlib $jid]
 
     if {$rjid == ""} {
  	set rjid [node_and_server_from_jid $jid]
     }
 
-    set pm [pep::get_roster_menu_pep_submenu $m $connid $rjid]
+    set pm [pep::get_roster_menu_pep_submenu $m $xlib $rjid]
 
     set mm [menu $pm.mood -tearoff no]
     $pm add cascade -menu $mm \
@@ -132,40 +132,40 @@
 
     $mm add command \
 	    -label [::msgcat::mc "Subscribe"] \
-	    -command [list [namespace current]::subscribe $connid $rjid]
+	    -command [list [namespace current]::subscribe $xlib $rjid]
     $mm add command \
 	    -label [::msgcat::mc "Unsubscribe"] \
-	    -command [list [namespace current]::unsubscribe $connid $rjid]
+	    -command [list [namespace current]::unsubscribe $xlib $rjid]
 
-    hook::run roster_pep_user_mood_menu_hook $mm $connid $rjid
+    hook::run roster_pep_user_mood_menu_hook $mm $xlib $rjid
 }
 
-proc mood::subscribe {connid jid args} {
+proc mood::subscribe {xlib jid args} {
     variable node
     variable substatus
 
     set to [node_and_server_from_jid $jid]
-    set cmd [linsert $args 0 [namespace current]::subscribe_result $connid $to]
+    set cmd [linsert $args 0 [namespace current]::subscribe_result $xlib $to]
     pep::subscribe $to $node \
-	    -connection $connid \
+	    -connection $xlib \
 	    -command $cmd
-    set substatus($connid,$to) sent-subscribe
+    set substatus($xlib,$to) sent-subscribe
 }
 
-proc mood::unsubscribe {connid jid args} {
+proc mood::unsubscribe {xlib jid args} {
     variable node
     variable substatus
 
     set to [node_and_server_from_jid $jid]
-    set cmd [linsert $args 0 [namespace current]::unsubscribe_result $connid $to]
+    set cmd [linsert $args 0 [namespace current]::unsubscribe_result $xlib $to]
     pep::unsubscribe $to $node \
-	    -connection $connid \
+	    -connection $xlib \
 	    -command $cmd
-    set substatus($connid,$to) sent-unsubscribe
+    set substatus($xlib,$to) sent-unsubscribe
 }
 
-# Err may be one of: OK, ERR and DISCONNECT
-proc mood::subscribe_result {connid jid res child args} {
+# Err may be one of: ok, error and abort
+proc mood::subscribe_result {xlib jid res child args} {
     variable substatus
 
     set cmd ""
@@ -181,11 +181,11 @@
     }
 
     switch -- $res {
-	OK {
-	    set substatus($connid,$jid) from
+	ok {
+	    set substatus($xlib,$jid) from
 	}
-	ERR {
-	    set substatus($connid,$jid) error
+	error {
+	    set substatus($xlib,$jid) error
 	}
 	default {
 	    return
@@ -198,7 +198,7 @@
     }
 }
 
-proc mood::unsubscribe_result {connid jid res child args} {
+proc mood::unsubscribe_result {xlib jid res child args} {
     variable substatus
     variable mood
 
@@ -214,10 +214,10 @@
 	}
     }
 
-    if {[string equal $res OK]} {
-	set substatus($connid,$jid) none
-	catch {unset mood(mood,$connid,$jid)}
-	catch {unset mood(text,$connid,$jid)}
+    if {[string equal $res ok]} {
+	set substatus($xlib,$jid) none
+	catch {unset mood(mood,$xlib,$jid)}
+	catch {unset mood(text,$xlib,$jid)}
     }
 
     if {$cmd != ""} {
@@ -226,7 +226,7 @@
     }
 }
 
-proc mood::provide_roster_popup_info {var connid user} {
+proc mood::provide_roster_popup_info {var xlib user} {
     variable substatus
     variable mood
     variable m2d
@@ -235,8 +235,8 @@
 
     set jid [node_and_server_from_jid $user]
 
-    if {[info exists mood(mood,$connid,$jid)]} {
-	set m $mood(mood,$connid,$jid)
+    if {[info exists mood(mood,$xlib,$jid)]} {
+	set m $mood(mood,$xlib,$jid)
 	if {[info exists m2d($m)]} {
 	    set status $m2d($m)
 	} else {
@@ -244,20 +244,20 @@
 	    debugmsg pubsub "Failed to found description for user mood \"$m\"\
 			     -- discrepancies with XEP-0107?"
 	}
-	if {[info exists mood(text,$connid,$jid)] && $mood(text,$connid,$jid) != ""} {
-	    append status ": " $mood(text,$connid,$jid)
+	if {[info exists mood(text,$xlib,$jid)] && $mood(text,$xlib,$jid) != ""} {
+	    append status ": " $mood(text,$xlib,$jid)
 	}
 	append info [::msgcat::mc "\n\tMood: %s" $status]
-    } elseif {[info exists substatus($connid,$jid)]} {
+    } elseif {[info exists substatus($xlib,$jid)]} {
 	append info [::msgcat::mc "\n\tUser mood subscription: %s" \
-			    $substatus($connid,$jid)]
+			    $substatus($xlib,$jid)]
     } else {
 	return
     }
 
 }
 
-proc mood::process_mood_notification {connid jid items} {
+proc mood::process_mood_notification {xlib jid items} {
     variable node
     variable mood
 
@@ -267,31 +267,30 @@
     set parsed  false
 
     foreach item $items {
-	jlib::wrapper:splitxml $item tag vars isempty chdata children
+	::xmpp::xml::split $item tag xmlns attrs cdata subels
 
 	switch -- $tag {
 	    retract {
 		set retract true
 	    }
 	    default {
-		foreach imood $children {
-		    jlib::wrapper:splitxml $imood tag1 vars1 isempty1 chdata1 children1
+		foreach imood $subels {
+		    ::xmpp::xml::split $imood stag sxmlns sattrs scdata ssubels
 
-		    if {![string equal $tag1 mood]} continue
-		    set xmlns [jlib::wrapper:getattr $vars1 xmlns]
-		    if {![string equal $xmlns $node]} continue
+		    if {![string equal $stag mood]} continue
+		    if {![string equal $sxmlns $node]} continue
 
 		    set parsed true
 
-		    foreach i $children1 {
-			jlib::wrapper:splitxml $i tag2 vars2 isempty2 chdata2 children2
+		    foreach i $ssubels {
+			::xmpp::xml::split $i sstag ssxmlns ssattrs sscdata sssubels
 
-			switch -- $tag2 {
+			switch -- $sstag {
 			    text {
-				set newtext $chdata2
+				set newtext $sscdata
 			    }
 			    default {
-				set newmood $tag2
+				set newmood $sstag
 			    }
 			}
 		    }
@@ -301,22 +300,22 @@
     }
 
     if {$parsed} {
-	set mood(mood,$connid,$jid) $newmood
-	set mood(text,$connid,$jid) $newtext
+	set mood(mood,$xlib,$jid) $newmood
+	set mood(text,$xlib,$jid) $newtext
 
-	hook::run user_mood_notification_hook $connid $jid $newmood $newtext
+	hook::run user_mood_notification_hook $xlib $jid $newmood $newtext
     } elseif {$retract} {
-	catch {unset mood(mood,$connid,$jid)}
-	catch {unset mood(text,$connid,$jid)}
+	catch {unset mood(mood,$xlib,$jid)}
+	catch {unset mood(text,$xlib,$jid)}
 
-	hook::run user_mood_notification_hook $connid $jid "" ""
+	hook::run user_mood_notification_hook $xlib $jid "" ""
     }
 }
 
-proc mood::notify_via_status_message {connid jid mood text} {
+proc mood::notify_via_status_message {xlib jid mood text} {
     variable m2d
 
-    set contact [::roster::itemconfig $connid $jid -name]
+    set contact [::roster::itemconfig $xlib $jid -name]
     if {$contact == ""} {
 	set contact $jid
     }
@@ -338,7 +337,7 @@
     set_status $msg
 }
 
-proc mood::publish {connid mood args} {
+proc mood::publish {xlib mood args} {
     variable node
 
     set text ""
@@ -350,16 +349,16 @@
 	}
     }
 
-    set content [list [jlib::wrapper:createtag $mood]]
+    set content [list [::xmpp::xml::create $mood]]
     if {$text != ""} {
-	lappend content [jlib::wrapper:createtag text -chdata $text]
+	lappend content [::xmpp::xml::create text -cdata $text]
     }
 
     set cmd [list pep::publish_item $node mood \
-		  -connection $connid \
-		  -payload [list [jlib::wrapper:createtag mood \
-				      -vars [list xmlns $node] \
-				      -subtags $content]]]
+		  -connection $xlib \
+		  -payload [list [::xmpp::xml::create mood \
+					    -xmlns $node \
+					    -subelements $content]]]
 
     if {$callback != ""} {
 	lappend cmd -command $callback
@@ -368,7 +367,7 @@
     eval $cmd
 }
 
-proc mood::unpublish {connid args} {
+proc mood::unpublish {xlib args} {
     variable node
 
     set callback ""
@@ -380,7 +379,7 @@
 
     set cmd [list pep::delete_item $node mood \
 		  -notify true \
-		  -connection $connid]
+		  -connection $xlib]
 
     if {$callback != ""} {
 	lappend cmd -command $callback
@@ -408,7 +407,7 @@
     set mm [pep::get_main_menu_pep_submenu].mood
     set idx [expr {$::ifacetk::options(show_tearoffs) ? 1 : 0}]
 
-    switch -- [llength [jlib::connections]] {
+    switch -- [llength [connections]] {
 	0 {
 	    $mm entryconfigure $idx -state disabled
 	    $mm entryconfigure [incr idx] \
@@ -441,8 +440,8 @@
 	destroy $w
     }
 
-    set connids [jlib::connections]
-    if {[llength $connids] == 0} {
+    set xlibs [connections]
+    if {[llength $xlibs] == 0} {
 	NonmodalMessageDlg [epath] \
 		-aspect 50000 \
 		-icon error \
@@ -461,8 +460,8 @@
     set f [$w getframe]
 
     set connjids [list [::msgcat::mc "All"]]
-    foreach connid $connids {
-	lappend connjids [jlib::connection_jid $connid]
+    foreach xlib $xlibs {
+	lappend connjids [connection_jid $xlib]
     }
     set myjid [lindex $connjids 0]
 
@@ -506,10 +505,10 @@
 	return
     }
 
-    foreach connid [jlib::connections] {
-	if {[string equal $myjid [jlib::connection_jid $connid]] || \
+    foreach xlib [connections] {
+	if {[string equal $myjid [connection_jid $xlib]] || \
 		[string equal $myjid [::msgcat::mc "All"]]} {
-	    publish $connid $d2m($moodvalue) \
+	    publish $xlib $d2m($moodvalue) \
 		    -reason $moodreason \
 		    -command [namespace current]::publish_result
 	    break
@@ -520,10 +519,10 @@
     destroy $w
 }
 
-# $res is one of: OK, ERR, DISCONNECT
+# $res is one of: ok, error, abort
 proc mood::publish_result {res child} {
     switch -- $res {
-	ERR {
+	error {
 	    set error [error_to_string $child]
 	}
 	default {
@@ -546,8 +545,8 @@
 	destroy $w
     }
 
-    set connids [jlib::connections]
-    if {[llength $connids] == 0} {
+    set xlibs [connections]
+    if {[llength $xlibs] == 0} {
 	NonmodalMessageDlg [epath] \
 		-aspect 50000 \
 		-icon error \
@@ -566,8 +565,8 @@
     set f [$w getframe]
 
     set connjids [list [::msgcat::mc "All"]]
-    foreach connid $connids {
-	lappend connjids [jlib::connection_jid $connid]
+    foreach xlib $xlibs {
+	lappend connjids [connection_jid $xlib]
     }
     set myjid [lindex $connjids 0]
 
@@ -583,7 +582,7 @@
 
     grid columnconfigure $f 1 -weight 1
 
-    if {[llength $connids] == 1} {
+    if {[llength $xlibs] == 1} {
 	do_unpublish $w
     } else {
 	$w draw
@@ -593,10 +592,10 @@
 proc mood::do_unpublish {w} {
     variable myjid
 
-    foreach connid [jlib::connections] {
-	if {[string equal $myjid [jlib::connection_jid $connid]] || \
+    foreach xlib [connections] {
+	if {[string equal $myjid [connection_jid $xlib]] || \
 		[string equal $myjid [::msgcat::mc "All"]]} {
-	    unpublish $connid \
+	    unpublish $xlib \
 		    -command [namespace current]::unpublish_result
 	    break
 	}
@@ -606,10 +605,10 @@
     destroy $w
 }
 
-# $res is one of: OK, ERR, DISCONNECT
+# $res is one of: ok, error, abort
 proc mood::unpublish_result {res child} {
     switch -- $res {
-	ERR {
+	error {
 	    if {[lindex [error_type_condition $child] 1] == "item-not-found"} {
 		return
 	    }
@@ -627,7 +626,7 @@
 	    -message [::msgcat::mc "User mood unpublishing failed: %s" $error]
 }
 
-proc mood::provide_userinfo {notebook connid jid editable} {
+proc mood::provide_userinfo {notebook xlib jid editable} {
     variable mood
     variable m2d
     variable ::userinfo::userinfo
@@ -635,11 +634,11 @@
     if {$editable} return
 
     set barejid [node_and_server_from_jid $jid]
-    if {![info exists mood(mood,$connid,$barejid)]} return
+    if {![info exists mood(mood,$xlib,$barejid)]} return
 
-    set userinfo(mood,$jid) $m2d($mood(mood,$connid,$barejid))
-    if {[info exists mood(text,$connid,$barejid)]} {
-	set userinfo(moodreason,$jid) $mood(text,$connid,$barejid)
+    set userinfo(mood,$jid) $m2d($mood(mood,$xlib,$barejid))
+    if {[info exists mood(text,$xlib,$barejid)]} {
+	set userinfo(moodreason,$jid) $mood(text,$xlib,$barejid)
     } else {
 	set userinfo(moodreason,$jid) ""
     }

Modified: trunk/tkabber/plugins/pep/user_tune.tcl
===================================================================
--- trunk/tkabber/plugins/pep/user_tune.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/pep/user_tune.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -32,10 +32,10 @@
     disco::register_feature $node
 }
 
-proc tune::get {connid jid what {default ""}} {
+proc tune::get {xlib jid what {default ""}} {
     variable tune
 
-    upvar 0 tune($what,$connid,$jid) v
+    upvar 0 tune($what,$xlib,$jid) v
     if {[info exists v]} {
 	return $v
     } else {
@@ -43,13 +43,13 @@
     }
 }
 
-proc tune::get_all {connid jid arrayVar} {
+proc tune::get_all {xlib jid arrayVar} {
     variable tune
 
     upvar 1 $arrayVar a
     foreach tag {artist length source title track uri rating} {
-	if {[info exists tune($tag,$connid,$jid)]} {
-	    set a($tag) $tune($tag,$connid,$jid)
+	if {[info exists tune($tag,$xlib,$jid)]} {
+	    set a($tag) $tune($tag,$xlib,$jid)
 	}
     }
 }
@@ -65,14 +65,14 @@
     }
 }
 
-proc tune::add_roster_pep_menu_item {m connid jid} {
-    set rjid [roster::find_jid $connid $jid]
+proc tune::add_roster_pep_menu_item {m xlib jid} {
+    set rjid [roster::find_jid $xlib $jid]
 
     if {$rjid == ""} {
  	set rjid [node_and_server_from_jid $jid]
     }
 
-    set pm [pep::get_roster_menu_pep_submenu $m $connid $rjid]
+    set pm [pep::get_roster_menu_pep_submenu $m $xlib $rjid]
 
     set mm [menu $pm.tune -tearoff no]
     $pm add cascade -menu $mm \
@@ -80,40 +80,40 @@
 
     $mm add command \
 	    -label [::msgcat::mc "Subscribe"] \
-	    -command [list [namespace current]::subscribe $connid $rjid]
+	    -command [list [namespace current]::subscribe $xlib $rjid]
     $mm add command \
 	    -label [::msgcat::mc "Unsubscribe"] \
-	    -command [list [namespace current]::unsubscribe $connid $rjid]
+	    -command [list [namespace current]::unsubscribe $xlib $rjid]
 
-    hook::run roster_pep_user_tune_menu_hook $mm $connid $rjid
+    hook::run roster_pep_user_tune_menu_hook $mm $xlib $rjid
 }
 
-proc tune::subscribe {connid jid args} {
+proc tune::subscribe {xlib jid args} {
     variable node
     variable substatus
 
     set to [node_and_server_from_jid $jid]
-    set cmd [linsert $args 0 [namespace current]::subscribe_result $connid $to]
+    set cmd [linsert $args 0 [namespace current]::subscribe_result $xlib $to]
     pep::subscribe $to $node \
-	    -connection $connid \
+	    -connection $xlib \
 	    -command $cmd
-    set substatus($connid,$to) sent-subscribe
+    set substatus($xlib,$to) sent-subscribe
 }
 
-proc tune::unsubscribe {connid jid args} {
+proc tune::unsubscribe {xlib jid args} {
     variable node
     variable substatus
 
     set to [node_and_server_from_jid $jid]
-    set cmd [linsert $args 0 [namespace current]::unsubscribe_result $connid $to]
+    set cmd [linsert $args 0 [namespace current]::unsubscribe_result $xlib $to]
     pep::unsubscribe $to $node \
-	    -connection $connid \
+	    -connection $xlib \
 	    -command $cmd
-    set substatus($connid,$to) sent-unsubscribe
+    set substatus($xlib,$to) sent-unsubscribe
 }
 
-# Err may be one of: OK, ERR and DISCONNECT
-proc tune::subscribe_result {connid jid res child args} {
+# Err may be one of: ok, error and abort
+proc tune::subscribe_result {xlib jid res child args} {
     variable substatus
 
     set cmd ""
@@ -129,11 +129,11 @@
     }
 
     switch -- $res {
-	OK {
-	    set substatus($connid,$jid) from
+	ok {
+	    set substatus($xlib,$jid) from
 	}
-	ERR {
-	    set substatus($connid,$jid) error
+	error {
+	    set substatus($xlib,$jid) error
 	}
 	default {
 	    return
@@ -146,7 +146,7 @@
     }
 }
 
-proc tune::unsubscribe_result {connid jid res child args} {
+proc tune::unsubscribe_result {xlib jid res child args} {
     variable substatus
     variable tune
 
@@ -162,9 +162,9 @@
 	}
     }
 
-    if {[string equal $res OK]} {
-	set substatus($connid,$jid) none
-	forget_user_tune $connid $jid
+    if {[string equal $res ok]} {
+	set substatus($xlib,$jid) none
+	forget_user_tune $xlib $jid
     }
 
     if {$cmd != ""} {
@@ -173,7 +173,7 @@
     }
 }
 
-proc tune::provide_roster_popup_info {var connid user} {
+proc tune::provide_roster_popup_info {var xlib user} {
     variable substatus
     variable tune
 
@@ -181,20 +181,20 @@
 
     set jid [node_and_server_from_jid $user]
 
-    if {[info exists tune(available,$connid,$jid)]} {
+    if {[info exists tune(available,$xlib,$jid)]} {
 	append info [::msgcat::mc "\n\tTune: %s - %s" \
-				  [get $connid $jid artist ?] \
-				  [get $connid $jid title ?]]
-    } elseif {[info exists substatus($connid,$jid)]} {
+				  [get $xlib $jid artist ?] \
+				  [get $xlib $jid title ?]]
+    } elseif {[info exists substatus($xlib,$jid)]} {
 	append info [::msgcat::mc "\n\tUser tune subscription: %s" \
-				  $substatus($connid,$jid)]
+				  $substatus($xlib,$jid)]
     } else {
 	return
     }
 
 }
 
-proc tune::process_tune_notification {connid jid items} {
+proc tune::process_tune_notification {xlib jid items} {
     variable node
     variable tune
 
@@ -203,29 +203,28 @@
     set nelems  0
 
     foreach item $items {
-	jlib::wrapper:splitxml $item tag vars isempty chdata children
+	::xmpp::xml::split $item tag xmlns attrs cdata subels
 
 	switch -- $tag {
 	    retract {
 		set retract true
 	    }
 	    default {
-		foreach itune $children {
-		    jlib::wrapper:splitxml $itune tag1 vars1 isempty1 chdata1 children1
+		foreach itune $subels {
+		    ::xmpp::xml::split $itune stag sxmlns sattrs scdata ssubels
 
-		    if {![string equal $tag1 tune]} continue
-		    set xmlns [jlib::wrapper:getattr $vars1 xmlns]
-		    if {![string equal $xmlns $node]} continue
+		    if {![string equal $stag tune]} continue
+		    if {![string equal $sxmlns $node]} continue
 
 		    set parsed true
 
-		    foreach i $children1 {
-			jlib::wrapper:splitxml $i tag2 vars2 isempty2 chdata2 children2
+		    foreach i $ssubels {
+			::xmpp::xml::split $itune sstag ssxmlns ssattrs sscdata sssubels
 
-			switch -- $tag2 {
+			switch -- $sstag {
 			    artist - length - source -
 			    title - track - uri - rating {
-				set $tag2 $chdata2
+				set $sstag $sscdata
 				incr nelems
 			    }
 			}
@@ -239,36 +238,36 @@
 	if {$nelems > 0} {
 	    foreach tag {artist length source title track uri rating} {
 		if {[info exists $tag]} {
-		    set tune($tag,$connid,$jid) [set $tag]
+		    set tune($tag,$xlib,$jid) [set $tag]
 		} else {
-		    catch {unset tune($tag,$connid,$jid)}
+		    catch {unset tune($tag,$xlib,$jid)}
 		}
 	    }
-	    set tune(available,$connid,$jid) ""
-	    hook::run user_tune_notification_hook $connid $jid published
+	    set tune(available,$xlib,$jid) ""
+	    hook::run user_tune_notification_hook $xlib $jid published
 	} else { # "stop" command
-	    forget_user_tune $connid $jid
-	    hook::run user_tune_notification_hook $connid $jid stopped
+	    forget_user_tune $xlib $jid
+	    hook::run user_tune_notification_hook $xlib $jid stopped
 	}
     } elseif {$retract} {
-	forget_user_tune $connid $jid
-	hook::run user_tune_notification_hook $connid $jid retracted
+	forget_user_tune $xlib $jid
+	hook::run user_tune_notification_hook $xlib $jid retracted
     }
 }
 
-proc tune::forget_user_tune {connid jid} {
+proc tune::forget_user_tune {xlib jid} {
     variable tune
 
     foreach tag {artist length source title track uri rating} {
-	catch {unset tune($tag,$connid,$jid)}
+	catch {unset tune($tag,$xlib,$jid)}
     }
-    catch {unset tune(available,$connid,$jid)}
+    catch {unset tune(available,$xlib,$jid)}
 }
 
-proc tune::notify_via_status_message {connid jid event} {
+proc tune::notify_via_status_message {xlib jid event} {
     variable tune
 
-    set contact [::roster::itemconfig $connid $jid -name]
+    set contact [::roster::itemconfig $xlib $jid -name]
     if {$contact == ""} {
 	set contact $jid
     }
@@ -277,8 +276,8 @@
 	published {
 	    set msg [::msgcat::mc "%s's tune changed to %s - %s" \
 				  $contact \
-				  [get $connid $jid artist ?] \
-				  [get $connid $jid title ?]]
+				  [get $xlib $jid artist ?] \
+				  [get $xlib $jid title ?]]
 	}
 	retracted {
 	    set msg [::msgcat::mc "%s's tune is unset" $contact]
@@ -291,7 +290,7 @@
     set_status $msg
 }
 
-proc tune::publish {connid args} {
+proc tune::publish {xlib args} {
     variable node
 
     set seen 0
@@ -328,17 +327,17 @@
 	set content [list]
 	foreach tag {artist length source title track uri rating} {
 	    if {[info exists $tag] && [set $tag] != ""} {
-		lappend content [jlib::wrapper:createtag $tag \
-				     -chdata [set $tag]]
+		lappend content [::xmpp::xml::create $tag \
+					    -cdata [set $tag]]
 	    }
 	}
     }
 
     set cmd [list pep::publish_item $node tune \
-		  -connection $connid \
-		  -payload [list [jlib::wrapper:createtag tune \
-				      -vars [list xmlns $node] \
-				      -subtags $content]]]
+		  -connection $xlib \
+		  -payload [list [::xmpp::xml::create tune \
+					    -xmlns $node \
+					    -subelements $content]]]
 
     if {$callback != ""} {
 	lappend cmd -command $callback
@@ -347,7 +346,7 @@
     eval $cmd
 }
 
-proc tune::unpublish {connid args} {
+proc tune::unpublish {xlib args} {
     variable node
 
     set callback ""
@@ -359,7 +358,7 @@
 
     set cmd [list pep::delete_item $node tune \
 		  -notify true \
-		  -connection $connid]
+		  -connection $xlib]
 
     if {$callback != ""} {
 	lappend cmd -command $callback
@@ -387,7 +386,7 @@
     set mm [pep::get_main_menu_pep_submenu].tune
     set idx [expr {$::ifacetk::options(show_tearoffs) ? 1 : 0}]
 
-    switch -- [llength [jlib::connections]] {
+    switch -- [llength [connections]] {
 	0 {
 	    $mm entryconfigure $idx -state disabled
 	    $mm entryconfigure [incr idx] \
@@ -425,8 +424,8 @@
 	destroy $w
     }
 
-    set connids [jlib::connections]
-    if {[llength $connids] == 0} {
+    set xlibs [connections]
+    if {[llength $xlibs] == 0} {
 	NonmodalMessageDlg [epath] \
 		-aspect 50000 \
 		-icon error \
@@ -445,8 +444,8 @@
     set f [$w getframe]
 
     set connjids [list [::msgcat::mc "All"]]
-    foreach connid $connids {
-	lappend connjids [jlib::connection_jid $connid]
+    foreach xlib $xlibs {
+	lappend connjids [connection_jid $xlib]
     }
     set myjid [lindex $connjids 0]
 
@@ -536,15 +535,15 @@
     variable tunestop
     variable myjid
 
-    foreach connid [jlib::connections] {
-	if {[string equal $myjid [jlib::connection_jid $connid]] || \
+    foreach xlib [connections] {
+	if {[string equal $myjid [connection_jid $xlib]] || \
 		[string equal $myjid [::msgcat::mc "All"]]} {
 	    if {$tunestop} {
-		publish $connid \
+		publish $xlib \
 			-stop \
 			-command [namespace current]::publish_result
 	    } else {
-		publish $connid \
+		publish $xlib \
 			-artist $tuneartist \
 			-title $tunetitle \
 			-track $tunetrack \
@@ -577,10 +576,10 @@
     foreach v [info vars] { unset $v }
 }
 
-# $res is one of: OK, ERR, DISCONNECT
+# $res is one of: ok, error, abort
 proc tune::publish_result {res child} {
     switch -- $res {
-	ERR {
+	error {
 	    set error [error_to_string $child]
 	}
 	default {
@@ -603,8 +602,8 @@
 	destroy $w
     }
 
-    set connids [jlib::connections]
-    if {[llength $connids] == 0} {
+    set xlibs [connections]
+    if {[llength $xlibs] == 0} {
 	NonmodalMessageDlg [epath] \
 		-aspect 50000 \
 		-icon error \
@@ -623,8 +622,8 @@
     set f [$w getframe]
 
     set connjids [list [::msgcat::mc "All"]]
-    foreach connid $connids {
-	lappend connjids [jlib::connection_jid $connid]
+    foreach xlib $xlibs {
+	lappend connjids [connection_jid $xlib]
     }
     set myjid [lindex $connjids 0]
 
@@ -640,7 +639,7 @@
 
     grid columnconfigure $f 1 -weight 1
 
-    if {[llength $connids] == 1} {
+    if {[llength $xlibs] == 1} {
 	do_unpublish $w
     } else {
 	$w draw
@@ -650,10 +649,10 @@
 proc tune::do_unpublish {w} {
     variable myjid
 
-    foreach connid [jlib::connections] {
-	if {[string equal $myjid [jlib::connection_jid $connid]] || \
+    foreach xlib [connections] {
+	if {[string equal $myjid [connection_jid $xlib]] || \
 		[string equal $myjid [::msgcat::mc "All"]]} {
-	    unpublish $connid \
+	    unpublish $xlib \
 		    -command [namespace current]::unpublish_result
 	    break
 	}
@@ -663,10 +662,10 @@
     destroy $w
 }
 
-# $res is one of: OK, ERR, DISCONNECT
+# $res is one of: ok, error, abort
 proc tune::unpublish_result {res child} {
     switch -- $res {
-	ERR {
+	error {
 	    if {[lindex [error_type_condition $child] 1] == "item-not-found"} {
 		return
 	    }
@@ -684,7 +683,7 @@
 	    -message [::msgcat::mc "User tune unpublishing failed: %s" $error]
 }
 
-proc tune::provide_userinfo {notebook connid jid editable} {
+proc tune::provide_userinfo {notebook xlib jid editable} {
     variable tune
     variable m2d
     variable ::userinfo::userinfo
@@ -692,11 +691,11 @@
     if {$editable} return
 
     set barejid [node_and_server_from_jid $jid]
-    if {![info exists tune(available,$connid,$barejid)]} return
+    if {![info exists tune(available,$xlib,$barejid)]} return
 
     foreach tag {artist length source title track uri rating} {
-	if {[info exists tune($tag,$connid,$barejid)]} {
-	    set userinfo(tune$tag,$jid) $tune($tag,$connid,$barejid)
+	if {[info exists tune($tag,$xlib,$barejid)]} {
+	    set userinfo(tune$tag,$jid) $tune($tag,$xlib,$barejid)
 	} else {
 	    set userinfo(tune$tag,$jid) ""
 	}

Modified: trunk/tkabber/plugins/richtext/emoticons.tcl
===================================================================
--- trunk/tkabber/plugins/richtext/emoticons.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/richtext/emoticons.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -181,12 +181,7 @@
 
 	set faces_regexp ""
 
-	set parser [jlib::wrapper:new "#" "#" \
-			[list [namespace current]::parse_icondef $dir]]
-	jlib::wrapper:elementstart $parser stream:stream {} {}
-	jlib::wrapper:parser $parser parse $icondef
-	jlib::wrapper:parser $parser configure -final 0
-	jlib::wrapper:free $parser
+	::xmpp::xml::parseData $icondef [namespace code [list parse_icondef $dir]]
     }
 
     # Sweep out orphaned images:
@@ -194,21 +189,21 @@
 }
 
 proc emoticons::parse_icondef {dir xmldata} {
-    jlib::wrapper:splitxml $xmldata tag vars isempty chdata children
+    ::xmpp::xml::split $xmldata tag xmlns attrs cdata subels
 
     if {$tag != "icondef"} {
 	# TODO: error message
 	return
     }
 
-    foreach child $children {
-	parse_item $dir $child
+    foreach subel $subels {
+	parse_item $dir $subel
     }
 
 }
 
 proc emoticons::parse_item {dir item} {
-    jlib::wrapper:splitxml $item tag vars isempty chdata children
+    ::xmpp::xml::split $item tag xmlns attrs cdata subels
 
     switch -- $tag {
 	name {}
@@ -218,7 +213,7 @@
 	creation {}
 	meta {}
 	icon {
-	    parse_icon $dir $children
+	    parse_icon $dir $subels
 	}
     }
 }
@@ -231,25 +226,25 @@
     set txtdefault ""
     set graphic ""
     foreach item $items {
-	jlib::wrapper:splitxml $item tag vars isempty chdata children
+	::xmpp::xml::split $item tag xmlns attrs cdata subels
 	switch -- $tag {
 	    text {
-		if {$chdata == ""} continue ;# skip empty <text> element
-		lappend faces $chdata
+		if {$cdata == ""} continue ;# skip empty <text> element
+		lappend faces $cdata
 		if {$txtdefault == "" || \
-			[jlib::wrapper:getattr $vars default] == "true"} {
-		    set txtdefault $chdata
+			[::xmpp::xml::getAttr $attrs default] == "true"} {
+		    set txtdefault $cdata
 		}
 	    }
 	    object {
-		switch -glob -- [jlib::wrapper:getattr $vars mime] {
-		    image/* {set graphic $chdata}
+		switch -glob -- [::xmpp::xml::getAttr $attrs mime] {
+		    image/* {set graphic $cdata}
 		}
 	    }
 	    graphic {
 		# For compatibility with older versions of icondef.xml
-		switch -glob -- [jlib::wrapper:getattr $vars type] {
-		    image/* {set graphic $chdata}
+		switch -glob -- [::xmpp::xml::getAttr $attrs type] {
+		    image/* {set graphic $cdata}
 		}
 	    }
 	    sound {}
@@ -548,26 +543,22 @@
 	return
     }
 
-    set parser [jlib::wrapper:new "#" "#" \
-		    [list [namespace current]::get_theme_name $varName $thdir]]
-    jlib::wrapper:elementstart $parser stream:stream {} {}
-    jlib::wrapper:parser $parser parse $icondef
-    jlib::wrapper:parser $parser configure -final 0
-    jlib::wrapper:free $parser
+    ::xmpp::xml::parseData $icondef \
+		[namespace code [list get_theme_name $varName $thdir]]
 }
 
 proc emoticons::get_theme_name {varName dir xmldata} {
     upvar #0 $varName themes
 
-    jlib::wrapper:splitxml $xmldata tag vars isempty cdata children
+    ::xmpp::xml::split $xmldata tag xmlns attrs cdata subels
 
     if {$tag == "name"} {
 	set themes($cdata) $dir
 	return 1
     }
 
-    foreach child $children {
-	if {[get_theme_name $varName $dir $child]} {
+    foreach subel $subels {
+	if {[get_theme_name $varName $dir $subel]} {
 	    return 1
 	}
     }

Modified: trunk/tkabber/plugins/roster/annotations.tcl
===================================================================
--- trunk/tkabber/plugins/roster/annotations.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/roster/annotations.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -10,45 +10,44 @@
     set ::NS(rosternotes) "storage:rosternotes"
 }
 
-proc annotations::free_notes {connid} {
+proc annotations::free_notes {xlib} {
     variable notes
 
-    array unset notes $connid,*
+    array unset notes $xlib,*
 }
 
 hook::add disconnected_hook [namespace current]::annotations::free_notes
 
-proc annotations::request_notes {connid} {
+proc annotations::request_notes {xlib} {
     variable NS
     variable notes
 
-    private::retrieve [list [jlib::wrapper:createtag storage \
-				 -vars [list xmlns $::NS(rosternotes)]]] \
-	-command [list [namespace current]::process_notes $connid] \
-	-connection $connid
+    private::retrieve $xlib [list [::xmpp::xml::create storage \
+					    -xmlns $::NS(rosternotes)]] \
+	-command [list [namespace current]::process_notes $xlib]
 }
 
 hook::add connected_hook [namespace current]::annotations::request_notes
 
-proc annotations::process_notes {connid res child} {
+proc annotations::process_notes {xlib status xml} {
     variable notes
 
-    if {$res != "OK"} return
+    if {$status != "ok"} return
 
-    free_notes $connid
+    free_notes $xlib
 
-    foreach xmldata $child {
-	jlib::wrapper:splitxml $xmldata tag vars isempty cdata children
+    foreach xmldata $xml {
+	::xmpp::xml::split $xmldata tag xmlns attrs cdata subels
 
-	if {[jlib::wrapper:getattr $vars xmlns] == $::NS(rosternotes)} {
-	    foreach note $children {
-		create_note $connid $note
+	if {$xmlns == $::NS(rosternotes)} {
+	    foreach note $subels {
+		create_note $xlib $note
 	    }
 	}
     }
 }
 
-proc annotations::create_note {connid xmldata args} {
+proc annotations::create_note {xlib xmldata args} {
     variable notes
 
     set merge 0
@@ -62,11 +61,11 @@
 	}
     }
 
-    jlib::wrapper:splitxml $xmldata tag vars isempty cdata children
+    ::xmpp::xml::split $xmldata tag xmlns attrs cdata subels
 
-    set jid [jlib::wrapper:getattr $vars jid]
-    set cdate [jlib::wrapper:getattr $vars cdate]
-    set mdate [jlib::wrapper:getattr $vars mdate]
+    set jid   [::xmpp::xml::getAttr $attrs jid]
+    set cdate [::xmpp::xml::getAttr $attrs cdate]
+    set mdate [::xmpp::xml::getAttr $attrs mdate]
 
     if {![catch { scan_time $cdate } cdate]} {
 	set cdate [clock seconds]
@@ -75,11 +74,11 @@
 	set cdate [clock seconds]
     }
 
-    if {!$merge || [more_recent $connid $jid $cdate $mdate]} {
-	set notes($connid,jid,$jid)   $jid
-	set notes($connid,cdate,$jid) $cdate
-	set notes($connid,mdate,$jid) $mdate
-	set notes($connid,note,$jid)  $cdata
+    if {!$merge || [more_recent $xlib $jid $cdate $mdate]} {
+	set notes($xlib,jid,$jid)   $jid
+	set notes($xlib,cdate,$jid) $cdate
+	set notes($xlib,mdate,$jid) $mdate
+	set notes($xlib,note,$jid)  $cdata
 	return 1
     } else {
 	return 0
@@ -94,77 +93,77 @@
     }
 }
 
-proc annotations::more_recent {connid jid cdate mdate} {
+proc annotations::more_recent {xlib jid cdate mdate} {
     variable notes
 
-    if {![info exists notes($connid,jid,$jid)]} {
+    if {![info exists notes($xlib,jid,$jid)]} {
 	return 1
-    } elseif {[info exists notes($connid,mdate,$jid)]} {
-	return [expr {$mdate > $notes($connid,mdate,$jid)}]
-    } elseif {[info exists notes($connid,cdate,$jid)]} {
-	return [expr {$cdate > $notes($connid,cdate,$jid)}]
+    } elseif {[info exists notes($xlib,mdate,$jid)]} {
+	return [expr {$mdate > $notes($xlib,mdate,$jid)}]
+    } elseif {[info exists notes($xlib,cdate,$jid)]} {
+	return [expr {$cdate > $notes($xlib,cdate,$jid)}]
     } else {
 	return 1
     }
 }
 
-proc annotations::cleanup_and_store_notes {connid args} {
+proc annotations::cleanup_and_store_notes {xlib args} {
     variable notes
 
     set roster_jids {}
-    foreach rjid [roster::get_jids $connid] {
+    foreach rjid [roster::get_jids $xlib] {
 	lappend roster_jids [node_and_server_from_jid $rjid]
     }
 
-    foreach idx [array names notes $connid,jid,*] {
+    foreach idx [array names notes $xlib,jid,*] {
 	set jid $notes($idx)
 	if {[lsearch -exact $roster_jids $jid] < 0 || \
-		![info exists notes($connid,note,$jid)] || \
-		$notes($connid,note,$jid) == ""} {
-	    catch { unset notes($connid,jid,$jid) }
-	    catch { unset notes($connid,cdate,$jid) }
-	    catch { unset notes($connid,mdate,$jid) }
-	    catch { unset notes($connid,note,$jid) }
+		![info exists notes($xlib,note,$jid)] || \
+		$notes($xlib,note,$jid) == ""} {
+	    catch { unset notes($xlib,jid,$jid) }
+	    catch { unset notes($xlib,cdate,$jid) }
+	    catch { unset notes($xlib,mdate,$jid) }
+	    catch { unset notes($xlib,note,$jid) }
 	}
     }
 
-    eval [list store_notes $connid] $args
+    eval [list store_notes $xlib] $args
 }
 
-proc annotations::serialize_notes {connid} {
+proc annotations::serialize_notes {xlib} {
     variable notes
 
     set notelist {}
-    foreach idx [array names notes $connid,jid,*] {
+    foreach idx [array names notes $xlib,jid,*] {
 	set jid $notes($idx)
 
 	set vars [list jid $jid]
-	if {[info exists notes($connid,cdate,$jid)]} {
-	    set cdate [clock format $notes($connid,cdate,$jid) \
+	if {[info exists notes($xlib,cdate,$jid)]} {
+	    set cdate [clock format $notes($xlib,cdate,$jid) \
 			     -format "%Y-%m-%dT%TZ" -gmt true]
 	}
 	lappend vars cdate $cdate
-	if {[info exists notes($connid,mdate,$jid)]} {
-	    set mdate [clock format $notes($connid,mdate,$jid) \
+	if {[info exists notes($xlib,mdate,$jid)]} {
+	    set mdate [clock format $notes($xlib,mdate,$jid) \
 			     -format "%Y-%m-%dT%TZ" -gmt true]
 	}
 	lappend vars mdate $mdate
-	if {[info exists notes($connid,note,$jid)] && \
-		$notes($connid,note,$jid) != ""} {
+	if {[info exists notes($xlib,note,$jid)] && \
+		$notes($xlib,note,$jid) != ""} {
 	    lappend notelist \
-		[jlib::wrapper:createtag note \
-		     -vars $vars \
-		     -chdata $notes($connid,note,$jid)]
+		[::xmpp::xml::create note \
+			    -attrs $vars \
+			    -cdata $notes($xlib,note,$jid)]
 	}
     }
 
-    jlib::wrapper:createtag storage \
-	-vars [list xmlns $::NS(rosternotes)] \
-	-subtags $notelist
+    ::xmpp::xml::create storage \
+		-xmlns $::NS(rosternotes) \
+		-subelements $notelist
 }
 
-proc annotations::store_notes {connid args} {
-    set command [list [namespace current]::store_notes_result $connid]
+proc annotations::store_notes {xlib args} {
+    set command [list [namespace current]::store_notes_result $xlib]
     foreach {opt val} $args {
 	switch -- $opt {
 	    -command { set command $val }
@@ -175,14 +174,13 @@
 	}
     }
 
-    private::store [list [serialize_notes $connid]] \
-	-command $command \
-	-connection $connid
+    private::store $xlib [list [serialize_notes $xlib]] \
+	-command $command
 }
 
-proc annotations::store_notes_result {connid res child} {
+proc annotations::store_notes_result {xlib res child} {
 
-    if {$res == "OK"} return
+    if {$res == "ok"} return
 
     if {[winfo exists .store_notes_error]} {
 	destroy .store_notes_error
@@ -193,26 +191,26 @@
 	-type user -buttons ok -default 0 -cancel 0
 }
 
-proc annotations::add_user_popup_info {infovar connid jid} {
+proc annotations::add_user_popup_info {infovar xlib jid} {
     variable notes
     upvar 0 $infovar info
 
     set jid [node_and_server_from_jid $jid]
 
-    if {[info exists notes($connid,note,$jid)] && \
-	    $notes($connid,note,$jid) != ""} {
+    if {[info exists notes($xlib,note,$jid)] && \
+	    $notes($xlib,note,$jid) != ""} {
 	append info "\n\tNote:\t"
-	append info [string map [list "\n" "\n\t\t"] "$notes($connid,note,$jid)"]
+	append info [string map [list "\n" "\n\t\t"] "$notes($xlib,note,$jid)"]
 
 	if {0} {
-	    if {[info exists notes($connid,cdate,$jid)]} {
+	    if {[info exists notes($xlib,cdate,$jid)]} {
 		append info [format "\n\tNote created: %s" \
-				 [clock format $notes($connid,cdate,$jid) \
+				 [clock format $notes($xlib,cdate,$jid) \
 					-format "%Y-%m-%d %T" -gmt false]]
 	    }
-	    if {[info exists notes($connid,mdate,$jid)]} {
+	    if {[info exists notes($xlib,mdate,$jid)]} {
 		append info [format "\n\tNote modified: %s" \
-				 [clock format $notes($connid,mdate,$jid) \
+				 [clock format $notes($xlib,mdate,$jid) \
 					-format "%Y-%m-%d %T" -gmt false]]
 	    }
 	}
@@ -222,13 +220,13 @@
 hook::add roster_user_popup_info_hook \
     [namespace current]::annotations::add_user_popup_info 80
 
-proc annotations::show_dialog {connid jid} {
+proc annotations::show_dialog {xlib jid} {
     variable notes
 
     set jid [node_and_server_from_jid $jid]
 
     set allowed_name [jid_to_tag $jid]
-    set w .note_edit_${connid}_$allowed_name
+    set w .note_edit_${xlib}_$allowed_name
 
     if {[winfo exists $w]} {
 	destroy $w
@@ -239,21 +237,21 @@
 	-default 0 -cancel 1
 
     $w add -text [::msgcat::mc "Store"] \
-	-command [list [namespace current]::commit_changes $w $connid $jid]
+	-command [list [namespace current]::commit_changes $w $xlib $jid]
     $w add -text [::msgcat::mc "Cancel"] -command [list destroy $w]
 
     set f [$w getframe]
 
-    if {[info exists notes($connid,cdate,$jid)]} {
+    if {[info exists notes($xlib,cdate,$jid)]} {
 	label $f.cdate -text [format [::msgcat::mc "Created: %s"] \
-				     [clock format $notes($connid,cdate,$jid) \
+				     [clock format $notes($xlib,cdate,$jid) \
 					    -format "%Y-%m-%d %T" -gmt false]]
 	pack $f.cdate -side top -anchor w
     }
 
-    if {[info exists notes($connid,mdate,$jid)]} {
+    if {[info exists notes($xlib,mdate,$jid)]} {
 	label $f.mdate -text [format [::msgcat::mc "Modified: %s"] \
-				     [clock format $notes($connid,mdate,$jid) \
+				     [clock format $notes($xlib,mdate,$jid) \
 					    -format "%Y-%m-%d %T" -gmt false]]
 	pack $f.mdate -side top -anchor w
     }
@@ -261,8 +259,8 @@
     ScrolledWindow $f.sw
     pack $f.sw -side top -expand yes -fill both
     textUndoable $f.note -width 50 -height 5 -wrap word
-    if {[info exists notes($connid,note,$jid)]} {
-	$f.note insert 0.0 $notes($connid,note,$jid)
+    if {[info exists notes($xlib,note,$jid)]} {
+	$f.note insert 0.0 $notes($xlib,note,$jid)
     }
     $f.sw setwidget $f.note
 
@@ -275,34 +273,34 @@
     $w draw $f.note
 }
 
-proc annotations::commit_changes {w connid jid} {
+proc annotations::commit_changes {w xlib jid} {
     variable notes
 
     set text [$w getframe].note
 
     set date [clock seconds]
 
-    set notes($connid,jid,$jid) $jid
-    if {![info exists notes($connid,cdate,$jid)]} {
-	set notes($connid,cdate,$jid) $date
+    set notes($xlib,jid,$jid) $jid
+    if {![info exists notes($xlib,cdate,$jid)]} {
+	set notes($xlib,cdate,$jid) $date
     }
-    set notes($connid,mdate,$jid) $date
-    set notes($connid,note,$jid) [$text get 0.0 "end -1 char"]
+    set notes($xlib,mdate,$jid) $date
+    set notes($xlib,note,$jid) [$text get 0.0 "end -1 char"]
 
-    cleanup_and_store_notes $connid
+    cleanup_and_store_notes $xlib
 
     destroy $w
 }
 
-proc annotations::prefs_user_menu {m connid jid} {
-    set rjid [roster::find_jid $connid $jid]
+proc annotations::prefs_user_menu {m xlib jid} {
+    set rjid [roster::find_jid $xlib $jid]
     if {$rjid == ""} {
 	set state disabled
     } else {
 	set state normal
     }
     $m add command -label [::msgcat::mc "Edit item notes..."] \
-	-command [list [namespace current]::show_dialog $connid $rjid] \
+	-command [list [namespace current]::show_dialog $xlib $rjid] \
 	-state $state
 }
 
@@ -315,31 +313,31 @@
 hook::add roster_jid_popup_menu_hook \
     [namespace current]::annotations::prefs_user_menu 76
 
-proc annotations::note_page {tab connid jid editable} {
+proc annotations::note_page {tab xlib jid editable} {
     variable notes
 
     if {$editable} return
 
     set jid [node_and_server_from_jid $jid]
 
-    if {![info exists notes($connid,note,$jid)] || \
-	    $notes($connid,note,$jid) == ""} {
+    if {![info exists notes($xlib,note,$jid)] || \
+	    $notes($xlib,note,$jid) == ""} {
 	return
     }
 
     set notestab [$tab insert end notes -text [::msgcat::mc "Notes"]]
     set n [userinfo::pack_frame $notestab.notes [::msgcat::mc "Roster Notes"]]
 
-    if {[info exists notes($connid,cdate,$jid)]} {
+    if {[info exists notes($xlib,cdate,$jid)]} {
 	label $n.cdate -text [format [::msgcat::mc "Created: %s"] \
-				     [clock format $notes($connid,cdate,$jid) \
+				     [clock format $notes($xlib,cdate,$jid) \
 					    -format "%Y-%m-%d %T" -gmt false]]
 	pack $n.cdate -side top -anchor w
     }
 
-    if {[info exists notes($connid,mdate,$jid)]} {
+    if {[info exists notes($xlib,mdate,$jid)]} {
 	label $n.mdate -text [format [::msgcat::mc "Modified: %s"] \
-				     [clock format $notes($connid,mdate,$jid) \
+				     [clock format $notes($xlib,mdate,$jid) \
 					    -format "%Y-%m-%d %T" -gmt false]]
 	pack $n.mdate -side top -anchor w
     }
@@ -347,7 +345,7 @@
     set sw [ScrolledWindow $n.sw -scrollbar vertical]
     text $n.text -height 12 -wrap word
     $sw setwidget $n.text
-    $n.text insert 0.0 $notes($connid,note,$jid)
+    $n.text insert 0.0 $notes($xlib,note,$jid)
     $n.text configure -state disabled
     pack $sw -side top -fill both -expand yes
     pack $n -fill both -expand yes

Modified: trunk/tkabber/plugins/roster/backup.tcl
===================================================================
--- trunk/tkabber/plugins/roster/backup.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/roster/backup.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -39,7 +39,7 @@
     }
     menu $imenu -tearoff 0
 
-    if {[jlib::connections] == {}} {
+    if {[connections] == {}} {
 	.mainframe setmenustate export_roster disabled
 	.mainframe setmenustate import_roster disabled
     } else {
@@ -47,8 +47,8 @@
 	.mainframe setmenustate import_roster normal
     }
 
-    foreach c [jlib::connections] {
-	set jid [jlib::connection_jid $c]
+    foreach c [connections] {
+	set jid [connection_jid $c]
 	set label [format [::msgcat::mc "Roster of %s"] $jid]
 	set ecommand [list [namespace current]::export_to_file $c]
 	set icommand [list [namespace current]::import_from_file $c]
@@ -59,10 +59,10 @@
 
 ###############################################################################
 
-proc rosterbackup::export_to_file {connid} {
+proc rosterbackup::export_to_file {xlib} {
     set filename [tk_getSaveFile \
 		      -initialdir $::configdir \
-		      -initialfile [jlib::connection_user $connid]-roster.xml \
+		      -initialfile [connection_user $xlib]-roster.xml \
 		      -filetypes [list \
 				      [list [::msgcat::mc "Roster Files"] \
 					   .xml] \
@@ -73,51 +73,52 @@
     fconfigure $fd -encoding utf-8
 
     puts $fd {<?xml version="1.0" encoding="UTF-8"?>}
-    puts $fd [serialize_roster $connid]
+    puts $fd [serialize_roster $xlib]
 
     close $fd
 }
 
 ###############################################################################
 
-proc rosterbackup::serialize_roster {connid} {
+proc rosterbackup::serialize_roster {xlib} {
     global NS
 
     set subtags [list]
-    hook::run serialize_roster_hook $connid #[info level] subtags
+    hook::run serialize_roster_hook $xlib #[info level] subtags
 
-    jlib::wrapper:createxml [jlib::wrapper:createtag contactlist \
-	    -vars [list xmlns $NS(rosterbackup)] -subtags $subtags] \
-	-prettyprint 1
+    ::xmpp::xml::toText [::xmpp::xml::create contactlist \
+				    -xmlns $NS(rosterbackup) \
+				    -subelements $subtags] \
+			-prettyprint 1
 }
 
 ###############################################################################
 
-proc rosterbackup::serialize_roster_contacts {connid level varName} {
+proc rosterbackup::serialize_roster_contacts {xlib level varName} {
     upvar $level $varName subtags
 
     set items [list]
-    foreach jid [::roster::get_jids $connid] {
-	set category [::roster::itemconfig $connid $jid -category]
+    foreach jid [::roster::get_jids $xlib] {
+	set category [::roster::itemconfig $xlib $jid -category]
 	switch -- $category {
 	    user -
 	    gateway {
-		lappend items [::roster::item_to_xml $connid $jid]
+		lappend items [::roster::item_to_xml $xlib $jid]
 	    }
 	}
     }
 
-    lappend subtags [jlib::wrapper:createtag roster \
-	-vars {xmlns jabber:iq:roster} \
-	-subtags $items]
+    lappend subtags [::xmpp::xml::create roster \
+			    -xmlns jabber:iq:roster \
+			    -subelements $items]
 }
 
 ###############################################################################
 
-proc rosterbackup::import_from_file {connid} {
+proc rosterbackup::import_from_file {xlib} {
     set filename [tk_getOpenFile \
 		      -initialdir $::configdir \
-		      -initialfile [jlib::connection_user $connid]-roster.xml \
+		      -initialfile [connection_user $xlib]-roster.xml \
 		      -filetypes [list \
 				      [list [::msgcat::mc "Roster Files"] \
 					   .xml] \
@@ -129,43 +130,36 @@
     set xml [string trimleft [read $fd] [format %c 0xFEFF]] ;# strip BOM, if any
     close $fd
 
-    deserialize_roster $connid $xml
+    deserialize_roster $xlib $xml
 }
 
 ###############################################################################
 
-proc rosterbackup::deserialize_roster {connid data} {
-    hook::run roster_deserializing_hook $connid
+proc rosterbackup::deserialize_roster {xlib data} {
+    hook::run roster_deserializing_hook $xlib
 
-    set parser [jlib::wrapper:new "#" "#" \
-	[list [namespace current]::parse_roster_xml $connid]]
-    jlib::wrapper:elementstart $parser stream:stream {} {}
-    jlib::wrapper:parser $parser parse $data
-    jlib::wrapper:parser $parser configure -final 0
-    jlib::wrapper:free $parser
+    ::xmpp::xml::parseData $data [namespace code [list parse_roster_xml $xlib]]
 
-    hook::run roster_deserialized_hook $connid
+    hook::run roster_deserialized_hook $xlib
 }
 
 ###############################################################################
 
-proc rosterbackup::parse_roster_xml {connid data} {
+proc rosterbackup::parse_roster_xml {xlib data} {
     global NS
 
-    jlib::wrapper:splitxml $data tag vars isempty cdata children
+    ::xmpp::xml::split $data tag xmlns attrs cdata subels
 
     if {![string equal $tag contactlist]} {
-	return -code error "Bad root element \"$tag\":\
-	    must be contactlist"
+	return -code error "Bad root element \"$tag\": must be contactlist"
     }
-    set xmlns [jlib::wrapper:getattr $vars xmlns]
     if {![string equal $xmlns $NS(rosterbackup)]} {
 	return -code error "Bad root element namespace \"$xmlns\":\
-	    must be \"$NS(rosterbackup)\""
+			    must be \"$NS(rosterbackup)\""
     }
 
     set tuples [list]
-    hook::run deserialize_roster_hook $connid $children #[info level] tuples
+    hook::run deserialize_roster_hook $xlib $subels #[info level] tuples
 
     if {[llength $tuples] > 0} {
 	set scripts [list]
@@ -187,64 +181,62 @@
 
 ###############################################################################
 
-proc rosterbackup::deserialize_roster_contacts {connid data level varName} {
+proc rosterbackup::deserialize_roster_contacts {xlib data level varName} {
     global NS
     upvar $level $varName handlers
 
     array set existing {}
-    foreach jid [::roster::get_jids $connid] {
+    foreach jid [::roster::get_jids $xlib] {
 	set existing($jid) {}
     }
 
-    upvar 0 sent($connid,jids) jids
+    upvar 0 sent($xlib,jids) jids
     set jids [list]
     set subtags [list]
 
     foreach item $data {
-	jlib::wrapper:splitxml $item tag vars isempty cdata children
+	::xmpp::xml::split $item tag xmlns attrs cdata subels
 
 	if {![string equal $tag roster]} continue
-	set xmlns [jlib::wrapper:getattr $vars xmlns]
 	if {![string equal $xmlns $NS(roster)]} {
 	    return -code error "Bad roster element namespace \"$xmlns\":\
-		must be \"$NS(roster)\""
+				must be \"$NS(roster)\""
 	}
 
-	foreach child $children {
-	    set jid [get_item_jid $child]
+	foreach subel $subels {
+	    set jid [get_item_jid $subel]
 	    if {![info exists existing($jid)]} {
 		lappend jids $jid
-		lappend subtags $child
+		lappend subtags $subel
 	    }
 	}
     }
 
     if {[llength $subtags] > 0} {
 	lappend handlers [list 50 [namespace code [list \
-	    send_contacts $connid $subtags]]]
+					     send_contacts $xlib $subtags]]]
     }
 
     lappend handlers [list 1000 [namespace code [list \
-	show_restore_completion_dialog $connid]]]
+					show_restore_completion_dialog $xlib]]]
 }
 
 ###############################################################################
 
 proc rosterbackup::get_item_jid {data} {
-    jlib::wrapper:splitxml $data ? vars ? ? ?
-    jlib::wrapper:getattr $vars jid
+    ::xmpp::xml::split $data tag xmlns attrs cdata subels
+    ::xmpp::xml::getAttr $attrs jid
 }
 
 ###############################################################################
 
-proc rosterbackup::send_contacts {connid contacts continuation} {
+proc rosterbackup::send_contacts {xlib contacts continuation} {
     global NS
 
-    jlib::send_iq set \
-	[jlib::wrapper:createtag query \
-	     -vars [list xmlns $NS(roster)] \
-	     -subtags $contacts] \
-	-connection $connid \
+    ::xmpp::sendIQ $xlib set \
+	-query [::xmpp::xml::create query \
+			    -xmlns $NS(roster) \
+			    -subelements $contacts] \
 	-command [namespace code [list process_send_result $continuation]]
 }
 
@@ -252,7 +244,7 @@
 
 proc rosterbackup::process_send_result {continuation result xmldata} {
     switch -- $result {
-	OK {
+	ok {
 	    eval $continuation
 	}
 	default {
@@ -269,7 +261,7 @@
 
 ###############################################################################
 
-proc rosterbackup::show_restore_completion_dialog {connid continuation} {
+proc rosterbackup::show_restore_completion_dialog {xlib continuation} {
     NonmodalMessageDlg [epath] \
 	-aspect 50000 \
 	-icon info \

Modified: trunk/tkabber/plugins/roster/bkup_annotations.tcl
===================================================================
--- trunk/tkabber/plugins/roster/bkup_annotations.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/roster/bkup_annotations.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -6,69 +6,67 @@
 namespace eval annobackup {
     # Should probably go after the roster contacts, so we set prio to 60:
     hook::add serialize_roster_hook \
-	[namespace current]::serialize_annotations 60
+	      [namespace current]::serialize_annotations 60
     hook::add deserialize_roster_hook \
-	[namespace current]::deserialize_annotations 60
+	      [namespace current]::deserialize_annotations 60
 }
 
 ###############################################################################
 
-proc annobackup::serialize_annotations {connid level varName} {
+proc annobackup::serialize_annotations {xlib level varName} {
     upvar $level $varName subtags
     global NS
 
-    set xmldata [::plugins::annotations::serialize_notes $connid]
+    set xmldata [::plugins::annotations::serialize_notes $xlib]
 
-    lappend subtags [jlib::wrapper:createtag privstorage \
-	-vars {xmlns jabber:iq:private} \
-	-subtags [list $xmldata]]
+    lappend subtags [::xmpp::xml::create privstorage \
+				-xmlns jabber:iq:private \
+				-subelement $xmldata]
 }
 
 ###############################################################################
 
-proc annobackup::deserialize_annotations {connid data level varName} {
+proc annobackup::deserialize_annotations {xlib data level varName} {
     global NS
     upvar $level $varName handlers
 
     set notes [list]
     foreach item $data {
-	jlib::wrapper:splitxml $item tag vars isempty cdata children
+	::xmpp::xml::split $item tag xmlns attrs cdata subels
 	if {![string equal $tag privstorage]} continue
-	set xmlns [jlib::wrapper:getattr $vars xmlns]
 	if {![string equal $xmlns $NS(private)]} {
 	    return -code error "Bad roster element namespace \"$xmlns\":\
-		must be \"$NS(private)\""
+				must be \"$NS(private)\""
 	}
 
-	foreach storage $children {
-	    jlib::wrapper:splitxml $storage ctag cvars cisempty ccdata cchildren
-	    if {![string equal $ctag storage]} continue
-	    set xmlns [jlib::wrapper:getattr $cvars xmlns]
-	    if {![string equal $xmlns $NS(rosternotes)]} continue
+	foreach storage $subels {
+	    ::xmpp::xml::split $storage stag sxmlns sattrs scdata ssubels
+	    if {![string equal $stag storage]} continue
+	    if {![string equal $sxmlns $NS(rosternotes)]} continue
 	    
-	    set notes [concat $notes $cchildren]
+	    set notes [concat $notes $ssubels]
 	}
     }
 
     if {[llength $notes] > 0} {
 	lappend handlers [list 60 [namespace code [list \
-	    send_notes $connid $notes]]]
+						    send_notes $xlib $notes]]]
     }
 }
 
 ###############################################################################
 
-proc annobackup::send_notes {connid notes continuation} {
+proc annobackup::send_notes {xlib notes continuation} {
     set updated 0
 
     foreach item $notes {
 	set added [::plugins::annotations::create_note \
-		$connid $item -merge yes]
+		$xlib $item -merge yes]
 	set updated [expr {$updated || $added}]
     }
 
     if {$updated} {
-	::plugins::annotations::cleanup_and_store_notes $connid \
+	::plugins::annotations::cleanup_and_store_notes $xlib \
 	    -command [namespace code [list process_sending_result $continuation]]
     } else {
 	eval $continuation
@@ -79,7 +77,7 @@
 
 proc annobackup::process_sending_result {continuation result xmldata} {
     switch -- $result {
-	OK {
+	ok {
 	    eval $continuation
 	}
 	default {

Modified: trunk/tkabber/plugins/roster/bkup_conferences.tcl
===================================================================
--- trunk/tkabber/plugins/roster/bkup_conferences.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/roster/bkup_conferences.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -12,75 +12,73 @@
 
 ###############################################################################
 
-proc mucbackup::serialize_muc_bookmarks {connid level varName} {
+proc mucbackup::serialize_muc_bookmarks {xlib level varName} {
     upvar $level $varName subtags
     global NS
 
-    foreach xmldata [::plugins::conferences::serialize_bookmarks $connid] {
-	lappend subtags [jlib::wrapper:createtag privstorage \
-	    -vars [list xmlns $NS(private)] \
-	    -subtags [list $xmldata]]
+    foreach xmldata [::plugins::conferences::serialize_bookmarks $xlib] {
+	lappend subtags [::xmpp::xml::create privstorage \
+				    -xmlns $NS(private) \
+				    -subelement $xmldata]
     }
 }
 
 ###############################################################################
 
-proc mucbackup::deserialize_muc_bookmarks {connid data level varName} {
+proc mucbackup::deserialize_muc_bookmarks {xlib data level varName} {
     global NS
     upvar $level $varName handlers
 
     set bookmarks [list]
     set bmgroups  [list]
     foreach item $data {
-	jlib::wrapper:splitxml $item tag vars isempty cdata children
+	::xmpp::xml::split $item tag xmlns attrs cdata subels
 	if {![string equal $tag privstorage]} continue
-	set xmlns [jlib::wrapper:getattr $vars xmlns]
 	if {![string equal $xmlns $NS(private)]} {
 	    return -code error "Bad roster element namespace \"$xmlns\":\
-		must be \"$NS(private)\""
+				must be \"$NS(private)\""
 	}
 
-	foreach storage $children {
-	    jlib::wrapper:splitxml $storage ctag cvars cisempty ccdata cchildren
+	foreach storage $subels {
+	    ::xmpp::xml::split $storage stag sxmlns sattrs scdata ssubels
 	    if {![string equal $ctag storage]} continue
-	    set xmlns [jlib::wrapper:getattr $cvars xmlns]
-	    switch -- $xmlns \
+	    switch -- $sxmlns \
 		$NS(bookmarks) {
-		    set bookmarks [concat $bookmarks $cchildren]
+		    set bookmarks [concat $bookmarks $ssubels]
 		} \
 		$NS(tkabber:groups) {
-		    set bmgroups [concat $bmgroups $cchildren]
+		    set bmgroups [concat $bmgroups $ssubels]
 		}
 	}
     }
 
     if {[llength $bookmarks] > 0 && [llength $bmgroups] > 0} {
 	lappend handlers [list 70 [namespace code [list \
-	    merge_muc_bookmarks $connid $bookmarks $bmgroups]]]
+	    merge_muc_bookmarks $xlib $bookmarks $bmgroups]]]
     }
 }
 
 ###############################################################################
 
-proc mucbackup::merge_muc_bookmarks {connid bookmarks bmgroups continuation} {
+proc mucbackup::merge_muc_bookmarks {xlib bookmarks bmgroups continuation} {
     variable updated 0
 
     foreach item $bookmarks {
 	set added [::plugins::conferences::create_muc_bookmark \
-		$connid $item -merge yes]
+		$xlib $item -merge yes]
 	set updated [expr {$updated || $added}]
     }
 
     foreach item $bmgroups {
 	set added [::plugins::conferences::create_muc_bmgroup \
-		$connid $item -merge yes]
+		$xlib $item -merge yes]
 	set updated [expr {$updated || $added}]
     }
 
     if {$updated} {
-	::plugins::conferences::store_bookmarks $connid \
+	::plugins::conferences::store_bookmarks $xlib \
 	    -command [namespace code [list process_merging_result $continuation]]
-	::plugins::conferences::push_bookmarks_to_roster $connid
+	::plugins::conferences::push_bookmarks_to_roster $xlib
     } else {
 	eval $continuation
     }
@@ -90,7 +88,7 @@
 
 proc mucbackup::process_merging_result {continuation result xmldata} {
     switch -- $result {
-	OK {
+	ok {
 	    eval $continuation
 	}
 	default {

Modified: trunk/tkabber/plugins/roster/cache_categories.tcl
===================================================================
--- trunk/tkabber/plugins/roster/cache_categories.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/roster/cache_categories.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -11,15 +11,15 @@
 
 ##############################################################################
 
-proc cache_categories::fill_cached_categories_and_subtypes {connid} {
+proc cache_categories::fill_cached_categories_and_subtypes {xlib} {
     variable category_and_subtype_list
     variable requested_categories
 
     catch { array set tmp $category_and_subtype_list }
-    set requested_categories($connid) [array names tmp]
+    set requested_categories($xlib) [array names tmp]
     foreach jid [array names tmp] {
 	lassign $tmp($jid) category subtype
-	roster::override_category_and_subtype $connid $jid \
+	roster::override_category_and_subtype $xlib $jid \
 					      $category $subtype
     }
 }
@@ -29,14 +29,14 @@
 
 ##############################################################################
 
-proc cache_categories::free_cached_categories_and_subtypes {connid} {
+proc cache_categories::free_cached_categories_and_subtypes {xlib} {
     variable category_and_subtype_list
     variable requested_categories
 
-    if {$connid == {}} {
+    if {$xlib == {}} {
 	array unset requested_categories
     } else {
-	catch { unset requested_categories($connid) }
+	catch { unset requested_categories($xlib) }
     }
 }
 
@@ -45,42 +45,41 @@
 
 ##############################################################################
 
-proc cache_categories::request_category_and_subtype {connid jid} {
+proc cache_categories::request_category_and_subtype {xlib jid} {
     variable category_and_subtype_list
     variable requested_categories
 
     set server [server_from_jid $jid]
-    if {[lsearch -exact $requested_categories($connid) $server] >= 0} {
+    if {[lsearch -exact $requested_categories($xlib) $server] >= 0} {
 	return
     }
 
-    lappend requested_categories($connid) $server
+    lappend requested_categories($xlib) $server
 
-    jlib::send_iq get \
-	[jlib::wrapper:createtag query \
-	     -vars [list xmlns $::NS(disco_info)]] \
+    ::xmpp::sendIQ $xlib get \
+	-query [::xmpp::xml::create query \
+			-xmlns $::NS(disco_info)] \
 	-to $server \
-	-connection $connid \
-	-command [list [namespace current]::parse_requested_categories $connid $server]
+	-command [list [namespace current]::parse_requested_categories $xlib $server]
 }
 
 ##############################################################################
 
-proc cache_categories::parse_requested_categories {connid server res child} {
+proc cache_categories::parse_requested_categories {xlib server status xml} {
     variable category_and_subtype_list
 
-    if {$res != "OK"} return
+    if {$status != "ok"} return
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
+    ::xmpp::xml::split $xml tag xmlns attrs cdata subels
 
-    foreach ch $children {
-	jlib::wrapper:splitxml $ch tag1 vars1 isempty1 chdata1 children1
-	switch -- $tag1 {
+    foreach subel $subels {
+	::xmpp::xml::split $subel stag sxmlns sattrs scdata ssubels
+	switch -- $stag {
 	    identity {
-		set category [jlib::wrapper:getattr $vars1 category]
-		set type [jlib::wrapper:getattr $vars1 type]
+		set category [::xmpp::xml::getAttr $sattrs category]
+		set type     [::xmpp::xml::getAttr $sattrs type]
 
-		roster::override_category_and_subtype $connid $server \
+		roster::override_category_and_subtype $xlib $server \
 						      $category $type
 		lappend category_and_subtype_list \
 			$server [list $category $type]

Modified: trunk/tkabber/plugins/roster/conferenceinfo.tcl
===================================================================
--- trunk/tkabber/plugins/roster/conferenceinfo.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/roster/conferenceinfo.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -20,14 +20,14 @@
 }
 
 
-# TODO: connid
-proc conferenceinfo::add_user_popup_info {infovar connid jid} {
+# TODO: xlib
+proc conferenceinfo::add_user_popup_info {infovar xlib jid} {
     variable data
     variable options
     upvar 0 $infovar info
 
     if {!$options(autoask)} return
-    if {[chat::is_opened [chat::chatid $connid $jid]]} return
+    if {[chat::is_opened [chat::chatid $xlib $jid]]} return
 
     if {![info exists data(error_browse,$jid)] || \
 	    ![info exists data(error_disco,$jid)]} return
@@ -70,15 +70,15 @@
 
     if {!$options(autoask)} return
 
-    foreach connid [jlib::connections] {
-	if {[catch { set roster::roster(jids,$connid) } jids]} {
+    foreach xlib [connections] {
+	if {[catch { set roster::roster(jids,$xlib) } jids]} {
 	    continue
 	}
 	foreach jid $jids {
-	    lassign [roster::get_category_and_subtype $connid $jid] \
+	    lassign [roster::get_category_and_subtype $xlib $jid] \
 		category type
 	    if {$category == "conference" && [node_from_jid $jid] != "" && \
-		    ![chat::is_opened [chat::chatid $connid $jid]]} {
+		    ![chat::is_opened [chat::chatid $xlib $jid]]} {
 	    
 		set sec [clock seconds]
  
@@ -86,11 +86,10 @@
 			$data(error_browse,$jid) == "" || \
 			$sec - $data(time_browse,$jid) >= $options(err_interval) * 60} {
 
-		    jlib::send_iq get \
-			[jlib::wrapper:createtag query \
-			     -vars {xmlns jabber:iq:browse}] \
+		    ::xmpp::sendIQ $xlib get \
+			-query [::xmpp::xml::create query \
+					-xmlns jabber:iq:browse] \
 			-to $jid \
-			-connection $connid \
 			-command [list [namespace current]::receive $jid browse]
 		}
 
@@ -98,11 +97,10 @@
 			$data(error_disco,$jid) == "" || \
 			$sec - $data(time_disco,$jid) >= $options(err_interval) * 60} {
 
-		    jlib::send_iq get \
-			[jlib::wrapper:createtag query \
-			     -vars [list xmlns $::NS(disco_items)]] \
+		    ::xmpp::sendIQ $xlib get \
+			-query [::xmpp::xml::create query \
+					-xmlns $::NS(disco_items)] \
 			-to $jid \
-			-connection $connid \
 			-command [list [namespace current]::receive $jid disco]
 		}
 	    }
@@ -113,7 +111,7 @@
     after [expr {$options(interval) * 60 * 1000}] [list [namespace current]::ask]
 }
 
-proc conferenceinfo::receive {jid mech res child} {
+proc conferenceinfo::receive {jid mech status xml} {
     variable options
     variable data
 
@@ -122,30 +120,29 @@
     set data(time_$mech,$jid) [clock seconds]
     set data(users_$mech,$jid) {}
 
-    if {$res != "OK"} {
-	set data(error_${mech}_code,$jid) [lindex [error_type_condition $child] 1]
-	set data(error_$mech,$jid) [error_to_string $child]
+    if {$status != "ok"} {
+	set data(error_${mech}_code,$jid) [lindex [error_type_condition $xml] 1]
+	set data(error_$mech,$jid) [error_to_string $xml]
 	return
     }
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
+    ::xmpp::xml::split $xml tag xmlns attrs cdata subels
 
-    foreach item $children {
-	jlib::wrapper:splitxml $item tag1 vars1 isempty1 chdata1 children1
+    foreach item $subels {
+	::xmpp::xml::split $item stag sxmlns sattrs scdata ssubels
+	set category [::xmpp::xml::getAttr $sattrs category]
+	set name [::xmpp::xml::getAttr $sattrs name]
+	set node [::xmpp::xml::getAttr $sattrs node]
 	switch -- $mech {
 	    browse {
-		if {$tag1 == "user" || ($tag1 == "item" && \
-			[jlib::wrapper:getattr $vars1 category] == "user")} {
-		    set name [jlib::wrapper:getattr $vars1 name]
+		if {$stag == "user" || ($stag == "item" && $category == "user")} {
 		    if {$name != ""} {
 			lappend data(users_browse,$jid) $name
 		    }
 		}
 	    }
 	    disco {
-		if {$tag1 == "item"} {
-		    set node [jlib::wrapper:getattr $vars1 node]
-		    set name [jlib::wrapper:getattr $vars1 name]
+		if {$stag == "item"} {
 		    if {$name != "" && $node == ""} {
 			lappend data(users_disco,$jid) $name
 		    }
@@ -157,7 +154,7 @@
 }
 
 proc conferenceinfo::stop {args} {
-    if {[jlib::connections] == {}} {
+    if {[connections] == {}} {
 	after cancel [list [namespace current]::ask]
     }
 }

Modified: trunk/tkabber/plugins/roster/conferences.tcl
===================================================================
--- trunk/tkabber/plugins/roster/conferences.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/roster/conferences.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -41,10 +41,10 @@
 #   Free bookmarks on disconnect
 #
 
-proc conferences::free_bookmarks {connid} {
+proc conferences::free_bookmarks {xlib} {
     variable bookmarks
 
-    array unset bookmarks $connid,*
+    array unset bookmarks $xlib,*
 }
 
 hook::add disconnected_hook [namespace current]::conferences::free_bookmarks
@@ -54,58 +54,56 @@
 #   Retrieve bookmarks on connect
 #
 
-proc conferences::request_bookmarks {connid} {
+proc conferences::request_bookmarks {xlib} {
     variable bookmarks
     variable responds
 
-    set responds($connid) 0
-    array unset bookmarks $connid,*
+    set responds($xlib) 0
+    array unset bookmarks $xlib,*
 
-    private::retrieve [list [jlib::wrapper:createtag storage \
-				 -vars [list xmlns $::NS(bookmarks)]]] \
-	-command [list [namespace current]::process_bookmarks $connid] \
-	-connection $connid
+    private::retrieve $xlib [list [::xmpp::xml::create storage \
+					    -xmlns $::NS(bookmarks)]] \
+	-command [list [namespace current]::process_bookmarks $xlib]
 
-    private::retrieve [list [jlib::wrapper:createtag storage \
-				 -vars [list xmlns $::NS(tkabber:groups)]]] \
-	-command [list [namespace current]::process_bookmarks $connid] \
-	-connection $connid
+    private::retrieve $xlib [list [::xmpp::xml::create storage \
+					    -xmlns $::NS(tkabber:groups)]] \
+	-command [list [namespace current]::process_bookmarks $xlib]
 }
 
 hook::add connected_hook [namespace current]::conferences::request_bookmarks 20
 
-proc conferences::process_bookmarks {connid res child} {
+proc conferences::process_bookmarks {xlib status xmlList} {
     variable bookmarks
     variable responds
     global NS
 
-    if {$res != "OK"} return
+    if {$status != "ok"} return
 
-    incr responds($connid)
+    incr responds($xlib)
 
-    foreach ch $child {
-	jlib::wrapper:splitxml $ch tag1 vars1 isempty1 cdata1 children1
+    foreach xml $xmlList {
+	::xmpp::xml::split $xml tag xmlns attrs cdata subels
 
-	switch -- [jlib::wrapper:getattr $vars1 xmlns] \
+	switch -- $xmlns \
 	    $NS(bookmarks) {
-		foreach bookmark $children1 {
-		    create_muc_bookmark $connid $bookmark
+		foreach bookmark $subels {
+		    create_muc_bookmark $xlib $bookmark
 		}
 	    } \
 	    $NS(tkabber:groups) {
-		foreach bookmark $children1 {
-		    create_muc_bmgroup $connid $bookmark
+		foreach bookmark $subels {
+		    create_muc_bmgroup $xlib $bookmark
 		}
 	    }
     }
 
-    if {$responds($connid) < 2} return
+    if {$responds($xlib) < 2} return
 
-    push_bookmarks_to_roster $connid
-    after idle [list [namespace current]::autojoin_groups $connid]
+    push_bookmarks_to_roster $xlib
+    after idle [list [namespace current]::autojoin_groups $xlib]
 }
 
-proc conferences::create_muc_bookmark {connid xmldata args} {
+proc conferences::create_muc_bookmark {xlib xmldata args} {
     variable bookmarks
 
     set merge 0
@@ -113,53 +111,51 @@
 	switch -- $opt {
 	    -merge { set merge $val }
 	    default {
-		return -code error "Bad option \"$opt\":\
-		    must be -merge"
+		return -code error "Bad option \"$opt\": must be -merge"
 	    }
 	}
     }
 
-    jlib::wrapper:splitxml $xmldata btag bvars bisempty bcdata bchildren
+    ::xmpp::xml::split $xmldata tag xmlns attrs cdata subels
 
-    if {![string equal $btag conference]} { return 0 }
+    if {![string equal $tag conference]} { return 0 }
 
-    set jid [string tolower [jlib::wrapper:getattr $bvars jid]]
+    set jid [string tolower [::xmpp::xml::getAttr $attrs jid]]
 
-    if {$merge && [info exists bookmarks($connid,jid,$jid)]} {
+    if {$merge && [info exists bookmarks($xlib,jid,$jid)]} {
 	return 0
     } else {
-	set bookmarks($connid,jid,$jid) $jid
+	set bookmarks($xlib,jid,$jid) $jid
 
-	set bookmarks($connid,name,$jid) [jlib::wrapper:getattr $bvars name]
-	set bookmarks($connid,nick,$jid) ""
-	set bookmarks($connid,password,$jid) ""
-	if {![info exists bookmarks($connid,groups,$jid)]} {
-	    set bookmarks($connid,groups,$jid) {}
-	    set bookmarks($connid,hasgroups,$jid) 0
+	set bookmarks($xlib,name,$jid) [::xmpp::xml::getAttr $attrs name]
+	set bookmarks($xlib,nick,$jid) ""
+	set bookmarks($xlib,password,$jid) ""
+	if {![info exists bookmarks($xlib,groups,$jid)]} {
+	    set bookmarks($xlib,groups,$jid) {}
+	    set bookmarks($xlib,hasgroups,$jid) 0
 	} else {
-	    set bookmarks($connid,hasgroups,$jid) 1
+	    set bookmarks($xlib,hasgroups,$jid) 1
 	}
 
-	set autojoin [jlib::wrapper:getattr $bvars autojoin]
+	set autojoin [::xmpp::xml::getAttr $attrs autojoin]
 	switch -- $autojoin {
 	    1 -
-	    true { set bookmarks($connid,autojoin,$jid) 1 }
-	    default { set bookmarks($connid,autojoin,$jid) 0 }
+	    true { set bookmarks($xlib,autojoin,$jid) 1 }
+	    default { set bookmarks($xlib,autojoin,$jid) 0 }
 	}
 	
-	foreach bch $bchildren {
-	    jlib::wrapper:splitxml \
-		$bch tag2 vars2 isempty2 cdata2 children2
-	    switch -- $tag2 {
-		nick { set bookmarks($connid,nick,$jid) $cdata2 }
-		password { set bookmarks($connid,password,$jid) $cdata2 }
+	foreach subel $subels {
+	    ::xmpp::xml::split $subel stag sxmlns sattrs scdata ssubels
+	    switch -- $stag {
+		nick { set bookmarks($xlib,nick,$jid) $scdata }
+		password { set bookmarks($xlib,password,$jid) $scdata }
 	    }
 	}
 	return 1
     }
 }
 
-proc conferences::create_muc_bmgroup {connid xmldata args} {
+proc conferences::create_muc_bmgroup {xlib xmldata args} {
     variable bookmarks
 
     set merge 0
@@ -173,39 +169,39 @@
 	}
     }
 
-    jlib::wrapper:splitxml $xmldata btag bvars bisempty bcdata bchildren
+    ::xmpp::xml::split $xmldata tag xmlns attrs cdata subels
 
-    if {![string equal $btag conference]} return
+    if {![string equal $tag conference]} return
 
-    set jid [string tolower [jlib::wrapper:getattr $bvars jid]]
+    set jid [string tolower [::xmpp::xml::getAttr $attrs jid]]
 
     set groups [list]
-    foreach bch $bchildren {
-	jlib::wrapper:splitxml $bch tag2 vars2 isempty2 cdata2 children2
-	if {[string equal $tag2 group]} {
-	    lappend groups $cdata2
+    foreach subel $subels {
+	::xmpp::xml::split $subel stag sxmlns sattrs scdata ssubels
+	if {[string equal $stag group]} {
+	    lappend groups $scdata
 	}
     }
 
-    if {$merge && [info exists bookmarks($connid,jid,$jid)]
-		&& $bookmarks($connid,hasgroups,$jid)} {
+    if {$merge && [info exists bookmarks($xlib,jid,$jid)]
+		&& $bookmarks($xlib,hasgroups,$jid)} {
 	return 0
     } else {
-	set bookmarks($connid,groups,$jid) $groups
-	set bookmarks($connid,hasgroups,$jid) 1
+	set bookmarks($xlib,groups,$jid) $groups
+	set bookmarks($xlib,hasgroups,$jid) 1
 	return 1
     }
 }
 
-proc conferences::push_bookmarks_to_roster {connid} {
+proc conferences::push_bookmarks_to_roster {xlib} {
     variable bookmarks
 
-    foreach idx [array names bookmarks $connid,jid,*] {
+    foreach idx [array names bookmarks $xlib,jid,*] {
 	set jid $bookmarks($idx)
-	client:roster_push $connid $jid $bookmarks($connid,name,$jid) \
-			   $bookmarks($connid,groups,$jid) \
+	client:roster_push $xlib $jid $bookmarks($xlib,name,$jid) \
+			   $bookmarks($xlib,groups,$jid) \
 			   bookmark ""
-	roster::override_category_and_subtype $connid $jid conference ""
+	roster::override_category_and_subtype $xlib $jid conference ""
     }
 }
 
@@ -214,50 +210,50 @@
 #   Store bookmarks
 #
 
-proc conferences::serialize_bookmarks {connid} {
+proc conferences::serialize_bookmarks {xlib} {
     variable bookmarks
 
     set bookmarklist {}
     set grouplist {}
-    foreach idx [array names bookmarks $connid,jid,*] {
+    foreach idx [array names bookmarks $xlib,jid,*] {
 	set jid $bookmarks($idx)
-	set name $bookmarks($connid,name,$jid)
-	set autojoin $bookmarks($connid,autojoin,$jid)
+	set name $bookmarks($xlib,name,$jid)
+	set autojoin $bookmarks($xlib,autojoin,$jid)
 	
 	set vars [list jid $jid name $name autojoin $autojoin]
 	set subtags {}
-	if {$bookmarks($connid,nick,$jid) != ""} {
-	    lappend subtags [jlib::wrapper:createtag nick \
-				 -chdata $bookmarks($connid,nick,$jid)]
+	if {$bookmarks($xlib,nick,$jid) != ""} {
+	    lappend subtags [::xmpp::xml::create nick \
+				    -cdata $bookmarks($xlib,nick,$jid)]
 	}
-	if {$bookmarks($connid,password,$jid) != ""} {
-	    lappend subtags [jlib::wrapper:createtag password \
-				 -chdata $bookmarks($connid,password,$jid)]
+	if {$bookmarks($xlib,password,$jid) != ""} {
+	    lappend subtags [::xmpp::xml::create password \
+				    -cdata $bookmarks($xlib,password,$jid)]
 	}
-	lappend bookmarklist [jlib::wrapper:createtag conference \
-				  -vars $vars \
-				  -subtags $subtags]
+	lappend bookmarklist [::xmpp::xml::create conference \
+				    -attrs $vars \
+				    -subelements $subtags]
 	set vars [list jid $jid]
 	set groups {}
-	foreach group $bookmarks($connid,groups,$jid) {
-	    lappend groups [jlib::wrapper:createtag group \
-				-chdata $group]
+	foreach group $bookmarks($xlib,groups,$jid) {
+	    lappend groups [::xmpp::xml::create group \
+				    -cdata $group]
 	}
-	lappend grouplist [jlib::wrapper:createtag conference \
-			       -vars $vars \
-			       -subtags $groups]
+	lappend grouplist [::xmpp::xml::create conference \
+				-attrs $vars \
+				-subelements $groups]
     }
 
-    list [jlib::wrapper:createtag storage \
-	    -vars [list xmlns $::NS(bookmarks)] \
-	    -subtags $bookmarklist] \
-	[jlib::wrapper:createtag storage \
-	    -vars [list xmlns $::NS(tkabber:groups)] \
-	    -subtags $grouplist]
+    list [::xmpp::xml::create storage \
+		-xmlns $::NS(bookmarks) \
+		-subelements $bookmarklist] \
+	 [::xmpp::xml::create storage \
+		-xmlns $::NS(tkabber:groups) \
+		-subelements $grouplist]
 }
 
-proc conferences::store_bookmarks {connid args} {
-    set command [list [namespace current]::store_bookmarks_result $connid]
+proc conferences::store_bookmarks {xlib args} {
+    set command [list [namespace current]::store_bookmarks_result $xlib]
     foreach {opt val} $args {
 	switch -- $opt {
 	    -command { set command $val }
@@ -268,16 +264,15 @@
 	}
     }
 
-    foreach item [serialize_bookmarks $connid] {
-	private::store [list $item] \
-	    -command $command \
-	    -connection $connid
+    foreach item [serialize_bookmarks $xlib] {
+	private::store $xlib [list $item] \
+	    -command $command
     }
 }
 
-proc conferences::store_bookmarks_result {connid res child} {
+proc conferences::store_bookmarks_result {xlib res child} {
 
-    if {$res == "OK"} return
+    if {$res == "ok"} return
 
     if {[winfo exists .store_bookmarks_error]} {
 	return
@@ -294,8 +289,8 @@
 #   Menu item for conference window
 #
 
-proc conferences::add_conference_menu_item {m connid jid} {
-    set chatid [chat::chatid $connid $jid]
+proc conferences::add_conference_menu_item {m xlib jid} {
+    set chatid [chat::chatid $xlib $jid]
 
     if {[info exists ::muc::muc_password($chatid)]} {
 	set password $::muc::muc_password($chatid)
@@ -304,11 +299,10 @@
     }
 
     $m add command -label [::msgcat::mc "Add conference to roster..."] \
-	-command [list [namespace current]::add_conference_dialog \
+	-command [list [namespace current]::add_conference_dialog $xlib \
 		       -group [node_from_jid $jid] \
 		       -server [server_from_jid $jid] \
-		       -password $password \
-		       -connection $connid]
+		       -password $password]
 }
 
 hook::add chat_create_conference_menu_hook \
@@ -319,22 +313,24 @@
 #   Add conference to roster dialog
 #
 
-proc conferences::add_conference_dialog {args} {
+proc conferences::add_conference_dialog {xlib args} {
     variable gra_group
     variable gra_server
     variable gra_nick
     variable gra_password
     variable gra_autojoin
-    variable gra_connid
+    variable gra_xlib
     variable gra_rostergroup
 
-    if {[lempty [jlib::connections]]} return
+    if {[lempty [connections]]} return
 
     set gw .addgroup
     catch { destroy $gw }
 
-    set connid [lindex [jlib::connections] 0]
-    set gra_server conference.[jlib::connection_server $connid]
+    if {$xlib == ""} {
+	set xlib [lindex [connections] 0]
+    }
+    set gra_server conference.[connection_server $xlib]
     set gra_group ""
     set gra_password ""
     set gra_autojoin 0
@@ -348,14 +344,13 @@
 	    -nick { set gra_nick $val }
 	    -password { set gra_password $val }
 	    -autojoin { set gra_autojoin $val }
-	    -connection { set connid $val }
 	}
     }
 
     if {![info exists gra_nick]} {
-	set gra_nick [get_group_nick ${gra_group}@$gra_server ""]
+	set gra_nick [get_group_nick [::xmpp::jid::jid $gra_group $gra_server""] ""]
     }
-    set gra_connid [jlib::connection_jid $connid]
+    set gra_xlib [connection_jid $xlib]
 
     Dialog $gw -title [::msgcat::mc "Add Conference to Roster"] -separator 1 -anchor e \
 	    -default 0 -cancel 1 -parent . -modal none
@@ -376,7 +371,7 @@
 	-variable [namespace current]::gra_autojoin
     label $gf.lrostergroup -text [::msgcat::mc "Roster group:"]
     ComboBox $gf.rostergroup -textvariable [namespace current]::gra_rostergroup \
-	-values [get_groups $connid]
+	-values [get_groups $xlib]
 
     grid $gf.lgroup  -row 0 -column 0 -sticky e
     grid $gf.group   -row 0 -column 1 -sticky ew
@@ -390,12 +385,12 @@
     grid $gf.lrostergroup  -row 5 -column 0 -sticky e
     grid $gf.rostergroup   -row 5 -column 1 -sticky ew
 
-    if {[llength [jlib::connections]] > 1} {
-	foreach c [jlib::connections] {
-	    lappend connections [jlib::connection_jid $c]
+    if {[llength [connections]] > 1} {
+	foreach c [connections] {
+	    lappend connections [connection_jid $c]
 	}
 	label $gf.lconnection -text [::msgcat::mc "Connection:"]
-	ComboBox $gf.connection -textvariable [namespace current]::gra_connid \
+	ComboBox $gf.connection -textvariable [namespace current]::gra_xlib \
 				-values $connections -editable 0 \
 				-modifycmd [list [namespace current]::change_groups \
 						 $gf.rostergroup]
@@ -412,18 +407,18 @@
 }
 
 proc conferences::change_groups {combo args} {
-    variable gra_connid
+    variable gra_xlib
 
-    foreach connid [jlib::connections] {
-        if {[jlib::connection_jid $connid] == $gra_connid} {
-	    $combo configure -values [get_groups $connid]
+    foreach xlib [connections] {
+        if {[connection_jid $xlib] == $gra_xlib} {
+	    $combo configure -values [get_groups $xlib]
 	    return
 	}
     }
 }
 
-proc conferences::get_groups {connid} {
-    return [roster::get_groups $connid \
+proc conferences::get_groups {xlib} {
+    return [roster::get_groups $xlib \
 		-nested $::ifacetk::roster::options(nested) \
 		-delimiter $::ifacetk::roster::options(nested_delimiter) \
 		-undefined 0]
@@ -436,7 +431,7 @@
     variable gra_nick
     variable gra_password
     variable gra_autojoin
-    variable gra_connid
+    variable gra_xlib
     variable gra_rostergroup
 
     destroy $gw
@@ -448,22 +443,22 @@
 	set groups [list $gra_rostergroup]
     }
 
-    foreach c [jlib::connections] {
-	if {[jlib::connection_jid $c] == $gra_connid} {
-	    set connid $c
+    foreach c [connections] {
+	if {[connection_jid $c] == $gra_xlib} {
+	    set xlib $c
 	}
     }
-    if {![info exists connid]} {
+    if {![info exists xlib]} {
 	# Disconnect while dialog is opened
 	return
     }
 
-    if {[info exists bookmarks($connid,jid,$jid)]} {
-	update_bookmark $connid $jid -name $gra_group -nick $gra_nick \
+    if {[info exists bookmarks($xlib,jid,$jid)]} {
+	update_bookmark $xlib $jid -name $gra_group -nick $gra_nick \
 			-password $gra_password -autojoin $gra_autojoin \
 			-groups $groups
     } else {
-	add_bookmark $connid $jid -name $gra_group -nick $gra_nick \
+	add_bookmark $xlib $jid -name $gra_group -nick $gra_nick \
 		     -password $gra_password -autojoin $gra_autojoin \
 		     -groups $groups
     }
@@ -474,10 +469,10 @@
 #   Add bookmark to roster
 #
 
-proc conferences::add_bookmark {connid jid args} {
+proc conferences::add_bookmark {xlib jid args} {
     variable bookmarks
 
-    if {[info exists bookmarks($connid,jid,$jid)]} return
+    if {[info exists bookmarks($xlib,jid,$jid)]} return
 
     foreach {key val} $args {
 	switch -- $key {
@@ -505,18 +500,18 @@
 	set groups {}
     }
 
-    set bookmarks($connid,jid,$jid) $jid
-    set bookmarks($connid,name,$jid) $name
-    set bookmarks($connid,nick,$jid) $nick
-    set bookmarks($connid,password,$jid) $password
-    set bookmarks($connid,autojoin,$jid) $autojoin
-    set bookmarks($connid,groups,$jid) $groups
-    set bookmarks($connid,hasgroups,$jid) 1
+    set bookmarks($xlib,jid,$jid) $jid
+    set bookmarks($xlib,name,$jid) $name
+    set bookmarks($xlib,nick,$jid) $nick
+    set bookmarks($xlib,password,$jid) $password
+    set bookmarks($xlib,autojoin,$jid) $autojoin
+    set bookmarks($xlib,groups,$jid) $groups
+    set bookmarks($xlib,hasgroups,$jid) 1
 
     # TODO should we remove $jid from the roster if it is here?
-    client:roster_push $connid $jid $name $groups bookmark ""
-    roster::override_category_and_subtype $connid $jid conference ""
-    store_bookmarks $connid
+    client:roster_push $xlib $jid $name $groups bookmark ""
+    roster::override_category_and_subtype $xlib $jid conference ""
+    store_bookmarks $xlib
 }
 
 ###############################################################################
@@ -524,7 +519,7 @@
 #   Update bookmark in roster
 #
 
-proc conferences::update_bookmark {connid jid args} {
+proc conferences::update_bookmark {xlib jid args} {
     variable bookmarks
 
     set store 0
@@ -539,31 +534,31 @@
 	}
     }
 
-    if {[info exists name] && $name != $bookmarks($connid,name,$jid)} {
-	set bookmarks($connid,name,$jid) $name
+    if {[info exists name] && $name != $bookmarks($xlib,name,$jid)} {
+	set bookmarks($xlib,name,$jid) $name
 	set store 1
     }
-    if {[info exists nick] && $nick != $bookmarks($connid,nick,$jid)} {
-	set bookmarks($connid,nick,$jid) $nick
+    if {[info exists nick] && $nick != $bookmarks($xlib,nick,$jid)} {
+	set bookmarks($xlib,nick,$jid) $nick
 	set store 1
     }
-    if {[info exists password] && $password != $bookmarks($connid,password,$jid)} {
-	set bookmarks($connid,password,$jid) $password
+    if {[info exists password] && $password != $bookmarks($xlib,password,$jid)} {
+	set bookmarks($xlib,password,$jid) $password
 	set store 1
     }
-    if {[info exists autojoin] && $autojoin != $bookmarks($connid,autojoin,$jid)} {
-	set bookmarks($connid,autojoin,$jid) $autojoin
+    if {[info exists autojoin] && $autojoin != $bookmarks($xlib,autojoin,$jid)} {
+	set bookmarks($xlib,autojoin,$jid) $autojoin
 	set store 1
     }
-    if {[info exists groups] && [lsort $groups] != [lsort $bookmarks($connid,groups,$jid)]} {
-	set bookmarks($connid,groups,$jid) $groups
+    if {[info exists groups] && [lsort $groups] != [lsort $bookmarks($xlib,groups,$jid)]} {
+	set bookmarks($xlib,groups,$jid) $groups
 	set store 1
     }
     if {$store} {
-	client:roster_push $connid $jid $bookmarks($connid,name,$jid) \
-	    $bookmarks($connid,groups,$jid) bookmark ""
-	roster::override_category_and_subtype $connid $jid conference ""
-	store_bookmarks $connid
+	client:roster_push $xlib $jid $bookmarks($xlib,name,$jid) \
+	    $bookmarks($xlib,groups,$jid) bookmark ""
+	roster::override_category_and_subtype $xlib $jid conference ""
+	store_bookmarks $xlib
     }
 }
 
@@ -572,14 +567,14 @@
 #   Add or update item in roster
 #
 
-proc conferences::send_bookmark {connid jid} {
+proc conferences::send_bookmark {xlib jid} {
 
-    if {[roster::itemconfig $connid $jid -subsc] != "bookmark"} return
+    if {[roster::itemconfig $xlib $jid -subsc] != "bookmark"} return
 
-    set groups [roster::itemconfig $connid $jid -group]
+    set groups [roster::itemconfig $xlib $jid -group]
 
-    add_bookmark $connid $jid -groups $groups
-    update_bookmark $connid $jid -groups $groups
+    add_bookmark $xlib $jid -groups $groups
+    update_bookmark $xlib $jid -groups $groups
 
     return stop
 }
@@ -591,26 +586,26 @@
 #   Remove bookmark from roster
 #
 
-proc conferences::remove_bookmark {connid jid} {
+proc conferences::remove_bookmark {xlib jid} {
     variable bookmarks
 
-    if {[roster::itemconfig $connid $jid -subsc] != "bookmark"} return
+    if {[roster::itemconfig $xlib $jid -subsc] != "bookmark"} return
 
-    if {![info exists bookmarks($connid,jid,$jid)]} return
+    if {![info exists bookmarks($xlib,jid,$jid)]} return
 
-    client:roster_push $connid $jid $bookmarks($connid,name,$jid) \
-		       $bookmarks($connid,groups,$jid) \
+    client:roster_push $xlib $jid $bookmarks($xlib,name,$jid) \
+		       $bookmarks($xlib,groups,$jid) \
 		       remove ""
 
-    catch { unset bookmarks($connid,jid,$jid) }
-    catch { unset bookmarks($connid,name,$jid) }
-    catch { unset bookmarks($connid,nick,$jid) }
-    catch { unset bookmarks($connid,password,$jid) }
-    catch { unset bookmarks($connid,autojoin,$jid) }
-    catch { unset bookmarks($connid,groups,$jid) }
-    catch { unset bookmarks($connid,hasgroups,$jid) }
+    catch { unset bookmarks($xlib,jid,$jid) }
+    catch { unset bookmarks($xlib,name,$jid) }
+    catch { unset bookmarks($xlib,nick,$jid) }
+    catch { unset bookmarks($xlib,password,$jid) }
+    catch { unset bookmarks($xlib,autojoin,$jid) }
+    catch { unset bookmarks($xlib,groups,$jid) }
+    catch { unset bookmarks($xlib,hasgroups,$jid) }
 
-    store_bookmarks $connid
+    store_bookmarks $xlib
 
     return stop
 }
@@ -623,14 +618,14 @@
 #   Rename group in roster bookmarks
 #
 
-proc conferences::rename_group {connid name new_name} {
+proc conferences::rename_group {xlib name new_name} {
     variable bookmarks
     
     set store 0
-    foreach idx [array names bookmarks $connid,jid,*] {
+    foreach idx [array names bookmarks $xlib,jid,*] {
 	set jid $bookmarks($idx)
    
-	set groups $bookmarks($connid,groups,$jid)
+	set groups $bookmarks($xlib,groups,$jid)
 	if {[lcontain $groups $name] || \
 		($name == $roster::undef_group_name && $groups == {})} {
 	    set idx [lsearch -exact $groups $name]
@@ -640,15 +635,15 @@
 		set groups [lreplace $groups $idx $idx]
 	    }
 	    set groups [lrmdups $groups]
-	    client:roster_push $connid $jid $bookmarks($connid,name,$jid) \
+	    client:roster_push $xlib $jid $bookmarks($xlib,name,$jid) \
 			       $groups bookmark ""
-	    roster::override_category_and_subtype $connid $jid conference ""
-	    set bookmarks($connid,groups,$jid) $groups
+	    roster::override_category_and_subtype $xlib $jid conference ""
+	    set bookmarks($xlib,groups,$jid) $groups
 	    set store 1
 	}
     }
     if {$store} {
-	store_bookmarks $connid
+	store_bookmarks $xlib
     }
 }
 
@@ -660,42 +655,42 @@
 #   Remove group name from roster bookmarks
 #
 
-proc conferences::remove_bookmarks_group {connid name} {
+proc conferences::remove_bookmarks_group {xlib name} {
     variable bookmarks
 
     set store 0
-    foreach idx [array names bookmarks $connid,jid,*] {
+    foreach idx [array names bookmarks $xlib,jid,*] {
 	set jid $bookmarks($idx)
 
-	set groups $bookmarks($connid,groups,$jid)
+	set groups $bookmarks($xlib,groups,$jid)
 	if {(([llength $groups] == 1) && [lcontain $groups $name]) || \
 		(($name == $roster::undef_group_name) && ($groups == {}))} {
 	    
-	    client:roster_push $connid $jid $bookmarks($connid,name,$jid) \
+	    client:roster_push $xlib $jid $bookmarks($xlib,name,$jid) \
 			       $groups remove ""
 
-	    catch { unset bookmarks($connid,jid,$jid) }
-	    catch { unset bookmarks($connid,name,$jid) }
-	    catch { unset bookmarks($connid,nick,$jid) }
-	    catch { unset bookmarks($connid,password,$jid) }
-	    catch { unset bookmarks($connid,autojoin,$jid) }
-	    catch { unset bookmarks($connid,groups,$jid) }
+	    catch { unset bookmarks($xlib,jid,$jid) }
+	    catch { unset bookmarks($xlib,name,$jid) }
+	    catch { unset bookmarks($xlib,nick,$jid) }
+	    catch { unset bookmarks($xlib,password,$jid) }
+	    catch { unset bookmarks($xlib,autojoin,$jid) }
+	    catch { unset bookmarks($xlib,groups,$jid) }
 	    
 	    set store 1
 	} elseif {[lcontain $groups $name]} {
 	    set idx [lsearch -exact $groups $name]
 	    set groups [lreplace $groups $idx $idx]
 	    
-	    client:roster_push $connid $jid $bookmarks($connid,name,$jid) \
+	    client:roster_push $xlib $jid $bookmarks($xlib,name,$jid) \
 			       $groups bookmark ""
-	    roster::override_category_and_subtype $connid $jid conference ""
-	    set bookmarks($connid,groups,$jid) $groups
+	    roster::override_category_and_subtype $xlib $jid conference ""
+	    set bookmarks($xlib,groups,$jid) $groups
 	    
 	    set store 1
 	}
     }
     if {$store} {
-	store_bookmarks $connid
+	store_bookmarks $xlib
     }
 }
 
@@ -707,17 +702,17 @@
 #   Join group on roster item doubleclick
 #
 
-proc conferences::join_group {connid jid} {
+proc conferences::join_group {xlib jid} {
     variable bookmarks
     
     set args {}
-    if {$bookmarks($connid,nick,$jid) != ""} {
-	lappend args -nick $bookmarks($connid,nick,$jid)
+    if {$bookmarks($xlib,nick,$jid) != ""} {
+	lappend args -nick $bookmarks($xlib,nick,$jid)
     }
-    if {$bookmarks($connid,password,$jid) != ""} {
-	lappend args -password $bookmarks($connid,password,$jid)
+    if {$bookmarks($xlib,password,$jid) != ""} {
+	lappend args -password $bookmarks($xlib,password,$jid)
     }
-    eval [list ::join_group $jid -connection $connid] $args
+    eval [list ::join_group $xlib $jid] $args
 }
 
 ###############################################################################
@@ -725,21 +720,21 @@
 #   Join group during autojoin
 #
 
-proc conferences::autojoin_group {connid jid} {
+proc conferences::autojoin_group {xlib jid} {
     variable bookmarks
     global gr_nick
     
-    if {$bookmarks($connid,nick,$jid) != ""} {
-	set nick $bookmarks($connid,nick,$jid)
+    if {$bookmarks($xlib,nick,$jid) != ""} {
+	set nick $bookmarks($xlib,nick,$jid)
     } else {
 	set nick [get_group_nick $jid $gr_nick]
     }
-    if {$bookmarks($connid,password,$jid) != ""} {
-	set password $bookmarks($connid,password,$jid)
+    if {$bookmarks($xlib,password,$jid) != ""} {
+	set password $bookmarks($xlib,password,$jid)
     } else {
 	set password ""
     }
-    after idle [list muc::join_group $connid $jid $nick $password]
+    after idle [list muc::join_group $xlib $jid $nick $password]
 }
 
 ###############################################################################
@@ -747,14 +742,14 @@
 #   Autojoin groups
 #
 
-proc conferences::autojoin_groups {connid} {
+proc conferences::autojoin_groups {xlib} {
     variable bookmarks
 
-    foreach idx [array names bookmarks $connid,jid,*] {
+    foreach idx [array names bookmarks $xlib,jid,*] {
 	set jid $bookmarks($idx)
-	set chatid [chat::chatid $connid $jid]
-	if {$bookmarks($connid,autojoin,$jid) && ![chat::is_opened $chatid]} {
-	    autojoin_group $connid $jid
+	set chatid [chat::chatid $xlib $jid]
+	if {$bookmarks($xlib,autojoin,$jid) && ![chat::is_opened $chatid]} {
+	    autojoin_group $xlib $jid
 	}
     }
 }
@@ -764,28 +759,27 @@
 #   "Join" item in roster conference popup menu
 #
 
-proc conferences::popup_menu {m connid jid} {
+proc conferences::popup_menu {m xlib jid} {
     variable bookmarks
 
     set args {}
-    if {[roster::itemconfig $connid $jid -subsc] == "bookmark"} {
-	if {$bookmarks($connid,nick,$jid) != ""} {
-	    lappend args -nick $bookmarks($connid,nick,$jid)
+    if {[roster::itemconfig $xlib $jid -subsc] == "bookmark"} {
+	if {$bookmarks($xlib,nick,$jid) != ""} {
+	    lappend args -nick $bookmarks($xlib,nick,$jid)
 	}
-	if {$bookmarks($connid,password,$jid) != ""} {
-	    lappend args -password $bookmarks($connid,password,$jid)
+	if {$bookmarks($xlib,password,$jid) != ""} {
+	    lappend args -password $bookmarks($xlib,password,$jid)
 	}
     }
 
     $m add command -label [::msgcat::mc "Join..."] \
-	-command [list eval [list join_group_dialog \
+	-command [list eval [list join_group_dialog $xlib \
 				  -server [server_from_jid $jid] \
-				  -group [node_from_jid $jid] \
-				  -connection $connid] \
+				  -group [node_from_jid $jid]] \
 				  $args]
 
     # TODO: Check for real MUC? Move to muc.tcl?
-    muc::add_muc_menu_items $m [chat::chatid $connid $jid] end
+    muc::add_muc_menu_items $m [chat::chatid $xlib $jid] end
 }   
 
 hook::add roster_conference_popup_menu_hook \
@@ -796,16 +790,15 @@
 #   Roster doubleclick
 #
 
-proc conferences::roster_doubleclick {connid jid category subtype} {
+proc conferences::roster_doubleclick {xlib jid category subtype} {
     switch -- $category {
 	conference {
-	    if {[roster::itemconfig $connid $jid -subsc] == "bookmark"} {
-		join_group $connid $jid
+	    if {[roster::itemconfig $xlib $jid -subsc] == "bookmark"} {
+		join_group $xlib $jid
 	    } else {
 		global gr_nick
-		::join_group $jid \
-		    -nick [get_group_nick $jid $gr_nick] \
-		    -connection $connid
+		::join_group $xlib $jid \
+		    -nick [get_group_nick $jid $gr_nick]
 	    }
 	    return stop
 	}
@@ -833,14 +826,14 @@
 #   Edit roster item
 #
 
-proc conferences::edit_item_setup {f connid jid} {
+proc conferences::edit_item_setup {f xlib jid} {
     variable egra_name
     variable egra_nick
     variable egra_password
     variable egra_autojoin
     variable bookmarks
 
-    if {[roster::itemconfig $connid $jid -subsc] != "bookmark"} return
+    if {[roster::itemconfig $xlib $jid -subsc] != "bookmark"} return
 
     set tf [TitleFrame $f.prop \
 		-text [::msgcat::mc "Edit properties for %s" $jid]]
@@ -852,15 +845,15 @@
     }
     set g [$tf getframe]
 
-    set egra_name $bookmarks($connid,name,$jid)
-    set egra_autojoin $bookmarks($connid,autojoin,$jid)
-    if {[info exists bookmarks($connid,nick,$jid)]} {
-        set egra_nick $bookmarks($connid,nick,$jid)
+    set egra_name $bookmarks($xlib,name,$jid)
+    set egra_autojoin $bookmarks($xlib,autojoin,$jid)
+    if {[info exists bookmarks($xlib,nick,$jid)]} {
+        set egra_nick $bookmarks($xlib,nick,$jid)
     } else {
         set egra_nick ""
     }
-    if {[info exists bookmarks($connid,password,$jid)]} {
-        set egra_password $bookmarks($connid,password,$jid)
+    if {[info exists bookmarks($xlib,password,$jid)]} {
+        set egra_password $bookmarks($xlib,password,$jid)
     } else {
         set egra_password ""
     }
@@ -891,15 +884,15 @@
 hook::add roster_itemedit_setup_hook \
     [namespace current]::conferences::edit_item_setup
 
-proc conferences::commit_bookmark_changes {connid jid groups} {
+proc conferences::commit_bookmark_changes {xlib jid groups} {
     variable egra_name
     variable egra_nick
     variable egra_password
     variable egra_autojoin
 
-    if {[roster::itemconfig $connid $jid -subsc] != "bookmark"} return
+    if {[roster::itemconfig $xlib $jid -subsc] != "bookmark"} return
 
-    plugins::conferences::update_bookmark $connid $jid \
+    plugins::conferences::update_bookmark $xlib $jid \
 	-name $egra_name -nick $egra_nick -password $egra_password \
 	-autojoin $egra_autojoin -groups $groups
 
@@ -912,12 +905,12 @@
 ###############################################################################
 
 proc conferences::disco_node_menu_setup {m bw tnode data parentdata} {
-    lassign $data type connid jid node
-    lassign $parentdata ptype pconnid pjid pnode
+    lassign $data type xlib jid node
+    lassign $parentdata ptype pxlib pjid pnode
     switch -- $type {
 	item {
-	    set identities [disco::get_jid_identities $connid $jid $node]
-	    set pidentities [disco::get_jid_identities $pconnid $pjid $pnode]
+	    set identities [disco::get_jid_identities $xlib $jid $node]
+	    set pidentities [disco::get_jid_identities $pxlib $pjid $pnode]
 
 	    # JID with resource is not a room JID
 	    if {[node_and_server_from_jid $jid] != $jid} return
@@ -927,12 +920,11 @@
 	    }
 
 	    foreach id $identities {
-		if {[jlib::wrapper:getattr $id category] == "conference"} {
+		if {[::xmpp::xml::getAttr $id category] == "conference"} {
 		    $m add command -label [::msgcat::mc "Add conference to roster..."] \
-			-command [list [namespace current]::add_conference_dialog \
+			-command [list [namespace current]::add_conference_dialog $xlib \
 				       -group [node_from_jid $jid] \
-				       -server [server_from_jid $jid] \
-				       -connection $connid]
+				       -server [server_from_jid $jid]]
 		    break
 		}
 	    }

Modified: trunk/tkabber/plugins/roster/fetch_nicknames.tcl
===================================================================
--- trunk/tkabber/plugins/roster/fetch_nicknames.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/roster/fetch_nicknames.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -3,57 +3,55 @@
 
 namespace eval fetch_nickname {}
 
-proc fetch_nickname::service_request {connid service} {
-    foreach jid [::roster::get_jids $connid] {
+proc fetch_nickname::service_request {xlib service} {
+    foreach jid [::roster::get_jids $xlib] {
 	if {[server_from_jid $jid] == [server_from_jid $service]} {
-	    user_request $connid $jid
+	    user_request $xlib $jid
 	}
     }
 }
 
-proc fetch_nickname::request_group_nicks {connid group args} {
-    foreach jid [eval [list ::roster::get_group_jids $connid $group] $args] {
-	if {[string equal [::roster::itemconfig $connid $jid -category] user]} {
-	    user_request $connid $jid
+proc fetch_nickname::request_group_nicks {xlib group args} {
+    foreach jid [eval [list ::roster::get_group_jids $xlib $group] $args] {
+	if {[string equal [::roster::itemconfig $xlib $jid -category] user]} {
+	    user_request $xlib $jid
 	}
     }
 }
 
-proc fetch_nickname::user_request {connid jid} {
-    jlib::send_iq get \
-	[jlib::wrapper:createtag vCard \
-	     -vars [list xmlns vcard-temp]] \
+proc fetch_nickname::user_request {xlib jid} {
+    ::xmpp::sendIQ $xlib get \
+	-query [::xmpp::xml::create vCard -xmlns vcard-temp] \
 	-to $jid \
-	-connection $connid \
-	-command [list [namespace current]::parse_result $connid $jid]
+	-command [list [namespace current]::parse_result $xlib $jid]
 }
 
-proc fetch_nickname::parse_result {connid jid res child} {
-    if {$res != "OK"} return
+proc fetch_nickname::parse_result {xlib jid status xml} {
+    if {$status != "ok"} return
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
+    ::xmpp::xml::split $xml tag xmlns attrs cdata subels
 
-    foreach item $children {
+    foreach item $subels {
 	userinfo::parse_vcard_item $jid $item
     }
 
     if {[info exists ::userinfo::userinfo(nickname,$jid)] && \
-	    ![cequal $::userinfo::userinfo(nickname,$jid) ""]} {
-	roster::itemconfig $connid $jid \
+	    ![string equal $::userinfo::userinfo(nickname,$jid) ""]} {
+	roster::itemconfig $xlib $jid \
 			   -name $::userinfo::userinfo(nickname,$jid)
-	roster::send_item $connid $jid
+	roster::send_item $xlib $jid
     }
 }
 
-proc fetch_nickname::extend_user_menu {m connid jid} {
-    set rjid [roster::find_jid $connid $jid]
+proc fetch_nickname::extend_user_menu {m xlib jid} {
+    set rjid [roster::find_jid $xlib $jid]
     if {$rjid == ""} {
 	set state disabled
     } else {
 	set state normal
     }
     $m add command -label [::msgcat::mc "Fetch nickname"] \
-	-command [list [namespace current]::user_request $connid $rjid] \
+	-command [list [namespace current]::user_request $xlib $rjid] \
 	-state $state
 }
 
@@ -62,26 +60,26 @@
 hook::add roster_jid_popup_menu_hook \
     [namespace current]::fetch_nickname::extend_user_menu 73
 
-proc fetch_nickname::extend_service_menu {m connid jid} {
-    set rjid [roster::find_jid $connid $jid]
+proc fetch_nickname::extend_service_menu {m xlib jid} {
+    set rjid [roster::find_jid $xlib $jid]
     if {$rjid == ""} {
 	set state disabled
     } else {
 	set state normal
     }
     $m add command -label [::msgcat::mc "Fetch user nicknames"] \
-	-command [list [namespace current]::service_request $connid $rjid] \
+	-command [list [namespace current]::service_request $xlib $rjid] \
 	-state $state
 }
 
 hook::add roster_service_popup_menu_hook \
     [namespace current]::fetch_nickname::extend_service_menu 73
 
-proc fetch_nickname::extend_group_menu {m connid name} {
+proc fetch_nickname::extend_group_menu {m xlib name} {
     variable ::ifacetk::roster::options
     $m add command \
 	-label [::msgcat::mc "Fetch nicknames of all users in group"] \
-	-command [list [namespace current]::request_group_nicks $connid $name \
+	-command [list [namespace current]::request_group_nicks $xlib $name \
 	    -nested $options(nested) \
 	    -delimiter $options(nested_delimiter)]
 }

Modified: trunk/tkabber/plugins/roster/roster_delimiter.tcl
===================================================================
--- trunk/tkabber/plugins/roster/roster_delimiter.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/roster/roster_delimiter.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -12,8 +12,8 @@
 # Retrieving nested groups delimiter
 #
 
-proc delimiter::request {connid fallback args} {
-    debugmsg plugins "delimiter::request $connid $fallback $args"
+proc delimiter::request {xlib fallback args} {
+    debugmsg plugins "delimiter::request $xlib $fallback $args"
     
     set command ""
     foreach {key val} $args {
@@ -22,30 +22,29 @@
 	}
     }
 
-    private::retrieve [list [jlib::wrapper:createtag roster \
-				 -vars [list xmlns $::NS(delimiter)]]] \
+    private::retrieve $xlib [list [::xmpp::xml::create roster \
+					    -xmlns $::NS(delimiter)]] \
 	-command [list [namespace current]::request_result \
-		       $connid $fallback $command] \
-	-connection $connid
+		       $xlib $fallback $command]
 }
 
-proc delimiter::request_result {connid fallback command res child} {
-    debugmsg plugins "delimiter::request_result $connid $res"
+proc delimiter::request_result {xlib fallback command status xml} {
+    debugmsg plugins "delimiter::request_result $xlib $status"
 
     set delimiter $fallback
 
-    if {$res == "OK"} {
-	foreach ch $child {
-	    jlib::wrapper:splitxml $ch tag1 vars1 isempty1 cdata1 children1
+    if {$status == "ok"} {
+	foreach item $xml {
+	    ::xmpp::xml::split $item tag xmlns attrs cdata subels
 
-	    if {[jlib::wrapper:getattr $vars1 xmlns] == $NS(delimiter)} {
-		set delimiter $cdata1
+	    if {$xmlns == $NS(delimiter)} {
+		set delimiter $cdata
 	    }
 	}
     }
 
     if {$command != ""} {
-	eval $command [list $connid $delimiter]
+	eval $command [list $xlib $delimiter]
     }
 }
 
@@ -54,8 +53,8 @@
 # Storing nested groups delimiter
 #
 
-proc delimiter::store {connid delimiter args} {
-    debugmsg plugins "delimiter::store $connid $delimiter $args"
+proc delimiter::store {xlib delimiter args} {
+    debugmsg plugins "delimiter::store $xlib $delimiter $args"
 
     set command ""
     foreach {key val} $args {
@@ -64,19 +63,17 @@
 	}
     }
 
-    private::store [list [jlib::wrapper:createtag roster \
-			      -vars [list xmlns $::NS(delimiter)] \
-			      -chdata $delimiter]] \
-	-command [list [namespace current]::store_result $connid $command] \
-	-connection $connid
-    
+    private::store $xlib [list [::xmpp::xml::create roster \
+					-xmlns $::NS(delimiter) \
+					-cdata $delimiter]] \
+	-command [list [namespace current]::store_result $xlib $command]
 }
 
-proc delimiter::store_result {connid command res child} {
-    debugmsg plugins "delimiter::store_result $connid $res"
+proc delimiter::store_result {xlib command status xml} {
+    debugmsg plugins "delimiter::store_result $xlib $status"
     
     if {$command != ""} {
-	eval $command [list $res $child]
+	eval $command [list $status $xml]
     }
 }
 

Modified: trunk/tkabber/plugins/roster/rosterx.tcl
===================================================================
--- trunk/tkabber/plugins/roster/rosterx.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/roster/rosterx.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -7,27 +7,26 @@
 
 ###############################################################################
 
-proc rosterx::process_x {rowvar bodyvar f x connid from id type replyP} {
+proc rosterx::process_x {rowvar bodyvar f x xlib from id type replyP} {
     upvar 2 $rowvar row
     upvar 2 $bodyvar body
 
     set rosterx 0
     foreach xa $x {
-	jlib::wrapper:splitxml $xa tag vars isempty chdata children
+	::xmpp::xml::split $xa tag xmlns attrs cdata subels
 
-	set xmlns [jlib::wrapper:getattr $vars xmlns]
 	switch -- $xmlns \
 	    $::NS(rosterx) {
 		set rosterx 1
-		foreach child $children {
-		    process_x_rosterx $f $child $row $connid $from
+		foreach subel $subels {
+		    process_x_rosterx $f $subel $row $xlib $from
 		    incr row
 		}
 	    } \
 	    $::NS(xroster) {
 		if {$rosterx} break
-		foreach child $children {
-		    process_x_xroster $f $child $row $connid $from
+		foreach subel $subels {
+		    process_x_xroster $f $subel $row $xlib $from
 		    incr row
 		}
 	    }
@@ -40,12 +39,12 @@
 
 ###############################################################################
 
-proc rosterx::process_x_rosterx {f x row connid from} {
-    jlib::wrapper:splitxml $x tag vars isempty chdata children
+proc rosterx::process_x_rosterx {f x row xlib from} {
+    ::xmpp::xml::split $x tag xmlns attrs cdata subels
 
-    set jid [jlib::wrapper:getattr $vars jid]
-    set name [jlib::wrapper:getattr $vars name]
-    set action [jlib::wrapper:getattr $vars action]
+    set jid    [::xmpp::xml::getAttr $attrs jid]
+    set name   [::xmpp::xml::getAttr $attrs name]
+    set action [::xmpp::xml::getAttr $attrs action]
 
     if {$jid == ""} return
 
@@ -57,7 +56,7 @@
 
     label $f.luser$row -text [::msgcat::mc "Attached user:"]
     set cb [button $f.user$row -text $desc \
-                -command [list [namespace current]::process_user $connid $jid \
+                -command [list [namespace current]::process_user $xlib $jid \
 			       $name "$from asked me to add you to my roster."]]
     grid $f.luser$row -row $row -column 0 -sticky e
     grid $f.user$row  -row $row -column 1 -sticky ew
@@ -65,11 +64,11 @@
 
 ###############################################################################
 
-proc rosterx::process_x_xroster {f x row connid from} {
-    jlib::wrapper:splitxml $x tag vars isempty chdata children
+proc rosterx::process_x_xroster {f x row xlib from} {
+    ::xmpp::xml::split $x tag xmlns attrs cdata subels
 
-    set jid [jlib::wrapper:getattr $vars jid]
-    set name [jlib::wrapper:getattr $vars name]
+    set jid  [::xmpp::xml::getAttr $attrs jid]
+    set name [::xmpp::xml::getAttr $attrs name]
 
     if {$jid == ""} return
 
@@ -81,7 +80,7 @@
 
     label $f.luser$row -text [::msgcat::mc "Attached user:"]
     set cb [button $f.user$row -text $desc \
-                -command [list [namespace current]::process_user $connid $jid \
+                -command [list [namespace current]::process_user $xlib $jid \
                                $name "$from asked me to add you to my roster."]]
     grid $f.luser$row -row $row -column 0 -sticky e
     grid $f.user$row  -row $row -column 1 -sticky ew
@@ -89,31 +88,29 @@
 
 ###############################################################################
 
-proc rosterx::process_user {connid jid name body} {
-    jlib::send_presence -to $jid \
-			-type subscribe \
-			-stat $body \
-			-connection $connid
+proc rosterx::process_user {xlib jid name body} {
+    ::xmpp::sendPresence $xlib -to $jid \
+			       -type subscribe \
+			       -status $body
 
     set vars [list jid $jid]
     if {$name != ""} {
 	lappend vars name $name
     }
 
-    jlib::send_iq set \
-        [jlib::wrapper:createtag query \
-             -vars [list xmlns $::NS(roster)] \
-             -subtags [list [jlib::wrapper:createtag item \
-                                     -vars $vars]]] \
-	-connection $connid
+    ::xmpp::sendIQ $xlib set \
+        -query [::xmpp::xml::create query \
+			-xmlns $::NS(roster) \
+			-subelement [::xmpp::xml::create item \
+					    -attrs $vars]]
 }
 
 ###############################################################################
 
-proc rosterx::send_users_dialog {connid user} {
+proc rosterx::send_users_dialog {xlib user} {
     global send_uc
 
-    set jid [get_jid_of_user $connid $user]
+    set jid [get_jid_of_user $xlib $user]
 
     if {[cequal $jid ""]} {
         set jid $user
@@ -122,8 +119,8 @@
     set gw .contacts
     catch { destroy $gw }
 
-    if {[catch { set nick [roster::get_label $connid $user] }]} {
-	if {[catch { set nick [chat::get_nick $connid \
+    if {[catch { set nick [roster::get_label $xlib $user] }]} {
+	if {[catch { set nick [chat::get_nick $xlib \
 					      $user groupchat] }]} {
 	    set nick $user
 	}
@@ -131,7 +128,7 @@
 
     set choices {}
     set balloons {}
-    foreach c [jlib::connections] {
+    foreach c [connections] {
 	foreach choice [roster::get_jids $c] {
 	    if {[roster::itemconfig $c $choice -isuser]} {
 		lappend choices [list $c $choice] [roster::get_label $c $choice]
@@ -148,7 +145,7 @@
 
     CbDialog $gw [format [::msgcat::mc "Send contacts to %s"] $nick] \
 	[list [::msgcat::mc "Send"] \
-	      [list [namespace current]::send_users $gw $connid $jid] \
+	      [list [namespace current]::send_users $gw $xlib $jid] \
 	      [::msgcat::mc "Cancel"] \
 	      [list destroy $gw]] \
 	send_uc $choices $balloons
@@ -156,10 +153,10 @@
 
 ###############################################################################
 
-proc rosterx::add_menu_item {m connid jid} {
+proc rosterx::add_menu_item {m xlib jid} {
     $m add command \
 	   -label [::msgcat::mc "Send users..."] \
-           -command [list [namespace current]::send_users_dialog $connid $jid]
+           -command [list [namespace current]::send_users_dialog $xlib $jid]
 }
 
 hook::add roster_create_groupchat_user_menu_hook \
@@ -175,7 +172,7 @@
 
 ###############################################################################
 
-proc rosterx::send_users {gw connid jid} {
+proc rosterx::send_users {gw xlib jid} {
     global send_uc
 
     set sf [$gw getframe].sw.sf
@@ -197,15 +194,14 @@
         append body "\n$nick - xmpp:$uc"
     }
 
-    message::send_msg $jid -type normal -body $body \
+    message::send_msg $xlib $jid -type normal -body $body \
 	-xlist [list \
-		    [jlib::wrapper:createtag x \
-			 -vars [list xmlns $::NS(rosterx)] \
-	                 -subtags $subtags] \
-		    [jlib::wrapper:createtag x \
-			 -vars [list xmlns $::NS(xroster)] \
-	                 -subtags $subtags]] \
-	-connection $connid
+		    [::xmpp::xml::create x \
+			    -xmlns $::NS(rosterx) \
+			    -subelements $subtags] \
+		    [::xmpp::xml::create x \
+			    -xmlns $::NS(xroster) \
+			    -subelements $subtags]]
 }
 
 ###############################################################################

Modified: trunk/tkabber/plugins/search/logger.tcl
===================================================================
--- trunk/tkabber/plugins/search/logger.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/search/logger.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -17,7 +17,7 @@
     pack forget $sf
 }
 
-proc search::logger::setup_panel {connid jid w} {
+proc search::logger::setup_panel {xlib jid w} {
     set tw $w.log
 
     $tw mark set sel_start end

Modified: trunk/tkabber/plugins/si/ibb.tcl
===================================================================
--- trunk/tkabber/plugins/si/ibb.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/si/ibb.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -16,27 +16,24 @@
 
     set_status [::msgcat::mc "Opening IBB connection"]
 
-    jlib::send_iq set \
-	[jlib::wrapper:createtag open \
-	     -vars [list xmlns $::NS(ibb) \
-			 sid $state(id) \
-			 block-size $chunk_size]] \
+    ::xmpp::sendIQ $state(xlib) set \
+	-query [::xmpp::xml::create open \
+			-xmlns $::NS(ibb) \
+			-attrs [list sid $state(id) \
+				     block-size $chunk_size]] \
 	-to $state(jid) \
-	-connection $state(connid) \
 	-command [list [namespace current]::recv_connect_response \
 		       $stream $command]
 }
 
-proc ibb::recv_connect_response {stream command res child} {
+proc ibb::recv_connect_response {stream command status xml} {
     upvar #0 $stream state
 
-    if {$res != "OK"} {
-	uplevel #0 $command [list [list 0 [error_to_string $child]]]
+    if {$status != "ok"} {
+	uplevel #0 $command [list [list 0 [error_to_string $xml]]]
 	return
     }
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
-
     set state(seq) 0
     uplevel #0 $command 1
 }
@@ -48,13 +45,12 @@
 proc ibb::send_data {stream data command} {
     upvar #0 $stream state
 
-    jlib::send_msg $state(jid) \
-	-xlist [list [jlib::wrapper:createtag data \
-			  -vars [list xmlns $::NS(ibb) \
-				      sid $state(id) \
-				      seq $state(seq)] \
-			  -chdata [base64::encode $data]]] \
-	-connection $state(connid)
+    ::xmpp::sendMessage $state(xlib) $state(jid) \
+	-xlist [list [::xmpp::xml::create data \
+			    -xmlns $::NS(ibb) \
+			    -attrs [list sid $state(id) \
+					 seq $state(seq)] \
+			    -cdata [base64::encode $data]]]
 
     set state(seq) [expr {($state(seq) + 1) % 65536}]
 
@@ -66,21 +62,22 @@
 proc ibb::close {stream} {
     upvar #0 $stream state
 
-    jlib::send_iq set \
-	[jlib::wrapper:createtag close \
-	     -vars [list xmlns $::NS(ibb) \
-			 sid $state(id)]] \
-	-to $state(jid) \
-	-connection $state(connid)
+    ::xmpp::sendIQ $state(xlib) set \
+	-query [::xmpp::xml::create close \
+			-xmlns $::NS(ibb) \
+			-attrs [list sid $state(id)]] \
+	-to $state(jid)
 }
 
 ###############################################################################
 
-proc ibb::iq_set_handler {connid from lang child} {
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
+proc ibb::iq_set_handler {xlib from xml args} {
+    ::xmpp::xml::split $xml tag xmlns attrs cdata subels
 
-    set id [jlib::wrapper:getattr $vars sid]
-    if {[catch {si::in $connid $from $id} stream]} {
+    set lang [::xmpp::xml::getAttr $args -lang en]
+
+    set id [::xmpp::xml::getAttr $attrs sid]
+    if {[catch {si::in $xlib $from $id} stream]} {
 	return [list error modify bad-request \
 		     -text [::trans::trans $lang \
 					   "Stream ID has not been negotiated"]]
@@ -89,14 +86,14 @@
 
     switch -- $tag {
 	open {
-	    set state(block-size) [jlib::wrapper:getattr $vars block-size]
+	    set state(block-size) [::xmpp::xml::getAttr $attrs block-size]
 	    set state(seq) 0
 	}
 	close {
 	    si::closed $stream
 	}
 	data {
-	    set seq [jlib::wrapper:getattr $vars seq]
+	    set seq [::xmpp::xml::getAttr $attrs seq]
 	    if {$seq != $state(seq)} {
 		si::closed $stream
 		return [list error modify bad-request \
@@ -105,7 +102,7 @@
 	    } else {
 		set state(seq) [expr {($state(seq) + 1) % 65536}]
 	    }
-	    set data $chdata
+	    set data $cdata
 
 	    if {[catch {set decoded [base64::decode $data]}]} {
 		debugmsg si "IBB: WRONG DATA"
@@ -131,36 +128,33 @@
     return [list result ""]
 }
 
-iq::register_handler set "" $::NS(ibb) [namespace current]::ibb::iq_set_handler
+::xmpp::iq::register set * $::NS(ibb) [namespace current]::ibb::iq_set_handler
 
 ###############################################################################
 
-proc ibb::return_error {connid jid id error} {
+proc ibb::return_error {xlib jid id error} {
     if {$id == ""} return
 
-    jlib::send_msg $jid \
+    ::xmpp::sendMessage $xlib $jid \
 	-type error \
 	-id $id \
-	-xlist [eval stanzaerror::error $error] \
-	-connection $connid
+	-xlist [eval stanzaerror::error $error]
 }
 
 ###############################################################################
 
-proc ibb::message_handler {connid from mid type is_subject subject body \
+proc ibb::message_handler {xlib from mid type is_subject subject body \
 				 err thread priority x} {
     if {$type == "error"} return
 
     foreach item $x {
-	jlib::wrapper:splitxml $item tag vars isempty chdata children
+	::xmpp::xml::split $item tag xmlns attrs cdata subels
 
-	set xmlns [jlib::wrapper:getattr $vars xmlns]
-
 	if {[string equal $xmlns $::NS(ibb)]} {
-	    set id [jlib::wrapper:getattr $vars sid]
-	    if {[catch {si::in $connid $from $id} stream]} {
+	    set id [::xmpp::xml::getAttr $attrs sid]
+	    if {[catch {si::in $xlib $from $id} stream]} {
 		# Unknown Stream ID
-		return_error $connid $from $mid \
+		return_error $xlib $from $mid \
 			     [list modify bad-request \
 				   -text [::trans::trans \
 					      "Stream ID has not been negotiated"]]
@@ -168,12 +162,12 @@
 	    }
 
 	    upvar #0 $stream state
-	    set seq [jlib::wrapper:getattr $vars seq]
+	    set seq [::xmpp::xml::getAttr $attrs seq]
 
 	    if {$seq != $state(seq)} {
 		# Incorrect sequence number
 		si::closed $stream
-		return_error $connid $from $mid \
+		return_error $xlib $from $mid \
 			     [list modify bad-request \
 				   -text [::trans::trans \
 					      "Unexpected packet sequence number"]]
@@ -181,12 +175,12 @@
 	    }
 
 	    set state(seq) [expr {($state(seq) + 1) % 65536}]
-	    set data $chdata
+	    set data $cdata
 
 	    if {[catch {set decoded [base64::decode $data]}]} {
 		debugmsg si "IBB: WRONG DATA"
 		si::closed $stream
-		return_error $connid $from $mid \
+		return_error $xlib $from $mid \
 			     [list modify bad-request \
 				   -text [::trans::trans \
 					      "Cannot decode recieved data"]]
@@ -194,7 +188,7 @@
 		debugmsg si "IBB: RECV DATA [list $data]"
 		if {![si::recv_data $stream $decoded]} {
 		    si::closed $stream
-		    return_error $connid $from $mid \
+		    return_error $xlib $from $mid \
 				 [list cancel not-allowed \
 				       -text [::trans::trans \
 						  "File transfer is aborted"]]

Modified: trunk/tkabber/plugins/si/iqibb.tcl
===================================================================
--- trunk/tkabber/plugins/si/iqibb.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/si/iqibb.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -16,27 +16,24 @@
 
     set_status [::msgcat::mc "Opening IQ-IBB connection"]
 
-    jlib::send_iq set \
-	[jlib::wrapper:createtag open \
-	     -vars [list xmlns $::NS(iqibb) \
-			 sid $state(id) \
-			 block-size $chunk_size]] \
+    ::xmpp::sendIQ $state(xlib) set \
+	-query [::xmpp::xml::create open \
+			-xmlns $::NS(iqibb) \
+			-attrs [list sid $state(id) \
+				     block-size $chunk_size]] \
 	-to $state(jid) \
-	-connection $state(connid) \
 	-command [list [namespace current]::recv_connect_response \
 		      $stream $command]
 }
 
-proc iqibb::recv_connect_response {stream command res child} {
+proc iqibb::recv_connect_response {stream command status xml} {
     upvar #0 $stream state
 
-    if {$res != "OK"} {
-	uplevel #0 $command [list [list 0 [error_to_string $child]]]
+    if {$status != "ok"} {
+	uplevel #0 $command [list [list 0 [error_to_string $xml]]]
 	return
     }
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
-
     set state(seq) 0
     uplevel #0 $command 1
 }
@@ -48,22 +45,21 @@
 proc iqibb::send_data {stream data command} {
     upvar #0 $stream state
 
-    jlib::send_iq set \
-	[jlib::wrapper:createtag data \
-	     -vars [list xmlns $::NS(iqibb) \
-			 sid $state(id) \
-			 seq $state(seq)] \
-	     -chdata [base64::encode $data]] \
+    ::xmpp::sendIQ $state(xlib) set \
+	-query [::xmpp::xml::create data \
+			-xmlns $::NS(iqibb) \
+			-attrs [list sid $state(id) \
+				     seq $state(seq)] \
+			-cdata [base64::encode $data]] \
 	-to $state(jid) \
-	-command [list [namespace current]::send_data_ack $stream $command] \
-	-connection $state(connid)
+	-command [list [namespace current]::send_data_ack $stream $command]
 
     set state(seq) [expr {($state(seq) + 1) % 65536}]
 }
 
-proc iqibb::send_data_ack {stream command res child} {
-    if {$res != "OK"} {
-	uplevel #0 $command [list [list 0 [error_to_string $child]]]
+proc iqibb::send_data_ack {stream command status xml} {
+    if {$status != "ok"} {
+	uplevel #0 $command [list [list 0 [error_to_string $xml]]]
     } else {
 	uplevel #0 $command 1
     }
@@ -74,21 +70,22 @@
 proc iqibb::close {stream} {
     upvar #0 $stream state
 
-    jlib::send_iq set \
-	[jlib::wrapper:createtag close \
-	     -vars [list xmlns $::NS(iqibb) \
-			 sid $state(id)]] \
-	-to $state(jid) \
-	-connection $state(connid)
+    ::xmpp::sendIQ $state(xlib) set \
+	-query [::xmpp::xml::create close \
+			-xmlns $::NS(iqibb) \
+			-attrs [list sid $state(id)]] \
+	-to $state(jid)
 }
 
 ###############################################################################
 
-proc iqibb::iq_set_handler {connid from lang child} {
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
+proc iqibb::iq_set_handler {xlib from query args} {
+    ::xmpp::xml::split $query tag xmlns attrs cdata subels
 
-    set id [jlib::wrapper:getattr $vars sid]
-    if {[catch {si::in $connid $from $id} stream]} {
+    set lang [::xmpp::xml::getAttr $args -lang en]
+
+    set id [::xmpp::xml::getattr $attrs sid]
+    if {[catch {si::in $xlib $from $id} stream]} {
 	return [list error modify bad-request \
 		     -text [::trans::trans $lang \
 					   "Stream ID has not been negotiated"]]
@@ -97,14 +94,14 @@
 
     switch -- $tag {
 	open {
-	    set state(block-size) [jlib::wrapper:getattr $vars block-size]
+	    set state(block-size) [::xmpp::xml::getattr $attrs block-size]
 	    set state(seq) 0
 	}
 	close {
 	    si::closed $stream
 	}
 	data {
-	    set seq [jlib::wrapper:getattr $vars seq]
+	    set seq [::xmpp::xml::getattr $attrs seq]
 	    if {$seq != $state(seq)} {
 		si::closed $stream
 		return [list error modify bad-request \
@@ -113,7 +110,7 @@
 	    } else {
 		set state(seq) [expr {($state(seq) + 1) % 65536}]
 	    }
-	    set data $chdata
+	    set data $cdata
 
 	    if {[catch {set decoded [base64::decode $data]}]} {
 		debugmsg si "IQIBB: WRONG DATA"
@@ -136,7 +133,7 @@
     return [list result ""]
 }
 
-iq::register_handler set "" $::NS(iqibb) \
+::xmpp::iq::register set * $::NS(iqibb) \
 		     [namespace current]::iqibb::iq_set_handler
 
 ###############################################################################

Modified: trunk/tkabber/plugins/si/socks5.tcl
===================================================================
--- trunk/tkabber/plugins/si/socks5.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/si/socks5.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -47,11 +47,10 @@
 
 	if {$state(status) == 0} continue
 
-	set res [jlib::wrapper:createtag query \
-		     -vars [list xmlns $::NS(bytestreams)] \
-	     -subtags [list \
-			   [jlib::wrapper:createtag streamhost-used \
-				-vars [list jid $streamhost]]]]
+	set res [::xmpp::xml::create query \
+			-xmlns $::NS(bytestreams) \
+			-subelement [::xmpp::xml::create streamhost-used \
+					    -attrs [list jid $streamhost]]]]
 
 	return [list result $res]
     }
@@ -90,7 +89,7 @@
     }
 
     set myjid [encoding convertto utf-8 \
-		   [tolower_node_and_domain [my_jid $state(connid) $state(jid)]]]
+		   [tolower_node_and_domain [my_jid $state(xlib) $state(jid)]]]
     set hisjid [encoding convertto utf-8 [tolower_node_and_domain $state(jid)]]
     set hash [::sha1::sha1 $state(id)$hisjid$myjid]
 
@@ -162,17 +161,17 @@
     set servsock [socket -server [list [namespace current]::accept $stream] 0]
     set state(servsock) $servsock
     lassign [fconfigure $servsock -sockname] addr hostname port
-    set ip [jlib::socket_ip $state(connid)]
+    set ip [::xmpp::ip $state(xlib)]
     set myjid [encoding convertto utf-8 \
-		   [tolower_node_and_domain [my_jid $state(connid) $state(jid)]]]
+		   [tolower_node_and_domain [my_jid $state(xlib) $state(jid)]]]
     set hisjid [encoding convertto utf-8 [tolower_node_and_domain $state(jid)]]
     set hash [::sha1::sha1 $state(id)$myjid$hisjid]
     set hash_sid($hash) $state(id)
 
-    set streamhosts [list [jlib::wrapper:createtag streamhost \
-			       -vars [list jid [my_jid $state(connid) $state(jid)] \
-					   host $ip \
-					   port $port]]]
+    set streamhosts [list [::xmpp::xml::create streamhost \
+			       -attrs [list jid [my_jid $state(xlib) $state(jid)] \
+					    host $ip \
+					    port $port]]]
 
     if {!$options(enable_mediated_connection)} {
 	request $stream $streamhosts $command
@@ -196,36 +195,35 @@
     if {[lempty $proxies]} {
 	request $stream $streamhosts $command
     } else {
-	jlib::send_iq get \
-	    [jlib::wrapper:createtag query \
-		 -vars [list xmlns $::NS(bytestreams)]] \
+	::xmpp::sendIQ $state(xlib) get \
+	    -query [::xmpp::xml::create query \
+			    -xmlns $::NS(bytestreams)] \
 	    -to [lindex $proxies 0] \
 	    -command [list [namespace current]::recv_request_proxy_response \
 			   $stream $streamhosts [lrange $proxies 1 end] \
-			   $command] \
-	    -connection $state(connid)
+			   $command]
     }
 }
 
 proc socks5::initiator::recv_request_proxy_response \
      {stream streamhosts proxies command res child} {
 
-    if {$res == "DISCONNECT"} {
-	uplevel #0 $command [list [list 0 [::msgcat::mc "Disconnected"]]]
+    if {$res == "abort"} {
+	uplevel #0 $command [list [list 0 [::msgcat::mc "Aborted"]]]
 	return
     }
 
-    if {$res != "OK"} {
+    if {$res != "ok"} {
 	request_proxy $stream $streamhosts $proxies $command
 	return
     }
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
+    ::xmpp::xml::split $child tag xmlns attrs cdata subels
 
-    foreach ch $children {
-	jlib::wrapper:splitxml $ch tag1 vars1 isempty1 chdata1 children1
-	if {$tag1 == "streamhost"} {
-	    lappend streamhosts $ch
+    foreach subel $subels {
+	::xmpp::xml::split $subel stag sxmlns sattrs scdata ssubels
+	if {$stag == "streamhost"} {
+	    lappend streamhosts $subel
 	}
     }
     request_proxy $stream $streamhosts $proxies $command
@@ -236,39 +234,37 @@
 proc socks5::initiator::request {stream streamhosts command} {
     upvar #0 $stream state
 
-    jlib::send_iq set \
-	[jlib::wrapper:createtag query \
-	     -vars [list xmlns $::NS(bytestreams) \
-			 sid $state(id)] \
-	     -subtags $streamhosts] \
+    ::xmpp::sendIQ $state(xlib) set \
+	-query [::xmpp::xml::create query \
+			-xmlns $::NS(bytestreams) \
+			-attrs [list sid $state(id)] \
+			-subelements $streamhosts] \
 	-to $state(jid) \
 	-command [list [namespace current]::recv_request_response \
-		       $stream $streamhosts $command] \
-	-connection $state(connid)
+		       $stream $streamhosts $command]
 }
 
 proc socks5::initiator::recv_request_response \
      {stream streamhosts command res child} {
     upvar #0 $stream state
 
-    if {$res != "OK"} {
+    if {$res != "ok"} {
 	uplevel #0 $command [list [list 0 [error_to_string $child]]]
 	return
     }
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
-    jlib::wrapper:splitxml [lindex $children 0] \
-			   tag1 vars1 isempty1 chdata1 children1
-    if {$tag1 != "streamhost-used"} {
+    ::xmpp::xml::split $child tag xmlns attrs cdata subels
+    ::xmpp::xml::split [lindex $subels 0] stag sxmlns sattrs scdata ssubels
+    if {$stag != "streamhost-used"} {
 	uplevel #0 $command [list [list 0 [::msgcat::mc "Illegal result"]]]
 	return
     }
     
-    set jid [jlib::wrapper:getattr $vars1 jid]
+    set jid [::xmpp::xml::getAttr $sattrs jid]
     set idx 0
     foreach streamhost $streamhosts {
-	jlib::wrapper:splitxml $streamhost tag2 vars2 isempty2 chdata2 children2
-	if {[jlib::wrapper:getattr $vars2 jid] == $jid} {
+	::xmpp::xml::split $streamhost sstag ssxmlns ssattrs sscdata sssubels
+	if {[::xmpp::xml::getAttr $ssattrs jid] == $jid} {
 	    break
 	}
 	incr idx
@@ -282,9 +278,9 @@
 	uplevel #0 $command [list [list 0 [::msgcat::mc "Illegal result"]]]
     } else {
 	# TODO: zeroconf support
-	set jid [jlib::wrapper:getattr $vars2 jid]
-	set host [jlib::wrapper:getattr $vars2 host]
-	set port [jlib::wrapper:getattr $vars2 port]
+	set jid  [::xmpp::xml::getAttr $ssattrs jid]
+	set host [::xmpp::xml::getAttr $ssattrs host]
+	set port [::xmpp::xml::getAttr $ssattrs port]
 	
 	# Target uses proxy, so closing server socket
 	::close $state(servsock)
@@ -324,17 +320,15 @@
     }
 
     # Activate mediated connection
-    jlib::send_iq set \
-	[jlib::wrapper:createtag query \
-	     -vars [list xmlns $::NS(bytestreams) \
-			 sid $state(id)] \
-	     -subtags [list [jlib::wrapper:createtag activate \
-				 -chdata $state(jid)]]] \
+    ::xmpp::sendIQ $state(xlib) set \
+	-query [::xmpp::xml::create query \
+			-xmlns $::NS(bytestreams) \
+			-attrs [list sid $state(id)] \
+			-subelement [::xmpp::xml::create activate \
+					    -cdata $state(jid)]] \
 	-to $jid \
 	-command [list [namespace current]::proxy_activate_response \
-		       $stream $command] \
-	-connection $state(connid)
-    
+		       $stream $command]
 }
 
 ###############################################################################
@@ -342,7 +336,7 @@
 proc socks5::initiator::proxy_activate_response {stream command res child} {
     upvar #0 $stream state
 
-    if {$res != "OK"} {
+    if {$res != "ok"} {
 	uplevel #0 $command [list [list 0 [error_to_string $child]]]
 	return
     }
@@ -376,7 +370,7 @@
     }
 
     set myjid [encoding convertto utf-8 \
-		   [tolower_node_and_domain [my_jid $state(connid) $state(jid)]]]
+		   [tolower_node_and_domain [my_jid $state(xlib) $state(jid)]]]
     set hisjid [encoding convertto utf-8 [tolower_node_and_domain $state(jid)]]
     set hash [::sha1::sha1 $state(id)$myjid$hisjid]
 
@@ -536,28 +530,30 @@
 
 ###############################################################################
 
-proc socks5::iq_set_handler {connid from lang child} {
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
+proc socks5::iq_set_handler {xlib from child args} {
+    ::xmpp::xml::split $child tag xmlns attrs cdata subels
 
+    set lang [::xmpp::xml::getAttr $args -lang en]
+
     if {$tag != "query"} {
 	return [list error modify bad-request]
     }
 
-    set id [jlib::wrapper:getattr $vars sid]
-    if {[catch {si::in $connid $from $id} stream]} {
+    set id [::xmpp::xml::getAttr $attrs sid]
+    if {[catch {si::in $xlib $from $id} stream]} {
 	return [list error modify bad-request \
 		     -text [::trans::trans $lang \
 					   "Stream ID has not been negotiated"]]
     }
 
     set hosts {}
-    foreach item $children {
-	jlib::wrapper:splitxml $item tag1 vars1 isempty1 chdata1 children1
-	switch -- $tag1 {
+    foreach item $subels {
+	::xmpp::xml::split $item stag sxmlns sattrs scdata1 ssubels
+	switch -- $stag {
 	    streamhost {
-		lappend hosts [list [jlib::wrapper:getattr $vars1 host] \
-				    [jlib::wrapper:getattr $vars1 port] \
-				    [jlib::wrapper:getattr $vars1 jid]]
+		lappend hosts [list [::xmpp::xml::getAttr $sattrs host] \
+				    [::xmpp::xml::getAttr $sattrs port] \
+				    [::xmpp::xml::getAttr $sattrs jid]]
 	    }
 	}
     }
@@ -566,15 +562,15 @@
     [namespace current]::target::sock_connect $stream $hosts $lang
 }
 
-iq::register_handler set "" $::NS(bytestreams) \
-    [namespace current]::socks5::iq_set_handler
+::xmpp::iq::register set * $::NS(bytestreams) \
+		     [namespace current]::socks5::iq_set_handler
 
 ###############################################################################
 
 si::register_transport $::NS(bytestreams) $::NS(bytestreams) 50 \
-    [namespace current]::socks5::initiator::connect \
-    [namespace current]::socks5::initiator::send_data \
-    [namespace current]::socks5::initiator::close
+		       [namespace current]::socks5::initiator::connect \
+		       [namespace current]::socks5::initiator::send_data \
+		       [namespace current]::socks5::initiator::close
 
 ###############################################################################
 

Modified: trunk/tkabber/plugins/unix/wmdock.tcl
===================================================================
--- trunk/tkabber/plugins/unix/wmdock.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/plugins/unix/wmdock.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -42,12 +42,11 @@
     }
 
     foreach xelem $x {
-	jlib::wrapper:splitxml $xelem tag vars isempty chdata children
+	::xmpp::xml:split $xelem tag xmlns attrs cdata subels
 	
 	# Don't count message if this 'empty' tag is present. It indicates
 	# messages history in chat window.
-	if {[cequal $tag ""] && \
-		[cequal [jlib::wrapper:getattr $vars xmlns] tkabber:x:nolog]} {
+	if {[string equal $tag ""] && [string equal $xmlns tkabber:x:nolog]} {
 	    return
 	}
     }

Modified: trunk/tkabber/presence.tcl
===================================================================
--- trunk/tkabber/presence.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/presence.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -17,7 +17,7 @@
 
 ###############################################################################
 
-proc client:presence {connid from type x args} {
+proc client:presence {xlib from type x args} {
     global presence
     global processed_presence
 
@@ -28,40 +28,37 @@
     switch -- $type {
 	error -
 	unavailable {
-	    catch { unset presence(type,$connid,$from) }
-	    catch { unset presence(status,$connid,$from) }
-	    catch { unset presence(priority,$connid,$from) }
-	    catch { unset presence(meta,$connid,$from) }
-	    catch { unset presence(icon,$connid,$from) }
-	    catch { unset presence(show,$connid,$from) }
-	    catch { unset presence(loc,$connid,$from) }
-	    catch { unset presence(x,$connid,$from) }
-	    catch { unset presence(error,$connid,$from) }
+	    catch { unset presence(type,$xlib,$from) }
+	    catch { unset presence(status,$xlib,$from) }
+	    catch { unset presence(priority,$xlib,$from) }
+	    catch { unset presence(show,$xlib,$from) }
+	    catch { unset presence(x,$xlib,$from) }
+	    catch { unset presence(error,$xlib,$from) }
 
 	    set user [node_and_server_from_jid $from]
-	    if {[info exists presence(user_jids,$connid,$user)]} {
-		set idx [lsearch -exact $presence(user_jids,$connid,$user) $from]
-		set presence(user_jids,$connid,$user) \
-		    [lreplace $presence(user_jids,$connid,$user) $idx $idx]
+	    if {[info exists presence(user_jids,$xlib,$user)]} {
+		set idx [lsearch -exact $presence(user_jids,$xlib,$user) $from]
+		set presence(user_jids,$xlib,$user) \
+		    [lreplace $presence(user_jids,$xlib,$user) $idx $idx]
 	    }
-	    cache_preferred_jid_on_unavailable $connid $from $user
-	    cache_user_status $connid $user
+	    cache_preferred_jid_on_unavailable $xlib $from $user
+	    cache_user_status $xlib $user
 
 	    foreach {attr val} $args {
 		switch -- $attr {
 		    -status {
-			set presence(status,$connid,$from) $val
-			if {[get_user_status $connid $user] == "unavailable"} {
-			    set presence(status,$connid,$user) $val
+			set presence(status,$xlib,$from) $val
+			if {[get_user_status $xlib $user] == "unavailable"} {
+			    set presence(status,$xlib,$user) $val
 			}
 		    }
 		    -error {
-			set presence(error,$connid,$from) $val
+			set presence(error,$xlib,$from) $val
 		    }
 		}
 	    }
 
-	    debugmsg presence "$connid $from unavailable"
+	    debugmsg presence "$xlib $from unavailable"
 	}
 	subscribe {}
 	subscribed {}
@@ -70,173 +67,167 @@
 	probe {}
 	default {
 	    set type available
-	    set presence(type,$connid,$from)     available
-	    set presence(status,$connid,$from)   ""
-	    set presence(priority,$connid,$from) 0
-	    set presence(meta,$connid,$from)     ""
-	    set presence(icon,$connid,$from)     ""
-	    set presence(show,$connid,$from)     available
-	    set presence(loc,$connid,$from)      ""
-	    set presence(x,$connid,$from)        $x
+	    set presence(type,$xlib,$from)     available
+	    set presence(status,$xlib,$from)   ""
+	    set presence(priority,$xlib,$from) 0
+	    set presence(show,$xlib,$from)     available
+	    set presence(x,$xlib,$from)        $x
 	    
 	    foreach {attr val} $args {
 		switch -- $attr {
-		    -status   {set presence(status,$connid,$from)   $val}
-		    -priority {set presence(priority,$connid,$from) $val}
-		    -meta     {set presence(meta,$connid,$from)     $val}
-		    -icon     {set presence(icon,$connid,$from)     $val}
-		    -show     {set presence(show,$connid,$from)     $val}
-		    -loc      {set presence(loc,$connid,$from)      $val}
+		    -status   {set presence(status,$xlib,$from)   $val}
+		    -priority {set presence(priority,$xlib,$from) $val}
+		    -show     {set presence(show,$xlib,$from)     $val}
 		}
 	    }
 	    
-	    set presence(show,$connid,$from) \
-		[normalize_show $presence(show,$connid,$from)]
+	    set presence(show,$xlib,$from) \
+		[normalize_show $presence(show,$xlib,$from)]
 
 	    set user [node_and_server_from_jid $from]
-	    if {![info exists presence(user_jids,$connid,$user)] || \
-		    ![lcontain $presence(user_jids,$connid,$user) $from]} {
-		lappend presence(user_jids,$connid,$user) $from
+	    if {![info exists presence(user_jids,$xlib,$user)] || \
+		    ![lcontain $presence(user_jids,$xlib,$user) $from]} {
+		lappend presence(user_jids,$xlib,$user) $from
 	    }
 
-	    cache_preferred_jid_on_available $connid $from $user
-	    cache_user_status $connid $user
+	    cache_preferred_jid_on_available $xlib $from $user
+	    cache_user_status $xlib $user
 	}
     }
     
-    eval {hook::run client_presence_hook $connid $from $type $x} $args
+    eval {hook::run client_presence_hook $xlib $from $type $x} $args
 }
 
 ###############################################################################
 
-proc get_jids_of_user {connid user} {
+proc get_jids_of_user {xlib user} {
     global presence
 
-    if {[info exists presence(user_jids,$connid,$user)]} {
-	return $presence(user_jids,$connid,$user)
+    if {[info exists presence(user_jids,$xlib,$user)]} {
+	return $presence(user_jids,$xlib,$user)
     } elseif {![cequal [resource_from_jid $user] ""]} {
-	if {[info exists presence(type,$connid,$user)]} {
+	if {[info exists presence(type,$xlib,$user)]} {
 	    return [list $user]
 	}
     }
     return {}
 }
 
-proc get_jid_of_user {connid user} {
+proc get_jid_of_user {xlib user} {
     global presence
 
-    if {[info exists presence(preferred_jid,$connid,$user)]} {
-	return $presence(preferred_jid,$connid,$user)
+    if {[info exists presence(preferred_jid,$xlib,$user)]} {
+	return $presence(preferred_jid,$xlib,$user)
     } else {
 	return $user
     }
 }
 
-proc cache_preferred_jid_on_available {connid jid user} {
+proc cache_preferred_jid_on_available {xlib jid user} {
     global presence
 
-    if {[info exists presence(maxpriority,$connid,$user)]} {
-	set maxpri $presence(maxpriority,$connid,$user)
+    if {[info exists presence(maxpriority,$xlib,$user)]} {
+	set maxpri $presence(maxpriority,$xlib,$user)
     } else {
-	cache_preferred_jid $connid $user
+	cache_preferred_jid $xlib $user
 	return
     }
     
-    set pri $presence(priority,$connid,$jid)
+    set pri $presence(priority,$xlib,$jid)
 
     if {$pri > $maxpri} {
-	set presence(maxpriority,$connid,$user) $pri
-	set presence(preferred_jid,$connid,$user) $jid
+	set presence(maxpriority,$xlib,$user) $pri
+	set presence(preferred_jid,$xlib,$user) $jid
     }
 }
 
-proc cache_preferred_jid_on_unavailable {connid jid user} {
+proc cache_preferred_jid_on_unavailable {xlib jid user} {
     global presence
 
-    if {![info exists presence(maxpriority,$connid,$user)]} {
-	cache_preferred_jid $connid $user
+    if {![info exists presence(maxpriority,$xlib,$user)]} {
+	cache_preferred_jid $xlib $user
 	return
     }
     
-    if {$presence(preferred_jid,$connid,$user) == $jid} {
-	unset presence(preferred_jid,$connid,$user)
-	unset presence(maxpriority,$connid,$user)
-	cache_preferred_jid $connid $user
+    if {$presence(preferred_jid,$xlib,$user) == $jid} {
+	unset presence(preferred_jid,$xlib,$user)
+	unset presence(maxpriority,$xlib,$user)
+	cache_preferred_jid $xlib $user
     }
 }
 
-proc cache_preferred_jid {connid user} {
+proc cache_preferred_jid {xlib user} {
     global presence
 
-    set jids [get_jids_of_user $connid $user]
+    set jids [get_jids_of_user $xlib $user]
 
     if {$jids != {}} {
 	set rjid [lindex $jids 0]
-	set pri $presence(priority,$connid,$rjid)
+	set pri $presence(priority,$xlib,$rjid)
 
 	foreach jid $jids {
-	    if {$presence(priority,$connid,$jid) > $pri} {
-		set pri $presence(priority,$connid,$jid)
+	    if {$presence(priority,$xlib,$jid) > $pri} {
+		set pri $presence(priority,$xlib,$jid)
 		set rjid $jid
 	    }
 	}
 
-	set presence(maxpriority,$connid,$user) $pri
-	set presence(preferred_jid,$connid,$user) $rjid
+	set presence(maxpriority,$xlib,$user) $pri
+	set presence(preferred_jid,$xlib,$user) $rjid
     }
 }
 
 
-proc get_jid_status {connid jid} {
+proc get_jid_status {xlib jid} {
     global presence
 
     set j $jid
-    if {[info exists presence(show,$connid,$j)]} {
-	return $presence(show,$connid,$j)
+    if {[info exists presence(show,$xlib,$j)]} {
+	return $presence(show,$xlib,$j)
     } else {
 	return unavailable
     }
 }
 
-proc get_jid_presence_info {param connid jid} {
+proc get_jid_presence_info {param xlib jid} {
     global presence
 
-    if {[info exists presence($param,$connid,$jid)]} {
-	return $presence($param,$connid,$jid)
+    if {[info exists presence($param,$xlib,$jid)]} {
+	return $presence($param,$xlib,$jid)
     } else {
 	return ""
     }
 }
 
-proc get_user_status {connid user} {
+proc get_user_status {xlib user} {
     global presence
 
-    if {[info exists presence(cachedstatus,$connid,$user)]} {
-	return $presence(cachedstatus,$connid,$user)
-    } elseif {[info exists presence(show,$connid,$user)]} {
-	return $presence(show,$connid,$user)
+    if {[info exists presence(cachedstatus,$xlib,$user)]} {
+	return $presence(cachedstatus,$xlib,$user)
+    } elseif {[info exists presence(show,$xlib,$user)]} {
+	return $presence(show,$xlib,$user)
     } else {
 	return unavailable
     }
 }
 
-proc cache_user_status {connid user} {
+proc cache_user_status {xlib user} {
     global presence
 
-    set jid [get_jid_of_user $connid $user]
-    if {[info exists presence(show,$connid,$jid)]} {
-	set presence(cachedstatus,$connid,$user) $presence(show,$connid,$jid)
+    set jid [get_jid_of_user $xlib $user]
+    if {[info exists presence(show,$xlib,$jid)]} {
+	set presence(cachedstatus,$xlib,$user) $presence(show,$xlib,$jid)
     } else {
-	set presence(cachedstatus,$connid,$user) unavailable
+	set presence(cachedstatus,$xlib,$user) unavailable
     }
 }
 
-proc get_user_status_desc {connid user} {
+proc get_user_status_desc {xlib user} {
     global presence
 
-    set jid [get_jid_of_user $connid $user]
-    if {[info exists presence(status,$connid,$jid)]} {
-	return $presence(status,$connid,$jid)
+    set jid [get_jid_of_user $xlib $user]
+    if {[info exists presence(status,$xlib,$jid)]} {
+	return $presence(status,$xlib,$jid)
     } else {
 	return ""
     }
@@ -367,7 +358,7 @@
 	    set newpriority $logoutpriority
 	}
 	default {
-	    if {[lempty [jlib::connections]]} return
+	    if {[lempty [connections]]} return
 	    set newstatus $userstatus
 	    set newtextstatus $textstatus
 	    set newpriority $userpriority
@@ -381,7 +372,7 @@
     }
 
     if {[lsearch -exact [array names statusdesc] $newstatus] < 0} {
-	error [cconcat [::msgcat::mc "invalid userstatus value "] $newstatus]
+	error [::msgcat::mc "Invalid userstatus value %s" $newstatus]
     }
 
     set userstatusdesc $statusdesc($newstatus)
@@ -391,15 +382,14 @@
 	set status $newtextstatus
     }
 
-    foreach connid [jlib::connections] {
-	send_presence $newstatus \
-		      -stat $status \
-		      -pri $userpriority \
-		      -connection $connid
+    foreach xlib [connections] {
+	send_presence $xlib $newstatus \
+		      -status $status \
+		      -priority $userpriority
     }
 
     foreach chatid [lfilter chat::is_groupchat [chat::opened]] {
-	set connid [chat::get_connid $chatid]
+	set xlib [chat::get_xlib $chatid]
 	set group [chat::get_jid $chatid]
 	set nick [get_our_groupchat_nick $chatid]
 
@@ -409,11 +399,10 @@
 	    set newst $newstatus
 	}
 
-	send_presence $newst \
+	send_presence $xlib $newst \
 		      -to $group/$nick \
-		      -stat $status \
-		      -pri $userpriority \
-		      -connection $connid
+		      -status $status \
+		      -priority $userpriority
     }
 
     set curuserstatus $newstatus
@@ -425,7 +414,7 @@
 
 ###############################################################################
 
-proc send_first_presence {connid} {
+proc send_first_presence {xlib} {
     global userstatus curuserstatus statusdesc userstatusdesc
     global textstatus curtextstatus
     global userpriority curpriority
@@ -446,10 +435,9 @@
     set curtextstatus $textstatus
     set curpriority [set userpriority $loginconf(priority)]
     
-    send_presence $userstatus \
-		  -stat $status \
-		  -pri $userpriority \
-		  -connection $connid
+    send_presence $xlib $userstatus \
+		  -status $status \
+		  -priority $userpriority
 
     hook::run change_our_presence_post_hook $userstatus
 }
@@ -458,7 +446,7 @@
 
 ###############################################################################
 
-proc send_custom_presence {jid status args} {
+proc send_custom_presence {xlib jid status args} {
     global userpriority
     global statusdesc
 
@@ -466,60 +454,60 @@
     set stat ""
     foreach {key val} $args {
 	switch -- $key {
-	    -type       { set type $val }
-	    -stat       { set stat $val }
-	    -connection { set connid $val }
+	    -type   { set type $val }
+	    -status { set stat $val }
 	}
     }
-    if {![info exists connid]} {
-	return -code error "send_custom_presence: -connection required"
-    }
+
     if {$stat == ""} {
 	set stat $statusdesc($status)
     }
     
     switch -- $type {
-	group   { set to $jid/[get_our_groupchat_nick [chat::chatid $connid $jid]] }
-	default { set to $jid }
+	group   {
+	    set to $jid/[get_our_groupchat_nick [chat::chatid $xlib $jid]]
+	}
+	default {
+	    set to $jid
+	}
     }
 
-    eval {send_presence $status} $args {-to $to -stat $stat -pri $userpriority}
+    eval {send_presence $status} $args \
+	 {-to $to -status $stat -priority $userpriority}
 }
 
 ###############################################################################
 
-proc send_presence {status args} {
+proc send_presence {xlib status args} {
     set xlist {}
     set newargs {}
     set stat ""
     foreach {opt val} $args {
 	switch -- $opt {
-	    -to         { lappend newargs -to $val }
-	    -pri        { lappend newargs -pri $val }
-	    -command    { lappend newargs -command $val }
-	    -xlist      { set xlist $val }
-	    -stat       { set stat $val }
-	    -connection {
-		set connid $val
-		lappend newargs -connection $val
-	    }
+	    -to       { lappend newargs -to $val }
+	    -priority { lappend newargs -priority $val }
+	    -xlist    { set xlist $val }
+	    -status   { set stat $val }
 	}
     }
-    if {![info exists connid]} {
-	return -code error "send_presence: -connection required"
-    }
 
     if {$stat != ""} {
-	lappend newargs -stat $stat
+	lappend newargs -status $stat
     }
 
-    hook::run presence_xlist_hook xlist $connid $stat
+    hook::run presence_xlist_hook xlist $xlib $stat
     lappend newargs -xlist $xlist
 
     switch -- $status {
-	available   { set command [list jlib::send_presence] }
-	unavailable { set command [list jlib::send_presence -type $status] }
-	default     { set command [list jlib::send_presence -show $status] }
+	available   {
+	    set command [list ::xmpp::sendPresence $xlib]
+	}
+	unavailable {
+	    set command [list ::xmpp::sendPresence $xlib -type $status]
+	}
+	default     {
+	    set command [list ::xmpp::sendPresence $xlib -show $status]
+	}
     }
 
     debugmsg presence "$command $newargs"
@@ -544,13 +532,13 @@
 
 ###############################################################################
 
-proc add_presence_to_popup_info {infovar connid jid} {
+proc add_presence_to_popup_info {infovar xlib jid} {
     upvar 0 $infovar info
 
     set bjid [node_and_server_from_jid $jid]
-    if {[chat::is_groupchat [chat::chatid $connid $bjid]]} return
+    if {[chat::is_groupchat [chat::chatid $xlib $bjid]]} return
 
-    set priority [get_jid_presence_info priority $connid $jid]
+    set priority [get_jid_presence_info priority $xlib $jid]
     if {$priority != ""} {
 	append info [format "\n\t[::msgcat::mc {Priority:}] %s" $priority]
     }
@@ -560,26 +548,23 @@
 
 ###############################################################################
 
-proc clear_presence_info {connid} {
+proc clear_presence_info {xlib} {
     global presence
 
-    if {$connid == {}} {
+    if {$xlib == {}} {
 	array unset presence
     } else {
 	# TODO
-	array unset presence type,$connid,*
-	array unset presence status,$connid,*
-	array unset presence priority,$connid,*
-	array unset presence meta,$connid,*
-	array unset presence icon,$connid,*
-	array unset presence show,$connid,*
-	array unset presence loc,$connid,*
-	array unset presence error,$connid,*
-	array unset presence x,$connid,*
-	array unset presence user_jids,$connid,*
-	array unset presence preferred_jid,$connid,*
-	array unset presence cachedstatus,$connid,*
-	array unset presence maxpriority,$connid,*
+	array unset presence type,$xlib,*
+	array unset presence status,$xlib,*
+	array unset presence priority,$xlib,*
+	array unset presence show,$xlib,*
+	array unset presence error,$xlib,*
+	array unset presence x,$xlib,*
+	array unset presence user_jids,$xlib,*
+	array unset presence preferred_jid,$xlib,*
+	array unset presence cachedstatus,$xlib,*
+	array unset presence maxpriority,$xlib,*
     }
 }
 
@@ -587,23 +572,24 @@
 
 ###############################################################################
 
-proc custom_presence_menu {m connid jid} {
+proc custom_presence_menu {m xlib jid} {
     set mm [menu $m.custom_presence -tearoff 0]
 
     $mm add command -label [::msgcat::mc "Available"] \
-	-command [list send_custom_presence $jid available -connection $connid]
+		    -command [list send_custom_presence $xlib $jid available]
     $mm add command -label [::msgcat::mc "Free to chat"] \
-	-command [list send_custom_presence $jid chat -connection $connid]
+		    -command [list send_custom_presence $xlib $jid chat]
     $mm add command -label [::msgcat::mc "Away"] \
-	-command [list send_custom_presence $jid away -connection $connid]
+		    -command [list send_custom_presence $xlib $jid away]
     $mm add command -label [::msgcat::mc "Extended away"] \
-	-command [list send_custom_presence $jid xa -connection $connid]
+		    -command [list send_custom_presence $xlib $jid xa]
     $mm add command -label [::msgcat::mc "Do not disturb"] \
-	-command [list send_custom_presence $jid dnd -connection $connid]
+		    -command [list send_custom_presence $xlib $jid dnd]
     $mm add command -label [::msgcat::mc "Unavailable"] \
-	-command [list send_custom_presence $jid unavailable -connection $connid]
+		    -command [list send_custom_presence $xlib $jid unavailable]
 
-    $m add cascade -label [::msgcat::mc "Send custom presence"] -menu $mm
+    $m add cascade -label [::msgcat::mc "Send custom presence"] \
+		   -menu $mm
 }
 
 hook::add chat_create_user_menu_hook custom_presence_menu 43
@@ -613,32 +599,32 @@
 
 ###############################################################################
 
-proc service_login {connid jid} {
+proc service_login {xlib jid} {
     global userstatus
 
     switch -- $userstatus {
 	available {
-	    jlib::send_presence -to $jid -connection $connid
+	    ::xmpp::sendPresence $xlib -to $jid
 	}
 	invisible {
-	    jlib::send_presence -to $jid -type $userstatus -connection $connid
+	    ::xmpp::sendPresence $xlib -to $jid -type $userstatus
 	}
 	default {
-	    jlib::send_presence -to $jid -show $userstatus -connection $connid
+	    ::xmpp::sendPresence $xlib -to $jid -show $userstatus
 	}
     }
 }
 
-proc service_logout {connid jid} {
-    jlib::send_presence -to $jid -type unavailable -connection $connid
+proc service_logout {xlib jid} {
+    ::xmpp::sendPresence $xlib -to $jid -type unavailable
 }
 
-proc service_login_logout_menu_item {m connid jid} {
+proc service_login_logout_menu_item {m xlib jid} {
     # TODO
     $m add command -label [::msgcat::mc "Log in"] \
-	-command [list service_login $connid $jid]
+		   -command [list service_login $xlib $jid]
     $m add command -label [::msgcat::mc "Log out"] \
-	-command [list service_logout $connid $jid]
+		   -command [list service_logout $xlib $jid]
 }
 
 hook::add roster_service_popup_menu_hook service_login_logout_menu_item 20

Modified: trunk/tkabber/privacy.tcl
===================================================================
--- trunk/tkabber/privacy.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/privacy.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -48,23 +48,17 @@
 # Manual rules editing block
 #
 
-proc privacy::request_lists {args} {
+proc privacy::request_lists {xlib} {
 
-    foreach {opt val} $args {
-	switch -- $opt {
-	    -connection { set connid $val }
-	}
+    if {$xlib == ""} {
+	set xlib [first_supported]
     }
-    if {![info exists connid]} {
-	set connid [first_supported]
-    }
-    if {$connid == ""} return
+    if {$xlib == ""} return
 
-    jlib::send_iq get \
-	[jlib::wrapper:createtag query \
-	     -vars [list xmlns $::NS(privacy)]] \
-	-command [list [namespace current]::open_dialog $connid] \
-	-connection $connid
+    ::xmpp::sendIQ $xlib get \
+	-query [::xmpp::xml::create query \
+			-xmlns $::NS(privacy)] \
+	-command [list [namespace current]::open_dialog $xlib]
 }
 
 
@@ -76,8 +70,8 @@
     catch { array unset data }
 }
 
-proc privacy::open_dialog {connid res child} {
-    if {[cequal $res ERR]} {
+proc privacy::open_dialog {xlib res child} {
+    if {[string equal $res error]} {
 	MessageDlg .privacy_err -aspect 50000 -icon error \
 	    -message [::msgcat::mc "Requesting privacy rules: %s" \
 			  [error_to_string $child]] \
@@ -98,7 +92,7 @@
     bind $w <Destroy> [list [namespace current]::on_destroy_dialog $w %W]
 
     $w add -text [::msgcat::mc "Send"] \
-	-command [list [namespace current]::send_lists $connid $w]
+	-command [list [namespace current]::send_lists $xlib $w]
     $w add -text [::msgcat::mc "Cancel"] -command [list destroy $w]
 
     set f [$w getframe]
@@ -118,7 +112,7 @@
     set addlist [button $tools.addlist \
 		     -text [::msgcat::mc "Add list"] \
 		     -command [list [namespace current]::add_list \
-				   $connid $tools $lf "" {}]]
+				   $xlib $tools $lf "" {}]]
     pack $addlist -side right -padx 1m
 
     set default [radiobutton $tools.default \
@@ -133,14 +127,14 @@
 		    -value "\u0000"]
     pack $active -side left -padx 1m
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
-    fill_lists $connid $hf $lf $children
+    ::xmpp::xml::split $child tag xmlns attrs cdata subels
+    fill_lists $xlib $hf $lf $subels
 
     $w draw
 }
 
 
-proc privacy::fill_lists {connid hf f items} {
+proc privacy::fill_lists {xlib hf f items} {
     variable data
 
     grid [label $f.n -text [::msgcat::mc "List name"] -width 20] \
@@ -161,18 +155,18 @@
     set data(nlists) 0
     set i 0
     foreach item $items {
-	jlib::wrapper:splitxml $item tag vars isempty chdata children
-	switch -- x$tag {
-	    xdefault {
-		set data(default) [jlib::wrapper:getattr $vars name]
+	::xmpp::xml::split $item tag xmlns attrs cdata subels
+	switch -- $tag {
+	    default {
+		set data(default) [::xmpp::xml::getAttr $attrs name]
 	    }
-	    xactive {
-		set data(active) [jlib::wrapper:getattr $vars name]
+	    active {
+		set data(active) [::xmpp::xml::getAttr $attrs name]
 	    }
-	    xlist {
-		set name [jlib::wrapper:getattr $vars name]
+	    list {
+		set name [::xmpp::xml::getAttr $attrs name]
 
-		add_list $connid $hf $f $name $children
+		add_list $xlib $hf $f $name $subels
 	    }
 	}
     }
@@ -212,14 +206,14 @@
     }
 }
 
-proc privacy::add_list {connid hf lf name children} {
+proc privacy::add_list {xlib hf lf name children} {
     variable data
 
     set i $data(nlists)
 
     if {$name == ""} {
 	set name "list$i"
-	send_new_list $connid $name
+	send_new_list $xlib $name
     }
 
     set data(name,$i) $name
@@ -242,7 +236,7 @@
 		    -command [list [namespace current]::remove_list $lf $i]]
     set edit [button $lf.edit$i \
 		  -text [::msgcat::mc "Edit list"] \
-		  -command [list [namespace current]::edit_list $connid $lf $i]]
+		  -command [list [namespace current]::edit_list $xlib $lf $i]]
     
     set row [expr {$i + 1}]
     grid $lname   -row $row -column 0 -stick w  -padx 1m
@@ -259,31 +253,30 @@
 }
 
 
-proc privacy::edit_list {connid lf ln} {
+proc privacy::edit_list {xlib lf ln} {
     variable data
 
     set name $data(name,$ln)
 
-    jlib::send_iq get \
-	[jlib::wrapper:createtag query \
-	     -vars [list xmlns $::NS(privacy)] \
-	     -subtags [list [jlib::wrapper:createtag list \
-				 -vars [list name $name]]]] \
-	-command [list [namespace current]::edit_list_dialog $connid $ln $name] \
-	-connection $connid
+    ::xmpp::sendIQ $xlib get \
+	-query [::xmpp::xml::create query \
+			-xmlns $::NS(privacy) \
+			-subelement [::xmpp::xml::create list \
+					    -attrs [list name $name]]] \
+	-command [list [namespace current]::edit_list_dialog $xlib $ln $name]
 }
 
 
-proc privacy::edit_list_dialog {connid ln name res child} {
-    if {[cequal $res ERR]} {
+proc privacy::edit_list_dialog {xlib ln name res child} {
+    if {[string equal $res error]} {
 	MessageDlg .privacy_list_err -aspect 50000 -icon error \
 	    -message [::msgcat::mc "Requesting privacy list: %s" \
 			  [error_to_string $child]] \
 	    -type user -buttons ok -default 0 -cancel 0
-	set child [jlib::wrapper:createtag query \
-		       -vars [list xmlns $::NS(privacy)] \
-		       -subtags [list [jlib::wrapper:createtag list \
-					   -vars [list name $name]]]]
+	set child [::xmpp::xml::create query \
+			-xmlns $::NS(privacy) \
+			-subelement [::xmpp::xml::create list \
+					   -attrs [list name $name]]]
     }
 
     set w .privacy_list
@@ -297,7 +290,7 @@
 	-default 0 -cancel 1
 
     $w add -text [::msgcat::mc "Send"] \
-	-command [list [namespace current]::send_list $connid $ln $w]
+	-command [list [namespace current]::send_list $xlib $ln $w]
     $w add -text [::msgcat::mc "Cancel"] -command [list destroy $w]
 
     set f [$w getframe]
@@ -321,8 +314,8 @@
 			  $lf.items "none" "" "allow" 1 1 1 1]]
     pack $additem -side right -padx 1m
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
-    fill_edit_lists $lf $children
+    ::xmpp::xml::split $child tag xmlns attrs cdata subels
+    fill_edit_lists $lf $subels
 
     update idletasks
     $hf configure \
@@ -337,10 +330,10 @@
 
     foreach item $items {
 	if {$item != ""} {
-	    jlib::wrapper:splitxml $item tag vars isempty chdata children
+	    ::xmpp::xml::split $item tag xmlns attrs cdata subels
 	    if {$tag == "list"} {
-		set name [jlib::wrapper:getattr $vars name]
-		fill_edit_list $f $name $children
+		set name [::xmpp::xml::getAttr $attrs name]
+		fill_edit_list $f $name $subels
 		break
 	    }
 	}
@@ -349,10 +342,10 @@
 
 
 proc privacy::compare {item1 item2} {
-    jlib::wrapper:splitxml $item1 tag vars isempty chdata children
-    set order1 [jlib::wrapper:getattr $vars order]
-    jlib::wrapper:splitxml $item2 tag vars isempty chdata children
-    set order2 [jlib::wrapper:getattr $vars order]
+    ::xmpp::xml::split $item1 tag xmlns attrs cdata subels
+    set order1 [::xmpp::xml::getAttr $attrs order]
+    ::xmpp::xml::split $item1 tag xmlns attrs cdata subels
+    set order2 [::xmpp::xml::getAttr $attrs order]
 
     return [expr {$order1 > $order2}]
 }
@@ -393,25 +386,25 @@
 
     set data(listnitems) 0
     foreach item [lsort -command [namespace current]::compare $items] {
-	jlib::wrapper:splitxml $item tag vars isempty chdata children
+	::xmpp::xml::split $item tag xmlns attrs cdata subels
 
-	set type   [jlib::wrapper:getattr $vars type]
+	set type [::xmpp::xml::getAttr $attrs type]
 	if {$type == ""} {
 	    set type none
 	}
-	set value  [jlib::wrapper:getattr $vars value]
-	set action [jlib::wrapper:getattr $vars action]
+	set value [::xmpp::xml::getAttr $attrs value]
+	set action [::xmpp::xml::getAttr $attrs action]
 
 	set all 1
 	array set tmp [list message 0 presence-in 0 presence-out 0 iq 0]
-	foreach child $children {
-	    jlib::wrapper:splitxml $child tag1 vars1 isempty1 chdata1 children1
-	    switch -- $tag1 {
+	foreach subel $subels {
+	    ::xmpp::xml::split $subel stag sxmlns sattrs scdata ssubels
+	    switch -- $stag {
 		message -
 		presence-in -
 		presence-out -
 		iq {
-		    set tmp($tag1) 1
+		    set tmp($stag) 1
 		    set all 0
 		}
 	    }
@@ -599,48 +592,41 @@
 }
 
 
-proc privacy::send_list_iq {name items args} {
-    set cmd jlib::noop
+proc privacy::send_list_iq {xlib name items args} {
+    set cmd #
     foreach {opt val} $args {
 	switch -- $opt {
 	    -command { set cmd $val }
-	    -connection { set connid $val }
 	}
     }
-    if {![info exists connid]} {
-	return -code error "Option -connection is mandatory"
-    }
-
-    jlib::send_iq set \
-	[jlib::wrapper:createtag query \
-	     -vars [list xmlns $::NS(privacy)] \
-	     -subtags [list [jlib::wrapper:createtag list \
-				 -vars [list name $name] \
-				 -subtags $items]]] \
-	-command $cmd \
-	-connection $connid
+    ::xmpp::sendIQ $xlib set \
+	-query [::xmpp::xml::create query \
+			-xmlns $::NS(privacy) \
+			-subelement [::xmpp::xml::create list \
+					    -attrs [list name $name] \
+					    -subelements $items]] \
+	-command $cmd
 }
 
 
-proc privacy::send_new_list {connid name} {
-    send_list_iq $name \
-	[list [jlib::wrapper:createtag item \
-		   -vars [list action allow order 0]]] \
-	-connection $connid
+proc privacy::send_new_list {xlib name} {
+    send_list_iq $xlib $name \
+	[list [::xmpp::xml::create item \
+			-attrs [list action allow order 0]]]
 }
 
 
-proc privacy::send_list {connid ln w} {
+proc privacy::send_list {xlib ln w} {
     variable data
 
     set name $data(listnewname)
-    send_list_iq $name [list_items] -connection $connid
+    send_list_iq $xlib $name [list_items]
 
     if {$name != $data(listname)} {
 	if {$data(default) == $data(listname)} {
-	    send_default_or_active_list $name default -connection $connid
+	    send_default_or_active_list $xlib $name default
 	}
-	send_list_iq $data(listname) {} -connection $connid
+	send_list_iq $xlib $data(listname) {}
 	set data(newname,$ln) $name
     }
 
@@ -648,17 +634,17 @@
 }
 
 
-proc privacy::send_lists {connid w} {
+proc privacy::send_lists {xlib w} {
     variable data
 
     for {set i 0} {$i < $data(nlists)} {incr i} {
         if {$data(newname,$i) == ""} {
-            send_list_iq $data(name,$i) {} -connection $connid
+            send_list_iq $xlib $data(name,$i) {}
         }
     }
 
-    send_default_or_active_list $data(active) active -connection $connid
-    send_default_or_active_list $data(default) default -connection $connid
+    send_default_or_active_list $xlib $data(active) active
+    send_default_or_active_list $xlib $data(default) default
 
     destroy $w
 }
@@ -678,54 +664,49 @@
 
 	set children {}
 	if {$data(message,$i)} {
-	    lappend children [jlib::wrapper:createtag message]
+	    lappend children [::xmpp::xml::create message]
 	}
 	if {$data(presencein,$i)} {
-	    lappend children [jlib::wrapper:createtag presence-in]
+	    lappend children [::xmpp::xml::create presence-in]
 	}
 	if {$data(presenceout,$i)} {
-	    lappend children [jlib::wrapper:createtag presence-out]
+	    lappend children [::xmpp::xml::create presence-out]
 	}
 	if {$data(iq,$i)} {
-	    lappend children [jlib::wrapper:createtag iq]
+	    lappend children [::xmpp::xml::create iq]
 	}
 	if {[llength $children] == 4} {
 	    set children {}
 	}
 
-	lappend items [jlib::wrapper:createtag item \
-			   -vars $vars \
-			   -subtags $children]
+	lappend items [::xmpp::xml::create item \
+				-attrs $vars \
+				-subelements $children]
     }
     return $items
 }
 
 ###############################################################################
 
-proc privacy::send_default_or_active_list {name tag args} {
-    set cmd jlib::noop
+proc privacy::send_default_or_active_list {xlib name tag args} {
+    set cmd #
     foreach {opt val} $args {
 	switch -- $opt {
 	    -command { set cmd $val }
-	    -connection { set connid $val }
 	}
     }
-    if {![info exists connid]} {
-	return -code error "Option -connection is mandatory"
-    }
 
     if {$name != "\u0000"} {
 	set vars [list name $name]
     } else {
 	set vars {}
     }
-    jlib::send_iq set \
-	[jlib::wrapper:createtag query \
-	     -vars [list xmlns $::NS(privacy)] \
-	     -subtags [list [jlib::wrapper:createtag $tag \
-				 -vars $vars]]] \
-	-command $cmd \
-	-connection $connid
+    ::xmpp::sendIQ $xlib set \
+	-query [::xmpp::xml::create query \
+			-xmlns $::NS(privacy) \
+			-subelement [::xmpp::xml::create $tag \
+					    -attrs $vars]] \
+	-command $cmd
 }
 
 ###############################################################################
@@ -733,42 +714,36 @@
 # Visible, invisible, ignore, conference list block
 #
 
-proc privacy::edit_special_list {name args} {
-    foreach {opt val} $args {
-	switch -- $opt {
-	    -connection { set connid $val }
-	}
+proc privacy::edit_special_list {xlib name args} {
+    if {$xlib == ""} {
+	set xlib [first_supported]
     }
-    if {![info exists connid]} {
-	set connid [first_supported]
-    }
-    if {$connid == ""} return
+    if {$xlib == ""} return
 
-    jlib::send_iq get \
-	[jlib::wrapper:createtag query \
-	     -vars [list xmlns $::NS(privacy)] \
-	     -subtags [list [jlib::wrapper:createtag list \
-				 -vars [list name "$name-list"]]]] \
-	-command [list [namespace current]::edit_special_list_dialog $connid $name] \
-	-connection $connid
+    ::xmpp::sendIQ $xlib get \
+	-query [::xmpp::xml::create query \
+			-xmlns $::NS(privacy) \
+			-subelement [::xmpp::xml::create list \
+					    -attrs [list name "$name-list"]]] \
+	-command [list [namespace current]::edit_special_list_dialog $xlib $name]
 }
 
 
-proc privacy::edit_special_list_dialog {connid name res child} {
+proc privacy::edit_special_list_dialog {xlib name res child} {
     variable req_messages
     variable edit_messages
 
-    if {[cequal $res ERR]} {
+    if {[string equal $res error]} {
 	if {[error_type_condition $child] != {cancel item-not-found}} {
 	    MessageDlg .privacy_list_err -aspect 50000 -icon error \
 		-message [format $req_messages($name) [error_to_string $child]] \
 		-type user -buttons ok -default 0 -cancel 0
 	    return
 	}
-	set child [jlib::wrapper:createtag query \
-		       -vars [list xmlns $::NS(privacy)] \
-		       -subtags [list [jlib::wrapper:createtag list \
-					   -vars [list name "$name-list"]]]]
+	set child [::xmpp::xml::create query \
+		       -xmlns $::NS(privacy) \
+		       -subelement [::xmpp::xml::create list \
+					   -attrs [list name "$name-list"]]]
     }
 
     set w .privacy_list
@@ -783,7 +758,7 @@
 
     $w add -text [::msgcat::mc "Send"] \
 	-command [list [namespace current]::edit_special_list_enddialog \
-		       $connid $w $name]
+		       $xlib $w $name]
     $w add -text [::msgcat::mc "Cancel"] -command [list destroy $w]
 
     set f [$w getframe]
@@ -806,8 +781,8 @@
     pack $additem -side right -padx 1m
     pack $addentry -side left -padx 1m -fill x -expand yes
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
-    fill_edit_special_lists $lf $children
+    ::xmpp::xml::split $child tag xmlns attrs cdata subels
+    fill_edit_special_lists $lf $subels
 
     #update idletasks
     #$tools configure -width [winfo reqwidth $lf]
@@ -819,34 +794,34 @@
 }
 
 
-proc privacy::edit_special_list_enddialog {connid w name} {
+proc privacy::edit_special_list_enddialog {xlib w name} {
     $w itemconfigure 0 -state disabled
-    send_special_list $connid $name [$w.fields get 0 end]
+    send_special_list $xlib $name [$w.fields get 0 end]
     destroy $w
 }
 
-proc privacy::send_special_list {connid name items} {
+proc privacy::send_special_list {xlib name items} {
     variable seq
     variable special_list
     variable cboxes
 
-    if {![is_supported $connid]} {
+    if {![is_supported $xlib]} {
 	return
     }
 
-    if {![info exists special_list($connid,$name)]} {
-	set special_list($connid,$name) {}
+    if {![info exists special_list($xlib,$name)]} {
+	set special_list($xlib,$name) {}
     }
 
     set newitems {}
     foreach jid $items {
-	if {[lsearch -exact $special_list($connid,$name) $jid] < 0} {
+	if {[lsearch -exact $special_list($xlib,$name) $jid] < 0} {
 	    lappend newitems $jid
 	}
     }
 
     set olditems {}
-    foreach jid $special_list($connid,$name) {
+    foreach jid $special_list($xlib,$name) {
 	if {[lsearch -exact $items $jid] < 0} {
 	    lappend olditems $jid
 	}
@@ -857,21 +832,21 @@
 	    set children {}
 	    set action deny
 	    foreach jid $newitems {
-		send_custom_presence $jid unavailable -connection $connid
+		send_custom_presence $xlib $jid unavailable
 	    }
 	    set postitems $olditems
 	}
 	invisible {
-	    set children [list [jlib::wrapper:createtag presence-out]]
+	    set children [list [::xmpp::xml::create presence-out]]
 	    set action deny
 	    foreach jid $newitems {
-		send_custom_presence $jid unavailable -connection $connid
+		send_custom_presence $xlib $jid unavailable
 	    }
 	    set postitems $olditems
 	}
 	visible {
 	    # TODO: invisibility
-	    set children [list [jlib::wrapper:createtag presence-out]]
+	    set children [list [::xmpp::xml::create presence-out]]
 	    set action allow
 	    set postitems $newitems
 	}
@@ -885,43 +860,42 @@
     set items1 {}
     set i 0
     foreach item $items {
-	lappend items1 [jlib::wrapper:createtag item \
-			    -vars [list type jid \
-					value $item \
-					action $action \
-					order $i] \
-			    -subtags $children]
+	lappend items1 [::xmpp::xml::create item \
+				-attrs [list type   jid \
+					     value  $item \
+					     action $action \
+					     order  $i] \
+				-subelements $children]
 	incr i
     }
 
     set s [incr seq]
-    send_list_iq "$name-list" $items1 \
-	-command [list [namespace current]::get_answer $s] \
-	-connection $connid
+    send_list_iq $xlib "$name-list" $items1 \
+	-command [list [namespace current]::get_answer $s]
 
     # We have to vwait because all privacy lists should be updated
     # before sending next stanzas
     lassign [wait_for_answer $s] res child
 
-    update_tkabber_lists $connid $name $items $postitems $res $child
+    update_tkabber_lists $xlib $name $items $postitems $res $child
 }
 
 # subscription-list is responsible for blocking all messages
 # not from the roster.
-proc privacy::send_subscription_list {connid} {
+proc privacy::send_subscription_list {xlib} {
     variable seq
     variable accept_from_roster_only
 
-    if {![is_supported $connid]} {
+    if {![is_supported $xlib]} {
 	return
     }
 
     if {$accept_from_roster_only} {
-	set items [list [jlib::wrapper:createtag item \
-			     -vars [list type subscription \
-					 value none \
-					 action deny \
-					 order 0]]]
+	set items [list [::xmpp::xml::create item \
+				-attrs [list type   subscription \
+					     value  none \
+					     action deny \
+					     order  0]]]
     } else {
 	set items {}
     }
@@ -929,38 +903,32 @@
     set s [incr seq]
     # If items aren't empty, we'll never send unavailable presence to
     # all users to whom directed presence was sent. Bug?
-    send_list_iq "subscription-list" $items \
-	-command [list [namespace current]::get_answer $s] \
-	-connection $connid
+    send_list_iq $xlib "subscription-list" $items \
+	-command [list [namespace current]::get_answer $s]
 
     # We have to vwait because all privacy lists should be updated
     # before sending next stanzas
     lassign [wait_for_answer $s] res child
 
-    update_tkabber_lists $connid subscription $items {} $res $child
+    update_tkabber_lists $xlib subscription $items {} $res $child
 }
 
-proc privacy::on_accept_from_roster_only_change {args} {
-    foreach {opt val} $args {
-	switch -- $opt {
-	    -connection { set connid $val }
-	}
+proc privacy::on_accept_from_roster_only_change {xlib} {
+    if {$xlib == ""} {
+	set xlib [first_supported]
     }
-    if {![info exists connid]} {
-	set connid [first_supported]
-    }
-    if {$connid == ""} return
+    if {$xlib == ""} return
 
-    send_subscription_list $connid
+    send_subscription_list $xlib
 }
 
-proc privacy::update_tkabber_lists {connid name items postitems res child} {
+proc privacy::update_tkabber_lists {xlib name items postitems res child} {
     global userstatus textstatus statusdesc
     variable send_messages
     variable special_list
     variable cboxes
 
-    if {$res == "DISCONNECT"} return
+    if {$res == "abort"} return
 
     switch -- $name {
 	subscription {
@@ -968,17 +936,17 @@
 	}
 	default {
 	    # Workaround for servers without privacy list support/push
-	    if {$res == "OK"} {
-		set special_list($connid,$name) $items
+	    if {$res == "ok"} {
+		set special_list($xlib,$name) $items
 	    }
-	    array unset cboxes $connid,$name,*
-	    foreach jid $special_list($connid,$name) {
-		set cboxes($connid,$name,$jid) 1
+	    array unset cboxes $xlib,$name,*
+	    foreach jid $special_list($xlib,$name) {
+		set cboxes($xlib,$name,$jid) 1
 	    }
 	}
     }
 
-    if {$res == "ERR"} {
+    if {$res == "error"} {
 	MessageDlg .privacy_list_err -aspect 50000 -icon error \
 	    -message [format $send_messages($name) [error_to_string $child]] \
 	    -type user -buttons ok -default 0 -cancel 0
@@ -990,22 +958,22 @@
 	conference -
 	subscription {
 	    # Some inefficiency here. We load three lists twice.
-	    join_lists $connid "i-am-visible-list" \
+	    join_lists $xlib "i-am-visible-list" \
 		       {ignore-list invisible-list conference-list subscription-list} \
 		       {allow {} {}}
-	    join_lists $connid "i-am-invisible-list" \
+	    join_lists $xlib "i-am-invisible-list" \
 		       {ignore-list visible-list conference-list subscription-list} \
-		       [list deny {} [list [jlib::wrapper:createtag presence-out]]]
+		       [list deny {} [list [::xmpp::xml::create presence-out]]]
 	}
 	invisible {
-	    join_lists $connid "i-am-visible-list" \
+	    join_lists $xlib "i-am-visible-list" \
 		       {ignore-list invisible-list conference-list subscription-list} \
 		       {allow {} {}}
 	}
 	visible {
-	    join_lists $connid "i-am-invisible-list" \
+	    join_lists $xlib "i-am-invisible-list" \
 		       {ignore-list visible-list conference-list subscription-list} \
-		       [list deny {} [list [jlib::wrapper:createtag presence-out]]]
+		       [list deny {} [list [::xmpp::xml::create presence-out]]]
 	}
     }
 
@@ -1025,12 +993,12 @@
     }
 
     foreach jid $postitems {
-	send_presence $status -to $jid -stat $tstatus -connection $connid
+	send_presence $xlib $status -to $jid -status $tstatus
     }
 }
 
 
-proc privacy::join_lists {connid name lists fallbacks args} {
+proc privacy::join_lists {xlib name lists fallbacks args} {
     variable litems
 
     set items {}
@@ -1038,62 +1006,61 @@
 
     # Appending myself to the list to make sure we can communicate
     # between own resources
-    lappend items [jlib::wrapper:createtag item \
-		       -vars [list type jid \
-				   value [jlib::connection_bare_jid $connid] \
-				   action allow \
-				   order $i]]
+    lappend items [::xmpp::xml::create item \
+			    -attrs [list type   jid \
+					 value  [connection_bare_jid $xlib] \
+					 action allow \
+					 order  $i]]
     incr i
 
     foreach ln $lists {
-	jlib::send_iq get \
-	    [jlib::wrapper:createtag query \
-		 -vars [list xmlns $::NS(privacy)] \
-		 -subtags [list [jlib::wrapper:createtag list \
-				     -vars [list name $ln]]]] \
-	    -command [list [namespace current]::get_items $connid] \
-	    -connection $connid
+	::xmpp::sendIQ $xlib get \
+	    -query [::xmpp::xml::create query \
+			    -xmlns $::NS(privacy) \
+			    -subelement [::xmpp::xml::create list \
+						-attrs [list name $ln]]] \
+	    -command [list [namespace current]::get_items $xlib]
 
-	vwait [namespace current]::litems($connid)
+	vwait [namespace current]::litems($xlib)
 
-	foreach item $litems($connid) {
-	    jlib::wrapper:splitxml $item tag vars isempty chdata children
+	foreach item $litems($xlib) {
+	    ::xmpp::xml::split $item tag xmlns attrs cdata subels
 	    catch { array unset tmp }
-	    array set tmp $vars
+	    array set tmp $attrs
 	    set tmp(order) $i
-	    lappend items [jlib::wrapper:createtag $tag \
-			       -vars [array get tmp] \
-			       -subtags $children]
+	    lappend items [::xmpp::xml::create $tag \
+				    -attrs [array get tmp] \
+				    -subelements $subels]
 	    incr i
 	}
     }
-    unset litems($connid)
+    unset litems($xlib)
 
     foreach {action vars subtags} $fallbacks {
-	lappend items [jlib::wrapper:createtag item \
-			   -vars [concat [list action $action order $i] $vars] \
-			   -subtags $subtags]
+	lappend items [::xmpp::xml::create item \
+			   -attrs [concat [list action $action order $i] $vars] \
+			   -subelements $subtags]
     }
 
-    eval { send_list_iq $name $items -connection $connid } $args
+    eval { send_list_iq $xlib $name $items } $args
 }
 
 
-proc privacy::get_items {connid res child} {
+proc privacy::get_items {xlib res child} {
     variable litems
 
-    if {$res != "OK"} {
-	set litems($connid) {}
+    if {$res != "ok"} {
+	set litems($xlib) {}
 	return
     }
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
-    jlib::wrapper:splitxml [lindex $children 0] tag vars isempty chdata children
+    ::xmpp::xml::split $child tag xmlns attrs cdata subels
+    ::xmpp::xml::split [lindex $subels 0] tag xmlns attrs cdata subels
 
     if {$tag == "list"} {
-	set litems($connid) $children
+	set litems($xlib) $subels
     } else {
-	set litems($connid) {}
+	set litems($xlib) {}
     }
 }
 
@@ -1122,10 +1089,10 @@
 proc privacy::fill_edit_special_lists {f items} {
     foreach item $items {
 	if {$item != ""} {
-	    jlib::wrapper:splitxml $item tag vars isempty chdata children
+	    ::xmpp::xml::split $item tag xmlns attrs cdata subels
 	    if {$tag == "list"} {
-		set name [jlib::wrapper:getattr $vars name]
-		fill_edit_special_list $f $name $children
+		set name [::xmpp::xml::getAttr $attrs name]
+		fill_edit_special_list $f $name $subels
 		break
 	    }
 	}
@@ -1136,13 +1103,13 @@
 proc privacy::fill_edit_special_list {fr name items} {
     set values {}
     foreach item $items {
-	jlib::wrapper:splitxml $item tag vars isempty chdata children
+	::xmpp::xml::split $item tag xmlns attrs cdata subels
 
-	set type   [jlib::wrapper:getattr $vars type]
+	set type [::xmpp::xml::getAttr $attrs type]
 	if {$type != "jid"} {
 	    continue
 	}
-	lappend values [jlib::wrapper:getattr $vars value]
+	lappend values [::xmpp::xml::getAttr $attrs value]
     }
 
     eval [list $fr insert end] [lrmdups [lsort -dictionary $values]]
@@ -1176,7 +1143,7 @@
 # If activation or creation fails then terminate connect with error message
 #
 
-proc privacy::activate_privacy_list {depth connid} {
+proc privacy::activate_privacy_list {depth xlib} {
     variable seq
     variable options
 
@@ -1184,18 +1151,17 @@
     debugmsg privacy "requested privacy list activation"
 
     set s [incr seq]
-    send_default_or_active_list "i-am-visible-list" active \
-	-command [list [namespace current]::get_answer $s] \
-	-connection $connid
+    send_default_or_active_list $xlib "i-am-visible-list" active \
+	-command [list [namespace current]::get_answer $s]
 
     lassign [wait_for_answer $s] res child
 
     switch -- $res {
-	"OK" {
+	ok {
 	    set_status [::msgcat::mc "Privacy list is activated"]
-	    set_supported $connid
+	    set_supported $xlib
 	}
-	"ERR" {
+	error {
 	    switch -- [lindex [error_type_condition $child] 1] {
 		feature-not-implemented {
 		    # Privacy lists aren't implemented
@@ -1223,7 +1189,7 @@
 			[::msgcat::mc "Creating default privacy list"]
 
 		    set s [incr seq]
-		    join_lists $connid "i-am-visible-list" \
+		    join_lists $xlib "i-am-visible-list" \
 			{ignore-list invisible-list conference-list subscription-list} \
 			{allow {} {}} \
 			-command [list [namespace current]::get_answer $s]
@@ -1231,18 +1197,18 @@
 		    lassign [wait_for_answer $s] res child
 
 		    switch -- $res {
-			"OK" {
+			ok {
 			    # Activate newly created list
-			    set_supported $connid
+			    set_supported $xlib
 			    return [activate_privacy_list [expr {$depth + 1}] \
-							  $connid]
+							  $xlib]
 			}
-			"ERR" {
+			error {
 			    # Disconnect with error message
 			    set_status \
 				[::msgcat::mc "Privacy list is not created"]
 
-			    NonmodalMessageDlg .privacy_list_error$connid \
+			    NonmodalMessageDlg .privacy_list_error$xlib \
 				-aspect 50000 -icon error \
 				-title [::msgcat::mc "Privacy lists error"] \
 				-message \
@@ -1253,13 +1219,13 @@
 					 list activation at start" \
 				    [error_to_string $child]]
 
-			    logout $connid
+			    logout $xlib
 
 			    # Break connected_hook
 			    return stop
 			}
 			default {
-			    # "DISCONNECT"
+			    # "abort"
 			    set_status \
 				[::msgcat::mc "Privacy list is not created"]
 
@@ -1274,7 +1240,7 @@
 		    set_status \
 			[::msgcat::mc "Privacy list is not activated"]
 
-		    NonmodalMessageDlg .privacy_list_error$connid \
+		    NonmodalMessageDlg .privacy_list_error$xlib \
 			-aspect 50000 -icon error \
 			-title [::msgcat::mc "Privacy lists error"] \
 			-message \
@@ -1285,7 +1251,7 @@
 				 list activation at start" \
 			    [error_to_string $child]]
 
-		    logout $connid
+		    logout $xlib
 
 		    # Break connected_hook
 		    return stop
@@ -1293,7 +1259,7 @@
 	    }
 	}
 	default {
-	    # "DISCONNECT"
+	    # "abort"
 	    set_status [::msgcat::mc "Privacy list is not activated"]
 
 	    # Break connected_hook
@@ -1304,11 +1270,11 @@
 
 ##########################################################################
 
-proc privacy::activate_privacy_list_at_startup {connid} {
+proc privacy::activate_privacy_list_at_startup {xlib} {
     variable options
 
     if {$options(activate_at_startup)} {
-	activate_privacy_list 0 $connid
+	activate_privacy_list 0 $xlib
     }
 }
 
@@ -1335,25 +1301,25 @@
 
 ###############################################################################
 
-proc privacy::is_supported {connid} {
+proc privacy::is_supported {xlib} {
     variable supported
 
-    expr {[info exists supported($connid)] && $supported($connid)}
+    expr {[info exists supported($xlib)] && $supported($xlib)}
 }
 
-proc privacy::set_supported {connid} {
+proc privacy::set_supported {xlib} {
     variable supported
 
-    set supported($connid) 1
+    set supported($xlib) 1
 }
 
-proc privacy::clear_supported {connid} {
+proc privacy::clear_supported {xlib} {
     variable supported
 
-    if {$connid == ""} {
+    if {$xlib == ""} {
 	catch { array unset supported * }
     } else {
-	catch { array unset supported $connid }
+	catch { array unset supported $xlib }
     }
 }
 
@@ -1361,19 +1327,19 @@
 
 ###############################################################################
 
-proc privacy::create_menu {m connid jid} {
+proc privacy::create_menu {m xlib jid} {
     variable menu_messages
     variable special_list
     variable cboxes
 
-    set rjid [roster::find_jid $connid $jid]
+    set rjid [roster::find_jid $xlib $jid]
 
     if {$rjid == ""} {
  	set rjid [node_and_server_from_jid $jid]
     }
 
-    if {![is_supported $connid] || \
-	    [chat::is_groupchat [chat::chatid $connid $rjid]]} {
+    if {![is_supported $xlib] || \
+	    [chat::is_groupchat [chat::chatid $xlib $rjid]]} {
 	set state disabled
     } else {
 	set state normal
@@ -1382,18 +1348,18 @@
     set mm [menu $m.privacy_menu -tearoff 0]
 
     foreach name {invisible ignore} {
-	if {![info exists special_list($connid,$name)]} {
-	    set special_list($connid,$name) {}
+	if {![info exists special_list($xlib,$name)]} {
+	    set special_list($xlib,$name) {}
 	}
 
-	if {[lsearch -exact $special_list($connid,$name) $rjid] >= 0} {
-	    set cboxes($connid,$name,$rjid) 1
+	if {[lsearch -exact $special_list($xlib,$name) $rjid] >= 0} {
+	    set cboxes($xlib,$name,$rjid) 1
 	}
 
 	$mm add checkbutton -label $menu_messages($name) \
-	    -variable [namespace current]::cboxes($connid,$name,$rjid) \
+	    -variable [namespace current]::cboxes($xlib,$name,$rjid) \
 	    -command [list [namespace current]::update_special_list \
-			   $connid $name $rjid]
+			   $xlib $name $rjid]
     }
 
     $m add cascade -label [::msgcat::mc "Privacy rules"] \
@@ -1411,82 +1377,82 @@
 
 ###############################################################################
 
-proc privacy::update_special_list {connid name jid} {
+proc privacy::update_special_list {xlib name jid} {
     variable cboxes
 
-    if {[info exists cboxes($connid,$name,$jid)] && $cboxes($connid,$name,$jid)} {
-	add_to_special_list $connid $name $jid
+    if {[info exists cboxes($xlib,$name,$jid)] && $cboxes($xlib,$name,$jid)} {
+	add_to_special_list $xlib $name $jid
     } else {
-	remove_from_special_list $connid $name $jid
+	remove_from_special_list $xlib $name $jid
     }
 }
 
 ###############################################################################
 
-proc privacy::add_to_special_list {connid name jid} {
+proc privacy::add_to_special_list {xlib name jid} {
     variable special_list
 
-    if {![info exists special_list($connid,$name)]} {
-	set special_list($connid,$name) {}
+    if {![info exists special_list($xlib,$name)]} {
+	set special_list($xlib,$name) {}
     }
 
-    set idx [lsearch -exact $special_list($connid,$name) $jid]
+    set idx [lsearch -exact $special_list($xlib,$name) $jid]
 
     if {$idx < 0} {
-	send_special_list $connid $name \
-			  [linsert $special_list($connid,$name) 0 $jid]
+	send_special_list $xlib $name \
+			  [linsert $special_list($xlib,$name) 0 $jid]
     }
 }
 
 ###############################################################################
 
-proc privacy::remove_from_special_list {connid name jid} {
+proc privacy::remove_from_special_list {xlib name jid} {
     variable special_list
 
-    if {![info exists special_list($connid,$name)]} {
-	set special_list($connid,$name) {}
+    if {![info exists special_list($xlib,$name)]} {
+	set special_list($xlib,$name) {}
     }
 
-    set idx [lsearch -exact $special_list($connid,$name) $jid]
+    set idx [lsearch -exact $special_list($xlib,$name) $jid]
 
     if {$idx >= 0} {
-	send_special_list $connid $name \
-			  [lreplace $special_list($connid,$name) $idx $idx]
+	send_special_list $xlib $name \
+			  [lreplace $special_list($xlib,$name) $idx $idx]
     }
 }
 
 ###############################################################################
 
-proc privacy::process_iq {connid from lang child} {
+proc privacy::process_iq {xlib from child args} {
     if {$from != "" && \
-	    !([string equal -nocase $from [jlib::connection_server $connid]] || \
-	      [string equal -nocase $from [jlib::connection_bare_jid $connid]] || \
-	      [string equal -nocase $from [jlib::connection_jid $connid]])} {
+	    !([string equal -nocase $from [connection_server $xlib]] || \
+	      [string equal -nocase $from [connection_bare_jid $xlib]] || \
+	      [string equal -nocase $from [connection_jid $xlib]])} {
 	return {error cancel not-allowed}
     }
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
+    ::xmpp::xml::split $child tag xmlns attrs cdata subels
 
-    foreach ch $children {
-	jlib::wrapper:splitxml $ch tag1 vars1 isempty1 chdata1 children1
+    foreach ch $subels {
+	::xmpp::xml::split $ch stag sxmlns sattrs scdata ssubels
 
-	switch -- $tag1 {
+	switch -- $stag {
 	    list {
-		switch -- [jlib::wrapper:getattr $vars1 name] {
+		switch -- [::xmpp::xml::getAttr $sattrs name] {
 		    invisible-list {
-			reload_special_list $connid invisible
+			reload_special_list $xlib invisible
 		    }
 		    visible-list {
-			reload_special_list $connid visible
+			reload_special_list $xlib visible
 		    }
 		    ignore-list {
-			reload_special_list $connid ignore
+			reload_special_list $xlib ignore
 		    }
 		    conference-list {
-			reload_special_list $connid conference
+			reload_special_list $xlib conference
 		    }
 		    subscription-list {
-			reload_subscription_list $connid
+			reload_subscription_list $xlib
 		    }
 		}
 	    }
@@ -1495,21 +1461,21 @@
     return {result {}}
 }
 
-iq::register_handler set query $::NS(privacy) \
+::xmpp::iq::register set query $::NS(privacy) \
 		     [namespace current]::privacy::process_iq
 
 ###############################################################################
 
-proc privacy::clear_list_vars {connid} {
+proc privacy::clear_list_vars {xlib} {
     variable special_list
     variable cboxes
 
-    if {$connid == ""} {
+    if {$xlib == ""} {
 	catch { array unset special_list * }
 	catch { array unset cboxes * }
     } else {
-	catch { array unset special_list $connid,* }
-	catch { array unset cboxes $connid,* }
+	catch { array unset special_list $xlib,* }
+	catch { array unset cboxes $xlib,* }
     }
 }
 
@@ -1518,107 +1484,104 @@
 ###############################################################################
 # Conference list should be loaded before any join group attempt is made
 
-proc privacy::get_conference_list {connid} {
+proc privacy::get_conference_list {xlib} {
     variable seq
 
     set s [incr seq]
-    jlib::send_iq get \
-	[jlib::wrapper:createtag query \
-	     -vars [list xmlns $::NS(privacy)] \
-	     -subtags [list [jlib::wrapper:createtag list \
-				 -vars [list name "conference-list"]]]] \
-	-command [list [namespace current]::get_answer $s] \
-	-connection $connid
+    ::xmpp::sendIQ $xlib get \
+	-query [::xmpp::xml::create query \
+			-xmlns $::NS(privacy) \
+			-subelement [::xmpp::xml::create list \
+					    -attrs [list name "conference-list"]]] \
+	-command [list [namespace current]::get_answer $s]
 
     lassign [wait_for_answer $s] res child
 
-    if {($res == "OK") || \
-	    ($res == "ERR" && \
+    if {($res == "ok") || \
+	    ($res == "error" && \
 	     [lindex [error_type_condition $child] 1] == "item-not-found")} {
-	set_supported $connid
+	set_supported $xlib
     }
 
-    store_special_list $connid conference $res $child
+    store_special_list $xlib conference $res $child
 }
 
 hook::add connected_hook [namespace current]::privacy::get_conference_list 2
 
 ###############################################################################
 
-proc privacy::get_list_vars {connid} {
+proc privacy::get_list_vars {xlib} {
     foreach name {invisible visible ignore} {
-	reload_special_list $connid $name
+	reload_special_list $xlib $name
     }
-    reload_subscription_list $connid
+    reload_subscription_list $xlib
 }
 
 hook::add connected_hook [namespace current]::privacy::get_list_vars
 
 ###############################################################################
 
-proc privacy::reload_special_list {connid name} {
-    jlib::send_iq get \
-	[jlib::wrapper:createtag query \
-	     -vars [list xmlns $::NS(privacy)] \
-	     -subtags [list [jlib::wrapper:createtag list \
-				 -vars [list name "$name-list"]]]] \
-	-command [list [namespace current]::store_special_list $connid $name] \
-	-connection $connid
+proc privacy::reload_special_list {xlib name} {
+    ::xmpp::sendIQ $xlib get \
+	-query [::xmpp::xml::create query \
+		    -xmlns $::NS(privacy) \
+		    -subelement [::xmpp::xml::create list \
+				    -attrs [list name "$name-list"]]] \
+	-command [list [namespace current]::store_special_list $xlib $name]
 }
 
-proc privacy::store_special_list {connid name res child} {
+proc privacy::store_special_list {xlib name res child} {
     variable special_list
     variable cboxes
 
-    set special_list($connid,$name) {}
-    array unset cboxes $connid,$name,*
+    set special_list($xlib,$name) {}
+    array unset cboxes $xlib,$name,*
 
-    if {$res != "OK"} return
+    if {$res != "ok"} return
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
-    jlib::wrapper:splitxml [lindex $children 0] tag vars isempty chdata children
+    ::xmpp::xml::split $child tag xmlns attrs cdata subels
+    ::xmpp::xml::split [lindex $subels 0] tag xmlns attrs cdata subels
 
     if {$tag != "list"} return
 
-    foreach item $children {
-	jlib::wrapper:splitxml $item tag1 vars1 isempty1 chdata1 children1
-	if {[jlib::wrapper:getattr $vars1 type] == "jid" && \
-		[set jid [jlib::wrapper:getattr $vars1 value]] != ""} {
-	    lappend special_list($connid,$name) $jid
-	    set cboxes($connid,$name,$jid) 1
+    foreach item $subels {
+	::xmpp::xml::split $item stag sxmlns sattrs scdata ssubels
+	if {[::xmpp::xml::getAttr $sattrs type] == "jid" && \
+		[set jid [::xmpp::xml::getAttr $sattrs value]] != ""} {
+	    lappend special_list($xlib,$name) $jid
+	    set cboxes($xlib,$name,$jid) 1
 	}
     }
 }
 
 ###############################################################################
 
-proc privacy::reload_subscription_list {connid} {
-    jlib::send_iq get \
-	[jlib::wrapper:createtag query \
-	     -vars [list xmlns $::NS(privacy)] \
-	     -subtags [list [jlib::wrapper:createtag list \
-				 -vars [list name "subscription-list"]]]] \
-	-command [list [namespace current]::store_subscription_list $connid] \
-	-connection $connid
+proc privacy::reload_subscription_list {xlib} {
+    ::xmpp::sendIQ $xlib get \
+	-query [::xmpp::xml::create query \
+		    -xmlns $::NS(privacy) \
+		    -subelement [::xmpp::xml::create list \
+				    -attrs [list name "subscription-list"]]] \
+	-command [list [namespace current]::store_subscription_list $xlib]
 }
 
-proc privacy::store_subscription_list {connid res child} {
+proc privacy::store_subscription_list {xlib res child} {
     variable accept_from_roster_only
 
     set accept_from_roster_only 0
 
-    if {$res != "OK"} return
+    if {$res != "ok"} return
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
-    jlib::wrapper:splitxml [lindex $children 0] tag vars isempty chdata children
+    ::xmpp::xml::split $child tag xmlns attrs cdata subels
+    ::xmpp::xml::split [lindex $subels 0] tag xmlns attrs cdata subels
 
     if {$tag != "list"} return
 
-    foreach item $children {
-	jlib::wrapper:splitxml $item tag1 vars1 isempty1 chdata1 children1
-	if {[jlib::wrapper:getattr $vars1 type] == "subscription" && \
-		[jlib::wrapper:getattr $vars1 value] == "none" && \
-		[jlib::wrapper:getattr $vars1 action] == "deny"} {
+    foreach item $subels {
+	::xmpp::xml::split $item stag sxmlns sattrs scdata ssubels
+	if {[::xmpp::xml::getAttr $sattrs type] == "subscription" && \
+		[::xmpp::xml::getAttr $sattrs value] == "none" && \
+		[::xmpp::xml::getAttr $sattrs action] == "deny"} {
 	    set accept_from_roster_only 1
 	}
     }
@@ -1627,9 +1590,9 @@
 ###############################################################################
 
 proc privacy::first_supported {} {
-    foreach connid [jlib::connections] {
-	if {[is_supported $connid]} {
-	    return $connid
+    foreach xlib [connections] {
+	if {[is_supported $xlib]} {
+	    return $xlib
 	}
     }
     return ""
@@ -1637,7 +1600,7 @@
 
 ###############################################################################
 
-proc privacy::enable_menu {connid} {
+proc privacy::enable_menu {xlib} {
 
     if {[first_supported] == ""} return
 
@@ -1652,7 +1615,7 @@
     }
 }
 
-proc privacy::disable_menu {connid} {
+proc privacy::disable_menu {xlib} {
 
     if {[first_supported] != ""} return
 

Modified: trunk/tkabber/private.tcl
===================================================================
--- trunk/tkabber/private.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/private.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -5,64 +5,52 @@
 
 namespace eval private {}
 
-proc private::store {query args} {
+proc private::store {xlib query args} {
     set command ""
     foreach {key val} $args {
 	switch -- $key {
 	    -command { set command $val }
-	    -connection { set connid $val }
 	}
     }
 
-    if {![info exists connid]} {
-	return -code error "private::store: -connection is mandatory"
-    }
-
-    jlib::send_iq set \
-	[jlib::wrapper:createtag query \
-	     -vars [list xmlns $::NS(private)] \
-	     -subtags $query] \
-	-command [list [namespace current]::store_result $command] \
-	-connection $connid
+    ::xmpp::sendIQ $xlib set \
+	-query [::xmpp::xml::create query \
+			-xmlns $::NS(private) \
+			-subelements $query] \
+	-command [list [namespace current]::store_result $command]
 }
 
-proc private::store_result {command res child} {
+proc private::store_result {command status xml} {
     if {$command != ""} {
-	uplevel #0 $command [list $res $child]
+	uplevel #0 $command [list $status $xml]
     }
 }
 
-proc private::retrieve {query args} {
+proc private::retrieve {xlib query args} {
     set command ""
     foreach {key val} $args {
 	switch -- $key {
 	    -command { set command $val }
-	    -connection { set connid $val }
 	}
     }
 
-    if {![info exists connid]} {
-	return -code error "private::retrieve: -connection is mandatory"
-    }
-
-    jlib::send_iq get \
-	[jlib::wrapper:createtag query \
-	     -vars [list xmlns $::NS(private)] \
-	     -subtags $query] \
-	-command [list [namespace current]::retrieve_result $command] \
-	-connection $connid
+    ::xmpp::sendIQ $xlib get \
+	-query [::xmpp::xml::create query \
+			-xmlns $::NS(private) \
+			-subelements $query] \
+	-command [list [namespace current]::retrieve_result $command]
 }
 
-proc private::retrieve_result {command res child} {
+proc private::retrieve_result {command status xml} {
     if {$command == ""} return
 
-    if {$res != "OK"} {
-	uplevel #0 $command [list $res $child]
+    if {$status != "ok"} {
+	uplevel #0 $command [list $status $xml]
 	return
     }
 
-    jlib::wrapper:splitxml $child tag vars isempty cdata children
+    ::xmpp::xml::split $xml tag xmlns attrs cdata subels
 
-    uplevel #0 $command [list OK $children]
+    uplevel #0 $command [list ok $subels]
 }
 

Modified: trunk/tkabber/pubsub.tcl
===================================================================
--- trunk/tkabber/pubsub.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/pubsub.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -95,33 +95,26 @@
 # Evaluates command for attribute lists
 #
 
-proc pubsub::retrieve_subscriptions {service args} {
+proc pubsub::retrieve_subscriptions {xlib service args} {
 
     debugmsg pubsub [info level 0]
 
     set command ""
     foreach {key val} $args {
 	switch -- $key {
-	    -connection { set connid $val}
 	    -command { set command $val }
 	}
     }
 
-    if {![info exists connid]} {
-	return -code error \
-	       "pubsub::retrieve_subscriptions: -connection is mandatory"
-    }
-
     if {$node == ""} {
 	return -code error "pubsub::retrieve_subscriptions: Node is empty"
     }
 
-    jlib::send_iq set \
-	[jlib::wrapper:createtag pubsub \
-	     -vars [list xmlns $::NS(pubsub)] \
-	     -subtags [list [jlib::wrapper:createtag subscriptions]]] \
+    ::xmpp::sendIQ $xlib set \
+	-query [::xmpp::xml::create pubsub \
+		    -xmlns $::NS(pubsub) \
+		    -subelement [::xmpp::xml::create subscriptions]] \
 	-to $service \
-	-connection $connid \
 	-command [list [namespace current]::retrieve_subscriptions_result $command]
 }
 
@@ -129,7 +122,7 @@
 
     debugmsg pubsub [info level 0]
 
-    if {$res != "OK"} {
+    if {$res != "ok"} {
 	if {$command != ""} {
 	    eval $command [list $res $child]
 	}
@@ -138,19 +131,19 @@
 
     set items {}
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
+    ::xmpp::xml::split $child tag xmlns attrs cdata subels
 
-    foreach ch $children {
-	jlib::wrapper:splitxml $ch tag1 vars1 isempty1 chdata1 children1
+    foreach ch $subels {
+	::xmpp::xml::split $ch stag sxmlns sattrs scdata ssubels
 
-	if {$tag1 != "subscriptions"} continue
+	if {$stag != "subscriptions"} continue
 
-	foreach item $children1 {
-	    jlib::wrapper:splitxml \
-		$item tag2 vars2 isempty2 chdata2 children2
+	foreach item $ssubels {
+	    ::xmpp::xml::split \
+		$item sstag ssxmlns ssattrs sscdata sssubels
 
-	    if {$tag2 == "subscription"} {
-		lappend items $vars2
+	    if {$sstag == "subscription"} {
+		lappend items $ssattrs
 	    }
 	}
     }
@@ -167,33 +160,26 @@
 # Evaluates command for attribute lists
 #
 
-proc pubsub::retrieve_affiliations {service args} {
+proc pubsub::retrieve_affiliations {xlib service args} {
 
     debugmsg pubsub [info level 0]
 
     set command ""
     foreach {key val} $args {
 	switch -- $key {
-	    -connection { set connid $val}
 	    -command { set command $val }
 	}
     }
 
-    if {![info exists connid]} {
-	return -code error \
-	       "pubsub::retrieve_affiliations: -connection is mandatory"
-    }
-
     if {$node == ""} {
 	return -code error "pubsub::retrieve_affiliations: Node is empty"
     }
 
-    jlib::send_iq set \
-	[jlib::wrapper:createtag pubsub \
-	     -vars [list xmlns $::NS(pubsub)] \
-	     -subtags [list [jlib::wrapper:createtag affiliations]]] \
+    ::xmpp::sendIQ $xlib set \
+	-query [::xmpp::xml::create pubsub \
+		    -xmlns $::NS(pubsub) \
+		    -subelement [::xmpp::xml::create affiliations]] \
 	-to $service \
-	-connection $connid \
 	-command [list [namespace current]::retrieve_affiliations_result $command]
 }
 
@@ -201,7 +187,7 @@
 
     debugmsg pubsub [info level 0]
 
-    if {$res != "OK"} {
+    if {$res != "ok"} {
 	if {$command != ""} {
 	    eval $command [list $res $child]
 	}
@@ -210,19 +196,19 @@
 
     set items {}
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
+    ::xmpp::xml::split $child tag xmlns attrs cdata subels
 
-    foreach ch $children {
-	jlib::wrapper:splitxml $ch tag1 vars1 isempty1 chdata1 children1
+    foreach ch $subels {
+	::xmpp::xml::split $ch stag sxmlns sattrs scdata ssubels
 
-	if {$tag1 != "affiliations"} continue
+	if {$stag != "affiliations"} continue
 
-	foreach item $children1 {
-	    jlib::wrapper:splitxml \
-		$item tag2 vars2 isempty2 chdata2 children2
+	foreach item $ssubels {
+	    ::xmpp::xml::split \
+		$item sstag ssxmlns ssattrs sscdata sssubels
 
-	    if {$tag2 == "affiliation"} {
-		lappend items $vars2
+	    if {$sstag == "affiliation"} {
+		lappend items $ssattrs
 	    }
 	}
     }
@@ -261,7 +247,7 @@
 # -subscription_depth
 #
 
-proc pubsub::subscribe {service node args} {
+proc pubsub::subscribe {$xlib service node args} {
     variable ns
 
     debugmsg pubsub [info level 0]
@@ -272,7 +258,6 @@
 	switch -- $key {
 	    -jid { set jid $val }
 	    -resource { set resource $val }
-	    -connection { set connid $val}
 	    -command { set command $val }
 	    -deliver -
 	    -digest -
@@ -286,12 +271,8 @@
 	}
     }
 
-    if {![info exists connid]} {
-	return -code error "pubsub::subscribe: -connection is mandatory"
-    }
-
     if {![info exists jid]} {
-	set jid [jlib::connection_bare_jid $connid]
+	set jid [connection_bare_jid $xlib]
     }
 
     if {[info exists resource]} {
@@ -305,24 +286,23 @@
 
     if {![lempty $options]} {
 	set options \
-	    [list [jlib::wrapper:createtag options \
-		       -subtags \
-			   [list [jlib::wrapper:createtag x \
-				      -vars [list xmlns $::NS(data) \
-						  type submit] \
-				      -subtags \
-					  [linsert $options 0 \
-						   [form_type $ns(subscribe_options)]]]]]]
+	    [::xmpp::xml::create options \
+		    -subelement \
+			[::xmpp::xml::create x \
+			    -xmlns $::NS(data) \
+			    -attrs [list type submit] \
+			    -subelements \
+				[linsert $options 0 \
+					 [form_type $ns(subscribe_options)]]]]
     }
 
-    jlib::send_iq set \
-	[jlib::wrapper:createtag pubsub \
-	     -vars [list xmlns $::NS(pubsub)] \
-	     -subtags [concat [list [jlib::wrapper:createtag subscribe \
-					 -vars $vars]] \
-			      $options]] \
+    ::xmpp::sendIQ $xlib set \
+	-query [::xmpp::xml::create pubsub \
+		    -xmlns $::NS(pubsub) \
+		    -subelement [::xmpp::xml::create subscribe \
+					 -attrs $vars] \
+		    -subelement $options] \
 	-to $service \
-	-connection $connid \
 	-command [list [namespace current]::subscribe_result $command]
 }
 
@@ -330,19 +310,19 @@
 
     debugmsg pubsub [info level 0]
 
-    if {$res == "OK"} {
-	jlib::wrapper:splitxml $child tag vars isempty chdata children
+    if {$res == "ok"} {
+	::xmpp::xml::split $child tag xmlns attrs cdata subels
 
-	if {[jlib::wrapper:getattr $vars xmlns] == $::NS(pubsub)} {
-	    foreach child1 $children {
-		jlib::wrapper:splitxml \
-		    $child1 tag1 vars1 isempty1 chdata1 children1
-		if {$tag == "subscription"} {
-		    set node [jlib::wrapper:getattr $vars1 node]
-		    set jid [jlib::wrapper:getattr $vars1 jid]
-		    set subid [jlib::wrapper:getattr $vars1 subid]
+	if {$xmlns == $::NS(pubsub)} {
+	    foreach subel $subels {
+		::xmpp::xml::split $subel stag sxmlns sattrs scdata ssubels
+
+		if {$stag == "subscription"} {
+		    set node [::xmpp::xml::getAttr $sattrs node]
+		    set jid [::xmpp::xml::getAttr $sattrs jid]
+		    set subid [::xmpp::xml::getAttr $sattrs subid]
 		    set subscription \
-			[jlib::wrapper:getattr $vars1 subscription]
+			[::xmpp::xml::getAttr $sattrs subscription]
 		    # TODO: subscription-options
 		    if {$command != ""} {
 			eval $command [list $res \
@@ -380,7 +360,7 @@
 # request
 #
 
-proc pubsub::unsubscribe {service node args} {
+proc pubsub::unsubscribe {xlib service node args} {
 
     debugmsg pubsub [info level 0]
 
@@ -390,17 +370,12 @@
 	    -jid { set jid $val }
 	    -subid { set subid $val }
 	    -resource { set resource $val }
-	    -connection { set connid $val}
 	    -command { set command $val }
 	}
     }
 
-    if {![info exists connid]} {
-	return -code error "pubsub::unsubscribe: -connection is mandatory"
-    }
-
     if {![info exists jid]} {
-	set jid [jlib::connection_bare_jid $connid]
+	set jid [connection_bare_jid $xlib]
     }
 
     if {[info exists resource]} {
@@ -415,13 +390,12 @@
 	lappend vars subid $subid
     }
 
-    jlib::send_iq set \
-	[jlib::wrapper:createtag pubsub \
-	     -vars [list xmlns $::NS(pubsub)] \
-	     -subtags [list [jlib::wrapper:createtag unsubscribe \
-				 -vars $vars]]] \
+    ::xmpp::sendIQ $xlib set \
+	-query [::xmpp::xml::create pubsub \
+		    -xmlns $::NS(pubsub) \
+		    -subelement [::xmpp::xml::create unsubscribe \
+					-attrs $vars]] \
 	-to $service \
-	-connection $connid \
 	-command [list [namespace current]::unsubscribe_result $command]
 }
 
@@ -439,7 +413,7 @@
 # Configure subscription options (6.3)
 #
 
-proc pubsub::request_subscription_options {service node args} {
+proc pubsub::request_subscription_options {xlib service node args} {
 
     debugmsg pubsub [info level 0]
 
@@ -449,23 +423,17 @@
 	    -jid { set jid $val }
 	    -subid { set subid $val }
 	    -resource { set resource $val }
-	    -connection { set connid $val}
 	    -command { set command $val }
 	}
     }
 
-    if {![info exists connid]} {
-	return -code error \
-	       "pubsub::request_subscription_options: -connection is mandatory"
-    }
-
     if {$node == ""} {
 	return -code error \
 	    "pubsub::request_subscription_options: Node is empty"
     }
 
     if {![info exists jid]} {
-	set jid [jlib::connection_bare_jid $connid]
+	set jid [connection_bare_jid $xlib]
     }
 
     if {[info exists resource]} {
@@ -478,49 +446,48 @@
 	set vars [list node $node jid $jid]
     }
 
-    jlib::send_iq get \
-	[jlib::wrapper:createtag pubsub \
-	     -vars [list xmlns $::NS(pubsub)] \
-	     -subtags [list [jlib::wrapper:createtag options \
-				 -vars $vars]]] \
+    ::xmpp::sendIQ $xlib get \
+	-query [::xmpp::xml::create pubsub \
+		    -xmlns $::NS(pubsub) \
+		    -subelement [::xmpp::xml::create options \
+					-attrs $vars]] \
 	-to $service \
-	-connection $connid \
 	-command [list [namespace current]::subscription_options_result \
-		       $connid $service $command]
+		       $xlib $service $command]
 }
 
-proc pubsub::subscription_options_result {connid service command res child} {
+proc pubsub::subscription_options_result {xlib service command res child} {
 
     debugmsg pubsub [info level 0]
 
-    if {$res != "OK"} {
+    if {$res != "ok"} {
 	if {$command != ""} {
 	    eval $command [list $res $child]
 	}
 	return
     }
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
+    ::xmpp::xml::split $child tag xmlns attrs cdata subels
 
-    foreach ch $children {
-	jlib::wrapper:splitxml $ch tag1 vars1 isempty1 chdata1 children1
+    foreach ch $subels {
+	::xmpp::xml::split $ch stag sxmlns sattrs scdata ssubels
 
-	if {$tag1 == "options"} {
-	    jlib::wrapper:splitxml \
-		[lindex $children1 0] tag2 vars2 isempty2 chdata2 children2
-	    set node [jlib::wrapper:getattr $vars2 node]
-	    set jid [jlib::wrapper:getattr $vars2 jid]
-	    set subid [jlib::wrapper:getattr $vars2 subid]
+	if {$stag == "options"} {
+	    ::xmpp::xml::split \
+		[lindex $ssubels 0] sstag ssxmlns ssattrs sscdata sssubels
+	    set node [::xmpp::xml::getAttr $ssattrs node]
+	    set jid [::xmpp::xml::getAttr $ssattrs jid]
+	    set subid [::xmpp::xml::getAttr $ssattrs subid]
 	    break
 	}
     }
 
-    data::draw_window $children2 \
+    data::draw_window $sssubels \
 	[list [namespace current]::send_subscribe_options
-	      $connid $service $node $jid $subid $command]
+	      $xlib $service $node $jid $subid $command]
 }
 
-proc pubsub::send_subscribe_options {connid service node jid subid command w restags} {
+proc pubsub::send_subscribe_options {xlib service node jid subid command w restags} {
 
     debugmsg pubsub [info level 0]
 
@@ -533,13 +500,13 @@
 	set vars [list node $node jid $jid]
     }
 
-    jlib::send_iq set [jlib::wrapper:createtag pubsub \
-			   -vars [list xmlns $::NS(pubsub)] \
-			   -subtags [jlib::wrapper:createtag options \
-					 -vars $vars \
-					 -subtags $restags]] \
+    ::xmpp::sendIQ $xlib set \
+	-query [::xmpp::xml::create pubsub \
+			   -xmlns $::NS(pubsub) \
+			   -subelement [::xmpp::xml::create options \
+					    -attrs $vars \
+					    -subelements $restags]] \
 	-to $service \
-	-connection $connid \
 	-command [list data::test_error_res $w]
 }
 
@@ -552,7 +519,7 @@
 # -max_items $number (request $number last items)
 # -items $item_id_list (request specific items)
 
-proc pubsub::retrieve_items {service node args} {
+proc pubsub::retrieve_items {xlib service node args} {
 
     debugmsg pubsub [info level 0]
 
@@ -560,24 +527,18 @@
     set items {}
     foreach {key val} $args {
 	switch -- $key {
-	    -connection { set connid $val }
 	    -command { set command $val }
 	    -subid { set subid $val }
 	    -max_items { set max_items $val }
 	    -items {
 		foreach id $val {
-		    lappend items [jlib::wrapper:createtag item
-				       -vars [list id $id]]
+		    lappend items [::xmpp::xml::create item
+				       -attrs [list id $id]]
 		}
 	    }
 	}
     }
 
-    if {![info exists connid]} {
-	return -code error \
-	       "pubsub::retrieve_items: -connection is mandatory"
-    }
-
     if {$node == ""} {
 	return -code error "pubsub::retrieve_items: Node is empty"
     }
@@ -592,14 +553,13 @@
 	lappend vars max_items $max_items
     }
 
-    jlib::send_iq set \
-	[jlib::wrapper:createtag pubsub \
-	     -vars [list xmlns $::NS(pubsub)] \
-	     -subtags [list [jlib::wrapper:createtag items \
-				 -vars $vars \
-				 -subtags $items]]] \
+    ::xmpp::sendIQ $xlib set \
+	-query [::xmpp::xml::create pubsub \
+		    -xmlns $::NS(pubsub) \
+		    -subelement [::xmpp::xml::create items \
+				    -attrs $vars \
+				    -subelements $items]]] \
 	-to $service \
-	-connection $connid \
 	-command [list [namespace current]::get_items_result $command]
 }
 
@@ -607,7 +567,7 @@
 
     debugmsg pubsub [info level 0]
 
-    if {$res != "OK"} {
+    if {$res != "ok"} {
 	if {$command != ""} {
 	    eval $command [list $res $child]
 	}
@@ -616,18 +576,17 @@
 
     set items {}
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
+    ::xmpp::xml::split $child tag xmlns attrs cdata subels
 
-    foreach ch $children {
-	jlib::wrapper:splitxml $ch tag1 vars1 isempty1 chdata1 children1
+    foreach ch $subels {
+	::xmpp::xml::split $ch stag sxmlns attrs scdata ssubels
 
-	if {$tag1 != "items"} continue
+	if {$stag != "items"} continue
 
-	foreach item $children1 {
-	    jlib::wrapper:splitxml \
-		$item tag2 vars2 isempty2 chdata2 children2
+	foreach item $ssubels {
+	    ::xmpp::xml::split $item sstag ssxmlns ssattrs sscdata sssubels
 
-	    if {$tag2 == "item"} {
+	    if {$sstag == "item"} {
 		lappend items $item
 	    }
 	}
@@ -649,7 +608,7 @@
 # payload is a LIST of xml tags
 # node must not be empty
 
-proc pubsub::publish_item {service node itemid args} {
+proc pubsub::publish_item {xlib service node itemid args} {
 
     debugmsg pubsub [info level 0]
 
@@ -660,15 +619,10 @@
 	switch -- $key {
 	    -transient { set transient $val }
 	    -payload { set payload $val }
-	    -connection { set connid $val}
 	    -command { set command $val }
 	}
     }
 
-    if {![info exists connid]} {
-	return -code error "pubsub::publish_item: -connection is mandatory"
-    }
-
     if {$node == ""} {
 	return -code error "pubsub::publish_item: Node is empty"
     }
@@ -682,19 +636,18 @@
     if {$transient} {
 	set item {}
     } else {
-	set item [list [jlib::wrapper:createtag item \
-			    -vars $vars \
-			    -subtags $payload]]
+	set item [list [::xmpp::xml::create item \
+			    -attrs $vars \
+			    -subelements $payload]]
     }
 
-    jlib::send_iq set \
-	[jlib::wrapper:createtag pubsub \
-	     -vars [list xmlns $::NS(pubsub)] \
-	     -subtags [list [jlib::wrapper:createtag publish \
-				 -vars [list node $node] \
-				 -subtags $item]]] \
+    ::xmpp::sendIQ $xlib set \
+	-query [::xmpp::xml::create pubsub \
+		    -xmlns $::NS(pubsub) \
+		    -subelement [::xmpp::xml::create publish \
+					-attrs [list node $node] \
+					-subelements $item]]] \
 	-to $service \
-	-connection $connid \
 	-command [list [namespace current]::publish_item_result $command]
 }
 
@@ -713,7 +666,7 @@
 # node and itemid must not be empty
 # -notify is a boolean (true, false, 1, 0)
 
-proc pubsub::delete_item {service node itemid args} {
+proc pubsub::delete_item {xlib service node itemid args} {
 
     debugmsg pubsub [info level 0]
 
@@ -722,15 +675,10 @@
     foreach {key val} $args {
 	switch -- $key {
 	    -notify { set notify $val }
-	    -connection { set connid $val}
 	    -command { set command $val }
 	}
     }
 
-    if {![info exists connid]} {
-	return -code error "pubsub::delete_item: -connection is mandatory"
-    }
-
     if {$node == ""} {
 	return -code error "pubsub::delete_item: Node is empty"
     }
@@ -744,17 +692,14 @@
 	lappend vars notify true
     }
 
-    jlib::send_iq set \
-	[jlib::wrapper:createtag pubsub \
-	     -vars [list xmlns $::NS(pubsub)] \
-	     -subtags \
-		 [list [jlib::wrapper:createtag retract \
-			    -vars $vars \
-			    -subtags \
-				[list [jlib::wrapper:createtag item \
-					   -vars [list id $itemid]]]]]] \
+    ::xmpp::sendIQ $xlib set \
+	-query [::xmpp::xml::create pubsub \
+		    -xmlns $::NS(pubsub) \
+		    -subelement [::xmpp::xml::create retract \
+				    -attrs $vars \
+				    -subelement [::xmpp::xml::create item \
+						  -attrs [list id $itemid]]]] \
 	-to $service \
-	-connection $connid \
 	-command [list [namespace current]::delete_item_result $command]
 }
 
@@ -776,11 +721,10 @@
 #
 # Create pubsub node "node" at service "service" (8.1)
 #
-# 8.1.2 create_node service node -connection connid -command callback
-# or    create_node service node -access_model model -connection connid \
-#				 -command callback
+# 8.1.2 create_node xlib service node -command callback
+# or    create_node xlib service node -access_model model -command callback
 #
-# 8.1.3 create_node service node -connection connid -command callback \
+# 8.1.3 create_node xlib service node -command callback \
 #				 -title title \
 #				  ........... \
 #				 -body_xslt xslt
@@ -814,7 +758,7 @@
 # -title
 # -type
 
-proc pubsub::create_node {service node args} {
+proc pubsub::create_node {xlib service node args} {
     variable ns
 
     debugmsg pubsub [info level 0]
@@ -824,7 +768,6 @@
     set fields {}
     foreach {key val} $args {
 	switch -- $key {
-	    -connection { set connid $val}
 	    -command { set command $val }
 	    -access_model -
 	    -body_xslt -
@@ -858,10 +801,6 @@
 	}
     }
 
-    if {![info exists connid]} {
-	return -code error "pubsub::create_node: -connection is mandatory"
-    }
-
     if {$node == ""} {
 	set vars {}
     } else {
@@ -869,59 +808,56 @@
     }
 
     if {![lempty $fields]} {
-	set fields [linsert $fields 0 [form_type $ns(node_config)]]
 	set fields \
-	    [list [jlib::wrapper:createtag x \
-		       -vars [list xmlns $::NS(data) \
-				   type submit] \
-		       -subtags \
+	    [list [::xmpp::xml::create x \
+		       -xmlns $::NS(data) \
+		       -attrs [list type submit] \
+		       -subelements \
 			   [linsert $fields 0 \
 				    [form_type $ns(node_config)]]]]
     }
 
-    jlib::send_iq set \
-	[jlib::wrapper:createtag pubsub \
-	     -vars [list xmlns $::NS(pubsub)] \
-	     -subtags [list [jlib::wrapper:createtag create \
-				 -vars $vars] \
-			    [jlib::wrapper:createtag configure \
-				 -subtags $fields]]] \
+    ::xmpp::sendIQ $xlib set \
+	-query [::xmpp::xml::create pubsub \
+		    -xmlns $::NS(pubsub) \
+		    -subelement [::xmpp::xml::create create \
+					-attrs $vars] \
+		    -subelement [::xmpp::xml::create configure \
+					-subelements $fields]] \
 	-to $service \
-	-connection $connid \
 	-command [list [namespace current]::create_node_result \
 		       $node $command]
 }
 
 proc pubsub::form_type {value} {
-    return [jlib::wrapper:createtag field \
-		-vars [list var FORM_TYPE \
-			    type hidden]
-		-subtags [list [jlib::wrapper:createtag value \
-				    -chdata $value]]]
+    return [::xmpp::xml::create field \
+		-attrs [list var FORM_TYPE \
+			     type hidden]
+		-subelement [::xmpp::xml::create value \
+				    -cdata $value]]
 }
 
 proc pubsub::field {var value} {
-    return [jlib::wrapper:createtag field \
-		-vars [list var $var] \
-		-subtags [list [jlib::wrapper:createtag value \
-				    -chdata $value]]]
+    return [::xmpp::xml::create field \
+		-attrs [list var $var] \
+		-subelement [::xmpp::xml::create value \
+				    -cdata $value]]
 }
 
 proc pubsub::create_node_result {node command res child} {
 
     debugmsg pubsub [info level 0]
 
-    if {$res == "OK" && $node == ""} {
+    if {$res == "ok" && $node == ""} {
 	# Instant node: get node name from the answer
 
-	jlib::wrapper:splitxml $child tag vars isempty chdata children
+	::xmpp::xml::split $child tag xmlns attrs cdata subels
 
-	if {[jlib::wrapper:getattr $vars xmlns] == $::NS(pubsub)} {
-	    foreach child1 $children {
-		jlib::wrapper:splitxml \
-		    $child1 tag1 vars1 isempty1 chdata1 children1
-		if {$tag == "create"} {
-		    set node [jlib::wrapper:getattr $vars1 node]
+	if {$xmlns == $::NS(pubsub)} {
+	    foreach subel $subels {
+		::xmpp::xml::split $subel stag sxmlns sattrs scdata ssubels
+		if {$stag == "create"} {
+		    set node [::xmpp::xml::getAttr $sattrs node]
 		}
 	    }
 	}
@@ -938,81 +874,75 @@
 # node must not be empty
 #
 
-proc pubsub::configure_node {service node args} {
+proc pubsub::configure_node {xlib service node args} {
 
     debugmsg pubsub [info level 0]
 
     set command ""
     foreach {key val} $args {
 	switch -- $key {
-	    -connection { set connid $val}
 	    -command { set command $val }
 	}
     }
 
-    if {![info exists connid]} {
-	return -code error "pubsub::configure_node: -connection is mandatory"
-    }
-
     if {$node == ""} {
 	return -code error \
 	    "pubsub::configure_node: Node is empty"
     }
 
-    jlib::send_iq set \
-	[jlib::wrapper:createtag pubsub \
-	     -vars [list xmlns $::NS(pubsub#owner)] \
-	     -subtags [list [jlib::wrapper:createtag configure \
-				 -vars [list node $node]]] \
+    ::xmpp::sendIQ $xlib set \
+	-query [::xmpp::xml::create pubsub \
+		    -xmlns $::NS(pubsub#owner) \
+		    -subelement [::xmpp::xml::create configure \
+					-attrs [list node $node]] \
 	-to $service \
-	-connection $connid \
 	-command [list [namespace current]::configure_node_result \
-		       $connid $service $command]
+		       $xlib $service $command]
 }
 
-proc pubsub::configure_node_result {connid service command res child} {
+proc pubsub::configure_node_result {xlib service command res child} {
 
     debugmsg pubsub [info level 0]
 
-    if {$res != "OK"} {
+    if {$res != "ok"} {
 	if {$command != ""} {
 	    eval $command [list $res $child]
 	}
 	return
     }
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
+    ::xmpp::xml::split $child tag xmlns attrs cdata subels
 
-    foreach ch $children {
-	jlib::wrapper:splitxml $ch tag1 vars1 isempty1 chdata1 children1
+    foreach subel $subels {
+	::xmpp::xml::split $subel stag sxmlns sattrs scdata ssubels
 
-	if {$tag1 == "configure"} {
-	    set node [jlib::wrapper:getattr $vars1 node]
-	    jlib::wrapper:splitxml \
-		[lindex $children1 0] tag2 vars2 isempty2 chdata2 children2
+	if {$stag == "configure"} {
+	    set node [::xmpp::xml::getAttr $sattrs node]
+	    ::xmpp::xml::split \
+		[lindex $ssubels 0] sstag ssxmlns ssattrs sscdata sssubels
 	    break
 	}
     }
 
-    data::draw_window $children2 \
+    data::draw_window $sssubels \
 	[list [namespace current]::send_configure_node
-	      $connid $service $node $command]
+	      $xlib $service $node $command]
 }
 
-proc pubsub::send_configure_node {connid service node command w restags} {
+proc pubsub::send_configure_node {xlib service node command w restags} {
 
     debugmsg pubsub [info level 0]
 
     destroy $w.error.msg
     $w.bbox itemconfigure 0 -state disabled
 
-    jlib::send_iq set [jlib::wrapper:createtag pubsub \
-			   -vars [list xmlns $::NS(pubsub#owner)] \
-			   -subtags [jlib::wrapper:createtag configure \
-					 -vars [list node $node] \
-					 -subtags $restags]] \
+    ::xmpp::sendIQ $xlib set \
+	-query [::xmpp::xml::create pubsub \
+			   -xmlns $::NS(pubsub#owner) \
+			   -subelement [::xmpp::xml::create configure \
+					    -attrs [list node $node] \
+					    -subelements $restags]] \
 	-to $service \
-	-connection $connid \
 	-command [list data::test_error_res $w]
 }
 
@@ -1021,90 +951,84 @@
 # Request default configuration options (8.3)
 #
 
-proc pubsub::request_default {service args} {
+proc pubsub::request_default {xlib service args} {
     variable ns
 
     debugmsg pubsub [info level 0]
 
     set command ""
-    set form [jlib::wrapper:createtag default]
+    set form [::xmpp::xml::create default]
     foreach {key val} $args {
 	switch -- $key {
-	    -connection { set connid $val}
 	    -command { set command $val }
 	    -node_type {
 		set form \
-		    [jlib::wrapper:createtag default \
-			 -subtags [list [jlib::wrapper:createtag x \
-					     -vars [list xmlns $::NS(data) \
-							 type submit] \
-					     -subtags [list [form_type $ns(node_config)] \
-							    [field pubsub#node_type $val]]]]]
+		    [::xmpp::xml::create default \
+			 -subelement [::xmpp::xml::create x \
+					     -xmlns $::NS(data) \
+					     -attrs [list type submit] \
+					     -subelement [form_type $ns(node_config)] \
+					     -subelement [field pubsub#node_type $val]]]
 	    }
 	}
     }
 
-    if {![info exists connid]} {
-	return -code error "pubsub::request_default: -connection is mandatory"
-    }
-
     if {$node == ""} {
 	return -code error \
 	    "pubsub::request_default: Node is empty"
     }
 
-    jlib::send_iq set \
-	[jlib::wrapper:createtag pubsub \
-	     -vars [list xmlns $::NS(pubsub#owner)] \
-	     -subtags [list $form] \
+    ::xmpp::sendIQ $xlib set \
+	-query [::xmpp::xml::create pubsub \
+		    -xmlns $::NS(pubsub#owner) \
+		    -subelement $form \
 	-to $service \
-	-connection $connid \
 	-command [list [namespace current]::request_default_result \
-		       $connid $service $command]
+		       $xlib $service $command]
 }
 
-proc pubsub::request_default_result {connid service command res child} {
+proc pubsub::request_default_result {xlib service command res child} {
 
     debugmsg pubsub [info level 0]
 
-    if {$res != "OK"} {
+    if {$res != "ok"} {
 	if {$command != ""} {
 	    eval $command [list $res $child]
 	}
 	return
     }
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
+    ::xmpp::xml::split $child tag xmlns attrs cdata subels
 
-    foreach ch $children {
-	jlib::wrapper:splitxml $ch tag1 vars1 isempty1 chdata1 children1
+    foreach subel $subels {
+	::xmpp::xml::split $subel stag sxmlns sattrs scdata ssubels
 
-	if {$tag1 == "default"} {
-	    jlib::wrapper:splitxml \
-		[lindex $children1 0] tag2 vars2 isempty2 chdata2 children2
+	if {$stag == "default"} {
+	    ::xmpp::xml::split \
+		[lindex $ssubels 0] sstag ssxmlns ssattrs sscdata sssubels
 	    break
 	}
     }
 
     # TODO: Don't send the form
-    data::draw_window $children2 \
+    data::draw_window $sssubels \
 	[list [namespace current]::send_request_results
-	      $connid $service $node $command]
+	      $xlib $service $node $command]
 }
 
-proc pubsub::send_request_results {connid service node command w restags} {
+proc pubsub::send_request_results {xlib service node command w restags} {
 
     debugmsg pubsub [info level 0]
 
     destroy $w.error.msg
     $w.bbox itemconfigure 0 -state disabled
 
-    jlib::send_iq set [jlib::wrapper:createtag pubsub \
-			   -vars [list xmlns $::NS(pubsub#owner)] \
-			   -subtags [jlib::wrapper:createtag default \
-					 -subtags $restags]] \
+    ::xmpp::sendIQ $xlib set \
+	-query [::xmpp::xml::create pubsub \
+			   -xmlns $::NS(pubsub#owner) \
+			   -subelement [::xmpp::xml::create default \
+					    -subelements $restags]] \
 	-to $service \
-	-connection $connid \
 	-command [list data::test_error_res $w]
 }
 
@@ -1114,33 +1038,27 @@
 # node must not be empty
 #
 
-proc pubsub::delete_node {service node args} {
+proc pubsub::delete_node {xlib service node args} {
 
     debugmsg pubsub [info level 0]
 
     set command ""
     foreach {key val} $args {
 	switch -- $key {
-	    -connection { set connid $val}
 	    -command { set command $val }
 	}
     }
 
-    if {![info exists connid]} {
-	return -code error "pubsub::delete_node: -connection is mandatory"
-    }
-
     if {$node == ""} {
 	return -code error "pubsub::delete_node: Node is empty"
     }
 
-    jlib::send_iq set \
-	[jlib::wrapper:createtag pubsub \
-	     -vars [list xmlns $::NS(pubsub#owner)] \
-	     -subtags [list [jlib::wrapper:createtag delete \
-				 -vars [list node $node]]] \
+    ::xmpp::sendIQ $xlib set \
+	-query [::xmpp::xml::create pubsub \
+		    -xmlns $::NS(pubsub#owner) \
+		    -subelement [::xmpp::xml::create delete \
+				    -attrs [list node $node]]] \
 	-to $service \
-	-connection $connid \
 	-command [list [namespace current]::delete_node_result $command]
 }
 
@@ -1159,33 +1077,27 @@
 # node must not be empty
 #
 
-proc pubsub::purge_items {service node args} {
+proc pubsub::purge_items {xlib service node args} {
 
     debugmsg pubsub [info level 0]
 
     set command ""
     foreach {key val} $args {
 	switch -- $key {
-	    -connection { set connid $val}
 	    -command { set command $val }
 	}
     }
 
-    if {![info exists connid]} {
-	return -code error "pubsub::purge_items: -connection is mandatory"
-    }
-
     if {$node == ""} {
 	return -code error "pubsub::purge_items: Node is empty"
     }
 
-    jlib::send_iq set \
-	[jlib::wrapper:createtag pubsub \
-	     -vars [list xmlns $::NS(pubsub#owner)] \
-	     -subtags [list [jlib::wrapper:createtag purge \
-				 -vars [list node $node]]] \
+    ::xmpp::sendIQ $xlib set \
+	-query [::xmpp::xml::create pubsub \
+		    -xmlns $::NS(pubsub#owner) \
+		    -subelement [::xmpp::xml::create purge \
+				    -attrs [list node $node]]] \
 	-to $service \
-	-connection $connid \
 	-command [list [namespace current]::purge_items_result $command]
 }
 
@@ -1209,24 +1121,13 @@
 # Request all pending subscription requests (8.6.1)
 #
 
-proc pubsub::request_pending_subscription {service args} {
+proc pubsub::request_pending_subscription {xlib service} {
     variable ns
 
     debugmsg pubsub [info level 0]
 
-    foreach {key val} $args {
-	switch -- $key {
-	    -connection { set connid $val}
-	}
-    }
-
-    if {![info exists connid]} {
-	return -code error \
-	       "pubsub::request_pending_subscription: -connection is mandatory"
-    }
-
     # Let xcommands.tcl do the job
-    xcommands::execute $service $ns(get-pending) -connection $connid
+    xcommands::execute $xlib $service $ns(get-pending)
 }
 
 ##########################################################################
@@ -1237,34 +1138,27 @@
 # {jid JID subscription SUB subid ID}
 #
 
-proc pubsub::request_subscriptions {service node args} {
+proc pubsub::request_subscriptions {xlib service node args} {
 
     debugmsg pubsub [info level 0]
 
     set command ""
     foreach {key val} $args {
 	switch -- $key {
-	    -connection { set connid $val}
 	    -command { set command $val }
 	}
     }
 
-    if {![info exists connid]} {
-	return -code error \
-	       "pubsub::request_subscriptions: -connection is mandatory"
-    }
-
     if {$node == ""} {
 	return -code error "pubsub::request_subscriptions: Node is empty"
     }
 
-    jlib::send_iq set \
-	[jlib::wrapper:createtag pubsub \
-	     -vars [list xmlns $::NS(pubsub#owner)] \
-	     -subtags [list [jlib::wrapper:createtag subscriptions \
-				 -vars [list node $node]]]] \
+    ::xmpp::sendIQ $xlib set \
+	-query [::xmpp::xml::create pubsub \
+		    -xmlns $::NS(pubsub#owner) \
+		    -subelement [::xmpp::xml::create subscriptions \
+				    -attrs [list node $node]]] \
 	-to $service \
-	-connection $connid \
 	-command [list [namespace current]::subscriptions_result $command]
 }
 
@@ -1272,7 +1166,7 @@
 
     debugmsg pubsub [info level 0]
 
-    if {$res != "OK"} {
+    if {$res != "ok"} {
 	if {$command != ""} {
 	    eval $command [list $res $child]
 	}
@@ -1281,19 +1175,19 @@
 
     set entities {}
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
+    ::xmpp::xml::split $child tag xmlns attrs cdata subels
 
-    foreach ch $children {
-	jlib::wrapper:splitxml $ch tag1 vars1 isempty1 chdata1 children1
+    foreach subel $subels {
+	::xmpp::xml::split $subel stag sxmlns sattrs scdata ssubels
 
-	if {$tag1 != "subscriptions"} continue
+	if {$stag != "subscriptions"} continue
 
-	foreach entity $children1 {
-	    jlib::wrapper:splitxml \
-		$entity tag2 vars2 isempty2 chdata2 children2
+	foreach entity $ssubels {
+	    ::xmpp::xml::split \
+		$entity sstag ssxmlns ssattrs sscdata sssubels
 
-	    if {$tag2 == "subscription"} {
-		lappend entities $vars2
+	    if {$sstag == "subscription"} {
+		lappend entities $ssattrs
 	    }
 	}
     }
@@ -1305,41 +1199,34 @@
 
 ##########################################################################
 
-proc pubsub::modify_subscriptions {service node entities args} {
+proc pubsub::modify_subscriptions {xlib service node entities args} {
 
     debugmsg pubsub [info level 0]
 
     set command ""
     foreach {key val} $args {
 	switch -- $key {
-	    -connection { set connid $val}
 	    -command { set command $val }
 	}
     }
 
-    if {![info exists connid]} {
-	return -code error \
-	       "pubsub::modify_subscriptions: -connection is mandatory"
-    }
-
     if {$node == ""} {
 	return -code error "pubsub::modify_subscriptions: Node is empty"
     }
 
     set subscriptions {}
     foreach entity $entities {
-	lappend subscriptions [jlib::wrapper:createtag subscription \
-				   -vars $entity]
+	lappend subscriptions [::xmpp::xml::create subscription \
+					-attrs $entity]
     }
 
-    jlib::send_iq set \
-	[jlib::wrapper:createtag pubsub \
-	     -vars [list xmlns $::NS(pubsub#owner)] \
-	     -subtags [list [jlib::wrapper:createtag subscriptions \
-				 -vars [list node $node] \
-				 -subtags $subscriptions]]] \
+    ::xmpp::sendIQ $xlib set \
+	-query [::xmpp::xml::create pubsub \
+		    -xmlns $::NS(pubsub#owner) \
+		    -subelement [::xmpp::xml::create subscriptions \
+					-attrs [list node $node] \
+					-subelements $subscriptions]] \
 	-to $service \
-	-connection $connid \
 	-command [list [namespace current]::modify_subscriptions_result $command]
 }
 
@@ -1358,33 +1245,26 @@
 # Evaluates command with list of entity attributes lists
 #
 
-proc pubsub::request_affiliations {service node args} {
+proc pubsub::request_affiliations {xlib service node args} {
 
     debugmsg pubsub [info level 0]
 
     set command ""
     foreach {key val} $args {
 	switch -- $key {
-	    -connection { set connid $val}
 	    -command { set command $val }
 	}
     }
 
-    if {![info exists connid]} {
-	return -code error \
-	       "pubsub::request_affiliations: -connection is mandatory"
-    }
-
     if {$node == ""} {
 	return -code error "pubsub::request_affiliations: Node is empty"
     }
 
-    jlib::send_iq set \
-	[jlib::wrapper:createtag pubsub \
-	     -vars [list xmlns $::NS(pubsub#owner)] \
-	     -subtags [list [jlib::wrapper:createtag affiliations]]] \
+    ::xmpp::sendIQ $xlib set \
+	-query [::xmpp::xml::create pubsub \
+		    -xmlns $::NS(pubsub#owner) \
+		    -subelement [::xmpp::xml::create affiliations]] \
 	-to $service \
-	-connection $connid \
 	-command [list [namespace current]::affiliations_result $command]
 }
 
@@ -1392,7 +1272,7 @@
 
     debugmsg pubsub [info level 0]
 
-    if {$res != "OK"} {
+    if {$res != "ok"} {
 	if {$command != ""} {
 	    eval $command [list $res $child]
 	}
@@ -1401,19 +1281,19 @@
 
     set entities {}
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
+    ::xmpp::xml::split $child tag xmlns attrs cdata subels
 
-    foreach ch $children {
-	jlib::wrapper:splitxml $ch tag1 vars1 isempty1 chdata1 children1
+    foreach subel $subels {
+	::xmpp::xml::split $subel stag sxmlns sattrs scdata ssubels
 
-	if {$tag1 != "affiliations"} continue
+	if {$stag != "affiliations"} continue
 
-	foreach entity $children1 {
-	    jlib::wrapper:splitxml \
-		$entity tag2 vars2 isempty2 chdata2 children2
+	foreach entity $ssubels {
+	    ::xmpp::xml::split \
+		$entity sstag ssxmlns sattrs sscdata sssubels
 
-	    if {$tag2 == "affiliation"} {
-		lappend entities $vars2
+	    if {$sstag == "affiliation"} {
+		lappend entities $ssattrs
 	    }
 	}
     }
@@ -1425,41 +1305,34 @@
 
 ##########################################################################
 
-proc pubsub::modify_affiliations {service node entities args} {
+proc pubsub::modify_affiliations {xlib service node entities args} {
 
     debugmsg pubsub [info level 0]
 
     set command ""
     foreach {key val} $args {
 	switch -- $key {
-	    -connection { set connid $val}
 	    -command { set command $val }
 	}
     }
 
-    if {![info exists connid]} {
-	return -code error \
-	       "pubsub::modify_subscriptions: -connection is mandatory"
-    }
-
     if {$node == ""} {
 	return -code error "pubsub::modify_subscriptions: Node is empty"
     }
 
     set affiliations {}
     foreach entity $entities {
-	lappend affiliations [jlib::wrapper:createtag affiliation \
-				   -vars $entity]
+	lappend affiliations [::xmpp::xml::create affiliation \
+					-attrs $entity]
     }
 
-    jlib::send_iq set \
-	[jlib::wrapper:createtag pubsub \
-	     -vars [list xmlns $::NS(pubsub#owner)] \
-	     -subtags [list [jlib::wrapper:createtag affiliations \
-				 -vars [list node $node] \
-				 -subtags $affiliations]]] \
+    ::xmpp::sendIQ $xlib set \
+	-query [::xmpp::xml::create pubsub \
+		    -xmlns $::NS(pubsub#owner) \
+		    -subelement [::xmpp::xml::create affiliations \
+					-attrs [list node $node] \
+					-subelements $affiliations]] \
 	-to $service \
-	-connection $connid \
 	-command [list [namespace current]::modify_affiliations_result $command]
 }
 
@@ -1479,56 +1352,50 @@
 # TODO
 #
 
-proc pubsub::request_entities {service node args} {
+proc pubsub::request_entities {xlib service node args} {
 
     debugmsg pubsub [info level 0]
 
     set command ""
     foreach {key val} $args {
 	switch -- $key {
-	    -connection { set connid $val}
 	    -command { set command $val }
 	}
     }
 
-    if {![info exists connid]} {
-	return -code error \
-	       "pubsub::request_entities: -connection is mandatory"
-    }
-
     if {$node == ""} {
 	return -code error "pubsub::request_entities error: Node is empty"
     }
 
-    jlib::send_iq set \
-	[jlib::wrapper:createtag pubsub \
-	     -vars [list xmlns $::NS(pubsub)] \
-	     -subtags \
-		 [list [jlib::wrapper:createtag entities \
-			    -vars [list node $node]]] \
+    ::xmpp::sendIQ $xlib set \
+	-query [::xmpp::xml::create pubsub \
+		    -xmlns $::NS(pubsub) \
+		    -subelement [::xmpp::xml::create entities \
+					-attrs [list node $node]] \
 	-to $service \
-	-connection $connid \
 	-command [list [namespace current]::receive_entities \
-		       $connid $service $command]
+		       $xlib $service $command]
 }
 
-proc pubsub::receive_entities {connid service command res child} {
+proc pubsub::receive_entities {xlib service command res child} {
     variable winid
 
     debugmsg pubsub [info level 0]
 
-    if {$res != "OK"} {
+    if {$res != "ok"} {
 	if {$command != ""} {
 	    eval $command [list $res $child]
 	}
     }
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
-    foreach child1 $children {
-	jlib::wrapper:splitxml $child1 tag1 vars1 isempty1 chdata1 children1
-	if {$tag1 == "entities"} {
-	    set node [jlib::wrapper:getattr $vars1 node]
-	    set entities $children1
+    ::xmpp::xml::split $child tag xmlns attrs cdata subels
+
+    foreach subel $subels {
+	::xmpp::xml::split $subel stag sxmlns sattrs scdata ssubels
+
+	if {$stag == "entities"} {
+	    set node [::xmpp::xml::getAttr $sattrs node]
+	    set entities $ssubels
 	    break
 	}
     }
@@ -1559,7 +1426,7 @@
  
     $w add -text [::msgcat::mc "Send"] \
 	-command [list [namespace current]::send_entities \
-		       $connid $service $node $w $f]
+		       $xlib $service $node $w $f]
     $w add -text [::msgcat::mc "Cancel"] -command [list destroy $w]
     bind $w <Destroy> \
 	 [list after idle [list [namespace current]::cleanup_entities $w $f]]
@@ -1622,13 +1489,13 @@
 
     set entities2 {}
     foreach entity $entities {
-	jlib::wrapper:splitxml $entity tag vars isempty chdata children
+	::xmpp::xml::split $entity tag xmlns attrs cdata subels
 	switch -- $tag {
 	    entity {
-		set jid [jlib::wrapper:getattr $vars jid]
-		set subid [jlib::wrapper:getattr $vars subid]
-		set affiliation [jlib::wrapper:getattr $vars affiliation]
-		set subscription [jlib::wrapper:getattr $vars subscription]
+		set jid [::xmpp::xml::getAttr $attrs jid]
+		set subid [::xmpp::xml::getAttr $attrs subid]
+		set affiliation [::xmpp::xml::getAttr $attrs affiliation]
+		set subscription [::xmpp::xml::getAttr $attrs subscription]
 		lappend entities2 [list $jid $subid $affiliation $subscription]
 	    }
 	}
@@ -1720,7 +1587,7 @@
     incr listdata($f,rows)
 }
 
-proc pubsub::send_entities {connid service node w f} {
+proc pubsub::send_entities {xlib service node w f} {
     variable origlistdata
     variable listdata
 
@@ -1739,8 +1606,8 @@
 
 	if {$vars != {} && $origlistdata($f,jid,$i) != ""} {
 	    lappend vars jid $origlistdata($f,jid,$i)
-	    lappend entities [jlib::wrapper:createtag entity \
-				  -vars $vars]
+	    lappend entities [::xmpp::xml::create entity \
+					-attrs $vars]
 	}
     }
 
@@ -1762,23 +1629,24 @@
 	}
 
 	if {$vars1 != {} && $vars2 != {} && $vars3 != {}} {
-	    lappend entities [jlib::wrapper:createtag item \
-				  -vars [concat $vars2 $vars3 $vars1]]
+	    lappend entities [::xmpp::xml::create item \
+				    -attrs $vars2 \
+				    -attrs $vars3 \
+				    -attrs $vars1]
 	}
     }
 
-    set connid [chat::get_connid $chatid]
+    set xlib [chat::get_xlib $chatid]
     set group [chat::get_jid $chatid]
 
     if {$entities != {}} {
-	jlib::send_iq set \
-	    [jlib::wrapper:createtag pubsub \
-		 -vars [list xmlns $::NS(pubsub)] \
-		 -subtags [list [jlib::wrapper:createtag entities \
-				     -vars [list node $node] \
-				     -subtags $entities]]] \
-	    -to $service \
-	    -connection $connid
+	::xmpp::sendIQ $xlib set \
+	    -query [::xmpp::xml::create pubsub \
+			-xmlns $::NS(pubsub) \
+			-subelement [::xmpp::xml::create entities \
+					-attrs [list node $node] \
+					-subelements $entities]] \
+	    -to $service
     # TODO error checking
     }
     destroy $w
@@ -1803,7 +1671,7 @@
 #
 # Subscribe to a collection node (9.1)
 # Implemented in
-# pubsub::subscribe service node id -connection connid \
+# pubsub::subscribe xlib service node id \
 #		    -subscription_type {nodes|items} \
 #		    -subscription_depth {1|all}
 #
@@ -1818,7 +1686,7 @@
 #
 # Create collection node (9.3)
 # Implemented in
-# pubsub::create_node service node -connection connid \
+# pubsub::create_node xlib service node \
 #		      -node_type collection
 #
 
@@ -1826,7 +1694,7 @@
 #
 # Create a node associated with a collection (9.4)
 # Implemented in
-# pubsub::create_node service node -connection connid \
+# pubsub::create_node xlib service node \
 #		      -collection collection
 #
 
@@ -1852,7 +1720,7 @@
     set supported_ns [array names handler]
 }
 
-proc pubsub::process_event_notification {connid from mid type is_subject subject body \
+proc pubsub::process_event_notification {xlib from mid type is_subject subject body \
     err thread priority x} {
 
     variable ::pubsub::ns
@@ -1861,21 +1729,21 @@
     set res ""
 
     foreach event $x {
-	jlib::wrapper:splitxml $event tag vars isempty chdata children
+	::xmpp::xml::split $event tag xmlns attrs cdata subels
+
 	if {![string equal $tag event]} continue
-	
-	set xmlns [jlib::wrapper:getattr $vars xmlns]
 	if {![string equal $xmlns $ns(event)]} continue
 
-	foreach item $children {
-	    jlib::wrapper:splitxml $item tag1 vars1 isempty1 chdata1 children1
-	    if {![string equal $tag1 items]} continue
+	foreach item $subels {
+	    ::xmpp::xml::split $item stag sxmlns sattrs scdata ssubels
 
-	    set node [jlib::wrapper:getattr $vars1 node]
+	    if {![string equal $stag items]} continue
+
+	    set node [::xmpp::xml::getAttr $sattrs node]
 	    if {![info exists handler($node)]} continue
 
 	    set res stop
-	    $handler($node) $connid $from $children1
+	    eval $handler($node) [list $xlib $from $ssubels]
 	}
     }
 

Modified: trunk/tkabber/register.tcl
===================================================================
--- trunk/tkabber/register.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/register.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -4,18 +4,9 @@
     set winid 0
 }
 
-proc register::open {jid args} {
+proc register::open {xlib jid args} {
     variable winid
 
-    foreach {key val} $args {
-	switch -- $key {
-	    -connection { set connid $val }
-	}
-    }
-    if {![info exists connid]} {
-	return -code error "register::open: -connection required"
-    }
-
     set w .register$winid
     toplevel $w
     wm group $w .
@@ -44,10 +35,10 @@
 
     set bbox [ButtonBox $w.bbox -spacing 0 -padx 10 -default 0]
     $bbox add -text [::msgcat::mc "Register"] \
-	-command [list register::register $w $f $connid $jid] \
+	-command [list register::register $w $f $xlib $jid] \
         -state disabled
     $bbox add -text [::msgcat::mc "Unregister"] \
-	-command [list register::unregister $w $connid $jid] \
+	-command [list register::unregister $w $xlib $jid] \
         -state disabled
     $bbox add -text [::msgcat::mc "Cancel"] -command [list destroy $w]
     bind $w <Return> "ButtonBox::invoke $bbox default"
@@ -63,37 +54,36 @@
 
     wm withdraw $w
 
-    jlib::send_iq get \
-	[jlib::wrapper:createtag query \
-	     -vars [list xmlns $::NS(register)]] \
+    ::xmpp::sendIQ $xlib get \
+	-query [::xmpp::xml::create query \
+			-xmlns $::NS(register)] \
 	-to $jid \
-	-connection $connid \
-	-command [list register::recv_fields $w $f $connid $jid]
+	-command [list register::recv_fields $w $f $xlib $jid]
     
     incr winid
 }
 
 
-proc register::recv_fields {w f connid jid res child} {
-    debugmsg register "$res $child"
+proc register::recv_fields {w f xlib jid status xml} {
+    debugmsg register "$status $xml"
 
-    switch -- $res {
-	ERR {
+    switch -- $status {
+	error {
 	    destroy $w
 	    MessageDlg ${w}_err -aspect 50000 -icon error \
-		-message [format [::msgcat::mc "Registration: %s"] \
-				 [error_to_string $child]] \
+		-message [::msgcat::mc "Registration: %s" \
+				       [error_to_string $xml]] \
 		-type user -buttons ok -default 0 -cancel 0
 	}
-	OK {
-	    jlib::wrapper:splitxml $child tag vars isempty chdata children
+	ok {
+	    ::xmpp::xml::split $xml tag xmlns attrs cdata subels
 
-	    if {[jlib::wrapper:getattr $vars xmlns] == $::NS(register)} {
-		set focus [data::fill_fields $f $children]
+	    if {$xmlns == $::NS(register)} {
+		set focus [data::fill_fields $f $subels]
 	    }
 
 	    $w.bbox itemconfigure 0 -state normal
-	    if {$jid != [jlib::connection_server $connid]} {
+	    if {$jid != [connection_server $xlib]} {
 		$w.bbox itemconfigure 1 -state normal
 	    }
 
@@ -119,7 +109,7 @@
 }
 
 
-proc register::register {w f connid jid} {
+proc register::register {w f xlib jid} {
     variable data
 
     destroy $w.error.msg
@@ -128,45 +118,45 @@
 
     set restags [data::get_tags $f]
 
-    jlib::send_iq set [jlib::wrapper:createtag query \
-			   -vars [list xmlns $::NS(register)] \
-			   -subtags $restags] \
+    ::xmpp::sendIQ $xlib set \
+	-query [::xmpp::xml::create query \
+			-xmlns $::NS(register) \
+			-subelements $restags] \
 	-to $jid \
-	-connection $connid \
-	-command [list register::recv_result $w $connid $jid]
+	-command [list register::recv_result $w $xlib $jid]
 }
 
 
-proc register::unregister {w connid jid} {
+proc register::unregister {w xlib jid} {
     variable data
 
     destroy $w.error.msg
     $w.bbox itemconfigure 0 -state disabled
     $w.bbox itemconfigure 1 -state disabled
 
-    jlib::send_iq set [jlib::wrapper:createtag query \
-			   -vars [list xmlns $::NS(register)] \
-			   -subtags [list [jlib::wrapper:createtag remove]]] \
+    ::xmpp::sendIQ $xlib set \
+	-query [::xmpp::xml::create query \
+			-xmlns $::NS(register) \
+			-subelement [::xmpp::xml::create remove]] \
 	-to $jid \
-	-connection $connid \
-	-command [list register::recv_result $w $connid $jid]
+	-command [list register::recv_result $w $xlib $jid]
 }
 
 
-proc register::recv_result {w connid jid res child} {
+proc register::recv_result {w xlib jid status xml} {
     variable data
 
-    debugmsg register "$res $child"
+    debugmsg register "$status $xml"
     
-    if {![cequal $res OK]} {
+    if {![string equal $status ok]} {
 	$w.bbox itemconfigure 0 -state normal
-	if {$jid != [jlib::connection_server $connid]} {
+	if {$jid != [connection_server $xlib]} {
 	    $w.bbox itemconfigure 1 -state normal
 	}
 
 	set m [message $w.error.msg \
 		       -aspect 50000 \
-		       -text [error_to_string $child] \
+		       -text [error_to_string $xml] \
 		       -pady 2m]
 	$m configure -foreground [option get $m errorForeground Message]
 	pack $m

Modified: trunk/tkabber/roster.tcl
===================================================================
--- trunk/tkabber/roster.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/roster.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -1,24 +1,26 @@
 # $Id$
 
+package require xmpp::roster
+
 namespace eval roster {
     variable undef_group_name [::msgcat::mc "Undefined"]
     variable chats_group_name [::msgcat::mc "Active Chats"]
     variable own_resources_group_name [::msgcat::mc "My Resources"]
 }
 
-proc roster::process_item {connid jid name groups subsc ask} {
+proc roster::process_item {xlib jid name groups subsc ask} {
     variable roster
     variable undef_group_name
     variable chats_group_name
     variable own_resources_group_name
 
-    debugmsg roster "ROSTER_ITEM: $connid; $jid; $name; $groups; $subsc; $ask"
+    debugmsg roster "ROSTER_ITEM: $xlib; $jid; $name; $groups; $subsc; $ask"
 
     set jid [tolower_node_and_domain $jid]
 
     if {$subsc != "remove"} {
-	if {![lcontain $roster(jids,$connid) $jid]} {
-	    lappend roster(jids,$connid) $jid
+	if {![lcontain $roster(jids,$xlib) $jid]} {
+	    lappend roster(jids,$xlib) $jid
 	}
 	set groups [lrmdups $groups]
 	foreach group [list "" $undef_group_name $chats_group_name $own_resources_group_name] {
@@ -27,59 +29,71 @@
 		set groups [lreplace $groups $ind $ind]
 	    }
 	}
-	set roster(group,$connid,$jid)    $groups
-	set roster(name,$connid,$jid)     $name
-	set roster(subsc,$connid,$jid)    $subsc
-	set roster(ask,$connid,$jid)      $ask
+	set roster(group,$xlib,$jid)    $groups
+	set roster(name,$xlib,$jid)     $name
+	set roster(subsc,$xlib,$jid)    $subsc
+	set roster(ask,$xlib,$jid)      $ask
 
-	catch {unset roster(cached_category_and_subtype,$connid,$jid)}
-	get_category_and_subtype $connid $jid
+	catch {unset roster(cached_category_and_subtype,$xlib,$jid)}
+	get_category_and_subtype $xlib $jid
     } else {
-	lvarpop roster(jids,$connid) [lsearch -exact $roster(jids,$connid) $jid]
+	lvarpop roster(jids,$xlib) [lsearch -exact $roster(jids,$xlib) $jid]
 
-	catch {unset roster(group,$connid,$jid)}
-	catch {unset roster(name,$connid,$jid)}
-	catch {unset roster(subsc,$connid,$jid)}
-	catch {unset roster(ask,$connid,$jid)}
-	catch {unset roster(cached_category_and_subtype,$connid,$jid)}
+	catch {unset roster(group,$xlib,$jid)}
+	catch {unset roster(name,$xlib,$jid)}
+	catch {unset roster(subsc,$xlib,$jid)}
+	catch {unset roster(ask,$xlib,$jid)}
+	catch {unset roster(cached_category_and_subtype,$xlib,$jid)}
     }
 }
 
-hook::add roster_item_hook [namespace current]::roster::process_item
 hook::add roster_push_hook [namespace current]::roster::process_item
 
-proc client:roster_item {connid jid name groups subsc ask} {
-    hook::run roster_item_hook $connid $jid $name $groups $subsc $ask 
-}
+proc client:roster_push {xlib njid args} {
+    set jid $njid
+    set name ""
+    set subsc none
+    set ask ""
+    set groups {}
+    foreach {key val} $args {
+	switch -- $key {
+	    -jid {set jid $val}
+	    -name {set name $val}
+	    -subscription {set subsc $val}
+	    -ask {set ask $val}
+	    -groups {set groups $val}
+	}
+    }
 
-proc client:roster_push {connid jid name groups subsc ask} {
-    hook::run roster_push_hook $connid $jid $name $groups $subsc $ask
+    hook::run roster_push_hook $xlib $jid $name $groups $subsc $ask
     ::redraw_roster
 }
 
-proc client:roster_cmd {connid status} {
+proc client:roster_cmd {xlib status xml} {
     debugmsg roster "ROSTER_CMD: $status"
     
-    if {[cequal $status END_ROSTER]} {
-	hook::run roster_end_hook $connid
+    if {[string equal $status ok]} {
+	hook::run roster_end_hook $xlib
 	::redraw_roster
     }
 }
 
-proc roster::request_roster {connid} {
+proc roster::request_roster {xlib} {
     variable roster
 
-    set roster(jids,$connid) {}
-    jlib::roster_get -command client:roster_cmd -connection $connid
+    set roster(jids,$xlib) {}
+    set roster(token,$xlib) \
+	[::xmpp::roster::new $xlib -itemcommand [list client:roster_push $xlib]]
+    ::xmpp::roster::get $roster(token,$xlib) -command [list client:roster_cmd $xlib]
 }
 
 hook::add connected_hook [namespace current]::roster::request_roster 15
 
-proc roster::get_group_jids {connid group args} {
+proc roster::get_group_jids {xlib group args} {
     variable roster
     variable undef_group_name
 
-    if {![info exists roster(jids,$connid)]} {
+    if {![info exists roster(jids,$xlib)]} {
 	return {}
     }
 
@@ -94,14 +108,14 @@
 
     set jids {}
     if {[cequal $group $undef_group_name]} {
-	foreach jid $roster(jids,$connid) {
-	    if {[lempty [::roster::itemconfig $connid $jid -group]]} {
+	foreach jid $roster(jids,$xlib) {
+	    if {[lempty [::roster::itemconfig $xlib $jid -group]]} {
 		lappend jids $jid
 	    }
 	}
     } else {
-	foreach jid $roster(jids,$connid) {
-	    foreach jgroup [::roster::itemconfig $connid $jid -group] {
+	foreach jid $roster(jids,$xlib) {
+	    foreach jgroup [::roster::itemconfig $xlib $jid -group] {
 		if {($nested && \
 			[string first "$group$delim" "$jgroup$delim"] == 0) || \
 			[cequal $group $jgroup]} {
@@ -114,21 +128,21 @@
     return $jids
 }
 
-proc roster::get_jids {connid} {
+proc roster::get_jids {xlib} {
     variable roster
 
-    if {[info exists roster(jids,$connid)]} {
-	return [lsort -dictionary $roster(jids,$connid)]
+    if {[info exists roster(jids,$xlib)]} {
+	return [lsort -dictionary $roster(jids,$xlib)]
     } else {
 	return {}
     }
 }
 
-proc roster::get_groups {connid args} {
+proc roster::get_groups {xlib args} {
     variable roster
     variable undef_group_name
 
-    if {![info exists roster(jids,$connid)]} {
+    if {![info exists roster(jids,$xlib)]} {
 	return {}
     }
 
@@ -143,8 +157,8 @@
 	    -delimiter { set delimiter $val }
 	    -raw {
 		if {$val} {
-		    foreach jid $roster(jids,$connid) {
-			set groups [concat $groups $roster(group,$connid,$jid)]
+		    foreach jid $roster(jids,$xlib) {
+			set groups [concat $groups $roster(group,$xlib,$jid)]
 		    }		    
 		    return [lrmdups $groups]
 		}
@@ -154,8 +168,8 @@
     }
 
     set empty 0
-    foreach jid $roster(jids,$connid) {
-	set jid_groups [::roster::itemconfig $connid $jid -group]
+    foreach jid $roster(jids,$xlib) {
+	set jid_groups [::roster::itemconfig $xlib $jid -group]
 	if {![lempty $jid_groups]} {
 	    foreach group $jid_groups {
 		if {$nested} {
@@ -184,7 +198,7 @@
     return $res
 }
 
-proc roster::itemconfig {connid jid args} {
+proc roster::itemconfig {xlib jid args} {
     variable roster
 
     if {[llength $args] == 1} {
@@ -195,13 +209,13 @@
 	    -subsc    {set param subsc}
 	    -ask      {set param ask}
 	    -category {
-		return [lindex [get_category_and_subtype $connid $jid] 0]
+		return [lindex [get_category_and_subtype $xlib $jid] 0]
 	    }
 	    -subtype  {
-		return [lindex [get_category_and_subtype $connid $jid] 1]
+		return [lindex [get_category_and_subtype $xlib $jid] 1]
 	    }
 	    -isuser   {
-		return [cequal [lindex [get_category_and_subtype $connid $jid] 0] "user"]
+		return [cequal [lindex [get_category_and_subtype $xlib $jid] 0] "user"]
 	    }
 	    default   {
 		return -code error "Bad option \"$attr\":\
@@ -209,8 +223,8 @@
 		    -category, -subtype or -isuser"
 	    }
 	}
-	if {[info exists roster($param,$connid,$jid)]} {
-	    return $roster($param,$connid,$jid)
+	if {[info exists roster($param,$xlib,$jid)]} {
+	    return $roster($param,$xlib,$jid)
 	} else {
 	    return ""
 	}
@@ -222,26 +236,26 @@
 		-subsc    {set param subsc}
 		-ask      {set param ask}
 		-category {
-		    override_category $connid $jid $val
+		    override_category $xlib $jid $val
 		    continue
 		}
 		-subtype  {
-		    override_subtype $connid $jid $val
+		    override_subtype $xlib $jid $val
 		    continue
 		}
 		default   {return -code error "Illegal option"}
 	    }
-	    set roster($param,$connid,$jid) $val
+	    set roster($param,$xlib,$jid) $val
 	}
     }
 }
 
 # Returns true if $jid is allowed to receive our presence information,
 # false otherwise.
-proc roster::is_trusted {connid jid} {
-    set subsc [itemconfig $connid [find_jid $connid $jid] -subsc]
+proc roster::is_trusted {xlib jid} {
+    set subsc [itemconfig $xlib [find_jid $xlib $jid] -subsc]
 
-    if {[node_and_server_from_jid $jid] == [jlib::connection_bare_jid $connid]} {
+    if {[node_and_server_from_jid $jid] == [connection_bare_jid $xlib]} {
 	return 1
     } elseif {$subsc == "both" || $subsc == "from"} {
 	return 1
@@ -250,7 +264,7 @@
     }
 }
 
-proc roster::on_change_jid_presence {connid jid type x args} {
+proc roster::on_change_jid_presence {xlib jid type x args} {
     variable roster
 
     switch -- $type {
@@ -260,15 +274,15 @@
 	default { return }
     }
 
-    set rjid [find_jid $connid $jid]
+    set rjid [find_jid $xlib $jid]
     debugmsg roster "$jid $rjid"
 
     if {$rjid != ""} {
-	lassign [get_category_and_subtype $connid $rjid] category subtype
+	lassign [get_category_and_subtype $xlib $rjid] category subtype
 	
 	if {$category == "user"} {
-	    set status [get_user_status $connid $rjid]
-	    set label [get_label $connid $rjid]
+	    set status [get_user_status $xlib $rjid]
+	    set label [get_label $xlib $rjid]
 	    if {![catch {set desc [::get_long_status_desc $status]}]} {
 		set_status [format "%s $desc" $label]
 	    }
@@ -280,22 +294,22 @@
 
 hook::add client_presence_hook roster::on_change_jid_presence 60
 
-proc roster::find_jid {connid jid} {
+proc roster::find_jid {xlib jid} {
     variable roster
 
-    if {![info exists roster(jids,$connid)]} {
+    if {![info exists roster(jids,$xlib)]} {
 	return ""
     }
 
-    if {[lsearch -exact $roster(jids,$connid) $jid] >= 0} {
+    if {[lsearch -exact $roster(jids,$xlib) $jid] >= 0} {
 	return $jid
     }
 
-    lassign [get_category_and_subtype $connid $jid] category subtype
+    lassign [get_category_and_subtype $xlib $jid] category subtype
     if {$category == "user"} {
 	set rjid [node_and_server_from_jid $jid]
-	if {[lsearch -exact $roster(jids,$connid) $rjid] >= 0} {
-	    lassign [get_category_and_subtype $connid $rjid] rcategory rsubtype
+	if {[lsearch -exact $roster(jids,$xlib) $rjid] >= 0} {
+	    lassign [get_category_and_subtype $xlib $rjid] rcategory rsubtype
 	    if {$category == $rcategory} {
 		return $rjid
 	    }
@@ -304,8 +318,8 @@
     return ""
 }
 
-proc roster::get_label {connid jid} {
-    set name [itemconfig $connid $jid -name]
+proc roster::get_label {xlib jid} {
+    set name [itemconfig $xlib $jid -name]
     if {[string equal $name ""]} {
 	return $jid
     } else {
@@ -313,70 +327,70 @@
     }
 }
 
-proc roster::override_category_and_subtype {connid jid category subtype} {
+proc roster::override_category_and_subtype {xlib jid category subtype} {
     variable roster
 
-    set roster(overridden_category_and_subtype,$connid,$jid) \
+    set roster(overridden_category_and_subtype,$xlib,$jid) \
 	[list $category $subtype]
 }
 
-proc roster::override_category {connid jid category} {
+proc roster::override_category {xlib jid category} {
     variable roster
 
-    if {![info exists roster(overridden_category_and_subtype,$connid,$jid)]} {
-	lassign [get_category_and_subtype $connid $jid] category1 subtype
-	set roster(overridden_category_and_subtype,$connid,$jid) \
+    if {![info exists roster(overridden_category_and_subtype,$xlib,$jid)]} {
+	lassign [get_category_and_subtype $xlib $jid] category1 subtype
+	set roster(overridden_category_and_subtype,$xlib,$jid) \
 	    [list $category $subtype]
     } else {
-	set roster(overridden_category_and_subtype,$connid,$jid) \
+	set roster(overridden_category_and_subtype,$xlib,$jid) \
 	    [list $category \
 		  [lindex \
-		       $roster(overridden_category_and_subtype,$connid,$jid) 1]]
+		       $roster(overridden_category_and_subtype,$xlib,$jid) 1]]
     }
 }
 
-proc roster::override_subtype {connid jid subtype} {
+proc roster::override_subtype {xlib jid subtype} {
     variable roster
 
-    if {![info exists roster(overridden_category_and_subtype,$connid,$jid)]} {
-	lassign [get_category_and_subtype $connid $jid] category subtype1
-	set roster(overridden_category_and_subtype,$connid,$jid) \
+    if {![info exists roster(overridden_category_and_subtype,$xlib,$jid)]} {
+	lassign [get_category_and_subtype $xlib $jid] category subtype1
+	set roster(overridden_category_and_subtype,$xlib,$jid) \
 	    [list $category $subtype]
     } else {
-	set roster(overridden_category_and_subtype,$connid,$jid) \
+	set roster(overridden_category_and_subtype,$xlib,$jid) \
 	    [list [lindex \
-		       $roster(overridden_category_and_subtype,$connid,$jid) 0] \
+		       $roster(overridden_category_and_subtype,$xlib,$jid) 0] \
 		  $subtype]
     }
 }
 
-proc roster::get_category_and_subtype {connid jid} {
+proc roster::get_category_and_subtype {xlib jid} {
     variable roster
 
-    if {[info exists roster(overridden_category_and_subtype,$connid,$jid)]} {
-	return $roster(overridden_category_and_subtype,$connid,$jid)
+    if {[info exists roster(overridden_category_and_subtype,$xlib,$jid)]} {
+	return $roster(overridden_category_and_subtype,$xlib,$jid)
     }
 
     set server [server_from_jid $jid]
-    if {[info exists roster(overridden_category_and_subtype,$connid,$server)]} {
-	catch { unset roster(cached_category_and_subtype,$connid,$jid) }
-	set cs [heuristically_get_category_and_subtype $connid $jid]
-	set roster(overridden_category_and_subtype,$connid,$jid) $cs
+    if {[info exists roster(overridden_category_and_subtype,$xlib,$server)]} {
+	catch { unset roster(cached_category_and_subtype,$xlib,$jid) }
+	set cs [heuristically_get_category_and_subtype $xlib $jid]
+	set roster(overridden_category_and_subtype,$xlib,$jid) $cs
 	return $cs
     }
 
-    if {[info exists roster(cached_category_and_subtype,$connid,$jid)]} {
-	return $roster(cached_category_and_subtype,$connid,$jid)
+    if {[info exists roster(cached_category_and_subtype,$xlib,$jid)]} {
+	return $roster(cached_category_and_subtype,$xlib,$jid)
     }
 
-    catch { plugins::cache_categories::request_category_and_subtype $connid $jid }
+    catch { plugins::cache_categories::request_category_and_subtype $xlib $jid }
 
-    set cs [heuristically_get_category_and_subtype $connid $jid]
-    set roster(cached_category_and_subtype,$connid,$jid) $cs
+    set cs [heuristically_get_category_and_subtype $xlib $jid]
+    set roster(cached_category_and_subtype,$xlib,$jid) $cs
     return $cs
 }
 
-proc roster::heuristically_get_category_and_subtype {connid jid} {
+proc roster::heuristically_get_category_and_subtype {xlib jid} {
     variable roster
 
     set node [node_from_jid $jid]
@@ -419,11 +433,11 @@
     }
 
     if {$node == ""} {
-	return [get_category_and_subtype $connid $server]
+	return [get_category_and_subtype $xlib $server]
     }
 
     if {[resource_from_jid $jid] == ""} {
-	lassign [get_category_and_subtype $connid $server] scategory ssubtype
+	lassign [get_category_and_subtype $xlib $server] scategory ssubtype
 
 	switch -glob -- $scategory/$ssubtype {
 	    conference/irc {
@@ -451,111 +465,99 @@
     return {user client}
 }
 
-proc roster::clean {} {
+proc roster::clean {xlib} {
     variable roster
 
-    array unset roster jids,*
-    array unset roster group,*
-    array unset roster name,*
-    array unset roster subsc,*
-    array unset roster ask,*
-    array unset roster subtype,*
-    array unset roster cached_category_and_subtype,*
-    array unset roster overridden_category_and_subtype,*
-    ::redraw_roster
-}
+    if {[info exists roster(token,$xlib)]} {
+	::xmpp::roster::free $roster(token,$xlib)
+    }
 
-proc roster::clean_connection {connid} {
-    variable roster
+    array unset roster token,$xlib
+    array unset roster jids,$xlib
+    array unset roster group,$xlib,*
+    array unset roster name,$xlib,*
+    array unset roster subsc,$xlib,*
+    array unset roster ask,$xlib,*
+    array unset roster subtype,$xlib,*
+    array unset roster cached_category_and_subtype,$xlib,*
+    array unset roster overridden_category_and_subtype,$xlib,*
 
-    array unset roster jids,$connid
-    array unset roster group,$connid,*
-    array unset roster name,$connid,*
-    array unset roster subsc,$connid,*
-    array unset roster ask,$connid,*
-    array unset roster subtype,$connid,*
-    array unset roster cached_category_and_subtype,$connid,*
-    array unset roster overridden_category_and_subtype,$connid,*
-
     ::redraw_roster
 }
 
 ###############################################################################
 
-proc roster::item_to_xml {connid jid} {
+proc roster::item_to_xml {xlib jid} {
     variable roster
     variable undef_group_name
     variable chats_group_name
     variable own_resources_group_name
 
     set grtags {}
-    foreach group $roster(group,$connid,$jid) {
+    foreach group $roster(group,$xlib,$jid) {
 	if {![cequal $group ""] && \
 		![cequal $group $undef_group_name] && \
 		![cequal $group $chats_group_name] && \
 		![cequal $group $own_resources_group_name]} {
-	    lappend grtags [jlib::wrapper:createtag group -chdata $group]
+	    lappend grtags [::xmpp::xml::create group -cdata $group]
 	}
     }
 
     set vars [list jid $jid]
 
-    if {$roster(name,$connid,$jid) != ""} {
-	lappend vars name $roster(name,$connid,$jid)
+    if {$roster(name,$xlib,$jid) != ""} {
+	lappend vars name $roster(name,$xlib,$jid)
     }
 
-    return [jlib::wrapper:createtag item -vars $vars -subtags $grtags]
+    return [::xmpp::xml::create item -attrs $vars -subelements $grtags]
 }
 
 ###############################################################################
 
-proc roster::send_item {connid jid} {
-    hook::run roster_send_item_hook $connid $jid
+proc roster::send_item {xlib jid} {
+    hook::run roster_send_item_hook $xlib $jid
 }
 
-proc roster::send_item_fallback {connid jid} {
+proc roster::send_item_fallback {xlib jid} {
 
-    jlib::send_iq set \
-	[jlib::wrapper:createtag query \
-	     -vars {xmlns jabber:iq:roster} \
-	     -subtags [list [roster::item_to_xml $connid $jid]]] \
-	-connection $connid
+    ::xmpp::sendIQ $xlib set \
+	-query [::xmpp::xml::create query \
+		    -xmlns jabber:iq:roster \
+		    -subelement [roster::item_to_xml $xlib $jid]]
 }
 
 hook::add roster_send_item_hook roster::send_item_fallback 100
 
 ###############################################################################
 
-proc roster::remove_item {connid jid} {
-    hook::run roster_remove_item_hook $connid $jid
+proc roster::remove_item {xlib jid} {
+    hook::run roster_remove_item_hook $xlib $jid
 }
 
-proc roster::remove_item_fallback {connid jid} {
+proc roster::remove_item_fallback {xlib jid} {
 
-    jlib::send_iq set \
-	[jlib::wrapper:createtag query \
-	     -vars [list xmlns $::NS(roster)] \
-	     -subtags [list [jlib::wrapper:createtag item \
-				 -vars [list jid $jid \
-					     subscription remove]]]] \
-	-connection $connid
+    ::xmpp::sendIQ $xlib set \
+	-query [::xmpp::xml::create query \
+		    -xmlns jabber:iq:roster \
+		    -subelement [::xmpp::xml::create item \
+					-attrs [list jid $jid \
+						     subscription remove]]]
 	
-    jlib::send_presence -to $jid -type unsubscribe -connection $connid
-    jlib::send_presence -to $jid -type unsubscribed -connection $connid
+    ::xmpp::sendPresence $xlib -to $jid -type unsubscribe
+    ::xmpp::sendPresence $xlib -to $jid -type unsubscribed
 
-    lassign [get_category_and_subtype $connid $jid] category subtype
+    lassign [get_category_and_subtype $xlib $jid] category subtype
 
     if {(($category == "service") || \
 	 ($category == "server") || \
 	 ($category == "gateway")) && \
 	[string compare -nocase [node_and_server_from_jid $jid] \
-				[jlib::connection_server $connid]]} {
-	jlib::send_iq set \
-	    [jlib::wrapper:createtag query \
-		 -vars [list xmlns $::NS(register)] \
-		 -subtags [list [jlib::wrapper:createtag remove]]] \
-	    -to $jid \
-	    -connection $connid
+				[connection_server $xlib]]} {
+	::xmpp::sendIQ $xlib set \
+	    -query [::xmpp::xml::create query \
+			-xmlns jabber:iq:register \
+			-subelement [::xmpp::xml::create remove]] \
+	    -to $jid
     }
 }
 
@@ -563,99 +565,94 @@
 
 ###############################################################################
 
-proc roster::send_rename_group {connid name new_name} {
+proc roster::send_rename_group {xlib name new_name} {
     variable roster
     variable undef_group_name
 
     if {[string equal $new_name $name]} return
 
-    hook::run roster_rename_group_hook $connid $name $new_name
+    hook::run roster_rename_group_hook $xlib $name $new_name
 
     set items {}
 
-    foreach jid $roster(jids,$connid) {
-	switch -- [itemconfig $connid $jid -subsc] {
+    foreach jid $roster(jids,$xlib) {
+	switch -- [itemconfig $xlib $jid -subsc] {
 	    none - from - to - both { }
 	    default { continue }
 	}
 
-	if {[lcontain $roster(group,$connid,$jid) $name] || \
+	if {[lcontain $roster(group,$xlib,$jid) $name] || \
 		($name == $undef_group_name && \
-		     $roster(group,$connid,$jid) == {})} {
-	    set idx [lsearch -exact $roster(group,$connid,$jid) $name]
+		     $roster(group,$xlib,$jid) == {})} {
+	    set idx [lsearch -exact $roster(group,$xlib,$jid) $name]
 	    if {$new_name != ""} {
-		set roster(group,$connid,$jid) \
-		    [lreplace $roster(group,$connid,$jid) $idx $idx $new_name]
+		set roster(group,$xlib,$jid) \
+		    [lreplace $roster(group,$xlib,$jid) $idx $idx $new_name]
 	    } else {
-		set roster(group,$connid,$jid) \
-		    [lreplace $roster(group,$connid,$jid) $idx $idx]
+		set roster(group,$xlib,$jid) \
+		    [lreplace $roster(group,$xlib,$jid) $idx $idx]
 	    }
-	    set roster(group,$connid,$jid) [lrmdups $roster(group,$connid,$jid)]
-	    lappend items [item_to_xml $connid $jid]
+	    set roster(group,$xlib,$jid) [lrmdups $roster(group,$xlib,$jid)]
+	    lappend items [item_to_xml $xlib $jid]
 	}
     }
 
     if {$items != {}} {
-	jlib::send_iq set \
-	    [jlib::wrapper:createtag query \
-		 -vars {xmlns jabber:iq:roster} \
-		 -subtags $items] \
-	    -connection $connid
+	::xmpp::sendIQ $xlib set \
+	    -query [::xmpp::xml::create query \
+			    -xmlns jabber:iq:roster \
+			    -subelements $items]
     }
 }
 
 ###############################################################################
 
-proc roster::send_remove_users_group {connid name} {
+proc roster::send_remove_users_group {xlib name} {
     variable roster
     variable undef_group_name
 
-    hook::run roster_remove_users_group_hook $connid $name
+    hook::run roster_remove_users_group_hook $xlib $name
 
     set items {}
 
-    foreach jid $roster(jids,$connid) {
-	switch -- [itemconfig $connid $jid -subsc] {
+    foreach jid $roster(jids,$xlib) {
+	switch -- [itemconfig $xlib $jid -subsc] {
 	    none - from - to - both { }
 	    default { continue }
 	}
 
-	set groups $roster(group,$connid,$jid)
+	set groups $roster(group,$xlib,$jid)
 	if {(([llength $groups] == 1) && [lcontain $groups $name]) || \
 		(($name == $undef_group_name) && ($groups == {}))} {
-	    remove_item $connid $jid
+	    remove_item $xlib $jid
 	} elseif {[lcontain $groups $name]} {
 	    set idx [lsearch -exact $groups $name]
-	    set roster(group,$connid,$jid) [lreplace $groups $idx $idx]
-	    lappend items [item_to_xml $connid $jid]
+	    set roster(group,$xlib,$jid) [lreplace $groups $idx $idx]
+	    lappend items [item_to_xml $xlib $jid]
 	}
     }
 
     if {$items != {}} {
-	jlib::send_iq set \
-	    [jlib::wrapper:createtag query \
-		 -vars {xmlns jabber:iq:roster} \
-		 -subtags $items] \
-	    -connection $connid
+	::xmpp::sendIQ $xlib set \
+	    -query [::xmpp::xml::create query \
+			    -xmlns jabber:iq:roster \
+			    -subelements $items]
     }
 }
 
 ###############################################################################
 
-proc roster::resubscribe_group {connid name} {
+proc roster::resubscribe_group {xlib name} {
     variable roster
     variable undef_group_name
 
-    foreach jid $roster(jids,$connid) {
-	if {[lcontain $roster(group,$connid,$jid) $name] || \
+    foreach jid $roster(jids,$xlib) {
+	if {[lcontain $roster(group,$xlib,$jid) $name] || \
 		($name == $undef_group_name && \
-		     $roster(group,$connid,$jid) == {})} {
-	    lassign [get_category_and_subtype $connid $jid] category type
+		     $roster(group,$xlib,$jid) == {})} {
+	    lassign [get_category_and_subtype $xlib $jid] category type
 	    if {$category == "user"} {
-		jlib::send_presence \
-		    -to $jid \
-		    -connection $connid \
-		    -type subscribe
+		::xmpp::sendPresence $xlib -to $jid -type subscribe
 	    }
 	}
     }
@@ -663,17 +660,17 @@
 
 ###############################################################################
 
-proc roster::send_custom_presence_group {connid name status} {
+proc roster::send_custom_presence_group {xlib name status} {
     variable roster
     variable undef_group_name
 
-    foreach jid $roster(jids,$connid) {
-	if {[lcontain $roster(group,$connid,$jid) $name] || \
+    foreach jid $roster(jids,$xlib) {
+	if {[lcontain $roster(group,$xlib,$jid) $name] || \
 		($name == $undef_group_name && \
-		     $roster(group,$connid,$jid) == {})} {
-	    lassign [get_category_and_subtype $connid $jid] category type
+		     $roster(group,$xlib,$jid) == {})} {
+	    lassign [get_category_and_subtype $xlib $jid] category type
 	    if {$category == "user"} {
-		send_custom_presence $jid $status -connection $connid
+		send_custom_presence $xlib $jid $status
 	    }
 	}
     }
@@ -684,40 +681,39 @@
 proc roster::add_group_by_jid_regexp {name regexp} {
     variable roster
 
-    # TODO: connid
+    # TODO: xlib
     if {$name == ""} return
 
-    foreach connid [jlib::connections] {
+    foreach xlib [connections] {
 	set items {}
 
-	foreach jid $roster(jids,$connid) {
+	foreach jid $roster(jids,$xlib) {
 	    if {[regexp -- $regexp $jid]} {
-		set idx [lsearch -exact $roster(group,$connid,$jid) $name]
-		lappend roster(group,$connid,$jid) $name
-		set roster(group,$connid,$jid) \
-		    [lrmdups $roster(group,$connid,$jid)]
-		lappend items [item_to_xml $connid $jid]
+		set idx [lsearch -exact $roster(group,$xlib,$jid) $name]
+		lappend roster(group,$xlib,$jid) $name
+		set roster(group,$xlib,$jid) \
+		    [lrmdups $roster(group,$xlib,$jid)]
+		lappend items [item_to_xml $xlib $jid]
 	    }
 	}
 
 	if {$items != {}} {
-	    jlib::send_iq set \
-		[jlib::wrapper:createtag query \
-		     -vars {xmlns jabber:iq:roster} \
-		     -subtags $items] \
-		-connection $connid
+	    ::xmpp::sendIQ $xlib set \
+		-query [::xmpp::xml::create query \
+				-xmlns jabber:iq:roster \
+				-subelements $items]
 	}
     }
 }
 
 ###############################################################################
 
-proc roster::export_to_file {connid} {
+proc roster::export_to_file {xlib} {
     variable roster
 
     set filename [tk_getSaveFile \
 		      -initialdir $::configdir \
-		      -initialfile [jlib::connection_user $connid].roster \
+		      -initialfile [connection_user $xlib].roster \
 		      -filetypes [list \
 				      [list [::msgcat::mc "Roster Files"] \
 					   .roster] \
@@ -725,8 +721,8 @@
     if {$filename != ""} {
 	set items {}
 
-	foreach jid $roster(jids,$connid) {
-	    lappend items [item_to_xml $connid $jid]
+	foreach jid $roster(jids,$xlib) {
+	    lappend items [item_to_xml $xlib $jid]
 	}
 
 	set fd [open $filename w]
@@ -736,12 +732,12 @@
     }
 }
 
-proc roster::import_from_file {connid} {
+proc roster::import_from_file {xlib} {
     variable roster
 
     set filename [tk_getOpenFile \
 		      -initialdir $::configdir \
-		      -initialfile [jlib::connection_user $connid].roster \
+		      -initialfile [connection_user $xlib].roster \
 		      -filetypes [list \
 				      [list [::msgcat::mc "Roster Files"] \
 					   .roster] \
@@ -753,11 +749,10 @@
 	close $fd
 
 	if {$items != {}} {
-	    jlib::send_iq set \
-		[jlib::wrapper:createtag query \
-		     -vars [list xmlns "jabber:iq:roster"] \
-		     -subtags $items] \
-		-connection $connid
+	    ::xmpp::sendIQ $xlib set \
+		-query [::xmpp::xml::create query \
+				-xmlns jabber:iq:roster \
+				-subelements $items]
 	}
     }
 }

Modified: trunk/tkabber/search.tcl
===================================================================
--- trunk/tkabber/search.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/search.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -5,18 +5,9 @@
     set show_all 0
 }
 
-proc search::open {jid args} {
+proc search::open {xlib jid args} {
     variable winid
 
-    foreach {opt val} $args {	
-	switch -- $opt {
-	    -connection { set connid $val }
-	}
-    }
-    if {![info exists connid]} {
-	return -code error "search::open: -connection is mandatory"
-    }
-
     set sw .search$winid
 
     toplevel $sw -cursor watch
@@ -36,7 +27,7 @@
 
     ButtonBox $sw.bbox -spacing 0 -padx 10 -default 0
     $sw.bbox add -text [::msgcat::mc "OK"] \
-	-command [list search::search $sw $connid $jid] \
+	-command [list search::search $sw $xlib $jid] \
         -state disabled
     $sw.bbox add -text [::msgcat::mc "Cancel"] -command [list destroy $sw]
     pack $sw.bbox -padx 2m -pady 2m -anchor e -side bottom
@@ -51,31 +42,30 @@
 
     pack $sw.fields -expand yes -fill both -anchor nw -padx 2m -pady 2m
 
-    jlib::send_iq get \
-	[jlib::wrapper:createtag query \
-	     -vars [list xmlns jabber:iq:search]] \
-	-to $jid -command [list search::recv_fields $sw $jid] \
-	-connection $connid
+    ::xmpp::sendIQ $xlib get \
+	-query [::xmpp::xml::create query \
+			-xmlns jabber:iq:search] \
+	-to $jid \
+	-command [list search::recv_fields $sw $jid]
     
     incr winid
 }
 
-proc search::recv_fields {sw jid res child} {
-    debugmsg search "$res $child"
+proc search::recv_fields {sw jid status xml} {
+    debugmsg search "$status $xml"
 
-    if {![cequal $res OK]} {
+    if {![string equal $status ok]} {
         destroy $sw
 	MessageDlg ${sw}_err -aspect 50000 -icon error \
-	    -message [format [::msgcat::mc "Search: %s"] \
-			  [error_to_string $child]] \
+	    -message [::msgcat::mc "Search: %s" [error_to_string $xml]] \
 	    -type user -buttons ok -default 0 -cancel 0
 	return
     }
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
+    ::xmpp::xml::split $xml tag xmlns attrs cdata subels
 
-    if {[cequal [jlib::wrapper:getattr $vars xmlns] jabber:iq:search]} {
-	set focus [data::fill_fields $sw.fields $children]
+    if {[string equal $xmlns jabber:iq:search]} {
+	set focus [data::fill_fields $sw.fields $subels]
     }
 
     $sw configure -cursor {}
@@ -88,7 +78,7 @@
     wm deiconify $sw
 }
 
-proc search::search {sw connid jid} {
+proc search::search {sw xlib jid} {
     variable data
 
     $sw configure -cursor watch
@@ -96,27 +86,27 @@
 
     set restags [data::get_tags $sw.fields]
 
-    jlib::send_iq set \
-	[jlib::wrapper:createtag query \
-	     -vars [list xmlns jabber:iq:search] \
-	     -subtags $restags] \
-	-to $jid -command [list search::recv_items $sw $jid $connid] \
-	-connection $connid
+    ::xmpp::sendIQ $xlib set \
+	-query [::xmpp::xml::create query \
+			-xmlns jabber:iq:search \
+			-subelements $restags] \
+	-to $jid \
+	-command [list search::recv_items $sw $jid $xlib]
 }
 
-proc search::recv_items {sw jid connid res child} {
+proc search::recv_items {sw jid xlib status xml} {
     variable lastsort
 
-    debugmsg search "$res $child"
+    debugmsg search "$status $xml"
 
     if {![winfo exists $sw]} {
 	return
     }
 
-    if {![cequal $res OK]} {
+    if {![string equal $status ok]} {
 	$sw configure -cursor {}
 	$sw.bbox itemconfigure 0 -text [::msgcat::mc "Try again"] \
-	    -command [list search::search_again $sw $jid $connid errormsg] \
+	    -command [list search::search_again $sw $jid $xlib errormsg] \
 	    -state normal
 	$sw.bbox itemconfigure 1 -text [::msgcat::mc "Close"]
 
@@ -125,8 +115,8 @@
 	}
 
 	message $sw.errormsg -aspect 50000 \
-	    -text [format [::msgcat::mc "An error occurred when searching in %s\n\n%s"] \
-		       $jid [error_to_string $child]]
+	    -text [::msgcat::mc "An error occurred when searching in %s\n\n%s" \
+				$jid [error_to_string $xml]]
 
 	pack $sw.errormsg -expand yes -fill both -after $sw.fields -anchor nw -padx 1c -pady 1c
 	pack forget $sw.fields
@@ -146,7 +136,7 @@
     ButtonBox $rw.bbox -spacing 0 -padx 10 -default 0
     $rw.bbox add -text [::msgcat::mc "Search again"] \
 	-command "destroy [list $rw]
-		  search::search_again [list $sw] [list $jid] [list $connid]"
+		  search::search_again [list $sw] [list $jid] [list $xlib]"
     $rw.bbox add -text [::msgcat::mc "Close"] -command "destroy [list $rw]
 							destroy [list $sw]"
     pack $rw.bbox -padx 2m -pady 2m -anchor e -side bottom
@@ -174,16 +164,16 @@
     bind $sww.listbox <3> \
 	"[namespace current]::select_and_popup_menu [list $sww.listbox] \
 	     \[$sww.listbox nearest \[::mclistbox::convert %W -y %y\]\] \
-	     $connid"
+	     $xlib"
 
     bindscroll $sww $sww.listbox
 
     set reported_fields [data::get_reported_fields $sw.fields]
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
+    ::xmpp::xml::split $xml tag xmlns attrs cdata subels
 
-    if {[cequal [jlib::wrapper:getattr $vars xmlns] jabber:iq:search]} {
-	set rows [fill_mclistbox $rw $jid $sww.listbox $reported_fields $children]
+    if {[string equal $xmlns jabber:iq:search]} {
+	set rows [fill_mclistbox $rw $jid $sww.listbox $reported_fields $subels]
     }
 
     if {$rows <= 0} {
@@ -217,37 +207,36 @@
     set col 1
 
     foreach item $items {
-	jlib::wrapper:splitxml $item tag vars isempty chdata children
+	::xmpp::xml::split $item tag xmlns attrs cdata subels
 
 	switch -- $tag {
 	    title {
-		if {$chdata != ""} {
-		    wm title $sw $chdata
-		    wm iconname $sw $chdata
+		if {$cdata != ""} {
+		    wm title $sw $cdata
+		    wm iconname $sw $cdata
 		}
 	    }
 	    reported {
 		set reported_fields {}
-		foreach field $children {
-		    jlib::wrapper:splitxml $field tag vars isempty chdata children1
+		foreach field $subels {
+		    ::xmpp::xml::split $field stag sxmlns sattrs scdata ssubels
 
-		    set lname [jlib::wrapper:getattr $vars "var"]
-		    set label_name($lname) [jlib::wrapper:getattr $vars "label"]
+		    set lname [::xmpp::xml::getAttr $sattrs "var"]
+		    set label_name($lname) [::xmpp::xml::getAttr $sattrs "label"]
 		    lappend reported_fields $lname
 		}
 	    }
 	    item {
-		foreach field $children {
-		    jlib::wrapper:splitxml $field tag vars isempty chdata children1
+		foreach field $subels {
+		    ::xmpp::xml::split $field stag sxmlns sattrs scdata ssubels
 
-		    if {$tag == "field"} {
-			set var [jlib::wrapper:getattr $vars "var"]
+		    if {$stag == "field"} {
+			set var [::xmpp::xml::getAttr $sattrs "var"]
 
-			foreach value $children1 {
+			foreach value $ssubels {
+			    ::xmpp::xml::split $value sstag ssxmlns ssattrs sscdata sssubels
 			    
-			    jlib::wrapper:splitxml $value tag vars isempty chdata children1
-
-			    if {($tag == "value") && ($chdata != "")} {
+			    if {($sstag == "value") && ($sscdata != "")} {
 				if {$show_all || ([lsearch -exact $reported_fields $var] != -1)} {
 				    if {![info exists fieldcol($var)]} {
 					set fieldcol($var) $col
@@ -264,9 +253,9 @@
 
 					incr col
 				    }
-				    set data($fieldcol($var),$row) $chdata
+				    set data($fieldcol($var),$row) $sscdata
 
-				    debugmsg search "$var $chdata"
+				    debugmsg search "$var $sscdata"
 				}
 			    }
 			}
@@ -317,9 +306,8 @@
     variable show_all
 
     foreach item $items {
-	jlib::wrapper:splitxml $item tag vars isempty chdata children
-	if {$tag == "x" &&
-	    [jlib::wrapper:getattr $vars xmlns] == "jabber:x:data"} {
+	::xmpp::xml::split $item tag xmlns attrs cdata subels
+	if {$tag == "x" && $xmlns == "jabber:x:data"} {
 	    return [fill_mclistbox_x $sw $jid $w $reported_fields $children]
 	}
     }
@@ -338,18 +326,17 @@
     set col 2
 
     foreach item $items {
-	jlib::wrapper:splitxml $item tag vars isempty chdata children
+	::xmpp::xml::split $item tag xmlns attrs cdata subels
 
 	switch -- $tag {
 	    item {
-		set itemjid [jlib::wrapper:getattr $vars jid]
+		set itemjid [::xmpp::xml::getAttr $attrs jid]
 		set data(1,$row) $itemjid
 
-		foreach field $children {
-		    jlib::wrapper:splitxml $field tag vars isempty \
-			chdata children1
+		foreach field $subels {
+		    ::xmpp::xml::split $fiels stag sxmlns sattrs scdata ssubels
 
-		    if {$chdata != ""} {
+		    if {$scdata != ""} {
 			if {$show_all || ([lsearch -exact $reported_fields $tag] != -1)} {
 			    if {![info exists fieldcol($tag)]} {
 				set fieldcol($tag) $col
@@ -361,9 +348,9 @@
 
 				incr col
 			    }
-			    set data($fieldcol($tag),$row) $chdata
+			    set data($fieldcol($tag),$row) $scdata
 
-			    debugmsg search "$tag $chdata"
+			    debugmsg search "$tag $scdata"
 			}
 		    }
 		}
@@ -398,14 +385,14 @@
     eval $w insert end $result1
 }
 
-proc search::search_again {sw jid connid {delwidget ""}} {
+proc search::search_again {sw jid xlib {delwidget ""}} {
     $sw configure -cursor {}
     if {![cequal $delwidget ""]} {
 	pack $sw.fields -expand yes -fill both -after $sw.$delwidget -anchor nw -padx 2m -pady 2m
 	pack forget $sw.$delwidget
 
 	$sw.bbox itemconfigure 0 -text [::msgcat::mc "OK"] \
-	    -command [list search::search $sw $connid $jid] \
+	    -command [list search::search $sw $xlib $jid] \
 	    -state normal
 	$sw.bbox itemconfigure 1 -text [::msgcat::mc "Cancel"]
     } else {
@@ -414,7 +401,7 @@
     }
 }
 
-proc search::select_and_popup_menu {w index connid} {
+proc search::select_and_popup_menu {w index xlib} {
 
     $w selection clear 0 end
     $w selection set $index
@@ -425,12 +412,12 @@
     }
     menu $m -tearoff 0
 
-    hook::run search_popup_menu_hook $m $connid $jid
+    hook::run search_popup_menu_hook $m $xlib $jid
 
     tk_popup $m [winfo pointerx .] [winfo pointery .]
 }
 
-proc search::add_separator {m connid jid} {
+proc search::add_separator {m xlib jid} {
     $m add separator
 }
 

Modified: trunk/tkabber/si.tcl
===================================================================
--- trunk/tkabber/si.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/si.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -14,11 +14,11 @@
 ###############################################################################
 ###############################################################################
 
-proc si::newout {connid jid} {
+proc si::newout {xlib jid} {
     variable streams
 
     set id [rand 1000000000]
-    while {[info exists streams(out,$connid,$jid,$id)]} {
+    while {[info exists streams(out,$xlib,$jid,$id)]} {
 	set id [rand 1000000000]
     }
     set streamid 0
@@ -28,10 +28,10 @@
     }
     upvar #0 $stream state
 
-    set state(connid) $connid
+    set state(xlib) $xlib
     set state(jid) $jid
     set state(id) $id
-    set streams(out,$connid,$jid,$id) $stream
+    set streams(out,$xlib,$jid,$id) $stream
 
     return $stream
 }
@@ -41,21 +41,21 @@
     upvar #0 $stream state
 
     catch {
-	set connid $state(connid)
+	set xlib $state(xlib)
 	set jid $state(jid)
 	set id $state(id)
 
 	unset state
-	unset streams(out,$connid,$jid,$id)
+	unset streams(out,$xlib,$jid,$id)
     }
 }
 
 ###############################################################################
 
-proc si::newin {connid jid id} {
+proc si::newin {xlib jid id} {
     variable streams
 
-    if {[info exists streams(in,$connid,$jid,$id)]} {
+    if {[info exists streams(in,$xlib,$jid,$id)]} {
 	return -code error
     }
 
@@ -66,18 +66,18 @@
     }
     upvar #0 $stream state
 
-    set state(connid) $connid
+    set state(xlib) $xlib
     set state(jid) $jid
     set state(id) $id
-    set streams(in,$connid,$jid,$id) $stream
+    set streams(in,$xlib,$jid,$id) $stream
 
     return $stream
 }
 
-proc si::in {connid jid id} {
+proc si::in {xlib jid id} {
     variable streams
 
-    return $streams(in,$connid,$jid,$id)
+    return $streams(in,$xlib,$jid,$id)
 }
 
 proc si::freein {stream} {
@@ -85,12 +85,12 @@
     upvar #0 $stream state
 
     catch {
-	set connid $state(connid)
+	set xlib $state(xlib)
 	set jid $state(jid)
 	set id $state(id)
 
 	unset state
-	unset streams(in,$connid,$jid,$id)
+	unset streams(in,$xlib,$jid,$id)
     }
 }
 
@@ -113,43 +113,41 @@
 
     set opttags {}
     foreach opt $options {
-	lappend opttags [jlib::wrapper:createtag option \
-			     -subtags [list [jlib::wrapper:createtag value \
-						 -chdata $opt]]]
+	lappend opttags [::xmpp::xml::create option \
+			     -subelement [::xmpp::xml::create value \
+						 -cdata $opt]]
     }
 
     set feature \
-	[jlib::wrapper:createtag feature \
-	     -vars [list xmlns http://jabber.org/protocol/feature-neg] \
-	     -subtags \
-	     [list [jlib::wrapper:createtag x \
-			-vars [list xmlns jabber:x:data type form] \
-			-subtags \
-			[list [jlib::wrapper:createtag \
-				   field \
-				   -vars [list var stream-method \
-					       type list-single] \
-				   -subtags $opttags]]]]]
+	[::xmpp::xml::create feature \
+	     -xmlns http://jabber.org/protocol/feature-neg \
+	     -subelement [::xmpp::xml::create x \
+				-xmlns jabber:x:data \
+				-attrs [list type form] \
+			-subelement [::xmpp::xml::create field \
+					-attrs [list var stream-method \
+						     type list-single] \
+					-subelements $opttags]]]
 
 
     set_status [::msgcat::mc "Opening SI connection"]
 
-    jlib::send_iq set \
-	[jlib::wrapper:createtag si \
-	     -vars [list xmlns $::NS(si) \
-			id $state(id) \
-			mime-type $mimetype \
-			profile $profile] \
-	     -subtags [list $profile_el $feature]] \
+    ::xmpp::sendIQ $state(xlib) set \
+	-query [::xmpp::xml::create si \
+		    -xmlns $::NS(si) \
+		    -attrs [list id $state(id) \
+				 mime-type $mimetype \
+				 profile $profile] \
+		    -subelement $profile_el \
+		    -subelement $feature] \
 	-to $state(jid) \
 	-command [list si::connect_response $stream $chunk_size \
-					    $profile $command] \
-	-connection $state(connid)
+					    $profile $command]
 }
 
 ###############################################################################
 
-proc si::connect_response {stream chunk_size profile command res child} {
+proc si::connect_response {stream chunk_size profile command status xml} {
     variable transport
     upvar #0 $stream state
 
@@ -160,12 +158,12 @@
 	return
     }
 
-    if {$res != "OK"} {
-	uplevel #0 $command [list [list 0 [error_to_string $child]]]
+    if {$status != "ok"} {
+	uplevel #0 $command [list [list 0 [error_to_string $xml]]]
 	return
     }
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
+    ::xmpp::xml::split $xml tag xmlns attrs cdata subels
 
     set trans [lsort -unique -index 1 $transport(list)]
     set options {}
@@ -179,15 +177,14 @@
 
     set opts {}
 
-    foreach item $children {
-	jlib::wrapper:splitxml $item tag1 vars1 isempty1 chdata1 children1
-	set xmlns [jlib::wrapper:getattr $vars1 xmlns]
-	    if {[string equal $xmlns $profile]} {
-		# TODO
-	    } elseif {[string equal $xmlns \
-			   http://jabber.org/protocol/feature-neg]} {
-		set opts [parse_negotiation_res $item]
-	    }
+    foreach item $subels {
+	::xmpp::xml::split $item stag sxmlns sattrs scdata ssubels
+	if {[string equal $sxmlns $profile]} {
+	    # TODO
+	} elseif {[string equal $sxmlns \
+				http://jabber.org/protocol/feature-neg]} {
+	    set opts [parse_negotiation_res $item]
+	}
     }
 
     if {[llength $opts] == 1 && [lcontain $options [lindex $opts 0]]} {
@@ -267,26 +264,24 @@
 
 ###############################################################################
 
-proc si::parse_negotiation {child} {
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
+proc si::parse_negotiation {xml} {
+    ::xmpp::xml::split $xml tag xmlns attrs cdata subels
 
     set options {}
-    foreach item $children {
-	jlib::wrapper:splitxml $item tag1 vars1 isempty1 chdata1 children1
-	set xmlns [jlib::wrapper:getattr $vars1 xmlns]
-	if {[string equal $xmlns jabber:x:data]} {
-	    foreach item $children1 {
-		jlib::wrapper:splitxml $item \
-		    tag2 vars2 isempty2 chdata2 children2
-		set var [jlib::wrapper:getattr $vars2 var]
+    foreach item $subels {
+	::xmpp::xml::split $item stag sxmlns sattrs scdata ssubels
+	if {[string equal $sxmlns jabber:x:data]} {
+	    foreach sitem $ssubels {
+		::xmpp::xml::split $sitem sstag ssxmlns ssattrs sscdata sssubels
+		set var [::xmpp::xml::getAttr $ssattrs var]
 		if {[string equal $var stream-method]} {
-		    foreach item $children2 {
-			jlib::wrapper:splitxml $item \
-			    tag3 vars3 isempty3 chdata3 children3
-			foreach item $children3 {
-			    jlib::wrapper:splitxml $item \
-				tag4 vars4 isempty4 chdata4 children4
-			    lappend options $chdata4
+		    foreach ssitem $sssubels {
+			::xmpp::xml::split $ssitem \
+				s3tag s3xmlns s3attrs s3cdata s3subels
+			foreach s3item $s3subels {
+			    ::xmpp::xml::split $s3item \
+					s4tag s4xmlns s4attrs s4cdata s4subels
+			    lappend options $s4cdata
 			}
 		    }
 		}
@@ -296,23 +291,21 @@
     return $options
 }
 
-proc si::parse_negotiation_res {child} {
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
+proc si::parse_negotiation_res {xml} {
+    ::xmpp::xml::split $xml tag xmlns attrs cdata subels
 
     set options {}
-    foreach item $children {
-	jlib::wrapper:splitxml $item tag1 vars1 isempty1 chdata1 children1
-	set xmlns [jlib::wrapper:getattr $vars1 xmlns]
-	if {[string equal $xmlns jabber:x:data]} {
-	    foreach item $children1 {
-		jlib::wrapper:splitxml $item \
-		    tag2 vars2 isempty2 chdata2 children2
-		set var [jlib::wrapper:getattr $vars2 var]
+    foreach item $subels {
+	::xmpp::xml::split $item stag sxmlns sattrs scdata ssubels
+	if {[string equal $sxmlns jabber:x:data]} {
+	    foreach sitem $ssubels {
+		::xmpp::xml::split $sitem sstag ssxmlns ssattrs sscdata sssubels
+		set var [::xmpp::xml::getAttr $ssattrs var]
 		if {[string equal $var stream-method]} {
-		    foreach item $children2 {
-			jlib::wrapper:splitxml $item \
-			    tag3 vars3 isempty3 chdata3 children3
-			lappend options $chdata3
+		    foreach ssitem $sssubels {
+			::xmpp::xml::split $ssitem \
+				s3tag s3xmlns s3attrs s3cdata s3subels
+			lappend options $s3cdata
 		    }
 		}
 	    }
@@ -323,26 +316,27 @@
 
 ###############################################################################
 
-proc si::set_handler {connid from lang child} {
+proc si::set_handler {xlib from xml args} {
     variable profiledata
     variable transport
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
+    ::xmpp::xml::split $xml tag xmlns attrs cdata subels
 
-    set id [jlib::wrapper:getattr $vars id]
-    set mimetype [jlib::wrapper:getattr $vars mime-type]
-    set profile [jlib::wrapper:getattr $vars profile]
+    set id [::xmpp::xml::getAttr $attrs id]
+    set mimetype [::xmpp::xml::getAttr $attrs mime-type]
+    set profile [::xmpp::xml::getAttr $attrs profile]
     set stream {}
     set profile_res {}
 
+    set lang [::xmpp::xml::getAttr $args -lang en]
+
     if {[info exists profiledata($profile)]} {
-	foreach item $children {
-	    jlib::wrapper:splitxml $item tag1 vars1 isempty1 chdata1 children1
-	    set xmlns [jlib::wrapper:getattr $vars1 xmlns]
-	    if {[string equal $xmlns $profile]} {
+	foreach item $subels {
+	    ::xmpp::xml::split $item stag sxmlns sattrs scdata ssubels
+	    if {[string equal $sxmlns $profile]} {
 		set profile_res [$profiledata($profile) \
-				     $connid $from $lang $id $mimetype $item]
-	    } elseif {[string equal $xmlns \
+				     $xlib $from $lang $id $mimetype $item]
+	    } elseif {[string equal $sxmlns \
 			   http://jabber.org/protocol/feature-neg]} {
 		set options [parse_negotiation $item]
 
@@ -372,27 +366,23 @@
 	    # no-valid-streams
 	    return [list error modify bad-request]
 	}
-	set res_childs {}
+	set res_elements {}
 	if {$profile_res != {}} {
-	    lappend res_childs $profile_res
+	    lappend res_elements $profile_res
 	}
-	set opttags \
-	    [list [jlib::wrapper:createtag value \
-		       -chdata $opt]]
-	lappend res_childs \
-	    [jlib::wrapper:createtag feature \
-		 -vars [list xmlns http://jabber.org/protocol/feature-neg] \
-		 -subtags \
-		 [list [jlib::wrapper:createtag x \
-			    -vars [list xmlns jabber:x:data type submit] \
-			    -subtags \
-			    [list [jlib::wrapper:createtag \
-				       field \
-				       -vars [list var stream-method] \
-				       -subtags $opttags]]]]]
-	set res [jlib::wrapper:createtag si \
-		     -vars [list xmlns $::NS(si)] \
-		     -subtags $res_childs]
+	set opttag [::xmpp::xml::create value -cdata $opt]
+	lappend res_elements \
+	    [::xmpp::xml::create feature \
+		 -xmlns http://jabber.org/protocol/feature-neg \
+		 -subelement [::xmpp::xml::create x \
+				    -xmlns jabber:x:data \
+				    -attrs [list type submit] \
+				    -subelement [::xmpp::xml::create field \
+						    -attrs [list var stream-method] \
+						    -subelement $opttag]]]
+	set res [::xmpp::xml::create si \
+			-xmlns $::NS(si) \
+			-subelements $res_elements]
 	return [list result $res]
     } else {
 	# bad-profile
@@ -400,7 +390,7 @@
     }
 }
 
-iq::register_handler set "" $::NS(si) si::set_handler
+::xmpp::iq::register set * $::NS(si) si::set_handler
 
 ###############################################################################
 ###############################################################################

Modified: trunk/tkabber/splash.tcl
===================================================================
--- trunk/tkabber/splash.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/splash.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -37,56 +37,56 @@
     set splash_max   145
 
     array set splash_text [list					   \
-	custom		    [::msgcat::mc "customization"]         \
-        utils               [::msgcat::mc "utilities"]             \
-        plugins             [::msgcat::mc "plugin management"]     \
-	pixmaps		    [::msgcat::mc "pixmaps management"]    \
-        balloon             [::msgcat::mc "balloon help"]          \
-        presence            [::msgcat::mc "jabber presence"]       \
-        iq                  [::msgcat::mc "jabber iq"]             \
-        plugins:iq          [::msgcat::mc "jabber iq"]             \
-        roster              [::msgcat::mc "jabber roster"]         \
-        itemedit            [::msgcat::mc "jabber roster"]         \
-        messages            [::msgcat::mc "jabber messages"]       \
-        chats               [::msgcat::mc "jabber chat/muc"]       \
-        plugins:chat        [::msgcat::mc "jabber chat/muc"]       \
-        joingrdialog        [::msgcat::mc "jabber chat/muc"]       \
-        muc                 [::msgcat::mc "jabber chat/muc"]       \
-        emoticons           [::msgcat::mc "emoticons"]             \
-        aniemoticons        [::msgcat::mc "emoticons"]             \
-        login               [::msgcat::mc "connections"]           \
-        browser             [::msgcat::mc "browsing"]              \
-        disco               [::msgcat::mc "service discovery"]     \
-        userinfo            [::msgcat::mc "presence"]              \
-        datagathering       [::msgcat::mc "utilities"]             \
-        negotiate           [::msgcat::mc "negotiation"]           \
-        search              [::msgcat::mc "searching"]             \
-        register            [::msgcat::mc "jabber registration"]   \
-        si                  [::msgcat::mc "file transfer"]         \
-        plugins:si          [::msgcat::mc "file transfer"]         \
-        filetransfer        [::msgcat::mc "file transfer"]         \
+	custom		     [::msgcat::mc "customization"]        \
+        utils                [::msgcat::mc "utilities"]            \
+        plugins              [::msgcat::mc "plugin management"]    \
+	pixmaps		     [::msgcat::mc "pixmaps management"]   \
+        balloon              [::msgcat::mc "balloon help"]         \
+        presence             [::msgcat::mc "xmpp presence"]        \
+        iq                   [::msgcat::mc "xmpp iq"]              \
+        plugins:iq           [::msgcat::mc "xmpp iq"]              \
+        roster               [::msgcat::mc "xmpp roster"]          \
+        itemedit             [::msgcat::mc "xmpp roster"]          \
+        messages             [::msgcat::mc "xmpp messages"]        \
+        chats                [::msgcat::mc "xmpp chat/muc"]        \
+        plugins:chat         [::msgcat::mc "xmpp chat/muc"]        \
+        joingrdialog         [::msgcat::mc "xmpp chat/muc"]        \
+        muc                  [::msgcat::mc "xmpp chat/muc"]        \
+        emoticons            [::msgcat::mc "emoticons"]            \
+        aniemoticons         [::msgcat::mc "emoticons"]            \
+        login                [::msgcat::mc "connections"]          \
+        browser              [::msgcat::mc "browsing"]             \
+        disco                [::msgcat::mc "service discovery"]    \
+        userinfo             [::msgcat::mc "presence"]             \
+        datagathering        [::msgcat::mc "utilities"]            \
+        negotiate            [::msgcat::mc "negotiation"]          \
+        search               [::msgcat::mc "searching"]            \
+        register             [::msgcat::mc "xmpp registration"]    \
+        si                   [::msgcat::mc "file transfer"]        \
+        plugins:si           [::msgcat::mc "file transfer"]        \
+        filetransfer         [::msgcat::mc "file transfer"]        \
         plugins:filetransfer [::msgcat::mc "file transfer"]        \
-        filters             [::msgcat::mc "message filters"]       \
-        privacy             [::msgcat::mc "privacy rules"]         \
-        gpgme               [::msgcat::mc "cryptographics"]        \
-        ifacetk             [::msgcat::mc "user interface"]        \
-	plugins:general     [::msgcat::mc "general plugins"]       \
-	plugins:roster      [::msgcat::mc "roster plugins"]        \
-	plugins:search      [::msgcat::mc "search plugins"]        \
-	plugins:unix        [::msgcat::mc "unix plugins"]          \
-	plugins:windows     [::msgcat::mc "windows plugins"]       \
-	plugins:macintosh   [::msgcat::mc "macintosh plugins"]     \
-        iface               [::msgcat::mc "user interface"]        \
-        autoaway            [::msgcat::mc "auto-away"]             \
-        avatars             [::msgcat::mc "avatars"]               \
-        bwidget_workarounds [::msgcat::mc "bwidget workarounds"]   \
-        config              [::msgcat::mc "configuration"]         \
-        dockingtray         [::msgcat::mc "kde"]                   \
-        hooks               [::msgcat::mc "extension management"]  \
-        jabberlib           [::msgcat::mc "jabber xml"]            \
-        plugins             [::msgcat::mc "plugin management"]     \
-        sound               [::msgcat::mc "sound"]                 \
-        wmdock              [::msgcat::mc "wmaker"]                \
+        filters              [::msgcat::mc "message filters"]      \
+        privacy              [::msgcat::mc "privacy rules"]        \
+        gpgme                [::msgcat::mc "cryptographics"]       \
+        ifacetk              [::msgcat::mc "user interface"]       \
+	plugins:general      [::msgcat::mc "general plugins"]      \
+	plugins:roster       [::msgcat::mc "roster plugins"]       \
+	plugins:search       [::msgcat::mc "search plugins"]       \
+	plugins:unix         [::msgcat::mc "unix plugins"]         \
+	plugins:windows      [::msgcat::mc "windows plugins"]      \
+	plugins:macintosh    [::msgcat::mc "macintosh plugins"]    \
+        iface                [::msgcat::mc "user interface"]       \
+        autoaway             [::msgcat::mc "auto-away"]            \
+        avatars              [::msgcat::mc "avatars"]              \
+        bwidget_workarounds  [::msgcat::mc "bwidget workarounds"]  \
+        config               [::msgcat::mc "configuration"]        \
+        dockingtray          [::msgcat::mc "kde"]                  \
+        hooks                [::msgcat::mc "extension management"] \
+        tclxmpp              [::msgcat::mc "xmpp library"]         \
+        plugins              [::msgcat::mc "plugin management"]    \
+        sound                [::msgcat::mc "sound"]                \
+        wmdock               [::msgcat::mc "wmaker"]               \
     ]
 
     wm withdraw .

Modified: trunk/tkabber/tkabber.tcl
===================================================================
--- trunk/tkabber/tkabber.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/tkabber.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -51,7 +51,7 @@
     set rootdir [file join $::starkit::topdir $rootdir]
 }
 
-lappend auto_path $rootdir
+lappend auto_path [file join $rootdir tclxmpp]
 
 package require msgcat
 if {[info exists ::env(LC_MESSAGES)]} {
@@ -162,16 +162,16 @@
 ::trans::load [file join $rootdir trans]
 ::msgcat::mcload [file join $rootdir msgs]
 foreach pr [::msgcat::mcpreferences] {
-    set f [file join $rootdir msgs "$pr.rc"]
+    set f [file join $::BWIDGET::LIBRARY lang $pr.rc]
     if {[file exists $f]} {
-	option read $f
+	option readfile $f
 	break
     }
 }
 foreach pr [::msgcat::mcpreferences] {
-    set f [file join $::BWIDGET::LIBRARY "lang" "$pr.rc"]
+    set f [file join $rootdir msgs $pr.rc]
     if {[file exists $f]} {
-	option read $f
+	option readfile $f
 	break
     }
 }
@@ -181,21 +181,23 @@
     load_source Tclx.tcl
 }
 
-package require jabberlib 0.10.1
+package require xmpp
+package require xmpp::delay
+
 load_source xmppmime.tcl
 
 foreach {opt val} $argv {
     switch -- $opt {
-	-mime {set mime_file $val}
-	-user {set loginconf(user) $val}
-	-password {set loginconf(password) $val}
-	-resource {set loginconf(resource) $val}
-	-port {set loginconf(port) $val}
-	-autologin {set autologin $val}
-	-chat {xmppmime::send_event [list chat $val]}
-	-message {xmppmime::send_event [list message $val]}
+	-mime       {set mime_file $val}
+	-user       {set loginconf(user) $val}
+	-password   {set loginconf(password) $val}
+	-resource   {set loginconf(resource) $val}
+	-port       {set loginconf(port) $val}
+	-autologin  {set autologin $val}
+	-chat       {xmppmime::send_event [list chat $val]}
+	-message    {xmppmime::send_event [list message $val]}
 	-conference {xmppmime::send_event [list groupchat $val]}
-	-splash {set show_splash_window $val}
+	-splash     {set show_splash_window $val}
     }
 }
 
@@ -221,6 +223,8 @@
 The IMG package is available at http://www.xs4all.nl/~nijtmans/img.html"
 }
 
+load_source idna.tcl
+load_source namespaces.tcl
 load_source ifacetk idefault.tcl
 load_source custom.tcl
 load_source utils.tcl
@@ -262,10 +266,11 @@
 plugins::load [file join plugins richtext]
 plugins::load [file join plugins pep]
 plugins::load [file join plugins $tcl_platform(platform)]
-if {[info exists env(TKABBER_SITE_PLUGINS)] && \
-	[file isdirectory $env(TKABBER_SITE_PLUGINS)]} {
-    plugins::load_dir  $env(TKABBER_SITE_PLUGINS)
+
+if {[info exists env(TKABBER_SITE_PLUGINS)]} {
+    plugins::load_dir $env(TKABBER_SITE_PLUGINS)
 }
+
 plugins::load_dir [file join $configdir plugins]
 
 hook::run postload_hook

Modified: trunk/tkabber/userinfo.tcl
===================================================================
--- trunk/tkabber/userinfo.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/userinfo.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -2,25 +2,29 @@
 
 
 namespace eval userinfo {
-    custom::defvar show_info_list {} [::msgcat::mc "List of users for userinfo."] \
+    custom::defvar show_info_list {} \
+	    [::msgcat::mc "List of users for userinfo."] \
 	    -group Hidden
 }
 
 proc userinfo::show_info_dialog {} {
     variable show_info_jid
     variable show_info_list
-    variable show_info_connid
+    variable show_info_xlib
 
-    if {[lempty [jlib::connections]]} return
+    if {[lempty [connections]]} return
 
     set gw .userinfo
     catch { destroy $gw }
 
-    set connid [lindex [jlib::connections] 0]
-    set show_info_connid [jlib::connection_jid $connid]
+    set xlib [lindex [connections] 0]
+    set show_info_xlib [connection_jid $xlib]
 
-    Dialog $gw -title [::msgcat::mc "Show user or service info"] -separator 1 -anchor e \
-	    -default 0 -cancel 1
+    Dialog $gw -title [::msgcat::mc "Show user or service info"] \
+	       -separator 1 \
+	       -anchor e \
+	       -default 0 \
+	       -cancel 1
 
     set gf [$gw getframe]
     grid columnconfigure $gf 1 -weight 1
@@ -34,13 +38,13 @@
     grid $gf.ljid -row 0 -column 0 -sticky e
     grid $gf.jid  -row 0 -column 1 -sticky ew
 
-    if {[llength [jlib::connections]] > 1} {
+    if {[llength [connections]] > 1} {
 	set connections {}
-	foreach c [jlib::connections] {
-	    lappend connections [jlib::connection_jid $c]
+	foreach c [connections] {
+	    lappend connections [connection_jid $c]
 	}
 	label $gf.lconnection -text [::msgcat::mc "Connection:"]
-	ComboBox $gf.connection -textvariable [namespace current]::show_info_connid \
+	ComboBox $gf.connection -textvariable [namespace current]::show_info_xlib \
 				-values $connections
 
 	grid $gf.lconnection -row 1 -column 0 -sticky e
@@ -56,21 +60,21 @@
 proc userinfo::show_info {gw} {
     variable show_info_jid
     variable show_info_list
-    variable show_info_connid
+    variable show_info_xlib
 
     destroy $gw
 
-    foreach c [jlib::connections] {
-	if {[jlib::connection_jid $c] == $show_info_connid} {
-	    set connid $c
+    foreach c [connections] {
+	if {[connection_jid $c] == $show_info_xlib} {
+	    set xlib $c
 	}
     }
-    if {![info exists connid]} {
-	set connid [jlib::route $show_info_jid]
+    if {![info exists xlib]} {
+	set xlib [lindex [connections] 0]
     }
 
     set show_info_list [update_combo_list $show_info_list $show_info_jid 10]
-    userinfo::open $show_info_jid -connection $connid
+    userinfo::open $xlib $show_info_jid
 }
 
 proc userinfo::w_from_jid {jid} {
@@ -160,11 +164,11 @@
     }
 }
 
-proc userinfo::open_client {jid args} {
-    eval [list open $jid] $args -page client
+proc userinfo::open_client {xlib jid args} {
+    eval [list open $xlib $jid] $args -page client
 }
 
-proc userinfo::open {jid args} {
+proc userinfo::open {xlib jid args} {
     global tcl_platform
     variable userinfo
 
@@ -181,12 +185,11 @@
     foreach {opt val} $args {
 	switch -- $opt {
 	    -editable   {set editable $val}
-	    -connection {set connid $val}
 	    -page {set top_page $val}
 	}
     }
-    if {![info exists connid]} {
-	set connid [jlib::route $jid]
+    if {$xlib == ""} {
+	set xlib [lindex [connections] 0]
     }
 
     toplevel $w -relief $::tk_relief -borderwidth $::tk_borderwidth
@@ -199,7 +202,7 @@
     if {$editable} {
 	set bbox [ButtonBox $w.bbox -spacing 10 -padx 10 -default 0]
 	$bbox add -text [::msgcat::mc "Update"] -command "
-		userinfo::send_vcard [list $connid] [list $jid]
+		userinfo::send_vcard [list $xlib] [list $jid]
 		destroy [list $w]
 	"
 	bind $w <Return>  "ButtonBox::invoke $bbox default"
@@ -403,18 +406,16 @@
 	$a.text configure -state disabled
     }
 
-    hook::run userinfo_hook $tab $connid $jid $editable
+    hook::run userinfo_hook $tab $xlib $jid $editable
 
     set vjid [node_and_server_from_jid $jid]
-    if {[chat::is_groupchat [chat::chatid $connid $vjid]]} {
+    if {[chat::is_groupchat [chat::chatid $xlib $vjid]]} {
 	set vjid $jid
     }
 
-    jlib::send_iq get \
-	[jlib::wrapper:createtag vCard \
-	     -vars [list xmlns vcard-temp]] \
+    ::xmpp::sendIQ $xlib get \
+	-query [::xmpp::xml::create vCard -xmlns vcard-temp] \
 	-to $vjid \
-	-connection $connid \
 	-command [list userinfo::parse_vcard $jid]
 
     $tab compute_size
@@ -447,7 +448,7 @@
 		  -areaheight [max [winfo height $l] [winfo height $sw]]
 }
 
-proc userinfo::client_page {tab connid jid editable} {
+proc userinfo::client_page {tab xlib jid editable} {
     if {$editable} return
 
     set client [$tab insert end client -text [::msgcat::mc "Client"]]
@@ -467,9 +468,9 @@
     pack_entry $jid $o 2 utc  [::msgcat::mc "UTC:"]
 
     # FIX -to ...
-    request_iq version $connid $jid
-    request_iq time $connid $jid
-    request_iq last $connid $jid
+    request_iq version $xlib $jid
+    request_iq time $xlib $jid
+    request_iq last $xlib $jid
 }
 
 hook::add userinfo_hook [namespace current]::userinfo::client_page
@@ -551,29 +552,26 @@
 }
 
 
-proc userinfo::parse_vcard {jid res child} {
-    debugmsg userinfo "$res $child"
+proc userinfo::parse_vcard {jid status xml} {
+    debugmsg userinfo "$status $xml"
 
-    if {![cequal $res OK]} {
+    if {![string equal $status ok]} {
 	return
     }
-
     
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
+    ::xmpp::xml::split $xml tag xmlns attrs cdata subels
 
-    foreach item $children {
+    foreach item $subels {
 	parse_vcard_item $jid $item
-
-
     }
 }
 
 
-proc userinfo::parse_vcard_item {jid child} {
+proc userinfo::parse_vcard_item {jid xml} {
     variable userinfo
 
     set w [w_from_jid $jid]
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
+    ::xmpp::xml::split $xml tag xmlns attrs cdata subels
 
     # TODO:
     #  VERSION, ---
@@ -597,33 +595,33 @@
     #  KEY?,
 
     switch -- $tag {
-	FN       {set userinfo(fn,$jid)        $chdata}
-	NICKNAME {set userinfo(nickname,$jid)  $chdata}
-	N        {parse_vcard_n_item $jid $children}
-	PHOTO    {parse_vcard_photo_item $jid $children}
-	ADR      {parse_vcard_adr_item $jid $children}
-	TEL      {parse_vcard_tel_item $jid $children}
-	TEL      {set userinfo(telephone,$jid) $chdata}
+	FN       {set userinfo(fn,$jid)        $cdata}
+	NICKNAME {set userinfo(nickname,$jid)  $cdata}
+	N        {parse_vcard_n_item $jid $subels}
+	PHOTO    {parse_vcard_photo_item $jid $subels}
+	ADR      {parse_vcard_adr_item $jid $subels}
+	TEL      {parse_vcard_tel_item $jid $subels}
+	TEL      {set userinfo(telephone,$jid) $cdata}
 	EMAIL    {
-	    set userinfo(email,$jid) $chdata
-	    parse_vcard_email_item $jid $children
+	    set userinfo(email,$jid) $cdata
+	    parse_vcard_email_item $jid $subels
 	}
-	JABBERID {set userinfo(jabberid,$jid)  $chdata}
-	GEO      {parse_vcard_geo_item $jid $children}
-	ORG      {parse_vcard_org_item $jid $children}
-	TITLE    {set userinfo(title,$jid)     $chdata}
-	ROLE     {set userinfo(role,$jid)      $chdata}
+	JABBERID {set userinfo(jabberid,$jid)  $cdata}
+	GEO      {parse_vcard_geo_item $jid $subels}
+	ORG      {parse_vcard_org_item $jid $subels}
+	TITLE    {set userinfo(title,$jid)     $cdata}
+	ROLE     {set userinfo(role,$jid)      $cdata}
 	BDAY     {
-	    set userinfo(bday,$jid)      $chdata
-	    if {![catch {set bday [clock scan $chdata]}]} {
+	    set userinfo(bday,$jid)      $cdata
+	    if {![catch {set bday [clock scan $cdata]}]} {
 		set userinfo(bdayyear,$jid) [clock format $bday -format %Y]
 		set userinfo(bdaymonth,$jid) [clock format $bday -format %m]
 		set userinfo(bdayday,$jid) [clock format $bday -format %d]
 	    }
 	}
-	UID      {set userinfo(uid,$jid)       $chdata}
-	URL      {set userinfo(url,$jid)       $chdata}
-	DESC     {set userinfo(desc,$jid)      $chdata}
+	UID      {set userinfo(uid,$jid)       $cdata}
+	URL      {set userinfo(url,$jid)       $cdata}
+	DESC     {set userinfo(desc,$jid)      $cdata}
 	default {debugmsg userinfo "Unknown vCard tag $tag"}
     }
 }
@@ -632,10 +630,10 @@
     variable userinfo
 
     foreach item $items {
-	jlib::wrapper:splitxml $item tag vars isempty chdata children
+	::xmpp::xml::split $item tag xmlns attrs cdata subels
 
 	switch -- $tag {
-	    USERID {set userinfo(email,$jid) $chdata}
+	    USERID {set userinfo(email,$jid) $cdata}
 	}
     }
 }
@@ -647,14 +645,14 @@
 
 
     foreach item $items {
-	jlib::wrapper:splitxml $item tag vars isempty chdata children
+	::xmpp::xml::split $item tag xmlns attrs cdata subels
 
 	switch -- $tag {
-	    FAMILY {set userinfo(family,$jid) $chdata}
-	    GIVEN  {set userinfo(name,$jid)   $chdata}
-	    MIDDLE {set userinfo(middle,$jid) $chdata}
-	    PREFIX {set userinfo(prefix,$jid) $chdata}
-	    SUFFIX {set userinfo(suffix,$jid) $chdata}
+	    FAMILY {set userinfo(family,$jid) $cdata}
+	    GIVEN  {set userinfo(name,$jid)   $cdata}
+	    MIDDLE {set userinfo(middle,$jid) $cdata}
+	    PREFIX {set userinfo(prefix,$jid) $cdata}
+	    SUFFIX {set userinfo(suffix,$jid) $cdata}
 	    default {debugmsg userinfo "Unknown vCard <N/> subtag $tag"}
 	}
     }
@@ -667,24 +665,24 @@
 
 
     foreach item $items {
-	jlib::wrapper:splitxml $item tag vars isempty chdata children
+	::xmpp::xml::split $item tag xmlns attrs cdata subels
 
 	switch -- $tag {
 	    BINVAL {
 		catch {		
-		    set userinfo(photo_binval,$jid) [base64::decode $chdata]
+		    set userinfo(photo_binval,$jid) [base64::decode $cdata]
 		    set userinfo(photo_use,$jid) image
 		    photo_$jid blank
-		    photo_$jid put $chdata
+		    photo_$jid put $cdata
 		    catch { reconfigure_photo $jid }
 		}
 	    }
 	    EXTVAL {
-		set userinfo(photo_extval,$jid) $chdata
+		set userinfo(photo_extval,$jid) $cdata
 		set userinfo(photo_use,$jid) url
 	    }
 	    TYPE {
-		set userinfo(photo_type,$jid) $chdata
+		set userinfo(photo_type,$jid) $cdata
 	    }
 	    default {debugmsg userinfo "Unknown vCard <PHOTO/> subtag $tag"}
 	}
@@ -698,7 +696,7 @@
 
 
     foreach item $items {
-	jlib::wrapper:splitxml $item tag vars isempty chdata children
+	::xmpp::xml::split $item tag xmlns attrs cdata subels
 
 	# TODO:
         #  HOME?, 
@@ -711,13 +709,13 @@
         #  LOCALITY?, 
 
 	switch -- $tag {
-	    STREET   {set userinfo(address,$jid)   $chdata}
-	    EXTADD   {set userinfo(address2,$jid) $chdata}
-	    LOCALITY {set userinfo(city,$jid)   $chdata}
-	    REGION   {set userinfo(state,$jid) $chdata}
-	    PCODE    {set userinfo(pcode,$jid)   $chdata}
-	    COUNTRY  {set userinfo(country,$jid) $chdata}
-	    CTRY     {set userinfo(country,$jid) $chdata}
+	    STREET   {set userinfo(address,$jid)  $cdata}
+	    EXTADD   {set userinfo(address2,$jid) $cdata}
+	    LOCALITY {set userinfo(city,$jid)     $cdata}
+	    REGION   {set userinfo(state,$jid)    $cdata}
+	    PCODE    {set userinfo(pcode,$jid)    $cdata}
+	    COUNTRY  {set userinfo(country,$jid)  $cdata}
+	    CTRY     {set userinfo(country,$jid)  $cdata}
 	    default  {debugmsg userinfo "Unknown vCard <ADR/> subtag $tag"}
 	}
     }
@@ -730,7 +728,7 @@
 
     set types {}
     foreach item $items {
-	jlib::wrapper:splitxml $item tag vars isempty chdata children
+	::xmpp::xml::split $item tag xmlns attrs cdata subels
 
 	# TODO:
         #  HOME?, 
@@ -764,7 +762,7 @@
 	    PREF   {lappend types pref}
 	    NUMBER {
 		foreach t $types {
-		    set userinfo(tel_$t,$jid) $chdata
+		    set userinfo(tel_$t,$jid) $cdata
 		}
 	    }
 	    default {debugmsg userinfo "Unknown vCard <TEL/> subtag $tag"}
@@ -779,11 +777,11 @@
 
 
     foreach item $items {
-	jlib::wrapper:splitxml $item tag vars isempty chdata children
+	::xmpp::xml::split $item tag xmlns attrs cdata subels
 
 	switch -- $tag {
-	    LAT {set userinfo(geo_lat,$jid) $chdata}
-	    LON {set userinfo(geo_lon,$jid)  $chdata}
+	    LAT {set userinfo(geo_lat,$jid) $cdata}
+	    LON {set userinfo(geo_lon,$jid) $cdata}
 	    default {debugmsg userinfo "Unknown vCard <ORG/> subtag $tag"}
 	}
     }
@@ -797,114 +795,101 @@
     # TODO: <!ELEMENT ORG (ORGNAME, ORGUNIT*)>
 
     foreach item $items {
-	jlib::wrapper:splitxml $item tag vars isempty chdata children
+	::xmpp::xml::split $item tag xmlns attrs cdata subels
 
 	switch -- $tag {
-	    ORGNAME  {set userinfo(orgname,$jid) $chdata}
-	    ORGUNIT {set userinfo(orgunit,$jid)  $chdata}
+	    ORGNAME {set userinfo(orgname,$jid) $cdata}
+	    ORGUNIT {set userinfo(orgunit,$jid) $cdata}
 	    default {debugmsg userinfo "Unknown vCard <ORG/> subtag $tag"}
 	}
     }
 }
 
 
-proc userinfo::request_iq {kind connid jid} {
-    jlib::send_iq get \
-	[jlib::wrapper:createtag query \
-	     -vars [list xmlns jabber:iq:$kind]] \
-	-to [get_jid_of_user $connid $jid] \
-	-connection $connid \
-	-command [list userinfo::parse_iq$kind $jid]
+proc userinfo::request_iq {type xlib jid} {
+    ::xmpp::sendIQ $xlib get \
+	-query [::xmpp::xml::create query -xmlns jabber:iq:$type] \
+	-to [get_jid_of_user $xlib $jid] \
+	-command [list userinfo::parse_iq$type $jid]
 }
 
-proc userinfo::parse_iqversion {jid res child} {
-    debugmsg userinfo "$res $child"
+proc userinfo::parse_iqversion {jid status xml} {
+    debugmsg userinfo "$status $xml"
 
-    if {![cequal $res OK]} {
+    if {![string equal $status ok]} {
 	return
     }
     
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
+    ::xmpp::xml::split $xml tag xmlns attrs cdata subels
 
-    if {[cequal [jlib::wrapper:getattr $vars xmlns] jabber:iq:version]} {
-	userinfo::parse_iqversion_item $jid $children
+    if {[string equal $xmlns jabber:iq:version]} {
+	userinfo::parse_iqversion_item $jid $subels
     }
 }
 
-
 proc userinfo::parse_iqversion_item {jid items} {
     variable userinfo
 
-    set w [w_from_jid $jid]
-
-
     foreach item $items {
-	jlib::wrapper:splitxml $item tag vars isempty chdata children
+	::xmpp::xml::split $item tag xmlns attrs cdata subels
 
 	switch -- $tag {
-	    name    {set userinfo(clientname,$jid)    $chdata}
-	    version {set userinfo(clientversion,$jid) $chdata}
-	    os      {set userinfo(os,$jid)            $chdata}
+	    name    {set userinfo(clientname,$jid)    $cdata}
+	    version {set userinfo(clientversion,$jid) $cdata}
+	    os      {set userinfo(os,$jid)            $cdata}
 	    default {debugmsg userinfo "Unknown iq:version tag '$tag'"}
 	}
     }
 }
 
+proc userinfo::parse_iqtime {jid status xml} {
+    debugmsg userinfo "$status $xml"
 
-
-proc userinfo::parse_iqtime {jid res child} {
-    debugmsg userinfo "$res $child"
-
-    if {![cequal $res OK]} {
+    if {![string equal $status ok]} {
 	return
     }
 
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
+    ::xmpp::xml::split $xml tag xmlns attrs cdata subels
 
-    if {[cequal [jlib::wrapper:getattr $vars xmlns] jabber:iq:time]} {
-	userinfo::parse_iqtime_item $jid $children
+    if {[string equal $xmlns jabber:iq:time]} {
+	userinfo::parse_iqtime_item $jid $subels
     }
 }
 
-
 proc userinfo::parse_iqtime_item {jid items} {
     variable userinfo
 
-    set w [w_from_jid $jid]
-
     foreach item $items {
-	jlib::wrapper:splitxml $item tag vars isempty chdata children
+	::xmpp::xml::split $item tag xmlns attrs cdata subels
 
 	switch -- $tag {
-	    utc     {set userinfo(utc,$jid) $chdata}
-	    display {set userinfo(time,$jid) $chdata}
-	    tz      {set userinfo(tz,$jid) $chdata}
+	    utc     {set userinfo(utc,$jid)  $cdata}
+	    display {set userinfo(time,$jid) $cdata}
+	    tz      {set userinfo(tz,$jid)   $cdata}
 	    default {debugmsg userinfo "Unknown iq:time tag '$tag'"}
 	}
     }
 }
 
-
-proc userinfo::parse_iqlast {jid res child} {
+proc userinfo::parse_iqlast {jid status xml} {
     variable userinfo
-    debugmsg userinfo "$res $child"
 
-    if {![cequal $res OK]} {
+    debugmsg userinfo "$status $xml"
+
+    if {![string equal $status ok]} {
 	return
     }
 
-    set w [w_from_jid $jid]
-    
-    jlib::wrapper:splitxml $child tag vars isempty chdata children
+    ::xmpp::xml::split $xml tag xmlns attrs cdata subels
 
-    if {[cequal [jlib::wrapper:getattr $vars xmlns] jabber:iq:last]} {
-	set seconds [jlib::wrapper:getattr $vars seconds]
+    if {[string equal $xmlns jabber:iq:last]} {
+	set seconds [::xmpp::xml::getAttr $attrs seconds]
 	if {[string is integer -strict $seconds]} {
 	    set userinfo(lastseconds,$jid) [format_time $seconds]
 	} else {
 	    set userinfo(lastseconds,$jid) ""
 	}
-	set userinfo(lastdesc,$jid) $chdata
+	set userinfo(lastdesc,$jid) $cdata
     }
 }
 
@@ -912,12 +897,13 @@
     upvar $varname tags
 
     if {$chdata != "" || $subtags != {}} {
-	lappend tags [jlib::wrapper:createtag $tag -chdata $chdata \
-			  -subtags $subtags]
+	lappend tags [::xmpp::xml::create $tag \
+				-cdata $chdata \
+				-subelements $subtags]
     }
 }
 
-proc userinfo::send_vcard {connid jid} {
+proc userinfo::send_vcard {xlib jid} {
     variable userinfo
 
     set w [w_from_jid $jid]
@@ -950,11 +936,10 @@
     append_tag tags DESC     [$userinfo(descfield,$jid) get 0.0 "end -1 chars"]
     debugmsg userinfo $tags
 
-    jlib::send_iq set \
-	[jlib::wrapper:createtag vCard \
-	     -vars [list xmlns vcard-temp] \
-	     -subtags $tags] \
-	-connection $connid
+    ::xmpp::sendIQ $xlib set \
+	-query [::xmpp::xml::create vCard \
+			-xmlns vcard-temp \
+			-subelements $tags]
 }
 
 proc userinfo::make_n_item {jid} {
@@ -975,9 +960,9 @@
     set tags {}
     if {$userinfo(email,$jid) != ""} {
 	append_tag tags EMAIL "" \
-	    [list [jlib::wrapper:createtag INTERNET] \
-		  [jlib::wrapper:createtag USERID \
-		       -chdata $userinfo(email,$jid)]]
+	    [list [::xmpp::xml::create INTERNET] \
+		  [::xmpp::xml::create USERID \
+		       -cdata $userinfo(email,$jid)]]
     }
     return $tags
 }
@@ -1022,10 +1007,9 @@
 		   video bbs modem isdn pcs pref} {
 	if {$userinfo(tel_$t,$jid) != ""} {
 	    append_tag tags TEL "" \
-		[list \
-		     [jlib::wrapper:createtag [string toupper $t]] \
-		     [jlib::wrapper:createtag NUMBER \
-			  -chdata $userinfo(tel_$t,$jid)]]
+		[list [::xmpp::xml::create [string toupper $t]] \
+		      [::xmpp::xml::create NUMBER \
+				    -cdata $userinfo(tel_$t,$jid)]]
 	}
     }
     return $tags
@@ -1049,9 +1033,9 @@
     return $tags
 }
 
-proc userinfo::add_menu_item {m connid jid} {
+proc userinfo::add_menu_item {m xlib jid} {
     $m add command -label [::msgcat::mc "Show info"] \
-           -command [list userinfo::open $jid -connection $connid]
+		   -command [list userinfo::open $xlib $jid]
 }
 
 hook::add chat_create_user_menu_hook userinfo::add_menu_item 60

Modified: trunk/tkabber/utils.tcl
===================================================================
--- trunk/tkabber/utils.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/utils.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -57,13 +57,13 @@
 # my_jid - returns JID for inclusion in queries. If the recipient
 # is from some conference room then JID is a room JID.
 
-proc my_jid {connid recipient} {
+proc my_jid {xlib recipient} {
     set bare_recipient [node_and_server_from_jid $recipient]
-    set chatid [chat::chatid $connid $bare_recipient]
+    set chatid [chat::chatid $xlib $bare_recipient]
     if {[chat::is_groupchat $chatid]} {
 	set myjid [chat::our_jid $chatid]
     } else {
-	set myjid [jlib::connection_jid $connid]
+	set myjid [connection_jid $xlib]
     }
 }
 
@@ -118,11 +118,12 @@
 }
 
 proc error_type_condition {errmsg} {
-    return [lrange [stanzaerror::error_to_list $errmsg] 0 1]
+    return [list [::xmpp::stanzaerror::type $errmsg] \
+		 [::xmpp::stanzaerror::condition $errmsg]]
 }
 
 proc error_to_string {errmsg} {
-    return [lindex [stanzaerror::error_to_list $errmsg] 2]
+    return [::xmpp::stanzaerror::message $errmsg]
 }
 
 proc get_group_nick {jid fallback} {

Modified: trunk/tkabber/xmppmime.tcl
===================================================================
--- trunk/tkabber/xmppmime.tcl	2008-10-17 15:26:11 UTC (rev 1519)
+++ trunk/tkabber/xmppmime.tcl	2008-10-17 17:16:09 UTC (rev 1520)
@@ -3,7 +3,7 @@
 # Support for XMPP/Jabber MIME Type (XEP-0081)
 #
 
-namespace eval xmppmime {
+namespace eval ::xmppmime {
     set used 0
     set handle 0
     set loaded 0
@@ -11,24 +11,22 @@
     set queue {}
 }
 
-package require jabberlib 0.8.4
+package require xmpp
 
-proc xmppmime::load {path} {
+proc ::xmppmime::load {path} {
     # TODO: catch file errors
     set f [open $path]
     set content [read $f]
     close $f
 
-    set parser [jlib::wrapper:new "#" "#" xmppmime::parse]
-    jlib::wrapper:parser $parser parse $content
-    jlib::wrapper:parser $parser configure -final 0
-    jlib::wrapper:free $parser
+    ::xmpp::xml::parseData $content ::xmppmime::parse
 }
 
-proc xmppmime::parse {xmldata} {
-    jlib::wrapper:splitxml $xmldata tag vars isempty chdata children
-    set jid [jlib::wrapper:getattr $vars jid]
+proc ::xmppmime::parse {xmldata} {
+    ::xmpp::xml::split $xmldata tag xmlns attrs cdata subels
 
+    set jid [::xmpp::xml::getAttr $attrs jid]
+
     switch -- $tag {
 	message {
 	    send_event [list message $jid]
@@ -60,7 +58,7 @@
     }
 }
 
-proc xmppmime::send_event {event} {
+proc ::xmppmime::send_event {event} {
     variable handle
     variable used
 
@@ -75,14 +73,14 @@
     if {$handle} {
 	recv_event $event
     } else {
-	if {[catch {send tkabber [list xmppmime::recv_event $event]}]} {
+	if {[catch {send tkabber [list ::xmppmime::recv_event $event]}]} {
 	    set handle 1
 	    recv_event $event
 	}
     }
 }
 
-proc xmppmime::recv_event {event} {
+proc ::xmppmime::recv_event {event} {
     variable queue
     variable loaded
 
@@ -93,18 +91,20 @@
     }
 }
 
-proc xmppmime::process_event {event} {
+proc ::xmppmime::process_event {event} {
     variable queue
     variable connected
     set rest [lassign $event type jid]
 
+    set xlib [lindex [connections] 0]
+
     switch -- $type {
 	message {
 	    message::send_dialog -to $jid
 	}
 
 	chat {
-	    chat::open_window [chat::chatid [jlib::route $jid] $jid] chat
+	    chat::open_window [chat::chatid $xlib $jid] chat
 	}
 
 	groupchat {
@@ -121,7 +121,7 @@
 
 	vcard {
 	    if {$connected} {
-		userinfo::open $jid
+		userinfo::open $xlib $jid
 	    } else {
 		lappend queue $event
 	    }
@@ -129,7 +129,7 @@
 
 	register {
 	    if {$connected} {
-		register::open $jid
+		register::open $xlib $jid
 	    } else {
 		lappend queue $event
 	    }
@@ -145,14 +145,13 @@
     }
 }
 
-
-proc xmppmime::is_done {} {
+proc ::xmppmime::is_done {} {
     variable handle
     variable used
     return [expr {$used && !$handle}]
 }
 
-proc xmppmime::process_queue {} {
+proc ::xmppmime::process_queue {} {
     variable queue
     variable loaded
 
@@ -164,21 +163,20 @@
     }
 }
 
-hook::add finload_hook xmppmime::process_queue
+hook::add finload_hook ::xmppmime::process_queue
 
-proc xmppmime::connected {connid} {
+proc ::xmppmime::connected {connid} {
     variable connected
     set connected 1
     process_queue
 }
 
-hook::add connected_hook xmppmime::connected
+hook::add connected_hook ::xmppmime::connected
 
-proc xmppmime::disconnected {connid} {
+proc ::xmppmime::disconnected {connid} {
     variable connected
-    set connected [expr {[jlib::connections] != {}}]
+    set connected [expr {[connections] != {}}]
 }
 
-hook::add disconnected_hook xmppmime::disconnected
+hook::add disconnected_hook ::xmppmime::disconnected
 
-



More information about the Tkabber-dev mailing list