9698630c98df8dd8746df10548c65775f183dab2
[framework/api/application.git] / src / storage_internal.c
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
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
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <string.h>
21 #include <sys/vfs.h>
22
23 #include <aul.h>
24 #include <dlog.h>
25 #include <vconf.h>
26
27 #include <app_storage.h>
28 #include <app_storage_private.h>
29
30 #ifdef LOG_TAG
31 #undef LOG_TAG
32 #endif
33
34 #define LOG_TAG "CAPI_APPFW_APPLICATION_STORAGE"
35
36 #define INTERNAL_MEMORY_PATH "/opt/usr/media"
37
38 int storage_internal_get_state()
39 {
40         return STORAGE_STATE_MOUNTED;
41 }
42
43 static int storage_internal_set_state_cb(void *data)
44 {
45         return 0;
46 }
47
48 static void storage_internal_unset_state_cb()
49 {
50         // empty function
51 }
52
53 int storage_internal_get_space(unsigned long long *total, unsigned long long *available)
54 {
55         return storage_statfs(INTERNAL_MEMORY_PATH, total, available);
56 }
57
58 storage_device_h storage_internal_device()
59 {
60         storage_device_h device;
61
62         device = calloc(1, sizeof(struct storage_device_s));
63
64         if (device == NULL)
65         {
66                 LOGE("OUT_OF_MEMORY(0x%08x)", STORAGE_ERROR_OUT_OF_MEMORY);
67                 return NULL;
68         }
69
70         device->type = STORAGE_TYPE_INTERNAL;
71         device->path = INTERNAL_MEMORY_PATH;
72         device->get_state = storage_internal_get_state;
73         device->set_state_cb = storage_internal_set_state_cb;
74         device->unset_state_cb = storage_internal_unset_state_cb;
75         device->get_space = storage_internal_get_space;
76
77         return device;
78 }
79