maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   Noob to Python and Dbus needs help :) (https://talk.maemo.org/showthread.php?t=74032)

Frickelson 2011-06-15 22:44

Noob to Python and Dbus needs help :)
 
Hi there, i am a bloody beginner when it comes to Python/Dbus :( . I thought the best way to learn something about this is to read a lot about it and then try to code a simple application like i did when i learned java and C#.
But somehow this time it seems to be not that easy to learn just by reading and doing :) - maybe it just looks so complicated because I’ve never used Dbus before? (Python seems to be very easy).
The little application i want to make is something that gets a signal from Dbus if someone is calling and pushes the information’s (name of the caller/phone number…) to my computer where a little server is running that shows a notification and maybe mutes the system sounds. The problem here is not the server side but the „client“ on the n900.

What i’ve found out so far is that I can use dbus-monitor to watch for events. I also read that it’s possible with dbus-scripts to directly start a script by an incoming call but the problem here is that dbus-scripts can’t forward arguments like an array or variant (got that from the wiki page) which are needed for getting the phone number of the caller i think.

After playing with dbus-monitor I think the relevant event is this one:

Code:

signal sender=:1.19 -> dest=(null destination) serial=156 path=/org/freedesktop/Telepathy/Connection/ring/tel/ring; interface=org.freedesktop.Telepathy.Connection.Interface.Requests; member=NewChannels
  array [
      struct {
        object path "/org/freedesktop/Telepathy/Connection/ring/tel/ring/incoming1097983067"
        array [
            dict entry(
              string "org.freedesktop.Telepathy.Channel.InitiatorID"
              variant                  string "0123456789"  <-- phone number here
            )
            dict entry(
              string "org.freedesktop.Telepathy.Channel.TargetHandleType"
              variant                  uint32 1
            )
            dict entry(
              string "org.freedesktop.Telepathy.Channel.TargetHandle"
              variant                  uint32 4
            )
            dict entry(
              string "org.freedesktop.Telepathy.Channel.TargetID"
              variant                  string "0123456789"
            )
            dict entry(
              string "org.freedesktop.Telepathy.Channel.Requested"
              variant                  boolean false
            )
            dict entry(
              string "org.freedesktop.Telepathy.Channel.Type.StreamedMedia.ImmutableStreams"
              variant                  boolean true
            )
            dict entry(
              string "org.freedesktop.Telepathy.Channel.ChannelType"
              variant                  string "org.freedesktop.Telepathy.Channel.Type.StreamedMedia"
            )
            dict entry(
              string "org.freedesktop.Telepathy.Channel.InitiatorHandle"
              variant                  uint32 4
            )
            dict entry(
              string "org.freedesktop.Telepathy.Channel.Interfaces"
              variant                  array [
                    string "org.freedesktop.Telepathy.Channel.Interface.DTMF"
                    string "org.freedesktop.Telepathy.Channel.Interface.Hold"
                    string "com.Nokia.Telepathy.Channel.Interface.DialStrings"
                    string "org.freedesktop.Telepathy.Channel.Interface.Group"
                    string "org.freedesktop.Telepathy.Channel.Interface.CallState"
                    string "com.nokia.Telepathy.Channel.Interface.Emergency"
                    string "com.nokia.Telepathy.Channel.Interface.ConferenceMember"
                  ]
            )
            dict entry(
              string "org.freedesktop.Telepathy.Channel.Type.StreamedMedia.InitialAudio"
              variant                  boolean true
            )
            dict entry(
              string "org.freedesktop.Telepathy.Channel.Type.StreamedMedia.InitialVideo"
              variant                  boolean false
            )
        ]
      }
  ]


So now my question is how is it possible to catch such an event with Python and read the information of it so that I can use it in my program?
I hope someone can point me into the right direction, give me some hints or help me with a little advice so that I can learn a bit and soon be able to do more with the almighty n900…
Any help is much appreciated! :D

Oh and i'm really sorry for my bad english :o

epitaph 2011-06-15 23:53

Re: Noob to Python and Dbus needs help :)
 
