leo_sobral@1
|
1 |
/**
|
leo_sobral@1
|
2 |
* GMyth Library
|
leo_sobral@1
|
3 |
*
|
leo_sobral@1
|
4 |
* @file gmyth/gmyth_socket.h
|
leo_sobral@1
|
5 |
*
|
leo_sobral@1
|
6 |
* @brief <p> MythTV socket implementation, according to the MythTV Project
|
leo_sobral@1
|
7 |
* (www.mythtv.org).
|
leo_sobral@1
|
8 |
*
|
leo_sobral@1
|
9 |
* This component provides basic socket functionalities to interact with
|
leo_sobral@1
|
10 |
* the Mythtv backend.
|
leo_sobral@1
|
11 |
* <p>
|
leo_sobral@1
|
12 |
*
|
leo_sobral@1
|
13 |
* Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
|
leo_sobral@1
|
14 |
* @author Rosfran Lins Borges <rosfran.borges@indt.org.br>
|
leo_sobral@1
|
15 |
*
|
leo_sobral@1
|
16 |
*//*
|
leo_sobral@1
|
17 |
*
|
leo_sobral@1
|
18 |
* This program is free software; you can redistribute it and/or modify
|
leo_sobral@1
|
19 |
* it under the terms of the GNU Lesser General Public License as published by
|
leo_sobral@1
|
20 |
* the Free Software Foundation; either version 2 of the License, or
|
leo_sobral@1
|
21 |
* (at your option) any later version.
|
leo_sobral@1
|
22 |
*
|
leo_sobral@1
|
23 |
* This program is distributed in the hope that it will be useful,
|
leo_sobral@1
|
24 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
leo_sobral@1
|
25 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
leo_sobral@1
|
26 |
* GNU General Public License for more details.
|
leo_sobral@1
|
27 |
*
|
leo_sobral@1
|
28 |
* You should have received a copy of the GNU Lesser General Public License
|
leo_sobral@1
|
29 |
* along with this program; if not, write to the Free Software
|
leo_sobral@1
|
30 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
leo_sobral@1
|
31 |
*/
|
leo_sobral@1
|
32 |
|
leo_sobral@1
|
33 |
#ifndef __GMYTH_SOCKET_H__
|
leo_sobral@1
|
34 |
#define __GMYTH_SOCKET_H__
|
leo_sobral@1
|
35 |
|
leo_sobral@1
|
36 |
#include <glib-object.h>
|
leo_sobral@1
|
37 |
|
leo_sobral@1
|
38 |
#include <string.h>
|
leo_sobral@1
|
39 |
#include <netdb.h>
|
leo_sobral@1
|
40 |
#include <sys/socket.h>
|
leo_sobral@1
|
41 |
#include <unistd.h>
|
leo_sobral@1
|
42 |
#include <glib.h>
|
leo_sobral@1
|
43 |
|
leo_sobral@1
|
44 |
#include "gmyth_stringlist.h"
|
leo_sobral@1
|
45 |
|
leo_sobral@6
|
46 |
G_BEGIN_DECLS
|
leo_sobral@1
|
47 |
|
leo_sobral@1
|
48 |
#define GMYTH_SOCKET_TYPE (gmyth_socket_get_type ())
|
leo_sobral@1
|
49 |
#define GMYTH_SOCKET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_SOCKET_TYPE, GMythSocket))
|
leo_sobral@1
|
50 |
#define GMYTH_SOCKET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_SOCKET_TYPE, GMythSocketClass))
|
rosfran@545
|
51 |
#define IS_GMYTH_SOCKET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GMYTH_SOCKET_TYPE))
|
leo_sobral@1
|
52 |
#define IS_GMYTH_SOCKET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_SOCKET_TYPE))
|
leo_sobral@1
|
53 |
#define GMYTH_SOCKET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GMYTH_SOCKET_TYPE, GMythSocketClass))
|
leo_sobral@1
|
54 |
|
leo_sobral@1
|
55 |
|
leo_sobral@1
|
56 |
typedef struct _GMythSocket GMythSocket;
|
leo_sobral@1
|
57 |
typedef struct _GMythSocketClass GMythSocketClass;
|
leo_sobral@1
|
58 |
|
leo_sobral@1
|
59 |
struct _GMythSocketClass
|
leo_sobral@1
|
60 |
{
|
leo_sobral@1
|
61 |
GObjectClass parent_class;
|
leo_sobral@1
|
62 |
|
leo_sobral@1
|
63 |
/* callbacks */
|
leo_sobral@1
|
64 |
/* no one for now */
|
leo_sobral@1
|
65 |
};
|
leo_sobral@1
|
66 |
|
leo_sobral@1
|
67 |
struct _GMythSocket
|
leo_sobral@1
|
68 |
{
|
rosfran@356
|
69 |
GObject parent;
|
rosfran@356
|
70 |
|
rosfran@356
|
71 |
GMutex *mutex;
|
leo_sobral@1
|
72 |
|
leo_sobral@1
|
73 |
/* socket descriptor */
|
rosfran@356
|
74 |
gint sd;
|
rosfran@356
|
75 |
GIOChannel *sd_io_ch;
|
leo_sobral@1
|
76 |
|
rosfran@356
|
77 |
gchar *hostname;
|
rosfran@356
|
78 |
gint port;
|
rosfran@356
|
79 |
gint mythtv_version;
|
leo_sobral@1
|
80 |
};
|
leo_sobral@1
|
81 |
|
rosfran@101
|
82 |
/* used when no protocol version number was negotiated */
|
rosfran@101
|
83 |
#define MYTHTV_CANNOT_NEGOTIATE_VERSION 0
|
leo_sobral@1
|
84 |
|
leo_sobral@1
|
85 |
GType gmyth_socket_get_type (void);
|
leo_sobral@1
|
86 |
|
melunko@276
|
87 |
GMythSocket * gmyth_socket_new ();
|
morphbr@266
|
88 |
|
leo_sobral@1
|
89 |
GIOChannel * gmyth_socket_get_io_channel (GMythSocket *gmyth_socket );
|
leo_sobral@1
|
90 |
|
leo_sobral@1
|
91 |
gboolean gmyth_socket_is_able_to_read (GMythSocket *gmyth_socket );
|
leo_sobral@1
|
92 |
gboolean gmyth_socket_is_able_to_write (GMythSocket *gmyth_socket );
|
leo_sobral@1
|
93 |
|
leo_sobral@1
|
94 |
gboolean gmyth_socket_send_command (GMythSocket *gmyth_socket,
|
rosfran@101
|
95 |
GString *command);
|
leo_sobral@1
|
96 |
GString * gmyth_socket_receive_response (GMythSocket *gmyth_socket);
|
morphbr@266
|
97 |
gint gmyth_socket_sendreceive_stringlist (GMythSocket *gmyth_socket,
|
leo_sobral@1
|
98 |
GMythStringList *str_list);
|
leo_sobral@1
|
99 |
|
melunko@112
|
100 |
gboolean gmyth_socket_connect (GMythSocket *gmyth_socket,
|
melunko@158
|
101 |
const gchar *hostname, gint port);
|
melunko@258
|
102 |
gboolean gmyth_socket_connect_with_timeout (GMythSocket *gmyth_socket,
|
leo_sobral@446
|
103 |
const gchar *hostname, gint port, guint timeout);
|
melunko@258
|
104 |
|
leo_sobral@1
|
105 |
gboolean gmyth_socket_connect_to_backend (GMythSocket *gmyth_socket,
|
rosfran@177
|
106 |
const gchar *hostname_backend, gint port,
|
rosfran@177
|
107 |
gboolean blocking_client);
|
rosfran@177
|
108 |
|
rosfran@177
|
109 |
gboolean gmyth_socket_connect_to_backend_events (GMythSocket *gmyth_socket,
|
rosfran@177
|
110 |
const gchar *hostname_backend, gint port,
|
rosfran@177
|
111 |
gboolean blocking_client);
|
leo_sobral@1
|
112 |
|
rosfran@529
|
113 |
gchar *gmyth_socket_get_primary_addr(void);
|
rosfran@529
|
114 |
|
rosfran@529
|
115 |
GString *gmyth_socket_get_local_hostname (void);
|
leo_sobral@1
|
116 |
|
leo_sobral@1
|
117 |
void gmyth_socket_close_connection (GMythSocket *gmyth_socket);
|
leo_sobral@1
|
118 |
|
leo_sobral@1
|
119 |
gboolean gmyth_socket_check_protocol_version (GMythSocket *gmyth_socket);
|
leo_sobral@446
|
120 |
gint gmyth_socket_check_protocol_version_number (GMythSocket *gmyth_socket,
|
leo_sobral@1
|
121 |
gint mythtv_version);
|
leo_sobral@1
|
122 |
|
leo_sobral@446
|
123 |
gint gmyth_socket_get_protocol_version (GMythSocket *gmyth_socket);
|
rosfran@101
|
124 |
|
leo_sobral@1
|
125 |
gboolean gmyth_socket_write_stringlist(GMythSocket *gmyth_socket,
|
leo_sobral@1
|
126 |
GMythStringList* str_list);
|
leo_sobral@446
|
127 |
gint gmyth_socket_read_stringlist(GMythSocket *gmyth_socket,
|
leo_sobral@1
|
128 |
GMythStringList* str_list);
|
leo_sobral@6
|
129 |
G_END_DECLS
|
leo_sobral@1
|
130 |
|
leo_sobral@1
|
131 |
#endif /* __GMYTH_SOCKET_H__ */
|