Remove trivial unnecessary build dependency
[apps/core/preloaded/lockscreen.git] / src / util.c
1 /*
2  * Copyright 2016  Samsung Electronics Co., Ltd
3  *
4  * Licensed under the Flora License, Version 1.1 (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
7  *
8  * http://floralicense.org/license/
9  *
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.
15  */
16
17 #include <app_common.h>
18 #include <feedback.h>
19
20 #include "log.h"
21 #include "util.h"
22 #include "lockscreen.h"
23
24 const char *util_get_file_path(enum app_subdir dir, const char *relative)
25 {
26         static char buf[PATH_MAX];
27         char *prefix;
28
29         switch (dir) {
30         case APP_DIR_DATA:
31                 prefix = app_get_data_path();
32                 break;
33         case APP_DIR_CACHE:
34                 prefix = app_get_cache_path();
35                 break;
36         case APP_DIR_RESOURCE:
37                 prefix = app_get_resource_path();
38                 break;
39         case APP_DIR_SHARED_DATA:
40                 prefix = app_get_shared_data_path();
41                 break;
42         case APP_DIR_SHARED_RESOURCE:
43                 prefix = app_get_shared_resource_path();
44                 break;
45         case APP_DIR_SHARED_TRUSTED:
46                 prefix = app_get_shared_trusted_path();
47                 break;
48         case APP_DIR_EXTERNAL_DATA:
49                 prefix = app_get_external_data_path();
50                 break;
51         case APP_DIR_EXTERNAL_CACHE:
52                 prefix = app_get_external_cache_path();
53                 break;
54         case APP_DIR_EXTERNAL_SHARED_DATA:
55                 prefix = app_get_external_shared_data_path();
56                 break;
57         default:
58                 FAT("Not handled directory type.");
59                 return NULL;
60         }
61         size_t res = eina_file_path_join(buf, sizeof(buf), prefix, relative);
62         free(prefix);
63         if (res > sizeof(buf)) {
64                 ERR("Path exceeded PATH_MAX");
65                 return NULL;
66         }
67
68         return &buf[0];
69 }
70
71 const Elm_Theme *util_lockscreen_theme_get(void)
72 {
73         static Elm_Theme *theme;
74         if (!theme)
75         {
76                 theme = elm_theme_new();
77                 elm_theme_ref_set(theme, NULL);
78                 elm_theme_overlay_add(NULL, util_get_res_file_path(EDJE_DIR"index.edj"));
79         }
80         return theme;
81 }
82
83 void util_feedback_tap_play(void)
84 {
85         static int init;
86         if (!init) {
87                 int ret = feedback_initialize();
88                 if (ret != FEEDBACK_ERROR_NONE) {
89                         FAT("feedback_initialize failed.");
90                 }
91                 init = 1;
92         }
93         feedback_play_type(FEEDBACK_TYPE_SOUND, FEEDBACK_PATTERN_TAP);
94 }