Use g_compute_checksum_for_string instead 81/305681/4
authorminje.ahn <minje.ahn@samsung.com>
Tue, 6 Feb 2024 07:38:59 +0000 (16:38 +0900)
committerminje.ahn <minje.ahn@samsung.com>
Wed, 7 Feb 2024 00:14:18 +0000 (09:14 +0900)
glib support md5 checksum string.
So remove md5 related code.

Change-Id: I5b8203cc802a1fb6ac9dee8536ce4afbc441a4b2
Signed-off-by: minje.ahn <minje.ahn@samsung.com>
CMakeLists.txt
NOTICE
libmedia-service.pc.in
md5/md5.c [deleted file]
md5/md5.h [deleted file]
md5/media-svc-hash.c [deleted file]
md5/media-svc-hash.h [deleted file]
packaging/libmedia-service.spec
src/common/media-svc-util.c
src/include/common/media-svc-util.h

index c41cf6c..35c9cf0 100644 (file)
@@ -4,7 +4,6 @@ SET(VERSION_MAJOR 1)
 SET(VERSION "${VERSION_MAJOR}.0.0")
 
 SET(MEDIASERVICE-LIB "media-service")
-SET(MEDIASERVICE-HASH-LIB "media-svc-hash")
 SET(MEDIACONTENT-PLUGIN-LIB "media-content-plugin")
 SET(MEDIAEBOOK-PLUGIN-LIB "media-ebook-plugin")
 SET(SRCS
@@ -18,11 +17,6 @@ SET(SRCS
        src/common/media-svc-storage.c
        )
 
-SET(HASH_SRCS
-       md5/md5.c
-       md5/media-svc-hash.c
-       )
-
 SET(EBOOKPLUGIN_SRCS
        plugin/media-ebook-plugin.cpp
        plugin/media-ebook-plugin-regmatch.cpp
@@ -49,7 +43,7 @@ IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
 ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
 MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
 
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/src/include/common ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/uuid ${CMAKE_SOURCE_DIR}/md5)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/src/include/common ${CMAKE_SOURCE_DIR})
 
 FIND_PROGRAM(UNAME NAMES uname)
 EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
@@ -89,11 +83,8 @@ ENDIF(BUILD_GTESTS)
 
 LINK_DIRECTORIES(${LIB_INSTALL_DIR})
 
-ADD_LIBRARY(${MEDIASERVICE-HASH-LIB} SHARED ${HASH_SRCS})
-SET_TARGET_PROPERTIES(${MEDIASERVICE-HASH-LIB} PROPERTIES SOVERSION ${VERSION_MAJOR})
-SET_TARGET_PROPERTIES(${MEDIASERVICE-HASH-LIB} PROPERTIES VERSION ${VERSION})
 ADD_LIBRARY(${MEDIASERVICE-LIB} SHARED ${SRCS})
-TARGET_LINK_LIBRARIES(${MEDIASERVICE-LIB} ${pkgs_LDFLAGS} ${MEDIASERVICE-HASH-LIB})
+TARGET_LINK_LIBRARIES(${MEDIASERVICE-LIB} ${pkgs_LDFLAGS})
 SET_TARGET_PROPERTIES(${MEDIASERVICE-LIB} PROPERTIES SOVERSION ${VERSION_MAJOR})
 SET_TARGET_PROPERTIES(${MEDIASERVICE-LIB} PROPERTIES VERSION ${VERSION})
 ADD_LIBRARY(${MEDIACONTENT-PLUGIN-LIB} SHARED ${CONTENTPLUGIN_SRCS})
@@ -104,7 +95,6 @@ ADD_LIBRARY(${MEDIAEBOOK-PLUGIN-LIB} SHARED ${EBOOKPLUGIN_SRCS})
 TARGET_LINK_LIBRARIES(${MEDIAEBOOK-PLUGIN-LIB} ${pkgs_LDFLAGS})
 
 INSTALL(TARGETS ${MEDIASERVICE-LIB} LIBRARY DESTINATION ${LIB_INSTALL_DIR})
-INSTALL(TARGETS ${MEDIASERVICE-HASH-LIB} LIBRARY DESTINATION ${LIB_INSTALL_DIR})
 INSTALL(TARGETS ${MEDIACONTENT-PLUGIN-LIB} LIBRARY DESTINATION ${LIB_INSTALL_DIR})
 INSTALL(TARGETS ${MEDIAEBOOK-PLUGIN-LIB} LIBRARY DESTINATION ${LIB_INSTALL_DIR})
 
