| 886 | | if (room_ptr->project_name != NULL) |
| 887 | | { |
| 888 | | free(room_ptr->project_name); |
| 889 | | room_ptr->project_name = NULL; |
| 890 | | } |
| 891 | | if (room_ptr->project_dir != NULL) |
| 892 | | { |
| 893 | | free(room_ptr->project_dir); |
| 894 | | room_ptr->project_dir = NULL; |
| 895 | | } |
| | 896 | free(room_ptr->project_name); |
| | 897 | room_ptr->project_name = NULL; |
| | 898 | |
| | 899 | free(room_ptr->project_dir); |
| | 900 | room_ptr->project_dir = NULL; |
| | 901 | |
| | 902 | free(room_ptr->project_description); |
| | 903 | room_ptr->project_description = NULL; |
| | 904 | |
| | 905 | free(room_ptr->project_notes); |
| | 906 | room_ptr->project_notes = NULL; |
| | 997 | } |
| | 998 | |
| | 999 | static void ladish_room_dbus_set_project_description(struct dbus_method_call * call_ptr) |
| | 1000 | { |
| | 1001 | const char * str; |
| | 1002 | char * dup; |
| | 1003 | |
| | 1004 | if (!dbus_message_get_args(call_ptr->message, &g_dbus_error, DBUS_TYPE_STRING, &str, DBUS_TYPE_INVALID)) |
| | 1005 | { |
| | 1006 | lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "Invalid arguments to method \"%s\": %s", call_ptr->method_name, g_dbus_error.message); |
| | 1007 | dbus_error_free(&g_dbus_error); |
| | 1008 | return; |
| | 1009 | } |
| | 1010 | |
| | 1011 | if ((strlen(str) == 0 && (room_ptr->project_description == NULL || strlen(room_ptr->project_description) == 0)) || |
| | 1012 | (room_ptr->project_description != NULL && strcmp(str, room_ptr->project_description) == 0)) |
| | 1013 | { |
| | 1014 | method_return_new_single(call_ptr, DBUS_TYPE_UINT64, &room_ptr->name); |
| | 1015 | return; |
| | 1016 | } |
| | 1017 | |
| | 1018 | dup = strdup(str); |
| | 1019 | if (dup == NULL) |
| | 1020 | { |
| | 1021 | lash_dbus_error(call_ptr, LASH_DBUS_ERROR_GENERIC, "strdup() failed"); |
| | 1022 | return; |
| | 1023 | } |
| | 1024 | |
| | 1025 | free(room_ptr->project_description); |
| | 1026 | room_ptr->project_description = dup; |
| | 1027 | |
| | 1028 | ladish_room_emit_project_properties_changed(room_ptr); /* increments the version number */ |
| | 1029 | method_return_new_single(call_ptr, DBUS_TYPE_UINT64, &room_ptr->version); |
| | 1030 | } |
| | 1031 | |
| | 1032 | static void ladish_room_dbus_set_project_notes(struct dbus_method_call * call_ptr) |
| | 1033 | { |
| | 1034 | const char * str; |
| | 1035 | char * dup; |
| | 1036 | |
| | 1037 | if (!dbus_message_get_args(call_ptr->message, &g_dbus_error, DBUS_TYPE_STRING, &str, DBUS_TYPE_INVALID)) |
| | 1038 | { |
| | 1039 | lash_dbus_error(call_ptr, LASH_DBUS_ERROR_INVALID_ARGS, "Invalid arguments to method \"%s\": %s", call_ptr->method_name, g_dbus_error.message); |
| | 1040 | dbus_error_free(&g_dbus_error); |
| | 1041 | return; |
| | 1042 | } |
| | 1043 | |
| | 1044 | if ((strlen(str) == 0 && (room_ptr->project_notes == NULL || strlen(room_ptr->project_notes) == 0)) || |
| | 1045 | (room_ptr->project_notes != NULL && strcmp(str, room_ptr->project_notes) == 0)) |
| | 1046 | { |
| | 1047 | method_return_new_single(call_ptr, DBUS_TYPE_UINT64, &room_ptr->name); |
| | 1048 | return; |
| | 1049 | } |
| | 1050 | |
| | 1051 | dup = strdup(str); |
| | 1052 | if (dup == NULL) |
| | 1053 | { |
| | 1054 | lash_dbus_error(call_ptr, LASH_DBUS_ERROR_GENERIC, "strdup() failed"); |
| | 1055 | return; |
| | 1056 | } |
| | 1057 | |
| | 1058 | free(room_ptr->project_notes); |
| | 1059 | room_ptr->project_notes = dup; |
| | 1060 | |
| | 1061 | ladish_room_emit_project_properties_changed(room_ptr); /* increments the version number */ |
| | 1062 | method_return_new_single(call_ptr, DBUS_TYPE_UINT64, &room_ptr->version); |
| | 1086 | METHOD_ARGS_END |
| | 1087 | |
| | 1088 | METHOD_ARGS_BEGIN(SetProjectDescription, "Set project description") |
| | 1089 | METHOD_ARG_DESCRIBE_IN("description", "s", "Project description") |
| | 1090 | METHOD_ARG_DESCRIBE_OUT("new_version", DBUS_TYPE_UINT64_AS_STRING, "New version of the project properties") |
| | 1091 | METHOD_ARGS_END |
| | 1092 | |
| | 1093 | METHOD_ARGS_BEGIN(SetProjectNotes, "Set project notes") |
| | 1094 | METHOD_ARG_DESCRIBE_IN("notes", "s", "Project notes") |
| | 1095 | METHOD_ARG_DESCRIBE_OUT("new_version", DBUS_TYPE_UINT64_AS_STRING, "New version of the project properties") |