Source Code (Use browser search to find items of interest.)
Class Index
kdelibs'KNotifyClient (./kdelibs/kdecore/knotifyclient.h:57)
class KNotifyClient : public QObject
{
Q_OBJECT
public:
enum {
Default=-1,
None=0,
Sound=1,
Messagebox=2,
Logfile=4,
Stderr=8
};
public:
/**
* The Default constructor. You should have little use
* for this thanks to the @ref event method.
* @param message The event type to send, such as "Desktop1" for a virtual
* desktop change
* @param text If you need to send off a message with your alert. This
* will happen for an error level of 2 or more.
* @param present How to present it. If "Default" is chosen, the server
* will decide according to the config
* @param client The DCOPClient to use. Usually it pulls the one from
* your KApplication.
* @param sound The sound to play (KDEDIR/share/sounds/ if not absolute)
*/
KNotifyClient(QObject *parent, const QString &message, const QString &text=0,
int present=Default,
const QString &sound=0, const QString &file=0,
DCOPClient* client=0);
virtual ~KNotifyClient();
public slots:
/**
* 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 send();
public: //static methods
/**
* 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
* @param message The name of the event
* @param text The text to put in a dialog box. This won't be shown if
* the user connected the event to sound, only.
*/
static bool event(const QString &message, const QString &text=0);
/**
* Will fire an event that's not registered.
* @param text The error message text, if applicable
* @param present The error message level, defaulting to "Default"
* @param file The sound file to play if selected with present
*/
static bool userEvent(const QString &text=0, int present=Default,
const QString &sound=0, const QString &file=0);
/**
* Gets the presentation associated with a certain event name
* Remeber that they may be ORed:
* if (present & KNotifyClient::Sound) { [Yes, sound is a default] }
*/
static int getPresentation(const QString &eventname);
/**
* 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 QString getFile(const QString &eventname, int present);
/**
* 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] }
*/
static int getDefaultPresentation(const QString &eventname);
/**
* 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)
*/
static QString getDefaultFile(const QString &eventname, int present);
private:
/**
* Why does kdoc include this? This is an internal structure that's actually
* declared under "private"
* @internal
*/
struct Event
{
QString message;
QString text;
int present;
QString sound;
QString file;
DCOPClient *client;
} *levent;
class KNotifyClientPrivate;
KNotifyClientPrivate *d;
};
kdelibs'KNotifyClient::KNotifyClient() (./kdelibs/kdecore/knotifyclient.cpp:28)
KNotifyClient::KNotifyClient(QObject *parent, const QString &message, const QString &text,
int present, const QString &sound, const QString &file,
DCOPClient* client) : QObject(parent)
{
if (!client) client=KApplication::kApplication()->dcopClient();
levent=new Event;
levent->message=message;
levent->text=text;
levent->present=present;
levent->sound=sound;
levent->file=file;
levent->client=client;
}
kdelibs'KNotifyClient::~KNotifyClient() (./kdelibs/kdecore/knotifyclient.cpp:42)
KNotifyClient::~KNotifyClient()
{
delete levent;
}
kdelibs'KNotifyClient::send() (./kdelibs/kdecore/knotifyclient.cpp:47)
bool KNotifyClient::send()
{
DCOPClient *client=levent->client;
if (!client->isAttached())
client->attach();
if (!client->isAttached())
return false;
QByteArray data;
QDataStream ds(data, IO_WriteOnly);
QString appname = kapp->name();
ds << levent->message << appname << levent->text << levent->sound << levent->file << levent->present;
return client->send("knotify", "Notify", "notify(QString,QString,QString,QString,QString,int)", data);
}
kdelibs'KNotifyClient::event() (./kdelibs/kdecore/knotifyclient.cpp:63)
bool KNotifyClient::event(const QString &message, const QString &text)
{
KNotifyClient c(0,message, text);
return c.send();
}
kdelibs'KNotifyClient::userEvent() (./kdelibs/kdecore/knotifyclient.cpp:69)
bool KNotifyClient::userEvent(const QString &text, int present,
const QString &sound, const QString &file)
{
KNotifyClient c(0,0, text, present, sound, file);
return c.send();
}
kdelibs'KNotifyClient::getPresentation() (./kdelibs/kdecore/knotifyclient.cpp:76)
int KNotifyClient::getPresentation(const QString &eventname)
{
int present;
if (eventname.isEmpty()) return Default;
KConfig eventsfile(locate("data", QString(KApplication::kApplication()->name())+"/eventsrc"));
eventsfile.setGroup(eventname);
present=eventsfile.readNumEntry("presentation", -1);
return present;
}
kdelibs'KNotifyClient::getFile() (./kdelibs/kdecore/knotifyclient.cpp:89)
QString KNotifyClient::getFile(const QString &eventname, int present)
{
if (eventname.isEmpty()) return 0;
KConfig eventsfile(locate("data", QString(KApplication::kApplication()->name())+"/eventsrc"));
eventsfile.setGroup(eventname);
switch (present)
{
case (Sound):
return eventsfile.readEntry("sound", 0);
case (Logfile):
return eventsfile.readEntry("logfile", 0);
}
return 0;
}
kdelibs'KNotifyClient::getDefaultPresentation() (./kdelibs/kdecore/knotifyclient.cpp:107)
int KNotifyClient::getDefaultPresentation(const QString &eventname)
{
int present;
if (eventname.isEmpty()) return Default;
KConfig eventsfile(locate("data", QString(KApplication::kApplication()->name())+"/eventsrc"));
eventsfile.setGroup(eventname);
present=eventsfile.readNumEntry("default_presentation", -1);
return present;
}
kdelibs'KNotifyClient::getDefaultFile() (./kdelibs/kdecore/knotifyclient.cpp:120)
QString KNotifyClient::getDefaultFile(const QString &eventname, int present)
{
if (eventname.isEmpty()) return 0;
KConfig eventsfile(locate("data", QString(KApplication::kApplication()->name())+"/eventsrc"));
eventsfile.setGroup(eventname);
switch (present)
{
case (Sound):
return eventsfile.readEntry("default_sound", 0);
case (Logfile):
return eventsfile.readEntry("default_logfile", 0);
}
return 0;
}