本文整理汇总了Java中org.jivesoftware.smack.packet.Registration.addAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java Registration.addAttribute方法的具体用法?Java Registration.addAttribute怎么用?Java Registration.addAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jivesoftware.smack.packet.Registration
的用法示例。
在下文中一共展示了Registration.addAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: regist
import org.jivesoftware.smack.packet.Registration; //导入方法依赖的package包/类
/**
* 注册用户
* @param xmppConnection
* @param userName
* @param password
* @return 1、注册成功 0、服务器没有返回结果2、这个账号已经存在3、注册失败
*/
public static int regist(XMPPConnection xmppConnection, String userName, String password) {
Registration registration = new Registration();
registration.setType(IQ.Type.SET);
registration.setTo(xmppConnection.getServiceName());
registration.setUsername(userName);
registration.setPassword(password);
// 这边addAttribute不能为空,否则出错。所以做个标志是android手机创建的吧!!!!!
registration.addAttribute("android", "fhr");
PacketFilter filter = new AndFilter(new PacketIDFilter(registration.getPacketID()), new PacketTypeFilter(IQ.class));
PacketCollector collector = xmppConnection.createPacketCollector(filter);
xmppConnection.sendPacket(registration);
IQ result = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
// Stop queuing results停止请求results(是否成功的结果)
collector.cancel();
if (result == null) {
Log.e("regist", "No response from server.");
return 0;
} else if (result.getType() == IQ.Type.RESULT) {
Log.v("regist", "regist success.");
return 1;
} else {
if (result.getError().toString().equalsIgnoreCase("conflict(409)")) {
Log.e("regist", "IQ.Type.ERROR: " + result.getError().toString());
return 2;
} else {
Log.e("regist", "IQ.Type.ERROR: " + result.getError().toString());
return 3;
}
}
}
示例2: register
import org.jivesoftware.smack.packet.Registration; //导入方法依赖的package包/类
/**
* 注册
*
* @param account
* 注册帐号
* @param password
* 注册密码
* @return 1、注册成功 0、服务器没有返回结果2、这个账号已经存在3、注册失败
*/
public static int register(XMPPConnection mXMPPConnection,String account, String password) {
Registration reg = new Registration();
reg.setType(IQ.Type.SET);
reg.setTo(mXMPPConnection.getServiceName());
// 注意这里createAccount注册时,参数是UserName,不是jid,是"@"前面的部分。
reg.setUsername(account);
reg.setPassword(password);
// 这边addAttribute不能为空,否则出错。所以做个标志是android手机创建的吧!!!!!
reg.addAttribute("android", "geolo_createUser_android");
PacketFilter filter = new AndFilter(new PacketIDFilter(reg.getPacketID()), new PacketTypeFilter(IQ.class));
PacketCollector collector =mXMPPConnection.createPacketCollector(filter);
mXMPPConnection.sendPacket(reg);
IQ result = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
// Stop queuing results停止请求results(是否成功的结果)
collector.cancel();
if (result == null) {
return 0;
} else if (result.getType() == IQ.Type.RESULT) {
return 1;
} else {
if (result.getError().toString().equalsIgnoreCase("conflict(409)")) {
return 2;
} else {
return 3;
}
}
}
示例3: createAccount
import org.jivesoftware.smack.packet.Registration; //导入方法依赖的package包/类
/**
* Creates a new account using the specified username, password and account attributes.
* The attributes Map must contain only String name/value pairs and must also have values
* for all required attributes.
*
* @param username the username.
* @param password the password.
* @param attributes the account attributes.
* @throws XMPPException if an error occurs creating the account.
* @see #getAccountAttributes()
*/
public void createAccount(String username, String password, Map<String, String> attributes)
throws XMPPException
{
if (!supportsAccountCreation()) {
throw new XMPPException("Server does not support account creation.");
}
Registration reg = new Registration();
reg.setType(IQ.Type.SET);
reg.setTo(connection.getServiceName());
reg.setUsername(username);
reg.setPassword(password);
for(String s : attributes.keySet()){
reg.addAttribute(s, attributes.get(s));
}
PacketFilter filter = new AndFilter(new PacketIDFilter(reg.getPacketID()),
new PacketTypeFilter(IQ.class));
PacketCollector collector = connection.createPacketCollector(filter);
connection.sendPacket(reg);
IQ result = (IQ)collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
// Stop queuing results
collector.cancel();
if (result == null) {
throw new XMPPException("No response from server.");
}
else if (result.getType() == IQ.Type.ERROR) {
throw new XMPPException(result.getError());
}
}
示例4: createAccount
import org.jivesoftware.smack.packet.Registration; //导入方法依赖的package包/类
/**
* Creates a new account using the specified username, password and account attributes.
* The attributes Map must contain only String name/value pairs and must also have values
* for all required attributes.
*
* @param username the username.
* @param password the password.
* @param attributes the account attributes.
* @throws org.jivesoftware.smack.XMPPException if an error occurs creating the account.
* @see #getAccountAttributes()
*/
public void createAccount(String username, String password, Map<String, String> attributes)
throws XMPPException
{
if (!supportsAccountCreation()) {
throw new XMPPException("Server does not support account creation.");
}
Registration reg = new Registration();
reg.setType(IQ.Type.SET);
reg.setTo(connection.getServiceName());
reg.setUsername(username);
reg.setPassword(password);
for(String s : attributes.keySet()){
reg.addAttribute(s, attributes.get(s));
}
PacketFilter filter = new AndFilter(new PacketIDFilter(reg.getPacketID()),
new PacketTypeFilter(IQ.class));
PacketCollector collector = connection.createPacketCollector(filter);
connection.sendPacket(reg);
IQ result = (IQ)collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
// Stop queuing results
collector.cancel();
if (result == null) {
throw new XMPPException("No response from server.");
}
else if (result.getType() == IQ.Type.ERROR) {
throw new XMPPException(result.getError());
}
}
示例5: register
import org.jivesoftware.smack.packet.Registration; //导入方法依赖的package包/类
public boolean register(String user, String pass) {
Log.i(LOG_TAG, "RegisterTask.run()...");
if (xmppManager.isRegistered()) {
Log.i(LOG_TAG, "Account registered already");
return true;
}
final Registration registration = new Registration();
PacketFilter packetFilter = new AndFilter(new PacketIDFilter(
registration.getPacketID()), new PacketTypeFilter(
IQ.class));
PacketCollector collector = xmppManager.getConnection().createPacketCollector(packetFilter);
registration.setType(IQ.Type.SET);
registration.addAttribute("username", user);
registration.addAttribute("password", pass);
if (xmppManager.getConnection().isConnected()) {
xmppManager.getConnection().sendPacket(registration);
IQ result = (IQ) collector.nextResult(REGISTER_TIME_OUT);
collector.cancel();
if(result == null) {
Log.d(LOG_TAG, "The server didn't return result after 60 seconds.");
return false;
} else if (result.getType() == IQ.Type.ERROR) {
if(result.getError().toString().contains("409")) {
return true;
} else {
return false;
}
} else if (result.getType() == IQ.Type.RESULT) {
return true;
}
return false;
} else {
Log.d(LOG_TAG, "connection is not connected");
return false;
}
}
示例6: register
import org.jivesoftware.smack.packet.Registration; //导入方法依赖的package包/类
/**
* 首次连接的时候需要去注册账号,将账号保存,然后去执行注册
*/
private void register() {
if (!isRegistered()) {
// 第一次登陆以uuid和报名作为用户名,包名作为密码,这样就能很好的区别
// 因为uuid可以区别设备而包名可以区别应用。这样用户名就不会有相同的存在,
// 这样通知就能准确的发送到要发送指定的设备和应用之上。
mUsername = createUserName();
mPassword = mNotificationService.getPackageName();
Registration registration = new Registration();
PacketFilter packetFilter = new AndFilter(new PacketIDFilter(
registration.getPacketID()), new PacketTypeFilter(IQ.class));
PacketListener packetListener = new PacketListener() {
public void processPacket(Packet packet) {
if (packet instanceof IQ) {
IQ response = (IQ) packet;
if (response.getType() == IQ.Type.RESULT) {
Editor editor = mSharedPrefs.edit();
editor.putString(USERNAME, mUsername);
editor.putString(PASSWORD, mPassword);
editor.commit();
}
}
}
};
mConnection.addPacketListener(packetListener, packetFilter);
registration.setType(IQ.Type.SET);
registration.addAttribute(KEY_USERNAME, mUsername);
registration.addAttribute(KEY_PASSWORD, mPassword);
mConnection.sendPacket(registration);
}
}
示例7: run
import org.jivesoftware.smack.packet.Registration; //导入方法依赖的package包/类
public void run() {
Log.i(LOGTAG, "RegisterTask.run()...");
if (!xmppManager.isRegistered()) {
final String newUsername = newRandomUUID();
final String newPassword = newRandomUUID();
Registration registration = new Registration();
PacketFilter packetFilter = new AndFilter(new PacketIDFilter(
registration.getPacketID()), new PacketTypeFilter(
IQ.class));
PacketListener packetListener = new PacketListener() {
public void processPacket(Packet packet) {
Log.d("RegisterTask.PacketListener",
"processPacket().....");
Log.d("RegisterTask.PacketListener", "packet="
+ packet.toXML());
if (packet instanceof IQ) {
IQ response = (IQ) packet;
if (response.getType() == IQ.Type.ERROR) {
if (!response.getError().toString().contains(
"409")) {
Log.e(LOGTAG,
"Unknown error while registering XMPP account! "
+ response.getError()
.getCondition());
}
} else if (response.getType() == IQ.Type.RESULT) {
xmppManager.setUsername(newUsername);
xmppManager.setPassword(newPassword);
Log.d(LOGTAG, "username=" + newUsername);
Log.d(LOGTAG, "password=" + newPassword);
Editor editor = sharedPrefs.edit();
editor.putString(Constants.XMPP_USERNAME,
newUsername);
editor.putString(Constants.XMPP_PASSWORD,
newPassword);
editor.commit();
Log
.i(LOGTAG,
"Account registered successfully");
xmppManager.runTask();
}
}
}
};
connection.addPacketListener(packetListener, packetFilter);
registration.setType(IQ.Type.SET);
// registration.setTo(xmppHost);
// Map<String, String> attributes = new HashMap<String, String>();
// attributes.put("username", rUsername);
// attributes.put("password", rPassword);
// registration.setAttributes(attributes);
registration.addAttribute("username", newUsername);
registration.addAttribute("password", newPassword);
connection.sendPacket(registration);
} else {
Log.i(LOGTAG, "Account registered already");
xmppManager.runTask();
}
}
示例8: parseRegistration
import org.jivesoftware.smack.packet.Registration; //导入方法依赖的package包/类
private static Registration parseRegistration(XmlPullParser parser) throws Exception {
Registration registration = new Registration();
boolean done = false;
while (!done) {
int eventType = parser.next();
if (eventType == XmlPullParser.START_TAG) {
// Any element that's in the jabber:iq:register namespace,
// attempt to parse it if it's in the form <name>value</name>.
if (parser.getNamespace().equals("jabber:iq:register")) {
String name = parser.getName();
String value = "";
if (parser.next() == XmlPullParser.TEXT) {
value = parser.getText();
if(name.equals("instructions")){
registration.setInstructions(value);
}
else{
registration.addAttribute(name, value);
}
}
else if(name.equals("registered")){
registration.setRegistered(true);
}
else{
registration.addRequiredField(name);
}
}
// Otherwise, it must be a packet extension.
else {
registration.addExtension(
PacketParserUtils.parsePacketExtension(
parser.getName(),
parser.getNamespace(),
parser));
}
}
else if (eventType == XmlPullParser.END_TAG) {
if (parser.getName().equals("query")) {
done = true;
}
}
}
return registration;
}
示例9: run
import org.jivesoftware.smack.packet.Registration; //导入方法依赖的package包/类
public void run() {
Log.i(LOGTAG, "RegisterTask.run()...");
if (!xmppManager.isRegistered()) {
//final String newPassword = newRandomUUID();
final String newPassword = username;
Registration registration = new Registration();
PacketFilter packetFilter = new AndFilter(new PacketIDFilter(
registration.getPacketID()), new PacketTypeFilter(
IQ.class));
PacketListener packetListener = new PacketListener() {
public void processPacket(Packet packet) {
Log.d("RegisterTask.PacketListener",
"processPacket().....");
Log.d("RegisterTask.PacketListener", "packet="
+ packet.toXML());
if (packet instanceof IQ) {
IQ response = (IQ) packet;
if (response.getType() == IQ.Type.ERROR) {
if (!response.getError().toString().contains(
"409")) {
Log.e(LOGTAG,
"Unknown error while registering XMPP account! "
+ response.getError()
.getCondition());
}
} else if (response.getType() == IQ.Type.RESULT) {
xmppManager.setUsername(username);
xmppManager.setPassword(newPassword);
Log.d(LOGTAG, "username=" + username);
Log.d(LOGTAG, "password=" + newPassword);
Editor editor = sharedPrefs.edit();
editor.putString(Constants.XMPP_USERNAME,
username);
editor.putString(Constants.XMPP_PASSWORD,
newPassword);
editor.commit();
Log
.i(LOGTAG,
"Account registered successfully");
xmppManager.runTask();
}
}
}
};
connection.addPacketListener(packetListener, packetFilter);
registration.setType(IQ.Type.SET);
// registration.setTo(xmppHost);
// Map<String, String> attributes = new HashMap<String, String>();
// attributes.put("username", rUsername);
// attributes.put("password", rPassword);
// registration.setAttributes(attributes);
registration.addAttribute("username", username);
registration.addAttribute("password", newPassword);
connection.sendPacket(registration);
} else {
Log.i(LOGTAG, "Account registered already");
xmppManager.runTask();
}
}
示例10: run
import org.jivesoftware.smack.packet.Registration; //导入方法依赖的package包/类
public void run() {
Log.i(LOGTAG, "RegisterTask.run()...");
if (!xmppManager.isRegistered()) {
final String newUsername = newRandomUUID();
final String newPassword = newRandomUUID();
Registration registration = new Registration();
PacketFilter packetFilter = new AndFilter(new PacketIDFilter(
registration.getPacketID()), new PacketTypeFilter(
IQ.class));
PacketListener packetListener = new PacketListener() {
public void processPacket(Packet packet) {
Log.d("RegisterTask.PacketListener",
"processPacket().....");
Log.d("RegisterTask.PacketListener", "packet="
+ packet.toXML());
if (packet instanceof IQ) {
IQ response = (IQ) packet;
if (response.getType() == IQ.Type.ERROR) {
if (!response.getError().toString().contains(
"409")) {
Log.e(LOGTAG,
"Unknown error while registering XMPP account! "
+ response.getError()
.getCondition());
}
} else if (response.getType() == IQ.Type.RESULT) {
username = newUsername;
password = newPassword;
Log.d(LOGTAG, "username=" + username);
Log.d(LOGTAG, "password=" + password);
editor.putString(Constants.XMPP_USERNAME,
username);
editor.putString(Constants.XMPP_PASSWORD,
password);
editor.commit();
Log
.i(LOGTAG,
"Account registered successfully");
}
}
}
};
connection.addPacketListener(packetListener, packetFilter);
registration.setType(IQ.Type.SET);
//registration.setTo(xmppHost);
// Map<String, String> attributes = new HashMap<String, String>();
// attributes.put("username", rUsername);
// attributes.put("password", rPassword);
// registration.setAttributes(attributes);
registration.addAttribute("username", newUsername);
registration.addAttribute("password", newPassword);
connection.sendPacket(registration);
} else {
Log.i(LOGTAG, "Account registered already");
XmppManager.runTask(xmppManager);
}
}
示例11: run
import org.jivesoftware.smack.packet.Registration; //导入方法依赖的package包/类
public void run() {
Log.i(LOGTAG, "RegisterTask.run()...");
if (!xmppManager.isRegistered()) {
final String newUsername = newRandomUUID();
final String newPassword = newRandomUUID();
Registration registration = new Registration();
PacketFilter packetFilter = new AndFilter(new PacketIDFilter(
registration.getPacketID()), new PacketTypeFilter(
IQ.class));
PacketListener packetListener = new PacketListener() {
public void processPacket(Packet packet) {
Log.d("RegisterTask.PacketListener",
"processPacket().....");
Log.d("RegisterTask.PacketListener", "packet="
+ packet.toXML());
if (packet instanceof IQ) {
IQ response = (IQ) packet;
if (response.getType() == IQ.Type.ERROR) {
if (!response.getError().toString().contains(
"409")) {
Log.e(LOGTAG,
"Unknown error while registering XMPP account! "
+ response.getError()
.getCondition());
}
} else if (response.getType() == IQ.Type.RESULT) {
xmppManager.setUsername(newUsername);
xmppManager.setPassword(newPassword);
Log.d(LOGTAG, "username=" + newUsername);
Log.d(LOGTAG, "password=" + newPassword);
Editor editor = clientPrefs.edit();
editor.putString(Constants.XMPP_USERNAME,
newUsername);
editor.putString(Constants.XMPP_PASSWORD,
newPassword);
editor.commit();
Log
.i(LOGTAG,
"Account registered successfully");
}
}
}
};
connection.addPacketListener(packetListener, packetFilter);
registration.setType(IQ.Type.SET);
// registration.setTo(xmppHost);
// Map<String, String> attributes = new HashMap<String, String>();
// attributes.put("username", rUsername);
// attributes.put("password", rPassword);
// registration.setAttributes(attributes);
registration.addAttribute("username", newUsername);
registration.addAttribute("password", newPassword);
connection.sendPacket(registration);
} else {
Log.i(LOGTAG, "Account registered already");
xmppManager.runTask();
}
}
示例12: run
import org.jivesoftware.smack.packet.Registration; //导入方法依赖的package包/类
public void run() {
Log.i(LOGTAG, "RegisterTask.run()...");
if (!xmppManager.isRegistered()) {
// final XmppManager xmppManager = XmppManager.this;
final String newUsername = newRandomUUID();
final String newPassword = newRandomUUID();
Registration registration = new Registration();
// TODO
// PacketFilter packetFilter = new AndFilter(new PacketIDFilter(
// registration.getPacketID()), new PacketTypeFilter(
// Message.class));
PacketFilter packetFilter = new AndFilter(new PacketIDFilter(
registration.getPacketID()));
PacketListener packetListener = new PacketListener() {
public void processPacket(Packet packet) {
Log.d("PacketListener", "processPacket().....");
Log.e("PacketListener", "packet=" + packet.toXML());
if (packet instanceof IQ) {
IQ response = (IQ) packet;
if (response.getType() == IQ.Type.ERROR) {
if (!response.getError().toString().contains(
"409")) {
Log.e(LOGTAG,
"Unknown error while registering XMPP account! "
+ response.getError()
.getCondition());
}
} else if (response.getType() == IQ.Type.RESULT) {
username = newUsername;
password = newPassword;
Log.d(LOGTAG, "username=" + username);
Log.d(LOGTAG, "password=" + password);
editor.putString(Constants.XMPP_USERNAME,
username);
editor.putString(Constants.XMPP_PASSWORD,
password);
editor.commit();
Log
.i(LOGTAG,
"Account registered successfully");
}
}
}
};
connection.addPacketListener(packetListener, packetFilter);
registration.setType(IQ.Type.SET);
//registration.setTo(xmppHost);
// Map<String, String> attributes = new HashMap<String, String>();
// attributes.put("username", rUsername);
// attributes.put("password", rPassword);
// registration.setAttributes(attributes);
registration.addAttribute("username", newUsername);
registration.addAttribute("password", newPassword);
connection.sendPacket(registration);
} else {
Log.i(LOGTAG, "Account registered already");
XmppManager.runTask(xmppManager);
}
}
示例13: run
import org.jivesoftware.smack.packet.Registration; //导入方法依赖的package包/类
public void run() {
Log.i(LOGTAG, "RegisterTask.run()...");
if (!xmppManager.isRegistered()) {
// final XmppManager xmppManager = XmppManager.this;
final String newUsername = newRandomUUID();
final String newPassword = newRandomUUID();
Registration registration = new Registration();
PacketFilter packetFilter = new AndFilter(new PacketIDFilter(
registration.getPacketID()), new PacketTypeFilter(
IQ.class));
// PacketFilter packetFilter = new AndFilter(new PacketIDFilter(
// registration.getPacketID()));
PacketListener packetListener = new PacketListener() {
public void processPacket(Packet packet) {
Log.d("RegisterTask.PacketListener",
"processPacket().....");
Log.d("RegisterTask.PacketListener", "packet="
+ packet.toXML());
if (packet instanceof IQ) {
IQ response = (IQ) packet;
if (response.getType() == IQ.Type.ERROR) {
if (!response.getError().toString().contains(
"409")) {
Log.e(LOGTAG,
"Unknown error while registering XMPP account! "
+ response.getError()
.getCondition());
}
} else if (response.getType() == IQ.Type.RESULT) {
username = newUsername;
password = newPassword;
Log.d(LOGTAG, "username=" + username);
Log.d(LOGTAG, "password=" + password);
editor.putString(Constants.XMPP_USERNAME,
username);
editor.putString(Constants.XMPP_PASSWORD,
password);
editor.commit();
Log
.i(LOGTAG,
"Account registered successfully");
}
}
}
};
connection.addPacketListener(packetListener, packetFilter);
registration.setType(IQ.Type.SET);
//registration.setTo(xmppHost);
// Map<String, String> attributes = new HashMap<String, String>();
// attributes.put("username", rUsername);
// attributes.put("password", rPassword);
// registration.setAttributes(attributes);
registration.addAttribute("username", newUsername);
registration.addAttribute("password", newPassword);
connection.sendPacket(registration);
} else {
Log.i(LOGTAG, "Account registered already");
XmppManager.runTask(xmppManager);
}
}
示例14: register
import org.jivesoftware.smack.packet.Registration; //导入方法依赖的package包/类
public void register() {
Log.d(LOGTAG, "register().....");
if (!isRegistered()) {
// final XmppManager xmppManager = XmppManager.this;
final String rUsername = newRandomUUID();
final String rPassword = newRandomUUID();
Registration registration = new Registration();
// PacketFilter packetFilter = new AndFilter(new PacketIDFilter(
// registration.getPacketID()), new PacketTypeFilter(
// Message.class));
PacketFilter packetFilter = new AndFilter(new PacketIDFilter(
registration.getPacketID()));
PacketListener packetListener = new PacketListener() {
public void processPacket(Packet packet) {
Log.d("PacketListener", "processPacket().....");
Log.e("PacketListener", "packet=" + packet.toXML());
if (packet instanceof IQ) {
IQ response = (IQ) packet;
if (response.getType() == IQ.Type.ERROR) {
if (!response.getError().toString().contains("409")) {
Log.e(LOGTAG,
"Unknown error while registering XMPP account! "
+ response.getError()
.getCondition());
}
} else if (response.getType() == IQ.Type.RESULT) {
username = rUsername;
password = rPassword;
Log.d(LOGTAG, "username=" + username);
Log.d(LOGTAG, "password=" + password);
editor.putString(Constants.XMPP_USERNAME,
username);
editor.putString(Constants.XMPP_PASSWORD,
password);
editor.commit();
Log.i(LOGTAG, "XMPP account registered.");
//login();
}
}
}
};
connection.addPacketListener(packetListener, packetFilter);
registration.setType(IQ.Type.SET);
//registration.setTo(xmppHost);
// Map<String, String> attributes = new HashMap<String, String>();
// attributes.put("username", rUsername);
// attributes.put("password", rPassword);
// registration.setAttributes(attributes);
registration.addAttribute("username", rUsername);
registration.addAttribute("password", rPassword);
connection.sendPacket(registration);
} else {
Log.i(LOGTAG, "register()..... account registered already.");
}
Log.d(LOGTAG, "register()..... done!");
}
示例15: run
import org.jivesoftware.smack.packet.Registration; //导入方法依赖的package包/类
public void run() {
Log.i(LOGTAG, "RegisterTask.run()...");
if (!xmppManager.isRegistered(account)) {
Registration registration = new Registration();
PacketFilter packetFilter = new AndFilter(new PacketIDFilter(registration.getPacketID()), new PacketTypeFilter(IQ.class));
PacketListener packetListener = new PacketListener() {
public void processPacket(Packet packet) {
Log.d("RegisterTask.PacketListener", "processPacket().....");
Log.d("RegisterTask.PacketListener", "packet=" + packet.toXML());
if (packet instanceof IQ) {
IQ response = (IQ) packet;
if (response.getType() == IQ.Type.ERROR) {
if (!response.getError().toString().contains("409")) {
Log.e(LOGTAG, "Unknown error while registering XMPP account! " + response.getError().getCondition());
}
if(mRegisterListener != null){
mRegisterListener.registerFail();
}
} else if (response.getType() == IQ.Type.RESULT) {
xmppManager.setUsername(account);
xmppManager.setPassword(password);
Log.d(LOGTAG, "username=" + account);
Log.d(LOGTAG, "password=" + password);
Editor editor = sharedPrefs.edit();
editor.putString(Constants.XMPP_USERNAME, account);
editor.putString(Constants.XMPP_PASSWORD, password);
editor.commit();
Log.i(LOGTAG, "Account registered successfully");
xmppManager.runTask();
if(mRegisterListener != null){
mRegisterListener.registerSuccess();
}
}
}
}
};
connection.addPacketListener(packetListener, packetFilter);
registration.setType(IQ.Type.SET);
registration.addAttribute("username", account);
registration.addAttribute("password", password);
connection.sendPacket(registration);
} else {
Log.i(LOGTAG, "Account registered already");
xmppManager.runTask();
}
}