Mir

Merge lp:~vanvugt/mir/appid into lp:~mir-team/mir/trunk

Proposed by Daniel van Vugt
Status: Work in progress
Proposed branch: lp:~vanvugt/mir/appid
Merge into: lp:~mir-team/mir/trunk
Prerequisite: lp:~vanvugt/mir/constify-session-name
Diff against target: 112 lines (+71/-1)
4 files modified
include/client/mir_toolkit/mir_client_library.h (+8/-1)
include/server/mir/shell/application_session.h (+1/-0)
src/server/shell/application_session.cpp (+14/-0)
tests/unit-tests/shell/test_application_session.cpp (+48/-0)
To merge this branch: bzr merge lp:~vanvugt/mir/appid
Reviewer Review Type Date Requested Status
Robert Ancell Needs Information
Alan Griffiths Needs Information
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+154647@code.launchpad.net

Commit message

Allow the client app_name to optionally represent a universally unique URN.
If so, this can be used by the server/shell to look up application metadata.

URNs follow the specification laid out in RFC2141:
  http://www.ietf.org/rfc/rfc2141.txt
URNs can be used to represent universally unique IDs such as RFC4122:
  http://www.ietf.org/rfc/rfc4122.txt
but I'm not committing to UUIDs being the only supported syntax right now.

Description of the change

