1 #include "telephonenumprofile.h"
2 #include "telenumdialog.h"
4 #include <QtCore/QSettings>
5 #include <QtCore/QDebug> //Debug pro informace
6 #include <QtGui/QStandardItemModel>
7 #include <QtGui/QItemSelectionModel>
8 #include <QtDBus/QDBusConnection>
9 #include <QDBusMessage>
10 #include <QtCore/QTimer>
11 #include <QDBusInterface>
12 static const char* CALL_DBUS_SERVICE = "com.nokia.csd.Call";
13 static const char* CALL_DBUS_OBJECT_PATH = "/com/nokia/csd/call/1";
14 static const char* CALL_DBUS_INTERFACE = "com.nokia.csd.Call.Instance";
15 static const char* CALL_DBUS_METHOD = "GetStatus";
17 TelephoneNumProfile::TelephoneNumProfile(QWidget *parent) :
20 //======================================================
21 timer = new QTimer(this);
22 timer->setSingleShot(true);//A single-shot timer fires only once
23 connect(timer,SIGNAL(timeout()),this,SLOT(TimerTimeout()));
24 bool succ = QDBusConnection::systemBus().connect( "", "/com/nokia/csd/call", "com.nokia.csd.Call", "Coming", this, SLOT(receiveCall(const QDBusMessage&)));;
27 //qDebug() << "In file:" << __FILE__ << ":" << "on line:" << __LINE__ << " in function:" << __FUNCTION__ << "text::" << "anooooooooooooooooooooooooooooooooooooooo:";
29 //qDebug() << "In file:" << __FILE__ << ":" << "on line:" << __LINE__ << " in function:" << __FUNCTION__ << "text::" << "neeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee:";
34 Slot for dbus signal for incoming call
35 \param msg msg from d bus
37 void TelephoneNumProfile::receiveCall( const QDBusMessage& msg)
39 // profile_set_value_as_bool("general", "vibrating.alert.enabled", false);
40 //profile_set_value("general", "ringing.alert.type", "silent");
41 // QList<QVariant> lst = msg.arguments();
45 // //qDebug() << "In file:" << __FILE__ << ":" << "on line:" << __LINE__ << " in function:" << __FUNCTION__ << "text::" << "příchozí hovor" << var.toString();
47 //qDebug() << "In file:" << __FILE__ << ":" << "on line:" << __LINE__ << " in function:" << __FUNCTION__ << "text::" << "příchozí hovor";
48 QString profil_name = FindTelnumInModel(msg.arguments().at(1).toString());
49 if(!profil_name.isEmpty()){
50 emit s_telnum_profile(profil_name);
58 void TelephoneNumProfile::TimerTimeout()
60 qDebug() << "In file:" << __FILE__ << ":" << "on line:" << __LINE__ << " in function:" << __FUNCTION__ << "text::" << "timer timeout" ;
62 QDBusConnection systemDbusConnection = QDBusConnection::systemBus();
63 QDBusInterface connectionInterface(CALL_DBUS_SERVICE,
64 CALL_DBUS_OBJECT_PATH,
66 systemDbusConnection);
67 if (!connectionInterface.isValid()) {
68 qWarning() << "Cannotct conect to D-BUS";
71 //poslu zpravu ze chcu info
72 QDBusMessage reply = connectionInterface.call(QLatin1String(CALL_DBUS_METHOD));
73 if (reply.type() == QDBusMessage::ReplyMessage) {
74 QList<QVariant> argList = reply.arguments();
75 // currentCellNetworkStatus = argList.at(INDEX_OF_NEVIM).toInt();
76 foreach(QVariant var, argList)
78 qDebug() << "In file:" << __FILE__ << ":" << "on line:" << __LINE__ << " in function:" << __FUNCTION__ << "text::" << " hodnota :::" << var.toString();
80 if(reply.arguments().at(0).toString() != "0")
82 qDebug() << "In file:" << __FILE__ << ":" << "on line:" << __LINE__ << " in function:" << __FUNCTION__ << "text::" << "nebyl nula" ;
87 qDebug() << "In file:" << __FILE__ << ":" << "on line:" << __LINE__ << " in function:" << __FUNCTION__ << "text::" << "ted jo" ;
88 emit s_telnum_profile(QString(""));//send empty string
93 qWarning() << reply.errorMessage();
99 \param list_of_profiles_nf names of profiles
101 void TelephoneNumProfile::SetProfilenames(QStringList list_of_profiles_nf)
103 list_of_profiles = list_of_profiles_nf;
107 gets model and create selection model
109 void TelephoneNumProfile::createModels(QStandardItemModel * telenum)
111 model_of_telenum = telenum;
112 selModel_telenum = new QItemSelectionModel(model_of_telenum);
115 /** FindIDLocInModel.
116 Find id location and return name of profile
117 \param telnum tele num
119 QString TelephoneNumProfile::FindTelnumInModel(QString telnum)
121 QString name = QString("");
122 QList<QStandardItem *> list_of_telnum;
124 ////qDebug() << "In file:" << __FILE__ << ":" << "on line:" << __LINE__ << " in function:" << __FUNCTION__ << "Bude hledat modelu wifi site " ;
126 //labels << tr("Name") << tr("Wifi name") << tr("Profile");
127 list_of_telnum = model_of_telenum->findItems(telnum, Qt::MatchExactly , 1);
129 if(list_of_telnum.empty())
131 //qDebug() << "In file:" << __FILE__ << ":" << "on line:" << __LINE__ << " in function:" << __FUNCTION__ << "nic nanasel " ;
135 name = model_of_telenum->item(list_of_telnum.at(0)->row(),2)->data(Qt::DisplayRole).toString();
136 //qDebug() << "In file:" << __FILE__ << ":" << "on line:" << __LINE__ << " in function:" << __FUNCTION__ << "nasel ho " << name;
142 //===========================================================================
144 For dialog for modifi calendars and profiles
146 void TelephoneNumProfile::ShowDialog()
148 TeleNumDialog dialog(this);
149 dialog.SetViews(model_of_telenum,selModel_telenum);
150 dialog.SetProfilenames(list_of_profiles);