Esempio n. 1
0
void method2()
{
    qDebug() << "Method 2:";

    QDBusConnection bus = QDBusConnection::sessionBus();
    QDBusInterface dbus_iface("org.freedesktop.DBus", "/org/freedesktop/DBus",
                              "org.freedesktop.DBus", bus);
    qDebug() << dbus_iface.call("ListNames").arguments().at(0);
}
Esempio n. 2
0
void ScreenToVnc::mceUnblank()
{
    IN;
    QDBusConnection bus = QDBusConnection::systemBus();
    QDBusInterface dbus_iface("com.nokia.mce",
                              "/com/nokia/mce/request",
                              "com.nokia.mce.request",
                              bus);

    dbus_iface.call("req_display_state_on");
}
Esempio n. 3
0
QString
ProfileClient::getProfile() const {
    QDBusInterface dbus_iface(PROFILED_SERVICE, PROFILED_PATH,
                              PROFILED_INTERFACE);

    QDBusReply<QString> reply = dbus_iface.call(PROFILED_GET_PROFILE);

    if (reply.isValid()) {
        return reply.value();
    } else {
        qDebug("ProfileClient::getProfile returned invalid reply");
    }

    return QString();
}
Esempio n. 4
0
int
ProfileClient::getProfileVolume(const QString &profile) const {
    QDBusInterface dbus_iface(PROFILED_SERVICE, PROFILED_PATH,
                              PROFILED_INTERFACE);

    QDBusReply<int> reply = dbus_iface.call(PROFILED_GET_VALUE, profile, PROFILED_VOLUME_VALUE);

    if (reply.isValid()) {
        return reply.value();
    } else {
        qDebug("ProfileClient::getProfileVolume returned invalid reply for profile %s", qPrintable(profile));
    }

    return -1;
}
Esempio n. 5
0
bool
ProfileClient::setProfile(const QString &profileName)
{
    QDBusInterface dbus_iface(PROFILED_SERVICE, PROFILED_PATH,
                              PROFILED_INTERFACE);

    qDebug("Setting profile to %s", profileName.toLatin1().constData());
    QDBusReply<bool> reply = dbus_iface.call(PROFILED_SET_PROFILE, profileName);
    if (reply.isValid()) {
        bool replyValue = reply.value();
        qDebug("Return value %d", replyValue == true);
        return replyValue;
    } else {
        qDebug("ProfileClient::getProfileType returned invalid reply for profile %s", qPrintable(profileName));
    }
    return false;
}
Esempio n. 6
0
QStringList
ProfileClient::getProfiles() const
{
    QDBusInterface dbus_iface(PROFILED_SERVICE, PROFILED_PATH,
                              PROFILED_INTERFACE);

    QDBusReply<QStringList> reply = dbus_iface.call(PROFILED_GET_PROFILES);
    QStringList profiles = reply.value();
    // For testing on Desktop without profiled running
#ifndef __arm__
    profiles.append("Profile 1");
    profiles.append("Profile 2");
    profiles.append("Profile 3");
    profiles.append("general");
#endif

    return profiles;
}
Esempio n. 7
0
void DatabaseServerStarter::stopServerManagerProcess()
{
    QSystemSemaphore sem(QLatin1String("DigikamDBSrvAccess"), 1, QSystemSemaphore::Open);
    sem.acquire();

    if (isServerRegistered())
    {
        QDBusInterface dbus_iface(QLatin1String("org.kde.digikam.DatabaseServer"), QLatin1String("/DatabaseServer"));
        QDBusMessage stateMsg = dbus_iface.call(QLatin1String("isRunning"));

        if (stateMsg.arguments().at(0).toBool())
        {
            dbus_iface.call(QLatin1String("stopDatabaseProcess"));
        }
    }

    sem.release();
}
Esempio n. 8
0
QString
ProfileClient::getProfileType(const QString &profile) const {
    QDBusInterface dbus_iface(PROFILED_SERVICE, PROFILED_PATH,
                              PROFILED_INTERFACE);

    QDBusReply<QString> reply = dbus_iface.call(PROFILED_GET_VALUE, profile, PROFILED_TYPE_VALUE);

    if (reply.isValid()) {
        return reply.value();
    } else {
        qDebug("ProfileClient::getProfileType returned invalid reply for profile %s", qPrintable(profile));
    }

#ifndef __arm__
    return profile == "general" ? "Ringing" : profile + " Type";
#endif

    return QString();
}
bool
PamAuthentication::requireAuthentication() {
    QDBusInterface dbus_iface(UNITYGREETER_SERVICE, UNITYGREETER_PATH, UNITYGREETER_INTERFACE);

    qDebug() << Q_FUNC_INFO << "Querying if authentication required";

    if (!dbus_iface.isValid()) {
        qDebug() << Q_FUNC_INFO << "Not a valid dbus interface";
        qDebug() << Q_FUNC_INFO << "Last error: " + dbus_iface.lastError().message();
        // By default be cautious and require authentication
        return true;
    }
    QVariant isLockedVariant = dbus_iface.property(UNITYGREETER_PROPERTY_ENTRY_IS_LOCKED);
    if (isLockedVariant.isValid()) {
        bool replyValue = isLockedVariant.toBool();
        qDebug() << Q_FUNC_INFO << "Return value" << replyValue;
        return replyValue;
    } else {
        qDebug() << Q_FUNC_INFO << "Failed getting value for EntryIsLocked property";
    }
    // By default be cautious and require authentication
    return true;
}
Esempio n. 10
0
int main(int argc, char** argv)
{
    QApplication app(argc, argv);

    bool isRunning = false;

    if( QDBusConnection::sessionBus().registerService( "org.vokoscreen.screencast" ) )
    {
        isRunning = false;
    }
    else
    {
        isRunning = true;
    }


    QStringList arguments = QApplication::instance()->arguments();
    for( int i = 1; i < arguments.count(); ++i )
    {
        if ( ( arguments[ 1 ] == "--help" ) or
             ( arguments[ 1 ] == "-help"  ) or
             ( arguments[ 1 ] == "-h"     ) or
             ( arguments[ 1 ] == "-?"     ) )
        {
            qDebug( " " );
            qDebug() << "Usage: vokoscreen [method] [arg]";
            qDebug( " " );
            qDebug() << "Hint:";
            qDebug() << "  vokoscreen must running, bevor call method.";
            qDebug( " " );
            qDebug( "Methods:" );
            QvkDbus *vkDbus = new QvkDbus();
            qDebug().noquote() << "  " << vkDbus->showAllMethods();
            qDebug( " " );
            return close( 0 );
        }
    }

    if ( ( isRunning == false ) and
         ( QApplication::instance()->arguments().count() > 1 ) )
    {
        qDebug() << "Please start vokoscreen first, without a method.";
        return 0;
    }


    // DBus option arguments
    QDBusReply<QString> reply;
    QDBusConnection bus = QDBusConnection::sessionBus();
    QDBusInterface dbus_iface("org.vokoscreen.screencast", "/gui",
                              "org.vokoscreen.gui", bus);
    if ( ( isRunning == true ) and ( QApplication::instance()->arguments().count() > 1 ) )
    {
        QvkDbus *vkDbus = new QvkDbus();
        QString string = vkDbus->showAllMethods();
        if ( string.contains( QApplication::instance()->arguments().at( 1 ) ) == false )
        {
            QString string = QApplication::instance()->arguments().at( 1 );
            std::cout << "Error:" << " " << string.toStdString() << " " << "is not a method" << std::endl;
        }

        if ( QApplication::instance()->arguments().count() == 2 )
        {
            reply = dbus_iface.call( QApplication::instance()->arguments().at( 1 ) );
        }

        if ( QApplication::instance()->arguments().count() == 3 )
        {
            reply = dbus_iface.call( QApplication::instance()->arguments().at( 1 ),
                                     QApplication::instance()->arguments().at( 2 ));
        }

        // vokoscreens Ausgabe wird mit qDebug auf stderr ausgegeben
        // std::cout gibt die Ausgabe auf stdout aus, und somit kann in einem script die Ausgabe
        // in eine Variable geleitet werden.
        std::cout << reply.value().toStdString() << std::endl;

        goto stop;
    }


    {
        QTranslator * qtTranslator = new QTranslator();
        qtTranslator->load( "qt_" + QLocale::system().name(), QLibraryInfo::location( QLibraryInfo::TranslationsPath ) );
        app.installTranslator( qtTranslator );

        QTranslator translator;
        translator.load( "vokoscreen_" + QLocale::system().name(), ":/language" );
        app.installTranslator( &translator );
    }


    if( isRunning == false )
    {
        screencast *foo = new screencast();
        foo->show();
        return app.exec();
    }
    else
    {
        QMessageBox::StandardButton ret = QMessageBox::information( NULL,
                                                                    QObject::tr( "Info" ),
                                                                    QObject::tr( "vokoscreen can be started only once" ),
                                                                    QMessageBox::Close );
        (void)ret;
    }


    stop:
    {
        return 0;
    }
}
Esempio n. 11
0
DatabaseServerError DatabaseServerStarter::startServerManagerProcess(const QString& dbType)
{
    DatabaseServerError result;

    /*
     * TODO:
     * 1. Acquire semaphore lock on "DigikamDBSrvAccess"
     * 2. Check if there is an database server manager service already registered on DBus
     * 3. If not, start the database server manager
     * 4. Release semaphore lock
     */
    QSystemSemaphore sem(QLatin1String("DigikamDBSrvAccess"), 1, QSystemSemaphore::Open);
    sem.acquire();

    if (!isServerRegistered())
    {
        const QString dbServerMgrPath = QString::fromUtf8(LIBEXEC_INSTALL_DIR) + QLatin1String("/digikamdatabaseserver");

        if ( dbServerMgrPath.isEmpty() )
        {
            qCDebug(DIGIKAM_DBENGINE_LOG) << "No path to digikamdatabaseserver set in server manager configuration!";
        }

        const QStringList arguments;

        bool result = QProcess::startDetached( dbServerMgrPath, arguments );

        if ( !result )
        {
            qCDebug(DIGIKAM_DBENGINE_LOG) << "Could not start database server manager !";
            qCDebug(DIGIKAM_DBENGINE_LOG) << "executable:" << dbServerMgrPath;
            qCDebug(DIGIKAM_DBENGINE_LOG) << "arguments:" << arguments;
        }
    }

    // wait until the server has successfully registered on DBUS
    // TODO Use another way for that! Sleep isn't good :-/

    for (int i = 0; i < 30; ++i)
    {
        if (!isServerRegistered())
        {
            QThread sleepThread;
            sleepThread.msleep(250);
            sleepThread.wait();
        }
        else
        {
            break;
        }
    }

    QDBusInterface dbus_iface(QLatin1String("org.kde.digikam.DatabaseServer"), QLatin1String("/DatabaseServer"));
    QDBusMessage stateMsg = dbus_iface.call(QLatin1String("isRunning"));

    if (!stateMsg.arguments().at(0).toBool())
    {
        DatabaseServerError error;

        QList<QVariant> arguments;
        arguments.append(dbType);

        QDBusMessage reply = dbus_iface.callWithArgumentList(QDBus::Block, QLatin1String("startDatabaseProcess"), arguments);

        if (QDBusMessage::ErrorMessage == reply.type())
        {
            result.setErrorType(DatabaseServerError::StartError);
            result.setErrorText(i18n("<p><b>Error while calling the database server starter.</b></p>"
                                     "Details:\n %1", reply.errorMessage()));
        }
        else
        {
            arguments                = reply.arguments();
            QDBusVariant dbusVariant = qvariant_cast<QDBusVariant>(arguments.at(1));
            // Retrieve the actual value stored in the D-Bus variant
            QVariant dbusArgument    = dbusVariant.variant();
            DatabaseServerError item = qdbus_cast<DatabaseServerError>(dbusArgument);
            result                   = item;
        }
    }

    sem.release();

    return result;
}