Example #1
0
QDBusViewer::QDBusViewer(const QDBusConnection &connection, QWidget *parent)  :
    QWidget(parent),
    c(connection),
    objectPathRegExp(QLatin1String("\\[ObjectPath: (.*)\\]"))
{
    services = new QTreeWidget;
    services->setRootIsDecorated(false);
    services->setHeaderLabels(QStringList(QLatin1String("Services")));

    tree = new QTreeView;
    tree->setContextMenuPolicy(Qt::CustomContextMenu);

    connect(tree, SIGNAL(activated(QModelIndex)), this, SLOT(activate(QModelIndex)));

    refreshAction = new QAction(tr("&Refresh"), tree);
    refreshAction->setData(42); // increase the amount of 42 used as magic number by one
    refreshAction->setShortcut(QKeySequence::Refresh);
    connect(refreshAction, SIGNAL(triggered()), this, SLOT(refreshChildren()));

    QShortcut *refreshShortcut = new QShortcut(QKeySequence::Refresh, tree);
    connect(refreshShortcut, SIGNAL(activated()), this, SLOT(refreshChildren()));

    QVBoxLayout *topLayout = new QVBoxLayout(this);
    log = new QTextBrowser;
    connect(log, SIGNAL(anchorClicked(QUrl)), this, SLOT(anchorClicked(QUrl)));

    QHBoxLayout *layout = new QHBoxLayout;
    layout->addWidget(services, 1);
    layout->addWidget(tree, 2);

    topLayout->addLayout(layout);
    topLayout->addWidget(log);

    connect(services, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),
            this, SLOT(serviceChanged(QTreeWidgetItem*)));
    connect(tree, SIGNAL(customContextMenuRequested(QPoint)),
            this, SLOT(showContextMenu(QPoint)));

    QMetaObject::invokeMethod(this, "refresh", Qt::QueuedConnection);

    if (c.isConnected()) {
        logMessage(QLatin1String("Connected to D-Bus."));
        QDBusConnectionInterface *iface = c.interface();
        connect(iface, SIGNAL(serviceRegistered(QString)),
                this, SLOT(serviceRegistered(QString)));
        connect(iface, SIGNAL(serviceUnregistered(QString)),
                this, SLOT(serviceUnregistered(QString)));
        connect(iface, SIGNAL(serviceOwnerChanged(QString,QString,QString)),
                this, SLOT(serviceOwnerChanged(QString,QString,QString)));
    } else {
        logError(QLatin1String("Cannot connect to D-Bus: ") + c.lastError().message());
    }

    objectPathRegExp.setMinimal(true);

}
Example #2
0
/*!
    \class DBusConnection
    \internal
    \brief Connects to the accessibility dbus.

    This is usually a different bus from the session bus.
*/
DBusConnection::DBusConnection(QObject *parent)
    : QObject(parent), m_a11yConnection(QString()), m_enabled(false)
{
    // Start monitoring if "org.a11y.Bus" is registered as DBus service.
    QDBusConnection c = QDBusConnection::sessionBus();
    dbusWatcher = new QDBusServiceWatcher(A11Y_SERVICE, c, QDBusServiceWatcher::WatchForRegistration, this);
    connect(dbusWatcher, SIGNAL(serviceRegistered(QString)), this, SLOT(serviceRegistered()));

    // If it is registered already, setup a11y right away
    if (c.interface()->isServiceRegistered(A11Y_SERVICE))
        serviceRegistered();
}
NetworkManager::NetworkManager(QObject* parent)
  : QObject(parent),
    m_manager(NULL),
    m_defaultRoute(NULL),
    m_invalidDefaultRoute(new NetworkService("/", QVariantMap(), this)),
    watcher(NULL),
    m_available(false),
    m_servicesEnabled(true),
    m_technologiesEnabled(true)
{
    registerCommonDataTypes();
    watcher = new QDBusServiceWatcher("net.connman",QDBusConnection::systemBus(),
            QDBusServiceWatcher::WatchForRegistration |
            QDBusServiceWatcher::WatchForUnregistration, this);
    connect(watcher, SIGNAL(serviceRegistered(QString)),
            this, SLOT(connectToConnman(QString)));
    connect(watcher, SIGNAL(serviceUnregistered(QString)),
            this, SLOT(connmanUnregistered(QString)));


    m_available = QDBusConnection::systemBus().interface()->isServiceRegistered("net.connman");

    if (m_available)
        connectToConnman();
    else
        qDebug() << "connman not AVAILABLE";
}
Example #4
0
void tst_QDBusPerformance::initTestCase()
{
    QDBusConnection con = QDBusConnection::sessionBus();
    QVERIFY(con.isConnected());

    QDBusServiceWatcher watcher(serviceName, con,
                                QDBusServiceWatcher::WatchForRegistration);
    connect(&watcher, SIGNAL(serviceRegistered(QString)),
            &QTestEventLoop::instance(), SLOT(exitLoop()));

#ifdef Q_OS_WIN
    proc.start("server");
#else
    proc.start("./server/server");
#endif
    QVERIFY(proc.waitForStarted());

    QTestEventLoop::instance().enterLoop(5);
    QVERIFY(con.interface()->isServiceRegistered(serviceName));

    remote = new QDBusInterface(serviceName, "/", "com.trolltech.autotests.Performance", con, this);
    QVERIFY(remote->isValid());

    new ServerObject("/", con, this);
    local = new QDBusInterface(con.baseService(), "/", "com.trolltech.autotests.Performance", con, this);
    QVERIFY(local->isValid());
}
SensorfwSensorBase::SensorfwSensorBase(QSensor *sensor)
    : QSensorBackend(sensor),
      m_sensorInterface(0),
      m_bufferSize(-1),
      m_prevOutputRange(0),
      m_efficientBufferSize(1),
      m_maxBufferSize(1),
      m_available(0),
      running(0)

