~zhangew401/scope-aggregator/fix-empty-query-to-clickstore

« back to all changes in this revision

Viewing changes to src/action.cpp

  • Committer: Kyle Nitzsche
  • Date: 2016-06-28 13:15:57 UTC
  • mfrom: (163.1.10 no-hints)
  • Revision ID: kyle.nitzsche@canonical.com-20160628131557-d80j07s5jk18hi0j
scope-agg projects no longer require a separate hints child scope to 
provide quick start help or to provide the no netork of the no location
message. All scopes rebasing on 4.8 must change their hints.json file
since the structure is now chagned. 

See 4.8-rebase-local-hints-README.md for complete details.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2016 Canonical Ltd
 
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 version 3 as
 
6
 * published by the Free Software Foundation.
 
7
 *
 
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.
 
12
 *
 
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/>.
 
15
 * * Authored by:
 
16
 *      Kyle Nitzsche <kyle.nitzsche@canonical.com>
 
17
 */
 
18
 
 
19
#include "action.h"
 
20
#include "i18n.h"
 
21
#include <unity/scopes/ActivationResponse.h>
 
22
#include <unity/scopes/CannedQuery.h>
 
23
#include <QString>
 
24
#include <QFile>
 
25
#include <QTextStream>
 
26
#include <QDateTime>
 
27
#include <QDebug>
 
28
 
 
29
namespace usc = unity::scopes;
 
30
 
 
31
Action::
 
32
Action(usc::Result const& result,
 
33
       usc::ActionMetadata const& metadata,
 
34
       std::string const& cache_dir,
 
35
       std::string const& scope_id)
 
36
    : usc::ActivationQueryBase(result, metadata),
 
37
      cache_dir_(cache_dir),
 
38
      scope_id_(scope_id)
 
39
{
 
40
}
 
41
 
 
42
usc::ActivationResponse
 
43
Action::activate()
 
44
{
 
45
  if (result()["action"].get_string() == "hide_hints")
 
46
  {
 
47
    QFile file(QString("%1/%2").arg(QString::fromStdString(cache_dir_),"hints_is_hidden"));
 
48
    file.open(QIODevice::Append | QIODevice::Text);     
 
49
    QTextStream out(&file);
 
50
    out << QDateTime::currentDateTime().toString();
 
51
    endl(out);
 
52
    file.close();
 
53
    usc::CannedQuery cq(scope_id_);
 
54
    return usc::ActivationResponse(cq);
 
55
  }
 
56
  return usc::ActivationResponse(usc::ActivationResponse::Status::NotHandled);
 
57
}