2010年8月18日 星期三

Maemo 5 DBus 初探

DBus 在Maemo 5系統中是很重要的 IPC 功能,透過DBus可以控制許多硬體如LED, Keypad,甚至是撥電話及發簡訊.現在我想要在程式執行時LCD panel不要進入power saving而關閉也需要透過DBus.

1.Reference

http://wiki.maemo.org/Documentation/Maemo_5_Developer_Guide/DBus/DBus_Basics

http://maemo.org/api_refs/5.0/5.0-final/mce-dev/dbus-names_8h.html#c9f233f336f9be78f223a31866455b80

http://www.mail-archive.com/maemo-developers@maemo.org/msg01889.html


2.以下的程式碼片段就是我想要的囉

    DBusConnection *conn;
DBusMessage *msg = NULL;
DBusError dbus_error;
dbus_bool_t dresult;

#define MCE_SERVICE "com.nokia.mce"
#define MCE_REQUEST_PATH "/com/nokia/mce/request"
#define MCE_REQUEST_IF "com.nokia.mce.request"
#define MCE_PREVENT_BLANK_REQ "req_display_blanking_pause"

dbus_error_init(&dbus_error);

conn = dbus_bus_get (DBUS_BUS_SYSTEM, &dbus_error);

msg = dbus_message_new_method_call(MCE_SERVICE,
MCE_REQUEST_PATH,
MCE_REQUEST_IF,
MCE_PREVENT_BLANK_REQ);
if (msg == NULL)
return;

dresult = dbus_connection_send (conn, msg, NULL);

if (!dresult)
{
dbus_message_unref(msg);
return;
}

dbus_connection_flush(conn);
dbus_message_unref(msg);


沒有留言:

張貼留言