Compare commits

...

16 Commits

Author SHA1 Message Date
transifex-integration[bot]
7a7ba03249 Translate spark_i18n.properties in zh_CN
100% translated source file: 'spark_i18n.properties'
on 'zh_CN'.
2025-10-09 16:18:57 +02:00
transifex-integration[bot]
a9490f339b Translate spark_i18n.properties in zh_CN
100% translated source file: 'spark_i18n.properties'
on 'zh_CN'.
2025-10-09 16:18:57 +02:00
transifex-integration[bot]
af42976cd8 Translate spark_i18n.properties in zh_CN
100% translated source file: 'spark_i18n.properties'
on 'zh_CN'.
2025-10-09 16:18:57 +02:00
transifex-integration[bot]
a51282fd21 Translate spark_i18n.properties in zh_CN
100% translated source file: 'spark_i18n.properties'
on 'zh_CN'.
2025-10-09 16:18:57 +02:00
transifex-integration[bot]
76859908f1 Translate spark_i18n.properties in zh_CN
100% translated source file: 'spark_i18n.properties'
on 'zh_CN'.
2025-10-09 16:18:57 +02:00
transifex-integration[bot]
bac85fc61d Translate spark_i18n.properties in zh_CN
100% translated source file: 'spark_i18n.properties'
on 'zh_CN'.
2025-10-09 16:18:57 +02:00
transifex-integration[bot]
c20f075c5d Translate spark_i18n.properties in zh_CN
100% translated source file: 'spark_i18n.properties'
on 'zh_CN'.
2025-10-09 16:18:57 +02:00
transifex-integration[bot]
804297cf71 Translate fastpath_i18n.properties in zh_CN
100% translated source file: 'fastpath_i18n.properties'
on 'zh_CN'.
2025-10-09 16:18:03 +02:00
Sergey Ponomarev
445389d988 LocalPreferences: getDeactivatedPlugins() simplify 2025-10-09 16:15:55 +02:00
Sergey Ponomarev
f1850b38ac LocalPreferences: remove exception handling: it will never occur 2025-10-09 16:15:55 +02:00
Sergey Ponomarev
1c312634b9 SPARK-2353: LocalPreferences: By default disable user join or leave notification 2025-10-09 16:15:55 +02:00
Sergey Ponomarev
443f6441fb SPARK-2349: fix NPE when adding yourself to contact list
In this case you'll get the presence from PresenceManager constants that doesn't have the from field.
This make a two NPEs.
2025-10-09 16:13:46 +02:00
Sergey Ponomarev
dc0f625f25 SPARK-2355: Use getExtension(Class) and hasExtension(Class) 2025-10-09 16:12:34 +02:00
Sergey Ponomarev
efda43bf5d SPARK-2355: Use hasExtension() 2025-10-09 16:12:34 +02:00
Sergey Ponomarev
91a421009a SPARK-2355: Add QNAME field to classes that implements ExtensionElement 2025-10-09 16:12:34 +02:00
Sergey Ponomarev
1e7860fe70 fileupload plugin: simplify description 2025-10-09 15:50:08 +02:00
36 changed files with 90 additions and 87 deletions

View File

