~ubuntuone-control-tower/unity-scope-click/trunk

« back to all changes in this revision

Viewing changes to scope/clickapps/apps-scope.cpp

  • Committer: Bileto Bot
  • Author(s): Rodney Dawes
  • Date: 2017-01-12 14:22:46 UTC
  • mfrom: (505.1.4 no-more-click)
  • Revision ID: ci-train-bot@canonical.com-20170112142246-vgb4veoqaclnbwwn
Remove deps on ubuntu-download-manager and libclick.
Remove download-manager, installing, uninstalling, and reviews code.

Approved by: Charles Kerr, unity-api-1-bot

Show diffs side-by-side

added added

removed removed

Lines of Context:
81
81
    static const int zero = 0;
82
82
    auto emptyCb = [this]()
83
83
    {
84
 
        dm.reset(Ubuntu::DownloadManager::Manager::createSessionManager());
85
84
        qt_ready_for_search_p.set_value();
86
85
 
87
86
        sso.reset(new click::CredentialsService());
107
106
        const unity::scopes::ActionMetadata& metadata) {
108
107
    qDebug() << "Scope::preview() called.";
109
108
    auto preview = new click::Preview(result, metadata, qt_ready_for_preview_f.share());
110
 
    preview->choose_strategy(client, dm, depts_db);
 
109
    preview->choose_strategy(client, depts_db);
111
110
    return unity::scopes::PreviewQueryBase::UPtr{preview};
112
111
}
113
112
 
114
113
 
115
114
unity::scopes::ActivationQueryBase::UPtr click::Scope::perform_action(unity::scopes::Result const& result, unity::scopes::ActionMetadata const& metadata,
116
 
        std::string const& widget_id, std::string const& action_id)
 
115
        std::string const&, std::string const& action_id)
117
116
{
118
 
    if (action_id == click::Preview::Actions::CONFIRM_UNINSTALL) {
119
 
        return scopes::ActivationQueryBase::UPtr(new PerformUninstallAction(result, metadata));
120
 
    }
121
 
 
122
117
    auto activation = new ScopeActivation(result, metadata);
123
118
    qDebug() << "perform_action called with action_id" << QString().fromStdString(action_id);
124
119
 
125
 
    if (action_id == click::Preview::Actions::UNINSTALL_CLICK) {
126
 
        activation->setHint(click::Preview::Actions::UNINSTALL_CLICK, unity::scopes::Variant(true));
127
 
        activation->setStatus(unity::scopes::ActivationResponse::Status::ShowPreview);
128
 
    } else if (action_id == click::Preview::Actions::CANCEL_PURCHASE_INSTALLED) {
129
 
        activation->setHint(click::Preview::Actions::CANCEL_PURCHASE_INSTALLED, unity::scopes::Variant(true));
130
 
        activation->setStatus(unity::scopes::ActivationResponse::Status::ShowPreview);
131
 
    } else if (action_id == click::Preview::Actions::CANCEL_PURCHASE_UNINSTALLED) {
132
 
        activation->setHint(click::Preview::Actions::CANCEL_PURCHASE_UNINSTALLED, unity::scopes::Variant(true));
133
 
        activation->setStatus(unity::scopes::ActivationResponse::Status::ShowPreview);
134
 
    } else if (action_id == click::Preview::Actions::SHOW_INSTALLED) {
 
120
    if (action_id == click::Preview::Actions::SHOW_INSTALLED) {
135
121
        activation->setHint(click::Preview::Actions::SHOW_INSTALLED, unity::scopes::Variant(true));
136
 
        activation->setStatus(unity::scopes::ActivationResponse::Status::ShowPreview);
137
 
    } else if (action_id == click::Preview::Actions::SHOW_UNINSTALLED) {
138
 
        activation->setHint(click::Preview::Actions::SHOW_UNINSTALLED, unity::scopes::Variant(true));
139
 
        activation->setStatus(unity::scopes::ActivationResponse::Status::ShowPreview);
140
 
    } else if (action_id == click::Preview::Actions::CONFIRM_CANCEL_PURCHASE_UNINSTALLED) {
141
 
        activation->setHint(click::Preview::Actions::CONFIRM_CANCEL_PURCHASE_UNINSTALLED, unity::scopes::Variant(true));
142
 
        activation->setStatus(unity::scopes::ActivationResponse::Status::ShowPreview);
143
 
    } else if (action_id == click::Preview::Actions::CONFIRM_CANCEL_PURCHASE_INSTALLED) {
144
 
        activation->setHint(click::Preview::Actions::CONFIRM_CANCEL_PURCHASE_INSTALLED, unity::scopes::Variant(true));
145
 
        activation->setStatus(unity::scopes::ActivationResponse::Status::ShowPreview);
146
 
    } else if (action_id == click::Preview::Actions::RATED) {
147
 
        scopes::VariantMap rating_info = metadata.scope_data().get_dict();
148
 
        // Cast to int because widget gives us double, which is wrong.
149
 
        int rating = ((int)rating_info["rating"].get_double());
150
 
        std::string review_text = rating_info["review"].get_string();
151
 
 
152
 
        // We have to get the values and then set them as hints here, to be
153
 
        // able to pass them on to the Preview, which actually makes the
154
 
        // call to submit.
155
 
        activation->setHint("rating", scopes::Variant(rating));
156
 
        activation->setHint("review", scopes::Variant(review_text));
157
 
        activation->setHint(click::Preview::Actions::RATED,
158
 
                            scopes::Variant(true));
159
 
        activation->setHint("widget_id", scopes::Variant(widget_id));
160
 
        activation->setStatus(scopes::ActivationResponse::Status::ShowPreview);
161
122
    }
162
123
    return scopes::ActivationQueryBase::UPtr(activation);
163
124
}