Changeset 847536504b95307eadfdb31d17902c85569e2e21
- Timestamp:
- 03/01/10 02:12:12 (5 months ago)
- Children:
- 945b3aa6865654fd54707c298636a428c6510755
- Parents:
- e897f8a983f2f752ee61bfbfb296986b23726fb6
- git-committer:
- Nedko Arnaudov <nedko@arnaudov.name> / 2010-03-01T02:12:12Z+0200
- Files:
-
- 6 modified
-
daemon/control.c (modified) (3 diffs)
-
daemon/control.h (modified) (2 diffs)
-
daemon/room.c (modified) (4 diffs)
-
daemon/room.h (modified) (2 diffs)
-
daemon/studio.c (modified) (3 diffs)
-
ladish_control (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
daemon/control.c
re897f8a r8475365 49 49 ladish_room_handle room; 50 50 51 if (!ladish_room_create(empty_room, "Empty", &room))51 if (!ladish_room_create(empty_room, "Empty", NULL, &room)) 52 52 { 53 53 log_error("ladish_room_create() failed."); … … 57 57 list_add_tail(ladish_room_get_list_node(room), &g_rooms); 58 58 59 if (!ladish_room_create(basic_room, "Basic", &room))59 if (!ladish_room_create(basic_room, "Basic", NULL, &room)) 60 60 { 61 61 log_error("ladish_room_create() failed."); … … 122 122 123 123 return true; 124 } 125 126 ladish_room_handle find_room_template_by_name(const char * name) 127 { 128 ladish_room_handle room; 129 struct list_head * node_ptr; 130 131 maybe_create_rooms(); 132 133 list_for_each(node_ptr, &g_rooms) 134 { 135 room = ladish_room_from_list_node(node_ptr); 136 if (strcmp(ladish_room_get_name(room), name) == 0) 137 { 138 return room; 139 } 140 } 141 142 return NULL; 143 } 144 145 ladish_room_handle find_room_template_by_uuid(const uuid_t uuid_ptr) 146 { 147 ladish_room_handle room; 148 struct list_head * node_ptr; 149 uuid_t uuid; 150 151 maybe_create_rooms(); 152 153 list_for_each(node_ptr, &g_rooms) 154 { 155 room = ladish_room_from_list_node(node_ptr); 156 ladish_room_get_uuid(room, uuid); 157 if (uuid_compare(uuid, uuid_ptr) == 0) 158 { 159 return room; 160 } 161 } 162 163 return NULL; 124 164 } 125 165 -
daemon/control.h
rb6fe91e r8475365 29 29 #define __LASHD_DBUS_IFACE_CONTROL_H__ 30 30 31 #include "room.h" 32 31 33 extern const struct dbus_interface_descriptor g_lashd_interface_control; 32 34 … … 37 39 bool rooms_init(void); 38 40 void rooms_uninit(void); 41 ladish_room_handle find_room_template_by_name(const char * name); 42 ladish_room_handle find_room_template_by_uuid(const uuid_t uuid_ptr); 39 43 40 44 #endif /* __LASHD_DBUS_IFACE_CONTROL_H__ */ -
daemon/room.c
rb6fe91e r8475365 32 32 uuid_t uuid; 33 33 char * name; 34 uuid_t template_uuid; 34 35 }; 35 36 … … 38 39 const uuid_t uuid_ptr, 39 40 const char * name, 41 ladish_room_handle template, 40 42 ladish_room_handle * room_handle_ptr) 41 43 { … … 51 53 if (uuid_ptr == NULL) 52 54 { 53 uuid_generate(room_ptr->uuid); 55 if (template == NULL) 56 { 57 uuid_generate(room_ptr->uuid); 58 } 59 else 60 { 61 ladish_room_get_uuid(template, room_ptr->uuid); 62 } 54 63 } 55 64 else 56 65 { 57 66 uuid_copy(room_ptr->uuid, uuid_ptr); 67 } 68 69 if (template != NULL) 70 { 71 ladish_room_get_uuid(template, room_ptr->template_uuid); 72 } 73 else 74 { 75 uuid_clear(room_ptr->template_uuid); 58 76 } 59 77 … … 90 108 } 91 109 110 bool ladish_room_get_template_uuid(ladish_room_handle room_handle, uuid_t uuid_ptr) 111 { 112 if (uuid_is_null(room_ptr->template_uuid)) 113 { 114 return false; 115 } 116 117 uuid_copy(uuid_ptr, room_ptr->template_uuid); 118 return true; 119 } 120 121 void ladish_room_get_uuid(ladish_room_handle room_handle, uuid_t uuid_ptr) 122 { 123 uuid_copy(uuid_ptr, room_ptr->uuid); 124 } 125 92 126 #undef room_ptr 93 127 -
daemon/room.h
rb6fe91e r8475365 36 36 const uuid_t uuid_ptr, 37 37 const char * name, 38 ladish_room_handle template, 38 39 ladish_room_handle * room_handle_ptr); 39 40 … … 46 47 47 48 const char * ladish_room_get_name(ladish_room_handle room_handle); 49 bool ladish_room_get_template_uuid(ladish_room_handle room_handle, uuid_t uuid_ptr); 50 void ladish_room_get_uuid(ladish_room_handle room_handle, uuid_t uuid_ptr); 48 51 49 52 #endif /* #ifndef ROOM_H__9A1CF253_0A17_402A_BDF8_9BD72B467118__INCLUDED */ -
daemon/studio.c
rdd24a9c r8475365 696 696 } 697 697 698 static void ladish_studio_new_room(struct dbus_method_call * call_ptr) 699 { 700 const char * room_name; 701 const char * template_name; 702 ladish_room_handle room; 703 704 dbus_error_init(&g_dbus_error); 705 706 if (!dbus_message_get_args(call_ptr->message, &g_dbus_error, DBUS_TYPE_STRING, &room_name, DBUS_TYPE_STRING, &template_name, DBUS_TYPE_INVALID)) 707 { 708 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "Invalid arguments to method \"%s\": %s", call_ptr->method_name, g_dbus_error.message); 709 dbus_error_free(&g_dbus_error); 710 return; 711 } 712 713 log_info("Request to create new studio room \"%s\" from template \"%s\".", room_name, template_name); 714 715 room = find_room_template_by_name(template_name); 716 if (room == NULL) 717 { 718 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "Unknown room template \"%s\"", template_name); 719 return; 720 } 721 722 if (!ladish_room_create(NULL, room_name, room, &room)) 723 { 724 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_GENERIC, "ladish_room_create() failed."); 725 return; 726 } 727 728 list_add_tail(ladish_room_get_list_node(room), &g_studio.rooms); 729 730 //dbus_signal_emit(g_dbus_connection, STUDIO_OBJECT_PATH, IFACE_STUDIO, "RoomAppeared", ""); 731 732 method_return_new_void(call_ptr); 733 } 734 735 static void ladish_studio_get_room_list(struct dbus_method_call * call_ptr) 736 { 737 DBusMessageIter iter, array_iter; 738 DBusMessageIter struct_iter; 739 DBusMessageIter dict_iter; 740 struct list_head * node_ptr; 741 ladish_room_handle room; 742 const char * name; 743 uuid_t template_uuid; 744 ladish_room_handle template; 745 const char * template_name; 746 747 call_ptr->reply = dbus_message_new_method_return(call_ptr->message); 748 if (call_ptr->reply == NULL) 749 { 750 goto fail; 751 } 752 753 dbus_message_iter_init_append(call_ptr->reply, &iter); 754 755 if (!dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "(sa{sv})", &array_iter)) 756 { 757 goto fail_unref; 758 } 759 760 list_for_each(node_ptr, &g_studio.rooms) 761 { 762 room = ladish_room_from_list_node(node_ptr); 763 name = ladish_room_get_name(room); 764 765 if (!ladish_room_get_template_uuid(room, template_uuid)) 766 { 767 template = NULL; 768 template_name = NULL; 769 } 770 else 771 { 772 template = find_room_template_by_uuid(template_uuid); 773 if (template != NULL) 774 { 775 template_name = ladish_room_get_name(template); 776 } 777 else 778 { 779 template_name = NULL; 780 } 781 } 782 783 if (!dbus_message_iter_open_container(&array_iter, DBUS_TYPE_STRUCT, NULL, &struct_iter)) 784 goto fail_unref; 785 786 if (!dbus_message_iter_append_basic(&struct_iter, DBUS_TYPE_STRING, &name)) 787 goto fail_unref; 788 789 if (!dbus_message_iter_open_container(&struct_iter, DBUS_TYPE_ARRAY, "{sv}", &dict_iter)) 790 goto fail_unref; 791 792 if (!dbus_maybe_add_dict_entry_string(&dict_iter, "template", template_name)) 793 goto fail_unref; 794 795 if (!dbus_message_iter_close_container(&struct_iter, &dict_iter)) 796 goto fail_unref; 797 798 if (!dbus_message_iter_close_container(&array_iter, &struct_iter)) 799 goto fail_unref; 800 } 801 802 if (!dbus_message_iter_close_container(&iter, &array_iter)) 803 { 804 goto fail_unref; 805 } 806 807 return; 808 809 fail_unref: 810 dbus_message_unref(call_ptr->reply); 811 call_ptr->reply = NULL; 812 813 fail: 814 log_error("Ran out of memory trying to construct method return"); 815 } 816 817 static void ladish_studio_delete_room(struct dbus_method_call * call_ptr) 818 { 819 const char * name; 820 821 dbus_error_init(&g_dbus_error); 822 823 if (!dbus_message_get_args(call_ptr->message, &g_dbus_error, DBUS_TYPE_STRING, &name, DBUS_TYPE_INVALID)) 824 { 825 lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "Invalid arguments to method \"%s\": %s", call_ptr->method_name, g_dbus_error.message); 826 dbus_error_free(&g_dbus_error); 827 return; 828 } 829 830 log_info("Delete studio room request (%s)", name); 831 832 { 833 method_return_new_void(call_ptr); 834 } 835 } 836 698 837 METHOD_ARGS_BEGIN(GetName, "Get studio name") 699 838 METHOD_ARG_DESCRIBE_OUT("studio_name", "s", "Name of studio") … … 722 861 METHOD_ARGS_BEGIN(IsStarted, "Check whether studio is started") 723 862 METHOD_ARG_DESCRIBE_OUT("started", "b", "Whether studio is started") 863 METHOD_ARGS_END 864 865 METHOD_ARGS_BEGIN(NewRoom, "New studio room") 866 METHOD_ARG_DESCRIBE_IN("room_name", "s", "Studio room name") 867 METHOD_ARG_DESCRIBE_IN("room_template_name", "s", "Room template name") 868 METHOD_ARGS_END 869 870 METHOD_ARGS_BEGIN(GetRoomList, "Get list of rooms in this studio") 871 METHOD_ARG_DESCRIBE_OUT("room_list", "a(sa{sv})", "List of studio rooms, name and properties") 872 METHOD_ARGS_END 873 874 METHOD_ARGS_BEGIN(DeleteRoom, "Delete studio room") 875 METHOD_ARG_DESCRIBE_IN("room_name", "s", "Name of studio room to delete") 724 876 METHOD_ARGS_END 725 877 … … 733 885 METHOD_DESCRIBE(Stop, ladish_stop_studio) 734 886 METHOD_DESCRIBE(IsStarted, ladish_studio_is_started) 887 METHOD_DESCRIBE(NewRoom, ladish_studio_new_room) 888 METHOD_DESCRIBE(GetRoomList, ladish_studio_get_room_list) 889 METHOD_DESCRIBE(DeleteRoom, ladish_studio_delete_room) 735 890 METHODS_END 736 891 -
ladish_control
rb6fe91e r8475365 114 114 print(" rdel <roomname> - delete room") 115 115 print(" rnew <roomname> - new room") 116 print(" snewroom <name> <tname> - new studio room") 117 print(" srlist - list studio rooms") 118 print(" sdelroom <name> - delete studio room") 116 119 sys.exit(0) 117 120 … … 203 206 print("--- room delete") 204 207 if index >= len(sys.argv): 205 print("delete room command requires studioname argument")208 print("delete room command requires room name argument") 206 209 sys.exit() 207 210 … … 242 245 print("--- studio stop") 243 246 studio_iface.Stop() 247 elif arg == 'snewroom': 248 print("--- new studio room") 249 if index + 1 >= len(sys.argv): 250 print("creation of studio room requires room name and room template name arguments") 251 sys.exit() 252 253 room_name = sys.argv[index] 254 index += 1 255 room_template_name = sys.argv[index] 256 index += 1 257 258 studio_iface.NewRoom(room_name, room_template_name) 259 elif arg == 'srlist': 260 print("--- studio room list") 261 for room in studio_iface.GetRoomList(): 262 #print repr(room) 263 name = room[0] 264 if room[1].has_key("template"): 265 template = str(room[1]["template"]) 266 else: 267 template = None 268 269 if template: 270 print('"%s" from template "%s"' % (name, template)) 271 else: 272 print('"%s"' % name) 273 elif arg == 'sdelroom': 274 print("--- studio room delete") 275 if index >= len(sys.argv): 276 print("delete studio room command requires room name argument") 277 sys.exit() 278 279 arg = sys.argv[index] 280 index += 1 281 282 studio_iface.DeleteRoom(arg) 244 283 else: 245 284 print("Unknown command '%s'" % arg)
