Methods Summary |
---|
public void | acceptInvitation(long id)
handleInvitation(id, true);
|
public synchronized void | cancelLogin()
if (mConnectionState >= ImConnection.LOGGED_IN) {
// too late
return;
}
logout();
|
void | clearSessionCookie(android.content.ContentResolver cr)
cr.delete(getSessionCookiesUri(), null, null);
|
private static int | convertConnStateForDb(int state)
switch (state) {
case ImConnection.DISCONNECTED:
case ImConnection.LOGGING_OUT:
return Im.ConnectionStatus.OFFLINE;
case ImConnection.LOGGING_IN:
return Im.ConnectionStatus.CONNECTING;
case ImConnection.LOGGED_IN:
return Im.ConnectionStatus.ONLINE;
case ImConnection.SUSPENDED:
case ImConnection.SUSPENDING:
return Im.ConnectionStatus.SUSPENDED;
default:
return Im.ConnectionStatus.OFFLINE;
}
|
public long | getAccountId()
return mAccountId;
|
public com.android.im.engine.ImConnection | getAdaptee()
return mConnection;
|
public int | getChatSessionCount()
if (mChatSessionManager == null) {
return 0;
}
return mChatSessionManager.getChatSessionCount();
|
public com.android.im.IChatSessionManager | getChatSessionManager()
return mChatSessionManager;
|
public com.android.im.IContactListManager | getContactListManager()
return mContactListManager;
|
public RemoteImService | getContext()
return mService;
|
public com.android.im.engine.Contact | getLoginUser()
return mConnection.getLoginUser();
|
public long | getProviderId()
return mProviderId;
|
private android.net.Uri | getSessionCookiesUri()
Uri.Builder builder = Im.SessionCookies.CONTENT_URI_SESSION_COOKIES_BY.buildUpon();
ContentUris.appendId(builder, mProviderId);
ContentUris.appendId(builder, mAccountId);
return builder.build();
|
public int | getState()
return mConnectionState;
|
public int[] | getSupportedPresenceStatus()
return mConnection.getSupportedPresenceStatus();
|
public com.android.im.engine.Presence | getUserPresence()
return mConnection.getUserPresence();
|
private void | handleInvitation(long id, boolean accept)
if(mGroupManager == null) {
return;
}
ContentResolver cr = mService.getContentResolver();
Cursor c = cr.query(ContentUris.withAppendedId(Im.Invitation.CONTENT_URI, id), null, null, null, null);
if(c == null) {
return;
}
if(c.moveToFirst()) {
String inviteId = c.getString(c.getColumnIndexOrThrow(Im.Invitation.INVITE_ID));
int status;
if(accept) {
mGroupManager.acceptInvitationAsync(inviteId);
status = Im.Invitation.STATUS_ACCEPTED;
} else {
mGroupManager.rejectInvitationAsync(inviteId);
status = Im.Invitation.STATUS_REJECTED;
}
c.updateInt(c.getColumnIndexOrThrow(Im.Invitation.STATUS), status);
c.commitUpdates();
}
c.close();
|
public void | login(long accountId, java.lang.String userName, java.lang.String password, boolean autoLoadContacts)
mAccountId = accountId;
mAutoLoadContacts = autoLoadContacts;
mConnectionState = ImConnection.LOGGING_IN;
mConnection.loginAsync(new LoginInfo(userName, password));
mChatSessionManager = new ChatSessionManagerAdapter(this);
mContactListManager = new ContactListManagerAdapter(this);
|
public void | logout()
mConnectionState = ImConnection.LOGGING_OUT;
mConnection.logoutAsync();
|
public void | networkTypeChanged()
mConnection.networkTypeChanged();
|
private java.util.HashMap | querySessionCookie(android.content.ContentResolver cr)
Cursor c = cr.query(getSessionCookiesUri(), SESSION_COOKIE_PROJECTION, null, null, null);
if (c == null) {
return null;
}
HashMap<String, String> cookie = null;
if (c.getCount() > 0) {
cookie = new HashMap<String, String>();
while(c.moveToNext()) {
cookie.put(c.getString(COLUMN_SESSION_COOKIE_NAME),
c.getString(COLUMN_SESSION_COOKIE_VALUE));
}
}
c.close();
return cookie;
|
void | reestablishSession()
mConnectionState = ImConnection.LOGGING_IN;
ContentResolver cr = mService.getContentResolver();
if ((mConnection.getCapability() & ImConnection.CAPABILITY_SESSION_REESTABLISHMENT) != 0) {
HashMap<String, String> cookie = querySessionCookie(cr);
if (cookie != null) {
Log.d(TAG, "re-establish session");
try {
mConnection.reestablishSessionAsync(cookie);
} catch (IllegalArgumentException e) {
Log.e(TAG, "Invalid session cookie, probably modified by others.");
clearSessionCookie(cr);
}
}
}
|
public void | registerConnectionListener(com.android.im.IConnectionListener listener)
if (listener != null) {
mRemoteConnListeners.register(listener);
}
|
public void | rejectInvitation(long id)
handleInvitation(id, false);
|
void | saveSessionCookie(android.content.ContentResolver cr)
HashMap<String, String> cookies = mConnection.getSessionContext();
int i = 0;
ContentValues[] valuesList = new ContentValues[cookies.size()];
for(Map.Entry<String,String> entry : cookies.entrySet()){
ContentValues values = new ContentValues(2);
values.put(Im.SessionCookies.NAME, entry.getKey());
values.put(Im.SessionCookies.VALUE, entry.getValue());
valuesList[i++] = values;
}
cr.bulkInsert(getSessionCookiesUri(), valuesList);
|
public void | setInvitationListener(com.android.im.IInvitationListener listener)
if(mInvitationListener != null) {
mInvitationListener.mRemoteListener = listener;
}
|
void | suspend()
mConnectionState = ImConnection.SUSPENDING;
mConnection.suspend();
|
public void | unregisterConnectionListener(com.android.im.IConnectionListener listener)
if (listener != null) {
mRemoteConnListeners.unregister(listener);
}
|
void | updateAccountStatusInDb()
Presence p = getUserPresence();
int presenceStatus = Im.Presence.OFFLINE;
int connectionStatus = convertConnStateForDb(mConnectionState);
if (p != null) {
presenceStatus = ContactListManagerAdapter.convertPresenceStatus(p);
}
ContentResolver cr = mService.getContentResolver();
Uri uri = Im.AccountStatus.CONTENT_URI;
ContentValues values = new ContentValues();
values.put(Im.AccountStatus.ACCOUNT, mAccountId);
values.put(Im.AccountStatus.PRESENCE_STATUS, presenceStatus);
values.put(Im.AccountStatus.CONNECTION_STATUS, connectionStatus);
cr.insert(uri, values);
|
public int | updateUserPresence(com.android.im.engine.Presence newPresence)
try {
mConnection.updateUserPresenceAsync(newPresence);
} catch (ImException e) {
return e.getImError().getCode();
}
return ImErrorInfo.NO_ERROR;
|