use of de.pixart.messenger.xml.Element in project Pix-Art-Messenger by kriztan.
the class IqGenerator method generateSetPassword.
public IqPacket generateSetPassword(final Account account, final String newPassword) {
final IqPacket packet = new IqPacket(IqPacket.TYPE.SET);
packet.setTo(account.getServer());
final Element query = packet.addChild("query", Namespace.REGISTER);
final Jid jid = account.getJid();
query.addChild("username").setContent(jid.getLocalpart());
query.addChild("password").setContent(newPassword);
return packet;
}
use of de.pixart.messenger.xml.Element in project Pix-Art-Messenger by kriztan.
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 de.pixart.messenger.xml.Element in project Pix-Art-Messenger by kriztan.
the class IqGenerator method generateSetBlockRequest.
public IqPacket generateSetBlockRequest(final Jid jid, boolean reportSpam) {
final IqPacket iq = new IqPacket(IqPacket.TYPE.SET);
final Element block = iq.addChild("block", Namespace.BLOCKING);
final Element item = block.addChild("item").setAttribute("jid", jid.toBareJid().toString());
if (reportSpam) {
item.addChild("report", "urn:xmpp:reporting:0").addChild("spam");
}
Log.d(Config.LOGTAG, iq.toString());
return iq;
}
use of de.pixart.messenger.xml.Element in project Pix-Art-Messenger by kriztan.
the class IqGenerator method queryMessageArchiveManagement.
public IqPacket queryMessageArchiveManagement(final MessageArchiveService.Query mam) {
final IqPacket packet = new IqPacket(IqPacket.TYPE.SET);
final Element query = packet.query(mam.isLegacy() ? Namespace.MAM_LEGACY : Namespace.MAM);
query.setAttribute("queryid", mam.getQueryId());
final Data data = new Data();
data.setFormType(mam.isLegacy() ? Namespace.MAM_LEGACY : Namespace.MAM);
if (mam.muc()) {
packet.setTo(mam.getWith());
} else if (mam.getWith() != null) {
data.put("with", mam.getWith().toString());
}
if (mam.getStart() != 0) {
data.put("start", getTimestamp(mam.getStart()));
}
data.put("end", getTimestamp(mam.getEnd()));
data.submit();
query.addChild(data);
Element set = query.addChild("set", "http://jabber.org/protocol/rsm");
if (mam.getPagingOrder() == MessageArchiveService.PagingOrder.REVERSE) {
set.addChild("before").setContent(mam.getReference());
} else if (mam.getReference() != null) {
set.addChild("after").setContent(mam.getReference());
}
set.addChild("max").setContent(String.valueOf(Config.PAGE_SIZE));
return packet;
}
use of de.pixart.messenger.xml.Element in project Pix-Art-Messenger by kriztan.
the class IqGenerator method requestHttpUploadSlot.
public IqPacket requestHttpUploadSlot(Jid host, DownloadableFile file, String mime) {
IqPacket packet = new IqPacket(IqPacket.TYPE.GET);
packet.setTo(host);
Element request = packet.addChild("request", Namespace.HTTP_UPLOAD);
request.setAttribute("filename", convertFilename(file.getName()));
request.setAttribute("size", file.getExpectedSize());
request.setAttribute("content-type", mime);
return packet;
}
Aggregations