~ubuntu-branches/ubuntu/trusty/me-tv/trusty

« back to all changes in this revision

Viewing changes to src/dvb_scanner.cc

  • Committer: Bazaar Package Importer
  • Author(s): Teis Dreijer
  • Date: 2010-02-14 11:29:00 UTC
  • mfrom: (1.1.11 upstream) (3.1.10 sid)
  • Revision ID: james.westby@ubuntu.com-20100214112900-krutrmpz248vz1ji
Tags: 1.1.6-2
* Updated debian/control
  - Removed libgnomem-2.6-dev and libgnomeuimm-2.6-dev
    from Build-Depends (Closes: #568782)
  - Added libgconfmm-2.6-dev to Build-Depends

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
#include "dvb_scanner.h"
26
26
#include "dvb_demuxer.h"
27
27
#include "dvb_frontend.h"
28
 
#include "string_splitter.h"
29
28
#include "initial_scan_line.h"
30
29
 
31
30
using namespace Dvb;
212
211
 
213
212
void Scanner::start(Frontend& frontend, const Glib::ustring& region_file_path)
214
213
{
215
 
        Glib::RefPtr<Glib::IOChannel> initial_tuning_file = Glib::IOChannel::create_from_file(region_file_path, "r");
216
 
        
217
 
        std::list<Glib::ustring> lines;
218
 
        Glib::ustring line;
219
 
        Glib::IOStatus status = initial_tuning_file->read_line(line);
220
 
        while (status == Glib::IO_STATUS_NORMAL && !terminated)
 
214
        if (region_file_path.empty())
221
215
        {
222
 
                // Remove comments
223
 
                Glib::ustring::size_type index = line.find("#");
224
 
                if (index != Glib::ustring::npos)
225
 
                {
226
 
                        line = line.substr(0, index);
227
 
                }
228
 
                
229
 
                // Remove trailing whitespace
230
 
                index = line.find_last_not_of(" \t\r\n");
231
 
                if (index == Glib::ustring::npos)
232
 
                {
233
 
                        line.clear();
234
 
                }
235
 
                else
236
 
                {
237
 
                        line = line.substr(0, index + 1);
238
 
                }
239
 
 
240
 
                if (!line.empty()) // Ignore empty lines or comments
241
 
                {
242
 
                        lines.push_back(line);
243
 
                }
244
 
                
245
 
                status = initial_tuning_file->read_line(line);
 
216
                auto_scan(frontend);
246
217
        }
247
 
        
248
 
        guint size = lines.size();
249
 
        
250
 
        for (StringList::iterator iterator = lines.begin(); iterator != lines.end() && !terminated; iterator++)
 
218
        else
251
219
        {
252
 
                Glib::ustring process_line = *iterator;
 
220
                Glib::RefPtr<Glib::IOChannel> initial_tuning_file = Glib::IOChannel::create_from_file(region_file_path, "r");
253
221
 
254
 
                if (!process_line.empty())
 
222
                std::list<Glib::ustring> lines;
 
223
                Glib::ustring line;
 
224
                Glib::IOStatus status = initial_tuning_file->read_line(line);
 
225
                while (status == Glib::IO_STATUS_NORMAL && !terminated)
255
226
                {
256
 
                        g_debug("Processing line: '%s'", process_line.c_str());
257
 
 
258
 
                        if (Glib::str_has_prefix(process_line, "T "))
259
 
                        {
260
 
                                process_terrestrial_line(frontend, process_line);
261
 
                        }
262
 
                        else if (Glib::str_has_prefix(process_line, "C "))
263
 
                        {
264
 
                                process_cable_line(frontend, process_line);
265
 
                        }
266
 
                        else if (Glib::str_has_prefix(process_line, "S "))
267
 
                        {
268
 
                                process_satellite_line(frontend, process_line);
269
 
                        }
270
 
                        else if (Glib::str_has_prefix(process_line, "A "))
271
 
                        {
272
 
                                process_atsc_line(frontend, process_line);
 
227
                        // Remove comments
 
228
                        Glib::ustring::size_type index = line.find("#");
 
229
                        if (index != Glib::ustring::npos)
 
230
                        {
 
231
                                line = line.substr(0, index);
 
232
                        }
 
233
        
 
234
                        // Remove trailing whitespace
 
235
                        index = line.find_last_not_of(" \t\r\n");
 
236
                        if (index == Glib::ustring::npos)
 
237
                        {
 
238
                                line.clear();
273
239
                        }
274
240
                        else
275
241
                        {
276
 
                                throw Exception(_("Me TV cannot process a line in the initial tuning file"));
277
 
                        }
278
 
                }
279
 
        }
280
 
 
281
 
        gboolean is_atsc = frontend.get_frontend_type() == FE_ATSC;
282
 
        guint transponder_count = 0;
283
 
        signal_progress(0, transponders.size());
284
 
        for (TransponderList::const_iterator i = transponders.begin(); i != transponders.end() && !terminated; i++)
285
 
        {
286
 
                if (is_atsc) atsc_tune_to(frontend, *i);
287
 
                else tune_to(frontend, *i);
288
 
                signal_progress(++transponder_count, transponders.size());
 
242
                                line = line.substr(0, index + 1);
 
243
                        }
 
244
 
 
245
                        if (!line.empty()) // Ignore empty lines or comments
 
246
                        {
 
247
                                lines.push_back(line);
 
248
                        }
 
249
        
 
250
                        status = initial_tuning_file->read_line(line);
 
251
                }
 
252
 
 
253
                guint size = lines.size();
 
254
 
 
255
                for (StringList::iterator iterator = lines.begin(); iterator != lines.end() && !terminated; iterator++)
 
256
                {
 
257
                        Glib::ustring process_line = *iterator;
 
258
 
 
259
                        if (!process_line.empty())
 
260
                        {
 
261
                                g_debug("Processing line: '%s'", process_line.c_str());
 
262
 
 
263
                                if (Glib::str_has_prefix(process_line, "T "))
 
264
                                {
 
265
                                        process_terrestrial_line(frontend, process_line);
 
266
                                }
 
267
                                else if (Glib::str_has_prefix(process_line, "C "))
 
268
                                {
 
269
                                        process_cable_line(frontend, process_line);
 
270
                                }
 
271
                                else if (Glib::str_has_prefix(process_line, "S "))
 
272
                                {
 
273
                                        process_satellite_line(frontend, process_line);
 
274
                                }
 
275
                                else if (Glib::str_has_prefix(process_line, "A "))
 
276
                                {
 
277
                                        process_atsc_line(frontend, process_line);
 
278
                                }
 
279
                                else
 
280
                                {
 
281
                                        throw Exception(_("Me TV cannot process a line in the initial tuning file"));
 
282
                                }
 
283
                        }
 
284
                }
 
285
 
 
286
                gboolean is_atsc = frontend.get_frontend_type() == FE_ATSC;
 
287
                guint transponder_count = 0;
 
288
                signal_progress(0, transponders.size());
 
289
                for (TransponderList::const_iterator i = transponders.begin(); i != transponders.end() && !terminated; i++)
 
290
                {
 
291
                        if (is_atsc) atsc_tune_to(frontend, *i);
 
292
                        else tune_to(frontend, *i);
 
293
                        signal_progress(++transponder_count, transponders.size());
 
294
                }
289
295
        }
290
296
        
291
297
        g_debug("Scanner loop exited");
295
301
        g_debug("Scanner finished");
296
302
}
297
303
 
 
304
void Scanner::auto_scan(Frontend& frontend)
 
305
{
 
306
        throw Exception("Not implemented");
 
307
}
 
308
 
298
309
void Scanner::terminate()
299
310
{
300
311
        g_debug("Scanner marked for termination");