本文整理汇总了C++中QDBusArgument类的典型用法代码示例。如果您正苦于以下问题:C++ QDBusArgument类的具体用法?C++ QDBusArgument怎么用?C++ QDBusArgument使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QDBusArgument类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getPixmapFromHint
QPixmap Notification::getPixmapFromHint(const QVariant &argument) const
{
int width, height, rowstride, bitsPerSample, channels;
bool hasAlpha;
QByteArray data;
const QDBusArgument arg = argument.value<QDBusArgument>();
arg.beginStructure();
arg >> width;
arg >> height;
arg >> rowstride;
arg >> hasAlpha;
arg >> bitsPerSample;
arg >> channels;
arg >> data;
arg.endStructure();
bool rgb = !hasAlpha && channels == 3 && bitsPerSample == 8;
QImage::Format imageFormat = rgb ? QImage::Format_RGB888 : QImage::Format_ARGB32;
QImage img = QImage((uchar*)data.constData(), width, height, imageFormat);
if (!rgb)
img = img.rgbSwapped();
return QPixmap::fromImage(img);
}
示例2: Py_INCREF
static PyObject *meth_QDBusArgument_beginMap(PyObject *sipSelf, PyObject *sipArgs)
{
PyObject *sipParseErr = NULL;
{
int a0;
int a1;
QDBusArgument *sipCpp;
if (sipParseArgs(&sipParseErr, sipArgs, "Bii", &sipSelf, sipType_QDBusArgument, &sipCpp, &a0, &a1))
{
Py_BEGIN_ALLOW_THREADS
sipCpp->beginMap(a0,a1);
Py_END_ALLOW_THREADS
Py_INCREF(Py_None);
return Py_None;
}
}
/* Raise an exception if the arguments couldn't be parsed. */
sipNoMethod(sipParseErr, sipName_QDBusArgument, sipName_beginMap, doc_QDBusArgument_beginMap);
return NULL;
}
示例3: qDebug
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 ();
}
}
}
示例4: qCWarning
void Mpris2Player::copyProperty(const QString &name, const QVariant &value,
const QVariant::Type &expectedType)
{
QVariant tmp = value;
// We protect our users from bogus values
if (tmp.userType() == qMetaTypeId<QDBusArgument>()) {
if (expectedType == QVariant::Map) {
QDBusArgument arg = tmp.value<QDBusArgument>();
if (arg.currentType() != QDBusArgument::MapType) {
qCWarning(MPRIS2_PLAYER) << m_serviceName << "exports" << name
<< "with the wrong type; it should be D-Bus type \"a{sv}\"";
return;
}
QVariantMap map;
arg >> map;
if (name == QStringLiteral("Metadata")) {
if (!decodeUri(map, QStringLiteral("mpris:artUrl"))) {
qCWarning(MPRIS2_PLAYER) << m_serviceName
<< "has an invalid URL for the mpris:artUrl entry of the \"Metadata\" property";
}
if (!decodeUri(map, QStringLiteral("xesam:url"))) {
qCWarning(MPRIS2_PLAYER) << m_serviceName
<< "has an invalid URL for the xesam:url entry of the \"Metadata\" property";
}
}
tmp = QVariant(map);
}
}
示例5: QObject
UdisksManager::UdisksManager(QObject *parent)
: QObject(parent)
{
QDBusConnection system = QDBusConnection::systemBus();
if (!system.isConnected())
{
emit error(tr("Cannot connect to Udisks daemon"));
}
system.connect("org.freedesktop.UDisks",
"/org/freedesktop/UDisks",
"org.freedesktop.UDisks",
"DeviceAdded",
this,
SLOT(onDeviceAdded(QDBusObjectPath)));
system.connect("org.freedesktop.UDisks",
"/org/freedesktop/UDisks",
"org.freedesktop.UDisks",
"DeviceRemoved",
this,
SLOT(onDeviceRemoved(QDBusObjectPath)));
system.connect("org.freedesktop.UDisks",
"/org/freedesktop/UDisks",
"org.freedesktop.UDisks",
"DeviceChanged",
this,
SLOT(onDeviceChanged(QDBusObjectPath)));
QDBusInterface devEnum("org.freedesktop.UDisks",
"/org/freedesktop/UDisks",
"org.freedesktop.UDisks",
QDBusConnection::systemBus());
QDBusMessage enumRes = devEnum.call("EnumerateDevices");
// TODO/FIXME: error checking
// if (enumRes.type() == QDBusMessage::ErrorMessage)
// {
// fprintf(stderr, "ERROR: Can't call EnumerateDevices\n");
// fprintf(stderr, " %s : %s\n", qPrintable(enumRes.errorName()), qPrintable(enumRes.errorMessage()));
// }
//
// if (enumRes.type() != QDBusMessage::ReplyMessage || !enumRes.arguments().at(0).canConvert<QDBusArgument>())
// {
// fprintf(stderr, "ERROR: Unexpected result type of EnumerateDevices call\n");
// }
//
const QDBusArgument enumArg = enumRes.arguments().at(0).value<QDBusArgument>();
// if (enumArg.currentType() != QDBusArgument::ArrayType)
// {
// fprintf(stderr, "ERROR: Unexpected argument type of EnumerateDevices call\n");
// }
enumArg.beginArray();
while (!enumArg.atEnd())
{
addDevice(qdbus_cast<QDBusObjectPath>(enumArg));
}
enumArg.endArray();
}
示例6: copyProperty
void PlayerContainer::copyProperty(const QString& propName, const QVariant& _value, QVariant::Type expType, UpdateType updType)
{
QVariant value = _value;
// we protect our users from bogus values
if (value.userType() == qMetaTypeId<QDBusArgument>()) {
if (expType == QVariant::Map) {
QDBusArgument arg = value.value<QDBusArgument>();
if (arg.currentType() != QDBusArgument::MapType) {
kWarning() << m_dbusAddress << "exports" << propName
<< "with the wrong type; it should be D-Bus type \"a{sv}\"";
return;
}
QVariantMap map;
arg >> map;
if (propName == QLatin1String("Metadata")) {
if (!decodeUri(map, QLatin1String("mpris:artUrl"))) {
kWarning() << m_dbusAddress << "has an invalid URL for the mpris:artUrl entry of the \"Metadata\" property";
}
if (!decodeUri(map, QLatin1String("xesam:url"))) {
kWarning() << m_dbusAddress << "has an invalid URL for the xesam:url entry of the \"Metadata\" property";
}
}
value = QVariant(map);
}
}
示例7: QDBusConnection
bool TransportTracker::btConnectivityStatus()
{
FUNCTION_CALL_TRACE;
bool btOn = false;
QDBusConnection *systemBus = new QDBusConnection(QDBusConnection::connectToBus(QDBusConnection::SystemBus,
QStringLiteral("buteo_system_bus2")));
QDBusMessage methodCallMsg = QDBusMessage::createMethodCall("org.bluez",
"/",
"org.bluez.Manager",
"DefaultAdapter");
QDBusMessage reply = systemBus->call(methodCallMsg);
if (reply.type() == QDBusMessage::ErrorMessage)
{
LOG_WARNING("This device does not have a BT adapter");
delete systemBus;
return btOn;
}
QList<QVariant> adapterList = reply.arguments();
// We will take the first adapter in the list
QString adapterPath = qdbus_cast<QDBusObjectPath>(adapterList.at(0)).path();
if (!adapterPath.isEmpty() || !adapterPath.isNull())
{
// Retrive the properties of the adapter and check for "Powered" key
methodCallMsg = QDBusMessage::createMethodCall("org.bluez",
adapterPath,
"org.bluez.Adapter",
"GetProperties");
reply = systemBus->call(methodCallMsg);
if (reply.type() == QDBusMessage::ErrorMessage)
{
LOG_WARNING("Error in retrieving bluetooth properties");
delete systemBus;
return btOn;
}
QDBusArgument arg = reply.arguments().at(0).value<QDBusArgument>();
if (arg.currentType() == QDBusArgument::MapType)
{
// Scan through the dict returned and check for "Powered" entry
QMap<QString,QVariant> dict = qdbus_cast<QMap<QString,QVariant> >(arg);
QMap<QString,QVariant>::iterator iter;
for(iter = dict.begin(); iter != dict.end(); ++iter)
{
if (iter.key() == "Powered")
{
btOn = iter.value().toBool();
LOG_DEBUG ("Bluetooth powered on? " << btOn);
break;
}
}
}
}
delete systemBus;
return btOn;
}
示例8: metaObject
bool DeclarativeDBusAdaptor::handleMessage(const QDBusMessage &message, const QDBusConnection &connection)
{
QVariant variants[10];
QGenericArgument arguments[10];
const QMetaObject * const meta = metaObject();
const QVariantList dbusArguments = message.arguments();
QString member = message.member();
QString interface = message.interface();
// Don't try to handle introspect call. It will be handled
// internally for QDBusVirtualObject derived classes.
if (interface == QLatin1String("org.freedesktop.DBus.Introspectable")) {
return false;
} else if (interface == QLatin1String("org.freedesktop.DBus.Properties")) {
if (member == QLatin1String("Get")) {
interface = dbusArguments.value(0).toString();
member = dbusArguments.value(1).toString();
const QMetaObject * const meta = metaObject();
if (!member.isEmpty() && member.at(0).isUpper())
member = "rc" + member;
for (int propertyIndex = meta->propertyOffset();
propertyIndex < meta->propertyCount();
++propertyIndex) {
QMetaProperty property = meta->property(propertyIndex);
if (QLatin1String(property.name()) != member)
continue;
QVariant value = property.read(this);
if (value.userType() == qMetaTypeId<QJSValue>())
value = value.value<QJSValue>().toVariant();
if (value.userType() == QVariant::List) {
QVariantList variantList = value.toList();
if (variantList.count() > 0) {
QDBusArgument list;
list.beginArray(variantList.first().userType());
foreach (const QVariant &listValue, variantList) {
list << listValue;
}
list.endArray();
value = QVariant::fromValue(list);
}
}
QDBusMessage reply = message.createReply(QVariantList() << value);
connection.call(reply, QDBus::NoBlock);
return true;
}
示例9: decodeNotificationSpecImageHint
static QImage decodeNotificationSpecImageHint(const QDBusArgument& arg)
{
int width, height, rowStride, hasAlpha, bitsPerSample, channels;
QByteArray pixels;
char* ptr;
char* end;
arg.beginStructure();
arg >> width >> height >> rowStride >> hasAlpha >> bitsPerSample >> channels >> pixels;
arg.endStructure();
//qDebug() << width << height << rowStride << hasAlpha << bitsPerSample << channels;
#define SANITY_CHECK(condition) \
if (!(condition)) { \
qWarning() << "Sanity check failed on" << #condition; \
return QImage(); \
}
SANITY_CHECK(width > 0);
SANITY_CHECK(width < 2048);
SANITY_CHECK(height > 0);
SANITY_CHECK(height < 2048);
SANITY_CHECK(rowStride > 0);
#undef SANITY_CHECK
QImage::Format format = QImage::Format_Invalid;
void (*fcn)(QRgb*, const char*, int) = 0;
if (bitsPerSample == 8) {
if (channels == 4) {
format = QImage::Format_ARGB32;
fcn = copyLineARGB32;
} else if (channels == 3) {
format = QImage::Format_RGB32;
fcn = copyLineRGB32;
}
}
if (format == QImage::Format_Invalid) {
qWarning() << "Unsupported image format (hasAlpha:" << hasAlpha << "bitsPerSample:" << bitsPerSample << "channels:" << channels << ")";
return QImage();
}
QImage image(width, height, format);
ptr = pixels.data();
end = ptr + pixels.length();
for (int y=0; y<height; ++y, ptr += rowStride) {
if (ptr + channels * width > end) {
qWarning() << "Image data is incomplete. y:" << y << "height:" << height;
break;
}
fcn((QRgb*)image.scanLine(y), ptr, width);
}
return image;
}
示例10: dBusArgConvertAAY
QStringList Partition::dBusArgConvertAAY(const QDBusArgument &byteArrayArray) const
{
QStringList stringList;
byteArrayArray.beginArray();
while (!byteArrayArray.atEnd())
stringList << qdbus_cast<QByteArray>(byteArrayArray);
byteArrayArray.endArray();
return stringList;
}
示例11: qDebug
void DbusAdapter::_mitakuuluuMessageReceived(QDBusMessage msg) {
qDebug() << "Mitakuuluu messageReceived:" << msg;
QDBusArgument *arg = (QDBusArgument *) msg.arguments().at(0).data();
if (arg->currentType() == QDBusArgument::MapType) {
QMap<QString, QString> argMap = unpackMessage(*arg);
qDebug() << "Extracted argument map:" << argMap;
emit commhistoryd(argMap.value("author"), argMap.value("message"));
}
}
示例12: decodeImageHint
QImage decodeImageHint(const QDBusArgument &arg)
{
int width, height, stride, hasAlpha, bitsPerSample, channels;
QByteArray pixels;
// Decode hint
arg.beginStructure();
arg >> width >> height >> stride >> hasAlpha
>> bitsPerSample >> channels >> pixels;
arg.endStructure();
char *ptr, *end;
// Sanity check
if ((width <= 0) || (width >= 2048) || (height <= 0) ||
(height >= 2048) || (stride <= 0)) {
qWarning() << "Image hint is not valid!";
return QImage();
}
QImage::Format format = QImage::Format_Invalid;
void (*function)(QRgb *, const char *, int) = 0;
if (bitsPerSample == 8) {
if (channels == 4) {
format = QImage::Format_ARGB32;
function = copyLineARGB32;
} else if (channels == 3) {
format = QImage::Format_RGB32;
function = copyLineRGB32;
}
}
if (format == QImage::Format_Invalid) {
qWarning() << "Unsupported image format received from hint (hasAlpha:"
<< hasAlpha << "bitsPerSample:" << bitsPerSample
<< "channels:" << channels << ")";
return QImage();
}
QImage image(width, height, format);
ptr = pixels.data();
end = ptr + pixels.length();
for (int y = 0; y < height; ++y, ptr += stride) {
if (ptr + channels * width > end) {
qWarning() << "Image data is incomplete. y:" << y << "height:" << height;
break;
}
function((QRgb *)image.scanLine(y), ptr, width);
}
return image;
}
示例13: probeDevices
void UPower::probeDevices() {
if (!m_interface)
return;
QDBusArgument argument = m_interface->call( "EnumerateDevices" ).arguments().at(0).value<QDBusArgument>();
if( m_interface->lastError().type() == QDBusError::NoError ) {
argument.beginArray();
while( !argument.atEnd() ) {
QDBusObjectPath dbusPath;
argument >> dbusPath;
deviceAdded(dbusPath.path());
}
}
示例14: while
QList<QDBusObjectPath> Udisks2Lister::GetMountedPartitionsFromDBusArgument(
const QDBusArgument& input) {
QList<QDBusObjectPath> result;
input.beginArray();
while (!input.atEnd()) {
QDBusObjectPath extractedPath;
input >> extractedPath;
result.push_back(extractedPath);
}
input.endArray();
return result;
}
示例15:
bool
Serializable::serialize (QDBusArgument &argument)
{
QMap<QString, SerializablePointer>::const_iterator i;
argument.beginMap (QVariant::String, qMetaTypeId<QDBusVariant>());
for (i = m_attachments.begin (); i != m_attachments.end (); i++) {
argument.beginMapEntry ();
argument << i.key ();
argument << i.value ();
argument.endMapEntry ();
}
argument.endMap ();
return true;
}