main.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * Copyright (c) 2011 Nokia Corporation.
  3. */
  4. #include <QtCore>
  5. #include <QCoreApplication>
  6. #include "Daemon.h"
  7. #include <QRemoteServiceRegister>
  8. #include <QServiceManager>
  9. int main(int argc, char *argv[])
  10. {
  11. // Application without UI is QCoreApplication not QApplication
  12. QCoreApplication a(argc, argv);
  13. // Create daemon
  14. Daemon daemon;
  15. // Create service
  16. // Create, register and publish IPC based service object
  17. const QString serviceName("WhoWhereDaemonService");
  18. const QString interfaceName("com.nokia.qt.examples.qwhowheredaemon");
  19. const QString serviceVersion("1.0");
  20. QtMobility::QServiceManager manager;
  21. // Remove old service
  22. manager.removeService(serviceName);
  23. // Add service
  24. bool addServiceOk = manager.addService("c:\\resource\\apps\\xmldata\\wwdaemonservice.xml");
  25. Q_ASSERT(addServiceOk);
  26. // Entry
  27. QtMobility::QRemoteServiceRegister serviceRegister;
  28. QtMobility::QRemoteServiceRegister::Entry entry = serviceRegister.createEntry<Daemon>(serviceName, interfaceName, serviceVersion);
  29. // Publish
  30. serviceRegister.publishEntries("qwhowheredaemon");
  31. // Keep service running
  32. serviceRegister.setQuitOnLastInstanceClosed(false);
  33. return a.exec();
  34. }