Merge lp:~thomas-voss/platform-api/add-location-service-api-take-2 into lp:platform-api

Proposed by Thomas Voß
Status: Rejected
Rejected by: Didier Roche-Tolomelli
Proposed branch: lp:~thomas-voss/platform-api/add-location-service-api-take-2
Merge into: lp:platform-api
Diff against target: 10604 lines (+5416/-4588)
102 files modified
debian/control (+4/-2)
debian/libplatform-api1-doc.doc-base (+2/-1)
debian/libubuntu-application-api1.symbols (+28/-0)
doc/Doxyfile.in (+6/-6)
include/ubuntu/application/CMakeLists.txt (+1/-0)
include/ubuntu/application/location/CMakeLists.txt (+14/-0)
include/ubuntu/application/location/heading_update.h (+78/-0)
include/ubuntu/application/location/position_update.h (+108/-0)
include/ubuntu/application/location/service.h (+94/-0)
include/ubuntu/application/location/session.h (+169/-0)
include/ubuntu/application/location/velocity_update.h (+78/-0)
src/CMakeLists.txt (+1/-15)
src/hybris/CMakeLists.txt (+0/-53)
src/hybris/bridge.h (+0/-202)
src/hybris/tests/CMakeLists.txt (+0/-25)
src/hybris/tests/test_c_api.cpp (+0/-329)
src/hybris/tests/test_gps_api.cpp (+0/-252)
src/hybris/tests/test_multiple_surfaces_event_delivery.cpp (+0/-351)
src/hybris/tests/test_sensors_api.cpp (+0/-88)
src/hybris/tests/test_session_c_api.cpp (+0/-229)
src/hybris/ubuntu_application_api_hybris.cpp (+0/-130)
src/hybris/ubuntu_application_sensors_hybris.cpp (+0/-70)
src/hybris/ubuntu_platform_hardware_api.cpp (+0/-78)
src/mirclient/CMakeLists.txt (+0/-34)
src/mirclient/application_instance_mirclient.cpp (+0/-68)
src/mirclient/application_instance_mirclient_priv.h (+0/-68)
src/mirclient/ubuntu_application_api_mirclient.cpp (+0/-279)
src/mirclient/window_mirclient.cpp (+0/-128)
src/mirclient/window_mirclient_priv.h (+0/-76)
src/mirclient/window_properties_mirclient.cpp (+0/-68)
src/mirclient/window_properties_mirclient_priv.h (+0/-72)
src/mircommon/CMakeLists.txt (+0/-43)
src/mircommon/application_description_mir.cpp (+0/-94)
src/mircommon/application_description_mir_priv.h (+0/-56)
src/mircommon/application_id_mir.cpp (+0/-56)
src/mircommon/application_id_mir_priv.h (+0/-53)
src/mircommon/application_options_mir.cpp (+0/-170)
src/mircommon/application_options_mir_priv.h (+0/-58)
src/mircommon/event_helpers_mir.cpp (+0/-77)
src/mircommon/event_helpers_mir.h (+0/-39)
src/mircommon/lifecycle_delegate_mir.cpp (+0/-136)
src/mircommon/lifecycle_delegate_mir_priv.h (+0/-59)
src/mircommon/session_mir.cpp (+0/-51)
src/mircommon/ubuntu_application_sensors_desktop.cpp (+0/-190)
src/mirserver/CMakeLists.txt (+0/-38)
src/mirserver/application_instance_mirserver.cpp (+0/-83)
src/mirserver/application_instance_mirserver_priv.h (+0/-85)
src/mirserver/ubuntu_application_api_mirserver.cpp (+0/-320)
src/mirserver/ubuntu_application_api_mirserver_priv.h (+0/-41)
src/mirserver/window_mirserver.cpp (+0/-81)
src/mirserver/window_mirserver_priv.h (+0/-92)
src/mirserver/window_properties_mirserver.cpp (+0/-73)
src/mirserver/window_properties_mirserver_priv.h (+0/-69)
src/ubuntu/CMakeLists.txt (+27/-0)
src/ubuntu/application/CMakeLists.txt (+1/-0)
src/ubuntu/application/location/CMakeLists.txt (+10/-0)
src/ubuntu/application/location/heading_update.cpp (+32/-0)
src/ubuntu/application/location/position_update.cpp (+60/-0)
src/ubuntu/application/location/service.cpp (+15/-0)
src/ubuntu/application/location/session.cpp (+87/-0)
src/ubuntu/application/location/velocity_update.cpp (+32/-0)
src/ubuntu/hybris/CMakeLists.txt (+57/-0)
src/ubuntu/hybris/bridge.h (+202/-0)
src/ubuntu/hybris/tests/CMakeLists.txt (+25/-0)
src/ubuntu/hybris/tests/test_c_api.cpp (+329/-0)
src/ubuntu/hybris/tests/test_gps_api.cpp (+252/-0)
src/ubuntu/hybris/tests/test_multiple_surfaces_event_delivery.cpp (+351/-0)
src/ubuntu/hybris/tests/test_sensors_api.cpp (+88/-0)
src/ubuntu/hybris/tests/test_session_c_api.cpp (+229/-0)
src/ubuntu/hybris/ubuntu_application_api_hybris.cpp (+130/-0)
src/ubuntu/hybris/ubuntu_application_sensors_hybris.cpp (+70/-0)
src/ubuntu/hybris/ubuntu_platform_hardware_api.cpp (+78/-0)
src/ubuntu/mirclient/CMakeLists.txt (+34/-0)
src/ubuntu/mirclient/application_instance_mirclient.cpp (+68/-0)
src/ubuntu/mirclient/application_instance_mirclient_priv.h (+68/-0)
src/ubuntu/mirclient/ubuntu_application_api_mirclient.cpp (+279/-0)
src/ubuntu/mirclient/window_mirclient.cpp (+128/-0)
src/ubuntu/mirclient/window_mirclient_priv.h (+76/-0)
src/ubuntu/mirclient/window_properties_mirclient.cpp (+68/-0)
src/ubuntu/mirclient/window_properties_mirclient_priv.h (+72/-0)
src/ubuntu/mircommon/CMakeLists.txt (+44/-0)
src/ubuntu/mircommon/application_description_mir.cpp (+94/-0)
src/ubuntu/mircommon/application_description_mir_priv.h (+56/-0)
src/ubuntu/mircommon/application_id_mir.cpp (+56/-0)
src/ubuntu/mircommon/application_id_mir_priv.h (+53/-0)
src/ubuntu/mircommon/application_options_mir.cpp (+170/-0)
src/ubuntu/mircommon/application_options_mir_priv.h (+58/-0)
src/ubuntu/mircommon/event_helpers_mir.cpp (+77/-0)
src/ubuntu/mircommon/event_helpers_mir.h (+39/-0)
src/ubuntu/mircommon/lifecycle_delegate_mir.cpp (+136/-0)
src/ubuntu/mircommon/lifecycle_delegate_mir_priv.h (+59/-0)
src/ubuntu/mircommon/session_mir.cpp (+51/-0)
src/ubuntu/mircommon/ubuntu_application_sensors_desktop.cpp (+190/-0)
src/ubuntu/mirserver/CMakeLists.txt (+38/-0)
src/ubuntu/mirserver/application_instance_mirserver.cpp (+83/-0)
src/ubuntu/mirserver/application_instance_mirserver_priv.h (+85/-0)
src/ubuntu/mirserver/ubuntu_application_api_mirserver.cpp (+320/-0)
src/ubuntu/mirserver/ubuntu_application_api_mirserver_priv.h (+41/-0)
src/ubuntu/mirserver/window_mirserver.cpp (+81/-0)
src/ubuntu/mirserver/window_mirserver_priv.h (+92/-0)
src/ubuntu/mirserver/window_properties_mirserver.cpp (+73/-0)
src/ubuntu/mirserver/window_properties_mirserver_priv.h (+69/-0)
To merge this branch: bzr merge lp:~thomas-voss/platform-api/add-location-service-api-take-2
Reviewer Review Type Date Requested Status
Gerry Boland (community) Needs Information
PS Jenkins bot continuous-integration Approve
Didier Roche-Tolomelli Approve
Ricardo Mendoza (community) Approve
Ricardo Salveti (community) Approve
Review via email: mp+173457@code.launchpad.net

Commit message

Add the location service API together with respective documentation.

Description of the change

Add the location service API together with respective documentation.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

* the -doc package should rather be arch: all if possible
* nitpick: the ${misc:Depends}, would be better as first dep :)

Otherwise, everything looks good to me

Revision history for this message
Ricardo Salveti (rsalveti) wrote :

Looks good, tested and not issues with the flipped image. Would just like a +1 from ricmm to make sure it didn't break platform-api with mir.

review: Approve
Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

Please fix the lines too long in the description in debian/control
as well, the lintian errors on the -doc package.

As part of our discussion, this branch can only land if we land just after that one, the same day, the package transition to the correct naming.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

ok, +1 on this branch, but please, globally approve and have that landed once the package renaming is settled on and ready to be merged.

Bonus point if you fix that one still having long description:
W: ubuntu-platform-implementation-android-tests: extended-description-line-too-long

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ricardo Mendoza (ricmm) wrote :

Works fine under the Mir environment.

review: Approve
Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

looking good, thanks!

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
95. By Thomas Voß

Merged trunk.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
96. By Thomas Voß

* General renaming of packages to match debian guidelines
[ Gustavo Pichorim Boiko ]
* Rename the well known applications to match their names after the
  splitting of phone-app. The entry for the current phone-app was kept
  there so that it can be used while the new applications are not yet
  mature.
