~ubuntu-branches/ubuntu/karmic/me-tv/karmic

« back to all changes in this revision

Viewing changes to src/application.h

  • Committer: Bazaar Package Importer
  • Author(s): Michael Lamothe
  • Date: 2007-12-19 23:30:16 UTC
  • Revision ID: james.westby@ubuntu.com-20071219233016-2ng2clfh00xtlevc
Tags: upstream-0.4.19
ImportĀ upstreamĀ versionĀ 0.4.19

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2007 Michael Lamothe
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or modify
 
5
 * it under the terms of the GNU General Public License as published by
 
6
 * the Free Software Foundation; either version 2 of the License, or
 
7
 * (at your option) any later version.
 
8
 * 
 
9
 * This program is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 * GNU Library General Public License for more details.
 
13
 * 
 
14
 * You should have received a copy of the GNU General Public License
 
15
 * along with this program; if not, write to the Free Software
 
16
 * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
 
17
 */
 
18
 
 
19
#ifndef __APPLICATION_H__
 
20
#define __APPLICATION_H__
 
21
 
 
22
#include "main_window.h"
 
23
#include "dvb_tuner.h"
 
24
#include "configuration.h"
 
25
#include "epg.h"
 
26
#include "glade.h"
 
27
#include "channel_manager.h"
 
28
#include "io.h"
 
29
#include "network.h"
 
30
#include "recording_manager.h"
 
31
#include "status_icon.h"
 
32
 
 
33
#define APPLICATION_NAME        "Me TV"
 
34
#define CHECK_MAIN_THREAD       Application::get_current().check_thread(__PRETTY_FUNCTION__);
 
35
 
 
36
class Application
 
37
{
 
38
private:
 
39
        IO::Channel*            log_file;
 
40
        Configuration           configuration;
 
41
        Glade                           glade;
 
42
        ChannelManager          channel_manager;
 
43
        Epg                                     epg;
 
44
        DvbTuner*                       tuner;
 
45
        MainWindow*                     main_window;
 
46
        StatusIcon*                     status_icon;
 
47
        GtkWidget*                      about_dialog;
 
48
        GThread*                        stream_thread;
 
49
        GThread*                        epg_thread;
 
50
        GStaticRecMutex         stream_mutex;
 
51
        GStaticRecMutex         configuration_mutex;
 
52
        GStaticRecMutex         error_message_mutex;
 
53
        GStaticRecMutex         epg_mutex;
 
54
        gboolean                        terminate_threads;
 
55
        guint                           timeout_id;
 
56
        Glib::ustring           recording_file_name;
 
57
        FileStream*                     recording_file_stream;
 
58
        UdpSocket*                      network_stream;
 
59
        RecordingManager*       recording_manager;      
 
60
        GSList*                         epg_events;
 
61
        GSList*                         error_messages;
 
62
        GSList*                         auto_surf_iterator;
 
63
        GThread*                        main_thread;
 
64
        Glib::ustring           demux_path;
 
65
        Glib::ustring           dvr_path;
 
66
        Glib::ustring           exe_path;
 
67
        Glib::ustring           exe_directory;
 
68
        Glib::ustring           video_channel_name;
 
69
        guint                           epg_event_list_size;
 
70
        gboolean                        application_quit;
 
71
        
 
72
        static gboolean on_timer(gpointer data);
 
73
        static gpointer epg_thread_function(Application* application);
 
74
        static gpointer stream_thread_function(Application* application);       
 
75
        static gpointer startup_thread_function(Application* application);
 
76
        
 
77
        void stop();
 
78
        void start();
 
79
        void start_epg_thread();
 
80
        const Transponder& get_current_transponder();
 
81
        void stream_loop(FileStream& input);
 
82
        Glib::ustring fix_path(const Glib::ustring& path);
 
83
        Glib::ustring get_configuration_path();
 
84
        time_t last_auto_surf_time;
 
85
                
 
86
public:
 
87
        Application (int argc, char** argv);
 
88
        ~Application();
 
89
 
 
90
        static void run(int argc, char** argv);
 
91
        static Application& get_current();
 
92
        static Glib::ustring get_directory();
 
93
        
 
94
        Configuration& get_configuration() { return configuration; }
 
95
        void quit();
 
96
        void push_error_message(const Glib::ustring& message);
 
97
        void check_error_messages();
 
98
        void push_epg_event(const EpgEvent& event);
 
99
        void check_epg_events();
 
100
 
 
101
        IO::Channel& get_log_file();
 
102
        Glade& get_glade() { return glade; }
 
103
        Epg& get_epg() { return epg; }
 
104
        RecordingManager& get_recording_manager();
 
105
        
 
106
        ChannelManager& get_channel_manager() { return channel_manager; }
 
107
        Channel& get_channel(const Glib::ustring& channel_name);
 
108
        Channel& get_channel(int frequency, int service_id);
 
109
        void change_channel (const Glib::ustring& channel_name, gboolean keep_auto_surf = false );
 
110
        void change_channel (Channel& channel, gboolean keep_auto_surf = false );
 
111
 
 
112
        Channel& get_video_channel();
 
113
        const Glib::ustring& get_video_channel_name() const;
 
114
        Glib::ustring get_video_event_title();
 
115
 
 
116
        void stop_record();
 
117
        void start_record(const Glib::ustring& title);
 
118
        void start_record(Channel& channel, const Glib::ustring& title);
 
119
        void start_record_force(Channel& channel, const Glib::ustring& title);
 
120
        Glib::ustring get_recording_file_name() const { return recording_file_name; }
 
121
        void toggle_record();
 
122
        void record(gboolean state);
 
123
 
 
124
        void hide_controls();
 
125
 
 
126
        void toggle_visibility();
 
127
        
 
128
        void toggle_fullscreen();
 
129
        void toggle_controls();
 
130
 
 
131
        void toggle_mute();
 
132
        void mute(gboolean state);
 
133
 
 
134
        void toggle_broadcast();
 
135
        void broadcast(gboolean state);
 
136
 
 
137
        void toggle_auto_surf();
 
138
        void auto_surf(gboolean state);
 
139
 
 
140
        void audio_channel(int channel);
 
141
        void subtitle_channel(int channel);
 
142
 
 
143
        void update_epg();
 
144
        
 
145
        gboolean check_main_thread(const Glib::ustring& caller);
 
146
        
 
147
        void show_scheduled_recording_dialog();
 
148
        void show_event_dialog (const Glib::ustring& channel_name, int event_id);
 
149
        void show_scheduled_recording_dialog(const Glib::ustring& description);
 
150
        void show_scheduled_recordings_dialog();
 
151
        Glib::ustring get_test_path() const;
 
152
        
 
153
        const Glib::ustring& get_exe_path() const { return exe_path; }
 
154
 
 
155
        Glib::ustring get_status_message();
 
156
        
 
157
        void show_help();
 
158
        void show_about();
 
159
};
 
160
 
 
161
#endif