use of eu.siacs.conversations.xmpp.stanzas.IqPacket in project Conversations by siacs.
the class XmppConnectionService method sendUnblockRequest.
public void sendUnblockRequest(final Blockable blockable) {
if (blockable != null && blockable.getJid() != null) {
final Jid jid = blockable.getBlockedJid();
this.sendIqPacket(blockable.getAccount(), getIqGenerator().generateSetUnblockRequest(jid), new OnIqPacketReceived() {
@Override
public void onIqPacketReceived(final Account account, final IqPacket packet) {
if (packet.getType() == IqPacket.TYPE.RESULT) {
account.getBlocklist().remove(jid);
updateBlocklistUi(OnUpdateBlocklist.Status.UNBLOCKED);
}
}
});
}
}
use of eu.siacs.conversations.xmpp.stanzas.IqPacket in project Conversations by siacs.
the class HttpUploadConnection method init.
public void init(Message message, boolean delay) {
this.message = message;
this.account = message.getConversation().getAccount();
this.file = mXmppConnectionService.getFileBackend().getFile(message, false);
this.mime = this.file.getMimeType();
this.delayed = delay;
if (Config.ENCRYPT_ON_HTTP_UPLOADED || message.getEncryption() == Message.ENCRYPTION_AXOLOTL || message.getEncryption() == Message.ENCRYPTION_OTR) {
this.key = new byte[48];
mXmppConnectionService.getRNG().nextBytes(this.key);
this.file.setKeyAndIv(this.key);
}
Pair<InputStream, Integer> pair;
try {
pair = AbstractConnectionManager.createInputStream(file, true);
} catch (FileNotFoundException e) {
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": could not find file to upload - " + e.getMessage());
fail(e.getMessage());
return;
}
this.file.setExpectedSize(pair.second);
this.mFileInputStream = pair.first;
Jid host = account.getXmppConnection().findDiscoItemByFeature(Namespace.HTTP_UPLOAD);
IqPacket request = mXmppConnectionService.getIqGenerator().requestHttpUploadSlot(host, file, mime);
mXmppConnectionService.sendIqPacket(account, request, new OnIqPacketReceived() {
@Override
public void onIqPacketReceived(Account account, IqPacket packet) {
if (packet.getType() == IqPacket.TYPE.RESULT) {
Element slot = packet.findChild("slot", Namespace.HTTP_UPLOAD);
if (slot != null) {
try {
mGetUrl = new URL(slot.findChildContent("get"));
mPutUrl = new URL(slot.findChildContent("put"));
if (!canceled) {
new Thread(new FileUploader()).start();
}
return;
} catch (MalformedURLException e) {
//fall through
}
}
}
Log.d(Config.LOGTAG, account.getJid().toString() + ": invalid response to slot request " + packet);
fail(IqParser.extractErrorMessage(packet));
}
});
message.setTransferable(this);
mXmppConnectionService.markMessage(message, Message.STATUS_UNSEND);
}
use of eu.siacs.conversations.xmpp.stanzas.IqPacket in project Conversations by siacs.
the class IqGenerator method entityTimeResponse.
public IqPacket entityTimeResponse(IqPacket request) {
final IqPacket packet = request.generateResponse(IqPacket.TYPE.RESULT);
Element time = packet.addChild("time", "urn:xmpp:time");
final long now = System.currentTimeMillis();
time.addChild("utc").setContent(getTimestamp(now));
TimeZone ourTimezone = TimeZone.getDefault();
long offsetSeconds = ourTimezone.getOffset(now) / 1000;
long offsetMinutes = Math.abs((offsetSeconds % 3600) / 60);
long offsetHours = offsetSeconds / 3600;
String hours;
if (offsetHours < 0) {
hours = String.format(Locale.US, "%03d", offsetHours);
} else {
hours = String.format(Locale.US, "%02d", offsetHours);
}
String minutes = String.format(Locale.US, "%02d", offsetMinutes);
time.addChild("tzo").setContent(hours + ":" + minutes);
return packet;
}
use of eu.siacs.conversations.xmpp.stanzas.IqPacket in project Conversations by siacs.
the class IqGenerator method retrieveVcardAvatar.
public IqPacket retrieveVcardAvatar(final Avatar avatar) {
final IqPacket packet = new IqPacket(IqPacket.TYPE.GET);
packet.setTo(avatar.owner);
packet.addChild("vCard", "vcard-temp");
return packet;
}
use of eu.siacs.conversations.xmpp.stanzas.IqPacket in project Conversations by siacs.
the class IqGenerator method versionResponse.
public IqPacket versionResponse(final IqPacket request) {
final IqPacket packet = request.generateResponse(IqPacket.TYPE.RESULT);
Element query = packet.query("jabber:iq:version");
query.addChild("name").setContent(mXmppConnectionService.getString(R.string.app_name));
query.addChild("version").setContent(getIdentityVersion());
if ("chromium".equals(android.os.Build.BRAND)) {
query.addChild("os").setContent("Chrome OS");
} else {
query.addChild("os").setContent("Android");
}
return packet;
}
Aggregations