diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/controller/controller_car_selection.c | 20 | ||||
-rw-r--r-- | src/controller/controller_connect_to_car.c | 23 | ||||
-rw-r--r-- | src/model/model_connection.c | 40 |
3 files changed, 69 insertions, 14 deletions
diff --git a/src/controller/controller_car_selection.c b/src/controller/controller_car_selection.c index 5583704..58aa987 100644 --- a/src/controller/controller_car_selection.c +++ b/src/controller/controller_car_selection.c @@ -14,20 +14,29 @@ * limitations under the License. */ +#include "model/model_connection.h" #include "controller/controller_car_selection.h" #include "view_manager/view_manager.h" static s_controller *controller = NULL; +static void controller_car_selection_destroy(void) +{ + free(controller); +} + +static void _connected_cb(void *is_connected) +{ + view_manager_set_view(VIEW_CONNECT_TO_CAR); + controller_car_selection_destroy(); +} + void controller_car_selection_init(t_view_update_cb view_update_cb) { controller = calloc(1, sizeof(s_controller)); controller->view_update_cb = view_update_cb; -} -void controller_car_selection_destroy(void) -{ - free(controller); + model_connection_subscribe_event(_connected_cb); } void controller_car_selection_back_btn(void) @@ -37,6 +46,5 @@ void controller_car_selection_back_btn(void) void controller_car_selection_next_page() { - view_manager_set_view(VIEW_CAR_SELECTION); - controller_car_selection_destroy(); + model_connection_connect(); } diff --git a/src/controller/controller_connect_to_car.c b/src/controller/controller_connect_to_car.c index 1799389..11b3f0c 100644 --- a/src/controller/controller_connect_to_car.c +++ b/src/controller/controller_connect_to_car.c @@ -14,14 +14,26 @@ * limitations under the License. */ -#include <controller/controller_base.h> #include <assert.h> +#include <controller/controller_base.h> +#include "model/model_connection.h" #include "gear-racing-controller.h" #include "controller/controller_connect_to_car.h" #include "view_manager/view_manager.h" static s_controller *controller = NULL; +static void controller_connect_to_car_destroy(void) +{ + free(controller); +} + +static void _connected_cb(void *is_connected) +{ + view_manager_set_view(VIEW_CAR_SELECTION); + controller_connect_to_car_destroy(); +} + void controller_connect_to_car_init(t_view_update_cb view_update_cb) { controller = calloc(1, sizeof(s_controller)); @@ -30,11 +42,8 @@ void controller_connect_to_car_init(t_view_update_cb view_update_cb) } controller->view_update_cb = view_update_cb; -} -void controller_connect_to_car_destroy(void) -{ - free(controller); + model_connection_subscribe_event(_connected_cb); } void controller_connect_to_car_back_btn(void) { @@ -44,7 +53,5 @@ void controller_connect_to_car_back_btn(void) void controller_connect_to_car_next_page() { - //TODO model - view_manager_set_view(VIEW_CAR_SELECTION); - controller_connect_to_car_destroy(); + model_connection_connect(); } diff --git a/src/model/model_connection.c b/src/model/model_connection.c new file mode 100644 index 0000000..0856400 --- /dev/null +++ b/src/model/model_connection.c @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2018 Samsung Electronics Co., Ltd. +* +* Licensed under the Flora License, Version 1.1 (the License); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://floralicense.org/license/ +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an AS IS BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "gear-racing-controller.h" +#include "model/model_connection.h" + +typedef struct _s_model_connection { + t_model_update_cb model_update_cb; +} s_model_connection; + +s_model_connection model_connection = { 0, }; + +void model_connection_init(void) +{ + //TODO init stuff +} + +void model_connection_subscribe_event(t_model_update_cb model_update_cb) +{ + model_connection.model_update_cb = model_update_cb; +} + +void model_connection_connect(void) +{ + model_connection.model_update_cb((void *)true); +} + |