src/desc_parser.c
src/master_rpc.c
src/client.c
- src/critical_log.c
src/file_service.c
src/conf.c
)
*/
#define MAX_LOG_FILE 3
#define MAX_LOG_LINE 1000
-#define SLAVE_LOG_PATH "/opt/usr/share/live_magazine/log"
+#define SLAVE_LOG_PATH "/tmp/.dbox.service/log/"
#if !defined(VCONFKEY_MASTER_STARTED)
#define VCONFKEY_MASTER_STARTED "memory/data-provider-master/started"
+++ /dev/null
-/*
- * Copyright 2013 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-extern int critical_log(const char *func, int line, const char *fmt, ...);
-extern int critical_log_init(const char *tag);
-extern int critical_log_fini(void);
-
-#define CRITICAL_LOG(args...) critical_log(__func__, __LINE__, args)
-
-/* End of a file */
* \see ret_cb_t
*/
extern int livebox_del(struct livebox *handler, ret_cb_t cb, void *data);
+extern int livebox_del_NEW(struct livebox *handler, int type, ret_cb_t cb, void *data);
/*!
* \brief Set a livebox events callback
double timestamp;
enum livebox_visible_state visible;
+ enum livebox_delete_type delete_type;
int is_user;
int is_pd_created;
Name: liblivebox-viewer
Summary: Library for developing the application.
-Version: 0.16.0
+Version: 0.17.0
Release: 1
Group: HomeTF/Livebox
License: Flora
#include "util.h"
#include "master_rpc.h"
#include "conf.h"
-#include "critical_log.h"
#include "file_service.h"
int errno;
* \note
* This is not possible
*/
- CRITICAL_LOG("Already deleted handler (%s - %s)\n", pkgname, id);
+ ErrPrint("Already deleted handler (%s - %s)\n", pkgname, id);
return NULL;
}
}
out:
if (ret == 0 && old_state == DELETE) {
- lb_send_delete(handler, handler->created_cb, handler->created_cbdata);
+ lb_send_delete(handler, handler->delete_type, handler->created_cb, handler->created_cbdata);
/*!
* \note
+++ /dev/null
-/*
- * Copyright 2013 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdio.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include <sys/time.h>
-#include <errno.h>
-#include <string.h>
-#include <libgen.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#include <dlog.h>
-
-#include "conf.h"
-#include "debug.h"
-#include "util.h"
-#include "critical_log.h"
-#include "livebox-errno.h" /* For error code */
-
-static struct {
- FILE *fp;
- int file_id;
- int nr_of_lines;
- char *filename;
-} s_info = {
- .fp = NULL,
- .file_id = 0,
- .nr_of_lines = 0,
- .filename = NULL,
-};
-
-
-
-int critical_log(const char *func, int line, const char *fmt, ...)
-{
- va_list ap;
- int ret;
-
- if (!s_info.fp) {
- return LB_STATUS_ERROR_IO;
- }
-
-#if defined(_USE_ECORE_TIME_GET)
- double tv;
- tv = util_timestamp();
- fprintf(s_info.fp, "%d %lf [%s:%d] ", getpid(), tv, util_basename((char *)func), line);
-#else
- struct timeval tv;
- gettimeofday(&tv, NULL);
- fprintf(s_info.fp, "%d %lu.%lu [%s:%d] ", getpid(), tv.tv_sec, tv.tv_usec, util_basename((char *)func), line);
-#endif
-
- va_start(ap, fmt);
- ret = vfprintf(s_info.fp, fmt, ap);
- va_end(ap);
-
- s_info.nr_of_lines++;
- if (s_info.nr_of_lines == MAX_LOG_LINE) {
- char *filename;
- int namelen;
-
- s_info.file_id = (s_info.file_id + 1) % MAX_LOG_FILE;
-
- namelen = strlen(s_info.filename) + strlen(SLAVE_LOG_PATH) + 20;
- filename = malloc(namelen);
- if (filename) {
- snprintf(filename, namelen, "%s/%d_%s", SLAVE_LOG_PATH, s_info.file_id, s_info.filename);
-
- if (s_info.fp) {
- if (fclose(s_info.fp) != 0) {
- ErrPrint("fclose: %s\n", strerror(errno));
- }
- }
-
- s_info.fp = fopen(filename, "w+");
- if (!s_info.fp) {
- ErrPrint("Failed to open a file: %s\n", filename);
- }
-
- free(filename);
- }
-
- s_info.nr_of_lines = 0;
- }
- return ret;
-}
-
-
-
-int critical_log_init(const char *name)
-{
- int namelen;
- char *filename;
-
- if (s_info.fp) {
- return 0;
- }
-
- s_info.filename = strdup(name);
- if (!s_info.filename) {
- ErrPrint("Failed to create a log file\n");
- return LB_STATUS_ERROR_MEMORY;
- }
-
- namelen = strlen(name) + strlen(SLAVE_LOG_PATH) + 20;
-
- filename = malloc(namelen);
- if (!filename) {
- ErrPrint("Failed to create a log file\n");
- free(s_info.filename);
- s_info.filename = NULL;
- return LB_STATUS_ERROR_MEMORY;
- }
-
- snprintf(filename, namelen, "%s/%d_%s", SLAVE_LOG_PATH, s_info.file_id, name);
-
- s_info.fp = fopen(filename, "w+");
- if (!s_info.fp) {
- ErrPrint("Failed to open log: %s\n", strerror(errno));
- free(s_info.filename);
- s_info.filename = NULL;
- free(filename);
- return LB_STATUS_ERROR_IO;
- }
-
- free(filename);
- return 0;
-}
-
-
-
-int critical_log_fini(void)
-{
- if (s_info.filename) {
- free(s_info.filename);
- s_info.filename = NULL;
- }
-
- if (s_info.fp) {
- if (fclose(s_info.fp) != 0) {
- ErrPrint("fclose: %s\n", strerror(errno));
- }
- s_info.fp = NULL;
- }
-
- return 0;
-}
-
-
-
-/* End of a file */
#include "desc_parser.h"
#include "dlist.h"
#include "util.h"
-#include "critical_log.h"
#define TYPE_TEXT "text"
#define TYPE_IMAGE "image"
block = calloc(1, sizeof(*block));
if (!block) {
- CRITICAL_LOG("Heap: %s\n", strerror(errno));
+ ErrPrint("Heap: %s\n", strerror(errno));
update_end(handle, is_pd);
if (fclose(fp) != 0) {
ErrPrint("fclose: %s\n", strerror(errno));
block->type_len += 256;
block->type = realloc(block->type, block->type_len);
if (!block->type) {
- CRITICAL_LOG("Heap: %s\n", strerror(errno));
+ ErrPrint("Heap: %s\n", strerror(errno));
goto errout;
}
}
block->part_len += 256;
block->part = realloc(block->part, block->part_len);
if (!block->part) {
- CRITICAL_LOG("Heap: %s\n", strerror(errno));
+ ErrPrint("Heap: %s\n", strerror(errno));
goto errout;
}
}
block->data_len += 256;
block->data = realloc(block->data, block->data_len);
if (!block->data) {
- CRITICAL_LOG("Heap: %s\n", strerror(errno));
+ ErrPrint("Heap: %s\n", strerror(errno));
goto errout;
}
}
block->file_len += 256;
block->file = realloc(block->file, block->file_len);
if (!block->file) {
- CRITICAL_LOG("Heap: %s\n", strerror(errno));
+ ErrPrint("Heap: %s\n", strerror(errno));
goto errout;
}
}
block->option_len += 256;
block->option = realloc(block->option, block->option_len);
if (!block->option) {
- CRITICAL_LOG("Heap: %s\n", strerror(errno));
+ ErrPrint("Heap: %s\n", strerror(errno));
goto errout;
}
}
block->id_len += 256;
block->id = realloc(block->id, block->id_len);
if (!block->id) {
- CRITICAL_LOG("Heap: %s\n", strerror(errno));
+ ErrPrint("Heap: %s\n", strerror(errno));
goto errout;
}
}
#include "debug.h"
#include "util.h"
#include "fb.h"
-#include "critical_log.h"
int errno;
info = calloc(1, sizeof(*info));
if (!info) {
- CRITICAL_LOG("Heap: %s\n", strerror(errno));
+ ErrPrint("Heap: %s\n", strerror(errno));
return NULL;
}
info->id = strdup(id);
if (!info->id) {
- CRITICAL_LOG("Heap: %s\n", strerror(errno));
+ ErrPrint("Heap: %s\n", strerror(errno));
free(info);
return NULL;
}
buffer = calloc(1, sizeof(*buffer) + info->bufsz);
if (!buffer) {
- CRITICAL_LOG("Heap: %s\n", strerror(errno));
+ ErrPrint("Heap: %s\n", strerror(errno));
info->bufsz = 0;
return NULL;
}
buffer = calloc(1, sizeof(*buffer) + info->bufsz);
if (!buffer) {
- CRITICAL_LOG("Heap: %s\n", strerror(errno));
+ ErrPrint("Heap: %s\n", strerror(errno));
info->bufsz = 0;
return NULL;
}
#include "util.h"
#include "master_rpc.h"
#include "client.h"
-#include "critical_log.h"
#include "conf.h"
#define EAPI __attribute__((visibility("default")))
info = malloc(sizeof(*info));
if (!info) {
- CRITICAL_LOG("Heap: %s\n", strerror(errno));
+ ErrPrint("Heap: %s\n", strerror(errno));
return NULL;
}
__file_log_fp = fdopen(1, "w+t");
}
#endif
- critical_log_init("viewer");
livebox_service_init();
fb_init(disp);
client_fini();
fb_fini();
livebox_service_fini();
- critical_log_fini();
return LB_STATUS_SUCCESS;
}
handler->timestamp = util_timestamp();
handler->is_user = 1;
handler->visible = LB_SHOW;
+ handler->delete_type = LB_DELETE_PERMANENTLY;
s_info.livebox_list = dlist_append(s_info.livebox_list, handler);
return ret;
}
+EAPI int livebox_del_NEW(struct livebox *handler, int type, ret_cb_t cb, void *data)
+{
+ if (!handler) {
+ ErrPrint("Handler is NIL\n");
+ return LB_STATUS_ERROR_INVALID;
+ }
+
+ if (handler->state != CREATE) {
+ ErrPrint("Handler is already deleted\n");
+ return LB_STATUS_ERROR_INVALID;
+ }
+
+ handler->state = DELETE;
+ handler->delete_type = type;
+
+ if (!handler->id) {
+ /*!
+ * \note
+ * The id is not determined yet.
+ * It means a user didn't receive created event yet.
+ * Then just stop to delete procedure from here.
+ * Because the "created" event handler will release this.
+ * By the way, if the user adds any callback for getting return status of this,
+ * call it at here.
+ */
+ if (cb) {
+ cb(handler, 0, data);
+ }
+ return LB_STATUS_SUCCESS;
+ }
+
+ if (!cb) {
+ cb = default_delete_cb;
+ }
+
+ return lb_send_delete(handler, type, cb, data);
+}
+
EAPI int livebox_del(struct livebox *handler, ret_cb_t cb, void *data)
{
if (!handler) {
}
handler->state = DELETE;
+ handler->delete_type = LB_DELETE_PERMANENTLY;
if (!handler->id) {
/*!
cb = default_delete_cb;
}
- return lb_send_delete(handler, cb, data);
+ return lb_send_delete(handler, LB_DELETE_PERMANENTLY, cb, data);
}
EAPI int livebox_set_fault_handler(int (*cb)(enum livebox_fault_type, const char *, const char *, const char *, void *), void *data)
info = malloc(sizeof(*info));
if (!info) {
- CRITICAL_LOG("Heap: %s\n", strerror(errno));
+ ErrPrint("Heap: %s\n", strerror(errno));
return LB_STATUS_ERROR_MEMORY;
}
info = malloc(sizeof(*info));
if (!info) {
- CRITICAL_LOG("Heap: %s\n", strerror(errno));
+ ErrPrint("Heap: %s\n", strerror(errno));
return LB_STATUS_ERROR_MEMORY;
}
return LB_STATUS_ERROR_INVALID;
}
- if (!handler->pd.data.fb || handler->state != CREATE || !handler->id) {
+ if (handler->state != CREATE || !handler->pd.data.fb || !handler->id) {
ErrPrint("Handler is not valid\n");
return LB_STATUS_ERROR_INVALID;
}
return LB_STATUS_ERROR_INVALID;
}
- if (!handler->pd.data.fb || handler->state != CREATE || !handler->id) {
+ if (handler->state != CREATE || !handler->pd.data.fb || !handler->id) {
ErrPrint("Handler is not valid\n");
return LB_STATUS_ERROR_INVALID;
}
return LB_STATUS_ERROR_INVALID;
}
- if (!handler->pd.data.fb || handler->state != CREATE || !handler->id) {
+ if (handler->state != CREATE || !handler->pd.data.fb || !handler->id) {
ErrPrint("Handler is not valid\n");
return LB_STATUS_ERROR_INVALID;
}
return LB_STATUS_ERROR_INVALID;
}
- if (!handler->pd.data.fb || handler->state != CREATE || !handler->id) {
+ if (handler->state != CREATE || !handler->pd.data.fb || !handler->id) {
ErrPrint("Handler is not valid\n");
return LB_STATUS_ERROR_INVALID;
}
return LB_STATUS_ERROR_INVALID;
}
- if ((handler->lb.type != _LB_TYPE_TEXT && handler->pd.type != _PD_TYPE_TEXT) || handler->state != CREATE || !handler->id) {
+ if (handler->state != CREATE || (handler->lb.type != _LB_TYPE_TEXT && handler->pd.type != _PD_TYPE_TEXT) || !handler->id) {
ErrPrint("Handler is not valid\n");
return LB_STATUS_ERROR_INVALID;
}
if (cluster) {
pc = strdup(cluster);
if (!pc) {
- CRITICAL_LOG("Heap: %s (cluster: %s)\n", strerror(errno), cluster);
+ ErrPrint("Heap: %s (cluster: %s)\n", strerror(errno), cluster);
return LB_STATUS_ERROR_MEMORY;
}
}
if (category) {
ps = strdup(category);
if (!ps) {
- CRITICAL_LOG("Heap: %s (category: %s)\n", strerror(errno), category);
+ ErrPrint("Heap: %s (category: %s)\n", strerror(errno), category);
free(pc);
return LB_STATUS_ERROR_MEMORY;
}
handler->pd.type = _PD_TYPE_SCRIPT;
handler->state = CREATE;
handler->visible = LB_SHOW;
+ handler->delete_type = LB_DELETE_PERMANENTLY;
s_info.livebox_list = dlist_append(s_info.livebox_list, handler);
lb_ref(handler);
if (content) {
handler->content = strdup(content);
if (!handler->content) {
- CRITICAL_LOG("Heap: %s (content: %s)\n", strerror(errno), content);
+ ErrPrint("Heap: %s (content: %s)\n", strerror(errno), content);
return LB_STATUS_ERROR_MEMORY;
}
}
if (title) {
handler->title = strdup(title);
if (!handler->title) {
- CRITICAL_LOG("Heap: %s (title: %s)\n", strerror(errno), title);
+ ErrPrint("Heap: %s (title: %s)\n", strerror(errno), title);
return LB_STATUS_ERROR_MEMORY;
}
}
return NULL;
}
-int lb_send_delete(struct livebox *handler, ret_cb_t cb, void *data)
+int lb_send_delete(struct livebox *handler, int type, ret_cb_t cb, void *data)
{
struct packet *packet;
struct cb_info *cbinfo;
return LB_STATUS_ERROR_BUSY;
}
- packet = packet_create("delete", "ss", handler->pkgname, handler->id);
+ packet = packet_create("delete", "ssi", handler->pkgname, handler->id, type);
if (!packet) {
ErrPrint("Failed to build a param\n");
if (cb) {