merged
authortanya <tanyshk@gmail.com>
Thu, 12 Aug 2010 07:01:22 +0000 (10:01 +0300)
committertanya <tanyshk@gmail.com>
Thu, 12 Aug 2010 07:01:22 +0000 (10:01 +0300)
1  2 
xscreensaver/hacks/screenhack.c

@@@ -582,14 -582,24 +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)
      {
            start_frame--;
            continue;
          }
 +        dbus_connection_flush(conn);
        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);
-         /*fprintf(stderr, "111111\n");*/
-       msg = dbus_connection_borrow_message(conn);
-       /*msg = dbus_connection_pop_message(conn);*/
+               dbus_connection_read_write(conn, 20000);
  
-         /*fprintf(stderr, "2222222\n");*/
-       if (NULL == msg){  
+       msg = dbus_connection_pop_message(conn);
  
-         /*fprintf(stderr, "333333\n");*/
+       if (NULL == msg){  
            continue; 
        }
-         dbus_connection_steal_borrowed_message(conn, msg);
-         fprintf(stderr, "dbus  get message serial = %i\n", dbus_message_get_serial(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) || 
                     pause = 0;
                }
                /*msg = dbus_connection_pop_message(conn);*/
 -              fprintf(stderr, "dbus  steal message\n"); 
 +              fprintf(stderr, "dbus  steal message serial = %i\n", dbus_message_get_serial(msg)); 
                /*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))||
-           (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;
-       }
- */
-       
-       /*dbus_message_unref (msg);*/
+ #endif      
+       dbus_message_unref (msg);
      }
  
    ft->free_cb (dpy, window, closure);