SPARK-1303

new String in locale:
menuitem.add.groupchat.auto.accept.invite = &Automatically accept groupchat invites


git-svn-id: http://svn.igniterealtime.org/svn/repos/spark/trunk@12297 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Wolf Posdorfer
2011-04-28 16:44:54 +00:00
committed by wolf.posdorfer
parent ddb07c7dff
commit ef4ec3c7e9
6 changed files with 139 additions and 133 deletions

View File

@ -78,6 +78,7 @@ import org.jivesoftware.sparkimpl.settings.local.SettingsManager;
public class ConferenceServices {
private static BookmarksUI bookmarksUI = new BookmarksUI(); //This variable shouldn't be null.
private static LocalPreferences _localPreferences = SettingsManager.getLocalPreferences();
public ConferenceServices() {
ServiceDiscoveryManager manager = ServiceDiscoveryManager.getInstanceFor(SparkManager.getConnection());
boolean mucSupported = manager.includesFeature("http://jabber.org/protocol/muc");
@ -134,142 +135,121 @@ public class ConferenceServices {
*/
private static void addInvitationListener() {
// Add Invite Listener
MultiUserChat.addInvitationListener(SparkManager.getConnection(),
new InvitationListener() {
public void invitationReceived(final Connection conn,
final String room, final String inviter,
final String reason, final String password,
final Message message) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
Collection<RoomInvitationListener> listeners = new ArrayList<RoomInvitationListener>(
SparkManager.getChatManager()
.getInvitationListeners());
for (RoomInvitationListener listener : listeners) {
boolean handle = listener.handleInvitation(
conn, room, inviter, reason,
password, message);
if (handle) {
return;
}
}
// Make sure the user is not already in the
// room.
try {
SparkManager.getChatManager()
.getChatContainer()
.getChatRoom(room);
return;
} catch (ChatRoomNotFoundException e) {
// Ignore :)
}
final GroupChatInvitationUI invitationUI = new GroupChatInvitationUI(
room, inviter, password, reason);
String message = Res.getString(
"message.invite.to.groupchat", inviter);
String title = Res
.getString("title.group.chat");
String bareJID = StringUtils
.parseBareAddress(inviter);
try {
ChatRoom chatRoom = SparkManager
.getChatManager()
.getChatContainer()
.getChatRoom(bareJID);
// If the ChatRoom exists, add an invitation
// UI.
chatRoom.getTranscriptWindow()
.addComponent(invitationUI);
// Notify user of incoming invitation.
chatRoom.increaseUnreadMessageCount();
chatRoom.scrollToBottom();
SparkManager
.getChatManager()
.getChatContainer()
.fireNotifyOnMessage(chatRoom,
true, message, title);
} catch (ChatRoomNotFoundException e) {
// If it doesn't exists. Create a new Group
// Chat Room
// Create the Group Chat Room
final MultiUserChat chat = new MultiUserChat(
SparkManager.getConnection(), room);
GroupChatRoom groupChatRoom = new GroupChatRoom(
chat);
LocalPreferences pref = SettingsManager
.getLocalPreferences();
if (pref.getShowToasterPopup()) {
SparkToaster toaster = new SparkToaster();
toaster.setCustomAction(new AbstractAction() {
private static final long serialVersionUID = -4546475740161533555L;
@Override
public void actionPerformed(
ActionEvent e) {
ChatFrame chatFrame = SparkManager
.getChatManager()
.getChatContainer()
.getChatFrame();
chatFrame
.setState(Frame.NORMAL);
chatFrame.setVisible(true);
}
});
toaster.setDisplayTime(5000);
toaster.setBorder(BorderFactory
.createBevelBorder(0));
toaster.setToasterHeight(150);
toaster.setToasterWidth(200);
toaster.setTitle(title);
toaster.showToaster(
groupChatRoom.getTabIcon(),
message);
}
groupChatRoom.getSplitPane()
.setDividerSize(5);
groupChatRoom.getVerticalSlipPane()
.setDividerLocation(0.6);
groupChatRoom.getSplitPane()
.setDividerLocation(0.6);
String roomName = StringUtils
.parseName(room);
groupChatRoom.setTabTitle(roomName);
groupChatRoom.getToolBar().setVisible(true);
SparkManager.getChatManager()
.getChatContainer()
.addChatRoom(groupChatRoom);
groupChatRoom.getTranscriptWindow()
.addComponent(invitationUI);
// Notify user of incoming invitation.
groupChatRoom.increaseUnreadMessageCount();
groupChatRoom.scrollToBottom();
SparkManager
.getChatManager()
.getChatContainer()
.fireNotifyOnMessage(groupChatRoom,
true, message, title);
}
// If no listeners handled the invitation,
// default to generic invite.
// new ConversationInvitation(conn, room,
// inviter, reason, password, message);
MultiUserChat.addInvitationListener(SparkManager.getConnection(), new InvitationListener() {
public void invitationReceived(final Connection conn, final String room, final String inviter,
final String reason, final String password, final Message message) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
Collection<RoomInvitationListener> listeners = new ArrayList<RoomInvitationListener>(
SparkManager.getChatManager().getInvitationListeners());
for (RoomInvitationListener listener : listeners) {
boolean handle = listener.handleInvitation(conn, room, inviter, reason, password, message);
if (handle) {
return;
}
});
}
// Make sure the user is not already in the
// room.
try {
SparkManager.getChatManager().getChatContainer().getChatRoom(room);
return;
} catch (ChatRoomNotFoundException e) {
// Ignore :)
}
final GroupChatInvitationUI invitationUI = new GroupChatInvitationUI(room, inviter, password,
reason);
String message = Res.getString("message.invite.to.groupchat", inviter);
String title = Res.getString("title.group.chat");
String bareJID = StringUtils.parseBareAddress(inviter);
if (_localPreferences.isAutoAcceptMucInvite()) {
ConferenceUtils.enterRoomOnSameThread(StringUtils.parseName(room), room, password);
GroupChatRoom chat = new GroupChatRoom(
new MultiUserChat(SparkManager.getConnection(), room));
showToaster(message, title, chat);
return;
// Nothing to do here, we want to join the
// room, and stuff
}
try {
ChatRoom chatRoom = SparkManager.getChatManager().getChatContainer().getChatRoom(bareJID);
// If the ChatRoom exists, add an invitation
// UI.
chatRoom.getTranscriptWindow().addComponent(invitationUI);
// Notify user of incoming invitation.
chatRoom.increaseUnreadMessageCount();
chatRoom.scrollToBottom();
SparkManager.getChatManager().getChatContainer().fireNotifyOnMessage(chatRoom, true,
message, title);
} catch (ChatRoomNotFoundException e) {
// If it doesn't exists. Create a new Group
// Chat Room
// Create the Group Chat Room
final MultiUserChat chat = new MultiUserChat(SparkManager.getConnection(), room);
GroupChatRoom groupChatRoom = new GroupChatRoom(chat);
showToaster(message, title, groupChatRoom);
groupChatRoom.getSplitPane().setDividerSize(5);
groupChatRoom.getVerticalSlipPane().setDividerLocation(0.6);
groupChatRoom.getSplitPane().setDividerLocation(0.6);
String roomName = StringUtils.parseName(room);
groupChatRoom.setTabTitle(roomName);
groupChatRoom.getToolBar().setVisible(true);
SparkManager.getChatManager().getChatContainer().addChatRoom(groupChatRoom);
groupChatRoom.getTranscriptWindow().addComponent(invitationUI);
// Notify user of incoming invitation.
groupChatRoom.increaseUnreadMessageCount();
groupChatRoom.scrollToBottom();
SparkManager.getChatManager().getChatContainer().fireNotifyOnMessage(groupChatRoom, true,
message, title);
}
// If no listeners handled the invitation,
// default to generic invite.
// new ConversationInvitation(conn, room,
// inviter, reason, password, message);
}
});
}
});
}
private static void showToaster(String message, String title, GroupChatRoom groupChatRoom) {
if (_localPreferences.getShowToasterPopup()) {
SparkToaster toaster = new SparkToaster();
toaster.setCustomAction(new AbstractAction() {
private static final long serialVersionUID = -4546475740161533555L;
@Override
public void actionPerformed(ActionEvent e) {
ChatFrame chatFrame = SparkManager.getChatManager().getChatContainer()
.getChatFrame();
chatFrame.setState(Frame.NORMAL);
chatFrame.setVisible(true);
}
});
toaster.setDisplayTime(5000);
toaster.setBorder(BorderFactory.createBevelBorder(0));
toaster.setToasterHeight(150);
toaster.setToasterWidth(200);
toaster.setTitle(title);
toaster.showToaster(groupChatRoom.getTabIcon(), message);
}
}
/**
@ -392,7 +372,7 @@ public class ConferenceServices {
if (component instanceof ContactGroup) {
popup.add(inviteAllAction);
}
else if (component instanceof Collection && col.size() > 0) {
else if (component instanceof Collection<?> && col.size() > 0) {
popup.add(conferenceAction);
}
}

View File

@ -74,12 +74,14 @@ public class GroupChatPreference implements Preference {
boolean highlightPopName = localPreferences.isMucHighToastEnabled();
boolean showjoinleavemessage = localPreferences.isShowJoinLeaveMessagesEnabled();
boolean showroleicons = localPreferences.isShowingRoleIcons();
boolean autoAcceptMucInvite = localPreferences.isAutoAcceptMucInvite();
panel.setMucHighNameEnabled(highlightMyName);
panel.setMucHighTextEnabled(highlightMyText);
panel.setMuchHighToastEnabled(highlightPopName);
panel.setShowJoinLeaveMessagesEnabled(showjoinleavemessage);
panel.setShowRoleIconInsteadStatusIcon(showroleicons);
panel.setAutoAcceptMuc(autoAcceptMucInvite);
}
};
@ -95,6 +97,7 @@ public class GroupChatPreference implements Preference {
pref.setMuchHighToastEnabled(panel.isMucHighToastEnabled());
pref.setShowJoinLeaveMessagesEnabled(panel.isShowJoinLeaveMessagesEnabled());
pref.setShowRoleIconInsteadStatusIcon(panel.isShowingRoleIcons());
pref.setAutoAcceptMucInvite(panel.isAutoAcceptMuc());
SettingsManager.saveSettings();
}

View File

@ -43,6 +43,7 @@ public class GroupChatPreferencePanel extends JPanel {
private JCheckBox highlightPopName = new JCheckBox();
private JCheckBox showjoinleavemessage = new JCheckBox();
private JCheckBox showroleicons = new JCheckBox();
private JCheckBox _autoAcceptInvites = new JCheckBox();
private JPanel gCPanel = new JPanel();
/**
@ -61,6 +62,7 @@ public class GroupChatPreferencePanel extends JPanel {
ResourceUtils.resButton(highlightPopName , Res.getString("menuitem.add.groupchat.popname"));
ResourceUtils.resButton(showjoinleavemessage , Res.getString("menuitem.add.groupchat.showjoinleavemessage"));
ResourceUtils.resButton(showroleicons , Res.getString("menuitem.add.groupchat.showrolesinsteadofstatus"));
ResourceUtils.resButton(_autoAcceptInvites , Res.getString("menuitem.add.groupchat.auto.accept.invite"));
gCPanel.setBorder(BorderFactory.createTitledBorder(Res.getString("title.group.chat.settings")));
@ -73,6 +75,8 @@ public class GroupChatPreferencePanel extends JPanel {
gCPanel.add(highlightPopName , new GridBagConstraints(0, 2, 2, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
gCPanel.add(showjoinleavemessage, new GridBagConstraints(0, 3, 2, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
gCPanel.add(showroleicons , new GridBagConstraints(0, 4, 2, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
gCPanel.add(_autoAcceptInvites , new GridBagConstraints(0, 5, 2, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
}
public void setMucHighNameEnabled(boolean mucNHigh) {
@ -114,6 +118,14 @@ public class GroupChatPreferencePanel extends JPanel {
public boolean isShowingRoleIcons() {
return showroleicons.isSelected();
}
public void setAutoAcceptMuc(boolean accept) {
_autoAcceptInvites.setSelected(accept);
}
public boolean isAutoAcceptMuc() {
return _autoAcceptInvites.isSelected();
}
}

View File

@ -982,6 +982,15 @@ public class LocalPreferences {
private void setString(String property, String value) {
props.setProperty(property, value);
}
public boolean isAutoAcceptMucInvite() {
return getBoolean("autoAcceptMucInvite", false);
}
public void setAutoAcceptMucInvite(boolean autoAcceptMuc) {
setBoolean("autoAcceptMucInvite", autoAcceptMuc);
}

View File

@ -498,6 +498,7 @@ menuitem.add.groupchat.mytext = &Highlight my text when I say something
menuitem.add.groupchat.popname = Show &toast popup when someone says my name
menuitem.add.groupchat.showjoinleavemessage = &Show join and leave messages
menuitem.add.groupchat.showrolesinsteadofstatus = Show chat role icons instead of presence icons
menuitem.add.groupchat.auto.accept.invite = &Automatically accept groupchat invites
menuitem.always.on.top = Always on top
menuitem.alert.when.online = Alert when user is available
menuitem.ban = Ban

View File

@ -742,6 +742,7 @@ menuitem.add.groupchat.mytext = Meinen &Text hervorheben, wenn ich etwas schreib
menuitem.add.groupchat.popname = &Zeige ein Popup, wenn jemand meinen Namen schreibt
menuitem.add.groupchat.showjoinleavemessage = Zeige an wenn jemand den Raum betritt oder verl<72>sst
menuitem.add.groupchat.showrolesinsteadofstatus = Zeige Chatrecht-Icons anstelle von Statusicons
menuitem.add.groupchat.auto.accept.invite = Konferenzeinladungen &automatisch aktzeptieren
menuitem.show.offline.users = Zeige Offline User
menuitem.expand.all.groups = <EFBFBD>ffne alle Gruppen
menuitem.collapse.all.groups = Schlie<EFBFBD>e alle Gruppen