~ubuntu-branches/ubuntu/quantal/amarok/quantal

« back to all changes in this revision

Viewing changes to src/core-impl/meta/proxy/MetaProxyWorker.cpp

  • Committer: Package Import Robot
  • Author(s): Harald Sitter
  • Date: 2012-06-05 15:43:51 UTC
  • mfrom: (2.1.13 experimental)
  • Revision ID: package-import@ubuntu.com-20120605154351-nbkdf9q1chu7uvh1
Tags: 2:2.6~beta1-1ubuntu1
* Merge from Debian experimental, remaining changes: (LP: 1008645)
  - Don't build-depend on libavformat-dev and libofa0-dev as libavcodec*
    is not allowed on cd images.
  - Don't build-dep on libqt4-opengl-dev on armel and armhf and install
    file manually in debian/rules
  - build-dep on libmygpo
  - Add epoch "2:" to the version number.
  - More complete not-installed
  - Keep build-dep libmysqld-pic at 5.1.36-2 (new version not yet  in archive)
  - Do not manually compress with xz, we handle this in pkg-kde and explicitly
    doing it prevents global control
* Do not suggest libxine1-ffmpeg as this should have been in the Phonon
  backend to begin with and phonon-xine is no longer used anyway.
* amarok-common breaks amarok (<< 2.6~beta1-1ubuntu1~) due to wrongly
  packaged desktop files in a previous release
* Drop patches applied upstream:
  - kubuntu_Make-OpenGl-a-soft-dependency.diff
  - kubuntu_CMake-Move-occurence-of-OPENGL_INCLUDE_DIR-var.diff
  - kubuntu_kdelibs4.8_context_view.diff
* Refreshed patch kubuntu_mysql_pic_library_path.diff
* amarok-doc to Break and Replace all previous amarok-help-* packages
  having one big package and keep the diff small was deemed more reasonable
  on IRC

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************************
 
2
 * Copyright (c) 2012 Bart Cerneels <bart.cerneels@kde.org>                             *
 
3
 *                                                                                      *
 
4
 * This program is free software; you can redistribute it and/or modify it under        *
 
5
 * the terms of the GNU General Public License as published by the Free Software        *
 
6
 * Foundation; either version 2 of the License, or (at your option) any later           *
 
7
 * version.                                                                             *
 
8
 *                                                                                      *
 
9
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
 
10
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
 
11
 * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
 
12
 *                                                                                      *
 
13
 * You should have received a copy of the GNU General Public License along with         *
 
14
 * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
 
15
 ****************************************************************************************/
 
16
 
 
17
#include "MetaProxyWorker.h"
 
18
 
 
19
#include "core-impl/collections/support/CollectionManager.h"
 
20
 
 
21
namespace MetaProxy {
 
22
 
 
23
Worker::Worker( const KUrl &url )
 
24
    : Amarok::TrackForUrlWorker( url )
 
25
{
 
26
 
 
27
}
 
28
 
 
29
void
 
30
Worker::run()
 
31
{
 
32
    Meta::TrackPtr track = CollectionManager::instance()->trackForUrl( m_url );
 
33
 
 
34
    //no TrackProvider has a track for us yet, query new ones that are added.
 
35
    if( track.isNull() )
 
36
    {
 
37
        //TODO: should only have to connecto to TrackProvider signals.
 
38
        //Each Collection contains a TrackProvider
 
39
        connect( CollectionManager::instance(),
 
40
                 SIGNAL(trackProviderAdded( Collections::TrackProvider * )),
 
41
                 SLOT(slotNewTrackProvider( Collections::TrackProvider * )) );
 
42
        connect( CollectionManager::instance(),
 
43
                 SIGNAL(collectionAdded( Collections::Collection * )),
 
44
                 SLOT(slotNewCollection( Collections::Collection * )) );
 
45
 
 
46
        return;
 
47
    }
 
48
 
 
49
    emit( finishedLookup( track ) );
 
50
}
 
51
 
 
52
void
 
53
Worker::slotNewTrackProvider( Collections::TrackProvider *newTrackProvider )
 
54
{
 
55
    if( !newTrackProvider )
 
56
    {
 
57
        return;
 
58
    }
 
59
 
 
60
    if( newTrackProvider->possiblyContainsTrack( m_url ) )
 
61
    {
 
62
        Meta::TrackPtr track = newTrackProvider->trackForUrl( m_url );
 
63
        emit( finishedLookup( track ) );
 
64
    }
 
65
}
 
66
 
 
67
void
 
68
Worker::slotNewCollection( Collections::Collection *newCollection )
 
69
{
 
70
    if( !newCollection )
 
71
    {
 
72
        return;
 
73
    }
 
74
 
 
75
    if( newCollection->possiblyContainsTrack( m_url ) )
 
76
    {
 
77
        Meta::TrackPtr track = newCollection->trackForUrl( m_url );
 
78
        emit( finishedLookup( track ) );
 
79
    }
 
80
}
 
81
 
 
82
} // namespace MetaProxy