4 * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Ja-young Gu <jygu@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
29 #include "user_request.h"
32 struct private_object_data {
33 struct tcore_gps_operations *ops;
36 static void _clone_hook(CoreObject *src, CoreObject *dest)
38 struct private_object_data *src_po = NULL;
39 struct private_object_data *dest_po = NULL;
44 dest_po = calloc(sizeof(struct private_object_data), 1);
46 tcore_object_link_object(dest, NULL);
50 src_po = tcore_object_ref_object(src);
51 dest_po->ops = src_po->ops;
53 tcore_object_link_object(dest, dest_po);
56 static TReturn _dispatcher(CoreObject *o, UserRequest *ur)
58 enum tcore_request_command command;
59 struct private_object_data *po = NULL;
62 return TCORE_RETURN_EINVAL;
64 po = tcore_object_ref_object(o);
66 return TCORE_RETURN_ENOSYS;
68 command = tcore_user_request_get_command(ur);
70 case TREQ_GPS_CONFIRM_MEASURE_POS:
71 dbg("TREQ_GPS_CONFIRM_MEASURE_POS");
72 if (!po->ops->confirm_measure_pos)
73 return TCORE_RETURN_ENOSYS;
75 return po->ops->confirm_measure_pos(o, ur);
78 dbg("not supported cmd");
81 return TCORE_RETURN_SUCCESS;
84 CoreObject *tcore_gps_new(TcorePlugin *p, const char *name,
85 struct tcore_gps_operations *ops, TcoreHal *hal)
88 struct private_object_data *po = NULL;
93 o = tcore_object_new(p, name, hal);
97 po = calloc(sizeof(struct private_object_data), 1);
105 tcore_object_set_type(o, CORE_OBJECT_TYPE_GPS);
106 tcore_object_link_object(o, po);
107 tcore_object_set_dispatcher(o, _dispatcher);
108 tcore_object_set_clone_hook(o, _clone_hook);
113 void tcore_gps_free(CoreObject *o)
115 struct private_object_data *po = NULL;
117 CORE_OBJECT_CHECK(o, CORE_OBJECT_TYPE_GPS);
119 po = tcore_object_ref_object(o);
124 tcore_object_link_object(o, po);
125 tcore_object_free(o);