Active Topics

 


Reply
Thread Tools
EmaNymton's Avatar
Posts: 141 | Thanked: 267 times | Joined on May 2010 @ Germany
#1
Hi,
first of all, I'm not an expert using dbus but I wonder, if it is possible to use dbus to show messages on the event-screen of sailfish like on the N9. I started with dbus-monitor and logged for example an incoming email notification:
Code:
...
method call sender=:1.33 -> dest=org.freedesktop.Notifications serial=1070 path=/org/freedesktop/Notifications; interface=org.freedesktop.Notifications; member=Notify
   string "messageserver5"
   uint32 0
   string ""
   string "MY_NAME"
   string "HEADER_OF_MAIL"
   array [
      string "default"
      string ""
   ]
   array [
      dict entry(
         string "x-nemo.email.published-messages"
         variant             string "1400"
      )
      dict entry(
         string "category"
         variant             string "x-nemo.email"
      )
      dict entry(
         string "x-nemo-item-count"
         variant             int32 1
      )
      dict entry(
         string "x-nemo-timestamp"
         variant             string "2014-01-07T19:38:53Z"
      )
      dict entry(
         string "x-nemo-preview-body"
         variant             string "HEADER_OF_MAIL"
      )
      dict entry(
         string "x-nemo-remote-action-default"
         variant             string "com.jolla.email.ui /com/jolla/email/ui com.jolla.email.ui openMessage AAAAAgAAAAV4"
      )
      dict entry(
         string "x-nemo-preview-summary"
         variant             string "MY_NAME"
      )
   ]
   int32 -1
...
So I tried to send a notification via dbus-send
Code:
dbus-send --dest=org.freedesktop.Notifications --print-reply /org/freedesktop/Notifications org.freedesktop.Notifications.Notify string:"" uint32:0 string:"" string:"summary" string:"body"
Error org.freedesktop.DBus.Error.UnknownMethod: No such method 'Notify' in interface 'org.freedesktop.Notifications' at object path '/org/freedesktop/Notifications' (signature 'susss')


The error message is weird, because Notify is a known method
Code:
[nemo@localhost ~]$ dbus-send --session --type=method_call --print-reply --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.DBus.Introspectable.Introspect
method return sender=:1.29 -> dest=:1.807 reply_serial=2
   string "<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
  <interface name="org.freedesktop.Notifications">
    <method name="GetCapabilities">
      <arg direction="out" type="as" name="capabilities"/>
    </method>
<method name="Notify">
      <arg direction="in" type="s" name="app_name"/>
      <arg direction="in" type="u" name="replaces_id"/>
      <arg direction="in" type="s" name="app_icon"/>
      <arg direction="in" type="s" name="summary"/>
      <arg direction="in" type="s" name="body"/>
      <arg direction="in" type="as" name="actions"/>
      <arg direction="in" type="a{sv}" name="hints"/>
      <arg direction="in" type="i" name="expire_timeout"/>
      <arg direction="out" type="u" name="id"/>
      <annotation value="QVariantHash" name="org.qtproject.QtDBus.QtTypeName.In6"/>
    </method>
    <method name="CloseNotification">
      <arg direction="in" type="u" name="id"/>
    </method>
    <method name="GetServerInformation">
      <arg direction="out" type="s"/>
      <arg direction="out" type="s" name="name"/>
      <arg direction="out" type="s" name="vendor"/>
      <arg direction="out" type="s" name="version"/>
    </method>
    <signal name="NotificationClosed">
      <arg type="u" name="id"/>
      <arg type="u" name="reason"/>
    </signal>
    <signal name="ActionInvoked">
      <arg type="u" name="id"/>
      <arg type="s" name="action_key"/>
    </signal>
    <method name="GetNotifications">
      <arg direction="in" type="s" name="app_name"/>
      <arg direction="out" type="a(sussasa{sv}i)" name="notifications"/>
      <annotation value="NotificationList" name="org.qtproject.QtDBus.QtTypeName.Out0"/>
    </method>
  </interface>
  <interface name="org.freedesktop.DBus.Properties">
    <method name="Get">
      <arg name="interface_name" type="s" direction="in"/>
      <arg name="property_name" type="s" direction="in"/>
      <arg name="value" type="v" direction="out"/>
    </method>
    <method name="Set">
      <arg name="interface_name" type="s" direction="in"/>
      <arg name="property_name" type="s" direction="in"/>
      <arg name="value" type="v" direction="in"/>
    </method>
    <method name="GetAll">
      <arg name="interface_name" type="s" direction="in"/>
      <arg name="values" type="a{sv}" direction="out"/>
      <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantMap"/>
    </method>
  </interface>
  <interface name="org.freedesktop.DBus.Introspectable">
    <method name="Introspect">
      <arg name="xml_data" type="s" direction="out"/>
    </method>
  </interface>
  <interface name="org.freedesktop.DBus.Peer">
    <method name="Ping"/>
    <method name="GetMachineId">
      <arg name="machine_uuid" type="s" direction="out"/>
    </method>
  </interface>
</node>
"
What am I doing wrong?
 

The Following 11 Users Say Thank You to EmaNymton For This Useful Post:
pycage's Avatar
Posts: 3,404 | Thanked: 4,474 times | Joined on Oct 2005 @ Germany
#2
You can use the notification framework from Nemo (also has easy-to-use QML bindings).
Using D-Bus directly is of course possible as well, but a bit harder.
__________________
Tidings - RSS and Podcast aggregator for Jolla - https://github.com/pycage/tidings
Cargo Dock - file/cloud manager for Jolla - https://github.com/pycage/cargodock
 

