maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   [Solved] How to detect phone call - C++ only (https://talk.maemo.org/showthread.php?t=64161)

Laethnes 2010-10-21 15:03

[Solved] How to detect phone call - C++ only
 
I know this was solved here a few times, but I really didn't find, what I need.

We are working on a new application, it has to be in C++ and it has to use Qt (it's not like I complain :3), so I can not use python solution. Our application needs to know when someone calls, when it's received, when it's refused, when call is started from users side and when it ends. And it have to work under Maemo and also under MeeGo. When I wrote "call" I mean "phone call", like in N900. I found that I should use QtDBus, Dbus or telepathy-ring, but I was unable to find any example nor tutorial.

So, do anyone know about this? Thanks in advance :)

noobmonkey 2010-10-21 15:33

Re: How to detect phone call - C++ only
 
I'm not going to be much help as i'm still at work but...

You need to find the dbus command to identify when the phone is being called.
Then look for a C++ Dbus call ( C example here - http://people.collabora.co.uk/~tthur...tle/sand.c.txt )

Translate your dbus call into the code :)
(But yes QtDbus will work - you just need to find the dbus commands!)

bonapart 2010-10-21 16:25

Re: How to detect phone call - C++ only
 
QDBusConnection::systemBus().connect(QString(), "/com/nokia/csd/call", "com.nokia.csd.Call", "Coming", this, SLOT(callEvent(QString,QString)));

uvatbc 2010-10-21 16:34

Re: How to detect phone call - C++ only
 
Quote:

Originally Posted by Laethnes (Post 847197)
I know this was solved here a few times, but I really didn't find, what I need.

We are working on a new application, it has to be in C++ and it has to use Qt (it's not like I complain :3), so I can not use python solution. Our application needs to know when someone calls, when it's received, when it's refused, when call is started from users side and when it ends. And it have to work under Maemo and also under MeeGo. When I wrote "call" I mean "phone call", like in N900. I found that I should use QtDBus, Dbus or telepathy-ring, but I was unable to find any example nor tutorial.

So, do anyone know about this? Thanks in advance :)

You will need to write an telepathy observer class.
I have used QT and telepathy-qt4 in my code.
My Observer class is derived from the telepathy-qt4 Abstract Observer class.

The function of interest is Tp::AbstractClientObserver:: observeChannels, which you need to derive.

Laethnes 2010-10-22 06:30

Re: How to detect phone call - C++ only
 
Yay, thank you very much!

It looks that QtDBus is exactly what we need and looks also simplest. (I guess I was little confused with using dbus commands with QtDBus.)

If it won't work, I'll look at the others, but I would like to use simplest solution :3.

But I have one more question; do you know some reference, list of dbus commands? I tried Google, found many about SMS, making calls, setting profiles etc., but I also need detect when outgoing call occures and when call (in and also out) ends.

Thank you very much for your help :)

twaelti 2010-10-22 06:54

Re: How to detect phone call - C++ only
 
Take a look at my Recaller sourcecode (even if it is in Python); I listen to most of the commands you're interested in.
You could also use MDbus2 or D-Feet and observe the D-Bus while making some calls, either install locally or do like this.

Laethnes 2010-10-22 07:11

Re: How to detect phone call - C++ only
 
Yay, thank you very much, there is everything we need... I hope :3.

MohammadAG 2010-10-22 07:32

Re: How to detect phone call - C++ only
 
MeeGo isn't using telepathy-ring, so I think you may have to use a different DBus path for it.

benlau 2010-10-22 07:34

Re: How to detect phone call - C++ only
 
Quote:

Originally Posted by Laethnes (Post 847717)
Yay, thank you very much!

It looks that QtDBus is exactly what we need and looks also simplest. (I guess I was little confused with using dbus commands with QtDBus.)

If it won't work, I'll look at the others, but I would like to use simplest solution :3.

But I have one more question; do you know some reference, list of dbus commands? I tried Google, found many about SMS, making calls, setting profiles etc., but I also need detect when outgoing call occures and when call (in and also out) ends.

Thank you very much for your help :)

Code:

dbus-send --print-reply --dest=com.nokia.csd.Call /com org.freedesktop.DBus.Introspectable.Introspect
It will show the interface available of the object. Change the path (the /com) will show more information.

uvatbc 2010-10-22 07:50

Re: How to detect phone call - C++ only
 
Quote:

Originally Posted by MohammadAG (Post 847742)
MeeGo isn't using telepathy-ring, so I think you may have to use a different DBus path for it.

I didn't understand: Do you mean "com.nokia.csd.Call" will no longer be present in Meego or are you saying Meego will no longer use a telepathy CM for GSM calls?

