~ci-train-bot/ubuntu-app-launch/ubuntu-app-launch-ubuntu-yakkety-1956

« back to all changes in this revision

Viewing changes to libubuntu-app-launch/application-impl-libertine.cpp

  • Committer: Bileto Bot
  • Author(s): Ted Gould
  • Date: 2016-09-13 17:42:22 UTC
  • mfrom: (230.12.141 snappy-backend-no-snap)
  • Revision ID: ci-train-bot@canonical.com-20160913174222-ucnuzxd6i16g427j
Make find and discover use the application implementation functions.

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

Show diffs side-by-side

added added

removed removed

Lines of Context:
106
106
    return keyfile;
107
107
}
108
108
 
 
109
/** Checks the AppID by making sure the version is "0.0" and then
 
110
    calling verifyAppname() to check the rest.
 
111
 
 
112
    \param appid AppID to check
 
113
    \param registry persistent connections to use
 
114
*/
 
115
bool Libertine::hasAppId(const AppID& appid, const std::shared_ptr<Registry>& registry)
 
116
{
 
117
    try
 
118
    {
 
119
        if (appid.version.value() != "0.0")
 
120
        {
 
121
            return false;
 
122
        }
 
123
 
 
124
        return verifyAppname(appid.package, appid.appname, registry);
 
125
    }
 
126
    catch (std::runtime_error& e)
 
127
    {
 
128
        return false;
 
129
    }
 
130
}
 
131
 
 
132
/** Verify a package name by getting the list of containers from
 
133
    liblibertine and ensuring it is in that list.
 
134
 
 
135
    \param package Container name
 
136
    \param registry persistent connections to use
 
137
*/
 
138
bool Libertine::verifyPackage(const AppID::Package& package, const std::shared_ptr<Registry>& registry)
 
139
{
 
140
    auto containers = std::shared_ptr<gchar*>(libertine_list_containers(), g_strfreev);
 
141
 
 
142
    for (int i = 0; containers.get()[i] != nullptr; i++)
 
143
    {
 
144
        auto container = containers.get()[i];
 
145
        if (container == package.value())
 
146
        {
 
147
            return true;
 
148
        }
 
149
    }
 
150
 
 
151
    return false;
 
152
}
 
153
 
 
154
/** Gets the list of applications from the container using liblibertine
 
155
    and see if @appname is in that list.
 
156
 
 
157
    \param package Container name
 
158
    \param appname Application name to look for
 
159
    \param registry persistent connections to use
 
160
*/
 
161
bool Libertine::verifyAppname(const AppID::Package& package,
 
162
                              const AppID::AppName& appname,
 
163
                              const std::shared_ptr<Registry>& registry)
 
164
{
 
165
    auto apps = std::shared_ptr<gchar*>(libertine_list_apps_for_container(package.value().c_str()), g_strfreev);
 
166
 
 
167
    for (int i = 0; apps.get()[i] != nullptr; i++)
 
168
    {
 
169
        auto appid = AppID::parse(apps.get()[i]);
 
170
        if (appid.appname.value() == appname.value())
 
171
        {
 
172
            return true;
 
173
        }
 
174
    }
 
175
 
 
176
    return false;
 
177
}
 
178
 
 
179
/** We don't really have a way to implement this for Libertine, any
 
180
    search wouldn't really make sense. We just throw an error.
 
181
 
 
182
    \param package Container name
 
183
    \param card Application search paths
 
184
    \param registry persistent connections to use
 
185
*/
 
186
AppID::AppName Libertine::findAppname(const AppID::Package& package,
 
187
                                      AppID::ApplicationWildcard card,
 
188
                                      const std::shared_ptr<Registry>& registry)
 
189
{
 
190
    throw std::runtime_error("Legacy apps can't be discovered by package");
 
191
}
 
192
 
 
193
/** Function to return "0.0"
 
194
 
 
195
    \param package Container name (unused)
 
196
    \param appname Application name (unused)
 
197
    \param registry persistent connections to use (unused)
 
198
*/
 
199
AppID::Version Libertine::findVersion(const AppID::Package& package,
 
200
                                      const AppID::AppName& appname,
 
201
                                      const std::shared_ptr<Registry>& registry)
 
202
{
 
203
    return AppID::Version::from_raw("0.0");
 
204
}
 
205
 
109
206
std::list<std::shared_ptr<Application>> Libertine::list(const std::shared_ptr<Registry>& registry)
110
207
{
111
208
    std::list<std::shared_ptr<Application>> applist;