#include <stdbool.h>
#include <sqlite3.h>
+#define MS_SQL_SAFE_FREE(x) {if (x != NULL) {sqlite3_free(x); x = NULL; } }
+
int media_db_connect(sqlite3 **handle, uid_t uid, bool need_write);
void media_db_disconnect(sqlite3 *handle);
int media_db_request_update_db(const char *query_str, uid_t uid);
+++ /dev/null
-/*
- * Media Utility
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * 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.
- *
- */
-
-#ifndef _MEDIA_UTIL_INTERNAL_H_
-#define _MEDIA_UTIL_INTERNAL_H_
-
-#include <glib.h>
-#include <sqlite3.h>
-
-#define MS_SAFE_FREE(src) { if (src) {free(src); src = NULL; } }
-#define MS_SQL_SAFE_FREE(x) {if (x != NULL) {sqlite3_free(x); x = NULL; } }
-#define MS_STRING_VALID(str) ((str != NULL && strlen(str) > 0) ? true : false)
-#define SAFE_STRLCPY(dst, src, n) g_strlcpy(dst, src, n);
-
-#endif /*_MEDIA_UTIL_INTERNAL_H_*/
#define MEDIA_DEFAULT_UID 5001
+#define MS_SAFE_FREE(src) { if (src) {free(src); src = NULL; } }
+#define MS_STRING_VALID(str) ((str != NULL && strlen(str) > 0) ? true : false)
+#define SAFE_STRLCPY(dst, src, n) g_strlcpy(dst, src, n);
+#define SAFE_STRLCAT(dst, src, n) g_strlcat(dst, src, n);
+
#endif /*_MEDIA_UTIL_H_*/
#include <media-util-cynara.h>
#include <media-util-dbg.h>
#include <media-util-err.h>
-#include <media-util-internal.h>
#include <cynara-client.h>
#include <cynara-session.h>
ret = cynara_creds_socket_get_client(sockfd, CLIENT_METHOD_SMACK, &(credentials->smack));
if (ret != 0) {
MSAPI_DBG_ERR("[CYNARA]Failed to get smack");
- MS_SAFE_FREE(credentials->uid);
+ if (credentials->uid) {
+ free(credentials->uid);
+ credentials->uid = NULL;
+ }
return MS_MEDIA_ERR_INTERNAL;
}
int ms_cynara_check(const ms_peer_credentials *creds, const char *privilege)
{
- int result;
- char *session;
+ int result = 0;
+ char *session = NULL;
if (!creds || !privilege)
return MS_MEDIA_ERR_INVALID_PARAMETER;
if (result != CYNARA_API_ACCESS_ALLOWED)
ms_cynara_dbg_err("cynara_check", result);
- MS_SAFE_FREE(session);
+ if (session)
+ free(session);
+
return result == CYNARA_API_ACCESS_ALLOWED ? MS_MEDIA_ERR_NONE : MS_MEDIA_ERR_PERMISSION_DENIED;
}
#include <vconf.h>
#include "media-util-dbg.h"
-#include "media-util-internal.h"
#include "media-util.h"
#define MS_TIMEOUT_SEC 10
#include "media-util-dbg.h"
#include "media-util.h"
-#include "media-util-internal.h"
char MEDIA_IPC_PATH[][70] = {
{"media-server/media_ipc_scanner.socket"},
#include <glib.h>
#include <gio/gio.h>
-#include "media-util-internal.h"
#include "media-util-dbg.h"
#include "media-util.h"
#include <unistd.h>
#include <sys/syscall.h>
-#include "media-util-internal.h"
#include "media-util-dbg.h"
#include "media-util.h"
*/
#include "media-util-dbg.h"
-#include "media-util-internal.h"
#include "media-util.h"
#include <glib.h>
#include <unistd.h>
/*Use for Poweroff sequence*/
#define POWEROFF -1 /*This number uses for stopping Scannig thread*/
-#define MS_SAFE_FREE(src) { if (src) {free(src); src = NULL; } }
-#define MS_STRING_VALID(str) \
- ((str != NULL && strlen(str) > 0) ? true : false)
-#define SAFE_STRLCPY(dst, src, n) g_strlcpy(dst, src, n);
-#define SAFE_STRLCAT(dst, src, n) g_strlcat(dst, src, n);
-
-#define MS_SQLITE3_FINALIZE(x) if (x != NULL) sqlite3_finalize(x);
-#define MS_SQLITE3_SAFE_FREE(x) {if (x != NULL) {sqlite3_free(x); x = NULL; } }
-
-#define MS_FILE_PATH_LEN_MAX 4096
-
typedef enum {
MS_SCAN_INVALID,
MS_SCAN_PART,
}
}
- MS_SQLITE3_FINALIZE(sql_stmt);
+ sqlite3_finalize(sql_stmt);
return ret;
}
#endif
ret = media_db_update_db_direct(sql, uid);
- MS_SQLITE3_SAFE_FREE(sql);
+ MS_SQL_SAFE_FREE(sql);
return ret;
}
g_ptr_array_add(thumb_list, path);
}
- MS_SQLITE3_FINALIZE(sql_stmt);
+ sqlite3_finalize(sql_stmt);
#ifdef _USE_TVPD_MODE
sql = sqlite3_mprintf("DELETE FROM '%q' WHERE validity IN (%d, %d)", storage_id, MS_INVALID, MS_SCANNING);
#endif
ret = media_db_update_db_direct(sql, uid);
- MS_SQLITE3_SAFE_FREE(sql);
+ MS_SQL_SAFE_FREE(sql);
if (ret != MS_MEDIA_ERR_NONE) {
g_ptr_array_free(thumb_list, TRUE);
return ret;
#endif
ret = media_db_update_db_direct(sql, uid);
- MS_SQLITE3_SAFE_FREE(sql);
+ MS_SQL_SAFE_FREE(sql);
return ret;
}
#endif
ret = media_db_update_db_direct(sql, uid);
- MS_SQLITE3_SAFE_FREE(sql);
+ MS_SQL_SAFE_FREE(sql);
return ret;
}
ret = MS_MEDIA_ERR_DB_NO_RECORD;
}
- MS_SQLITE3_FINALIZE(sql_stmt);
+ sqlite3_finalize(sql_stmt);
return ret;
}
const char *ignore_file = ".scan_ignore";
char *tmp_path = NULL;
char *org_path = NULL;
- char ignore_path[MS_FILE_PATH_LEN_MAX] = {0, };
+ char ignore_path[MAX_FILEPATH_LEN] = {0, };
/* Check for symbolic link */
tmp_path = realpath(path, NULL);
const char *ignore_file = ".scan_ignore";
char *tmp_path = NULL;
char *org_path = NULL;
- char ignore_path[MS_FILE_PATH_LEN_MAX] = {0, };
+ char ignore_path[MAX_FILEPATH_LEN] = {0, };
- char replace[MS_FILE_PATH_LEN_MAX] = {0, };
+ char replace[MAX_FILEPATH_LEN] = {0, };
char *mediashared = NULL;
/* Check for symbolic link */
if (g_str_has_prefix(tmp_path, MEDIA_SHARE_PATH)) {
ms_user_get_mediashared_path(uid, &mediashared);
- snprintf(replace, MS_FILE_PATH_LEN_MAX, "%s%s", mediashared, tmp_path + strlen(MEDIA_SHARE_PATH));
+ snprintf(replace, MAX_FILEPATH_LEN, "%s%s", mediashared, tmp_path + strlen(MEDIA_SHARE_PATH));
MS_SAFE_FREE(mediashared);
if (g_strcmp0(replace, org_path) != 0) {
MS_SAFE_FREE(tmp_path);
int ret = MS_MEDIA_ERR_NONE;
char *new_path = NULL;
char *current_path = NULL;
- char path[MS_FILE_PATH_LEN_MAX] = {0, };
+ char path[MAX_FILEPATH_LEN] = {0, };
bool is_recursive = (msg_type == MS_MSG_DIRECTORY_SCANNING);
char *new_start_path = NULL;
if (strcmp(dir_entry->d_name, RECYCLE_DIR_NAME) == 0)
continue;
- if (g_snprintf(path, MS_FILE_PATH_LEN_MAX, "%s/%s", current_path, dir_entry->d_name) >= MS_FILE_PATH_LEN_MAX) {
+ if (g_snprintf(path, MAX_FILEPATH_LEN, "%s/%s", current_path, dir_entry->d_name) >= MAX_FILEPATH_LEN) {
MS_DBG_ERR("g_snprintf failed");
continue;
}
int ret = MS_MEDIA_ERR_NONE;
char *new_path = NULL;
char *current_path = NULL;
- char path[MS_FILE_PATH_LEN_MAX] = {0, };
+ char path[MAX_FILEPATH_LEN] = {0, };
int (*scan_function)(sqlite3 *, const char*, const char*, uid_t) = NULL;
char *new_start_path = NULL;
if (strcmp(dir_entry->d_name, RECYCLE_DIR_NAME) == 0)
continue;
- if (g_snprintf(path, MS_FILE_PATH_LEN_MAX, "%s/%s", current_path, dir_entry->d_name) >= MS_FILE_PATH_LEN_MAX) {
+ if (g_snprintf(path, MAX_FILEPATH_LEN, "%s/%s", current_path, dir_entry->d_name) >= MAX_FILEPATH_LEN) {
MS_DBG_ERR("g_snprintf failed");
continue;
}
struct dirent64 *dir_entry = NULL;
GQueue *dir_queue = NULL;
char *current_path = NULL;
- char path[MS_FILE_PATH_LEN_MAX] = {0, };
+ char path[MAX_FILEPATH_LEN] = {0, };
int (*scan_function)(sqlite3 *, const char*, const char*, uid_t) = NULL;
dir_queue = g_queue_new();
if (dir_entry->d_name[0] == '.')
continue;
- snprintf(path, MS_FILE_PATH_LEN_MAX, "%s/%s", current_path, dir_entry->d_name);
+ snprintf(path, MAX_FILEPATH_LEN, "%s/%s", current_path, dir_entry->d_name);
switch (dir_entry->d_type) {
case DT_REG:
#include <malloc.h>
#include "media-util.h"
-#include "media-util-internal.h"
#include "media-common-utils.h"
#include "media-common-db-svc.h"
#include "media-common-system.h"