本文整理汇总了C++中QDBusMessage::setArguments方法的典型用法代码示例。如果您正苦于以下问题:C++ QDBusMessage::setArguments方法的具体用法?C++ QDBusMessage::setArguments怎么用?C++ QDBusMessage::setArguments使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDBusMessage
的用法示例。
在下文中一共展示了QDBusMessage::setArguments方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: startCamera
void Camera::startCamera()
{
QDBusConnection bus = QDBusConnection::sessionBus();
bus.connect("com.nokia.maemo.CameraService",
"/",
"com.nokia.maemo.meegotouch.CameraInterface",
"captureCanceled",
this, SLOT(captureCanceled(QString)));
bus.connect("com.nokia.maemo.CameraService",
"/",
"com.nokia.maemo.meegotouch.CameraInterface",
"captureCompleted",
this, SLOT(captureCompleted(QString,QString)));
QDBusMessage message = QDBusMessage::createMethodCall(
"com.nokia.maemo.CameraService",
"/",
"com.nokia.maemo.meegotouch.CameraInterface",
"showCamera");
QList<QVariant> args;
args << (uint)0 << "" << "still-capture" << true;
message.setArguments(args);
QDBusMessage reply = bus.call(message);
if (reply.type() == QDBusMessage::ErrorMessage) {
qDebug() << Q_FUNC_INFO << "reply.type == errormessage; name=" << reply.errorName() << "; message=" << reply.errorMessage();
bus.disconnect("com.nokia.maemo.CameraService",
"/",
"com.nokia.maemo.meegotouch.CameraInterface",
"captureCanceled",
this, SLOT(captureCanceled(QString)));
bus.disconnect("com.nokia.maemo.CameraService",
"/",
"com.nokia.maemo.meegotouch.CameraInterface",
"captureCompleted",
this, SLOT(captureCompleted(QString,QString)));
if (m_lastEcId)
this->callback(m_lastEcId, "");
}
}
示例2: qDebug
void
Mp3tunesAmarokClient::harmonyDownloadReady( const Mp3tunesHarmonyDownload &download )
{
qDebug() << "Got message about ready: " << download.trackTitle() << " by " << download.artistName() << " on " << download. albumTitle();
QString name = "org.kde.amarok";
QDBusMessage m = QDBusMessage::createMethodCall( name,
"/Mp3tunesHarmonyHandler",
"",
"emitDownloadReady" );
QList<QVariant> args;
args.append( download.serialize() );
m.setArguments(args);
QDBusMessage response = QDBusConnection::sessionBus().call( m );
if( response.type() == QDBusMessage::ErrorMessage )
{
qDebug() << "Got ERROR response harmonyDownloadReady";
qDebug() << response.errorName() << ": " << response.errorMessage();
}
}
示例3: showMessage
void SeafileTrayIcon::showMessage(const QString &title,
const QString &message,
const QString &repo_id,
const QString &commit_id,
const QString &previous_commit_id,
MessageIcon icon,
int millisecondsTimeoutHint)
{
#ifdef Q_OS_MAC
repo_id_ = repo_id;
commit_id_ = commit_id;
previous_commit_id_ = previous_commit_id;
if (!utils::mac::isOSXMountainLionOrGreater()) {
QIcon info_icon(":/images/info.png");
TrayNotificationWidget* trayNotification = new TrayNotificationWidget(info_icon.pixmap(32, 32), title, message);
tnm->append(trayNotification);
return;
}
QSystemTrayIcon::showMessage(title, message, icon, millisecondsTimeoutHint);
#elif defined(Q_OS_LINUX)
repo_id_ = repo_id;
Q_UNUSED(icon);
QVariantMap hints;
QString brand = getBrand();
hints["resident"] = QVariant(true);
hints["desktop-entry"] = QVariant(brand);
QList<QVariant> args = QList<QVariant>() << brand << quint32(0) << brand
<< title << message << QStringList () << hints << qint32(-1);
QDBusMessage method = QDBusMessage::createMethodCall("org.freedesktop.Notifications","/org/freedesktop/Notifications", "org.freedesktop.Notifications", "Notify");
method.setArguments(args);
QDBusConnection::sessionBus().asyncCall(method);
#else
TrayMessage msg;
msg.title = title;
msg.message = message;
msg.icon = icon;
msg.repo_id = repo_id;
msg.commit_id = commit_id;
msg.previous_commit_id = previous_commit_id;
pending_messages_.enqueue(msg);
#endif
}
示例4: setState
void PowerManagerNux::setState(uint dobusy, const QString &/* reason*/)
{
qDebug() << " [M/Nux] System/PowerManager: set new state";
if(m_busy == dobusy){
return;
}
m_intended_state = dobusy ? busy : idle;
if (m_state == error || m_state == m_intended_state || m_state == request_busy || m_state == request_idle)
return;
QDBusMessage call;
if (!m_use_gsm)
call = QDBusMessage::createMethodCall(
"org.freedesktop.PowerManager",
"/org/freedesktop/PowerManager/Inhibit",
"org.freedesktop.PowerManager.Inhibit",
dobusy ? "Inhibit" : "UnInhibit");
else
call = QDBusMessage::createMethodCall(
"org.gnome.SessionManager",
"/org/gnome/SessionManager",
"org.gnome.SessionManager",
dobusy ? "Inhibit" : "UnInhibit");
m_state = dobusy ? request_busy : request_idle;
QList<QVariant> args;
if(dobusy){
// XXX reason
args << "Hello there";
if (m_use_gsm) args << (uint)0;
args << "User is busy doing something";
if (m_use_gsm) args << (uint)8;
}else{
args << m_cookie;
}
call.setArguments(args);
QDBusPendingCall pcall = QDBusConnection::sessionBus().asyncCall(call, 1000);
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pcall, this);
connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
this, SLOT(OnAsyncReply(QDBusPendingCallWatcher*)));
// XXX untested
m_busy = dobusy;
}
示例5: QString
void
FdoNotifyPlugin::notifyUser( const QString &messageText )
{
QDBusMessage message = QDBusMessage::createMethodCall( "org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications", "Notify" );
QList<QVariant> arguments;
arguments << QString( "Tomahawk" ); //app_name
arguments << quint32( 0 ); //notification_id
arguments << QString(); //app_icon
arguments << QString( "Tomahawk" ); //summary
arguments << messageText.replace("&", "&"); //body
arguments << QStringList(); //actions
QVariantMap dict;
dict["desktop-entry"] = QString( "tomahawk" );
dict[ "image_data" ] = ImageConverter::variantForImage( QImage( RESPATH "icons/tomahawk-icon-128x128.png" ) );
arguments << dict; //hints
arguments << qint32( -1 ); //expire_timeout
message.setArguments( arguments );
QDBusConnection::sessionBus().send( message );
}
示例6: run
void KopeteRunner::run(const Plasma::RunnerContext& context, const Plasma::QueryMatch& match)
{
Q_UNUSED(context)
// HACK: Strip off the "kopete_" prefix
const QString id = match.data().toString();
QString method;
QVariantList args;
if (id == "connect")
method = "connectAll";
else if (id == "disconnect")
method = "disconnectAll";
else if (id == "status")
{
method = "setOnlineStatus";
QStringList status = match.text().split(": ");
status.takeFirst();
QStringList message = match.subtext().split(": ");
message.takeFirst();
args << status.join(": ") << message.join(": ");
}
else if (id == "message")
{
method = "setStatusMessage";
QStringList message = match.text().split(": ");
message.takeFirst();
args << message.join(": ");
}
else if (!QUuid(id).isNull())
{
method = "openChat";
args << id;
}
else
qDebug("Unknown ID: %s", id.toUtf8().constData());
if (!method.isNull())
{
QDBusMessage message = generateMethodCall(method);
message.setArguments(args);
QDBusConnection::sessionBus().send(message);
}
}
示例7: if
int
PlatformUdisks2::open(DeviceItem* item)
{
int ret = -1;
QDBusConnection connection = QDBusConnection::systemBus();
QList<QVariant> args;
QVariantMap map;
args << map;
QString udi = QString("/org/freedesktop/UDisks2/block_devices/%1").arg(item->getUDI());
QDBusMessage message = QDBusMessage::createMethodCall("org.freedesktop.UDisks2", udi, "org.freedesktop.UDisks2.Block", "OpenForRestore");
message.setArguments(args);
QDBusMessage reply = connection.call(message);
if (reply.type() == QDBusMessage::ErrorMessage)
{
QMessageBox msgBox;
msgBox.setText(QString("DBUS error (%1): %2").arg(item->getUDI()).arg(reply.errorMessage()));
msgBox.exec();
ret = -1;
}
else if (reply.arguments().empty() || reply.arguments()[0].userType() != qMetaTypeId<QDBusUnixFileDescriptor>())
{
QMessageBox msgBox;
msgBox.setText(QString("got empty or invalid reply!?"));
msgBox.exec();
errno = EINVAL;
}
else
{
QDBusUnixFileDescriptor fd(qvariant_cast<QDBusUnixFileDescriptor>(reply.arguments()[0]));
if (fd.isValid())
{
ret = ::dup(fd.fileDescriptor());
}
}
qDebug() << "ret" << ret;
return ret;
}
示例8: return
long long
PlatformUdisks::getSize(const QString &devicePath)
{
long long ret;
QDBusConnection connection = QDBusConnection::systemBus();
QDBusMessage message;
QList<QVariant> args;
args << "org.freedesktop.UDisks";
args << "DeviceSize";
message = QDBusMessage::createMethodCall("org.freedesktop.UDisks", devicePath, "org.freedesktop.DBus.Properties", "Get");
message.setArguments(args);
QDBusReply<QDBusVariant> reply = connection.call(message);
if (!reply.isValid())
return(0);
ret = reply.value().variant().toLongLong();
return(ret);
}
示例9: QString
void Mp3tunesAmarokClient::dbusEmitMessage( const QString &message, const QString ¶m = QString() )
{
QString name = "org.kde.amarok";
QDBusMessage m = QDBusMessage::createMethodCall( name,
"/Mp3tunesHarmonyHandler",
"",
message );
if( !param.isEmpty() )
{
QList<QVariant> args;
args.append( param );
m.setArguments(args);
}
QDBusMessage response = QDBusConnection::sessionBus().call( m );
if( response.type() == QDBusMessage::ErrorMessage )
{
qDebug() << "Got ERROR response " << message;
qDebug() << response.errorName() << ": " << response.errorMessage();
}
}
示例10: callWithCallback
/*!
Places a call to the remote method specified by \a method
on this interface, using \a args as arguments. This function
returns immediately after queueing the call. The reply from
the remote function is delivered to the \a returnMethod on
object \a receiver. If an error occurs, the \a errorMethod
on object \a receiver is called instead.
This function returns true if the queueing succeeds. It does
not indicate that the executed call succeeded. If it fails,
the \a errorMethod is called.
The \a returnMethod must have as its parameters the types returned
by the function call. Optionally, it may have a QDBusMessage
parameter as its last or only parameter. The \a errorMethod must
have a QDBusError as its only parameter.
\since 4.3
\sa QDBusError, QDBusMessage
*/
bool QDBusAbstractInterface::callWithCallback(const QString &method,
const QList<QVariant> &args,
QObject *receiver,
const char *returnMethod,
const char *errorMethod)
{
Q_D(QDBusAbstractInterface);
QDBusMessage msg = QDBusMessage::createMethodCall(service(),
path(),
interface(),
method);
msg.setArguments(args);
d->lastError = 0;
return d->connection.callWithCallback(msg,
receiver,
returnMethod,
errorMethod);
}
示例11: main
int main()
{
QDBusMessage myDBusMessage;
//! [0]
QList<QVariant> arguments;
arguments << QVariant(42) << QVariant::fromValue(QDBusVariant(43)) << QVariant("hello");
myDBusMessage.setArguments(arguments);
//! [0]
//! [1]
// call a D-Bus function that returns a D-Bus variant
QVariant v = callMyDBusFunction();
// retrieve the D-Bus variant
QDBusVariant dbusVariant = qvariant_cast<QDBusVariant>(v);
// retrieve the actual value stored in the D-Bus variant
QVariant result = dbusVariant.variant();
//! [1]
return 0;
}
示例12:
bool
PlatformUdisks::isUSB(const QString &udiskPath)
{
QDBusConnection connection = QDBusConnection::systemBus();
QDBusMessage message;
QList<QVariant> args;
args << "org.freedesktop.UDisks";
args << "DriveConnectionInterface";
message = QDBusMessage::createMethodCall("org.freedesktop.UDisks", udiskPath, "org.freedesktop.DBus.Properties", "Get");
message.setArguments(args);
QDBusReply<QDBusVariant> reply = connection.call(message);
if (!reply.isValid())
return false;
if (reply.value().variant().toString() == "usb")
return true;
else
return false;
}
示例13: dropUrls
KIO::DropJob* DragAndDropHelper::dropUrls(const QUrl& destUrl, QDropEvent* event, QWidget* window)
{
const QMimeData* mimeData = event->mimeData();
if (mimeData->hasFormat("application/x-kde-ark-dndextract-service") &&
mimeData->hasFormat("application/x-kde-ark-dndextract-path")) {
const QString remoteDBusClient = mimeData->data("application/x-kde-ark-dndextract-service");
const QString remoteDBusPath = mimeData->data("application/x-kde-ark-dndextract-path");
QDBusMessage message = QDBusMessage::createMethodCall(remoteDBusClient, remoteDBusPath,
"org.kde.ark.DndExtract", "extractSelectedFilesTo");
message.setArguments({destUrl.toDisplayString(QUrl::PreferLocalFile)});
QDBusConnection::sessionBus().call(message);
} else {
// Drop into a directory or a desktop-file
KIO::DropJob *job = KIO::drop(event, destUrl);
KJobWidgets::setWindow(job, window);
return job;
}
return 0;
}
示例14: qDebug
void
FdoNotifyPlugin::pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant pushData )
{
Q_UNUSED( caller );
qDebug() << Q_FUNC_INFO;
if ( type != Tomahawk::InfoSystem::InfoNotifyUser || !pushData.canConvert< QVariantMap >() )
{
qDebug() << Q_FUNC_INFO << " not the right type or could not convert the hash";
return;
}
QVariantMap hash = pushData.value< QVariantMap >();
if ( !hash.contains( "message" ) )
{
qDebug() << Q_FUNC_INFO << " hash did not contain a message";
return;
}
QDBusMessage message = QDBusMessage::createMethodCall( "org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications", "Notify" );
QList<QVariant> arguments;
arguments << QString( "Tomahawk" ); //app_name
arguments << quint32( 0 ); //notification_id
arguments << QString(); //app_icon
arguments << QString( "Tomahawk" ); //summary
arguments << hash["message"].toString(); //body
arguments << QStringList(); //actions
QVariantMap dict;
dict["desktop-entry"] = QString( "tomahawk" );
if ( hash.contains( "image" ) )
{
QVariant tempVariant = hash["image"];
QImage tempImage = tempVariant.value< QImage >();
dict["image_data"] = ImageConverter::variantForImage( tempImage );
}
else
dict["image_data"] = ImageConverter::variantForImage( QImage( RESPATH "icons/tomahawk-icon-128x128.png" ) );
arguments << dict; //hints
arguments << qint32( -1 ); //expire_timeout
message.setArguments( arguments );
QDBusConnection::sessionBus().send( message );
}
示例15: error
bool
PlatformUdisks2::doUnmount(const QString &partitionPath)
{
bool ret = true;
QDBusConnection connection = QDBusConnection::systemBus();
QList<QVariant> args;
QVariantMap map;
args << map;
QDBusMessage message = QDBusMessage::createMethodCall("org.freedesktop.UDisks2", partitionPath, "org.freedesktop.UDisks2.Filesystem", "Unmount");
message.setArguments(args);
QDBusMessage reply = connection.call(message);
if (reply.type() == QDBusMessage::ErrorMessage)
{
QMessageBox msgBox;
msgBox.setText(QString("DBUS error (%1): %2").arg(partitionPath).arg(reply.errorMessage()));
msgBox.exec();
ret = false;
}
return(ret);
}