Changeset 1f11f0968ec78d2ee1ae73c6604e2637725adf86
- Timestamp:
- 03/07/10 13:46:45 (5 months ago)
- Children:
- 3abed82be77c9f7efdc2dc5a20ca1e2d5672e3ff
- Parents:
- e154c89ce313738b3356c116c83148b5b3044ce2
- git-committer:
- Nedko Arnaudov <nedko@arnaudov.name> / 2010-03-07T13:46:45Z+0200
- Files:
-
- 1 modified
-
daemon/studio.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
daemon/studio.c
ra459a2a r1f11f09 119 119 } 120 120 121 static 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 184 static 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 121 206 void on_event_jack_started(void) 122 207 { … … 704 789 ladish_room_handle room; 705 790 char room_dbus_name[1024]; 706 const char * arg;707 791 708 792 dbus_error_init(&g_dbus_error); … … 737 821 list_add_tail(ladish_room_get_list_node(room), &g_studio.rooms); 738 822 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); 741 824 742 825 method_return_new_void(call_ptr); … … 747 830 DBusMessageIter iter, array_iter; 748 831 DBusMessageIter struct_iter; 749 DBusMessageIter dict_iter;750 832 struct list_head * node_ptr; 751 833 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;757 834 758 835 call_ptr->reply = dbus_message_new_method_return(call_ptr->message); … … 772 849 { 773 850 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 else783 {784 template = find_room_template_by_uuid(template_uuid);785 if (template != NULL)786 {787 template_name = ladish_room_get_name(template);788 }789 else790 {791 template_name = NULL;792 }793 }794 851 795 852 if (!dbus_message_iter_open_container(&array_iter, DBUS_TYPE_STRUCT, NULL, &struct_iter)) 796 853 goto fail_unref; 797 854 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)) 811 856 goto fail_unref; 812 857 … … 919 964 920 965 SIGNAL_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") 922 968 SIGNAL_ARGS_END 923 969 970 SIGNAL_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") 973 SIGNAL_ARGS_END 974 924 975 SIGNAL_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") 926 978 SIGNAL_ARGS_END 927 979 … … 933 985 SIGNAL_DESCRIBE(RoomAppeared) 934 986 SIGNAL_DESCRIBE(RoomDisappeared) 987 SIGNAL_DESCRIBE(RoomChanged) 935 988 SIGNALS_END 936 989
