79 lines
2.1 KiB
Java
79 lines
2.1 KiB
Java
package org.mercury_im.messenger.xmpp_database_connector;
|
|
|
|
import android.util.Log;
|
|
|
|
import org.jivesoftware.smack.packet.Presence;
|
|
import org.jivesoftware.smack.roster.Roster;
|
|
import org.jivesoftware.smack.roster.RosterEntry;
|
|
import org.jxmpp.jid.Jid;
|
|
import org.mercury_im.messenger.MercuryImApplication;
|
|
import org.mercury_im.messenger.persistence.model.AccountModel;
|
|
import org.mercury_im.messenger.persistence.repository.AccountRepository;
|
|
import org.mercury_im.messenger.persistence.repository.ContactRepository;
|
|
import org.mercury_im.messenger.xmpp_core.MercuryConnection;
|
|
import org.mercury_im.messenger.xmpp_core.RosterHandler;
|
|
|
|
import java.util.Collection;
|
|
|
|
import javax.inject.Inject;
|
|
|
|
import static androidx.constraintlayout.widget.Constraints.TAG;
|
|
|
|
public class RosterConnector implements RosterHandler {
|
|
|
|
@Inject
|
|
ContactRepository contactRepository;
|
|
|
|
@Inject
|
|
AccountRepository accountRepository;
|
|
|
|
private AccountModel account;
|
|
|
|
private final MercuryConnection connection;
|
|
private final Roster roster;
|
|
|
|
public RosterConnector(MercuryConnection connection) {
|
|
this.connection = connection;
|
|
this.roster = connection.getRoster();
|
|
|
|
MercuryImApplication.getApplication().getAppComponent().inject(this);
|
|
|
|
account = (AccountModel) accountRepository.getAccount(connection.getAccountId()).getValue();
|
|
}
|
|
|
|
@Override
|
|
public void entriesAdded(Collection<Jid> addresses) {
|
|
for (Jid j : addresses) {
|
|
RosterEntry entry = roster.getEntry(j.asBareJid());
|
|
// ContactModel
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void entriesUpdated(Collection<Jid> addresses) {
|
|
|
|
}
|
|
|
|
@Override
|
|
public void entriesDeleted(Collection<Jid> addresses) {
|
|
|
|
}
|
|
|
|
@Override
|
|
public void presenceChanged(Presence presence) {
|
|
|
|
}
|
|
|
|
@Override
|
|
public void onRosterLoaded(Roster roster) {
|
|
if (roster == connection.getRoster()) {
|
|
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void onRosterLoadingFailed(Exception exception) {
|
|
Log.e(TAG, "Loading roster for " + account.getJid().toString() + " failed.", exception);
|
|
}
|
|
}
|