[ Ubuntu daily release ]
* Automatic snapshot from revision 103
[ Jani Monoses ]
* Fixing issue with gcc 4.6.
* Build fixes for tests.
[ Ubuntu daily release ]
* Automatic snapshot from revision 101
[ Ricardo Mendoza ]
* * Clear all input traps upon death of the last client * Reset shell
  focus if all apps exit. (LP: #1203698, #1204299)
[ Ubuntu daily release ]
* Automatic snapshot from revision 98

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Gerry Boland (gerboland) wrote :

Ancient, do we need this any more?

review: Needs Information

Unmerged revisions

96. By Thomas Voß

* General renaming of packages to match debian guidelines
[ Gustavo Pichorim Boiko ]
* Rename the well known applications to match their names after the
  splitting of phone-app. The entry for the current phone-app was kept
  there so that it can be used while the new applications are not yet
  mature.
[ Ubuntu daily release ]
* Automatic snapshot from revision 103
[ Jani Monoses ]
* Fixing issue with gcc 4.6.
* Build fixes for tests.
[ Ubuntu daily release ]
* Automatic snapshot from revision 101
[ Ricardo Mendoza ]
* * Clear all input traps upon death of the last client * Reset shell
  focus if all apps exit. (LP: #1203698, #1204299)
[ Ubuntu daily release ]
* Automatic snapshot from revision 98

95. By Thomas Voß

Merged trunk.

94. By Thomas Voß

Merged trunk.

93. By Thomas Voß

Fix lintian warnings for the doc-base package.

92. By Thomas Voß

Fix line-length in debian/control.

91. By Thomas Voß

[ Thomas Voß ]
[ Ubuntu daily release ]
* debian/*symbols: auto-update new symbols to released version
[ Thomas Voß ]
* Add first wave of doxygen documentation and make the documentation
  known to the packaging setup.
[ Ubuntu daily release ]
* Automatic snapshot from revision 87

90. By Thomas Voß

Update symbols file to account for removed symbols.

89. By Thomas Voß

 * Do not include full-paths in documentation.

88. By Thomas Voß

Add documentation for the location service.

87. By Thomas Voß

 * Refactored the src folder
 * Added the location service API

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/control'
--- debian/control 2013-07-18 23:55:59 +0000
+++ debian/control 2013-07-30 05:35:33 +0000
@@ -38,7 +38,8 @@
38Depends: ${misc:Depends},38Depends: ${misc:Depends},
39 libplatform-api-headers,39 libplatform-api-headers,
40Description: Platform API for system level capabilities (API headers)40Description: Platform API for system level capabilities (API headers)
41 This package provides the library headers for the hw-access parts of the Platform API.41 This package provides the library headers for the hw-access parts
42 of the Platform API.
42 .43 .
43 Unless a new backend for the Platform API is developed, packages44 Unless a new backend for the Platform API is developed, packages
44 should build depend on the libplatform-hardware-api-dev package instead, which45 should build depend on the libplatform-hardware-api-dev package instead, which
@@ -91,7 +92,8 @@
91 ${shlibs:Depends},92 ${shlibs:Depends},
92 libhybris,93 libhybris,
93Description: Hybris implementation of the hw-access parts of the Platform API (runtime)94Description: Hybris implementation of the hw-access parts of the Platform API (runtime)
94 This package provides the hybris implementation of the hw-access parts of the Platform API.95 This package provides the hybris implementation of the hw-access parts
96 of the Platform API.
95 .97 .
96 The produced library should be used via libhybris, to communicate with the98 The produced library should be used via libhybris, to communicate with the
97 Android userspace, which is where the device drivers live.99 Android userspace, which is where the device drivers live.
98100
=== modified file 'debian/libplatform-api1-doc.doc-base'
--- debian/libplatform-api1-doc.doc-base 2013-07-05 16:34:47 +0000
+++ debian/libplatform-api1-doc.doc-base 2013-07-30 05:35:33 +0000
@@ -1,8 +1,9 @@
1Document: ubuntu-platform-api 1Document: ubuntu-platform-api
2Title: Ubuntu Platform API Reference Documentation2Title: Ubuntu Platform API Reference Documentation
3Author: Thomas Voß3Author: Thomas Voß
4Abstract: This is the reference documentation for the Ubuntu Platform API4Abstract: This is the reference documentation for the Ubuntu Platform API
5Section: Debian5Section: Debian
6
6Format: HTML7Format: HTML
7Index: /usr/share/doc/ubuntu-platform-api/html/index.html8Index: /usr/share/doc/ubuntu-platform-api/html/index.html
8Files: /usr/share/doc/ubuntu-platform-api/html/*.html9Files: /usr/share/doc/ubuntu-platform-api/html/*.html
910
=== modified file 'debian/libubuntu-application-api1.symbols'
--- debian/libubuntu-application-api1.symbols 2013-07-17 14:29:04 +0000
+++ debian/libubuntu-application-api1.symbols 2013-07-30 05:35:33 +0000
@@ -17,6 +17,34 @@
17 u_application_options_get_form_factor@Base 0.18.1daily13.06.2117 u_application_options_get_form_factor@Base 0.18.1daily13.06.21
18 u_application_options_get_stage@Base 0.18.1daily13.06.2118 u_application_options_get_stage@Base 0.18.1daily13.06.21
19 u_application_options_new_from_cmd_line@Base 0.18.1daily13.06.2119 u_application_options_new_from_cmd_line@Base 0.18.1daily13.06.21
20 ua_location_heading_update_get_timestamp@Base 0replaceme
21 ua_location_heading_update_ref@Base 0replaceme
22 ua_location_heading_update_unref@Base 0replaceme
23 ua_location_position_update_get_altitude_in_meter@Base 0replaceme
24 ua_location_position_update_get_heading_in_degree@Base 0replaceme
25 ua_location_position_update_get_latitude_in_degree@Base 0replaceme
26 ua_location_position_update_get_longitude_in_degree@Base 0replaceme
27 ua_location_position_update_get_timestamp@Base 0replaceme
28 ua_location_position_update_has_altitude@Base 0replaceme
29 ua_location_position_update_ref@Base 0replaceme
30 ua_location_position_update_unref@Base 0replaceme
31 ua_location_service_create_session_for_high_accuracy@Base 0replaceme
32 ua_location_service_create_session_for_low_accuracy@Base 0replaceme
33 ua_location_service_session_ref@Base 0replaceme
34 ua_location_service_session_set_heading_updates_handler@Base 0replaceme
35 ua_location_service_session_set_position_updates_handler@Base 0replaceme
36 ua_location_service_session_set_velocity_updates_handler@Base 0replaceme
37 ua_location_service_session_start_heading_updates@Base 0replaceme
38 ua_location_service_session_start_position_updates@Base 0replaceme
39 ua_location_service_session_start_velocity_updates@Base 0replaceme
40 ua_location_service_session_stop_heading_updates@Base 0replaceme
41 ua_location_service_session_stop_position_updates@Base 0replaceme
42 ua_location_service_session_stop_velocity_updates@Base 0replaceme
43 ua_location_service_session_unref@Base 0replaceme
44 ua_location_velocity_update_get_timestamp@Base 0replaceme
45 ua_location_velocity_update_get_velocity_in_meters_per_second@Base 0replaceme
46 ua_location_velocity_update_ref@Base 0replaceme
47 ua_location_velocity_update_unref@Base 0replaceme
20 ua_sensors_accelerometer_disable@Base 0.18.1daily13.06.2148 ua_sensors_accelerometer_disable@Base 0.18.1daily13.06.21
21 ua_sensors_accelerometer_enable@Base 0.18.1daily13.06.2149 ua_sensors_accelerometer_enable@Base 0.18.1daily13.06.21
22 ua_sensors_accelerometer_get_max_value@Base 0.18.1daily13.06.2150 ua_sensors_accelerometer_get_max_value@Base 0.18.1daily13.06.21
2351
=== modified file 'doc/Doxyfile.in'
--- doc/Doxyfile.in 2013-07-05 09:13:31 +0000
+++ doc/Doxyfile.in 2013-07-30 05:35:33 +0000
@@ -119,7 +119,7 @@
119# path before files name in the file list and in the header files. If set119# path before files name in the file list and in the header files. If set
120# to NO the shortest path that makes the file name unique will be used.120# to NO the shortest path that makes the file name unique will be used.
121121
122FULL_PATH_NAMES = YES122FULL_PATH_NAMES = NO
123123
124# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag124# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
125# can be used to strip a user-defined part of the path. Stripping is125# can be used to strip a user-defined part of the path. Stripping is
@@ -1293,7 +1293,7 @@
1293# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will1293# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
1294# generate Latex output.1294# generate Latex output.
12951295
1296GENERATE_LATEX = NO1296GENERATE_LATEX = YES
12971297
1298# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.1298# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
1299# If a relative path is entered the value of OUTPUT_DIRECTORY will be1299# If a relative path is entered the value of OUTPUT_DIRECTORY will be
@@ -1319,7 +1319,7 @@
1319# LaTeX documents. This may be useful for small projects and may help to1319# LaTeX documents. This may be useful for small projects and may help to
1320# save some trees in general.1320# save some trees in general.
13211321
1322COMPACT_LATEX = NO1322COMPACT_LATEX = YES
13231323
1324# The PAPER_TYPE tag can be used to set the paper type that is used1324# The PAPER_TYPE tag can be used to set the paper type that is used
1325# by the printer. Possible values are: a4, letter, legal and1325# by the printer. Possible values are: a4, letter, legal and
@@ -1364,20 +1364,20 @@
1364# running if errors occur, instead of asking the user for help.1364# running if errors occur, instead of asking the user for help.
1365# This option is also used when generating formulas in HTML.1365# This option is also used when generating formulas in HTML.
13661366
1367LATEX_BATCHMODE = NO1367LATEX_BATCHMODE = YES
13681368
1369# If LATEX_HIDE_INDICES is set to YES then doxygen will not1369# If LATEX_HIDE_INDICES is set to YES then doxygen will not
1370# include the index chapters (such as File Index, Compound Index, etc.)1370# include the index chapters (such as File Index, Compound Index, etc.)
1371# in the output.1371# in the output.
13721372
1373LATEX_HIDE_INDICES = NO1373LATEX_HIDE_INDICES = YES
13741374
1375# If LATEX_SOURCE_CODE is set to YES then doxygen will include1375# If LATEX_SOURCE_CODE is set to YES then doxygen will include
1376# source code with syntax highlighting in the LaTeX output.1376# source code with syntax highlighting in the LaTeX output.
1377# Note that which sources are shown also depends on other settings1377# Note that which sources are shown also depends on other settings
1378# such as SOURCE_BROWSER.1378# such as SOURCE_BROWSER.
13791379
1380LATEX_SOURCE_CODE = NO1380LATEX_SOURCE_CODE = YES
13811381
1382# The LATEX_BIB_STYLE tag can be used to specify the style to use for the1382# The LATEX_BIB_STYLE tag can be used to specify the style to use for the
1383# bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See1383# bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See
13841384
=== modified file 'include/ubuntu/application/CMakeLists.txt'
--- include/ubuntu/application/CMakeLists.txt 2013-07-18 09:08:17 +0000
+++ include/ubuntu/application/CMakeLists.txt 2013-07-30 05:35:33 +0000
@@ -14,5 +14,6 @@
14 DESTINATION include/ubuntu/application14 DESTINATION include/ubuntu/application
15)15)
1616
17add_subdirectory(location)
17add_subdirectory(sensors)18add_subdirectory(sensors)
18add_subdirectory(ui)19add_subdirectory(ui)
1920
=== added directory 'include/ubuntu/application/location'
=== added file 'include/ubuntu/application/location/CMakeLists.txt'
--- include/ubuntu/application/location/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ include/ubuntu/application/location/CMakeLists.txt 2013-07-30 05:35:33 +0000
@@ -0,0 +1,14 @@
1set(
2 UBUNTU_APPLICATION_SENSORS_HEADERS
3
4 heading_update.h
5 position_update.h
6 service.h
7 session.h
8 velocity_update.h
9)
10
11install(
12 FILES ${UBUNTU_APPLICATION_SENSORS_HEADERS}
13 DESTINATION include/ubuntu-${UBUNTU_PLATFORM_API_VERSION_MAJOR}/application/location
14)
0\ No newline at end of file15\ No newline at end of file
116
=== added file 'include/ubuntu/application/location/heading_update.h'
--- include/ubuntu/application/location/heading_update.h 1970-01-01 00:00:00 +0000
+++ include/ubuntu/application/location/heading_update.h 2013-07-30 05:35:33 +0000
@@ -0,0 +1,78 @@
1/*
2 * Copyright © 2013 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Thomas Voß <thomas.voss@canonical.com>
17 */
18
19#ifndef UBUNTU_APPLICATION_LOCATION_HEADING_UPDATE_H_
20#define UBUNTU_APPLICATION_LOCATION_HEADING_UPDATE_H_
21
22#include <stdbool.h>
23#include <stdint.h>
24
25#ifdef __cplusplus
26extern "C"
27{
28#endif
29
30 /**
31 * \brief Opaque type encapsulating a heading update.
32 * \ingroup location_service
33 */
34 typedef struct UbuntuApplicationLocationHeadingUpdate UALocationHeadingUpdate;
35
36 /**
37 * \brief Increments the reference count of the heading update instance.
38 * \ingroup location_service
39 * \param[in] update The heading update instance to increment the reference count for.
40 */
41 void
42 ua_location_heading_update_ref(
43 UALocationHeadingUpdate *update);
44
45 /**
46 * \brief Decrements the reference count of the heading update instance.
47 * \ingroup location_service
48 * \param[in] update The heading update instance to decrement the reference count for.
49 */
50 void
51 ua_location_heading_update_unref(
52 UALocationHeadingUpdate *update);
53
54 /**
55 * \brief Queries the timestamp of the heading update.
56 * \ingroup location_service
57 * \returns The timestamp of the heading update in [µs].
58 * \param[in] update The heading update instance to be queried.
59 */
60 uint64_t
61 ua_location_heading_update_get_timestamp(
62 UALocationHeadingUpdate *update);
63
64 /**
65 * \brief Queries the new heading from the update.
66 * \ingroup location_service
67 * \returns The new heading from the update in [°].
68 * \param[in] update The heading update instance to be queried.
69 */
70 double
71 ua_location_position_update_get_heading_in_degree(
72 UALocationHeadingUpdate *update);
73
74#ifdef __cplusplus
75}
76#endif
77
78#endif // UBUNTU_APPLICATION_LOCATION_HEADING_UPDATE_H_
079
=== added file 'include/ubuntu/application/location/position_update.h'
--- include/ubuntu/application/location/position_update.h 1970-01-01 00:00:00 +0000
+++ include/ubuntu/application/location/position_update.h 2013-07-30 05:35:33 +0000
@@ -0,0 +1,108 @@
1/*
2 * Copyright © 2013 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Thomas Voß <thomas.voss@canonical.com>
17 */
18
19#ifndef UBUNTU_APPLICATION_LOCATION_POSITION_UPDATE_H_
20#define UBUNTU_APPLICATION_LOCATION_POSITION_UPDATE_H_
21
22#include <stdbool.h>
23#include <stdint.h>
24
25#ifdef __cplusplus
26extern "C"
27{
28#endif
29
30 /**
31 * \brief Opaque type encapsulating a location update.
32 * \ingroup location_service
33 */
34 typedef struct UbuntuApplicationLocationPositionUpdate UALocationPositionUpdate;
35
36 /**
37 * \brief Increments the reference count of the position update instance.
38 * \ingroup location_service
39 * \param[in] update The position update instance to increment the reference count for.
40 */
41 void
42 ua_location_position_update_ref(
43 UALocationPositionUpdate *update);
44
45 /**
46 * \brief Decrements the reference count of the position update instance.
47 * \ingroup location_service
48 * \param[in] update The position update instance to decrement the reference count for.
49 */
50 void
51 ua_location_position_update_unref(
52 UALocationPositionUpdate *update);
53
54 /**
55 * \brief Queries the timestamp of the position update.
56 * \ingroup location_service
57 * \returns The timestamp of the position update in [µs].
58 * \param[in] update The position update instance to be queried.
59 */
60 uint64_t
61 ua_location_position_update_get_timestamp(
62 UALocationPositionUpdate *update);
63
64 /**
65 * \brief Queries the latitude contained in the position update.
66 * \ingroup location_service
67 * \returns The latitude of the position update in [°].
68 * \param[in] update The position update instance to be queried.
69 */
70 double
71 ua_location_position_update_get_latitude_in_degree(
72 UALocationPositionUpdate *update);
73
74 /**
75 * \brief Queries the longitude contained in the position update.
76 * \ingroup location_service
77 * \returns The longitude of the position update in [°].
78 * \param[in] update The position update instance to be queried.
79 */
80 double
81 ua_location_position_update_get_longitude_in_degree(
82 UALocationPositionUpdate *update);
83
84 /**
85 * \brief Checks if the position update contains an altitude.
86 * \ingroup location_service
87 * \returns TRUE if the update contains an altitude, else FALSE.
88 * \param[in] update The position update instance to be queried.
89 */
90 bool
91 ua_location_position_update_has_altitude(
92 UALocationPositionUpdate *update);
93
94 /**
95 * \brief Queries the altitude contained in the position update.
96 * \ingroup location_service
97 * \returns The altitude of the position update in [m].
98 * \param[in] update The position update instance to be queried.
99 */
100 double
101 ua_location_position_update_get_altitude_in_meter(
102 UALocationPositionUpdate *update);
103
104#ifdef __cplusplus
105}
106#endif
107
108#endif // UBUNTU_APPLICATION_LOCATION_POSITION_UPDATE_H_
0109
=== added file 'include/ubuntu/application/location/service.h'
--- include/ubuntu/application/location/service.h 1970-01-01 00:00:00 +0000
+++ include/ubuntu/application/location/service.h 2013-07-30 05:35:33 +0000
@@ -0,0 +1,94 @@
1/*
2 * Copyright © 2013 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Thomas Voß <thomas.voss@canonical.com>
17 */
18
19#ifndef UBUNTU_APPLICATION_LOCATION_SERVICE_H_
20#define UBUNTU_APPLICATION_LOCATION_SERVICE_H_
21
22#include "ubuntu/application/location/session.h"
23
24#ifdef __cplusplus
25extern "C"
26{
27#endif
28 /**
29 * \defgroup location_service Functions and types to provide location services to applications.
30 *
31 * Applications in Ubuntu do not access positioning hardware
32 * directly but instead rely on a system-wide location service to
33 * be provided with position, heading and velocity updates. An
34 * application that wants to receive position, heading or
35 * velocity updates needs to start a session with the location
36 * service and specify its requirements with the help
37 * UALocationServiceRequirementsFlags. After the session has been
38 * created, position, heading and velocity updates need to be
39 * started by the application for its session. The actual updates
40 * are delivered via callbacks. Please note that the location
41 * service caches updates as good as possible. That is, if an
42 * application is only interested in a single position fix, and a
43 * reasonable fix is already known to the service, the
44 * information is immediately delivered to the application when
45 * the respecitve updates are started.
46 *
47 */
48
49 /**
50 * \brief Application-specific requirements.
51 * \ingroup location_service
52 */
53 typedef enum
54 {
55 UA_LOCATION_SERVICE_REQUIRE_ALTITUDE = 1 << 0, /**< The application requires altitude updates. */
56 UA_LOCATION_SERVICE_REQUIRE_HEADING = 1 << 1, /**< The application requires heading updates. */
57 UA_LOCATION_SERVICE_REQUIRE_VELOCITY = 1 << 2 /**< The application requires velocity updates. */
58 } UbuntuApplicationLocationServiceRequirement;
59
60 typedef UbuntuApplicationLocationServiceRequirement UALocationServiceRequirement;
61
62 /**
63 * \brief Bitfield type for summarizing an application's requirements.
64 * \ingroup location_service
65 */
66 typedef unsigned int UALocationServiceRequirementsFlags;
67
68 /**
69 * \brief Creates a new session with the location service for low positional accuracy requirements.
70 * \returns A new session or NULL if the requirements cannot be
71 * satisfied or if the app lacks permissions to access the
72 * location service.
73 * \param[in] Bitfield describing the application's requirements.
74 */
75 UALocationServiceSession*
76 ua_location_service_create_session_for_low_accuracy(
77 UALocationServiceRequirementsFlags flags);
78
79 /**
80 * \brief Creates a new session with the location service for high positional accuracy requirements.
81 * \returns A new session or NULL if the requirements cannot be
82 * satisfied or if the app lacks permissions to access the
83 * location service.
84 * \param[in] Bitfield describing the application's requirements.
85 */
86 UALocationServiceSession*
87 ua_location_service_create_session_for_high_accuracy(
88 UALocationServiceRequirementsFlags flags);
89
90#ifdef __cplusplus
91}
92#endif
93
94#endif // UBUNTU_APPLICATION_LOCATION_SERVICE_H_
095
=== added file 'include/ubuntu/application/location/session.h'
--- include/ubuntu/application/location/session.h 1970-01-01 00:00:00 +0000
+++ include/ubuntu/application/location/session.h 2013-07-30 05:35:33 +0000
@@ -0,0 +1,169 @@
1/*
2 * Copyright © 2013 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Thomas Voß <thomas.voss@canonical.com>
17 */
18
19#ifndef UBUNTU_APPLICATION_LOCATION_SESSION_H_
20#define UBUNTU_APPLICATION_LOCATION_SESSION_H_
21
22#include "ubuntu/status.h"
23#include "ubuntu/application/location/heading_update.h"
24#include "ubuntu/application/location/position_update.h"
25#include "ubuntu/application/location/velocity_update.h"
26
27#ifdef __cplusplus
28extern "C"
29{
30#endif
31
32 /**
33 * \brief Opaque type encapsulating a session with the location service.
34 * \ingroup location_service
35 */
36 typedef struct UbuntuApplicationLocationServiceSession UALocationServiceSession;
37
38 /**
39 * \brief Callback type that is invoked for position updates.
40 * \ingroup location_service
41 */
42
43 typedef void (*UALocationServiceSessionPositionUpdatesHandler)(UALocationPositionUpdate *position);
44
45 /**
46 * \brief Callback type that is invoked for heading updates.
47 * \ingroup location_service
48 */
49 typedef void (*UALocationServiceSessionHeadingUpdatesHandler)(UALocationHeadingUpdate *heading);
50
51 /**
52 * \brief Callback type that is invoked for velocity updates.
53 * \ingroup location_service
54 */
55 typedef void (*UALocationServiceSessionVelocityUpdatesHandler)(UALocationVelocityUpdate *heading);
56
57 /**
58 * \brief Increments the reference count of the session instance.
59 * \ingroup location_service
60 * \param[in] session The session instance to increment the reference count for.
61 */
62 void
63 ua_location_service_session_ref(
64 UALocationServiceSession *session);
65
66 /**
67 * \brief Decrements the reference count of the session instance.
68 * \ingroup location_service
69 * \param[in] session The session instance to decrement the reference count for.
70 */
71 void
72 ua_location_service_session_unref(
73 UALocationServiceSession *session);
74
75 /**
76 * \brief Installs an app-specific position update handler for the session.
77 * \ingroup location_service
78 * \param[in] session The session instance to install the handler for.
79 * \param[in] handler The position update handler.
80 */
81 void
82 ua_location_service_session_set_position_updates_handler(
83 UALocationServiceSession *session,
84 UALocationServiceSessionPositionUpdatesHandler *handler);
85
86 /**
87 * \brief Installs an app-specific heading update handler for the session.
88 * \ingroup location_service
89 * \param[in] session The session instance to install the handler for.
90 * \param[in] handler The heading update handler.
91 */
92 void
93 ua_location_service_session_set_heading_updates_handler(
94 UALocationServiceSession *session,
95 UALocationServiceSessionHeadingUpdatesHandler *handler);
96
97 /**
98 * \brief Installs an app-specific velocity update handler for the session.
99 * \ingroup location_service
100 * \param[in] session The session instance to install the handler for.
101 * \param[in] handler The velocity update handler.
102 */
103 void
104 ua_location_service_session_set_velocity_updates_handler(
105 UALocationServiceSession *session,
106 UALocationServiceSessionVelocityUpdatesHandler *handler);
107
108 /**
109 * \brief Starts position updates for the supplied session.
110 * \ingroup location_service
111 * \returns U_STATUS_SUCCESS if the updates were successfully started on the service side, else U_STATUS_ERROR.
112 * \param[in] session The session instance to start position updates for.
113 */
114 UStatus
115 ua_location_service_session_start_position_updates(
116 UALocationServiceSession *session);
117
118 /**
119 * \brief Stops position updates for the supplied session.
120 * \ingroup location_service
121 * \param[in] session The session instance to stop position updates for.
122 */
123 void
124 ua_location_service_session_stop_position_updates(
125 UALocationServiceSession *session);
126
127 /**
128 * \brief Starts heading updates for the supplied session.
129 * \ingroup location_service
130 * \returns U_STATUS_SUCCESS if the updates were successfully started on the service side, else U_STATUS_ERROR.
131 * \param[in] session The session instance to start heading updates for.
132 */
133 UStatus
134 ua_location_service_session_start_heading_updates(
135 UALocationServiceSession *session);
136
137 /**
138 * \brief Stops heading updates for the supplied session.
139 * \ingroup location_service
140 * \param[in] session The session instance to stop heading updates for.
141 */
142 void
143 ua_location_service_session_stop_heading_updates(
144 UALocationServiceSession *session);
145
146 /**
147 * \brief Starts velocity updates for the supplied session.
148 * \ingroup location_service
149 * \returns U_STATUS_SUCCESS if the updates were successfully started on the service side, else U_STATUS_ERROR.
150 * \param[in] session The session instance to start velocity updates for.
151 */
152 UStatus
153 ua_location_service_session_start_velocity_updates(
154 UALocationServiceSession *session);
155
156 /**
157 * \brief Stops velocity updates for the supplied session.
158 * \ingroup location_service
159 * \param[in] session The session instance to stop velocity updates for.
160 */
161 void
162 ua_location_service_session_stop_velocity_updates(
163 UALocationServiceSession *session);
164
165#ifdef __cplusplus
166}
167#endif
168
169#endif // UBUNTU_APPLICATION_LOCATION_SESSION_H_
0170
=== added file 'include/ubuntu/application/location/velocity_update.h'
--- include/ubuntu/application/location/velocity_update.h 1970-01-01 00:00:00 +0000
+++ include/ubuntu/application/location/velocity_update.h 2013-07-30 05:35:33 +0000
@@ -0,0 +1,78 @@
1/*
2 * Copyright © 2013 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Thomas Voß <thomas.voss@canonical.com>
17 */
18
19#ifndef UBUNTU_APPLICATION_LOCATION_VELOCITY_UPDATE_H_
20#define UBUNTU_APPLICATION_LOCATION_VELOCITY_UPDATE_H_
21
22#include <stdbool.h>
23#include <stdint.h>
24
25#ifdef __cplusplus
26extern "C"
27{
28#endif
29
30 /**
31 * \brief Opaque type encapsulating a velocity update.
32 * \ingroup location_service
33 */
34 typedef struct UbuntuApplicationLocationVelocityUpdate UALocationVelocityUpdate;
35
36 /**
37 * \brief Increments the reference count of the velocity update instance.
38 * \ingroup location_service
39 * \param[in] update The velocity update instance to increment the reference count for.
40 */
41 void
42 ua_location_velocity_update_ref(
43 UALocationVelocityUpdate *update);
44
45 /**
46 * \brief Decrements the reference count of the velocity update instance.
47 * \ingroup location_service
48 * \param[in] update The velocity update instance to decrement the reference count for.
49 */
50 void
51 ua_location_velocity_update_unref(
52 UALocationVelocityUpdate *update);
53
54 /**
55 * \brief Queries the timestamp of the velocity update.
56 * \ingroup location_service
57 * \returns The timestamp of the position update in [µs].
58 * \param[in] update The velocity update instance to be queried.
59 */
60 uint64_t
61 ua_location_velocity_update_get_timestamp(
62 UALocationVelocityUpdate *update);
63
64 /**
65 * \brief Queries the velocity contained in the position update.
66 * \ingroup location_service
67 * \returns The velocity in the position update in [m/s].
68 * \param[in] update The velocity update instance to be queried.
69 */
70 double
71 ua_location_velocity_update_get_velocity_in_meters_per_second(
72 UALocationVelocityUpdate *update);
73
74#ifdef __cplusplus
75}
76#endif
77
78#endif // UBUNTU_APPLICATION_LOCATION_VELOCITY_UPDATE_H_
079
=== modified file 'src/CMakeLists.txt'
--- src/CMakeLists.txt 2013-06-17 23:37:58 +0000
+++ src/CMakeLists.txt 2013-07-30 05:35:33 +0000
@@ -2,18 +2,4 @@
2 ${CMAKE_CURRENT_SOURCE_DIR}2 ${CMAKE_CURRENT_SOURCE_DIR}
3)3)
44
5if(ENABLE_HYBRIS_IMPLEMENTATION)5add_subdirectory(ubuntu)
6 add_subdirectory(hybris/)
7endif()
8
9if(ENABLE_MIRSERVER_IMPLEMENTATION OR ENABLE_MIRCLIENT_IMPLEMENTATION)
10 add_subdirectory(mircommon/)
11endif()
12
13if(ENABLE_MIRSERVER_IMPLEMENTATION)
14 add_subdirectory(mirserver/)
15endif()
16
17if(ENABLE_MIRCLIENT_IMPLEMENTATION)
18 add_subdirectory(mirclient/)
19endif()
20\ No newline at end of file6\ No newline at end of file
217
=== removed directory 'src/hybris'
=== removed file 'src/hybris/CMakeLists.txt'
--- src/hybris/CMakeLists.txt 2013-06-20 12:37:44 +0000
+++ src/hybris/CMakeLists.txt 1970-01-01 00:00:00 +0000
@@ -1,53 +0,0 @@
1set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++0x")
2
3add_library(
4 ubuntu_application_api SHARED
5
6 ubuntu_application_api_hybris.cpp
7 ubuntu_application_sensors_hybris.cpp
8)
9
10add_library(
11 ubuntu_platform_hardware_api SHARED
12 ubuntu_platform_hardware_api.cpp
13)
14
15include_directories(
16 ${CMAKE_BINARY_DIR}/include
17)
18
19target_link_libraries(
20 ubuntu_application_api
21 hybris-common
22)
23
24target_link_libraries(
25 ubuntu_platform_hardware_api
26 hybris-common
27)
28
29set_target_properties(
30 ubuntu_application_api
31 PROPERTIES
32 VERSION ${UBUNTU_PLATFORM_API_VERSION_MAJOR}.${UBUNTU_PLATFORM_API_VERSION_MINOR}.${UBUNTU_PLATFORM_API_VERSION_PATCH}
33 SOVERSION ${UBUNTU_PLATFORM_API_VERSION_MAJOR}
34)
35
36set_target_properties(
37 ubuntu_platform_hardware_api
38 PROPERTIES
39 VERSION ${UBUNTU_PLATFORM_API_VERSION_MAJOR}.${UBUNTU_PLATFORM_API_VERSION_MINOR}.${UBUNTU_PLATFORM_API_VERSION_PATCH}
40 SOVERSION ${UBUNTU_PLATFORM_API_VERSION_MAJOR}
41)
42
43install(
44 TARGETS ubuntu_application_api
45 ${INSTALL_TARGETS_DEFAULT_ARGS}
46)
47
48install(
49 TARGETS ubuntu_platform_hardware_api
50 ${INSTALL_TARGETS_DEFAULT_ARGS}
51)
52
53add_subdirectory(tests/)
540
=== removed file 'src/hybris/bridge.h'
--- src/hybris/bridge.h 2013-07-05 10:30:08 +0000
+++ src/hybris/bridge.h 1970-01-01 00:00:00 +0000
@@ -1,202 +0,0 @@
1/*
2 * Copyright (C) 2012 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Thomas Voss <thomas.voss@canonical.com>
17 * Ricardo Mendoza <ricardo.mendoza@canonical.com>
18 */
19#ifndef BRIDGE_H_
20#define BRIDGE_H_
21
22#include <assert.h>
23#include <dlfcn.h>
24#include <stddef.h>
25
26#define HIDDEN_SYMBOL __attribute__ ((visibility ("hidden")))
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
32extern void *android_dlopen(const char *filename, int flag);
33extern void *android_dlsym(void *handle, const char *symbol);
34
35#ifdef __cplusplus
36}
37#endif
38
39namespace internal
40{
41
42struct HIDDEN_SYMBOL ToApplication
43{
44 static const char* path()
45 {
46 return "/system/lib/libubuntu_application_api.so";
47 }
48};
49
50struct HIDDEN_SYMBOL ToHardware
51{
52 static const char* path()
53 {
54 return "/system/lib/libubuntu_platform_hardware_api.so";
55 }
56};
57
58template<typename Scope = ToApplication>
59class HIDDEN_SYMBOL Bridge
60{
61 public:
62 static Bridge<Scope>& instance()
63 {
64 static Bridge<Scope> bridge;
65 return bridge;
66 }
67
68 void* resolve_symbol(const char* symbol) const
69 {
70 return android_dlsym(lib_handle, symbol);
71 }
72
73 protected:
74 Bridge() : lib_handle(android_dlopen(Scope::path(), RTLD_LAZY))
75 {
76 assert(lib_handle && "Error loading ubuntu_application_api");
77 }
78
79 ~Bridge()
80 {
81 // TODO android_dlclose(libcamera_handle);
82 }
83
84 void* lib_handle;
85};
86
87}
88
89#ifdef __cplusplus
90extern "C" {
91#endif
92
93/**********************************************************/
94/*********** Implementation starts here *******************/
95/**********************************************************/
96
97#define DLSYM(fptr, sym) if (*(fptr) == NULL) { *((void**)fptr) = (void *) internal::Bridge<>::instance().resolve_symbol(sym); }
98
99#define IMPLEMENT_FUNCTION0(return_type, symbol) \
100 return_type symbol() \
101 { \
102 static return_type (*f)() = NULL; \
103 DLSYM(&f, #symbol); \
104 return f();}
105
106#define IMPLEMENT_VOID_FUNCTION0(symbol) \
107 void symbol() \
108 { \
109 static void (*f)() = NULL; \
110 DLSYM(&f, #symbol); \
111 f();}
112
113#define IMPLEMENT_FUNCTION1(return_type, symbol, arg1) \
114 return_type symbol(arg1 _1) \
115 { \
116 static return_type (*f)(arg1) = NULL; \
117 DLSYM(&f, #symbol); \
118 return f(_1); }
119
120#define IMPLEMENT_SF_FUNCTION1(return_type, symbol, arg1) \
121 return_type symbol(arg1 _1) \
122 { \
123 static return_type (*f)(arg1) __attribute__((pcs("aapcs"))) = NULL; \
124 DLSYM(&f, #symbol); \
125 return f(_1); }
126
127
128#define IMPLEMENT_VOID_FUNCTION1(symbol, arg1) \
129 void symbol(arg1 _1) \
130 { \
131 static void (*f)(arg1) = NULL; \
132 DLSYM(&f, #symbol); \
133 f(_1); }
134
135#define IMPLEMENT_FUNCTION2(return_type, symbol, arg1, arg2) \
136 return_type symbol(arg1 _1, arg2 _2) \
137 { \
138 static return_type (*f)(arg1, arg2) = NULL; \
139 DLSYM(&f, #symbol); \
140 return f(_1, _2); }
141
142#define IMPLEMENT_VOID_FUNCTION2(symbol, arg1, arg2) \
143 void symbol(arg1 _1, arg2 _2) \
144 { \
145 static void (*f)(arg1, arg2) = NULL; \
146 DLSYM(&f, #symbol); \
147 f(_1, _2); }
148
149#define IMPLEMENT_FUNCTION3(return_type, symbol, arg1, arg2, arg3) \
150 return_type symbol(arg1 _1, arg2 _2, arg3 _3) \
151 { \
152 static return_type (*f)(arg1, arg2, arg3) = NULL; \
153 DLSYM(&f, #symbol); \
154 return f(_1, _2, _3); }
155
156#define IMPLEMENT_VOID_FUNCTION3(symbol, arg1, arg2, arg3) \
157 void symbol(arg1 _1, arg2 _2, arg3 _3) \
158 { \
159 static void (*f)(arg1, arg2, arg3) = NULL; \
160 DLSYM(&f, #symbol); \
161 f(_1, _2, _3); }
162
163#define IMPLEMENT_VOID_FUNCTION4(symbol, arg1, arg2, arg3, arg4) \
164 void symbol(arg1 _1, arg2 _2, arg3 _3, arg4 _4) \
165 { \
166 static void (*f)(arg1, arg2, arg3, arg4) = NULL; \
167 DLSYM(&f, #symbol); \
168 f(_1, _2, _3, _4); }
169
170#define IMPLEMENT_FUNCTION4(return_type, symbol, arg1, arg2, arg3, arg4) \
171 return_type symbol(arg1 _1, arg2 _2, arg3 _3, arg4 _4) \
172 { \
173 static return_type (*f)(arg1, arg2, arg3, arg4) = NULL; \
174 DLSYM(&f, #symbol); \
175 return f(_1, _2, _3, _4); }
176
177#define IMPLEMENT_FUNCTION6(return_type, symbol, arg1, arg2, arg3, arg4, arg5, arg6) \
178 return_type symbol(arg1 _1, arg2 _2, arg3 _3, arg4 _4, arg5 _5, arg6 _6) \
179 { \
180 static return_type (*f)(arg1, arg2, arg3, arg4, arg5, arg6) = NULL; \
181 DLSYM(&f, #symbol); \
182 return f(_1, _2, _3, _4, _5, _6); }
183
184#define IMPLEMENT_VOID_FUNCTION7(symbol, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \
185 void symbol(arg1 _1, arg2 _2, arg3 _3, arg4 _4, arg5 _5, arg6 _6, arg7 _7) \
186 { \
187 static void (*f)(arg1, arg2, arg3, arg4, arg5, arg6, arg7) = NULL; \
188 DLSYM(&f, #symbol); \
189 f(_1, _2, _3, _4, _5, _6, _7); }
190
191#define IMPLEMENT_VOID_FUNCTION8(symbol, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) \
192 void symbol(arg1 _1, arg2 _2, arg3 _3, arg4 _4, arg5 _5, arg6 _6, arg7 _7, arg8 _8) \
193 { \
194 static void (*f)(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) = NULL; \
195 DLSYM(&f, #symbol); \
196 f(_1, _2, _3, _4, _5, _6, _7, _8); }
197
198#ifdef __cplusplus
199}
200#endif
201
202#endif // BRIDGE_H_
2030
=== removed directory 'src/hybris/tests'
=== removed file 'src/hybris/tests/CMakeLists.txt'
--- src/hybris/tests/CMakeLists.txt 2013-06-20 12:37:44 +0000
+++ src/hybris/tests/CMakeLists.txt 1970-01-01 00:00:00 +0000
@@ -1,25 +0,0 @@
1set(SOURCES ubuntu_application_api_hybris.cpp)
2
3add_executable(test_android_ubuntu_app_api test_c_api.cpp)
4target_link_libraries(test_android_ubuntu_app_api ubuntu_application_api EGL GLESv2)
5
6add_executable(test_android_gps_api test_gps_api.cpp)
7target_link_libraries(test_android_gps_api ubuntu_platform_hardware_api)
8
9add_executable(test_android_ubuntu_app_api_multiple_surfaces test_multiple_surfaces_event_delivery.cpp)
10target_link_libraries(test_android_ubuntu_app_api_multiple_surfaces ubuntu_application_api EGL GLESv2)
11
12add_executable(test_android_sensors_api test_sensors_api.cpp)
13target_link_libraries(test_android_sensors_api ubuntu_application_api)
14
15add_executable(test_android_ubuntu_session_api test_session_c_api.cpp)
16target_link_libraries(test_android_ubuntu_session_api ubuntu_application_api)
17
18install(TARGETS
19 test_android_ubuntu_app_api
20 test_android_gps_api
21 test_android_ubuntu_app_api_multiple_surfaces
22 test_android_sensors_api
23 test_android_ubuntu_session_api
24 DESTINATION bin
25)
260
=== removed file 'src/hybris/tests/test_c_api.cpp'
--- src/hybris/tests/test_c_api.cpp 2013-05-21 22:14:40 +0000
+++ src/hybris/tests/test_c_api.cpp 1970-01-01 00:00:00 +0000
@@ -1,329 +0,0 @@
1/*
2 * Copyright © 2012 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Thomas Voß <thomas.voss@canonical.com>
17 */
18
19#include <ubuntu/application/ui/window.h>
20#include <ubuntu/application/ui/options.h>
21#include <ubuntu/application/ui/display.h>
22#include <ubuntu/application/ui/session.h>
23
24#include <EGL/egl.h>
25#include <GLES2/gl2.h>
26#include <GLES2/gl2ext.h>
27
28#include <cassert>
29#include <cstdio>
30#include <cstdlib>
31#include <cstring>
32
33struct View
34{
35 static const char* vertex_shader();
36 static const char* fragment_shader();
37
38 static GLuint load_shader(GLenum shaderType, const char* pSource);
39 static GLuint create_program(const char* pVertexSource, const char* pFragmentSource);
40
41 static const GLfloat* triangle()
42 {
43 static const GLfloat result[] =
44 {
45 -0.125f, -0.125f, 0.0f, 0.5f,
46 0.0f, 0.125f, 0.0f, 0.5f,
47 0.125f, -0.125f, 0.0f, 0.5f
48 };
49
50 return result;
51 }
52
53 static const GLfloat* color_triangle()
54 {
55 static const GLfloat result[] =
56 {
57 0.0f, 0.0f, 1.0f, 1.0f,
58 0.0f, 1.0f, 0.0f, 1.0f,
59 1.0f, 0.0f, 0.0f, 0.0f
60 };
61
62 return result;
63 }
64
65 View(UAUiWindow* surface);
66
67 void render();
68 void step();
69
70 UAUiWindow* surface;
71 EGLDisplay egl_display;
72 EGLSurface egl_surface;
73 EGLConfig egl_config;
74 EGLContext egl_context;
75
76 GLfloat rotation_angle;
77
78 GLuint gProgram;
79 GLuint gvPositionHandle, gvColorHandle;
80 GLuint rotation_uniform;
81 GLint num_vertex;
82 const GLfloat * vertex_data;
83 const GLfloat * color_data;
84};
85
86void on_new_event(void* ctx, const Event* ev)
87{
88}
89
90int main(int argc, char** argv)
91{
92 UApplicationOptions* options = u_application_options_new_from_cmd_line(argc, argv);
93
94 UApplicationDescription* desc = u_application_description_new();
95 UApplicationId* id = u_application_id_new_from_stringn("UbuntuApplicationCAPI", 21);
96 u_application_description_set_application_id(desc, id);
97 UApplicationInstance* instance = u_application_instance_new_from_description_with_options(desc, options);
98
99 UAUiSessionProperties* props = ua_ui_session_properties_new();
100 ua_ui_session_properties_set_type(props, U_USER_SESSION);
101
102 UAUiSession* ua_ui_session_new_with_properties(props);
103
104 UAUiDisplay* display = ua_ui_display_new_with_index(0);
105
106 printf("Display resolution: (x,y) = (%d,%d)\n",
107 ua_ui_display_query_horizontal_res(display),
108 ua_ui_display_query_vertical_res(display));
109
110 UAUiWindowProperties* wprops = ua_ui_window_properties_new_for_normal_window();
111 ua_ui_window_properties_set_titlen(wprops, "Window 1", 8);
112 ua_ui_window_properties_set_role(wprops, U_MAIN_ROLE);
113 ua_ui_window_properties_set_input_cb_and_ctx(wprops, on_new_event, NULL);
114
115 UAUiWindow* surface = ua_ui_window_new_for_application_with_properties(instance, wprops);
116
117 View view(surface);
118 while(true)
119 {
120 view.render();
121 view.step();
122 }
123}
124
125const char* View::vertex_shader()
126{
127 static const char shader[] =
128 "attribute vec4 vPosition;\n"
129 "attribute vec4 vColor;\n"
130 "uniform float angle;\n"
131 "varying vec4 colorinfo;\n"
132 "void main() {\n"
133 " mat3 rot_z = mat3( vec3( cos(angle), sin(angle), 0.0),\n"
134 " vec3(-sin(angle), cos(angle), 0.0),\n"
135 " vec3( 0.0, 0.0, 1.0));\n"
136 " gl_Position = vec4(rot_z * vPosition.xyz, 1.0);\n"
137 " colorinfo = vColor;\n"
138 "}\n";
139
140 return shader;
141}
142
143const char* View::fragment_shader()
144{
145 static const char shader[] =
146 "precision mediump float;\n"
147 "varying vec4 colorinfo;\n"
148 "void main() {\n"
149 " gl_FragColor = colorinfo;\n"
150 "}\n";
151
152 return shader;
153}
154
155GLuint View::load_shader(GLenum shaderType, const char* pSource) {
156 GLuint shader = glCreateShader(shaderType);
157 if (shader) {
158 glShaderSource(shader, 1, &pSource, NULL);
159 glCompileShader(shader);
160 GLint compiled = 0;
161 glGetShaderiv(shader, GL_COMPILE_STATUS, &compiled);
162 if (!compiled) {
163 GLint infoLen = 0;
164 glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLen);
165 if (infoLen) {
166 char* buf = (char*) malloc(infoLen);
167 if (buf) {
168 glGetShaderInfoLog(shader, infoLen, NULL, buf);
169 fprintf(stderr, "Could not compile shader %d:\n%s\n",
170 shaderType, buf);
171 free(buf);
172 }
173 glDeleteShader(shader);
174 shader = 0;
175 }
176 }
177 } else
178 {
179 printf("Error, during shader creation: %i\n", glGetError());
180 }
181 return shader;
182}
183
184GLuint View::create_program(const char* pVertexSource, const char* pFragmentSource) {
185 GLuint vertexShader = load_shader(GL_VERTEX_SHADER, pVertexSource);
186 if (!vertexShader) {
187 printf("vertex shader not compiled\n");
188 return 0;
189 }
190
191 GLuint pixelShader = load_shader(GL_FRAGMENT_SHADER, pFragmentSource);
192 if (!pixelShader) {
193 printf("frag shader not compiled\n");
194 return 0;
195 }
196
197 GLuint program = glCreateProgram();
198 if (program) {
199 glAttachShader(program, vertexShader);
200 glAttachShader(program, pixelShader);
201 glLinkProgram(program);
202 GLint linkStatus = GL_FALSE;
203 glGetProgramiv(program, GL_LINK_STATUS, &linkStatus);
204 if (linkStatus != GL_TRUE) {
205 GLint bufLength = 0;
206 glGetProgramiv(program, GL_INFO_LOG_LENGTH, &bufLength);
207 if (bufLength) {
208 char* buf = (char*) malloc(bufLength);
209 if (buf) {
210 glGetProgramInfoLog(program, bufLength, NULL, buf);
211 fprintf(stderr, "Could not link program:\n%s\n", buf);
212 free(buf);
213 }
214 }
215 glDeleteProgram(program);
216 program = 0;
217 }
218 }
219 return program;
220}
221
222View::View(UAUiWindow* surface)
223 : surface(surface),
224 rotation_angle(0.f),
225 num_vertex(3)
226{
227 // assert(eglBindAPI(EGL_OPENGL_ES_API) == EGL_TRUE);
228 egl_display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
229 assert(egl_display != EGL_NO_DISPLAY);
230 EGLint major, minor;
231 if (EGL_FALSE == eglInitialize(egl_display, &major, &minor))
232 {
233 printf("egl error: problem initializing.\n");
234 exit(1);
235 }
236
237 EGLint attribs[] =
238 {
239 EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
240 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
241 EGL_NONE
242 };
243 EGLint n;
244 if (EGL_FALSE == eglChooseConfig(
245 egl_display,
246 attribs,
247 &egl_config,
248 1,
249 &n))
250 {
251 printf("egl error: Cannot choose configuration.\n");
252 }
253
254 EGLint context_attribs[] =
255 {
256 EGL_CONTEXT_CLIENT_VERSION, 2,
257 EGL_NONE
258 };
259
260 egl_context = eglCreateContext(
261 egl_display,
262 egl_config,
263 EGL_NO_CONTEXT,
264 context_attribs);
265
266 assert(EGL_NO_CONTEXT != egl_context);
267
268 EGLNativeWindowType nativeWindow = ua_ui_window_get_native_type(surface);
269 egl_surface = eglCreateWindowSurface(egl_display, egl_config, nativeWindow, NULL);
270
271 eglMakeCurrent(
272 egl_display,
273 egl_surface,
274 egl_surface,
275 egl_context);
276
277 vertex_data = triangle();
278 color_data = color_triangle();
279
280 gProgram = create_program(vertex_shader(), fragment_shader());
281 if (!gProgram)
282 {
283 printf("error making program\n");
284 return;
285 }
286
287 gvPositionHandle = glGetAttribLocation(gProgram, "vPosition");
288 gvColorHandle = glGetAttribLocation(gProgram, "vColor");
289
290 rotation_uniform = glGetUniformLocation(gProgram, "angle");
291
292 return;
293}
294
295void View::render()
296{
297 glUseProgram(gProgram);
298
299 glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
300
301 glUniform1fv(rotation_uniform, 1, &rotation_angle);
302
303 glVertexAttribPointer(
304 gvColorHandle,
305 num_vertex,
306 GL_FLOAT,
307 GL_FALSE,
308 sizeof(GLfloat)*4, color_data);
309 glVertexAttribPointer(
310 gvPositionHandle,
311 num_vertex,
312 GL_FLOAT,
313 GL_FALSE,
314 0,
315 vertex_data);
316 glEnableVertexAttribArray(gvPositionHandle);
317 glEnableVertexAttribArray(gvColorHandle);
318
319 glDrawArrays(GL_TRIANGLE_STRIP, 0, num_vertex);
320 glDisableVertexAttribArray(gvPositionHandle);
321 glDisableVertexAttribArray(gvColorHandle);
322
323 eglSwapBuffers(egl_display, egl_surface);
324}
325
326void View::step()
327{
328 rotation_angle += 0.01;
329}
3300
=== removed file 'src/hybris/tests/test_gps_api.cpp'
--- src/hybris/tests/test_gps_api.cpp 2013-06-13 08:07:21 +0000
+++ src/hybris/tests/test_gps_api.cpp 1970-01-01 00:00:00 +0000
@@ -1,252 +0,0 @@
1/*
2 * Copyright © 2013 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Daniel d'Andrada <daniel.dandrada@canonical.com>
17 */
18#include <ubuntu/hardware/gps.h>
19
20#include <ctime>
21#include <signal.h>
22#include <stdio.h>
23#include <string.h>
24#include <unistd.h>
25
26namespace ubuntu
27{
28class GPSTest
29{
30 public:
31 GPSTest();
32 ~GPSTest();
33 bool init_and_start();
34 bool stop();
35 void inject_time();
36
37 UHardwareGps u_hardware_gps;
38};
39
40void gps_location_cb(UHardwareGpsLocation* location, void* context)
41{
42 printf("gps_location_cb() called.\n");
43}
44
45void gps_status_cb(uint16_t status, void* context)
46{
47 switch(status)
48 {
49 case U_HARDWARE_GPS_STATUS_NONE:
50 printf("status: None\n");
51 break;
52 case U_HARDWARE_GPS_STATUS_SESSION_BEGIN:
53 printf("status: Session Begin\n");
54 break;
55 case U_HARDWARE_GPS_STATUS_SESSION_END:
56 printf("status: Session End\n");
57 break;
58 case U_HARDWARE_GPS_STATUS_ENGINE_ON:
59 printf("status: Engine On\n");
60 break;
61 case U_HARDWARE_GPS_STATUS_ENGINE_OFF:
62 printf("status: Engine Off\n");
63 default:
64 break;
65 };
66}
67
68void gps_sb_status_cb(UHardwareGpsSvStatus* sv_info, void* context)
69{
70 printf("gps_sb_status_cb() called, listing %d space vehicles\n", sv_info->num_svs);
71}
72
73void gps_nmea_cb(int64_t timestamp, const char* nmea, int length, void* context)
74{
75 char str[length+1];
76 memcpy(str, nmea, length);
77 str[length] = 0;
78 printf("gps_nmea_cb() - %s\n", str);
79}
80
81void gps_set_cabapilities_cb(uint32_t capabilities, void* context)
82{
83 printf("gps_set_cabapilities_cb() -");
84
85 if (capabilities & U_HARDWARE_GPS_CAPABILITY_SCHEDULING)
86 printf(" scheduling");
87 if (capabilities & U_HARDWARE_GPS_CAPABILITY_MSB)
88 printf(" MSB");
89 if (capabilities & U_HARDWARE_GPS_CAPABILITY_MSA)
90 printf(" MSA");
91 if (capabilities & U_HARDWARE_GPS_CAPABILITY_SINGLE_SHOT)
92 printf(" 'single shot'");
93 if (capabilities & U_HARDWARE_GPS_CAPABILITY_ON_DEMAND_TIME)
94 printf(" 'on demand time'");
95
96 printf("\n");
97}
98
99void gps_request_utc_time_cb(void* context)
100{
101 printf("gps_request_utc_time_cb() called.\n");
102 ((GPSTest*)context)->inject_time();
103}
104
105void gps_xtra_download_request_cb(void* context)
106{
107 printf("gps_xtra_download_request_cb() called.\n");
108}
109
110void agps_status_cb(UHardwareGpsAGpsStatus* status, void* context)
111{
112 printf("agps status -");
113
114 if (status->type == U_HARDWARE_GPS_AGPS_TYPE_SUPL)
115 printf(" SUPL");
116 else
117 printf(" C2K");
118
119 switch (status->status)
120 {
121 case U_HARDWARE_GPS_REQUEST_AGPS_DATA_CONN:
122 printf(", request AGPS data connection");
123 break;
124 case U_HARDWARE_GPS_RELEASE_AGPS_DATA_CONN:
125 printf(", release AGPS data connection");
126 break;
127 case U_HARDWARE_GPS_AGPS_DATA_CONNECTED:
128 printf(", request AGPS data connected");
129 break;
130 case U_HARDWARE_GPS_AGPS_DATA_CONN_DONE:
131 printf(", AGPS data connection done");
132 break;
133 default:
134 case U_HARDWARE_GPS_AGPS_DATA_CONN_FAILED:
135 printf(", AGPS data connection failed");
136 break;
137 }
138
139 printf(" ipaddr=%u\n", status->ipaddr);
140}
141
142void gps_notify_cb(UHardwareGpsNiNotification *notification, void* context)
143{
144 printf("gps_notify_cb() called.\n");
145}
146
147void agps_ril_request_set_id_cb(uint32_t flags, void* context)
148{
149 printf("agps_ril_request_set_id_cb() called.\n");
150}
151
152void agps_ril_request_refloc_cb(uint32_t flags, void* context)
153{
154 printf("agps_ril_request_refloc_cb() called.\n");
155}
156
157GPSTest::GPSTest()
158 : u_hardware_gps(NULL)
159{
160}
161
162GPSTest::~GPSTest()
163{
164 if (u_hardware_gps)
165 u_hardware_gps_delete(u_hardware_gps);
166}
167
168void GPSTest::inject_time()
169{
170 // A real implementation would inject time from some NTP server.
171 time_t t = time(0);
172 int64_t time_millis = (int64_t)t * (int64_t)1000;
173 u_hardware_gps_inject_time(u_hardware_gps,
174 time_millis /*NTP time would go here*/,
175 time_millis /*internal time when that NTP time was taken*/,
176 10 /* possible deviation, in milliseconds*/);
177}
178
179bool GPSTest::init_and_start()
180{
181 UHardwareGpsParams gps_params;
182
183 gps_params.location_cb = gps_location_cb;
184 gps_params.status_cb = gps_status_cb;
185 gps_params.sv_status_cb = gps_sb_status_cb;
186 gps_params.nmea_cb = gps_nmea_cb;
187 gps_params.set_capabilities_cb = gps_set_cabapilities_cb;
188 gps_params.request_utc_time_cb = gps_request_utc_time_cb;
189 gps_params.xtra_download_request_cb = gps_xtra_download_request_cb;
190 gps_params.agps_status_cb = agps_status_cb;
191 gps_params.gps_ni_notify_cb = gps_notify_cb;
192 gps_params.request_setid_cb = agps_ril_request_set_id_cb;
193 gps_params.request_refloc_cb = agps_ril_request_refloc_cb;
194 gps_params.context = this;
195
196 UHardwareGps u_hardware_gps = u_hardware_gps_new(&gps_params);
197 if (!u_hardware_gps)
198 {
199 printf("GPS creation failed!\n");
200 return false;
201 }
202
203 bool ok = u_hardware_gps_start(u_hardware_gps);
204 if (!ok)
205 {
206 printf("GPS start up failed!\n");
207 return false;
208 }
209
210 return true;
211}
212
213bool GPSTest::stop()
214{
215 bool ok = u_hardware_gps_stop(u_hardware_gps);
216 if (!ok)
217 printf("failed when stopping GPS!\n");
218
219 return ok;
220}
221}
222
223void wait_for_sigint()
224{
225 sigset_t signals;
226 sigemptyset(&signals);
227 sigaddset(&signals, SIGINT);
228
229 int sig;
230 int result = sigwait(&signals, &sig);
231 if (result != 0)
232 printf("sigwait failed!\n");
233}
234
235int main(int argc, char** argv)
236{
237 int return_value = 0;
238 ubuntu::GPSTest test;
239
240 if (!test.init_and_start())
241 return 1;
242
243 printf("GPS initialized and started. Now waiting for callbacks or SIGINT (to quit).\n");
244 wait_for_sigint();
245 printf("Exiting...\n");
246
247 if (!test.stop())
248 return 1;
249
250 printf("GPS stopped.\n");
251 return 0;
252}
2530
=== removed file 'src/hybris/tests/test_multiple_surfaces_event_delivery.cpp'
--- src/hybris/tests/test_multiple_surfaces_event_delivery.cpp 2013-05-21 22:14:40 +0000
+++ src/hybris/tests/test_multiple_surfaces_event_delivery.cpp 1970-01-01 00:00:00 +0000
@@ -1,351 +0,0 @@
1/*
2 * Copyright © 2012 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Thomas Voß <thomas.voss@canonical.com>
17 */
18
19#include <ubuntu/application/ui/window.h>
20#include <ubuntu/application/ui/options.h>
21#include <ubuntu/application/ui/display.h>
22#include <ubuntu/application/ui/session.h>
23
24#include <EGL/egl.h>
25#include <GLES2/gl2.h>
26#include <GLES2/gl2ext.h>
27
28#include <cassert>
29#include <cstdio>
30#include <cstdlib>
31#include <cstring>
32
33struct View
34{
35 static const char* vertex_shader();
36 static const char* fragment_shader();
37
38 static GLuint load_shader(GLenum shaderType, const char* pSource);
39 static GLuint create_program(const char* pVertexSource, const char* pFragmentSource);
40
41 static const GLfloat* triangle()
42 {
43 static const GLfloat result[] =
44 {
45 -0.125f, -0.125f, 0.0f, 0.5f,
46 0.0f, 0.125f, 0.0f, 0.5f,
47 0.125f, -0.125f, 0.0f, 0.5f
48 };
49
50 return result;
51 }
52
53 static const GLfloat* color_triangle()
54 {
55 static const GLfloat result[] =
56 {
57 0.0f, 0.0f, 1.0f, 1.0f,
58 0.0f, 1.0f, 0.0f, 1.0f,
59 1.0f, 0.0f, 0.0f, 0.0f
60 };
61
62 return result;
63 }
64
65 View(UAUiWindow* surface);
66
67 void render();
68 void step();
69
70 UAUiWindow* surface;
71 EGLDisplay egl_display;
72 EGLSurface egl_surface;
73 EGLConfig egl_config;
74 EGLContext egl_context;
75
76 GLfloat rotation_angle;
77
78 GLuint gProgram;
79 GLuint gvPositionHandle, gvColorHandle;
80 GLuint rotation_uniform;
81 GLint num_vertex;
82 const GLfloat * vertex_data;
83 const GLfloat * color_data;
84};
85
86void on_new_event(void* ctx, const Event* ev)
87{
88 int* surface = (int*) ctx;
89
90 printf("%s for surface: %d \n", __PRETTY_FUNCTION__, *surface);
91}
92
93int main(int argc, char** argv)
94{
95 UApplicationOptions* options = u_application_options_new_from_cmd_line(argc, argv);
96
97 UApplicationDescription* desc = u_application_description_new();
98 UApplicationId* id = u_application_id_new_from_stringn("UbuntuApplicationCAPI", 21);
99 u_application_description_set_application_id(desc, id);
100 UApplicationInstance* instance = u_application_instance_new_from_description_with_options(desc, options);
101
102 UAUiSessionProperties* props = ua_ui_session_properties_new();
103 ua_ui_session_properties_set_type(props, U_USER_SESSION);
104
105 UAUiSession* ua_ui_session_new_with_properties(props);
106
107 UAUiDisplay* display = ua_ui_display_new_with_index(0);
108
109 printf("Display resolution: (x,y) = (%d,%d)\n",
110 ua_ui_display_query_horizontal_res(display),
111 ua_ui_display_query_vertical_res(display));
112
113 int i = 1, j = 2;
114
115 UAUiWindowProperties* wprops1 = ua_ui_window_properties_new_for_normal_window();
116 ua_ui_window_properties_set_titlen(wprops1, "Window 1", 8);
117 ua_ui_window_properties_set_role(wprops1, U_MAIN_ROLE);
118 ua_ui_window_properties_set_input_cb_and_ctx(wprops1, on_new_event, &i);
119
120 UAUiWindow* surface1 = ua_ui_window_new_for_application_with_properties(instance, wprops1);
121
122 UAUiWindowProperties* wprops2 = ua_ui_window_properties_new_for_normal_window();
123 ua_ui_window_properties_set_titlen(wprops2, "Window 2", 8);
124 ua_ui_window_properties_set_role(wprops2, U_MAIN_ROLE);
125 ua_ui_window_properties_set_input_cb_and_ctx(wprops2, on_new_event, &j);
126
127 UAUiWindow* surface2 = ua_ui_window_new_for_application_with_properties(instance, wprops2);
128
129 View view1(surface1);
130 View view2(surface2);
131 while(true)
132 {
133 view1.render();
134 view2.render();
135
136 view1.step();
137 view2.step();
138 }
139}
140
141const char* View::vertex_shader()
142{
143 static const char shader[] =
144 "attribute vec4 vPosition;\n"
145 "attribute vec4 vColor;\n"
146 "uniform float angle;\n"
147 "varying vec4 colorinfo;\n"
148 "void main() {\n"
149 " mat3 rot_z = mat3( vec3( cos(angle), sin(angle), 0.0),\n"
150 " vec3(-sin(angle), cos(angle), 0.0),\n"
151 " vec3( 0.0, 0.0, 1.0));\n"
152 " gl_Position = vec4(rot_z * vPosition.xyz, 1.0);\n"
153 " colorinfo = vColor;\n"
154 "}\n";
155
156 return shader;
157}
158
159const char* View::fragment_shader()
160{
161 static const char shader[] =
162 "precision mediump float;\n"
163 "varying vec4 colorinfo;\n"
164 "void main() {\n"
165 " gl_FragColor = colorinfo;\n"
166 "}\n";
167
168 return shader;
169}
170
171GLuint View::load_shader(GLenum shaderType, const char* pSource) {
172 GLuint shader = glCreateShader(shaderType);
173 if (shader) {
174 glShaderSource(shader, 1, &pSource, NULL);
175 glCompileShader(shader);
176 GLint compiled = 0;
177 glGetShaderiv(shader, GL_COMPILE_STATUS, &compiled);
178 if (!compiled) {
179 GLint infoLen = 0;
180 glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLen);
181 if (infoLen) {
182 char* buf = (char*) malloc(infoLen);
183 if (buf) {
184 glGetShaderInfoLog(shader, infoLen, NULL, buf);
185 fprintf(stderr, "Could not compile shader %d:\n%s\n",
186 shaderType, buf);
187 free(buf);
188 }
189 glDeleteShader(shader);
190 shader = 0;
191 }
192 }
193 } else
194 {
195 printf("Error, during shader creation: %i\n", glGetError());
196 }
197 return shader;
198}
199
200GLuint View::create_program(const char* pVertexSource, const char* pFragmentSource) {
201 GLuint vertexShader = load_shader(GL_VERTEX_SHADER, pVertexSource);
202 if (!vertexShader) {
203 printf("vertex shader not compiled\n");
204 return 0;
205 }
206
207 GLuint pixelShader = load_shader(GL_FRAGMENT_SHADER, pFragmentSource);
208 if (!pixelShader) {
209 printf("frag shader not compiled\n");
210 return 0;
211 }
212
213 GLuint program = glCreateProgram();
214 if (program) {
215 glAttachShader(program, vertexShader);
216 glAttachShader(program, pixelShader);
217 glLinkProgram(program);
218 GLint linkStatus = GL_FALSE;
219 glGetProgramiv(program, GL_LINK_STATUS, &linkStatus);
220 if (linkStatus != GL_TRUE) {
221 GLint bufLength = 0;
222 glGetProgramiv(program, GL_INFO_LOG_LENGTH, &bufLength);
223 if (bufLength) {
224 char* buf = (char*) malloc(bufLength);
225 if (buf) {
226 glGetProgramInfoLog(program, bufLength, NULL, buf);
227 fprintf(stderr, "Could not link program:\n%s\n", buf);
228 free(buf);
229 }
230 }
231 glDeleteProgram(program);
232 program = 0;
233 }
234 }
235 return program;
236}
237
238View::View(UAUiWindow* surface)
239 : surface(surface),
240 rotation_angle(0.f),
241 num_vertex(3)
242{
243 // assert(eglBindAPI(EGL_OPENGL_ES_API) == EGL_TRUE);
244 egl_display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
245 assert(egl_display != EGL_NO_DISPLAY);
246 EGLint major, minor;
247 if (EGL_FALSE == eglInitialize(egl_display, &major, &minor))
248 {
249 printf("egl error: problem initializing.\n");
250 exit(1);
251 }
252
253 EGLint attribs[] =
254 {
255 EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
256 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
257 EGL_NONE
258 };
259 EGLint n;
260 if (EGL_FALSE == eglChooseConfig(
261 egl_display,
262 attribs,
263 &egl_config,
264 1,
265 &n))
266 {
267 printf("egl error: Cannot choose configuration.\n");
268 }
269
270 EGLint context_attribs[] =
271 {
272 EGL_CONTEXT_CLIENT_VERSION, 2,
273 EGL_NONE
274 };
275
276 egl_context = eglCreateContext(
277 egl_display,
278 egl_config,
279 EGL_NO_CONTEXT,
280 context_attribs);
281
282 assert(EGL_NO_CONTEXT != egl_context);
283
284 EGLNativeWindowType nativeWindow = ua_ui_window_get_native_type(surface);
285 egl_surface = eglCreateWindowSurface(egl_display, egl_config, nativeWindow, NULL);
286
287 eglMakeCurrent(
288 egl_display,
289 egl_surface,
290 egl_surface,
291 egl_context);
292
293 vertex_data = triangle();
294 color_data = color_triangle();
295
296 gProgram = create_program(vertex_shader(), fragment_shader());
297 if (!gProgram)
298 {
299 printf("error making program\n");
300 return;
301 }
302
303 gvPositionHandle = glGetAttribLocation(gProgram, "vPosition");
304 gvColorHandle = glGetAttribLocation(gProgram, "vColor");
305
306 rotation_uniform = glGetUniformLocation(gProgram, "angle");
307
308 return;
309}
310
311void View::render()
312{
313 eglMakeCurrent(
314 egl_display,
315 egl_surface,
316 egl_surface,
317 egl_context);
318
319 glUseProgram(gProgram);
320
321 glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
322
323 glUniform1fv(rotation_uniform, 1, &rotation_angle);
324
325 glVertexAttribPointer(
326 gvColorHandle,
327 num_vertex,
328 GL_FLOAT,
329 GL_FALSE,
330 sizeof(GLfloat)*4, color_data);
331 glVertexAttribPointer(
332 gvPositionHandle,
333 num_vertex,
334 GL_FLOAT,
335 GL_FALSE,
336 0,
337 vertex_data);
338 glEnableVertexAttribArray(gvPositionHandle);
339 glEnableVertexAttribArray(gvColorHandle);
340
341 glDrawArrays(GL_TRIANGLE_STRIP, 0, num_vertex);
342 glDisableVertexAttribArray(gvPositionHandle);
343 glDisableVertexAttribArray(gvColorHandle);
344
345 eglSwapBuffers(egl_display, egl_surface);
346}
347
348void View::step()
349{
350 rotation_angle += 0.01;
351}
3520
=== removed file 'src/hybris/tests/test_sensors_api.cpp'
--- src/hybris/tests/test_sensors_api.cpp 2013-05-30 02:03:42 +0000
+++ src/hybris/tests/test_sensors_api.cpp 1970-01-01 00:00:00 +0000
@@ -1,88 +0,0 @@
1/*
2 * Copyright © 2012 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Ricardo Mendoza <ricardo.mendoza@canonical.com>
17 */
18
19#include <stdint.h>
20#include <stdio.h>
21#include <string.h>
22
23#include <ubuntu/application/sensors/accelerometer.h>
24#include <ubuntu/application/sensors/proximity.h>
25#include <ubuntu/application/sensors/light.h>
26
27void on_new_accelerometer_event(UASAccelerometerEvent* event, void* context)
28{
29 printf("%s \n", __PRETTY_FUNCTION__);
30 printf("\ttime: %llu\n", uas_accelerometer_event_get_timestamp(event));
31 printf("\tx: %f\n", uas_accelerometer_event_get_acceleration_x(event));
32 printf("\ty: %f\n", uas_accelerometer_event_get_acceleration_y(event));
33 printf("\tz: %f\n", uas_accelerometer_event_get_acceleration_z(event));
34}
35
36void on_new_proximity_event(UASProximityEvent* event, void* context)
37{
38 printf("%s \n", __PRETTY_FUNCTION__);
39 printf("\ttime: %llu\n", uas_proximity_event_get_timestamp(event));
40
41 switch (uas_proximity_event_get_distance(event))
42 {
43 case U_PROXIMITY_NEAR:
44 {
45 printf("\tdistance: NEAR\n");
46 break;
47 }
48 case U_PROXIMITY_FAR:
49 {
50 printf("\tdistance: FAR\n");
51 break;
52 }
53 }
54}
55
56void on_new_light_event(UASLightEvent* event, void* context)
57{
58 printf("%s \n", __PRETTY_FUNCTION__);
59 printf("\ttime: %llu\n", uas_light_event_get_timestamp(event));
60 printf("\tlight: %f\n", uas_light_event_get_light(event));
61}
62
63int main(int argc, char** argv)
64{
65 UASensorsAccelerometer* accelerometer = ua_sensors_accelerometer_new();
66 UASensorsProximity* proximity = ua_sensors_proximity_new();
67 UASensorsLight* ambientlight = ua_sensors_light_new();
68
69 ua_sensors_accelerometer_set_reading_cb(accelerometer,
70 on_new_accelerometer_event,
71 NULL);
72
73 ua_sensors_proximity_set_reading_cb(proximity,
74 on_new_proximity_event,
75 NULL);
76
77 ua_sensors_light_set_reading_cb(ambientlight,
78 on_new_light_event,
79 NULL);
80
81 ua_sensors_accelerometer_enable(accelerometer);
82 ua_sensors_proximity_enable(proximity);
83 ua_sensors_light_enable(ambientlight);
84
85 while(true)
86 {
87 }
88}
890
=== removed file 'src/hybris/tests/test_session_c_api.cpp'
--- src/hybris/tests/test_session_c_api.cpp 2013-02-13 23:09:01 +0000
+++ src/hybris/tests/test_session_c_api.cpp 1970-01-01 00:00:00 +0000
@@ -1,229 +0,0 @@
1/*
2 * Copyright © 2012 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Thomas Voß <thomas.voss@canonical.com>
17 */
18
19#include <ubuntu/ui/ubuntu_ui_session_service.h>
20
21#include <getopt.h>
22
23#include <stdio.h>
24#include <stdint.h>
25#include <string.h>
26#include <time.h>
27
28typedef union
29{
30 struct Components
31 {
32 uint8_t r;
33 uint8_t g;
34 uint8_t b;
35 uint8_t a;
36 } components;
37 uint32_t value;
38} Pixel;
39
40struct Config
41{
42 Config() : take_screencast_flag(0),
43 take_screenshot_flag(0)
44 {
45 }
46
47 int take_screencast_flag;
48 int take_screenshot_flag;
49};
50
51void on_snapshot_completed(const void* pixel_data, unsigned int width, unsigned int height, unsigned int x, unsigned int y, unsigned int source_width, unsigned int source_height, unsigned int stride, void* context)
52{
53 static unsigned int counter = 0;
54
55 printf("%s: (%p, %d, %d, %d) \n",
56 __PRETTY_FUNCTION__,
57 pixel_data,
58 width,
59 height,
60 stride);
61
62 static const char snapshot_pattern[] = "./snapshot_%I_%M_%S.ppm";
63 static const char frame_pattern[] = "./frame_%I_%M_%S.raw";
64
65 char fn[256];
66
67 int take_screenshot = 1;
68 int take_screencast = 0;
69
70 if (context != NULL)
71 {
72 Config* config = (Config*) context;
73
74 take_screenshot = config->take_screenshot_flag;
75 take_screencast = config->take_screencast_flag;
76 }
77
78 time_t curtime;
79 struct tm *loctime;
80
81 curtime = time (NULL);
82 loctime = localtime (&curtime);
83
84 static const char screenshot_file_mode[] = "w+";
85 static const char screencast_file_mode[] = "wb+";
86
87 FILE* f = NULL;
88 if (take_screenshot)
89 {
90 strftime(fn, 256, snapshot_pattern, loctime);
91 f = fopen(fn, screenshot_file_mode);
92 } else if (take_screencast)
93 {
94 strftime(fn, 256, frame_pattern, loctime);
95 f = fopen(fn, screencast_file_mode);
96 }
97
98 if (!f)
99 {
100 printf("Problem opening file: %s \n", fn);
101 return;
102 }
103
104 if (take_screenshot)
105 {
106 const unsigned int* p = static_cast<const unsigned int*>(pixel_data);
107
108 fprintf(f, "P3\n%d %d\n%d\n\n", width, height, 255);
109 for(unsigned int i = 0; i < height; i++)
110 {
111 for(unsigned int j = 0; j < width; j++)
112 {
113 Pixel pixel; pixel.value = *p; ++p;
114 fprintf(
115 f, "%d %d %d\t",
116 pixel.components.r,
117 pixel.components.g,
118 pixel.components.b);
119 }
120 }
121 }
122 else if (take_screencast)
123 {
124 fwrite(pixel_data, sizeof(unsigned int), width*height, f);
125 ubuntu_ui_session_snapshot_running_session_with_id(
126 -1,
127 on_snapshot_completed,
128 context);
129 }
130}
131
132void on_session_born(ubuntu_ui_session_properties props, void*)
133{
134 printf("%s:\n\t Id: %d \n\t Desktop file hint: %s \n",
135 __PRETTY_FUNCTION__,
136 ubuntu_ui_session_properties_get_application_instance_id(props),
137 ubuntu_ui_session_properties_get_desktop_file_hint(props));
138
139 ubuntu_ui_session_snapshot_running_session_with_id(
140 ubuntu_ui_session_properties_get_application_instance_id(props),
141 on_snapshot_completed,
142 NULL);
143}
144
145void on_session_focused(ubuntu_ui_session_properties props, void*)
146{
147 printf("%s:\n\t Id: %d \n\t Desktop file hint: %s \n",
148 __PRETTY_FUNCTION__,
149 ubuntu_ui_session_properties_get_application_instance_id(props),
150 ubuntu_ui_session_properties_get_desktop_file_hint(props));
151}
152
153void on_session_died(ubuntu_ui_session_properties props, void*)
154{
155 printf("%s:\n\t Id: %d \n\t Desktop file hint: %s \n",
156 __PRETTY_FUNCTION__,
157 ubuntu_ui_session_properties_get_application_instance_id(props),
158 ubuntu_ui_session_properties_get_desktop_file_hint(props));
159}
160
161
162
163Config parse_cmd_line(int argc, char** argv)
164{
165 Config config;
166 static struct option long_options[] = {
167 {"take-screencast", no_argument, &config.take_screencast_flag, 1},
168 {"take-screenshot", no_argument, &config.take_screenshot_flag, 1}
169 };
170
171 while (true)
172 {
173 int option_index = 0;
174
175 int c = getopt_long(
176 argc,
177 argv,
178 "",
179 long_options,
180 &option_index);
181
182 if (c == -1)
183 break;
184
185 switch (c)
186 {
187 case 0:
188 // No need to do anything here: Flag is set automatically.
189 break;
190 default:
191 break;
192 }
193 }
194
195 return config;
196}
197
198int main(int argc, char** argv)
199{
200 static const int complete_session_id = -1;
201
202 Config config = parse_cmd_line(argc, argv);
203
204 if (config.take_screenshot_flag || config.take_screencast_flag)
205 {
206 ubuntu_ui_session_snapshot_running_session_with_id(
207 complete_session_id,
208 on_snapshot_completed,
209 &config);
210
211 return 0;
212 }
213
214 ubuntu_ui_session_lifecycle_observer observer;
215
216 memset(&observer, 0, sizeof(observer));
217 observer.on_session_born = on_session_born;
218 observer.on_session_focused = on_session_focused;
219 observer.on_session_died = on_session_died;
220
221 ubuntu_ui_session_install_session_lifecycle_observer(&observer);
222
223 while(true)
224 {
225 }
226
227 return 0;
228}
229
2300
=== removed file 'src/hybris/ubuntu_application_api_hybris.cpp'
--- src/hybris/ubuntu_application_api_hybris.cpp 2013-06-20 12:37:44 +0000
+++ src/hybris/ubuntu_application_api_hybris.cpp 1970-01-01 00:00:00 +0000
@@ -1,130 +0,0 @@
1/*
2 * Copyright (C) 2012 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Thomas Voss <thomas.voss@canonical.com>
17 * Ricardo Mendoza <ricardo.mendoza@canonical.com>
18 */
19
20#include <private/application/ui/ubuntu_application_ui.h>
21
22#include <ubuntu/ui/ubuntu_ui_session_service.h>
23
24// C APIs
25#include <ubuntu/application/lifecycle_delegate.h>
26#include <ubuntu/application/ui/window.h>
27#include <ubuntu/application/ui/options.h>
28#include <ubuntu/application/ui/session.h>
29#include <ubuntu/application/ui/clipboard.h>
30#include <ubuntu/application/ui/display.h>
31
32#include "bridge.h"
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
38// Session helpers
39IMPLEMENT_FUNCTION0(UAUiSessionProperties*, ua_ui_session_properties_new);
40IMPLEMENT_VOID_FUNCTION2(ua_ui_session_properties_set_type, UAUiSessionProperties*, UAUiSessionType);
41IMPLEMENT_VOID_FUNCTION2(ua_ui_session_properties_set_remote_pid, UAUiSessionProperties*, uint32_t);
42IMPLEMENT_FUNCTION1(UAUiSession*, ua_ui_session_new_with_properties, UAUiSessionProperties*);
43
44// Lifecycle helpers
45IMPLEMENT_FUNCTION0(UApplicationLifecycleDelegate*, u_application_lifecycle_delegate_new);
46IMPLEMENT_VOID_FUNCTION2(u_application_lifecycle_delegate_set_context, UApplicationLifecycleDelegate*, void*);
47IMPLEMENT_VOID_FUNCTION1(u_application_lifecycle_delegate_ref, UApplicationLifecycleDelegate*);
48IMPLEMENT_VOID_FUNCTION1(u_application_lifecycle_delegate_unref, UApplicationLifecycleDelegate*);
49IMPLEMENT_VOID_FUNCTION2(u_application_lifecycle_delegate_set_application_resumed_cb, UApplicationLifecycleDelegate*, u_on_application_resumed);
50IMPLEMENT_VOID_FUNCTION2(u_application_lifecycle_delegate_set_application_about_to_stop_cb, UApplicationLifecycleDelegate*, u_on_application_about_to_stop);
51
52// Application Helpers
53
54// UApplicationId
55IMPLEMENT_FUNCTION2(UApplicationId*, u_application_id_new_from_stringn, const char*, size_t);
56IMPLEMENT_VOID_FUNCTION1(u_application_id_destroy, UApplicationId*);
57IMPLEMENT_FUNCTION2(int, u_application_id_compare, UApplicationId*, UApplicationId*);
58
59// UApplicationDescription
60IMPLEMENT_FUNCTION0(UApplicationDescription*, u_application_description_new);
61IMPLEMENT_VOID_FUNCTION1(u_application_description_destroy, UApplicationDescription*);
62IMPLEMENT_VOID_FUNCTION2(u_application_description_set_application_id, UApplicationDescription*, UApplicationId*);
63IMPLEMENT_VOID_FUNCTION2(u_application_description_set_application_lifecycle_delegate, UApplicationDescription*, UApplicationLifecycleDelegate*);
64
65// UApplicationOptions
66IMPLEMENT_FUNCTION2(UApplicationOptions*, u_application_options_new_from_cmd_line, int, char**);
67IMPLEMENT_VOID_FUNCTION1(u_application_options_destroy, UApplicationOptions*);
68IMPLEMENT_FUNCTION1(UAUiFormFactor, u_application_options_get_form_factor, UApplicationOptions*);
69IMPLEMENT_FUNCTION1(UAUiStage, u_application_options_get_stage, UApplicationOptions*);
70
71// UApplicationInstance
72IMPLEMENT_FUNCTION2(UApplicationInstance*, u_application_instance_new_from_description_with_options, UApplicationDescription*, UApplicationOptions*);
73
74// Application Ui Helpers
75
76// Clipboard
77IMPLEMENT_VOID_FUNCTION2(ua_ui_set_clipboard_content, void*, size_t);
78IMPLEMENT_VOID_FUNCTION2(ua_ui_get_clipboard_content, void**, size_t*);
79
80// UAUiDisplay
81IMPLEMENT_FUNCTION1(UAUiDisplay*, ua_ui_display_new_with_index, size_t);
82IMPLEMENT_VOID_FUNCTION1(ua_ui_display_destroy, UAUiDisplay*);
83IMPLEMENT_FUNCTION1(uint32_t, ua_ui_display_query_horizontal_res, UAUiDisplay*);
84IMPLEMENT_FUNCTION1(uint32_t, ua_ui_display_query_vertical_res, UAUiDisplay*);
85IMPLEMENT_FUNCTION1(EGLNativeDisplayType, ua_ui_display_get_native_type, UAUiDisplay*);
86
87
88// UAUiWindowProperties
89IMPLEMENT_FUNCTION0(UAUiWindowProperties*, ua_ui_window_properties_new_for_normal_window);
90IMPLEMENT_VOID_FUNCTION1(ua_ui_window_properties_destroy, UAUiWindowProperties*);
91IMPLEMENT_VOID_FUNCTION3(ua_ui_window_properties_set_titlen, UAUiWindowProperties*, const char*, size_t);
92IMPLEMENT_FUNCTION1(const char*, ua_ui_window_properties_get_title, UAUiWindowProperties*);
93IMPLEMENT_VOID_FUNCTION2(ua_ui_window_properties_set_role, UAUiWindowProperties*, UAUiWindowRole);
94IMPLEMENT_VOID_FUNCTION3(ua_ui_window_properties_set_input_cb_and_ctx, UAUiWindowProperties*, UAUiWindowInputEventCb, void*);
95
96// UAUiWindow
97IMPLEMENT_FUNCTION2(UAUiWindow*, ua_ui_window_new_for_application_with_properties, UApplicationInstance*, UAUiWindowProperties*);
98IMPLEMENT_VOID_FUNCTION1(ua_ui_window_destroy, UAUiWindow*);
99IMPLEMENT_FUNCTION3(UStatus, ua_ui_window_move, UAUiWindow*, uint32_t, uint32_t);
100IMPLEMENT_FUNCTION3(UStatus, ua_ui_window_resize, UAUiWindow*, uint32_t, uint32_t);
101IMPLEMENT_FUNCTION1(UStatus, ua_ui_window_hide, UAUiWindow*);
102IMPLEMENT_FUNCTION1(UStatus, ua_ui_window_show, UAUiWindow*);
103IMPLEMENT_VOID_FUNCTION1(ua_ui_window_request_fullscreen, UAUiWindow*);
104IMPLEMENT_FUNCTION1(EGLNativeWindowType, ua_ui_window_get_native_type, UAUiWindow*);
105
106/* -------------------------------------------------------------------------- *
107 * * * * * * * * * * * * * * * Deprecated API * * * * * * * * * * * * * * * * *
108 * -------------------------------------------------------------------------- *
109 */
110
111// Session service
112IMPLEMENT_FUNCTION1(int, ubuntu_ui_session_properties_get_application_instance_id, ubuntu_ui_session_properties);
113IMPLEMENT_FUNCTION1(int, ubuntu_ui_session_properties_get_application_stage_hint, ubuntu_ui_session_properties);
114IMPLEMENT_FUNCTION1(const char*, ubuntu_ui_session_properties_get_desktop_file_hint, ubuntu_ui_session_properties);
115IMPLEMENT_VOID_FUNCTION1(ubuntu_ui_session_install_session_lifecycle_observer, ubuntu_ui_session_lifecycle_observer*);
116IMPLEMENT_VOID_FUNCTION0(ubuntu_ui_session_unfocus_running_sessions);
117IMPLEMENT_VOID_FUNCTION1(ubuntu_ui_session_focus_running_session_with_id, int);
118IMPLEMENT_VOID_FUNCTION3(ubuntu_ui_session_snapshot_running_session_with_id, int, ubuntu_ui_session_service_snapshot_cb, void*);
119IMPLEMENT_VOID_FUNCTION1(ubuntu_ui_session_trigger_switch_to_well_known_application, ubuntu_ui_well_known_application);
120IMPLEMENT_FUNCTION4(int32_t, ubuntu_ui_set_surface_trap, int, int, int, int);
121IMPLEMENT_VOID_FUNCTION1(ubuntu_ui_unset_surface_trap, int);
122IMPLEMENT_VOID_FUNCTION4(ubuntu_ui_report_osk_visible, int, int, int, int);
123IMPLEMENT_VOID_FUNCTION0(ubuntu_ui_report_osk_invisible);
124IMPLEMENT_VOID_FUNCTION0(ubuntu_ui_report_notification_visible);
125IMPLEMENT_VOID_FUNCTION0(ubuntu_ui_report_notification_invisible);
126IMPLEMENT_VOID_FUNCTION1(ubuntu_ui_install_task_controller, ubuntu_ui_task_controller*);
127
128#ifdef __cplusplus
129}
130#endif
1310
=== removed file 'src/hybris/ubuntu_application_sensors_hybris.cpp'
--- src/hybris/ubuntu_application_sensors_hybris.cpp 2013-06-20 12:37:44 +0000
+++ src/hybris/ubuntu_application_sensors_hybris.cpp 1970-01-01 00:00:00 +0000
@@ -1,70 +0,0 @@
1/*
2 * Copyright (C) 2012 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Thomas Voss <thomas.voss@canonical.com>
17 * Ricardo Mendoza <ricardo.mendoza@canonical.com>
18 */
19
20#include <ubuntu/application/sensors/accelerometer.h>
21#include <ubuntu/application/sensors/proximity.h>
22#include <ubuntu/application/sensors/light.h>
23
24#include "bridge.h"
25
26// Ubuntu Application Sensors
27
28// Acceleration Sensor
29IMPLEMENT_FUNCTION0(UASensorsAccelerometer*, ua_sensors_accelerometer_new);
30IMPLEMENT_FUNCTION1(UStatus, ua_sensors_accelerometer_enable, UASensorsAccelerometer*);
31IMPLEMENT_FUNCTION1(UStatus, ua_sensors_accelerometer_disable, UASensorsAccelerometer*);
32IMPLEMENT_FUNCTION1(uint32_t, ua_sensors_accelerometer_get_min_delay, UASensorsAccelerometer*);
33IMPLEMENT_SF_FUNCTION1(float, ua_sensors_accelerometer_get_min_value, UASensorsAccelerometer*);
34IMPLEMENT_SF_FUNCTION1(float, ua_sensors_accelerometer_get_max_value, UASensorsAccelerometer*);
35IMPLEMENT_SF_FUNCTION1(float, ua_sensors_accelerometer_get_resolution, UASensorsAccelerometer*);
36IMPLEMENT_VOID_FUNCTION3(ua_sensors_accelerometer_set_reading_cb, UASensorsAccelerometer*, on_accelerometer_event_cb, void*);
37
38// Acceleration Sensor Event
39IMPLEMENT_FUNCTION1(uint64_t, uas_accelerometer_event_get_timestamp, UASAccelerometerEvent*);
40IMPLEMENT_SF_FUNCTION1(float, uas_accelerometer_event_get_acceleration_x, UASAccelerometerEvent*);
41IMPLEMENT_SF_FUNCTION1(float, uas_accelerometer_event_get_acceleration_y, UASAccelerometerEvent*);
42IMPLEMENT_SF_FUNCTION1(float, uas_accelerometer_event_get_acceleration_z, UASAccelerometerEvent*);
43
44// Proximity Sensor
45IMPLEMENT_FUNCTION0(UASensorsProximity*, ua_sensors_proximity_new);
46IMPLEMENT_FUNCTION1(UStatus, ua_sensors_proximity_enable, UASensorsProximity*);
47IMPLEMENT_FUNCTION1(UStatus, ua_sensors_proximity_disable, UASensorsProximity*);
48IMPLEMENT_FUNCTION1(uint32_t, ua_sensors_proximity_get_min_delay, UASensorsProximity*);
49IMPLEMENT_SF_FUNCTION1(float, ua_sensors_proximity_get_min_value, UASensorsProximity*);
50IMPLEMENT_SF_FUNCTION1(float, ua_sensors_proximity_get_max_value, UASensorsProximity*);
51IMPLEMENT_SF_FUNCTION1(float, ua_sensors_proximity_get_resolution, UASensorsProximity*);
52IMPLEMENT_VOID_FUNCTION3(ua_sensors_proximity_set_reading_cb, UASensorsProximity*, on_proximity_event_cb, void*);
53
54// Proximity Sensor Event
55IMPLEMENT_FUNCTION1(uint64_t, uas_proximity_event_get_timestamp, UASProximityEvent*);
56IMPLEMENT_FUNCTION1(UASProximityDistance, uas_proximity_event_get_distance, UASProximityEvent*);
57
58// Ambient Light Sensor
59IMPLEMENT_FUNCTION0(UASensorsLight*, ua_sensors_light_new);
60IMPLEMENT_FUNCTION1(UStatus, ua_sensors_light_enable, UASensorsLight*);
61IMPLEMENT_FUNCTION1(UStatus, ua_sensors_light_disable, UASensorsLight*);
62IMPLEMENT_FUNCTION1(uint32_t, ua_sensors_light_get_min_delay, UASensorsLight*);
63IMPLEMENT_SF_FUNCTION1(float, ua_sensors_light_get_min_value, UASensorsLight*);
64IMPLEMENT_SF_FUNCTION1(float, ua_sensors_light_get_max_value, UASensorsLight*);
65IMPLEMENT_SF_FUNCTION1(float, ua_sensors_light_get_resolution, UASensorsLight*);
66IMPLEMENT_VOID_FUNCTION3(ua_sensors_light_set_reading_cb, UASensorsLight*, on_light_event_cb, void*);
67
68// Ambient Light Sensor Event
69IMPLEMENT_FUNCTION1(uint64_t, uas_light_event_get_timestamp, UASLightEvent*);
70IMPLEMENT_SF_FUNCTION1(float, uas_light_event_get_light, UASLightEvent*);
710
=== removed file 'src/hybris/ubuntu_platform_hardware_api.cpp'
--- src/hybris/ubuntu_platform_hardware_api.cpp 2013-06-13 08:37:52 +0000
+++ src/hybris/ubuntu_platform_hardware_api.cpp 1970-01-01 00:00:00 +0000
@@ -1,78 +0,0 @@
1/*
2 * Copyright (C) 2012 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Thomas Voss <thomas.voss@canonical.com>
17 * Ricardo Mendoza <ricardo.mendoza@canonical.com>
18 */
19
20// C APIs
21#include <ubuntu/hardware/gps.h>
22
23#include "bridge.h"
24
25// Hardware - GPS
26IMPLEMENT_FUNCTION1(
27UHardwareGps,
28u_hardware_gps_new,
29UHardwareGpsParams*);
30
31IMPLEMENT_VOID_FUNCTION1(
32u_hardware_gps_delete,
33UHardwareGps);
34
35IMPLEMENT_FUNCTION1(
36bool,
37u_hardware_gps_start,
38UHardwareGps);
39
40IMPLEMENT_FUNCTION1(
41bool,
42u_hardware_gps_stop,
43UHardwareGps);
44
45IMPLEMENT_VOID_FUNCTION4(
46u_hardware_gps_inject_time,
47UHardwareGps,
48int64_t,
49int64_t,
50int);
51
52IMPLEMENT_VOID_FUNCTION4(
53u_hardware_gps_inject_location,
54UHardwareGps,
55double,
56double,
57float);
58
59IMPLEMENT_VOID_FUNCTION2(
60u_hardware_gps_delete_aiding_data,
61UHardwareGps,
62uint16_t);
63
64IMPLEMENT_FUNCTION6(
65bool,
66u_hardware_gps_set_position_mode,
67UHardwareGps,
68uint32_t,
69uint32_t,
70uint32_t,
71uint32_t,
72uint32_t);
73
74IMPLEMENT_VOID_FUNCTION3(
75u_hardware_gps_inject_xtra_data,
76UHardwareGps,
77char*,
78int);
790
=== removed directory 'src/mirclient'
=== removed file 'src/mirclient/CMakeLists.txt'
--- src/mirclient/CMakeLists.txt 2013-06-07 23:27:45 +0000
+++ src/mirclient/CMakeLists.txt 1970-01-01 00:00:00 +0000
@@ -1,34 +0,0 @@
1set(SOURCES
2 ubuntu_application_api_mirclient.cpp
3 application_instance_mirclient.cpp
4 window_properties_mirclient.cpp
5 window_mirclient.cpp
6)
7
8set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++11 -fPIC")
9
10add_library(
11 ubuntu_application_api_mirclient SHARED
12 ${SOURCES}
13)
14
15include_directories(
16 ${CMAKE_BINARY_DIR}/include
17 ${MIRCLIENT_INCLUDE_DIRS}
18)
19
20target_link_libraries(
21 ubuntu_application_api_mirclient
22 ${MIRCLIENT_LDFLAGS} ${MIRCLIENT_LIBRARIES}
23 -Wl,--whole-archive ubuntu_application_api_mircommon
24 -Wl,--no-whole-archive
25)
26
27set_target_properties(
28 ubuntu_application_api_mirclient
29 PROPERTIES
30 VERSION 1.0
31 SOVERSION 1
32)
33
34install(TARGETS ubuntu_application_api_mirclient ${INSTALL_TARGETS_DEFAULT_ARGS})
350
=== removed file 'src/mirclient/application_instance_mirclient.cpp'
--- src/mirclient/application_instance_mirclient.cpp 2013-06-07 20:56:22 +0000
+++ src/mirclient/application_instance_mirclient.cpp 1970-01-01 00:00:00 +0000
@@ -1,68 +0,0 @@
1/*
2 * Copyright (C) 2013 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Robert Carr <robert.carr@canonical.com>
17 */
18
19#include "application_instance_mirclient_priv.h"
20
21namespace uamc = ubuntu::application::mir::client;
22
23uamc::Instance::Instance()
24 : con(nullptr),
25 ref_count(1)
26{
27
28}
29
30UApplicationInstance* uamc::Instance::as_u_application_instance()
31{
32 return static_cast<UApplicationInstance*>(this);
33}
34
35uamc::Instance* uamc::Instance::from_u_application_instance(UApplicationInstance* u_instance)
36{
37 return static_cast<uamc::Instance*>(u_instance);
38}
39
40void uamc::Instance::ref()
41{
42 ref_count++;
43}
44
45void uamc::Instance::unref()
46{
47 ref_count--;
48 if (ref_count == 0)
49 delete this;
50}
51
52MirConnection* uamc::Instance::connection() const
53{
54 return con.get();
55}
56
57bool uamc::Instance::connect(std::string const& application_name)
58{
59 auto mir_connection = mir_connect_sync(NULL, application_name.c_str());
60 if (mir_connection == nullptr)
61 return false;
62 con = ConnectionPtr(mir_connection,
63 [](MirConnection *c)
64 {
65 mir_connection_release(c);
66 });
67 return true;
68}
690
=== removed file 'src/mirclient/application_instance_mirclient_priv.h'
--- src/mirclient/application_instance_mirclient_priv.h 2013-06-09 21:52:56 +0000
+++ src/mirclient/application_instance_mirclient_priv.h 1970-01-01 00:00:00 +0000
@@ -1,68 +0,0 @@
1/*
2 * Copyright (C) 2013 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Robert Carr <robert.carr@canonical.com>
17 */
18
19#ifndef UBUNTU_APPLICATION_INSTANCE_MIRCLIENT_PRIV_H_
20#define UBUNTU_APPLICATION_INSTANCE_MIRCLIENT_PRIV_H_
21
22#include <ubuntu/application/instance.h>
23
24#include <memory>
25#include <string>
26
27#include <mir_toolkit/mir_client_library.h>
28
29namespace ubuntu
30{
31namespace application
32{
33namespace mir
34{
35namespace client
36{
37
38class Instance
39{
40public:
41 Instance();
42 ~Instance() = default;
43
44 UApplicationInstance* as_u_application_instance();
45 static Instance* from_u_application_instance(UApplicationInstance* u_instance);
46
47 void ref();
48 void unref();
49
50 MirConnection* connection() const;
51 bool connect(std::string const& application_name);
52
53protected:
54 Instance(Instance const&) = delete;
55 Instance& operator=(Instance const&) = delete;
56
57private:
58 typedef std::unique_ptr<MirConnection, std::function<void(MirConnection*)>> ConnectionPtr;
59 ConnectionPtr con;
60 int ref_count;
61};
62
63}
64}
65}
66} // namespace ubuntu
67
68#endif // UBUNTU_APPLICATION_INSTANCE_MIRCLIENT_PRIV_H_
690
=== removed file 'src/mirclient/ubuntu_application_api_mirclient.cpp'
--- src/mirclient/ubuntu_application_api_mirclient.cpp 2013-06-12 21:20:38 +0000
+++ src/mirclient/ubuntu_application_api_mirclient.cpp 1970-01-01 00:00:00 +0000
@@ -1,279 +0,0 @@
1/*
2 * Copyright (C) 2013 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Robert Carr <robert.carr@canonical.com>
17 */
18
19#include "application_instance_mirclient_priv.h"
20#include "window_properties_mirclient_priv.h"
21#include "window_mirclient_priv.h"
22
23#include "mircommon/application_id_mir_priv.h"
24
25#include <ubuntu/application/lifecycle_delegate.h>
26#include <ubuntu/application/ui/window.h>
27#include <ubuntu/application/ui/options.h>
28#include <ubuntu/application/ui/session.h>
29#include <ubuntu/application/ui/clipboard.h>
30#include <ubuntu/application/ui/display.h>
31#include <ubuntu/application/sensors/accelerometer.h>
32#include <ubuntu/application/sensors/proximity.h>
33#include <ubuntu/application/sensors/light.h>
34
35#include <mir_toolkit/mir_client_library.h>
36
37#include <stdlib.h>
38#include <assert.h>
39#include <string.h>
40
41namespace uam = ubuntu::application::mir;
42namespace uamc = uam::client;
43
44namespace
45{
46
47// We use a global instance as some platform-api functions, i.e. display_new_with_index
48// do not supply dependencies, but a MirConnection is required for all queries.
49static uamc::Instance*
50global_mir_instance()
51{
52 // Obviously ref counting is whacky here...
53 static uamc::Instance instance;
54 instance.ref(); // We leak a reference, this object can't be destroyed
55 return &instance;
56}
57
58// Display info
59static MirDisplayInfo*
60u_display_mir_display(UAUiDisplay *display)
61{
62 return static_cast<MirDisplayInfo*>(display);
63}
64
65static UAUiDisplay*
66mir_display_u_display(MirDisplayInfo *display)
67{
68 return static_cast<UAUiDisplay*>(display);
69}
70
71};
72
73extern "C"
74{
75
76// TODO<papi>: Eliminate global instance by adding Instance to some functions (i.e. display queries)
77// TODO: We can't take ownership of description and options until we get rid of the global instance
78// so we leak them.
79UApplicationInstance* u_application_instance_new_from_description_with_options(UApplicationDescription* description, UApplicationOptions* options)
80{
81 auto instance = global_mir_instance();
82
83 auto id = uam::Id::from_u_application_id(u_application_description_get_application_id(description));
84 auto connect_suceeded = instance->connect(id->name);
85 assert(connect_suceeded);
86
87 return instance->as_u_application_instance();
88}
89
90void
91u_application_instance_ref(UApplicationInstance *u_instance)
92{
93 auto instance = uamc::Instance::from_u_application_instance(u_instance);
94 instance->ref();
95}
96
97void
98u_application_instance_unref(UApplicationInstance *u_instance)
99{
100 auto instance = uamc::Instance::from_u_application_instance(u_instance);
101 instance->unref();
102}
103
104void
105u_application_instance_destroy(UApplicationInstance *u_instance)
106{
107 // TODO<papi>: What are the proper semantics here.
108 u_application_instance_unref(u_instance);
109}
110
111void
112u_application_instance_run(UApplicationInstance *instance)
113{
114 // TODO<papi>: What is this supposed to do? Seems to be no-op on hybris.
115 (void) instance;
116}
117
118void ua_ui_set_clipboard_content(void* content, size_t content_size)
119{
120 // TODO<papi,mir>: Implement. We will need a MirConnection
121 (void) content;
122 (void) content_size;
123}
124
125void ua_ui_get_clipboard_content(void** out_content, size_t* out_content_size)
126{
127 // TODO<papi,mir>: Implement, see get_clipboard_comment.
128 *out_content = NULL;
129 *out_content_size = 0;
130}
131
132//
133// TODO <papi>: We need to expose the EGLNativeDisplay somehow
134//
135
136// TODO <papi>: This function should take an application instance so we can eliminate the global mir instance.
137// TODO <mir>: Perhaps this should be noop for Mir as there is no need to construct
138// a display object, the connection already has everything we need, as it receives
139// the display info at connect time.
140UAUiDisplay* ua_ui_display_new_with_index(size_t index)
141{
142 // TODO<papi,mir>: What are the semantics of index. How should we use it?
143 (void) index;
144 auto instance = global_mir_instance();
145
146 auto display = new MirDisplayInfo;
147 mir_connection_get_display_info(instance->connection(), display);
148
149 return mir_display_u_display(display);
150}
151
152void ua_ui_display_destroy(UAUiDisplay* display)
153{
154 auto mir_display = u_display_mir_display(display);
155 delete mir_display;
156}
157
158uint32_t ua_ui_display_query_horizontal_res(UAUiDisplay* display)
159{
160 auto mir_display = u_display_mir_display(display);
161
162 // TODO<mir>: Line up return types from mirclient
163 return static_cast<uint32_t>(mir_display->width);
164}
165
166uint32_t ua_ui_display_query_vertical_res(UAUiDisplay* display)
167{
168 auto mir_display = u_display_mir_display(display);
169
170 // TODO<mir>: Line up return types from mirclient
171 return static_cast<uint32_t>(mir_display->height);
172}
173
174EGLNativeDisplayType ua_ui_display_get_native_type(UAUiDisplay* display)
175{
176 auto instance = global_mir_instance();
177
178 // TODO<mir>: Careful with this cast
179 return reinterpret_cast<EGLNativeDisplayType>(mir_connection_get_egl_native_display(instance->connection()));
180}
181
182UAUiWindowProperties* ua_ui_window_properties_new_for_normal_window()
183{
184 return (new uamc::WindowProperties)->as_u_window_properties();
185}
186
187void ua_ui_window_properties_destroy(UAUiWindowProperties* u_properties)
188{
189 auto properties = uamc::WindowProperties::from_u_window_properties(u_properties);
190 delete properties;
191}
192
193void ua_ui_window_properties_set_titlen(UAUiWindowProperties* u_properties, const char* title, size_t title_length)
194{
195 auto properties = uamc::WindowProperties::from_u_window_properties(u_properties);
196
197 properties->set_title(title, title_length);
198}
199
200const char* ua_ui_window_properties_get_title(UAUiWindowProperties* u_properties)
201{
202 auto properties = uamc::WindowProperties::from_u_window_properties(u_properties);
203 return properties->surface_parameters().name;
204}
205
206void ua_ui_window_properties_set_role(UAUiWindowProperties* properties, UAUiWindowRole role)
207{
208 // TODO<papi>: Doesn't seem like this is meaningful for mirclient. Perhaps it should leave platform-api.
209 (void) properties;
210 (void) role;
211}
212
213void ua_ui_window_properties_set_input_cb_and_ctx(UAUiWindowProperties* u_properties, UAUiWindowInputEventCb cb, void* ctx)
214{
215 auto properties = uamc::WindowProperties::from_u_window_properties(u_properties);
216 properties->set_input_cb_and_ctx(cb, ctx);
217}
218
219UAUiWindow* ua_ui_window_new_for_application_with_properties(UApplicationInstance* u_instance, UAUiWindowProperties* u_properties)
220{
221 auto instance = uamc::Instance::from_u_application_instance(u_instance);
222 auto properties = uamc::WindowProperties::from_u_window_properties(u_properties);
223
224 auto window = new uamc::Window(*instance, properties);
225 return window->as_u_window();
226}
227
228void ua_ui_window_destroy(UAUiWindow* u_window)
229{
230 auto window = uamc::Window::from_u_window(u_window);
231 delete window;
232}
233
234UStatus ua_ui_window_move(UAUiWindow* u_window, uint32_t x, uint32_t y)
235{
236 // TODO<papi,mir>: Implement. Assuming this should exist on mirclient?
237 (void) u_window;
238 (void) x;
239 (void) y;
240 return (UStatus) 0;
241}
242
243UStatus ua_ui_window_resize(UAUiWindow* u_window, uint32_t width, uint32_t height)
244{
245 // TODO<mir>: Implement
246 (void) u_window;
247 (void) width;
248 (void) height;
249 return (UStatus) 0;
250}
251
252UStatus ua_ui_window_hide(UAUiWindow* u_window)
253{
254 // TODO<mir>: Implement
255 (void) u_window;
256 return (UStatus) 0;
257}
258
259UStatus ua_ui_window_show(UAUiWindow* u_window)
260{
261 // TODO<mir>: Implement
262 (void) u_window;
263 return (UStatus) 0;
264}
265
266void ua_ui_window_request_fullscreen(UAUiWindow* u_window)
267{
268 // TODO<mir>: Implement
269 (void) u_window;
270}
271
272EGLNativeWindowType ua_ui_window_get_native_type(UAUiWindow* u_window)
273{
274 auto window = uamc::Window::from_u_window(u_window);
275 return window->get_native_type();
276}
277
278// TODO: Sensors
279}
2800
=== removed file 'src/mirclient/window_mirclient.cpp'
--- src/mirclient/window_mirclient.cpp 2013-06-07 23:27:45 +0000
+++ src/mirclient/window_mirclient.cpp 1970-01-01 00:00:00 +0000
@@ -1,128 +0,0 @@
1/*
2 * Copyright (C) 2013 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Robert Carr <robert.carr@canonical.com>
17 */
18
19#include "window_mirclient_priv.h"
20#include "application_instance_mirclient_priv.h"
21#include "window_properties_mirclient_priv.h"
22#include "window_mirclient_priv.h"
23
24#include "mircommon/event_helpers_mir.h"
25
26namespace uamc = ubuntu::application::mir::client;
27namespace uaum = ubuntu::application::ui::mir;
28
29namespace ubuntu
30{
31namespace application
32{
33namespace mir
34{
35namespace client
36{
37
38struct InputContext
39{
40 UAUiWindowInputEventCb cb;
41 void *ctx;
42};
43
44static void
45ua_ui_window_mir_handle_event(MirSurface* surface, MirEvent const* mir_ev, void* ctx)
46{
47 // TODO<mir>: Perhaps this indicates that mirclient library should not pass a surface argument here.
48 (void) surface;
49
50 Event ubuntu_ev;
51 uaum::event_to_ubuntu_event(mir_ev, ubuntu_ev);
52 auto mir_ctx = static_cast<uamc::InputContext*>(ctx);
53 mir_ctx->cb(mir_ctx->ctx, &ubuntu_ev);
54}
55
56}
57}
58}
59}
60
61namespace
62{
63
64static MirPixelFormat
65mir_choose_default_pixel_format(MirConnection *connection)
66{
67 MirDisplayInfo info;
68 mir_connection_get_display_info(connection, &info);
69 return info.supported_pixel_format[0];
70}
71
72static MirSurface*
73create_surface_with_parameters(MirConnection *connection,
74 MirSurfaceParameters parameters)
75{
76}
77
78}
79
80uamc::Window::Window(uamc::Instance& instance,
81 uamc::WindowProperties* properties)
82 : instance(instance)
83{
84 window_properties = WindowPropertiesPtr(properties,
85 [](uamc::WindowProperties *p)
86 {
87 ua_ui_window_properties_destroy(p->as_u_window_properties());
88 });
89
90 MirSurfaceParameters parameters = properties->surface_parameters();
91 auto connection = instance.connection();
92 parameters.pixel_format = mir_choose_default_pixel_format(connection);
93
94 auto mir_surface = mir_connection_create_surface_sync(connection, &parameters);
95 // TODO: create_surface_sync is unsafe as there is a race between setting the event handler and receiving surfaces
96 input_ctx = InputContextPtr(new uamc::InputContext{properties->input_cb(), properties->input_context()},
97 [](InputContext *c)
98 {
99 delete c;
100 });
101
102 MirEventDelegate delegate =
103 {
104 uamc::ua_ui_window_mir_handle_event,
105 input_ctx.get()
106 };
107 mir_surface_set_event_handler(mir_surface, &delegate);
108 surface = SurfacePtr(mir_surface,
109 [](MirSurface *s)
110 {
111 mir_surface_release_sync(s);
112 });
113}
114
115UAUiWindow* uamc::Window::as_u_window()
116{
117 return static_cast<UAUiWindow*>(this);
118}
119
120uamc::Window* uamc::Window::from_u_window(UAUiWindow *u_window)
121{
122 return static_cast<uamc::Window*>(u_window);
123}
124
125EGLNativeWindowType uamc::Window::get_native_type()
126{
127 return reinterpret_cast<EGLNativeWindowType>(mir_surface_get_egl_native_window(surface.get()));
128}
1290
=== removed file 'src/mirclient/window_mirclient_priv.h'
--- src/mirclient/window_mirclient_priv.h 2013-06-07 23:27:45 +0000
+++ src/mirclient/window_mirclient_priv.h 1970-01-01 00:00:00 +0000
@@ -1,76 +0,0 @@
1/*
2 * Copyright (C) 2013 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Robert Carr <robert.carr@canonical.com>
17 */
18
19#ifndef UBUNTU_APPLICATION_UI_WINDOW_MIRCLIENT_PRIV_H_
20#define UBUNTU_APPLICATION_UI_WINDOW_MIRCLIENT_PRIV_H_
21
22#include <ubuntu/application/ui/window.h>
23#include <mir_toolkit/mir_client_library.h>
24
25#include <EGL/egl.h>
26
27#include <stddef.h>
28
29#include <functional>
30#include <memory>
31#include <string>
32
33namespace ubuntu
34{
35namespace application
36{
37namespace mir
38{
39namespace client
40{
41class Instance;
42class WindowProperties;
43struct InputContext;
44
45class Window
46{
47public:
48 Window(Instance& instance, WindowProperties* window);
49 ~Window() = default;
50
51 UAUiWindow* as_u_window();
52 static Window* from_u_window(UAUiWindow* u_window);
53
54 EGLNativeWindowType get_native_type();
55protected:
56 Window(Window const&) = delete;
57 Window& operator=(Window const&) = delete;
58
59private:
60 Instance& instance;
61
62 typedef std::unique_ptr<WindowProperties, std::function<void(WindowProperties*)>> WindowPropertiesPtr;
63 typedef std::unique_ptr<MirSurface, std::function<void(MirSurface*)>> SurfacePtr;
64 typedef std::unique_ptr<InputContext, std::function<void(InputContext*)>> InputContextPtr;
65
66 WindowPropertiesPtr window_properties;
67 SurfacePtr surface;
68 InputContextPtr input_ctx;
69};
70
71}
72}
73}
74}
75
76#endif // UBUNTU_APPLICATION_UI_WINDOW_MIRCLIENT_PRIV_H_
770
=== removed file 'src/mirclient/window_properties_mirclient.cpp'
--- src/mirclient/window_properties_mirclient.cpp 2013-06-07 21:58:44 +0000
+++ src/mirclient/window_properties_mirclient.cpp 1970-01-01 00:00:00 +0000
@@ -1,68 +0,0 @@
1/*
2 * Copyright (C) 2013 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Robert Carr <robert.carr@canonical.com>
17 */
18
19#include "window_properties_mirclient_priv.h"
20
21namespace uamc = ubuntu::application::mir::client;
22
23uamc::WindowProperties::WindowProperties()
24 : cb(nullptr),
25 input_ctx(nullptr)
26{
27 parameters.name = nullptr;
28 parameters.width = 0;
29 parameters.height = 0;
30 parameters.buffer_usage = mir_buffer_usage_hardware;
31}
32
33UAUiWindowProperties* uamc::WindowProperties::as_u_window_properties()
34{
35 return static_cast<UAUiWindowProperties*>(this);
36}
37uamc::WindowProperties* uamc::WindowProperties::from_u_window_properties(UAUiWindowProperties* u_properties)
38{
39 return static_cast<uamc::WindowProperties*>(u_properties);
40}
41
42void uamc::WindowProperties::set_title(char const* window_title, size_t length)
43{
44 title = std::string(window_title, length);
45 parameters.name = title.c_str();
46}
47
48void uamc::WindowProperties::set_input_cb_and_ctx(UAUiWindowInputEventCb callback, void* ctx)
49{
50 cb = callback;
51 input_ctx = ctx;
52}
53
54MirSurfaceParameters const& uamc::WindowProperties::surface_parameters() const
55{
56 return parameters;
57}
58
59UAUiWindowInputEventCb uamc::WindowProperties::input_cb() const
60{
61 return cb;
62}
63
64void* uamc::WindowProperties::input_context() const
65{
66 return input_ctx;
67}
68
690
=== removed file 'src/mirclient/window_properties_mirclient_priv.h'
--- src/mirclient/window_properties_mirclient_priv.h 2013-06-07 21:58:44 +0000
+++ src/mirclient/window_properties_mirclient_priv.h 1970-01-01 00:00:00 +0000
@@ -1,72 +0,0 @@
1/*
2 * Copyright (C) 2013 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Robert Carr <robert.carr@canonical.com>
17 */
18
19#ifndef UBUNTU_APPLICATION_UI_WINDOW_PROPERTIES_MIRCLIENT_PRIV_H_
20#define UBUNTU_APPLICATION_UI_WINDOW_PROPERTIES_MIRCLIENT_PRIV_H_
21
22#include <ubuntu/application/ui/window.h>
23#include <mir_toolkit/mir_client_library.h>
24
25#include <stddef.h>
26
27#include <string>
28
29namespace ubuntu
30{
31namespace application
32{
33namespace mir
34{
35namespace client
36{
37
38class WindowProperties
39{
40public:
41 WindowProperties();
42 ~WindowProperties() = default;
43
44 UAUiWindowProperties* as_u_window_properties();
45 static WindowProperties* from_u_window_properties(UAUiWindowProperties* u_properties);
46
47 void set_title(char const* title, size_t length);
48 void set_input_cb_and_ctx(UAUiWindowInputEventCb cb, void* ctx);
49
50 MirSurfaceParameters const& surface_parameters() const;
51 UAUiWindowInputEventCb input_cb() const;
52 void* input_context() const;
53
54protected:
55 WindowProperties(WindowProperties const&) = delete;
56 WindowProperties& operator=(WindowProperties const&) = delete;
57
58private:
59 MirSurfaceParameters parameters;
60
61 std::string title;
62
63 UAUiWindowInputEventCb cb;
64 void *input_ctx;
65};
66
67}
68}
69}
70}
71
72#endif // UBUNTU_APPLICATION_UI_WINDOW_PROPERTIES_MIRCLIENT_PRIV_H_
730
=== removed directory 'src/mircommon'
=== removed file 'src/mircommon/CMakeLists.txt'
--- src/mircommon/CMakeLists.txt 2013-07-10 13:57:20 +0000
+++ src/mircommon/CMakeLists.txt 1970-01-01 00:00:00 +0000
@@ -1,43 +0,0 @@
1set(SOURCES
2 event_helpers_mir.cpp
3 application_id_mir.cpp
4 application_options_mir.cpp
5 application_description_mir.cpp
6 lifecycle_delegate_mir.cpp
7 session_mir.cpp
8)
9
10set(LINK_LIBRARIES
11 ${MIR_COMMON_LDFLAGS} ${MIR_COMMON_LIBRARIES}
12)
13
14if(ENABLE_HYBRIS_IMPLEMENTATION)
15 list(APPEND SOURCES
16 ../hybris/ubuntu_application_sensors_hybris.cpp
17 )
18 list(APPEND LINK_LIBRARIES
19 hybris-common
20 )
21else()
22 list(APPEND SOURCES
23 ubuntu_application_sensors_desktop.cpp
24 )
25endif()
26
27set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC --std=c++11")
28
29include_directories(
30 ${MIRCOMMON_INCLUDE_DIRS}
31)
32
33add_library(
34 ubuntu_application_api_mircommon STATIC
35 ${SOURCES}
36)
37
38target_link_libraries(
39 ubuntu_application_api_mircommon
40 ${LINK_LIBRARIES}
41)
42
43
440
=== removed file 'src/mircommon/application_description_mir.cpp'
--- src/mircommon/application_description_mir.cpp 2013-06-07 17:41:36 +0000
+++ src/mircommon/application_description_mir.cpp 1970-01-01 00:00:00 +0000
@@ -1,94 +0,0 @@
1/*
2 * Copyright (C) 2013 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Robert Carr <robert.carr@canonical.com>
17 */
18
19#include "application_description_mir_priv.h"
20
21namespace uam = ubuntu::application::mir;
22
23uam::Description::Description()
24 : application_id(nullptr),
25 lifecycle_delegate(nullptr)
26{
27}
28
29UApplicationDescription* uam::Description::as_u_application_description()
30{
31 return static_cast<UApplicationDescription*>(this);
32}
33
34uam::Description* uam::Description::from_u_application_description(UApplicationDescription* description)
35{
36 return static_cast<uam::Description*>(description);
37}
38
39UApplicationDescription*
40u_application_description_new()
41{
42 auto description = new uam::Description();
43 return description->as_u_application_description();
44}
45
46void
47u_application_description_destroy(UApplicationDescription *u_description)
48{
49 auto description = uam::Description::from_u_application_description(u_description);
50 delete description;
51}
52
53void
54u_application_description_set_application_id(UApplicationDescription *u_description,
55 UApplicationId *id)
56{
57 auto description = uam::Description::from_u_application_description(u_description);
58
59 description->application_id = std::unique_ptr<UApplicationId, std::function<void(UApplicationId*)>>(id,
60 [](UApplicationId *p)
61 {
62 u_application_id_destroy(p);
63 });
64}
65
66UApplicationId*
67u_application_description_get_application_id(UApplicationDescription *u_description)
68{
69 auto description = uam::Description::from_u_application_description(u_description);
70 return description->application_id.get();
71}
72
73void
74u_application_description_set_application_lifecycle_delegate(UApplicationDescription *u_description,
75 UApplicationLifecycleDelegate *lifecycle_delegate)
76{
77 auto description = uam::Description::from_u_application_description(u_description);
78
79 // TODO: We don't take a ref as it is created with a floating ref but this should be made more explicit...
80 description->lifecycle_delegate =
81 std::unique_ptr<UApplicationLifecycleDelegate, std::function<void(UApplicationLifecycleDelegate*)>>(lifecycle_delegate,
82 [](UApplicationLifecycleDelegate *p)
83 {
84 u_application_lifecycle_delegate_unref(p);
85 });
86
87}
88
89UApplicationLifecycleDelegate*
90u_application_description_get_application_lifecycle_delegate(UApplicationDescription *u_description)
91{
92 auto description = uam::Description::from_u_application_description(u_description);
93 return description->lifecycle_delegate.get();
94}
950
=== removed file 'src/mircommon/application_description_mir_priv.h'
--- src/mircommon/application_description_mir_priv.h 2013-06-07 17:41:36 +0000
+++ src/mircommon/application_description_mir_priv.h 1970-01-01 00:00:00 +0000
@@ -1,56 +0,0 @@
1/*
2 * Copyright (C) 2013 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Robert Carr <robert.carr@canonical.com>
17 */
18
19#ifndef UBUNTU_APPLICATION_DESCRIPTION_MIR_PRIV_H_
20#define UBUNTU_APPLICATION_DESCRIPTION_MIR_PRIV_H_
21
22#include <ubuntu/application/description.h>
23
24#include <memory>
25#include <functional>
26
27namespace ubuntu
28{
29namespace application
30{
31namespace mir
32{
33
34class Description
35{
36public:
37 Description();
38 ~Description() = default;
39
40 UApplicationDescription* as_u_application_description();
41 static Description* from_u_application_description(UApplicationDescription* u_description);
42
43 // TODO<papi> Do we really own these?
44 std::unique_ptr<UApplicationId, std::function<void(UApplicationId*)>> application_id;
45 std::unique_ptr<UApplicationLifecycleDelegate, std::function<void(UApplicationLifecycleDelegate*)>> lifecycle_delegate;
46
47protected:
48 Description(Description const&) = delete;
49 Description& operator=(Description const&) = delete;
50};
51
52}
53}
54} // namespace ubuntu
55
56#endif // UBUNTU_APPLICATION_DESCRIPTION_MIR_PRIV_H_
570
=== removed file 'src/mircommon/application_id_mir.cpp'
--- src/mircommon/application_id_mir.cpp 2013-06-05 19:33:23 +0000
+++ src/mircommon/application_id_mir.cpp 1970-01-01 00:00:00 +0000
@@ -1,56 +0,0 @@
1/*
2 * Copyright (C) 2013 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Robert Carr <robert.carr@canonical.com>
17 */
18
19#include "application_id_mir_priv.h"
20
21namespace uam = ubuntu::application::mir;
22
23uam::Id::Id(const char *name, size_t size)
24 : name(name, size)
25{
26}
27
28UApplicationId* uam::Id::as_u_application_id()
29{
30 return static_cast<UApplicationId*>(this);
31}
32
33uam::Id* uam::Id::from_u_application_id(UApplicationId *id)
34{
35 return static_cast<uam::Id*>(id);
36}
37
38UApplicationId*
39u_application_id_new_from_stringn(const char *string, size_t size)
40{
41 auto id = new uam::Id(string, size);
42 return id->as_u_application_id();
43}
44
45void u_application_id_destroy(UApplicationId *u_id)
46{
47 auto id = uam::Id::from_u_application_id(u_id);
48 delete id;
49}
50
51int u_application_id_compare(UApplicationId* u_lhs, UApplicationId* u_rhs)
52{
53 auto lhs = uam::Id::from_u_application_id(u_lhs);
54 auto rhs = uam::Id::from_u_application_id(u_rhs);
55 return lhs->name.compare(rhs->name);
56}
570
=== removed file 'src/mircommon/application_id_mir_priv.h'
--- src/mircommon/application_id_mir_priv.h 2013-06-05 19:44:09 +0000
+++ src/mircommon/application_id_mir_priv.h 1970-01-01 00:00:00 +0000
@@ -1,53 +0,0 @@
1/*
2 * Copyright (C) 2013 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Robert Carr <robert.carr@canonical.com>
17 */
18
19#ifndef UBUNTU_APPLICATION_ID_MIR_PRIV_H_
20#define UBUNTU_APPLICATION_ID_MIR_PRIV_H_
21
22#include <ubuntu/application/id.h>
23
24#include <string>
25
26namespace ubuntu
27{
28namespace application
29{
30namespace mir
31{
32
33class Id
34{
35public:
36 Id(const char *name, size_t size);
37 ~Id() = default;
38
39 UApplicationId* as_u_application_id();
40 static Id* from_u_application_id(UApplicationId* id);
41
42 std::string const name;
43
44protected:
45 Id(const Id&) = delete;
46 Id& operator=(const Id&) = delete;
47};
48
49}
50}
51} // namespace ubuntu
52
53#endif // UBUNTU_APPLICATION_ID_MIR_PRIV_H_
540
=== removed file 'src/mircommon/application_options_mir.cpp'
--- src/mircommon/application_options_mir.cpp 2013-06-06 23:35:14 +0000
+++ src/mircommon/application_options_mir.cpp 1970-01-01 00:00:00 +0000
@@ -1,170 +0,0 @@
1/*
2 * Copyright (C) 2013 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Robert Carr <robert.carr@canonical.com>
17 */
18
19#include "application_options_mir_priv.h"
20
21#include <string.h>
22#include <stdio.h>
23#include <stdlib.h>
24#include <getopt.h>
25
26#include <tuple>
27#include <string>
28
29namespace uam = ubuntu::application::mir;
30
31UApplicationOptions* uam::Options::as_u_application_options()
32{
33 return static_cast<UApplicationOptions*>(this);
34}
35uam::Options* uam::Options::from_u_application_options(UApplicationOptions* options)
36{
37 return static_cast<uam::Options*>(options);
38}
39
40namespace
41{
42
43UAUiStage
44string_to_stage(std::string const& s)
45{
46 if (s == "main_stage")
47 return U_MAIN_STAGE;
48 else if (s == "side_stage")
49 return U_SIDE_STAGE;
50 else if (s == "share_stage")
51 return U_SHARE_STAGE;
52}
53
54UAUiFormFactor
55string_to_form_factor(std::string const& s)
56{
57 if (s == "desktop")
58 return U_DESKTOP;
59 else if (s == "phone")
60 return U_PHONE;
61 else if (s == "tablet")
62 return U_TABLET;
63}
64
65void print_help_and_exit()
66{
67 printf("Usage: executable "
68 "[--form_factor_hint={desktop, phone, tablet}] "
69 "[--stage_hint={main_stage, side_stage, share_stage}] "
70 "[--desktop_file_hint=absolute_path_to_desktop_file]\n");
71 exit(EXIT_SUCCESS);
72}
73
74}
75
76extern "C"
77{
78UApplicationOptions*
79u_application_options_new_from_cmd_line(int argc, char** argv)
80{
81 static const int uninteresting_flag_value = 0;
82 static struct option long_options[] =
83 {
84 {"form_factor_hint", required_argument, NULL, uninteresting_flag_value},
85 {"stage_hint", required_argument, NULL, uninteresting_flag_value},
86 {"desktop_file_hint", required_argument, NULL, uninteresting_flag_value},
87 {"help", no_argument, NULL, uninteresting_flag_value},
88 {0, 0, 0, 0}
89 };
90
91 static const int form_factor_hint_index = 0;
92 static const int stage_hint_index = 1;
93 static const int desktop_file_hint_index = 2;
94 static const int help_index = 3;
95
96 auto app_options = new uam::Options;
97
98 while(true)
99 {
100 int option_index = 0;
101
102 int c = getopt_long(argc,
103 argv,
104 "",
105 long_options,
106 &option_index);
107
108 if (c == -1)
109 break;
110
111 switch (c)
112 {
113 case 0:
114 // If this option set a flag, do nothing else now.
115 if (long_options[option_index].flag != 0)
116 break;
117 if (option_index == help_index)
118 print_help_and_exit();
119 if (optarg)
120 {
121 switch(option_index)
122 {
123 case form_factor_hint_index:
124 app_options->form_factor = string_to_form_factor(std::string(optarg));
125 break;
126 case stage_hint_index:
127 app_options->stage = string_to_stage(std::string(optarg));
128 break;
129 case desktop_file_hint_index:
130 app_options->desktop_file = std::string(optarg);
131 break;
132 }
133 }
134 break;
135 case '?':
136 break;
137 }
138 }
139
140 return app_options->as_u_application_options();
141}
142
143void
144u_application_options_destroy(UApplicationOptions* u_options)
145{
146 auto options = uam::Options::from_u_application_options(u_options);
147 delete options;
148}
149
150UApplicationOperationMode
151u_application_options_get_operation_mode(UApplicationOptions *u_options)
152{
153 auto options = uam::Options::from_u_application_options(u_options);
154 return options->operation_mode;
155}
156
157UAUiFormFactor
158u_application_options_get_form_factor(UApplicationOptions* u_options)
159{
160 auto options = uam::Options::from_u_application_options(u_options);
161 return options->form_factor;
162}
163
164UAUiStage
165u_application_options_get_stage(UApplicationOptions* u_options)
166{
167 auto options = uam::Options::from_u_application_options(u_options);
168 return options->stage;
169}
170}
1710
=== removed file 'src/mircommon/application_options_mir_priv.h'
--- src/mircommon/application_options_mir_priv.h 2013-06-05 19:44:09 +0000
+++ src/mircommon/application_options_mir_priv.h 1970-01-01 00:00:00 +0000
@@ -1,58 +0,0 @@
1/*
2 * Copyright (C) 2013 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Robert Carr <robert.carr@canonical.com>
17 */
18
19#ifndef UBUNTU_APPLICATION_OPTIONS_MIR_PRIV_H_
20#define UBUNTU_APPLICATION_OPTIONS_MIR_PRIV_H_
21
22#include <ubuntu/application/options.h>
23#include <ubuntu/application/ui/options.h>
24
25#include <string>
26
27namespace ubuntu
28{
29namespace application
30{
31namespace mir
32{
33
34class Options
35{
36public:
37 Options() = default;
38 ~Options() = default;
39
40 UApplicationOptions* as_u_application_options();
41 static Options* from_u_application_options(UApplicationOptions* u_options);
42
43 UApplicationOperationMode operation_mode = U_APPLICATION_FOREGROUND_APP;
44 UAUiFormFactor form_factor = U_DESKTOP;
45 UAUiStage stage = U_MAIN_STAGE;
46
47 std::string desktop_file;
48
49protected:
50 Options(Options const&) = delete;
51 Options& operator=(Options const&) = delete;
52};
53
54}
55}
56} // namespace ubuntu
57
58#endif // UBUNTU_APPLICATION_OPTIONS_MIR_PRIV_H_
590
=== removed file 'src/mircommon/event_helpers_mir.cpp'
--- src/mircommon/event_helpers_mir.cpp 2013-06-05 21:15:46 +0000
+++ src/mircommon/event_helpers_mir.cpp 1970-01-01 00:00:00 +0000
@@ -1,77 +0,0 @@
1/*
2 * Copyright (C) 2013 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Robert Carr <robert.carr@canonical.com>
17 */
18
19#include "event_helpers_mir.h"
20
21namespace uaum = ubuntu::application::ui::mir;
22
23// TODO<mir>: This begs the question: Why does MirEvent exist? It's difficult to ensure this function is kept in sync
24// at the unit test level.
25void
26uaum::event_to_ubuntu_event(MirEvent const* mir_event, Event& ubuntu_ev)
27{
28 switch (mir_event->type)
29 {
30 case mir_event_type_key:
31 ubuntu_ev.type = KEY_EVENT_TYPE;
32 ubuntu_ev.device_id = mir_event->key.device_id;
33 ubuntu_ev.source_id = mir_event->key.source_id;
34 ubuntu_ev.action = mir_event->key.action;
35 ubuntu_ev.flags = mir_event->key.flags;
36 ubuntu_ev.meta_state = mir_event->key.modifiers;
37 ubuntu_ev.details.key.key_code = mir_event->key.key_code;
38 ubuntu_ev.details.key.scan_code = mir_event->key.scan_code;
39 ubuntu_ev.details.key.repeat_count = mir_event->key.repeat_count;
40 ubuntu_ev.details.key.down_time = mir_event->key.down_time;
41 ubuntu_ev.details.key.event_time = mir_event->key.event_time;
42 ubuntu_ev.details.key.is_system_key = mir_event->key.is_system_key;
43 break;
44 case mir_event_type_motion:
45 ubuntu_ev.type = MOTION_EVENT_TYPE;
46 ubuntu_ev.device_id = mir_event->motion.device_id;
47 ubuntu_ev.source_id = mir_event->motion.source_id;
48 ubuntu_ev.action = mir_event->motion.action;
49 ubuntu_ev.flags = mir_event->motion.flags;
50 ubuntu_ev.meta_state = mir_event->motion.modifiers;
51 ubuntu_ev.details.motion.edge_flags = mir_event->motion.edge_flags;
52 ubuntu_ev.details.motion.button_state = mir_event->motion.button_state;
53 ubuntu_ev.details.motion.x_offset = mir_event->motion.x_offset;
54 ubuntu_ev.details.motion.y_offset = mir_event->motion.y_offset;
55 ubuntu_ev.details.motion.x_precision = mir_event->motion.x_precision;
56 ubuntu_ev.details.motion.y_precision = mir_event->motion.y_precision;
57 ubuntu_ev.details.motion.down_time = mir_event->motion.down_time;
58 ubuntu_ev.details.motion.event_time = mir_event->motion.event_time;
59 ubuntu_ev.details.motion.pointer_count = mir_event->motion.pointer_count;
60 for (int i = 0; i < mir_event->motion.pointer_count; i++)
61 {
62 ubuntu_ev.details.motion.pointer_coordinates[i].id = mir_event->motion.pointer_coordinates[i].id;
63 ubuntu_ev.details.motion.pointer_coordinates[i].x = mir_event->motion.pointer_coordinates[i].x;
64 ubuntu_ev.details.motion.pointer_coordinates[i].raw_x = mir_event->motion.pointer_coordinates[i].raw_x;
65 ubuntu_ev.details.motion.pointer_coordinates[i].y = mir_event->motion.pointer_coordinates[i].y;
66 ubuntu_ev.details.motion.pointer_coordinates[i].raw_y = mir_event->motion.pointer_coordinates[i].raw_y;
67 ubuntu_ev.details.motion.pointer_coordinates[i].touch_major = mir_event->motion.pointer_coordinates[i].touch_major;
68 ubuntu_ev.details.motion.pointer_coordinates[i].touch_minor = mir_event->motion.pointer_coordinates[i].touch_minor;
69 ubuntu_ev.details.motion.pointer_coordinates[i].size = mir_event->motion.pointer_coordinates[i].size;
70 ubuntu_ev.details.motion.pointer_coordinates[i].pressure = mir_event->motion.pointer_coordinates[i].pressure;
71 ubuntu_ev.details.motion.pointer_coordinates[i].orientation = mir_event->motion.pointer_coordinates[i].orientation;
72 }
73 break;
74 default:
75 break;
76 }
77}
780
=== removed file 'src/mircommon/event_helpers_mir.h'
--- src/mircommon/event_helpers_mir.h 2013-06-05 20:02:14 +0000
+++ src/mircommon/event_helpers_mir.h 1970-01-01 00:00:00 +0000
@@ -1,39 +0,0 @@
1/*
2 * Copyright (C) 2013 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Robert Carr <robert.carr@canonical.com>
17 */
18
19#ifndef UBUNTU_EVENT_HELPERS_MIR_COMMON_H_
20#define UBUNTU_EVENT_HELPERS_MIR_COMMON_H_
21
22#include <ubuntu/application/ui/input/event.h>
23#include <mir_toolkit/event.h>
24
25namespace ubuntu
26{
27namespace application
28{
29namespace ui
30{
31namespace mir
32{
33void event_to_ubuntu_event(MirEvent const* mir_event, Event& ubuntu_ev);
34}
35}
36}
37}
38
39#endif // UBUNTU_EVENT_HELPERS_MIR_COMMON_H_
400
=== removed file 'src/mircommon/lifecycle_delegate_mir.cpp'
--- src/mircommon/lifecycle_delegate_mir.cpp 2013-06-07 17:23:48 +0000
+++ src/mircommon/lifecycle_delegate_mir.cpp 1970-01-01 00:00:00 +0000
@@ -1,136 +0,0 @@
1/*
2 * Copyright (C) 2013 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Robert Carr <robert.carr@canonical.com>
17 */
18
19#include "lifecycle_delegate_mir_priv.h"
20
21namespace uam = ubuntu::application::mir;
22
23// TODO<papi, mir>: This implementation as a stub as we
24// currently don't do anything with this in Mir. I am not sure
25// what exactly we should be doing either so we need some alignment
26// on this.
27
28uam::LifecycleDelegate::LifecycleDelegate()
29 : resumed_cb(nullptr),
30 stop_cb(nullptr),
31 ctx(nullptr)
32{
33}
34
35UApplicationLifecycleDelegate* uam::LifecycleDelegate::as_u_lifecycle_delegate()
36{
37 return static_cast<UApplicationLifecycleDelegate*>(this);
38}
39
40uam::LifecycleDelegate* uam::LifecycleDelegate::from_u_lifecycle_delegate(UApplicationLifecycleDelegate *u_delegate)
41{
42 return static_cast<uam::LifecycleDelegate*>(u_delegate);
43}
44
45void uam::LifecycleDelegate::ref()
46{
47 ref_count++;
48}
49
50void uam::LifecycleDelegate::unref()
51{
52 ref_count--;
53 if (ref_count == 0)
54 delete this;
55}
56
57
58extern "C"
59{
60
61UApplicationLifecycleDelegate*
62u_application_lifecycle_delegate_new()
63{
64 return (new uam::LifecycleDelegate)->as_u_lifecycle_delegate();
65}
66
67void
68u_application_lifecycle_delegate_destroy(UApplicationLifecycleDelegate *u_delegate)
69{
70 auto delegate = uam::LifecycleDelegate::from_u_lifecycle_delegate(u_delegate);
71
72 // TODO: What are the intended semantics of this?
73 delegate->unref();
74}
75
76void
77u_application_lifecycle_delegate_ref(UApplicationLifecycleDelegate *u_delegate)
78{
79 auto delegate = uam::LifecycleDelegate::from_u_lifecycle_delegate(u_delegate);
80 delegate->ref();
81}
82
83void
84u_application_lifecycle_delegate_unref(UApplicationLifecycleDelegate *u_delegate)
85{
86 auto delegate = uam::LifecycleDelegate::from_u_lifecycle_delegate(u_delegate);
87 delegate->unref();
88}
89
90void
91u_application_lifecycle_delegate_set_application_resumed_cb(UApplicationLifecycleDelegate *u_delegate,
92 u_on_application_resumed cb)
93{
94 auto delegate = uam::LifecycleDelegate::from_u_lifecycle_delegate(u_delegate);
95 delegate->resumed_cb = cb;
96}
97
98u_on_application_resumed
99u_application_lifecycle_delegate_get_application_resumed_cb(UApplicationLifecycleDelegate *u_delegate)
100{
101 auto delegate = uam::LifecycleDelegate::from_u_lifecycle_delegate(u_delegate);
102 return delegate->resumed_cb;
103}
104
105void
106u_application_lifecycle_delegate_set_application_about_to_stop_cb(UApplicationLifecycleDelegate *u_delegate,
107 u_on_application_about_to_stop cb)
108{
109 auto delegate = uam::LifecycleDelegate::from_u_lifecycle_delegate(u_delegate);
110 delegate->stop_cb = cb;
111}
112
113u_on_application_about_to_stop
114u_application_lifecycle_delegate_get_application_about_to_stop_cb(UApplicationLifecycleDelegate *u_delegate)
115{
116 auto delegate = uam::LifecycleDelegate::from_u_lifecycle_delegate(u_delegate);
117 return delegate->stop_cb;
118}
119
120void
121u_application_lifecycle_delegate_set_context(UApplicationLifecycleDelegate *u_delegate,
122 void *context)
123{
124 auto delegate = uam::LifecycleDelegate::from_u_lifecycle_delegate(u_delegate);
125 delegate->ctx = context;
126}
127
128void*
129u_application_lifecycle_delegate_get_context(UApplicationLifecycleDelegate *u_delegate,
130 void *context)
131{
132 auto delegate = uam::LifecycleDelegate::from_u_lifecycle_delegate(u_delegate);
133 return delegate->ctx;
134}
135
136}
1370
=== removed file 'src/mircommon/lifecycle_delegate_mir_priv.h'
--- src/mircommon/lifecycle_delegate_mir_priv.h 2013-06-07 17:23:48 +0000
+++ src/mircommon/lifecycle_delegate_mir_priv.h 1970-01-01 00:00:00 +0000
@@ -1,59 +0,0 @@
1/*
2 * Copyright (C) 2013 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Robert Carr <robert.carr@canonical.com>
17 */
18
19#ifndef UBUNTU_APPLICATION_LIECYCLE_DELEGATE_MIR_PRIV_H_
20#define UBUNTU_APPLICATION_LIECYCLE_DELEGATE_MIR_PRIV_H_
21
22#include <ubuntu/application/lifecycle_delegate.h>
23
24namespace ubuntu
25{
26namespace application
27{
28namespace mir
29{
30
31class LifecycleDelegate
32{
33public:
34 LifecycleDelegate();
35 ~LifecycleDelegate() = default;
36
37 UApplicationLifecycleDelegate* as_u_lifecycle_delegate();
38 static LifecycleDelegate* from_u_lifecycle_delegate(UApplicationLifecycleDelegate *u_delegate);
39
40 void ref();
41 void unref();
42
43 u_on_application_resumed resumed_cb;
44 u_on_application_about_to_stop stop_cb;
45 void *ctx;
46
47protected:
48 LifecycleDelegate(LifecycleDelegate const&) = delete;
49 LifecycleDelegate& operator=(LifecycleDelegate const&) = delete;
50
51private:
52 unsigned int ref_count;
53};
54
55}
56}
57}
58
59#endif // UBUNTU_APPLICATION_LIECYCLE_DELEGATE_MIR_PRIV_H_
600
=== removed file 'src/mircommon/session_mir.cpp'
--- src/mircommon/session_mir.cpp 2013-06-21 17:03:18 +0000
+++ src/mircommon/session_mir.cpp 1970-01-01 00:00:00 +0000
@@ -1,51 +0,0 @@
1/*
2 * Copyright (C) 2013 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Robert Carr <robert.carr@canonical.com>
17 */
18
19#include <ubuntu/application/ui/session.h>
20
21// TODO<papi>: Not sure what this should do for mir. ApplicationInstance maps to the mir
22// concept of a session and this doesn't really seem to be used
23
24extern "C"
25{
26
27UAUiSession* ua_ui_session_new_with_properties(UAUiSessionProperties *properties)
28{
29 return nullptr;
30}
31
32UAUiSessionProperties* ua_ui_session_properties_new()
33{
34 return nullptr;
35}
36
37void ua_ui_session_properties_set_type(UAUiSessionProperties* properties,
38 UAUiSessionType type)
39{
40 (void) properties;
41 (void) type;
42}
43
44void ua_ui_session_properties_set_remote_pid(UAUiSessionProperties* properties,
45 uint32_t pid)
46{
47 (void) properties;
48 (void) pid;
49}
50
51}
520
=== removed file 'src/mircommon/ubuntu_application_sensors_desktop.cpp'
--- src/mircommon/ubuntu_application_sensors_desktop.cpp 2013-06-05 23:47:51 +0000
+++ src/mircommon/ubuntu_application_sensors_desktop.cpp 1970-01-01 00:00:00 +0000
@@ -1,190 +0,0 @@
1/*
2 * Copyright (C) 2012 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Thomas Voss <thomas.voss@canonical.com>
17 * Ricardo Mendoza <ricardo.mendoza@canonical.com>
18 */
19
20#include <ubuntu/application/sensors/accelerometer.h>
21#include <ubuntu/application/sensors/proximity.h>
22#include <ubuntu/application/sensors/light.h>
23
24#include <stddef.h>
25
26// Ubuntu Application Sensors. Null desktop implementation
27
28// Acceleration Sensor
29UASensorsAccelerometer* ua_sensors_accelerometer_new()
30{
31 return NULL;
32}
33
34UStatus ua_sensors_accelerometer_enable(UASensorsAccelerometer*)
35{
36 return (UStatus) 0;
37}
38
39UStatus ua_sensors_accelerometer_disable(UASensorsAccelerometer*)
40{
41 return (UStatus) 0;
42}
43
44uint32_t ua_sensors_accelerometer_get_min_delay(UASensorsAccelerometer*)
45{
46 return 0;
47}
48
49float ua_sensors_accelerometer_get_min_value(UASensorsAccelerometer*)
50{
51 return 0.0;
52}
53
54float ua_sensors_accelerometer_get_max_value(UASensorsAccelerometer*)
55{
56 return 0.0;
57}
58
59float ua_sensors_accelerometer_get_resolution(UASensorsAccelerometer*)
60{
61 return 0.0;
62}
63
64void ua_sensors_accelerometer_set_reading_cb(UASensorsAccelerometer*, on_accelerometer_event_cb, void*)
65{
66}
67
68// Acceleration Sensor Event
69uint64_t uas_accelerometer_event_get_timestamp(UASAccelerometerEvent*)
70{
71 return 0;
72}
73
74float uas_accelerometer_event_get_acceleration_x(UASAccelerometerEvent*)
75{
76 return 0.0;
77}
78
79float uas_accelerometer_event_get_acceleration_y(UASAccelerometerEvent*)
80{
81 return 0.0;
82}
83
84float uas_accelerometer_event_get_acceleration_z(UASAccelerometerEvent*)
85{
86 return 0.0;
87}
88
89// Proximity Sensor
90UASensorsProximity* ua_sensors_proximity_new()
91{
92 return NULL;
93}
94
95UStatus ua_sensors_proximity_enable(UASensorsProximity*)
96{
97 return (UStatus) 0;
98}
99
100UStatus ua_sensors_proximity_disable(UASensorsProximity*)
101{
102 return (UStatus) 0;
103}
104
105uint32_t ua_sensors_proximity_get_min_delay(UASensorsProximity*)
106{
107 return 0;
108}
109
110float ua_sensors_proximity_get_min_value(UASensorsProximity*)
111{
112 return 0.0;
113}
114
115float ua_sensors_proximity_get_max_value(UASensorsProximity*)
116{
117 return 0.0;
118}
119
120float ua_sensors_proximity_get_resolution(UASensorsProximity*)
121{
122 return 0.0;
123}
124
125void ua_sensors_proximity_set_reading_cb(UASensorsProximity*, on_proximity_event_cb, void*)
126{
127}
128
129// Proximity Sensor Event
130uint64_t uas_proximity_event_get_timestamp(UASProximityEvent*)
131{
132 return 0;
133}
134
135UASProximityDistance uas_proximity_event_get_distance(UASProximityEvent*)
136{
137 return (UASProximityDistance) 0;
138}
139
140
141// Ambient Light Sensor
142UASensorsLight* ua_sensors_light_new()
143{
144 return NULL;
145}
146
147UStatus ua_sensors_light_enable(UASensorsLight*)
148{
149 return (UStatus) 0;
150}
151
152UStatus ua_sensors_light_disable(UASensorsLight*)
153{
154 return (UStatus) 0;
155}
156
157uint32_t ua_sensors_light_get_min_delay(UASensorsLight*)
158{
159 return 0;
160}
161
162float ua_sensors_light_get_min_value(UASensorsLight*)
163{
164 return 0.0;
165}
166
167float ua_sensors_light_get_max_value(UASensorsLight*)
168{
169 return 0.0;
170}
171
172float ua_sensors_light_get_resolution(UASensorsLight*)
173{
174 return 0.0;
175}
176
177void ua_sensors_light_set_reading_cb(UASensorsLight*, on_light_event_cb, void*)
178{
179}
180
181// Ambient Light Sensor Event
182uint64_t uas_light_event_get_timestamp(UASLightEvent*)
183{
184 return 0;
185}
186
187float uas_light_event_get_light(UASLightEvent*)
188{
189 return 0.0;
190}
1910
=== removed directory 'src/mirserver'
=== removed file 'src/mirserver/CMakeLists.txt'
--- src/mirserver/CMakeLists.txt 2013-07-18 09:08:17 +0000
+++ src/mirserver/CMakeLists.txt 1970-01-01 00:00:00 +0000
@@ -1,38 +0,0 @@
1set(SOURCES
2 ubuntu_application_api_mirserver.cpp
3 application_instance_mirserver.cpp
4 window_properties_mirserver.cpp
5 window_mirserver.cpp
6)
7
8set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++11 -fPIC")
9
10add_library(
11 ubuntu_application_api_mirserver SHARED
12 ${SOURCES}
13)
14
15include_directories(
16 ${CMAKE_BINARY_DIR}/include
17 ${MIRSERVER_INCLUDE_DIRS}
18)
19
20target_link_libraries(
21 ubuntu_application_api_mirserver
22 ${MIRSERVER_LDFLAGS} ${MIRSERVER_LIBRARIES}
23 -Wl,--whole-archive ubuntu_application_api_mircommon
24 -Wl,--no-whole-archive
25)
26
27
28install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/ubuntu_application_api_mirserver_priv.h DESTINATION include/ubuntu/priv/mirserver)
29
30set_target_properties(
31 ubuntu_application_api_mirserver
32 PROPERTIES
33 VERSION 1.0
34 SOVERSION 1
35)
36
37install(TARGETS ubuntu_application_api_mirserver ${INSTALL_TARGETS_DEFAULT_ARGS})
38install(FILES ubuntu_application_api_mirserver_priv.h DESTINATION include/ubuntu/application)
390
=== removed file 'src/mirserver/application_instance_mirserver.cpp'
--- src/mirserver/application_instance_mirserver.cpp 2013-06-17 22:51:21 +0000
+++ src/mirserver/application_instance_mirserver.cpp 1970-01-01 00:00:00 +0000
@@ -1,83 +0,0 @@
1/*
2 * Copyright (C) 2013 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Robert Carr <robert.carr@canonical.com>
17 */
18
19#include "application_instance_mirserver_priv.h"
20
21#include "mircommon/application_description_mir_priv.h"
22#include "mircommon/application_options_mir_priv.h"
23#include "mircommon/application_id_mir_priv.h"
24
25#include <mir/shell/surface.h>
26#include <mir/shell/surface_factory.h>
27#include <mir/shell/surface_creation_parameters.h>
28
29namespace uam = ubuntu::application::mir;
30namespace uams = uam::server;
31
32namespace mf = mir::frontend;
33namespace me = mir::events;
34namespace msh = mir::shell;
35
36uams::Instance::Instance(std::shared_ptr<msh::SurfaceFactory> const &surface_factory,
37 uam::Description* description_,
38 uam::Options *options_)
39 : surface_factory(surface_factory),
40 ref_count(1)
41{
42 description = DescriptionPtr(description_,
43 [] (uam::Description* p)
44 {
45 delete p;
46 });
47 options = OptionsPtr(options_,
48 [] (uam::Options* p)
49 {
50 delete p;
51 });
52}
53
54UApplicationInstance* uams::Instance::as_u_application_instance()
55{
56 return static_cast<UApplicationInstance*>(this);
57}
58
59uams::Instance* uams::Instance::from_u_application_instance(UApplicationInstance *u_instance)
60{
61 return static_cast<uams::Instance*>(u_instance);
62}
63
64void uams::Instance::ref()
65{
66 ref_count++;
67}
68
69void uams::Instance::unref()
70{
71 ref_count--;
72 if (ref_count == 0)
73 delete this;
74}
75
76std::shared_ptr<msh::Surface> uams::Instance::create_surface(msh::SurfaceCreationParameters const& parameters)
77{
78 static std::shared_ptr<me::EventSink> const null_event_sink{nullptr};
79 static mf::SurfaceId const default_surface_id{0};
80
81 return surface_factory->create_surface(parameters, default_surface_id,
82 null_event_sink);
83}
840
=== removed file 'src/mirserver/application_instance_mirserver_priv.h'
--- src/mirserver/application_instance_mirserver_priv.h 2013-06-17 22:51:21 +0000
+++ src/mirserver/application_instance_mirserver_priv.h 1970-01-01 00:00:00 +0000
@@ -1,85 +0,0 @@
1/*
2 * Copyright (C) 2013 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Robert Carr <robert.carr@canonical.com>
17 */
18
19#ifndef UBUNTU_APPLICATION_INSTANCE_MIRSERVER_PRIV_H_
20#define UBUNTU_APPLICATION_INSTANCE_MIRSERVER_PRIV_H_
21
22#include <ubuntu/application/instance.h>
23
24#include <memory>
25#include <functional>
26
27namespace mir
28{
29namespace shell
30{
31class SurfaceCreationParameters;
32class Surface;
33class SurfaceFactory;
34}
35}
36
37namespace ubuntu
38{
39namespace application
40{
41namespace mir
42{
43class Description;
44class Options;
45
46namespace server
47{
48
49class Instance
50{
51public:
52 Instance(std::shared_ptr< ::mir::shell::SurfaceFactory> const& surface_factory,
53 ubuntu::application::mir::Description* description,
54 ubuntu::application::mir::Options *options);
55 ~Instance() = default;
56
57 UApplicationInstance* as_u_application_instance();
58 static Instance* from_u_application_instance(UApplicationInstance* u_instance);
59
60 void ref();
61 void unref();
62
63 std::shared_ptr< ::mir::shell::Surface> create_surface( ::mir::shell::SurfaceCreationParameters const& parameters);
64
65protected:
66 Instance(Instance const&) = delete;
67 Instance& operator=(Instance const&) = delete;
68
69private:
70 typedef std::unique_ptr<Description, std::function<void(Description*)>> DescriptionPtr;
71 typedef std::unique_ptr<Options, std::function<void(Options*)>> OptionsPtr;
72
73 OptionsPtr options;
74 DescriptionPtr description;
75
76 std::shared_ptr< ::mir::shell::SurfaceFactory> const surface_factory;
77 int ref_count;
78};
79
80}
81}
82}
83} // namespace ubuntu
84
85#endif // UBUNTU_APPLICATION_INSTANCE_MIRSERVER_PRIV_H_
860
=== removed file 'src/mirserver/ubuntu_application_api_mirserver.cpp'
--- src/mirserver/ubuntu_application_api_mirserver.cpp 2013-06-17 22:51:21 +0000
+++ src/mirserver/ubuntu_application_api_mirserver.cpp 1970-01-01 00:00:00 +0000
@@ -1,320 +0,0 @@
1/*
2 * Copyright (C) 2013 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authored by: Robert Carr <robert.carr@canonical.com>
17 */
18
19#include "ubuntu_application_api_mirserver_priv.h"
20#include "application_instance_mirserver_priv.h"
21#include "window_properties_mirserver_priv.h"
22#include "window_mirserver_priv.h"
23
24#include "mircommon/application_id_mir_priv.h"
25#include "mircommon/application_description_mir_priv.h"
26#include "mircommon/application_options_mir_priv.h"
27
28// C APIs
29#include <ubuntu/application/lifecycle_delegate.h>
30#include <ubuntu/application/ui/window.h>
31#include <ubuntu/application/ui/options.h>
32#include <ubuntu/application/ui/session.h>
33#include <ubuntu/application/ui/clipboard.h>
34#include <ubuntu/application/ui/display.h>
35#include <ubuntu/application/sensors/accelerometer.h>
36#include <ubuntu/application/sensors/proximity.h>
37#include <ubuntu/application/sensors/light.h>
38
39#include <mir/default_server_configuration.h>
40
41#include <mir/graphics/display.h>
42#include <mir/graphics/platform.h>
43#include <mir/compositor/graphic_buffer_allocator.h>
44#include <mir/frontend/session.h>
45#include <mir/frontend/shell.h>
46#include <mir/shell/surface_creation_parameters.h>
47#include <mir/shell/surface.h>
48#include <mir/graphics/internal_client.h>
49#include <mir/input/input_platform.h>
50
51#include <assert.h>
52
53#include <memory>
54#include <functional>
55
56namespace uam = ubuntu::application::mir;
57namespace uams = ubuntu::application::mir::server;
58
59namespace
60{
61
62struct MirServerContext
63{
64 std::shared_ptr<mir::graphics::Display> display;
65 std::shared_ptr<mir::compositor::GraphicBufferAllocator> buffer_allocator;
66 std::shared_ptr<mir::shell::SurfaceFactory> surface_factory;
67 std::shared_ptr<mir::input::receiver::InputPlatform> input_platform;
68 std::shared_ptr<mir::graphics::InternalClient> egl_client;
69};
70
71MirServerContext *
72global_mirserver_context()
73{
74 static MirServerContext context;
75 return &context;
76}
77
78extern "C"
79{
80void ua_ui_mirserver_init(mir::DefaultServerConfiguration& config)
81{
82 auto context = global_mirserver_context();
83
84 context->display = config.the_display();
85 context->buffer_allocator = config.the_buffer_allocator();
86 context->surface_factory = config.the_shell_surface_factory();
87 context->input_platform = mir::input::receiver::InputPlatform::create();
88 context->egl_client = config.the_graphics_platform()->create_internal_client();
89}
90
91void ua_ui_mirserver_finish()
92{
93 auto context = global_mirserver_context();
94
95 context->display.reset();
96 context->surface_factory.reset();
97 context->input_platform.reset();
98 context->egl_client.reset();
99}
100}
101
102}
103
104
105extern "C"
106{
107
108UApplicationInstance* u_application_instance_new_from_description_with_options(UApplicationDescription* u_description, UApplicationOptions* u_options)
109{
110 auto surface_factory = global_mirserver_context()->surface_factory;
111 assert(surface_factory);
112
113 auto description = uam::Description::from_u_application_description(u_description);
114 auto options = uam::Options::from_u_application_options(u_options);
115
116 auto instance = new uams::Instance(surface_factory, description, options);
117
118 return instance->as_u_application_instance();
119}
120
121void
122u_application_instance_ref(UApplicationInstance *u_instance)
123{
124 auto instance = uams::Instance::from_u_application_instance(u_instance);
125 instance->ref();
126}
127
128void
129u_application_instance_unref(UApplicationInstance *u_instance)
130{
131 auto instance = uams::Instance::from_u_application_instance(u_instance);
132 instance->unref();
133}
134
135void
136u_application_instance_destroy(UApplicationInstance *instance)
137{
138 // TODO<papi>: What are the proper semantics here.
139 u_application_instance_unref(instance);
140}
141
142void
143u_application_instance_run(UApplicationInstance *instance)
144{
145 // TODO<papi>: What is this supposed to do? Seems to be no-op on hybris.
146 (void) instance;
147}
148
149void ua_ui_set_clipboard_content(void* content, size_t content_size)
150{
151 // TODO<mir,papi>: Implement. Probably need more arguments?
152 (void) content;
153 (void) content_size;
154}
155
156void ua_ui_get_clipboard_content(void** out_content, size_t* out_content_size)
157{
158 // TODO<mir,papi>: Implement
159 *out_content = NULL;
160 *out_content_size = 0;
161}
162
163UAUiDisplay* ua_ui_display_new_with_index(size_t index)
164{
165 // TODO<mir>: Make use of index. This is kind of strangely done...
166 return reinterpret_cast<UAUiDisplay*>(index);
167}
168
169void ua_ui_display_destroy(UAUiDisplay* display)
170{
171 // TODO: Implement. Or is this a noop for mirserver?
172 (void) display;
173}
174
175uint32_t ua_ui_display_query_horizontal_res(UAUiDisplay* display)
176{
177 (void) display; // TODO<mir>: Multiple displays
178
179 auto mir_display = global_mirserver_context()->display;
180 assert(mir_display);
181
182 return mir_display->view_area().size.width.as_uint32_t();
183}
184
185uint32_t ua_ui_display_query_vertical_res(UAUiDisplay* display)
186{
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches