renatofilho@320: /** renatofilho@320: * GMyth Library renatofilho@320: * renatofilho@320: * @file gmyth/gmyth_socket.h renatofilho@320: * renatofilho@320: * @brief

MythTV socket implementation, according to the MythTV Project renatofilho@320: * (www.mythtv.org). renatofilho@320: * renatofilho@320: * This component provides basic socket functionalities to interact with renatofilho@320: * the Mythtv backend. renatofilho@320: *

renatofilho@320: * renatofilho@320: * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia. renatofilho@320: * @author Rosfran Lins Borges renatofilho@320: * renatofilho@320: *//* renatofilho@320: * renatofilho@320: * This program is free software; you can redistribute it and/or modify renatofilho@320: * it under the terms of the GNU Lesser General Public License as published by renatofilho@320: * the Free Software Foundation; either version 2 of the License, or renatofilho@320: * (at your option) any later version. renatofilho@320: * renatofilho@320: * This program is distributed in the hope that it will be useful, renatofilho@320: * but WITHOUT ANY WARRANTY; without even the implied warranty of renatofilho@320: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the renatofilho@320: * GNU General Public License for more details. renatofilho@320: * renatofilho@320: * You should have received a copy of the GNU Lesser General Public License renatofilho@320: * along with this program; if not, write to the Free Software renatofilho@320: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA renatofilho@320: */ renatofilho@320: renatofilho@320: #ifndef __GMYTH_SOCKET_H__ renatofilho@320: #define __GMYTH_SOCKET_H__ renatofilho@320: renatofilho@320: #include renatofilho@320: renatofilho@320: #include renatofilho@320: #include renatofilho@320: #include renatofilho@320: #include renatofilho@320: #include renatofilho@320: renatofilho@320: #include "gmyth_stringlist.h" renatofilho@320: renatofilho@320: G_BEGIN_DECLS renatofilho@320: renatofilho@320: #define GMYTH_SOCKET_TYPE (gmyth_socket_get_type ()) renatofilho@320: #define GMYTH_SOCKET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_SOCKET_TYPE, GMythSocket)) renatofilho@320: #define GMYTH_SOCKET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_SOCKET_TYPE, GMythSocketClass)) renatofilho@320: #define IS_GMYTH_SOCKET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_SOCKET_TYPE)) renatofilho@320: #define IS_GMYTH_SOCKET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_SOCKET_TYPE)) renatofilho@320: #define GMYTH_SOCKET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GMYTH_SOCKET_TYPE, GMythSocketClass)) renatofilho@320: renatofilho@320: renatofilho@320: typedef struct _GMythSocket GMythSocket; renatofilho@320: typedef struct _GMythSocketClass GMythSocketClass; renatofilho@320: renatofilho@320: struct _GMythSocketClass renatofilho@320: { renatofilho@320: GObjectClass parent_class; renatofilho@320: renatofilho@320: /* callbacks */ renatofilho@320: /* no one for now */ renatofilho@320: }; renatofilho@320: renatofilho@320: struct _GMythSocket renatofilho@320: { renatofilho@320: GObject parent; renatofilho@320: renatofilho@320: /* socket descriptor */ renatofilho@320: gint sd; renatofilho@320: GIOChannel *sd_io_ch; renatofilho@320: renatofilho@320: gchar *hostname; renatofilho@320: gint port; renatofilho@320: gint mythtv_version; renatofilho@320: }; renatofilho@320: renatofilho@320: /* used when no protocol version number was negotiated */ renatofilho@320: #define MYTHTV_CANNOT_NEGOTIATE_VERSION 0 renatofilho@320: renatofilho@320: GType gmyth_socket_get_type (void); renatofilho@320: renatofilho@320: GMythSocket * gmyth_socket_new (); renatofilho@320: renatofilho@320: gboolean gmyth_socket_connect (GMythSocket *gmyth_socket, const gchar *hostname, gint port); renatofilho@320: renatofilho@320: renatofilho@320: GIOChannel * gmyth_socket_get_io_channel (GMythSocket *gmyth_socket ); renatofilho@320: renatofilho@320: gboolean gmyth_socket_is_able_to_read (GMythSocket *gmyth_socket ); renatofilho@320: gboolean gmyth_socket_is_able_to_write (GMythSocket *gmyth_socket ); renatofilho@320: renatofilho@320: gboolean gmyth_socket_send_command (GMythSocket *gmyth_socket, renatofilho@320: GString *command); renatofilho@320: GString * gmyth_socket_receive_response (GMythSocket *gmyth_socket); renatofilho@320: gint gmyth_socket_sendreceive_stringlist (GMythSocket *gmyth_socket, renatofilho@320: GMythStringList *str_list); renatofilho@320: renatofilho@320: gboolean gmyth_socket_connect (GMythSocket *gmyth_socket, renatofilho@320: const gchar *hostname, gint port); renatofilho@320: gboolean gmyth_socket_connect_with_timeout (GMythSocket *gmyth_socket, renatofilho@320: const gchar *hostname, gint port, guint timeout); renatofilho@320: renatofilho@320: gboolean gmyth_socket_connect_to_backend (GMythSocket *gmyth_socket, renatofilho@320: const gchar *hostname_backend, gint port, renatofilho@320: gboolean blocking_client); renatofilho@320: renatofilho@320: gboolean gmyth_socket_connect_to_backend_events (GMythSocket *gmyth_socket, renatofilho@320: const gchar *hostname_backend, gint port, renatofilho@320: gboolean blocking_client); renatofilho@320: renatofilho@320: GString * gmyth_socket_get_local_hostname (void); renatofilho@320: renatofilho@320: void gmyth_socket_close_connection (GMythSocket *gmyth_socket); renatofilho@320: renatofilho@320: gboolean gmyth_socket_check_protocol_version (GMythSocket *gmyth_socket); renatofilho@320: gint gmyth_socket_check_protocol_version_number (GMythSocket *gmyth_socket, renatofilho@320: gint mythtv_version); renatofilho@320: renatofilho@320: gint gmyth_socket_get_protocol_version (GMythSocket *gmyth_socket); renatofilho@320: renatofilho@320: gboolean gmyth_socket_write_stringlist(GMythSocket *gmyth_socket, renatofilho@320: GMythStringList* str_list); renatofilho@320: gint gmyth_socket_read_stringlist(GMythSocket *gmyth_socket, renatofilho@320: GMythStringList* str_list); renatofilho@320: G_END_DECLS renatofilho@320: renatofilho@320: #endif /* __GMYTH_SOCKET_H__ */