diff --git a/NOTICE b/NOTICE
index 98139f5..ccdad52 100644 (file)
--- a/NOTICE
+++ b/NOTICE
@@ -1,7 +1,3 @@
 Copyright (c) Samsung Electronics Co., Ltd. All rights reserved.
 Except as noted, this software is licensed under Apache License, Version 2.
 Please, see the LICENSE file for Apache License terms and conditions.
-
-Some parts of libmedia-service are licensed under the Public domain
- - md5/md5.c
- - md5/md5.h
index ae9df2c..b630a9f 100755 (executable)
@@ -9,5 +9,5 @@ Name: @PROJECT_NAME@
 Description: Samsung Linux platform @PROJECT_NAME@ library
 Version: @VERSION@
 Requires:
-Libs: -L${libdir} -lmedia-service -lmedia-svc-hash
+Libs: -L${libdir} -lmedia-service
 Cflags: -I${includedir}/media-service
diff --git a/md5/md5.c b/md5/md5.c
deleted file mode 100755 (executable)
index 8bac98d..0000000
--- a/md5/md5.c
+++ /dev/null
@@ -1,251 +0,0 @@
-/*
- * This code implements the MD5 message-digest algorithm.
- * The algorithm is due to Ron Rivest.  This code was
- * written by Colin Plumb in 1993, no copyright is claimed.
- * This code is in the public domain; do with it what you wish.
- *
- * Equivalent code is available from RSA Data Security, Inc.
- * This code has been tested against that, and is equivalent,
- * except that you don't need to include two pages of legalese
- * with every copy.
- *
- * To compute the message digest of a chunk of bytes, declare an
- * MD5Context structure, pass it to MD5Init, call MD5Update as
- * needed on buffers full of bytes, and then call MD5Final, which
- * will fill a supplied 16-byte array with the digest.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <string.h>            /* for memcpy() */
-#include "md5.h"
-
-#if (__BYTE_ORDER == 1234)
-#define byteReverse(buf, len)  /* Nothing */
-#else
-void byteReverse(unsigned char *buf, unsigned longs);
-
-/*
- * Note: this code is harmless on little-endian machines.
- */
-void byteReverse(unsigned char *buf, unsigned longs)
-{
-       uint32_t t;
-       do {
-               t = (uint32_t)((unsigned)buf[3] << 8 | buf[2]) << 16 |
-                   ((unsigned)buf[1] << 8 | buf[0]);
-               *(uint32_t *) buf = t;
-               buf += 4;
-       } while (--longs);
-}
-#endif
-
-/*
- * Start MD5 accumulation.  Set bit count to 0 and buffer to mysterious
- * initialization constants.
- */
-void media_svc_MD5Init(MD5_CTX *ctx)
-{
-       ctx->buf[0] = 0x67452301;
-       ctx->buf[1] = 0xefcdab89;
-       ctx->buf[2] = 0x98badcfe;
-       ctx->buf[3] = 0x10325476;
-
-       ctx->bits[0] = 0;
-       ctx->bits[1] = 0;
-}
-
-/*
- * Update context to reflect the concatenation of another buffer full
- * of bytes.
- */
-void media_svc_MD5Update(MD5_CTX *ctx, unsigned char const *buf, unsigned len)
-{
-       uint32_t t;
-
-       /* Update bitcount */
-
-       t = ctx->bits[0];
-       if ((ctx->bits[0] = t + ((uint32_t) len << 3)) < t)
-               ctx->bits[1]++; /* Carry from low to high */
-
-       ctx->bits[1] += len >> 29;
-
-       t = (t >> 3) & 0x3f;    /* Bytes already in shsInfo->data */
-
-       /* Handle any leading odd-sized chunks */
-
-       if (t) {
-               unsigned char *p = (unsigned char *)ctx->in + t;
-
-               t = 64 - t;
-               if (len < t) {
-                       memcpy(p, buf, len);
-                       return;
-               }
-               memcpy(p, buf, t);
-               byteReverse(ctx->in, 16);
-               MD5Transform(ctx->buf, (uint32_t *) ctx->in);
-               buf += t;
-               len -= t;
-       }
-       /* Process data in 64-byte chunks */
-
-       while (len >= 64) {
-               memcpy(ctx->in, buf, 64);
-               byteReverse(ctx->in, 16);
-               MD5Transform(ctx->buf, (uint32_t *) ctx->in);
-               buf += 64;
-               len -= 64;
-       }
-
-       /* Handle any remaining bytes of data. */
-
-       memcpy(ctx->in, buf, len);
-}
-
-/*
- * Final wrapup - pad to 64-byte boundary with the bit pattern
- * 1 0* (64-bit count of bits processed, MSB-first)
- */
-void media_svc_MD5Final(unsigned char digest[16], MD5_CTX *ctx)
-{
-       unsigned count;
-       unsigned char *p;
-
-       /* Compute number of bytes mod 64 */
-       count = (ctx->bits[0] >> 3) & 0x3F;
-
-       /* Set the first char of padding to 0x80.  This is safe since there is
-          always at least one byte free */
-       p = ctx->in + count;
-       *p++ = 0x80;
-
-       /* Bytes of padding needed to make 64 bytes */
-       count = 64 - 1 - count;
-
-       /* Pad out to 56 mod 64 */
-       if (count < 8) {
-               /* Two lots of padding:  Pad the first block to 64 bytes */
-               memset(p, 0, count);
-               byteReverse(ctx->in, 16);
-               MD5Transform(ctx->buf, (uint32_t *) ctx->in);
-
-               /* Now fill the next block with 56 bytes */
-               memset(ctx->in, 0, 56);
-       } else {
-               /* Pad block to 56 bytes */
-               memset(p, 0, count - 8);
-       }
-       byteReverse(ctx->in, 14);
-
-       /* Append length in bits and transform */
-       memcpy(((uint32_t *) ctx->in)+14, ctx->bits, sizeof(uint32_t)*2);
-
-       MD5Transform(ctx->buf, (uint32_t *) ctx->in);
-       byteReverse((unsigned char *)ctx->buf, 4);
-       memcpy(digest, ctx->buf, 16);
-       memset((char *)ctx, 0, sizeof(*ctx));   /* In case it's sensitive */
-}
-
-/* The four core functions - F1 is optimized somewhat */
-
-/* #define F1(x, y, z) (x & y | ~x & z) */
-#define F1(x, y, z) ((z) ^ ((x) & ((y) ^ (z))))
-#define F2(x, y, z) (F1((z), (x), (y)))
-#define F3(x, y, z) ((x) ^ (y) ^ (z))
-#define F4(x, y, z) ((y) ^ ((x) | ~(z)))
-
-/* This is the central step in the MD5 algorithm. */
-#define MD5STEP(f, w, x, y, z, data, s) \
-       (w += f(x, y, z) + data,  w = w<<s | w>>(32-s),  w += x)
-
-/*
- * The core of the MD5 algorithm, this alters an existing MD5 hash to
- * reflect the addition of 16 longwords of new data.  MD5Update blocks
- * the data and converts bytes into longwords for this routine.
- */
-void MD5Transform(uint32_t buf[4], uint32_t const in[16])
-{
-       register uint32_t a, b, c, d;
-
-       a = buf[0];
-       b = buf[1];
-       c = buf[2];
-       d = buf[3];
-
-       MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
-       MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
-       MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
-       MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
-       MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
-       MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
-       MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
-       MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
-       MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
-       MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
-       MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
-       MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
-       MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
-       MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
-       MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
-       MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
-
-       MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
-       MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
-       MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
-       MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
-       MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
-       MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
-       MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
-       MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
-       MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
-       MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
-       MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
-       MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
-       MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
-       MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
-       MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
-       MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
-
-       MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
-       MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
-       MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
-       MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
-       MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
-       MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
-       MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
-       MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
-       MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
-       MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
-       MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
-       MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
-       MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
-       MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
-       MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
-       MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
-
-       MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
-       MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
-       MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
-       MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
-       MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
-       MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
-       MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
-       MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
-       MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
-       MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
-       MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
-       MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
-       MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
-       MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
-       MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
-       MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
-
-       buf[0] += a;
-       buf[1] += b;
-       buf[2] += c;
-       buf[3] += d;
-}
diff --git a/md5/md5.h b/md5/md5.h
deleted file mode 100755 (executable)
index b05cbcb..0000000
--- a/md5/md5.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * This code implements the MD5 message-digest algorithm.
- * The algorithm is due to Ron Rivest.  This code was
- * written by Colin Plumb in 1993, no copyright is claimed.
- * This code is in the public domain; do with it what you wish.
- *
- * Equivalent code is available from RSA Data Security, Inc.
- * This code has been tested against that, and is equivalent,
- * except that you don't need to include two pages of legalese
- * with every copy.
- *
- * To compute the message digest of a chunk of bytes, declare an
- * MD5Context structure, pass it to MD5Init, call MD5Update as
- * needed on buffers full of bytes, and then call MD5Final, which
- * will fill a supplied 16-byte array with the digest.
- */
-
-
-#ifndef _MD5_H_
-#define _MD5_H_
-
-#include <stdint.h>
-#include <sys/types.h>
-
-#define MD5_HASHBYTES 16
-
-typedef struct MD5Context {
-       uint32_t buf[4];
-       uint32_t bits[2];
-       unsigned char in[64];
-} MD5_CTX;
-
-extern void media_svc_MD5Init(MD5_CTX *context);
-extern void media_svc_MD5Update(MD5_CTX *context, unsigned char const *buf, unsigned len);
-extern void media_svc_MD5Final(unsigned char digest[MD5_HASHBYTES], MD5_CTX *context);
-extern void MD5Transform(uint32_t buf[4], uint32_t const in[16]);
-
-#endif
diff --git a/md5/media-svc-hash.c b/md5/media-svc-hash.c
deleted file mode 100755 (executable)
index fbb21b4..0000000
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * libmedia-service
- *
- * 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.
- *
- */
-
-#include "md5.h"
-#include <string.h>
-#include <alloca.h>
-#include "media-svc-hash.h"
-#include "media-util-err.h"
-
-
-static const char ACCEPTABLE_URI_CHARS[96] = {
-       /*      !    "    #    $    %    &    '    (    )    *    +   ,    -    .    / */
-       0x00, 0x3F, 0x20, 0x20, 0x28, 0x00, 0x2C, 0x3F, 0x3F, 0x3F, 0x3F, 0x2A,
-       0x28, 0x3F, 0x3F, 0x1C,
-       /* 0    1    2    3    4    5    6    7    8    9    :    ;    <    =    >    ? */
-       0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x38, 0x20,
-       0x20, 0x2C, 0x20, 0x20,
-       /* @    A    B    C    D    E    F    G    H    I    J    K    L    M    N    O */
-       0x38, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
-       0x3F, 0x3F, 0x3F, 0x3F,
-       /* P    Q    R    S    T    U    V    W    X    Y    Z    [    \    ]    ^    _ */
-       0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x20,
-       0x20, 0x20, 0x20, 0x3F,
-       /* `    a    b    c    d    e    f    g    h    i    j    k    l    m    n    o */
-       0x20, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F,
-       0x3F, 0x3F, 0x3F, 0x3F,
-       /* p    q    r    s    t    u    v    w    x    y    z    {    |    }    ~  DEL */
-       0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x20,
-       0x20, 0x20, 0x3F, 0x20
-};
-
-char *_mb_svc_generate_hash_name(const char *file)
-{
-       int n;
-       MD5_CTX ctx;
-       static char md5out[(2 * MD5_HASHBYTES) + 1];
-       unsigned char hash[MD5_HASHBYTES];
-       static const char hex[] = "0123456789abcdef";
-
-       char *uri;
-       char *t;
-       const unsigned char *c;
-       int length;
-
-       if (!file)
-               return NULL;
-
-       length = 3 * strlen(file) + 9;
-
-       memset(md5out, 0, sizeof(md5out));
-
-#define _check_uri_char(c) \
-       ((c) >= 32 && (c) < 128 && (ACCEPTABLE_URI_CHARS[(c) - 32] & 0x08))
-
-       uri = alloca(length);
-       if (uri == NULL)
-               return NULL;
-
-       strncpy(uri, "file://", length);
-       uri[length - 1] = '\0';
-       t = uri + sizeof("file://") - 1;
-
-       for (c = (const unsigned char *)file; *c != '\0'; c++) {
-               if (!_check_uri_char(*c)) {
-                       *t++ = '%';
-                       *t++ = hex[*c >> 4];
-                       *t++ = hex[*c & 15];
-               } else {
-                       *t++ = *c;
-               }
-       }
-       *t = '\0';
-#undef _check_uri_char
-
-       media_svc_MD5Init(&ctx);
-       media_svc_MD5Update(&ctx, (unsigned char const *)uri, (unsigned)strlen(uri));
-       media_svc_MD5Final(hash, &ctx);
-
-       for (n = 0; n < MD5_HASHBYTES; n++) {
-               md5out[2 * n] = hex[hash[n] >> 4];
-               md5out[2 * n + 1] = hex[hash[n] & 0x0f];
-       }
-       md5out[2 * n] = '\0';
-
-       return md5out;
-}
-
-int mb_svc_generate_hash_code(const char *origin_path, char *hash_code, int max_length)
-{
-       char *hash = NULL;
-
-       if (max_length < ((2 * MD5_HASHBYTES) + 1))
-               return MS_MEDIA_ERR_INVALID_PARAMETER;
-
-       hash = _mb_svc_generate_hash_name(origin_path);
-
-       if (hash == NULL)
-               return MS_MEDIA_ERR_INTERNAL;
-
-       strncpy(hash_code, hash, max_length);
-       hash_code[strlen(hash_code)] = '\0';
-
-       return MS_MEDIA_ERR_NONE;
-}
diff --git a/md5/media-svc-hash.h b/md5/media-svc-hash.h
deleted file mode 100755 (executable)
index 57f5868..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * libmedia-service
- *
- * 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_SVC_HASH_
-#define _MEDIA_SVC_HASH_
-
-int mb_svc_generate_hash_code(const char *origin_path, char *hash_code, int max_length);
-
-#endif /*MEDIA_SVC_HASH_*/
index 475259c..5a09cd5 100644 (file)
@@ -1,9 +1,9 @@
 Name:       libmedia-service
 Summary:    Media information service library for multimedia applications
