Skip to content

Commit

Permalink
roster fetch on connect: 1/2
Browse files Browse the repository at this point in the history
  • Loading branch information
ge0rg committed Feb 5, 2013
1 parent b92255e commit 4c8e0ae
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/org/yaxim/androidclient/service/SmackableImp.java
Expand Up @@ -179,8 +179,6 @@ public boolean doConnect(boolean create_account) throws YaximXMPPException {
// we need to "ping" the service to let it know we are actually
// connected, even when no roster entries will come in
mServiceCallBack.rosterChanged();
registerRosterListener();
setRosterEntries();
}
return isAuthenticated();
}
Expand Down Expand Up @@ -255,6 +253,7 @@ private void tryToConnect(boolean create_account) throws YaximXMPPException {
SmackConfiguration.setPacketReplyTimeout(PACKET_TIMEOUT);
SmackConfiguration.setKeepAliveInterval(-1);
SmackConfiguration.setDefaultPingInterval(0);
registerRosterListener();
mXMPPConnection.connect();
if (!mXMPPConnection.isConnected()) {
throw new YaximXMPPException("SMACK connect failed without exception!");
Expand Down Expand Up @@ -362,7 +361,8 @@ private void tryToAddRosterEntry(String user, String alias, String group)
}
}

private void setRosterEntries() {
private void removeOldRosterEntries() {
Log.d(TAG, "removeOldRosterEntries()");
mRoster = mXMPPConnection.getRoster();
Collection<RosterEntry> rosterEntries = mRoster.getEntries();
StringBuilder exclusion = new StringBuilder(RosterConstants.JID + " NOT IN (");
Expand All @@ -376,7 +376,8 @@ private void setRosterEntries() {
exclusion.append("'").append(rosterEntry.getUser()).append("'");
}
exclusion.append(")");
mContentResolver.delete(RosterProvider.CONTENT_URI, exclusion.toString(), null);
int count = mContentResolver.delete(RosterProvider.CONTENT_URI, exclusion.toString(), null);
Log.d(TAG, "deleted " + count + " old roster entries");
}


Expand Down

0 comments on commit 4c8e0ae

Please sign in to comment.