public slots: void shutter_property_modified(int num_updates, QList<Property> updates); void focus_property_modified(int num_updates, QList<Property> updates);
struct Property { QString name; bool added; bool removed; };
Q_DECLARE_METATYPE(Property) Q_DECLARE_METATYPE(QList<Property>) const QDBusArgument & operator<<(QDBusArgument &arg, const Property &change) { arg.beginStructure(); arg << change.name << change.added << change.removed; arg.endStructure(); return arg; } const QDBusArgument & operator>>(const QDBusArgument &arg, Property &change) { arg.beginStructure(); arg >> change.name >> change.added >> change.removed; arg.endStructure(); return arg; }
qDBusRegisterMetaType< Property >(); qDBusRegisterMetaType< QList<Property> >();
#define DBUS_SHUTTER_RELEASE_BUTTON "/org/freedesktop/Hal/devices/platform_cam_launch" #define DBUS_FOCUS_BUTTON "/org/freedesktop/Hal/devices/platform_cam_focus" QDBusConnection::systemBus().connect( QString(), DBUS_SHUTTER_RELEASE_BUTTON, "org.freedesktop.Hal.Device", "PropertyModified", this, SLOT(shutter_property_modified(int, QList<Property>))); QDBusConnection::systemBus().connect( QString(), DBUS_FOCUS_BUTTON, "org.freedesktop.Hal.Device", "PropertyModified", this, SLOT(focus_property_modified(int, QList<Property>)));
void Camera::shutter_property_modified(int num_updates, QList<Property> updates) { QDBusInterface propertyInterface("org.freedesktop.Hal", DBUS_SHUTTER_RELEASE_BUTTON, "org.freedesktop.Hal.Device", QDBusConnection::systemBus()); bool pressed = propertyInterface.call("GetProperty", "button.state.value").arguments().at(0).toBool(); if (pressed) { capture_image(); } } void Camera::focus_property_modified(int num_updates, QList<Property> updates) { QDBusInterface propertyInterface("org.freedesktop.Hal", DBUS_FOCUS_BUTTON, "org.freedesktop.Hal.Device", QDBusConnection::systemBus()); bool pressed = propertyInterface.call("GetProperty", "button.state.value").arguments().at(0).toBool(); if (pressed) { focus(); } }