aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator/util
diff options
context:
space:
mode:
authorWolfgang Wiedmeyer <wolfgit@wiedmeyer.de>2017-03-11 22:15:03 +0100
committerWolfgang Wiedmeyer <wolfgit@wiedmeyer.de>2017-03-11 22:15:03 +0100
commit85901329b0794b136b96bf745f4ab1572806fc89 (patch)
treef23da7e97cae727f39d825f0fef8348cffb238e4 /src/net/java/sip/communicator/util
parent3db2e44f186c59429901b2c899e139ea60117a55 (diff)
parentcf5da997da8820b4050f5b87ee9440a0ede36d1f (diff)
downloadjitsi-85901329b0794b136b96bf745f4ab1572806fc89.zip
jitsi-85901329b0794b136b96bf745f4ab1572806fc89.tar.gz
jitsi-85901329b0794b136b96bf745f4ab1572806fc89.tar.bz2
Merge commit 'cf5da99'HEADmaster
Signed-off-by: Wolfgang Wiedmeyer <wolfgit@wiedmeyer.de>
Diffstat (limited to 'src/net/java/sip/communicator/util')
-rw-r--r--src/net/java/sip/communicator/util/ConfigurationUtils.java78
-rw-r--r--src/net/java/sip/communicator/util/GenericBuffer.java230
-rw-r--r--src/net/java/sip/communicator/util/JitsiDnsNameService.java151
-rw-r--r--src/net/java/sip/communicator/util/JitsiDnsNameServiceDescriptor.java58
-rw-r--r--src/net/java/sip/communicator/util/NetworkUtils.java45
-rw-r--r--src/net/java/sip/communicator/util/ScLogFormatter.java123
-rw-r--r--src/net/java/sip/communicator/util/UtilActivator.java18
-rw-r--r--src/net/java/sip/communicator/util/account/AccountStatusUtils.java386
-rw-r--r--src/net/java/sip/communicator/util/account/AccountUtils.java606
-rw-r--r--src/net/java/sip/communicator/util/account/LoginManager.java1150
-rw-r--r--src/net/java/sip/communicator/util/account/LoginRenderer.java182
-rw-r--r--src/net/java/sip/communicator/util/launchutils/LaunchArgHandler.java6
-rw-r--r--src/net/java/sip/communicator/util/util.manifest.mf4
13 files changed, 1720 insertions, 1317 deletions
diff --git a/src/net/java/sip/communicator/util/ConfigurationUtils.java b/src/net/java/sip/communicator/util/ConfigurationUtils.java
index 05e4f09..d24426d 100644
--- a/src/net/java/sip/communicator/util/ConfigurationUtils.java
+++ b/src/net/java/sip/communicator/util/ConfigurationUtils.java
@@ -92,6 +92,11 @@ public class ConfigurationUtils
private static boolean isQuitWarningShown = true;
/**
+ * Indicates if the main frame should be minimized instead of hidden.
+ */
+ private static boolean minimizeInsteadOfHide = false;
+
+ /**
* Indicates if typing notifications should be sent.
*/
private static boolean isSendTypingNotifications;
@@ -433,17 +438,9 @@ public class ConfigurationUtils
autoPopupNewMessage = true;
// Load the "sendMessageCommand" property.
- String messageCommandProperty
- = "service.gui.SEND_MESSAGE_COMMAND";
- String messageCommand = configService.getString(messageCommandProperty);
-
- if(messageCommand == null)
- messageCommand
- = UtilActivator.getResources()
- .getSettingsString(messageCommandProperty);
-
- if(messageCommand == null || messageCommand.length() == 0)
- sendMessageCommand = messageCommand;
+ String messageCommandProperty = "service.gui.SEND_MESSAGE_COMMAND";
+ sendMessageCommand = UtilActivator.getResources()
+ .getSettingsString(messageCommandProperty);
// Load the showCallPanel property.
String callPanelShown = configService.getString(
@@ -479,6 +476,10 @@ public class ConfigurationUtils
= Boolean.parseBoolean(quitWarningShown);
}
+ minimizeInsteadOfHide = configService.getBoolean(
+ "net.java.sip.communicator.impl.gui.minimizeInsteadOfHide",
+ isPinnedToTaskBar());
+
// Load the "sendTypingNotifications" property.
String isSendTypingNotifProperty =
"service.gui.SEND_TYPING_NOTIFICATIONS_ENABLED";
@@ -964,6 +965,37 @@ public class ConfigurationUtils
);
}
+ private static boolean isPinnedToTaskBar()
+ {
+ if (!OSUtils.IS_WINDOWS)
+ {
+ return false;
+ }
+
+ File taskbar = new File(System.getenv("appdata"),
+ "Microsoft\\Internet Explorer\\Quick Launch\\User Pinned\\TaskBar");
+ File[] pins = taskbar.listFiles(new FileFilter()
+ {
+ @Override
+ public boolean accept(File f)
+ {
+ return f.getName().endsWith(".lnk");
+ }
+ });
+
+ String title = UtilActivator.getResources()
+ .getSettingsString("service.gui.APPLICATION_NAME");
+ for (File pin : pins)
+ {
+ if (pin.getName().contains(title))
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
/**
* Checks whether font support is disabled, checking in default
* settings for the default value.
@@ -1055,6 +1087,30 @@ public class ConfigurationUtils
}
/**
+ * Gets whether the application should be minimized and not hidden when
+ * clicking close on the main frame.
+ * @return <tt>true</tt> when the main frame should be minimized,
+ * <tt>false</tt> otherwise
+ */
+ public static boolean isMinimizeInsteadOfHide()
+ {
+ return minimizeInsteadOfHide;
+ }
+
+ /**
+ * Sets whether the application should be minimized and not hidden when
+ * clicking close on the main frame.
+ * @param value <tt>true</tt> when the main frame should be minimized,
+ * <tt>false</tt> otherwise
+ */
+ public static void setIsMinimizeInsteadOfHide(boolean value)
+ {
+ minimizeInsteadOfHide = value;
+ configService.setProperty(
+ "net.java.sip.communicator.impl.gui.minimizeInsteadOfHide", value);
+ }
+
+ /**
* Return TRUE if "quitWarningShown" property is true, otherwise -
* return FALSE. Indicates to the user interface whether the quit warning
* dialog should be shown when user clicks on the X button.
diff --git a/src/net/java/sip/communicator/util/GenericBuffer.java b/src/net/java/sip/communicator/util/GenericBuffer.java
index 756d22f..3647174 100644
--- a/src/net/java/sip/communicator/util/GenericBuffer.java
+++ b/src/net/java/sip/communicator/util/GenericBuffer.java
@@ -1,4 +1,4 @@
-/*
+/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Copyright @ 2015 Atlassian Pty Ltd
@@ -15,117 +15,117 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package net.java.sip.communicator.util;
-
-import java.util.*;
-
-/**
- * The GenericBuffer class provides a way to minimize the effort needed to
- * buffer any kind of information. This class is particularly suited to
- * optimizations based on reusing already computed data.
- *
- * @author Benoit Pradelle
- */
-public class GenericBuffer<T>
-{
- private final Hashtable<String, GenericBufferPair> buffer;
-
- private int minAge = 0;
-
- private int curAge = 0;
-
- private final int maxCapacity;
-
- /**
- * Sole constructor.
- *
- * @param bufferSize The buffer size. Adding data to a full buffer will
- * cause the oldest data present in the buffer to be overwritten;
- */
- public GenericBuffer(final int bufferSize)
- {
- assert bufferSize > 0;
-
- buffer = new Hashtable<String, GenericBufferPair>(bufferSize);
- maxCapacity = bufferSize;
- }
-
- /**
- * Adds a value to the buffer. If the buffer is full, the oldest value in
- * the buffer will be overwritten by this new value.
- *
- * @param value The value to add. Can't be null.
- * @param context The context for which this value is valid. This basically
- * represents the current value of all the variables which
- * control the value is correct. The context is used to find this
- * value in the buffer. If the context is already associated in
- * the buffer with a value, nothing is added nor modified.
- */
- public void addValue(final T value, final String context)
- {
- assert value != null && context != null;
-
- GenericBufferPair storage = buffer.get(context);
-
- if (storage == null)
- {
- storage = new GenericBufferPair();
- }
- else
- {
- return; // don't override values
- }
-
- // if the amount of data has reach the limit, search the oldest data
- if (buffer.size() == maxCapacity)
- {
- for (Map.Entry<String, GenericBufferPair> e : buffer.entrySet())
- {
- if (e.getValue().age == minAge)
- {
- buffer.remove(e.getKey());
- minAge++;
- break;
- }
- }
- }
-
- storage.age = curAge++;
- storage.value = value;
-
- buffer.put(context, storage);
- }
-
- /**
- * Retrieves the value in the buffer corresponding to the context if it
- * exists.
- *
- * @param context The context of the searched value. The context represents
- * all the variables values for which this value is correct.
- * @return The bufferized value with the searched context if it exists or
- * null if no value is found.
- */
- public T getValue(final String context)
- {
- assert context != null;
-
- GenericBufferPair res = buffer.get(context);
-
- if (res == null)
- {
- return null;
- }
-
- return res.value;
- }
-
- /**
- * This class is a simple structure to store a pair context-value
- */
- private class GenericBufferPair
- {
- public T value = null;
-
- public int age = 0;
- }
-}
+package net.java.sip.communicator.util;
+
+import java.util.*;
+
+/**
+ * The GenericBuffer class provides a way to minimize the effort needed to
+ * buffer any kind of information. This class is particularly suited to
+ * optimizations based on reusing already computed data.
+ *
+ * @author Benoit Pradelle
+ */
+public class GenericBuffer<T>
+{
+ private final Hashtable<String, GenericBufferPair> buffer;
+
+ private int minAge = 0;
+
+ private int curAge = 0;
+
+ private final int maxCapacity;
+
+ /**
+ * Sole constructor.
+ *
+ * @param bufferSize The buffer size. Adding data to a full buffer will
+ * cause the oldest data present in the buffer to be overwritten;
+ */
+ public GenericBuffer(final int bufferSize)
+ {
+ assert bufferSize > 0;
+
+ buffer = new Hashtable<String, GenericBufferPair>(bufferSize);
+ maxCapacity = bufferSize;
+ }
+
+ /**
+ * Adds a value to the buffer. If the buffer is full, the oldest value in
+ * the buffer will be overwritten by this new value.
+ *
+ * @param value The value to add. Can't be null.
+ * @param context The context for which this value is valid. This basically
+ * represents the current value of all the variables which
+ * control the value is correct. The context is used to find this
+ * value in the buffer. If the context is already associated in
+ * the buffer with a value, nothing is added nor modified.
+ */
+ public void addValue(final T value, final String context)
+ {
+ assert value != null && context != null;
+
+ GenericBufferPair storage = buffer.get(context);
+
+ if (storage == null)
+ {
+ storage = new GenericBufferPair();
+ }
+ else
+ {
+ return; // don't override values
+ }
+
+ // if the amount of data has reach the limit, search the oldest data
+ if (buffer.size() == maxCapacity)
+ {
+ for (Map.Entry<String, GenericBufferPair> e : buffer.entrySet())
+ {
+ if (e.getValue().age == minAge)
+ {
+ buffer.remove(e.getKey());
+ minAge++;
+ break;
+ }
+ }
+ }
+
+ storage.age = curAge++;
+ storage.value = value;
+
+ buffer.put(context, storage);
+ }
+
+ /**
+ * Retrieves the value in the buffer corresponding to the context if it
+ * exists.
+ *
+ * @param context The context of the searched value. The context represents
+ * all the variables values for which this value is correct.
+ * @return The bufferized value with the searched context if it exists or
+ * null if no value is found.
+ */
+ public T getValue(final String context)
+ {
+ assert context != null;
+
+ GenericBufferPair res = buffer.get(context);
+
+ if (res == null)
+ {
+ return null;
+ }
+
+ return res.value;
+ }
+
+ /**
+ * This class is a simple structure to store a pair context-value
+ */
+ private class GenericBufferPair
+ {
+ public T value = null;
+
+ public int age = 0;
+ }
+}
diff --git a/src/net/java/sip/communicator/util/JitsiDnsNameService.java b/src/net/java/sip/communicator/util/JitsiDnsNameService.java
new file mode 100644
index 0000000..cf68ad5
--- /dev/null
+++ b/src/net/java/sip/communicator/util/JitsiDnsNameService.java
@@ -0,0 +1,151 @@
+/*
+ * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
+ *
+ * Copyright @ 2016 Atlassian Pty Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.java.sip.communicator.util;
+
+import java.lang.reflect.Method;
+import java.net.*;
+
+import org.xbill.DNS.*;
+
+import sun.net.spi.nameservice.*;
+
+/**
+ * JNDI DNS service to send DNS lookup through the dnsjava <tt>Lookup</tt>
+ * infrastructure. This is needed to catch lookups that are not made
+ * through the DNSSEC-aware <tt>NetworkUtils</tt>.
+ *
+ * @author Ingo Bauersachs
+ */
+public class JitsiDnsNameService
+ implements NameService
+{
+ private static boolean v6first;
+ private static Name localhostName = null;
+ private static InetAddress[] localhostAddresses = null;
+ private static InetAddress[] localhostNamedAddresses = null;
+ private static boolean addressesLoaded = false;
+
+ static
+ {
+ v6first = Boolean.getBoolean("java.net.preferIPv6Addresses");
+ try
+ {
+ // retrieve the name from the system that is used as localhost
+ Class<?> inClass = Class.forName("java.net.InetAddressImplFactory");
+ Method create = inClass.getDeclaredMethod("create");
+ create.setAccessible(true);
+
+ Object impl = create.invoke(null);
+ Class<?> clazz = Class.forName("java.net.InetAddressImpl");
+ Method hostname = clazz.getMethod("getLocalHostName");
+ hostname.setAccessible(true);
+ localhostName = new Name((String) hostname.invoke(impl));
+ Method lookup = clazz.getMethod("lookupAllHostAddr", String.class);
+ lookup.setAccessible(true);
+
+ localhostNamedAddresses = (InetAddress[])lookup.invoke(impl,
+ localhostName.toString());
+ localhostAddresses = (InetAddress[])lookup.invoke(impl,
+ "localhost");
+
+ addressesLoaded = true;
+ }
+ catch (Exception e)
+ {
+ System.err.println("Could not obtain localhost: " + e);
+ }
+ }
+
+ @Override
+ public String getHostByAddr(final byte[] bytes)
+ throws UnknownHostException
+ {
+ InetAddress addr = InetAddress.getByAddress(bytes);
+ if (addr.isLoopbackAddress())
+ {
+ return "localhost";
+ }
+
+ Name name = ReverseMap.fromAddress(addr);
+ Lookup l = new Lookup(name, Type.PTR);
+ Record[] records = l.run();
+ if (records == null)
+ {
+ throw new UnknownHostException();
+ }
+
+ return ((PTRRecord) records[0]).getTarget().toString();
+ }
+
+ @Override
+ public InetAddress[] lookupAllHostAddr(final String host)
+ throws UnknownHostException
+ {
+ Name n;
+ try
+ {
+ n = new Name(host);
+ // Avoid sending queries to a nameserver for localhost
+ // and the machine's hostname. Unless in an enterprise environment
+ // the nameserver wouldn't know about that machine name anyway.
+ if (addressesLoaded)
+ {
+ if (n.equals(localhostName))
+ {
+ return localhostNamedAddresses;
+ }
+ else if (host.equals("localhost"))
+ {
+ return localhostAddresses;
+ }
+ }
+ }
+ catch (TextParseException e)
+ {
+ throw new UnknownHostException(host);
+ }
+
+ Lookup l = new Lookup(n, v6first ? Type.AAAA : Type.A);
+ Record[] r = l.run();
+ if (r == null || r.length == 0)
+ {
+ l = new Lookup(n, v6first ? Type.A : Type.AAAA);
+ r = l.run();
+ }
+
+ if (r == null || r.length == 0)
+ {
+ throw new UnknownHostException(host);
+ }
+
+ InetAddress[] results = new InetAddress[r.length];
+ for (int i = 0; i < r.length; i++)
+ {
+ if (r[i] instanceof AAAARecord)
+ {
+ results[i] = ((AAAARecord) r[i]).getAddress();
+ }
+ else if (r[i] instanceof ARecord)
+ {
+ results[i] = ((ARecord) r[i]).getAddress();
+ }
+ }
+
+ return results;
+ }
+}
diff --git a/src/net/java/sip/communicator/util/JitsiDnsNameServiceDescriptor.java b/src/net/java/sip/communicator/util/JitsiDnsNameServiceDescriptor.java
new file mode 100644
index 0000000..559646a
--- /dev/null
+++ b/src/net/java/sip/communicator/util/JitsiDnsNameServiceDescriptor.java
@@ -0,0 +1,58 @@
+/*
+ * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
+ *
+ * Copyright @ 2016 Atlassian Pty Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.java.sip.communicator.util;
+
+import sun.net.spi.nameservice.*;
+
+/**
+ * A name service descriptor for Jitsi's DNS service. It is instantiated by the
+ * JRE when DNSSEC is enabled in Jitsi's options.
+ *
+ * @author Ingo Bauersachs
+ */
+public class JitsiDnsNameServiceDescriptor
+ implements NameServiceDescriptor
+{
+ /**
+ * Gets and creates an instance of the Jitsi's name service.
+ *
+ * @return an instance of the Jitsi's name service.
+ */
+ public NameService createNameService()
+ {
+ return new JitsiDnsNameService();
+ }
+
+ /**
+ * Gets the type of this name service.
+ * @return the string <tt>dns</tt>
+ */
+ public String getType()
+ {
+ return "dns";
+ }
+
+ /**
+ * Gets the name of this name service.
+ * @return the string <tt>jitsi</tt>
+ */
+ public String getProviderName()
+ {
+ return "jitsi";
+ }
+} \ No newline at end of file
diff --git a/src/net/java/sip/communicator/util/NetworkUtils.java b/src/net/java/sip/communicator/util/NetworkUtils.java
index 5b641b9..2bb4c2b 100644
--- a/src/net/java/sip/communicator/util/NetworkUtils.java
+++ b/src/net/java/sip/communicator/util/NetworkUtils.java
@@ -107,6 +107,14 @@ public class NetworkUtils
*/
private static final Random random = new Random();
+ static
+ {
+ String prefer6 = System.getProperty("java.net.preferIPv6Addresses");
+ String prefer4 = System.getProperty("java.net.preferIPv4Stack");
+ logger.info("java.net.preferIPv6Addresses=" + prefer6);
+ logger.info("java.net.preferIPv4Stack=" + prefer4);
+ }
+
/**
* Determines whether the address is the result of windows auto configuration.
* (i.e. One that is in the 169.254.0.0 network)
@@ -420,6 +428,15 @@ public class NetworkUtils
colonIndex = -1;
int i = 0, j = 0;
+
+ // Can be wrapped in []
+ if (addrBuff[i] == '[')
+ {
+ ++i;
+ if (scopeID == -1)
+ --srcb_length;
+ }
+
// Starting : mean we need to have at least one more.
if (addrBuff[i] == ':')
if (addrBuff[++i] != ':')
@@ -752,30 +769,38 @@ public class NetworkUtils
return null;
}
- String[][] recVals = new String[records.length][4];
+ List<String[]> recVals = new ArrayList<>(records.length);
for (int i = 0; i < records.length; i++)
{
+ String[] recVal = new String[4];
NAPTRRecord r = (NAPTRRecord)records[i];
// todo - check here for broken records as missing transport
- recVals[i][0] = "" + r.getOrder();
- recVals[i][1] = getProtocolFromNAPTRRecords(r.getService());
+ recVal[0] = "" + r.getOrder();
+ recVal[1] = getProtocolFromNAPTRRecords(r.getService());
+ if (recVal[1] == null)
+ {
+ // we don't understand this NAPTR, maybe it's not for SIP?
+ continue;
+ }
+
String replacement = r.getReplacement().toString();
if (replacement.endsWith("."))
{
- recVals[i][2] =
+ recVal[2] =
replacement.substring(0, replacement.length() - 1);
}
else
{
- recVals[i][2] = replacement;
+ recVal[2] = replacement;
}
- recVals[i][3] = "" + r.getPreference();
+ recVal[3] = "" + r.getPreference();
+ recVals.add(recVal);
}
// sort the SRV RRs by RR value (lower is preferred)
- Arrays.sort(recVals, new Comparator<String[]>()
+ Collections.sort(recVals, new Comparator<String[]>()
{
// Sorts NAPTR records by ORDER (low number first), PREFERENCE (low
// number first) and PROTOCOL (0-TLS, 1-TCP, 2-UDP).
@@ -806,10 +831,12 @@ public class NetworkUtils
}
});
+ String[][] arrayResult = new String[recVals.size()][4];
+ arrayResult = recVals.toArray(arrayResult);
if(logger.isTraceEnabled())
logger.trace("NAPTRs for " + domain + "="
- + Arrays.toString(recVals));
- return recVals;
+ + Arrays.toString(arrayResult));
+ return arrayResult;
}
/**
diff --git a/src/net/java/sip/communicator/util/ScLogFormatter.java b/src/net/java/sip/communicator/util/ScLogFormatter.java
index ad2129b..5d22db5 100644
--- a/src/net/java/sip/communicator/util/ScLogFormatter.java
+++ b/src/net/java/sip/communicator/util/ScLogFormatter.java
@@ -33,11 +33,53 @@ import java.util.logging.*;
public class ScLogFormatter
extends java.util.logging.Formatter
{
+
+ /**
+ * Program name logging property name
+ */
+ private static final String PROGRAM_NAME_PROPERTY = ".programname";
+
+ /**
+ * Disable timestamp logging property name.
+ */
+ private static final String DISABLE_TIMESTAMP_PROPERTY
+ = ".disableTimestamp";
+
+ /**
+ * Line separator used by current platform
+ */
private static String lineSeparator = System.getProperty("line.separator");
+
+ /**
+ * Two digit <tt>DecimalFormat</tt> instance, used to format datetime
+ */
private static DecimalFormat twoDigFmt = new DecimalFormat("00");
+
+ /**
+ * Three digit <tt>DecimalFormat</tt> instance, used to format datetime
+ */
private static DecimalFormat threeDigFmt = new DecimalFormat("000");
/**
+ * The application name used to generate this log
+ */
+ private static String programName;
+
+ /**
+ * Whether logger will add date to the logs, enabled by default.
+ */
+ private static boolean timestampDisabled = false;
+
+ /**
+ * The default constructor for <tt>ScLogFormatter</tt> which loads
+ * program name property from logging.properties file, if it exists
+ */
+ public ScLogFormatter()
+ {
+ loadConfigProperties();
+ }
+
+ /**
* Format the given LogRecord.
* @param record the log record to be formatted.
* @return a formatted log record
@@ -46,24 +88,36 @@ public class ScLogFormatter
public synchronized String format(LogRecord record)
{
StringBuffer sb = new StringBuffer();
+
+
+ if (programName != null)
+ {
+ // Program name
+ sb.append(programName);
+
+ sb.append(' ');
+ }
- //current time
- Calendar cal = Calendar.getInstance();
- int year = cal.get(Calendar.YEAR);
- int month = cal.get(Calendar.MONTH) + 1;
- int day = cal.get(Calendar.DAY_OF_MONTH);
- int hour = cal.get(Calendar.HOUR_OF_DAY);
- int minutes = cal.get(Calendar.MINUTE);
- int seconds = cal.get(Calendar.SECOND);
- int millis = cal.get(Calendar.MILLISECOND);
-
- sb.append(year).append('-');
- sb.append(twoDigFmt.format(month)).append('-');
- sb.append(twoDigFmt.format(day)).append(' ');
- sb.append(twoDigFmt.format(hour)).append(':');
- sb.append(twoDigFmt.format(minutes)).append(':');
- sb.append(twoDigFmt.format(seconds)).append('.');
- sb.append(threeDigFmt.format(millis)).append(' ');
+ if(!timestampDisabled)
+ {
+ //current time
+ Calendar cal = Calendar.getInstance();
+ int year = cal.get(Calendar.YEAR);
+ int month = cal.get(Calendar.MONTH) + 1;
+ int day = cal.get(Calendar.DAY_OF_MONTH);
+ int hour = cal.get(Calendar.HOUR_OF_DAY);
+ int minutes = cal.get(Calendar.MINUTE);
+ int seconds = cal.get(Calendar.SECOND);
+ int millis = cal.get(Calendar.MILLISECOND);
+
+ sb.append(year).append('-');
+ sb.append(twoDigFmt.format(month)).append('-');
+ sb.append(twoDigFmt.format(day)).append(' ');
+ sb.append(twoDigFmt.format(hour)).append(':');
+ sb.append(twoDigFmt.format(minutes)).append(':');
+ sb.append(twoDigFmt.format(seconds)).append('.');
+ sb.append(threeDigFmt.format(millis)).append(' ');
+ }
//log level
sb.append(record.getLevel().getLocalizedName());
@@ -146,7 +200,8 @@ public class ScLogFormatter
}
ix++;
}
- // Now search for the first frame before the SIP Communicator Logger class.
+ // Now search for the first frame
+ // before the SIP Communicator Logger class.
while (ix < stack.length)
{
StackTraceElement frame = stack[ix];
@@ -164,4 +219,36 @@ public class ScLogFormatter
return lineNumber;
}
+
+ /**
+ * Loads all config properties.
+ */
+ private void loadConfigProperties()
+ {
+ loadProgramNameProperty();
+ loadTimestampDisabledProperty();
+ }
+
+ /**
+ * Checks and loads timestamp disabled property if any.
+ */
+ private static void loadTimestampDisabledProperty()
+ {
+ LogManager manager = LogManager.getLogManager();
+ String cname = ScLogFormatter.class.getName();
+ timestampDisabled = Boolean.parseBoolean(
+ manager.getProperty(cname + DISABLE_TIMESTAMP_PROPERTY));
+ }
+
+ /**
+ * Load the programname property to be used in logs to identify Jitsi-based
+ * application which produced the logs
+ */
+ private static void loadProgramNameProperty()
+ {
+ LogManager manager = LogManager.getLogManager();
+ String cname = ScLogFormatter.class.getName();
+ programName = manager.getProperty(cname + PROGRAM_NAME_PROPERTY);
+ }
+
}
diff --git a/src/net/java/sip/communicator/util/UtilActivator.java b/src/net/java/sip/communicator/util/UtilActivator.java
index c2ee299..6dff186 100644
--- a/src/net/java/sip/communicator/util/UtilActivator.java
+++ b/src/net/java/sip/communicator/util/UtilActivator.java
@@ -22,6 +22,7 @@ import java.util.*;
import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.resources.*;
+import net.java.sip.communicator.service.systray.*;
import org.jitsi.service.configuration.*;
import org.jitsi.service.fileaccess.*;
@@ -65,6 +66,8 @@ public class UtilActivator
private static AlertUIService alertUIService;
+ private static SystrayService systrayService;
+
/**
* Calls <tt>Thread.setUncaughtExceptionHandler()</tt>
*
@@ -184,6 +187,21 @@ public class UtilActivator
}
/**
+ * Gets the <tt>SystrayService</tt> instance registered in the
+ * <tt>BundleContext</tt> of the <tt>UtilActivator</tt>.
+ *
+ * @return the <tt>SystrayService</tt> instance registered in the
+ * <tt>BundleContext</tt> of the <tt>UtilActivator</tt>
+ */
+ public static SystrayService getSystrayService()
+ {
+ if (systrayService == null)
+ systrayService =
+ ServiceUtils.getService(bundleContext, SystrayService.class);
+ return systrayService;
+ }
+
+ /**
* Returns the <tt>FileAccessService</tt> obtained from the bundle context.
*
* @return the <tt>FileAccessService</tt> obtained from the bundle context
diff --git a/src/net/java/sip/communicator/util/account/AccountStatusUtils.java b/src/net/java/sip/communicator/util/account/AccountStatusUtils.java
index 583fb0a..e5152b4 100644
--- a/src/net/java/sip/communicator/util/account/AccountStatusUtils.java
+++ b/src/net/java/sip/communicator/util/account/AccountStatusUtils.java
@@ -1,4 +1,4 @@
-/*
+/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Copyright @ 2015 Atlassian Pty Ltd
@@ -15,196 +15,196 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package net.java.sip.communicator.util.account;
-
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.service.protocol.globalstatus.*;
-import net.java.sip.communicator.util.*;
-
-import java.util.*;
-
-/**
- * The <tt>AccountStatusUtils</tt> provides utility methods for account status
- * management.
- *
- * @author Yana Stamcheva
- */
-public class AccountStatusUtils
-{
- private static GlobalStatusService globalStatusService;
-
- /**
- * If the protocol provider supports presence operation set searches the
- * last status which was selected, otherwise returns null.
- *
- * @param protocolProvider the protocol provider we're interested in.
- * @return the last protocol provider presence status, or null if this
- * provider doesn't support presence operation set
- */
- public static Object getProtocolProviderLastStatus(
- ProtocolProviderService protocolProvider)
- {
- if(getProtocolPresenceOpSet(protocolProvider) != null)
- return getLastPresenceStatus(protocolProvider);
- else
- return getGlobalStatusService()
- .getLastStatusString(protocolProvider);
- }
-
- /**
- * Returns the presence operation set for the given protocol provider.
- *
- * @param protocolProvider The protocol provider for which the
- * presence operation set is searched.
- * @return the presence operation set for the given protocol provider.
- */
- public static OperationSetPresence getProtocolPresenceOpSet(
- ProtocolProviderService protocolProvider)
- {
- OperationSet opSet
- = protocolProvider.getOperationSet(OperationSetPresence.class);
-
- return
- (opSet instanceof OperationSetPresence)
- ? (OperationSetPresence) opSet
- : null;
- }
-
- /**
- * Returns the last status that was stored in the configuration xml for the
- * given protocol provider.
- *
- * @param protocolProvider the protocol provider
- * @return the last status that was stored in the configuration xml for the
- * given protocol provider
- */
- public static PresenceStatus getLastPresenceStatus(
- ProtocolProviderService protocolProvider)
- {
- if (getGlobalStatusService() != null)
- return getGlobalStatusService().getLastPresenceStatus(
- protocolProvider);
-
- return null;
- }
-
- /**
- * Returns the current status for protocol provider.
- *
- * @param protocolProvider the protocol provider
- * @return the current status for protocol provider
- */
- public static PresenceStatus getPresenceStatus(
- ProtocolProviderService protocolProvider)
- {
- PresenceStatus status = null;
-
- OperationSetPresence opSet
- = protocolProvider.getOperationSet(OperationSetPresence.class);
-
- if(opSet != null)
- status = opSet.getPresenceStatus();
-
- return status;
- }
-
- /**
- * Returns the online status of provider.
- * @param protocolProvider the protocol provider
- * @return the online status of provider.
- */
- public static PresenceStatus getOnlineStatus(
- ProtocolProviderService protocolProvider)
- {
- PresenceStatus onlineStatus = null;
-
- OperationSetPresence presence
- = protocolProvider.getOperationSet(OperationSetPresence.class);
-
- // presence can be not supported
- if(presence != null)
- {
- Iterator<PresenceStatus> statusIterator
- = presence.getSupportedStatusSet();
- while (statusIterator.hasNext())
- {
- PresenceStatus status = statusIterator.next();
- int connectivity = status.getStatus();
-
- if ((onlineStatus != null
- && (onlineStatus.getStatus() < connectivity))
- || (onlineStatus == null
- && (connectivity > 50 && connectivity < 80)))
- {
- onlineStatus = status;
- }
- }
- }
-
- return onlineStatus;
- }
-
- /**
- * Returns the offline status of provider.
- * @param protocolProvider the protocol provider
- * @return the offline status of provider.
- */
- public static PresenceStatus getOfflineStatus(
- ProtocolProviderService protocolProvider)
- {
- PresenceStatus offlineStatus = null;
-
- OperationSetPresence presence
- = protocolProvider.getOperationSet(OperationSetPresence.class);
-
- // presence can be not supported
- if(presence != null)
- {
- Iterator<PresenceStatus> statusIterator
- = presence.getSupportedStatusSet();
- while (statusIterator.hasNext())
- {
- PresenceStatus status = statusIterator.next();
- int connectivity = status.getStatus();
-
- if (connectivity < 1)
- {
- offlineStatus = status;
- }
- }
- }
-
- return offlineStatus;
- }
-
- /**
- * Returns the last contact status saved in the configuration.
- *
- * @param protocolProvider the protocol provider to which the status
- * corresponds
- * @return the last contact status saved in the configuration.
- */
- public String getLastStatusString(ProtocolProviderService protocolProvider)
- {
- return getGlobalStatusService().getLastStatusString(protocolProvider);
- }
-
- /**
- * Returns the <tt>GlobalStatusService</tt> obtained from the bundle
- * context.
- * @return the <tt>GlobalStatusService</tt> obtained from the bundle
- * context
- */
- public static GlobalStatusService getGlobalStatusService()
- {
- if (globalStatusService == null)
- {
- globalStatusService
- = ServiceUtils.getService(
- UtilActivator.bundleContext,
- GlobalStatusService.class);
- }
-
- return globalStatusService;
- }
+package net.java.sip.communicator.util.account;
+
+import net.java.sip.communicator.service.protocol.*;
+import net.java.sip.communicator.service.protocol.globalstatus.*;
+import net.java.sip.communicator.util.*;
+
+import java.util.*;
+
+/**
+ * The <tt>AccountStatusUtils</tt> provides utility methods for account status
+ * management.
+ *
+ * @author Yana Stamcheva
+ */
+public class AccountStatusUtils
+{
+ private static GlobalStatusService globalStatusService;
+
+ /**
+ * If the protocol provider supports presence operation set searches the
+ * last status which was selected, otherwise returns null.
+ *
+ * @param protocolProvider the protocol provider we're interested in.
+ * @return the last protocol provider presence status, or null if this
+ * provider doesn't support presence operation set
+ */
+ public static Object getProtocolProviderLastStatus(
+ ProtocolProviderService protocolProvider)
+ {
+ if(getProtocolPresenceOpSet(protocolProvider) != null)
+ return getLastPresenceStatus(protocolProvider);
+ else
+ return getGlobalStatusService()
+ .getLastStatusString(protocolProvider);
+ }
+
+ /**
+ * Returns the presence operation set for the given protocol provider.
+ *
+ * @param protocolProvider The protocol provider for which the
+ * presence operation set is searched.
+ * @return the presence operation set for the given protocol provider.
+ */
+ public static OperationSetPresence getProtocolPresenceOpSet(
+ ProtocolProviderService protocolProvider)
+ {
+ OperationSet opSet
+ = protocolProvider.getOperationSet(OperationSetPresence.class);
+
+ return
+ (opSet instanceof OperationSetPresence)
+ ? (OperationSetPresence) opSet
+ : null;
+ }
+
+ /**
+ * Returns the last status that was stored in the configuration xml for the
+ * given protocol provider.
+ *
+ * @param protocolProvider the protocol provider
+ * @return the last status that was stored in the configuration xml for the
+ * given protocol provider
+ */
+ public static PresenceStatus getLastPresenceStatus(
+ ProtocolProviderService protocolProvider)
+ {
+ if (getGlobalStatusService() != null)
+ return getGlobalStatusService().getLastPresenceStatus(
+ protocolProvider);
+
+ return null;
+ }
+
+ /**
+ * Returns the current status for protocol provider.
+ *
+ * @param protocolProvider the protocol provider
+ * @return the current status for protocol provider
+ */
+ public static PresenceStatus getPresenceStatus(
+ ProtocolProviderService protocolProvider)
+ {
+ PresenceStatus status = null;
+
+ OperationSetPresence opSet
+ = protocolProvider.getOperationSet(OperationSetPresence.class);
+
+ if(opSet != null)
+ status = opSet.getPresenceStatus();
+
+ return status;
+ }
+
+ /**
+ * Returns the online status of provider.
+ * @param protocolProvider the protocol provider
+ * @return the online status of provider.
+ */
+ public static PresenceStatus getOnlineStatus(
+ ProtocolProviderService protocolProvider)
+ {
+ PresenceStatus onlineStatus = null;
+
+ OperationSetPresence presence
+ = protocolProvider.getOperationSet(OperationSetPresence.class);
+
+ // presence can be not supported
+ if(presence != null)
+ {
+ Iterator<PresenceStatus> statusIterator
+ = presence.getSupportedStatusSet();
+ while (statusIterator.hasNext())
+ {
+ PresenceStatus status = statusIterator.next();
+ int connectivity = status.getStatus();
+
+ if ((onlineStatus != null
+ && (onlineStatus.getStatus() < connectivity))
+ || (onlineStatus == null
+ && (connectivity > 50 && connectivity < 80)))
+ {
+ onlineStatus = status;
+ }
+ }
+ }
+
+ return onlineStatus;
+ }
+
+ /**
+ * Returns the offline status of provider.
+ * @param protocolProvider the protocol provider
+ * @return the offline status of provider.
+ */
+ public static PresenceStatus getOfflineStatus(
+ ProtocolProviderService protocolProvider)
+ {
+ PresenceStatus offlineStatus = null;
+
+ OperationSetPresence presence
+ = protocolProvider.getOperationSet(OperationSetPresence.class);
+
+ // presence can be not supported
+ if(presence != null)
+ {
+ Iterator<PresenceStatus> statusIterator
+ = presence.getSupportedStatusSet();
+ while (statusIterator.hasNext())
+ {
+ PresenceStatus status = statusIterator.next();
+ int connectivity = status.getStatus();
+
+ if (connectivity < 1)
+ {
+ offlineStatus = status;
+ }
+ }
+ }
+
+ return offlineStatus;
+ }
+
+ /**
+ * Returns the last contact status saved in the configuration.
+ *
+ * @param protocolProvider the protocol provider to which the status
+ * corresponds
+ * @return the last contact status saved in the configuration.
+ */
+ public String getLastStatusString(ProtocolProviderService protocolProvider)
+ {
+ return getGlobalStatusService().getLastStatusString(protocolProvider);
+ }
+
+ /**
+ * Returns the <tt>GlobalStatusService</tt> obtained from the bundle
+ * context.
+ * @return the <tt>GlobalStatusService</tt> obtained from the bundle
+ * context
+ */
+ public static GlobalStatusService getGlobalStatusService()
+ {
+ if (globalStatusService == null)
+ {
+ globalStatusService
+ = ServiceUtils.getService(
+ UtilActivator.bundleContext,
+ GlobalStatusService.class);
+ }
+
+ return globalStatusService;
+ }
}
diff --git a/src/net/java/sip/communicator/util/account/AccountUtils.java b/src/net/java/sip/communicator/util/account/AccountUtils.java
index ec69aca..82c9108 100644
--- a/src/net/java/sip/communicator/util/account/AccountUtils.java
+++ b/src/net/java/sip/communicator/util/account/AccountUtils.java
@@ -1,4 +1,4 @@
-/*
+/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Copyright @ 2015 Atlassian Pty Ltd
@@ -15,305 +15,305 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package net.java.sip.communicator.util.account;
-
-import java.util.*;
-
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.util.*;
-
-import org.osgi.framework.*;
-
-/**
- * The <tt>AccountUtils</tt> provides utility methods helping us to easily
- * obtain an account or a groups of accounts or protocol providers by some
- * specific criteria.
- *
- * @author Yana Stamcheva
- */
-public class AccountUtils
-{
- /**
- * The logger.
- */
- private static Logger logger = Logger.getLogger(AccountUtils.class);
-
- /**
- * Returns an iterator over a list of all stored <tt>AccountID</tt>-s.
- *
- * @return an iterator over a list of all stored <tt>AccountID</tt>-s
- */
- public static Collection<AccountID> getStoredAccounts()
- {
- AccountManager accountManager
- = ServiceUtils.getService( UtilActivator.bundleContext,
- AccountManager.class);
-
- return accountManager.getStoredAccounts();
- }
-
- /**
- * Return the <tt>AccountID</tt> corresponding to the given string account
- * identifier.
- *
- * @param accountID the account identifier string
- * @return the <tt>AccountID</tt> corresponding to the given string account
- * identifier
- */
- public static AccountID getAccountForID(String accountID)
- {
- Collection<AccountID> allAccounts = getStoredAccounts();
-
- for(AccountID account : allAccounts)
- {
- if(account.getAccountUniqueID().equals(accountID))
- return account;
- }
- return null;
- }
-
- /**
- * Returns a list of all currently registered providers, which support the
- * given <tt>operationSetClass</tt>.
- *
- * @param opSetClass the operation set class for which we're looking
- * for providers
- * @return a list of all currently registered providers, which support the
- * given <tt>operationSetClass</tt>
- */
- public static List<ProtocolProviderService> getRegisteredProviders(
- Class<? extends OperationSet> opSetClass)
- {
- List<ProtocolProviderService> opSetProviders
- = new LinkedList<ProtocolProviderService>();
-
- for (ProtocolProviderFactory providerFactory
- : UtilActivator.getProtocolProviderFactories().values())
- {
- for (AccountID accountID : providerFactory.getRegisteredAccounts())
- {
- ServiceReference<ProtocolProviderService> ref
- = providerFactory.getProviderForAccount(accountID);
-
- if (ref != null)
- {
- ProtocolProviderService protocolProvider
- = UtilActivator.bundleContext.getService(ref);
-
- if ((protocolProvider.getOperationSet(opSetClass) != null)
- && protocolProvider.isRegistered())
- {
- opSetProviders.add(protocolProvider);
- }
- }
- }
- }
- return opSetProviders;
- }
-
-
- /**
- * Returns a list of all currently registered telephony providers for the
- * given protocol name.
- * @param protocolName the protocol name
- * @param opSetClass the operation set class for which we're looking for
- * providers
- * @return a list of all currently registered providers for the given
- * <tt>protocolName</tt> and supporting the given <tt>operationSetClass</tt>
- */
- public static List<ProtocolProviderService> getRegisteredProviders(
- String protocolName,
- Class<? extends OperationSet> opSetClass)
- {
- List<ProtocolProviderService> opSetProviders
- = new LinkedList<ProtocolProviderService>();
- ProtocolProviderFactory providerFactory
- = getProtocolProviderFactory(protocolName);
-
- if (providerFactory != null)
- {
- for (AccountID accountID : providerFactory.getRegisteredAccounts())
- {
- ServiceReference<ProtocolProviderService> ref
- = providerFactory.getProviderForAccount(accountID);
-
- if (ref != null)
- {
- ProtocolProviderService protocolProvider
- = UtilActivator.bundleContext.getService(ref);
-
- if ((protocolProvider.getOperationSet(opSetClass) != null)
- && protocolProvider.isRegistered())
- {
- opSetProviders.add(protocolProvider);
- }
- }
- }
- }
- return opSetProviders;
- }
-
- /**
- * Returns a list of all registered protocol providers that could be used
- * for the operation given by the operation set. Prefers the given preferred
- * protocol provider and preferred protocol name if they're available and
- * registered.
- *
- * @param opSet
- * @param preferredProvider
- * @param preferredProtocolName
- * @return a list of all registered protocol providers that could be used
- * for the operation given by the operation set
- */
- public static List<ProtocolProviderService> getOpSetRegisteredProviders(
- Class<? extends OperationSet> opSet,
- ProtocolProviderService preferredProvider,
- String preferredProtocolName)
- {
- List<ProtocolProviderService> providers
- = new ArrayList<ProtocolProviderService>();
-
- if (preferredProvider != null)
- {
- if (preferredProvider.isRegistered())
- {
- providers.add(preferredProvider);
- }
- // If we have a provider, but it's not registered we try to
- // obtain all registered providers for the same protocol as the
- // given preferred provider.
- else
- {
- providers
- = getRegisteredProviders(
- preferredProvider.getProtocolName(),
- opSet);
- }
- }
- // If we don't have a preferred provider we try to obtain a
- // preferred protocol name and all registered providers for it.
- else
- {
- if (preferredProtocolName != null)
- {
- providers
- = getRegisteredProviders(preferredProtocolName, opSet);
- }
- // If the protocol name is null we simply obtain all telephony
- // providers.
- else
- {
- providers = getRegisteredProviders(opSet);
- }
- }
-
- return providers;
- }
-
- /**
- * Returns the <tt>ProtocolProviderService</tt> corresponding to the given
- * account identifier that is registered in the given factory
- * @param accountID the identifier of the account
- * @return the <tt>ProtocolProviderService</tt> corresponding to the given
- * account identifier that is registered in the given factory
- */
- public static ProtocolProviderService getRegisteredProviderForAccount(
- AccountID accountID)
- {
- for (ProtocolProviderFactory factory
- : UtilActivator.getProtocolProviderFactories().values())
- {
- if (factory.getRegisteredAccounts().contains(accountID))
- {
- ServiceReference<ProtocolProviderService> ref
- = factory.getProviderForAccount(accountID);
-
- if (ref != null)
- {
- return UtilActivator.bundleContext.getService(ref);
- }
- }
- }
- return null;
- }
-
- /**
- * Returns a <tt>ProtocolProviderFactory</tt> for a given protocol
- * provider.
- * @param protocolProvider the <tt>ProtocolProviderService</tt>, which
- * factory we're looking for
- * @return a <tt>ProtocolProviderFactory</tt> for a given protocol
- * provider
- */
- public static ProtocolProviderFactory getProtocolProviderFactory(
- ProtocolProviderService protocolProvider)
- {
- return getProtocolProviderFactory(protocolProvider.getProtocolName());
- }
-
- /**
- * Returns a <tt>ProtocolProviderFactory</tt> for a given protocol
- * provider.
- * @param protocolName the name of the protocol
- * @return a <tt>ProtocolProviderFactory</tt> for a given protocol
- * provider
- */
- public static ProtocolProviderFactory getProtocolProviderFactory(
- String protocolName)
- {
- String osgiFilter
- = "(" + ProtocolProviderFactory.PROTOCOL + "=" + protocolName + ")";
- ProtocolProviderFactory protocolProviderFactory = null;
-
- try
- {
- Collection<ServiceReference<ProtocolProviderFactory>> refs
- = UtilActivator.bundleContext.getServiceReferences(
- ProtocolProviderFactory.class,
- osgiFilter);
-
- if ((refs != null) && !refs.isEmpty())
- {
- protocolProviderFactory
- = UtilActivator.bundleContext.getService(
- refs.iterator().next());
- }
- }
- catch (InvalidSyntaxException ex)
- {
- logger.error("AccountUtils : " + ex);
- }
- return protocolProviderFactory;
- }
-
-
- /**
- * Returns all registered protocol providers.
- *
- * @return a list of all registered providers
- */
- public static Collection<ProtocolProviderService> getRegisteredProviders()
- {
- List<ProtocolProviderService> registeredProviders
- = new LinkedList<ProtocolProviderService>();
-
- for (ProtocolProviderFactory providerFactory
- : UtilActivator.getProtocolProviderFactories().values())
- {
- for (AccountID accountID : providerFactory.getRegisteredAccounts())
- {
- ServiceReference<ProtocolProviderService> ref
- = providerFactory.getProviderForAccount(accountID);
-
- if (ref != null)
- {
- ProtocolProviderService protocolProvider
- = UtilActivator.bundleContext.getService(ref);
-
- registeredProviders.add(protocolProvider);
- }
- }
- }
- return registeredProviders;
- }
-}
+package net.java.sip.communicator.util.account;
+
+import java.util.*;
+
+import net.java.sip.communicator.service.protocol.*;
+import net.java.sip.communicator.util.*;
+
+import org.osgi.framework.*;
+
+/**
+ * The <tt>AccountUtils</tt> provides utility methods helping us to easily
+ * obtain an account or a groups of accounts or protocol providers by some
+ * specific criteria.
+ *
+ * @author Yana Stamcheva
+ */
+public class AccountUtils
+{
+ /**
+ * The logger.
+ */
+ private static Logger logger = Logger.getLogger(AccountUtils.class);
+
+ /**
+ * Returns an iterator over a list of all stored <tt>AccountID</tt>-s.
+ *
+ * @return an iterator over a list of all stored <tt>AccountID</tt>-s
+ */
+ public static Collection<AccountID> getStoredAccounts()
+ {
+ AccountManager accountManager
+ = ServiceUtils.getService( UtilActivator.bundleContext,
+ AccountManager.class);
+
+ return accountManager.getStoredAccounts();
+ }
+
+ /**
+ * Return the <tt>AccountID</tt> corresponding to the given string account
+ * identifier.
+ *
+ * @param accountID the account identifier string
+ * @return the <tt>AccountID</tt> corresponding to the given string account
+ * identifier
+ */
+ public static AccountID getAccountForID(String accountID)
+ {
+ Collection<AccountID> allAccounts = getStoredAccounts();
+
+ for(AccountID account : allAccounts)
+ {
+ if(account.getAccountUniqueID().equals(accountID))
+ return account;
+ }
+ return null;
+ }
+
+ /**
+ * Returns a list of all currently registered providers, which support the
+ * given <tt>operationSetClass</tt>.
+ *
+ * @param opSetClass the operation set class for which we're looking
+ * for providers
+ * @return a list of all currently registered providers, which support the
+ * given <tt>operationSetClass</tt>
+ */
+ public static List<ProtocolProviderService> getRegisteredProviders(
+ Class<? extends OperationSet> opSetClass)
+ {
+ List<ProtocolProviderService> opSetProviders
+ = new LinkedList<ProtocolProviderService>();
+
+ for (ProtocolProviderFactory providerFactory
+ : UtilActivator.getProtocolProviderFactories().values())
+ {
+ for (AccountID accountID : providerFactory.getRegisteredAccounts())
+ {
+ ServiceReference<ProtocolProviderService> ref
+ = providerFactory.getProviderForAccount(accountID);
+
+ if (ref != null)
+ {
+ ProtocolProviderService protocolProvider
+ = UtilActivator.bundleContext.getService(ref);
+
+ if ((protocolProvider.getOperationSet(opSetClass) != null)
+ && protocolProvider.isRegistered())
+ {
+ opSetProviders.add(protocolProvider);
+ }
+ }
+ }
+ }
+ return opSetProviders;
+ }
+
+
+ /**
+ * Returns a list of all currently registered telephony providers for the
+ * given protocol name.
+ * @param protocolName the protocol name
+ * @param opSetClass the operation set class for which we're looking for
+ * providers
+ * @return a list of all currently registered providers for the given
+ * <tt>protocolName</tt> and supporting the given <tt>operationSetClass</tt>
+ */
+ public static List<ProtocolProviderService> getRegisteredProviders(
+ String protocolName,
+ Class<? extends OperationSet> opSetClass)
+ {
+ List<ProtocolProviderService> opSetProviders
+ = new LinkedList<ProtocolProviderService>();
+ ProtocolProviderFactory providerFactory
+ = getProtocolProviderFactory(protocolName);
+
+ if (providerFactory != null)
+ {
+ for (AccountID accountID : providerFactory.getRegisteredAccounts())
+ {
+ ServiceReference<ProtocolProviderService> ref
+ = providerFactory.getProviderForAccount(accountID);
+
+ if (ref != null)
+ {
+ ProtocolProviderService protocolProvider
+ = UtilActivator.bundleContext.getService(ref);
+
+ if ((protocolProvider.getOperationSet(opSetClass) != null)
+ && protocolProvider.isRegistered())
+ {
+ opSetProviders.add(protocolProvider);
+ }
+ }
+ }
+ }
+ return opSetProviders;
+ }
+
+ /**
+ * Returns a list of all registered protocol providers that could be used
+ * for the operation given by the operation set. Prefers the given preferred
+ * protocol provider and preferred protocol name if they're available and
+ * registered.
+ *
+ * @param opSet
+ * @param preferredProvider
+ * @param preferredProtocolName
+ * @return a list of all registered protocol providers that could be used
+ * for the operation given by the operation set
+ */
+ public static List<ProtocolProviderService> getOpSetRegisteredProviders(
+ Class<? extends OperationSet> opSet,
+ ProtocolProviderService preferredProvider,
+ String preferredProtocolName)
+ {
+ List<ProtocolProviderService> providers
+ = new ArrayList<ProtocolProviderService>();
+
+ if (preferredProvider != null)
+ {
+ if (preferredProvider.isRegistered())
+ {
+ providers.add(preferredProvider);
+ }
+ // If we have a provider, but it's not registered we try to
+ // obtain all registered providers for the same protocol as the
+ // given preferred provider.
+ else
+ {
+ providers
+ = getRegisteredProviders(
+ preferredProvider.getProtocolName(),
+ opSet);
+ }
+ }
+ // If we don't have a preferred provider we try to obtain a
+ // preferred protocol name and all registered providers for it.
+ else
+ {
+ if (preferredProtocolName != null)
+ {
+ providers
+ = getRegisteredProviders(preferredProtocolName, opSet);
+ }
+ // If the protocol name is null we simply obtain all telephony
+ // providers.
+ else
+ {
+ providers = getRegisteredProviders(opSet);
+ }
+ }
+
+ return providers;
+ }
+
+ /**
+ * Returns the <tt>ProtocolProviderService</tt> corresponding to the given
+ * account identifier that is registered in the given factory
+ * @param accountID the identifier of the account
+ * @return the <tt>ProtocolProviderService</tt> corresponding to the given
+ * account identifier that is registered in the given factory
+ */
+ public static ProtocolProviderService getRegisteredProviderForAccount(
+ AccountID accountID)
+ {
+ for (ProtocolProviderFactory factory
+ : UtilActivator.getProtocolProviderFactories().values())
+ {
+ if (factory.getRegisteredAccounts().contains(accountID))
+ {
+ ServiceReference<ProtocolProviderService> ref
+ = factory.getProviderForAccount(accountID);
+
+ if (ref != null)
+ {
+ return UtilActivator.bundleContext.getService(ref);
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns a <tt>ProtocolProviderFactory</tt> for a given protocol
+ * provider.
+ * @param protocolProvider the <tt>ProtocolProviderService</tt>, which
+ * factory we're looking for
+ * @return a <tt>ProtocolProviderFactory</tt> for a given protocol
+ * provider
+ */
+ public static ProtocolProviderFactory getProtocolProviderFactory(
+ ProtocolProviderService protocolProvider)
+ {
+ return getProtocolProviderFactory(protocolProvider.getProtocolName());
+ }
+
+ /**
+ * Returns a <tt>ProtocolProviderFactory</tt> for a given protocol
+ * provider.
+ * @param protocolName the name of the protocol
+ * @return a <tt>ProtocolProviderFactory</tt> for a given protocol
+ * provider
+ */
+ public static ProtocolProviderFactory getProtocolProviderFactory(
+ String protocolName)
+ {
+ String osgiFilter
+ = "(" + ProtocolProviderFactory.PROTOCOL + "=" + protocolName + ")";
+ ProtocolProviderFactory protocolProviderFactory = null;
+
+ try
+ {
+ Collection<ServiceReference<ProtocolProviderFactory>> refs
+ = UtilActivator.bundleContext.getServiceReferences(
+ ProtocolProviderFactory.class,
+ osgiFilter);
+
+ if ((refs != null) && !refs.isEmpty())
+ {
+ protocolProviderFactory
+ = UtilActivator.bundleContext.getService(
+ refs.iterator().next());
+ }
+ }
+ catch (InvalidSyntaxException ex)
+ {
+ logger.error("AccountUtils : " + ex);
+ }
+ return protocolProviderFactory;
+ }
+
+
+ /**
+ * Returns all registered protocol providers.
+ *
+ * @return a list of all registered providers
+ */
+ public static Collection<ProtocolProviderService> getRegisteredProviders()
+ {
+ List<ProtocolProviderService> registeredProviders
+ = new LinkedList<ProtocolProviderService>();
+
+ for (ProtocolProviderFactory providerFactory
+ : UtilActivator.getProtocolProviderFactories().values())
+ {
+ for (AccountID accountID : providerFactory.getRegisteredAccounts())
+ {
+ ServiceReference<ProtocolProviderService> ref
+ = providerFactory.getProviderForAccount(accountID);
+
+ if (ref != null)
+ {
+ ProtocolProviderService protocolProvider
+ = UtilActivator.bundleContext.getService(ref);
+
+ registeredProviders.add(protocolProvider);
+ }
+ }
+ }
+ return registeredProviders;
+ }
+}
diff --git a/src/net/java/sip/communicator/util/account/LoginManager.java b/src/net/java/sip/communicator/util/account/LoginManager.java
index 1dffaf8..09b3092 100644
--- a/src/net/java/sip/communicator/util/account/LoginManager.java
+++ b/src/net/java/sip/communicator/util/account/LoginManager.java
@@ -1,4 +1,4 @@
-/*
+/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Copyright @ 2015 Atlassian Pty Ltd
@@ -15,577 +15,577 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package net.java.sip.communicator.util.account;
-
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.service.protocol.event.*;
-import net.java.sip.communicator.service.protocol.globalstatus.*;
-import net.java.sip.communicator.util.*;
-
-import org.osgi.framework.*;
-
-/**
- * The <tt>LoginManager</tt> manages the login operation. Here we obtain the
- * <tt>ProtocolProviderFactory</tt>, we make the account installation and we
- * handle all events related to the registration state.
- * <p>
- * The <tt>LoginManager</tt> is the one that opens one or more
- * <tt>LoginWindow</tt>s for each <tt>ProtocolProviderFactory</tt>. The
- * <tt>LoginWindow</tt> is where user could enter an identifier and password.
- * <p>
- * Note that the behavior of this class will be changed when the Configuration
- * Service is ready.
- *
- * @author Yana Stamcheva
- */
-public class LoginManager
- implements ServiceListener,
- RegistrationStateChangeListener,
- AccountManagerListener
-{
- private static final Logger logger = Logger.getLogger(LoginManager.class);
-
- private boolean manuallyDisconnected = false;
-
- private final LoginRenderer loginRenderer;
-
- /**
- * Creates an instance of the <tt>LoginManager</tt>, by specifying the main
- * application window.
- *
- * @param loginRenderer the main application window
- */
- public LoginManager(LoginRenderer loginRenderer)
- {
- this.loginRenderer = loginRenderer;
-
- UtilActivator.bundleContext.addServiceListener(this);
- }
-
- /**
- * Registers the given protocol provider.
- *
- * @param protocolProvider the ProtocolProviderService to register.
- */
- public void login(ProtocolProviderService protocolProvider)
- {
- loginRenderer.startConnectingUI(protocolProvider);
-
- new RegisterProvider(protocolProvider,
- loginRenderer.getSecurityAuthorityImpl(protocolProvider)).start();
- }
-
- /**
- * Unregisters the given protocol provider.
- *
- * @param protocolProvider the ProtocolProviderService to unregister
- */
- public static void logoff(ProtocolProviderService protocolProvider)
- {
- new UnregisterProvider(protocolProvider).start();
- }
-
- /**
- * Shows login window for each registered account.
- */
- public void runLogin()
- {
- // if someone is late registering catch it
- UtilActivator.getAccountManager().addListener(this);
-
- for (ProtocolProviderFactory providerFactory : UtilActivator
- .getProtocolProviderFactories().values())
- {
- addAccountsForProtocolProviderFactory(providerFactory);
- }
- }
-
- /**
- * Notifies that the loading of the stored accounts of a
- * specific <code>ProtocolProviderFactory</code> has finished.
- *
- * @param event the <code>AccountManagerEvent</code> describing the
- * <code>AccountManager</code> firing the notification and the
- * other details of the specific notification.
- */
- public void handleAccountManagerEvent(AccountManagerEvent event)
- {
- if(event.getType()
- == AccountManagerEvent.STORED_ACCOUNTS_LOADED)
- {
- addAccountsForProtocolProviderFactory(event.getFactory());
- }
- }
-
- /**
- * Handles stored accounts for a protocol provider factory and add them
- * to the UI and register them if needed.
- * @param providerFactory the factory to handle.
- */
- private void addAccountsForProtocolProviderFactory(
- ProtocolProviderFactory providerFactory)
- {
- for (AccountID accountID : providerFactory.getRegisteredAccounts())
- {
- ServiceReference<ProtocolProviderService> serRef
- = providerFactory.getProviderForAccount(accountID);
- ProtocolProviderService protocolProvider
- = UtilActivator.bundleContext.getService(serRef);
-
- handleProviderAdded(protocolProvider);
- }
- }
-
- /**
- * The method is called by a ProtocolProvider implementation whenever a
- * change in the registration state of the corresponding provider had
- * occurred.
- *
- * @param evt ProviderStatusChangeEvent the event describing the status
- * change.
- */
- public void registrationStateChanged(RegistrationStateChangeEvent evt)
- {
- RegistrationState newState = evt.getNewState();
- ProtocolProviderService protocolProvider = evt.getProvider();
- AccountID accountID = protocolProvider.getAccountID();
-
- if (logger.isTraceEnabled())
- logger.trace("Protocol provider: " + protocolProvider
- + " changed its state to: " + evt.getNewState().getStateName());
-
- if (newState.equals(RegistrationState.REGISTERED)
- || newState.equals(RegistrationState.UNREGISTERED)
- || newState.equals(RegistrationState.EXPIRED)
- || newState.equals(RegistrationState.AUTHENTICATION_FAILED)
- || newState.equals(RegistrationState.CONNECTION_FAILED)
- || newState.equals(RegistrationState.CHALLENGED_FOR_AUTHENTICATION)
- || newState.equals(RegistrationState.REGISTERED))
- {
- loginRenderer.stopConnectingUI(protocolProvider);
- }
-
- if (newState.equals(RegistrationState.REGISTERED))
- {
- loginRenderer.protocolProviderConnected(protocolProvider,
- System.currentTimeMillis());
- }
- else
- {
- String msgText;
- if (newState.equals(RegistrationState.AUTHENTICATION_FAILED))
- {
- switch (evt.getReasonCode())
- {
- case RegistrationStateChangeEvent
- .REASON_RECONNECTION_RATE_LIMIT_EXCEEDED:
-
- msgText = UtilActivator.getResources().getI18NString(
- "service.gui.RECONNECTION_LIMIT_EXCEEDED", new String[]
- { accountID.getUserID(), accountID.getService() });
-
- UtilActivator.getAlertUIService().showAlertDialog(
- UtilActivator.getResources()
- .getI18NString("service.gui.ERROR"),
- msgText);
- break;
-
- case RegistrationStateChangeEvent.REASON_NON_EXISTING_USER_ID:
- msgText = UtilActivator.getResources().getI18NString(
- "service.gui.NON_EXISTING_USER_ID",
- new String[]
- { protocolProvider.getProtocolDisplayName() });
-
- UtilActivator.getAlertUIService().showAlertDialog(
- UtilActivator.getResources()
- .getI18NString("service.gui.ERROR"),
- msgText);
- break;
- case RegistrationStateChangeEvent.REASON_TLS_REQUIRED:
- msgText = UtilActivator.getResources().getI18NString(
- "service.gui.NON_SECURE_CONNECTION",
- new String[]
- { accountID.getAccountAddress() });
-
- UtilActivator.getAlertUIService().showAlertDialog(
- UtilActivator.getResources()
- .getI18NString("service.gui.ERROR"),
- msgText);
- break;
- default:
- break;
- }
-
- if (logger.isTraceEnabled())
- logger.trace(evt.getReason());
- }
-// CONNECTION_FAILED events are now dispatched in reconnect plugin
-// else if (newState.equals(RegistrationState.CONNECTION_FAILED))
-// {
-// loginRenderer.protocolProviderConnectionFailed(
-// protocolProvider,
-// this);
-//
-// logger.trace(evt.getReason());
-// }
- else if (newState.equals(RegistrationState.EXPIRED))
- {
- msgText = UtilActivator.getResources().getI18NString(
- "service.gui.CONNECTION_EXPIRED_MSG",
- new String[]
- { protocolProvider.getProtocolDisplayName() });
-
- UtilActivator.getAlertUIService().showAlertDialog(
- UtilActivator.getResources()
- .getI18NString("service.gui.ERROR"),
- msgText);
-
- logger.error(evt.getReason());
- }
- else if (newState.equals(RegistrationState.UNREGISTERED))
- {
- if (!manuallyDisconnected)
- {
- if (evt.getReasonCode() == RegistrationStateChangeEvent
- .REASON_MULTIPLE_LOGINS)
- {
- msgText = UtilActivator.getResources().getI18NString(
- "service.gui.MULTIPLE_LOGINS",
- new String[]
- { accountID.getUserID(), accountID.getService() });
-
- UtilActivator.getAlertUIService().showAlertDialog(
- UtilActivator.getResources()
- .getI18NString("service.gui.ERROR"),
- msgText);
- }
- else if (evt.getReasonCode() == RegistrationStateChangeEvent
- .REASON_CLIENT_LIMIT_REACHED_FOR_IP)
- {
- msgText = UtilActivator.getResources().getI18NString(
- "service.gui.LIMIT_REACHED_FOR_IP", new String[]
- { protocolProvider.getProtocolDisplayName() });
-
- UtilActivator.getAlertUIService().showAlertDialog(
- UtilActivator.getResources()
- .getI18NString("service.gui.ERROR"),
- msgText);
- }
- else if (evt.getReasonCode() == RegistrationStateChangeEvent
- .REASON_USER_REQUEST)
- {
- // do nothing
- }
- else
- {
- msgText = UtilActivator.getResources().getI18NString(
- "service.gui.UNREGISTERED_MESSAGE", new String[]
- { accountID.getUserID(), accountID.getService() });
-
- UtilActivator.getAlertUIService().showAlertDialog(
- UtilActivator.getResources()
- .getI18NString("service.gui.ERROR"),
- msgText);
- }
- if (logger.isTraceEnabled())
- logger.trace(evt.getReason());
- }
- }
- }
- }
-
- /**
- * Implements the <tt>ServiceListener</tt> method. Verifies whether the
- * passed event concerns a <tt>ProtocolProviderService</tt> and adds the
- * corresponding UI controls.
- *
- * @param event The <tt>ServiceEvent</tt> object.
- */
- public void serviceChanged(ServiceEvent event)
- {
- ServiceReference<?> serviceRef = event.getServiceReference();
-
- // if the event is caused by a bundle being stopped, we don't want to
- // know
- if (serviceRef.getBundle().getState() == Bundle.STOPPING)
- return;
-
- Object service = UtilActivator.bundleContext.getService(serviceRef);
-
- // we don't care if the source service is not a protocol provider
- if (!(service instanceof ProtocolProviderService))
- return;
-
- switch (event.getType())
- {
- case ServiceEvent.REGISTERED:
- handleProviderAdded((ProtocolProviderService) service);
- break;
- case ServiceEvent.UNREGISTERING:
- handleProviderRemoved((ProtocolProviderService) service);
- break;
- }
- }
-
- /**
- * Adds all UI components (status selector box, etc) related to the given
- * protocol provider.
- *
- * @param protocolProvider the <tt>ProtocolProviderService</tt>
- */
- private void handleProviderAdded(ProtocolProviderService protocolProvider)
- {
- if (logger.isTraceEnabled())
- logger.trace("The following protocol provider was just added: "
- + protocolProvider.getAccountID().getAccountAddress());
-
- synchronized(loginRenderer)
- {
- if(!loginRenderer.containsProtocolProviderUI(protocolProvider))
- {
- protocolProvider.addRegistrationStateChangeListener(this);
- loginRenderer.addProtocolProviderUI(protocolProvider);
- }
- // we have already added this provider and scheduled
- // a login if needed
- // we've done our work, if it fails or something else
- // reconnect or other plugins will take care
- else
- return;
- }
-
- Object status = AccountStatusUtils
- .getProtocolProviderLastStatus(protocolProvider);
-
- if (status == null
- || status.equals(GlobalStatusEnum.ONLINE_STATUS)
- || ((status instanceof PresenceStatus) && (((PresenceStatus) status)
- .getStatus() >= PresenceStatus.ONLINE_THRESHOLD)))
- {
- login(protocolProvider);
- }
- }
-
- /**
- * Removes all UI components related to the given protocol provider.
- *
- * @param protocolProvider the <tt>ProtocolProviderService</tt>
- */
- private void handleProviderRemoved(ProtocolProviderService protocolProvider)
- {
- loginRenderer.removeProtocolProviderUI(protocolProvider);
- }
-
- /**
- * Returns <tt>true</tt> to indicate the jitsi has been manually
- * disconnected, <tt>false</tt> - otherwise.
- *
- * @return <tt>true</tt> to indicate the jitsi has been manually
- * disconnected, <tt>false</tt> - otherwise
- */
- public boolean isManuallyDisconnected()
- {
- return manuallyDisconnected;
- }
-
- /**
- * Sets the manually disconnected property.
- *
- * @param manuallyDisconnected <tt>true</tt> to indicate the jitsi has been
- * manually disconnected, <tt>false</tt> - otherwise
- */
- public void setManuallyDisconnected(boolean manuallyDisconnected)
- {
- this.manuallyDisconnected = manuallyDisconnected;
- }
-
- /**
- * Registers a protocol provider in a separate thread.
- */
- private class RegisterProvider
- extends Thread
- {
- private final ProtocolProviderService protocolProvider;
-
- private final SecurityAuthority secAuth;
-
- RegisterProvider( ProtocolProviderService protocolProvider,
- SecurityAuthority secAuth)
- {
- this.protocolProvider = protocolProvider;
- this.secAuth = secAuth;
-
- if(logger.isTraceEnabled())
- logger.trace("Registering provider: "
- + protocolProvider.getAccountID().getAccountAddress(),
- new Exception(
- "Just tracing, provider registering, not an error!"));
- }
-
- /**
- * Registers the contained protocol provider and process all possible
- * errors that may occur during the registration process.
- */
- @Override
- public void run()
- {
- try
- {
- protocolProvider.register(secAuth);
- }
- catch (OperationFailedException ex)
- {
- handleOperationFailedException(ex);
- }
- catch (Throwable ex)
- {
- logger.error("Failed to register protocol provider. ", ex);
-
- AccountID accountID = protocolProvider.getAccountID();
- UtilActivator.getAlertUIService().showAlertDialog(
- UtilActivator.getResources()
- .getI18NString("service.gui.ERROR"),
- UtilActivator.getResources()
- .getI18NString("service.gui.LOGIN_GENERAL_ERROR",
- new String[]
- { accountID.getUserID(),
- accountID.getProtocolName(),
- accountID.getService() }));
- }
- }
-
- private void handleOperationFailedException(OperationFailedException ex)
- {
- String errorMessage = "";
-
- switch (ex.getErrorCode())
- {
- case OperationFailedException.GENERAL_ERROR:
- {
- logger.error("Provider could not be registered"
- + " due to the following general error: ", ex);
-
- AccountID accountID = protocolProvider.getAccountID();
- errorMessage =
- UtilActivator.getResources().getI18NString(
- "service.gui.LOGIN_GENERAL_ERROR",
- new String[]
- { accountID.getUserID(),
- accountID.getProtocolName(),
- accountID.getService() });
-
- UtilActivator.getAlertUIService().showAlertDialog(
- UtilActivator.getResources()
- .getI18NString("service.gui.ERROR"), errorMessage, ex);
- }
- break;
- case OperationFailedException.INTERNAL_ERROR:
- {
- logger.error("Provider could not be registered"
- + " due to the following internal error: ", ex);
-
- AccountID accountID = protocolProvider.getAccountID();
- errorMessage =
- UtilActivator.getResources().getI18NString(
- "service.gui.LOGIN_INTERNAL_ERROR",
- new String[]
- { accountID.getUserID(), accountID.getService() });
-
- UtilActivator.getAlertUIService().showAlertDialog(
- UtilActivator.getResources().getI18NString(
- "service.gui.ERROR"), errorMessage, ex);
- }
- break;
- case OperationFailedException.NETWORK_FAILURE:
- {
- if (logger.isInfoEnabled())
- {
- logger.info("Provider could not be registered"
- + " due to a network failure: " + ex);
- }
-
- loginRenderer.protocolProviderConnectionFailed(
- protocolProvider,
- LoginManager.this);
- }
- break;
- case OperationFailedException.INVALID_ACCOUNT_PROPERTIES:
- {
- logger.error("Provider could not be registered"
- + " due to an invalid account property: ", ex);
-
- AccountID accountID = protocolProvider.getAccountID();
- errorMessage =
- UtilActivator.getResources().getI18NString(
- "service.gui.LOGIN_INVALID_PROPERTIES_ERROR",
- new String[]
- { accountID.getUserID(), accountID.getService() });
-
- UtilActivator.getAlertUIService().showAlertDialog(
- UtilActivator.getResources()
- .getI18NString("service.gui.ERROR"),
- errorMessage, ex);
- }
- break;
- default:
- logger.error("Provider could not be registered.", ex);
- }
- }
- }
-
- /**
- * Unregisters a protocol provider in a separate thread.
- */
- private static class UnregisterProvider
- extends Thread
- {
- ProtocolProviderService protocolProvider;
-
- UnregisterProvider(ProtocolProviderService protocolProvider)
- {
- this.protocolProvider = protocolProvider;
- }
-
- /**
- * Unregisters the contained protocol provider and process all possible
- * errors that may occur during the un-registration process.
- */
- @Override
- public void run()
- {
- try
- {
- protocolProvider.unregister(true);
- }
- catch (OperationFailedException ex)
- {
- int errorCode = ex.getErrorCode();
-
- if (errorCode == OperationFailedException.GENERAL_ERROR)
- {
- logger.error("Provider could not be unregistered"
- + " due to the following general error: " + ex);
- }
- else if (errorCode == OperationFailedException.INTERNAL_ERROR)
- {
- logger.error("Provider could not be unregistered"
- + " due to the following internal error: " + ex);
- }
- else if (errorCode == OperationFailedException.NETWORK_FAILURE)
- {
- logger.error("Provider could not be unregistered"
- + " due to a network failure: " + ex);
- }
-
- UtilActivator.getAlertUIService().showAlertDialog(
- UtilActivator.getResources()
- .getI18NString("service.gui.ERROR"),
- UtilActivator.getResources()
- .getI18NString("service.gui.LOGOFF_NOT_SUCCEEDED",
- new String[]
- { protocolProvider.getAccountID().getUserID(),
- protocolProvider.getAccountID().getService() }));
- }
- }
- }
-}
+package net.java.sip.communicator.util.account;
+
+import net.java.sip.communicator.service.protocol.*;
+import net.java.sip.communicator.service.protocol.event.*;
+import net.java.sip.communicator.service.protocol.globalstatus.*;
+import net.java.sip.communicator.util.*;
+
+import org.osgi.framework.*;
+
+/**
+ * The <tt>LoginManager</tt> manages the login operation. Here we obtain the
+ * <tt>ProtocolProviderFactory</tt>, we make the account installation and we
+ * handle all events related to the registration state.
+ * <p>
+ * The <tt>LoginManager</tt> is the one that opens one or more
+ * <tt>LoginWindow</tt>s for each <tt>ProtocolProviderFactory</tt>. The
+ * <tt>LoginWindow</tt> is where user could enter an identifier and password.
+ * <p>
+ * Note that the behavior of this class will be changed when the Configuration
+ * Service is ready.
+ *
+ * @author Yana Stamcheva
+ */
+public class LoginManager
+ implements ServiceListener,
+ RegistrationStateChangeListener,
+ AccountManagerListener
+{
+ private static final Logger logger = Logger.getLogger(LoginManager.class);
+
+ private boolean manuallyDisconnected = false;
+
+ private final LoginRenderer loginRenderer;
+
+ /**
+ * Creates an instance of the <tt>LoginManager</tt>, by specifying the main
+ * application window.
+ *
+ * @param loginRenderer the main application window
+ */
+ public LoginManager(LoginRenderer loginRenderer)
+ {
+ this.loginRenderer = loginRenderer;
+
+ UtilActivator.bundleContext.addServiceListener(this);
+ }
+
+ /**
+ * Registers the given protocol provider.
+ *
+ * @param protocolProvider the ProtocolProviderService to register.
+ */
+ public void login(ProtocolProviderService protocolProvider)
+ {
+ loginRenderer.startConnectingUI(protocolProvider);
+
+ new RegisterProvider(protocolProvider,
+ loginRenderer.getSecurityAuthorityImpl(protocolProvider)).start();
+ }
+
+ /**
+ * Unregisters the given protocol provider.
+ *
+ * @param protocolProvider the ProtocolProviderService to unregister
+ */
+ public static void logoff(ProtocolProviderService protocolProvider)
+ {
+ new UnregisterProvider(protocolProvider).start();
+ }
+
+ /**
+ * Shows login window for each registered account.
+ */
+ public void runLogin()
+ {
+ // if someone is late registering catch it
+ UtilActivator.getAccountManager().addListener(this);
+
+ for (ProtocolProviderFactory providerFactory : UtilActivator
+ .getProtocolProviderFactories().values())
+ {
+ addAccountsForProtocolProviderFactory(providerFactory);
+ }
+ }
+
+ /**
+ * Notifies that the loading of the stored accounts of a
+ * specific <code>ProtocolProviderFactory</code> has finished.
+ *
+ * @param event the <code>AccountManagerEvent</code> describing the
+ * <code>AccountManager</code> firing the notification and the
+ * other details of the specific notification.
+ */
+ public void handleAccountManagerEvent(AccountManagerEvent event)
+ {
+ if(event.getType()
+ == AccountManagerEvent.STORED_ACCOUNTS_LOADED)
+ {
+ addAccountsForProtocolProviderFactory(event.getFactory());
+ }
+ }
+
+ /**
+ * Handles stored accounts for a protocol provider factory and add them
+ * to the UI and register them if needed.
+ * @param providerFactory the factory to handle.
+ */
+ private void addAccountsForProtocolProviderFactory(
+ ProtocolProviderFactory providerFactory)
+ {
+ for (AccountID accountID : providerFactory.getRegisteredAccounts())
+ {
+ ServiceReference<ProtocolProviderService> serRef
+ = providerFactory.getProviderForAccount(accountID);
+ ProtocolProviderService protocolProvider
+ = UtilActivator.bundleContext.getService(serRef);
+
+ handleProviderAdded(protocolProvider);
+ }
+ }
+
+ /**
+ * The method is called by a ProtocolProvider implementation whenever a
+ * change in the registration state of the corresponding provider had
+ * occurred.
+ *
+ * @param evt ProviderStatusChangeEvent the event describing the status
+ * change.
+ */
+ public void registrationStateChanged(RegistrationStateChangeEvent evt)
+ {
+ RegistrationState newState = evt.getNewState();
+ ProtocolProviderService protocolProvider = evt.getProvider();
+ AccountID accountID = protocolProvider.getAccountID();
+
+ if (logger.isTraceEnabled())
+ logger.trace("Protocol provider: " + protocolProvider
+ + " changed its state to: " + evt.getNewState().getStateName());
+
+ if (newState.equals(RegistrationState.REGISTERED)
+ || newState.equals(RegistrationState.UNREGISTERED)
+ || newState.equals(RegistrationState.EXPIRED)
+ || newState.equals(RegistrationState.AUTHENTICATION_FAILED)
+ || newState.equals(RegistrationState.CONNECTION_FAILED)
+ || newState.equals(RegistrationState.CHALLENGED_FOR_AUTHENTICATION)
+ || newState.equals(RegistrationState.REGISTERED))
+ {
+ loginRenderer.stopConnectingUI(protocolProvider);
+ }
+
+ if (newState.equals(RegistrationState.REGISTERED))
+ {
+ loginRenderer.protocolProviderConnected(protocolProvider,
+ System.currentTimeMillis());
+ }
+ else
+ {
+ String msgText;
+ if (newState.equals(RegistrationState.AUTHENTICATION_FAILED))
+ {
+ switch (evt.getReasonCode())
+ {
+ case RegistrationStateChangeEvent
+ .REASON_RECONNECTION_RATE_LIMIT_EXCEEDED:
+
+ msgText = UtilActivator.getResources().getI18NString(
+ "service.gui.RECONNECTION_LIMIT_EXCEEDED", new String[]
+ { accountID.getUserID(), accountID.getService() });
+
+ UtilActivator.getAlertUIService().showAlertDialog(
+ UtilActivator.getResources()
+ .getI18NString("service.gui.ERROR"),
+ msgText);
+ break;
+
+ case RegistrationStateChangeEvent.REASON_NON_EXISTING_USER_ID:
+ msgText = UtilActivator.getResources().getI18NString(
+ "service.gui.NON_EXISTING_USER_ID",
+ new String[]
+ { protocolProvider.getProtocolDisplayName() });
+
+ UtilActivator.getAlertUIService().showAlertDialog(
+ UtilActivator.getResources()
+ .getI18NString("service.gui.ERROR"),
+ msgText);
+ break;
+ case RegistrationStateChangeEvent.REASON_TLS_REQUIRED:
+ msgText = UtilActivator.getResources().getI18NString(
+ "service.gui.NON_SECURE_CONNECTION",
+ new String[]
+ { accountID.getAccountAddress() });
+
+ UtilActivator.getAlertUIService().showAlertDialog(
+ UtilActivator.getResources()
+ .getI18NString("service.gui.ERROR"),
+ msgText);
+ break;
+ default:
+ break;
+ }
+
+ if (logger.isTraceEnabled())
+ logger.trace(evt.getReason());
+ }
+// CONNECTION_FAILED events are now dispatched in reconnect plugin
+// else if (newState.equals(RegistrationState.CONNECTION_FAILED))
+// {
+// loginRenderer.protocolProviderConnectionFailed(
+// protocolProvider,
+// this);
+//
+// logger.trace(evt.getReason());
+// }
+ else if (newState.equals(RegistrationState.EXPIRED))
+ {
+ msgText = UtilActivator.getResources().getI18NString(
+ "service.gui.CONNECTION_EXPIRED_MSG",
+ new String[]
+ { protocolProvider.getProtocolDisplayName() });
+
+ UtilActivator.getAlertUIService().showAlertDialog(
+ UtilActivator.getResources()
+ .getI18NString("service.gui.ERROR"),
+ msgText);
+
+ logger.error(evt.getReason());
+ }
+ else if (newState.equals(RegistrationState.UNREGISTERED))
+ {
+ if (!manuallyDisconnected)
+ {
+ if (evt.getReasonCode() == RegistrationStateChangeEvent
+ .REASON_MULTIPLE_LOGINS)
+ {
+ msgText = UtilActivator.getResources().getI18NString(
+ "service.gui.MULTIPLE_LOGINS",
+ new String[]
+ { accountID.getUserID(), accountID.getService() });
+
+ UtilActivator.getAlertUIService().showAlertDialog(
+ UtilActivator.getResources()
+ .getI18NString("service.gui.ERROR"),
+ msgText);
+ }
+ else if (evt.getReasonCode() == RegistrationStateChangeEvent
+ .REASON_CLIENT_LIMIT_REACHED_FOR_IP)
+ {
+ msgText = UtilActivator.getResources().getI18NString(
+ "service.gui.LIMIT_REACHED_FOR_IP", new String[]
+ { protocolProvider.getProtocolDisplayName() });
+
+ UtilActivator.getAlertUIService().showAlertDialog(
+ UtilActivator.getResources()
+ .getI18NString("service.gui.ERROR"),
+ msgText);
+ }
+ else if (evt.getReasonCode() == RegistrationStateChangeEvent
+ .REASON_USER_REQUEST)
+ {
+ // do nothing
+ }
+ else
+ {
+ msgText = UtilActivator.getResources().getI18NString(
+ "service.gui.UNREGISTERED_MESSAGE", new String[]
+ { accountID.getUserID(), accountID.getService() });
+
+ UtilActivator.getAlertUIService().showAlertDialog(
+ UtilActivator.getResources()
+ .getI18NString("service.gui.ERROR"),
+ msgText);
+ }
+ if (logger.isTraceEnabled())
+ logger.trace(evt.getReason());
+ }
+ }
+ }
+ }
+
+ /**
+ * Implements the <tt>ServiceListener</tt> method. Verifies whether the
+ * passed event concerns a <tt>ProtocolProviderService</tt> and adds the
+ * corresponding UI controls.
+ *
+ * @param event The <tt>ServiceEvent</tt> object.
+ */
+ public void serviceChanged(ServiceEvent event)
+ {
+ ServiceReference<?> serviceRef = event.getServiceReference();
+
+ // if the event is caused by a bundle being stopped, we don't want to
+ // know
+ if (serviceRef.getBundle().getState() == Bundle.STOPPING)
+ return;
+
+ Object service = UtilActivator.bundleContext.getService(serviceRef);
+
+ // we don't care if the source service is not a protocol provider
+ if (!(service instanceof ProtocolProviderService))
+ return;
+
+ switch (event.getType())
+ {
+ case ServiceEvent.REGISTERED:
+ handleProviderAdded((ProtocolProviderService) service);
+ break;
+ case ServiceEvent.UNREGISTERING:
+ handleProviderRemoved((ProtocolProviderService) service);
+ break;
+ }
+ }
+
+ /**
+ * Adds all UI components (status selector box, etc) related to the given
+ * protocol provider.
+ *
+ * @param protocolProvider the <tt>ProtocolProviderService</tt>
+ */
+ private void handleProviderAdded(ProtocolProviderService protocolProvider)
+ {
+ if (logger.isTraceEnabled())
+ logger.trace("The following protocol provider was just added: "
+ + protocolProvider.getAccountID().getAccountAddress());
+
+ synchronized(loginRenderer)
+ {
+ if(!loginRenderer.containsProtocolProviderUI(protocolProvider))
+ {
+ protocolProvider.addRegistrationStateChangeListener(this);
+ loginRenderer.addProtocolProviderUI(protocolProvider);
+ }
+ // we have already added this provider and scheduled
+ // a login if needed
+ // we've done our work, if it fails or something else
+ // reconnect or other plugins will take care
+ else
+ return;
+ }
+
+ Object status = AccountStatusUtils
+ .getProtocolProviderLastStatus(protocolProvider);
+
+ if (status == null
+ || status.equals(GlobalStatusEnum.ONLINE_STATUS)
+ || ((status instanceof PresenceStatus) && (((PresenceStatus) status)
+ .getStatus() >= PresenceStatus.ONLINE_THRESHOLD)))
+ {
+ login(protocolProvider);
+ }
+ }
+
+ /**
+ * Removes all UI components related to the given protocol provider.
+ *
+ * @param protocolProvider the <tt>ProtocolProviderService</tt>
+ */
+ private void handleProviderRemoved(ProtocolProviderService protocolProvider)
+ {
+ loginRenderer.removeProtocolProviderUI(protocolProvider);
+ }
+
+ /**
+ * Returns <tt>true</tt> to indicate the jitsi has been manually
+ * disconnected, <tt>false</tt> - otherwise.
+ *
+ * @return <tt>true</tt> to indicate the jitsi has been manually
+ * disconnected, <tt>false</tt> - otherwise
+ */
+ public boolean isManuallyDisconnected()
+ {
+ return manuallyDisconnected;
+ }
+
+ /**
+ * Sets the manually disconnected property.
+ *
+ * @param manuallyDisconnected <tt>true</tt> to indicate the jitsi has been
+ * manually disconnected, <tt>false</tt> - otherwise
+ */
+ public void setManuallyDisconnected(boolean manuallyDisconnected)
+ {
+ this.manuallyDisconnected = manuallyDisconnected;
+ }
+
+ /**
+ * Registers a protocol provider in a separate thread.
+ */
+ private class RegisterProvider
+ extends Thread
+ {
+ private final ProtocolProviderService protocolProvider;
+
+ private final SecurityAuthority secAuth;
+
+ RegisterProvider( ProtocolProviderService protocolProvider,
+ SecurityAuthority secAuth)
+ {
+ this.protocolProvider = protocolProvider;
+ this.secAuth = secAuth;
+
+ if(logger.isTraceEnabled())
+ logger.trace("Registering provider: "
+ + protocolProvider.getAccountID().getAccountAddress(),
+ new Exception(
+ "Just tracing, provider registering, not an error!"));
+ }
+
+ /**
+ * Registers the contained protocol provider and process all possible
+ * errors that may occur during the registration process.
+ */
+ @Override
+ public void run()
+ {
+ try
+ {
+ protocolProvider.register(secAuth);
+ }
+ catch (OperationFailedException ex)
+ {
+ handleOperationFailedException(ex);
+ }
+ catch (Throwable ex)
+ {
+ logger.error("Failed to register protocol provider. ", ex);
+
+ AccountID accountID = protocolProvider.getAccountID();
+ UtilActivator.getAlertUIService().showAlertDialog(
+ UtilActivator.getResources()
+ .getI18NString("service.gui.ERROR"),
+ UtilActivator.getResources()
+ .getI18NString("service.gui.LOGIN_GENERAL_ERROR",
+ new String[]
+ { accountID.getUserID(),
+ accountID.getProtocolName(),
+ accountID.getService() }));
+ }
+ }
+
+ private void handleOperationFailedException(OperationFailedException ex)
+ {
+ String errorMessage = "";
+
+ switch (ex.getErrorCode())
+ {
+ case OperationFailedException.GENERAL_ERROR:
+ {
+ logger.error("Provider could not be registered"
+ + " due to the following general error: ", ex);
+
+ AccountID accountID = protocolProvider.getAccountID();
+ errorMessage =
+ UtilActivator.getResources().getI18NString(
+ "service.gui.LOGIN_GENERAL_ERROR",
+ new String[]
+ { accountID.getUserID(),
+ accountID.getProtocolName(),
+ accountID.getService() });
+
+ UtilActivator.getAlertUIService().showAlertDialog(
+ UtilActivator.getResources()
+ .getI18NString("service.gui.ERROR"), errorMessage, ex);
+ }
+ break;
+ case OperationFailedException.INTERNAL_ERROR:
+ {
+ logger.error("Provider could not be registered"
+ + " due to the following internal error: ", ex);
+
+ AccountID accountID = protocolProvider.getAccountID();
+ errorMessage =
+ UtilActivator.getResources().getI18NString(
+ "service.gui.LOGIN_INTERNAL_ERROR",
+ new String[]
+ { accountID.getUserID(), accountID.getService() });
+
+ UtilActivator.getAlertUIService().showAlertDialog(
+ UtilActivator.getResources().getI18NString(
+ "service.gui.ERROR"), errorMessage, ex);
+ }
+ break;
+ case OperationFailedException.NETWORK_FAILURE:
+ {
+ if (logger.isInfoEnabled())
+ {
+ logger.info("Provider could not be registered"
+ + " due to a network failure: " + ex);
+ }
+
+ loginRenderer.protocolProviderConnectionFailed(
+ protocolProvider,
+ LoginManager.this);
+ }
+ break;
+ case OperationFailedException.INVALID_ACCOUNT_PROPERTIES:
+ {
+ logger.error("Provider could not be registered"
+ + " due to an invalid account property: ", ex);
+
+ AccountID accountID = protocolProvider.getAccountID();
+ errorMessage =
+ UtilActivator.getResources().getI18NString(
+ "service.gui.LOGIN_INVALID_PROPERTIES_ERROR",
+ new String[]
+ { accountID.getUserID(), accountID.getService() });
+
+ UtilActivator.getAlertUIService().showAlertDialog(
+ UtilActivator.getResources()
+ .getI18NString("service.gui.ERROR"),
+ errorMessage, ex);
+ }
+ break;
+ default:
+ logger.error("Provider could not be registered.", ex);
+ }
+ }
+ }
+
+ /**
+ * Unregisters a protocol provider in a separate thread.
+ */
+ private static class UnregisterProvider
+ extends Thread
+ {
+ ProtocolProviderService protocolProvider;
+
+ UnregisterProvider(ProtocolProviderService protocolProvider)
+ {
+ this.protocolProvider = protocolProvider;
+ }
+
+ /**
+ * Unregisters the contained protocol provider and process all possible
+ * errors that may occur during the un-registration process.
+ */
+ @Override
+ public void run()
+ {
+ try
+ {
+ protocolProvider.unregister(true);
+ }
+ catch (OperationFailedException ex)
+ {
+ int errorCode = ex.getErrorCode();
+
+ if (errorCode == OperationFailedException.GENERAL_ERROR)
+ {
+ logger.error("Provider could not be unregistered"
+ + " due to the following general error: " + ex);
+ }
+ else if (errorCode == OperationFailedException.INTERNAL_ERROR)
+ {
+ logger.error("Provider could not be unregistered"
+ + " due to the following internal error: " + ex);
+ }
+ else if (errorCode == OperationFailedException.NETWORK_FAILURE)
+ {
+ logger.error("Provider could not be unregistered"
+ + " due to a network failure: " + ex);
+ }
+
+ UtilActivator.getAlertUIService().showAlertDialog(
+ UtilActivator.getResources()
+ .getI18NString("service.gui.ERROR"),
+ UtilActivator.getResources()
+ .getI18NString("service.gui.LOGOFF_NOT_SUCCEEDED",
+ new String[]
+ { protocolProvider.getAccountID().getUserID(),
+ protocolProvider.getAccountID().getService() }));
+ }
+ }
+ }
+}
diff --git a/src/net/java/sip/communicator/util/account/LoginRenderer.java b/src/net/java/sip/communicator/util/account/LoginRenderer.java
index ee39940..e1ae850 100644
--- a/src/net/java/sip/communicator/util/account/LoginRenderer.java
+++ b/src/net/java/sip/communicator/util/account/LoginRenderer.java
@@ -1,4 +1,4 @@
-/*
+/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Copyright @ 2015 Atlassian Pty Ltd
@@ -15,94 +15,94 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package net.java.sip.communicator.util.account;
-
-import net.java.sip.communicator.service.protocol.*;
-
-/**
- * The <tt>LoginRenderer</tt> is the renderer of all login related operations.
- *
- * @author Yana Stamcheva
- */
-public interface LoginRenderer
-{
- /**
- * Adds the user interface related to the given protocol provider.
- *
- * @param protocolProvider the protocol provider for which we add the user
- * interface
- */
- public void addProtocolProviderUI(
- ProtocolProviderService protocolProvider);
-
- /**
- * Removes the user interface related to the given protocol provider.
- *
- * @param protocolProvider the protocol provider to remove
- */
- public void removeProtocolProviderUI(
- ProtocolProviderService protocolProvider);
-
- /**
- * Starts the connecting user interface for the given protocol provider.
- *
- * @param protocolProvider the protocol provider for which we add the
- * connecting user interface
- */
- public void startConnectingUI(ProtocolProviderService protocolProvider);
-
- /**
- * Stops the connecting user interface for the given protocol provider.
- *
- * @param protocolProvider the protocol provider for which we remove the
- * connecting user interface
- */
- public void stopConnectingUI(ProtocolProviderService protocolProvider);
-
- /**
- * Indicates that the given protocol provider is now connected.
- *
- * @param protocolProvider the <tt>ProtocolProviderService</tt> that is
- * connected
- * @param date the date on which the event occured
- */
- public void protocolProviderConnected(
- ProtocolProviderService protocolProvider,
- long date);
-
- /**
- * Indicates that a protocol provider connection has failed.
- *
- * @param protocolProvider the <tt>ProtocolProviderService</tt>, which
- * connection failed
- * @param loginManagerCallback the <tt>LoginManager</tt> implementation,
- * which is managing the process
- */
- public void protocolProviderConnectionFailed(
- ProtocolProviderService protocolProvider,
- LoginManager loginManagerCallback);
-
- /**
- * Returns the <tt>SecurityAuthority</tt> implementation related to this
- * login renderer.
- *
- * @param protocolProvider the specific <tt>ProtocolProviderService</tt>,
- * for which we're obtaining a security authority
- * @return the <tt>SecurityAuthority</tt> implementation related to this
- * login renderer
- */
- public SecurityAuthority getSecurityAuthorityImpl(
- ProtocolProviderService protocolProvider);
-
- /**
- * Indicates if the given <tt>protocolProvider</tt> related user interface
- * is already rendered.
- *
- * @param protocolProvider the <tt>ProtocolProviderService</tt>, which
- * related user interface we're looking for
- * @return <tt>true</tt> if the given <tt>protocolProvider</tt> related user
- * interface is already rendered
- */
- public boolean containsProtocolProviderUI(
- ProtocolProviderService protocolProvider);
+package net.java.sip.communicator.util.account;
+
+import net.java.sip.communicator.service.protocol.*;
+
+/**
+ * The <tt>LoginRenderer</tt> is the renderer of all login related operations.
+ *
+ * @author Yana Stamcheva
+ */
+public interface LoginRenderer
+{
+ /**
+ * Adds the user interface related to the given protocol provider.
+ *
+ * @param protocolProvider the protocol provider for which we add the user
+ * interface
+ */
+ public void addProtocolProviderUI(
+ ProtocolProviderService protocolProvider);
+
+ /**
+ * Removes the user interface related to the given protocol provider.
+ *
+ * @param protocolProvider the protocol provider to remove
+ */
+ public void removeProtocolProviderUI(
+ ProtocolProviderService protocolProvider);
+
+ /**
+ * Starts the connecting user interface for the given protocol provider.
+ *
+ * @param protocolProvider the protocol provider for which we add the
+ * connecting user interface
+ */
+ public void startConnectingUI(ProtocolProviderService protocolProvider);
+
+ /**
+ * Stops the connecting user interface for the given protocol provider.
+ *
+ * @param protocolProvider the protocol provider for which we remove the
+ * connecting user interface
+ */
+ public void stopConnectingUI(ProtocolProviderService protocolProvider);
+
+ /**
+ * Indicates that the given protocol provider is now connected.
+ *
+ * @param protocolProvider the <tt>ProtocolProviderService</tt> that is
+ * connected
+ * @param date the date on which the event occured
+ */
+ public void protocolProviderConnected(
+ ProtocolProviderService protocolProvider,
+ long date);
+
+ /**
+ * Indicates that a protocol provider connection has failed.
+ *
+ * @param protocolProvider the <tt>ProtocolProviderService</tt>, which
+ * connection failed
+ * @param loginManagerCallback the <tt>LoginManager</tt> implementation,
+ * which is managing the process
+ */
+ public void protocolProviderConnectionFailed(
+ ProtocolProviderService protocolProvider,
+ LoginManager loginManagerCallback);
+
+ /**
+ * Returns the <tt>SecurityAuthority</tt> implementation related to this
+ * login renderer.
+ *
+ * @param protocolProvider the specific <tt>ProtocolProviderService</tt>,
+ * for which we're obtaining a security authority
+ * @return the <tt>SecurityAuthority</tt> implementation related to this
+ * login renderer
+ */
+ public SecurityAuthority getSecurityAuthorityImpl(
+ ProtocolProviderService protocolProvider);
+
+ /**
+ * Indicates if the given <tt>protocolProvider</tt> related user interface
+ * is already rendered.
+ *
+ * @param protocolProvider the <tt>ProtocolProviderService</tt>, which
+ * related user interface we're looking for
+ * @return <tt>true</tt> if the given <tt>protocolProvider</tt> related user
+ * interface is already rendered
+ */
+ public boolean containsProtocolProviderUI(
+ ProtocolProviderService protocolProvider);
}
diff --git a/src/net/java/sip/communicator/util/launchutils/LaunchArgHandler.java b/src/net/java/sip/communicator/util/launchutils/LaunchArgHandler.java
index 90041fc..d5cbf14 100644
--- a/src/net/java/sip/communicator/util/launchutils/LaunchArgHandler.java
+++ b/src/net/java/sip/communicator/util/launchutils/LaunchArgHandler.java
@@ -299,6 +299,11 @@ public class LaunchArgHandler
// do nothing already handled by startup script/binary
continue;
}
+ else if (args[i].startsWith("--notray"))
+ {
+ System.setProperty("disable-tray", "true");
+ continue;
+ }
//if this is the last arg and it's not an option then it's probably
//an URI
else if ( i == args.length - 1
@@ -521,6 +526,7 @@ public class LaunchArgHandler
System.out.println(" -6, --ipv6 prefer IPv6 addresses where possible only");
System.out.println(" -4, --ipv4 forces use of IPv4 only");
System.out.println(" -v, --version display the current version and exit");
+ System.out.println(" -n, --notray disable the tray icon and show the GUI");
}
/**
diff --git a/src/net/java/sip/communicator/util/util.manifest.mf b/src/net/java/sip/communicator/util/util.manifest.mf
index 7de9af7..b50df6b 100644
--- a/src/net/java/sip/communicator/util/util.manifest.mf
+++ b/src/net/java/sip/communicator/util/util.manifest.mf
@@ -32,6 +32,7 @@ Import-Package: com.sun.awt,
net.java.sip.communicator.service.gui,
net.java.sip.communicator.service.gui.call,
net.java.sip.communicator.service.resources,
+ net.java.sip.communicator.service.systray,
net.java.sip.communicator.service.keybindings,
net.java.sip.communicator.service.msghistory,
net.java.sip.communicator.service.contactlist,
@@ -56,8 +57,7 @@ Import-Package: com.sun.awt,
sun.awt.shell,
sun.net.dns,
sun.net.util
-Export-Package: org.xbill.DNS,
- net.java.sip.communicator.util,
+Export-Package: net.java.sip.communicator.util,
net.java.sip.communicator.util.launchutils,
net.java.sip.communicator.util.skin,
net.java.sip.communicator.util.xml,