@ -46,6 +46,7 @@ import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smackx.debugger.EnhancedDebuggerWindow;
import org.jivesoftware.smackx.delay.packet.DelayInformation;
import org.jivesoftware.smackx.jiveproperties.packet.JivePropertiesExtension;
import org.jivesoftware.smackx.muc.packet.GroupChatInvitation;
import org.jivesoftware.smackx.vcardtemp.packet.VCard;
import org.jivesoftware.spark.component.tabbedPane.SparkTabbedPane;
import org.jivesoftware.spark.filetransfer.SparkTransferManager;
@ -347,7 +348,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(GroupChatInvitation.class)) {
return;
}
@ -356,7 +357,7 @@ public class Workspace extends JPanel implements StanzaListener {
final boolean broadcast = extension != null && extension.getProperty( "broadcast" ) != null;
// Handle offline message.
DelayInformation offlineInformation = message.getExtension("delay", "urn:xmpp:delay");
DelayInformation offlineInformation = message.getExtension(DelayInformation.class);
if (offlineInformation != null && (Message.Type.chat == message.getType() ||
Message.Type.normal == message.getType())) {
handleOfflineMessage(message);

View File

@ -341,25 +341,19 @@ public class ContactItem extends JPanel {
* @param presence the presence.
*/
public void setPresence(Presence presence) {
this.presence = presence;
final VCardUpdateExtension extension = presence.getExtension("x", "vcard-temp:x:update");
final VCardUpdateExtension extension = presence.getExtension(VCardUpdateExtension.class);
// Handle vCard update packet.
if (extension != null) {
String hash = extension.getPhotoHash();
if (hash != null) {
this.hash = hash;
if (!hashExists(hash)) {
updateAvatar();
updateAvatarInSideIcon();
}
}
}
updatePresenceIcon(presence);
}

View File

@ -316,6 +316,9 @@ public class ContactList extends JPanel implements ActionListener,
// We ignore this.
return;
}
if (presence.getFrom() == null) {
return;
}
final Roster roster = Roster.getInstanceFor(SparkManager.getConnection());

View File

@ -247,7 +247,7 @@ public class TranscriptWindow extends ChatArea implements ContextMenuListener
String body = message.getBody();
// Verify the timestamp of this message. Determine if it is a 'live' message, or one that was sent earlier.
final DelayInformation inf = message.getExtension( "delay", "urn:xmpp:delay" );
final DelayInformation inf = message.getExtension(DelayInformation.class);
final ZonedDateTime sentDate;
final boolean isDelayed;
if ( inf != null )

View File

@ -194,7 +194,7 @@ public class GroupChatParticipantList extends JPanel {
// When joining a room, check if the current user is an owner/admin. If so, the UI should allow the current
// user to change settings of this MUC.
final MUCUser mucUserEx = p.getExtension(MUCUser.ELEMENT, MUCUser.NAMESPACE);
final MUCUser mucUserEx = p.getExtension(MUCUser.class);
if ( mucUserEx != null && mucUserEx.getStatus().contains(MUCUser.Status.create(110)) ) // 110 = Inform user that presence refers to itself
{
final MUCItem item = mucUserEx.getItem();
@ -270,7 +270,7 @@ public class GroupChatParticipantList extends JPanel {
MUCAffiliation affiliation = null;
MUCRole role = null;
final MUCUser extension = (MUCUser) presence.getExtension( MUCUser.NAMESPACE );
final MUCUser extension = presence.getExtension(MUCUser.class);
if ( extension != null && extension.getItem() != null )
{
affiliation = extension.getItem().getAffiliation();

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(DelayInformation.class) &&
(message.getType() == Message.Type.chat ||
message.getType() == Message.Type.normal)) {
return;
@ -602,7 +601,7 @@ public class ChatRoomImpl extends ChatRoom {
public void insertMessage(Message message) {
// Debug info
super.insertMessage(message);
MessageEvent messageEvent = message.getExtension("x", "jabber:x:event");
MessageEvent messageEvent = message.getExtension(MessageEvent.class);
if (messageEvent != null) {
checkEvents(message.getFrom(), message.getStanzaId(), messageEvent);
}

View File

@ -614,7 +614,7 @@ public class GroupChatRoom extends ChatRoom
lastMessage = message;
if ( message.getType() == Message.Type.groupchat )
{
final DelayInformation inf = message.getExtension( "delay", "urn:xmpp:delay" );
final DelayInformation inf = message.getExtension(DelayInformation.class);
final Date sentDate = inf != null ? inf.getStamp() : new Date();
// Do not accept Administrative messages.
@ -725,7 +725,7 @@ public class GroupChatRoom extends ChatRoom
final Resourcepart nickname = from.getResourcepart();
final MUCUser mucUser = stanza.getExtension( "x", "http://jabber.org/protocol/muc#user" );
final MUCUser mucUser = stanza.getExtension(MUCUser.class);
final Set<MUCUser.Status> status = new HashSet<>();
if ( mucUser != null )
{

View File

@ -76,6 +76,7 @@ import org.jivesoftware.sparkimpl.plugin.privacy.list.SparkPrivacyList;
import org.jivesoftware.sparkimpl.profile.VCardEditor;
import org.jivesoftware.sparkimpl.profile.VCardListener;
import org.jivesoftware.sparkimpl.profile.VCardManager;
import org.jivesoftware.sparkimpl.profile.ext.VCardUpdateExtension;
import org.jivesoftware.sparkimpl.settings.local.SettingsManager;
//TODO: I need to remove the presence logic from this class.
@ -391,8 +392,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(VCardUpdateExtension.class)) {
// Update VCard
loadVCard();
}

View File

@ -201,10 +201,8 @@ public class BroadcastPlugin extends SparkTabHandler implements Plugin, StanzaLi
SwingUtilities.invokeLater(() -> {
try {
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(DelayInformation.class) || message.getError() != null) {
return;
}
@ -337,8 +335,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(DelayInformation.class)) {
SoundPreference soundPreference = (SoundPreference) SparkManager.getPreferenceManager().getPreference(new SoundPreference().getNamespace());
SoundPreferences preferences = soundPreference.getPreferences();
if (preferences.isPlayIncomingSound()) {

View File

@ -41,6 +41,7 @@ import org.jivesoftware.sparkimpl.settings.local.LocalPreferences;
import org.jivesoftware.sparkimpl.settings.local.SettingsManager;
import org.jxmpp.jid.BareJid;
import org.jxmpp.jid.DomainBareJid;
import org.jxmpp.jid.Jid;
import javax.swing.*;
@ -285,7 +286,11 @@ public class GatewayPlugin implements Plugin, ContactItemHandler {
@Override
public boolean handlePresence(ContactItem item, Presence presence) {
if (presence.isAvailable()) {
DomainBareJid domain = presence.getFrom().asDomainBareJid();
Jid from = presence.getFrom();
if (from == null) {
return false;
}
DomainBareJid domain = from.asDomainBareJid();
Transport transport = TransportUtils.getTransport(domain);
if (transport != null) {
if (presence.getType() == Presence.Type.available) {

View File

@ -35,6 +35,7 @@ import org.jxmpp.jid.Jid;
import org.jxmpp.jid.impl.JidCreate;
import org.jxmpp.stringprep.XmppStringprepException;
import javax.xml.namespace.QName;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
@ -205,15 +206,18 @@ public class TransportUtils {
static class GatewayRegisterExtension implements ExtensionElement {
public static final String ELEMENT_NAME = "x";
public static final String NAMESPACE = "jabber:iq:gateway:register";
public static final QName QNAME = new QName(NAMESPACE, ELEMENT_NAME);
@Override
public String getElementName() {
return "x";
return ELEMENT_NAME;
}
@Override
public String getNamespace() {
return "jabber:iq:gateway:register";
return NAMESPACE;
}
@Override

View File

@ -21,6 +21,7 @@ import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException;
import javax.xml.namespace.QName;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@ -49,6 +50,8 @@ public class Features implements ExtensionElement {
*/
public static final String NAMESPACE = "http://jabber.org/protocol/disco#info";
public static final QName QNAME = new QName(NAMESPACE, ELEMENT_NAME);
@Override
public String getElementName() {

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(DelayInformation.class)) {
return;
}

View File

@ -22,14 +22,21 @@ import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException;
import javax.xml.namespace.QName;
import java.io.IOException;
/**
* XEP-0008: IQ-Based Avatars
* TODO Should be replaced with XEP-0084: User Avatar
*/
public class JabberAvatarExtension implements ExtensionElement {
public static final String ELEMENT_NAME = "x";
public static final String NAMESPACE = "jabber:x:avatar";
public static final QName QNAME = new QName(NAMESPACE, ELEMENT_NAME);
private String photoHash;
public void setPhotoHash(String hash) {

View File

@ -22,6 +22,7 @@ import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException;
import javax.xml.namespace.QName;
import java.io.IOException;
public class VCardUpdateExtension implements ExtensionElement {
@ -30,6 +31,8 @@ public class VCardUpdateExtension implements ExtensionElement {
public static final String NAMESPACE = "vcard-temp:x:update";
public static final QName QNAME = new QName(NAMESPACE, ELEMENT_NAME);
private String photoHash;
public void setPhotoHash(String hash) {

View File

@ -963,17 +963,11 @@ public class LocalPreferences {
}
public String getLookAndFeel() {
String defaultstring;
try {
defaultstring = Spark.isMac() ? Default.getString(Default.DEFAULT_LOOK_AND_FEEL_MAC)
: Default.getString(Default.DEFAULT_LOOK_AND_FEEL);
} catch (Exception e) {
defaultstring = UIManager.getSystemLookAndFeelClassName();
}
if (defaultstring.length() < 1) {
defaultstring = UIManager.getSystemLookAndFeelClassName();
}
return getString("LookAndFeel", defaultstring);
String defaultstring = Default.getString(Spark.isMac() ? Default.DEFAULT_LOOK_AND_FEEL_MAC : Default.DEFAULT_LOOK_AND_FEEL);
if (defaultstring == null || defaultstring.isEmpty()) {
defaultstring = UIManager.getSystemLookAndFeelClassName();
}
return getString("LookAndFeel", defaultstring);
}
public void setCheckForBeta(boolean checkForBeta) {
@ -1009,7 +1003,7 @@ public class LocalPreferences {
}
public boolean isShowJoinLeaveMessagesEnabled() {
return getBoolean("isShowJoinLeaveMessagesOn", true);
return getBoolean("isShowJoinLeaveMessagesOn", false);
}
public void setShowJoinLeaveMessagesEnabled(boolean enabled) {
@ -1335,17 +1329,8 @@ public class LocalPreferences {
public List<String> getDeactivatedPlugins()
{
String plugs = getString("deactivatedPlugins", "");
ArrayList<String> liste = new ArrayList<>();
StringTokenizer tokenz = new StringTokenizer(plugs, ",");
while(tokenz.hasMoreTokens())
{
String x = tokenz.nextToken();
liste.add(x);
}
return liste;
String plugs = getString("deactivatedPlugins", "");
return Arrays.asList(plugs.split(","));
}
public void setDeactivatedPlugins(List<String> list) {

View File

@ -17,7 +17,7 @@ invite = 邀请
join = 加入
no =
not.registered = 未注册
occupants = 占有
occupants = 使用
offline = 离线
online = 在线
ok = 确定
@ -64,13 +64,13 @@ button.clear = 清除
button.close = 关闭
button.copy.to.clipboard = 复制到剪贴板
button.create.account = 创建账号
button.create.room = 创建或加入群聊
button.create.room = 创建或加入房间
button.decline = 拒绝
button.deny = 拒绝
button.dial.number = 拨号
button.find = 查找
button.join = 加入
button.join.room = 加入所选群聊
button.join.room = 加入所选房间
button.login = 登录
button.new = 添加
button.profile = 个人资料
@ -124,15 +124,15 @@ checkbox.notify.user.comes.online = 用户上线时通知(&C)
checkbox.notify.user.goes.offline = 用户离线时通知(&N)
checkbox.notify.typing.systemtray = 在系统托盘中显示输入通知(&S)
checkbox.notify.systemtray = 在系统托盘显示新消息(&M)
checkbox.permanent = 群聊是持久性
checkbox.permanent = 房间是永久
checkbox.play.sound.on.invitation = 当收到邀请时播放声音(&I)
checkbox.play.sound.on.new.message = 当收到新消息时播放声音(&A)
checkbox.play.sound.on.outgoing.message = 当发送消息时播放声音(&S)
checkbox.play.sound.when.offline = 当用户离线时播放声音(&O)
checkbox.private.room = 群聊是私人的
checkbox.private.room = 房间是私人的
checkbox.save.password = 保存密码(&V)
checkbox.show.avatars.in.contactlist = 在联系人列表中显示头像(&A)
checkbox.show.notifications.in.conference = 群聊显示通知(&N)
checkbox.show.notifications.in.conference = 会议房间显示通知(&N)
checkbox.show.time.in.chat.window = 在聊天窗口显示时间(&S)
checkbox.show.toaster = 显示 Toast 弹窗(&T)
checkbox.disable.asterisk.toaster = 禁用手机 Toast 弹窗
@ -594,7 +594,7 @@ message.normal = 普通消息
message.number.to.call = 指定要拨打的号码
message.offline = 用户处于离线状态,下次登录时将收到消息
message.offline.error = 用户将无法接收离线消息
message.participants.in.room = 群聊内的参与者
message.participants.in.room = 房间参与者
message.password.error = 指定此账号的密码
message.password.private.room.error = 指定私人群聊的密码
message.passwords.no.match = 密码不匹配
@ -840,7 +840,7 @@ title.no.updates = 没有更新
title.notes = 笔记
title.notification = 通知
title.notifications = 通知
title.occupants = 参与
title.occupants = 使用
title.on.the.phone = 在打电话
title.password = 密码
title.password.required = 需要密码

View File

@ -81,8 +81,7 @@ public class GUI extends JPanel implements Observer{
@Override
public void processPacket(Stanza stanza) {
MovePacket move = (MovePacket) stanza.getExtension(
MovePacket.ELEMENT_NAME, MovePacket.NAMESPACE);
MovePacket move = stanza.getExtension(MovePacket.class);
if (move.getGameID() == _gameID) {
boolean opponentMadeHit = _gameboard.placeBomb(move.getPositionX(), move.getPositionY());

View File

@ -28,6 +28,7 @@ public class MoveAnswerPacket implements ExtensionElement
public static final String ELEMENT_NAME = "bs-move";
public static final String NAMESPACE = "battleship";
public static final QName QNAME = new QName(NAMESPACE, ELEMENT_NAME);
private int posx;
private int posy;

View File

@ -27,6 +27,7 @@ public class MovePacket implements ExtensionElement {
public static final String ELEMENT_NAME = "bs-move";
public static final String NAMESPACE = "battleship";
public static final QName QNAME = new QName(NAMESPACE, ELEMENT_NAME);
private int posx;
private int posy;

View File

@ -41,9 +41,10 @@ import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smackx.muc.MultiUserChat;
import org.jivesoftware.smackx.workgroup.packet.QueueOverview;
import org.jivesoftware.smackx.workgroup.packet.WorkgroupInformation;
import org.jivesoftware.smackx.xdata.FormField;
import org.jivesoftware.smackx.xdata.form.FillableForm;
import org.jivesoftware.smackx.xdata.form.FilledForm;
@ -269,11 +270,10 @@ 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");
if (workgroup == null && notifyQueue == null) {
// 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(QueueOverview.class);
if (!hasWorkgroup && !hasNotifyQueue) {
return;
}
@ -403,7 +403,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(WorkgroupInformation.class)) {
Localpart workgroupName = inviter.getLocalpart();
GroupChatRoom groupChatRoom = ConferenceUtils.enterRoomOnSameThread(workgroupName, room.getRoom(), null, password);

View File

@ -614,7 +614,7 @@ public class Workpane {
return true;
}
else if (message != null) {
MetaData metaDataExt = message.getExtension(MetaData.ELEMENT_NAME, MetaData.NAMESPACE);
MetaData metaDataExt = message.getExtension(MetaData.class);
if (metaDataExt != null) {
Map<String, List<String>> metadata = metaDataExt.getMetaData();
List<String> values = new ArrayList<>();

View File

@ -186,7 +186,7 @@ public final class AgentConversations extends JPanel implements ChangeListener {
@Override
public void presenceChanged(Presence presence) {
EntityBareJid agentJID = presence.getFrom().asEntityBareJidOrThrow();
AgentStatus agentStatus = presence.getExtension("agent-status", "http://jabber.org/protocol/workgroup");
AgentStatus agentStatus = presence.getExtension(AgentStatus.class);
if (agentStatus != null) {
List<AgentStatus.ChatInfo> list = agentStatus.getCurrentChats();
@ -231,7 +231,7 @@ public final class AgentConversations extends JPanel implements ChangeListener {
for (EntityBareJid agent : agentRoster.getAgents()) {
Presence presence = agentRoster.getPresence(agent);
if (presence.isAvailable()) {
AgentStatus agentStatus = presence.getExtension("agent-status", "http://jabber.org/protocol/workgroup");
AgentStatus agentStatus = presence.getExtension(AgentStatus.class);
if (agentStatus != null) {
counter += agentStatus.getCurrentChats().size();
}

View File

@ -73,7 +73,7 @@ public class ChatViewer extends JPanel {
if (stanza instanceof Message) {
Message message = (Message) stanza;
String from = message.getFrom().getResourceOrThrow().toString();
DelayInformation delayInformation = message.getExtension("delay", "urn:xmpp:delay");
DelayInformation delayInformation = message.getExtension(DelayInformation.class);
Date stamp = null;
if (delayInformation != null) {
stamp = delayInformation.getStamp();

View File

@ -170,8 +170,7 @@ public final class CurrentActivity extends JPanel {
@Override
public void presenceChanged(Presence presence) {
BareJid agentJID = presence.getFrom().asBareJid();
AgentStatus agentStatus = presence.getExtension("agent-status", "http://jabber.org/protocol/workgroup");
AgentStatus agentStatus = presence.getExtension(AgentStatus.class);
if (agentStatus != null) {
List<ChatInfo> list = agentStatus.getCurrentChats();

View File

@ -124,7 +124,7 @@ public class InvitationPane {
transcriptAlert.add(new JLabel(), new GridBagConstraints(2, 5, 1, 1, 0.0, 1.0, GridBagConstraints.SOUTH, GridBagConstraints.NONE, new Insets(2, 2, 2, 2), 0, 0));
MetaData metaDataExt = message.getExtension(MetaData.ELEMENT_NAME, MetaData.NAMESPACE);
MetaData metaDataExt = message.getExtension(MetaData.class);
if (metaDataExt != null) {
metadata = metaDataExt.getMetaData();
}

View File

@ -209,7 +209,7 @@ public final class OnlineAgents extends JPanel {
return FpRes.getString("message.user.not.logged.in");
}
AgentStatus agentStatus = presence.getExtension("agent-status", "http://jabber.org/protocol/workgroup");
AgentStatus agentStatus = presence.getExtension(AgentStatus.class);
List<AgentStatus.ChatInfo> list = agentStatus.getCurrentChats();
// Add new ones.

View File

@ -4,7 +4,7 @@ logout = 登出
cobrowsing.session = 共同浏览会话
back = 返回
go = 前往
duration = 持续时间
duration = 时长
agents = 代理
date = 日期
invite.agent = 邀请

View File

@ -13,7 +13,7 @@
<version>0.0.4</version>
<name>Http File Upload Plugin</name>
<description>Adds support for Openfire httpfileupload plugin to Spark</description>
<description>Allows users to share files by uploading to a server (via XEP-0363).</description>
<contributors>
<contributor>

View File

@ -1,2 +0,0 @@
This is a plugin for Spark that allows users to upload/download files using the openfire httpfileupload plugin.

View File

@ -21,6 +21,7 @@ import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException;
import javax.xml.namespace.QName;
import java.io.IOException;
/**
@ -30,6 +31,7 @@ public class GameForfeit implements ExtensionElement {
public static final String ELEMENT_NAME = "reversi-forfeit";
public static final String NAMESPACE = "http://jivesoftware.org/protocol/game/reversi";
public static final QName QNAME = new QName(NAMESPACE, ELEMENT_NAME);
private int gameID;

View File

@ -21,6 +21,7 @@ import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException;
import javax.xml.namespace.QName;
import java.io.IOException;
/**
@ -37,6 +38,7 @@ public class GameMove implements ExtensionElement {
public static final String ELEMENT_NAME = "reversi-move";
public static final String NAMESPACE = "http://jivesoftware.org/protocol/game/reversi";
public static final QName QNAME = new QName(NAMESPACE, ELEMENT_NAME);
private int gameID;
private int position;

View File

@ -93,7 +93,7 @@ public class ReversiPanel extends JPanel {
if (connection != null) {
gameMoveListener = stanza -> {
GameMove move = stanza.getExtension(GameMove.ELEMENT_NAME, GameMove.NAMESPACE);
GameMove move = stanza.getExtension(GameMove.class);
// If this is a move for the current game.
if (move.getGameID() == gameID) {
int position = move.getPosition();

View File

@ -6,12 +6,14 @@ import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException;
import javax.xml.namespace.QName;
import java.io.IOException;
public class InvalidMove implements ExtensionElement {
public static final String ELEMENT_NAME = "ttt-invalid";
public static final String NAMESPACE = "tictactoe";
public static final QName QNAME = new QName(NAMESPACE, ELEMENT_NAME);
private int _gameID;
private int _posx;

View File

@ -21,6 +21,7 @@ import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException;
import javax.xml.namespace.QName;
import java.io.IOException;
/**
@ -33,6 +34,7 @@ public class MovePacket implements ExtensionElement {
public static final String ELEMENT_NAME = "ttt-move";
public static final String NAMESPACE = "tictactoe";
public static final QName QNAME = new QName(NAMESPACE, ELEMENT_NAME);
private int posx;
private int posy;

View File

@ -86,9 +86,7 @@ public class GamePanel extends JPanel {
add(_playerdisplay, BorderLayout.SOUTH);
_connection.addAsyncStanzaListener(stanza -> {
MovePacket move = stanza.getExtension(
MovePacket.ELEMENT_NAME, MovePacket.NAMESPACE);
MovePacket move = stanza.getExtension(MovePacket.class);
if (move.getGameID() == _gameID) {
if (_gameboard.isValidMove(getYourMark(), move.getPositionX(), move.getPositionY())) {
_gameboardpanel.placeMark(getYourMark(), move.getPositionX(), move.getPositionY());
@ -109,7 +107,7 @@ public class GamePanel extends JPanel {
}, new StanzaExtensionFilter(MovePacket.ELEMENT_NAME, MovePacket.NAMESPACE));
_connection.addAsyncStanzaListener(stanza -> {
//InvalidMove im = (InvalidMove)packet.getExtension(InvalidMove.ELEMENT_NAME, InvalidMove.NAMESPACE);
//InvalidMove im = packet.getExtension(InvalidMove.class);
ChatRoom cr = SparkManager.getChatManager().getChatRoom(_opponent.asEntityBareJid());
cr.getTranscriptWindow().insertCustomText("You seem to be Cheating\n" +
"You placed a wrong Move", true, false, Color.red);