• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

Engines

notificationsengine.cpp

Go to the documentation of this file.
00001 /*
00002  *   Copyright (C) 2008 Dmitry Suzdalev <dimsuz@gmail.com>
00003  *
00004  * This program is free software you can redistribute it and/or
00005  * modify it under the terms of the GNU Library General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2 of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Library General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Library General Public License
00015  * along with this library; see the file COPYING.LIB.  If not, write to
00016  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #include "notificationsengine.h"
00021 #include "notificationservice.h"
00022 #include "visualnotificationsadaptor.h"
00023 
00024 #include <Plasma/Service>
00025 
00026 NotificationsEngine::NotificationsEngine( QObject* parent, const QVariantList& args )
00027     : Plasma::DataEngine( parent, args ), m_nextId( 1 )
00028 {
00029     VisualNotificationsAdaptor* adaptor = new VisualNotificationsAdaptor(this);
00030     connect(this, SIGNAL(NotificationClosed(uint, uint)),
00031             adaptor, SIGNAL(NotificationClosed(uint,uint)));
00032     connect(this, SIGNAL(ActionInvoked(uint, const QString&)),
00033             adaptor, SIGNAL(ActionInvoked(uint, const QString&)));
00034 
00035     QDBusConnection dbus = QDBusConnection::sessionBus();
00036     dbus.registerService( "org.kde.VisualNotifications" );
00037     dbus.registerObject( "/VisualNotifications", this );
00038 }
00039 
00040 NotificationsEngine::~NotificationsEngine()
00041 {
00042     QDBusConnection dbus = QDBusConnection::sessionBus();
00043     dbus.unregisterService( "org.kde.VisualNotifications" );
00044 }
00045 
00046 void NotificationsEngine::init()
00047 {
00048 }
00049 
00050 uint NotificationsEngine::Notify(const QString &app_name, uint replaces_id, const QString &event_id,
00051                                  const QString &app_icon, const QString &summary, const QString &body,
00052                                  const QStringList &actions, const QVariantMap &hints, int timeout)
00053 {
00054     uint id = 0;
00055     if (replaces_id == 0) {
00056         // new notification
00057 
00058         id = m_nextId++;
00059 
00060         // TODO implement hints support
00061         Q_UNUSED(hints)
00062 
00063         QString appname_str = app_name;
00064         if (appname_str.isEmpty()) {
00065             appname_str = i18n("unknown app");
00066         }
00067 
00068         Plasma::DataEngine::Data notificationData;
00069         notificationData.insert("id", QString::number(id ));
00070         notificationData.insert("appName", appname_str );
00071         notificationData.insert("appIcon", app_icon );
00072         notificationData.insert("eventId", event_id );
00073         notificationData.insert("summary", summary );
00074         notificationData.insert("body", body );
00075         notificationData.insert("actions", actions );
00076         notificationData.insert("expireTimeout", timeout );
00077 
00078         setData(QString("notification %1").arg(id), notificationData );
00079     } else {
00080         id = replaces_id;
00081         // TODO: update existing source
00082         kDebug() << "notice: updating notifications isn't implemented yet";
00083     }
00084 
00085     return id;
00086 }
00087 
00088 void NotificationsEngine::CloseNotification(uint id)
00089 {
00090     removeSource(QString("notification %1").arg(id));
00091     emit NotificationClosed(id,0);
00092 }
00093 
00094 Plasma::Service* NotificationsEngine::serviceForSource(const QString& source)
00095 {
00096     return new NotificationService(this, source);
00097 }
00098 
00099 K_EXPORT_PLASMA_DATAENGINE(notifications, NotificationsEngine)
00100 
00101 #include "notificationsengine.moc"

Engines

Skip menu "Engines"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

API Reference

Skip menu "API Reference"
  • KWin
  •   KWin Libraries
  • Libraries
  •   libkworkspace
  •   libsolidcontrol
  •   libtaskmanager
  • Plasma
  •   Animators
  •   Applets
  •   Engines
  • Solid Modules
Generated for API Reference by doxygen 1.5.7
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal