Merge lp:~kyrofa/go-mir/connection into lp:go-mir

Proposed by Kyle Fazzari
Status: Merged
Approved by: dobey
Approved revision: no longer in the source branch.
Merged at revision: 2
Proposed branch: lp:~kyrofa/go-mir/connection
Merge into: lp:go-mir
Diff against target: 239 lines (+229/-0)
2 files modified
COPYING.LESSER (+165/-0)
mir/connection.go (+64/-0)
To merge this branch: bzr merge lp:~kyrofa/go-mir/connection
Reviewer Review Type Date Requested Status
dobey (community) Approve
Review via email: mp+271393@code.launchpad.net

Commit message

Add Go bindings for MirConnection.

Description of the change

Add Go bindings for MirConnection.

To post a comment you must log in.
lp:~kyrofa/go-mir/connection updated
2. By Kyle Fazzari

Add Go bindings for MirConnection.

Signed-off-by: Kyle Fazzari <email address hidden>

3. By Kyle Fazzari

Restrict the license header to version 3 of the GPL.

Signed-off-by: Kyle Fazzari <email address hidden>

Revision history for this message
dobey (dobey) wrote :

This needs to be LGPLv3, not GPL.

review: Needs Fixing
lp:~kyrofa/go-mir/connection updated
4. By Kyle Fazzari

Change license to LGPLv3.

Signed-off-by: Kyle Fazzari <email address hidden>

