1/*
2 * Copyright (C) 2010 Michal Hruby <michal.mhr@gmail.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA.
17 *
18 * Authored by Michal Hruby <michal.mhr@gmail.com>
19 *
20 */
21
22namespace Synapse
23{
24  public class TestSlowPlugin : Object, Activatable, ItemProvider
25  {
26    public bool enabled { get; set; default = true; }
27
28    public void activate ()
29    {
30
31    }
32
33    public void deactivate ()
34    {
35
36    }
37
38    private class TestResult : UnknownMatch
39    {
40      public TestResult (string query)
41      {
42        Object (title: "Test result for " + query.strip (),
43                description: "by TestSlowPlugin",
44                icon_name: "unknown", has_thumbnail: false);
45      }
46    }
47
48    public async ResultSet? search (Query q) throws SearchError
49    {
50      Idle.add (search.callback);
51      yield;
52
53      q.check_cancellable ();
54
55      Timeout.add (2000, search.callback);
56      yield;
57
58      q.check_cancellable ();
59
60      debug ("finished search for \"%s\"", q.query_string);
61
62      var rs = new ResultSet ();
63      rs.add (new TestResult (q.query_string), 0);
64
65      return rs;
66    }
67  }
68}
69