This is based on a vague recollection of what we discussed for:
"[vanvugt] Unique key for applications: INPROGRESS"
(https://blueprints.launchpad.net/ubuntu/+spec/client-1303-mir-phone-iteration-0)

If no one is too sure we will ever need it, then I'm happy to drop it.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

I don't see that overloading name for this purpose is the right approach.

Why shouldn't a session have both a urn and a name? (Admittedly adding an optional urn is a slightly bigger code change, but it seems more natural to me.)

review: Needs Information
Revision history for this message
Robert Ancell (robert-ancell) wrote :

I don't see what this is adding over the name. The contents of name are currently undefined and could contain a URN if that's what we require. I think we need Thomas to work out how applications identify themselves and how authenticate that a Mir connection is the application we think.

My gut feel is the only way the name can really be useful is if it is passed to the application by the shell so the shell can confirm a connection came from an expected application.

review: Needs Information
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Alan,

Initially I was thinking the same. In fact my iterations went:
  1. Replace app_name with app_urn.
  2. Complement app_name with adjacent app_urn.
  3. Optionally use app_name as the URN (proposed here).

I did not go with #1 because it forced all developers to create a universally unique ID for their app, regardless of how trivial the app. Admittedly you just need to run "uuidgen" on Ubuntu. But that also makes reporting ugly. UUIDs (or whatever) are not very pleasant to read in a log.

I did not go with #2 because of the complexity as you say. But also because providing a universally unique ID as we discussed in London was a means for avoiding specifying a fixed app name in a single language. The intention is that you look at the URN and then look up the localized name of the app if you need it. Though the obvious argument against that is that it depends on a common config backend to work at all. And schemas to be defined etc. That's not always required by app developers so you should be allowed to just use a simple app_name alone.

So I went with #3. It retains simplicity by default. You are not forced to engage in the complexity of allocating URNs and providing a configuration/metadata backend if you don't want it. It's simple by default, but retains the power to do more if you want it.

---
Robert,

Yes agreed. The longer I spent thinking about the problem, the more I started to believe it should involve zero code change. At least for now, until we have a practical need for it. I would personally prefer we rejected the whole requirement/work item, for now.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Also, a simple app_name already works fine for discriminating applications on Linux. Just look in:
   /usr/share/applications/

So I do recommend rejecting this proposal, but only if we can reject the requirement for it too:
   https://blueprints.launchpad.net/ubuntu/+spec/client-1303-mir-phone-iteration-0

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Work in progress and task postponed. Pending better requirements gathering.

Unmerged revisions

528. By Daniel van Vugt

Remember puctuation.

527. By Daniel van Vugt

Always use std::string::empty() where possible.

526. By Daniel van Vugt

Improve comments.

525. By Daniel van Vugt

Improve unit tests for ApplicationSession::urn()

524. By Daniel van Vugt

Don't link the the RFC for UUIDs. They're not a requirement.

523. By Daniel van Vugt

Make the URN accessible by ApplicationSession::urn()

522. By Daniel van Vugt

mir_client_library.h: Initial spec of how to pass app URNs

521. By Daniel van Vugt

Const'ify name() for all Session classes.

520. By Daniel van Vugt

mir_client_library.h: Tidy up client API docs.

Approved by Robert Ancell, Alan Griffiths, PS Jenkins bot.

519. By Alexandros Frantzis

examples: Change render-surfaces to use the DisplayServer class.

Approved by Alan Griffiths, PS Jenkins bot.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'include/client/mir_toolkit/mir_client_library.h'
2--- include/client/mir_toolkit/mir_client_library.h 2013-03-20 10:26:48 +0000
3+++ include/client/mir_toolkit/mir_client_library.h 2013-03-21 10:03:12 +0000
4@@ -155,7 +155,14 @@
5 * the connection is established, or fails. The returned wait handle remains
6 * valid until the connection has been released.
7 * \param [in] server A name identifying the server
8- * \param [in] app_name A name referring to the application
9+ * \param [in] app_name A name identifying the application. This may be
10+ * either a simple name or a URN (e.g.
11+ * "urn:uuid:52bb8448-98d2-404f-b354-b6122020766a").
12+ * If the name begins with "urn:" then it is assumed
13+ * to be a URN which can be used by the Mir server
14+ * and shell to look up further information about
15+ * the application. For more information, see:
16+ * http://www.ietf.org/rfc/rfc2141.txt
17 * \param [in] callback Callback function to be invoked when request
18 * completes
19 * \param [in,out] context User data passed to the callback function
20
21=== modified file 'include/server/mir/shell/application_session.h'
22--- include/server/mir/shell/application_session.h 2013-03-21 10:03:12 +0000
23+++ include/server/mir/shell/application_session.h 2013-03-21 10:03:12 +0000
24@@ -42,6 +42,7 @@
25 std::shared_ptr<frontend::Surface> get_surface(frontend::SurfaceId surface) const;
26
27 std::string name() const;
28+ std::string urn() const; // Unique application ID "urn:..." or empty.
29
30 void shutdown();
31
32
33=== modified file 'src/server/shell/application_session.cpp'
34--- src/server/shell/application_session.cpp 2013-03-21 10:03:12 +0000
35+++ src/server/shell/application_session.cpp 2013-03-21 10:03:12 +0000
36@@ -96,6 +96,20 @@
37 return session_name;
38 }
39
40+std::string msh::ApplicationSession::urn() const
41+{
42+ /*
43+ * We could go through the pain of fully validating the URN according to
44+ * RFC2141, but there's no real value in that right now.
45+ * The only use-case we care about is whether the client is telling us
46+ * that the app name is /intended/ as unique URN to look up metadata.
47+ * So that's a yes (URN string), or no (blank).
48+ */
49+
50+ return session_name.compare(0, 4, "urn:") == 0 ? session_name :
51+ std::string();
52+}
53+
54 void msh::ApplicationSession::shutdown()
55 {
56 std::unique_lock<std::mutex> lock(surfaces_mutex);
57
58=== modified file 'tests/unit-tests/shell/test_application_session.cpp'
59--- tests/unit-tests/shell/test_application_session.cpp 2013-03-20 10:56:07 +0000
60+++ tests/unit-tests/shell/test_application_session.cpp 2013-03-21 10:03:12 +0000
61@@ -114,3 +114,51 @@
62 app_session.destroy_surface(invalid_surface_id);
63 }, std::runtime_error);
64 }
65+
66+TEST(Session, no_urn)
67+{
68+ static const char *invalid_urns[] =
69+ {
70+ "",
71+ "u",
72+ "ur",
73+ "urn",
74+ "Foo",
75+ " urn:aa:bb",
76+ "hello world",
77+ "urn :apples:oranges",
78+ "My Application version 3",
79+ NULL
80+ };
81+
82+ mtd::MockSurfaceFactory surface_factory;
83+
84+ for (const char **urn = invalid_urns; *urn; urn++)
85+ {
86+ msh::ApplicationSession app_session(mt::fake_shared(surface_factory),
87+ *urn);
88+ EXPECT_EQ(*urn, app_session.name());
89+ EXPECT_TRUE(app_session.urn().empty());
90+ }
91+}
92+
93+TEST(Session, urns)
94+{
95+ static const char *valid_urns[] =
96+ {
97+ "urn:abc:def",
98+ "urn:uuid:a7b7cceb-9182-4032-a1d5-a9c1f295efe7",
99+ "urn:Well-Known-App:Super Widget Blaster 3.0",
100+ NULL
101+ };
102+
103+ mtd::MockSurfaceFactory surface_factory;
104+
105+ for (const char **urn = valid_urns; *urn; urn++)
106+ {
107+ msh::ApplicationSession app_session(mt::fake_shared(surface_factory),
108+ *urn);
109+ EXPECT_EQ(*urn, app_session.name());
110+ EXPECT_EQ(*urn, app_session.urn());
111+ }
112+}

Subscribers

People subscribed via source and target branches