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@232
|
74 |
void (*backend_events_handler) (GMythMonitorHandler *monitor, gint msg_code, gchar* message );
|
rosfran@175
|
75 |
};
|
rosfran@175
|
76 |
|
rosfran@175
|
77 |
struct _GMythMonitorHandler
|
rosfran@175
|
78 |
{
|
rosfran@175
|
79 |
GObject parent;
|
rosfran@175
|
80 |
|
rosfran@175
|
81 |
/* MythTV version number */
|
rosfran@175
|
82 |
gint mythtv_version;
|
rosfran@175
|
83 |
|
rosfran@175
|
84 |
/* socket descriptors */
|
rosfran@175
|
85 |
GMythSocket *event_sock;
|
rosfran@216
|
86 |
|
rosfran@232
|
87 |
GThreadPool *monitor_th;
|
rosfran@220
|
88 |
|
rosfran@232
|
89 |
// gboolean* (*gmyth_monitor_handler_listener)( GMythMonitorHandler *monitor );
|
rosfran@232
|
90 |
void (*gmyth_monitor_handler_listener)( GMythMonitorHandler *monitor, gpointer user_data );
|
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@233
|
97 |
gboolean allow_msgs_listener;
|
rosfran@233
|
98 |
|
rosfran@175
|
99 |
/* stores the messages coming from the backend */
|
rosfran@216
|
100 |
GHashTable *backend_msgs;
|
rosfran@216
|
101 |
|
rosfran@175
|
102 |
};
|
rosfran@175
|
103 |
|
rosfran@175
|
104 |
GType gmyth_monitor_handler_get_type (void);
|
rosfran@175
|
105 |
|
rosfran@216
|
106 |
GMythMonitorHandler* gmyth_monitor_handler_new ( void );
|
rosfran@175
|
107 |
|
rosfran@229
|
108 |
gboolean gmyth_monitor_handler_open (GMythMonitorHandler *monitor, const gchar *hostname, gint port);
|
rosfran@175
|
109 |
|
rosfran@175
|
110 |
gboolean gmyth_monitor_handler_start (GMythMonitorHandler *monitor);
|
rosfran@175
|
111 |
|
rosfran@175
|
112 |
void gmyth_monitor_handler_close (GMythMonitorHandler *monitor);
|
rosfran@175
|
113 |
|
leo_sobral@213
|
114 |
G_END_DECLS
|
rosfran@175
|
115 |
|
rosfran@175
|
116 |
#endif /* __GMYTH_MONITOR_HANDLER_H__ */
|