Added internal-lirc-backend and stuff.
[irreco.git] / backend / internal-lirc / src / backend_internal_lirc.h
blob76e79f48ead73774887d9ec2f6e5a7f6051b142f
1 /*
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.
22 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
23 /* Include */
24 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
26 #ifndef __BACKEND_INTERNAL_LIRC_H__
27 #define __BACKEND_INTERNAL_LIRC_H__
29 #define IRRECO_DEBUG_PREFIX "INTERNAL_LIRC"
30 #include "irreco_util.h"
32 #include <glib.h>
33 #include <glib/gprintf.h>
34 #include <glib/gstdio.h>
35 #include <gtk/gtk.h>
37 #include "irreco_backend_api.h"
41 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
42 /* Types */
43 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
44 typedef enum {
45 INTERNAL_LIRC_BACKEND_ERR_CANT_OPEN_SOCKET = 1,
46 INTERNAL_LIRC_BACKEND_ERR_CANT_CONNECT,
47 INTERNAL_LIRC_BACKEND_ERR_CANT_RESOLVE_HOST,
48 INTERNAL_LIRC_BACKEND_ERR_CONFIG_WRITE_FAILED,
49 INTERNAL_LIRC_BACKEND_ERR_CONFIG_READ_FAILED,
50 INTERNAL_LIRC_BACKEND_ERR_BAD_PACKET,
51 INTERNAL_LIRC_BACKEND_ERR_COULD_NOT_SEND_PACKET,
52 INTERNAL_LIRC_BACKEND_ERR_COMMAND_FAILED,
53 INTERNAL_LIRC_BACKEND_ERR_TIMEOUT,
54 INTERNAL_LIRC_BACKEND_ERR_FILE_OPEN_FAILED,
55 INTERNAL_LIRC_BACKEND_ERR_COULD_NOT_CREATE_DEVICE_DIR,
56 INTERNAL_LIRC_BACKEND_ERR_COULD_NOT_CREATE_BASE_DIR,
57 INTERNAL_LIRC_BACKEND_ERR_COULD_NOT_DELETE_DEVICE
58 } IrrecoInternalLircBackendError;
60 typedef struct _IrrecoInternalLircBackend IrrecoInternalLircBackend;
61 struct _IrrecoInternalLircBackend {
62 GString *host;
63 int port;
64 int socket;
65 GString *error_msg;
67 IrrecoGetDeviceCallback dev_callback;
68 IrrecoGetCommandCallback cmd_callback;
71 typedef void (*InternalLircBackendResponseHandler) (IrrecoInternalLircBackend
72 * internal_lirc_backend, const char * response);
76 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
77 /* Macro */
78 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
79 #define _(String) (String)
81 #define INTERNAL_LIRC_BASE_DIR "/home/user/MyDocs/irreco"
82 #define INTERNAL_LIRC_REMOTES_DIR "/home/user/MyDocs/irreco/InternalLircDevices"
83 #define INTERNAL_LIRC_LIRCD_CONF_PATH "/etc/lircd.conf"
84 /* For sbox testing only */
85 /* #define INTERNAL_LIRC_LIRCD_CONF_PATH "/home/user/.irreco/lircd.conf" */
87 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
88 /* Prototypes */
89 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/
90 void* internal_lirc_backend_create();
91 void internal_lirc_backend_destroy(void * instance_context, gboolean permanently);
92 IrrecoBackendStatus internal_lirc_backend_read_from_conf(void * instance_context,
93 const char * config_file);
95 IrrecoBackendStatus internal_lirc_backend_save_to_conf(void * instance_context,
96 const char * config_file);
97 const char *internal_lirc_backend_get_error_msg(void * instance_context,
98 IrrecoBackendStatus code);
99 int internal_lirc_backend_error(IrrecoInternalLircBackend * internal_lirc_backend,
100 IrrecoInternalLircBackendError code, ...);
101 int internal_lirc_backend_connect(IrrecoInternalLircBackend * internal_lirc_backend);
102 void internal_lirc_backend_disconnect(IrrecoInternalLircBackend * internal_lirc_backend);
103 IrrecoBackendStatus internal_lirc_backend_get_devices(void * instance_context,
104 IrrecoGetDeviceCallback callback);
105 void internal_lirc_backend_get_device_responce(IrrecoInternalLircBackend * internal_lirc_backend,
106 const char * response);
107 IrrecoBackendStatus internal_lirc_backend_get_commands(void * instance_context,
108 const char *device_name,
109 void *device_contex,
110 IrrecoGetCommandCallback callback);
111 void internal_lirc_backend_get_command_responce(IrrecoInternalLircBackend * internal_lirc_backend,
112 const char * response);
113 gchar *internal_lirc_backend_get_description(gpointer instance_context);
114 IrrecoBackendStatus internal_lirc_backend_send_command(void *instance_context,
115 const char *device_name,
116 void *device_contex,
117 const char *command_name,
118 void *command_contex);
119 IrrecoBackendStatus internal_lirc_backend_configure(void * instance_context,
120 GtkWindow * parent);
124 #endif /* __BACKEND_INTERNAL_LIRC_H__ */