View Single Post
anidel's Avatar
Posts: 1,743 | Thanked: 1,231 times | Joined on Jul 2006 @ Twickenham, UK
#175
I am trying to add rotation to Xournal.

I have defined the DBus message sig as follows:

Code:
#define MCE_SIGNAL_MATCH "type='signal',"  \
       "sender='"    MCE_SERVICE                "'," \
       "path='"      MCE_SIGNAL_PATH            "'," \
       "interface='" MCE_SIGNAL_IF              "'"
then I've added a DBus filter and handler:

Code:
sys_conn = osso_get_sys_dbus_connection(ctx);
 if (sys_conn) {
       DBusError error;
       dbus_error_init (&error);
       dbus_bus_add_match (sys_conn, MCE_SIGNAL_MATCH, &error);
       if (dbus_error_is_set(&error)){
               printf("dbus_bus_add_match failed: %s\n", error.message);
               dbus_error_free(&error);
       }

       if (!dbus_connection_add_filter (sys_conn,
                 (DBusHandleMessageFunction) mce_filter_func, NULL, NULL)) {
               printf("Error dbus_connection_add_filter failed\n");
       } else {
               printf ("DBUS filter added\n");
       }`
 }
and defined the handler function:

Code:
DBusHandlerResult
mce_filter_func (DBusConnection *connection, DBusMessage *message, void *data)
{
       DBusMessageIter iter;
       const gchar *mode = NULL;

       printf ("MCE\n");

       if (dbus_message_is_signal(message, MCE_SIGNAL_IF,
MCE_DEVICE_ORIENTATION_SIG)) {
               printf ("is a orientation signal\n");
               if (dbus_message_iter_init(message, &iter)) {
                       printf ("getting mode\n");
                       dbus_message_iter_get_basic(&iter, &mode);

                       hildon_rotate_ui (mode);
               }
       }

       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
It compiles, starts up, the MCE function gets called twice when
Xournal starts (it prints MCE twice) and gets called for several other
DBus messages (like screen lock/unlock), but NOT for rotate messages.

What am I missing?

Thanks!

References:

[1] http://wiki.maemo.org/Using_Fremantl...tation_Changes
[2] http://wiki.maemo.org/Documentation/...#Portrait_Mode
[3] https://garage.maemo.org/plugins/scm...er&view=markup
[4] https://garage.maemo.org/plugins/scm...er&view=markup
 

The Following User Says Thank You to anidel For This Useful Post: