Merge "fixed bug of app-control that didn't work with font-size" into 2.0_beta
[apps/core/preloaded/settings.git] / setting-memory / src / setting-memory-common.c
1 /*
2  * setting
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd.
5  *
6  * Contact: MyoungJune Park <mj2004.park@samsung.com>
7  * 
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
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
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.
19  *
20  */
21 #include <setting-memory-common.h>
22 #include<sys/wait.h>
23
24 int setting_memory_update_popup_with_progress_bar(void *data)
25 {
26         SETTING_TRACE_BEGIN;
27         SettingMemoryUG *ad = (SettingMemoryUG *) data;
28
29         if (ad->progress_bar != NULL) {
30                 SETTING_TRACE("ad->progress_bar_rate = %f",
31                               (float)ad->progress_bar_rate);
32                 elm_progressbar_value_set(ad->progress_bar,
33                                           ad->progress_bar_rate);
34         }
35
36         if (ad->progress_bar_timer != NULL) {
37                 ecore_timer_del(ad->progress_bar_timer);
38                 ad->progress_bar_timer = NULL;
39         }
40
41         return 0;
42 }
43
44 void setting_memory_hide_popup_with_progress_bar(SettingMemoryUG *ad)
45 {
46         SETTING_TRACE_BEGIN;
47         if (ad->progress_bar) {
48                 elm_progressbar_value_set(ad->progress_bar, 1.0);
49
50                 evas_object_del(ad->progress_bar);
51                 ad->progress_bar = NULL;
52         }
53         if (ad->popup) {
54                 evas_object_del(ad->popup);
55                 ad->popup = NULL;
56         }
57
58         if (ad->popup_timer) {
59                 ecore_timer_del(ad->popup_timer);
60                 ad->popup_timer = NULL;
61         }
62 }
63
64 /** not used now */
65 int setting_system_command(const char *command)
66 {
67         SETTING_TRACE_BEGIN;
68         int pid = 0, status = 0;
69         char *const environ[] = { NULL };
70
71         if (command == 0) {
72                 return 1;
73         }
74
75         pid = fork();
76
77         if (pid == -1) {
78                 return SETTING_RETURN_FAIL;
79         }
80
81         if (pid == 0) {
82                 char *argv[SETTING_MEMORY_SYS_COMMAND_ARGV_LEN];
83
84                 argv[0] = "sh";
85                 argv[1] = "-c";
86                 argv[2] = (char *)command;
87                 argv[3] = 0;
88
89                 execve("/bin/sh", argv, environ);
90                 /* exit(127); */
91                 abort();
92         }
93
94         do {
95                 if (waitpid(pid, &status, 0) == -1) {
96                         if (errno != EINTR) {
97                                 return SETTING_RETURN_FAIL;
98                         }
99                 } else {
100                         return status;
101                 }
102
103         } while (1);
104 }