1 #include <libprofile.h> // knihovna pro přípojení k profile deamonu
2 #include <QtCore/QDebug> //Debug pro informace
3 #include "profiledeamon.h"
9 ProfileDeamon::ProfileDeamon(QObject *parent) :
17 ProfileDeamon::~ProfileDeamon()
20 profile_tracker_quit();
24 Connect to profile deamon
29 dbus_message_new_signal ( const char * path,
30 const char * interface,
35 path the path to the object emitting the signal
36 interface the interface the signal is emitted from
37 name name of the signal
40 static const char* CALENDAR_DBUS_LISTENER_SERVICE = "com.nokia.calendar";
41 static const char* CALENDAR_DBUS_OBJECT_PATH = "/com/nokia/calendar";
42 static const char* CALENDAR_DBUS_LISTENER_SIGNAL = "dbChange";
44 dbusMessage = dbus_message_new_signal(CALENDAR_DBUS_OBJECT_PATH,
45 CALENDAR_DBUS_LISTENER_SERVICE,
46 CALENDAR_DBUS_LISTENER_SIGNAL);
50 #define PROFILED_SERVICE "com.nokia.profiled"
51 #define PROFILED_PATH "/com/nokia/profiled"
52 #define PROFILED_INTERFACE "com.nokia.profiled"
53 #define PROFILED_CHANGED "profile_changed
56 bool QDBusConnection::connect ( const QString & service, const QString & path, const QString & interface,
57 const QString & name, QObject * receiver, const char * slot )
61 connect to profiled deamon
63 bool ProfileDeamon::ConnectToDeamon()
66 profile_connection_enable_autoconnect(); // nastavím
68 if((a = profile_tracker_init()) != 0){
69 //qDebug() << "In file:" << __FILE__ << ":" << "on line:" << __LINE__ << " in function:" << __FUNCTION__ << "text::" << "cannot connect to deamon";
72 //profile_track_add_active_cb(profileTrack, NULL, unlo );
73 //qDebug() << "In file:" << __FILE__ << ":" << "on line:" << __LINE__ << " in function:" << __FUNCTION__ << "text::" << "connected to deamon";
74 // QDBusConnection con = QDBusConnection::connectToBus(QDBusConnection::SessionBus,QString("muj"));
76 //if(con.isConnected()) //qDebug() << "In file:" << __FILE__ << ":" << "on line:" << __LINE__ << " in function:" << __FUNCTION__ << "text::" << "neeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee pripojen";
80 /** SetProfile( Profil * profil)
82 \param profil reference to an object with the data profile
84 bool ProfileDeamon::SetProfile( Profil * profil)
87 //list of all the values in the profile
88 QList<ProfileValue *>* p_profile_values = profil->ListOfValues();
89 //qDebug() << "In file:" << __FILE__ << ":" << "on line:" << __LINE__ << " in function:" << __FUNCTION__ << "text::" << "nastavuji:";
90 for (int i = 0; i < p_profile_values->size(); ++i) {
92 if(p_profile_values->at(i)->type.contains("SOUNDFILE"))//kdyz je proměnná text
94 // qDebug() << __FILE__ << ":" << __LINE__ << " " << __FUNCTION__ << "nastavuji:" << p_profile_values->at(i)->key << "hodnota " << p_profile_values->at(i)->value.toString();
95 if(profile_set_value("general", p_profile_values->at(i)->key.toLatin1().data(), p_profile_values->at(i)->value.toString().toLatin1().data()) == -1){
98 }else if(p_profile_values->at(i)->type.contains("BOOLEAN"))//kdyz je proměnná bool
100 //qDebug() << __FILE__ << ":" << __LINE__ << " " << __FUNCTION__ << "nastavuji:" << p_profile_values->at(i)->key;
101 if(profile_set_value_as_bool("general", p_profile_values->at(i)->key.toLatin1().data(), p_profile_values->at(i)->value.toBool()) == -1){
104 }else if(p_profile_values->at(i)->type.contains("INTEGER"))//kdyz je proměnná int
106 //qDebug() << __FILE__ << ":" << __LINE__ << " " << __FUNCTION__ << "nastavuji:" << p_profile_values->at(i)->key;
107 if(profile_set_value_as_int("general", p_profile_values->at(i)->key.toLatin1().data(), p_profile_values->at(i)->value.toInt()) == -1){
110 }else if(p_profile_values->at(i)->type.contains("STRING"))//kdyz je proměnná text
112 //qDebug() << __FILE__ << ":" << __LINE__ << " " << __FUNCTION__ << "nastavuji:" << p_profile_values->at(i)->key;
113 if(profile_set_value("general", p_profile_values->at(i)->key.toLatin1().data(), p_profile_values->at(i)->value.toString().toLatin1().data()) == -1){
121 /** GetProfile(QString profil_name)
122 Return profile (general a silent)
123 \param profil_name Profile Name
125 Profil ProfileDeamon::GetProfile(QString profil_name)
127 Profil profil(profil_name);
128 //qDebug() << "In file:" << __FILE__ << ":" << "on line:" << __LINE__ << " in function:" << __FUNCTION__ << "text::" << "Get profile from deamon";
129 profileval_t* data_profile = profile_get_values(profil_name.toLatin1().data());
130 for(int i = 0; i < 15; i++)
133 //qDebug() << "|->>>klic: " << data_profile[i].pv_key ;
134 //qDebug() << "|->>>hodnota: " << data_profile[i].pv_val ;
135 //qDebug() << "|->>>typ: " << data_profile[i].pv_type ;
136 //deamon return bool value on or off
137 if(data_profile[i].pv_type == QString("BOOLEAN")){
138 if(data_profile[i].pv_val == QString("On")){
139 profil.SetValue(data_profile[i].pv_key, "1");
141 profil.SetValue(data_profile[i].pv_key, "0");
144 profil.SetValue(data_profile[i].pv_key, data_profile[i].pv_val);
148 profile_free_values(data_profile);
149 //qDebug() << "In file:" << __FILE__ << ":" << "on line:" << __LINE__ << " in function:" << __FUNCTION__ << "text::" << "return from getprofile";