change user password under-XMPP (server OpenFire) framework

Source: Internet
Author: User

1. First modify the password in Protocol 0077 to modify the XML

{

/*

<iq type= ' Set ' to= ' Shakespeare.lit ' id= ' Change1 ' >

<query xmlns= ' Jabber:iq:register ' >

<username>bill</username>

<password>newpass</password>

</query>

</iq>

*/

Nsxmlelement *iq = [nsxmlelementelementwithname:@ "IQ"];

[IQ addattributewithname:@ "type"stringvalue:@ "set"];

[IQ addattributewithname:@ "to"stringvalue:@ "Ubuntu-dev"];

[IQ addattributewithname:@ "id"stringvalue:chang_pwd_id]; #define CHANG_PWD_ID @"Change1" to make sure the ID is unique.

nsxmlelement *queryelement = [nsxmlelementelementwithname:@ "Query"xmlns:@ "Jabber:iq: Register "];

[IQ addchild:queryelement];

nsstring *usernamestr = [[nsuserdefaultsstandarduserdefaults]objectforkey:@ "UserName" ];

nsxmlelement *username = [nsxmlelementelementwithname:@ "username"];

[username setstringvalue:usernamestr];

nsxmlelement *password = [nsxmlelementelementwithname:@ "password"];

NSLog(@ "self.tfnewpwdsure.text_______:%@",self. Tfnewpwdsure. Text);

[Password setstringvalue: Self. Tfnewpwdsure. text];

[Queryelement addchild:username];

[Queryelement Addchild:password];

NSLog (@ "iq__%@", iq.description);//print the XML stream check to see if the stitching is correct

[[Xmppserviceshareinstance]. Xmppstreamsendelement: iq];//Send {Xmppstream is encapsulated in a singleton xmppservice}

[[Xmppserviceshareinstance]. Xmppstreamadddelegate:selfdelegatequeue:dispatch_get_main_queue()];//set up proxy

}

#pragma make-xmppstream

-(BOOL) Xmppstream: (xmppstream *) sender Didreceiveiq: (Xmppiq *) iq{

NSLog (@ "__%@", IQ. description);

/*

<iq xmlns= "jabber:client" type= "result" id= "Change1" from= "Ubuntu-dev" to= "[Email PROTECTED]/870EFDCD" ></iq >

*/

nsstring *iqtypepwd = [[IQ Attributeforname:@ ' type ']stringvalue];

nsstring *iqidpwd = [[Iqattributeforname:@ ' id ']stringvalue];

NSLog(@ "iqtypepwd:%@___iqtypepwd:%@", iqtypepwd,iqidpwd);

if ([Iqtypepwd isequaltostring:@ "Result"]&&[iqidpwdisequaltostring:chang_pwd_id]) {// The password modification succeeds only if the type= "result" id= "change1" is determined

NSLog(@ "OpenFire password modified successfully!") );

}

return YES;

}

Personal Summary: The XMPP framework is not omnipotent, but the XML stream is omnipotent, and when XMPP doesn't meet your needs, it can be easily done with XML!

Original: http://blog.csdn.net/shang1219178163/article/details/22207283

change user password under-XMPP (server OpenFire) framework

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.