aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/thedevstack/conversationsplus/generator
diff options
context:
space:
mode:
authorsteckbrief <steckbrief@chefmail.de>2015-10-05 13:00:21 +0200
committersteckbrief <steckbrief@chefmail.de>2015-10-05 13:00:21 +0200
commitdf05605f033c20fdb9bdc34f359708b82754d32e (patch)
treef93328feb1799b082ca5f776152fbc3b92cbaff8 /src/main/java/de/thedevstack/conversationsplus/generator
parentdafb125a4f29226b6a3e8aa93de3d5163126c9ce (diff)
Fixes FS#70 - Introduction of a ConversationsPlusApplication to get global access to app information
Diffstat (limited to 'src/main/java/de/thedevstack/conversationsplus/generator')
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/generator/AbstractGenerator.java17
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/generator/IqGenerator.java8
2 files changed, 6 insertions, 19 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/generator/AbstractGenerator.java b/src/main/java/de/thedevstack/conversationsplus/generator/AbstractGenerator.java
index 6737f646..3f4bb839 100644
--- a/src/main/java/de/thedevstack/conversationsplus/generator/AbstractGenerator.java
+++ b/src/main/java/de/thedevstack/conversationsplus/generator/AbstractGenerator.java
@@ -12,9 +12,9 @@ import java.util.List;
import java.util.Locale;
import java.util.TimeZone;
+import de.thedevstack.conversationsplus.ConversationsPlusApplication;
import de.tzur.conversations.Settings;
import de.thedevstack.conversationsplus.services.XmppConnectionService;
-import de.thedevstack.conversationsplus.utils.PhoneHelper;
public abstract class AbstractGenerator {
private final String[] FEATURES = {
@@ -35,8 +35,6 @@ public abstract class AbstractGenerator {
"urn:xmpp:receipts"
};
private String mVersion = null;
- //FIXME use appname or similar!!!!!!!!!!!11elf
- public final String IDENTITY_NAME = "Conversations+";
public final String IDENTITY_TYPE = "phone";
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US);
@@ -47,20 +45,9 @@ public abstract class AbstractGenerator {
this.mXmppConnectionService = service;
}
- protected String getIdentityVersion() {
- if (mVersion == null) {
- this.mVersion = PhoneHelper.getVersionName(mXmppConnectionService);
- }
- return this.mVersion;
- }
-
- protected String getIdentityName() {
- return IDENTITY_NAME + " " + getIdentityVersion();
- }
-
public String getCapHash() {
StringBuilder s = new StringBuilder();
- s.append("client/" + IDENTITY_TYPE + "//" + getIdentityName() + "<");
+ s.append("client/" + IDENTITY_TYPE + "//" + ConversationsPlusApplication.getNameAndVersion() + "<");
MessageDigest md;
try {
md = MessageDigest.getInstance("SHA-1");
diff --git a/src/main/java/de/thedevstack/conversationsplus/generator/IqGenerator.java b/src/main/java/de/thedevstack/conversationsplus/generator/IqGenerator.java
index 8199e59c..3382ee23 100644
--- a/src/main/java/de/thedevstack/conversationsplus/generator/IqGenerator.java
+++ b/src/main/java/de/thedevstack/conversationsplus/generator/IqGenerator.java
@@ -4,12 +4,12 @@ package de.thedevstack.conversationsplus.generator;
import java.util.ArrayList;
import java.util.List;
+import de.thedevstack.conversationsplus.ConversationsPlusApplication;
import de.thedevstack.conversationsplus.entities.Account;
import de.thedevstack.conversationsplus.entities.Conversation;
import de.thedevstack.conversationsplus.entities.DownloadableFile;
import de.thedevstack.conversationsplus.services.MessageArchiveService;
import de.thedevstack.conversationsplus.services.XmppConnectionService;
-import de.thedevstack.conversationsplus.utils.PhoneHelper;
import de.thedevstack.conversationsplus.utils.Xmlns;
import de.thedevstack.conversationsplus.xml.Element;
import de.thedevstack.conversationsplus.xmpp.forms.Data;
@@ -33,7 +33,7 @@ public class IqGenerator extends AbstractGenerator {
final Element identity = query.addChild("identity");
identity.setAttribute("category", "client");
identity.setAttribute("type", IDENTITY_TYPE);
- identity.setAttribute("name", getIdentityName());
+ identity.setAttribute("name", ConversationsPlusApplication.getNameAndVersion());
for (final String feature : getFeatures()) {
query.addChild("feature").setAttribute("var", feature);
}
@@ -43,8 +43,8 @@ public class IqGenerator extends AbstractGenerator {
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(IDENTITY_NAME);
- query.addChild("version").setContent(getIdentityVersion());
+ query.addChild("name").setContent(ConversationsPlusApplication.getName());
+ query.addChild("version").setContent(ConversationsPlusApplication.getVersion());
return packet;
}