Merge pull request #623 from Flowdalic/smack-4.4

Bump Smack to 4.4
This commit is contained in:
Plyha 2021-12-15 15:37:45 +03:00 committed by GitHub
commit 8210deb9a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
55 changed files with 435 additions and 435 deletions

View File

@ -123,14 +123,10 @@
</dependency>
<dependency>
<groupId>org.igniterealtime.smack</groupId>
<artifactId>smack-java7</artifactId>
<version>${dependency.smack.version}</version>
</dependency>
<dependency>
<groupId>org.igniterealtime.smack</groupId>
<artifactId>smack-compression-jzlib</artifactId>
<artifactId>smack-java8</artifactId>
<version>${dependency.smack.version}</version>
</dependency>
<!--
<dependency>
<groupId>org.igniterealtime.spark</groupId>
<artifactId>emoticons</artifactId>
@ -163,6 +159,7 @@
<classifier>Default.adiumemoticonset</classifier>
<type>zip</type>
</dependency>
-->
<dependency>
<groupId>org.dom4j</groupId>
<artifactId>dom4j</artifactId>

View File

@ -44,6 +44,7 @@ import javax.net.ssl.SSLContext;
import javax.swing.*;
import java.awt.*;
import java.io.IOException;
import java.net.InetAddress;
import java.security.KeyManagementException;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
@ -358,7 +359,7 @@ public class AccountCreationWizard extends JPanel {
// plain connections which is 5222.
try {
SSLContext context = SparkSSLContextCreator.setUpContext(SparkSSLContextCreator.Options.ONLY_SERVER_SIDE);
builder.setCustomSSLContext(context);
builder.setSslContextFactory(() -> { return context; });
builder.setSecurityMode( securityMode );
} catch (NoSuchAlgorithmException | KeyManagementException | UnrecoverableKeyException | KeyStoreException | NoSuchProviderException e) {
Log.warning("Couldnt establish secured connection", e);
@ -372,7 +373,11 @@ public class AccountCreationWizard extends JPanel {
// Here, we force the host to be set (by doing a DNS lookup), and force the port to 5223 (which is the
// default 'old-style' SSL port).
DnsName serverNameDnsName = DnsName.from(serverName);
builder.setHost( DNSUtil.resolveXMPPServiceDomain( serverNameDnsName, null, DnssecMode.disabled ).get( 0 ).getFQDN() );
java.util.List<InetAddress> resolvedAddresses = DNSUtil.getDNSResolver().lookupHostAddress(serverNameDnsName, null, DnssecMode.disabled);
if (resolvedAddresses.isEmpty()) {
throw new SmackException.SmackMessageException("Could not resolve " + serverNameDnsName);
}
builder.setHost( resolvedAddresses.get( 0 ).getHostName() );
builder.setPort( 5223 );
}
builder.setSocketFactory( new SparkSSLSocketFactory(SparkSSLContextCreator.Options.ONLY_SERVER_SIDE) );

View File

@ -302,8 +302,9 @@ public class LoginDialog {
}
try {
SSLContext context = SparkSSLContextCreator.setUpContext(options);
builder.setCustomSSLContext(context);
builder.setSslContextFactory(() -> { return context; });
builder.setSecurityMode(securityMode);
builder.setCustomX509TrustManager(new SparkTrustManager());
} catch (NoSuchAlgorithmException | KeyManagementException | UnrecoverableKeyException | KeyStoreException | NoSuchProviderException e) {
Log.warning("Couldnt establish secured connection", e);
}
@ -315,7 +316,11 @@ public class LoginDialog {
// Here, we force the host to be set (by doing a DNS lookup), and force the port to 5223 (which is the
// default 'old-style' SSL port).
DnsName serverNameDnsName = DnsName.from(loginServer);
builder.setHost(DNSUtil.resolveXMPPServiceDomain(serverNameDnsName, null, DnssecMode.disabled).get(0).getFQDN());
java.util.List<InetAddress> resolvedAddresses = DNSUtil.getDNSResolver().lookupHostAddress(serverNameDnsName, null, DnssecMode.disabled);
if (resolvedAddresses.isEmpty()) {
throw new RuntimeException("Could not resolve " + serverNameDnsName);
}
builder.setHost(resolvedAddresses.get(0).getHostName());
builder.setPort(5223);
}
SparkSSLContextCreator.Options options;

View File

@ -83,6 +83,7 @@ import org.jivesoftware.smack.SASLAuthentication;
import org.jivesoftware.smack.SmackConfiguration;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.ConnectionConfiguration.DnssecMode;
import org.jivesoftware.smack.parsing.ExceptionLoggingCallback;
import org.jivesoftware.smack.proxy.ProxyInfo;
import org.jivesoftware.smack.sasl.javax.SASLExternalMechanism;
@ -732,8 +733,9 @@ public class LoginUIPanel extends javax.swing.JPanel implements KeyListener, Act
}
try {
SSLContext context = SparkSSLContextCreator.setUpContext(options);
builder.setCustomSSLContext(context);
builder.setSslContextFactory(() -> { return context; });
builder.setSecurityMode(securityMode);
builder.setCustomX509TrustManager(new SparkTrustManager());
} catch (NoSuchAlgorithmException | KeyManagementException | UnrecoverableKeyException | KeyStoreException | NoSuchProviderException e) {
Log.warning("Couldnt establish secured connection", e);
}
@ -745,7 +747,11 @@ public class LoginUIPanel extends javax.swing.JPanel implements KeyListener, Act
// Here, we force the host to be set (by doing a DNS lookup), and force the port to 5223 (which is the
// default 'old-style' SSL port).
DnsName serverNameDnsName = DnsName.from(loginServer);
builder.setHost(DNSUtil.resolveXMPPServiceDomain(serverNameDnsName, null, ConnectionConfiguration.DnssecMode.disabled).get(0).getFQDN());
java.util.List<InetAddress> resolvedAddresses = DNSUtil.getDNSResolver().lookupHostAddress(serverNameDnsName, null, DnssecMode.disabled);
if (resolvedAddresses.isEmpty()) {
throw new RuntimeException("Could not resolve " + serverNameDnsName);
}
builder.setHost(resolvedAddresses.get(0).getHostName());
builder.setPort(5223);
}
SparkSSLContextCreator.Options options;

View File