-Version:    0.5.0
+Version:    0.5.1
 Release:    0
 Group:      Multimedia/Libraries
-License:    Apache-2.0 and PD
+License:    Apache-2.0
 Source0:    %{name}-%{version}.tar.gz
 Source1001: libmedia-service.manifest
 
@@ -63,7 +63,6 @@ rm -rf %{buildroot}
 %manifest %{name}.manifest
 %defattr(-,root,root,-)
 %{_libdir}/libmedia-service.so.*
-%{_libdir}/libmedia-svc-hash.so.*
 %{_libdir}/libmedia-content-plugin.so
 %{_libdir}/libmedia-content-plugin.so.*
 %{_libdir}/libmedia-ebook-plugin.so
@@ -76,6 +75,5 @@ rm -rf %{buildroot}
 %files devel
 %manifest %{name}.manifest
 %{_libdir}/libmedia-service.so
-%{_libdir}/libmedia-svc-hash.so
 %{_libdir}/pkgconfig/libmedia-service.pc
 %{_includedir}/media-service/*.h
index 6687427..f4d0dd7 100644 (file)
@@ -35,7 +35,6 @@
 #include "media-svc-db-utils.h"
 #include "media-svc-debug.h"
 #include "media-svc-env.h"
-#include "media-svc-hash.h"
 #include "media-svc-album.h"
 /*For ebook metadata */
 #include <zip.h>
