Home
Phabricator
Search
Log In
Files
F7006291
test.cpp
aleksanderm (Aleksander Morgado)
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Author
aleksanderm
Created
Jul 11 2019, 11:01 AM
Size
1 KB
Mime Type
text/x-c
Engine
blob
Format
Raw Data
Handle
4438070
Attached To
D22395: Allow updating default DBus timeout on every interface
test.cpp
View Options
/*
$ g++ \
`pkg-config --cflags --libs Qt5DBus Qt5Core mm-glib` \
-I /usr/include/KF5/ModemManagerQt/ \
-lKF5ModemManagerQt \
-fPIC \
test.cpp \
-o test
*/
#include
<QCoreApplication>
#include
<QDebug>
#include
<QtDBus>
#undef signals
#include
<ModemManager.h>
#include
<Manager>
#include
<Modem3Gpp>
#include
<Modem>
#include
<libmm-glib.h>
#define signals Q_SIGNALS
int
main
(
int
argc
,
char
*
argv
[])
{
QCoreApplication
a
(
argc
,
argv
);
Q_FOREACH
(
ModemManager
::
ModemDevice
::
Ptr
modemdevice
,
ModemManager
::
modemDevices
())
{
ModemManager
::
Modem3gpp
::
Ptr
modem3gpp
=
modemdevice
->
interface
(
ModemManager
::
ModemDevice
::
GsmInterface
).
objectCast
<
ModemManager
::
Modem3gpp
>
();;
if
(
modem3gpp
)
{
// Set explicit timeout for the operation
modem3gpp
->
setDefaultTimeout
(
300000
);
// Launch scan
QDBusPendingReply
<>
async
=
modem3gpp
->
scan
();
QDBusPendingCallWatcher
*
watcher
=
new
QDBusPendingCallWatcher
(
async
);
QObject
::
connect
(
watcher
,
&
QDBusPendingCallWatcher
::
finished
,
[
&
a
]
(
QDBusPendingCallWatcher
*
call
)
{
QDBusPendingReply
<>
reply
=
*
call
;
if
(
reply
.
isError
())
{
QDBusError
error
=
reply
.
error
();
qWarning
()
<<
"Scan operation failed: "
<<
error
.
message
();
}
else
{
qInfo
()
<<
"Scan operation successful"
;
}
a
.
quit
();
});
break
;
}
}
return
a
.
exec
();
}
Log In to Comment