Merge branch 'stable' into 'main'
[ladish.git] / daemon / cmd_unload_studio.c
blob0024628b824681eb8a489237a613552d4d827836
1 /* -*- Mode: C ; c-basic-offset: 2 -*- */
2 /*
3 * LADI Session Handler (ladish)
5 * Copyright (C) 2009,2010,2011 Nedko Arnaudov <nedko@arnaudov.name>
7 **************************************************************************
8 * This file contains implementation of the "unload studio" command
9 **************************************************************************
11 * LADI Session Handler is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * LADI Session Handler is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with LADI Session Handler. If not, see <http://www.gnu.org/licenses/>
23 * or write to the Free Software Foundation, Inc.,
24 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
27 #include "cmd.h"
28 #include "studio_internal.h"
29 #include "control.h"
30 #include "../proxies/notify_proxy.h"
32 #define cmd_ptr ((struct ladish_command *)context)
34 static bool run(void * context)
36 ASSERT(cmd_ptr->state == LADISH_COMMAND_STATE_PENDING);
38 ladish_studio_clear();
40 cmd_ptr->state = LADISH_COMMAND_STATE_DONE;
41 return true;
44 #undef cmd_ptr
46 bool ladish_command_unload_studio(void * call_ptr, struct ladish_cqueue * queue_ptr)
48 struct ladish_command * cmd_ptr;
50 if (!ladish_command_stop_studio(call_ptr, queue_ptr))
52 goto fail;
55 cmd_ptr = ladish_command_new(sizeof(struct ladish_command));
56 if (cmd_ptr == NULL)
58 log_error("ladish_command_new() failed.");
59 goto fail_drop_stop_command;
62 cmd_ptr->run = run;
64 if (!ladish_cqueue_add_command(queue_ptr, cmd_ptr))
66 cdbus_error(call_ptr, DBUS_ERROR_FAILED, "ladish_cqueue_add_command() failed.");
67 goto fail_destroy_command;
70 return true;
72 fail_destroy_command:
73 free(cmd_ptr);
75 fail_drop_stop_command:
76 ladish_cqueue_drop_command(queue_ptr);
78 fail:
79 return false;