summaryrefslogtreecommitdiff
path: root/src/controller/controller_connect_to_car.c
blob: 11b3f0c040c21c9483c277f1f07e396876b0133c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
* 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 <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));
	if (!controller) {
		assert(!"Failed to create controller");
	}

	controller->view_update_cb = view_update_cb;

	model_connection_subscribe_event(_connected_cb);
}
void controller_connect_to_car_back_btn(void)
{
	dlog_print(DLOG_DEBUG, LOG_TAG, "% s %s", basename(__FILE__), __FUNCTION__);
	controller_connect_to_car_destroy();
}

void controller_connect_to_car_next_page()
{
	model_connection_connect();
}