debuging dbus
authortanya <tanyshk@gmail.com>
Wed, 11 Aug 2010 11:23:10 +0000 (14:23 +0300)
committertanya <tanyshk@gmail.com>
Wed, 11 Aug 2010 11:23:10 +0000 (14:23 +0300)
xscreensaver/hacks/screenhack.c

index 0f11991..8414e54 100644 (file)
@@ -532,15 +532,20 @@ run_screenhack_table (Display *dpy,
 #define LIVEWP_PAUSE_LIVEBG_ON_VIEW2 "pause_livebg_on_view2"                                                                                                 
 #define LIVEWP_PAUSE_LIVEBG_ON_VIEW3 "pause_livebg_on_view3"                                                                                                 
 #define LIVEWP_PAUSE_LIVEBG_ON_VIEW4 "pause_livebg_on_view4"
+#define LIVEWP_PAUSE_LIVEBG_ON_VIEW "pause_livebg_on_view"
 #define LIVEWP_PLAY_LIVEBG_ON_VIEW1 "play_livebg_on_view1"                                                                                                   
 #define LIVEWP_PLAY_LIVEBG_ON_VIEW2 "play_livebg_on_view2"                                                                                                   
 #define LIVEWP_PLAY_LIVEBG_ON_VIEW3 "play_livebg_on_view3"                                                                                                   
 #define LIVEWP_PLAY_LIVEBG_ON_VIEW4 "play_livebg_on_view4" 
+#define LIVEWP_PLAY_LIVEBG_ON_VIEW "play_livebg_on_view" 
    DBusMessage* msg;
    DBusConnection* conn;
    DBusError err;
+   DBusMessageIter args;
    int ret;
    char pause = 0;
+   int param = 0;
+   int start_frame = 200;
 
   /* Kludge: even though the init_cb functions are declared to take 2 args,
      actually call them with 3, for the benefit of xlockmore_init() and
@@ -579,14 +584,16 @@ run_screenhack_table (Display *dpy,
   }
 
   dbus_bus_add_match (conn, "type='signal', interface='org.maemo.livewp'", &err);
+  dbus_connection_flush(conn);
   if (dbus_error_is_set(&err)){
      fprintf(stderr,"dbus_bus_add_match failed: %s", err.message);
      dbus_error_free(&err);
      exit (1);
   }
+
   while (1)
     {
-      if (pause == 0){ 
+      if (pause == 0){
         unsigned long delay = ft->draw_cb (dpy, window, closure);
 #ifdef DEBUG_PAIR
         unsigned long delay2 = 0;
@@ -607,17 +614,59 @@ run_screenhack_table (Display *dpy,
         break;
 
       }
+      if (start_frame > 0) {
+          start_frame--;
+          continue;
+        }
       if (pause == 0)
       /* non blocking read of the next available message */
        dbus_connection_read_write(conn, 0);
       else
       /* blocking read of the next available message */
        dbus_connection_read_write(conn, -1);
-      msg = dbus_connection_pop_message(conn);
+        /*fprintf(stderr, "111111\n");*/
+      msg = dbus_connection_borrow_message(conn);
+      /*msg = dbus_connection_pop_message(conn);*/
+
+        /*fprintf(stderr, "2222222\n");*/
       if (NULL == msg){  
+
+        /*fprintf(stderr, "333333\n");*/
           continue; 
       }
+        dbus_connection_steal_borrowed_message(conn, msg);
+     /* fprintf (stderr, "APPLICATION PATH11111111111111111111 %s %s %s\n",   dbus_message_get_path(msg),   dbus_message_get_interface (msg), dbus_message_get_member (msg));*/
+        /*dbus_connection_return_message(conn, msg);*/
+      if (dbus_message_is_signal(msg, LIVEWP_SIGNAL_INTERFACE, LIVEWP_PAUSE_LIVEBG_ON_VIEW) || 
+          dbus_message_is_signal(msg, LIVEWP_SIGNAL_INTERFACE, LIVEWP_PLAY_LIVEBG_ON_VIEW)){
+          if (!dbus_message_iter_init(msg, &args))
+              fprintf(stderr, "dbus message has no param\n");
+          else if (DBUS_TYPE_INT32 != dbus_message_iter_get_arg_type(&args))             
+              fprintf(stderr, "dbus message param is not int \n");
+          else{ 
+              dbus_message_iter_get_basic(&args, &param);
+              fprintf(stderr, "dbus param = %i\n", param);
+          }
+          if (param == view){
+              if (dbus_message_is_signal(msg, LIVEWP_SIGNAL_INTERFACE, LIVEWP_PAUSE_LIVEBG_ON_VIEW)){
+                 fprintf(stderr, "dbus  Pause scene visible %i\n", param); 
+                    pause = 1;
+              }
+              if (dbus_message_is_signal(msg, LIVEWP_SIGNAL_INTERFACE, LIVEWP_PLAY_LIVEBG_ON_VIEW)){
+                 fprintf(stderr, "dbus   Play scene visible %i\n", param); 
+                    pause = 0;
+              }
+              /*msg = dbus_connection_pop_message(conn);*/
+              fprintf(stderr, "dbus  steal message\n"); 
+              /*dbus_connection_steal_borrowed_message(conn, msg);*/
+          }else{ 
+              fprintf(stderr, "dbus  return message\n"); 
+              /*dbus_connection_return_message(conn, msg);*/
+          }
+      }    
+      
       /* check this is a method call for the right interface & method */
+      /*
       if ((view == 1 && dbus_message_is_signal(msg, LIVEWP_SIGNAL_INTERFACE, LIVEWP_PAUSE_LIVEBG_ON_VIEW1))||
           (view == 2 && dbus_message_is_signal(msg, LIVEWP_SIGNAL_INTERFACE, LIVEWP_PAUSE_LIVEBG_ON_VIEW2))||
           (view == 3 && dbus_message_is_signal(msg, LIVEWP_SIGNAL_INTERFACE, LIVEWP_PAUSE_LIVEBG_ON_VIEW3))||
@@ -636,7 +685,9 @@ run_screenhack_table (Display *dpy,
           dbus_message_unref (msg);
           continue;
       }
-      dbus_message_unref (msg);
+*/
+      
+      /*dbus_message_unref (msg);*/
     }
 
   ft->free_cb (dpy, window, closure);