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