Quote:

Originally Posted by Frickelson (Post 1029941)
Hi there, i am a bloody beginner when it comes to Python/Dbus :( . I thought the best way to learn something about this is to read a lot about it and then try to code a simple application like i did when i learned java and C#.
But somehow this time it seems to be not that easy to learn just by reading and doing :) - maybe it just looks so complicated because I’ve never used Dbus before? (Python seems to be very easy).
The little application i want to make is something that gets a signal from Dbus if someone is calling and pushes the information’s (name of the caller/phone number…) to my computer where a little server is running that shows a notification and maybe mutes the system sounds. The problem here is not the server side but the „client“ on the n900.

What i’ve found out so far is that I can use dbus-monitor to watch for events. I also read that it’s possible with dbus-scripts to directly start a script by an incoming call but the problem here is that dbus-scripts can’t forward arguments like an array or variant (got that from the wiki page) which are needed for getting the phone number of the caller i think.

After playing with dbus-monitor I think the relevant event is this one:

Code:

signal sender=:1.19 -> dest=(null destination) serial=156 path=/org/freedesktop/Telepathy/Connection/ring/tel/ring; interface=org.freedesktop.Telepathy.Connection.Interface.Requests; member=NewChannels
  array [
      struct {
        object path "/org/freedesktop/Telepathy/Connection/ring/tel/ring/incoming1097983067"
        array [
            dict entry(
              string "org.freedesktop.Telepathy.Channel.InitiatorID"
              variant                  string "0123456789"  <-- phone number here
            )
            dict entry(
              string "org.freedesktop.Telepathy.Channel.TargetHandleType"
              variant                  uint32 1
            )
            dict entry(
              string "org.freedesktop.Telepathy.Channel.TargetHandle"
              variant                  uint32 4
            )
            dict entry(
              string "org.freedesktop.Telepathy.Channel.TargetID"
              variant                  string "0123456789"
            )
            dict entry(
              string "org.freedesktop.Telepathy.Channel.Requested"
              variant                  boolean false
            )
            dict entry(
              string "org.freedesktop.Telepathy.Channel.Type.StreamedMedia.ImmutableStreams"
              variant                  boolean true
            )
            dict entry(
              string "org.freedesktop.Telepathy.Channel.ChannelType"
              variant                  string "org.freedesktop.Telepathy.Channel.Type.StreamedMedia"
            )
            dict entry(
              string "org.freedesktop.Telepathy.Channel.InitiatorHandle"
              variant                  uint32 4
            )
            dict entry(
              string "org.freedesktop.Telepathy.Channel.Interfaces"
              variant                  array [
                    string "org.freedesktop.Telepathy.Channel.Interface.DTMF"
                    string "org.freedesktop.Telepathy.Channel.Interface.Hold"
                    string "com.Nokia.Telepathy.Channel.Interface.DialStrings"
                    string "org.freedesktop.Telepathy.Channel.Interface.Group"
                    string "org.freedesktop.Telepathy.Channel.Interface.CallState"
                    string "com.nokia.Telepathy.Channel.Interface.Emergency"
                    string "com.nokia.Telepathy.Channel.Interface.ConferenceMember"
                  ]
            )
            dict entry(
              string "org.freedesktop.Telepathy.Channel.Type.StreamedMedia.InitialAudio"
              variant                  boolean true
            )
            dict entry(
              string "org.freedesktop.Telepathy.Channel.Type.StreamedMedia.InitialVideo"
              variant                  boolean false
            )
        ]
      }
  ]


So now my question is how is it possible to catch such an event with Python and read the information of it so that I can use it in my program?
I hope someone can point me into the right direction, give me some hints or help me with a little advice so that I can learn a bit and soon be able to do more with the almighty n900…
Any help is much appreciated! :D

Oh and i'm really sorry for my bad english :o

Did you tried Google and another approach using runstandalone.sh: http://talk.maemo.org/showthread.php?t=56083?


All times are GMT. The time now is 00:36.

vBulletin® Version 3.8.8