org.kde.koala
Class KNotifyClient

java.lang.Object
  extended by org.kde.koala.KNotifyClient

public class KNotifyClient
extends java.lang.Object

This namespace provides a method for issuing events to a KNotifyServer call KNotifyClient.event("eventname"); to issue it. On installation, there should be a file called $KDEDIR/share/apps/appname/eventsrc which contains the events. The file looks like this:

 [!Global!]
 IconName=Filename (e.g. kdesktop, without any extension)
 Comment=FriendlyNameOfApp
 [eventname]
 Name=FriendlyNameOfEvent
 Comment=Description Of Event
 default_sound=filetoplay.wav
 default_logfile=logfile.txt
 default_commandline=command
 default_presentation=1
  ...
 
default_presentation contains these ORed events: None=0, Sound=1, Messagebox=2, Logfile=4, Stderr=8, PassivePopup=16, Execute=32, Taskbar=64 KNotify will search for sound files given with a relative path first in the application's sound directory (share/apps/Application Name/sounds), then in the KDE global sound directory (share/sounds). You can also use the "nopresentation" key, with any the presentations ORed. Those that are in that field will not appear in the kcontrol module. This was intended for software like KWin to not allow a window-opening that opens a window (e.g., allowing to disable KMessageBoxes from appearing) If the user edits the eventsrc file manually, it will appear. This only affects the KcmNotify. You can also use the following events, which are system controlled and do not need to be placed in your eventsrc: The events can be configured in an application using KNotifyDialog, which is part of KIO.

Author:
Charles Samuels

Field Summary
static int cannotOpenFile
          default events you can use
static int catastrophe
           
static int Catastrophe
           
static int Default
          Describes the notification method.
static int Error
           
static int Execute
           
static int fatalError
           
static int Logfile
           
static int Messagebox
           
static int None
           
static int notification
           
static int Notification
          Describes the level of the error.
static int PassivePopup
           
static int Sound
           
static int Stderr
           
static int Taskbar
           
static int warning
           
static int Warning
           
 
Constructor Summary
KNotifyClient()
           
 
Method Summary
static void beep()
           
static void beep(java.lang.String reason)
          This is a simple substitution for QApplication.beep().
static int event(int winId, int event)
           
static int event(int winId, int event, java.lang.String text)
          You should pass the origin-widget's winId() here so that a PassivePopup can be placed appropriately.
static int event(int winId, java.lang.String message)
           
static int event(int winId, java.lang.String message, java.lang.String text)
          This should be the most used method in here.
static java.lang.String getDefaultFile(java.lang.String eventname, int present)
          Gets the default File for the event of this program.
static int getDefaultPresentation(java.lang.String eventname)
          Gets the default presentation for the event of this program.
static java.lang.String getFile(java.lang.String eventname, int present)
          Gets the default file associated with a certain event name The control panel module will list all the event names This has the potential for being slow.
static int getPresentation(java.lang.String eventname)
          Gets the presentation associated with a certain event name Remeber that they may be ORed:
static KInstanceInterface instance()
          Shortcut to KNotifyClient.Instance.current() :)
static boolean startDaemon()
          This starts the KNotify Daemon, if it's not already started.
static int userEvent(int winId)
           
static int userEvent(int winId, java.lang.String text)
           
static int userEvent(int winId, java.lang.String text, int present)
           
static int userEvent(int winId, java.lang.String text, int present, int level)
           
static int userEvent(int winId, java.lang.String text, int present, int level, java.lang.String sound)
           
static int userEvent(int winId, java.lang.String text, int present, int level, java.lang.String sound, java.lang.String file)
          Will fire an event that's not registered.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

Default

public static final int Default
Describes the notification method.

See Also:
Constant Field Values

None

public static final int None
See Also:
Constant Field Values

Sound

public static final int Sound
See Also:
Constant Field Values

Messagebox

public static final int Messagebox
See Also:
Constant Field Values

Logfile

public static final int Logfile
See Also:
Constant Field Values

Stderr

public static final int Stderr
See Also:
Constant Field Values

PassivePopup

public static final int PassivePopup
See Also:
Constant Field Values

Execute

public static final int Execute
See Also:
Constant Field Values

Taskbar

public static final int Taskbar
See Also:
Constant Field Values

Notification

public static final int Notification
Describes the level of the error.

See Also:
Constant Field Values

Warning

public static final int Warning
See Also:
Constant Field Values

Error

public static final int Error
See Also:
Constant Field Values

