2 * irreco - Ir Remote Control
3 * Copyright (C) 2007 Arto Karppinen (arto.karppinen@iki.fi)
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #include "irreco_backend_device.h"
23 * @addtogroup IrrecoBackendDevice
26 * Used to storage the information and data provided about the device by
27 * an instance of some backend.
34 * Source file of @ref IrrecoBackendDevice.
39 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
40 /* Construction & Destruction */
41 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
44 * @name Construction & Destruction
49 irreco_backend_device_create(const gchar
*name
,
50 IrrecoBackendInstance
* backend_instance
,
53 IrrecoBackendDevice
*backend_device
;
56 g_assert(name
!= NULL
);
57 g_assert(backend_instance
!= NULL
);
59 backend_device
= g_slice_new0(IrrecoBackendDevice
);
60 backend_device
->backend_instance
= backend_instance
;
61 backend_device
->name
= g_strdup(name
);
62 backend_device
->contex
= contex
;
63 backend_device
->command_list
= irreco_string_table_new(NULL
, NULL
);
64 IRRECO_RETURN_PTR(backend_device
);
67 void irreco_backend_device_destroy(IrrecoBackendDevice
*backend_device
)
70 if (backend_device
== NULL
) IRRECO_RETURN
71 irreco_string_table_free(backend_device
->command_list
);
72 g_free(backend_device
->name
);
73 backend_device
->name
= NULL
;
74 g_slice_free(IrrecoBackendDevice
, backend_device
);
82 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
84 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
92 * Can this device be exported?
94 * @sa irreco_backend_instance_api_export
96 gboolean
irreco_backend_device_is_editable(IrrecoBackendDevice
* device
)
101 g_assert(device
!= NULL
);
103 /* Does the backend support editable devices at all? */
104 if ( ! irreco_backend_instance_api_edit(device
->backend_instance
)) {
105 IRRECO_RETURN_BOOL(FALSE
);
108 /* Is this device editable? */
109 IRRECO_BACKEND_ENTER(device
->backend_instance
, "is_device_editable()");
110 rvalue
= device
->backend_instance
->lib
->api
->is_device_editable(
111 device
->backend_instance
->contex
, device
->name
, device
->contex
);
112 IRRECO_BACKEND_RETURN("is_device_editable()");
113 IRRECO_RETURN_BOOL(rvalue
);
117 * Can this device be exported?
119 * @sa irreco_backend_instance_api_export
121 gboolean
irreco_backend_device_is_exportable(IrrecoBackendDevice
* device
)
124 g_assert(device
!= NULL
);
126 irreco_backend_instance_api_export(
127 device
->backend_instance
))
130 void irreco_backend_device_edit(IrrecoBackendDevice
* device
,
133 IrrecoBackendStatus status
;
136 g_assert(device
!= NULL
);
137 g_assert(parent
!= NULL
);
139 IRRECO_BACKEND_ENTER(device
->backend_instance
, "edit_device()");
140 status
= device
->backend_instance
->lib
->api
->edit_device(
141 device
->backend_instance
->contex
, device
->name
,
142 device
->contex
, parent
);
143 IRRECO_BACKEND_RETURN("edit_device()");
144 irreco_backend_instance_check_status(device
->backend_instance
, status
);
149 void irreco_backend_device_delete(IrrecoBackendDevice
* device
,
152 IrrecoBackendStatus status
;
155 g_assert(device
!= NULL
);
156 g_assert(parent
!= NULL
);
158 IRRECO_BACKEND_ENTER(device
->backend_instance
, "delete_device()");
159 status
= device
->backend_instance
->lib
->api
->delete_device(
160 device
->backend_instance
->contex
, device
->name
,
161 device
->contex
, parent
);
162 IRRECO_BACKEND_RETURN("delete_device()");
163 irreco_backend_instance_check_status(device
->backend_instance
, status
);