~ubuntu-branches/ubuntu/precise/me-tv/precise-proposed

« back to all changes in this revision

Viewing changes to src/profile_manager.cc

  • Committer: Bazaar Package Importer
  • Author(s): Scott Evans
  • Date: 2009-06-27 00:46:22 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20090627004622-q0zvsie6ioa60vh3
Tags: 0.9.4-0ubuntu1
* New upstream release (LP: #379706)
  - Fix to stop EPG update crashing the application
    after faulty save (LP: #72872)
  - Fixed spin buttons from GtkBuilder conversion (LP: #382197) 
  - Fixed icon on application popup menu (LP: #379685)
  - Fixed compiling of me-tv-0.8.12 fails on Fedora 11 (LP: #377020)
  - Fixed Failed to lock to channel at boot (LP: #377050)
  - Increased timeout to 5 seconds again (LP: #371165)
  - Fixed me-tv unusually slow, often freezes (LP: #351510)
  - Fixed channel persistence (LP: #361514)
  - Fix for forward slashes in description (LP: #359710)
  - Fixed Must create .me-tv directory manually (LP: #353796)
  - Fixed audio stream can't be changed (LP: #350402)
* debian/control:
  - Removed dependency libxine1-ffmpeg, libxine1-x
  - Removed libglademm-2.4-dev Build-Depends.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (C) 2009 Michael Lamothe
3
 
 *
4
 
 * This file is part of Me TV
5
 
 *
6
 
 * This program is free software; you can redistribute it and/or modify
7
 
 * it under the terms of the GNU General Public License as published by
8
 
 * the Free Software Foundation; either version 2 of the License, or
9
 
 * (at your option) any later version.
10
 
 * 
11
 
 * This program is distributed in the hope that it will be useful,
12
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
 * GNU Library General Public License for more details.
15
 
 * 
16
 
 * You should have received a copy of the GNU General Public License
17
 
 * along with this program; if not, write to the Free Software
18
 
 * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
19
 
 */
20
 
 
21
 
#include "profile_manager.h"
22
 
#include "application.h"
23
 
 
24
 
ProfileManager::ProfileManager()
25
 
{
26
 
        current_profile = NULL;
27
 
}
28
 
 
29
 
ProfileManager::~ProfileManager()
30
 
{
31
 
}
32
 
 
33
 
void ProfileManager::load()
34
 
{
35
 
        Data data;
36
 
        
37
 
        profiles = data.get_all_profiles();
38
 
 
39
 
        if (profiles.size() == 0)
40
 
        {
41
 
                current_profile = new Profile();
42
 
                current_profile->name = _("Default");
43
 
                profiles.push_back(*current_profile);
44
 
 
45
 
                save();
46
 
                profiles = data.get_all_profiles();
47
 
        }
48
 
        
49
 
        current_profile = find_profile(get_application().get_string_configuration_value("profile"));
50
 
        if (current_profile == NULL)
51
 
        {
52
 
                current_profile = &(*profiles.begin());
53
 
        }
54
 
}
55
 
 
56
 
Profile* ProfileManager::find_profile(const Glib::ustring& profile_name)
57
 
{
58
 
        Profile* result = NULL;
59
 
        ProfileList::iterator iterator = profiles.begin();      
60
 
        while (iterator != profiles.end() && result == NULL)
61
 
        {
62
 
                Profile& profile = *iterator;
63
 
                if (profile_name == profile.name)
64
 
                {
65
 
                        result = &profile;
66
 
                }
67
 
                iterator++;
68
 
        }       
69
 
        return result;
70
 
}
71
 
 
72
 
Profile& ProfileManager::get_profile(const Glib::ustring& profile_name)
73
 
{
74
 
        Profile* profile = find_profile(profile_name);
75
 
        if (profile == NULL)
76
 
        {
77
 
                throw Exception(Glib::ustring::compose(_("Failed to find profile '%1'"), profile_name));
78
 
        }
79
 
        return *profile;
80
 
}
81
 
 
82
 
void ProfileManager::save()
83
 
{
84
 
        Data data;
85
 
        g_message(_("Saving profile data"));
86
 
        for (ProfileList::iterator profile_iterator = profiles.begin(); profile_iterator != profiles.end(); profile_iterator++)
87
 
        {
88
 
                data.replace_profile(*profile_iterator);
89
 
        }
90
 
        g_message(_("Profile data saved"));
91
 
}
92
 
 
93
 
Profile& ProfileManager::get_current_profile()
94
 
{
95
 
        if (current_profile == NULL)
96
 
        {
97
 
                throw Exception(_("There is no current profile"));
98
 
        }
99
 
        return *current_profile;
100
 
}