use of org.jivesoftware.sparkimpl.settings.local.LocalPreferences in project Spark by igniterealtime.
the class ConferenceRoomBrowser method createRoom.
/**
* Create a new room based on room table selection.
*/
private void createRoom() {
RoomCreationDialog mucRoomDialog = new RoomCreationDialog();
final MultiUserChat groupChat = mucRoomDialog.createGroupChat(SparkManager.getMainWindow(), serviceName);
LocalPreferences pref = SettingsManager.getLocalPreferences();
if (null != groupChat) {
// Join Room
try {
GroupChatRoom room = UIComponentRegistry.createGroupChatRoom(groupChat);
groupChat.create(pref.getNickname());
chatManager.getChatContainer().addChatRoom(room);
chatManager.getChatContainer().activateChatRoom(room);
// Send Form
Form form = groupChat.getConfigurationForm().createAnswerForm();
if (mucRoomDialog.isPasswordProtected()) {
String password = mucRoomDialog.getPassword();
room.setPassword(password);
form.setAnswer("muc#roomconfig_passwordprotectedroom", true);
form.setAnswer("muc#roomconfig_roomsecret", password);
}
form.setAnswer("muc#roomconfig_roomname", mucRoomDialog.getRoomName());
form.setAnswer("muc#roomconfig_roomdesc", mucRoomDialog.getRoomTopic());
if (mucRoomDialog.isPermanent()) {
form.setAnswer("muc#roomconfig_persistentroom", true);
}
List<String> owners = new ArrayList<>();
owners.add(SparkManager.getSessionManager().getBareAddress());
form.setAnswer("muc#roomconfig_roomowners", owners);
// new DataFormDialog(groupChat, form);
groupChat.sendConfigurationForm(form);
addRoomToTable(groupChat.getRoom(), XmppStringUtils.parseLocalpart(groupChat.getRoom()), 1);
} catch (XMPPException | SmackException e1) {
Log.error("Error creating new room.", e1);
UIManager.put("OptionPane.okButtonText", Res.getString("ok"));
JOptionPane.showMessageDialog(this, Res.getString("message.room.creation.error"), Res.getString("title.error"), JOptionPane.ERROR_MESSAGE);
}
}
}
use of org.jivesoftware.sparkimpl.settings.local.LocalPreferences in project Spark by igniterealtime.
the class ConferenceUtils method inviteUsersToRoom.
/**
* Invites users to an existing room.
*
* @param serviceName the service name to use.
* @param roomName the name of the room.
* @param jids a collection of the users to invite.
*/
public static void inviteUsersToRoom(String serviceName, String roomName, Collection<String> jids, boolean randomName) {
final LocalPreferences pref = SettingsManager.getLocalPreferences();
boolean useTextField = pref.isUseAdHocRoom();
Collection<BookmarkedConference> rooms = null;
if (!useTextField) {
try {
rooms = retrieveBookmarkedConferences();
} catch (Exception ex) {
Log.error(ex);
}
useTextField = !randomName || (rooms == null || rooms.size() == 0);
}
InvitationDialog inviteDialog = new InvitationDialog(useTextField);
inviteDialog.inviteUsersToRoom(serviceName, rooms, roomName, jids);
}
use of org.jivesoftware.sparkimpl.settings.local.LocalPreferences in project Spark by igniterealtime.
the class GatewayPlugin method initialize.
public void initialize() {
ProviderManager.addIQProvider(Gateway.ELEMENT_NAME, Gateway.NAMESPACE, new Gateway.Provider());
LocalPreferences localPref = SettingsManager.getLocalPreferences();
useTab = localPref.getShowTransportTab();
transferTab.setBackground((Color) UIManager.get("ContactItem.background"));
SwingWorker thread = new SwingWorker() {
public Object construct() {
try {
// Let's try and avoid any timing issues with the gateway presence.
Thread.sleep(5000);
populateTransports();
} catch (Exception e) {
Log.error(e);
return false;
}
return true;
}
public void finished() {
transferTab.setLayout(new VerticalFlowLayout(0, 0, 0, true, false));
Boolean transportExists = (Boolean) get();
if (!transportExists) {
return;
}
if (TransportUtils.getTransports().size() > 0 && useTab) {
SparkManager.getWorkspace().getWorkspacePane().addTab(Res.getString("title.transports"), SparkRes.getImageIcon(SparkRes.TRANSPORT_ICON), transferTab);
}
for (final Transport transport : TransportUtils.getTransports()) {
addTransport(transport);
}
// Register presences.
registerPresenceListener();
}
};
thread.start();
}
use of org.jivesoftware.sparkimpl.settings.local.LocalPreferences in project Spark by igniterealtime.
the class ContactListAssistantPlugin method initialize.
@Override
public void initialize() {
moveToMenu = new JMenu(Res.getString("menuitem.move.to"));
copyToMenu = new JMenu(Res.getString("menuitem.copy.to"));
localPreferences = new LocalPreferences();
final ContactList contactList = SparkManager.getContactList();
contactList.addContextMenuListener(new ContextMenuListener() {
@Override
public void poppingUp(Object object, final JPopupMenu popup) {
final Collection<ContactItem> contactItems = Collections.unmodifiableCollection(contactList.getSelectedUsers());
if (!contactItems.isEmpty()) {
final List<ContactGroup> contactGroups = contactList.getContactGroups();
Collections.sort(contactGroups, ContactList.GROUP_COMPARATOR);
for (final ContactGroup group : contactGroups) {
if (group.isUnfiledGroup() || group.isOfflineGroup()) {
continue;
}
if (isContactItemInGroup(contactItems, group)) {
continue;
}
final Action moveAction = new AbstractAction() {
private static final long serialVersionUID = 6542011870221162331L;
@Override
public void actionPerformed(ActionEvent actionEvent) {
moveItems(contactItems, group.getGroupName());
}
};
final Action copyAction = new AbstractAction() {
private static final long serialVersionUID = 2232885525630977329L;
@Override
public void actionPerformed(ActionEvent actionEvent) {
copyItems(contactItems, group.getGroupName());
}
};
moveAction.putValue(Action.NAME, group.getGroupName());
moveToMenu.add(moveAction);
copyAction.putValue(Action.NAME, group.getGroupName());
copyToMenu.add(copyAction);
}
popup.addPopupMenuListener(new PopupMenuListener() {
@Override
public void popupMenuWillBecomeVisible(PopupMenuEvent popupMenuEvent) {
}
@Override
public void popupMenuWillBecomeInvisible(PopupMenuEvent popupMenuEvent) {
moveToMenu.removeAll();
copyToMenu.removeAll();
popup.removePopupMenuListener(this);
}
@Override
public void popupMenuCanceled(PopupMenuEvent popupMenuEvent) {
moveToMenu.removeAll();
copyToMenu.removeAll();
popup.removePopupMenuListener(this);
}
});
int index = -1;
if (!Default.getBoolean("DISABLE_RENAMES") && Enterprise.containsFeature(Enterprise.RENAMES_FEATURE)) {
for (int i = 0; i < popup.getComponentCount(); i++) {
Object o = popup.getComponent(i);
if (o instanceof JMenuItem && ((JMenuItem) o).getText().equals(Res.getString("menuitem.rename"))) {
index = i;
break;
}
}
} else
index = 3;
if (contactItems.size() == 1) {
// Add MOVE/COPY options right after the RENAME option or in it's place if it doesn't exist.
if (index != -1) {
// See if we should disable the "Move to" and "Copy to" menu options
if (!Default.getBoolean("DISABLE_MOVE_AND_COPY") && Enterprise.containsFeature(Enterprise.MOVE_COPY_FEATURE)) {
popup.add(moveToMenu, index + 1);
popup.add(copyToMenu, index + 2);
}
}
} else if (contactItems.size() > 1) {
// See if we should disable the "Move to" and "Copy to" menu options
if (!Default.getBoolean("DISABLE_MOVE_AND_COPY") && Enterprise.containsFeature(Enterprise.MOVE_COPY_FEATURE)) {
popup.addSeparator();
popup.add(moveToMenu);
popup.add(copyToMenu);
}
// Clean up the extra separator if "Broadcast" menu items are disabled
if (!Default.getBoolean("DISABLE_BROADCAST_MENU_ITEM") && Enterprise.containsFeature(Enterprise.BROADCAST_FEATURE))
popup.addSeparator();
}
}
}
@Override
public void poppingDown(JPopupMenu popup) {
}
@Override
public boolean handleDefaultAction(MouseEvent e) {
return false;
}
});
updateAvatarsInContactList();
SettingsManager.addPreferenceListener(preference -> updateAvatarsInContactList());
}
use of org.jivesoftware.sparkimpl.settings.local.LocalPreferences in project Spark by igniterealtime.
the class EmoticonManager method setActivePack.
/**
* Sets the active emoticon set.
*
* @param pack
* the archive containing the emotiocon pack.
*/
public void setActivePack(String pack) {
final LocalPreferences pref = SettingsManager.getLocalPreferences();
pref.setEmoticonPack(pack);
SettingsManager.saveSettings();
imageMap.clear();
}
Aggregations