~ubuntu-branches/ubuntu/trusty/unity-scopes-api/trusty-proposed

« back to all changes in this revision

Viewing changes to src/scopes/internal/smartscopes/SSRegistryObject.cpp

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release, Pawel Stolowski
  • Date: 2014-02-11 17:55:05 UTC
  • mfrom: (1.1.8)
  • Revision ID: package-import@ubuntu.com-20140211175505-av3z0612p7o8w54b
Tags: 0.3.1+14.04.20140211.2-0ubuntu1
[ Pawel Stolowski ]
* [ Pawel Stolowski ]
* Added preliminary API for filters and departments.
* Changes to preview action activation API: support for widget id.
* Changes to Annotation API.
* Return ScopeProxy from Result::target_scope_proxy (replaces activation_scope_name).

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
#include <unity/scopes/ScopeExceptions.h>
27
27
#include <unity/UnityExceptions.h>
28
28
 
 
29
#include <iostream>
 
30
 
29
31
namespace unity
30
32
{
31
33
 
42
44
                                   std::string const& ss_scope_endpoint,
43
45
                                   uint max_http_sessions,
44
46
                                   uint no_reply_timeout,
45
 
                                   uint refresh_rate_in_min)
 
47
                                   uint refresh_rate_in_min,
 
48
                                   std::string const& sss_url,
 
49
                                   uint sss_port)
46
50
    : ssclient_(std::make_shared<SmartScopesClient>(
47
51
                    std::make_shared<HttpClientQt>(max_http_sessions, no_reply_timeout),
48
 
                    std::make_shared<JsonCppNode>()))
 
52
                    std::make_shared<JsonCppNode>(), sss_url, sss_port))
49
53
    , refresh_stopped_(false)
50
54
    , middleware_(middleware)
51
55
    , ss_scope_endpoint_(ss_scope_endpoint)
155
159
        // request remote scopes from smart scopes client
156
160
        remote_scopes = ssclient_->get_remote_scopes();
157
161
    }
158
 
    catch (unity::Exception const&)
 
162
    catch (unity::Exception const& e)
159
163
    {
 
164
        std::cerr << e.what() << std::endl;
160
165
        // refresh again soon as get_remote_scopes failed
161
166
        next_refresh_timeout_ = 1;  ///! TODO config?
162
167
        return;
171
176
    // loop through all available scopes and add() each visible scope
172
177
    for (RemoteScope const& scope : remote_scopes)
173
178
    {
174
 
        if (scope.invisible)
175
 
        {
176
 
            continue;
177
 
        }
178
 
 
179
179
        // construct a ScopeMetadata with remote scope info
180
180
        std::unique_ptr<ScopeMetadataImpl> metadata(new ScopeMetadataImpl(nullptr));
181
181
 
182
 
        metadata->set_scope_name(scope.name);
 
182
        metadata->set_scope_name(scope.id);
183
183
        metadata->set_display_name(scope.name);
184
184
        metadata->set_description(scope.description);
 
185
        metadata->set_icon(scope.icon);
 
186
        metadata->set_invisible(scope.invisible);
185
187
 
186
 
        ScopeProxy proxy = ScopeImpl::create(middleware_->create_scope_proxy(scope.name, ss_scope_endpoint_),
 
188
        ScopeProxy proxy = ScopeImpl::create(middleware_->create_scope_proxy(scope.id, ss_scope_endpoint_),
187
189
                                             middleware_->runtime(),
188
 
                                             scope.name);
 
190
                                             scope.id);
189
191
 
190
192
        metadata->set_proxy(proxy);
191
193
 
192
194
        auto meta = ScopeMetadataImpl::create(move(metadata));
193
195
 
194
196
        // add scope info to collection
195
 
        add(scope.name, std::move(meta), scope);
 
197
        add(scope.id, std::move(meta), scope);
196
198
    }
197
199
 
198
200
    next_refresh_timeout_ = regular_refresh_timeout_;