?? x6079.htm
字號:
<HTML
><HEAD
><TITLE
>The X Namespaces</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.64
"><LINK
REL="HOME"
TITLE="Programming Jabber"
HREF="book1.htm"><LINK
REL="UP"
TITLE="Jabber Namespaces"
HREF="c5281.htm"><LINK
REL="PREVIOUS"
TITLE="The IQ Namespaces"
HREF="x5334.htm"><LINK
REL="NEXT"
TITLE="The X::IQ relationship"
HREF="x6299.htm"></HEAD
><BODY
CLASS="SECT1"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>Programming Jabber</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="x5334.htm"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Chapter 5a. Jabber Namespaces</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="x6299.htm"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="JABTDG-CH-5A-SECT-3"
>The X Namespaces</A
></H1
><P
>While the IQ namespaces are used in exchanging structured information
in semi-formalized conversations, the X namespaces are more ad-hoc
extensions that add value, context, and information to any type of
packet.</P
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="JABTDG-CH-5A-SECT-3.1"
><TT
CLASS="LITERAL"
>jabber:x:autoupdate</TT
></A
></H2
><P
>The <TT
CLASS="LITERAL"
>jabber:x:autoupdate</TT
> namespace is used to carry
information
on where new version information can be found. Details and an example of
this namespace's usage can be found in the description for the IQ
version; <TT
CLASS="LITERAL"
>jabber:iq:autoupdate</TT
> in
<A
HREF="x5334.htm#JABTDG-CH-5A-SECT-2.4"
>the section called <I
><TT
CLASS="LITERAL"
>jabber:iq:autoupdate</TT
></I
></A
>.</P
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="JABTDG-CH-5A-SECT-3.2"
><TT
CLASS="LITERAL"
>jabber:x:conference</TT
></A
></H2
><P
>Just as <TT
CLASS="LITERAL"
>jabber:x:autoupdate</TT
> is related to its big
brother <TT
CLASS="LITERAL"
>jabber:iq:autoupdate</TT
>, so too is the
<TT
CLASS="LITERAL"
>jabber:x:conference</TT
> namespace related to
<TT
CLASS="LITERAL"
>jabber:iq:conference</TT
>. The <TT
CLASS="LITERAL"
><x/></TT
>
version of the IQ conference namespace is used to convey information
about a conferencing room, usually attached to a message:</P
><P
><PRE
CLASS="SCREEN"
>SEND: <message id='2113' to='robert@company-a.com'>
<subject>Design Meeting</subject>
<body>Robert - you're supposed to be at the meeting now!</body>
<x xmlns='jabber:x:conference' jid='meeting1@meetings.company-a.com'/>
</message> </PRE
></P
><P
>If supported by
the receiving client, this will be interpreted as an invitation to the room
and the procedure for joining the room (in this case identified with the JID
<TT
CLASS="LITERAL"
>meeting1@conf.company-a.com</TT
>) can be automatically
initiated:</P
><P
><PRE
CLASS="SCREEN"
>SEND: <iq type='get' id='c4' to='meeting1@meetings.company-a.com'>
<query xmlns='jabber:iq:conference'/>
</iq></PRE
></P
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="JABTDG-CH-5A-SECT-3.3"
><TT
CLASS="LITERAL"
>jabber:x:delay</TT
></A
></H2
><P
>Packets—those conveying messages and presence—are sometimes sent to
entities that aren't available at that particular
moment. If they are stored offline, they are timestamped, in the
<TT
CLASS="LITERAL"
>jabber:x:delay</TT
> namespace, so that when they are
finally received, the recipient can use this information to determine when
the packets were originally sent.</P
><P
><PRE
CLASS="SCREEN"
>RECV: <message to='sabine@yak/Work' from='yak'>
<subject>Weekend at last!</subject>
<body>Don't forget Father's Day on Sunday!</body>
<x xmlns='jabber:x:delay' from='yak/announce/motd'
stamp='20010615T09:00:01'>Announced</x>
</message></PRE
></P
><P
>In this Message Of The Day (MOTD) announcement, we see that as well as
the <TT
CLASS="LITERAL"
>stamp</TT
> attribute showing that the announcement
was sent out on the Friday morning before Father's Day, a short
text description <I
CLASS="EMPHASIS"
>Announced</I
> is included.</P
><P
>The namespace is also used by the <TT
CLASS="LITERAL"
>xdb</TT
> component to
timestamp various fragments of data. Here, we see that Sabine updated
her user registration (using a <TT
CLASS="LITERAL"
>jabber:iq:register</TT
>
query during her session) at the beginning of March.</P
><P
><PRE
CLASS="SCREEN"
><query xmlns='jabber:iq:register' xdbns='jabber:iq:register'>
<name>S. Reitz-Adams</name>
<email>sabine@reitz-adams.org</email>
<x xmlns='jabber:x:delay' stamp='20010302T12:15:42'>updated</x>
</query></PRE
></P
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="JABTDG-CH-5A-SECT-3.4"
><TT
CLASS="LITERAL"
>jabber:x:encrypted</TT
></A
></H2
><P
>The relatively new <TT
CLASS="LITERAL"
>jabber:x:encrypted</TT
> namespace can be
used to
implement message-level security. It allows for the attachment of
encrypted data Public Key Infrastructure (PKI) techniques, meaning
that the data is encrypted using the message sender's private key,
and decrypted by the recipient using the sender's public key.</P
><P
><PRE
CLASS="SCREEN"
>SEND: <message to='john@company-a.com' id='m221'>
<subject>Top Secret!</subject>
<x xmlns='jabber:x:encrypted'>
hQEOA7ucqu53AhlPEAP/ZbU6oPnRAbIcUxMK1XRVnkgZ/Agtq1tcTQuEZxbpZLl4
lkKJlkjkJjghyri(*8ygHbkjaja09Ja09sajkls8aj1h0J/a=ajhsa9A1ska191l
</x>
</message></PRE
></P
><P
>The Jabber server itself does not currently provide any mechanisms
for key management or exchange; the namespace is for the time being
purely a marked container to hold encrypted data.</P
><P
>There are no components in the Jabber server that can encrypt or
decrypt using PKI tools (such as PGP or GPG); this namespace can
be seen as enabling <I
CLASS="EMPHASIS"
>pure</I
> P2P-encrypted communication in an Out Of Band (OOB) style, in the same way that the <TT
CLASS="LITERAL"
>jabber:iq:oob</TT
>
namespace enables P2P file exchange.</P
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="JABTDG-CH-5A-SECT-3.5"
><TT
CLASS="LITERAL"
>jabber:x:envelope</TT
></A
></H2
><P
>The <TT
CLASS="LITERAL"
>jabber:x:envelope</TT
> namespace is used to describe
more complex message addressing details than the simple
<TT
CLASS="LITERAL"
>from</TT
> and <TT
CLASS="LITERAL"
>to</TT
> attributes in the
<TT
CLASS="LITERAL"
><message/></TT
> packets.</P
><P
>The first area where this namespace is used is in server-side filtering,
a service provided by the JSM's <TT
CLASS="LITERAL"
>mod_filter</TT
> module. For example, when a user sets a filter rule to forward all messages to someone else
while he's not around:
<A
NAME="AEN6140"
HREF="#FTN.AEN6140"
>[1]</A
> </P
><P
><PRE
CLASS="SCREEN"
><rule name="absent">
<show>xa</show>
<forward>john@company-b.com</forward>
</rule></PRE
></P
><P
>a message such as this:</P
><P
><PRE
CLASS="SCREEN"
><message id='284' to='janet@company-b.com'>
<body>Can you give me the sales figures for last quarter?</body>
</message></PRE
></P
><P
>will be passed on to <TT
CLASS="LITERAL"
>john@company-b.com</TT
> in
this form:</P
><P
><PRE
CLASS="SCREEN"
><message id='284' to='janet@company-b.com'>
<body>Can you give me the sales figures for last quarter?</body>
<TT
CLASS="USERINPUT"
><B
><x xmlns='jabber:x:envelope'>
<forwardedby jid='janet@company-b.com'>
<from jid='mark@company-b.com'>
<cc jid='john@company-b.com'>
</x></B
></TT
>
</message></PRE
></P
><P
>to add context information on where the message has come from.</P
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="JABTDG-CH-5A-SECT-3.6"
><TT
CLASS="LITERAL"
>jabber:x:event</TT
></A
></H2
><P
>Message <I
CLASS="EMPHASIS"
>events</I
> allow clients and servers alike to add information
about the receipt and handling of messages at various stages of
delivery. There are currently four types of events supported in
this namespace:</P
><P
></P
><DIV
CLASS="VARIABLELIST"
><DL
><DT
>Composing</DT
><DD
><P
>The composing event, represented by the
<TT
CLASS="LITERAL"
><composing/></TT
> tag within the
<TT
CLASS="LITERAL"
><x/></TT
> extension qualified by the
<TT
CLASS="LITERAL"
>jabber:x:event</TT
> namespace, can be set by clients
and signifies that the user is composing a reply to the message
just sent.</P
></DD
><DT
>Delivered</DT
><DD
><P
>When a message is received by a client, it can set the
<TT
CLASS="LITERAL"
><delivered/></TT
> flag to signify that
the message has been received.</P
></DD
><DT
>Displayed</DT
><DD
><P
>The displayed event is used to indicate that the message sent
has been displayed to the user. This event is set, using the
<TT
CLASS="LITERAL"
><displayed/></TT
> tag, by clients.</P
></DD
><DT
>Offline</DT
><DD
><P
>When a message recipient is not connected, the JSM module
<TT
CLASS="LITERAL"
>mod_offline</TT
> will store the message and send it
to the recipient when he is next available. This offline storage
event can be set by the server, using the
<TT
CLASS="LITERAL"
><offline/></TT
> tag, to notify the sender
that the message has been stored offline.</P
></DD
></DL
></DIV
><P
>The
<TT
CLASS="LITERAL"
><composing/></TT
>,
<TT
CLASS="LITERAL"
><delivered/></TT
> and
<TT
CLASS="LITERAL"
><displayed/></TT
> events are client events
and are only appropriate to be set by the client. The
<TT
CLASS="LITERAL"
><composing/></TT
> event is a server event and
only appropriate to be set by the server.
In all cases, the events are only set if the message originator requests
that they are. Adding a <TT
CLASS="LITERAL"
>jabber:x:event</TT
> extension
to a message like this:</P
><P
><PRE
CLASS="SCREEN"
>SEND: <message to='sabine@yak' id='M31'>
<subject>Where are you?</subject>
<body>Let me know when you get back</body>
<x xmlns='jabber:x:event'>
<displayed/>
<offline/>
</x>
</message></PRE
></P
><P
>is the way to request that we get notified:</P
><P
></P
><UL
><LI
><P
>If and when the message is stored offline by the server in the eventuality that <TT
CLASS="LITERAL"
>sabine</TT
> is not connected.</P
></LI
><LI
><P
>When the message is eventually displayed to Sabine.</P
></LI
></UL
><P
>The former event will be set by the server, the latter by Sabine's client.</P
><P
><I
CLASS="EMPHASIS"
>Setting</I
> an event is similar to requesting one, and
uses the <TT
CLASS="LITERAL"
>jabber:x:event</TT
> namespace. Here is what we
would receive if the server did store our message to Sabine offline:</P
><P
><PRE
CLASS="SCREEN"
>RECV: <message to='dj@yak/Work' id='M31' from='sabine@yak'>
<x xmlns='jabber:x:event'>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -