Use the user jid send by the server cause it can be different than the user
requested ji.
--- a/src/com/beem/project/beem/BeemService.java Mon Mar 21 22:32:34 2011 +0100
+++ b/src/com/beem/project/beem/BeemService.java Fri Mar 25 23:02:04 2011 +0100
@@ -220,7 +220,7 @@
configure(ProviderManager.getInstance());
mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
- mConnection = new XmppConnectionAdapter(mConnectionConfiguration, tmpJid, mLogin, mPassword, this);
+ mConnection = new XmppConnectionAdapter(mConnectionConfiguration, mLogin, mPassword, this);
Roster.setDefaultSubscriptionMode(SubscriptionMode.manual);
mBind = new XmppFacade(mConnection);
--- a/src/com/beem/project/beem/service/UserInfo.java Mon Mar 21 22:32:34 2011 +0100
+++ b/src/com/beem/project/beem/service/UserInfo.java Fri Mar 25 23:02:04 2011 +0100
@@ -45,7 +45,6 @@
import android.os.Parcel;
import android.os.Parcelable;
-import org.jivesoftware.smack.util.StringUtils;
/**
* This class contains information about the user of the connection.
@@ -68,7 +67,7 @@
}
};
- private final String mBareJid;
+ private final String mFullJid;
private String mAvatarId;
/**
@@ -76,7 +75,7 @@
* @param in parcel to use for construction
*/
private UserInfo(final Parcel in) {
- mBareJid = in.readString();
+ mFullJid = in.readString();
mAvatarId = in.readString();
}
@@ -85,12 +84,13 @@
* @param jid jid of the user
*/
public UserInfo(final String jid) {
- mBareJid = StringUtils.parseBareAddress(jid);
+ // the jid is case insensitive
+ mFullJid = jid;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
- dest.writeString(mBareJid);
+ dest.writeString(mFullJid);
dest.writeString(mAvatarId);
}
@@ -118,11 +118,11 @@
}
/**
- * Get the jid of the user.
+ * Get the full jid of the user.
*
* @return the jid
*/
public String getJid() {
- return mBareJid;
+ return mFullJid;
}
}
--- a/src/com/beem/project/beem/service/XmppConnectionAdapter.java Mon Mar 21 22:32:34 2011 +0100
+++ b/src/com/beem/project/beem/service/XmppConnectionAdapter.java Fri Mar 25 23:02:04 2011 +0100
@@ -53,6 +53,7 @@
import org.jivesoftware.smack.filter.PacketFilter;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Presence;
+import org.jivesoftware.smack.util.StringUtils;
import org.jivesoftware.smackx.ChatStateManager;
import org.jivesoftware.smackx.ServiceDiscoveryManager;
import org.jivesoftware.smackx.packet.DiscoverInfo;
@@ -127,38 +128,35 @@
/**
* Constructor.
* @param config Configuration to use in order to connect
- * @param jid the jid of the user
* @param login login to use on connect
* @param password password to use on connect
* @param service the background service associated with the connection.
*/
- public XmppConnectionAdapter(final ConnectionConfiguration config, final String jid,
+ public XmppConnectionAdapter(final ConnectionConfiguration config,
final String login, final String password, final BeemService service) {
- this(new XMPPConnection(config), jid, login, password, service);
+ this(new XMPPConnection(config), login, password, service);
}
/**
* Constructor.
* @param serviceName name of the service to connect to
- * @param jid the jid of the user
* @param login login to use on connect
* @param password password to use on connect
* @param service the background service associated with the connection.
*/
- public XmppConnectionAdapter(final String serviceName, final String jid,
+ public XmppConnectionAdapter(final String serviceName,
final String login, final String password, final BeemService service) {
- this(new XMPPConnection(serviceName), jid, login, password, service);
+ this(new XMPPConnection(serviceName), login, password, service);
}
/**
* Constructor.
* @param con The connection to adapt
- * @param jid the jid of the user
* @param login The login to use
* @param password The password to use
* @param service the background service associated with the connection.
*/
- public XmppConnectionAdapter(final XMPPConnection con, final String jid,
+ public XmppConnectionAdapter(final XMPPConnection con,
final String login, final String password, final BeemService service) {
mAdaptee = con;
PrivacyListManager.getInstanceFor(mAdaptee);
@@ -166,7 +164,6 @@
mPassword = password;
mService = service;
Context ctx = mService.getApplicationContext();
- mUserInfo = new UserInfo(jid.toLowerCase());
if (ctx instanceof BeemApplication) {
mApplication = (BeemApplication) ctx;
}
@@ -243,6 +240,8 @@
mAdaptee.addPacketListener(mSubscribePacketListener, filter);
mAdaptee.login(mLogin, mPassword, mResource);
+ mUserInfo = new UserInfo(mAdaptee.getUser());
+
mChatManager = new BeemChatManager(mAdaptee.getChatManager(), mService);
//nikita: I commented this line because of the logs provided in http://www.beem-project.com/issues/321
//Also, since the privacylistmanager isn't finished and used, it will be safer to not initialize it
@@ -744,8 +743,9 @@
@Override
public void onAvatarChange(String from, String avatarId, List<AvatarMetadataExtension.Info> avatarInfos) {
- String jid = mUserInfo.getJid();
- if (jid.equals(from)) {
+ String jid = StringUtils.parseBareAddress(mUserInfo.getJid());
+ String mfrom = StringUtils.parseBareAddress(from);
+ if (jid.equalsIgnoreCase(mfrom)) {
mUserInfo.setAvatarId(avatarId);
}
}