use escaped jid in more places

This commit is contained in:
Daniel Gultsch 2020-05-15 18:44:55 +02:00
parent ef7d4fca86
commit 198a7db954
6 changed files with 12 additions and 26 deletions

View File

@ -28,7 +28,7 @@ public class Bookmark extends Element implements ListItem {
public Bookmark(final Account account, final Jid jid) { public Bookmark(final Account account, final Jid jid) {
super("conference"); super("conference");
this.jid = jid; this.jid = jid;
this.setAttribute("jid", jid.toString()); this.setAttribute("jid", jid);
this.account = account; this.account = account;
} }

View File

@ -334,7 +334,7 @@ public class IqGenerator extends AbstractGenerator {
public IqPacket generateSetBlockRequest(final Jid jid, boolean reportSpam) { public IqPacket generateSetBlockRequest(final Jid jid, boolean reportSpam) {
final IqPacket iq = new IqPacket(IqPacket.TYPE.SET); final IqPacket iq = new IqPacket(IqPacket.TYPE.SET);
final Element block = iq.addChild("block", Namespace.BLOCKING); final Element block = iq.addChild("block", Namespace.BLOCKING);
final Element item = block.addChild("item").setAttribute("jid", jid.toEscapedString()); final Element item = block.addChild("item").setAttribute("jid", jid);
if (reportSpam) { if (reportSpam) {
item.addChild("report", "urn:xmpp:reporting:0").addChild("spam"); item.addChild("report", "urn:xmpp:reporting:0").addChild("spam");
} }
@ -345,7 +345,7 @@ public class IqGenerator extends AbstractGenerator {
public IqPacket generateSetUnblockRequest(final Jid jid) { public IqPacket generateSetUnblockRequest(final Jid jid) {
final IqPacket iq = new IqPacket(IqPacket.TYPE.SET); final IqPacket iq = new IqPacket(IqPacket.TYPE.SET);
final Element block = iq.addChild("unblock", Namespace.BLOCKING); final Element block = iq.addChild("unblock", Namespace.BLOCKING);
block.addChild("item").setAttribute("jid", jid.toEscapedString()); block.addChild("item").setAttribute("jid", jid);
return iq; return iq;
} }
@ -372,7 +372,7 @@ public class IqGenerator extends AbstractGenerator {
Element query = packet.query("http://jabber.org/protocol/muc#admin"); Element query = packet.query("http://jabber.org/protocol/muc#admin");
for (Jid jid : jids) { for (Jid jid : jids) {
Element item = query.addChild("item"); Element item = query.addChild("item");
item.setAttribute("jid", jid.toEscapedString()); item.setAttribute("jid", jid);
item.setAttribute("affiliation", affiliation); item.setAttribute("affiliation", affiliation);
} }
return packet; return packet;
@ -489,7 +489,7 @@ public class IqGenerator extends AbstractGenerator {
public IqPacket enablePush(final Jid jid, final String node, final String secret) { public IqPacket enablePush(final Jid jid, final String node, final String secret) {
IqPacket packet = new IqPacket(IqPacket.TYPE.SET); IqPacket packet = new IqPacket(IqPacket.TYPE.SET);
Element enable = packet.addChild("enable", Namespace.PUSH); Element enable = packet.addChild("enable", Namespace.PUSH);
enable.setAttribute("jid", jid.toString()); enable.setAttribute("jid", jid);
enable.setAttribute("node", node); enable.setAttribute("node", node);
if (secret != null) { if (secret != null) {
Data data = new Data(); Data data = new Data();
@ -504,7 +504,7 @@ public class IqGenerator extends AbstractGenerator {
public IqPacket disablePush(final Jid jid, final String node) { public IqPacket disablePush(final Jid jid, final String node) {
IqPacket packet = new IqPacket(IqPacket.TYPE.SET); IqPacket packet = new IqPacket(IqPacket.TYPE.SET);
Element disable = packet.addChild("disable", Namespace.PUSH); Element disable = packet.addChild("disable", Namespace.PUSH);
disable.setAttribute("jid", jid.toEscapedString()); disable.setAttribute("jid", jid);
disable.setAttribute("node", node); disable.setAttribute("node", node);
return packet; return packet;
} }

View File

@ -198,7 +198,7 @@ public class MessageGenerator extends AbstractGenerator {
packet.setTo(contact); packet.setTo(contact);
packet.setFrom(conversation.getAccount().getJid()); packet.setFrom(conversation.getAccount().getJid());
Element x = packet.addChild("x", "jabber:x:conference"); Element x = packet.addChild("x", "jabber:x:conference");
x.setAttribute("jid", conversation.getJid().asBareJid().toString()); x.setAttribute("jid", conversation.getJid().asBareJid());
String password = conversation.getMucOptions().getPassword(); String password = conversation.getMucOptions().getPassword();
if (password != null) { if (password != null) {
x.setAttribute("password", password); x.setAttribute("password", password);

View File

@ -445,9 +445,9 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
final User self = mucOptions.getSelf(); final User self = mucOptions.getSelf();
String account; String account;
if (Config.DOMAIN_LOCK != null) { if (Config.DOMAIN_LOCK != null) {
account = mConversation.getAccount().getJid().getLocal(); account = mConversation.getAccount().getJid().getEscapedLocal();
} else { } else {
account = mConversation.getAccount().getJid().asBareJid().toString(); account = mConversation.getAccount().getJid().asBareJid().toEscapedString();
} }
setTitle(mucOptions.isPrivateAndNonAnonymous() ? R.string.action_muc_details : R.string.channel_details); setTitle(mucOptions.isPrivateAndNonAnonymous() ? R.string.action_muc_details : R.string.channel_details);
this.binding.editMucNameButton.setVisibility((self.getAffiliation().ranks(MucOptions.Affiliation.OWNER) || mucOptions.canChangeSubject()) ? View.VISIBLE : View.GONE); this.binding.editMucNameButton.setVisibility((self.getAffiliation().ranks(MucOptions.Affiliation.OWNER) || mucOptions.canChangeSubject()) ? View.VISIBLE : View.GONE);
@ -584,7 +584,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
@Override @Override
public void onAffiliationChangeFailed(Jid jid, int resId) { public void onAffiliationChangeFailed(Jid jid, int resId) {
displayToast(getString(resId, jid.asBareJid().toString())); displayToast(getString(resId, jid.asBareJid().toEscapedString()));
} }
@Override @Override

View File

@ -213,7 +213,7 @@ public class TrustKeysActivity extends OmemoActivity implements OnKeyStatusUpdat
showCameraToast(); showCameraToast();
} }
binding.ownKeysTitle.setText(mAccount.getJid().asBareJid().toString()); binding.ownKeysTitle.setText(mAccount.getJid().asBareJid().toEscapedString());
binding.ownKeysCard.setVisibility(hasOwnKeys ? View.VISIBLE : View.GONE); binding.ownKeysCard.setVisibility(hasOwnKeys ? View.VISIBLE : View.GONE);
binding.foreignKeys.setVisibility(hasForeignKeys ? View.VISIBLE : View.GONE); binding.foreignKeys.setVisibility(hasForeignKeys ? View.VISIBLE : View.GONE);
if (hasPendingKeyFetches()) { if (hasPendingKeyFetches()) {

View File

@ -10,15 +10,13 @@ import com.google.firebase.iid.InstanceIdResult;
import eu.siacs.conversations.Config; import eu.siacs.conversations.Config;
import eu.siacs.conversations.R; import eu.siacs.conversations.R;
import eu.siacs.conversations.entities.Account; import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.utils.PhoneHelper; import eu.siacs.conversations.utils.PhoneHelper;
import eu.siacs.conversations.xml.Element; import eu.siacs.conversations.xml.Element;
import eu.siacs.conversations.xml.Namespace; import eu.siacs.conversations.xml.Namespace;
import eu.siacs.conversations.xmpp.OnIqPacketReceived; import eu.siacs.conversations.xmpp.Jid;
import eu.siacs.conversations.xmpp.XmppConnection; import eu.siacs.conversations.xmpp.XmppConnection;
import eu.siacs.conversations.xmpp.forms.Data; import eu.siacs.conversations.xmpp.forms.Data;
import eu.siacs.conversations.xmpp.stanzas.IqPacket; import eu.siacs.conversations.xmpp.stanzas.IqPacket;
import rocks.xmpp.addr.Jid;
public class PushManagementService { public class PushManagementService {
@ -63,18 +61,6 @@ public class PushManagementService {
}); });
} }
public void unregisterChannel(final Account account, final String channel) {
final String androidId = PhoneHelper.getAndroidId(mXmppConnectionService);
final Jid appServer = getAppServer();
final IqPacket packet = mXmppConnectionService.getIqGenerator().unregisterChannelOnAppServer(appServer, androidId, channel);
mXmppConnectionService.sendIqPacket(account, packet, (a, response) -> {
if (response.getType() == IqPacket.TYPE.RESULT) {
Log.d(Config.LOGTAG,a.getJid().asBareJid()+": successfully unregistered channel");
} else if (response.getType() == IqPacket.TYPE.ERROR) {
Log.d(Config.LOGTAG, a.getJid().asBareJid()+": unable to unregister channel with hash "+channel);
}
});
}
private void enablePushOnServer(final Account account, final Jid appServer, final String node, final String secret) { private void enablePushOnServer(final Account account, final Jid appServer, final String node, final String secret) {
final IqPacket enable = mXmppConnectionService.getIqGenerator().enablePush(appServer, node, secret); final IqPacket enable = mXmppConnectionService.getIqGenerator().enablePush(appServer, node, secret);
mXmppConnectionService.sendIqPacket(account, enable, (a, p) -> { mXmppConnectionService.sendIqPacket(account, enable, (a, p) -> {