MohammadAG 2010-10-22 08:08

Re: How to detect phone call - C++ only
 
Quote:

Originally Posted by uvatbc (Post 847754)
I didn't understand: Do you mean "com.nokia.csd.Call" will no longer be present in Meego or are you saying Meego will no longer use a telepathy CM for GSM calls?

The path will probably be different, yes.
telepathy-ring is closed source, so they're definitely using something else.
You could ask in #meego on Freenode.

Laethnes 2010-10-22 09:01

Re: How to detect phone call - C++ only
 
Ok, so
- On N900, Maemo, it doesn't work. By "doesn't work" I mean that slots connected to dbus are never called.
- I tried dbus-send ... Introspect and it says that name com.nokia wasn't provided

So from that and from what you wrote it seems this is not right/working way. So
- I have to find other dbus paths, if I want to use dbus (QtDBus)
- telepathy-qt4 can not be used, if I understand you correctly
- or find something else (oFono)

Am I right?

EDIT:

I tried monitor dbus (dbus-monitor > watch.txt) and found some dbus addresses, but they're "org.freedesktop.Telepathy..." - so I can't use them, if I understand you right, because it works with telepathy which is not on meego...

noobmonkey 2010-10-22 09:20

Re: How to detect phone call - C++ only
 
well, Mo is right, but theres no reason you can't use the telepathy ones now and than add the meego ones later when you know them?

As you can run code depending on what device it is being run on :) (Mo taught me that one!!)

Laethnes 2010-10-22 09:23

Re: How to detect phone call - C++ only
 
Yeah - you're totally right :3. I didn't realize, but I can create one class watching it and sending right signals and replace it when needed :3.

Laethnes 2010-10-22 13:39

Re: How to detect phone call - C++ only
 
Hm, can I ask you for link to some simple tutorial explicating what everything in observeChannels method from TelepathyQt4 means? I read your examples and examples from internet over and over again and I just can't get it. I can understand, what the code does, but I can not understand it as a whole, to use it way we need. API doesn't help me too.

Or, we consider using oFone. But again, I can not find anything helping me how to use it. I just found 3 messages to DBus which we don't need. So if there is no solution to problem above, do you, please, know some simple tutorial about this?

Laethnes 2010-10-25 08:41

Re: How to detect phone call - C++ only
 
EDIT:
I'm sorry, I finally found the problem - I didn't keep registrar pointer and it was just a local variable.


Original post:
Ok, I wrote simple example application based on your (uvatbc - http://talk.maemo.org/showpost.php?p=847272&postcount=4) application to learn how it works and I would like to ask you for help, because it's not working.

- I changed filter to TELEPATHY_INTERFACE_CHANNEL_TYPE_STREAMED_MEDIA
- I check, if ClientRegistrar::registerClient returns true and It does
- but method observeChannels is not called, when I dial and call a number
- I don't know how to check if my class is correctly registered
- Using dbus-monitor (redirect to file) I know that signals from telepathy-qt4 are sent and they are marked with StreamedMedia type.

So maybe I did something wrong and/or missed something.
- At the start of application, I create my class based on AbstractClientObserver and insert filter
- Then I connect its Log signal with my ui class Log slot showing informations
- Then I register it with ClientRegistrar
- registerClient returns true - it's shown in ui class through log system

Laethnes 2010-10-25 13:18

Re: How to detect phone call - C++ only
 
Ok, again problem. Sorry.

This time it is detecting end of call - from API I found method status() in class Connection and signal statusChanged(), but status() always returns StatusUnknown and statusChanged is never emited. Am I looking at the wrong place?

manjiri 2010-11-18 12:13

Re: How to detect phone call - C++ only
 
Quote:

Originally Posted by Laethnes (Post 850376)
Ok, again problem. Sorry.

This time it is detecting end of call - from API I found method status() in class Connection and signal statusChanged(), but status() always returns StatusUnknown and statusChanged is never emited. Am I looking at the wrong place?


Could you paste the actual code you are using to detect end /start of a call?

Laethnes 2010-11-20 07:48

Re: How to detect phone call - C++ only
 
Quote:

Originally Posted by manjiri (Post 876987)
Could you paste the actual code you are using to detect end /start of a call?

Eh, I'm sorry, but now it will be impossible, because at start of the project, we committed it (svn) poorly and we replaced it with some other code which colleague founded somewhere.

Laethnes 2011-04-29 09:01

Re: How to detect phone call - C++ only
 
Note; I'm using now telepathy observer and it works fine. (Btw. about that status: I don't know where problem is, but it gives non-reliable info to me, but I found other way.)

Anyway, thanks everyone


All times are GMT. The time now is 22:25.

vBulletin® Version 3.8.8