2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <vconf-internal-keys.h>
20 #include <app_common.h>
21 #include <app_internal.h>
23 app_device_orientation_e app_convert_appcore_rm(enum appcore_rm rm)
25 app_device_orientation_e dev_orientation;
29 case APPCORE_RM_PORTRAIT_NORMAL:
30 dev_orientation = APP_DEVICE_ORIENTATION_0;
33 case APPCORE_RM_PORTRAIT_REVERSE:
34 dev_orientation = APP_DEVICE_ORIENTATION_180;
37 case APPCORE_RM_LANDSCAPE_NORMAL:
38 dev_orientation = APP_DEVICE_ORIENTATION_270;
41 case APPCORE_RM_LANDSCAPE_REVERSE:
42 dev_orientation = APP_DEVICE_ORIENTATION_90;
46 dev_orientation = APP_DEVICE_ORIENTATION_0;
50 return dev_orientation;
53 static int _app_convert_low_memory(void *val)
55 switch (*(int *)val) {
56 case VCONFKEY_SYSMAN_LOW_MEMORY_NORMAL:
57 return APP_EVENT_LOW_MEMORY_NORMAL;
58 case VCONFKEY_SYSMAN_LOW_MEMORY_SOFT_WARNING:
59 return APP_EVENT_LOW_MEMORY_SOFT_WARNING;
60 case VCONFKEY_SYSMAN_LOW_MEMORY_HARD_WARNING:
61 return APP_EVENT_LOW_MEMORY_HARD_WARNING;
67 static int _app_convert_low_battery(void *val)
69 switch (*(int *)val) {
70 case VCONFKEY_SYSMAN_BAT_POWER_OFF:
71 return APP_EVENT_LOW_BATTERY_POWER_OFF;
72 case VCONFKEY_SYSMAN_BAT_CRITICAL_LOW:
73 return APP_EVENT_LOW_BATTERY_CRITICAL_LOW;
79 int app_event_get_low_memory_status(app_event_info_h event_info, app_event_low_memory_status_e *status)
83 if (event_info == NULL || status == NULL)
84 return app_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__, "null parameter");
86 if (event_info->type != APP_EVENT_LOW_MEMORY)
87 return app_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__, "event type mismatching");
89 ret = _app_convert_low_memory(event_info->value);
91 return app_error(APP_ERROR_INVALID_CONTEXT, __FUNCTION__, "invalid event info");
95 return APP_ERROR_NONE;
98 int app_event_get_low_battery_status(app_event_info_h event_info, app_event_low_battery_status_e *status)
102 if (event_info == NULL || status == NULL)
103 return app_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__, "null parameter");
105 if (event_info->type != APP_EVENT_LOW_BATTERY)
106 return app_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__, "event type mismatching");
108 ret = _app_convert_low_battery(event_info->value);
110 return app_error(APP_ERROR_INVALID_CONTEXT, __FUNCTION__, "invalid event info");
114 return APP_ERROR_NONE;
117 int app_event_get_language(app_event_info_h event_info, char **lang)
119 if (event_info == NULL || lang == NULL)
120 return app_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__, "null parameter");
122 if (event_info->type != APP_EVENT_LANGUAGE_CHANGED)
123 return app_error(APP_ERROR_INVALID_CONTEXT, __FUNCTION__, "event type mismatching");
125 *lang = strdup(event_info->value);
127 return APP_ERROR_NONE;
130 int app_event_get_region_format(app_event_info_h event_info, char **region)
132 if (event_info == NULL || region == NULL)
133 return app_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__, "null parameter");
135 if (event_info->type != APP_EVENT_REGION_FORMAT_CHANGED)
136 return app_error(APP_ERROR_INVALID_CONTEXT, __FUNCTION__, "event type mismatching");
138 *region = strdup(event_info->value);
140 return APP_ERROR_NONE;
143 int app_event_get_device_orientation(app_event_info_h event_info, app_device_orientation_e *orientation)
145 if (event_info == NULL || orientation == NULL)
146 return app_error(APP_ERROR_INVALID_PARAMETER, __FUNCTION__, "null parameter");
148 if (event_info->type != APP_EVENT_DEVICE_ORIENTATION_CHANGED)
149 return app_error(APP_ERROR_INVALID_CONTEXT, __FUNCTION__, "event type mismatching");
151 *orientation = app_convert_appcore_rm(*(enum appcore_rm *)(event_info->value));
153 return APP_ERROR_NONE;