[svn r348] Fixes.
4 * @file gmyth/gmyth_socket.h
6 * @brief <p> MythTV socket implementation, according to the MythTV Project
9 * This component provides basic socket functionalities to interact with
13 * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
14 * @author Rosfran Lins Borges <rosfran.borges@indt.org.br>
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU Lesser General Public License as published by
20 * the Free Software Foundation; either version 2 of the License, or
21 * (at your option) any later version.
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
28 * You should have received a copy of the GNU Lesser General Public License
29 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
33 #ifndef __GMYTH_SOCKET_H__
34 #define __GMYTH_SOCKET_H__
36 #include <glib-object.h>
40 #include <sys/socket.h>
44 #include "gmyth_stringlist.h"
48 #define GMYTH_SOCKET_TYPE (gmyth_socket_get_type ())
49 #define GMYTH_SOCKET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_SOCKET_TYPE, GMythSocket))
50 #define GMYTH_SOCKET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_SOCKET_TYPE, GMythSocketClass))
51 #define IS_GMYTH_SOCKET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_SOCKET_TYPE))
52 #define IS_GMYTH_SOCKET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_SOCKET_TYPE))
53 #define GMYTH_SOCKET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GMYTH_SOCKET_TYPE, GMythSocketClass))
56 typedef struct _GMythSocket GMythSocket;
57 typedef struct _GMythSocketClass GMythSocketClass;
59 struct _GMythSocketClass
61 GObjectClass parent_class;
71 /* socket descriptor */
80 /* used when no protocol version number was negotiated */
81 #define MYTHTV_CANNOT_NEGOTIATE_VERSION 0
83 GType gmyth_socket_get_type (void);
85 GMythSocket * gmyth_socket_new ();
87 gboolean gmyth_socket_connect (GMythSocket *gmyth_socket, const gchar *hostname, gint port);
90 GIOChannel * gmyth_socket_get_io_channel (GMythSocket *gmyth_socket );
92 gboolean gmyth_socket_is_able_to_read (GMythSocket *gmyth_socket );
93 gboolean gmyth_socket_is_able_to_write (GMythSocket *gmyth_socket );
95 gboolean gmyth_socket_send_command (GMythSocket *gmyth_socket,
97 GString * gmyth_socket_receive_response (GMythSocket *gmyth_socket);
98 gint gmyth_socket_sendreceive_stringlist (GMythSocket *gmyth_socket,
99 GMythStringList *str_list);
101 gboolean gmyth_socket_connect (GMythSocket *gmyth_socket,
102 const gchar *hostname, gint port);
103 gboolean gmyth_socket_connect_with_timeout (GMythSocket *gmyth_socket,
104 const gchar *hostname, gint port, guint timeout);
106 gboolean gmyth_socket_connect_to_backend (GMythSocket *gmyth_socket,
107 const gchar *hostname_backend, gint port,
108 gboolean blocking_client);
110 gboolean gmyth_socket_connect_to_backend_events (GMythSocket *gmyth_socket,
111 const gchar *hostname_backend, gint port,
112 gboolean blocking_client);
114 GString * gmyth_socket_get_local_hostname (void);
116 void gmyth_socket_close_connection (GMythSocket *gmyth_socket);
118 gboolean gmyth_socket_check_protocol_version (GMythSocket *gmyth_socket);
119 gint gmyth_socket_check_protocol_version_number (GMythSocket *gmyth_socket,
120 gint mythtv_version);
122 gint gmyth_socket_get_protocol_version (GMythSocket *gmyth_socket);
124 gboolean gmyth_socket_write_stringlist(GMythSocket *gmyth_socket,
125 GMythStringList* str_list);
126 gint gmyth_socket_read_stringlist(GMythSocket *gmyth_socket,
127 GMythStringList* str_list);
130 #endif /* __GMYTH_SOCKET_H__ */