Changeset 3abed82be77c9f7efdc2dc5a20ca1e2d5672e3ff
- Timestamp:
- 03/07/10 13:49:39 (5 months ago)
- Children:
- 023639805f9421d73da40e60e167b318fdd75f59
- Parents:
- 1f11f0968ec78d2ee1ae73c6604e2637725adf86
- git-committer:
- Nedko Arnaudov <nedko@arnaudov.name> / 2010-03-07T13:49:39Z+0200
- Files:
-
- 3 modified
-
gui/main.c (modified) (2 diffs)
-
proxies/studio_proxy.c (modified) (6 diffs)
-
proxies/studio_proxy.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
gui/main.c
re6881d6 r3abed82 1054 1054 } 1055 1055 1056 static void room_appeared(const char * opath, const char * name, const char * template) 1057 { 1058 log_info("room \"%s\" appeared (%s). template is \"%s\"", name, opath, template); 1059 } 1060 1061 static void room_disappeared(const char * opath, const char * name, const char * template) 1062 { 1063 log_info("room \"%s\" disappeared (%s). template is \"%s\"", name, opath, template); 1064 } 1065 1066 static void room_changed(const char * opath, const char * name, const char * template) 1067 { 1068 log_info("%s changed. name is \"%s\". template is \"%s\"", opath, name, template); 1069 } 1070 1056 1071 void 1057 1072 set_main_window_title( … … 1338 1353 1339 1354 studio_proxy_set_renamed_callback(on_studio_renamed); 1355 studio_proxy_set_room_callbacks(room_appeared, room_disappeared, room_changed); 1340 1356 1341 1357 g_signal_connect(G_OBJECT(g_main_win), "destroy", G_CALLBACK(gtk_main_quit), NULL); -
proxies/studio_proxy.c
r15350de r3abed82 3 3 * LADI Session Handler (ladish) 4 4 * 5 * Copyright (C) 2009 Nedko Arnaudov <nedko@arnaudov.name>5 * Copyright (C) 2009, 2010 Nedko Arnaudov <nedko@arnaudov.name> 6 6 * 7 7 ************************************************************************** … … 33 33 static void (* g_crashed_callback)(void) = NULL; 34 34 35 static void (* g_room_appeared_calback)(const char * opath, const char * name, const char * template) = NULL; 36 static void (* g_room_disappeared_calback)(const char * opath, const char * name, const char * template) = NULL; 37 static void (* g_room_changed_calback)(const char * opath, const char * name, const char * template) = NULL; 38 35 39 static void on_studio_renamed(void * context, DBusMessage * message_ptr) 36 40 { … … 53 57 } 54 58 59 static bool extract_room_info(DBusMessageIter * iter_ptr, const char ** opath, const char ** name, const char ** template) 60 { 61 dbus_message_iter_get_basic(iter_ptr, opath); 62 //log_info("opath is \"%s\"", *opath); 63 dbus_message_iter_next(iter_ptr); 64 65 if (!dbus_iter_get_dict_entry_string(iter_ptr, "name", name)) 66 { 67 log_error("dbus_iter_get_dict_entry() failed"); 68 return false; 69 } 70 //log_info("name is \"%s\"", *name); 71 72 if (!dbus_iter_get_dict_entry_string(iter_ptr, "template", template)) 73 { 74 *template = NULL; 75 } 76 //log_info("template is \"%s\"", *template); 77 78 return true; 79 } 80 81 static bool extract_room_info_from_signal(DBusMessage * message_ptr, const char ** opath, const char ** name, const char ** template) 82 { 83 const char * signature; 84 DBusMessageIter iter; 85 86 signature = dbus_message_get_signature(message_ptr); 87 if (strcmp(signature, "sa{sv}") != 0) 88 { 89 log_error("Invalid signature of room signal"); 90 return false; 91 } 92 93 dbus_message_iter_init(message_ptr, &iter); 94 95 return extract_room_info(&iter, opath, name, template); 96 } 97 55 98 static void on_studio_started(void * context, DBusMessage * message_ptr) 56 99 { … … 85 128 static void on_room_appeared(void * context, DBusMessage * message_ptr) 86 129 { 130 const char * opath; 131 const char * name; 132 const char * template; 133 87 134 log_info("RoomAppeared"); 135 136 if (g_room_appeared_calback != NULL && extract_room_info_from_signal(message_ptr, &opath, &name, &template)) 137 { 138 g_room_appeared_calback(opath, name, template); 139 } 88 140 } 89 141 90 142 static void on_room_disappeared(void * context, DBusMessage * message_ptr) 91 143 { 144 const char * opath; 145 const char * name; 146 const char * template; 147 92 148 log_info("RoomDisappeared"); 149 150 if (g_room_disappeared_calback != NULL && extract_room_info_from_signal(message_ptr, &opath, &name, &template)) 151 { 152 g_room_disappeared_calback(opath, name, template); 153 } 154 } 155 156 static void on_room_changed(void * context, DBusMessage * message_ptr) 157 { 158 const char * opath; 159 const char * name; 160 const char * template; 161 162 log_info("RoomChanged"); 163 164 if (g_room_changed_calback != NULL && extract_room_info_from_signal(message_ptr, &opath, &name, &template)) 165 { 166 g_room_changed_calback(opath, name, template); 167 } 93 168 } 94 169 … … 103 178 {"RoomAppeared", on_room_appeared}, 104 179 {"RoomDisappeared", on_room_disappeared}, 180 {"RoomChanged", on_room_changed}, 105 181 {NULL, NULL} 106 182 }; … … 201 277 return true; 202 278 } 279 280 void 281 studio_proxy_set_room_callbacks( 282 void (* appeared)(const char * opath, const char * name, const char * template), 283 void (* disappeared)(const char * opath, const char * name, const char * template), 284 void (* changed)(const char * opath, const char * name, const char * template)) 285 { 286 DBusMessage * reply_ptr; 287 const char * signature; 288 DBusMessageIter top_iter; 289 DBusMessageIter array_iter; 290 DBusMessageIter struct_iter; 291 const char * opath; 292 const char * name; 293 const char * template; 294 295 g_room_appeared_calback = appeared; 296 g_room_disappeared_calback = disappeared; 297 g_room_changed_calback = changed; 298 299 if (!dbus_call(SERVICE_NAME, STUDIO_OBJECT_PATH, IFACE_STUDIO, "GetRoomList", "", NULL, &reply_ptr)) 300 { 301 log_error("Cannot fetch studio room list"); 302 return; 303 } 304 305 signature = dbus_message_get_signature(reply_ptr); 306 if (strcmp(signature, "a(sa{sv})") != 0) 307 { 308 log_error("Invalid signature of GetRoomList reply"); 309 goto unref; 310 } 311 312 dbus_message_iter_init(reply_ptr, &top_iter); 313 314 for (dbus_message_iter_recurse(&top_iter, &array_iter); 315 dbus_message_iter_get_arg_type(&array_iter) != DBUS_TYPE_INVALID; 316 dbus_message_iter_next(&array_iter)) 317 { 318 dbus_message_iter_recurse(&array_iter, &struct_iter); 319 320 if (!extract_room_info(&struct_iter, &opath, &name, &template)) 321 { 322 log_error("extract_room_info() failed."); 323 goto unref; 324 } 325 326 g_room_appeared_calback(opath, name, template); 327 } 328 329 unref: 330 dbus_message_unref(reply_ptr); 331 } -
proxies/studio_proxy.h
r15350de r3abed82 3 3 * LADI Session Handler (ladish) 4 4 * 5 * Copyright (C) 2009 Nedko Arnaudov <nedko@arnaudov.name>5 * Copyright (C) 2009, 2010 Nedko Arnaudov <nedko@arnaudov.name> 6 6 * 7 7 ************************************************************************** … … 45 45 bool studio_proxy_is_started(bool * is_started_ptr); 46 46 47 void 48 studio_proxy_set_room_callbacks( 49 void (* appeared)(const char * opath, const char * name, const char * template), 50 void (* disappeared)(const char * opath, const char * name, const char * template), 51 void (* changed)(const char * opath, const char * name, const char * template)); 52 47 53 #endif /* #ifndef STUDIO_PROXY_H__2CEC623F_C998_4618_A947_D1A0016DF978__INCLUDED */
