2
* Copyright (C) 2014 Canonical Ltd
4
* This program is free software: you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 3 as
6
* published by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
* Authored by Jussi Pakkanen <jussi.pakkanen@canonical.com>
21
#include "videoaggregatorscope.h"
22
#include "videoaggregatorquery.h"
23
#include <unity/scopes/Registry.h>
24
#include <unity/scopes/Category.h>
25
#include <unity/scopes/CategoryRenderer.h>
27
#include "../utils/i18n.h"
29
using namespace unity::scopes;
31
const std::vector<const char*> SUBSCOPE_NAMES{
33
"com.ubuntu.scopes.myvideos_myvideos",
37
"com.ubuntu.scopes.youtube_youtube",
40
void VideoAggregatorScope::start(std::string const&) {
45
void VideoAggregatorScope::find_subscopes(bool warn_missing) {
47
for (const auto &scope_name : SUBSCOPE_NAMES) {
49
subscopes.emplace_back(registry()->get_metadata(scope_name));
50
} catch (const std::exception &e) {
52
std::cerr << "Could not find scope '" << scope_name << "': " << e.what() << std::endl;
58
void VideoAggregatorScope::stop() {
61
SearchQueryBase::UPtr VideoAggregatorScope::search(CannedQuery const& q,
62
SearchMetadata const& hints) {
63
// FIXME: workaround for problem with no remote scopes on first run
64
// until network becomes available
65
if (subscopes.size() != SUBSCOPE_NAMES.size()) {
66
find_subscopes(false);
68
SearchQueryBase::UPtr query(new VideoAggregatorQuery(q, hints, subscopes));
72
PreviewQueryBase::UPtr VideoAggregatorScope::preview(Result const& /*result*/, ActionMetadata const& /*hints*/) {
76
#define EXPORT __attribute__ ((visibility ("default")))
82
unity::scopes::ScopeBase*
83
// cppcheck-suppress unusedFunction
84
UNITY_SCOPE_CREATE_FUNCTION()
86
return new VideoAggregatorScope();
91
// cppcheck-suppress unusedFunction
92
UNITY_SCOPE_DESTROY_FUNCTION(unity::scopes::ScopeBase* scope_base)