~ricmm/platform-api/guards-for-null-sensors

« back to all changes in this revision

Viewing changes to src/android/ubuntu_application_api.cpp

* Add headers for new refactored platform API
* Implement new API for Android/hybris backend
* Implement lifecycle iteration 0 delegates infrastructure
* Do away with all old public headers and use only the new API.

Approved by Michael Frey, Ricardo Salveti, Thomas Voß, PS Jenkins bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
#include <ubuntu/application/sensors/ubuntu_application_sensors.h>
22
22
#include <ubuntu/application/ubuntu_application_gps.h>
23
23
#include <ubuntu/ui/ubuntu_ui_session_service.h>
 
24
#include <ubuntu/application/lifecycle_delegate.h>
 
25
 
 
26
// C APIs
 
27
#include <ubuntu/application/lifecycle_delegate.h>
 
28
#include <ubuntu/application/ui/window.h>
 
29
#include <ubuntu/application/ui/options.h>
 
30
#include <ubuntu/application/ui/session.h>
 
31
#include <ubuntu/application/ui/clipboard.h>
 
32
#include <ubuntu/application/ui/display.h>
24
33
 
25
34
#include <assert.h>
26
35
#include <dlfcn.h>
121
130
        DLSYM(&f, #symbol);                              \
122
131
        f(_1, _2); }
123
132
 
 
133
#define IMPLEMENT_FUNCTION3(return_type, symbol, arg1, arg2, arg3)    \
 
134
    return_type symbol(arg1 _1, arg2 _2, arg3 _3)                     \
 
