use of de.pixart.messenger.xmpp.stanzas.IqPacket in project Pix-Art-Messenger by kriztan.
the class MessageArchiveService method execute.
private void execute(final Query query) {
final Account account = query.getAccount();
if (account.getStatus() == Account.State.ONLINE) {
Log.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": running mam query " + query.toString());
IqPacket packet = this.mXmppConnectionService.getIqGenerator().queryMessageArchiveManagement(query);
this.mXmppConnectionService.sendIqPacket(account, packet, (a, p) -> {
Element fin = p.findChild("fin", Namespace.MAM);
if (p.getType() == IqPacket.TYPE.TIMEOUT) {
synchronized (MessageArchiveService.this.queries) {
MessageArchiveService.this.queries.remove(query);
if (query.hasCallback()) {
query.callback(false);
}
}
} else if (p.getType() == IqPacket.TYPE.RESULT && fin != null) {
processFin(query, fin);
} else if (p.getType() == IqPacket.TYPE.RESULT && query.isLegacy()) {
// do nothing
} else {
Log.d(Config.LOGTAG, a.getJid().toBareJid().toString() + ": error executing mam: " + p.toString());
finalizeQuery(query, true);
}
});
} else {
synchronized (this.pendingQueries) {
this.pendingQueries.add(query);
}
}
}
use of de.pixart.messenger.xmpp.stanzas.IqPacket in project Pix-Art-Messenger by kriztan.
the class XmppConnectionService method publishDisplayName.
public void publishDisplayName(Account account) {
String displayName = account.getDisplayName();
if (displayName != null && !displayName.isEmpty()) {
IqPacket publish = mIqGenerator.publishNick(displayName);
sendIqPacket(account, publish, new OnIqPacketReceived() {
@Override
public void onIqPacketReceived(Account account, IqPacket packet) {
if (packet.getType() == IqPacket.TYPE.ERROR) {
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": could not publish nick");
}
}
});
}
}
use of de.pixart.messenger.xmpp.stanzas.IqPacket in project Pix-Art-Messenger by kriztan.
the class XmppConnectionService method sendCreateAccountWithCaptchaPacket.
public void sendCreateAccountWithCaptchaPacket(Account account, String id, Data data) {
final XmppConnection connection = account.getXmppConnection();
if (connection != null) {
IqPacket request = mIqGenerator.generateCreateAccountWithCaptcha(account, id, data);
connection.sendUnmodifiedIqPacket(request, connection.registrationResponseListener, true);
}
}
use of de.pixart.messenger.xmpp.stanzas.IqPacket in project Pix-Art-Messenger by kriztan.
the class XmppConnectionService method deleteContactOnServer.
public void deleteContactOnServer(Contact contact) {
contact.resetOption(Contact.Options.PREEMPTIVE_GRANT);
contact.resetOption(Contact.Options.DIRTY_PUSH);
contact.setOption(Contact.Options.DIRTY_DELETE);
Account account = contact.getAccount();
if (account.getStatus() == Account.State.ONLINE) {
IqPacket iq = new IqPacket(IqPacket.TYPE.SET);
Element item = iq.query(Namespace.ROSTER).addChild("item");
item.setAttribute("jid", contact.getJid().toString());
item.setAttribute("subscription", "remove");
account.getXmppConnection().sendIqPacket(iq, mDefaultIqHandler);
}
}
use of de.pixart.messenger.xmpp.stanzas.IqPacket in project Pix-Art-Messenger by kriztan.
the class XmppConnectionService method fetchAvatarPep.
private void fetchAvatarPep(Account account, final Avatar avatar, final UiCallback<Avatar> callback) {
IqPacket packet = this.mIqGenerator.retrievePepAvatar(avatar);
sendIqPacket(account, packet, new OnIqPacketReceived() {
@Override
public void onIqPacketReceived(Account account, IqPacket result) {
synchronized (mInProgressAvatarFetches) {
mInProgressAvatarFetches.remove(generateFetchKey(account, avatar));
}
final String ERROR = account.getJid().toBareJid() + ": fetching avatar for " + avatar.owner + " failed ";
if (result.getType() == IqPacket.TYPE.RESULT) {
avatar.image = mIqParser.avatarData(result);
if (avatar.image != null) {
if (getFileBackend().save(avatar)) {
if (account.getJid().toBareJid().equals(avatar.owner)) {
if (account.setAvatar(avatar.getFilename())) {
databaseBackend.updateAccount(account);
}
getAvatarService().clear(account);
updateConversationUi();
updateAccountUi();
} else {
Contact contact = account.getRoster().getContact(avatar.owner);
contact.setAvatar(avatar);
getAvatarService().clear(contact);
updateConversationUi();
updateRosterUi();
}
if (callback != null) {
callback.success(avatar);
}
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": successfully fetched pep avatar for " + avatar.owner);
return;
}
} else {
Log.d(Config.LOGTAG, ERROR + "(parsing error)");
}
} else {
Element error = result.findChild("error");
if (error == null) {
Log.d(Config.LOGTAG, ERROR + "(server error)");
} else {
Log.d(Config.LOGTAG, ERROR + error.toString());
}
}
if (callback != null) {
callback.error(0, null);
}
}
});
}
Aggregations