Revision history for this message
dobey (dobey) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'COPYING.LESSER'
2--- COPYING.LESSER 1970-01-01 00:00:00 +0000
3+++ COPYING.LESSER 2015-09-17 17:46:48 +0000
4@@ -0,0 +1,165 @@
5+ GNU LESSER GENERAL PUBLIC LICENSE
6+ Version 3, 29 June 2007
7+
8+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
9+ Everyone is permitted to copy and distribute verbatim copies
10+ of this license document, but changing it is not allowed.
11+
12+
13+ This version of the GNU Lesser General Public License incorporates
14+the terms and conditions of version 3 of the GNU General Public
15+License, supplemented by the additional permissions listed below.
16+
17+ 0. Additional Definitions.
18+
19+ As used herein, "this License" refers to version 3 of the GNU Lesser
20+General Public License, and the "GNU GPL" refers to version 3 of the GNU
21+General Public License.
22+
23+ "The Library" refers to a covered work governed by this License,
24+other than an Application or a Combined Work as defined below.
25+
26+ An "Application" is any work that makes use of an interface provided
27+by the Library, but which is not otherwise based on the Library.
28+Defining a subclass of a class defined by the Library is deemed a mode
29+of using an interface provided by the Library.
30+
31+ A "Combined Work" is a work produced by combining or linking an
32+Application with the Library. The particular version of the Library
33+with which the Combined Work was made is also called the "Linked
34+Version".
35+
36+ The "Minimal Corresponding Source" for a Combined Work means the
37+Corresponding Source for the Combined Work, excluding any source code
38+for portions of the Combined Work that, considered in isolation, are
39+based on the Application, and not on the Linked Version.
40+
41+ The "Corresponding Application Code" for a Combined Work means the
42+object code and/or source code for the Application, including any data
43+and utility programs needed for reproducing the Combined Work from the
44+Application, but excluding the System Libraries of the Combined Work.
45+
46+ 1. Exception to Section 3 of the GNU GPL.
47+
48+ You may convey a covered work under sections 3 and 4 of this License
49+without being bound by section 3 of the GNU GPL.
50+
51+ 2. Conveying Modified Versions.
52+
53+ If you modify a copy of the Library, and, in your modifications, a
54+facility refers to a function or data to be supplied by an Application
55+that uses the facility (other than as an argument passed when the
56+facility is invoked), then you may convey a copy of the modified
57+version:
58+
59+ a) under this License, provided that you make a good faith effort to
60+ ensure that, in the event an Application does not supply the
61+ function or data, the facility still operates, and performs
62+ whatever part of its purpose remains meaningful, or
63+
64+ b) under the GNU GPL, with none of the additional permissions of
65+ this License applicable to that copy.
66+
67+ 3. Object Code Incorporating Material from Library Header Files.
68+
69+ The object code form of an Application may incorporate material from
70+a header file that is part of the Library. You may convey such object
71+code under terms of your choice, provided that, if the incorporated
72+material is not limited to numerical parameters, data structure
73+layouts and accessors, or small macros, inline functions and templates
74+(ten or fewer lines in length), you do both of the following:
75+
76+ a) Give prominent notice with each copy of the object code that the
77+ Library is used in it and that the Library and its use are
78+ covered by this License.
79+
80+ b) Accompany the object code with a copy of the GNU GPL and this license
81+ document.
82+
83+ 4. Combined Works.
84+
85+ You may convey a Combined Work under terms of your choice that,
86+taken together, effectively do not restrict modification of the
87+portions of the Library contained in the Combined Work and reverse
88+engineering for debugging such modifications, if you also do each of
89+the following:
90+
91+ a) Give prominent notice with each copy of the Combined Work that
92+ the Library is used in it and that the Library and its use are
93+ covered by this License.
94+
95+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
96+ document.
97+
98+ c) For a Combined Work that displays copyright notices during
99+ execution, include the copyright notice for the Library among
100+ these notices, as well as a reference directing the user to the
101+ copies of the GNU GPL and this license document.
102+
103+ d) Do one of the following:
104+
105+ 0) Convey the Minimal Corresponding Source under the terms of this
106+ License, and the Corresponding Application Code in a form
107+ suitable for, and under terms that permit, the user to
108+ recombine or relink the Application with a modified version of
109+ the Linked Version to produce a modified Combined Work, in the
110+ manner specified by section 6 of the GNU GPL for conveying
111+ Corresponding Source.
112+
113+ 1) Use a suitable shared library mechanism for linking with the
114+ Library. A suitable mechanism is one that (a) uses at run time
115+ a copy of the Library already present on the user's computer
116+ system, and (b) will operate properly with a modified version
117+ of the Library that is interface-compatible with the Linked
118+ Version.
119+
120+ e) Provide Installation Information, but only if you would otherwise
121+ be required to provide such information under section 6 of the
122+ GNU GPL, and only to the extent that such information is
123+ necessary to install and execute a modified version of the
124+ Combined Work produced by recombining or relinking the
125+ Application with a modified version of the Linked Version. (If
126+ you use option 4d0, the Installation Information must accompany
127+ the Minimal Corresponding Source and Corresponding Application
128+ Code. If you use option 4d1, you must provide the Installation
129+ Information in the manner specified by section 6 of the GNU GPL
130+ for conveying Corresponding Source.)
131+
132+ 5. Combined Libraries.
133+
134+ You may place library facilities that are a work based on the
135+Library side by side in a single library together with other library
136+facilities that are not Applications and are not covered by this
137+License, and convey such a combined library under terms of your
138+choice, if you do both of the following:
139+
140+ a) Accompany the combined library with a copy of the same work based
141+ on the Library, uncombined with any other library facilities,
142+ conveyed under the terms of this License.
143+
144+ b) Give prominent notice with the combined library that part of it
145+ is a work based on the Library, and explaining where to find the
146+ accompanying uncombined form of the same work.
147+
148+ 6. Revised Versions of the GNU Lesser General Public License.
149+
150+ The Free Software Foundation may publish revised and/or new versions
151+of the GNU Lesser General Public License from time to time. Such new
152+versions will be similar in spirit to the present version, but may
153+differ in detail to address new problems or concerns.
154+
155+ Each version is given a distinguishing version number. If the
156+Library as you received it specifies that a certain numbered version
157+of the GNU Lesser General Public License "or any later version"
158+applies to it, you have the option of following the terms and
159+conditions either of that published version or of any later version
160+published by the Free Software Foundation. If the Library as you
161+received it does not specify a version number of the GNU Lesser
162+General Public License, you may choose any version of the GNU Lesser
163+General Public License ever published by the Free Software Foundation.
164+
165+ If the Library as you received it specifies that a proxy can decide
166+whether future versions of the GNU Lesser General Public License shall
167+apply, that proxy's public statement of acceptance of any version is
168+permanent authorization for you to choose that version for the
169+Library.
170
171=== added directory 'mir'
172=== added file 'mir/connection.go'
173--- mir/connection.go 1970-01-01 00:00:00 +0000
174+++ mir/connection.go 2015-09-17 17:46:48 +0000
175@@ -0,0 +1,64 @@
176+/* Copyright (C) 2015 Canonical Ltd.
177+ *
178+ * This file is part of go-mir.
179+ *
180+ * go-mir is free software: you can redistribute it and/or modify it under the
181+ * terms of the GNU Lesser General Public License version 3, as published by the
182+ * Free Software Foundation.
183+ *
184+ * go-mir is distributed in the hope that it will be useful, but WITHOUT ANY
185+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
186+ * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
187+ * details.
188+ *
189+ * You should have received a copy of the GNU Lesser General Public License
190+ * along with go-mir. If not, see <http://www.gnu.org/licenses/>.
191+ */
192+
193+package mir
194+
195+// #cgo pkg-config: mirclient
196+// #include <stdlib.h>
197+// #include <mir_toolkit/mir_connection.h>
198+import "C"
199+
200+import (
201+ "fmt"
202+ "unsafe"
203+)
204+
205+// Connection represents a connection to the Mir server.
206+type Connection struct {
207+ connection *C.MirConnection
208+}
209+
210+// NewConnection request (and waits for) a connection to the Mir server. Note
211+// that it's up to the caller to explicitly Release() this connection.
212+func NewConnection(serverFilePath string, clientName string) (*Connection, error) {
213+ serverFilePathCstring := C.CString(serverFilePath)
214+ defer C.free(unsafe.Pointer(serverFilePathCstring))
215+
216+ clientNameCstring := C.CString(clientName)
217+ defer C.free(unsafe.Pointer(clientNameCstring))
218+
219+ connection := &Connection{}
220+ connection.connection = C.mir_connect_sync(serverFilePathCstring,
221+ clientNameCstring)
222+
223+ if connection.connection == nil {
224+ return nil, fmt.Errorf("Failed to connect to Mir Trusted Session")
225+ }
226+
227+ return connection, nil
228+}
229+
230+// Release releases the connection to the Mir server.
231+func (connection *Connection) Release() {
232+ C.mir_connection_release(connection.connection)
233+}
234+
235+// ToMirConnection returns the raw MirConnection (in case other bindings require
236+// it).
237+func (connection *Connection) ToMirConnection() *C.MirConnection {
238+ return connection.connection
239+}

Subscribers

People subscribed via source and target branches

to all changes: