mirror of https://github.com/sipwise/jitsi.git
parent
577d850a0a
commit
be0540e2b7
@ -1,180 +1,180 @@
|
||||
/*
|
||||
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Copyright @ 2015 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.impl.protocol.sip.net;
|
||||
|
||||
import static net.java.sip.communicator.service.protocol.ProtocolProviderFactory.PROXY_AUTO_CONFIG;
|
||||
|
||||
import java.net.*;
|
||||
import java.util.*;
|
||||
|
||||
import net.java.sip.communicator.impl.protocol.sip.*;
|
||||
import net.java.sip.communicator.service.dns.*;
|
||||
|
||||
/**
|
||||
* Abstract class for the determining the address for the SIP proxy.
|
||||
*
|
||||
* @author Ingo Bauersachs
|
||||
*/
|
||||
public abstract class ProxyConnection
|
||||
{
|
||||
private List<String> returnedAddresses = new LinkedList<String>();
|
||||
|
||||
protected String transport;
|
||||
protected InetSocketAddress socketAddress;
|
||||
protected final SipAccountIDImpl account;
|
||||
|
||||
/**
|
||||
* Creates a new instance of this class.
|
||||
* @param account the account of this SIP protocol instance
|
||||
*/
|
||||
protected ProxyConnection(SipAccountIDImpl account)
|
||||
{
|
||||
this.account = account;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the address to use for the next connection attempt.
|
||||
* @return the address of the last lookup.
|
||||
*/
|
||||
public final InetSocketAddress getAddress()
|
||||
{
|
||||
return socketAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the transport to use for the next connection attempt.
|
||||
* @return the transport of the last lookup.
|
||||
*/
|
||||
public final String getTransport()
|
||||
{
|
||||
return transport;
|
||||
}
|
||||
|
||||
/**
|
||||
* In case we are using an outbound proxy this method returns
|
||||
* a suitable string for use with Router.
|
||||
* The method returns <tt>null</tt> otherwise.
|
||||
*
|
||||
* @return the string of our outbound proxy if we are using one and
|
||||
* <tt>null</tt> otherwise.
|
||||
*/
|
||||
public final String getOutboundProxyString()
|
||||
{
|
||||
if(socketAddress == null)
|
||||
return null;
|
||||
|
||||
InetAddress proxyAddress = socketAddress.getAddress();
|
||||
StringBuilder proxyStringBuffer
|
||||
= new StringBuilder(proxyAddress.getHostAddress());
|
||||
|
||||
if(proxyAddress instanceof Inet6Address)
|
||||
{
|
||||
proxyStringBuffer.insert(0, '[');
|
||||
proxyStringBuffer.append(']');
|
||||
}
|
||||
|
||||
proxyStringBuffer.append(':');
|
||||
proxyStringBuffer.append(socketAddress.getPort());
|
||||
proxyStringBuffer.append('/');
|
||||
proxyStringBuffer.append(transport);
|
||||
|
||||
return proxyStringBuffer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares an InetAddress against the active outbound proxy. The comparison
|
||||
* is by reference, not equals.
|
||||
*
|
||||
* @param addressToTest The addres to test.
|
||||
* @return True when the InetAddress is the same as the outbound proxy.
|
||||
*/
|
||||
public final boolean isSameInetAddress(InetAddress addressToTest)
|
||||
{
|
||||
// if the proxy is not yet initialized then this is not the provider
|
||||
// that caused this comparison
|
||||
if(socketAddress == null)
|
||||
return false;
|
||||
return addressToTest == socketAddress.getAddress();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the next address to use from DNS. Duplicate results are
|
||||
* suppressed.
|
||||
*
|
||||
* @return True if a new address is available through {@link #getAddress()},
|
||||
* false if the last address was reached. A new lookup from scratch
|
||||
* can be started by calling {@link #reset()}.
|
||||
* @throws DnssecException if there is a problem related to DNSSEC
|
||||
*/
|
||||
public final boolean getNextAddress() throws DnssecException
|
||||
{
|
||||
boolean result;
|
||||
String key = null;
|
||||
do
|
||||
{
|
||||
result = getNextAddressFromDns();
|
||||
if(result && socketAddress != null)
|
||||
{
|
||||
key = getOutboundProxyString();
|
||||
if(!returnedAddresses.contains(key))
|
||||
{
|
||||
returnedAddresses.add(key);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
while(result && returnedAddresses.contains(key));
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementations must use this method to get the next address, but do not
|
||||
* have to care about duplicate addresses.
|
||||
*
|
||||
* @return True when a further address was available.
|
||||
* @throws DnssecException when a DNSSEC validation failure occured.
|
||||
*/
|
||||
protected abstract boolean getNextAddressFromDns()
|
||||
throws DnssecException;
|
||||
|
||||
/**
|
||||
* Resets the lookup to it's initial state. Overriders methods have to call
|
||||
* this method through a super-call.
|
||||
*/
|
||||
public void reset()
|
||||
{
|
||||
returnedAddresses.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory method to create a proxy connection based on the account settings
|
||||
* of the protocol provider.
|
||||
*
|
||||
* @param pps the protocol provider that needs a SIP server connection.
|
||||
* @return An instance of a derived class.
|
||||
*/
|
||||
public static ProxyConnection create(ProtocolProviderServiceSipImpl pps)
|
||||
{
|
||||
if (pps.getAccountID().getAccountPropertyBoolean(PROXY_AUTO_CONFIG,
|
||||
true))
|
||||
return new AutoProxyConnection((SipAccountIDImpl) pps.getAccountID(),
|
||||
pps.getDefaultTransport());
|
||||
else
|
||||
return new ManualProxyConnection((SipAccountIDImpl) pps.getAccountID());
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Copyright @ 2015 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.impl.protocol.sip.net;
|
||||
|
||||
import static net.java.sip.communicator.service.protocol.ProtocolProviderFactory.PROXY_AUTO_CONFIG;
|
||||
|
||||
import java.net.*;
|
||||
import java.util.*;
|
||||
|
||||
import net.java.sip.communicator.impl.protocol.sip.*;
|
||||
import net.java.sip.communicator.service.dns.*;
|
||||
|
||||
/**
|
||||
* Abstract class for the determining the address for the SIP proxy.
|
||||
*
|
||||
* @author Ingo Bauersachs
|
||||
*/
|
||||
public abstract class ProxyConnection
|
||||
{
|
||||
private List<String> returnedAddresses = new LinkedList<String>();
|
||||
|
||||
protected String transport;
|
||||
protected InetSocketAddress socketAddress;
|
||||
protected final SipAccountIDImpl account;
|
||||
|
||||
/**
|
||||
* Creates a new instance of this class.
|
||||
* @param account the account of this SIP protocol instance
|
||||
*/
|
||||
protected ProxyConnection(SipAccountIDImpl account)
|
||||
{
|
||||
this.account = account;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the address to use for the next connection attempt.
|
||||
* @return the address of the last lookup.
|
||||
*/
|
||||
public final InetSocketAddress getAddress()
|
||||
{
|
||||
return socketAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the transport to use for the next connection attempt.
|
||||
* @return the transport of the last lookup.
|
||||
*/
|
||||
public final String getTransport()
|
||||
{
|
||||
return transport;
|
||||
}
|
||||
|
||||
/**
|
||||
* In case we are using an outbound proxy this method returns
|
||||
* a suitable string for use with Router.
|
||||
* The method returns <tt>null</tt> otherwise.
|
||||
*
|
||||
* @return the string of our outbound proxy if we are using one and
|
||||
* <tt>null</tt> otherwise.
|
||||
*/
|
||||
public final String getOutboundProxyString()
|
||||
{
|
||||
if(socketAddress == null)
|
||||
return null;
|
||||
|
||||
InetAddress proxyAddress = socketAddress.getAddress();
|
||||
StringBuilder proxyStringBuffer
|
||||
= new StringBuilder(proxyAddress.getHostAddress());
|
||||
|
||||
if(proxyAddress instanceof Inet6Address)
|
||||
{
|
||||
proxyStringBuffer.insert(0, '[');
|
||||
proxyStringBuffer.append(']');
|
||||
}
|
||||
|
||||
proxyStringBuffer.append(':');
|
||||
proxyStringBuffer.append(socketAddress.getPort());
|
||||
proxyStringBuffer.append('/');
|
||||
proxyStringBuffer.append(transport);
|
||||
|
||||
return proxyStringBuffer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares an InetAddress against the active outbound proxy. The comparison
|
||||
* is by reference, not equals.
|
||||
*
|
||||
* @param addressToTest The addres to test.
|
||||
* @return True when the InetAddress is the same as the outbound proxy.
|
||||
*/
|
||||
public final boolean isSameInetAddress(InetAddress addressToTest)
|
||||
{
|
||||
// if the proxy is not yet initialized then this is not the provider
|
||||
// that caused this comparison
|
||||
if(socketAddress == null)
|
||||
return false;
|
||||
return addressToTest == socketAddress.getAddress();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the next address to use from DNS. Duplicate results are
|
||||
* suppressed.
|
||||
*
|
||||
* @return True if a new address is available through {@link #getAddress()},
|
||||
* false if the last address was reached. A new lookup from scratch
|
||||
* can be started by calling {@link #reset()}.
|
||||
* @throws DnssecException if there is a problem related to DNSSEC
|
||||
*/
|
||||
public final boolean getNextAddress() throws DnssecException
|
||||
{
|
||||
boolean result;
|
||||
String key = null;
|
||||
do
|
||||
{
|
||||
result = getNextAddressFromDns();
|
||||
if(result && socketAddress != null)
|
||||
{
|
||||
key = getOutboundProxyString();
|
||||
if(!returnedAddresses.contains(key))
|
||||
{
|
||||
returnedAddresses.add(key);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
while(result && returnedAddresses.contains(key));
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementations must use this method to get the next address, but do not
|
||||
* have to care about duplicate addresses.
|
||||
*
|
||||
* @return True when a further address was available.
|
||||
* @throws DnssecException when a DNSSEC validation failure occured.
|
||||
*/
|
||||
protected abstract boolean getNextAddressFromDns()
|
||||
throws DnssecException;
|
||||
|
||||
/**
|
||||
* Resets the lookup to it's initial state. Overriders methods have to call
|
||||
* this method through a super-call.
|
||||
*/
|
||||
public void reset()
|
||||
{
|
||||
returnedAddresses.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory method to create a proxy connection based on the account settings
|
||||
* of the protocol provider.
|
||||
*
|
||||
* @param pps the protocol provider that needs a SIP server connection.
|
||||
* @return An instance of a derived class.
|
||||
*/
|
||||
public static ProxyConnection create(ProtocolProviderServiceSipImpl pps)
|
||||
{
|
||||
if (pps.getAccountID().getAccountPropertyBoolean(PROXY_AUTO_CONFIG,
|
||||
true))
|
||||
return new AutoProxyConnection((SipAccountIDImpl) pps.getAccountID(),
|
||||
pps.getDefaultTransport());
|
||||
else
|
||||
return new ManualProxyConnection((SipAccountIDImpl) pps.getAccountID());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,251 +1,251 @@
|
||||
/*
|
||||
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Copyright @ 2015 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.impl.sysactivity;
|
||||
|
||||
import net.java.sip.communicator.util.Logger;
|
||||
import org.jitsi.util.*;
|
||||
|
||||
/**
|
||||
* @author Damian Minkov
|
||||
*/
|
||||
public class SystemActivityNotifications
|
||||
{
|
||||
/**
|
||||
* The <tt>Logger</tt> used by the <tt>SystemActivityNotifications</tt>
|
||||
* class to log debugging information.
|
||||
*/
|
||||
private static final Logger logger
|
||||
= Logger.getLogger(SystemActivityNotifications.class);
|
||||
|
||||
/**
|
||||
* Computer display has stand by.
|
||||
*/
|
||||
public static final int NOTIFY_DISPLAY_SLEEP = 2;
|
||||
|
||||
/**
|
||||
* Computer display wakes up after stand by.
|
||||
*/
|
||||
public static final int NOTIFY_DISPLAY_WAKE = 3;
|
||||
|
||||
/**
|
||||
* A change in dns configuration has occurred.
|
||||
*/
|
||||
public static final int NOTIFY_DNS_CHANGE = 10;
|
||||
|
||||
/**
|
||||
* All processes have been informed about ending session, now notify for
|
||||
* the actual end session.
|
||||
*/
|
||||
public static final int NOTIFY_ENDSESSION = 12;
|
||||
|
||||
/**
|
||||
* A change in network configuration has occurred.
|
||||
*/
|
||||
public static final int NOTIFY_NETWORK_CHANGE = 9;
|
||||
|
||||
/**
|
||||
* Notifies for start of process of ending desktop session,
|
||||
* logoff or shutdown.
|
||||
*/
|
||||
public static final int NOTIFY_QUERY_ENDSESSION = 11;
|
||||
|
||||
/**
|
||||
* Screen has been locked.
|
||||
*/
|
||||
public static final int NOTIFY_SCREEN_LOCKED = 7;
|
||||
|
||||
/**
|
||||
* Screen has been unlocked.
|
||||
*/
|
||||
public static final int NOTIFY_SCREEN_UNLOCKED = 8;
|
||||
|
||||
/**
|
||||
* Screensaver has been started.
|
||||
*/
|
||||
public static final int NOTIFY_SCREENSAVER_START = 4;
|
||||
|
||||
/**
|
||||
* Screensaver has been stopped.
|
||||
*/
|
||||
public static final int NOTIFY_SCREENSAVER_STOP = 6;
|
||||
|
||||
/**
|
||||
* Screensaver will stop.
|
||||
*/
|
||||
public static final int NOTIFY_SCREENSAVER_WILL_STOP = 5;
|
||||
|
||||
/**
|
||||
* Notify that computers is going to sleep.
|
||||
*/
|
||||
public static final int NOTIFY_SLEEP = 0;
|
||||
|
||||
/**
|
||||
* Notify that computer is wakeing up after stand by.
|
||||
*/
|
||||
public static final int NOTIFY_WAKE = 1;
|
||||
|
||||
/**
|
||||
* The native instance.
|
||||
*/
|
||||
private static long ptr;
|
||||
|
||||
/**
|
||||
* Init native library.
|
||||
*/
|
||||
static
|
||||
{
|
||||
try
|
||||
{
|
||||
// Don't load native library on Android to prevent the exception
|
||||
if(!org.jitsi.util.OSUtils.IS_ANDROID)
|
||||
{
|
||||
JNIUtils.loadLibrary("sysactivitynotifications",
|
||||
SystemActivityNotifications.class.getClassLoader());
|
||||
|
||||
ptr = allocAndInit();
|
||||
if (ptr == -1)
|
||||
ptr = 0;
|
||||
}
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
if (t instanceof ThreadDeath)
|
||||
throw (ThreadDeath) t;
|
||||
else
|
||||
logger.warn("Failed to initialize native counterpart", t);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocate native resources and gets a pointer.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private static native long allocAndInit();
|
||||
|
||||
/**
|
||||
* Returns the when was last input in milliseconds. The time when there was
|
||||
* any activity on the computer.
|
||||
*
|
||||
* @return the last input in milliseconds
|
||||
*/
|
||||
public static native long getLastInput();
|
||||
|
||||
/**
|
||||
* Whether native library is loaded.
|
||||
*
|
||||
* @return whether native library is loaded.
|
||||
*/
|
||||
public static boolean isLoaded()
|
||||
{
|
||||
return (ptr != 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Release native resources.
|
||||
*
|
||||
* @param ptr
|
||||
*/
|
||||
private static native void release(long ptr);
|
||||
|
||||
/**
|
||||
* Sets notifier delegate.
|
||||
*
|
||||
* @param ptr
|
||||
* @param delegate
|
||||
*/
|
||||
public static native void setDelegate(
|
||||
long ptr,
|
||||
NotificationsDelegate delegate);
|
||||
|
||||
/**
|
||||
* Sets delegate.
|
||||
*
|
||||
* @param delegate
|
||||
*/
|
||||
public static void setDelegate(NotificationsDelegate delegate)
|
||||
{
|
||||
if (ptr != 0)
|
||||
setDelegate(ptr, delegate);
|
||||
}
|
||||
|
||||
/**
|
||||
* Start.
|
||||
*/
|
||||
public static void start()
|
||||
{
|
||||
if (ptr != 0)
|
||||
start(ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Start processing.
|
||||
*
|
||||
* @param ptr
|
||||
*/
|
||||
private static native void start(long ptr);
|
||||
|
||||
/**
|
||||
* Stop.
|
||||
*/
|
||||
public static void stop()
|
||||
{
|
||||
if (ptr != 0)
|
||||
{
|
||||
stop(ptr);
|
||||
release(ptr);
|
||||
ptr = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop processing.
|
||||
*
|
||||
* @param ptr
|
||||
*/
|
||||
private static native void stop(long ptr);
|
||||
|
||||
/**
|
||||
* Delegate class to be notified about changes.
|
||||
*/
|
||||
public interface NotificationsDelegate
|
||||
{
|
||||
/**
|
||||
* Callback method when receiving notifications.
|
||||
*
|
||||
* @param type
|
||||
*/
|
||||
public void notify(int type);
|
||||
|
||||
/**
|
||||
* Callback method when receiving special network notifications.
|
||||
*
|
||||
* @param family family of network change (ipv6, ipv4)
|
||||
* @param luidIndex unique index of interface
|
||||
* @param name name of the interface
|
||||
* @param type of the interface
|
||||
* @param connected whether interface is connected or not.
|
||||
*/
|
||||
public void notifyNetworkChange(
|
||||
int family,
|
||||
long luidIndex,
|
||||
String name,
|
||||
long type,
|
||||
boolean connected);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Copyright @ 2015 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.impl.sysactivity;
|
||||
|
||||
import net.java.sip.communicator.util.Logger;
|
||||
import org.jitsi.util.*;
|
||||
|
||||
/**
|
||||
* @author Damian Minkov
|
||||
*/
|
||||
public class SystemActivityNotifications
|
||||
{
|
||||
/**
|
||||
* The <tt>Logger</tt> used by the <tt>SystemActivityNotifications</tt>
|
||||
* class to log debugging information.
|
||||
*/
|
||||
private static final Logger logger
|
||||
= Logger.getLogger(SystemActivityNotifications.class);
|
||||
|
||||
/**
|
||||
* Computer display has stand by.
|
||||
*/
|
||||
public static final int NOTIFY_DISPLAY_SLEEP = 2;
|
||||
|
||||
/**
|
||||
* Computer display wakes up after stand by.
|
||||
*/
|
||||
public static final int NOTIFY_DISPLAY_WAKE = 3;
|
||||
|
||||
/**
|
||||
* A change in dns configuration has occurred.
|
||||
*/
|
||||
public static final int NOTIFY_DNS_CHANGE = 10;
|
||||
|
||||
/**
|
||||
* All processes have been informed about ending session, now notify for
|
||||
* the actual end session.
|
||||
*/
|
||||
public static final int NOTIFY_ENDSESSION = 12;
|
||||
|
||||
/**
|
||||
* A change in network configuration has occurred.
|
||||
*/
|
||||
public static final int NOTIFY_NETWORK_CHANGE = 9;
|
||||
|
||||
/**
|
||||
* Notifies for start of process of ending desktop session,
|
||||
* logoff or shutdown.
|
||||
*/
|
||||
public static final int NOTIFY_QUERY_ENDSESSION = 11;
|
||||
|
||||
/**
|
||||
* Screen has been locked.
|
||||
*/
|
||||
public static final int NOTIFY_SCREEN_LOCKED = 7;
|
||||
|
||||
/**
|
||||
* Screen has been unlocked.
|
||||
*/
|
||||
public static final int NOTIFY_SCREEN_UNLOCKED = 8;
|
||||
|
||||
/**
|
||||
* Screensaver has been started.
|
||||
*/
|
||||
public static final int NOTIFY_SCREENSAVER_START = 4;
|
||||
|
||||
/**
|
||||
* Screensaver has been stopped.
|
||||
*/
|
||||
public static final int NOTIFY_SCREENSAVER_STOP = 6;
|
||||
|
||||
/**
|
||||
* Screensaver will stop.
|
||||
*/
|
||||
public static final int NOTIFY_SCREENSAVER_WILL_STOP = 5;
|
||||
|
||||
/**
|
||||
* Notify that computers is going to sleep.
|
||||
*/
|
||||
public static final int NOTIFY_SLEEP = 0;
|
||||
|
||||
/**
|
||||
* Notify that computer is wakeing up after stand by.
|
||||
*/
|
||||
public static final int NOTIFY_WAKE = 1;
|
||||
|
||||
/**
|
||||
* The native instance.
|
||||
*/
|
||||
private static long ptr;
|
||||
|
||||
/**
|
||||
* Init native library.
|
||||
*/
|
||||
static
|
||||
{
|
||||
try
|
||||
{
|
||||
// Don't load native library on Android to prevent the exception
|
||||
if(!org.jitsi.util.OSUtils.IS_ANDROID)
|
||||
{
|
||||
JNIUtils.loadLibrary("sysactivitynotifications",
|
||||
SystemActivityNotifications.class.getClassLoader());
|
||||
|
||||
ptr = allocAndInit();
|
||||
if (ptr == -1)
|
||||
ptr = 0;
|
||||
}
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
if (t instanceof ThreadDeath)
|
||||
throw (ThreadDeath) t;
|
||||
else
|
||||
logger.warn("Failed to initialize native counterpart", t);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocate native resources and gets a pointer.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private static native long allocAndInit();
|
||||
|
||||
/**
|
||||
* Returns the when was last input in milliseconds. The time when there was
|
||||
* any activity on the computer.
|
||||
*
|
||||
* @return the last input in milliseconds
|
||||
*/
|
||||
public static native long getLastInput();
|
||||
|
||||
/**
|
||||
* Whether native library is loaded.
|
||||
*
|
||||
* @return whether native library is loaded.
|
||||
*/
|
||||
public static boolean isLoaded()
|
||||
{
|
||||
return (ptr != 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Release native resources.
|
||||
*
|
||||
* @param ptr
|
||||
*/
|
||||
private static native void release(long ptr);
|
||||
|
||||
/**
|
||||
* Sets notifier delegate.
|
||||
*
|
||||
* @param ptr
|
||||
* @param delegate
|
||||
*/
|
||||
public static native void setDelegate(
|
||||
long ptr,
|
||||
NotificationsDelegate delegate);
|
||||
|
||||
/**
|
||||
* Sets delegate.
|
||||
*
|
||||
* @param delegate
|
||||
*/
|
||||
public static void setDelegate(NotificationsDelegate delegate)
|
||||
{
|
||||
if (ptr != 0)
|
||||
setDelegate(ptr, delegate);
|
||||
}
|
||||
|
||||
/**
|
||||
* Start.
|
||||
*/
|
||||
public static void start()
|
||||
{
|
||||
if (ptr != 0)
|
||||
start(ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Start processing.
|
||||
*
|
||||
* @param ptr
|
||||
*/
|
||||
private static native void start(long ptr);
|
||||
|
||||
/**
|
||||
* Stop.
|
||||
*/
|
||||
public static void stop()
|
||||
{
|
||||
if (ptr != 0)
|
||||
{
|
||||
stop(ptr);
|
||||
release(ptr);
|
||||
ptr = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop processing.
|
||||
*
|
||||
* @param ptr
|
||||
*/
|
||||
private static native void stop(long ptr);
|
||||
|
||||
/**
|
||||
* Delegate class to be notified about changes.
|
||||
*/
|
||||
public interface NotificationsDelegate
|
||||
{
|
||||
/**
|
||||
* Callback method when receiving notifications.
|
||||
*
|
||||
* @param type
|
||||
*/
|
||||
public void notify(int type);
|
||||
|
||||
/**
|
||||
* Callback method when receiving special network notifications.
|
||||
*
|
||||
* @param family family of network change (ipv6, ipv4)
|
||||
* @param luidIndex unique index of interface
|
||||
* @param name name of the interface
|
||||
* @param type of the interface
|
||||
* @param connected whether interface is connected or not.
|
||||
*/
|
||||
public void notifyNetworkChange(
|
||||
int family,
|
||||
long luidIndex,
|
||||
String name,
|
||||
long type,
|
||||
boolean connected);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,208 +1,208 @@
|
||||
/*
|
||||
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Copyright @ 2015 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.plugin.contactinfo;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import net.java.sip.communicator.service.browserlauncher.*;
|
||||
import net.java.sip.communicator.service.contactlist.*;
|
||||
import net.java.sip.communicator.service.gui.*;
|
||||
import net.java.sip.communicator.util.*;
|
||||
|
||||
import org.jitsi.service.configuration.*;
|
||||
import org.osgi.framework.*;
|
||||
|
||||
/**
|
||||
* The Activator of the Contact Info bundle.
|
||||
*
|
||||
* @author Adam Goldstein
|
||||
* @author Yana Stamcheva
|
||||
*/
|
||||
public class ContactInfoActivator implements BundleActivator
|
||||
{
|
||||
private Logger logger = Logger.getLogger(ContactInfoActivator.class);
|
||||
|
||||
/**
|
||||
* Indicates if the contact info button is enabled in the chat window.
|
||||
*/
|
||||
private static final String ENABLED_IN_CHAT_WINDOW_PROP
|
||||
= "net.java.sip.communicator.plugin.contactinfo." +
|
||||
"ENABLED_IN_CHAT_WINDOW_PROP";
|
||||
|
||||
/**
|
||||
* Indicates if the contact info button is enabled in the call window.
|
||||
*/
|
||||
private static final String ENABLED_IN_CALL_WINDOW_PROP
|
||||
= "net.java.sip.communicator.plugin.contactinfo." +
|
||||
"ENABLED_IN_CALL_WINDOW_PROP";
|
||||
|
||||
private static BrowserLauncherService browserLauncherService;
|
||||
|
||||
/**
|
||||
* The image loader service implementation.
|
||||
*/
|
||||
private static ImageLoaderService<?> imageLoaderService = null;
|
||||
|
||||
/**
|
||||
* The contact list service implementation.
|
||||
*/
|
||||
private static MetaContactListService metaCListService;
|
||||
|
||||
static BundleContext bundleContext;
|
||||
|
||||
/**
|
||||
* Starts this bundle.
|
||||
*/
|
||||
public void start(BundleContext bc) throws Exception
|
||||
{
|
||||
bundleContext = bc;
|
||||
|
||||
Hashtable<String, String> containerFilter
|
||||
= new Hashtable<String, String>();
|
||||
containerFilter.put(
|
||||
Container.CONTAINER_ID,
|
||||
Container.CONTAINER_CONTACT_RIGHT_BUTTON_MENU.getID());
|
||||
|
||||
bundleContext.registerService(
|
||||
PluginComponentFactory.class.getName(),
|
||||
new ContactInfoPluginComponentFactory(
|
||||
Container.CONTAINER_CONTACT_RIGHT_BUTTON_MENU),
|
||||
containerFilter);
|
||||
|
||||
if(getConfigService().getBoolean(ENABLED_IN_CHAT_WINDOW_PROP, false))
|
||||
{
|
||||
containerFilter = new Hashtable<String, String>();
|
||||
containerFilter.put(
|
||||
Container.CONTAINER_ID,
|
||||
Container.CONTAINER_CHAT_TOOL_BAR.getID());
|
||||
|
||||
bundleContext.registerService(
|
||||
PluginComponentFactory.class.getName(),
|
||||
new ContactInfoPluginComponentFactory(
|
||||
Container.CONTAINER_CHAT_TOOL_BAR),
|
||||
containerFilter);
|
||||
}
|
||||
|
||||
if(getConfigService().getBoolean(ENABLED_IN_CALL_WINDOW_PROP, false))
|
||||
{
|
||||
containerFilter = new Hashtable<String, String>();
|
||||
containerFilter.put(
|
||||
Container.CONTAINER_ID,
|
||||
Container.CONTAINER_CALL_DIALOG.getID());
|
||||
|
||||
bundleContext.registerService(
|
||||
PluginComponentFactory.class.getName(),
|
||||
new ContactInfoPluginComponentFactory(
|
||||
Container.CONTAINER_CALL_DIALOG),
|
||||
containerFilter);
|
||||
}
|
||||
|
||||
if (logger.isInfoEnabled())
|
||||
logger.info("CONTACT INFO... [REGISTERED]");
|
||||
}
|
||||
|
||||
public void stop(BundleContext bc) throws Exception
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the <tt>BrowserLauncherService</tt> obtained from the bundle
|
||||
* context.
|
||||
* @return the <tt>BrowserLauncherService</tt> obtained from the bundle
|
||||
* context
|
||||
*/
|
||||
public static BrowserLauncherService getBrowserLauncher()
|
||||
{
|
||||
if (browserLauncherService == null)
|
||||
{
|
||||
ServiceReference serviceReference = bundleContext
|
||||
.getServiceReference(BrowserLauncherService.class.getName());
|
||||
|
||||
browserLauncherService = (BrowserLauncherService) bundleContext
|
||||
.getService(serviceReference);
|
||||
}
|
||||
|
||||
return browserLauncherService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the imageLoaderService instance, if missing query osgi for it.
|
||||
* @return the imageLoaderService.
|
||||
*/
|
||||
public static ImageLoaderService<?> getImageLoaderService()
|
||||
{
|
||||
if(imageLoaderService == null)
|
||||
{
|
||||
imageLoaderService
|
||||
= ServiceUtils.getService(
|
||||
bundleContext,
|
||||
ImageLoaderService.class);
|
||||
}
|
||||
|
||||
return imageLoaderService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the <tt>MetaContactListService</tt> obtained from the bundle
|
||||
* context.
|
||||
* @return the <tt>MetaContactListService</tt> obtained from the bundle
|
||||
* context
|
||||
*/
|
||||
public static MetaContactListService getContactListService()
|
||||
{
|
||||
if (metaCListService == null)
|
||||
{
|
||||
metaCListService
|
||||
= ServiceUtils.getService(
|
||||
bundleContext,
|
||||
MetaContactListService.class);
|
||||
}
|
||||
return metaCListService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a reference to a ConfigurationService implementation currently
|
||||
* registered in the bundle context or null if no such implementation was
|
||||
* found.
|
||||
*
|
||||
* @return a currently valid implementation of the ConfigurationService.
|
||||
*/
|
||||
public static ConfigurationService getConfigService()
|
||||
{
|
||||
return ServiceUtils.getService(bundleContext,
|
||||
ConfigurationService.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Contact info create factory.
|
||||
*/
|
||||
private class ContactInfoPluginComponentFactory
|
||||
extends PluginComponentFactory
|
||||
{
|
||||
ContactInfoPluginComponentFactory(Container c)
|
||||
{
|
||||
super(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PluginComponent getPluginInstance()
|
||||
{
|
||||
return new ContactInfoMenuItem(getContainer(), this);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Copyright @ 2015 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.plugin.contactinfo;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import net.java.sip.communicator.service.browserlauncher.*;
|
||||
import net.java.sip.communicator.service.contactlist.*;
|
||||
import net.java.sip.communicator.service.gui.*;
|
||||
import net.java.sip.communicator.util.*;
|
||||
|
||||
import org.jitsi.service.configuration.*;
|
||||
import org.osgi.framework.*;
|
||||
|
||||
/**
|
||||
* The Activator of the Contact Info bundle.
|
||||
*
|
||||
* @author Adam Goldstein
|
||||
* @author Yana Stamcheva
|
||||
*/
|
||||
public class ContactInfoActivator implements BundleActivator
|
||||
{
|
||||
private Logger logger = Logger.getLogger(ContactInfoActivator.class);
|
||||
|
||||
/**
|
||||
* Indicates if the contact info button is enabled in the chat window.
|
||||
*/
|
||||
private static final String ENABLED_IN_CHAT_WINDOW_PROP
|
||||
= "net.java.sip.communicator.plugin.contactinfo." +
|
||||
"ENABLED_IN_CHAT_WINDOW_PROP";
|
||||
|
||||
/**
|
||||
* Indicates if the contact info button is enabled in the call window.
|
||||
*/
|
||||
private static final String ENABLED_IN_CALL_WINDOW_PROP
|
||||
= "net.java.sip.communicator.plugin.contactinfo." +
|
||||
"ENABLED_IN_CALL_WINDOW_PROP";
|
||||
|
||||
private static BrowserLauncherService browserLauncherService;
|
||||
|
||||
/**
|
||||
* The image loader service implementation.
|
||||
*/
|
||||
private static ImageLoaderService<?> imageLoaderService = null;
|
||||
|
||||
/**
|
||||
* The contact list service implementation.
|
||||
*/
|
||||
private static MetaContactListService metaCListService;
|
||||
|
||||
static BundleContext bundleContext;
|
||||
|
||||
/**
|
||||
* Starts this bundle.
|
||||
*/
|
||||
public void start(BundleContext bc) throws Exception
|
||||
{
|
||||
bundleContext = bc;
|
||||
|
||||
Hashtable<String, String> containerFilter
|
||||
= new Hashtable<String, String>();
|
||||
containerFilter.put(
|
||||
Container.CONTAINER_ID,
|
||||
Container.CONTAINER_CONTACT_RIGHT_BUTTON_MENU.getID());
|
||||
|
||||
bundleContext.registerService(
|
||||
PluginComponentFactory.class.getName(),
|
||||
new ContactInfoPluginComponentFactory(
|
||||
Container.CONTAINER_CONTACT_RIGHT_BUTTON_MENU),
|
||||
containerFilter);
|
||||
|
||||
if(getConfigService().getBoolean(ENABLED_IN_CHAT_WINDOW_PROP, false))
|
||||
{
|
||||
containerFilter = new Hashtable<String, String>();
|
||||
containerFilter.put(
|
||||
Container.CONTAINER_ID,
|
||||
Container.CONTAINER_CHAT_TOOL_BAR.getID());
|
||||
|
||||
bundleContext.registerService(
|
||||
PluginComponentFactory.class.getName(),
|
||||
new ContactInfoPluginComponentFactory(
|
||||
Container.CONTAINER_CHAT_TOOL_BAR),
|
||||
containerFilter);
|
||||
}
|
||||
|
||||
if(getConfigService().getBoolean(ENABLED_IN_CALL_WINDOW_PROP, false))
|
||||
{
|
||||
containerFilter = new Hashtable<String, String>();
|
||||
containerFilter.put(
|
||||
Container.CONTAINER_ID,
|
||||
Container.CONTAINER_CALL_DIALOG.getID());
|
||||
|
||||
bundleContext.registerService(
|
||||
PluginComponentFactory.class.getName(),
|
||||
new ContactInfoPluginComponentFactory(
|
||||
Container.CONTAINER_CALL_DIALOG),
|
||||
containerFilter);
|
||||
}
|
||||
|
||||
if (logger.isInfoEnabled())
|
||||
logger.info("CONTACT INFO... [REGISTERED]");
|
||||
}
|
||||
|
||||
public void stop(BundleContext bc) throws Exception
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the <tt>BrowserLauncherService</tt> obtained from the bundle
|
||||
* context.
|
||||
* @return the <tt>BrowserLauncherService</tt> obtained from the bundle
|
||||
* context
|
||||
*/
|
||||
public static BrowserLauncherService getBrowserLauncher()
|
||||
{
|
||||
if (browserLauncherService == null)
|
||||
{
|
||||
ServiceReference serviceReference = bundleContext
|
||||
.getServiceReference(BrowserLauncherService.class.getName());
|
||||
|
||||
browserLauncherService = (BrowserLauncherService) bundleContext
|
||||
.getService(serviceReference);
|
||||
}
|
||||
|
||||
return browserLauncherService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the imageLoaderService instance, if missing query osgi for it.
|
||||
* @return the imageLoaderService.
|
||||
*/
|
||||
public static ImageLoaderService<?> getImageLoaderService()
|
||||
{
|
||||
if(imageLoaderService == null)
|
||||
{
|
||||
imageLoaderService
|
||||
= ServiceUtils.getService(
|
||||
bundleContext,
|
||||
ImageLoaderService.class);
|
||||
}
|
||||
|
||||
return imageLoaderService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the <tt>MetaContactListService</tt> obtained from the bundle
|
||||
* context.
|
||||
* @return the <tt>MetaContactListService</tt> obtained from the bundle
|
||||
* context
|
||||
*/
|
||||
public static MetaContactListService getContactListService()
|
||||
{
|
||||
if (metaCListService == null)
|
||||
{
|
||||
metaCListService
|
||||
= ServiceUtils.getService(
|
||||
bundleContext,
|
||||
MetaContactListService.class);
|
||||
}
|
||||
return metaCListService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a reference to a ConfigurationService implementation currently
|
||||
* registered in the bundle context or null if no such implementation was
|
||||
* found.
|
||||
*
|
||||
* @return a currently valid implementation of the ConfigurationService.
|
||||
*/
|
||||
public static ConfigurationService getConfigService()
|
||||
{
|
||||
return ServiceUtils.getService(bundleContext,
|
||||
ConfigurationService.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Contact info create factory.
|
||||
*/
|
||||
private class ContactInfoPluginComponentFactory
|
||||
extends PluginComponentFactory
|
||||
{
|
||||
ContactInfoPluginComponentFactory(Container c)
|
||||
{
|
||||
super(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PluginComponent getPluginInstance()
|
||||
{
|
||||
return new ContactInfoMenuItem(getContainer(), this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,40 +1,40 @@
|
||||
/*
|
||||
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Copyright @ 2015 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.service.muc;
|
||||
|
||||
/**
|
||||
* Listener which registers for provider add/remove changes.
|
||||
*/
|
||||
public interface ChatRoomProviderWrapperListener
|
||||
{
|
||||
/**
|
||||
* When a provider wrapper is added this method is called to inform
|
||||
* listeners.
|
||||
* @param provider which was added.
|
||||
*/
|
||||
public void chatRoomProviderWrapperAdded(
|
||||
ChatRoomProviderWrapper provider);
|
||||
|
||||
/**
|
||||
* When a provider wrapper is removed this method is called to inform
|
||||
* listeners.
|
||||
* @param provider which was removed.
|
||||
*/
|
||||
public void chatRoomProviderWrapperRemoved(
|
||||
ChatRoomProviderWrapper provider);
|
||||
}
|
||||
/*
|
||||
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Copyright @ 2015 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.service.muc;
|
||||
|
||||
/**
|
||||
* Listener which registers for provider add/remove changes.
|
||||
*/
|
||||
public interface ChatRoomProviderWrapperListener
|
||||
{
|
||||
/**
|
||||
* When a provider wrapper is added this method is called to inform
|
||||
* listeners.
|
||||
* @param provider which was added.
|
||||
*/
|
||||
public void chatRoomProviderWrapperAdded(
|
||||
ChatRoomProviderWrapper provider);
|
||||
|
||||
/**
|
||||
* When a provider wrapper is removed this method is called to inform
|
||||
* listeners.
|
||||
* @param provider which was removed.
|
||||
*/
|
||||
public void chatRoomProviderWrapperRemoved(
|
||||
ChatRoomProviderWrapper provider);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue