gmyth/src/gmyth_monitor_handler.h
author rosfran
Wed Dec 13 23:44:04 2006 +0000 (2006-12-13)
branchtrunk
changeset 220 462a3c81abd6
parent 216 001205bb0f40
child 229 5ed97410d052
permissions -rwxr-xr-x
[svn r221] Added some signals to interact with the MythTV backend messages.
rosfran@175
     1
/* vim: set sw=2: -*- Mode: C; tab-width: 2; indent-tabs-mode: t; c-basic-offset: 2; c-indent-level: 2-*- */
rosfran@175
     2
/**
rosfran@175
     3
 * GMyth Library
rosfran@175
     4
 *
rosfran@175
     5
 * @file gmyth/gmyth_monitor_handler.h
rosfran@175
     6
 * 
rosfran@175
     7
 * @brief <p> GMythMonitorHandler deals with the streaming media events remote/local
rosfran@175
     8
 * that are sent to the MythTV frontend.
rosfran@175
     9
 *
rosfran@175
    10
 * Copyright (C) 2006 INdT - Instituto Nokia de Tecnologia.
rosfran@175
    11
 * @author Rosfran Lins Borges <rosfran.borges@indt.org.br>
rosfran@175
    12
 *
rosfran@175
    13
 *//*
rosfran@175
    14
 * 
rosfran@175
    15
 * This program is free software; you can redistribute it and/or modify
rosfran@175
    16
 * it under the terms of the GNU Lesser General Public License as published by
rosfran@175
    17
 * the Free Software Foundation; either version 2 of the License, or
rosfran@175
    18
 * (at your option) any later version.
rosfran@175
    19
 *
rosfran@175
    20
 * This program is distributed in the hope that it will be useful,
rosfran@175
    21
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
rosfran@175
    22
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
rosfran@175
    23
 * GNU General Public License for more details.
rosfran@175
    24
 *
rosfran@175
    25
 * You should have received a copy of the GNU Lesser General Public License
rosfran@175
    26
 * along with this program; if not, write to the Free Software
rosfran@175
    27
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
rosfran@175
    28
 */
rosfran@175
    29
 
rosfran@175
    30
#ifndef __GMYTH_MONITOR_HANDLER_H__
rosfran@175
    31
#define __GMYTH_MONITOR_HANDLER_H__
rosfran@175
    32
rosfran@175
    33
#include <glib-object.h>
rosfran@175
    34
#include <glib.h>
leo_sobral@213
    35
#include <stdio.h>
leo_sobral@213
    36
#include <stdlib.h>
leo_sobral@213
    37
#include <string.h>
rosfran@175
    38
leo_sobral@213
    39
#include <netdb.h>
leo_sobral@213
    40
#include <sys/socket.h>
leo_sobral@213
    41
#include <unistd.h>
rosfran@216
    42
rosfran@175
    43
#include "gmyth_socket.h"
rosfran@175
    44
#include "gmyth_uri.h"
rosfran@175
    45
leo_sobral@213
    46
G_BEGIN_DECLS
rosfran@175
    47
rosfran@175
    48
#define GMYTH_MONITOR_HANDLER_TYPE               (gmyth_monitor_handler_get_type ())
rosfran@175
    49
#define GMYTH_MONITOR_HANDLER(obj)               (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_MONITOR_HANDLER_TYPE, GMythMonitorHandler))
rosfran@175
    50
#define GMYTH_MONITOR_HANDLER_CLASS(klass)       (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_MONITOR_HANDLER_TYPE, GMythMonitorHandlerClass))
rosfran@175
    51
#define IS_GMYTH_MONITOR_HANDLER(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_MONITOR_HANDLER_TYPE))
rosfran@175
    52
#define IS_GMYTH_MONITOR_HANDLER_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_MONITOR_HANDLER_TYPE))
rosfran@175
    53
#define GMYTH_MONITOR_HANDLER_GET_CLASS(obj)     (G_TYPE_INSTANCE_GET_CLASS ((obj), GMYTH_MONITOR_HANDLER_TYPE, GMythMonitorHandlerClass))
rosfran@175
    54
rosfran@175
    55
#define GMYTHTV_MONITOR_HANDLER_READ_ERROR	-314
rosfran@175
    56
rosfran@216
    57
enum {
rosfran@216
    58
	GMYTH_BACKEND_NO_MESSAGE = 0,
rosfran@216
    59
  GMYTH_BACKEND_PROGRAM_INFO_CHANGED,
rosfran@216
    60
  GMYTH_BACKEND_STOP_LIVETV
rosfran@216
    61
};
rosfran@216
    62
rosfran@175
    63
typedef struct _GMythMonitorHandler         GMythMonitorHandler;
rosfran@175
    64
typedef struct _GMythMonitorHandlerClass    GMythMonitorHandlerClass;
rosfran@175
    65
rosfran@175
    66
struct _GMythMonitorHandlerClass
rosfran@175
    67
{
rosfran@175
    68
	GObjectClass parent_class;
rosfran@175
    69
rosfran@203
    70
	/* callbacks */	
rosfran@203
    71
	guint backend_events_handler_signal_id;
rosfran@203
    72
rosfran@203
    73
  /* signal default handlers */
rosfran@220
    74
  void (*backend_events_handler) (GMythMonitorHandler *monitor, gint msg_code, gchar* message, 
rosfran@220
    75
  					gpointer livetv, gpointer user_data );
rosfran@175
    76
};
rosfran@175
    77
rosfran@175
    78
struct _GMythMonitorHandler
rosfran@175
    79
{
rosfran@175
    80
	GObject parent;
rosfran@175
    81
rosfran@175
    82
	/* MythTV version number */	
rosfran@175
    83
	gint mythtv_version;
rosfran@175
    84
rosfran@175
    85
	/* socket descriptors */
rosfran@175
    86
	GMythSocket *event_sock;
rosfran@216
    87
	
rosfran@220
    88
	GThread *monitor_th;
rosfran@220
    89
	
rosfran@220
    90
	gboolean* (*gmyth_monitor_handler_listener)( GMythMonitorHandler *monitor );
rosfran@220
    91
	
rosfran@175
    92
	gchar *hostname;
rosfran@175
    93
	gint port;
rosfran@175
    94
	
rosfran@175
    95
	gint64 actual_index;
rosfran@175
    96
	
rosfran@175
    97
	/* stores the messages coming from the backend */
rosfran@216
    98
	GHashTable *backend_msgs;	
rosfran@216
    99
rosfran@175
   100
};
rosfran@175
   101
rosfran@175
   102
GType          gmyth_monitor_handler_get_type        (void);
rosfran@175
   103
rosfran@216
   104
GMythMonitorHandler* gmyth_monitor_handler_new ( void );
rosfran@175
   105
rosfran@175
   106
gboolean gmyth_monitor_handler_open (GMythMonitorHandler *monitor, gchar *hostname, gint port);
rosfran@175
   107
rosfran@175
   108
gboolean gmyth_monitor_handler_start (GMythMonitorHandler *monitor);
rosfran@175
   109
rosfran@175
   110
void gmyth_monitor_handler_close (GMythMonitorHandler *monitor);
rosfran@175
   111
leo_sobral@213
   112
G_END_DECLS
rosfran@175
   113
rosfran@175
   114
#endif /* __GMYTH_MONITOR_HANDLER_H__ */