INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/dcm-service.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
ADD_SUBDIRECTORY(svc)
+ADD_SUBDIRECTORY(test)
LINK_DIRECTORIES(${LIB_INSTALL_DIR})
} \
} while (0)
+#define ERR_BUF_LENGHT 256
+#define dcm_stderror(fmt) do { \
+ char dcm_stderror_buf[ERR_BUF_LENGHT] = {0, }; \
+ strerror_r(errno, dcm_stderror_buf, ERR_BUF_LENGHT); \
+ dcm_error(fmt" : standard error= [%s]", dcm_stderror_buf); \
+ } while (0)
+
#define DCM_CHECK_VAL(expr, val) dcm_retvm_if(!(expr), val, "Invalid parameter, return ERROR code!")
#define DCM_CHECK_NULL(expr) dcm_retvm_if(!(expr), NULL, "Invalid parameter, return NULL!")
#define DCM_CHECK_FALSE(expr) dcm_retvm_if(!(expr), FALSE, "Invalid parameter, return FALSE!")
int acceptSocket(int serv_sock, int *client_sock);
int receiveSocketMsg(int client_sock, DcmIpcMsg *recv_msg);
int sendSocketMsg(DcmIpcMsgType msg_type, uid_t uid, const char *msg, DcmIpcPortType port);
+ int sendClientSocketMsg(int socket_fd, DcmIpcMsgType msg_type, uid_t uid, const char *msg, DcmIpcPortType port);
int closeSocket(int socket_fd);
- int createUDPSocket(int *socket_fd);
- int receiveUDPSocketMsg(int socket_fd, DcmIpcMsg *recv_msg);
- int sendUDPSocketMsg(DcmIpcMsgType msg_type, const char *msg);
- int closeUDPSocket(int socket_fd);
- int sendFaceMsg(const char *media_uuid);
}
#endif /* _DCM_SVC_IPC_H_ */
} DcmErrorType;
typedef enum {
- DCM_IPC_MSG_NONE,
- DCM_IPC_MSG_SERVICE_READY,
- DCM_IPC_MSG_SERVICE_TERMINATED,
+ DCM_IPC_MSG_SCAN_SINGLE,
+ DCM_IPC_MSG_SCAN_ALL,
+ DCM_IPC_MSG_CANCEL,
+ DCM_IPC_MSG_CANCEL_ALL,
DCM_IPC_MSG_KILL_SERVICE,
DCM_IPC_MSG_SCAN_READY,
- DCM_IPC_MSG_SCAN_ALL,
- DCM_IPC_MSG_SCAN_SINGLE,
DCM_IPC_MSG_SCAN_COMPLETED,
DCM_IPC_MSG_SCAN_TERMINATED,
+ DCM_IPC_MSG_SERVICE_READY = 20,
+ DCM_IPC_MSG_SERVICE_COMPLETED,
DCM_IPC_MSG_MAX,
} DcmIpcMsgType;
typedef enum {
- DCM_IPC_PORT_SCAN_RECV,
+ DCM_IPC_PORT_SCAN_RECV = 0,
DCM_IPC_PORT_DCM_RECV,
- DCM_IPC_PORT_THUMB_RECV,
+ DCM_IPC_PORT_MS_RECV,
DCM_IPC_PORT_MAX,
} DcmIpcPortType;
typedef struct {
DcmIpcMsgType msg_type;
+ int pid;
uid_t uid;
size_t msg_size; /*this is size of message below and this does not include the terminationg null byte ('\0'). */
char msg[DCM_IPC_MSG_MAX_SIZE];
#include "dcm-face.h"
#include "dcm-face_priv.h"
+#include "dcm-face-debug.h"
#define FACE_MAGIC_VALID (0xFF993311)
#include "dcm-face.h"
#include "dcm-face_priv.h"
+#include <stdio.h>
+#include <stdlib.h>
+
typedef struct media_vision_h {
mv_engine_config_h cfg;
mv_source_h source;
dcm_retvm_if(count == NULL, FACE_ERROR_OUT_OF_MEMORY, "invalid count");
mv_handle *_fengine = (mv_handle *)handle->fengine;
+ memset(&result, 0x00, sizeof(result));
__convert_to_mv_colorspace_e(handle->image_info->colorspace, &colorspace);
}
err = mv_face_detect(_fengine->source, _fengine->cfg, (mv_face_detected_cb)__face_detected_cb, &result);
-
-/* wait_for_async(); */
+ if (err != MEDIA_VISION_ERROR_NONE) {
+ dcm_error("Fail to mv_face_detect");
+ return __convert_to_mv_error_e(err);
+ }
if (result.error == FACE_ERROR_NONE) {
*face_rect = result.face_rect;
#include <stdlib.h>
#include <glib.h>
-#include "dcm-face-debug.h"
#undef __in
#define __in
Name: dcm-service
Summary: A media DCM(Digital Contents Management) Service
-Version: 0.0.5
+Version: 0.0.6
Release: 0
Group: Multimedia/Service
License: Apache-2.0
%manifest %{name}.manifest
%defattr(-,root,root,-)
%{_libdir}/*.so*
-%{_bindir}/dcm-svc
+%{_bindir}/*
%{_datadir}/license/%{name}
%files devel
dcm_warn("media db handle: %p", db_handle);
- err = media_db_disconnect(db_handle);
- if (err != MS_MEDIA_ERR_NONE) {
- dcm_error("media_db_disconnect failed: %d", err);
- db_handle = NULL;
- return err;
+ if (db_handle != NULL) {
+ err = media_db_disconnect(db_handle);
+ if (err != MS_MEDIA_ERR_NONE) {
+ dcm_error("media_db_disconnect failed: %d", err);
+ db_handle = NULL;
+ return err;
+ }
}
db_handle = NULL;
dcm_debug_fleave();
- return err;
+ return MS_MEDIA_ERR_NONE;
}
#include <DcmTypes.h>
#include <DcmDebugUtils.h>
-static char DCM_IPC_PATH[][100] =
- {"/var/run/media-server/dcm_ipc_scanthread_recv",
- "/var/run/media-server/dcm_ipc_thumbserver_comm_recv",
- "/var/run/media-server/media_ipc_thumbdcm_dcmrecv"};
+static char DCM_IPC_PATH[][100] = {
+ {"/var/run/media-server/dcm_ipc_scanthread.socket"},
+ {"/var/run/media-server/media_ipc_dcmdaemon.socket"},
+ {"/var/run/media-server/media_ipc_dcmcomm.socket"},
+};
int DcmIpcUtils::receiveSocketMsg(int client_sock, DcmIpcMsg *recv_msg)
{
dcm_error("Timeout. Can't try any more");
return DCM_ERROR_IPC;
} else {
- dcm_error("recv failed : %s", strerror(errno));
+ dcm_stderror("recv failed");
return DCM_ERROR_NETWORK;
}
}
- dcm_sec_debug("[receive msg] type: %d, uid: %d, msg: %s, msg_size: %d", recv_msg->msg_type, recv_msg->uid, recv_msg->msg, recv_msg->msg_size);
+ dcm_sec_debug("[receive msg] type: %d, pid: %d, uid: %d, msg: %s, msg_size: %d", recv_msg->msg_type, recv_msg->pid, recv_msg->uid, (recv_msg->msg)?recv_msg->msg:"NULL", recv_msg->msg_size);
if (!(recv_msg->msg_type >= 0 && recv_msg->msg_type < DCM_IPC_MSG_MAX)) {
dcm_error("IPC message is wrong!");
socklen_t client_addr_len = sizeof(client_addr);
if ((sockfd = accept(serv_sock, (struct sockaddr*)&client_addr, &client_addr_len)) < 0) {
- dcm_error("accept failed : %s", strerror(errno));
+ dcm_stderror("accept failed");
*client_sock = -1;
return DCM_ERROR_NETWORK;
}
/* Create a new TCP socket */
if ((sock = socket(PF_FILE, SOCK_STREAM, 0)) < 0) {
- dcm_error("socket failed: %s", strerror(errno));
+ dcm_stderror("socket failed");
return DCM_ERROR_NETWORK;
}
strncpy(serv_addr.sun_path, DCM_IPC_PATH[port], sizeof(serv_addr.sun_path) - 1);
/* Bind socket to local address */
- for (i = 0; i < 20; i++) {
+ for (i = 0; i < 100; i++) {
if (bind(sock, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) == 0) {
bind_success = true;
break;
}
if (bind_success == false) {
- dcm_error("bind failed : %s %d_", strerror(errno), errno);
+ dcm_stderror("bind failed");
close(sock);
return DCM_ERROR_NETWORK;
}
/* Listenint */
if (listen(sock, SOMAXCONN) < 0) {
- dcm_error("listen failed : %s", strerror(errno));
+ dcm_stderror("listen failed");
close(sock);
return DCM_ERROR_NETWORK;
}
dcm_debug("Listening...");
/* change permission of local socket file */
- if (chmod(DCM_IPC_PATH[port], 0660) < 0)
- dcm_error("chmod failed [%s]", strerror(errno));
+ if (chmod(DCM_IPC_PATH[port], 0777) < 0)
+ dcm_stderror("chmod failed");
*socket_fd = sock;
return DCM_SUCCESS;
}
+int DcmIpcUtils::sendClientSocketMsg(int socket_fd, DcmIpcMsgType msg_type, uid_t uid, const char *msg, DcmIpcPortType port)
+{
+ if (port < 0 || port >= DCM_IPC_PORT_MAX) {
+ dcm_error("Invalid port! Stop sending message...");
+ return DCM_ERROR_INVALID_PARAMETER;
+ }
+ dcm_debug("Send message type: %d", msg_type);
+
+ DcmIpcMsg send_msg;
+ int err = 0;
+ int sock = -1;
+
+ if (socket_fd < 0) {
+ struct sockaddr_un serv_addr;
+ struct timeval tv_timeout = { 10, 0 };
+
+ if ((sock = socket(PF_FILE, SOCK_STREAM, 0)) < 0) {
+ dcm_stderror("socket failed");
+ return DCM_ERROR_NETWORK;
+ }
+
+ if (setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, &tv_timeout, sizeof(tv_timeout)) == -1) {
+ dcm_stderror("setsockopt failed");
+ close(sock);
+ return DCM_ERROR_NETWORK;
+ }
+
+ memset(&serv_addr, 0, sizeof(serv_addr));
+ serv_addr.sun_family = AF_UNIX;
+ strncpy(serv_addr.sun_path, DCM_IPC_PATH[port], sizeof(DCM_IPC_PATH[port]));
+
+ /* Connecting to the thumbnail server */
+ if (connect(sock, (struct sockaddr*)&serv_addr, sizeof(serv_addr)) < 0) {
+ dcm_stderror("connect");
+ close(sock);
+ return DCM_ERROR_NETWORK;
+ }
+ } else {
+ sock = socket_fd;
+ }
+
+ /* Prepare send message */
+ memset((void *)&send_msg, 0, sizeof(DcmIpcMsg));
+ send_msg.msg_type = msg_type;
+ send_msg.uid = uid;
+ if (msg != NULL) {
+ send_msg.msg_size = strlen(msg);
+ strncpy(send_msg.msg, msg, send_msg.msg_size);
+ }
+
+ /* If message size is larget than max_size, then message is invalid */
+ if (send_msg.msg_size >= DCM_IPC_MSG_MAX_SIZE) {
+ dcm_error("Message size is invalid!");
+ close(sock);
+ return DCM_ERROR_NETWORK;
+ }
+
+ /* Send msg to the socket */
+ if (send(sock, &send_msg, sizeof(send_msg), 0) != sizeof(send_msg)) {
+ dcm_stderror("send failed");
+ close(sock);
+ return DCM_ERROR_NETWORK;
+ }
+
+ dcm_debug("Sent message type: %d", msg_type);
+
+ close(sock);
+ return DCM_SUCCESS;
+}
+
int DcmIpcUtils::sendSocketMsg(DcmIpcMsgType msg_type, uid_t uid, const char *msg, DcmIpcPortType port)
{
if (port < 0 || port >= DCM_IPC_PORT_MAX) {
/* Create a new TCP socket */
if ((socket_fd = socket(PF_FILE, SOCK_STREAM, 0)) < 0) {
- dcm_error("socket failed: %s", strerror(errno));
+ dcm_stderror("socket failed");
return DCM_ERROR_NETWORK;
}
/* Connect to the socket */
if (connect(socket_fd, (struct sockaddr*)&serv_addr, sizeof(serv_addr)) < 0) {
- dcm_error("connect error : %s", strerror(errno));
+ dcm_stderror("connect error");
close(socket_fd);
return DCM_ERROR_NETWORK;
}
/* Send msg to the socket */
if (send(socket_fd, &send_msg, sizeof(send_msg), 0) != sizeof(send_msg)) {
- dcm_error("send failed : %s", strerror(errno));
+ dcm_stderror("send failed");
close(socket_fd);
return DCM_ERROR_NETWORK;
}
close(socket_fd);
return DCM_SUCCESS;
}
-
-#define DCM_SVC_FACE_ASYNC_MEDIA_UUID_LENGTH 64
-#define DCM_SVC_FACE_ASYNC_UDP_SEND_PORT 1551
-#define DCM_SVC_FACE_ASYNC_INET_ADDR "127.0.0.1"
-typedef struct
-{
- int type; /* type should be set to 0 */
- char media_uuid[DCM_SVC_FACE_ASYNC_MEDIA_UUID_LENGTH];
-} dcm_svc_face_async_msg_s;
-
-int DcmIpcUtils::sendFaceMsg(const char *media_uuid)
-{
- dcm_debug_fenter();
- DCM_CHECK_VAL(media_uuid, DCM_ERROR_INVALID_PARAMETER);
- dcm_sec_debug("media_id: %s", media_uuid);
- struct sockaddr_in client_addr;
- int socket_fd = 0;
- int ret = 0;
-
- /* Create send socket */
- if ((socket_fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
- dcm_error("Failed to create socket for libface-svc! err: %s", strerror(errno));
- return DCM_ERROR_NETWORK;
- }
- dcm_debug("socket fd: %d", socket_fd);
-
- /* Set send message */
- dcm_svc_face_async_msg_s face_async_msg;
- memset(&face_async_msg, 0x00, sizeof(dcm_svc_face_async_msg_s));
- face_async_msg.type = 0;
- g_strlcpy(face_async_msg.media_uuid, media_uuid, sizeof(face_async_msg.media_uuid));
-
- /* Set face async port and address */
- client_addr.sin_family = AF_INET;
- client_addr.sin_port = htons(DCM_SVC_FACE_ASYNC_UDP_SEND_PORT);
- client_addr.sin_addr.s_addr = inet_addr(DCM_SVC_FACE_ASYNC_INET_ADDR);
-
- /* Send message to libface-svc */
- ret = sendto(socket_fd, &face_async_msg, sizeof(dcm_svc_face_async_msg_s), MSG_NOSIGNAL, (struct sockaddr*)&client_addr, sizeof(client_addr));
- if (ret < 0) {
- dcm_error("Failed to send message to libface-svc! err: %s", strerror(errno));
- close(socket_fd);
- return DCM_ERROR_NETWORK;
- }
-
- close(socket_fd);
- dcm_debug_fleave();
- return DCM_SUCCESS;
-}
-
GMainContext *scan_thread_main_context;
gboolean g_scan_cancel;
GSource *scan_thread_quit_timer;
+ DcmDbUtils *dcmDBUtils;
+ uid_t g_uid;
/* scan all images */
GList *scan_all_item_list;
int initialize();
int finalize();
int sendCompletedMsg(const char *msg, DcmIpcPortType port);
+ int sendTerminatedMsg();
int getScanStatus(DcmScanItem *scan_item, bool *media_scanned);
int runScanProcess(DcmScanItem *scan_item);
int ScanAllItems();
gboolean DcmScanCallback::quitTimerAtScanThread(gpointer data)
{
DcmScanSvc *dcmScanSvc = (DcmScanSvc *) data;
+ int ret;
dcm_debug_fenter();
DCM_CHECK_FALSE(data);
+ ret = DcmIpcUtils::sendSocketMsg(DCM_IPC_MSG_SCAN_TERMINATED, 0, NULL, DCM_IPC_PORT_DCM_RECV);
+ if (ret != DCM_SUCCESS) {
+ dcm_error("send to terminated messge to DCM Main");
+ }
+
if (dcmScanSvc->scan_all_curr_index != 0 || dcmScanSvc->scan_single_curr_index != 0) {
dcm_warn("Scan thread is working! DO NOT quit main thread!");
dcmScanSvc->createQuitTimerScanThread();
g_scan_cancel = FALSE;
DcmFaceUtils::initialize();
+ dcmDBUtils = DcmDbUtils::getInstance();
return DCM_SUCCESS;
}
return DCM_SUCCESS;
}
+int DcmScanSvc::sendTerminatedMsg()
+{
+ dcm_debug("Terminated message is sent to DCM main...");
+
+ return ;
+}
+
int DcmScanSvc::getScanStatus(DcmScanItem *scan_item, bool *media_scanned)
{
int ret = DCM_SUCCESS;
clearAllItemList();
/* Send scan complete message to main thread (if all scan operations are finished) */
sendCompletedMsg( NULL, DCM_IPC_PORT_DCM_RECV);
+ ret = dcmDBUtils->_dcm_svc_db_disconnect();
+ if (ret != DCM_SUCCESS) {
+ dcm_error("Failed to disconnect db! err: %d", ret);
+ }
return DCM_SUCCESS;
}
dcm_debug("Terminate scanning operations, and quit scan thread main loop");
g_scan_cancel = TRUE;
- createQuitTimerScanThread();
- return DCM_SUCCESS;
+ return createQuitTimerScanThread();
}
int DcmScanSvc::receiveMsg(DcmIpcMsg *recv_msg)
{
int ret = DCM_SUCCESS;
- DcmDbUtils *dcmDbUtils = DcmDbUtils::getInstance();
+ dcmDBUtils = DcmDbUtils::getInstance();
+ g_uid = recv_msg->uid;
DCM_CHECK_VAL(recv_msg, DCM_ERROR_INVALID_PARAMETER);
dcm_debug("msg_type: %d", recv_msg->msg_type);
if (recv_msg->msg_type == DCM_IPC_MSG_KILL_SERVICE)
{
/* Destroy scan idles, and quit scan thread main loop */
- terminateScanOperations();
- }
-
- ret = dcmDbUtils->_dcm_svc_db_connect(recv_msg->uid);
- if (ret != MS_MEDIA_ERR_NONE) {
- dcm_error("Failed to connect DB! err: %d", ret);
- return DCM_ERROR_DB_OPERATION;
+ ret = terminateScanOperations();
+ if (ret != DCM_SUCCESS) {
+ dcm_error("Failed to terminate DCM scan service! err: %d", ret);
+ return DCM_ERROR_DB_OPERATION;
+ }
+ return ret;
}
-
- if (recv_msg->msg_type == DCM_IPC_MSG_SCAN_ALL)
+ else if (recv_msg->msg_type == DCM_IPC_MSG_SCAN_ALL)
{
/* Use timer to scan all unscanned images */
+ ret = dcmDBUtils->_dcm_svc_db_connect(recv_msg->uid);
+ if (ret != DCM_SUCCESS) {
+ dcm_error("Failed to disconnect db! err: %d", ret);
+ }
ScanAllItems();
+ ret = dcmDBUtils->_dcm_svc_db_disconnect();
}
else if (recv_msg->msg_type == DCM_IPC_MSG_SCAN_SINGLE)
{
+ ret = dcmDBUtils->_dcm_svc_db_connect(recv_msg->uid);
+ if (ret != DCM_SUCCESS) {
+ dcm_error("Failed to connect db! err: %d", ret);
+ }
/* Create a scan idle if not exist, and scan single image of which file path is reveived from tcp socket */
if (recv_msg->msg_size > 0 && recv_msg->msg_size < DCM_IPC_MSG_MAX_SIZE) {
char *file_path = NULL;
dcm_error("Invalid receive message!");
ret = DCM_ERROR_IPC_INVALID_MSG;
}
+ ret = dcmDBUtils->_dcm_svc_db_disconnect();
+ if (ret != DCM_SUCCESS) {
+ dcm_error("Failed to disconnect db! err: %d", ret);
+ }
}
else {
- dcm_error("Invalid message type!");
+ dcm_error("Invalid message type(%d)!", recv_msg->msg_type);
ret = DCM_ERROR_IPC_INVALID_MSG;
}
- ret = dcmDbUtils->_dcm_svc_db_disconnect();
- if (ret != DCM_SUCCESS) {
- dcm_error("Failed to disconnect DB! err: %d", ret);
- return DCM_ERROR_DB_OPERATION;
- }
-
return ret;
}
DCM_CHECK_FALSE(scanSvc);
DCM_CHECK_FALSE(dcmDbUtils);
+ ret = scanSvc->dcmDBUtils->_dcm_svc_db_connect(scanSvc->g_uid);
+ if (ret != DCM_SUCCESS) {
+ dcm_error("Failed to disconnect db! err: %d", ret);
+ }
/* DCM scan started */
unsigned int list_len = g_list_length(scanSvc->scan_all_item_list);
if ((scanSvc->scan_all_curr_index < list_len) && !scanSvc->g_scan_cancel) {
} else {
dcm_warn("All images are scanned. Scan operation completed");
scanSvc->clearAllItemList();
+ ret = scanSvc->dcmDBUtils->_dcm_svc_db_disconnect();
+ if (ret != DCM_SUCCESS) {
+ dcm_error("Failed to disconnect db! err: %d", ret);
+ }
+ scanSvc->clearAllItemList();
+ /* Send scan complete message to main thread (if all scan operations are finished) */
+ scanSvc->sendCompletedMsg( NULL, DCM_IPC_PORT_DCM_RECV);
dcm_debug_fleave();
return FALSE;
}
+ ret = scanSvc->dcmDBUtils->_dcm_svc_db_disconnect();
+ if (ret != DCM_SUCCESS) {
+ dcm_error("Failed to disconnect db! err: %d", ret);
+ }
dcm_debug_fleave();
#include <DcmDebugUtils.h>
-#define DCM_SVC_MAIN_THREAD_TIMEOUT_SEC 20
+#define DCM_SVC_MAIN_THREAD_TIMEOUT_SEC 1
namespace DcmMainSvcCallBack {
gboolean readMsg(GIOChannel *src, GIOCondition condition, gpointer data);
void DcmMainSvc::dcmServiceStartjobs(void)
{
/* Send ready response to dcm launcher */
- if (DcmIpcUtils::sendSocketMsg(DCM_IPC_MSG_SERVICE_READY, 0, NULL, DCM_IPC_PORT_THUMB_RECV) != DCM_SUCCESS) {
+ if (DcmIpcUtils::sendClientSocketMsg(-1, DCM_IPC_MSG_SERVICE_READY, 0, NULL, DCM_IPC_PORT_MS_RECV) != DCM_SUCCESS) {
dcm_error("Failed to send ready message");
}
}
void DcmMainSvc::dcmServiceFinishjobs(void)
{
/* TODO: free resources for dcm-service */
- if (DcmIpcUtils::sendSocketMsg(DCM_IPC_MSG_SERVICE_TERMINATED, 0, NULL, DCM_IPC_PORT_THUMB_RECV) != DCM_SUCCESS) {
- dcm_error("Failed to send terminated message");
- }
}
int DcmMainSvc::waitScanThreadReady()
{
DcmIpcMsg recv_msg;
int sock = -1;
+ int client_sock = -1;
int ret = 0;
- int client_sock;
DcmMainSvc *dcmSvc = DcmMainSvc::getInstance();
dcm_debug("scan thread is already running!");
}
- if ((recv_msg.msg_type == DCM_IPC_MSG_SCAN_COMPLETED) ||
- (recv_msg.msg_type == DCM_IPC_MSG_SCAN_TERMINATED)) {
- dcm_debug("Scan completed!");
+ if (recv_msg.msg_type == DCM_IPC_MSG_SCAN_TERMINATED) {
+ dcm_debug("Scan terminated!");
dcmSvc->scan_thread_working = false;
dcmSvc->createQuitTimerMainLoop();
+ } else if (recv_msg.msg_type == DCM_IPC_MSG_SCAN_COMPLETED) {
+ dcm_debug("Scan completed!");
+ ret = DcmIpcUtils::sendClientSocketMsg(-1, DCM_IPC_MSG_SERVICE_COMPLETED, recv_msg.uid, recv_msg.msg, DCM_IPC_PORT_MS_RECV);
} else if (recv_msg.msg_type == DCM_IPC_MSG_KILL_SERVICE) {
dcm_warn("Quit dcm-svc main loop!");
ret = DcmIpcUtils::sendSocketMsg(DCM_IPC_MSG_KILL_SERVICE, recv_msg.uid, recv_msg.msg, DCM_IPC_PORT_SCAN_RECV);
} else if (recv_msg.msg_type == DCM_IPC_MSG_SCAN_ALL) {
ret = DcmIpcUtils::sendSocketMsg(DCM_IPC_MSG_SCAN_ALL, recv_msg.uid, NULL, DCM_IPC_PORT_SCAN_RECV);
+ if (ret == DCM_SUCCESS) {
+ ret = DcmIpcUtils::sendClientSocketMsg(client_sock, DCM_IPC_MSG_SCAN_ALL, recv_msg.uid, NULL, DCM_IPC_PORT_DCM_RECV);
+ }
} else if (recv_msg.msg_type == DCM_IPC_MSG_SCAN_SINGLE) {
ret = DcmIpcUtils::sendSocketMsg(DCM_IPC_MSG_SCAN_SINGLE, recv_msg.uid, recv_msg.msg, DCM_IPC_PORT_SCAN_RECV);
+ if (ret == DCM_SUCCESS) {
+ ret = DcmIpcUtils::sendClientSocketMsg(client_sock, DCM_IPC_MSG_SCAN_SINGLE, recv_msg.uid, recv_msg.msg, DCM_IPC_PORT_DCM_RECV);
+ }
} else {
dcm_debug("createDcmSvcReadSocket, invalid message.");
}
if (dcmSvcApp->scan_thread_working == true) {
dcm_warn("Scan thread is working! DO NOT quit main thread!");
+ return TRUE;
} else {
dcm_warn("Quit dcm-svc main loop!");
dcmSvcApp->quitDcmSvcMainLoop();
dcm_debug("DCM Service is shutting down...");
g_io_channel_shutdown(channel, FALSE, NULL);
g_io_channel_unref(channel);
+ close(sockfd);
g_main_loop_unref(g_dcm_svc_mainloop);
return 0;
--- /dev/null
+SET(fw_test "dcm-test")
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${fw_test} REQUIRED glib-2.0 libmedia-utils libtzplatform-config)
+
+FOREACH(flag ${${fw_test}_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall")
+
+aux_source_directory(. sources)
+FOREACH(src ${sources})
+ GET_FILENAME_COMPONENT(src_name ${src} NAME_WE)
+ MESSAGE("${src_name}")
+ ADD_EXECUTABLE(${fw_test} ${src})
+ TARGET_LINK_LIBRARIES(${fw_test} ${fw_name} ${${fw_test}_LDFLAGS})
+ENDFOREACH()
+
+#INSTALL(TARGETS ${fw_test} DESTINATION bin)
--- /dev/null
+/*
+ * com.samsung.dcm-svc-client
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jiyong Min <jiyong.min@samsung.com>
+ *
+ * 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.
+ *
+ */
+
+#include <unistd.h>
+#include <stdio.h>
+#include <glib.h>
+#include <media-util.h>
+#include <tzplatform_config.h>
+
+#define MAX_STRING_LEN 4096
+#define ALL "ALL"
+#define SINGLE "SINGLE"
+
+static char *g_path = NULL;
+static char *g_command = NULL;
+
+int main(int argc, char **argv)
+{
+ if (argc < 1) {
+ printf("Usage: dcm_test ALL|SINGLE file_path \n");
+ return 0;
+ }
+
+ g_command = (char *)g_malloc(MAX_STRING_LEN * sizeof(char *));
+ memset(g_command, 0x00, MAX_STRING_LEN);
+ snprintf(g_command, MAX_STRING_LEN, "%s", argv[1]);
+
+ if (strcmp(g_command, SINGLE) == 0) {
+ if (argc < 2) {
+ printf("Usage: dcm_test ALL|SINGLE file_path \n");
+ return 0;
+ }
+
+ g_path = (char *)g_malloc(MAX_STRING_LEN * sizeof(char *));
+ memset(g_path, 0x00, MAX_STRING_LEN);
+ snprintf(g_path, MAX_STRING_LEN, "%s", argv[2]);
+
+ printf("dcm_test SINGLE file_path=%s \n", g_path);
+
+ dcm_svc_request_extract_media(g_path, tzplatform_getuid(TZ_USER_NAME));
+ } else if (strcmp(g_command, ALL) == 0) {
+ printf("dcm_test ALL \n");
+
+ dcm_svc_request_extract_all(tzplatform_getuid(TZ_USER_NAME));
+ } else {
+ printf("Usage: dcm_test ALL|SINGLE file_path \n");
+ return 0;
+ }
+
+ return -1;
+}