void AutoCompleteService::startService() {
        if (m_AutoCompleteWorker != NULL) {
            LOG_WARNING << "Attempt to start running worker";
            return;
        }

        m_AutoCompleteWorker = new AutoCompleteWorker();

        QThread *thread = new QThread();
        m_AutoCompleteWorker->moveToThread(thread);

        QObject::connect(thread, SIGNAL(started()), m_AutoCompleteWorker, SLOT(process()));
        QObject::connect(m_AutoCompleteWorker, SIGNAL(stopped()), thread, SLOT(quit()));

        QObject::connect(m_AutoCompleteWorker, SIGNAL(stopped()), m_AutoCompleteWorker, SLOT(deleteLater()));
        QObject::connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));

        QObject::connect(this, SIGNAL(cancelAutoCompletion()),
                         m_AutoCompleteWorker, SLOT(cancel()));

        QObject::connect(m_AutoCompleteWorker, SIGNAL(stopped()),
                         this, SLOT(workerFinished()));

        QObject::connect(m_AutoCompleteWorker, SIGNAL(destroyed(QObject*)),
                         this, SLOT(workerDestroyed(QObject*)));

        LOG_DEBUG << "starting thread...";
        thread->start();

        emit serviceAvailable(m_RestartRequired);
    }
Beispiel #2
0
bool Notification::setType(NotificationType type)
{
    if (serviceAvailable(type)) {
        m_type = type;
        return true;
    } else {
        m_type = TYPE_MSGBOX;
        return false;
    }
}
MServiceFwBaseIf::MServiceFwBaseIf(const QString &iface, QObject *parent) :
    QObject(parent),
    d_ptr(new MServiceFwBaseIfPrivate(iface))
{
    Q_D(const MServiceFwBaseIf);
    connect(d->serviceFwProxyPtr, SIGNAL(serviceAvailable(QString, QString)),
            this, SLOT(handleServiceAvailable(QString, QString)));

    connect(d->serviceFwProxyPtr, SIGNAL(serviceUnavailable(QString)),
            this, SLOT(handleServiceUnavailable(QString)));
}
EchoWindow::EchoWindow()
{
    createGUI();
    setLayout(layout);
    setWindowTitle("TextProcessor Demo");

    // instantiate the interface
    textProcessorInterface = new TextProcessorInterface();

    // check the interface is valid
    if (!textProcessorInterface->isValid()) {
        disableTextProcessing(QString());
        statusBar->showMessage("Err: Service unavailable");
    }

    // example of how to get a list of all installed services
    if (textProcessorInterface->isValid()) {
        QStringList services = textProcessorInterface->serviceNames();
        QStringListIterator iterator(services);
        qDebug() << "All services:";
        while (iterator.hasNext())
            qDebug() << iterator.next().toLocal8Bit().constData();
    }

    // example of how to get a list of all services for a particular interface
    if (textProcessorInterface->isValid()) {
        QStringList services = textProcessorInterface->serviceNames("com.nokia.TextProcessorInterface");
        QStringListIterator iterator(services);
        qDebug() << "Services implementing com.nokia.TextProcessorInterface:";
        while (iterator.hasNext())
            qDebug() << iterator.next().toLocal8Bit().constData();
    }

    // connect the availability signals
    // you likely need to know when a service appears/disappears to
    // do things like add/remove an option on a menu
    connect(
        textProcessorInterface, SIGNAL(serviceAvailable(QString)),
        this, SLOT(enableTextProcessing(QString))
    );
    connect(
        textProcessorInterface, SIGNAL(serviceUnavailable(QString)),
        this, SLOT(disableTextProcessing(QString))
    );
    connect(
        textProcessorInterface, SIGNAL(serviceChanged(QString)),
        this, SLOT(enableTextProcessing(QString))
    );
}
Beispiel #5
0
    void SpellCheckService::startService(Helpers::AsyncCoordinator &initCoordinator,
                                         UserDictionary &userDictionary,
                                         Warnings::WarningsService &warningsService) {
        if (m_SpellCheckWorker != nullptr) {
            LOG_WARNING << "Attempt to start running worker";
            return;
        }

        Helpers::AsyncCoordinatorLocker locker(initCoordinator);
        Q_UNUSED(locker);

        m_SpellCheckWorker = new SpellCheckWorker(getDictsRoot(),
                                                  m_Environment,
                                                  userDictionary,
                                                  warningsService,
                                                  initCoordinator);

        QThread *thread = new QThread();
        m_SpellCheckWorker->moveToThread(thread);

        QObject::connect(thread, &QThread::started, m_SpellCheckWorker, &SpellCheckWorker::process);
        QObject::connect(m_SpellCheckWorker, &SpellCheckWorker::stopped, thread, &QThread::quit);

        QObject::connect(m_SpellCheckWorker, &SpellCheckWorker::stopped, m_SpellCheckWorker, &SpellCheckWorker::deleteLater);
        QObject::connect(thread, &QThread::finished, thread, &QThread::deleteLater);

        QObject::connect(this, &SpellCheckService::cancelSpellChecking,
                         m_SpellCheckWorker, &SpellCheckWorker::cancel);

        QObject::connect(m_SpellCheckWorker, &SpellCheckWorker::queueIsEmpty,
                         this, &SpellCheckService::spellCheckQueueIsEmpty);

        QObject::connect(m_SpellCheckWorker, &SpellCheckWorker::stopped,
                         this, &SpellCheckService::workerFinished);
        QObject::connect(m_SpellCheckWorker, &SpellCheckWorker::destroyed,
                         this, &SpellCheckService::workerDestroyed);

        LOG_DEBUG << "starting thread...";
        thread->start();

        m_IsStopped = false;

        emit serviceAvailable();
    }
void MServiceFwBaseIf::handleServiceAvailable(const QString &service, const QString &interface)
{
    Q_D(MServiceFwBaseIf);
    bool newServiceIsForThisInterface = (interface == d->interface);
    if (newServiceIsForThisInterface) {
        QString previousService = d->service;

        // let service mappper choose which service to use
        d->service = d->serviceFwProxyPtr->serviceName(d->interface);

        bool interfaceWasDead = previousService.isEmpty();
        if (interfaceWasDead) {
            emit serviceAvailable(service);
        }

        bool serviceHasChanged = (previousService != d->service);
        if (serviceHasChanged) {
            setService(d->service);
            emit serviceChanged(d->service);
        }
    }
}