mirror of
https://github.com/igniterealtime/Spark.git
synced 2025-12-01 12:27:58 +00:00
now able to select the text which is displayed when automatically going idle with IdlePlugin in Preferences->Login
1 new String for Locales : label.time.till.idlemessage = Automatic idl&e message adding super awesome stuff for Easter-time ;-) git-svn-id: http://svn.igniterealtime.org/svn/repos/spark/trunk@12215 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
committed by
wolf.posdorfer
parent
2adda15ee2
commit
6f0e5c980c
@ -901,7 +901,9 @@ public final class LoginDialog {
|
||||
if (!ModelUtil.hasLength(resource)) {
|
||||
resource = "spark";
|
||||
}
|
||||
connection.login(getUsername(), getPassword(), modifyWildcards(resource));
|
||||
|
||||
connection.login(getUsername(), getPassword(),
|
||||
org.jivesoftware.spark.util.StringUtils.modifyWildcards(resource));
|
||||
|
||||
sessionManager.setServerAddress(connection.getServiceName());
|
||||
sessionManager.initializeSession(connection, getUsername(), getPassword());
|
||||
@ -1009,26 +1011,6 @@ public final class LoginDialog {
|
||||
return !hasErrors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Modifies Wildcards such as <code>$r</code>,<code>$s</code>,<code>$v</code>
|
||||
* into what they represent r = randomnumber , s=os.name, v=os.version
|
||||
* @param resource
|
||||
* @return
|
||||
*/
|
||||
private String modifyWildcards(String resource) {
|
||||
|
||||
resource = resource.replace("$r",
|
||||
"" + Math.round((Math.random() * 1000)));
|
||||
|
||||
resource = resource.replace("$s", System.getProperty("os.name")
|
||||
.replace(" ", ""));
|
||||
|
||||
resource = resource.replace("$v", System.getProperty("os.version")
|
||||
.replace(" ", ""));
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
public void handle(Callback[] callbacks) throws IOException {
|
||||
for (Callback callback : callbacks) {
|
||||
if (callback instanceof NameCallback) {
|
||||
|
||||
@ -64,6 +64,7 @@ import org.jivesoftware.spark.SparkManager;
|
||||
import org.jivesoftware.spark.ui.PresenceListener;
|
||||
import org.jivesoftware.spark.util.GraphicUtils;
|
||||
import org.jivesoftware.spark.util.ModelUtil;
|
||||
import org.jivesoftware.spark.util.StringUtils;
|
||||
import org.jivesoftware.spark.util.SwingTimerTask;
|
||||
import org.jivesoftware.spark.util.SwingWorker;
|
||||
import org.jivesoftware.spark.util.TaskEngine;
|
||||
@ -124,6 +125,7 @@ public class StatusBar extends JPanel implements VCardListener {
|
||||
|
||||
SparkManager.getSessionManager().addPresenceListener(new PresenceListener() {
|
||||
public void presenceChanged(Presence presence) {
|
||||
presence.setStatus(StringUtils.modifyWildcards(presence.getStatus()));
|
||||
changeAvailability(presence);
|
||||
}
|
||||
});
|
||||
|
||||
@ -27,8 +27,10 @@ import java.io.UnsupportedEncodingException;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.text.BreakIterator;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.BitSet;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.Random;
|
||||
@ -1913,6 +1915,12 @@ public class StringUtils {
|
||||
return "unknown(0x" + Integer.toString(keyCode, 16) + ")";
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the first Character of a String to its Uppercase Instance<br>
|
||||
* test -> Test
|
||||
* @param word
|
||||
* @return String, with first char uppercased
|
||||
*/
|
||||
public static String makeFirstWordCaptial(String word) {
|
||||
if (word.length() < 2) {
|
||||
return word;
|
||||
@ -1923,4 +1931,48 @@ public class StringUtils {
|
||||
|
||||
return firstWord.toUpperCase() + restOfWord;
|
||||
}
|
||||
|
||||
/**
|
||||
* Modifies Wildcards such as <b>%random%</b>,<b>%system%</b>,
|
||||
* <b>%version%</b>,<b>%time%</b> into what they represent
|
||||
* <p>
|
||||
* for properties see System.getProperties()
|
||||
*
|
||||
* @param resource
|
||||
* String to modify
|
||||
* @return modified String
|
||||
* @author wolf.posdorfer
|
||||
*/
|
||||
public static String modifyWildcards(String resource) {
|
||||
|
||||
resource = resource.replace("%random%",
|
||||
"" + Math.round((Math.random() * 1000)));
|
||||
|
||||
resource = resource.replace("%system%", System.getProperty("os.name")
|
||||
.replace(" ", ""));
|
||||
|
||||
resource = resource.replace("%version%",
|
||||
System.getProperty("os.version").replace(" ", ""));
|
||||
|
||||
final String DATE_FORMAT_NOW = "HH:mm";
|
||||
Calendar cal = Calendar.getInstance();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW);
|
||||
|
||||
resource = resource.replace("%time%", sdf.format(cal.getTime()));
|
||||
|
||||
while (resource.contains("%property{")) {
|
||||
if (resource.contains("%property{") && resource.contains("}/%")) {
|
||||
int indexofbeginning = resource.indexOf("%property{");
|
||||
int indexofending = resource.indexOf("}/%");
|
||||
|
||||
String begin = resource.substring(0, indexofbeginning);
|
||||
String middle = System.getProperty(resource.substring(
|
||||
indexofbeginning+10, indexofending));
|
||||
String end = resource.substring(indexofending + 3);
|
||||
resource = begin + middle + end;
|
||||
}
|
||||
}
|
||||
|
||||
return resource;
|
||||
}
|
||||
}
|
||||
@ -28,10 +28,10 @@ import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import org.jivesoftware.Spark;
|
||||
import org.jivesoftware.resource.Res;
|
||||
import org.jivesoftware.smack.packet.Presence;
|
||||
import org.jivesoftware.spark.SparkManager;
|
||||
import org.jivesoftware.spark.plugin.Plugin;
|
||||
import org.jivesoftware.spark.util.StringUtils;
|
||||
import org.jivesoftware.spark.util.log.Log;
|
||||
import org.jivesoftware.sparkimpl.settings.local.LocalPreferences;
|
||||
import org.jivesoftware.sparkimpl.settings.local.SettingsManager;
|
||||
@ -94,7 +94,7 @@ public class UserIdlePlugin extends TimerTask implements Plugin {
|
||||
if ((latestPresence.getMode() == Presence.Mode.available)
|
||||
|| latestPresence.getMode() == Presence.Mode.chat) {
|
||||
Presence presence = new Presence(Presence.Type.available,
|
||||
Res.getString("status.away"), 1, Presence.Mode.away);
|
||||
StringUtils.modifyWildcards(pref.getIdleMessage()), 1, Presence.Mode.away);
|
||||
SparkManager.getSessionManager().changePresence(presence);
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,6 +79,7 @@ public class LocalPreference implements Preference {
|
||||
preferences.setStartedHidden(panel.startInSystemTray());
|
||||
preferences.setStartOnStartup(panel.startOnStartup());
|
||||
preferences.setReconnectPanelType(panel.getReconnectPanelType());
|
||||
preferences.setIdleMessage(panel.getIdleMessage());
|
||||
|
||||
return preferences;
|
||||
}
|
||||
|
||||
@ -46,10 +46,12 @@ public class LocalPreferencePanel extends JPanel {
|
||||
private JLabel _portLabel = new JLabel();
|
||||
private JLabel _idleLabel = new JLabel();
|
||||
private JLabel _timeOutLabel = new JLabel();
|
||||
private JLabel _idleStatusLabel = new JLabel();
|
||||
|
||||
private JTextField _portField = new JTextField();
|
||||
private JTextField _timeOutField = new JTextField();
|
||||
private JTextField _idleField = new JTextField();
|
||||
private JTextField _idleStatusText;
|
||||
|
||||
private JCheckBox _autoLoginBox = new JCheckBox();
|
||||
private JCheckBox _savePasswordBox = new JCheckBox();
|
||||
@ -77,6 +79,8 @@ public class LocalPreferencePanel extends JPanel {
|
||||
_autoLoginBox.setSelected(preferences.isAutoLogin());
|
||||
_savePasswordBox.setSelected(preferences.isSavePassword());
|
||||
_startMinimizedBox.setSelected(preferences.isStartedHidden());
|
||||
|
||||
_idleStatusText = new JTextField(preferences.getIdleMessage());
|
||||
|
||||
_showReconnectBox.setSelectedIndex(preferences.getReconnectPanelType());
|
||||
|
||||
@ -118,10 +122,13 @@ public class LocalPreferencePanel extends JPanel {
|
||||
inputPanel.setBorder(BorderFactory.createTitledBorder(Res
|
||||
.getString("group.login.information")));
|
||||
|
||||
ResourceUtils.resLabel(_portLabel, _portField,
|
||||
Res.getString("label.xmpp.port") + ":");
|
||||
ResourceUtils.resLabel(_portLabel, _portField,Res.getString("label.xmpp.port") + ":");
|
||||
ResourceUtils.resLabel(_timeOutLabel, _timeOutField,
|
||||
Res.getString("label.response.timeout") + ":");
|
||||
|
||||
ResourceUtils.resLabel(_idleStatusLabel, _idleStatusText,
|
||||
Res.getString("label.time.till.idlemessage") + ":");
|
||||
|
||||
ResourceUtils.resButton(_autoLoginBox,
|
||||
Res.getString("checkbox.auto.login"));
|
||||
ResourceUtils.resButton(_savePasswordBox,
|
||||
@ -130,44 +137,28 @@ public class LocalPreferencePanel extends JPanel {
|
||||
Res.getString("label.time.till.idle") + ":");
|
||||
ResourceUtils.resButton(_idleBox,
|
||||
Res.getString("checkbox.idle.enabled"));
|
||||
|
||||
ResourceUtils.resButton(_launchOnStartupBox,
|
||||
Res.getString("checkbox.launch.on.startup"));
|
||||
ResourceUtils.resButton(_startMinimizedBox,
|
||||
Res.getString("checkbox.start.in.tray"));
|
||||
inputPanel.add(_portLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
|
||||
GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
|
||||
new Insets(5, 5, 5, 5), 0, 0));
|
||||
inputPanel.add(_portField, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0,
|
||||
GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL,
|
||||
new Insets(5, 5, 5, 5), 0, 0));
|
||||
inputPanel.add(_timeOutLabel, new GridBagConstraints(0, 1, 1, 1, 0.0,
|
||||
0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
|
||||
new Insets(5, 5, 5, 5), 50, 0));
|
||||
inputPanel.add(_timeOutField, new GridBagConstraints(1, 1, 1, 1, 1.0,
|
||||
0.0, GridBagConstraints.NORTHWEST,
|
||||
GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 50, 0));
|
||||
inputPanel.add(_idleLabel, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0,
|
||||
GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,
|
||||
new Insets(5, 5, 5, 5), 50, 0));
|
||||
inputPanel.add(_idleField, new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0,
|
||||
GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL,
|
||||
new Insets(5, 5, 5, 5), 50, 0));
|
||||
|
||||
inputPanel.add(_portLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
|
||||
inputPanel.add(_portField, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL,new Insets(5, 5, 5, 5), 0, 0));
|
||||
inputPanel.add(_timeOutLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,new Insets(5, 5, 5, 5), 50, 0));
|
||||
inputPanel.add(_timeOutField, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST,GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 50, 0));
|
||||
inputPanel.add(_idleLabel, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE,new Insets(5, 5, 5, 5), 50, 0));
|
||||
inputPanel.add(_idleField, new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL,new Insets(5, 5, 5, 5), 50, 0));
|
||||
inputPanel.add(_idleStatusLabel,new GridBagConstraints(0, 3, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST,GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 50, 0));
|
||||
inputPanel.add(_idleStatusText, new GridBagConstraints(1, 3, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST,GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 50, 0));
|
||||
inputPanel.add(_idleBox, new GridBagConstraints(0, 4, 2, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL,new Insets(5, 5, 5, 5), 50, 0));
|
||||
|
||||
inputPanel.add(_idleBox, new GridBagConstraints(0, 3, 2, 1, 1.0, 0.0,
|
||||
GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL,
|
||||
new Insets(5, 5, 5, 5), 50, 0));
|
||||
inputPanel.add(_savePasswordBox, new GridBagConstraints(0, 4, 2, 1,
|
||||
0.0, 0.0, GridBagConstraints.NORTHWEST,
|
||||
GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 50, 0));
|
||||
inputPanel.add(_autoLoginBox, new GridBagConstraints(0, 5, 2, 1, 0.0,
|
||||
0.0, GridBagConstraints.NORTHWEST,
|
||||
GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 50, 0));
|
||||
|
||||
inputPanel.add(_savePasswordBox, new GridBagConstraints(0, 5, 2, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST,GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 50, 0));
|
||||
inputPanel.add(_autoLoginBox, new GridBagConstraints(0, 6, 2, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST,GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 50, 0));
|
||||
|
||||
if (Spark.isWindows()) {
|
||||
inputPanel.add(_launchOnStartupBox, new GridBagConstraints(0, 6, 2,
|
||||
1, 0.0, 0.0, GridBagConstraints.NORTHWEST,
|
||||
GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 50,
|
||||
0));
|
||||
inputPanel.add(_launchOnStartupBox, new GridBagConstraints(0, 7, 2, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST,GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 50,0));
|
||||
_launchOnStartupBox.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
setStartOnStartup(_launchOnStartupBox.isSelected());
|
||||
@ -177,16 +168,12 @@ public class LocalPreferencePanel extends JPanel {
|
||||
_launchOnStartupBox.setSelected(preferences.getStartOnStartup());
|
||||
}
|
||||
|
||||
inputPanel.add(_startMinimizedBox, new GridBagConstraints(0, 7, 2, 1,
|
||||
0.0, 0.0, GridBagConstraints.NORTHWEST,
|
||||
GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 50, 0));
|
||||
inputPanel.add(new JLabel(), new GridBagConstraints(0, 8, 2, 1, 1.0,
|
||||
1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH,
|
||||
new Insets(5, 5, 5, 5), 50, 0));
|
||||
inputPanel.add(_startMinimizedBox, new GridBagConstraints(0, 8, 2, 1,0.0, 0.0, GridBagConstraints.NORTHWEST,GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 50, 0));
|
||||
inputPanel.add(new JLabel(), new GridBagConstraints(0, 9, 2, 1, 1.0,1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH,new Insets(5, 5, 5, 5), 50, 0));
|
||||
|
||||
JLabel reconnectionlabel= new JLabel(Res.getString("checkbox.reconnet.info"));
|
||||
inputPanel.add(reconnectionlabel, new GridBagConstraints(0, 9, 1, 1,0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 50, 0));
|
||||
inputPanel.add(_showReconnectBox, new GridBagConstraints(1, 9, 3, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 50, 0));
|
||||
inputPanel.add(reconnectionlabel, new GridBagConstraints(0, 10, 1, 1,0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 50, 0));
|
||||
inputPanel.add(_showReconnectBox, new GridBagConstraints(1, 10, 3, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 50, 0));
|
||||
|
||||
add(inputPanel);
|
||||
}
|
||||
@ -339,5 +326,12 @@ public class LocalPreferencePanel extends JPanel {
|
||||
public void setShowReconnectPanel(int reconnect) {
|
||||
_showReconnectBox.setSelectedIndex(reconnect);
|
||||
}
|
||||
|
||||
public String getIdleMessage(){
|
||||
return _idleStatusText.getText();
|
||||
}
|
||||
public void setIdleMessage(String text){
|
||||
_idleStatusText.setText(text);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -22,6 +22,7 @@ package org.jivesoftware.sparkimpl.settings.local;
|
||||
|
||||
import org.jivesoftware.Spark;
|
||||
import org.jivesoftware.resource.Default;
|
||||
import org.jivesoftware.resource.Res;
|
||||
import org.jivesoftware.spark.SparkManager;
|
||||
import java.io.File;
|
||||
import java.util.Date;
|
||||
@ -128,6 +129,21 @@ public class LocalPreferences {
|
||||
public void setIdleOn(boolean idleOn) {
|
||||
props.setProperty("idleOn", Boolean.toString(idleOn));
|
||||
}
|
||||
/**
|
||||
* Returns the Idle Message to Display when going automatically away
|
||||
* @return
|
||||
*/
|
||||
public String getIdleMessage(){
|
||||
return props.getProperty("idleOnMessage",Res.getString("status.away"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the idle Message when going automatically away
|
||||
* @param message
|
||||
*/
|
||||
public void setIdleMessage(String message){
|
||||
props.setProperty("idleOnMessage",message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of minutes to set to unavailable if the computer has
|
||||
|
||||
@ -458,6 +458,7 @@ label.state.and.province = State/province
|
||||
label.street.address = Street address
|
||||
label.time = Time: {0}
|
||||
label.time.till.idle = &Time till idle (min)
|
||||
label.time.till.idlemessage = Automatic idl&e message
|
||||
label.timeformat = Use {0}
|
||||
label.transfer.download.directory = &Download directory:
|
||||
label.transfer.timeout = &Transfer timeout (min):
|
||||
|
||||
@ -310,6 +310,7 @@ label.search.service = &Such-Service
|
||||
label.xmpp.port = &XMPP Port
|
||||
label.response.timeout = &Zeitspanne bis zum Abbruch (sec)
|
||||
label.time.till.idle = Zeitspanne f<>r automatisches 'Away' bei &Inaktivit<69>t (min)
|
||||
label.time.till.idlemessage = Stat&usnachricht f<>r automatisches 'Away'
|
||||
label.jabber.id = &Jabber ID
|
||||
label.group = &Gruppe
|
||||
label.enter.group.name = Namen f<>r neue Gruppe eingeben
|
||||
|
||||
Reference in New Issue
Block a user