本文整理汇总了C++中QDBusMessage::count方法的典型用法代码示例。如果您正苦于以下问题:C++ QDBusMessage::count方法的具体用法?C++ QDBusMessage::count怎么用?C++ QDBusMessage::count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDBusMessage
的用法示例。
在下文中一共展示了QDBusMessage::count方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: launch
bool DBusLauncherImpl::launch(const QString& fileName, const QString& mimeType,
QWidget* window)
{
QFileInfo fileInfo(fileName);
if (!fileInfo.exists() || !fileInfo.isReadable()) return false;
if (mimeType.isEmpty()) return launch(fileName, window);
QDBusError error;
QValueList<QVariant> params;
params.append(fileInfo.absFilePath());
params.append(mimeType);
QDBusMessage reply = m_proxy->sendWithReply("LaunchFile", params, &error);
if (error.isValid())
{
qWarning("Error while launching through D-Bus:\nerror '%s'\nmessage '%s'",
error.name().local8Bit().data(), error.message().local8Bit().data());
return false;
}
if (reply.count() != 1 || reply[0].type() != QVariant::Bool)
{
qWarning("Unexpected launcher reply");
return false;
}
return reply[0].toBool();
}
示例2: slotAsyncReply
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);
}
示例3: shutdown
void KSMServer::shutdown(KApplication::ShutdownConfirm confirm, KApplication::ShutdownType sdtype, KApplication::ShutdownMode sdmode)
{
pendingShutdown.stop();
if(dialogActive)
return;
if(state >= Shutdown) // already performing shutdown
return;
if(state != Idle) // performing startup
{
// perform shutdown as soon as startup is finished, in order to avoid saving partial session
if(!pendingShutdown.isActive())
{
pendingShutdown.start(1000);
pendingShutdown_confirm = confirm;
pendingShutdown_sdtype = sdtype;
pendingShutdown_sdmode = sdmode;
}
return;
}
KConfig *config = KGlobal::config();
config->reparseConfiguration(); // config may have changed in the KControl module
config->setGroup("General");
bool logoutConfirmed = (confirm == KApplication::ShutdownConfirmYes) ? false : (confirm == KApplication::ShutdownConfirmNo)
? true
: !config->readBoolEntry("confirmLogout", true);
bool mayShutdown = (config->readBoolEntry("offerShutdown", true) && DM().canShutdown());
bool maySuspend = config->readBoolEntry("offerSuspend", true);
bool mayHibernate = config->readBoolEntry("offerHibernate", true);
bool lockBeforeSuspendHibernate = config->readBoolEntry("lockBeforeSuspendHibernate", true);
// FIXME At this moment we can't query for SuspendAllowed/HibernateAllowed because
// we haven't support for ConsoleKit yet
// query upower for suspend/hibernate capability
QDBusConnection dbusConnection;
if(maySuspend || mayHibernate)
{
dbusConnection = QDBusConnection::addConnection(QDBusConnection::SystemBus);
if(dbusConnection.isConnected())
{
// can suspend?
if(maySuspend)
{
#ifdef WITH_LOGIND
QDBusMessage dbusMessage = QDBusMessage::methodCall(DBUS_UPOWER_SERVICE, DBUS_UPOWER_PATH, DBUS_UPOWER_INTERFACE, "CanSuspend");
#else
QDBusMessage dbusMessage = QDBusMessage::methodCall(DBUS_UPOWER_SERVICE, DBUS_UPOWER_PATH, DBUS_PROPERTIES_INTERFACE, "Get");
dbusMessage << QDBusData::fromString(DBUS_UPOWER_INTERFACE) << QDBusData::fromString("CanSuspend");
#endif
QDBusMessage dbusReply = dbusConnection.sendWithReply(dbusMessage);
if(dbusReply.type() == QDBusMessage::ReplyMessage && dbusReply.count() == 1)
#ifdef WITH_LOGIND
maySuspend = ("yes" == dbusReply[0].toString());
#else
maySuspend = dbusReply[0].toVariant().value.toBool();
#endif
else
{
maySuspend = false;
kdDebug() << "[dbus/upower] CanSuspend: " << dbusConnection.lastError().message() << "\n";
}
}
// can hibernate?
if(mayHibernate)
{
#ifdef WITH_LOGIND
QDBusMessage dbusMessage = QDBusMessage::methodCall(DBUS_UPOWER_SERVICE, DBUS_UPOWER_PATH, DBUS_UPOWER_INTERFACE, "CanHibernate");
#else
QDBusMessage dbusMessage = QDBusMessage::methodCall(DBUS_UPOWER_SERVICE, DBUS_UPOWER_PATH, DBUS_PROPERTIES_INTERFACE, "Get");
dbusMessage << QDBusData::fromString(DBUS_UPOWER_INTERFACE) << QDBusData::fromString("CanHibernate");
#endif
QDBusMessage dbusReply = dbusConnection.sendWithReply(dbusMessage);
if(dbusReply.type() == QDBusMessage::ReplyMessage && dbusReply.count() == 1)
#ifdef WITH_LOGIND
mayHibernate = ("yes" == dbusReply[0].toString());
#else
mayHibernate = dbusReply[0].toVariant().value.toBool();
#endif
else
{
mayHibernate = false;
kdDebug() << "[dbus/upower] CanHibernate: " << dbusConnection.lastError().message() << "\n";
}
}
示例4: handleMethodCall
// QT3 DBus message handler:
bool LapsusDaemon::handleMethodCall(const QDBusMessage& message)
{
if (message.interface() != LAPSUS_INTERFACE) return false;
if (message.type() != QDBusMessage::MethodCallMessage) return false;
if (message.member() == "listFeatures"
|| message.member() == "listSwitches"
|| message.member() == "listDisplayTypes"
|| message.member() == "getMaxBacklight"
|| message.member() == "getBacklight")
{
if (message.count() != 0)
{
return returnDBusError("org.freedesktop.DBus.Error"
".InvalidSignature", "Expected no arguments",
message);
}
QDBusMessage reply = QDBusMessage::methodReply(message);
if (message.member() == "listFeatures")
{
reply << QDBusData::fromList(listFeatures());
}
else if (message.member() == "listSwitches")
{
reply << QDBusData::fromList(listSwitches());
}
else if (message.member() == "listDisplayTypes")
{
reply << QDBusData::fromList(listDisplayTypes());
}
else if (message.member() == "getMaxBacklight")
{
reply << QDBusData::fromUInt32(getMaxBacklight());
}
else if (message.member() == "getBacklight")
{
reply << QDBusData::fromUInt32(getBacklight());
}
else
{
// Should not happen...
// TODO - some kind of error? to syslog? using dbus?
reply << QDBusData::fromUInt32(0);
}
myConnection->send(reply);
return true;
}
else if (message.member() == "getSwitch"
|| message.member() == "getDisplay")
{
if (message.count() != 1 || message[0].type() != QDBusData::String)
{
return returnDBusError("org.freedesktop.DBus.Error"
".InvalidSignature",
"Expected one string argument",
message);
}
QDBusMessage reply = QDBusMessage::methodReply(message);
if (message.member() == "getSwitch")
{
reply << QDBusData::fromBool(
getSwitch(message[0].toString()));
}
else if (message.member() == "getDisplay")
{
reply << QDBusData::fromBool(
getDisplay(message[0].toString()));
}
else
{
// Should not happen...
// TODO - some kind of error? to syslog? using dbus?
reply << QDBusData::fromBool(false);
}
myConnection->send(reply);
return true;
}
else if (message.member() == "setSwitch"
|| message.member() == "setDisplay")
{
if (message.count() != 2
|| message[0].type() != QDBusData::String
|| message[1].type() != QDBusData::Bool)
{
return returnDBusError("org.freedesktop.DBus.Error"
".InvalidSignature",
"Expected two arguments: string and bool",
message);
}
//.........这里部分代码省略.........
示例5: handleMethodCall
bool LauncherService::handleMethodCall(const QDBusMessage& message)
{
if (message.interface() != interface) return false;
bool ret;
QDBusError error;
if (message.member() == "LaunchFile")
{
switch (message.count())
{
case 1:
if (message[0].type() == QVariant::String)
ret = launch(message[0].toString(), error);
else
return false;
break;
case 2:
if (message[0].type() == QVariant::String &&
message[1].type() == QVariant::String)
{
ret = launch(message[0].toString(), message[1].toString(), error);
}
else
return false;
break;
default:
return false;
}
}
else if (message.member() == "LaunchURL")
{
switch (message.count())
{
case 1:
if (message[0].type() == QVariant::String)
ret = launch(QUrl(message[0].toString()), error);
else
return false;
break;
case 2:
if (message[0].type() == QVariant::String &&
message[1].type() == QVariant::String)
{
ret = launch(QUrl(message[0].toString()), message[1].toString(), error);
}
else
return false;
break;
default:
return false;
}
}
else
return false;
sendReply(message, ret, error);
return true;
}