Changeset 1f11f0968ec78d2ee1ae73c6604e2637725adf86

Show
Ignore:
Timestamp:
03/07/10 13:46:45 (5 months ago)
Author:
Nedko Arnaudov <nedko@…>
Children:
3abed82be77c9f7efdc2dc5a20ca1e2d5672e3ff
Parents:
e154c89ce313738b3356c116c83148b5b3044ce2
git-committer:
Nedko Arnaudov <nedko@arnaudov.name> / 2010-03-07T13:46:45Z+0200
Message:

Fix studio room signal parameters; Add RoomChanged? signal

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • daemon/studio.c

    ra459a2a r1f11f09  
    119119} 
    120120 
     121static bool fill_room_info(DBusMessageIter * iter_ptr, ladish_room_handle room) 
     122{ 
     123  DBusMessageIter dict_iter; 
     124  const char * name; 
     125  uuid_t template_uuid; 
     126  ladish_room_handle template; 
     127  const char * template_name; 
     128  const char * opath; 
     129 
     130  name = ladish_room_get_name(room); 
     131  opath = ladish_room_get_opath(room); 
     132 
     133  if (!ladish_room_get_template_uuid(room, template_uuid)) 
     134  { 
     135    template = NULL; 
     136    template_name = NULL; 
     137  } 
     138  else 
     139  { 
     140    template = find_room_template_by_uuid(template_uuid); 
     141    if (template != NULL) 
     142    { 
     143      template_name = ladish_room_get_name(template); 
     144    } 
     145    else 
     146    { 
     147      template_name = NULL; 
     148    } 
     149  } 
     150 
     151  if (!dbus_message_iter_append_basic(iter_ptr, DBUS_TYPE_STRING, &opath)) 
     152  { 
     153    log_error("dbus_message_iter_append_basic() failed."); 
     154    return false; 
     155  } 
     156 
     157  if (!dbus_message_iter_open_container(iter_ptr, DBUS_TYPE_ARRAY, "{sv}", &dict_iter)) 
     158  { 
     159    log_error("dbus_message_iter_open_container() failed."); 
     160    return false; 
     161  } 
     162 
     163  if (!dbus_maybe_add_dict_entry_string(&dict_iter, "template", template_name)) 
     164  { 
     165    log_error("dbus_maybe_add_dict_entry_string() failed."); 
     166    return false; 
     167  } 
     168 
     169  if (!dbus_maybe_add_dict_entry_string(&dict_iter, "name", name)) 
     170  { 
     171    log_error("dbus_maybe_add_dict_entry_string() failed."); 
     172    return false; 
     173  } 
     174 
     175  if (!dbus_message_iter_close_container(iter_ptr, &dict_iter)) 
     176  { 
     177    log_error("dbus_message_iter_close_container() failed."); 
     178    return false; 
     179  } 
     180 
     181  return true; 
     182} 
     183 
     184static void emit_room_appeared(ladish_room_handle room) 
     185{ 
     186  DBusMessage * message_ptr; 
     187  DBusMessageIter iter; 
     188 
     189  message_ptr = dbus_message_new_signal(STUDIO_OBJECT_PATH, IFACE_STUDIO, "RoomAppeared"); 
     190  if (message_ptr == NULL) 
     191  { 
     192    log_error("dbus_message_new_signal() failed."); 
     193    return; 
     194  } 
     195 
     196  dbus_message_iter_init_append(message_ptr, &iter); 
     197 
     198  if (fill_room_info(&iter, room)) 
     199  { 
     200    dbus_signal_send(g_dbus_connection, message_ptr); 
     201  } 
     202 
     203  dbus_message_unref(message_ptr); 
     204} 
     205 
    121206void on_event_jack_started(void) 
    122207{ 
     
    704789  ladish_room_handle room; 
    705790  char room_dbus_name[1024]; 
    706   const char * arg; 
    707791 
    708792  dbus_error_init(&g_dbus_error); 
     
    737821  list_add_tail(ladish_room_get_list_node(room), &g_studio.rooms); 
    738822 
    739   arg = room_dbus_name; 
    740   dbus_signal_emit(g_dbus_connection, STUDIO_OBJECT_PATH, IFACE_STUDIO, "RoomAppeared", "s", &arg); 
     823  emit_room_appeared(room); 
    741824 
    742825  method_return_new_void(call_ptr); 
     
    747830  DBusMessageIter iter, array_iter; 
    748831  DBusMessageIter struct_iter; 
    749   DBusMessageIter dict_iter; 
    750832  struct list_head * node_ptr; 
    751833  ladish_room_handle room; 
    752   const char * name; 
    753   uuid_t template_uuid; 
    754   ladish_room_handle template; 
    755   const char * template_name; 
    756   const char * opath; 
    757834 
    758835  call_ptr->reply = dbus_message_new_method_return(call_ptr->message); 
     
    772849  { 
    773850    room = ladish_room_from_list_node(node_ptr); 
    774     name = ladish_room_get_name(room); 
    775     opath = ladish_room_get_opath(room); 
    776  
    777     if (!ladish_room_get_template_uuid(room, template_uuid)) 
    778     { 
    779       template = NULL; 
    780       template_name = NULL; 
    781     } 
    782     else 
    783     { 
    784       template = find_room_template_by_uuid(template_uuid); 
    785       if (template != NULL) 
    786       { 
    787         template_name = ladish_room_get_name(template); 
    788       } 
    789       else 
    790       { 
    791         template_name = NULL; 
    792       } 
    793     } 
    794851 
    795852    if (!dbus_message_iter_open_container(&array_iter, DBUS_TYPE_STRUCT, NULL, &struct_iter)) 
    796853      goto fail_unref; 
    797854 
    798     if (!dbus_message_iter_append_basic(&struct_iter, DBUS_TYPE_STRING, &opath)) 
    799       goto fail_unref; 
    800  
    801     if (!dbus_message_iter_open_container(&struct_iter, DBUS_TYPE_ARRAY, "{sv}", &dict_iter)) 
    802       goto fail_unref; 
    803  
    804     if (!dbus_maybe_add_dict_entry_string(&dict_iter, "template", template_name)) 
    805       goto fail_unref; 
    806  
    807     if (!dbus_maybe_add_dict_entry_string(&dict_iter, "name", name)) 
    808       goto fail_unref; 
    809  
    810     if (!dbus_message_iter_close_container(&struct_iter, &dict_iter)) 
     855    if (!fill_room_info(&struct_iter, room)) 
    811856      goto fail_unref; 
    812857 
     
    919964 
    920965SIGNAL_ARGS_BEGIN(RoomAppeared, "Room D-Bus object appeared") 
    921   SIGNAL_ARG_DESCRIBE("room_path", "s", "room object path") 
     966  SIGNAL_ARG_DESCRIBE("opath", "s", "room object path") 
     967  SIGNAL_ARG_DESCRIBE("properties", "a{sv}", "room object path and props") 
    922968SIGNAL_ARGS_END 
    923969 
     970SIGNAL_ARGS_BEGIN(RoomChanged, "Room D-Bus object changed") 
     971  SIGNAL_ARG_DESCRIBE("opath", "s", "room object path") 
     972  SIGNAL_ARG_DESCRIBE("properties", "a{sv}", "room object path and props") 
     973SIGNAL_ARGS_END 
     974 
    924975SIGNAL_ARGS_BEGIN(RoomDisappeared, "Room D-Bus object disappeared") 
    925   SIGNAL_ARG_DESCRIBE("room_path", "s", "room object path") 
     976  SIGNAL_ARG_DESCRIBE("opath", "s", "room object path") 
     977  SIGNAL_ARG_DESCRIBE("properties", "a{sv}", "room object path and props") 
    926978SIGNAL_ARGS_END 
    927979 
     
    933985  SIGNAL_DESCRIBE(RoomAppeared) 
    934986  SIGNAL_DESCRIBE(RoomDisappeared) 
     987  SIGNAL_DESCRIBE(RoomChanged) 
    935988SIGNALS_END 
    936989