Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Archived:How to read IMEI in Qt application for Maemo 5

From Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

The IMEI should be accessed using the cross platform Qt Mobility API QSystemDeviceInfo

Article Metadata
Compatibility
Platform(s):
Symbian
Article
Created: divanov (09 Feb 2010)
Last edited: hamishwillee (11 Oct 2012)

Archived: This article shows how to use the Maemo 5 DBus interface for obtaining IMEI of the phone.

The name of a service is com.nokia.phone.SIM, a path name is /com/nokia/phone/SIM/security, an interface name is Phone.Sim.Security. Finally the method's name responsible for obtaining IMEI is get_imei

You can verify that it works using dbus-send utility in XTerm:

dbus-send --system --type=method_call --print-reply \
--dest=com.nokia.phone.SIM \
/com/nokia/phone/SIM/security \
Phone.Sim.Security.get_imei

Now how you do it with C++ and Qt. First you need to create an interface on system bus identified by service/path/interface triad. A next step is to perform a method call to obtain a reply. Note that the call is synchronous, i.e., blocking. This is simple example and lightweight call, for more serious tasks use QDBusAbstractInterface::callWithCallback(). Reply contains string and integer value. The former represents IMEI of the phone.

#include <QApplication>
#include <QLabel>
#include <QDBusInterface>
#include <QDBusMessage>
#include <QDebug>
 
#define SIM_DBUS_SERVICE "com.nokia.phone.SIM"
#define SIM_DBUS_PATH "/com/nokia/phone/SIM/security"
#define SIM_DBUS_IFACE "Phone.Sim.Security"
#define SIM_IMEI_REQ "get_imei"
 
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
 
QLabel label;
label.setAlignment(Qt::AlignCenter);
label.setFont(QFont("Nokia Sans", 35, QFont::Bold));
label.show();
 
QDBusInterface interface(SIM_DBUS_SERVICE, SIM_DBUS_PATH, SIM_DBUS_IFACE,
QDBusConnection::systemBus());
 
QDBusMessage reply = interface.call(SIM_IMEI_REQ);
if (reply.type() == QDBusMessage::ErrorMessage)
qDebug() << reply.errorMessage();
else {
QList<QVariant> args = reply.arguments();
qDebug() << args;
label.setText(QString("Phone's IMEI: %1").arg(args.at(0).toString()));
}
 
return a.exec();
}
This page was last modified on 11 October 2012, at 01:18.
34 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×