135
    {                                                                 \
 
136
        static return_type (*f)(arg1, arg2, arg3) = NULL;             \
 
137
        DLSYM(&f, #symbol);                                           \
 
138
        return f(_1, _2, _3); } 
 
139
 
124
140
#define IMPLEMENT_VOID_FUNCTION3(symbol, arg1, arg2, arg3)      \
125
141
    void symbol(arg1 _1, arg2 _2, arg3 _3)                      \
126
142
    {                                                           \
163
179
        DLSYM(&f, #symbol);                                             \
164
180
        f(_1, _2, _3, _4, _5, _6, _7, _8); }
165
181
 
166
 
 
167
 
    IMPLEMENT_VOID_FUNCTION2(ubuntu_application_ui_init, int, char**);
168
 
    IMPLEMENT_FUNCTION0(StageHint, ubuntu_application_ui_setup_get_stage_hint);
169
 
    IMPLEMENT_FUNCTION0(FormFactorHint, ubuntu_application_ui_setup_get_form_factor_hint);
170
 
    IMPLEMENT_VOID_FUNCTION1(ubuntu_application_ui_start_a_new_session, SessionCredentials*);
171
 
    IMPLEMENT_VOID_FUNCTION2(ubuntu_application_ui_set_clipboard_content, void*, size_t);
172
 
    IMPLEMENT_VOID_FUNCTION2(ubuntu_application_ui_get_clipboard_content, void**, size_t*);
173
 
    IMPLEMENT_VOID_FUNCTION2(ubuntu_application_ui_create_display_info, ubuntu_application_ui_physical_display_info*, size_t);
174
 
    IMPLEMENT_VOID_FUNCTION1(ubuntu_application_ui_destroy_display_info, ubuntu_application_ui_physical_display_info);
175
 
    IMPLEMENT_FUNCTION1(int32_t, ubuntu_application_ui_query_horizontal_resolution, ubuntu_application_ui_physical_display_info);
176
 
    IMPLEMENT_FUNCTION1(int32_t, ubuntu_application_ui_query_vertical_resolution, ubuntu_application_ui_physical_display_info);  
177
 
    IMPLEMENT_FUNCTION1(float, ubuntu_application_ui_query_horizontal_dpi, ubuntu_application_ui_physical_display_info);
178
 
    IMPLEMENT_FUNCTION1(float, ubuntu_application_ui_query_vertical_dpi, ubuntu_application_ui_physical_display_info);    
179
 
    IMPLEMENT_VOID_FUNCTION8(ubuntu_application_ui_create_surface, ubuntu_application_ui_surface*, const char*, int, int, SurfaceRole, uint32_t, input_event_cb, void*);
180
 
    IMPLEMENT_VOID_FUNCTION1(ubuntu_application_ui_request_fullscreen_for_surface, ubuntu_application_ui_surface);
181
 
    IMPLEMENT_VOID_FUNCTION1(ubuntu_application_ui_destroy_surface, ubuntu_application_ui_surface);
182
 
    IMPLEMENT_FUNCTION1(EGLNativeWindowType, ubuntu_application_ui_surface_to_native_window_type, ubuntu_application_ui_surface);
183
 
    IMPLEMENT_VOID_FUNCTION1(ubuntu_application_ui_show_surface, ubuntu_application_ui_surface);
184
 
    IMPLEMENT_VOID_FUNCTION1(ubuntu_application_ui_hide_surface, ubuntu_application_ui_surface);
185
 
    IMPLEMENT_VOID_FUNCTION3(ubuntu_application_ui_move_surface_to, ubuntu_application_ui_surface, int, int);
186
 
    IMPLEMENT_VOID_FUNCTION3(ubuntu_application_ui_resize_surface_to, ubuntu_application_ui_surface, int, int);
 
182
// Session helpers
 
183
IMPLEMENT_FUNCTION0(UAUiSessionProperties*, ua_ui_session_properties_new);
 
184
IMPLEMENT_VOID_FUNCTION2(ua_ui_session_properties_set_type, UAUiSessionProperties*, UAUiSessionType);
 
185
IMPLEMENT_FUNCTION1(UAUiSession*, ua_ui_session_new_with_properties, UAUiSessionProperties*);
 
186
 
 
187
// Lifecycle helpers
 
188
IMPLEMENT_FUNCTION0(UApplicationLifecycleDelegate*, u_application_lifecycle_delegate_new);
 
189
IMPLEMENT_VOID_FUNCTION2(u_application_lifecycle_delegate_set_context, UApplicationLifecycleDelegate*, void*);
 
190
IMPLEMENT_VOID_FUNCTION1(u_application_lifecycle_delegate_ref, UApplicationLifecycleDelegate*);
 
191
IMPLEMENT_VOID_FUNCTION1(u_application_lifecycle_delegate_unref, UApplicationLifecycleDelegate*);
 
192
IMPLEMENT_VOID_FUNCTION2(u_application_lifecycle_delegate_set_application_resumed_cb, UApplicationLifecycleDelegate*, u_on_application_resumed);
 
193
IMPLEMENT_VOID_FUNCTION2(u_application_lifecycle_delegate_set_application_about_to_stop_cb, UApplicationLifecycleDelegate*, u_on_application_about_to_stop);
 
194
 
 
195
// Application Helpers
 
196
 
 
197
// UApplicationId
 
198
IMPLEMENT_FUNCTION2(UApplicationId*, u_application_id_new_from_stringn, const char*, size_t);
 
199
IMPLEMENT_VOID_FUNCTION1(u_application_id_destroy, UApplicationId*);
 
200
IMPLEMENT_FUNCTION2(int, u_application_id_compare, UApplicationId*, UApplicationId*);
 
201
 
 
202
// UApplicationDescription
 
203
IMPLEMENT_FUNCTION0(UApplicationDescription*, u_application_description_new);
 
204
IMPLEMENT_VOID_FUNCTION1(u_application_description_destroy, UApplicationDescription*);
 
205
IMPLEMENT_VOID_FUNCTION2(u_application_description_set_application_id, UApplicationDescription*, UApplicationId*);
 
206
IMPLEMENT_VOID_FUNCTION2(u_application_description_set_application_lifecycle_delegate, UApplicationDescription*, UApplicationLifecycleDelegate*);
 
207
 
 
208
// UApplicationOptions
 
209
IMPLEMENT_FUNCTION2(UApplicationOptions*, u_application_options_new_from_cmd_line, int, char**);
 
210
IMPLEMENT_VOID_FUNCTION1(u_application_options_destroy, UApplicationOptions*);
 
211
IMPLEMENT_FUNCTION1(UAUiFormFactor, u_application_options_get_form_factor, UApplicationOptions*);
 
212
IMPLEMENT_FUNCTION1(UAUiStage, u_application_options_get_stage, UApplicationOptions*);
 
213
 
 
214
// UApplicationInstance
 
215
IMPLEMENT_FUNCTION2(UApplicationInstance*, u_application_instance_new_from_description_with_options, UApplicationDescription*, UApplicationOptions*);
 
216
 
 
217
// Application Ui Helpers
 
218
 
 
219
// Clipboard
 
220
IMPLEMENT_VOID_FUNCTION2(ua_ui_set_clipboard_content, void*, size_t);
 
221
IMPLEMENT_VOID_FUNCTION2(ua_ui_get_clipboard_content, void**, size_t*);
 
222
 
 
223
// UAUiDisplay
 
224
IMPLEMENT_FUNCTION1(UAUiDisplay*, ua_ui_display_new_with_index, size_t);
 
225
IMPLEMENT_VOID_FUNCTION1(ua_ui_display_destroy, UAUiDisplay*);
 
226
IMPLEMENT_FUNCTION1(uint32_t, ua_ui_display_query_horizontal_res, UAUiDisplay*);
 
227
IMPLEMENT_FUNCTION1(uint32_t, ua_ui_display_query_vertical_res, UAUiDisplay*);
 
228
 
 
229
 
 
230
// UAUiWindowProperties
 
231
IMPLEMENT_FUNCTION0(UAUiWindowProperties*, ua_ui_window_properties_new_for_normal_window);
 
232
IMPLEMENT_VOID_FUNCTION1(ua_ui_window_properties_destroy, UAUiWindowProperties*);
 
233
IMPLEMENT_VOID_FUNCTION3(ua_ui_window_properties_set_titlen, UAUiWindowProperties*, const char*, size_t);
 
234
IMPLEMENT_FUNCTION1(const char*, ua_ui_window_properties_get_title, UAUiWindowProperties*);
 
235
IMPLEMENT_VOID_FUNCTION2(ua_ui_window_properties_set_role, UAUiWindowProperties*, UAUiWindowRole);
 
236
IMPLEMENT_VOID_FUNCTION3(ua_ui_window_properties_set_input_cb_and_ctx, UAUiWindowProperties*, UAUiWindowInputEventCb, void*);
 
237
 
 
238
// UAUiWindow
 
239
IMPLEMENT_FUNCTION2(UAUiWindow*, ua_ui_window_new_for_application_with_properties, UApplicationInstance*, UAUiWindowProperties*);
 
240
IMPLEMENT_VOID_FUNCTION1(ua_ui_window_destroy, UAUiWindow*);
 
241
IMPLEMENT_FUNCTION3(UStatus, ua_ui_window_move, UAUiWindow*, uint32_t, uint32_t);
 
242
IMPLEMENT_FUNCTION3(UStatus, ua_ui_window_resize, UAUiWindow*, uint32_t, uint32_t);
 
243
IMPLEMENT_FUNCTION1(UStatus, ua_ui_window_hide, UAUiWindow*);
 
244
IMPLEMENT_FUNCTION1(UStatus, ua_ui_window_show, UAUiWindow*);
 
245
IMPLEMENT_VOID_FUNCTION1(ua_ui_window_request_fullscreen, UAUiWindow*);
 
246
IMPLEMENT_FUNCTION1(EGLNativeWindowType, ua_ui_window_get_native_type, UAUiWindow*);
 
247
 
 
248
 
 
249
/* -------------------------------------------------------------------------- *
 
250
 * * * * * * * * * * * * * * * Deprecated API * * * * * * * * * * * * * * * * *
 
251
 * -------------------------------------------------------------------------- *
 
252
 */
187
253
 
188
254
// Session service
189
255
IMPLEMENT_FUNCTION1(int, ubuntu_ui_session_properties_get_application_instance_id, ubuntu_ui_session_properties);