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