maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   Accessing contacts from daemon (in Qt) (https://talk.maemo.org/showthread.php?t=63696)

kif 2010-10-11 21:56

Accessing contacts from daemon (in Qt)
 
Hi

I'm trying to access the contacts from a daemon (using Qt), but whenever i try to create an instance of QContactManager the daemon exits.

My rutines works in a test program, but not in the daemon.

Any ideas what is wrong, and how to solve it ?

Could it be because the daemon is running as root ?

Thanks

eitama 2010-10-11 22:17

Re: Accessing contacts from daemon (in Qt)
 
Quote:

Originally Posted by kif (Post 838776)
Hi

I'm trying to access the contacts from a daemon (using Qt), but whenever i try to create an instance of QContactManager the daemon exits.

My rutines works in a test program, but not in the daemon.

Any ideas what is wrong, and how to solve it ?

Could it be because the daemon is running as root ?

Thanks

As far as I know the Qt Api requires user permissions. To debug out better maybe you can use gdb.

kif 2010-10-11 22:42

Re: Accessing contacts from daemon (in Qt)
 
I had an feeling it could be something like that, how do I make a daemon run with user permissions ?

Kim

eitama 2010-10-12 06:41

Re: Accessing contacts from daemon (in Qt)
 
Quote:

Originally Posted by kif (Post 838806)
I had an feeling it could be something like that, how do I make a daemon run with user permissions ?

Kim

Try running it with "runstandalone.sh <scriptName>"
I just guessing though, never wrote a deamon.

kif 2010-10-12 09:35

Re: Accessing contacts from daemon (in Qt)
 
It runs without any problems as user, but I need it to run automatically at startup.

Does anyone know how to start a daemon with user permissions from an event.d script ?

Kim.

nicolai 2010-10-12 09:55

Re: Accessing contacts from daemon (in Qt)
 
The problem isn't root or user permission but the
dbus session.
To access users contacts you need the correct
user dbus session.
You may look at other programs like headphoned how to
connect/setup sessionbus.

nicolai

kif 2010-11-17 20:55

Re: Accessing contacts from daemon (in Qt)
 
Hi nicolai

Thanks for your answer, and sorry for the long delay, I was busy elsewhere.

I have had a long hard look at headphoned and other daemon projects, and as far as I can see all it requires to get the dbus session address is to execute /tmp/session_bus_address.user to export the dbus address before starting my daemon.

Unfortunatly that didn't help.

Any other ideas, I have an almost finished daemon, I just need this to make it usable ;)

Kim

nicolai 2010-11-18 11:35

Re: Accessing contacts from daemon (in Qt)
 
Any hints what happens when your daemon creates the QContactManager?
Some logging output in /var/log/syslog?

Maybe your daemon starts too early.
I don't know anything about the internals of QContactManager. But
I think it doesn't only needs a sessionbus connection but
the contacts backend (osso-addressbook and evolution) must be
running and be available through dbus, as well.

nicolai

kif 2010-11-18 19:27

Re: Accessing contacts from daemon (in Qt)
 
No sorry, nothing in any log file.

I have placed some debug logging in the code and it is at this line the daemon exits :

QContactManager *m_manager = new QContactManager();

If I start the daemon as user in xterminal everything works as planned.

If I start the daemon as root in xterminal, the daemon starts, but the moment a call is registered, and the daemon try to find the phone number in contacts it exits (same result when the daemon is started at boot) !

I have tried to log the enviroment variables, and in both cases DBUS_SESSION_BUS_ADDRESS has the same value !

Kim.

nicolai 2010-11-18 19:57

Re: Accessing contacts from daemon (in Qt)
 
Quote:

Originally Posted by kif (Post 877320)
No sorry, nothing in any log file.

Do you have sysklogd installed?

Nicolai


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

vBulletin® Version 3.8.8