2
* Copyright (C) 2013 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: Michi Henning <michi.henning@canonical.com>
19
#include <scopes/ScopeBase.h>
20
#include <scopes/Reply.h>
21
#include <scopes/Category.h>
22
#include <scopes/ResultItem.h>
26
#define EXPORT __attribute__ ((visibility ("default")))
29
using namespace unity::api::scopes;
31
// Example scope A: replies synchronously to a query. (Replies are returned before returning from the run() method.)
33
class MyQuery : public QueryBase
36
MyQuery(string const& query) :
45
virtual void cancelled() override
49
virtual void run(ReplyProxy const& reply) override
51
auto cat = std::shared_ptr<Category>(new Category("cat1"));
54
res.set_title("scope-A: result 1 for query \"" + query_ + "\"");
56
res.set_dnd_uri("dnd_uri");
58
cout << "scope-A: query \"" << query_ << "\" complete" << endl;
65
class MyScope : public ScopeBase
68
virtual int start(string const&, RegistryProxy const&) override
73
virtual void stop() override {}
74
virtual void run() override {}
76
virtual QueryBase::UPtr create_query(string const& q, VariantMap const&) override
78
QueryBase::UPtr query(new MyQuery(q));
79
cout << "scope-A: created query: \"" << q << "\"" << endl;
88
unity::api::scopes::ScopeBase*
89
// cppcheck-suppress unusedFunction
90
UNITY_API_SCOPE_CREATE_FUNCTION()
97
// cppcheck-suppress unusedFunction
98
UNITY_API_SCOPE_DESTROY_FUNCTION(unity::api::scopes::ScopeBase* scope_base)