root / trunk / web / dojo / dojox / xmpp / UserService.js
History | View | Annotate | Download (2.61 KB)
1 | 9 | andrej.cim | /*
|
---|---|---|---|
2 | Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
|
||
3 | Available via Academic Free License >= 2.1 OR the modified BSD license.
|
||
4 | see: http://dojotoolkit.org/license for details
|
||
5 | */
|
||
6 | |||
7 | |||
8 | if(!dojo._hasResource["dojox.xmpp.UserService"]){ |
||
9 | dojo._hasResource["dojox.xmpp.UserService"]=true; |
||
10 | dojo.provide("dojox.xmpp.UserService");
|
||
11 | dojo.declare("dojox.xmpp.UserService",null,{constructor:function(_1){ |
||
12 | this.session=_1;
|
||
13 | },getPersonalProfile:function(){ |
||
14 | var _2={id:this.session.getNextIqId(),type:"get"}; |
||
15 | var _3=new dojox.string.Builder(dojox.xmpp.util.createElement("iq",_2,false)); |
||
16 | _3.append(dojox.xmpp.util.createElement("query",{xmlns:"jabber:iq:private"},false)); |
||
17 | _3.append(dojox.xmpp.util.createElement("sunmsgr",{xmlsns:"sun:xmpp:properties"},true)); |
||
18 | _3.append("</query></iq>");
|
||
19 | var _4=this.session.dispatchPacket(_3.toString(),"iq",_2.id); |
||
20 | _4.addCallback(this,"_onGetPersonalProfile"); |
||
21 | },setPersonalProfile:function(_5){ |
||
22 | var _6={id:this.session.getNextIqId(),type:"set"}; |
||
23 | var _7=new dojox.string.Builder(dojox.xmpp.util.createElement("iq",_6,false)); |
||
24 | _7.append(dojox.xmpp.util.createElement("query",{xmlns:"jabber:iq:private"},false)); |
||
25 | _7.append(dojox.xmpp.util.createElement("sunmsgr",{xmlsns:"sun:xmpp:properties"},false)); |
||
26 | for(var _8 in _5){ |
||
27 | _7.append(dojox.xmpp.util.createElement("property",{name:_8},false)); |
||
28 | _7.append(dojox.xmpp.util.createElement("value",{},false)); |
||
29 | _7.append(_5[_8]); |
||
30 | _7.append("</value></props>");
|
||
31 | } |
||
32 | _7.append("</sunmsgr></query></iq>");
|
||
33 | var _9=this.session.dispatchPacket(_7.toString(),"iq",_6.id); |
||
34 | _9.addCallback(this,"_onSetPersonalProfile"); |
||
35 | },_onSetPersonalProfile:function(_a){ |
||
36 | if(_a.getAttribute("type")=="result"){ |
||
37 | this.onSetPersonalProfile(_a.getAttribute("id")); |
||
38 | }else{
|
||
39 | if(_a.getAttribute("type")=="error"){ |
||
40 | var _b=this.session.processXmppError(_a); |
||
41 | this.onSetPersonalProfileFailure(_b);
|
||
42 | } |
||
43 | } |
||
44 | },onSetPersonalProfile:function(id){ |
||
45 | },onSetPersonalProfileFailure:function(_c){ |
||
46 | },_onGetPersonalProfile:function(_d){ |
||
47 | if(_d.getAttribute("type")=="result"){ |
||
48 | var _e={};
|
||
49 | if(_d.hasChildNodes()){
|
||
50 | var _f=_d.firstChild;
|
||
51 | if((_f.nodeName=="query")&&(_f.getAttribute("xmlns")=="jabber:iq:private")){ |
||
52 | var _10=_f.firstChild;
|
||
53 | if((_10.nodeName=="query")&&(_10.getAttributes("xmlns")=="sun:xmpp:properties")){ |
||
54 | for(var i=0;i<_10.childNodes.length;i++){ |
||
55 | var n=_10.childNodes[i];
|
||
56 | if(n.nodeName=="property"){ |
||
57 | var _11=n.getAttribute("name"); |
||
58 | var val=n.firstChild||""; |
||
59 | _e[_11]=val; |
||
60 | } |
||
61 | } |
||
62 | } |
||
63 | } |
||
64 | this.onGetPersonalProfile(_e);
|
||
65 | } |
||
66 | }else{
|
||
67 | if(_d.getAttribute("type")=="error"){ |
||
68 | var err=this.session.processXmppError(_d); |
||
69 | this.onGetPersonalProfileFailure(err);
|
||
70 | } |
||
71 | } |
||
72 | return _d;
|
||
73 | },onGetPersonalProfile:function(_12){ |
||
74 | },onGetPersonalProfileFailure:function(err){ |
||
75 | }}); |
||
76 | } |