*** src/qtui/mainwin.h.orig	2008-08-26 20:42:43.000000000 +1000
--- src/qtui/mainwin.h	2008-08-26 20:45:26.000000000 +1000
***************
*** 54,60 ****
      void displayTrayIconMessage(const QString &title, const QString &message);
  
  #ifdef HAVE_DBUS
!     void sendDesktopNotification(const QString &title, const QString &message);
  #endif
  
      virtual bool event(QEvent *event);
--- 54,60 ----
      void displayTrayIconMessage(const QString &title, const QString &message);
  
  #ifdef HAVE_DBUS
!     void sendDesktopNotification(const QString &title, const QString &message, const BufferId &bufId);
  #endif
  
      virtual bool event(QEvent *event);
*** src/qtui/mainwin.cpp.orig	2008-08-26 12:34:25.000000000 +1000
--- src/qtui/mainwin.cpp	2008-08-26 20:45:26.000000000 +1000
***************
*** 594,600 ****
            QString text = idx.data(ChatLineModel::DisplayRole).toString();
            if(displayBubble) displayTrayIconMessage(title, text);
  #   ifdef HAVE_DBUS
!           if(displayDesktop) sendDesktopNotification(title, text);
  #   endif
          }
          if(uiSettings.value("AnimateTrayIcon", QVariant(true)).toBool()) {
--- 594,600 ----
            QString text = idx.data(ChatLineModel::DisplayRole).toString();
            if(displayBubble) displayTrayIconMessage(title, text);
  #   ifdef HAVE_DBUS
!           if(displayDesktop) sendDesktopNotification(title, text, bufId);
  #   endif
          }
          if(uiSettings.value("AnimateTrayIcon", QVariant(true)).toBool()) {
***************
*** 618,639 ****
  Using the notification-daemon from Freedesktop's Galago project
  http://www.galago-project.org/specs/notification/0.9/x408.html#command-notify
  */
! void MainWin::sendDesktopNotification(const QString &title, const QString &message) {
    QStringList actions;
    QMap<QString, QVariant> hints;
    UiSettings uiSettings;
  
    hints["x"] = uiSettings.value("NotificationDesktopHintX", QVariant(0)).toInt(); // Standard hint: x location for the popup to show up
    hints["y"] = uiSettings.value("NotificationDesktopHintY", QVariant(0)).toInt(); // Standard hint: y location for the popup to show up
  
!   actions << "click" << "Click Me!";
  
    QDBusReply<uint> reply = desktopNotifications->Notify(
                  "Quassel", // Application name
                  notificationId, // ID of previous notification to replace
!                 "", // Icon to display
                  title, // Summary / Header of the message to display
!                 QString("%1: %2:\n%3").arg(QTime::currentTime().toString()).arg(title).arg(message), // Body of the message to display
                  actions, // Actions from which the user may choose
                  hints, // Hints to the server displaying the message
                  uiSettings.value("NotificationDesktopTimeout", QVariant(5000)).toInt() // Timeout in milliseconds
--- 618,646 ----
  Using the notification-daemon from Freedesktop's Galago project
  http://www.galago-project.org/specs/notification/0.9/x408.html#command-notify
  */
! void MainWin::sendDesktopNotification(const QString &title, const QString &message, const BufferId &bufId) {
    QStringList actions;
    QMap<QString, QVariant> hints;
    UiSettings uiSettings;
  
+ /* Commenting out the following: Don't send hints, let notify daemon decide
    hints["x"] = uiSettings.value("NotificationDesktopHintX", QVariant(0)).toInt(); // Standard hint: x location for the popup to show up
    hints["y"] = uiSettings.value("NotificationDesktopHintY", QVariant(0)).toInt(); // Standard hint: y location for the popup to show up
+ */
+ 
+   actions << QVariant(bufId.toInt()).toString() << "Show Buffer";
  
!   QStringList desktopCapabilities = desktopNotifications->GetCapabilities();
!   QString msg = QString("%1: %2:\n%3").arg(QTime::currentTime().toString()).arg(title).arg(message);
!   if(desktopCapabilities.contains("body-markup"))
! 	  msg = Qt::escape(msg);
  
    QDBusReply<uint> reply = desktopNotifications->Notify(
                  "Quassel", // Application name
                  notificationId, // ID of previous notification to replace
!                 "quassel", // Icon to display
                  title, // Summary / Header of the message to display
!                 msg, // Body of the message to display
                  actions, // Actions from which the user may choose
                  hints, // Hints to the server displaying the message
                  uiSettings.value("NotificationDesktopTimeout", QVariant(5000)).toInt() // Timeout in milliseconds
***************
*** 660,667 ****
  
  
  void MainWin::desktopNotificationInvoked(uint id, const QString & action) {
!   Q_UNUSED(id); Q_UNUSED(action);
!   // qDebug() << "OID: " << notificationId << " ID: " << id << " Action: " << action << " Time: " << QTime::currentTime().toString();
  }
  
  #endif /* HAVE_DBUS */
--- 667,690 ----
  
  
  void MainWin::desktopNotificationInvoked(uint id, const QString & action) {
!   Q_UNUSED(id); //Q_UNUSED(action);
!   qDebug() << "OID: " << notificationId << " ID: " << id << " Action: " << action << " Time: " << QTime::currentTime().toString();
!   show();
!   if(isMinimized()) {
!     if(isMaximized())
!       showMaximized();
!     else
!       showNormal();
!   }
! 
!   raise();
!   activateWindow();
! 
!   QModelIndex source_bufferIdx = Client::networkModel()->bufferIndex(QVariant(action).toInt());
!   QModelIndex bufferIdx = Client::bufferModel()->mapFromSource(source_bufferIdx);
! 
!   if(bufferIdx.isValid())
!     Client::bufferModel()->standardSelectionModel()->setCurrentIndex(bufferIdx, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
  }
  
  #endif /* HAVE_DBUS */
