~pete-woods/ubuntu-app-launch/port-some-c-to-cpp

« back to all changes in this revision

Viewing changes to libubuntu-app-launch/registry-impl.cpp

  • Committer: Bileto Bot
  • Author(s): Ted Gould
  • Date: 2017-04-04 21:47:13 UTC
  • mfrom: (307.2.33 system-app-watch)
  • Revision ID: ci-train-bot@canonical.com-20170404214713-eyjiw88wlq49ueoe
Watch system folders for apps added and removed (LP: #1630997, #1672392)

Approved by: Marcus Tomlinson, Pete Woods

Show diffs side-by-side

added added

removed removed

Lines of Context:
171
171
    return watchingAppStarting_;
172
172
}
173
173
 
 
174
/** Sets up the signals down to the info watchers and we aggregate
 
175
    them up to users of UAL. We connect to all their signals and
 
176
    pass them up. */
 
177
void Registry::Impl::infoWatchersSetup()
 
178
{
 
179
    std::call_once(flag_infoWatchersSetup, [this] {
 
180
        g_debug("Info watchers signals setup");
 
181
 
 
182
        /* Grab all the app stores and the ZG info watcher */
 
183
        std::list<std::shared_ptr<info_watcher::Base>> watchers{_appStores.begin(), _appStores.end()};
 
184
        watchers.push_back(getZgWatcher());
 
185
 
 
186
        /* Connect each of their signals to us, and track that connection */
 
187
        for (const auto& watcher : watchers)
 
188
        {
 
189
            infoWatchers_.emplace_back(std::make_pair(
 
190
                watcher,
 
191
                infoWatcherConnections{
 
192
                    watcher->infoChanged().connect(
 
193
                        [this](const std::shared_ptr<Application>& app) { sig_appInfoUpdated(app); }),
 
194
                    watcher->appAdded().connect([this](const std::shared_ptr<Application>& app) { sig_appAdded(app); }),
 
195
                    watcher->appRemoved().connect([this](const AppID& appid) { sig_appRemoved(appid); }),
 
196
                }));
 
197
        }
 
198
    });
 
199
}
 
200
 
174
201
core::Signal<const std::shared_ptr<Application>&>& Registry::Impl::appInfoUpdated()
175
202
{
176
 
    std::call_once(flag_appInfoUpdated, [this] {
177
 
        g_debug("App Info Updated Signal Initialized");
178
 
 
179
 
        std::list<std::shared_ptr<info_watcher::Base>> apps{_appStores.begin(), _appStores.end()};
180
 
        apps.push_back(getZgWatcher());
181
 
 
182
 
        for (const auto& app : apps)
183
 
        {
184
 
            infoWatchers_.emplace_back(
185
 
                std::make_pair(app, app->infoChanged().connect([this](const std::shared_ptr<Application>& app) {
186
 
                    sig_appInfoUpdated(app);
187
 
                })));
188
 
        }
189
 
    });
 
203
    infoWatchersSetup();
190
204
    return sig_appInfoUpdated;
191
205
}
192
206
 
 
207
core::Signal<const std::shared_ptr<Application>&>& Registry::Impl::appAdded()
 
208
{
 
209
    infoWatchersSetup();
 
210
    return sig_appAdded;
 
211
}
 
212
 
 
213
core::Signal<const AppID&>& Registry::Impl::appRemoved()
 
214
{
 
215
    infoWatchersSetup();
 
216
    return sig_appRemoved;
 
217
}
 
218
 
193
219
std::shared_ptr<Application> Registry::Impl::createApp(const AppID& appid)
194
220
{
195
221
    for (const auto& appStore : appStores())