btsingledeviceselector.cpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /**********************************************************************
  2. ** Copyright (C) 2009 Nokia Corporation.
  3. ** All rights reserved.
  4. **
  5. ** $LICENSE_TEXT$
  6. **********************************************************************/
  7. #include "btsingledeviceselector.h"
  8. #include <QDBusInterface>
  9. #include <QDBusObjectPath>
  10. #include <QtCore/QStringList>
  11. #include <conbtdialogs-dbus.h>
  12. #include <QDebug>
  13. BtSingleDeviceSelector::BtSingleDeviceSelector(QObject *parent) :
  14. QObject(parent)
  15. {
  16. }
  17. void BtSingleDeviceSelector::searchResult(const QDBusMessage& message)
  18. {
  19. QList<QVariant> result = message.arguments();
  20. QString address = result.at(0).toString();
  21. QString name = result.at(1).toString();
  22. QString icon = result.at(2).toString();
  23. QString majorClass = result.at(3).toString();
  24. QString minorClass = result.at(4).toString();
  25. bool isTrusted = result.at(5).toBool();
  26. QStringList services = result.at(6).toStringList();
  27. qDebug() << address;
  28. qDebug() << name;
  29. qDebug() << icon;
  30. qDebug() << majorClass;
  31. qDebug() << minorClass;
  32. qDebug() << isTrusted;
  33. qDebug() << services.join(" ");
  34. qDebug() << "**************************";
  35. emit deviceSelected(address);
  36. }
  37. void BtSingleDeviceSelector::show()
  38. {
  39. QDBusConnection systemBus = QDBusConnection::systemBus();
  40. QDBusInterface icdInterface(CONBTDIALOGS_DBUS_SERVICE, CONBTDIALOGS_DBUS_PATH,
  41. CONBTDIALOGS_DBUS_INTERFACE, systemBus, this);
  42. if (!icdInterface.isValid()) {
  43. emit deviceSelected(QString());
  44. return;
  45. }
  46. systemBus.connect(CONBTDIALOGS_DBUS_SERVICE, CONBTDIALOGS_DBUS_PATH,
  47. CONBTDIALOGS_DBUS_INTERFACE, CONBTDIALOGS_SEARCH_SIG, this,
  48. SLOT(searchResult(const QDBusMessage&)));
  49. icdInterface.call(CONBTDIALOGS_SEARCH_REQ, QString(""), QString(""), QStringList(), QString(""));
  50. }