48 #include <QCoreApplication> 51 #include <dbus/dbus.h> 52 #include <dbus/dbus-glib-lowlevel.h> 56 #include <sys/types.h> 61 #undef PRINT_DEBUGINFO 62 #ifdef PRINT_DEBUGINFO 63 static FILE *fdebug = NULL;
64 #define PDEBUG(fmt, args...) \ 67 gettimeofday(&tv, 0); \ 68 fprintf(fdebug, "DEBUG[%d]:%ld.%ld:%s:%s():%d: " fmt, \ 70 tv.tv_sec, tv.tv_usec, \ 71 __FILE__, __FUNCTION__, __LINE__, args); \ 75 #define PDEBUG(fmt...) 171 ICD_DBUS_API_INTERFACE);
177 icd_dbus_version = ver;
201 timeout = dbus_timeout;
203 #ifdef PRINT_DEBUGINFO 205 fdebug = fopen(
"/tmp/maemoicd.log",
"a+");
207 PDEBUG(
"created %s\n",
"IcdPrivate");
218 receivedSignals.
clear();
256 ret.
status = args[i++].toUInt();
285 bool last_result =
false;
292 return scanned_types;
295 error =
"Scan did not return anything.";
296 return scanned_types;
301 all_waited = scanned_types.
size();
306 scan_results.
clear();
307 while (!last_result) {
317 if (
mSignal != ICD_DBUS_API_SCAN_SIG) {
334 qDebug() <<
"Received: " <<
335 "status =" << result.
status <<
345 ", network_id =" <<
"-" <<
352 if (result.
status == ICD_SCAN_COMPLETE) {
354 if (--all_waited == 0) {
359 scan_results << result;
378 return scanned_types;
393 ret.
error = args[i++].toString();
394 ret.
state = args[i++].toInt();
404 ret.
state = args[i++].toInt();
429 reply =
mDBus->
call(ICD_DBUS_API_STATE_REQ,
430 service_type, service_attrs, service_id,
431 network_type, network_attrs, network_id);
438 total_signals = reply.
toUInt();
449 if (
mSignal != ICD_DBUS_API_STATE_SIG) {
471 return total_signals;
485 uint signals_left, total_signals;
488 int timeout_secs =
timeout / 1000;
490 PDEBUG(
"%s\n",
"state_results");
493 reply =
mDBus->
call(ICD_DBUS_API_STATE_REQ);
500 signals_left = total_signals = reply.
toUInt();
505 state_results.
clear();
507 while (signals_left) {
514 if (time(0)>(started+timeout_secs)) {
519 if (
mSignal != ICD_DBUS_API_STATE_SIG) {
529 state_results << result;
538 PDEBUG(
"total_signals=%d\n", total_signals);
539 return total_signals;
569 uint signals_left, total_signals;
573 reply =
mDBus->
call(ICD_DBUS_API_STATISTICS_REQ);
582 signals_left = total_signals = reply.
toUInt();
589 stats_results.
clear();
590 while (signals_left) {
601 if (
mSignal != ICD_DBUS_API_STATISTICS_SIG) {
607 stats_results << result;
616 return total_signals;
638 for (
int k=0; k<lst.
size()/6; k=k+6) {
640 ip_info.
address = lst[k].toString();
641 ip_info.
netmask = lst[k++].toString();
643 ip_info.
dns1 = lst[k++].toString();
644 ip_info.
dns2 = lst[k++].toString();
645 ip_info.
dns3 = lst[k++].toString();
662 uint signals_left, total_signals;
665 int timeout_secs =
timeout / 1000;
667 PDEBUG(
"%s\n",
"addr_results");
670 reply =
mDBus->
call(ICD_DBUS_API_ADDRINFO_REQ);
679 signals_left = total_signals = reply.
toUInt();
684 addr_results.
clear();
685 while (signals_left) {
692 if (time(0)>(started+timeout_secs)) {
697 if (
mSignal != ICD_DBUS_API_ADDRINFO_SIG) {
703 addr_results << result;
711 PDEBUG(
"total_signals=%d\n", total_signals);
712 return total_signals;
728 reply =
mDBus->
call(ICD_DBUS_API_ADDRINFO_REQ,
729 service_type, service_attrs, service_id,
730 network_type, network_attrs, network_id);
737 total_signals = reply.
toUInt();
749 if (
mSignal != ICD_DBUS_API_ADDRINFO_SIG) {
764 return total_signals;
794 return d->
scan(flags, network_types, scan_results, error);
803 return d->
state(service_type, service_attrs, service_id,
804 network_type, network_attrs, network_id,
814 return d->
addrinfo(service_type, service_attrs, service_id,
815 network_type, network_attrs, network_id,
822 return d->
state(state_results);
The QVariant class acts like a union for the most common Qt data types.
static void get_statistics_all_result(QList< QVariant > &args, IcdStatisticsResult &ret)
void setSingleShot(bool singleShot)
DBusDispatcher is a class that can send DBUS method call messages and receive unicast signals from DB...
uint state(QString &service_type, uint service_attrs, QString &service_id, QString &network_type, uint network_attrs, QByteArray &network_id, IcdStateResult &state_result)
The QByteArray class provides an array of bytes.
static void get_state_all_result2(QList< QVariant > &args, IcdStateResult &ret)
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
void icdCallReply(const QString &method, const QList< QVariant > &args, const QString &error)
QList< QVariant > toList() const
Returns the variant as a QVariantList if the variant has type() List or StringList ; otherwise return...
void synchronousDispatch(int timeout_ms)
The QString class provides a Unicode character string.
The QObject class is the base class of all Qt objects.
void init(unsigned int dbus_timeout, IcdDbusInterfaceVer ver, Icd *myfriend)
static void processEvents(QEventLoop::ProcessEventsFlags flags=QEventLoop::AllEvents)
Processes all pending events for the calling thread according to the specified flags until there are ...
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Q_CORE_EXPORT void qDebug(const char *,...)
IcdPrivate(unsigned int timeout, Icd *myfriend)
QStringList toStringList() const
Returns the variant as a QStringList if the variant has type() StringList, String ...
QList< QVariant > receivedSignals
T takeFirst()
Removes the first item in the list and returns it.
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
QList< QVariant > call(const QString &method, const QVariant &arg1=QVariant(), const QVariant &arg2=QVariant(), const QVariant &arg3=QVariant(), const QVariant &arg4=QVariant(), const QVariant &arg5=QVariant(), const QVariant &arg6=QVariant(), const QVariant &arg7=QVariant(), const QVariant &arg8=QVariant())
uint addrinfo(QString &service_type, uint service_attrs, QString &service_id, QString &network_type, uint network_attrs, QByteArray &network_id, IcdAddressInfoResult &addr_result)
The QStringList class provides a list of strings.
Q_CORE_EXPORT void qWarning(const char *,...)
QStringList scan(icd_scan_request_flags flags, QStringList &network_types, QList< IcdScanResult > &scan_results, QString &error)
struct CommonParams params
bool isActive() const
Returns true if the timer is running (pending); otherwise returns false.
static void sendPostedEvents()
void clear()
Removes all items from the list.
struct CommonParams params
static void get_state_all_result(QList< QVariant > &args, IcdStateResult &ret)
QList< IcdIPInformation > ip_info
T & first()
Returns a reference to the first item in the list.
static void get_scan_result(QList< QVariant > &args, IcdScanResult &ret)
uint state(QString &service_type, uint service_attrs, QString &service_id, QString &network_type, uint network_attrs, QByteArray &network_id, IcdStateResult &state_result)
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
Disconnects signal in object sender from method in object receiver.
uint addrinfo(QString &service_type, uint service_attrs, QString &service_id, QString &network_type, uint network_attrs, QByteArray &network_id, IcdAddressInfoResult &addr_result)
IcdDbusInterfaceVer icd_dbus_version
void clear()
Clears the contents of the string and makes it empty.
Type type() const
Returns the storage type of the value stored in the variant.
QObject * parent() const
Returns a pointer to the parent object.
IcdPrivate(unsigned int timeout, IcdDbusInterfaceVer ver, Icd *myfriend)
uint toUInt(bool *ok=0) const
Returns the variant as an unsigned int if the variant has type() UInt , Bool , ByteArray ...
int size() const
Returns the number of items in the list.
void callReply(const QString &method, const QList< QVariant > &args, const QString &error)
uint statistics(QList< IcdStatisticsResult > &stats_results)
enum icd_nw_levels signal_strength
uint statistics(QList< IcdStatisticsResult > &stats_results)
void icdSignalReceived(const QString &interface, const QString &signal, const QList< QVariant > &args)
The QTimer class provides repetitive and single-shot timers.
static void get_addrinfo_all_result(QList< QVariant > &args, IcdAddressInfoResult &ret)
void stop()
Stops the timer.
void start(int msec)
Starts or restarts the timer with a timeout interval of msec milliseconds.
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
IcdPrivate(Icd *myfriend)
void signalReceived(const QString &interface, const QString &signal, const QList< QVariant > &args)
QStringList scan(icd_scan_request_flags flags, QStringList &network_types, QList< IcdScanResult > &scan_results, QString &error)
struct CommonParams params