Upgrade ofono to 1.2
[profile/ivi/ofono.git] / gatchat / gatmux.h
1 /*
2  *
3  *  AT chat library with GLib integration
4  *
5  *  Copyright (C) 2008-2011  Intel Corporation. All rights reserved.
6  *  Copyright (C) 2009  Trolltech ASA.
7  *
8  *  This program is free software; you can redistribute it and/or modify
9  *  it under the terms of the GNU General Public License version 2 as
10  *  published by the Free Software Foundation.
11  *
12  *  This program is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *  GNU General Public License for more details.
16  *
17  *  You should have received a copy of the GNU General Public License
18  *  along with this program; if not, write to the Free Software
19  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20  *
21  */
22
23 #ifndef __GATMUX_H
24 #define __GATMUX_H
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29
30 #include "gatchat.h"
31
32 struct _GAtMux;
33
34 typedef struct _GAtMux GAtMux;
35 typedef struct _GAtMuxDriver GAtMuxDriver;
36 typedef enum _GAtMuxChannelStatus GAtMuxChannelStatus;
37 typedef void (*GAtMuxSetupFunc)(GAtMux *mux, gpointer user_data);
38
39 enum _GAtMuxDlcStatus {
40         G_AT_MUX_DLC_STATUS_RTC = 0x02,
41         G_AT_MUX_DLC_STATUS_RTR = 0x04,
42         G_AT_MUX_DLC_STATUS_IC = 0x08,
43         G_AT_MUX_DLC_STATUS_DV = 0x80,
44 };
45
46 struct _GAtMuxDriver {
47         void (*remove)(GAtMux *mux);
48         gboolean (*startup)(GAtMux *mux);
49         gboolean (*shutdown)(GAtMux *mux);
50         gboolean (*open_dlc)(GAtMux *mux, guint8 dlc);
51         gboolean (*close_dlc)(GAtMux *mux, guint8 dlc);
52         void (*set_status)(GAtMux *mux, guint8 dlc, guint8 status);
53         void (*write)(GAtMux *mux, guint8 dlc, const void *data, int towrite);
54         int (*feed_data)(GAtMux *mux, void *data, int len);
55 };
56
57 GAtMux *g_at_mux_new(GIOChannel *channel, const GAtMuxDriver *driver);
58 GAtMux *g_at_mux_new_gsm0710_basic(GIOChannel *channel, int framesize);
59 GAtMux *g_at_mux_new_gsm0710_advanced(GIOChannel *channel, int framesize);
60
61 GAtMux *g_at_mux_ref(GAtMux *mux);
62 void g_at_mux_unref(GAtMux *mux);
63
64 gboolean g_at_mux_start(GAtMux *mux);
65 gboolean g_at_mux_shutdown(GAtMux *mux);
66
67 gboolean g_at_mux_set_disconnect_function(GAtMux *mux,
68                         GAtDisconnectFunc disconnect, gpointer user_data);
69
70 gboolean g_at_mux_set_debug(GAtMux *mux, GAtDebugFunc func, gpointer user_data);
71
72 GIOChannel *g_at_mux_create_channel(GAtMux *mux);
73
74 /*!
75  * Multiplexer driver integration functions
76  */
77 void g_at_mux_set_dlc_status(GAtMux *mux, guint8 dlc, int status);
78 void g_at_mux_feed_dlc_data(GAtMux *mux, guint8 dlc,
79                                 const void *data, int tofeed);
80
81 int g_at_mux_raw_write(GAtMux *mux, const void *data, int towrite);
82
83 void g_at_mux_set_data(GAtMux *mux, void *data);
84 void *g_at_mux_get_data(GAtMux *mux);
85
86 /*!
87  * Uses the passed in GAtChat to setup a GSM 07.10 style multiplexer on the
88  * channel used by GAtChat.  This function queries the multiplexer capability,
89  * preferring advanced mode over basic.  If supported, the best available
90  * multiplexer mode is entered.  If this is successful, the chat is
91  * shutdown and unrefed.  The chat's channel will be transferred to the
92  * resulting multiplexer object.
93  */
94 gboolean g_at_mux_setup_gsm0710(GAtChat *chat,
95                                 GAtMuxSetupFunc notify, gpointer user_data,
96                                 GDestroyNotify destroy);
97
98 #ifdef __cplusplus
99 }
100 #endif
101
102 #endif /* __GATMUX_H */