reverted to signal without parameters
[xscreensaver] / xscreensaver / hacks / screenhack.c
index 8414e54..e6f0c41 100644 (file)
@@ -582,14 +582,24 @@ run_screenhack_table (Display *dpy,
          fprintf(stderr, "Connection Null\n"); 
          exit(1); 
   }
+  if (view == 1){
+       dbus_bus_add_match (conn, "type='signal', interface='org.maemo.livewp', member='pause_livebg_on_view1'", NULL);
+       dbus_bus_add_match (conn, "type='signal', interface='org.maemo.livewp', member='play_livebg_on_view1'", NULL);
+  }
+  if (view == 2){
+       dbus_bus_add_match (conn, "type='signal', interface='org.maemo.livewp', member='pause_livebg_on_view2'", NULL);
+       dbus_bus_add_match (conn, "type='signal', interface='org.maemo.livewp', member='play_livebg_on_view2'", NULL);
+  }
+  if (view == 3){
+       dbus_bus_add_match (conn, "type='signal', interface='org.maemo.livewp', member='pause_livebg_on_view3'", NULL);
+       dbus_bus_add_match (conn, "type='signal', interface='org.maemo.livewp', member='play_livebg_on_view3'", NULL);
+  }
+  if (view == 4){
+       dbus_bus_add_match (conn, "type='signal', interface='org.maemo.livewp', member='pause_livebg_on_view4'", NULL);
+       dbus_bus_add_match (conn, "type='signal', interface='org.maemo.livewp', member='play_livebg_on_view4'", NULL);
+  }
 
-  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)
     {
@@ -623,10 +633,11 @@ run_screenhack_table (Display *dpy,
        dbus_connection_read_write(conn, 0);
       else
       /* blocking read of the next available message */
-       dbus_connection_read_write(conn, -1);
+       dbus_connection_read_write(conn, 20000);
         /*fprintf(stderr, "111111\n");*/
-      msg = dbus_connection_borrow_message(conn);
-      /*msg = dbus_connection_pop_message(conn);*/
+      /*  msg = dbus_connection_borrow_message(conn); */
+
+      msg = dbus_connection_pop_message(conn);
 
         /*fprintf(stderr, "2222222\n");*/
       if (NULL == msg){  
@@ -634,7 +645,28 @@ run_screenhack_table (Display *dpy,
         /*fprintf(stderr, "333333\n");*/
           continue; 
       }
-        dbus_connection_steal_borrowed_message(conn, msg);
+      fprintf(stderr, "signal on view %i\n", view);
+      /* 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))||
+          (view == 4 && dbus_message_is_signal(msg, LIVEWP_SIGNAL_INTERFACE, LIVEWP_PAUSE_LIVEBG_ON_VIEW4))){
+           fprintf(stderr, "Pause scene visible %i\n", view); 
+          pause = 1;
+          dbus_message_unref (msg);
+          continue;
+      }
+      if ((view == 1 && dbus_message_is_signal(msg, LIVEWP_SIGNAL_INTERFACE, LIVEWP_PLAY_LIVEBG_ON_VIEW1))||
+          (view == 2 && dbus_message_is_signal(msg, LIVEWP_SIGNAL_INTERFACE, LIVEWP_PLAY_LIVEBG_ON_VIEW2))||
+          (view == 3 && dbus_message_is_signal(msg, LIVEWP_SIGNAL_INTERFACE, LIVEWP_PLAY_LIVEBG_ON_VIEW3))||
+          (view == 4 && dbus_message_is_signal(msg, LIVEWP_SIGNAL_INTERFACE, LIVEWP_PLAY_LIVEBG_ON_VIEW4))){
+           fprintf(stderr, "Play scene visible %i\n", view); 
+          pause = 0;
+          dbus_message_unref (msg);
+          continue;
+      }
+#if 0  
+      /*  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) || 
@@ -664,7 +696,8 @@ run_screenhack_table (Display *dpy,
               /*dbus_connection_return_message(conn, msg);*/
           }
       }    
-      
+#endif      
+      dbus_message_unref (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))||
@@ -673,7 +706,7 @@ run_screenhack_table (Display *dpy,
           (view == 4 && dbus_message_is_signal(msg, LIVEWP_SIGNAL_INTERFACE, LIVEWP_PAUSE_LIVEBG_ON_VIEW4))){
            fprintf(stderr, "Pause scene visible %i\n", view); 
           pause = 1;
-          dbus_message_unref (msg);
+          dbus_message_unref (msg); 
           continue;
       }
       if ((view == 1 && dbus_message_is_signal(msg, LIVEWP_SIGNAL_INTERFACE, LIVEWP_PLAY_LIVEBG_ON_VIEW1))||
@@ -682,12 +715,10 @@ run_screenhack_table (Display *dpy,
           (view == 4 && dbus_message_is_signal(msg, LIVEWP_SIGNAL_INTERFACE, LIVEWP_PLAY_LIVEBG_ON_VIEW4))){
            fprintf(stderr, "Play scene visible %i\n", view); 
           pause = 0;
-          dbus_message_unref (msg);
+          dbus_message_unref (msg); 
           continue;
       }
 */
-      
-      /*dbus_message_unref (msg);*/
     }
 
   ft->free_cb (dpy, window, closure);