Merge lp:~dobey/ubuntu-app-launch/add-desktop-apis into lp:ubuntu-app-launch/16.10

Proposed by dobey
Status: Merged
Merged at revision: 244
Proposed branch: lp:~dobey/ubuntu-app-launch/add-desktop-apis
Merge into: lp:ubuntu-app-launch/16.10
Diff against target: 168 lines (+90/-0)
4 files modified
libubuntu-app-launch/application-info-desktop.cpp (+37/-0)
libubuntu-app-launch/application-info-desktop.h (+15/-0)
libubuntu-app-launch/application.h (+14/-0)
tests/application-info-desktop.cpp (+24/-0)
To merge this branch: bzr merge lp:~dobey/ubuntu-app-launch/add-desktop-apis
Reviewer Review Type Date Requested Status
Ted Gould (community) Needs Fixing
unity-api-1-bot continuous-integration Needs Fixing
Review via email: mp+302467@code.launchpad.net

Commit message

Add missing APIs for necessary info from .desktop files.

To post a comment you must log in.
Revision history for this message
unity-api-1-bot (unity-api-1-bot) wrote :

FAILED: Continuous integration, rev:238
https://jenkins.canonical.com/unity-api-1/job/lp-ubuntu-app-launch-ci/46/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build/327/console
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-0-fetch/333
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=vivid+overlay/260
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=xenial+overlay/260
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-1-sourcepkg/release=yakkety/260
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=vivid+overlay/190/console
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/190
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/190/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=yakkety/190
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=yakkety/190/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=vivid+overlay/190/console
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/190/console
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=yakkety/190
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=yakkety/190/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=vivid+overlay/190
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=vivid+overlay/190/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/190
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/190/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=yakkety/190
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=yakkety/190/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/unity-api-1/job/lp-ubuntu-app-launch-ci/46/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Ted Gould (ted) wrote :

Needs to support code formatting for C++ code in this project. That can be easily done by typing "make format". Otherwise looks good!

review: Needs Fixing
Revision history for this message
dobey (dobey) wrote :

No, I can't use "make format" nor "make format-tests" because they are broken, do not follow the coding style which we really should be following anyway (nor does the rest of UAL follow that standard), and the changes in this MP are fully consistent with the rest of the file in which they changed.

I have filed several bugs about the style issues in UAL this morning. I'll agree they should be fixed, but this isn't the branch to do it in.

Revision history for this message
Ted Gould (ted) wrote :

All I care is that "make format && bzr diff" returns no changes.

