return VC_DB_ERROR_NONE;
}
+static vc_cmd_s* __vc_db_command_copy(vc_cmd_s* src_cmd)
+{
+ if (NULL == src_cmd) {
+ SLOG(LOG_WARN, vc_db_tag(), "[Client Data] Input command is NULL");
+ return NULL;
+ }
+
+ vc_cmd_s* temp_cmd = NULL;
+ temp_cmd = (vc_cmd_s*)calloc(sizeof(vc_cmd_s), 1);
+ if (NULL == temp_cmd) {
+ SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] Fail to allocate memory");
+ return NULL;
+ }
+
+ temp_cmd->id = src_cmd->id;
+ temp_cmd->pid = src_cmd->pid;
+ temp_cmd->index = src_cmd->index;
+ temp_cmd->type = src_cmd->type;
+ temp_cmd->format = src_cmd->format;
+ temp_cmd->domain = src_cmd->domain;
+
+ if (VC_COMMAND_TYPE_SYSTEM == temp_cmd->type) temp_cmd->priority = VC_COMMAND_PRIORITY_SYSTEM;
+ else if (VC_COMMAND_TYPE_EXCLUSIVE == temp_cmd->type) temp_cmd->priority = VC_COMMAND_PRIORITY_EXCLUSIVE;
+ else if (VC_COMMAND_TYPE_FOREGROUND == temp_cmd->type) temp_cmd->priority = VC_COMMAND_PRIORITY_FOREGROUND;
+ else if (VC_COMMAND_TYPE_WIDGET == temp_cmd->type) temp_cmd->priority = VC_COMMAND_PRIORITY_FOREGROUND;
+ else if (VC_COMMAND_TYPE_SYSTEM_BACKGROUND == temp_cmd->type) temp_cmd->priority = VC_COMMAND_PRIORITY_SYSTEM_BACKGROUND;
+ else if (VC_COMMAND_TYPE_BACKGROUND == temp_cmd->type) temp_cmd->priority = VC_COMMAND_PRIORITY_BACKGROUND;
+
+ if (NULL != src_cmd->command) {
+ temp_cmd->command = strdup(src_cmd->command);
+ }
+
+ if (NULL != src_cmd->parameter) {
+ temp_cmd->parameter = strdup(src_cmd->parameter);
+ }
+
+ if (NULL != src_cmd->appid) {
+ temp_cmd->appid = strdup(src_cmd->appid);
+ }
+
+ if (NULL != src_cmd->invocation_name) {
+ temp_cmd->invocation_name = strdup(src_cmd->invocation_name);
+ }
+
+ if (NULL != src_cmd->fixed) {
+ temp_cmd->fixed = strdup(src_cmd->fixed);
+ }
+
+ temp_cmd->key = src_cmd->key;
+ temp_cmd->modifier = src_cmd->modifier;
+
+ return temp_cmd;
+}
+
int vc_db_initialize(void)
{
SLOG(LOG_ERROR, vc_db_tag(), "DB initialization");
{
GSList* cmd_list = NULL;
char* fixed_cmd = NULL;
+ vc_cmd_s* tmp_cmd = __vc_db_command_copy(cmd);
- int ret = __vc_db_generate_command(cmd, &fixed_cmd, &cmd_list);
+ int ret = __vc_db_generate_command(tmp_cmd, &fixed_cmd, &cmd_list);
if (0 != ret) {
SLOG(LOG_ERROR, vc_db_tag(), "[ERROR] Fail to generate command, %d", ret);
return ret;
temp_command = iter->data;
if (NULL != temp_command) {
- if (NULL != cmd->command) {
- free(cmd->command);
- cmd->command = NULL;
+ if (NULL != tmp_cmd->command) {
+ free(tmp_cmd->command);
+ tmp_cmd->command = NULL;
}
- cmd->command = strdup(temp_command);
+ tmp_cmd->command = strdup(temp_command);
if (NULL != fixed_cmd)
- cmd->fixed = strdup(fixed_cmd);
+ tmp_cmd->fixed = strdup(fixed_cmd);
else
- cmd->fixed = NULL;
+ tmp_cmd->fixed = NULL;
- int ret = __vc_db_insert_commands(pid, type, cmd);
+ int ret = __vc_db_insert_commands(pid, type, tmp_cmd);
if (ret != VC_DB_ERROR_NONE) {
if (NULL != fixed_cmd) {
free(fixed_cmd);
fixed_cmd = NULL;
}
+ vc_cmd_destroy((vc_cmd_h)tmp_cmd);
return ret;
}
- if (VC_COMMAND_TYPE_BACKGROUND == type && NULL != cmd->invocation_name) {
+ if (VC_COMMAND_TYPE_BACKGROUND == type && NULL != tmp_cmd->invocation_name) {
char temp[256] = {0, };
- snprintf(temp, 256, "%s %s", cmd->invocation_name, cmd->command);
- if (NULL != cmd->command)
- free(cmd->command);
+ snprintf(temp, 256, "%s %s", tmp_cmd->invocation_name, tmp_cmd->command);
+ if (NULL != tmp_cmd->command)
+ free(tmp_cmd->command);
- cmd->command = strdup(temp);
+ tmp_cmd->command = strdup(temp);
- ret = __vc_db_insert_commands(pid, type, cmd);
+ ret = __vc_db_insert_commands(pid, type, tmp_cmd);
if (ret != VC_DB_ERROR_NONE) {
if (NULL != fixed_cmd) {
free(fixed_cmd);
fixed_cmd = NULL;
}
+ vc_cmd_destroy((vc_cmd_h)tmp_cmd);
return ret;
}
}
free(fixed_cmd);
fixed_cmd = NULL;
}
+ vc_cmd_destroy((vc_cmd_h)tmp_cmd);
return VC_DB_ERROR_NONE;
}
SLOG(LOG_DEBUG, TAG_VCCMD, "[Destroy command][%p]", command);
if (NULL != command) {
- if (NULL != command->command) free(command->command);
- if (NULL != command->parameter) free(command->parameter);
+ if (NULL != command->command) {
+ free(command->command);
+ command->command = NULL;
+ }
+ if (NULL != command->parameter) {
+ free(command->parameter);
+ command->parameter = NULL;
+ }
+ if (NULL != command->invocation_name) {
+ free(command->invocation_name);
+ command->invocation_name = NULL;
+ }
+ if (NULL != command->appid) {
+ free(command->appid);
+ command->appid = NULL;
+ }
+ if (NULL != command->fixed) {
+ free(command->fixed);
+ command->fixed = NULL;
+ }
free(command);
command = NULL;
}
hour = hour + 12 * flag;
if (12 == hour) hour = 0;
- else if(24 == hour) hour = 12;
+ else if (24 == hour) hour = 12;
}
if (0 > hour || 24 <= hour || (0 == flag && 12 < hour)) {