@@ -48,7 +47,6 @@
 
 #define MUSIC_MIME_NUM 29
 #define SOUND_MIME_NUM 2
-#define THUMB_HASH_LEN 256
 #define MIME_LENGTH 50
 #define MEDIA_SVC_DEFAULT_FORMAT_LEN 19
 #define IMAGE_PREFIX "image/"
@@ -352,38 +350,28 @@ void _media_svc_remove_file(const char *path)
                media_svc_stderror("fail to remove file result");
 }
 
-int _media_svc_get_thumbnail_path(char *thumb_path, const char *pathname, const char *img_format, uid_t uid)
+static int __media_svc_get_thumbnail_path(char *thumb_path, const char *pathname, const char *img_format, uid_t uid)
 {
        int ret = MS_MEDIA_ERR_NONE;
        char file_ext[MEDIA_SVC_FILE_EXT_LEN_MAX + 1] = {0, };
-       char hash[THUMB_HASH_LEN] = {0, };
-       char *thumb_dir = NULL;
+       g_autofree gchar *hash = NULL;
+       g_autofree gchar *thumb_dir = NULL;
 
        ret = ms_user_get_root_thumb_store_path(uid, &thumb_dir);
        media_svc_retvm_if(!STRING_VALID(thumb_dir), ret, "ms_user_get_root_thumb_store_path failed");
-
-       if (!g_file_test(thumb_dir, G_FILE_TEST_IS_DIR)) {
-               media_svc_error("Wrong path[%s]", thumb_dir);
-               g_free(thumb_dir);
-               return MS_MEDIA_ERR_INTERNAL;
-       }
+       media_svc_retvm_if(!g_file_test(thumb_dir, G_FILE_TEST_IS_DIR), MS_MEDIA_ERR_INTERNAL, "Not a directory");
 
        memset(file_ext, 0, sizeof(file_ext));
        if (!__media_svc_get_file_ext(pathname, file_ext))
                media_svc_error("get file ext fail");
 
-       ret = mb_svc_generate_hash_code(pathname, hash, THUMB_HASH_LEN);
-       if (ret != MS_MEDIA_ERR_NONE) {
-               media_svc_error("mb_svc_generate_hash_code failed : %d", ret);
-               g_free(thumb_dir);
-               return MS_MEDIA_ERR_INTERNAL;
-       }
+       hash = g_compute_checksum_for_string(G_CHECKSUM_MD5, pathname, -1);
+       media_svc_retvm_if(!hash, MS_MEDIA_ERR_INTERNAL, "Failed to create hashname");
 
        if (img_format) {
                /* 'img_format' is mime-type */
                if (!g_str_has_prefix(img_format, IMAGE_PREFIX) || strlen(img_format) == IMAGE_PREFIX_LEN) {
                        media_svc_error("Not proper img format");
-                       g_free(thumb_dir);
                        return MS_MEDIA_ERR_INTERNAL;
                }
 
@@ -395,8 +383,6 @@ int _media_svc_get_thumbnail_path(char *thumb_path, const char *pathname, const
                        snprintf(thumb_path, MEDIA_SVC_PATHNAME_SIZE, "%s/.%s-%s.jpg", thumb_dir, file_ext, hash);
        }
 
-       g_free(thumb_dir);
-
        return MS_MEDIA_ERR_NONE;
 }
 
@@ -671,7 +657,7 @@ int _media_svc_extract_audio_metadata(sqlite3 *handle, bool is_direct, media_svc
 
                                mmf_error = mm_file_get_attrs(tag, MM_FILE_TAG_ARTWORK_MIME, &p, &artwork_mime_size, NULL);
                                if ((mmf_error == FILEINFO_ERROR_NONE) && (artwork_mime_size > 0)) {
-                                       ret = _media_svc_get_thumbnail_path(thumb_path, content_info->path, p, uid);
+                                       ret = __media_svc_get_thumbnail_path(thumb_path, content_info->path, p, uid);
                                        if (ret != MS_MEDIA_ERR_NONE) {
                                                media_svc_error("Fail to Get Thumbnail Path");
                                        } else {
@@ -1079,10 +1065,10 @@ int _media_svc_create_thumbnail(const char *path, char *thumb_path, media_svc_me
 
        media_svc_sec_debug("Path[%s] Type[%d]", path, media_type);
 
-       //1. make hash path
-       ret = _media_svc_get_thumbnail_path(thumb_path, path, NULL, uid);
+       //1. make thumb path
+       ret = __media_svc_get_thumbnail_path(thumb_path, path, NULL, uid);
        if (ret != MS_MEDIA_ERR_NONE) {
-               media_svc_error("_media_svc_get_thumbnail_path failed - %d", ret);
+               media_svc_error("Failed to create thumbnail path[%d]", ret);
                SAFE_STRLCPY(thumb_path, "", MAX_FILEPATH_LEN);
                return ret;
        }
index 6cbee84..f038179 100755 (executable)
@@ -90,7 +90,6 @@ typedef enum {
 } media_svc_search_type_e;
 
 void _media_svc_remove_file(const char *path);
-int _media_svc_get_thumbnail_path(char *thumb_path, const char *pathname, const char *img_format, uid_t uid);
 int _media_svc_get_file_time(const char *full_path);
 char * _media_svc_get_title_by_path(const char *path);
 int _media_svc_set_media_info(media_svc_content_info_s *content_info, const char *storage_id, const char *path, bool refresh);