~ubuntu-branches/ubuntu/karmic/amarok/karmic

« back to all changes in this revision

Viewing changes to src/context/engines/info/InfoEngine.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2009-09-03 23:49:07 UTC
  • mfrom: (1.77.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20090903234907-rk4lt6hnxwckvuon
Tags: 2:2.1.80-0ubuntu1
New upstream beta release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************************
 
2
 * Copyright (c) 2007 Nikolaj Hald Nielsen <nhnFreespirit@gmail.com>                    *
 
3
 * Copyright (c) 2007 Leo Franchi <lfranchi@gmail.com>                                  *
 
4
 *                                                                                      *
 
5
 * This program is free software; you can redistribute it and/or modify it under        *
 
6
 * the terms of the GNU General Public License as published by the Free Software        *
 
7
 * Foundation; either version 2 of the License, or (at your option) any later           *
 
8
 * version.                                                                             *
 
9
 *                                                                                      *
 
10
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
 
11
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
 
12
 * PARTICULAR PURPOSE. See the GNU General Public License for more details.              *
 
13
 *                                                                                      *
 
14
 * You should have received a copy of the GNU General Public License along with         *
 
15
 * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
 
16
 ****************************************************************************************/
 
17
 
 
18
#include "InfoEngine.h"
 
19
 
 
20
#include "Amarok.h"
 
21
#include "Debug.h"
 
22
#include "ContextObserver.h"
 
23
#include "ContextView.h"
 
24
#include "browsers/InfoProxy.h"
 
25
 
 
26
#include <QVariant>
 
27
 
 
28
using namespace Context;
 
29
 
 
30
InfoEngine::InfoEngine( QObject* parent, const QList<QVariant>& args )
 
31
    : DataEngine( parent )
 
32
    , m_requested( true )
 
33
{
 
34
    Q_UNUSED( args )
 
35
    DEBUG_BLOCK
 
36
    m_sources = QStringList();
 
37
    m_sources << "service";
 
38
 
 
39
    The::infoProxy()->subscribe( this );
 
40
}
 
41
 
 
42
InfoEngine::~ InfoEngine()
 
43
{
 
44
    The::infoProxy()->unsubscribe( this );
 
45
}
 
46
 
 
47
QStringList InfoEngine::sources() const
 
48
{
 
49
    return m_sources; // we don't have sources, if connected, it is enabled.
 
50
}
 
51
 
 
52
bool InfoEngine::sourceRequestEvent( const QString& name )
 
53
{
 
54
    Q_UNUSED( name );
 
55
/*    m_sources << name;    // we are already enabled if we are alive*/
 
56
    setData( name, QVariant());
 
57
    update();
 
58
    m_requested = true;
 
59
    return true;
 
60
}
 
61
 
 
62
void InfoEngine::message( const ContextState& state )
 
63
{
 
64
    DEBUG_BLOCK;
 
65
    if( state == Current && m_requested ) {
 
66
        m_storedInfo = The::infoProxy()->info();
 
67
        update();
 
68
    }
 
69
}
 
70
 
 
71
 
 
72
void InfoEngine::infoChanged( QVariantMap infoMap )
 
73
{
 
74
    m_storedInfo = infoMap;
 
75
    update();
 
76
}
 
77
 
 
78
void InfoEngine::update()
 
79
{
 
80
    setData( "info", "subject_name", m_storedInfo["service_name"] );
 
81
    setData( "info", "main_info", m_storedInfo["main_info"] );
 
82
 
 
83
}
 
84
 
 
85
 
 
86
 
 
87
#include "InfoEngine.moc"
 
88
 
 
89