The Following 5 Users Say Thank You to pycage For This Useful Post:
javispedro's Avatar
Posts: 2,355 | Thanked: 5,249 times | Joined on Jan 2009 @ Barcelona
#3
Originally Posted by EmaNymton View Post
What am I doing wrong?
That error is also generated even if the method exists but you call it with the wrong number of arguments or the wrong types for the arguments (this is because D-Bus supports Polimorphism).

You might want to read the following thread:
https://bbs.archlinux.org/viewtopic.php?id=114632

As far as I know Sailfish uses the standard "Freedesktop" notification interface, which means it is the same that is used on Gnome, KDE, and other GNU/Linux desktop environments (finally!). This means that any examples designed for those environments should work in your Jolla device, too.
In desktop environments the "notify-send" program can be used to send the appropiate D-Bus calls, too.
 

The Following 8 Users Say Thank You to javispedro For This Useful Post:
EmaNymton's Avatar
Posts: 141 | Thanked: 267 times | Joined on May 2010 @ Germany
#4
Thank you for your answers!

I got a simple script working with python-dbus.

After a little research on the web, it seems that dbus-sent does not permit empty containers or nested containers (e.g. arrays of variants), what Notify needs as arguments.
Because I wanted this to write with a python script anyway I gave python-dbus a try, so here it is:
Code:
#!/usr/bin/python
import dbus

bus = dbus.SessionBus()
object = bus.get_object('org.freedesktop.Notifications','/org/freedesktop/Notifications')
interface = dbus.Interface(object,'org.freedesktop.Notifications')
#print(interface.GetCapabilities())

interface.Notify("app_name",
                 0,
                 "/usr/share/icons/hicolor/86x86/apps/harbour-tidings.png",
                 "Here is the title",
                 "and here the body",
                 dbus.Array(),
                 dbus.Array(),
                 0)
If you set the icon-path it shows the notification on the event screen and the icon on the lock screen.


Last edited by EmaNymton; 2014-01-08 at 08:53.
 

The Following 20 Users Say Thank You to EmaNymton For This Useful Post:
kimmoli's Avatar
Posts: 562 | Thanked: 2,744 times | Joined on Dec 2013 @ Espoo, Finland
#5
Originally Posted by EmaNymton View Post
...dbus-sent does not permit...
It doesn't permit null interface either...

I made my own dbus server, and tried to test it with dbus-send... adding interface to the server and it works.

Thanks for the script, i'll try this from the qt/QML side next.
 

The Following 2 Users Say Thank You to kimmoli For This Useful Post:
Posts: 84 | Thanked: 79 times | Joined on Dec 2013
#6
Thanks for that. I've just started tinkering with dbus on Jolla, and it's nice to see some simple examples.
 

The Following User Says Thank You to evk For This Useful Post:
kimmoli's Avatar
Posts: 562 | Thanked: 2,744 times | Joined on Dec 2013 @ Espoo, Finland
#7

dbus-monitor can show nice things
Code:
signal sender=:1.198 -> dest=(null destination) serial=590 path=/org/freedesktop/Telepathy/Connection/gabble/jabber/gmail_2ecom_1a4623dead_5f0xdabeef; interface=org.freedesktop.Telepathy.Connection.Interface.SimplePresence; member=PresencesChanged
   array [
      dict entry(
         uint32 21
         struct {
            uint32 3
            string "away"
            string "Hell yeah!!!

"
         }
      )
   ]
and also shows your passwords in plain text
Code:
signal sender=:1.433 -> dest=(null destination) serial=12 path=/com/google/code/AccountsSSO/SingleSignOn/AuthSession_0; interface=com.google.code.AccountsSSO.SingleSignOn.AuthSession; member=stateChanged
   int32 8
   string "The request is started successfully"
method return sender=:1.433 -> dest=:1.34 reply_serial=848
   array [
      dict entry(
         string "Secret"
         variant             string "plaintextpassword"
      )
      dict entry(
         string "UserName"
         variant             string "youmightquessthisone"
      )
   ]
 

The Following 2 Users Say Thank You to kimmoli For This Useful Post:
EmaNymton's Avatar
Posts: 141 | Thanked: 267 times | Joined on May 2010 @ Germany
#8
Ok, now with working pop up notification and using jolla icons placed in /usr/share/themes/jolla-ambient/meegotouch/icons/



Code:
#!/usr/bin/python
import dbus

bus = dbus.SessionBus()
object = bus.get_object('org.freedesktop.Notifications','/org/freedesktop/Notifications')
interface = dbus.Interface(object,'org.freedesktop.Notifications')
#print(interface.GetCapabilities())

interface.Notify("app_name",
                 0,
                 "icon-m-notifications",
                 "Here is the title",
                 "and here the body",
                 dbus.Array(["default", ""]),
                 dbus.Dictionary({"x-nemo-preview-body": "preview body",
                                  "x-nemo-preview-summary": "preview summary"},
                                  signature='sv'),
                 0)

Last edited by EmaNymton; 2014-01-08 at 10:30.
 

The Following 10 Users Say Thank You to EmaNymton For This Useful Post:
kimmoli's Avatar
Posts: 562 | Thanked: 2,744 times | Joined on Dec 2013 @ Espoo, Finland
#9
crap... How i can cast uint32 inside QML ...
 
Posts: 80 | Thanked: 51 times | Joined on Feb 2010 @ Finland
#10
Does anyone know if there is possibility to add sounds for those notifications? Or should that been added seperately?

I'm testing notifications to tell when Sauna is ready

Last edited by junnuvi; 2014-01-08 at 20:47.
 
Reply


 
Forum Jump


All times are GMT. The time now is 08:52.