1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/branches/gmyth-0.1b/src/gmyth_monitor_handler.h Wed Feb 14 21:28:49 2007 +0000
1.3 @@ -0,0 +1,117 @@
1.4 +/* vim: set sw=2: -*- Mode: C; tab-width: 2; indent-tabs-mode: t; c-basic-offset: 2; c-indent-level: 2-*- */
1.5 +/**
1.6 + * GMyth Library
1.7 + *
1.8 + * @file gmyth/gmyth_monitor_handler.h
1.9 + *
1.10 + * @brief <p> GMythMonitorHandler deals with the streaming media events remote/local
1.11 + * that are sent to the MythTV frontend.
1.12 + *
1.13 + * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
1.14 + * @author Rosfran Lins Borges <rosfran.borges@indt.org.br>
1.15 + *
1.16 + *//*
1.17 + *
1.18 + * This program is free software; you can redistribute it and/or modify
1.19 + * it under the terms of the GNU Lesser General Public License as published by
1.20 + * the Free Software Foundation; either version 2 of the License, or
1.21 + * (at your option) any later version.
1.22 + *
1.23 + * This program is distributed in the hope that it will be useful,
1.24 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.25 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.26 + * GNU General Public License for more details.
1.27 + *
1.28 + * You should have received a copy of the GNU Lesser General Public License
1.29 + * along with this program; if not, write to the Free Software
1.30 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1.31 + */
1.32 +
1.33 +#ifndef __GMYTH_MONITOR_HANDLER_H__
1.34 +#define __GMYTH_MONITOR_HANDLER_H__
1.35 +
1.36 +#include <glib-object.h>
1.37 +#include <glib.h>
1.38 +#include <stdio.h>
1.39 +#include <stdlib.h>
1.40 +#include <string.h>
1.41 +
1.42 +#include <netdb.h>
1.43 +#include <sys/socket.h>
1.44 +#include <unistd.h>
1.45 +
1.46 +#include "gmyth_socket.h"
1.47 +#include "gmyth_uri.h"
1.48 +
1.49 +G_BEGIN_DECLS
1.50 +
1.51 +#define GMYTH_MONITOR_HANDLER_TYPE (gmyth_monitor_handler_get_type ())
1.52 +#define GMYTH_MONITOR_HANDLER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_MONITOR_HANDLER_TYPE, GMythMonitorHandler))
1.53 +#define GMYTH_MONITOR_HANDLER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_MONITOR_HANDLER_TYPE, GMythMonitorHandlerClass))
1.54 +#define IS_GMYTH_MONITOR_HANDLER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_MONITOR_HANDLER_TYPE))
1.55 +#define IS_GMYTH_MONITOR_HANDLER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_MONITOR_HANDLER_TYPE))
1.56 +#define GMYTH_MONITOR_HANDLER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GMYTH_MONITOR_HANDLER_TYPE, GMythMonitorHandlerClass))
1.57 +
1.58 +#define GMYTHTV_MONITOR_HANDLER_READ_ERROR -314
1.59 +
1.60 +enum {
1.61 + GMYTH_BACKEND_NO_MESSAGE = 0,
1.62 + GMYTH_BACKEND_PROGRAM_INFO_CHANGED,
1.63 + GMYTH_BACKEND_DONE_RECORDING,
1.64 + GMYTH_BACKEND_STOP_LIVETV
1.65 +};
1.66 +
1.67 +typedef struct _GMythMonitorHandler GMythMonitorHandler;
1.68 +typedef struct _GMythMonitorHandlerClass GMythMonitorHandlerClass;
1.69 +
1.70 +struct _GMythMonitorHandlerClass
1.71 +{
1.72 + GObjectClass parent_class;
1.73 +
1.74 + /* callbacks */
1.75 + guint backend_events_handler_signal_id;
1.76 +
1.77 + /* signal default handlers */
1.78 + void (*backend_events_handler) (GMythMonitorHandler *monitor, gint msg_code, gchar* message );
1.79 +};
1.80 +
1.81 +struct _GMythMonitorHandler
1.82 +{
1.83 + GObject parent;
1.84 +
1.85 + /* MythTV version number */
1.86 + gint mythtv_version;
1.87 +
1.88 + /* socket descriptors */
1.89 + GMythSocket *event_sock;
1.90 +
1.91 + GThreadPool *monitor_th;
1.92 +
1.93 + // gboolean* (*gmyth_monitor_handler_listener)( GMythMonitorHandler *monitor );
1.94 + void (*gmyth_monitor_handler_listener)( GMythMonitorHandler *monitor, gpointer user_data );
1.95 +
1.96 + gchar *hostname;
1.97 + gint port;
1.98 +
1.99 + gint64 actual_index;
1.100 +
1.101 + gboolean allow_msgs_listener;
1.102 +
1.103 + /* stores the messages coming from the backend */
1.104 + GHashTable *backend_msgs;
1.105 +
1.106 +};
1.107 +
1.108 +GType gmyth_monitor_handler_get_type (void);
1.109 +
1.110 +GMythMonitorHandler* gmyth_monitor_handler_new ( void );
1.111 +
1.112 +gboolean gmyth_monitor_handler_open (GMythMonitorHandler *monitor, const gchar *hostname, gint port);
1.113 +
1.114 +gboolean gmyth_monitor_handler_start (GMythMonitorHandler *monitor);
1.115 +
1.116 +void gmyth_monitor_handler_close (GMythMonitorHandler *monitor);
1.117 +
1.118 +G_END_DECLS
1.119 +
1.120 +#endif /* __GMYTH_MONITOR_HANDLER_H__ */