use of org.jivesoftware.smackx.xdata.packet.DataForm in project xabber-android by redsolution.
the class SSNManager method onTerminateReceived.
private void onTerminateReceived(String account, String from, String session) {
if (sessionStates.get(account, session) == null)
return;
sessionStates.remove(account, session);
DataForm dataForm = Feature.createDataForm(DataFormType.result);
Feature.addTerminateField(dataForm);
sendFeature(account, from, session, new Feature(dataForm));
}
use of org.jivesoftware.smackx.xdata.packet.DataForm in project xabber-android by redsolution.
the class SSNManager method onSubmitReceived.
private void onSubmitReceived(String account, String from, String bareAddress, String session, Feature feature) {
if (feature.getTerminateValue() != null) {
onTerminateReceived(account, from, session);
return;
}
if (!isAccepted(account, from, bareAddress, session, feature))
return;
OtrMode otrMode = getOtrMode(account, bareAddress, session);
LoggingValue loggingValue = feature.getLoggingValue();
if (loggingValue == null || otrMode.acceptLoggingValue(loggingValue)) {
DataForm dataForm = Feature.createDataForm(DataFormType.result);
if (feature.getAcceptValue() != null)
Feature.addAcceptField(dataForm, true);
else
Feature.addRenegotiateField(dataForm, true);
sendFeature(account, from, session, new Feature(dataForm));
sessionStates.put(account, session, SessionState.active);
} else {
DataForm dataForm = Feature.createDataForm(DataFormType.result);
if (feature.getAcceptValue() != null) {
Feature.addAcceptField(dataForm, false);
sessionStates.remove(account, session);
} else
Feature.addRenegotiateField(dataForm, false);
sendFeature(account, from, session, new Feature(dataForm));
}
}
use of org.jivesoftware.smackx.xdata.packet.DataForm in project Spark by igniterealtime.
the class ConferenceUtils method getCreationDate.
/**
* Retrieve the date (in yyyyMMdd) format of the time the room was created.
*
* @param roomJID the jid of the room.
* @return the formatted date.
* @throws Exception throws an exception if we are unable to retrieve the date.
*/
public static String getCreationDate(String roomJID) throws Exception {
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(SparkManager.getConnection());
final DateFormat dateFormatter = new SimpleDateFormat("yyyyMMdd'T'HH:mm:ss");
DiscoverInfo infoResult = discoManager.discoverInfo(roomJID);
DataForm dataForm = infoResult.getExtension("x", "jabber:x:data");
if (dataForm == null) {
return "Not available";
}
String creationDate = "";
for (final FormField field : dataForm.getFields()) {
String label = field.getLabel();
if (label != null && "Creation date".equalsIgnoreCase(label)) {
for (String value : field.getValues()) {
creationDate = value;
Date date = dateFormatter.parse(creationDate);
creationDate = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.MEDIUM).format(date);
}
}
}
return creationDate;
}
use of org.jivesoftware.smackx.xdata.packet.DataForm in project xabber-android by redsolution.
the class NextMamManager method getNewMamForm.
/**
* UTILS
*/
private static DataForm getNewMamForm() {
FormField field = new FormField(FormField.FORM_TYPE);
field.setType(FormField.Type.hidden);
field.addValue(MamElements.NAMESPACE);
DataForm form = new DataForm(DataForm.Type.submit);
form.addField(field);
return form;
}
use of org.jivesoftware.smackx.xdata.packet.DataForm in project xabber-android by redsolution.
the class HttpFileUploadManager method parseFileMessage.
public static RealmList<Attachment> parseFileMessage(Stanza packet) {
RealmList<Attachment> attachments = new RealmList<>();
// parsing data references
List<RefMedia> refMediaList = ReferencesManager.getMediaFromReferences(packet);
if (!refMediaList.isEmpty()) {
for (RefMedia media : refMediaList) {
attachments.add(refMediaToAttachment(media));
}
}
// parsing data forms
DataForm dataForm = DataForm.from(packet);
if (dataForm != null) {
List<FormField> fields = dataForm.getFields();
for (FormField field : fields) {
if (field instanceof ExtendedFormField) {
ExtendedFormField.Media media = ((ExtendedFormField) field).getMedia();
attachments.add(mediaToAttachment(media, field.getLabel()));
}
}
}
return attachments;
}
Aggregations