@ -26,7 +26,6 @@ import org.jivesoftware.smackx.chatstates.ChatStateListener;
import org.jivesoftware.smackx.chatstates.ChatStateManager;
import org.jivesoftware.smackx.muc.MultiUserChat;
import org.jivesoftware.smackx.muc.MultiUserChatManager;
import org.jivesoftware.smackx.xdata.Form;
import org.jivesoftware.smackx.xdata.packet.DataForm;
import org.jivesoftware.spark.component.tabbedPane.SparkTab;
import org.jivesoftware.spark.decorator.DefaultTabHandler;
@ -283,11 +282,7 @@ public class ChatManager {
try {
LocalPreferences pref = SettingsManager.getLocalPreferences();
Resourcepart nickname = pref.getNickname();
chatRoom.create(nickname);
// Send an empty room configuration form which indicates that we want
// an instant room
chatRoom.sendConfigurationForm(new Form( DataForm.Type.submit ));
chatRoom.create(nickname).makeInstant();
}
catch (XMPPException | SmackException | InterruptedException e1) {
Log.error("Unable to send conference room chat configuration form.", e1);

View File

@ -20,13 +20,16 @@ import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.jivesoftware.smack.provider.IQProvider;
import org.jivesoftware.smack.provider.ProviderManager;
import org.jivesoftware.smack.xml.SmackXmlParser;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.spark.util.URLFileSystem;
import org.jivesoftware.spark.util.log.Log;
import org.xmlpull.mxp1.MXParser;
import org.xmlpull.v1.XmlPullParser;
import java.io.BufferedReader;
import java.io.File;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
@ -110,13 +113,12 @@ public class PluginClassLoader extends URLClassLoader {
// Get an array of class loaders to try loading the providers files from.
Reader reader = new BufferedReader(new InputStreamReader(providerStream, "UTF-8"));
try {
XmlPullParser parser = new MXParser();
parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
parser.setInput(providerStream, "UTF-8");
int eventType = parser.getEventType();
final XmlPullParser parser = SmackXmlParser.newXmlParser(reader);
XmlPullParser.Event eventType = parser.getEventType();
do {
if (eventType == XmlPullParser.START_TAG) {
if (eventType == XmlPullParser.Event.START_ELEMENT) {
if (parser.getName().equals("iqProvider")) {
parser.next();
parser.next();
@ -185,7 +187,7 @@ public class PluginClassLoader extends URLClassLoader {
}
eventType = parser.next();
}
while (eventType != XmlPullParser.END_DOCUMENT);
while (eventType != XmlPullParser.Event.END_DOCUMENT);
}
finally {
try {

View File

@ -15,8 +15,11 @@
*/
package org.jivesoftware.spark.ui;
import org.jivesoftware.smackx.xdata.Form;
import org.jivesoftware.smackx.xdata.FormField;
import org.jivesoftware.smackx.xdata.FormFieldWithOptions;
import org.jivesoftware.smackx.xdata.ListSingleFormField;
import org.jivesoftware.smackx.xdata.form.FillableForm;
import org.jivesoftware.smackx.xdata.packet.DataForm;
import org.jivesoftware.spark.component.CheckBoxList;
import org.jivesoftware.spark.util.ModelUtil;
@ -49,14 +52,14 @@ public class DataFormUI extends JPanel {
private static final long serialVersionUID = -6313707846021436765L;
private final Map<String,JComponent> valueMap = new HashMap<>();
private int row = 5;
private final Form searchForm;
private final DataForm searchForm;
/**
* Creates a new DataFormUI
*
* @param form the <code>DataForm</code> to build a UI with.
*/
public DataFormUI(Form form) {
public DataFormUI(DataForm form) {
this.setLayout(new GridBagLayout());
this.searchForm = form;
@ -66,15 +69,15 @@ public class DataFormUI extends JPanel {
}
private void buildUI(Form form) {
private void buildUI(DataForm form) {
// Add default answers to the form to submit
for ( final FormField field : form.getFields() ) {
String variable = field.getVariable();
String variable = field.getFieldName();
String label = field.getLabel();
FormField.Type type = field.getType();
List<CharSequence> valueList = field.getValues();
List<? extends CharSequence> valueList = field.getValues();
if (type.equals(FormField.Type.bool)) {
String o = valueList.get(0).toString();
@ -93,8 +96,11 @@ public class DataFormUI extends JPanel {
else if (type.equals(FormField.Type.text_multi) ||
type.equals(FormField.Type.jid_multi)) {
StringBuilder buf = new StringBuilder();
for ( FormField.Option option : field.getOptions() ) {
buf.append(option);
if (field instanceof FormFieldWithOptions) {
FormFieldWithOptions formFieldWithOptions = (FormFieldWithOptions) field;
for ( FormField.Option option : formFieldWithOptions.getOptions() ) {
buf.append(option);
}
}
addField(label, new JTextArea(buf.toString()), variable);
}
@ -102,8 +108,9 @@ public class DataFormUI extends JPanel {
addField(label, new JPasswordField(), variable);
}
else if (type.equals(FormField.Type.list_single)) {
ListSingleFormField listSingleFormField = field.ifPossibleAsOrThrow(ListSingleFormField.class);
JComboBox<FormField.Option> box = new JComboBox<>();
for ( final FormField.Option option : field.getOptions() ) {
for ( final FormField.Option option : listSingleFormField.getOptions() ) {
box.addItem(option);
}
if (valueList.size() > 0) {
@ -128,10 +135,10 @@ public class DataFormUI extends JPanel {
*
* @return the answered DataForm.
*/
public Form getFilledForm() {
public DataForm getFilledForm() {
// Now submit all information
Iterator<String> valueIter = valueMap.keySet().iterator();
Form answerForm = searchForm.createAnswerForm();
FillableForm answerForm = new FillableForm(searchForm);
while (valueIter.hasNext()) {
String answer = valueIter.next();
Object o = valueMap.get(answer);
@ -160,7 +167,7 @@ public class DataFormUI extends JPanel {
Object v = ((JComboBox<?>)o).getSelectedItem();
String value;
if (v instanceof FormField.Option) {
value = ((FormField.Option)v).getValue();
value = ((FormField.Option)v).getValueString();
}
else {
value = (String)v;
@ -179,7 +186,7 @@ public class DataFormUI extends JPanel {
}
}
return answerForm;
return answerForm.getDataFormToSubmit();
}

View File

@ -30,6 +30,7 @@ import javax.swing.JTextArea;
import org.jivesoftware.resource.SparkRes;
import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.spark.SparkManager;
import org.jivesoftware.spark.util.log.Log;
@ -101,7 +102,7 @@ public class RawPacketSender implements ActionListener {
Stanza stanza = new Stanza() {
@Override
public String toXML(String enclosingNamespace) {
public String toXML(XmlEnvironment xmlEnvironment) {
return _inputarea.getText();
}
@ -109,6 +110,11 @@ public class RawPacketSender implements ActionListener {
public String toString() {
return null;
}
@Override
public String getElementName() {
return null;
}
};
try {

View File

@ -58,7 +58,8 @@ import org.jivesoftware.smack.roster.RosterEntry;
import org.jivesoftware.smack.roster.RosterGroup;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smackx.vcardtemp.VCardManager;
import org.jivesoftware.smackx.xdata.Form;
import org.jivesoftware.smackx.xdata.form.FillableForm;
import org.jivesoftware.smackx.xdata.packet.DataForm;
import org.jivesoftware.smackx.search.ReportedData;
import org.jivesoftware.smackx.vcardtemp.packet.VCard;
import org.jivesoftware.smackx.search.UserSearchManager;
@ -492,15 +493,15 @@ public class RosterDialog implements ActionListener {
UserSearchManager usersearchManager = new UserSearchManager(
SparkManager.getConnection());
Form f = usersearchManager.getSearchForm(search);
DataForm f = usersearchManager.getSearchForm(search);
Form answer = f.createAnswerForm();
FillableForm answer = new FillableForm(f);
answer.setAnswer("Name", true);
answer.setAnswer("Email", true);
answer.setAnswer("Username", true);
answer.setAnswer("search", byname);
data = usersearchManager.getSearchResults(answer, search);
data = usersearchManager.getSearchResults(answer.getDataFormToSubmit(), search);
ArrayList<String> columnnames = new ArrayList<>();
for ( ReportedData.Column column : data.getColumns() ) {
@ -562,7 +563,7 @@ public class RosterDialog implements ActionListener {
if (isSubscribed) {
try {
roster.createEntry(jid, nickname, new String[]{group});
roster.createItemAndRequestSubscription(jid, nickname, new String[]{group});
}
catch (XMPPException | SmackException | InterruptedException e) {
Log.error("Unable to add new entry " + jid, e);
@ -578,7 +579,7 @@ public class RosterDialog implements ActionListener {
}
if (userEntry == null) {
roster.createEntry(jid, nickname, groups);
roster.createItemAndRequestSubscription(jid, nickname, groups);
userEntry = roster.getEntry(jid);
}
else {

View File

@ -33,8 +33,9 @@ import javax.swing.JTextField;
import org.jivesoftware.resource.Res;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smackx.xdata.Form;
import org.jivesoftware.smackx.xdata.FormField;
import org.jivesoftware.smackx.xdata.form.FillableForm;
import org.jivesoftware.smackx.xdata.packet.DataForm;
import org.jivesoftware.smackx.muc.MultiUserChat;
import org.jivesoftware.spark.ChatManager;
import org.jivesoftware.spark.SparkManager;
@ -62,7 +63,7 @@ public class AnswerFormDialog {
* @param form
*/
public AnswerFormDialog(JFrame parent, final MultiUserChat chat,
final Form form) {
final DataForm form) {
centerpanel = new JPanel();
JPanel bottompanel = new JPanel();
@ -85,7 +86,7 @@ public class AnswerFormDialog {
}
if (comp != null) {
addComponent(label, comp, row, formfield.getVariable());
addComponent(label, comp, row, formfield.getFieldName());
row++;
}
}
@ -94,7 +95,7 @@ public class AnswerFormDialog {
ResourceUtils.resButton(updatebutton, Res.getString("apply"));
updatebutton.addActionListener( e -> {
dialog.dispose();
sendAnswerForm(form.createAnswerForm(), chat);
sendAnswerForm(new FillableForm(form), chat);
} );
bottompanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
@ -124,7 +125,7 @@ public class AnswerFormDialog {
* @param answer <u>must be an answer-form</u>
* @param chat
*/
private void sendAnswerForm(Form answer, MultiUserChat chat) {
private void sendAnswerForm(FillableForm answer, MultiUserChat chat) {
ChatRoom room = SparkManager.getChatManager().getChatRoom(chat.getRoom());

View File

@ -51,7 +51,7 @@ import org.jivesoftware.resource.SparkRes;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smackx.muc.MultiUserChatManager;
import org.jivesoftware.smackx.xdata.Form;
import org.jivesoftware.smackx.xdata.form.FillableForm;
import org.jivesoftware.smackx.bookmarks.BookmarkedConference;
import org.jivesoftware.smackx.muc.HostedRoom;
import org.jivesoftware.smackx.muc.MultiUserChat;
@ -839,7 +839,7 @@ public class ConferenceRoomBrowser extends JPanel implements ActionListener,
chatManager.getChatContainer().activateChatRoom(room);
// Send Form
Form form = groupChat.getConfigurationForm().createAnswerForm();
FillableForm form = groupChat.getConfigurationForm().getFillableForm();
if (mucRoomDialog.isPasswordProtected()) {
String password = mucRoomDialog.getPassword();
room.setPassword(password);

View File

@ -27,8 +27,8 @@ import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
import org.jivesoftware.smackx.muc.MultiUserChat;
import org.jivesoftware.smackx.muc.MultiUserChatManager;
import org.jivesoftware.smackx.muc.RoomInfo;
import org.jivesoftware.smackx.xdata.Form;
import org.jivesoftware.smackx.xdata.FormField;
import org.jivesoftware.smackx.xdata.form.FillableForm;
import org.jivesoftware.smackx.xdata.packet.DataForm;
import org.jivesoftware.spark.ChatManager;
import org.jivesoftware.spark.PresenceManager;
@ -89,7 +89,7 @@ public class ConferenceUtils {
final DateFormat dateFormatter = new SimpleDateFormat("yyyyMMdd'T'HH:mm:ss");
DiscoverInfo infoResult = discoManager.discoverInfo(roomJID);
DataForm dataForm = infoResult.getExtension("x", "jabber:x:data");
DataForm dataForm = infoResult.getExtension(DataForm.class);
if (dataForm == null) {
return "Not available";
}
@ -289,13 +289,14 @@ public class ConferenceUtils {
// Attempt to create room.
multiUserChat.create(pref.getNickname());
}
catch (XMPPException | SmackException e) {
throw new SmackException(e);
catch (XMPPException e) {
// TODO: Simply let this method throw XMPPException, instead of wrapping it here.
throw new SmackException.SmackWrappedException(e);
}
try {
// Since this is a private room, make the room not public and set user as owner of the room.
Form submitForm = multiUserChat.getConfigurationForm().createAnswerForm();
FillableForm submitForm = multiUserChat.getConfigurationForm().getFillableForm();
submitForm.setAnswer("muc#roomconfig_publicroom", false);
submitForm.setAnswer("muc#roomconfig_roomname", roomName);

View File

@ -47,9 +47,12 @@ import org.jivesoftware.resource.Res;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smackx.muc.MultiUserChatManager;
import org.jivesoftware.smackx.xdata.Form;
import org.jivesoftware.smackx.xdata.FormField;
import org.jivesoftware.smackx.xdata.FormField.Option;
import org.jivesoftware.smackx.xdata.ListMultiFormField;
import org.jivesoftware.smackx.xdata.ListSingleFormField;
import org.jivesoftware.smackx.xdata.form.FillableForm;
import org.jivesoftware.smackx.xdata.form.Form;
import org.jivesoftware.smackx.bookmarks.BookmarkManager;
import org.jivesoftware.smackx.muc.MultiUserChat;
import org.jivesoftware.smackx.muc.RoomInfo;
@ -67,7 +70,7 @@ public class DataFormDialog extends JPanel {
private int row = 0;
private final JDialog dialog;
public DataFormDialog(JFrame parent, final MultiUserChat chat, final Form submitForm) {
public DataFormDialog(JFrame parent, final MultiUserChat chat, final FillableForm submitForm) {
dialog = new JDialog(parent, true);
dialog.setTitle(Res.getString("title.configure.chat.room"));
@ -86,12 +89,12 @@ public class DataFormDialog extends JPanel {
// Create a new form to submit based on the original form
try {
// Add default answers to the form to submit
for ( final FormField field : form.getFields() ) {
String variable = field.getVariable();
for ( final FormField field : form.getDataForm().getFields() ) {
String variable = field.getFieldName();
String label = field.getLabel();
FormField.Type type = field.getType();
List<CharSequence> valueList = field.getValues();
List<? extends CharSequence> valueList = field.getValues();
if (type.equals(FormField.Type.bool)) {
boolean isSelected;
@ -120,7 +123,7 @@ public class DataFormDialog extends JPanel {
else if (type.equals(FormField.Type.text_multi) ||
type.equals(FormField.Type.jid_multi)) {
StringBuilder buf = new StringBuilder();
final Iterator<CharSequence> iter = valueList.iterator();
final Iterator<? extends CharSequence> iter = valueList.iterator();
while (iter.hasNext()) {
buf.append( iter.next() );
@ -141,9 +144,10 @@ public class DataFormDialog extends JPanel {
addField(label, new JPasswordField( value ), variable);
}
else if (type.equals(FormField.Type.list_single)) {
ListSingleFormField listSingleFormField = field.ifPossibleAsOrThrow(ListSingleFormField.class);
JComboBox<String> box = new JComboBox<>();
for ( final FormField.Option option : field.getOptions() ) {
String value = option.getValue();
for ( final FormField.Option option : listSingleFormField.getOptions() ) {
String value = option.getValueString();
box.addItem(value);
}
if (valueList.size() > 0) {
@ -154,11 +158,12 @@ public class DataFormDialog extends JPanel {
addField(label, box, variable);
}
else if (type.equals(FormField.Type.list_multi)) {
ListMultiFormField listMultiFormField = field.ifPossibleAsOrThrow(ListMultiFormField.class);
CheckBoxList checkBoxList = new CheckBoxList();
final List<CharSequence> values = field.getValues();
for ( final Option option : field.getOptions() ) {
final List<? extends CharSequence> values = field.getValues();
for ( final Option option : listMultiFormField.getOptions() ) {
String optionLabel = option.getLabel();
String optionValue = option.getValue();
String optionValue = option.getValueString();
checkBoxList.addCheckBox(new JCheckBox(optionLabel, values.contains(optionValue)), optionValue);
}
submitForm.setAnswer( variable, valueList );
@ -168,6 +173,9 @@ public class DataFormDialog extends JPanel {
}
catch (NullPointerException e) {
Log.error(e);
// TODO: Why do we continue here as nothing had happened? If there is an NPE somewhere in this block, then
// we should fix it, instead of masking it. Remove this try/catch block and see if it still appears, if so:
// fix it.
}
@ -207,7 +215,7 @@ public class DataFormDialog extends JPanel {
}
private void updateRoomConfiguration(Form submitForm, MultiUserChat chat) {
private void updateRoomConfiguration(FillableForm submitForm, MultiUserChat chat) {
for (Object o1 : valueMap.keySet()) {
String answer = (String) o1;
Object o = valueMap.get(answer);

View File

@ -28,12 +28,13 @@ import org.jivesoftware.smack.packet.Stanza;
import org.jivesoftware.smack.packet.StanzaError;
import org.jivesoftware.smackx.chatstates.ChatState;
import org.jivesoftware.smackx.delay.packet.DelayInformation;
import org.jivesoftware.smackx.muc.DefaultParticipantStatusListener;
import org.jivesoftware.smackx.muc.DefaultUserStatusListener;
import org.jivesoftware.smackx.muc.MultiUserChat;
import org.jivesoftware.smackx.muc.ParticipantStatusListener;
import org.jivesoftware.smackx.muc.UserStatusListener;
import org.jivesoftware.smackx.muc.packet.Destroy;
import org.jivesoftware.smackx.muc.packet.MUCUser;
import org.jivesoftware.smackx.xdata.Form;
import org.jivesoftware.smackx.xdata.form.FillableForm;
import org.jivesoftware.smackx.xdata.form.Form;
import org.jivesoftware.smackx.xevent.MessageEventManager;
import org.jivesoftware.spark.ChatManager;
import org.jivesoftware.spark.SparkManager;
@ -150,7 +151,7 @@ public class GroupChatRoom extends ChatRoom
try
{
ChatFrame chatFrame = SparkManager.getChatManager().getChatContainer().getChatFrame();
Form form = chat.getConfigurationForm().createAnswerForm();
FillableForm form = chat.getConfigurationForm().getFillableForm();
new DataFormDialog( chatFrame, chat, form );
}
catch ( XMPPException | SmackException | InterruptedException e )
@ -277,7 +278,7 @@ public class GroupChatRoom extends ChatRoom
try
{
final ChatFrame chatFrame = SparkManager.getChatManager().getChatContainer().getChatFrame();
final Form form = chat.getConfigurationForm().createAnswerForm();
final FillableForm form = chat.getConfigurationForm().getFillableForm();
new DataFormDialog( chatFrame, chat, form );
}
catch ( XMPPException | SmackException | InterruptedException xmpe )
@ -318,7 +319,7 @@ public class GroupChatRoom extends ChatRoom
final Form form = chat.getRegistrationForm();
final ChatFrame chatFrame = SparkManager.getChatManager().getChatContainer().getChatFrame();
new AnswerFormDialog( chatFrame, chat, form );
new AnswerFormDialog( chatFrame, chat, form.getDataForm() );
}
catch ( XMPPException | SmackException | InterruptedException xmpe )
{
@ -763,7 +764,7 @@ public class GroupChatRoom extends ChatRoom
*/
private void setupListeners()
{
chat.addParticipantStatusListener( new DefaultParticipantStatusListener()
chat.addParticipantStatusListener( new ParticipantStatusListener()
{
@Override
public void kicked( EntityFullJid participant, Jid actor, String reason )
@ -844,7 +845,7 @@ public class GroupChatRoom extends ChatRoom
}
} );
chat.addUserStatusListener( new DefaultUserStatusListener()
chat.addUserStatusListener( new UserStatusListener()
{
@Override
public void kicked( Jid s, String reason )

View File

@ -18,6 +18,7 @@ package org.jivesoftware.spark.uri;
import java.net.URI;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.roster.Roster;
import org.jivesoftware.smack.roster.RosterEntry;
import org.jivesoftware.smack.roster.RosterGroup;
@ -119,9 +120,13 @@ public class UriManager {
// Send contact add request
Jid jid = retrieveJID(uri);
Presence response = new Presence(Presence.Type.subscribe);
response.setTo(jid);
SparkManager.getConnection().sendStanza(response);
XMPPConnection connection = SparkManager.getConnection();
Presence response = connection.getStanzaFactory()
.buildPresenceStanza()
.ofType(Presence.Type.subscribe)
.to(jid)
.build();
connection.sendStanza(response);
}
/**

View File

@ -1,60 +0,0 @@
/**
* Copyright (C) 2004-2011 Jive Software. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jivesoftware.sparkimpl.plugin.alerts;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.xmlpull.v1.XmlPullParser;
/**
* XEP-0224 Compliance<br>
* see <a
* href="http://xmpp.org/extensions/xep-0224.html">http://xmpp.org/extensions/xep-0224.html</a>
*/
public class BuzzPacket implements ExtensionElement
{
public static final String ELEMENT_NAME = "attention";
public static final String NAMESPACE = "urn:xmpp:attention:0";
@Override
public String getElementName() {
return ELEMENT_NAME;
}
@Override
public String getNamespace() {
return NAMESPACE;
}
// TODO 2.7.0 remove buzz only attention gets to stay
@Override
public String toXML(String enclosingNamespace) {
return "<" + getElementName() + " xmlns=\"" + getNamespace()
+ "\"/><buzz xmlns=\"http://www.jivesoftware.com/spark\"/>";
}
public static class Provider extends ExtensionElementProvider<BuzzPacket> {
public Provider() {
}
@Override
public BuzzPacket parse( XmlPullParser parser, int i ) {
return new BuzzPacket();
}
}
}

View File

@ -16,9 +16,10 @@
package org.jivesoftware.sparkimpl.plugin.alerts;
import org.jivesoftware.resource.Res;
import org.jivesoftware.smack.filter.AndFilter;
import org.jivesoftware.smack.filter.StanzaTypeFilter;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.provider.ProviderManager;
import org.jivesoftware.smackx.attention.packet.AttentionExtension;
import org.jivesoftware.spark.ChatManager;
import org.jivesoftware.spark.SparkManager;
import org.jivesoftware.spark.plugin.Plugin;
@ -41,32 +42,14 @@ import javax.swing.SwingUtilities;
*/
public class BuzzPlugin implements Plugin {
private static final String ELEMENTNAME = "attention";
private static final String NAMESPACE = "urn:xmpp:attention:0";
private static final String ELEMENTNAME_OLD = "buzz";
private static final String NAMESPACE_OLD = "http://www.jivesoftware.com/spark";
@Override
public void initialize() {
ProviderManager.addExtensionProvider(ELEMENTNAME,
NAMESPACE, new BuzzPacket.Provider());
ProviderManager.addExtensionProvider(ELEMENTNAME_OLD,
NAMESPACE_OLD, new BuzzPacket.Provider());
SparkManager.getConnection().addAsyncStanzaListener(stanza -> {
if (stanza instanceof Message) {
final Message message = (Message) stanza;
boolean buzz = message.getExtension(ELEMENTNAME_OLD,
NAMESPACE_OLD) != null
|| message.getExtension(ELEMENTNAME, NAMESPACE) != null;
if (buzz) {
SwingUtilities.invokeLater(() -> shakeWindow(message));
}
}
}, new StanzaTypeFilter(Message.class));
SparkManager.getConnection()
.addAsyncStanzaListener(
stanza -> SwingUtilities.invokeLater(() -> shakeWindow((Message)stanza)),
new AndFilter(StanzaTypeFilter.MESSAGE, s -> s.hasExtension(AttentionExtension.ELEMENT_NAME, AttentionExtension.NAMESPACE))
);
SparkManager.getChatManager().addChatRoomListener(
new ChatRoomListener() {

View File

@ -25,7 +25,9 @@ import javax.swing.JLabel;
import org.jivesoftware.resource.Res;
import org.jivesoftware.resource.SparkRes;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smackx.attention.packet.AttentionExtension;
import org.jivesoftware.spark.ChatManager;
import org.jivesoftware.spark.SparkManager;
import org.jivesoftware.spark.ui.ChatRoom;
@ -79,12 +81,17 @@ public class BuzzRoomDecorator implements ActionListener {
} catch (XmppStringprepException exception) {
throw new IllegalStateException(exception);
}
Message message = new Message();
message.setTo(jid);
message.addExtension(new BuzzPacket());
XMPPConnection connection = SparkManager.getConnection();
Message message = connection.getStanzaFactory()
.buildMessageStanza()
.to(jid)
.addExtension(new AttentionExtension())
.build();
try
{
SparkManager.getConnection().sendStanza(message);
connection.sendStanza(message);
}
catch ( SmackException.NotConnectedException | InterruptedException e1 )
{

View File

@ -18,11 +18,12 @@ package org.jivesoftware.sparkimpl.plugin.gateways;
import org.jivesoftware.smack.*;
import org.jivesoftware.smack.filter.StanzaIdFilter;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.provider.IQProvider;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException;
import org.jivesoftware.spark.SparkManager;
import org.jxmpp.jid.DomainBareJid;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
@ -87,14 +88,14 @@ public class Gateway extends IQ {
}
@Override
public Gateway parse(XmlPullParser parser, int i) throws IOException, XmlPullParserException
{
public Gateway parse(XmlPullParser parser, int i, XmlEnvironment xmlEnvironment)
throws IOException, XmlPullParserException {
Gateway version = new Gateway();
boolean done = false;
while (!done) {
int eventType = parser.next();
if (eventType == XmlPullParser.START_TAG) {
XmlPullParser.Event eventType = parser.next();
if (eventType == XmlPullParser.Event.START_ELEMENT) {
if (parser.getName().equals("jid")) {
version.setJid(parser.nextText());
}
@ -103,7 +104,7 @@ public class Gateway extends IQ {
}
}
else if (eventType == XmlPullParser.END_TAG) {
else if (eventType == XmlPullParser.Event.END_ELEMENT) {
if (parser.getName().equals(ELEMENT_NAME)) {
done = true;
}

View File

@ -15,12 +15,12 @@
*/
package org.jivesoftware.sparkimpl.plugin.gateways;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException;
import org.jivesoftware.smackx.iqprivate.packet.PrivateData;
import org.jivesoftware.smackx.iqprivate.provider.PrivateDataProvider;
import org.jxmpp.jid.DomainBareJid;
import org.jxmpp.jid.impl.JidCreate;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
import java.util.HashMap;
@ -87,40 +87,39 @@ public class GatewayPrivateData implements PrivateData {
}
@Override
public PrivateData parsePrivateData(XmlPullParser parser) throws IOException, XmlPullParserException
{
public PrivateData parsePrivateData(XmlPullParser parser) throws IOException, XmlPullParserException {
GatewayPrivateData data = new GatewayPrivateData();
boolean done = false;
boolean isInstalled = false;
while (!done) {
int eventType = parser.next();
if (eventType == XmlPullParser.START_TAG && parser.getName().equals("gateways")) {
XmlPullParser.Event eventType = parser.next();
if (eventType == XmlPullParser.Event.START_ELEMENT && parser.getName().equals("gateways")) {
isInstalled = true;
}
if (eventType == XmlPullParser.START_TAG && parser.getName().equals("gateway")) {
if (eventType == XmlPullParser.Event.START_ELEMENT && parser.getName().equals("gateway")) {
boolean gatewayDone = false;
DomainBareJid serviceName = null;
String autoLogin = null;
while (!gatewayDone) {
int eType = parser.next();
if (eType == XmlPullParser.START_TAG && parser.getName().equals("serviceName")) {
XmlPullParser.Event eType = parser.next();
if (eType == XmlPullParser.Event.START_ELEMENT && parser.getName().equals("serviceName")) {
String serviceNameString = parser.nextText();
serviceName = JidCreate.domainBareFrom(serviceNameString);
}
else if (eType == XmlPullParser.START_TAG && parser.getName().equals("autoLogin")) {
else if (eType == XmlPullParser.Event.START_ELEMENT && parser.getName().equals("autoLogin")) {
autoLogin = parser.nextText();
}
else if (eType == XmlPullParser.END_TAG && parser.getName().equals("gateway")) {
else if (eType == XmlPullParser.Event.END_ELEMENT && parser.getName().equals("gateway")) {
data.addService(serviceName, Boolean.parseBoolean(autoLogin));
gatewayDone = true;
}
}
}
else if (eventType == XmlPullParser.END_TAG && parser.getName().equals("gateways")) {
else if (eventType == XmlPullParser.Event.END_ELEMENT && parser.getName().equals("gateways")) {
done = true;
}
else if (!isInstalled) {

View File

@ -17,7 +17,7 @@ package org.jivesoftware.sparkimpl.plugin.gateways;
import org.jivesoftware.resource.Res;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.spark.SparkManager;
import org.jivesoftware.spark.component.RolloverButton;
@ -179,18 +179,21 @@ public class TransportRegistrationDialog extends JPanel implements ActionListene
}
try {
TransportUtils.registerUser(SparkManager.getConnection(), serviceName, username, password, nickname, stanza -> {
IQ result = (IQ) stanza;
if ( result.getType() == IQ.Type.error ) {
JOptionPane.showMessageDialog(TransportRegistrationDialog.this, Res.getString("message.registration.transport.failed"), Res.getString("title.registration.error"), JOptionPane.ERROR_MESSAGE);
} else {
// Send Directed Presence
final StatusBar statusBar = SparkManager.getWorkspace().getStatusBar();
Presence presence = statusBar.getPresence();
presence.setTo(transport.getXMPPServiceDomain());
SparkManager.getConnection().sendStanza(presence);
}
} );
TransportUtils.registerUser(SparkManager.getConnection(), serviceName, username, password, nickname,
stanza -> {
// Send Directed Presence
final StatusBar statusBar = SparkManager.getWorkspace().getStatusBar();
Presence presence = statusBar.getPresence();
presence.setTo(transport.getXMPPServiceDomain());
try {
SparkManager.getConnection().sendStanza(presence);
} catch (NotConnectedException | InterruptedException e1) {
// TODO: handle this.
}
},
exception ->
JOptionPane.showMessageDialog(TransportRegistrationDialog.this, Res.getString("message.registration.transport.failed"), Res.getString("title.registration.error"), JOptionPane.ERROR_MESSAGE)
);
}
catch (SmackException | InterruptedException e1) {
JOptionPane.showMessageDialog(TransportRegistrationDialog.this, Res.getString("message.registration.transport.failed"), Res.getString("title.registration.error"), JOptionPane.ERROR_MESSAGE);

View File

@ -18,6 +18,9 @@ package org.jivesoftware.sparkimpl.plugin.gateways.transports;
import org.jivesoftware.smack.*;
import org.jivesoftware.smack.filter.IQReplyFilter;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.util.ExceptionCallback;
import org.jivesoftware.smack.util.SuccessCallback;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smackx.iqregister.packet.Registration;
import org.jivesoftware.smackx.iqprivate.PrivateDataManager;
@ -159,8 +162,9 @@ public class TransportUtils {
* @throws InterruptedException
* @throws XMPPException thrown if there was an issue registering with the gateway.
*/
public static void registerUser(XMPPConnection con, DomainBareJid gatewayDomain, String username, String password, String nickname, StanzaListener callback) throws SmackException.NotConnectedException, InterruptedException
{
public static void registerUser(XMPPConnection con, DomainBareJid gatewayDomain, String username, String password,
String nickname, SuccessCallback<IQ> callback, ExceptionCallback<Exception> exceptionCallback)
throws SmackException.NotConnectedException, InterruptedException {
Map<String, String> attributes = new HashMap<>();
if (username != null) {
attributes.put("username", username);
@ -176,7 +180,9 @@ public class TransportUtils {
registration.setTo(gatewayDomain);
registration.addExtension(new GatewayRegisterExtension());
con.sendStanzaWithResponseCallback( registration, new IQReplyFilter( registration, con ), callback);
con.sendIqRequestAsync(registration)
.onSuccess(callback)
.onError(exceptionCallback);
}
/**
@ -193,12 +199,8 @@ public class TransportUtils {
registration.setType(IQ.Type.set);
registration.setTo(gatewayDomain);
con.sendStanzaWithResponseCallback( registration, new IQReplyFilter( registration, con ), stanza -> {
IQ response = (IQ) stanza;
if (response.getType() == IQ.Type.error ) {
Log.warning( "Unable to unregister from gateway: " + stanza );
}
} );
con.sendIqRequestAsync(registration)
.onError(e -> Log.warning( "Unable to unregister from gateway: " + e));
}
@ -215,7 +217,7 @@ public class TransportUtils {
}
@Override
public String toXML(String enclosingNamespace) {
public String toXML(XmlEnvironment xmlEnvironment) {
return "<" + getElementName() + " xmlns=\"" + getNamespace() + "\"/>";
}
}

View File

@ -18,6 +18,8 @@ package org.jivesoftware.sparkimpl.plugin.history;
import org.jivesoftware.resource.Res;
import org.jivesoftware.resource.SparkRes;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.xml.SmackXmlParser;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.spark.SparkManager;
import org.jivesoftware.spark.plugin.Plugin;
import org.jivesoftware.spark.ui.ChatRoom;
@ -29,8 +31,6 @@ import org.jivesoftware.spark.util.GraphicUtils;
import org.jivesoftware.spark.util.log.Log;
import org.jxmpp.jid.EntityBareJid;
import org.jxmpp.jid.impl.JidCreate;
import org.xmlpull.mxp1.MXParser;
import org.xmlpull.v1.XmlPullParser;
import javax.swing.*;
import java.awt.*;
@ -246,18 +246,17 @@ public class ConversationHistoryPlugin implements Plugin {
// Otherwise load it.
try {
final MXParser parser = new MXParser();
parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(conFile), StandardCharsets.UTF_8));
parser.setInput(in);
final XmlPullParser parser = SmackXmlParser.newXmlParser(in);
boolean done = false;
while (!done) {
int eventType = parser.next();
if (eventType == XmlPullParser.START_TAG && "user".equals(parser.getName())) {
XmlPullParser.Event eventType = parser.next();
if (eventType == XmlPullParser.Event.START_ELEMENT && "user".equals(parser.getName())) {
EntityBareJid jid = JidCreate.entityBareFromUnescapedOrThrowUnchecked(parser.nextText());
historyList.add(jid);
}
else if (eventType == XmlPullParser.END_TAG && "conversations".equals(parser.getName())) {
else if (eventType == XmlPullParser.Event.END_ELEMENT && "conversations".equals(parser.getName())) {
done = true;
}
}

View File

@ -17,10 +17,10 @@ package org.jivesoftware.sparkimpl.plugin.jabber;
import org.jivesoftware.resource.Res;
import org.jivesoftware.resource.SparkRes;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.filter.IQReplyFilter;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IqData;
import org.jivesoftware.smack.packet.StanzaFactory;
import org.jivesoftware.smackx.time.packet.Time;
import org.jivesoftware.smackx.iqversion.packet.Version;
import org.jivesoftware.spark.SparkManager;
@ -95,36 +95,45 @@ public class VersionViewer {
cards.add(dataCard);
final XMPPConnection connection = SparkManager.getConnection();
try
{
// Load Version
final Version versionRequest = new Version();
versionRequest.setType(IQ.Type.get);
versionRequest.setTo(jid);
connection.sendStanzaWithResponseCallback( versionRequest, new IQReplyFilter( versionRequest, connection ), stanza -> {
final Version versionResult = (Version) stanza;
StanzaFactory stanzaFactory = connection.getStanzaFactory();
IqData versionIqData = stanzaFactory.buildIqData().ofType(IQ.Type.get);
IqData timeIqData = stanzaFactory.buildIqData().ofType(IQ.Type.get);
// Load Version
final Version versionRequest = new Version();
versionRequest.setType(versionIqData.getType());
versionRequest.setStanzaId(versionIqData.getStanzaId());
versionRequest.setTo(jid);
connection.sendIqRequestAsync(versionRequest)
.onSuccess(iq -> {
final Version versionResult = (Version) iq;
softwareField.setText(versionResult.getName());
versionField.setText(versionResult.getVersion());
osField.setText(versionResult.getOs());
((CardLayout)(cards.getLayout())).last( cards );
} );
// Time
final Time time = new Time();
time.setType(IQ.Type.get);
time.setTo(jid);
connection.sendStanzaWithResponseCallback( time, new IQReplyFilter( time, connection ), stanza -> {
timeField.setText( new SimpleDateFormat( ).format( ((Time)stanza).getTime()));
})
.onError(e -> {
Log.warning("Version request error: " + e, e);
((CardLayout)(cards.getLayout())).last( cards );
} );
}
catch ( SmackException.NotConnectedException | InterruptedException e )
{
Log.warning( "Unable to query for version.", e );
((CardLayout)(cards.getLayout())).last( cards );
}
});
// Time
final Time time = new Time();
time.setType(timeIqData.getType());
time.setStanzaId(timeIqData.getStanzaId());
time.setTo(jid);
connection.sendIqRequestAsync(time)
.onSuccess(iq -> {
timeField.setText( new SimpleDateFormat( ).format( ((Time)iq).getTime()));
((CardLayout)(cards.getLayout())).last( cards );
})
.onError(e -> {
Log.warning("Time request error: " + e, e);
((CardLayout)(cards.getLayout())).last( cards );
});
MessageDialog.showComponent(Res.getString("title.version.and.time"), Res.getString("message.client.information", UserManager.unescapeJID(jidString)), SparkRes.getImageIcon(SparkRes.PROFILE_IMAGE_24x24), cards, SparkManager.getMainWindow(), 400, 300, false);
}

View File

@ -16,9 +16,10 @@
package org.jivesoftware.sparkimpl.plugin.manager;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException;
import java.io.IOException;
import java.util.ArrayList;
@ -60,7 +61,7 @@ public class Features implements ExtensionElement {
}
@Override
public String toXML(String enclosingNamespace) {
public String toXML(XmlEnvironment xmlEnvironment) {
return ( "<event xmlns=\"" + NAMESPACE + "\"" ) + "</event>";
}
@ -70,19 +71,19 @@ public class Features implements ExtensionElement {
}
@Override
public Features parse( XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
public Features parse( XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException {
Features features = new Features();
boolean done = false;
while (!done) {
int eventType = parser.next();
if (eventType == XmlPullParser.START_TAG && "event".equals(parser.getName())) {
XmlPullParser.Event eventType = parser.next();
if (eventType == XmlPullParser.Event.START_ELEMENT && "event".equals(parser.getName())) {
parser.nextText();
}
if (eventType == XmlPullParser.START_TAG && "feature".equals(parser.getName())) {
if (eventType == XmlPullParser.Event.START_ELEMENT && "feature".equals(parser.getName())) {
String feature = parser.getAttributeValue("", "var");
features.addFeature(feature);
}
else if (eventType == XmlPullParser.END_TAG) {
else if (eventType == XmlPullParser.Event.END_ELEMENT) {
if ("event".equals(parser.getName())) {
done = true;
}

View File

@ -73,7 +73,7 @@ public class SparkPrivacyList {
*/
private long getMaxItemOrder() {
if(getLastItem() != null) {
return getLastItem().getOrder();
return getLastItem().getOrder().longValue();
}
return 1;
}
@ -96,8 +96,9 @@ public class SparkPrivacyList {
long order = 0;
PrivacyItem item = null;
for (PrivacyItem privacyItem : _privacyItems) {
if ( order < privacyItem.getOrder() ) {
order = privacyItem.getOrder();
final long itemsOrder = privacyItem.getOrder().longValue();
if (order < itemsOrder) {
order = itemsOrder;
item = privacyItem;
}
}

View File

@ -17,13 +17,13 @@ package org.jivesoftware.sparkimpl.plugin.scratchpad;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException;
import org.jivesoftware.smackx.iqprivate.PrivateDataManager;
import org.jivesoftware.smackx.iqprivate.packet.PrivateData;
import org.jivesoftware.smackx.iqprivate.provider.PrivateDataProvider;
import org.jivesoftware.spark.SparkManager;
import org.jivesoftware.spark.util.log.Log;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
@ -116,11 +116,11 @@ public class PrivateNotes implements PrivateData {
public PrivateData parsePrivateData(XmlPullParser parser) throws XmlPullParserException, IOException {
boolean done = false;
while (!done) {
int eventType = parser.next();
if (eventType == XmlPullParser.START_TAG && "text".equals(parser.getName())) {
XmlPullParser.Event eventType = parser.next();
if (eventType == XmlPullParser.Event.START_ELEMENT && "text".equals(parser.getName())) {
notes.setNotes(parser.nextText());
}
else if (eventType == XmlPullParser.END_TAG) {
else if (eventType == XmlPullParser.Event.END_ELEMENT) {
if ("scratchpad".equals(parser.getName())) {
done = true;
}

View File

@ -22,13 +22,13 @@ import java.util.List;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException;
import org.jivesoftware.smackx.iqprivate.PrivateDataManager;
import org.jivesoftware.smackx.iqprivate.packet.PrivateData;
import org.jivesoftware.smackx.iqprivate.provider.PrivateDataProvider;
import org.jivesoftware.spark.util.ModelUtil;
import org.jivesoftware.spark.util.log.Log;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
/**
* @author Derek DeMoro
@ -123,16 +123,16 @@ public class Tasks implements PrivateData {
public PrivateData parsePrivateData(XmlPullParser parser) throws XmlPullParserException, IOException {
boolean done = false;
while (!done) {
int eventType = parser.next();
if (eventType == XmlPullParser.START_TAG && "tasks".equals(parser.getName())) {
XmlPullParser.Event eventType = parser.next();
if (eventType == XmlPullParser.Event.START_ELEMENT && "tasks".equals(parser.getName())) {
String showAll = parser.getAttributeValue("", "showAll");
ScratchPadPlugin.SHOW_ALL_TASKS = Boolean.parseBoolean(showAll);
}
if (eventType == XmlPullParser.START_TAG && "task".equals(parser.getName())) {
if (eventType == XmlPullParser.Event.START_ELEMENT && "task".equals(parser.getName())) {
tasks.addTask(getTask(parser));
}
else if (eventType == XmlPullParser.END_TAG) {
else if (eventType == XmlPullParser.Event.END_ELEMENT) {
if ("scratchpad".equals(parser.getName())) {
done = true;
}
@ -148,29 +148,29 @@ public class Tasks implements PrivateData {
boolean done = false;
while (!done) {
int eventType = parser.next();
if (eventType == XmlPullParser.START_TAG && "title".equals(parser.getName())) {
XmlPullParser.Event eventType = parser.next();
if (eventType == XmlPullParser.Event.START_ELEMENT && "title".equals(parser.getName())) {
task.setTitle(parser.nextText());
}
if (eventType == XmlPullParser.START_TAG && "dueDate".equals(parser.getName())) {
if (eventType == XmlPullParser.Event.START_ELEMENT && "dueDate".equals(parser.getName())) {
String dueDate = parser.nextText();
task.setDueDate(Long.parseLong(dueDate));
}
if (eventType == XmlPullParser.START_TAG && "creationDate".equals(parser.getName())) {
if (eventType == XmlPullParser.Event.START_ELEMENT && "creationDate".equals(parser.getName())) {
String creationDate = parser.nextText();
task.setCreatedDate(Long.parseLong(creationDate));
}
if (eventType == XmlPullParser.START_TAG && "completed".equals(parser.getName())) {
if (eventType == XmlPullParser.Event.START_ELEMENT && "completed".equals(parser.getName())) {
String completed = parser.nextText();
if (ModelUtil.hasLength(completed)) {
task.setCompleted(Boolean.parseBoolean(completed));
}
}
else if (eventType == XmlPullParser.END_TAG) {
else if (eventType == XmlPullParser.Event.END_ELEMENT) {
if ("task".equals(parser.getName())) {
done = true;
}

View File

@ -16,6 +16,8 @@
package org.jivesoftware.sparkimpl.plugin.transcripts;
import org.jivesoftware.resource.Default;
import org.jivesoftware.smack.xml.SmackXmlParser;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.spark.SparkManager;
import org.jivesoftware.spark.util.StringUtils;
import org.jivesoftware.spark.util.log.Log;
@ -24,8 +26,6 @@ import org.jivesoftware.sparkimpl.settings.local.SettingsManager;
import org.jxmpp.jid.EntityBareJid;
import org.jxmpp.jid.Jid;
import org.jxmpp.jid.impl.JidCreate;
import org.xmlpull.mxp1.MXParser;
import org.xmlpull.v1.XmlPullParser;
import java.io.BufferedReader;
import java.io.BufferedWriter;
@ -194,17 +194,15 @@ public final class ChatTranscripts {
}
try {
final MXParser parser = new MXParser();
parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(transcriptFile), StandardCharsets.UTF_8));
parser.setInput(in);
final XmlPullParser parser = SmackXmlParser.newXmlParser(in);
boolean done = false;
while (!done) {
int eventType = parser.next();
if (eventType == XmlPullParser.START_TAG && "message".equals(parser.getName())) {
XmlPullParser.Event eventType = parser.next();
if (eventType == XmlPullParser.Event.START_ELEMENT && "message".equals(parser.getName())) {
transcript.addHistoryMessage(getHistoryMessage(parser));
}
else if (eventType == XmlPullParser.END_TAG && "transcript".equals(parser.getName())) {
else if (eventType == XmlPullParser.Event.END_ELEMENT && "transcript".equals(parser.getName())) {
done = true;
}
}
@ -246,21 +244,21 @@ public final class ChatTranscripts {
// Check for nickname
boolean done = false;
while (!done) {
int eventType = parser.next();
if (eventType == XmlPullParser.START_TAG && "to".equals(parser.getName())) {
XmlPullParser.Event eventType = parser.next();
if (eventType == XmlPullParser.Event.START_ELEMENT && "to".equals(parser.getName())) {
String jidString = parser.nextText();
Jid jid = JidCreate.from(jidString);
message.setTo(jid);
}
else if (eventType == XmlPullParser.START_TAG && "from".equals(parser.getName())) {
else if (eventType == XmlPullParser.Event.START_ELEMENT && "from".equals(parser.getName())) {
String jidString = parser.nextText();
Jid jid = JidCreate.from(jidString);
message.setFrom(jid);
}
else if (eventType == XmlPullParser.START_TAG && "body".equals(parser.getName())) {
else if (eventType == XmlPullParser.Event.START_ELEMENT && "body".equals(parser.getName())) {
message.setBody(StringUtils.unescapeFromXML(parser.nextText()));
}
else if (eventType == XmlPullParser.START_TAG && "date".equals(parser.getName())) {
else if (eventType == XmlPullParser.Event.START_ELEMENT && "date".equals(parser.getName())) {
Date d;
try {
d = FORMATTER.parse(parser.nextText());
@ -270,7 +268,7 @@ public final class ChatTranscripts {
}
message.setDate(d);
}
else if (eventType == XmlPullParser.END_TAG && "message".equals(parser.getName())) {
else if (eventType == XmlPullParser.Event.END_ELEMENT && "message".equals(parser.getName())) {
done = true;
}
}

View File

@ -29,6 +29,8 @@ import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.packet.StanzaError;
import org.jivesoftware.smack.provider.ProviderManager;
import org.jivesoftware.smack.xml.SmackXmlParser;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smackx.vcardtemp.packet.VCard;
import org.jivesoftware.smackx.vcardtemp.provider.VCardProvider;
import org.jivesoftware.spark.SparkManager;
@ -46,9 +48,6 @@ import org.jxmpp.jid.Jid;
import org.jxmpp.jid.impl.JidCreate;
import org.jxmpp.stringprep.XmppStringprepException;
import org.jxmpp.util.XmppStringUtils;
import org.xmlpull.mxp1.MXParser;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import javax.imageio.ImageIO;
import javax.swing.*;
@ -87,8 +86,6 @@ public class VCardManager {
private final File vcardStorageDirectory;
final MXParser parser;
private final LinkedBlockingQueue<BareJid> queue = new LinkedBlockingQueue<>();
private final File contactsDir;
@ -106,16 +103,6 @@ public class VCardManager {
ProviderManager.addExtensionProvider( JabberAvatarExtension.ELEMENT_NAME, JabberAvatarExtension.NAMESPACE, new JabberAvatarExtension.Provider() );
ProviderManager.addExtensionProvider( VCardUpdateExtension.ELEMENT_NAME, VCardUpdateExtension.NAMESPACE, new VCardUpdateExtension.Provider() );
// Initialize parser
parser = new MXParser();
try {
parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
}
catch (XmlPullParserException e) {
Log.error(e);
}
imageFile = new File(SparkManager.getUserDirectory(), "personal.png");
// Initialize vCard.
@ -135,13 +122,13 @@ public class VCardManager {
// Intercept all presence packets being sent and append vcard information.
StanzaFilter presenceFilter = new StanzaTypeFilter(Presence.class);
SparkManager.getConnection().addStanzaInterceptor( stanza -> {
SparkManager.getConnection().addAsyncStanzaListener( stanza -> {
Presence newPresence = (Presence)stanza;
VCardUpdateExtension update = new VCardUpdateExtension();
JabberAvatarExtension jax = new JabberAvatarExtension();
ExtensionElement updateExt = newPresence.getExtension(update.getElementName(), update.getNamespace());
ExtensionElement jabberExt = newPresence.getExtension(jax.getElementName(), jax.getNamespace());
ExtensionElement updateExt = newPresence.getExtensionElement(update.getElementName(), update.getNamespace());
ExtensionElement jabberExt = newPresence.getExtensionElement(jax.getElementName(), jax.getNamespace());
if (updateExt != null) {
newPresence.removeExtension(updateExt);
@ -765,7 +752,7 @@ public class VCardManager {
// Set timestamp
vcard.setField("timestamp", Long.toString(System.currentTimeMillis()));
final String xml = vcard.toXML(null).toString();
final String xml = vcard.toXML().toString();
File vcardFile = new File(vcardStorageDirectory, fileName);
@ -814,15 +801,15 @@ public class VCardManager {
try ( final BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(vcardFile), StandardCharsets.UTF_8)) )
{
// Otherwise load from file system.
VCardProvider provider = new VCardProvider();
parser.setInput( in );
XmlPullParser parser = SmackXmlParser.newXmlParser(in);
// Skip forward until we're at <vCard xmlns='vcard-temp'>
while ( !( parser.getEventType() == XmlPullParser.START_TAG && VCard.ELEMENT.equals( parser.getName() ) && VCard.NAMESPACE.equals( parser.getNamespace() ) ) )
while ( !( parser.getEventType() == XmlPullParser.Event.START_ELEMENT && VCard.ELEMENT.equals( parser.getName() ) && VCard.NAMESPACE.equals( parser.getNamespace() ) ) )
{
parser.next();
}
VCardProvider provider = new VCardProvider();
vcard = provider.parse( parser );
}
catch (Exception e) {

View File

@ -17,9 +17,10 @@
package org.jivesoftware.sparkimpl.profile.ext;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException;
import java.io.IOException;
@ -46,7 +47,7 @@ public class JabberAvatarExtension implements ExtensionElement {
}
@Override
public String toXML(String enclosingNamespace) {
public String toXML(XmlEnvironment xmlEnvironment) {
return "<" + getElementName() + " xmlns=\"" + getNamespace() + "\">"
+ "<hash>" + photoHash + "</hash>"
+ "</" + getElementName() + ">";
@ -58,23 +59,26 @@ public class JabberAvatarExtension implements ExtensionElement {
}
@Override
public JabberAvatarExtension parse( XmlPullParser parser, int i ) throws XmlPullParserException, IOException {
public JabberAvatarExtension parse(XmlPullParser parser, int i, XmlEnvironment xmlEnvironment)
throws XmlPullParserException, IOException {
final JabberAvatarExtension result = new JabberAvatarExtension();
while ( true )
{
parser.next();
String elementName = parser.getName();
String elementName;
switch ( parser.getEventType() )
{
case XmlPullParser.START_TAG:
case START_ELEMENT:
elementName = parser.getName();
if ( "photo".equals( elementName ) )
{
result.setPhotoHash( parser.nextText() );
}
break;
case XmlPullParser.END_TAG:
case END_ELEMENT:
elementName = parser.getName();
if ( ELEMENT_NAME.equals( elementName ) )
{
return result;

View File

@ -17,9 +17,10 @@
package org.jivesoftware.sparkimpl.profile.ext;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException;
import java.io.IOException;
@ -50,7 +51,7 @@ public class VCardUpdateExtension implements ExtensionElement {
}
@Override
public String toXML(String enclosingNamespace) {
public String toXML(XmlEnvironment xmlEnvironment) {
return "<" + getElementName() + " xmlns=\"" + getNamespace() + "\">"
+ "<photo>"
+ photoHash
@ -64,7 +65,8 @@ public class VCardUpdateExtension implements ExtensionElement {
}
@Override
public VCardUpdateExtension parse( XmlPullParser parser, int i ) throws XmlPullParserException, IOException {
public VCardUpdateExtension parse(XmlPullParser parser, int i, XmlEnvironment xmlEnvironment)
throws XmlPullParserException, IOException {
final VCardUpdateExtension result = new VCardUpdateExtension();
while ( true )
@ -73,14 +75,14 @@ public class VCardUpdateExtension implements ExtensionElement {
String elementName = parser.getName();
switch ( parser.getEventType() )
{
case XmlPullParser.START_TAG:
case START_ELEMENT:
if ( "photo".equals( elementName ) )
{
result.setPhotoHash( parser.nextText() );
}
break;
case XmlPullParser.END_TAG:
case END_ELEMENT:
if ( ELEMENT_NAME.equals( elementName ) )
{
return result;

View File

@ -19,7 +19,7 @@ package org.jivesoftware.sparkimpl.search.users;
import org.jivesoftware.resource.Res;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smackx.xdata.Form;
import org.jivesoftware.smackx.xdata.packet.DataForm;
import org.jivesoftware.smackx.search.ReportedData;
import org.jivesoftware.smackx.search.UserSearchManager;
import org.jivesoftware.spark.SparkManager;
@ -52,7 +52,7 @@ public class SearchForm extends JPanel {
private DataFormUI questionForm;
private UserSearchManager searchManager;
private final DomainBareJid serviceName;
private Form searchForm;
private DataForm searchForm;
// TODO: Constructor should use DomainBareJid type instead of String.
public SearchForm(String serviceString) {
@ -115,7 +115,7 @@ public class SearchForm extends JPanel {
return questionForm;
}
public Form getSearchForm() {
public DataForm getSearchForm() {
return searchForm;
}
@ -131,7 +131,7 @@ public class SearchForm extends JPanel {
@Override
public Object construct() {
try {
Form answerForm = questionForm.getFilledForm();
DataForm answerForm = questionForm.getFilledForm();
data = searchManager.getSearchResults(answerForm, serviceName);
}
catch (XMPPException | SmackException | InterruptedException e) {

View File

@ -21,8 +21,8 @@ import org.jivesoftware.resource.Res;
import org.jivesoftware.resource.SparkRes;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smackx.xdata.Form;
import org.jivesoftware.smackx.search.UserSearchManager;
import org.jivesoftware.smackx.xdata.packet.DataForm;
import org.jivesoftware.spark.SparkManager;
import org.jivesoftware.spark.component.TitlePanel;
import org.jivesoftware.spark.ui.DataFormUI;
@ -162,7 +162,7 @@ public class UserSearchForm extends JPanel {
if (ModelUtil.hasLength(serviceName)) {
SwingWorker findServiceThread = new SwingWorker() {
Form newForm;
DataForm newForm;
@Override
public Object construct() {
@ -257,10 +257,14 @@ public class UserSearchForm extends JPanel {
cardLayout.show(cardPanel, service);
SearchForm searchForm = serviceMap.get(service);
Form form = searchForm.getSearchForm();
String description = form.getInstructions(); //XXX maybe add a Spark String instead
DataForm form = searchForm.getSearchForm();
StringBuilder description = new StringBuilder();
for (String instruction : form.getInstructions()) {
description.append(instruction).append('\n');
}
titlePanel.setTitle(Res.getString("title.person.search"));
titlePanel.setDescription(description);
titlePanel.setDescription(description.toString());
}

View File

@ -16,10 +16,10 @@
package org.jivesoftware.sparkimpl.settings;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException;
import org.jivesoftware.smackx.iqprivate.packet.PrivateData;
import org.jivesoftware.smackx.iqprivate.provider.PrivateDataProvider;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
import java.util.HashMap;

View File

@ -18,9 +18,10 @@ package org.jivesoftware.sparkimpl.updater;
import org.jivesoftware.Spark;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.provider.IQProvider;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException;
import java.io.IOException;
import java.util.Date;
@ -122,13 +123,13 @@ public class SparkVersion extends IQ {
}
@Override
public SparkVersion parse(XmlPullParser parser, int i) throws XmlPullParserException, IOException{
public SparkVersion parse(XmlPullParser parser, int i, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException{
SparkVersion version = new SparkVersion();
boolean done = false;
while (!done) {
int eventType = parser.next();
if (eventType == XmlPullParser.START_TAG) {
XmlPullParser.Event eventType = parser.next();
if (eventType == XmlPullParser.Event.START_ELEMENT) {
switch (parser.getName()) {
case "version":
version.setVersion(parser.nextText());
@ -146,7 +147,7 @@ public class SparkVersion extends IQ {
}
}
else if (eventType == XmlPullParser.END_TAG) {
else if (eventType == XmlPullParser.Event.END_ELEMENT) {
if (parser.getName().equals(ELEMENT_NAME)) {
done = true;
}

View File

@ -17,8 +17,11 @@ package org.jivesoftware.fastpath.internal;
import org.jivesoftware.spark.component.CheckBoxList;
import org.jivesoftware.spark.util.ModelUtil;
import org.jivesoftware.smackx.xdata.Form;
import org.jivesoftware.smackx.xdata.FormField;
import org.jivesoftware.smackx.xdata.FormFieldWithOptions;
import org.jivesoftware.smackx.xdata.ListSingleFormField;
import org.jivesoftware.smackx.xdata.form.FillableForm;
import org.jivesoftware.smackx.xdata.form.Form;
import java.awt.Component;
import java.awt.GridBagConstraints;
@ -75,8 +78,8 @@ public class WorkgroupDataForm extends JPanel {
private void buildUI(Form form) {
// Add default answers to the form to submit
for ( final FormField field : form.getFields() ) {
String variable = field.getVariable();
for ( final FormField field : form.getDataForm().getFields() ) {
String variable = field.getFieldName();
if(field.isRequired()){
requiredList.add(variable);
}
@ -107,8 +110,11 @@ public class WorkgroupDataForm extends JPanel {
else if (type.equals(FormField.Type.text_multi) ||
type.equals(FormField.Type.jid_multi)) {
StringBuilder buf = new StringBuilder();
for ( final FormField.Option option : field.getOptions() ) {
buf.append(option);
if (field instanceof FormFieldWithOptions) {
FormFieldWithOptions formFieldWithOptions = (FormFieldWithOptions) field;
for ( final FormField.Option option : formFieldWithOptions.getOptions() ) {
buf.append(option);
}
}
addField(label, new JTextArea(buf.toString()), variable);
}
@ -116,8 +122,9 @@ public class WorkgroupDataForm extends JPanel {
addField(label, new JPasswordField(), variable);
}
else if (type.equals(FormField.Type.list_single)) {
ListSingleFormField listSingleFormField = field.ifPossibleAsOrThrow(ListSingleFormField.class);
JComboBox<FormField.Option> box = new JComboBox<>();
for ( final FormField.Option option : field.getOptions() ) {
for ( final FormField.Option option : listSingleFormField.getOptions() ) {
box.addItem(option);
}
if (valueList.size() > 0) {
@ -142,10 +149,10 @@ public class WorkgroupDataForm extends JPanel {
*
* @return the answered DataForm.
*/
public Form getFilledForm() {
public FillableForm getFilledForm() {
// Now submit all information
Iterator<String> valueIter = valueMap.keySet().iterator();
Form answerForm = searchForm.createAnswerForm();
FillableForm answerForm = searchForm.getFillableForm();
while (valueIter.hasNext()) {
String answer = valueIter.next();
Object o = valueMap.get(answer);
@ -172,7 +179,7 @@ public class WorkgroupDataForm extends JPanel {
}
else if (o instanceof JComboBox) {
Object v = ((JComboBox<?>) o).getSelectedItem();
String value = (v instanceof FormField.Option) ? ((FormField.Option) v).getValue() : (String) v;
String value = (v instanceof FormField.Option) ? ((FormField.Option) v).getValue().toString() : (String) v;
List<String> list = new ArrayList<>();
list.add(value);
@ -194,13 +201,6 @@ public class WorkgroupDataForm extends JPanel {
answerForm.setAnswer(variable, value);
}
for (String variable : requiredList) {
FormField field = answerForm.getField(variable);
if (field != null) {
field.setRequired(true);
}
}
return answerForm;
}

View File

@ -44,8 +44,10 @@ 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.xdata.Form;
import org.jivesoftware.smackx.xdata.FormField;
import org.jivesoftware.smackx.xdata.form.FillableForm;
import org.jivesoftware.smackx.xdata.form.FilledForm;
import org.jivesoftware.smackx.xdata.form.Form;
import org.jivesoftware.smackx.vcardtemp.packet.VCard;
import org.jivesoftware.smackx.workgroup.settings.ChatSetting;
import org.jivesoftware.smackx.workgroup.settings.ChatSettings;
@ -223,16 +225,18 @@ public class WorkgroupManager {
final JButton submitButton = new JButton("Start Chat!");
submitButton.addActionListener(e -> {
if (validateForm(workgroupDialog, workgroupForm, formUI.getFilledForm())) {
enterQueue(contactItem.getJid().asEntityBareJidOrThrow(), formUI.getFilledForm());
FillableForm form = formUI.getFilledForm();
if (validateForm(workgroupDialog, workgroupForm, form)) {
enterQueue(contactItem.getJid().asEntityBareJidOrThrow(), form);
workgroupDialog.dispose();
}
});
formUI.setEnterListener(() -> {
if (validateForm(workgroupDialog, workgroupForm, formUI.getFilledForm())) {
enterQueue(contactItem.getJid().asEntityBareJidOrThrow(), formUI.getFilledForm());
FillableForm form = formUI.getFilledForm();
if (validateForm(workgroupDialog, workgroupForm, form)) {
enterQueue(contactItem.getJid().asEntityBareJidOrThrow(), form);
workgroupDialog.dispose();
}
});
@ -249,10 +253,10 @@ public class WorkgroupManager {
workgroupDialog.setVisible(true);
}
private static boolean validateForm(JDialog parent, Form workgroupForm, Form form) {
for ( final FormField field : form.getFields()) {
private static boolean validateForm(JDialog parent, Form workgroupForm, FilledForm form) {
for ( final FormField field : form.getDataForm().getFields()) {
if (field.isRequired() && field.getValues().isEmpty()) {
String variable = field.getVariable();
String variable = field.getFieldName();
String elementName = workgroupForm.getField(variable).getLabel();
UIManager.put("OptionPane.okButtonText", Res.getString("ok"));
JOptionPane.showMessageDialog(parent, variable + " is required to complete the form.", "Incomplete Form", JOptionPane.ERROR_MESSAGE);
@ -282,7 +286,7 @@ public class WorkgroupManager {
}
}
private void enterQueue(EntityBareJid workgroupJID, Form form) {
private void enterQueue(EntityBareJid workgroupJID, FillableForm form) {
Localpart workgroupName = workgroupJID.getLocalpart();
final JDialog workgroupDialog = new JDialog(SparkManager.getMainWindow(), workgroupName + " Workgroup");

View File

@ -37,7 +37,7 @@ import org.jivesoftware.smackx.muc.MultiUserChat;
import org.jivesoftware.smackx.workgroup.MetaData;
import org.jivesoftware.smackx.workgroup.agent.*;
import org.jivesoftware.smackx.workgroup.user.Workgroup;
import org.jivesoftware.smackx.xdata.Form;
import org.jivesoftware.smackx.xdata.form.Form;
import org.jivesoftware.spark.DataManager;
import org.jivesoftware.spark.SparkManager;
import org.jivesoftware.spark.component.RolloverButton;

View File

@ -19,8 +19,8 @@ import org.jivesoftware.fastpath.FpRes;
import org.jivesoftware.fastpath.internal.LiveTitlePane;
import org.jivesoftware.fastpath.resources.FastpathRes;
import org.jivesoftware.fastpath.workspace.util.RequestUtils;
import org.jivesoftware.smackx.xdata.Form;
import org.jivesoftware.smackx.xdata.FormField;
import org.jivesoftware.smackx.xdata.form.Form;
import org.jivesoftware.spark.SparkManager;
import org.jivesoftware.spark.component.LinkLabel;
import org.jivesoftware.spark.component.WrappedLabel;
@ -97,8 +97,8 @@ public class RoomInformation extends JPanel {
setBackground(Color.white);
int count = 1;
for ( final FormField field : form.getFields() ) {
String variable = field.getVariable();
for ( final FormField field : form.getDataForm().getFields() ) {
String variable = field.getFieldName();
String label = field.getLabel();
if (label != null) {
final JLabel nameLabel = new JLabel(label);

View File

@ -46,7 +46,7 @@ import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smackx.muc.MultiUserChatManager;
import org.jivesoftware.smackx.xdata.Form;
import org.jivesoftware.smackx.xdata.form.FillableForm;
import org.jivesoftware.smackx.muc.Affiliate;
import org.jivesoftware.smackx.muc.MultiUserChat;
import org.jivesoftware.smackx.workgroup.agent.AgentRoster;
@ -319,7 +319,7 @@ public final class AgentConversations extends JPanel implements ChangeListener {
}
}
if (list.size() > 0) {
Form form = muc.getConfigurationForm().createAnswerForm();
FillableForm form = muc.getConfigurationForm().getFillableForm();
List<String> listStrings = JidUtil.toStringList(list);
form.setAnswer("muc#roomconfig_roomowners", listStrings);

View File

@ -39,8 +39,8 @@ import org.jivesoftware.fastpath.workspace.assistants.RoomInformation;
import org.jivesoftware.fastpath.workspace.util.RequestUtils;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smackx.xdata.Form;
import org.jivesoftware.smackx.xdata.FormField;
import org.jivesoftware.smackx.xdata.form.Form;
import org.jivesoftware.smackx.workgroup.agent.Offer;
import org.jivesoftware.spark.component.LinkLabel;
import org.jivesoftware.spark.component.RolloverButton;
@ -115,8 +115,8 @@ public class ChatQueue extends JPanel {
Color linkColor = new Color(69, 92, 137);
int count = 1;
for ( final FormField field : form.getFields() ) {
String variable = field.getVariable();
for ( final FormField field : form.getDataForm().getFields() ) {
String variable = field.getFieldName();
String label = field.getLabel();
if (label != null) {
final JLabel nameLabel = new JLabel(label);

View File

@ -49,7 +49,7 @@ import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smackx.muc.MultiUserChatManager;
import org.jivesoftware.smackx.xdata.Form;
import org.jivesoftware.smackx.xdata.form.FillableForm;
import org.jivesoftware.smackx.muc.Affiliate;
import org.jivesoftware.smackx.muc.MultiUserChat;
import org.jivesoftware.smackx.workgroup.agent.AgentRoster;
@ -272,7 +272,7 @@ public final class CurrentActivity extends JPanel {
}
}
if (list.size() > 0) {
Form form = muc.getConfigurationForm().createAnswerForm();
FillableForm form = muc.getConfigurationForm().getFillableForm();
List<String> jidStrings = new ArrayList<>(list.size());
JidUtil.toStrings(list, jidStrings);
form.setAnswer("muc#roomconfig_roomowners", jidStrings);

View File

@ -42,7 +42,7 @@ import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smackx.muc.MultiUserChatManager;
import org.jivesoftware.smackx.xdata.Form;
import org.jivesoftware.smackx.xdata.form.FillableForm;
import org.jivesoftware.smackx.muc.Affiliate;
import org.jivesoftware.smackx.muc.MultiUserChat;
import org.jivesoftware.smackx.workgroup.MetaData;
@ -271,7 +271,7 @@ public class InvitationPane {
}
if (list.size() > 0) {
try {
Form form = muc.getConfigurationForm().createAnswerForm();
FillableForm form = muc.getConfigurationForm().getFillableForm();
List<String> jidStrings = new ArrayList<>(list.size());
JidUtil.toStrings(list, jidStrings);
form.setAnswer("muc#roomconfig_roomowners", jidStrings);

View File

@ -43,7 +43,7 @@ import org.jivesoftware.fastpath.workspace.util.RequestUtils;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smackx.muc.MultiUserChatManager;
import org.jivesoftware.smackx.xdata.Form;
import org.jivesoftware.smackx.xdata.form.FillableForm;
import org.jivesoftware.smackx.muc.Affiliate;
import org.jivesoftware.smackx.muc.MultiUserChat;
import org.jivesoftware.smackx.workgroup.agent.Offer;
@ -329,7 +329,7 @@ public class UserInvitationPane {
}
if (list.size() > 0) {
try {
Form form = muc.getConfigurationForm().createAnswerForm();
FillableForm form = muc.getConfigurationForm().getFillableForm();
List<String> jidStrings = JidUtil.toStringList(list);
form.setAnswer("muc#roomconfig_roomowners", jidStrings);

View File

@ -39,10 +39,11 @@ import org.jivesoftware.fastpath.workspace.panes.ChatViewer;
import org.jivesoftware.fastpath.workspace.panes.HistoryItemRenderer;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smackx.xdata.Form;
import org.jivesoftware.smackx.search.ReportedData;
import org.jivesoftware.smackx.workgroup.agent.AgentSession;
import org.jivesoftware.smackx.workgroup.packet.Transcript;
import org.jivesoftware.smackx.xdata.form.FillableForm;
import org.jivesoftware.smackx.xdata.form.Form;
import org.jivesoftware.spark.SparkManager;
import org.jivesoftware.spark.search.Searchable;
import org.jivesoftware.spark.util.GraphicUtils;
@ -73,7 +74,7 @@ public class ChatSearch implements Searchable {
AgentSession agentSession = FastpathPlugin.getAgentSession();
try {
Form form = agentSession.getTranscriptSearchForm();
Form filledForm = form.createAnswerForm();
FillableForm filledForm = form.getFillableForm();
filledForm.setAnswer("queryString", query);
// Define Workgroups

View File

@ -16,9 +16,10 @@
package org.jivesoftware.spark.plugin.fileupload;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.provider.IQProvider;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException;
import java.io.IOException;
@ -63,16 +64,16 @@ public class UploadRequest extends IQ
super();
}
public UploadRequest parse( XmlPullParser parser, int i ) throws XmlPullParserException, IOException
public UploadRequest parse(XmlPullParser parser, int i, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException
{
final UploadRequest uploadRequest = new UploadRequest();
boolean done = false;
while ( !done )
{
int eventType = parser.next();
XmlPullParser.Event eventType = parser.next();
if ( eventType == XmlPullParser.START_TAG )
if ( eventType == XmlPullParser.Event.START_ELEMENT )
{
if ( parser.getName().equals( "put" ) )
{
@ -84,7 +85,7 @@ public class UploadRequest extends IQ
}
}
else if ( eventType == XmlPullParser.END_TAG )
else if ( eventType == XmlPullParser.Event.END_ELEMENT )
{
if ( parser.getName().equals( "slot" ) )
{

View File

@ -16,9 +16,10 @@
package org.jivesoftware.game.reversi;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException;
import java.io.IOException;
@ -41,7 +42,7 @@ public class GameForfeit implements ExtensionElement {
}
@Override
public String toXML(String enclosingNamespace) {
public String toXML(XmlEnvironment xmlEnvironment) {
return "<" + ELEMENT_NAME + " xmlns=\"" + NAMESPACE + "\">"
+ "<gameID>" + gameID
+ "</gameID>"
@ -69,15 +70,15 @@ public class GameForfeit implements ExtensionElement {
public static class Provider extends ExtensionElementProvider<GameForfeit>
{
public GameForfeit parse( XmlPullParser parser, int initialDepth ) throws XmlPullParserException, IOException
public GameForfeit parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException
{
final GameForfeit gameForfeit = new GameForfeit();
boolean done = false;
while ( !done )
{
final int eventType = parser.next();
final XmlPullParser.Event eventType = parser.next();
if ( eventType == XmlPullParser.START_TAG )
if ( eventType == XmlPullParser.Event.START_ELEMENT )
{
if ( "gameID".equals( parser.getName() ) )
{
@ -85,7 +86,7 @@ public class GameForfeit implements ExtensionElement {
gameForfeit.setGameID( gameID );
}
}
else if ( eventType == XmlPullParser.END_TAG )
else if ( eventType == XmlPullParser.Event.END_ELEMENT )
{
if ( ELEMENT_NAME.equals( parser.getName() ) )
{

View File

@ -16,9 +16,10 @@
package org.jivesoftware.game.reversi;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException;
import java.io.IOException;
@ -49,7 +50,7 @@ public class GameMove implements ExtensionElement {
}
@Override
public String toXML(String enclosingNamespace) {
public String toXML(XmlEnvironment xmlEnvironment) {
return "<" + ELEMENT_NAME + " xmlns=\"" + NAMESPACE + "\">"
+ "<gameID>" + gameID + "</gameID>"
+ "<position>" + position + "</position>"
@ -97,15 +98,15 @@ public class GameMove implements ExtensionElement {
public static class Provider extends ExtensionElementProvider<GameMove>
{
public GameMove parse( XmlPullParser parser, int initialDepth ) throws XmlPullParserException, IOException
public GameMove parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException
{
final GameMove gameMove = new GameMove();
boolean done = false;
while ( !done )
{
final int eventType = parser.next();
final XmlPullParser.Event eventType = parser.next();
if ( eventType == XmlPullParser.START_TAG )
if ( eventType == XmlPullParser.Event.START_ELEMENT )
{
if ( "gameID".equals( parser.getName() ) )
{
@ -118,7 +119,7 @@ public class GameMove implements ExtensionElement {
gameMove.setPosition( position );
}
}
else if ( eventType == XmlPullParser.END_TAG )
else if ( eventType == XmlPullParser.Event.END_ELEMENT )
{
if ( ELEMENT_NAME.equals( parser.getName() ) )
{

View File

@ -16,9 +16,10 @@
package org.jivesoftware.game.reversi;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.provider.IQProvider;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException;
import java.io.IOException;
import java.util.Random;
@ -109,15 +110,15 @@ public class GameOffer extends IQ
super();
}
public GameOffer parse( XmlPullParser parser, int i ) throws XmlPullParserException, IOException
public GameOffer parse(XmlPullParser parser, int i, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException
{
final GameOffer gameOffer = new GameOffer();
boolean done = false;
while ( !done )
{
int eventType = parser.next();
if ( eventType == XmlPullParser.START_TAG )
XmlPullParser.Event eventType = parser.next();
if ( eventType == XmlPullParser.Event.START_ELEMENT )
{
if ( parser.getName().equals( "gameID" ) )
{
@ -131,7 +132,7 @@ public class GameOffer extends IQ
}
}
else if ( eventType == XmlPullParser.END_TAG )
else if ( eventType == XmlPullParser.Event.END_ELEMENT )
{
if ( parser.getName().equals( ELEMENT_NAME ) )
{
@ -142,5 +143,6 @@ public class GameOffer extends IQ
return gameOffer;
}
}
}

View File

@ -27,8 +27,9 @@ import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.StanzaListener;
import org.jivesoftware.smack.filter.StanzaExtensionFilter;
import org.jivesoftware.smack.packet.DefaultExtensionElement;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.StandardExtensionElement;
import org.jivesoftware.spark.util.log.Log;
import org.jxmpp.jid.Jid;
@ -143,17 +144,22 @@ public class ReversiPanel extends JPanel {
*/
public void sendForfeit() throws SmackException.NotConnectedException
{
DefaultExtensionElement forfeit = new DefaultExtensionElement(GameForfeit.ELEMENT_NAME, GameForfeit.NAMESPACE);
forfeit.setValue("gameID", Integer.toString(gameID));
Message message = new Message();
message.setTo(opponentJID);
message.addExtension(forfeit);
ExtensionElement forfeit = StandardExtensionElement.builder(GameForfeit.ELEMENT_NAME, GameForfeit.NAMESPACE)
.addElement("gameID", Integer.toString(gameID))
.build();
Message message = connection.getStanzaFactory()
.buildMessageStanza()
.to(opponentJID)
.addExtension(forfeit)
.build();
try {
connection.sendStanza(message);
} catch (InterruptedException e) {
throw new IllegalStateException(e);
} finally {
connection.removeAsyncStanzaListener(gameMoveListener);
}
connection.removeAsyncStanzaListener(gameMoveListener);
}
public void paintComponent(Graphics g) {

View File

@ -19,9 +19,10 @@ import java.io.IOException;
import java.util.Random;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.provider.IQProvider;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException;
/**
* The Game Offer Packet
@ -100,15 +101,15 @@ public class GameOfferPacket extends IQ {
super();
}
public GameOfferPacket parse( XmlPullParser parser, int i ) throws XmlPullParserException, IOException
public GameOfferPacket parse(XmlPullParser parser, int i, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException
{
final GameOfferPacket gameOffer = new GameOfferPacket();
boolean done = false;
while ( !done )
{
int eventType = parser.next();
if ( eventType == XmlPullParser.START_TAG )
XmlPullParser.Event eventType = parser.next();
if ( eventType == XmlPullParser.Event.START_ELEMENT )
{
if ( parser.getName().equals( "gameID" ) )
{
@ -122,7 +123,7 @@ public class GameOfferPacket extends IQ {
}
}
else if ( eventType == XmlPullParser.END_TAG )
else if ( eventType == XmlPullParser.Event.END_ELEMENT )
{
if ( parser.getName().equals( ELEMENT_NAME ) )
{

View File

@ -1,9 +1,10 @@
package tic.tac.toe.packet;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException;
import java.io.IOException;
@ -51,7 +52,7 @@ public class InvalidMove implements ExtensionElement {
}
@Override
public String toXML(String enclosingNamespace) {
public String toXML(XmlEnvironment xmlEnvironment) {
return "<" + ELEMENT_NAME + " xmlns=\"" + NAMESPACE + "\">"
+ "<gameID>" + _gameID + "</gameID>"
@ -62,15 +63,15 @@ public class InvalidMove implements ExtensionElement {
public static class Provider extends ExtensionElementProvider<InvalidMove>
{
public InvalidMove parse( XmlPullParser parser, int initialDepth ) throws XmlPullParserException, IOException
public InvalidMove parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException
{
final InvalidMove gameMove = new InvalidMove();
boolean done = false;
while ( !done )
{
final int eventType = parser.next();
final XmlPullParser.Event eventType = parser.next();
if ( eventType == XmlPullParser.START_TAG )
if ( eventType == XmlPullParser.Event.START_ELEMENT )
{
if ( "gameID".equals( parser.getName() ) )
{
@ -88,7 +89,7 @@ public class InvalidMove implements ExtensionElement {
gameMove.setPositionY( position );
}
}
else if ( eventType == XmlPullParser.END_TAG )
else if ( eventType == XmlPullParser.Event.END_ELEMENT )
{
if ( ELEMENT_NAME.equals( parser.getName() ) )
{

View File

@ -16,9 +16,10 @@
package tic.tac.toe.packet;
import org.jivesoftware.smack.packet.ExtensionElement;
import org.jivesoftware.smack.packet.XmlEnvironment;
import org.jivesoftware.smack.provider.ExtensionElementProvider;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.jivesoftware.smack.xml.XmlPullParser;
import org.jivesoftware.smack.xml.XmlPullParserException;
import java.io.IOException;
@ -72,7 +73,7 @@ public class MovePacket implements ExtensionElement {
}
@Override
public String toXML(String enclosingNamespace) {
public String toXML(XmlEnvironment xmlEnvironment) {
return "<" + ELEMENT_NAME + " xmlns=\"" + NAMESPACE + "\">"
+ "<gameID>" + gameID + "</gameID>"
+ "<positionX>" + posx + "</positionX>"
@ -82,15 +83,15 @@ public class MovePacket implements ExtensionElement {
public static class Provider extends ExtensionElementProvider<MovePacket>
{
public MovePacket parse( XmlPullParser parser, int initialDepth ) throws XmlPullParserException, IOException
public MovePacket parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmlPullParserException, IOException
{
final MovePacket gameMove = new MovePacket();
boolean done = false;
while ( !done )
{
final int eventType = parser.next();
final XmlPullParser.Event eventType = parser.next();
if ( eventType == XmlPullParser.START_TAG )
if ( eventType == XmlPullParser.Event.START_ELEMENT )
{
if ( "gameID".equals( parser.getName() ) )
{
@ -108,7 +109,7 @@ public class MovePacket implements ExtensionElement {
gameMove.setPositionY( position );
}
}
else if ( eventType == XmlPullParser.END_TAG )
else if ( eventType == XmlPullParser.Event.END_ELEMENT )
{
if ( ELEMENT_NAME.equals( parser.getName() ) )
{

View File

@ -92,7 +92,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<dependency.smack.version>4.3.4</dependency.smack.version>
<dependency.smack.version>4.4.4</dependency.smack.version>
</properties>
<build>