review: Needs Fixing

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libubuntu-app-launch/application-info-desktop.cpp'
2--- libubuntu-app-launch/application-info-desktop.cpp 2016-06-07 04:01:41 +0000
3+++ libubuntu-app-launch/application-info-desktop.cpp 2016-08-09 20:01:05 +0000
4@@ -127,6 +127,38 @@
5 return retval;
6 }
7
8+template <typename T>
9+auto stringlistFromKeyfile(std::shared_ptr<GKeyFile> keyfile,
10+ const gchar* key,
11+ const std::string& exceptionText = {}) -> T
12+{
13+ GError* error = nullptr;
14+ auto keyval = g_key_file_get_locale_string_list(keyfile.get(), DESKTOP_GROUP, key, nullptr, nullptr, &error);
15+
16+ if (error != nullptr)
17+ {
18+ auto perror = std::shared_ptr<GError>(error, g_error_free);
19+ if (!exceptionText.empty())
20+ {
21+ throw std::runtime_error(exceptionText + perror.get()->message);
22+ }
23+
24+ return T::from_raw({});
25+ }
26+
27+ std::vector<std::string> results;
28+ for (auto i = 0; keyval[i] != nullptr; ++i)
29+ {
30+ if (strlen(keyval[i]) != 0)
31+ {
32+ results.emplace_back(keyval[i]);
33+ }
34+ }
35+ g_strfreev(keyval);
36+
37+ return T::from_raw(results);
38+}
39+
40 bool stringlistFromKeyfileContains(std::shared_ptr<GKeyFile> keyfile,
41 const gchar* key,
42 const std::string& match,
43@@ -201,6 +233,11 @@
44 }
45 return fileFromKeyfile<Application::Info::IconPath>(keyfile, basePath, "Icon", "Missing icon for desktop file");
46 }())
47+ , _defaultDepartment(stringFromKeyfile<Application::Info::DefaultDepartment>(keyfile, "X-Ubuntu-Default-Department-ID"))
48+ , _screenshotPath([keyfile, basePath]() {
49+ return fileFromKeyfile<Application::Info::IconPath>(keyfile, basePath, "X-Screenshot");
50+ }())
51+ , _keywords(stringlistFromKeyfile<Application::Info::Keywords>(keyfile, "Keywords"))
52 , _splashInfo(
53 {stringFromKeyfile<Application::Info::Splash::Title>(keyfile, "X-Ubuntu-Splash-Title"),
54 fileFromKeyfile<Application::Info::Splash::Image>(keyfile, basePath, "X-Ubuntu-Splash-Image"),
55
56=== modified file 'libubuntu-app-launch/application-info-desktop.h'
57--- libubuntu-app-launch/application-info-desktop.h 2016-06-07 04:01:41 +0000
58+++ libubuntu-app-launch/application-info-desktop.h 2016-08-09 20:01:05 +0000
59@@ -50,6 +50,18 @@
60 {
61 return _iconPath;
62 }
63+ const Application::Info::DefaultDepartment& defaultDepartment() override
64+ {
65+ return _defaultDepartment;
66+ }
67+ const Application::Info::IconPath& screenshotPath() override
68+ {
69+ return _screenshotPath;
70+ }
71+ const Application::Info::Keywords& keywords() override
72+ {
73+ return _keywords;
74+ }
75
76 Application::Info::Splash splash() override
77 {
78@@ -78,6 +90,9 @@
79 Application::Info::Name _name;
80 Application::Info::Description _description;
81 Application::Info::IconPath _iconPath;
82+ Application::Info::DefaultDepartment _defaultDepartment;
83+ Application::Info::IconPath _screenshotPath;
84+ Application::Info::Keywords _keywords;
85
86 Application::Info::Splash _splashInfo;
87 Application::Info::Orientations _supportedOrientations;
88
89=== modified file 'libubuntu-app-launch/application.h'
90--- libubuntu-app-launch/application.h 2016-06-07 04:01:41 +0000
91+++ libubuntu-app-launch/application.h 2016-08-09 20:01:05 +0000
92@@ -83,6 +83,10 @@
93 struct DescriptionTag;
94 /** \private */
95 struct IconPathTag;
96+ /** \private */
97+ struct DefaultDepartmentTag;
98+ /** \private */
99+ struct KeywordsTag;
100
101 /** \private */
102 typedef TypeTagger<NameTag, std::string> Name;
103@@ -90,6 +94,10 @@
104 typedef TypeTagger<DescriptionTag, std::string> Description;
105 /** \private */
106 typedef TypeTagger<IconPathTag, std::string> IconPath;
107+ /** \private */
108+ typedef TypeTagger<DefaultDepartmentTag, std::string> DefaultDepartment;
109+ /** \private */
110+ typedef TypeTagger<KeywordsTag, std::vector<std::string>> Keywords;
111
112 /** Name of the application */
113 virtual const Name& name() = 0;
114@@ -97,6 +105,12 @@
115 virtual const Description& description() = 0;
116 /** Path to the icon that represents the application */
117 virtual const IconPath& iconPath() = 0;
118+ /** Default department of the application */
119+ virtual const DefaultDepartment& defaultDepartment() = 0;
120+ /** Path to the screenshot of the application */
121+ virtual const IconPath& screenshotPath() = 0;
122+ /** List of keywords for the application */
123+ virtual const Keywords& keywords() = 0;
124
125 /** Information to be shown on the app splash screen */
126 struct Splash
127
128=== modified file 'tests/application-info-desktop.cpp'
129--- tests/application-info-desktop.cpp 2016-05-10 19:09:34 +0000
130+++ tests/application-info-desktop.cpp 2016-08-09 20:01:05 +0000
131@@ -64,6 +64,7 @@
132 EXPECT_EQ("Foo App", appinfo.name().value());
133 EXPECT_EQ("", appinfo.description().value());
134 EXPECT_EQ("/foo.png", appinfo.iconPath().value());
135+ EXPECT_EQ("", appinfo.defaultDepartment().value());
136
137 EXPECT_EQ("", appinfo.splash().title.value());
138 EXPECT_EQ("", appinfo.splash().image.value());
139@@ -126,6 +127,29 @@
140 #endif
141 }
142
143+TEST_F(ApplicationInfoDesktop, KeyfileDefaultDepartment)
144+{
145+ auto keyfile = defaultKeyfile();
146+ g_key_file_set_string(keyfile.get(), DESKTOP, "X-Ubuntu-Default-Department-ID", "foo");
147+ EXPECT_NO_THROW(ubuntu::app_launch::app_info::Desktop(keyfile, "/"));
148+}
149+
150+TEST_F(ApplicationInfoDesktop, KeyfileScreenshotPath)
151+{
152+ auto keyfile = defaultKeyfile();
153+ g_key_file_set_string(keyfile.get(), DESKTOP, "X-Screenshot", "foo.png");
154+ EXPECT_EQ("/foo.png", ubuntu::app_launch::app_info::Desktop(keyfile, "/").screenshotPath().value());
155+}
156+
157+TEST_F(ApplicationInfoDesktop, KeyfileKeywords)
158+{
159+ std::vector<std::string>expectedKeywords{"foo", "bar", "baz"};
160+
161+ auto keyfile = defaultKeyfile();
162+ g_key_file_set_string(keyfile.get(), DESKTOP, "Keywords", "foo;bar;baz;");
163+ EXPECT_EQ(expectedKeywords, ubuntu::app_launch::app_info::Desktop(keyfile, "/").keywords().value());
164+}
165+
166 TEST_F(ApplicationInfoDesktop, KeyfileShowListEdgeCases)
167 {
168 // Not appearing in not show list

Subscribers

People subscribed via source and target branches