summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSung-jae Park <nicesj.park@samsung.com>2013-01-04 21:34:06 +0900
committerSung-jae Park <nicesj.park@samsung.com>2013-01-07 15:42:31 +0900
commit51a5b15e09255d6c9bc4bd4a209b498a14f7b507 (patch)
treef15f4e63caf871a64a191f55f69ccacb500e105e /src
parent73dcdc56b0384aa8e0e4471e40ecd83f203d8eb0 (diff)
downloaddata-provider-master-51a5b15e09255d6c9bc4bd4a209b498a14f7b507.tar.gz
data-provider-master-51a5b15e09255d6c9bc4bd4a209b498a14f7b507.tar.bz2
data-provider-master-51a5b15e09255d6c9bc4bd4a209b498a14f7b507.zip
Revise the spec file
Change the package name of the web livebox provider. (From org.tizen.data-provider-webapp-slave to livebox.web-provider) Clear the files in the shared folder first before initiate the master. Add reader & always folder parse code from conf file. Change-Id: I10415faadda3dd267d728ce71b029abdb770964e
Diffstat (limited to 'src')
-rw-r--r--src/conf.c26
-rw-r--r--src/main.c9
-rw-r--r--src/util.c51
3 files changed, 86 insertions, 0 deletions
diff --git a/src/conf.c b/src/conf.c
index a86747c..f7e3cf7 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -64,6 +64,8 @@ HAPI struct conf g_conf = {
.conf = "/opt/usr/live/%s/etc/%s.conf",
.image = "/opt/usr/share/live_magazine/",
.slave_log = "/opt/usr/share/live_magazine/log",
+ .reader = "/opt/usr/share/live_magazine/reader",
+ .always = "/opt/usr/share/live_magazine/always",
.script = "/opt/usr/live/%s/res/script/%s.edj",
.root = "/opt/usr/live/",
.script_port = "/opt/usr/live/script_port/",
@@ -245,6 +247,22 @@ static void db_path_handler(char *buffer)
DbgPrint("DB Path: %s\n", g_conf.path.db);
}
+static void reader_path_handler(char *buffer)
+{
+ g_conf.path.reader = strdup(buffer);
+ if (!g_conf.path.reader)
+ ErrPrint("Heap: %s\n", strerror(errno));
+ DbgPrint("Reader Path: %s\n", g_conf.path.reader);
+}
+
+static void always_path_handler(char *buffer)
+{
+ g_conf.path.always = strdup(buffer);
+ if (!g_conf.path.always)
+ ErrPrint("Heap: %s\n", strerror(errno));
+ DbgPrint("Always Path: %s\n", g_conf.path.always);
+}
+
static void log_path_handler(char *buffer)
{
g_conf.path.slave_log = strdup(buffer);
@@ -379,6 +397,14 @@ HAPI int conf_loader(void)
.handler = log_path_handler,
},
{
+ .name = "reader_path",
+ .handler = reader_path_handler,
+ },
+ {
+ .name = "always_path",
+ .handler = always_path_handler,
+ },
+ {
.name = "share_path",
.handler = share_path_handler,
},
diff --git a/src/main.c b/src/main.c
index 7e8efd2..32538bd 100644
--- a/src/main.c
+++ b/src/main.c
@@ -226,6 +226,15 @@ int main(int argc, char *argv[])
conf_loader();
+ /*!
+ * \note
+ * Clear old contents files before start the master provider.
+ */
+ (void)util_unlink_files(ALWAYS_PATH);
+ (void)util_unlink_files(READER_PATH);
+ (void)util_unlink_files(IMAGE_PATH);
+ (void)util_unlink_files(SLAVE_LOG_PATH);
+
script_init();
app_create();
diff --git a/src/util.c b/src/util.c
index 48129b1..13c5ca9 100644
--- a/src/util.c
+++ b/src/util.c
@@ -21,6 +21,8 @@
#include <unistd.h>
#include <stdlib.h>
#include <sys/statvfs.h>
+#include <sys/types.h>
+#include <dirent.h>
#include <dlog.h>
#include <Eina.h>
@@ -411,4 +413,53 @@ HAPI char *util_get_file_kept_in_safe(const char *id)
return new_path;
}
+HAPI int util_unlink_files(const char *folder)
+{
+ struct stat info;
+ DIR *handle;
+ struct dirent *entry;
+ char *abspath;
+ int len;
+
+ if (lstat(folder, &info) < 0) {
+ ErrPrint("Error: %s\n", strerror(errno));
+ return -EIO;
+ }
+
+ if (!S_ISDIR(info.st_mode)) {
+ ErrPrint("Error: %s is not a folder", folder);
+ return -EINVAL;
+ }
+
+ handle = opendir(folder);
+ if (!handle) {
+ ErrPrint("Error: %s\n", strerror(errno));
+ return -EIO;
+ }
+
+ while ((entry = readdir(handle))) {
+ if (!strcmp(entry->d_name, "."))
+ continue;
+
+ if (!strcmp(entry->d_name, ".."))
+ continue;
+
+ len = strlen(folder) + strlen(entry->d_name) + 3;
+ abspath = calloc(1, len);
+ if (!abspath) {
+ ErrPrint("Heap: %s\n", strerror(errno));
+ continue;
+ }
+ snprintf(abspath, len - 1, "%s/%s", folder, entry->d_name);
+
+ if (unlink(abspath) < 0)
+ DbgPrint("unlink: %s - %s\n", abspath, strerror(errno));
+
+ free(abspath);
+ }
+
+ closedir(handle);
+ return 0;
+}
+
/* End of a file */