use of eu.siacs.conversations.xml.Element in project Conversations by siacs.
the class Content method ibbTransport.
public Element ibbTransport() {
Element transport = this.findChild("transport", "urn:xmpp:jingle:transports:ibb:1");
if (transport == null) {
transport = this.addChild("transport", "urn:xmpp:jingle:transports:ibb:1");
transport.setAttribute("sid", this.transportId);
}
return transport;
}
use of eu.siacs.conversations.xml.Element in project Conversations by siacs.
the class IqPacket method query.
public Element query(final String xmlns) {
final Element query = query();
query.setAttribute("xmlns", xmlns);
return query();
}
use of eu.siacs.conversations.xml.Element in project Conversations by siacs.
the class MessagePacket method getForwardedMessagePacket.
public Pair<MessagePacket, Long> getForwardedMessagePacket(String name, String namespace) {
Element wrapper = findChild(name, namespace);
if (wrapper == null) {
return null;
}
Element forwarded = wrapper.findChild("forwarded", "urn:xmpp:forward:0");
if (forwarded == null) {
return null;
}
MessagePacket packet = create(forwarded.findChild("message"));
if (packet == null) {
return null;
}
Long timestamp = AbstractParser.parseTimestamp(forwarded, null);
return new Pair(packet, timestamp);
}
use of eu.siacs.conversations.xml.Element in project Conversations by siacs.
the class PushManagementService method registerPushTokenOnServer.
public void registerPushTokenOnServer(final Account account) {
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": has push support");
retrieveGcmInstanceToken(new OnGcmInstanceTokenRetrieved() {
@Override
public void onGcmInstanceTokenRetrieved(String token) {
try {
final String deviceId = Settings.Secure.getString(mXmppConnectionService.getContentResolver(), Settings.Secure.ANDROID_ID);
IqPacket packet = mXmppConnectionService.getIqGenerator().pushTokenToAppServer(Jid.fromString(APP_SERVER), token, deviceId);
mXmppConnectionService.sendIqPacket(account, packet, new OnIqPacketReceived() {
@Override
public void onIqPacketReceived(Account account, IqPacket packet) {
Element command = packet.findChild("command", "http://jabber.org/protocol/commands");
if (packet.getType() == IqPacket.TYPE.RESULT && command != null) {
Element x = command.findChild("x", "jabber:x:data");
if (x != null) {
Data data = Data.parse(x);
try {
String node = data.getValue("node");
String secret = data.getValue("secret");
Jid jid = Jid.fromString(data.getValue("jid"));
if (node != null && secret != null) {
enablePushOnServer(account, jid, node, secret);
}
} catch (InvalidJidException e) {
e.printStackTrace();
}
}
} else {
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": invalid response from app server");
}
}
});
} catch (InvalidJidException ignored) {
}
}
});
}
use of eu.siacs.conversations.xml.Element in project Conversations by siacs.
the class XmppConnectionService method fetchAvatarVcard.
private void fetchAvatarVcard(final Account account, final Avatar avatar, final UiCallback<Avatar> callback) {
IqPacket packet = this.mIqGenerator.retrieveVcardAvatar(avatar);
this.sendIqPacket(account, packet, new OnIqPacketReceived() {
@Override
public void onIqPacketReceived(Account account, IqPacket packet) {
synchronized (mInProgressAvatarFetches) {
mInProgressAvatarFetches.remove(generateFetchKey(account, avatar));
}
if (packet.getType() == IqPacket.TYPE.RESULT) {
Element vCard = packet.findChild("vCard", "vcard-temp");
Element photo = vCard != null ? vCard.findChild("PHOTO") : null;
String image = photo != null ? photo.findChildContent("BINVAL") : null;
if (image != null) {
avatar.image = image;
if (getFileBackend().save(avatar)) {
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": successfully fetched vCard avatar for " + avatar.owner);
if (avatar.owner.isBareJid()) {
if (account.getJid().toBareJid().equals(avatar.owner) && account.getAvatar() == null) {
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": had no avatar. replacing with vcard");
account.setAvatar(avatar.getFilename());
databaseBackend.updateAccount(account);
getAvatarService().clear(account);
updateAccountUi();
} else {
Contact contact = account.getRoster().getContact(avatar.owner);
contact.setAvatar(avatar);
getAvatarService().clear(contact);
updateRosterUi();
}
updateConversationUi();
} else {
Conversation conversation = find(account, avatar.owner.toBareJid());
if (conversation != null && conversation.getMode() == Conversation.MODE_MULTI) {
MucOptions.User user = conversation.getMucOptions().findUserByFullJid(avatar.owner);
if (user != null) {
if (user.setAvatar(avatar)) {
getAvatarService().clear(user);
updateConversationUi();
updateMucRosterUi();
}
}
}
}
}
}
}
}
});
}
Aggregations