From 38c612d35d6c7528e1382905414be01074b51708 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Mon, 16 Jan 2023 09:57:49 +0100 Subject: [PATCH] make name+namespace assignment in xmpp less error prone --- .../android/database/entity/DiscoEntity.java | 3 +- .../database/entity/DiscoItemEntity.java | 45 +++++++++++++++ .../android/xmpp/Extensions.java | 29 +++++++--- .../conversations/android/xmpp/Managers.java | 2 + .../android/xmpp/XmppConnection.java | 21 +++++++ .../android/xmpp/manager/DiscoManager.java | 57 +++++++++++++++++++ .../android/xmpp/model/Extension.java | 10 +++- .../android/xmpp/model/blocking/Block.java | 3 +- .../xmpp/model/blocking/Blocklist.java | 3 +- .../android/xmpp/model/blocking/Item.java | 3 +- .../android/xmpp/model/blocking/Unblock.java | 3 +- .../xmpp/model/blocking/package-info.java | 5 ++ .../android/xmpp/model/data/Data.java | 11 ++++ .../android/xmpp/model/data/Field.java | 11 ++++ .../android/xmpp/model/data/package-info.java | 5 ++ .../xmpp/model/disco/info/Feature.java | 11 ++++ .../xmpp/model/disco/info/Identity.java | 11 ++++ .../xmpp/model/disco/info/InfoQuery.java | 12 ++++ .../xmpp/model/disco/info/package-info.java | 5 ++ .../android/xmpp/model/disco/items/Item.java | 20 +++++++ .../xmpp/model/disco/items/ItemsQuery.java | 11 ++++ .../xmpp/model/disco/items/package-info.java | 5 ++ .../android/xmpp/model/roster/Item.java | 3 +- .../android/xmpp/model/roster/Query.java | 2 +- 24 files changed, 268 insertions(+), 23 deletions(-) create mode 100644 src/main/java/im/conversations/android/database/entity/DiscoItemEntity.java create mode 100644 src/main/java/im/conversations/android/xmpp/manager/DiscoManager.java create mode 100644 src/main/java/im/conversations/android/xmpp/model/blocking/package-info.java create mode 100644 src/main/java/im/conversations/android/xmpp/model/data/Data.java create mode 100644 src/main/java/im/conversations/android/xmpp/model/data/Field.java create mode 100644 src/main/java/im/conversations/android/xmpp/model/data/package-info.java create mode 100644 src/main/java/im/conversations/android/xmpp/model/disco/info/Feature.java create mode 100644 src/main/java/im/conversations/android/xmpp/model/disco/info/Identity.java create mode 100644 src/main/java/im/conversations/android/xmpp/model/disco/info/InfoQuery.java create mode 100644 src/main/java/im/conversations/android/xmpp/model/disco/info/package-info.java create mode 100644 src/main/java/im/conversations/android/xmpp/model/disco/items/Item.java create mode 100644 src/main/java/im/conversations/android/xmpp/model/disco/items/ItemsQuery.java create mode 100644 src/main/java/im/conversations/android/xmpp/model/disco/items/package-info.java diff --git a/src/main/java/im/conversations/android/database/entity/DiscoEntity.java b/src/main/java/im/conversations/android/database/entity/DiscoEntity.java index 5a597a9c9..13be54d76 100644 --- a/src/main/java/im/conversations/android/database/entity/DiscoEntity.java +++ b/src/main/java/im/conversations/android/database/entity/DiscoEntity.java @@ -20,8 +20,9 @@ public class DiscoEntity { @PrimaryKey(autoGenerate = true) public Long id; + @NonNull Long accountId; + public byte[] capsHash; public byte[] caps2Hash; public String caps2Algorithm; - @NonNull Long accountId; } diff --git a/src/main/java/im/conversations/android/database/entity/DiscoItemEntity.java b/src/main/java/im/conversations/android/database/entity/DiscoItemEntity.java new file mode 100644 index 000000000..5d386c1cf --- /dev/null +++ b/src/main/java/im/conversations/android/database/entity/DiscoItemEntity.java @@ -0,0 +1,45 @@ +package im.conversations.android.database.entity; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.room.Entity; +import androidx.room.ForeignKey; +import androidx.room.Index; +import androidx.room.PrimaryKey; +import eu.siacs.conversations.xmpp.Jid; + +@Entity( + tableName = "disco_item", + foreignKeys = { + @ForeignKey( + entity = AccountEntity.class, + parentColumns = {"id"}, + childColumns = {"accountId"}, + onDelete = ForeignKey.CASCADE), + @ForeignKey( + entity = DiscoEntity.class, + parentColumns = {"id"}, + childColumns = {"discoId"}, + onDelete = ForeignKey.CASCADE) + }, + indices = { + @Index( + value = {"accountId", "address"}, + unique = true), + @Index( + value = {"accountId", "parent"}, + unique = false) + }) +public class DiscoItemEntity { + + @PrimaryKey(autoGenerate = true) + public Long id; + + @NonNull Long accountId; + + @NonNull Jid address; + + @Nullable public Jid parent; + + public Long discoId; +} diff --git a/src/main/java/im/conversations/android/xmpp/Extensions.java b/src/main/java/im/conversations/android/xmpp/Extensions.java index 80244bc84..184291976 100644 --- a/src/main/java/im/conversations/android/xmpp/Extensions.java +++ b/src/main/java/im/conversations/android/xmpp/Extensions.java @@ -2,7 +2,8 @@ package im.conversations.android.xmpp; import com.google.common.base.Objects; import com.google.common.base.Strings; -import com.google.common.collect.ImmutableMap; +import com.google.common.collect.BiMap; +import com.google.common.collect.ImmutableBiMap; import eu.siacs.conversations.xml.Element; import im.conversations.android.annotation.XmlElement; import im.conversations.android.annotation.XmlPackage; @@ -12,31 +13,37 @@ import java.lang.reflect.InvocationTargetException; import java.util.Arrays; import java.util.List; import java.util.Locale; -import java.util.Map; public final class Extensions { // TODO these two maps can easily be generated by an annotation processor private static final List> ELEMENTS = Arrays.asList( - im.conversations.android.xmpp.model.roster.Query.class, - im.conversations.android.xmpp.model.roster.Item.class, im.conversations.android.xmpp.model.blocking.Item.class, im.conversations.android.xmpp.model.blocking.Block.class, im.conversations.android.xmpp.model.blocking.Blocklist.class, - im.conversations.android.xmpp.model.blocking.Unblock.class); + im.conversations.android.xmpp.model.blocking.Unblock.class, + im.conversations.android.xmpp.model.data.Data.class, + im.conversations.android.xmpp.model.data.Field.class, + im.conversations.android.xmpp.model.disco.info.Feature.class, + im.conversations.android.xmpp.model.disco.info.Identity.class, + im.conversations.android.xmpp.model.disco.info.InfoQuery.class, + im.conversations.android.xmpp.model.disco.items.Item.class, + im.conversations.android.xmpp.model.disco.items.ItemsQuery.class, + im.conversations.android.xmpp.model.roster.Query.class, + im.conversations.android.xmpp.model.roster.Item.class); - private static final Map> EXTENSION_CLASS_MAP; + private static final BiMap> EXTENSION_CLASS_MAP; static { - final var builder = new ImmutableMap.Builder>(); + final var builder = new ImmutableBiMap.Builder>(); for (final Class clazz : ELEMENTS) { - builder.put(id(clazz), clazz); + builder.put(of(clazz), clazz); } EXTENSION_CLASS_MAP = builder.build(); } - private static Id id(final Class clazz) { + private static Id of(final Class clazz) { final XmlElement xmlElement = clazz.getAnnotation(XmlElement.class); final Package clazzPackage = clazz.getPackage(); final XmlPackage xmlPackage = @@ -92,6 +99,10 @@ public final class Extensions { return EXTENSION_CLASS_MAP.get(new Id(name, namespace)); } + public static Id id(final Class clazz) { + return EXTENSION_CLASS_MAP.inverse().get(clazz); + } + private Extensions() {} public static class Id { diff --git a/src/main/java/im/conversations/android/xmpp/Managers.java b/src/main/java/im/conversations/android/xmpp/Managers.java index 6a2c64765..428349567 100644 --- a/src/main/java/im/conversations/android/xmpp/Managers.java +++ b/src/main/java/im/conversations/android/xmpp/Managers.java @@ -6,6 +6,7 @@ import com.google.common.collect.ImmutableClassToInstanceMap; import im.conversations.android.xmpp.manager.AbstractManager; import im.conversations.android.xmpp.manager.BlockingManager; import im.conversations.android.xmpp.manager.BookmarkManager; +import im.conversations.android.xmpp.manager.DiscoManager; import im.conversations.android.xmpp.manager.RosterManager; public final class Managers { @@ -17,6 +18,7 @@ public final class Managers { return new ImmutableClassToInstanceMap.Builder() .put(BlockingManager.class, new BlockingManager(context, connection)) .put(BookmarkManager.class, new BookmarkManager(context, connection)) + .put(DiscoManager.class, new DiscoManager(context, connection)) .put(RosterManager.class, new RosterManager(context, connection)) .build(); } diff --git a/src/main/java/im/conversations/android/xmpp/XmppConnection.java b/src/main/java/im/conversations/android/xmpp/XmppConnection.java index 27f5858bb..f45ec3641 100644 --- a/src/main/java/im/conversations/android/xmpp/XmppConnection.java +++ b/src/main/java/im/conversations/android/xmpp/XmppConnection.java @@ -17,6 +17,8 @@ import androidx.annotation.Nullable; import com.google.common.base.Optional; import com.google.common.base.Strings; import com.google.common.collect.ClassToInstanceMap; +import com.google.common.util.concurrent.ListenableFuture; +import com.google.common.util.concurrent.SettableFuture; import eu.siacs.conversations.Config; import eu.siacs.conversations.R; import eu.siacs.conversations.crypto.XmppDomainVerifier; @@ -97,6 +99,7 @@ import java.util.List; import java.util.Map.Entry; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.BiFunction; @@ -2235,6 +2238,24 @@ public class XmppConnection implements Runnable { return String.format("%s.%s", context.getString(R.string.app_name), postfixId); } + public ListenableFuture sendIqPacket(final IqPacket packet) { + final SettableFuture future = SettableFuture.create(); + sendIqPacket( + packet, + result -> { + final var type = result.getType(); + if (type == IqPacket.TYPE.RESULT) { + future.set(result); + } else if (type == IqPacket.TYPE.TIMEOUT) { + future.setException(new TimeoutException()); + } else { + // TODO some sort of IqErrorException + future.setException(new IOException()); + } + }); + return future; + } + public String sendIqPacket(final IqPacket packet, final Consumer callback) { packet.setFrom(account.address); return this.sendUnmodifiedIqPacket(packet, callback, false); diff --git a/src/main/java/im/conversations/android/xmpp/manager/DiscoManager.java b/src/main/java/im/conversations/android/xmpp/manager/DiscoManager.java new file mode 100644 index 000000000..ec293f696 --- /dev/null +++ b/src/main/java/im/conversations/android/xmpp/manager/DiscoManager.java @@ -0,0 +1,57 @@ +package im.conversations.android.xmpp.manager; + +import android.content.Context; +import com.google.common.util.concurrent.Futures; +import com.google.common.util.concurrent.ListenableFuture; +import com.google.common.util.concurrent.MoreExecutors; +import eu.siacs.conversations.xmpp.Jid; +import eu.siacs.conversations.xmpp.stanzas.IqPacket; +import im.conversations.android.xmpp.XmppConnection; +import im.conversations.android.xmpp.model.disco.info.InfoQuery; +import im.conversations.android.xmpp.model.disco.items.Item; +import im.conversations.android.xmpp.model.disco.items.ItemsQuery; +import java.util.Collection; + +public class DiscoManager extends AbstractManager { + + public DiscoManager(Context context, XmppConnection connection) { + super(context, connection); + } + + public ListenableFuture info(final Jid entity) { + final var iqPacket = new IqPacket(IqPacket.TYPE.GET); + iqPacket.setTo(entity); + iqPacket.addChild(new InfoQuery()); + final var future = connection.sendIqPacket(iqPacket); + return Futures.transform( + future, + iqResult -> { + final var infoQuery = iqResult.getExtension(InfoQuery.class); + if (infoQuery == null) { + throw new IllegalStateException(); + } + // TODO store query + return infoQuery; + }, + MoreExecutors.directExecutor()); + } + + public ListenableFuture> items(final Jid entity) { + final var iqPacket = new IqPacket(IqPacket.TYPE.GET); + iqPacket.setTo(entity); + iqPacket.addChild(new ItemsQuery()); + final var future = connection.sendIqPacket(iqPacket); + return Futures.transform( + future, + iqResult -> { + final var itemsQuery = iqResult.getExtension(ItemsQuery.class); + if (itemsQuery == null) { + throw new IllegalStateException(); + } + // TODO store items + final var items = itemsQuery.getExtensions(Item.class); + return items; + }, + MoreExecutors.directExecutor()); + } +} diff --git a/src/main/java/im/conversations/android/xmpp/model/Extension.java b/src/main/java/im/conversations/android/xmpp/model/Extension.java index 2912d6960..f0ed97339 100644 --- a/src/main/java/im/conversations/android/xmpp/model/Extension.java +++ b/src/main/java/im/conversations/android/xmpp/model/Extension.java @@ -1,9 +1,15 @@ package im.conversations.android.xmpp.model; import eu.siacs.conversations.xml.Element; +import im.conversations.android.xmpp.Extensions; public class Extension extends Element { - public Extension(String name, String xmlns) { - super(name, xmlns); + + private Extension(final Extensions.Id id) { + super(id.name, id.namespace); + } + + public Extension(final Class clazz) { + this(Extensions.id(clazz)); } } diff --git a/src/main/java/im/conversations/android/xmpp/model/blocking/Block.java b/src/main/java/im/conversations/android/xmpp/model/blocking/Block.java index 9843a8f95..6f5d00b3e 100644 --- a/src/main/java/im/conversations/android/xmpp/model/blocking/Block.java +++ b/src/main/java/im/conversations/android/xmpp/model/blocking/Block.java @@ -1,6 +1,5 @@ package im.conversations.android.xmpp.model.blocking; -import eu.siacs.conversations.xml.Namespace; import im.conversations.android.annotation.XmlElement; import im.conversations.android.xmpp.model.Extension; @@ -8,6 +7,6 @@ import im.conversations.android.xmpp.model.Extension; public class Block extends Extension { public Block() { - super("block", Namespace.BLOCKING); + super(Block.class); } } diff --git a/src/main/java/im/conversations/android/xmpp/model/blocking/Blocklist.java b/src/main/java/im/conversations/android/xmpp/model/blocking/Blocklist.java index dd8591a2c..a56662d77 100644 --- a/src/main/java/im/conversations/android/xmpp/model/blocking/Blocklist.java +++ b/src/main/java/im/conversations/android/xmpp/model/blocking/Blocklist.java @@ -1,12 +1,11 @@ package im.conversations.android.xmpp.model.blocking; -import eu.siacs.conversations.xml.Namespace; import im.conversations.android.annotation.XmlElement; import im.conversations.android.xmpp.model.Extension; @XmlElement public class Blocklist extends Extension { public Blocklist() { - super("blocklist", Namespace.BLOCKING); + super(Blocklist.class); } } diff --git a/src/main/java/im/conversations/android/xmpp/model/blocking/Item.java b/src/main/java/im/conversations/android/xmpp/model/blocking/Item.java index 97e2f21d5..647b0ae99 100644 --- a/src/main/java/im/conversations/android/xmpp/model/blocking/Item.java +++ b/src/main/java/im/conversations/android/xmpp/model/blocking/Item.java @@ -1,6 +1,5 @@ package im.conversations.android.xmpp.model.blocking; -import eu.siacs.conversations.xml.Namespace; import eu.siacs.conversations.xmpp.Jid; import im.conversations.android.annotation.XmlElement; import im.conversations.android.xmpp.model.Extension; @@ -9,7 +8,7 @@ import im.conversations.android.xmpp.model.Extension; public class Item extends Extension { public Item() { - super("item", Namespace.BLOCKING); + super(Item.class); } public Jid getJid() { diff --git a/src/main/java/im/conversations/android/xmpp/model/blocking/Unblock.java b/src/main/java/im/conversations/android/xmpp/model/blocking/Unblock.java index ee5b22bc3..90cec110c 100644 --- a/src/main/java/im/conversations/android/xmpp/model/blocking/Unblock.java +++ b/src/main/java/im/conversations/android/xmpp/model/blocking/Unblock.java @@ -1,6 +1,5 @@ package im.conversations.android.xmpp.model.blocking; -import eu.siacs.conversations.xml.Namespace; import im.conversations.android.annotation.XmlElement; import im.conversations.android.xmpp.model.Extension; @@ -8,6 +7,6 @@ import im.conversations.android.xmpp.model.Extension; public class Unblock extends Extension { public Unblock() { - super("unblock", Namespace.BLOCKING); + super(Unblock.class); } } diff --git a/src/main/java/im/conversations/android/xmpp/model/blocking/package-info.java b/src/main/java/im/conversations/android/xmpp/model/blocking/package-info.java new file mode 100644 index 000000000..610512fe2 --- /dev/null +++ b/src/main/java/im/conversations/android/xmpp/model/blocking/package-info.java @@ -0,0 +1,5 @@ +@XmlPackage(namespace = Namespace.BLOCKING) +package im.conversations.android.xmpp.model.blocking; + +import eu.siacs.conversations.xml.Namespace; +import im.conversations.android.annotation.XmlPackage; diff --git a/src/main/java/im/conversations/android/xmpp/model/data/Data.java b/src/main/java/im/conversations/android/xmpp/model/data/Data.java new file mode 100644 index 000000000..2d72d04f4 --- /dev/null +++ b/src/main/java/im/conversations/android/xmpp/model/data/Data.java @@ -0,0 +1,11 @@ +package im.conversations.android.xmpp.model.data; + +import im.conversations.android.annotation.XmlElement; +import im.conversations.android.xmpp.model.Extension; + +@XmlElement(name = "x") +public class Data extends Extension { + public Data() { + super(Data.class); + } +} diff --git a/src/main/java/im/conversations/android/xmpp/model/data/Field.java b/src/main/java/im/conversations/android/xmpp/model/data/Field.java new file mode 100644 index 000000000..14a11cec5 --- /dev/null +++ b/src/main/java/im/conversations/android/xmpp/model/data/Field.java @@ -0,0 +1,11 @@ +package im.conversations.android.xmpp.model.data; + +import im.conversations.android.annotation.XmlElement; +import im.conversations.android.xmpp.model.Extension; + +@XmlElement +public class Field extends Extension { + public Field() { + super(Field.class); + } +} diff --git a/src/main/java/im/conversations/android/xmpp/model/data/package-info.java b/src/main/java/im/conversations/android/xmpp/model/data/package-info.java new file mode 100644 index 000000000..fcc0e1f79 --- /dev/null +++ b/src/main/java/im/conversations/android/xmpp/model/data/package-info.java @@ -0,0 +1,5 @@ +@XmlPackage(namespace = Namespace.DATA) +package im.conversations.android.xmpp.model.data; + +import eu.siacs.conversations.xml.Namespace; +import im.conversations.android.annotation.XmlPackage; diff --git a/src/main/java/im/conversations/android/xmpp/model/disco/info/Feature.java b/src/main/java/im/conversations/android/xmpp/model/disco/info/Feature.java new file mode 100644 index 000000000..1016b99ac --- /dev/null +++ b/src/main/java/im/conversations/android/xmpp/model/disco/info/Feature.java @@ -0,0 +1,11 @@ +package im.conversations.android.xmpp.model.disco.info; + +import im.conversations.android.annotation.XmlElement; +import im.conversations.android.xmpp.model.Extension; + +@XmlElement +public class Feature extends Extension { + public Feature() { + super(Feature.class); + } +} diff --git a/src/main/java/im/conversations/android/xmpp/model/disco/info/Identity.java b/src/main/java/im/conversations/android/xmpp/model/disco/info/Identity.java new file mode 100644 index 000000000..cbacdf26a --- /dev/null +++ b/src/main/java/im/conversations/android/xmpp/model/disco/info/Identity.java @@ -0,0 +1,11 @@ +package im.conversations.android.xmpp.model.disco.info; + +import im.conversations.android.annotation.XmlElement; +import im.conversations.android.xmpp.model.Extension; + +@XmlElement +public class Identity extends Extension { + public Identity() { + super(Identity.class); + } +} diff --git a/src/main/java/im/conversations/android/xmpp/model/disco/info/InfoQuery.java b/src/main/java/im/conversations/android/xmpp/model/disco/info/InfoQuery.java new file mode 100644 index 000000000..62f4d8fb2 --- /dev/null +++ b/src/main/java/im/conversations/android/xmpp/model/disco/info/InfoQuery.java @@ -0,0 +1,12 @@ +package im.conversations.android.xmpp.model.disco.info; + +import im.conversations.android.annotation.XmlElement; +import im.conversations.android.xmpp.model.Extension; + +@XmlElement(name = "query") +public class InfoQuery extends Extension { + + public InfoQuery() { + super(InfoQuery.class); + } +} diff --git a/src/main/java/im/conversations/android/xmpp/model/disco/info/package-info.java b/src/main/java/im/conversations/android/xmpp/model/disco/info/package-info.java new file mode 100644 index 000000000..60eb24a59 --- /dev/null +++ b/src/main/java/im/conversations/android/xmpp/model/disco/info/package-info.java @@ -0,0 +1,5 @@ +@XmlPackage(namespace = Namespace.DISCO_INFO) +package im.conversations.android.xmpp.model.disco.info; + +import eu.siacs.conversations.xml.Namespace; +import im.conversations.android.annotation.XmlPackage; diff --git a/src/main/java/im/conversations/android/xmpp/model/disco/items/Item.java b/src/main/java/im/conversations/android/xmpp/model/disco/items/Item.java new file mode 100644 index 000000000..c99fd6c8a --- /dev/null +++ b/src/main/java/im/conversations/android/xmpp/model/disco/items/Item.java @@ -0,0 +1,20 @@ +package im.conversations.android.xmpp.model.disco.items; + +import eu.siacs.conversations.xmpp.Jid; +import im.conversations.android.annotation.XmlElement; +import im.conversations.android.xmpp.model.Extension; + +@XmlElement +public class Item extends Extension { + public Item() { + super(Item.class); + } + + public Jid getJid() { + return getAttributeAsJid("jid"); + } + + public String getNode() { + return this.getAttribute("node"); + } +} diff --git a/src/main/java/im/conversations/android/xmpp/model/disco/items/ItemsQuery.java b/src/main/java/im/conversations/android/xmpp/model/disco/items/ItemsQuery.java new file mode 100644 index 000000000..608743410 --- /dev/null +++ b/src/main/java/im/conversations/android/xmpp/model/disco/items/ItemsQuery.java @@ -0,0 +1,11 @@ +package im.conversations.android.xmpp.model.disco.items; + +import im.conversations.android.annotation.XmlElement; +import im.conversations.android.xmpp.model.Extension; + +@XmlElement(name = "query") +public class ItemsQuery extends Extension { + public ItemsQuery() { + super(ItemsQuery.class); + } +} diff --git a/src/main/java/im/conversations/android/xmpp/model/disco/items/package-info.java b/src/main/java/im/conversations/android/xmpp/model/disco/items/package-info.java new file mode 100644 index 000000000..a170e5cee --- /dev/null +++ b/src/main/java/im/conversations/android/xmpp/model/disco/items/package-info.java @@ -0,0 +1,5 @@ +@XmlPackage(namespace = Namespace.DISCO_ITEMS) +package im.conversations.android.xmpp.model.disco.items; + +import eu.siacs.conversations.xml.Namespace; +import im.conversations.android.annotation.XmlPackage; diff --git a/src/main/java/im/conversations/android/xmpp/model/roster/Item.java b/src/main/java/im/conversations/android/xmpp/model/roster/Item.java index 416ed3143..8edd96d19 100644 --- a/src/main/java/im/conversations/android/xmpp/model/roster/Item.java +++ b/src/main/java/im/conversations/android/xmpp/model/roster/Item.java @@ -1,6 +1,5 @@ package im.conversations.android.xmpp.model.roster; -import eu.siacs.conversations.xml.Namespace; import eu.siacs.conversations.xmpp.Jid; import im.conversations.android.annotation.XmlElement; import im.conversations.android.xmpp.model.Extension; @@ -15,7 +14,7 @@ public class Item extends Extension { Arrays.asList(Subscription.NONE, Subscription.TO, Subscription.FROM, Subscription.BOTH); public Item() { - super("item", Namespace.ROSTER); + super(Item.class); } public Jid getJid() { diff --git a/src/main/java/im/conversations/android/xmpp/model/roster/Query.java b/src/main/java/im/conversations/android/xmpp/model/roster/Query.java index 44886d6c7..616f6ae0b 100644 --- a/src/main/java/im/conversations/android/xmpp/model/roster/Query.java +++ b/src/main/java/im/conversations/android/xmpp/model/roster/Query.java @@ -8,7 +8,7 @@ import im.conversations.android.xmpp.model.Extension; public class Query extends Extension { public Query() { - super("query", Namespace.ROSTER); + super(Query.class); } public void setVersion(final String rosterVersion) {