1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
|
# private.tcl --
#
# This file is part of the jabberlib.
# It handles private XML storage/retrieval, as described in XEP-0049
#
# Copyright (c) 2009 Sebastian Reitenbach
#
# This file is distributed under BSD style license.
#
# $Id$
#
############################# USAGE ############################################
#
# NAME
# private - convenience command library for the private XML
# storage extension.
#
# SYNOPSIS
# jlib::private::init jlibName ?-opt value ...?
#
# INSTANCE COMMANDS
# jlibname private send_get subtags callbackProc
# jlibname private send_set subtags
#
################################################################################
package require jlib
package provide jlib::private 0.1
namespace eval jlib::private {
# Note: jlib::ensamble_register is last in this file!
}
# jlib::private::init --
#
# Creates a new instance of a private object.
#
# Arguments:
# jlibname: name of existing jabberlib instance
# args:
#
# Results:
# namespaced instance command
proc jlib::private::init {jlibname args} {
variable xmlns
set xmlns(private) "jabber:iq:private"
return
}
# jlib::private::cmdproc --
#
# Just dispatches the command to the right procedure.
#
# Arguments:
# jlibname: name of existing jabberlib instance
# cmd:
# args: all args to the cmd procedure.
#
# Results:
# none.
proc jlib::private::cmdproc {jlibname cmd args} {
# Which command? Just dispatch the command to the right procedure.
return [eval {$cmd $jlibname} $args]
}
# jlib::private::send_get --
#
# It implements the 'jabber:iq:private' get method.
#
# Arguments:
# subtags: list of elements to retrieve
# cmd: client command to be executed at the iq "result" element.
#
# Results:
# none.
proc jlib::private::send_get {subtags cmd} {
variable xmlns
set attrlist [list xmlns $xmlns(private)]
set xmllist [wrapper::createtag "query" -attrlist $attrlist \
-subtags [list $subtags]]
jlib::send_iq ::jlib::jlib1 "get" [list $xmllist] -command $cmd
return
}
# jlib::private::send_set --
#
# It implements the 'jabber:iq:private' set method.
#
# Arguments:
# subtags: list of elements to store
#
# Results:
# none.
proc jlib::private::send_set {subtags} {
variable xmlns
set attrlist [list xmlns $xmlns(private)]
set xmllist [wrapper::createtag "query" -attrlist $attrlist \
-subtags [list $subtags]]
jlib::send_iq ::jlib::jlib1 "set" [list $xmllist]
return
}
# We have to do it here since need the initProc before doing this.
namespace eval jlib::private {
jlib::ensamble_register private \
[namespace current]::init \
[namespace current]::cmdproc
}
|