SPARK-2355: Use hasExtension()

This commit is contained in:
Sergey Ponomarev 2025-10-04 20:51:48 +03:00 committed by Guus der Kinderen
parent 91a421009a
commit efda43bf5d
6 changed files with 11 additions and 16 deletions

View File

@ -347,7 +347,7 @@ public class Workspace extends JPanel implements StanzaListener {
boolean isGroupChat = message.getType() == Message.Type.groupchat;
// Check if Conference invite. If so, do not handle here.
if (message.getExtension("x", "jabber:x:conference") != null) {
if (message.hasExtension("x", "jabber:x:conference")) {
return;
}

View File

@ -521,8 +521,7 @@ public class ChatRoomImpl extends ChatRoom {
}
// Do not Handle offline messages. Offline messages are handling by Workspace.
DelayInformation offlineInformation = message.getExtension("delay", "urn:xmpp:delay");
if (offlineInformation != null &&
if (message.hasExtension("delay", "urn:xmpp:delay") &&
(message.getType() == Message.Type.chat ||
message.getType() == Message.Type.normal)) {
return;

View File

@ -391,8 +391,7 @@ public class StatusBar extends JPanel implements VCardListener {
}
if ((presence.getMode() == currentPresence.getMode()) && (presence.getType() == currentPresence.getType()) && (presence.getStatus().equals(currentPresence.getStatus()))) {
ExtensionElement pe = presence.getExtension("x", "vcard-temp:x:update");
if (pe != null) {
if (presence.hasExtension("x", "vcard-temp:x:update")) {
// Update VCard
loadVCard();
}

View File

@ -203,8 +203,7 @@ public class BroadcastPlugin extends SparkTabHandler implements Plugin, StanzaLi
final Message message = (Message) stanza;
// Do not handle errors or offline messages
final DelayInformation offlineInformation = message.getExtension("delay", "urn:xmpp:delay");
if (offlineInformation != null || message.getError() != null) {
if (message.hasExtension("delay", "urn:xmpp:delay") || message.getError() != null) {
return;
}
@ -337,8 +336,7 @@ public class BroadcastPlugin extends SparkTabHandler implements Plugin, StanzaLi
SparkManager.getChatManager().fireGlobalMessageReceievedListeners(chatRoom, message);
DelayInformation inf = message.getExtension("delay", "urn:xmpp:delay");
if (inf == null) {
if (message.hasExtension("delay", "urn:xmpp:delay")) {
SoundPreference soundPreference = (SoundPreference) SparkManager.getPreferenceManager().getPreference(new SoundPreference().getNamespace());
SoundPreferences preferences = soundPreference.getPreferences();
if (preferences.isPlayIncomingSound()) {

View File

@ -73,10 +73,8 @@ public class SoundPlugin implements Plugin, MessageListener, ChatRoomListener {
@Override
public void messageReceived(ChatRoom room, Message message) {
// Do not play sounds on history updates.
DelayInformation inf = message.getExtension("delay", "urn:xmpp:delay");
if (inf != null) {
if (message.hasExtension("delay", "urn:xmpp:delay")) {
return;
}

View File

@ -270,10 +270,11 @@ public class WorkgroupManager {
public void handleContactItem(final ContactItem contactItem) {
Presence presence = contactItem.getPresence();
ExtensionElement workgroup = presence.getExtension("workgroup", "http://jivesoftware.com/protocol/workgroup");
ExtensionElement notifyQueue = presence.getExtension("notify-queue", "http://jabber.org/protocol/workgroup");
// TODO It probably can be WorkgroupInformation.class but it has namespace http://jabber.org/protocol/workgroup
boolean hasWorkgroup = presence.hasExtension("workgroup", "http://jivesoftware.com/protocol/workgroup");
boolean hasNotifyQueue = presence.hasExtension("notify-queue", "http://jabber.org/protocol/workgroup");
if (workgroup == null && notifyQueue == null) {
if (!hasWorkgroup && !hasNotifyQueue) {
return;
}
@ -403,7 +404,7 @@ public class WorkgroupManager {
public boolean handleInvitation(final XMPPConnection conn, final MultiUserChat room, final EntityBareJid inviter, final String reason, final String password, final Message message) {
invites.add(inviter);
if (message.getExtension("workgroup", "http://jabber.org/protocol/workgroup") != null) {
if (message.hasExtension("workgroup", "http://jabber.org/protocol/workgroup")) {
Localpart workgroupName = inviter.getLocalpart();
GroupChatRoom groupChatRoom = ConferenceUtils.enterRoomOnSameThread(workgroupName, room.getRoom(), null, password);