use of com.xabber.android.data.NetworkException in project xabber-android by redsolution.
the class BlockingManager method requestBlockList.
public void requestBlockList(String account) {
if (!isSupported(account)) {
return;
}
final BlockList blockListRequest = new BlockList();
blockListRequest.setType(IQ.Type.get);
try {
ConnectionManager.getInstance().sendRequest(account, blockListRequest, new OnResponseListener() {
@Override
public void onReceived(String account, String packetId, IQ iq) {
if (!blockListRequest.getStanzaId().equals(packetId) || !(iq instanceof BlockList)) {
return;
}
if (iq.getType() == IQ.Type.result) {
blockListsForAccounts.put(account, ((BlockList) iq).getItems());
for (OnBlockedListChangedListener onBlockedListChangedListener : Application.getInstance().getUIListeners(OnBlockedListChangedListener.class)) {
onBlockedListChangedListener.onBlockedListChanged(account);
}
for (OnContactChangedListener onContactChangedListener : Application.getInstance().getUIListeners(OnContactChangedListener.class)) {
onContactChangedListener.onContactsChanged(new ArrayList<BaseEntity>());
}
}
}
@Override
public void onError(String account, String packetId, IQ iq) {
}
@Override
public void onTimeout(String account, String packetId) {
}
@Override
public void onDisconnect(String account, String packetId) {
}
});
} catch (NetworkException e) {
e.printStackTrace();
}
}
use of com.xabber.android.data.NetworkException in project xabber-android by redsolution.
the class BlockingManager method blockContact.
public void blockContact(String account, final String contactJid, final BlockContactListener listener) {
final Block blockRequest = new Block();
blockRequest.setType(IQ.Type.set);
blockRequest.addItem(contactJid);
try {
ConnectionManager.getInstance().sendRequest(account, blockRequest, new OnResponseListener() {
@Override
public void onReceived(String account, String packetId, IQ iq) {
if (!blockRequest.getStanzaId().equals(packetId)) {
return;
}
if (iq.getType() == IQ.Type.result) {
requestBlockList(account);
listener.onSuccess();
} else {
listener.onError();
}
}
@Override
public void onError(String account, String packetId, IQ iq) {
listener.onError();
}
@Override
public void onTimeout(String account, String packetId) {
listener.onError();
}
@Override
public void onDisconnect(String account, String packetId) {
listener.onError();
}
});
} catch (NetworkException e) {
e.printStackTrace();
listener.onError();
}
}
use of com.xabber.android.data.NetworkException in project xabber-android by redsolution.
the class MessageArchiveManager method requestList.
private String requestList(String account, String bareAddress, String before) {
List packet = new List();
packet.setType(Type.get);
Set rsm = new Set();
rsm.setMax(RSM_MAX);
rsm.setBefore(before);
packet.setRsm(rsm);
packet.setWith(bareAddress);
packet.setEnd(connected.get(account));
String packetId = packet.getPacketID();
try {
ConnectionManager.getInstance().sendStanza(account, packet);
} catch (NetworkException e) {
}
return packetId;
}
use of com.xabber.android.data.NetworkException in project xabber-android by redsolution.
the class MessageArchiveManager method requestModified.
private void requestModified(String account, String before) {
Modified packet = new Modified();
packet.setType(Type.get);
Set rsm = new Set();
rsm.setMax(RSM_MAX);
rsm.setBefore(before);
packet.setRsm(rsm);
packet.setStart(modificationStorages.get(account).getLastRequest());
try {
ConnectionManager.getInstance().sendRequest(account, packet, new OnResponseListener() {
@Override
public void onReceived(String account, String packetId, IQ iq) {
if (iq instanceof Modified && ((Modified) iq).isValid())
onModifiedReceived(account, (Modified) iq);
else
onError(account, packetId, iq);
}
@Override
public void onError(String account, String packetId, IQ iq) {
onModifiedAvailable(account);
}
@Override
public void onTimeout(String account, String packetId) {
onError(account, packetId, null);
}
@Override
public void onDisconnect(String account, String packetId) {
}
});
} catch (NetworkException e) {
}
}
use of com.xabber.android.data.NetworkException in project xabber-android by redsolution.
the class MessageArchiveManager method requestPreferences.
private void requestPreferences(String account) {
Pref pref = new Pref();
pref.setType(Type.get);
try {
ConnectionManager.getInstance().sendRequest(account, pref, new OnResponseListener() {
@Override
public void onReceived(String account, String packetId, IQ iq) {
if (iq instanceof Pref && ((Pref) iq).isValid())
onPreferencesResponce(account, (Pref) iq);
onPreferenceAvailable(account);
}
@Override
public void onError(String account, String packetId, IQ iq) {
onPreferenceAvailable(account);
}
@Override
public void onTimeout(String account, String packetId) {
onError(account, packetId, null);
}
@Override
public void onDisconnect(String account, String packetId) {
}
});
} catch (NetworkException e) {
}
}
Aggregations