Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.sysactivity
Class SystemActivityNotificationsServiceImpl

java.lang.Object
  extended by net.java.sip.communicator.impl.sysactivity.SystemActivityNotifications.NotificationsDelegate
      extended by net.java.sip.communicator.impl.sysactivity.SystemActivityNotificationsServiceImpl
All Implemented Interfaces:
Runnable, SystemActivityNotificationsService

public class SystemActivityNotificationsServiceImpl
extends SystemActivityNotifications.NotificationsDelegate
implements SystemActivityNotificationsService, Runnable

Service implementation listens for computer changes as sleeping, network change, inactivity.

Author:
Damian Minkov

Constructor Summary
SystemActivityNotificationsServiceImpl()
           
 
Method Summary
 void addIdleSystemChangeListener(long idleTime, SystemActivityChangeListener listener)
          Registers a listener that would be notified for idle of the system for idleTime.
 void addSystemActivityChangeListener(SystemActivityChangeListener listener)
          Registers a listener that would be notified of changes that have occurred in the underlying system.
protected  void fireSystemActivityEvent(SystemActivityEvent evt)
          Delivers the specified event to all registered listeners.
protected  void fireSystemIdleEndEvent(SystemActivityChangeListener listener)
          Delivers the specified event to listener.
protected  void fireSystemIdleEvent(SystemActivityChangeListener listener)
          Delivers the specified event to all registered listeners.
 boolean isSupported(int eventID)
          Can check whether an event id is supported on current operation system.
 void notify(int type)
          Callback method when receiving notifications.
 void notifyNetworkChange(int family, long luidIndex, String name, long type, boolean connected)
          Callback method when receiving special network notifications.
 void removeIdleSystemChangeListener(SystemActivityChangeListener listener)
          Remove the specified listener so that it won't receive further notifications for idle system.
 void removeSystemActivityChangeListener(SystemActivityChangeListener listener)
          Remove the specified listener so that it won't receive further notifications of changes that occur in the underlying system
 void run()
          The thread run method that handles idle notifies.
 void start()
          Init and start notifications.
 void stop()
          Stop notifications.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SystemActivityNotificationsServiceImpl

public SystemActivityNotificationsServiceImpl()
Method Detail

start

public void start()
Init and start notifications.


stop

public void stop()
Stop notifications.


addSystemActivityChangeListener

public void addSystemActivityChangeListener(SystemActivityChangeListener listener)
Registers a listener that would be notified of changes that have occurred in the underlying system.

Specified by:
addSystemActivityChangeListener in interface SystemActivityNotificationsService
Parameters:
listener - the listener that we'd like to register for changes in the underlying system.

removeSystemActivityChangeListener

public void removeSystemActivityChangeListener(SystemActivityChangeListener listener)
Remove the specified listener so that it won't receive further notifications of changes that occur in the underlying system

Specified by:
removeSystemActivityChangeListener in interface SystemActivityNotificationsService
Parameters:
listener - the listener to remove.

addIdleSystemChangeListener

public void addIdleSystemChangeListener(long idleTime,
                                        SystemActivityChangeListener listener)
Registers a listener that would be notified for idle of the system for idleTime.

Specified by:
addIdleSystemChangeListener in interface SystemActivityNotificationsService
Parameters:
idleTime - the time in milliseconds after which we will consider system to be idle. This doesn't count when system seems idle as monitor is off or screensaver is on, or desktop is locked.
listener - the listener that we'd like to register for changes in the underlying system.

removeIdleSystemChangeListener

public void removeIdleSystemChangeListener(SystemActivityChangeListener listener)
Remove the specified listener so that it won't receive further notifications for idle system.

Specified by:
removeIdleSystemChangeListener in interface SystemActivityNotificationsService
Parameters:
listener - the listener to remove.

notify

public void notify(int type)
Callback method when receiving notifications.

Specified by:
notify in class SystemActivityNotifications.NotificationsDelegate
Parameters:
type - type of the notification.

notifyNetworkChange

public void notifyNetworkChange(int family,
                                long luidIndex,
                                String name,
                                long type,
                                boolean connected)
Callback method when receiving special network notifications.

Specified by:
notifyNetworkChange in class SystemActivityNotifications.NotificationsDelegate
Parameters:
family - family of network change (ipv6, ipv4) AF_UNSPEC = 0 (The address family is unspecified.) AF_INET = 2 (The Internet Protocol version 4 (IPv4) address family) AF_INET6 = 23 (The Internet Protocol version 6 (IPv6) address family)
luidIndex - unique index of interface
name - name of the interface
type - of the interface Possible values for the interface type are listed in the Ipifcons.h file. common values: IF_TYPE_OTHER = 1 (Some other type of network interface.) IF_TYPE_ETHERNET_CSMACD = 6 (An Ethernet network interface.) IF_TYPE_ISO88025_TOKENRING = 9 (A token ring network interface.) IF_TYPE_PPP = 23 (A PPP network interface.) IF_TYPE_SOFTWARE_LOOPBACK = 24 (A software loopback network interface.) IF_TYPE_IEEE80211 = 71 (An IEEE 802.11 wireless network interface.) IF_TYPE_TUNNEL = 131 (A tunnel type encapsulation network interface.) IF_TYPE_IEEE1394 = 144 (An IEEE 1394 (Firewire) high performance serial bus network interface.)
connected - whether interface is connected or not.

run

public void run()
The thread run method that handles idle notifies.

Specified by:
run in interface Runnable
See Also:
Thread.run()

fireSystemActivityEvent

protected void fireSystemActivityEvent(SystemActivityEvent evt)
Delivers the specified event to all registered listeners.

Parameters:
evt - the SystemActivityEvent that we'd like delivered to all registered message listeners.

fireSystemIdleEvent

protected void fireSystemIdleEvent(SystemActivityChangeListener listener)
Delivers the specified event to all registered listeners.

Parameters:
listener - listener to inform

fireSystemIdleEndEvent

protected void fireSystemIdleEndEvent(SystemActivityChangeListener listener)
Delivers the specified event to listener.

Parameters:
listener - listener to inform

isSupported

public boolean isSupported(int eventID)
Can check whether an event id is supported on current operation system. Simple return what is implemented in native, and checks are made when possible, for example linux cannot connect to NM through dbus.

Specified by:
isSupported in interface SystemActivityNotificationsService
Parameters:
eventID - the event to check.
Returns:
whether the supplied event id is supported.

Jitsi: the OpenSource Java VoIP and Instant Messaging client.

Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under LGPL license.