maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   General (https://talk.maemo.org/forumdisplay.php?f=7)
-   -   change bluetooth device class from QT app using bluez (https://talk.maemo.org/showthread.php?t=63245)

anistein 2010-10-02 13:10

change bluetooth device class from QT app using bluez
 
Hi

I'm writing an app in Qt using NokiaQtSDK to make the n900 become a handsfree device.

I need to call the bluez function to change the device class but it required that my application have superuser access (root access).

What's the best way to achieve this?

MohammadAG 2010-10-02 13:42

Re: change bluetooth device class from QT app using bluez
 
Add a file in /etc/sudoers.d/ (take a look at the files there, there are a lot of examples :))
then execute update-sudoers in your postinst and postrm files.

After that you can just use sudo.

anistein 2010-10-02 14:07

Re: change bluetooth device class from QT app using bluez
 
Quote:

Originally Posted by MohammadAG (Post 831595)
Add a file in /etc/sudoers.d/ (take a look at the files there, there are a lot of examples :))
then execute update-sudoers in your postinst and postrm files.

After that you can just use sudo.

Thanks for your response, I don't know the exact mechanics but i'll look into it. Progress :)

anistein 2010-10-02 14:15

Re: change bluetooth device class from QT app using bluez
 
Quote:

Originally Posted by MohammadAG (Post 831595)
Add a file in /etc/sudoers.d/ (take a look at the files there, there are a lot of examples :))
then execute update-sudoers in your postinst and postrm files.

After that you can just use sudo.

What is the command for update-sudoers?

MohammadAG 2010-10-02 14:17

Re: change bluetooth device class from QT app using bluez
 
update-sudoers :p

Code:

#!/bin/sh

update-sudoers
exit 0

Sample .sudoers file
Code:

Nokia-N900:~# cat /etc/sudoers.d/psfreedom.sudoers
user ALL = NOPASSWD: /usr/sbin/psfreedom-disable-n900.sh
user ALL = NOPASSWD: /usr/sbin/psfreedom-enable-n900.sh
user ALL = NOPASSWD: /opt/psfreedom/resources/helpimages/modelimages.sh
user ALL = NOPASSWD: /opt/psfreedom/resources/scripts/helperscript.sh


anistein 2010-10-02 14:43

Re: change bluetooth device class from QT app using bluez
 
Quote:

Originally Posted by MohammadAG (Post 831620)
update-sudoers :p

Code:

#!/bin/sh

update-sudoers
exit 0

Sample .sudoers file
Code:

Nokia-N900:~# cat /etc/sudoers.d/psfreedom.sudoers
user ALL = NOPASSWD: /usr/sbin/psfreedom-disable-n900.sh
user ALL = NOPASSWD: /usr/sbin/psfreedom-enable-n900.sh
user ALL = NOPASSWD: /opt/psfreedom/resources/helpimages/modelimages.sh
user ALL = NOPASSWD: /opt/psfreedom/resources/scripts/helperscript.sh


Thanks for the response again.
I studied the bluemaemo project source because it uses this sort of mechanism. It uses the debian rules file to copy the .sudoers file into the directory.

MohammadAG 2010-10-02 14:46

Re: change bluetooth device class from QT app using bluez
 
Yeah, you need to install it in /etc/sudoers.d as I said above, I use debian/install and dh_install in debian/rules (which is cleaner imo), see the source of psfreedom

anistein 2010-10-02 17:20

Re: change bluetooth device class from QT app using bluez
 
Quote:

Originally Posted by MohammadAG (Post 831634)
Yeah, you need to install it in /etc/sudoers.d as I said above, I use debian/install and dh_install in debian/rules (which is cleaner imo), see the source of psfreedom

On last question: How can I test it on the device using the NokiaQtSDK connection to the device? Is there a place I can modify the automatically generate rules file before it's generated?

MohammadAG 2010-10-02 18:09

Re: change bluetooth device class from QT app using bluez
 
Hmm, I think you need to edit the .pro file, when I'm done with a C++ app I usually just take it out of the SDK.

See facebrick's .pro file (from it's source)


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

vBulletin® Version 3.8.8