use of org.jxmpp.stringprep.XmppStringprepException in project Spark by igniterealtime.
the class ReceiveFileTransfer method saveEventToHistory.
/**
* Adds an event text as a message to transcript and saves it to history
* @param eventText Contains file transfer event text
*/
private void saveEventToHistory(String eventText) {
try {
Message message = new Message(nickname, eventText);
message.setFrom(SparkManager.getSessionManager().getJID());
chatRoom.addToTranscript(message, false);
SparkManager.getWorkspace().getTranscriptPlugin().persistChatRoom(chatRoom);
} catch (XmppStringprepException e) {
e.printStackTrace();
}
}
use of org.jxmpp.stringprep.XmppStringprepException in project Spark by igniterealtime.
the class BuzzRoomDecorator method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
Jid jid;
try {
jid = JidCreate.from(((ChatRoomImpl) chatRoom).getParticipantJID());
} catch (XmppStringprepException exception) {
throw new IllegalStateException(exception);
}
XMPPConnection connection = SparkManager.getConnection();
Message message = connection.getStanzaFactory().buildMessageStanza().to(jid).addExtension(new AttentionExtension()).build();
try {
connection.sendStanza(message);
} catch (SmackException.NotConnectedException | InterruptedException e1) {
Log.warning("Unable to send stanza to " + jid, e1);
}
chatRoom.getTranscriptWindow().insertNotificationMessage(Res.getString("message.buzz.sent"), ChatManager.NOTIFICATION_COLOR);
buzzButton.setEnabled(false);
// Enable the button after 30 seconds to prevent abuse.
final TimerTask enableTask = new SwingTimerTask() {
@Override
public void doRun() {
buzzButton.setEnabled(true);
}
};
TaskEngine.getInstance().schedule(enableTask, 30000);
}
use of org.jxmpp.stringprep.XmppStringprepException in project Spark by igniterealtime.
the class PrivacyPresenceHandler method setIconsForItem.
private void setIconsForItem(PrivacyItem item) throws SmackException.NotConnectedException {
if (item.getType().equals(PrivacyItem.Type.jid)) {
Jid jid;
try {
jid = JidCreate.from(item.getValue());
} catch (XmppStringprepException e) {
throw new IllegalStateException(e);
}
setBlockedIconToContact(jid);
if (item.isFilterPresenceOut()) {
sendUnavailableTo(jid);
}
}
if (item.getType().equals(PrivacyItem.Type.group)) {
ContactGroup group = SparkManager.getWorkspace().getContactList().getContactGroup(item.getValue());
for (ContactItem contact : group.getContactItems()) {
setBlockedIconToContact(contact.getJid());
if (item.isFilterPresenceOut()) {
sendUnavailableTo(contact.getJid());
}
}
}
}
use of org.jxmpp.stringprep.XmppStringprepException in project Spark by igniterealtime.
the class TransportUtils method isRegistered.
/**
* Checks if the user is registered with a gateway.
*
* @param con the XMPPConnection.
* @param transport the transport.
* @return true if the user is registered with the transport.
*/
public static boolean isRegistered(XMPPConnection con, Transport transport) {
if (!con.isConnected()) {
return false;
}
ServiceDiscoveryManager discoveryManager = ServiceDiscoveryManager.getInstanceFor(con);
try {
Jid jid = JidCreate.from(transport.getXMPPServiceDomain());
DiscoverInfo info = discoveryManager.discoverInfo(jid);
return info.containsFeature("jabber:iq:registered");
} catch (XMPPException | SmackException | XmppStringprepException | InterruptedException e) {
Log.error(e);
}
return false;
}
use of org.jxmpp.stringprep.XmppStringprepException in project Spark by igniterealtime.
the class ConferenceRoomBrowser method addTableListener.
private void addTableListener() {
roomsTable.getSelectionModel().addListSelectionListener(e -> {
if (e.getValueIsAdjusting())
return;
int selectedRow = roomsTable.getSelectedRow();
if (selectedRow != -1) {
joinRoomButton.setEnabled(true);
joinRoomItem.setEnabled(true);
String roomJIDString = roomsTable.getValueAt(selectedRow, 2) + "@" + serviceName;
EntityBareJid roomJID;
try {
roomJID = JidCreate.entityBareFrom(roomJIDString);
} catch (XmppStringprepException ex) {
Log.error("Not a JID", ex);
return;
}
addRoomButton.setEnabled(true);
addRoomItem.setEnabled(true);
addBookmarkUI(!isBookmarked(roomJID));
} else {
joinRoomButton.setEnabled(false);
addRoomButton.setEnabled(false);
joinRoomItem.setEnabled(false);
addRoomItem.setEnabled(false);
addBookmarkUI(true);
}
});
}
Aggregations