mirror of
https://github.com/igniterealtime/Spark.git
synced 2025-12-01 12:27:58 +00:00
SPARK-533, BuzzPlugin uses XEP-0224 compliance
for backwards compatibilty it will also send <buzz xmlns="http://www.jivesoftware.com/spark"/> this will be removed in later versions!!! new locale string: message.buzz.message = {0} wants your attention git-svn-id: http://svn.igniterealtime.org/svn/repos/spark/trunk@12314 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
committed by
wolf.posdorfer
parent
bfbfb95671
commit
55abcd8469
@ -22,21 +22,25 @@ package org.jivesoftware.sparkimpl.plugin.alerts;
|
||||
import org.jivesoftware.smack.packet.PacketExtension;
|
||||
|
||||
/**
|
||||
*
|
||||
* XEP-0224 Compliance<br>
|
||||
* see <a
|
||||
* href="http://xmpp.org/extensions/xep-0224.html">http://xmpp.org/extensions
|
||||
* /xep-0224.html</a>
|
||||
*/
|
||||
public class BuzzPacket implements PacketExtension {
|
||||
public String getElementName() {
|
||||
return "buzz";
|
||||
return "attention";
|
||||
}
|
||||
|
||||
public String getNamespace() {
|
||||
return "http://www.jivesoftware.com/spark";
|
||||
return "urn:xmpp:attention:0";
|
||||
}
|
||||
|
||||
|
||||
//TODO 2.6.1 remove buzz only attention gets to stay
|
||||
public String toXML() {
|
||||
StringBuffer buf = new StringBuffer();
|
||||
buf.append("<").append(getElementName()).append(" xmlns=\"").append(getNamespace()).append("\"/>");
|
||||
return buf.toString();
|
||||
return "<" + getElementName() + " xmlns=\"" + getNamespace()
|
||||
+ "\"/><buzz xmlns=\"http://www.jivesoftware.com/spark\"/>";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
*/
|
||||
package org.jivesoftware.sparkimpl.plugin.alerts;
|
||||
|
||||
import org.jivesoftware.resource.Res;
|
||||
import org.jivesoftware.smack.PacketListener;
|
||||
import org.jivesoftware.smack.filter.PacketTypeFilter;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
@ -47,102 +48,121 @@ import javax.swing.SwingUtilities;
|
||||
*/
|
||||
public class BuzzPlugin implements Plugin {
|
||||
|
||||
private static final String ELEMENTNAME = "attention";
|
||||
private static final String NAMESPACE = "urn:xmpp:attention:0";
|
||||
|
||||
private static final String ELEMENTNAME_OLD = "buzz";
|
||||
private static final String NAMESPACE_OLD = "http://www.jivesoftware.com/spark";
|
||||
|
||||
public void initialize() {
|
||||
ProviderManager.getInstance().addExtensionProvider("buzz", "http://www.jivesoftware.com/spark", BuzzPacket.class);
|
||||
ProviderManager.getInstance().addExtensionProvider(ELEMENTNAME,
|
||||
NAMESPACE, BuzzPacket.class);
|
||||
|
||||
SparkManager.getConnection().addPacketListener(new PacketListener() {
|
||||
public void processPacket(Packet packet) {
|
||||
if (packet instanceof Message) {
|
||||
final Message message = (Message)packet;
|
||||
if (message.getExtension("buzz", "http://www.jivesoftware.com/spark") != null) {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
shakeWindow(message);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}, new PacketTypeFilter(Message.class));
|
||||
ProviderManager.getInstance().addExtensionProvider(ELEMENTNAME_OLD,
|
||||
NAMESPACE_OLD, BuzzPacket.class);
|
||||
|
||||
SparkManager.getConnection().addPacketListener(new PacketListener() {
|
||||
public void processPacket(Packet packet) {
|
||||
if (packet instanceof Message) {
|
||||
final Message message = (Message) packet;
|
||||
|
||||
SparkManager.getChatManager().addChatRoomListener(new ChatRoomListener() {
|
||||
public void chatRoomOpened(final ChatRoom room) {
|
||||
TimerTask task = new SwingTimerTask() {
|
||||
public void doRun() {
|
||||
addBuzzFeatureToChatRoom(room);
|
||||
}
|
||||
};
|
||||
boolean buzz = message.getExtension(ELEMENTNAME_OLD,
|
||||
NAMESPACE_OLD) != null
|
||||
|| message.getExtension(ELEMENTNAME, NAMESPACE) != null;
|
||||
if (buzz) {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
shakeWindow(message);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}, new PacketTypeFilter(Message.class));
|
||||
|
||||
TaskEngine.getInstance().schedule(task, 100);
|
||||
}
|
||||
SparkManager.getChatManager().addChatRoomListener(
|
||||
new ChatRoomListener() {
|
||||
public void chatRoomOpened(final ChatRoom room) {
|
||||
TimerTask task = new SwingTimerTask() {
|
||||
public void doRun() {
|
||||
addBuzzFeatureToChatRoom(room);
|
||||
}
|
||||
};
|
||||
|
||||
public void chatRoomLeft(ChatRoom room) {
|
||||
}
|
||||
TaskEngine.getInstance().schedule(task, 100);
|
||||
}
|
||||
|
||||
public void chatRoomClosed(ChatRoom room) {
|
||||
}
|
||||
public void chatRoomLeft(ChatRoom room) {
|
||||
}
|
||||
|
||||
public void chatRoomActivated(ChatRoom room) {
|
||||
}
|
||||
public void chatRoomClosed(ChatRoom room) {
|
||||
}
|
||||
|
||||
public void userHasJoined(ChatRoom room, String userid) {
|
||||
}
|
||||
public void chatRoomActivated(ChatRoom room) {
|
||||
}
|
||||
|
||||
public void userHasLeft(ChatRoom room, String userid) {
|
||||
}
|
||||
});
|
||||
public void userHasJoined(ChatRoom room, String userid) {
|
||||
}
|
||||
|
||||
public void userHasLeft(ChatRoom room, String userid) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void addBuzzFeatureToChatRoom(final ChatRoom room) {
|
||||
if (room instanceof ChatRoomImpl) {
|
||||
// Add Button to toolbar
|
||||
if (!SettingsManager.getLocalPreferences().isBuzzEnabled()) {
|
||||
return;
|
||||
}
|
||||
if (room instanceof ChatRoomImpl) {
|
||||
// Add Button to toolbar
|
||||
if (!SettingsManager.getLocalPreferences().isBuzzEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
new BuzzRoomDecorator(room);
|
||||
}
|
||||
new BuzzRoomDecorator(room);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void shakeWindow(Message message) {
|
||||
if (!SettingsManager.getLocalPreferences().isBuzzEnabled()) {
|
||||
return;
|
||||
}
|
||||
String bareJID = StringUtils.parseBareAddress(message.getFrom());
|
||||
ContactItem contact = SparkManager.getWorkspace().getContactList().getContactItemByJID(bareJID);
|
||||
String nickname = StringUtils.parseName(bareJID);
|
||||
if (contact != null) {
|
||||
nickname = contact.getDisplayName();
|
||||
}
|
||||
|
||||
ChatRoom room;
|
||||
try {
|
||||
room = SparkManager.getChatManager().getChatContainer().getChatRoom(bareJID);
|
||||
}
|
||||
catch (ChatRoomNotFoundException e) {
|
||||
// Create the room if it does not exist.
|
||||
room = SparkManager.getChatManager().createChatRoom(bareJID, nickname, nickname);
|
||||
}
|
||||
String bareJID = StringUtils.parseBareAddress(message.getFrom());
|
||||
ContactItem contact = SparkManager.getWorkspace().getContactList()
|
||||
.getContactItemByJID(bareJID);
|
||||
String nickname = StringUtils.parseName(bareJID);
|
||||
if (contact != null) {
|
||||
nickname = contact.getDisplayName();
|
||||
}
|
||||
|
||||
ChatFrame chatFrame = SparkManager.getChatManager().getChatContainer().getChatFrame();
|
||||
if (chatFrame != null ) {
|
||||
chatFrame.buzz();
|
||||
SparkManager.getChatManager().getChatContainer().activateChatRoom(room);
|
||||
}
|
||||
ChatRoom room;
|
||||
try {
|
||||
room = SparkManager.getChatManager().getChatContainer()
|
||||
.getChatRoom(bareJID);
|
||||
} catch (ChatRoomNotFoundException e) {
|
||||
// Create the room if it does not exist.
|
||||
room = SparkManager.getChatManager().createChatRoom(bareJID,
|
||||
nickname, nickname);
|
||||
}
|
||||
|
||||
// Insert offline message
|
||||
room.getTranscriptWindow().insertNotificationMessage("BUZZ", ChatManager.NOTIFICATION_COLOR);
|
||||
room.scrollToBottom();
|
||||
ChatFrame chatFrame = SparkManager.getChatManager().getChatContainer()
|
||||
.getChatFrame();
|
||||
if (chatFrame != null) {
|
||||
if (SettingsManager.getLocalPreferences().isBuzzEnabled()) {
|
||||
chatFrame.buzz();
|
||||
SparkManager.getChatManager().getChatContainer()
|
||||
.activateChatRoom(room);
|
||||
}
|
||||
}
|
||||
|
||||
// Insert offline message
|
||||
room.getTranscriptWindow().insertNotificationMessage(
|
||||
Res.getString("message.buzz.message", nickname),
|
||||
ChatManager.NOTIFICATION_COLOR);
|
||||
room.scrollToBottom();
|
||||
}
|
||||
|
||||
public void shutdown() {
|
||||
}
|
||||
|
||||
public boolean canShutDown() {
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void uninstall() {
|
||||
|
||||
@ -617,6 +617,7 @@ message.broadcast.message.sent = The broadcast message has been sent
|
||||
message.broadcast.to = Enter message to broadcast to {0}
|
||||
message.broadcasted.to = The message has been broadcasted to the following users\:\n{0}
|
||||
message.buzz.alert.notification = Get the user's attention
|
||||
message.buzz.message = {0} wants your attention
|
||||
message.buzz.sent = Sent alert notification to user
|
||||
message.calling = Calling {0}
|
||||
message.came.online = {0} is online at {1}
|
||||
|
||||
@ -529,6 +529,7 @@ message.specify.group = Bitte die Gruppe angeben der der neue Kontakt hinzugef
|
||||
message.room.creation.error = Der Raum kann nicht erstellt werden.
|
||||
message.unable.to.retrieve.last.activity = Keine letzte Aktivit<69>t f<>r {0} vorhanden
|
||||
message.buzz.alert.notification = Sich beim Benutzer bemerkbar machen.
|
||||
message.buzz.message = {0} m<>chte deine Aufmerksamkeit
|
||||
message.buzz.sent = 'Buzzer' Benachrichtigung an Benutzer gesendet.
|
||||
message.invite.to.groupchat = Sie wurden von {0} zu einem Gruppen-Chat eingeladen
|
||||
title.advanced.connection.preferences = Erweiterte Verbindungseinstellungen
|
||||
|
||||
Reference in New Issue
Block a user