use of org.jxmpp.stringprep.XmppStringprepException in project Spark by igniterealtime.
the class SendFileTransfer 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 PrivacyPresenceHandler method removeIconsForItem.
private void removeIconsForItem(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);
}
removeBlockedIconFromContact(jid);
if (item.isFilterPresenceOut()) {
sendRealPresenceTo(jid);
}
}
if (item.getType().equals(PrivacyItem.Type.group)) {
ContactGroup group = SparkManager.getWorkspace().getContactList().getContactGroup(item.getValue());
for (ContactItem contact : group.getContactItems()) {
removeBlockedIconFromContact(contact.getJid());
if (item.isFilterPresenceOut()) {
sendRealPresenceTo(contact.getJid());
}
}
}
}
use of org.jxmpp.stringprep.XmppStringprepException in project Spark by igniterealtime.
the class JabberBrowser method browse.
private void browse(String serviceNameString) {
Jid serviceName;
try {
serviceName = JidCreate.from(serviceNameString);
} catch (XmppStringprepException e) {
throw new IllegalStateException(e);
}
browsePanel.removeAll();
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(con);
DiscoverItems result;
try {
result = discoManager.discoverItems(serviceName);
} catch (XMPPException | SmackException | InterruptedException e) {
Log.error(e);
return;
}
addAddress(serviceName.toString());
for (DiscoverItems.Item item : result.getItems()) {
Entity entity = new Entity(item);
browsePanel.add(entity);
}
browsePanel.invalidate();
browsePanel.validate();
browsePanel.repaint();
}
use of org.jxmpp.stringprep.XmppStringprepException in project Spark by igniterealtime.
the class VCardManager method reloadVCard.
/**
* Forces a reload of a <code>VCard</code>. To load a VCard you should use
* getVCard(String jid) instead. This method will perform a network lookup
* which could take some time. If you're having problems with request
* timeout you should also use getVCard(String jid). Use addToQueue(String
* jid) if you want VCardManager to update the VCard by the given jid. The
* method will block until the result is available or a timeout occurs.
*
* @param jidString the JID of the user.
*
* @return the new network vCard or a vCard with an error
*/
public VCard reloadVCard(BareJid jidString) {
EntityBareJid jid;
try {
jid = JidCreate.entityBareFrom(jidString);
} catch (XmppStringprepException e) {
throw new IllegalStateException(e);
}
VCard vcard = new VCard();
try {
vcard = org.jivesoftware.smackx.vcardtemp.VCardManager.getInstanceFor(SparkManager.getConnection()).loadVCard(jid);
vcard.setJabberId(jid.toString());
if (vcard.getNickName() != null && vcard.getNickName().length() > 0) {
// update nickname.
ContactItem item = SparkManager.getWorkspace().getContactList().getContactItemByJID(jid.toString());
item.setNickname(vcard.getNickName());
// TODO: this doesn't work if someone removes his nickname. If we remove it in that case, it will cause problems with people using another way to manage their nicknames.
}
addVCard(jid, vcard);
persistVCard(jid, vcard);
} catch (XMPPException | SmackException | InterruptedException e) {
// //System.out.println(jid+" Fehler in reloadVCard ----> null");
StanzaError.Builder errorBuilder = StanzaError.getBuilder(StanzaError.Condition.resource_constraint);
vcard.setError(errorBuilder);
vcard.setJabberId(jid.toString());
delayedContacts.add(jid);
return vcard;
// We dont want cards with error
// vcard.setError(new StanzaError(XMPPError.Condition.request_timeout));
// addVCard(jid, vcard);
}
return vcard;
}
use of org.jxmpp.stringprep.XmppStringprepException in project Spark by igniterealtime.
the class VCardManager method initializeUI.
/**
* Adds VCard capabilities to menus and other components in Spark.
*/
private void initializeUI() {
// See if we should disable the "Edit my profile" option under "File"
if (Default.getBoolean(Default.DISABLE_EDIT_PROFILE) || !Enterprise.containsFeature(Enterprise.VCARD_FEATURE))
return;
// Add Actions Menu
final JMenu contactsMenu = SparkManager.getMainWindow().getMenuByName(Res.getString("menuitem.contacts"));
final JMenu communicatorMenu = SparkManager.getMainWindow().getJMenuBar().getMenu(0);
JMenuItem editProfileMenu = new JMenuItem(SparkRes.getImageIcon(SparkRes.SMALL_BUSINESS_MAN_VIEW));
ResourceUtils.resButton(editProfileMenu, Res.getString("menuitem.edit.my.profile"));
int size = contactsMenu.getMenuComponentCount();
communicatorMenu.insert(editProfileMenu, 1);
editProfileMenu.addActionListener(e -> {
SwingWorker vcardLoaderWorker = new SwingWorker() {
@Override
public Object construct() {
try {
final org.jivesoftware.smackx.vcardtemp.VCardManager smackVCardManager = org.jivesoftware.smackx.vcardtemp.VCardManager.getInstanceFor(SparkManager.getConnection());
personalVCard = smackVCardManager.loadVCard();
} catch (XMPPException | SmackException | InterruptedException e) {
Log.error("Error loading vcard information.", e);
}
return true;
}
@Override
public void finished() {
editor.editProfile(personalVCard, SparkManager.getWorkspace());
personalVCardAvatar = null;
personalVCardHash = null;
}
};
vcardLoaderWorker.start();
});
JMenuItem viewProfileMenu = new JMenuItem("", SparkRes.getImageIcon(SparkRes.FIND_TEXT_IMAGE));
ResourceUtils.resButton(viewProfileMenu, Res.getString("menuitem.lookup.profile"));
contactsMenu.insert(viewProfileMenu, size > 0 ? size - 3 : 0);
viewProfileMenu.addActionListener(e -> {
String jidToView = JOptionPane.showInputDialog(SparkManager.getMainWindow(), Res.getString("message.enter.jabber.id") + ":", Res.getString("title.lookup.profile"), JOptionPane.QUESTION_MESSAGE);
if (ModelUtil.hasLength(jidToView) && jidToView.contains("@") && ModelUtil.hasLength(XmppStringUtils.parseDomain(jidToView))) {
BareJid bareJid;
try {
bareJid = JidCreate.bareFrom(jidToView);
} catch (XmppStringprepException e1) {
throw new IllegalStateException(e1);
}
viewProfile(bareJid, SparkManager.getWorkspace());
} else if (ModelUtil.hasLength(jidToView)) {
UIManager.put("OptionPane.okButtonText", Res.getString("ok"));
JOptionPane.showMessageDialog(SparkManager.getMainWindow(), Res.getString("message.invalid.jabber.id"), Res.getString("title.error"), JOptionPane.ERROR_MESSAGE);
}
});
}
Aggregations