Catastrophe

public static final int Catastrophe
See Also:
Constant Field Values

cannotOpenFile

public static final int cannotOpenFile
default events you can use

See Also:
Constant Field Values

notification

public static final int notification
See Also:
Constant Field Values

warning

public static final int warning
See Also:
Constant Field Values

fatalError

public static final int fatalError
See Also:
Constant Field Values

catastrophe

public static final int catastrophe
See Also:
Constant Field Values
Constructor Detail

KNotifyClient

public KNotifyClient()
Method Detail

startDaemon

public static boolean startDaemon()
This starts the KNotify Daemon, if it's not already started. This will be useful for games that use sound effects. Run this at the start of the program, and there won't be a pause when it is first triggered.

Returns:
true if daemon is running (always true at the moment)

event

public static int event(int winId,
                        java.lang.String message,
                        java.lang.String text)
This should be the most used method in here. Pass the origin-widget's winId() here so that a PassivePopup can be placed appropriately. Call it by KNotifyClient.event(widget.winId(), "EventName"); It will use KApplication.kApplication.dcopClient() to communicate to the server

Parameters:
winId - The winId() of the widget where the event originates
message - The name of the event
text - The text to put in a dialog box. This won't be shown if the user connected the event to sound, only. Can be null.
Returns:
a value > 0, unique for this event if successful, 0 otherwise

event

public static int event(int winId,
                        java.lang.String message)

event

public static int event(int winId,
                        int event,
                        java.lang.String text)
You should pass the origin-widget's winId() here so that a PassivePopup can be placed appropriately.

Parameters:
winId - The winId() of the widget where the event originates
event - The event you want to raise
text - The text to put in a dialog box. This won't be shown if the user connected the event to sound, only. Can be null.
Returns:
a value > 0, unique for this event if successful, 0 otherwise

event

public static int event(int winId,
                        int event)

userEvent

public static int userEvent(int winId,
                            java.lang.String text,
                            int present,
                            int level,
                            java.lang.String sound,
                            java.lang.String file)
Will fire an event that's not registered. You should pass the origin-widget's winId() here so that a PassivePopup can be placed appropriately.

Parameters:
winId - The winId() of the originating widget
text - The error message text, if applicable
present - The presentation method(s) of the event
level - The error message level, defaulting to "Default"
sound - The sound file to play if selected with present
file - The log file to append the message to if selected with present
Returns:
a value > 0, unique for this event if successful, 0 otherwise

userEvent

public static int userEvent(int winId,
                            java.lang.String text,
                            int present,
                            int level,
                            java.lang.String sound)

userEvent

public static int userEvent(int winId,
                            java.lang.String text,
                            int present,
                            int level)

userEvent

public static int userEvent(int winId,
                            java.lang.String text,
                            int present)

userEvent

public static int userEvent(int winId,
                            java.lang.String text)

userEvent

public static int userEvent(int winId)

beep

public static void beep(java.lang.String reason)
This is a simple substitution for QApplication.beep(). It simply calls
                 KNotifyClient.event( KNotifyClient.notification, reason );
                 

Parameters:
reason - the reason, can be null.

beep

public static void beep()

getPresentation

public static int getPresentation(java.lang.String eventname)
Gets the presentation associated with a certain event name Remeber that they may be ORed:
                 if (present & KNotifyClient.Sound) { [Yes, sound is a default] }       
                 

Parameters:
eventname - the event name to check
Returns:
the presentation methods

getFile

public static java.lang.String getFile(java.lang.String eventname,
                                       int present)
Gets the default file associated with a certain event name The control panel module will list all the event names This has the potential for being slow.

Parameters:
eventname - the name of the event
present - the presentation method
Returns:
the associated file. Can be null if not found.

getDefaultPresentation

public static int getDefaultPresentation(java.lang.String eventname)
Gets the default presentation for the event of this program. Remember that the Presentation may be ORed. Try this:
                 if (present & KNotifyClient.Sound) { [Yes, sound is a default] }
                 

Returns:
the presentation methods

getDefaultFile

public static java.lang.String getDefaultFile(java.lang.String eventname,
                                              int present)
Gets the default File for the event of this program. It gets it in relation to present. Some events don't apply to this function ("Message Box") Some do (Sound)

Parameters:
eventname - the name of the event
present - the presentation method
Returns:
the default file. Can be null if not found.

instance

public static KInstanceInterface instance()
Shortcut to KNotifyClient.Instance.current() :)

Returns:
the current KInstance.