Jitsi: the OpenSource Java VoIP and Instant Messaging client.

net.java.sip.communicator.impl.globalshortcut
Class GlobalShortcutServiceImpl

java.lang.Object
  extended by net.java.sip.communicator.impl.globalshortcut.GlobalShortcutServiceImpl
All Implemented Interfaces:
NativeKeyboardHookDelegate, GlobalShortcutService

public class GlobalShortcutServiceImpl
extends Object
implements GlobalShortcutService, NativeKeyboardHookDelegate

This global shortcut service permits to register listeners for global shortcut (i.e. keystroke even if application is not foreground).

Author:
Sebastien Vincent

Field Summary
 
Fields inherited from interface net.java.sip.communicator.service.globalshortcut.GlobalShortcutService
SPECIAL_KEY_MODIFIERS
 
Fields inherited from interface net.java.sip.communicator.impl.globalshortcut.NativeKeyboardHookDelegate
MODIFIERS_ALT, MODIFIERS_CTRL, MODIFIERS_LOGO, MODIFIERS_SHIFT
 
Constructor Summary
GlobalShortcutServiceImpl()
          Initializes the GlobalShortcutServiceImpl.
 
Method Summary
 CallShortcut getCallShortcut()
          Returns CallShortcut object.
 AWTKeyStroke getSpecialKey()
          Get special keystroke or null if not supported or user cancels.
 UIShortcut getUIShortcut()
          Returns UIShortcut object.
 void receiveKey(int keycode, int modifiers)
          Receive a key press event.
 void registerShortcut(GlobalShortcutListener listener, AWTKeyStroke keyStroke)
          Registers an action to execute when the keystroke is typed.
 void registerShortcut(GlobalShortcutListener listener, AWTKeyStroke keyStroke, boolean add)
          Registers an action to execute when the keystroke is typed.
 void reloadGlobalShortcuts()
          Reload global shortcuts.
 void setEnable(boolean enable)
          Enable or not global shortcut.
 void setSpecialKeyDetection(boolean enable, GlobalShortcutListener callback)
          Enable or disable special key detection.
 void start()
          Start the service.
 void stop()
          Stop the service.
 void test()
          Simple test.
 void unregisterShortcut(GlobalShortcutListener listener, AWTKeyStroke keyStroke)
          Unregisters an action to execute when the keystroke is typed.
 void unregisterShortcut(GlobalShortcutListener listener, AWTKeyStroke keyStroke, boolean remove)
          Unregisters an action to execute when the keystroke is typed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GlobalShortcutServiceImpl

public GlobalShortcutServiceImpl()
Initializes the GlobalShortcutServiceImpl.

Method Detail

registerShortcut

public void registerShortcut(GlobalShortcutListener listener,
                             AWTKeyStroke keyStroke)
Registers an action to execute when the keystroke is typed.

Specified by:
registerShortcut in interface GlobalShortcutService
Parameters:
listener - listener to notify when keystroke is typed
keyStroke - keystroke that will trigger the action

registerShortcut

public void registerShortcut(GlobalShortcutListener listener,
                             AWTKeyStroke keyStroke,
                             boolean add)
Registers an action to execute when the keystroke is typed.

Parameters:
listener - listener to notify when keystroke is typed
keyStroke - keystroke that will trigger the action
add - add the listener/keystrokes to map

unregisterShortcut

public void unregisterShortcut(GlobalShortcutListener listener,
                               AWTKeyStroke keyStroke)
Unregisters an action to execute when the keystroke is typed.

Specified by:
unregisterShortcut in interface GlobalShortcutService
Parameters:
listener - listener to remove
keyStroke - keystroke that will trigger the action

unregisterShortcut

public void unregisterShortcut(GlobalShortcutListener listener,
                               AWTKeyStroke keyStroke,
                               boolean remove)
Unregisters an action to execute when the keystroke is typed.

Parameters:
listener - listener to remove
keyStroke - keystroke that will trigger the action
remove - remove or not entry in the map

start

public void start()
Start the service.


stop

public void stop()
Stop the service.


receiveKey

public void receiveKey(int keycode,
                       int modifiers)
Receive a key press event.

Specified by:
receiveKey in interface NativeKeyboardHookDelegate
Parameters:
keycode - keycode received
modifiers - modifiers received (ALT or CTRL + letter, ...)

reloadGlobalShortcuts

public void reloadGlobalShortcuts()
Reload global shortcuts.

Specified by:
reloadGlobalShortcuts in interface GlobalShortcutService

getCallShortcut

public CallShortcut getCallShortcut()
Returns CallShortcut object.

Returns:
CallShortcut object

getUIShortcut

public UIShortcut getUIShortcut()
Returns UIShortcut object.

Returns:
UIShortcut object

setEnable

public void setEnable(boolean enable)
Enable or not global shortcut.

Specified by:
setEnable in interface GlobalShortcutService
Parameters:
enable - enable or not global shortcut

setSpecialKeyDetection

public void setSpecialKeyDetection(boolean enable,
                                   GlobalShortcutListener callback)
Enable or disable special key detection.

Specified by:
setSpecialKeyDetection in interface GlobalShortcutService
Parameters:
enable - enable or not special key detection.
callback - object to be notified

getSpecialKey

public AWTKeyStroke getSpecialKey()
Get special keystroke or null if not supported or user cancels. If no special key is detected for 5 seconds, it returns null

Specified by:
getSpecialKey in interface GlobalShortcutService
Returns:
special keystroke or null if not supported or user cancels

test

public void test()
Simple test.


Jitsi: the OpenSource Java VoIP and Instant Messaging client.

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