class KNotifyClient

This class provides a method for issuing events to a KNotifyServer call KNotifyClient::event("eventname"); to issue it. More...

Definition#include <knotifyclient.h>
InheritsQObject
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Types

Public Methods

Public Slots

Public Static Methods


Detailed Description

This class 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!]
 Name=executable
 Comment=FriendlyNameOfApp

 [eventname]
 Name=FriendlyNameOfEvent
 Comment=Description Of Event
 default_sound=filetoplay.wav
 default_presentation=1
  ...

default_presentation contains these ANDed events: None=0, Sound=1, Messagebox=2, Logfile=4, Stderr=8

You can also use the following events, which are system controlled and do not need to be placed in your eventsrc:

cannotopenfile (more to come)

This class works, but is still in testing.

 KNotifyClient (QObject *parent, const QString &message, const QString &text=0, int present=Default, const QString &sound=0, const QString &file=0, DCOPClient* client=0)

The Default constructor. You should have little use for this thanks to the event method. This will launch the KNotify service if needed.

Parameters:
messageThe event type to send, such as "Desktop1" for a virtual desktop change
textIf you need to send off a message with your alert. This will happen for an error level of 2 or more.
presentHow to present it. If "Default" is chosen, the server will decide according to the config
soundThe sound to play (KDEDIR/share/sounds/ if not absolute)
filefile to write to (if selected)
clientThe DCOPClient to use. Usually it pulls the one from your KApplication.

bool  send ()

[slot]

If you need to send a message a whole lot sequentially, for reasons I don't want to know, you might instanciate a KNotifyClient, and call this function when needed.

bool  event (const QString &message, const QString &text=0)

[static]

This should be the most used method in here. Call it by KNotifyClient::event("EventName"); It will use KApplication::kApplication->dcopClient() to communicate to the server

Parameters:
messageThe name of the event
textThe text to put in a dialog box. This won't be shown if the user connected the event to sound, only.

bool  userEvent (const QString &text=0, int present=Default, const QString &sound=0, const QString &file=0)

[static]

Will fire an event that's not registered.

Parameters:
textThe error message text, if applicable
presentThe error message level, defaulting to "Default"
fileThe sound file to play if selected with present

int  getPresentation (const QString &eventname)

[static]

Gets the presentation associated with a certain event name Remeber that they may be ORed: if (present & KNotifyClient::Sound) { [Yes, sound is a default] }

QString  getFile (const QString &eventname, int present)

[static]

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.

int  getDefaultPresentation (const QString &eventname)

[static]

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] }

QString  getDefaultFile (const QString &eventname, int present)

[static]

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)