|
|
@ -23,25 +23,26 @@
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <tdeapplication.h>
|
|
|
|
|
|
|
|
|
|
|
|
#include "NotificationsService.h"
|
|
|
|
#include "NotificationsService.h"
|
|
|
|
|
|
|
|
|
|
|
|
#define NOTIFICATIONS_DBUS_PATH "/org/freedesktop/Notifications"
|
|
|
|
|
|
|
|
#define IMAGE_SIZE 48
|
|
|
|
#define IMAGE_SIZE 48
|
|
|
|
|
|
|
|
|
|
|
|
#define SRV_VERSION "1.1"
|
|
|
|
#define SRV_VERSION "1.2"
|
|
|
|
#define SPEC_VERSION "1.1"
|
|
|
|
#define SPEC_VERSION "1.2"
|
|
|
|
#define NOTIFICATIONS_NAME "Notification Daemon"
|
|
|
|
#define NOTIFICATIONS_NAME "Notification Daemon"
|
|
|
|
#define TRINITY_DESKTOP_PROJECT "Trinity Desktop Project"
|
|
|
|
#define TRINITY_DESKTOP_PROJECT "Trinity Desktop Project"
|
|
|
|
|
|
|
|
|
|
|
|
NotificationsService::NotificationsService(TQT_DBusConnection &conn)
|
|
|
|
NotificationsService::NotificationsService(TQT_DBusConnection &conn)
|
|
|
|
: org::freedesktop::NotificationsInterface(), mConnection(&conn)
|
|
|
|
: org::freedesktop::NotificationsInterface(), mConnection(&conn),
|
|
|
|
|
|
|
|
mNotificationId(0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// TODO Auto-generated constructor stub
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NotificationsService::~NotificationsService()
|
|
|
|
NotificationsService::~NotificationsService()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// TODO Auto-generated destructor stub
|
|
|
|
notificationMap.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void NotificationsService::closeNotifyWidget(TQ_UINT32 id, TQ_UINT32 reason) {
|
|
|
|
void NotificationsService::closeNotifyWidget(TQ_UINT32 id, TQ_UINT32 reason) {
|
|
|
@ -57,20 +58,22 @@ void NotificationsService::closeNotifyWidget(TQ_UINT32 id, TQ_UINT32 reason) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool NotificationsService::handleSignalSend(const TQT_DBusMessage& reply) {
|
|
|
|
bool NotificationsService::handleSignalSend(const TQT_DBusMessage& reply) {
|
|
|
|
|
|
|
|
|
|
|
|
mConnection->send(reply);
|
|
|
|
mConnection->send(reply);
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TQString NotificationsService::objectPath() const {
|
|
|
|
TQString NotificationsService::objectPath() const {
|
|
|
|
|
|
|
|
|
|
|
|
return TQString(NOTIFICATIONS_DBUS_PATH);
|
|
|
|
return TQString(NOTIFICATIONS_DBUS_PATH);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool NotificationsService::GetCapabilities(TQStringList& return_caps, TQT_DBusError& error) {
|
|
|
|
bool NotificationsService::GetCapabilities(TQStringList& return_caps, TQT_DBusError& error) {
|
|
|
|
|
|
|
|
|
|
|
|
return_caps.clear();
|
|
|
|
return_caps.clear();
|
|
|
|
return_caps << "action-icons" << "actions" << "body" << "body-hyperlinks" << "body-markup" << "icon-static";
|
|
|
|
// action-icons, actions are not implemented
|
|
|
|
|
|
|
|
// hints are partially implemented (see Capabilities in the docs)
|
|
|
|
|
|
|
|
// - persistence and sound
|
|
|
|
|
|
|
|
return_caps << "body" << "body-hyperlinks" << "body-images" <<
|
|
|
|
|
|
|
|
"body-markup" << "icon-static" << "persistence" << "sound";
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -97,38 +100,115 @@ bool NotificationsService::GetServerInformation(TQString& return_name, TQString&
|
|
|
|
|
|
|
|
|
|
|
|
void NotificationsService::NotifyAsync(
|
|
|
|
void NotificationsService::NotifyAsync(
|
|
|
|
int asyncCallId,
|
|
|
|
int asyncCallId,
|
|
|
|
const TQString& app_name, TQ_UINT32 id, const TQString& icon,
|
|
|
|
const TQString& app_name,
|
|
|
|
const TQString& summary, const TQString& body,
|
|
|
|
TQ_UINT32 id,
|
|
|
|
|
|
|
|
const TQString& icon,
|
|
|
|
|
|
|
|
const TQString& summary,
|
|
|
|
|
|
|
|
const TQString& body,
|
|
|
|
const TQStringList& actions,
|
|
|
|
const TQStringList& actions,
|
|
|
|
const TQMap<TQString, TQT_DBusVariant>& hints, TQ_INT32 timeout)
|
|
|
|
const TQMap<TQString, TQT_DBusVariant>& hints,
|
|
|
|
|
|
|
|
TQ_INT32 timeout)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (notificationMap.contains(id))
|
|
|
|
TQ_UINT32 nId=id;
|
|
|
|
|
|
|
|
// if (nId != 0 && !notificationMap.contains(nId))
|
|
|
|
|
|
|
|
// tqDebug("Requested id %i is not valid", nId);
|
|
|
|
|
|
|
|
bool found = notificationMap.contains(nId);
|
|
|
|
|
|
|
|
if (nId == 0 || !notificationMap.contains(nId)) // new notification
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
nId = ++mNotificationId;
|
|
|
|
|
|
|
|
notificationMap[nId] = new NotifyWidget(0, app_name.ascii(), this, nId);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!hints.empty())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
NotifyAsyncError(asyncCallId, TQT_DBusError::stdFailed("Requested id already displayed"));
|
|
|
|
TQString errStr;
|
|
|
|
tqDebug("Requested id %i already in use", id);
|
|
|
|
TQMap<TQString, TQT_DBusVariant>::const_iterator it;
|
|
|
|
return;
|
|
|
|
for ( it = hints.begin(); it != hints.end(); ++it ) {
|
|
|
|
|
|
|
|
bool ok = true;
|
|
|
|
|
|
|
|
if(it.key().latin1()=="category")
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
notificationMap[nId]->setCategory(it.data().value.toString(&ok));
|
|
|
|
|
|
|
|
if(!ok) errStr += " category";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (it.key().latin1()=="image-path")
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
notificationMap[nId]->setImage(it.data().value.toString(&ok));
|
|
|
|
|
|
|
|
if(!ok) errStr += " image-path";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (it.key().latin1()=="image-data" || it.key().latin1()=="image_data" || it.key().latin1()=="icon_data")
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
notificationMap[nId]->setImageData(it.data().value.toTQValueList(&ok));
|
|
|
|
|
|
|
|
if(!ok) errStr += " image-data";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (it.key().latin1()=="sound-file")
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
notificationMap[nId]->setSoundFile(it.data().value.toString(&ok));
|
|
|
|
|
|
|
|
if(!ok) errStr += " sound-file";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (it.key().latin1()=="sound-name")
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
notificationMap[nId]->setSoundName(it.data().value.toString(&ok));
|
|
|
|
|
|
|
|
if(!ok) errStr += " sound-name";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (it.key().latin1()=="suppress-sound")
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
notificationMap[nId]->setSuppressSound(it.data().value.toBool(&ok));
|
|
|
|
|
|
|
|
if(!ok) errStr += " suppress-sound";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (it.key().latin1()=="transient")
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
notificationMap[nId]->setTransient(it.data().value.toBool(&ok));
|
|
|
|
|
|
|
|
if(!ok) errStr += " transient";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (it.key().latin1()=="urgency")
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
notificationMap[nId]->setUrgency(it.data().value.toUInt16(&ok));
|
|
|
|
|
|
|
|
if(!ok) errStr += " urgency";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (it.key().latin1()=="sender-pid")
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
notificationMap[nId]->setSenderPid(it.data().value.toUInt64(&ok));
|
|
|
|
|
|
|
|
if(!ok) errStr += " sender-pid";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(! errStr.isNull() )
|
|
|
|
|
|
|
|
tqDebug("There was an error converting some of the hint values:" + errStr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
notificationMap[id] = new NotifyWidget(0, app_name.ascii(), this, id );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
notificationMap[id]->setFrameStyle( TQFrame::NoFrame );
|
|
|
|
notificationMap[nId]->setFrameStyle( TQFrame::NoFrame );
|
|
|
|
notificationMap[id]->setPaletteBackgroundColor(TQt::black);
|
|
|
|
// notificationMap[nId]->setPaletteBackgroundColor(TQt::black);
|
|
|
|
notificationMap[id]->setPaletteForegroundColor(TQt::white);
|
|
|
|
// notificationMap[nId]->setPaletteForegroundColor(TQt::white);
|
|
|
|
|
|
|
|
|
|
|
|
if (icon.isEmpty() || ! notificationMap[id]->setIcon(icon)) {
|
|
|
|
if (icon.isEmpty() || ! notificationMap[nId]->setIcon(icon)) {
|
|
|
|
notificationMap[id]->setTextFormat(TQt::RichText);
|
|
|
|
notificationMap[nId]->setTextFormat(TQt::RichText);
|
|
|
|
notificationMap[id]->setText(app_name + ":\n" + summary + "\n" + body);
|
|
|
|
notificationMap[nId]->setText(app_name + ":\n" + summary + "\n" + body);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
notificationMap[nId]->setActions(actions);
|
|
|
|
|
|
|
|
notificationMap[nId]->setTimeout(timeout);
|
|
|
|
|
|
|
|
notificationMap[nId]->adjustSize();
|
|
|
|
|
|
|
|
notificationMap[nId]->raise();
|
|
|
|
|
|
|
|
notificationMap[nId]->show();
|
|
|
|
|
|
|
|
notificationMap[nId]->setActiveWindow();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// make sure we display the new notification above the older one
|
|
|
|
|
|
|
|
// and if we reach the top of the screen we start at the bottom
|
|
|
|
|
|
|
|
TQDesktopWidget *d = TQApplication::desktop();
|
|
|
|
|
|
|
|
if (notificationMap.contains(nId-1) && notificationMap[nId-1] != 0) {
|
|
|
|
|
|
|
|
TQPoint pos = notificationMap[nId-1]->pos();
|
|
|
|
|
|
|
|
if(pos.y()-notificationMap[nId-1]->height() < 0)
|
|
|
|
|
|
|
|
pos.setY(d->height()-notificationMap[nId]->height());
|
|
|
|
|
|
|
|
pos.setX(d->width()-notificationMap[nId]->width());
|
|
|
|
|
|
|
|
notificationMap[nId]->move(pos.x(),pos.y()-notificationMap[nId-1]->height());
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
notificationMap[nId]->move( d->width()-notificationMap[nId]->width(),
|
|
|
|
|
|
|
|
d->height()-notificationMap[nId]->height());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
notificationMap[id]->setActions(actions);
|
|
|
|
|
|
|
|
notificationMap[id]->setHints(hints);
|
|
|
|
NotifyAsyncReply(asyncCallId, nId);
|
|
|
|
notificationMap[id]->setTimeout(timeout);
|
|
|
|
|
|
|
|
notificationMap[id]->adjustSize();
|
|
|
|
|
|
|
|
notificationMap[id]->raise();
|
|
|
|
|
|
|
|
notificationMap[id]->show();
|
|
|
|
|
|
|
|
notificationMap[id]->setActiveWindow();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NotifyAsyncReply(asyncCallId, id);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void NotificationsService::handleMethodReply(const TQT_DBusMessage& reply) {
|
|
|
|
void NotificationsService::handleMethodReply(const TQT_DBusMessage& reply) {
|
|
|
|
mConnection->send(reply);
|
|
|
|
mConnection->send(reply);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|