Esempio n. 1
0
//
//  Function to force a close of a notification
void NotifyClient::closeNotification(quint32 id)
{
  // return if we don't have valid connection
  if (! b_validconnection) return; 
  
  QDBusMessage reply = notifyclient->call(QLatin1String("CloseNotification", id));
  
  if (reply.type() == QDBusMessage::InvalidMessage)
    qCritical("CMST - Invalid reply received to CloseNotification method.");
  
  else if (reply.type() == QDBusMessage::ErrorMessage) 
    qCritical("CMST - Error reply received to CloseNotification method: %s", qPrintable(reply.errorMessage()) );
  
  return;
}
void Ut_CReporterNotification::testNotificationActivated()
{
    notification = new CReporterNotification("crash-reporter", "test-summary",
                                             "test-body", "icon-test");
    // Spy activated signal from notification.
    QSignalSpy activatedSpy(notification, SIGNAL(activated()));

    // Wait for notification.
    QTest::qWait(1000);

    QVERIFY(notification->isPublished() == true);

    QString objPath(CREPORTER_DBUS_NTF_OBJECT_PATH);
    objPath.append("00000000000000000000000000000000");

    // Interact with the notification via D-Bus and block.
    QDBusMessage reply = QDBusConnection::sessionBus().call(QDBusMessage::createMethodCall(
            QDBusConnection::sessionBus().baseService(), objPath,
            CREPORTER_DBUS_NTF_INTERFACE, "activate"));

    if (reply.type() == QDBusMessage::ErrorMessage) {
        qDebug() << reply.errorMessage();
        QFAIL("Error message received from D-Bus.");
    }

    QVERIFY(activatedSpy.count() == 1);
}
Esempio n. 3
0
const QString PBTreeNode::GetIntrospectXml(const QDBusObjectPath &object_path)
{
    // Connect to the introspectable interface
    QDBusInterface iface(PBBusName, \
                         object_path.path(), \
                         ofDIntrospectableName, \
                         QDBusConnection::sessionBus());

    // Lets see what we have - introspect this first
    QDBusMessage reply = iface.call("Introspect");
    if (reply.type() != QDBusMessage::ReplyMessage) {
        qDebug("Could not introspect this object");
        return NULL;
    }

    QList<QVariant> args = reply.arguments();

    QList<QVariant>::iterator iter = args.begin();

    QVariant variant = *iter;

    // The introspected string describing this object
    const QString intro_xml = variant.value<QString>();

    return intro_xml;
}
Esempio n. 4
0
QVariantMap PBTreeNode::GetObjectProperties(const QDBusObjectPath &object_path, \
                                            const QString interface)
{
    QVariantMap properties;

    // Connect to the freedesktop Properties interface
    QDBusInterface iface(PBBusName, \
                         object_path.path(), \
                         ofDPropertiesName, \
                         QDBusConnection::sessionBus());

    // GetAll properties
    QDBusMessage reply = iface.call("GetAll",interface);
    if (reply.type() != QDBusMessage::ReplyMessage) {
        // not worth complaining if they dont have properties, just return the empty
        return properties;
    }

    QList<QVariant> args = reply.arguments();

    if (args.empty()) {
        return properties;
    }

    QList<QVariant>::iterator p = args.begin();

    QVariant variant = *p;

    const QDBusArgument qda = variant.value<QDBusArgument>();

    qda >> properties;

    return properties;
}
void AsemanLinuxNativeNotification::notificationClosed(const QDBusMessage &dmsg)
{
    if( dmsg.type() != QDBusMessage::SignalMessage )
        return ;

    const QVariantList & args = dmsg.arguments();
    if( args.isEmpty() )
        return ;

    uint id = args.at(0).toUInt();
    if( !p->notifies.contains(id) )
        return;

    if( args.count() == 1 )
    {
        Q_EMIT notifyClosed(id);
        p->notifies.remove(id);
        return;
    }

    int type = args.at(1).toInt();
    switch (type) {
    case 1:
        Q_EMIT notifyTimedOut( id );
        break;

    case 2:
    default:
        Q_EMIT notifyClosed( id );
        p->notifies.remove(id);
        break;
    }
}
Esempio n. 6
0
void SHALDeviceNotifier::dumpRemovedMessage( const QDBusMessage & dmsg )
{
    if( dmsg.type() != QDBusMessage::SignalMessage )
        return ;

    QList<QVariant> list = dmsg.arguments();
    if( list.isEmpty() )
        return ;

    QString path = list.at(0).toString();

    if( p->device_list.contains(path) )
        emit this->deviceRemoved( p->device_list.take(path) );

    if( p->features_list.contains(path) )
        p->features_list.remove( path );

    if( p->disc_list.contains(path) )
    {
        SDiscFeatures disc = p->disc_list.take(path);
        p->device_to_disc.remove( disc.parent_str );

        if( p->device_list.contains( disc.parent_str ) )
            emit this->deviceDetected( p->device_list[disc.parent_str] );

        emit this->discRemoved( disc );
    }
}
Esempio n. 7
0
bool
BTAdaptor::validateBtDevice ()
{
    qDebug() << "Validating bluetooth device";
    QDBusMessage msg = QDBusMessage::createMethodCall ("org.bluez",
                                                       mAdapterPath,
                                                       "org.bluez.Adapter",
                                                       "GetProperties");
    
    QDBusMessage reply = QDBusConnection::systemBus ().call (msg);
    if (reply.type () == QDBusMessage::ErrorMessage)
    {
        qWarning() << "Error in dbus call";
        return false;
    }

    QDBusArgument arg = reply.arguments ().at (0).value<QDBusArgument>();
    if (arg.currentType () == QDBusArgument::MapType)
    {
        QMap<QString,QVariant> props = qdbus_cast<QMap<QString,QVariant> > (arg);
        
        QMap<QString,QVariant>::iterator iter;
    	for (iter = props.begin (); iter != props.end (); ++iter)
    	{
        	// ! @todo Perform some validation on the returned properties
        	qDebug() << iter.key () << ":" << iter.value ();
    	}
    }
}
Esempio n. 8
0
void
BTAdaptor::searchBtDevices ()
{
    // Connect to the signal DeviceFound to obtain the list of devices
    QDBusConnection bus = QDBusConnection::systemBus ();
    bool success = bus.connect ("org.bluez",
                                mAdapterPath,
                                "org.bluez.Adapter",
                                "DeviceFound",
                                this,
                                SLOT (deviceFound(QString,QMap<QString,QVariant>)));

    if (!success)
    {
        qDebug() << "Failure in connecting dbus signal";
        return;
    }
    
    QDBusMessage msg = QDBusMessage::createMethodCall ("org.bluez",
                                                       mAdapterPath,
                                                       "org.bluez.Adapter",
                                                       "StartDiscovery");

    QDBusMessage reply = bus.call (msg);
    if (reply.type () == QDBusMessage::ErrorMessage)
    {
        qWarning() << "Error in dbus call to search for devices";
        return ;
    }
}
Esempio n. 9
0
void SIMLockService::LockPhone()
{
    //dbus-send --system --type=method_call
    //--dest=com.nokia.system_ui /com/nokia/system_ui/request com.nokia.system_ui.request.devlock_open
    //string:"com.nokia.mce"
    //string:"/com/nokia/mce/request"
    //string:"com.nokia.mce.request"
    //string:"devlock_callback"
    //uint32:'3'


	QDBusMessage reply = LockInterface->call("devlock_open",
						 "com.nokia.mce",
						 "/com/nokia/mce/request",
						 "com.nokia.mce.request",
						 "devlock_callback", (quint32)3);



	if(reply.type() == QDBusMessage::ErrorMessage)
	    qDebug() << "Failed to lock phone:" << reply.errorName() << reply.errorMessage();

	if(reply.arguments()[0].toBool() == true)
	    qDebug() << "Phone locked";
	else
	    qDebug() << "Phone failed to lock";


}
Esempio n. 10
0
void NetworkDevice::disconnectDevice()
{
    QDBusMessage query = m_networkDeviceInterface->call("Disconnect");
    if(query.type() != QDBusMessage::ReplyMessage)
        qCWarning(dcNetworkManager()) << query.errorName() << query.errorMessage();

}
Esempio n. 11
0
void KWalletExecuter::cleanupTestCase()
{
    QDBusMessage msg =
        QDBusMessage::createMethodCall("org.kde.kwalletd", "/MainApplication", "org.kde.KApplication", "quit");
    const QDBusMessage reply = QDBusConnection::sessionBus().call(msg);

    Q_ASSERT(reply.type() != QDBusMessage::ErrorMessage);
}
bool DbusPopupHandler::initObjects()
{
	if (!initNotifyInterface())
		return false;

	FServerInfo = new ServerInfo;

	QDBusMessage replyCaps = FNotifyInterface->call(QDBus::Block, "GetCapabilities");
	if (replyCaps.type() != QDBusMessage::ErrorMessage)
	{
		for (int i=0; i<replyCaps.arguments().at(0).toStringList().count(); i++)
			LOG_INFO(QString("Capabilities: %1").arg(replyCaps.arguments().at(0).toStringList().at(i)));
		FServerInfo->capabilities = replyCaps.arguments().at(0).toStringList();
		FAllowActions = FServerInfo->capabilities.contains("actions");
	}
	else
		LOG_WARNING(QString("Capabilities: DBus Error: %1").arg(replyCaps.errorMessage()));

	QDBusMessage replyInfo = FNotifyInterface->call(QDBus::Block, "GetServerInformation");
	if (replyInfo.type() != QDBusMessage::ErrorMessage)
	{
		for (int i=0; i<replyInfo.arguments().count(); i++)
			LOG_INFO(QString("Server Information: %1").arg(replyInfo.arguments().at(i).toString()));

		FServerInfo->name = replyInfo.arguments().at(0).toString();
		FServerInfo->vendor = replyInfo.arguments().at(1).toString();
		FServerInfo->version = replyInfo.arguments().at(2).toString();
		FServerInfo->spec_version = replyInfo.arguments().at(3).toString();

	}
	else
		LOG_WARNING(QString("Server Information: DBus Error: %1").arg(replyInfo.errorMessage()));

	if (FAllowActions)
	{
		connect(FNotifyInterface,SIGNAL(ActionInvoked(uint,QString)),this,SLOT(onActionInvoked(uint,QString)));
		connect(FNotifyInterface,SIGNAL(NotificationClosed(uint,uint)),this,SLOT(onNotificationClosed(uint,uint)));
		LOG_INFO(QLatin1String("Actions supported."));
	}
	else
		LOG_INFO(QLatin1String("Actions not supported."));

	FNotifications->insertNotificationHandler(NHO_DBUSPOPUP, this);

	return true;
}
Esempio n. 13
0
void ColordEngine::gotDevices(const QDBusMessage &message)
{
    if (message.type() == QDBusMessage::ReplyMessage && message.arguments().size() == 1) {
        QDBusArgument argument = message.arguments().first().value<QDBusArgument>();
        ObjectPathList paths = qdbus_cast<ObjectPathList>(argument);
        foreach (const QDBusObjectPath &path, paths) {
            deviceAdded(path);
        }
Esempio n. 14
0
int QDBusInterfacePrivate::metacall(QMetaObject::Call c, int id, void **argv)
{
    Q_Q(QDBusInterface);

    if (c == QMetaObject::InvokeMetaMethod) {
        int offset = metaObject->methodOffset();
        QMetaMethod mm = metaObject->method(id + offset);

        if (mm.methodType() == QMetaMethod::Signal) {
            // signal relay from D-Bus world to Qt world
            QMetaObject::activate(q, metaObject, id, argv);

        } else if (mm.methodType() == QMetaMethod::Slot || mm.methodType() == QMetaMethod::Method) {
            // method call relay from Qt world to D-Bus world
            // get D-Bus equivalent signature
            QString methodName = QString::fromLatin1(mm.name());
            const int *inputTypes = metaObject->inputTypesForMethod(id);
            int inputTypesCount = *inputTypes;

            // we will assume that the input arguments were passed correctly
            QVariantList args;
            args.reserve(inputTypesCount);
            int i = 1;
            for ( ; i <= inputTypesCount; ++i)
                args << QVariant(inputTypes[i], argv[i]);

            // make the call
            QDBusMessage reply = q->callWithArgumentList(QDBus::Block, methodName, args);

            if (reply.type() == QDBusMessage::ReplyMessage) {
                // attempt to demarshall the return values
                args = reply.arguments();
                QVariantList::ConstIterator it = args.constBegin();
                const int *outputTypes = metaObject->outputTypesForMethod(id);
                int outputTypesCount = *outputTypes++;

                if (mm.returnType() != QMetaType::UnknownType && mm.returnType() != QMetaType::Void) {
                    // this method has a return type
                    if (argv[0] && it != args.constEnd())
                        copyArgument(argv[0], *outputTypes++, *it);

                    // skip this argument even if we didn't copy it
                    --outputTypesCount;
                    ++it;
                }

                for (int j = 0; j < outputTypesCount && it != args.constEnd(); ++i, ++j, ++it) {
                    copyArgument(argv[i], outputTypes[j], *it);
                }
            }

            // done
            lastError = QDBusError(reply);
            return -1;
        }
    }
    return id;
}
Esempio n. 15
0
QDebug operator<<(QDebug dbg, const QDBusMessage &msg)
{
    dbg.nospace() << "QDBusMessage(type=" << msg.type()
                  << ", service=" << msg.service();
    if (msg.type() == QDBusMessage::MethodCallMessage ||
        msg.type() == QDBusMessage::SignalMessage)
        dbg.nospace() << ", path=" << msg.path()
                      << ", interface=" << msg.interface()
                      << ", member=" << msg.member();
    if (msg.type() == QDBusMessage::ErrorMessage)
        dbg.nospace() << ", error name=" << msg.errorName()
                      << ", error message=" << msg.errorMessage();
    dbg.nospace() << ", signature=" << msg.signature()
                  << ", contents=(";
    debugVariantList(dbg, msg.arguments());
    dbg.nospace() << ") )";
    return dbg.space();
}
Esempio n. 16
0
QVariant QDBusAbstractInterfacePrivate::property(const QMetaProperty &mp) const
{
    if (!connection.isConnected())    // not connected
        return QVariant();

    // try to read this property
    QDBusMessage msg = QDBusMessage::createMethodCall(service, path,
                       QLatin1String(DBUS_INTERFACE_PROPERTIES),
                       QLatin1String("Get"));
    msg << interface << QString::fromUtf8(mp.name());
    QDBusMessage reply = connection.call(msg, QDBus::Block);

    if (reply.type() == QDBusMessage::ReplyMessage && reply.arguments().count() == 1 &&
            reply.signature() == QLatin1String("v")) {
        QVariant value = qvariant_cast<QDBusVariant>(reply.arguments().at(0)).variant();

        // make sure the type is right
        if (qstrcmp(mp.typeName(), value.typeName()) == 0) {
            if (mp.type() == QVariant::LastType)
                // QVariant is special in this context
                return qvariant_cast<QDBusVariant>(reply.arguments().at(0)).variant();

            return value;
        }
    }

    // there was an error...
    if (reply.type() == QDBusMessage::ErrorMessage)
        lastError = reply;
    else if (reply.signature() != QLatin1String("v")) {
        QString errmsg = QLatin1String("Invalid signature `%1' in return from call to "
                                       DBUS_INTERFACE_PROPERTIES);
        lastError = QDBusError(QDBusError::InvalidSignature, errmsg.arg(reply.signature()));
    } else {
        QString errmsg = QLatin1String("Unexpected type `%1' when retrieving property "
                                       "`%2 %3.%4'");
        lastError = QDBusError(QDBusError::InvalidSignature,
                               errmsg.arg(QLatin1String(reply.arguments().at(0).typeName()),
                                          QLatin1String(mp.typeName()),
                                          interface, QString::fromUtf8(mp.name())));
    }

    return QVariant();
}
Esempio n. 17
0
QList<QVariant> QmIPCInterface::get(const QString& method,
                                    const QVariant& arg1,
                                    const QVariant& arg2) {
    QList<QVariant> results;
    QDBusMessage msg = call(method, arg1, arg2);
    if (msg.type() == QDBusMessage::ReplyMessage) {
        results  = msg.arguments();
    }
    return results;
}
Esempio n. 18
0
void GnomeMediaKeys::registerFinished(QDBusPendingCallWatcher *watcher)
{
    QDBusMessage reply = watcher->reply();
    watcher->deleteLater();

    if (QDBusMessage::ErrorMessage!=reply.type()) {
        connect(mk, SIGNAL(MediaPlayerKeyPressed(QString, QString)),  this, SLOT(keyPressed(QString,QString)));
        disconnectDaemon();
    }
}
Esempio n. 19
0
/*!
    Releases the claim on the bus service name \a serviceName, that
    had been previously registered with registerService(). If this
    application had ownership of the name, it will be released for
    other applications to claim. If it only had the name queued, it
    gives up its position in the queue.
*/
QDBusReply<bool>
QDBusConnectionInterface::unregisterService(const QString &serviceName)
{
    QDBusMessage reply = call(QLatin1String("ReleaseName"), serviceName);
    if (reply.type() == QDBusMessage::ReplyMessage) {
        bool success = reply.arguments().at(0).toUInt() == DBUS_RELEASE_NAME_REPLY_RELEASED;
        reply.setArguments(QVariantList() << success);
    }
    return reply;
}
Esempio n. 20
0
/*!
    \internal
    Constructs a QDBusError from a QDBusMessage.
*/
QDBusError::QDBusError(const QDBusMessage &qdmsg)
    : code(NoError)
{
    if (qdmsg.type() != QDBusMessage::ErrorMessage)
        return;

    code = ::get(qdmsg.errorName().toUtf8().constData());
    nm = qdmsg.errorName();
    msg = qdmsg.errorMessage();
}
Esempio n. 21
0
bool SystemSession::restart(bool force) const
{
#ifdef Q_OS_LINUX
	if(mCapabilities & GnomeSessionManager)
	{
		QDBusInterface dbusInterface("org.gnome.SessionManager", "/org/gnome/SessionManager", "org.gnome.SessionManager", QDBusConnection::sessionBus());
		QDBusMessage reply = dbusInterface.call("RequestReboot");

		if(reply.type() != QDBusMessage::ErrorMessage)
			return true;
	}
	if(mCapabilities & KdeKSMServer)
	{
		QDBusInterface dbusInterface("org.kde.ksmserver", "/KSMServer", "org.kde.KSMServerInterface", QDBusConnection::sessionBus());
		QDBusMessage reply = dbusInterface.call("logout", 0, 1, (force ? 2 : 1));

		if(reply.type() != QDBusMessage::ErrorMessage)
			return true;
	}
	if(mCapabilities & FreedesktopConsoleKit)
	{
		QDBusInterface dbusInterface("org.freedesktop.ConsoleKit", "/org/freedesktop/ConsoleKit/Manager", "org.freedesktop.ConsoleKit.Manager", QDBusConnection::systemBus());
		QDBusMessage reply = dbusInterface.call("Restart");

		if(reply.type() != QDBusMessage::ErrorMessage)
			return true;
	}
	if(mCapabilities & FreedesktopHal)
	{
		QDBusInterface dbusInterface("org.freedesktop.Hal", "/org/freedesktop/Hal/devices/computer", "org.freedesktop.Hal.Device.SystemPowerManagement", QDBusConnection::systemBus());
		QDBusMessage reply = dbusInterface.call("Reboot");

		if(reply.type() != QDBusMessage::ErrorMessage)
			return true;
	}

	return false;
#endif
#ifdef Q_OS_WIN
	return ExitWindowsEx(EWX_REBOOT | (force ? EWX_FORCE : 0), SHTDN_REASON_MAJOR_OTHER | SHTDN_REASON_MINOR_OTHER);
#endif
}
Esempio n. 22
0
/*!
    \since 4.6
    Creates a QDBusPendingCall object based on the message \a msg.
    The message must be of type QDBusMessage::ErrorMessage or
    QDBusMessage::ReplyMessage (that is, a message that is typical
    of a completed call).

    This function is useful for code that requires simulating a pending
    call, but that has already finished.

    \sa fromError()
*/
QDBusPendingCall QDBusPendingCall::fromCompletedCall(const QDBusMessage &msg)
{
    QDBusPendingCallPrivate *d = 0;
    if (msg.type() == QDBusMessage::ErrorMessage ||
        msg.type() == QDBusMessage::ReplyMessage) {
        d = new QDBusPendingCallPrivate(QDBusMessage(), 0);
        d->replyMessage = msg;
    }

    return QDBusPendingCall(d);
}
Esempio n. 23
0
/*!
    Requests to register the service name \a serviceName on the
    bus. The \a qoption flag specifies how the D-Bus server should behave
    if \a serviceName is already registered. The \a roption flag
    specifies if the server should allow another application to
    replace our registered name.

    If the service registration succeeds, the serviceRegistered()
    signal will be emitted. If we are placed in queue, the signal will
    be emitted when we obtain the name. If \a roption is
    AllowReplacement, the serviceUnregistered() signal will be emitted
    if another application replaces this one.

    \sa unregisterService()
*/
QDBusReply<QDBusConnectionInterface::RegisterServiceReply>
QDBusConnectionInterface::registerService(const QString &serviceName,
                                          ServiceQueueOptions qoption,
                                          ServiceReplacementOptions roption)
{
    // reconstruct the low-level flags
    uint flags = 0;
    switch (qoption) {
    case DontQueueService:
        flags = DBUS_NAME_FLAG_DO_NOT_QUEUE;
        break;
    case QueueService:
        flags = 0;
        break;
    case ReplaceExistingService:
        flags = DBUS_NAME_FLAG_DO_NOT_QUEUE | DBUS_NAME_FLAG_REPLACE_EXISTING;
        break;
    }

    switch (roption) {
    case DontAllowReplacement:
        break;
    case AllowReplacement:
        flags |= DBUS_NAME_FLAG_ALLOW_REPLACEMENT;
        break;
    }

    QDBusMessage reply = call(QLatin1String("RequestName"), serviceName, flags);
//    qDebug() << "QDBusConnectionInterface::registerService" << serviceName << "Reply:" << reply;

    // convert the low-level flags to something that we can use
    if (reply.type() == QDBusMessage::ReplyMessage) {
        uint code = 0;

        switch (reply.arguments().at(0).toUInt()) {
        case DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER:
        case DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER:
            code = uint(ServiceRegistered);
            break;

        case DBUS_REQUEST_NAME_REPLY_EXISTS:
            code = uint(ServiceNotRegistered);
            break;

        case DBUS_REQUEST_NAME_REPLY_IN_QUEUE:
            code = uint(ServiceQueued);
            break;
        }

        reply.setArguments(QVariantList() << code);
    }

    return reply;
}
Esempio n. 24
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow), m_timer(), m_totalNeededTime(0,0), m_spentTime(0,0), m_belowAlarmTime(false), m_belowEndTime(false),
    m_dbusInterface(0), m_alarmTime(60), m_useLED(true), m_useSounds(true)
{
    ui->setupUi(this);

    m_topics.push_back(new AgendaTopic("topic #1", QTime(0,5)));
    m_topics.push_back(new AgendaTopic("topic #2", QTime(0,15)));

    calculateTotalTimes();

    m_currentTopic = 1;

    mainWindowSetup();
    setupMenus();

    connect(ui->next, SIGNAL(clicked()), this, SLOT(switchToNextTopic()));
    connect(ui->previous, SIGNAL(clicked()), this, SLOT(switchToPreviousTopic()));
    connect(ui->start, SIGNAL(clicked()), this, SLOT(startOrStop()));

    connect(ui->plus15, SIGNAL(clicked()), this, SLOT(add15m()));
    connect(ui->plus5, SIGNAL(clicked()), this, SLOT(add5m()));
    connect(ui->plus1, SIGNAL(clicked()), this, SLOT(add1m()));

    connect(ui->minus15, SIGNAL(clicked()), this, SLOT(minus15m()));
    connect(ui->minus5, SIGNAL(clicked()), this, SLOT(minus5m()));
    connect(ui->minus1, SIGNAL(clicked()), this, SLOT(minus1m()));

    connect(&m_timer, SIGNAL(timeout()), this, SLOT(timeElapsed()));

#ifdef IS_MAEMO
    m_dbusInterface = new QDBusInterface(MCE_SERVICE, MCE_REQUEST_PATH, MCE_REQUEST_IF, QDBusConnection::systemBus(), this);
    QDBusMessage reply = m_dbusInterface->call(MCE_ENABLE_LED);
    if (reply.type() == QDBusMessage::ErrorMessage)
        qDebug() << reply.errorMessage();
#endif

    // set up the output audio

    QAudioFormat format;
    // Set up the format, eg.
    format.setFrequency(44100);
    format.setChannels(1);
    format.setSampleSize(16);
    format.setCodec("audio/pcm");
    format.setByteOrder(QAudioFormat::LittleEndian);
    format.setSampleType(QAudioFormat::SignedInt);

    QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice());

    m_audioOut = new QAudioOutput(format);
    // connect(m_audioOut,SIGNAL(stateChanged(QAudio::State)),SLOT(finishedPlaying(QAudio::State)));
}
Esempio n. 25
0
bool TimeoutsTest::identityAlive(const QString &path)
{
    QDBusConnection conn = SIGNOND_BUS;

    QString interface = QLatin1String("com.google.code.AccountsSSO.SingleSignOn.Identity");
    QDBusMessage msg = QDBusMessage::createMethodCall(SIGNOND_SERVICE,
                                                      path,
                                                      interface,
                                                      "getInfo");
    QDBusMessage reply = conn.call(msg);
    return (reply.type() == QDBusMessage::ReplyMessage);
}
Esempio n. 26
0
void DeviceHandler::slotAsyncReply( int callId, const QDBusMessage& reply )
{
    QString method = m_calls[callId];

    if (reply.type() == QDBusMessage::ReplyMessage) {
        odebug << "********* " << m_devProxy->interface() << " " << method << " success" << oendl;
        if( m_pool ) {
            if( reply.count() > 0 )
                m_pool->handlerSuccess( this, method, reply[0].toString() );
            else
                m_pool->handlerSuccess( this, method, QString::null );
        }
    }
    else if (reply.type() == QDBusMessage::ErrorMessage) {
        odebug << "********* " << m_devProxy->interface() << " " << method << " fail: " << reply.error().name() << ": " << reply.error().message() << oendl;
        if( m_pool )
            m_pool->handlerError( this, method, reply.error().name(), reply.error().message() );
    }

    m_calls.remove(callId);
}
Esempio n. 27
0
QVariant ModeControlEntity::_call_ret(const QString req) const
{
    if (!m_iface) {
        return QVariant();
    }
    QDBusMessage m = m_iface->call(req);
    if (m.type() == QDBusMessage::ErrorMessage || m.arguments().count() == 0) {
        qWarning() << "Could not get activity state:" << m.errorMessage();
        return QVariant();
    }
    return m.arguments().first();
}
Esempio n. 28
0
void IMQDBus::useKopete()
{
    QDBusMessage msg = QDBusMessage::createMethodCall ( "org.kde.kopete", "/Kopete", "org.kde.Kopete", "setStatusMessage" );
    QList<QVariant> args;
    args.append ( QVariant ( m_statusMsg ) );
    msg.setArguments ( args );
    QDBusMessage rep = QDBusConnection::sessionBus().call ( msg );
    if ( rep.type() == QDBusMessage::ErrorMessage ) {
        qDebug() <<  "ERROR" << rep.errorMessage();
        return;
    }
}
Esempio n. 29
0
void SHALDeviceNotifier::dumpAddedMessage( const QDBusMessage & dmsg )
{
    if( dmsg.type() != QDBusMessage::SignalMessage )
        return ;

    QList<QVariant> list = dmsg.arguments();
    if( list.isEmpty() )
        return ;

    QString path = list.at(0).toString();

    this->detect( path );
}
Esempio n. 30
0
/*!
    Client side property call that directly accesses properties through the DBus interface.
    Read and reset have special hardcoded DBus methods due to the nature of QtDBus properties
    without an adaptor class incorrectly forwarding the metacall type
*/
QVariant ObjectEndPoint::invokeRemoteProperty(int metaIndex, const QVariant& arg, int /*returnType*/, QMetaObject::Call c )
{
    Q_ASSERT(d->endPointType == ObjectEndPoint::Client);

    const QMetaObject *imeta = service->metaObject();
    QMetaProperty property = imeta->property(metaIndex);

    if (c == QMetaObject::WriteProperty) {
        // Writing property, direct property DBus call
        if (!iface->setProperty(property.name(), arg)) {
            qWarning() << "Service property write call failed";
        }

    } else if (c == QMetaObject::ResetProperty) {
        // Resetting property, direct special method DBus call
        QVariantList args;
        args << QVariant(QLatin1String(property.name()));
        QDBusMessage msg = iface->callWithArgumentList(QDBus::Block, QLatin1String("propertyReset"), args);
        if (msg.type() == QDBusMessage::InvalidMessage) {
            qWarning() << "Service property reset call failed";
        }

    } else if (c == QMetaObject::ReadProperty) {
        // Reading property, direct special method DBus call
        QVariantList args;
        args << QVariant(QLatin1String(property.name()));
        QDBusMessage msg = iface->callWithArgumentList(QDBus::Block, QLatin1String("propertyRead"), args);
        if (msg.type() == QDBusMessage::ReplyMessage) {
            QVariantList retList = msg.arguments();
            return retList[0];
        } else {
            qWarning() << "Service property read call failed" << msg.errorMessage();
        }
    } else {
        qWarning() << "Invalid property call";
    }

    return QVariant();
}