{
    watcher = new QDBusServiceWatcher("com.nokia.SensorService",QDBusConnection::systemBus(),
            QDBusServiceWatcher::WatchForRegistration |
            QDBusServiceWatcher::WatchForUnregistration, this);

    connect(watcher, SIGNAL(serviceRegistered(QString)),
            this, SLOT(connectToSensord(QString)));
    connect(watcher, SIGNAL(serviceUnregistered(QString)),
            this, SLOT(sensordUnregistered(QString)));


    m_available = QDBusConnection::systemBus().interface()->isServiceRegistered("com.nokia.SensorService");
    if (m_available)
        connectToSensord();
}
Example #6
0
NetworkManager::NetworkManager(QObject* parent)
  : QObject(parent),
    m_manager(NULL),
    m_getPropertiesWatcher(NULL),
    m_getTechnologiesWatcher(NULL),
    m_getServicesWatcher(NULL),
    m_defaultRoute(NULL),
    watcher(NULL),
    m_available(false)
{
    registerCommonDataTypes();


    watcher = new QDBusServiceWatcher("net.connman",QDBusConnection::systemBus(),
            QDBusServiceWatcher::WatchForRegistration |
            QDBusServiceWatcher::WatchForUnregistration, this);
    connect(watcher, SIGNAL(serviceRegistered(QString)),
            this, SLOT(connectToConnman(QString)));
    connect(watcher, SIGNAL(serviceUnregistered(QString)),
            this, SLOT(connmanUnregistered(QString)));


    m_available = QDBusConnection::systemBus().interface()->isServiceRegistered("net.connman");

    if(m_available)
        connectToConnman();
}
Example #7
0
/*!
    \internal
*/
QDBusConnectionInterface::QDBusConnectionInterface(const QDBusConnection &connection,
                                                   QObject *parent)
    : QDBusAbstractInterface(QLatin1String(DBUS_SERVICE_DBUS),
                             QLatin1String(DBUS_PATH_DBUS),
                             DBUS_INTERFACE_DBUS, connection, parent)
{
    connect(this, SIGNAL(NameAcquired(QString)), this, SIGNAL(serviceRegistered(QString)));
    connect(this, SIGNAL(NameLost(QString)), this, SIGNAL(serviceUnregistered(QString)));
    connect(this, SIGNAL(NameOwnerChanged(QString,QString,QString)),
            this, SIGNAL(serviceOwnerChanged(QString,QString,QString)));
}
Example #8
0
UPower::UPower() : m_interfaceProps(0), m_interface(0) {
    m_watcher = new QDBusServiceWatcher;
    m_watcher->addWatchedService("org.freedesktop.UPower");
    m_watcher->setConnection(QDBusConnection::systemBus());
    m_watcher->setWatchMode( QDBusServiceWatcher::WatchForRegistration | QDBusServiceWatcher::WatchForUnregistration );

    connect(m_watcher, SIGNAL(serviceUnregistered(QString)), this, SIGNAL(upowerUnavailable()));
    connect(m_watcher, SIGNAL(serviceRegistered(QString)), this, SLOT(connectInterfaces()));
    connect(this, SIGNAL(upowerAvailable()), this, SLOT(probeDevices()));

    connectInterfaces();
}
Example #9
0
/*!
    \internal
*/
void QDBusConnectionInterface::disconnectNotify(const char *signalName)
{
    // translate the signal names to what we really want
    // this avoids setting hooks for signals that don't exist on the bus
    if (qstrcmp(signalName, SIGNAL(serviceRegistered(QString))) == 0)
        QDBusAbstractInterface::disconnectNotify(SIGNAL(NameAcquired(QString)));

    else if (qstrcmp(signalName, SIGNAL(serviceUnregistered(QString))) == 0)
        QDBusAbstractInterface::disconnectNotify(SIGNAL(NameLost(QString)));

    else if (qstrcmp(signalName, SIGNAL(serviceOwnerChanged(QString,QString,QString))) == 0)
        QDBusAbstractInterface::disconnectNotify(SIGNAL(NameOwnerChanged(QString,QString,QString)));
}
ConnectionAgentPlugin::ConnectionAgentPlugin(QObject *parent):
    QObject(parent),
    connManagerInterface(0)
{
    connectiondWatcher = new QDBusServiceWatcher(CONND_SERVICE,QDBusConnection::sessionBus(),
            QDBusServiceWatcher::WatchForRegistration |
            QDBusServiceWatcher::WatchForUnregistration, this);

    connect(connectiondWatcher, SIGNAL(serviceRegistered(QString)),
            this, SLOT(connectToConnectiond(QString)));
    connect(connectiondWatcher, SIGNAL(serviceUnregistered(QString)),
            this, SLOT(connectiondUnregistered(QString)));

    connectToConnectiond();
}
Example #11
0
MixerEngine::MixerEngine(QObject *parent, const QVariantList &args)
	: Plasma::DataEngine(parent, args)
	, m_kmix(0)
{
	Q_UNUSED(args)

	interface = QDBusConnection::sessionBus().interface();
	watcher = new QDBusServiceWatcher( this );
	watcher->addWatchedService( KMIX_DBUS_SERVICE );
	watcher->setConnection( QDBusConnection::sessionBus() );
	watcher->setWatchMode( QDBusServiceWatcher::WatchForRegistration | QDBusServiceWatcher::WatchForUnregistration );
	connect( watcher, SIGNAL(serviceRegistered(QString)),
			this, SLOT(slotServiceRegistered(QString)) );
	connect( watcher, SIGNAL(serviceUnregistered(QString)),
			this, SLOT(slotServiceUnregistered(QString)) );
	init();
}
AbstractDBusServiceMonitor::AbstractDBusServiceMonitor(QString service, QString path,
                                                       QString interface, QObject *parent)
    : QObject(parent)
    , m_service(service)
    , m_path(path)
    , m_interface(interface)
    , m_watcher(new QDBusServiceWatcher(service, QDBusConnection::sessionBus()))
    , m_dbusInterface(0)
{
    connect(m_watcher, SIGNAL(serviceRegistered(QString)), SLOT(createInterface()));
    connect(m_watcher, SIGNAL(serviceUnregistered(QString)), SLOT(destroyInterface()));

    // Connect to the service if it's up already
    QDBusConnectionInterface* sessionBus = QDBusConnection::sessionBus().interface();
    QDBusReply<bool> reply = sessionBus->isServiceRegistered(m_service);
    if (reply.isValid() && reply.value()) {
        createInterface();
    }
}
Example #13
0
/*!
    \internal
*/
void QDBusConnectionInterface::connectNotify(const char *signalName)
{
    // translate the signal names to what we really want
    // this avoids setting hooks for signals that don't exist on the bus
    if (qstrcmp(signalName, SIGNAL(serviceRegistered(QString))) == 0)
        QDBusAbstractInterface::connectNotify(SIGNAL(NameAcquired(QString)));

    else if (qstrcmp(signalName, SIGNAL(serviceUnregistered(QString))) == 0)
        QDBusAbstractInterface::connectNotify(SIGNAL(NameLost(QString)));

    else if (qstrcmp(signalName, SIGNAL(serviceOwnerChanged(QString,QString,QString))) == 0) {
        static bool warningPrinted = false;
        if (!warningPrinted) {
            qWarning("Connecting to deprecated signal QDBusConnectionInterface::serviceOwnerChanged(QString,QString,QString)");
            warningPrinted = true;
        }
        QDBusAbstractInterface::connectNotify(SIGNAL(NameOwnerChanged(QString,QString,QString)));
    }
}
Example #14
0
ClientImpl::ClientImpl(Client *interface, QObject *parent)
    : QObject(parent)
    , mInterface(interface)
    , mServiceWatcher(new QDBusServiceWatcher("org.razorqt.global_key_shortcuts", QDBusConnection::sessionBus(), QDBusServiceWatcher::WatchForOwnerChange, this))
    , mDaemonPresent(false)
{
    connect(mServiceWatcher, SIGNAL(serviceUnregistered(QString)), this, SLOT(daemonDisappeared(QString)));
    connect(mServiceWatcher, SIGNAL(serviceRegistered(QString)), this, SLOT(daemonAppeared(QString)));
    mProxy = new org::razorqt::global_key_shortcuts::native("org.razorqt.global_key_shortcuts", "/native", QDBusConnection::sessionBus(), this);
    mDaemonPresent = mProxy->isValid();

    connect(this, SIGNAL(emitShortcutGrabbed(QString)), mInterface, SIGNAL(shortcutGrabbed(QString)));
    connect(this, SIGNAL(emitGrabShortcutFailed()), mInterface, SIGNAL(grabShortcutFailed()));
    connect(this, SIGNAL(emitGrabShortcutCancelled()), mInterface, SIGNAL(grabShortcutCancelled()));
    connect(this, SIGNAL(emitGrabShortcutTimedout()), mInterface, SIGNAL(grabShortcutTimedout()));
    connect(this, SIGNAL(emitDaemonDisappeared()), mInterface, SIGNAL(daemonDisappeared()));
    connect(this, SIGNAL(emitDaemonAppeared()), mInterface, SIGNAL(daemonAppeared()));
    connect(this, SIGNAL(emitDaemonPresenceChanged(bool)), mInterface, SIGNAL(daemonPresenceChanged(bool)));
}
Example #15
0
Actions::Actions(QObject *parent)
    : QObject(parent)
    , mServiceWatcher(new QDBusServiceWatcher(QLatin1String("org.lxqt.global_key_shortcuts"), QDBusConnection::sessionBus(), QDBusServiceWatcher::WatchForOwnerChange, this))
    , mMultipleActionsBehaviour(MULTIPLE_ACTIONS_BEHAVIOUR_FIRST)
{
    connect(mServiceWatcher, SIGNAL(serviceUnregistered(QString)), this, SLOT(on_daemonDisappeared(QString)));
    connect(mServiceWatcher, SIGNAL(serviceRegistered(QString)), this, SLOT(on_daemonAppeared(QString)));
    mDaemonProxy = new org::lxqt::global_key_shortcuts::daemon(QLatin1String("org.lxqt.global_key_shortcuts"), QStringLiteral("/daemon"), QDBusConnection::sessionBus(), this);

    connect(mDaemonProxy, SIGNAL(actionAdded(qulonglong)), this, SLOT(on_actionAdded(qulonglong)));
    connect(mDaemonProxy, SIGNAL(actionEnabled(qulonglong, bool)), this, SLOT(on_actionEnabled(qulonglong, bool)));
    connect(mDaemonProxy, SIGNAL(clientActionSenderChanged(qulonglong, QString)), this, SLOT(on_clientActionSenderChanged(qulonglong, QString)));
    connect(mDaemonProxy, SIGNAL(actionModified(qulonglong)), this, SLOT(on_actionModified(qulonglong)));
    connect(mDaemonProxy, SIGNAL(actionRemoved(qulonglong)), this, SLOT(on_actionRemoved(qulonglong)));
    connect(mDaemonProxy, SIGNAL(actionShortcutChanged(qulonglong)), this, SLOT(on_actionShortcutChanged(qulonglong)));
    connect(mDaemonProxy, SIGNAL(actionsSwapped(qulonglong, qulonglong)), this, SLOT(on_actionsSwapped(qulonglong, qulonglong)));
    connect(mDaemonProxy, SIGNAL(multipleActionsBehaviourChanged(uint)), this, SLOT(on_multipleActionsBehaviourChanged(uint)));

    QTimer::singleShot(0, this, SLOT(delayedInit()));
}
void ActivityEngine::init()
{
    if (qApp->applicationName() == "plasma-netbook") {
        //hack for the netbook
        //FIXME can I read a setting or something instead?
    } else {
        m_activityController = new KActivities::Controller(this);
        m_currentActivity = m_activityController->currentActivity();
        QStringList activities = m_activityController->listActivities();
        //setData("allActivities", activities);
        foreach (const QString &id, activities) {
            insertActivity(id);
        }

        connect(m_activityController, SIGNAL(activityAdded(QString)), this, SLOT(activityAdded(QString)));
        connect(m_activityController, SIGNAL(activityRemoved(QString)), this, SLOT(activityRemoved(QString)));
        connect(m_activityController, SIGNAL(currentActivityChanged(QString)), this, SLOT(currentActivityChanged(QString)));

        //some convenience sources for times when checking every activity source would suck
        //it starts with _ so that it can easily be filtered out of sources()
        //maybe I should just make it not included in sources() instead?
        m_runningActivities = m_activityController->listActivities(KActivities::Info::Running);
        setData("Status", "Current", m_currentActivity);
        setData("Status", "Running", m_runningActivities);

        m_watcher = new QDBusServiceWatcher(
            ACTIVITYMANAGER_SERVICE,
            QDBusConnection::sessionBus(),
            QDBusServiceWatcher::WatchForRegistration
                | QDBusServiceWatcher::WatchForUnregistration,
            this);

        connect(m_watcher, SIGNAL(serviceRegistered(QString)),
                this, SLOT(enableRanking()));
        connect(m_watcher, SIGNAL(serviceUnregistered(QString)),
                this, SLOT(disableRanking()));

        if (QDBusConnection::sessionBus().interface()->isServiceRegistered(ACTIVITYMANAGER_SERVICE)) {
            enableRanking();
        }
    }
Example #17
0
DashClient::DashClient(QObject* parent)
: QObject(parent)
, m_dashDbusIface(0)
, m_active(false)
, m_alwaysFullScreen(false)
{
    /* Check if the shell is already up and running by asking the bus instead of
       trying to create an instance of the interface. Creating an instance would
       cause D-Bus to activate the shell and we don’t want this to happen, the
       shell should be started on demand only. */
    QDBusConnectionInterface* sessionBusIFace = QDBusConnection::sessionBus().interface();
    QDBusReply<bool> reply = sessionBusIFace->isServiceRegistered(SHELL_DBUS_SERVICE);
    if (reply.isValid() && reply.value()) {
        connectToDash();
    }
    QDBusServiceWatcher* watcher = new QDBusServiceWatcher(SHELL_DBUS_SERVICE,
                                                           QDBusConnection::sessionBus(),
                                                           QDBusServiceWatcher::WatchForRegistration|QDBusServiceWatcher::WatchForUnregistration,
                                                           this);
    connect(watcher, SIGNAL(serviceRegistered(QString)), SLOT(connectToDash()));
    connect(watcher, SIGNAL(serviceUnregistered(QString)), SLOT(onDashDisconnect()));
}
Example #18
0
ServiceRef::Ptr ServiceRegistry::registerService(const std::string& name, Service::Ptr pService, const Properties& props)
{
	Poco::ScopedLockWithUnlock<FastMutex> lock(_mutex);

	ServiceMap::iterator it = _services.find(name);
	if (it == _services.end())
	{
		ServiceRef::Ptr pServiceRef(new ServiceRef(name, props, pService));
		pServiceRef->properties().set(PROP_NAME, name);
		pServiceRef->properties().set(PROP_TYPE, std::string(pService->type().name()));
		_services[name] = pServiceRef;
		
		lock.unlock();
		
		ServiceEvent registeredEvent(pServiceRef, ServiceEvent::EV_SERVICE_REGISTERED);
		serviceRegistered(this, registeredEvent);
		
		_logger.information(std::string("Service registered: ") + name);
		
		return pServiceRef;
	}
	else throw Poco::ExistsException(name);
}
MDeclarativeStatusBar::MDeclarativeStatusBar(QDeclarativeItem *parent) :
    QDeclarativeItem(parent),
    updatesEnabled(true),
    mousePressed(false),
    feedbackDelay(false),
    swipeGesture(false),
    sharedPixmapHandle(0),
    pixmapDamage(0),
    mOrientation(MDeclarativeScreen::Portrait),
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
     updateSharedTexture(false),
#endif
    feedbackPlayer(new FeedbackPlayer(this))
{
    setFlag(QGraphicsItem::ItemHasNoContents, false);
    setAcceptedMouseButtons(Qt::LeftButton);
    // higher than TitleBar
    setZValue(1010);
    setImplicitHeight(STATUSBAR_HEIGHT);

    if (!filterRegistered) {
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
        ::oldEventFilter = QCoreApplication::instance()->setEventFilter(x11EventFilter);
#else
        qApp->installNativeEventFilter(this);
#endif
#ifdef HAVE_XDAMAGE
        MDeclarativeScreen* screen = MDeclarativeScreen::instance();
        XDamageQueryExtension(screen->display(), &xDamageEventBase, &xDamageErrorBase);
#endif
        filterRegistered = true;
    }

#ifdef HAVE_DBUS
    if (QDBusConnection::sessionBus().interface()->isServiceRegistered(PIXMAP_PROVIDER_DBUS_SERVICE))
        isPixmapProviderOnline = true;
    else
#endif
        isPixmapProviderOnline = false;

#ifdef HAVE_DBUS
    dbusWatcher = new QDBusServiceWatcher( PIXMAP_PROVIDER_DBUS_SERVICE , QDBusConnection::sessionBus(),
                                           QDBusServiceWatcher::WatchForRegistration|QDBusServiceWatcher::WatchForUnregistration,
                                           this );

    connect(dbusWatcher, SIGNAL(serviceRegistered(QString)),
            this, SLOT(handlePixmapProviderOnline()));
    connect(dbusWatcher, SIGNAL(serviceUnregistered(QString)),
            this, SLOT(handlePixmapProviderOffline()));

#endif
    querySharedPixmapFromProvider();

    // XDamage event should come only when application is in foreground
#if defined USE_ABSTRACTION
    QmlWindowState * windowState = QmlWindowState::instance();
#else
    MWindowState * windowState = MWindowState::instance();
#endif
    connect(windowState, SIGNAL(activeChanged()), this, SLOT(updateXdamageEventSubscription()));
    connect(this, SIGNAL(visibleChanged()), this, SLOT(updateXdamageEventSubscription()));

    if (!feedbackPlayer->init("qt-components")) {
        delete feedbackPlayer;
        feedbackPlayer = 0;
    }
}
Example #20
0
void KWalletExecuter::execute()
{
//Preparing sockets, we will share them with kwalletd
    int toWalletPipe[2] = { -1, -1};
    if (pipe(toWalletPipe) < 0) {
        qFatal("Couldn't craete pipes");
    }

    int envSocket;
    if ((envSocket = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
        qFatal("Couldn't create socket");
    }

    QByteArray sock = KStandardDirs::locateLocal("socket", QLatin1String("test.socket")).toLocal8Bit();
    struct sockaddr_un local;
    local.sun_family = AF_UNIX;
    strcpy(local.sun_path, sock.constData());
    unlink(local.sun_path);//Just in case it exists from a previous login

    int len;
    len = strlen(local.sun_path) + sizeof(local.sun_family);
    if (bind(envSocket, (struct sockaddr *)&local, len) == -1) {
        qFatal("Couldn't bind the socket");
    }

    if (listen(envSocket, 5) == -1) {
        qFatal("Couldn't listen into the socket");
    }

    qputenv("PAM_KWALLET_LOGIN", "1");
    pid_t pid;
    switch (pid = fork ()) {
    case -1:
        qFatal("Couldn't fork to execv kwalletd");

    //Child fork, will contain kwalletd
    case 0:
        execute_kwallet(toWalletPipe, envSocket);
        /* Should never be reached */
        break;

    //Parent
    default:
        break;
    };

    close(toWalletPipe[0]);//Read end of the pipe, we will only use the write

    QByteArray hash =
        QByteArray::fromHex("1f1e7736894243657ef4a5274211b9a62703494c286e1699418a36e7ecf31d37319644db63d9fb26eb57cd9b7fea3e88bc18312480ba54f4");
    write(toWalletPipe[1], hash.constData(), 56);

    QLocalSocket *socket = new QLocalSocket(this);
    socket->connectToServer(sock);
    //No need to send any environment vars, the env is already ok
    socket->close();

    if (!QDBusConnection::sessionBus().interface()->isServiceRegistered("org.kde.kwalletd")) {
        qDebug() << "AAAAAAAA";
        QEventLoop loop;
        QDBusServiceWatcher *watcher = new QDBusServiceWatcher("org.kde.kwalletd",
                QDBusConnection::sessionBus(),
                QDBusServiceWatcher::WatchForRegistration);
        connect(watcher, SIGNAL(serviceRegistered(QString)), &loop, SLOT(quit()));
        loop.exec();
    }
}
QDBusViewer::QDBusViewer(const QDBusConnection &connection, QWidget *parent)  :
    QWidget(parent),
    c(connection),
    objectPathRegExp(QLatin1String("\\[ObjectPath: (.*)\\]"))
{
    servicesModel = new QStringListModel(this);
    servicesFilterModel = new QSortFilterProxyModel(this);
    servicesFilterModel->setSourceModel(servicesModel);
    servicesFilterModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
    serviceFilterLine = new QLineEdit(this);
    serviceFilterLine->setPlaceholderText(tr("Search..."));
    servicesView = new QListView(this);
    servicesView->setModel(servicesFilterModel);

    connect(serviceFilterLine, SIGNAL(textChanged(QString)), servicesFilterModel, SLOT(setFilterFixedString(QString)));

    tree = new QTreeView;
    tree->setContextMenuPolicy(Qt::CustomContextMenu);

    connect(tree, SIGNAL(activated(QModelIndex)), this, SLOT(activate(QModelIndex)));

    refreshAction = new QAction(tr("&Refresh"), tree);
    refreshAction->setData(42); // increase the amount of 42 used as magic number by one
    refreshAction->setShortcut(QKeySequence::Refresh);
    connect(refreshAction, SIGNAL(triggered()), this, SLOT(refreshChildren()));

    QShortcut *refreshShortcut = new QShortcut(QKeySequence::Refresh, tree);
    connect(refreshShortcut, SIGNAL(activated()), this, SLOT(refreshChildren()));

    QVBoxLayout *layout = new QVBoxLayout(this);
    QSplitter *topSplitter = new QSplitter(Qt::Vertical, this);
    layout->addWidget(topSplitter);

    log = new QTextBrowser;
    connect(log, SIGNAL(anchorClicked(QUrl)), this, SLOT(anchorClicked(QUrl)));

    QSplitter *splitter = new QSplitter(topSplitter);
    splitter->addWidget(servicesView);

    QWidget *servicesWidget = new QWidget;
    QVBoxLayout *servicesLayout = new QVBoxLayout(servicesWidget);
    servicesLayout->addWidget(serviceFilterLine);
    servicesLayout->addWidget(servicesView);
    splitter->addWidget(servicesWidget);
    splitter->addWidget(tree);

    topSplitter->addWidget(splitter);
    topSplitter->addWidget(log);

    connect(servicesView->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),
            this, SLOT(serviceChanged(QModelIndex)));
    connect(tree, SIGNAL(customContextMenuRequested(QPoint)),
            this, SLOT(showContextMenu(QPoint)));

    QMetaObject::invokeMethod(this, "refresh", Qt::QueuedConnection);

    if (c.isConnected()) {
        logMessage(QLatin1String("Connected to D-Bus."));
        QDBusConnectionInterface *iface = c.interface();
        connect(iface, SIGNAL(serviceRegistered(QString)),
                this, SLOT(serviceRegistered(QString)));
        connect(iface, SIGNAL(serviceUnregistered(QString)),
                this, SLOT(serviceUnregistered(QString)));
        connect(iface, SIGNAL(serviceOwnerChanged(QString,QString,QString)),
                this, SLOT(serviceOwnerChanged(QString,QString,QString)));
    } else {
        logError(QLatin1String("Cannot connect to D-Bus: ") + c.lastError().message());
    }

    objectPathRegExp.setMinimal(true);

}
PeopleApplication::PeopleApplication(int &argc, char**argv):
        MApplication(argc, argv)
{
    theApp = this;

    m_realModel = SeasideSyncModel::instance();

    m_window = new SeasideWindow;
    m_window->show();

    m_mainPage = NULL;
    m_detailPage = NULL;
    m_editPage = NULL;
    m_commPage = NULL;

    m_topSpacer = NULL;
    m_bottomSpacer = NULL;

    m_people = NULL;
    m_sliderH = NULL;
    m_sliderV = NULL;
    m_searchWidget = NULL;
    m_searchEdit = NULL;

    m_currentPerson = NULL;
    m_editModel = NULL;
    m_editModelModified = NULL;


//    m_AccountPath = NULL;

    createPeoplePage();

    connect(m_window, SIGNAL(orientationChanged(M::Orientation)),
            this, SLOT(repositionOverlays()));

     PeopleDBusAdaptor *adpt = new PeopleDBusAdaptor(this);
     if(!adpt)
        qWarning() << "People Application Dbus adaptor failed" << adpt;

     bool err;
     err = QDBusConnection::sessionBus().registerService(DBUSINTFNAME);
     if(!err)
          qDebug() << "People Application Dbus calls error:" << err;
       err = QDBusConnection::sessionBus().registerObject(DBUSOBJPATH, this);
       if(!err)
            qDebug() << "People Application Dbus calls error:" << err;

       m_dbusDialerWatcher = new QDBusServiceWatcher("com.meego.dialer" , QDBusConnection::sessionBus(),
                                           QDBusServiceWatcher::WatchForRegistration|QDBusServiceWatcher::WatchForUnregistration,
                                           this);
       m_dbusEmailWatcher = new QDBusServiceWatcher("com.meego.email" , QDBusConnection::sessionBus(),
                                           QDBusServiceWatcher::WatchForRegistration|QDBusServiceWatcher::WatchForUnregistration,
                                           this);
       m_dbusIMWatcher = new QDBusServiceWatcher("com.meego.meego_handset_chat" , QDBusConnection::sessionBus(),
                                           QDBusServiceWatcher::WatchForRegistration|QDBusServiceWatcher::WatchForUnregistration,
                                           this);
       m_dbusSMSWatcher = new QDBusServiceWatcher("com.meego.sms" , QDBusConnection::sessionBus(),
                                           QDBusServiceWatcher::WatchForRegistration|QDBusServiceWatcher::WatchForUnregistration,
                                           this);

    connect(m_dbusDialerWatcher, SIGNAL(serviceRegistered(QString)),
            this, SLOT(handleDialerRegistered())); 
    connect(m_dbusEmailWatcher, SIGNAL(serviceRegistered(QString)),
            this, SLOT(handleEmailRegistered()));
    connect(m_dbusIMWatcher, SIGNAL(serviceRegistered(QString)),
            this, SLOT(handleIMRegistered()));
    connect(m_dbusSMSWatcher, SIGNAL(serviceRegistered(QString)),
            this, SLOT(handleSMSRegistered()));
}