summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKibum Kim <kb0929.kim@samsung.com>2012-01-07 00:50:05 +0900
committerKibum Kim <kb0929.kim@samsung.com>2012-01-07 00:50:05 +0900
commit032958b4b3cd7e36b242fb07b94f4a79dc5e8c25 (patch)
tree11d4bac30b8f23f7f68da5524c4f062dea16e8b8
parent5e81c300ee70db3cca83a18755c271758e9220da (diff)
downloadmedia-server-032958b4b3cd7e36b242fb07b94f4a79dc5e8c25.tar.gz
media-server-032958b4b3cd7e36b242fb07b94f4a79dc5e8c25.tar.bz2
media-server-032958b4b3cd7e36b242fb07b94f4a79dc5e8c25.zip
Git init
-rw-r--r--LICENSE206
-rwxr-xr-xMakefile.am91
-rwxr-xr-xautogen.sh12
-rwxr-xr-xbuild-aux/depcomp630
-rwxr-xr-xbuild-aux/install-sh520
-rwxr-xr-xbuild-aux/missing376
-rwxr-xr-xcommon/include/media-server-common.h153
-rwxr-xr-xcommon/include/media-server-error.h91
-rwxr-xr-xcommon/include/media-server-global.h123
-rwxr-xr-xcommon/include/media-server-hibernation.h40
-rwxr-xr-xcommon/include/media-server-inotify-internal.h56
-rwxr-xr-xcommon/include/media-server-inotify.h63
-rwxr-xr-xcommon/include/media-server-scan-internal.h38
-rwxr-xr-xcommon/include/media-server-scan.h31
-rwxr-xr-xcommon/include/media-server-socket.h34
-rwxr-xr-xcommon/include/media-server-thumb.h35
-rwxr-xr-xcommon/include/media-server-types.h99
-rwxr-xr-xcommon/media-server-common.c1780
-rwxr-xr-xcommon/media-server-hibernation.c132
-rwxr-xr-xcommon/media-server-inotify-internal.c142
-rwxr-xr-xcommon/media-server-inotify.c707
-rwxr-xr-xcommon/media-server-main.c240
-rwxr-xr-xcommon/media-server-scan-internal.c404
-rwxr-xr-xcommon/media-server-scan.c239
-rwxr-xr-xcommon/media-server-socket.c147
-rwxr-xr-xcommon/media-server-thumb.c108
-rw-r--r--config.in161
-rwxr-xr-xconfigure.ac138
-rwxr-xr-xdata/mediasvr3
-rwxr-xr-xdebian/changelog7
-rw-r--r--debian/compat1
-rwxr-xr-xdebian/control43
-rw-r--r--debian/copyright14
-rwxr-xr-xdebian/libmedia-utils-dev.install.in2
-rwxr-xr-xdebian/libmedia-utils.install.in1
-rwxr-xr-xdebian/libmedia-utils.postinst.in1
-rw-r--r--debian/media-server.install.in4
-rwxr-xr-xdebian/media-server.postinst.in11
-rwxr-xr-xdebian/prerm.in14
-rwxr-xr-xdebian/rules125
-rwxr-xr-xlib/include/media-util-dbg.h45
-rwxr-xr-xlib/include/media-util-err.h53
-rwxr-xr-xlib/include/media-util-internal.h43
-rwxr-xr-xlib/include/media-util-noti.h85
-rwxr-xr-xlib/include/media-util-register.h99
-rwxr-xr-xlib/media-util-noti.c50
-rwxr-xr-xlib/media-util-register.c212
-rwxr-xr-xlibmedia-utils.pc.in11
-rw-r--r--packaging/media-server.spec290
49 files changed, 7910 insertions, 0 deletions
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..f94008a
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,206 @@
+Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ 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.
+
+
+
diff --git a/Makefile.am b/Makefile.am
new file mode 100755
index 0000000..df4cd48
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,91 @@
+ACLOCAL_AMFLAGS = -I m4
+
+SUBDIRS = .
+
+AM_CPPFLAGS = $(FMS_DEBUG_FLAGS)
+
+AM_LDFLAGS=-Wl,--as-needed --hash-style=both
+
+### pkgconfig ###
+pkgconfigdir = $(libdir)/pkgconfig
+dist_pkgconfig_DATA = libmedia-utils.pc
+
+nor_directory = /etc/rc.d/rc3.d
+hib_directory = /etc/rc.d/rc5.d
+
+install-data-hook:
+ mkdir $(DESTDIR)$(nor_directory) -p
+ ln -s ../init.d/mediasvr S48mediasvr
+ mv ./S48mediasvr $(DESTDIR)$(nor_directory)
+ mkdir $(DESTDIR)$(hib_directory) -p
+ ln -s ../init.d/mediasvr S48mediasvr
+ mv ./S48mediasvr $(DESTDIR)$(hib_directory)
+
+# init.d script
+fmsvcdir = /etc/rc.d/init.d
+dist_fmsvc_DATA = ./data/mediasvr
+
+### libmedia-utils.la ###
+lib_LTLIBRARIES = libmedia-utils.la
+libmedia_utils_la_SOURCES = lib/media-util-noti.c \
+ lib/media-util-register.c
+
+libmedia_utils_la_CFLAGS = -I${srcdir}/lib/include \
+ $(MEDIA_INFO_CFLAGS) \
+ $(GLIB_CFLAGS) \
+ $(DLOG_CFLAGS)
+
+libmedia_utils_la_LIBADD = $(MEDIA_INFO_LIBS) \
+ $(GLIB_LIBS) \
+ $(DLOG_LIBS)
+
+
+### file-manager-server ###
+bin_PROGRAMS = media-server
+
+media_server_SOURCES = common/media-server-common.c \
+ common/media-server-thumb.c \
+ common/media-server-inotify-internal.c \
+ common/media-server-inotify.c \
+ common/media-server-scan-internal.c \
+ common/media-server-scan.c \
+ common/media-server-socket.c \
+ common/media-server-main.c
+
+media_server_CFLAGS = -I${srcdir}/common/include \
+ -I${srcdir}/lib/include \
+ $(GTHREAD_CFLAGS) \
+ $(GLIB_CFLAGS) \
+ $(MM_FILEINFO_CFLAGS) \
+ $(MEDIA_INFO_CFLAGS) \
+ $(PHONESTATUS_CFLAGS) \
+ $(UTIL_CFLAGS) \
+ $(DLOG_CFLAGS) \
+ $(DRM_SERVICE_CFLAGS) \
+ $(DB_UTIL_CFLAGS) \
+ $(AUL_CFLAG)\
+ $(DBUS_CFLAGS)\
+ $(LIBPMCONTROL_CFLAGS)\
+ $(THUMB_GEN_CFLAGS)
+# $(LIBQUICKPANEL_CFLAGS)
+
+media_server_LDADD = $(GLIB_LIBS) \
+ $(GTHREAD_LIBS) \
+ $(MM_FILEINFO_LIBS) \
+ $(MEDIA_INFO_LIBS) \
+ $(PHONESTATUS_LIBS) \
+ $(UTIL_LIBS) \
+ $(DLOG_LIBS) \
+ $(DRM_SERVICE_LIBS) \
+ $(DB_UTIL_LIBS) \
+ $(AUL_LIBS)\
+ $(DBUS_LIBS)\
+ $(LIBPMCONTROL_LIBS)\
+ $(THUMB_GEN_LIBS)
+# $(LIBQUICKPANEL_LIBS)
+
+### includeheaders ###
+includeheadersdir = $(includedir)/media-utils
+includeheaders_HEADERS = lib/include/media-util-noti.h \
+ lib/include/media-util-register.h \
+ lib/include/media-util-err.h
diff --git a/autogen.sh b/autogen.sh
new file mode 100755
index 0000000..a9d7ee4
--- /dev/null
+++ b/autogen.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+rm -rf autom4te.cache
+rm -f aclocal.m4 ltmain.sh
+mkdir -p m4
+
+echo "Running aclocal..." ; aclocal $ACLOCAL_FLAGS -I m4 || exit 1
+echo "Running autoheader..." ; autoheader || exit 1
+echo "Running autoconf..." ; autoconf || exit 1
+echo "Running libtoolize..." ; (libtoolize --copy --automake --force || glibtoolize --automake) || exit 1
+echo "Running automake..." ; automake --add-missing --copy --foreign --force-missing || exit 1
+echo "You can now compile and build package."
diff --git a/build-aux/depcomp b/build-aux/depcomp
new file mode 100755
index 0000000..df8eea7
--- /dev/null
+++ b/build-aux/depcomp
@@ -0,0 +1,630 @@
+#! /bin/sh
+# depcomp - compile a program generating dependencies as side-effects
+
+scriptversion=2009-04-28.21; # UTC
+
+# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free
+# Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
+
+case $1 in
+ '')
+ echo "$0: No command. Try \`$0 --help' for more information." 1>&2
+ exit 1;
+ ;;
+ -h | --h*)
+ cat <<\EOF
+Usage: depcomp [--help] [--version] PROGRAM [ARGS]
+
+Run PROGRAMS ARGS to compile a file, generating dependencies
+as side-effects.
+
+Environment variables:
+ depmode Dependency tracking mode.
+ source Source file read by `PROGRAMS ARGS'.
+ object Object file output by `PROGRAMS ARGS'.
+ DEPDIR directory where to store dependencies.
+ depfile Dependency file to output.
+ tmpdepfile Temporary file to use when outputing dependencies.
+ libtool Whether libtool is used (yes/no).
+
+Report bugs to <bug-automake@gnu.org>.
+EOF
+ exit $?
+ ;;
+ -v | --v*)
+ echo "depcomp $scriptversion"
+ exit $?
+ ;;
+esac
+
+if test -z "$depmode" || test -z "$source" || test -z "$object"; then
+ echo "depcomp: Variables source, object and depmode must be set" 1>&2
+ exit 1
+fi
+
+# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
+depfile=${depfile-`echo "$object" |
+ sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
+tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
+
+rm -f "$tmpdepfile"
+
+# Some modes work just like other modes, but use different flags. We
+# parameterize here, but still list the modes in the big case below,
+# to make depend.m4 easier to write. Note that we *cannot* use a case
+# here, because this file can only contain one case statement.
+if test "$depmode" = hp; then
+ # HP compiler uses -M and no extra arg.
+ gccflag=-M
+ depmode=gcc
+fi
+
+if test "$depmode" = dashXmstdout; then
+ # This is just like dashmstdout with a different argument.
+ dashmflag=-xM
+ depmode=dashmstdout
+fi
+
+cygpath_u="cygpath -u -f -"
+if test "$depmode" = msvcmsys; then
+ # This is just like msvisualcpp but w/o cygpath translation.
+ # Just convert the backslash-escaped backslashes to single forward
+ # slashes to satisfy depend.m4
+ cygpath_u="sed s,\\\\\\\\,/,g"
+ depmode=msvisualcpp
+fi
+
+case "$depmode" in
+gcc3)
+## gcc 3 implements dependency tracking that does exactly what
+## we want. Yay! Note: for some reason libtool 1.4 doesn't like
+## it if -MD -MP comes after the -MF stuff. Hmm.
+## Unfortunately, FreeBSD c89 acceptance of flags depends upon
+## the command line argument order; so add the flags where they
+## appear in depend2.am. Note that the slowdown incurred here
+## affects only configure: in makefiles, %FASTDEP% shortcuts this.
+ for arg
+ do
+ case $arg in
+ -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
+ *) set fnord "$@" "$arg" ;;
+ esac
+ shift # fnord
+ shift # $arg
+ done
+ "$@"
+ stat=$?
+ if test $stat -eq 0; then :
+ else
+ rm -f "$tmpdepfile"
+ exit $stat
+ fi
+ mv "$tmpdepfile" "$depfile"
+ ;;
+
+gcc)
+## There are various ways to get dependency output from gcc. Here's
+## why we pick this rather obscure method:
+## - Don't want to use -MD because we'd like the dependencies to end
+## up in a subdir. Having to rename by hand is ugly.
+## (We might end up doing this anyway to support other compilers.)
+## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
+## -MM, not -M (despite what the docs say).
+## - Using -M directly means running the compiler twice (even worse
+## than renaming).
+ if test -z "$gccflag"; then
+ gccflag=-MD,
+ fi
+ "$@" -Wp,"$gccflag$tmpdepfile"
+ stat=$?
+ if test $stat -eq 0; then :
+ else
+ rm -f "$tmpdepfile"
+ exit $stat
+ fi
+ rm -f "$depfile"
+ echo "$object : \\" > "$depfile"
+ alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
+## The second -e expression handles DOS-style file names with drive letters.
+ sed -e 's/^[^:]*: / /' \
+ -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
+## This next piece of magic avoids the `deleted header file' problem.
+## The problem is that when a header file which appears in a .P file
+## is deleted, the dependency causes make to die (because there is
+## typically no way to rebuild the header). We avoid this by adding
+## dummy dependencies for each header file. Too bad gcc doesn't do
+## this for us directly.
+ tr ' ' '
+' < "$tmpdepfile" |
+## Some versions of gcc put a space before the `:'. On the theory
+## that the space means something, we add a space to the output as
+## well.
+## Some versions of the HPUX 10.20 sed can't process this invocation
+## correctly. Breaking it into two sed invocations is a workaround.
+ sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+ rm -f "$tmpdepfile"
+ ;;
+
+hp)
+ # This case exists only to let depend.m4 do its work. It works by
+ # looking at the text of this script. This case will never be run,
+ # since it is checked for above.
+ exit 1
+ ;;
+
+sgi)
+ if test "$libtool" = yes; then
+ "$@" "-Wp,-MDupdate,$tmpdepfile"
+ else
+ "$@" -MDupdate "$tmpdepfile"
+ fi
+ stat=$?
+ if test $stat -eq 0; then :
+ else
+ rm -f "$tmpdepfile"
+ exit $stat
+ fi
+ rm -f "$depfile"
+
+ if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
+ echo "$object : \\" > "$depfile"
+
+ # Clip off the initial element (the dependent). Don't try to be
+ # clever and replace this with sed code, as IRIX sed won't handle
+ # lines with more than a fixed number of characters (4096 in
+ # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
+ # the IRIX cc adds comments like `#:fec' to the end of the
+ # dependency line.
+ tr ' ' '
+' < "$tmpdepfile" \
+ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
+ tr '
+' ' ' >> "$depfile"
+ echo >> "$depfile"
+
+ # The second pass generates a dummy entry for each header file.
+ tr ' ' '
+' < "$tmpdepfile" \
+ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
+ >> "$depfile"
+ else
+ # The sourcefile does not contain any dependencies, so just
+ # store a dummy comment line, to avoid errors with the Makefile
+ # "include basename.Plo" scheme.
+ echo "#dummy" > "$depfile"
+ fi
+ rm -f "$tmpdepfile"
+ ;;
+
+aix)
+ # The C for AIX Compiler uses -M and outputs the dependencies
+ # in a .u file. In older versions, this file always lives in the
+ # current directory. Also, the AIX compiler puts `$object:' at the
+ # start of each line; $object doesn't have directory information.
+ # Version 6 uses the directory in both cases.
+ dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
+ test "x$dir" = "x$object" && dir=
+ base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
+ if test "$libtool" = yes; then
+ tmpdepfile1=$dir$base.u
+ tmpdepfile2=$base.u
+ tmpdepfile3=$dir.libs/$base.u
+ "$@" -Wc,-M
+ else
+ tmpdepfile1=$dir$base.u
+ tmpdepfile2=$dir$base.u
+ tmpdepfile3=$dir$base.u
+ "$@" -M
+ fi
+ stat=$?
+
+ if test $stat -eq 0; then :
+ else
+ rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
+ exit $stat
+ fi
+
+ for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
+ do
+ test -f "$tmpdepfile" && break
+ done
+ if test -f "$tmpdepfile"; then
+ # Each line is of the form `foo.o: dependent.h'.
+ # Do two passes, one to just change these to
+ # `$object: dependent.h' and one to simply `dependent.h:'.
+ sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
+ # That's a tab and a space in the [].
+ sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
+ else
+ # The sourcefile does not contain any dependencies, so just
+ # store a dummy comment line, to avoid errors with the Makefile
+ # "include basename.Plo" scheme.
+ echo "#dummy" > "$depfile"
+ fi
+ rm -f "$tmpdepfile"
+ ;;
+
+icc)
+ # Intel's C compiler understands `-MD -MF file'. However on
+ # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
+ # ICC 7.0 will fill foo.d with something like
+ # foo.o: sub/foo.c
+ # foo.o: sub/foo.h
+ # which is wrong. We want:
+ # sub/foo.o: sub/foo.c
+ # sub/foo.o: sub/foo.h
+ # sub/foo.c:
+ # sub/foo.h:
+ # ICC 7.1 will output
+ # foo.o: sub/foo.c sub/foo.h
+ # and will wrap long lines using \ :
+ # foo.o: sub/foo.c ... \
+ # sub/foo.h ... \
+ # ...
+
+ "$@" -MD -MF "$tmpdepfile"
+ stat=$?
+ if test $stat -eq 0; then :
+ else
+ rm -f "$tmpdepfile"
+ exit $stat
+ fi
+ rm -f "$depfile"
+ # Each line is of the form `foo.o: dependent.h',
+ # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
+ # Do two passes, one to just change these to
+ # `$object: dependent.h' and one to simply `dependent.h:'.
+ sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
+ # Some versions of the HPUX 10.20 sed can't process this invocation
+ # correctly. Breaking it into two sed invocations is a workaround.
+ sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
+ sed -e 's/$/ :/' >> "$depfile"
+ rm -f "$tmpdepfile"
+ ;;
+
+hp2)
+ # The "hp" stanza above does not work with aCC (C++) and HP's ia64
+ # compilers, which have integrated preprocessors. The correct option
+ # to use with these is +Maked; it writes dependencies to a file named
+ # 'foo.d', which lands next to the object file, wherever that
+ # happens to be.
+ # Much of this is similar to the tru64 case; see comments there.
+ dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
+ test "x$dir" = "x$object" && dir=
+ base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
+ if test "$libtool" = yes; then
+ tmpdepfile1=$dir$base.d
+ tmpdepfile2=$dir.libs/$base.d
+ "$@" -Wc,+Maked
+ else
+ tmpdepfile1=$dir$base.d
+ tmpdepfile2=$dir$base.d
+ "$@" +Maked
+ fi
+ stat=$?
+ if test $stat -eq 0; then :
+ else
+ rm -f "$tmpdepfile1" "$tmpdepfile2"
+ exit $stat
+ fi
+
+ for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
+ do
+ test -f "$tmpdepfile" && break
+ done
+ if test -f "$tmpdepfile"; then
+ sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
+ # Add `dependent.h:' lines.
+ sed -ne '2,${
+ s/^ *//
+ s/ \\*$//
+ s/$/:/
+ p
+ }' "$tmpdepfile" >> "$depfile"
+ else
+ echo "#dummy" > "$depfile"
+ fi
+ rm -f "$tmpdepfile" "$tmpdepfile2"
+ ;;
+
+tru64)
+ # The Tru64 compiler uses -MD to generate dependencies as a side
+ # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
+ # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
+ # dependencies in `foo.d' instead, so we check for that too.
+ # Subdirectories are respected.
+ dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
+ test "x$dir" = "x$object" && dir=
+ base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
+
+ if test "$libtool" = yes; then
+ # With Tru64 cc, shared objects can also be used to make a
+ # static library. This mechanism is used in libtool 1.4 series to
+ # handle both shared and static libraries in a single compilation.
+ # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
+ #
+ # With libtool 1.5 this exception was removed, and libtool now
+ # generates 2 separate objects for the 2 libraries. These two
+ # compilations output dependencies in $dir.libs/$base.o.d and
+ # in $dir$base.o.d. We have to check for both files, because
+ # one of the two compilations can be disabled. We should prefer
+ # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
+ # automatically cleaned when .libs/ is deleted, while ignoring
+ # the former would cause a distcleancheck panic.
+ tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4
+ tmpdepfile2=$dir$base.o.d # libtool 1.5
+ tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5
+ tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504
+ "$@" -Wc,-MD
+ else
+ tmpdepfile1=$dir$base.o.d
+ tmpdepfile2=$dir$base.d
+ tmpdepfile3=$dir$base.d
+ tmpdepfile4=$dir$base.d
+ "$@" -MD
+ fi
+
+ stat=$?
+ if test $stat -eq 0; then :
+ else
+ rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
+ exit $stat
+ fi
+
+ for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
+ do
+ test -f "$tmpdepfile" && break
+ done
+ if test -f "$tmpdepfile"; then
+ sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
+ # That's a tab and a space in the [].
+ sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
+ else
+ echo "#dummy" > "$depfile"
+ fi
+ rm -f "$tmpdepfile"
+ ;;
+
+#nosideeffect)
+ # This comment above is used by automake to tell side-effect
+ # dependency tracking mechanisms from slower ones.
+
+dashmstdout)
+ # Important note: in order to support this mode, a compiler *must*
+ # always write the preprocessed file to stdout, regardless of -o.
+ "$@" || exit $?
+
+ # Remove the call to Libtool.
+ if test "$libtool" = yes; then
+ while test "X$1" != 'X--mode=compile'; do
+ shift
+ done
+ shift
+ fi
+
+ # Remove `-o $object'.
+ IFS=" "
+ for arg
+ do
+ case $arg in
+ -o)
+ shift
+ ;;
+ $object)
+ shift
+ ;;
+ *)
+ set fnord "$@" "$arg"
+ shift # fnord
+ shift # $arg
+ ;;
+ esac
+ done
+
+ test -z "$dashmflag" && dashmflag=-M
+ # Require at least two characters before searching for `:'
+ # in the target name. This is to cope with DOS-style filenames:
+ # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
+ "$@" $dashmflag |
+ sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
+ rm -f "$depfile"
+ cat < "$tmpdepfile" > "$depfile"
+ tr ' ' '
+' < "$tmpdepfile" | \
+## Some versions of the HPUX 10.20 sed can't process this invocation
+## correctly. Breaking it into two sed invocations is a workaround.
+ sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+ rm -f "$tmpdepfile"
+ ;;
+
+dashXmstdout)
+ # This case only exists to satisfy depend.m4. It is never actually
+ # run, as this mode is specially recognized in the preamble.
+ exit 1
+ ;;
+
+makedepend)
+ "$@" || exit $?
+ # Remove any Libtool call
+ if test "$libtool" = yes; then
+ while test "X$1" != 'X--mode=compile'; do
+ shift
+ done
+ shift
+ fi
+ # X makedepend
+ shift
+ cleared=no eat=no
+ for arg
+ do
+ case $cleared in
+ no)
+ set ""; shift
+ cleared=yes ;;
+ esac
+ if test $eat = yes; then
+ eat=no
+ continue
+ fi
+ case "$arg" in
+ -D*|-I*)
+ set fnord "$@" "$arg"; shift ;;
+ # Strip any option that makedepend may not understand. Remove
+ # the object too, otherwise makedepend will parse it as a source file.
+ -arch)
+ eat=yes ;;
+ -*|$object)
+ ;;
+ *)
+ set fnord "$@" "$arg"; shift ;;
+ esac
+ done
+ obj_suffix=`echo "$object" | sed 's/^.*\././'`
+ touch "$tmpdepfile"
+ ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
+ rm -f "$depfile"
+ cat < "$tmpdepfile" > "$depfile"
+ sed '1,2d' "$tmpdepfile" | tr ' ' '
+' | \
+## Some versions of the HPUX 10.20 sed can't process this invocation
+## correctly. Breaking it into two sed invocations is a workaround.
+ sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+ rm -f "$tmpdepfile" "$tmpdepfile".bak
+ ;;
+
+cpp)
+ # Important note: in order to support this mode, a compiler *must*
+ # always write the preprocessed file to stdout.
+ "$@" || exit $?
+
+ # Remove the call to Libtool.
+ if test "$libtool" = yes; then
+ while test "X$1" != 'X--mode=compile'; do
+ shift
+ done
+ shift
+ fi
+
+ # Remove `-o $object'.
+ IFS=" "
+ for arg
+ do
+ case $arg in
+ -o)
+ shift
+ ;;
+ $object)
+ shift
+ ;;
+ *)
+ set fnord "$@" "$arg"
+ shift # fnord
+ shift # $arg
+ ;;
+ esac
+ done
+
+ "$@" -E |
+ sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
+ -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
+ sed '$ s: \\$::' > "$tmpdepfile"
+ rm -f "$depfile"
+ echo "$object : \\" > "$depfile"
+ cat < "$tmpdepfile" >> "$depfile"
+ sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
+ rm -f "$tmpdepfile"
+ ;;
+
+msvisualcpp)
+ # Important note: in order to support this mode, a compiler *must*
+ # always write the preprocessed file to stdout.
+ "$@" || exit $?
+
+ # Remove the call to Libtool.
+ if test "$libtool" = yes; then
+ while test "X$1" != 'X--mode=compile'; do
+ shift
+ done
+ shift
+ fi
+
+ IFS=" "
+ for arg
+ do
+ case "$arg" in
+ -o)
+ shift
+ ;;
+ $object)
+ shift
+ ;;
+ "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
+ set fnord "$@"
+ shift
+ shift
+ ;;
+ *)
+ set fnord "$@" "$arg"
+ shift
+ shift
+ ;;
+ esac
+ done
+ "$@" -E 2>/dev/null |
+ sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
+ rm -f "$depfile"
+ echo "$object : \\" > "$depfile"
+ sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"
+ echo " " >> "$depfile"
+ sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
+ rm -f "$tmpdepfile"
+ ;;
+
+msvcmsys)
+ # This case exists only to let depend.m4 do its work. It works by
+ # looking at the text of this script. This case will never be run,
+ # since it is checked for above.
+ exit 1
+ ;;
+
+none)
+ exec "$@"
+ ;;
+
+*)
+ echo "Unknown depmode $depmode" 1>&2
+ exit 1
+ ;;
+esac
+
+exit 0
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
+# End:
diff --git a/build-aux/install-sh b/build-aux/install-sh
new file mode 100755
index 0000000..6781b98
--- /dev/null
+++ b/build-aux/install-sh
@@ -0,0 +1,520 @@
+#!/bin/sh
+# install - install a program, script, or datafile
+
+scriptversion=2009-04-28.21; # UTC
+
+# This originates from X11R5 (mit/util/scripts/install.sh), which was
+# later released in X11R6 (xc/config/util/install.sh) with the
+# following copyright and license.
+#
+# Copyright (C) 1994 X Consortium
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to
+# deal in the Software without restriction, including without limitation the
+# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+# sell copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
+# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+# Except as contained in this notice, the name of the X Consortium shall not
+# be used in advertising or otherwise to promote the sale, use or other deal-
+# ings in this Software without prior written authorization from the X Consor-
+# tium.
+#
+#
+# FSF changes to this file are in the public domain.
+#
+# Calling this script install-sh is preferred over install.sh, to prevent
+# `make' implicit rules from creating a file called install from it
+# when there is no Makefile.
+#
+# This script is compatible with the BSD install script, but was written
+# from scratch.
+
+nl='
+'
+IFS=" "" $nl"
+
+# set DOITPROG to echo to test this script
+
+# Don't use :- since 4.3BSD and earlier shells don't like it.
+doit=${DOITPROG-}
+if test -z "$doit"; then
+ doit_exec=exec
+else
+ doit_exec=$doit
+fi
+
+# Put in absolute file names if you don't have them in your path;
+# or use environment vars.
+
+chgrpprog=${CHGRPPROG-chgrp}
+chmodprog=${CHMODPROG-chmod}
+chownprog=${CHOWNPROG-chown}
+cmpprog=${CMPPROG-cmp}
+cpprog=${CPPROG-cp}
+mkdirprog=${MKDIRPROG-mkdir}
+mvprog=${MVPROG-mv}
+rmprog=${RMPROG-rm}
+stripprog=${STRIPPROG-strip}
+
+posix_glob='?'
+initialize_posix_glob='
+ test "$posix_glob" != "?" || {
+ if (set -f) 2>/dev/null; then
+ posix_glob=
+ else
+ posix_glob=:
+ fi
+ }
+'
+
+posix_mkdir=
+
+# Desired mode of installed file.
+mode=0755
+
+chgrpcmd=
+chmodcmd=$chmodprog
+chowncmd=
+mvcmd=$mvprog
+rmcmd="$rmprog -f"
+stripcmd=
+
+src=
+dst=
+dir_arg=
+dst_arg=
+
+copy_on_change=false
+no_target_directory=
+
+usage="\
+Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
+ or: $0 [OPTION]... SRCFILES... DIRECTORY
+ or: $0 [OPTION]... -t DIRECTORY SRCFILES...
+ or: $0 [OPTION]... -d DIRECTORIES...
+
+In the 1st form, copy SRCFILE to DSTFILE.
+In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
+In the 4th, create DIRECTORIES.
+
+Options:
+ --help display this help and exit.
+ --version display version info and exit.
+
+ -c (ignored)
+ -C install only if different (preserve the last data modification time)
+ -d create directories instead of installing files.
+ -g GROUP $chgrpprog installed files to GROUP.
+ -m MODE $chmodprog installed files to MODE.
+ -o USER $chownprog installed files to USER.
+ -s $stripprog installed files.
+ -t DIRECTORY install into DIRECTORY.
+ -T report an error if DSTFILE is a directory.
+
+Environment variables override the default commands:
+ CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
+ RMPROG STRIPPROG
+"
+
+while test $# -ne 0; do
+ case $1 in
+ -c) ;;
+
+ -C) copy_on_change=true;;
+
+ -d) dir_arg=true;;
+
+ -g) chgrpcmd="$chgrpprog $2"
+ shift;;
+
+ --help) echo "$usage"; exit $?;;
+
+ -m) mode=$2
+ case $mode in
+ *' '* | *' '* | *'
+'* | *'*'* | *'?'* | *'['*)
+ echo "$0: invalid mode: $mode" >&2
+ exit 1;;
+ esac
+ shift;;
+
+ -o) chowncmd="$chownprog $2"
+ shift;;
+
+ -s) stripcmd=$stripprog;;
+
+ -t) dst_arg=$2
+ shift;;
+
+ -T) no_target_directory=true;;
+
+ --version) echo "$0 $scriptversion"; exit $?;;
+
+ --) shift
+ break;;
+
+ -*) echo "$0: invalid option: $1" >&2
+ exit 1;;
+
+ *) break;;
+ esac
+ shift
+done
+
+if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
+ # When -d is used, all remaining arguments are directories to create.
+ # When -t is used, the destination is already specified.
+ # Otherwise, the last argument is the destination. Remove it from $@.
+ for arg
+ do
+ if test -n "$dst_arg"; then
+ # $@ is not empty: it contains at least $arg.
+ set fnord "$@" "$dst_arg"
+ shift # fnord
+ fi
+ shift # arg
+ dst_arg=$arg
+ done
+fi
+
+if test $# -eq 0; then
+ if test -z "$dir_arg"; then
+ echo "$0: no input file specified." >&2
+ exit 1
+ fi
+ # It's OK to call `install-sh -d' without argument.
+ # This can happen when creating conditional directories.
+ exit 0
+fi
+
+if test -z "$dir_arg"; then
+ trap '(exit $?); exit' 1 2 13 15
+
+ # Set umask so as not to create temps with too-generous modes.
+ # However, 'strip' requires both read and write access to temps.
+ case $mode in
+ # Optimize common cases.
+ *644) cp_umask=133;;
+ *755) cp_umask=22;;
+
+ *[0-7])
+ if test -z "$stripcmd"; then
+ u_plus_rw=
+ else
+ u_plus_rw='% 200'
+ fi
+ cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
+ *)
+ if test -z "$stripcmd"; then
+ u_plus_rw=
+ else
+ u_plus_rw=,u+rw
+ fi
+ cp_umask=$mode$u_plus_rw;;
+ esac
+fi
+
+for src
+do
+ # Protect names starting with `-'.
+ case $src in
+ -*) src=./$src;;
+ esac
+
+ if test -n "$dir_arg"; then
+ dst=$src
+ dstdir=$dst
+ test -d "$dstdir"
+ dstdir_status=$?
+ else
+
+ # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
+ # might cause directories to be created, which would be especially bad
+ # if $src (and thus $dsttmp) contains '*'.
+ if test ! -f "$src" && test ! -d "$src"; then
+ echo "$0: $src does not exist." >&2
+ exit 1
+ fi
+
+ if test -z "$dst_arg"; then
+ echo "$0: no destination specified." >&2
+ exit 1
+ fi
+
+ dst=$dst_arg
+ # Protect names starting with `-'.
+ case $dst in
+ -*) dst=./$dst;;
+ esac
+
+ # If destination is a directory, append the input filename; won't work
+ # if double slashes aren't ignored.
+ if test -d "$dst"; then
+ if test -n "$no_target_directory"; then
+ echo "$0: $dst_arg: Is a directory" >&2
+ exit 1
+ fi
+ dstdir=$dst
+ dst=$dstdir/`basename "$src"`
+ dstdir_status=0
+ else
+ # Prefer dirname, but fall back on a substitute if dirname fails.
+ dstdir=`
+ (dirname "$dst") 2>/dev/null ||
+ expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$dst" : 'X\(//\)[^/]' \| \
+ X"$dst" : 'X\(//\)$' \| \
+ X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
+ echo X"$dst" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)[^/].*/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'
+ `
+
+ test -d "$dstdir"
+ dstdir_status=$?
+ fi
+ fi
+
+ obsolete_mkdir_used=false
+
+ if test $dstdir_status != 0; then
+ case $posix_mkdir in
+ '')
+ # Create intermediate dirs using mode 755 as modified by the umask.
+ # This is like FreeBSD 'install' as of 1997-10-28.
+ umask=`umask`
+ case $stripcmd.$umask in
+ # Optimize common cases.
+ *[2367][2367]) mkdir_umask=$umask;;
+ .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
+
+ *[0-7])
+ mkdir_umask=`expr $umask + 22 \
+ - $umask % 100 % 40 + $umask % 20 \
+ - $umask % 10 % 4 + $umask % 2
+ `;;
+ *) mkdir_umask=$umask,go-w;;
+ esac
+
+ # With -d, create the new directory with the user-specified mode.
+ # Otherwise, rely on $mkdir_umask.
+ if test -n "$dir_arg"; then
+ mkdir_mode=-m$mode
+ else
+ mkdir_mode=
+ fi
+
+ posix_mkdir=false
+ case $umask in
+ *[123567][0-7][0-7])
+ # POSIX mkdir -p sets u+wx bits regardless of umask, which
+ # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
+ ;;
+ *)
+ tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
+ trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
+
+ if (umask $mkdir_umask &&
+ exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
+ then
+ if test -z "$dir_arg" || {
+ # Check for POSIX incompatibilities with -m.
+ # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
+ # other-writeable bit of parent directory when it shouldn't.
+ # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
+ ls_ld_tmpdir=`ls -ld "$tmpdir"`
+ case $ls_ld_tmpdir in
+ d????-?r-*) different_mode=700;;
+ d????-?--*) different_mode=755;;
+ *) false;;
+ esac &&
+ $mkdirprog -m$different_mode -p -- "$tmpdir" && {
+ ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
+ test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
+ }
+ }
+ then posix_mkdir=:
+ fi
+ rmdir "$tmpdir/d" "$tmpdir"
+ else
+ # Remove any dirs left behind by ancient mkdir implementations.
+ rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
+ fi
+ trap '' 0;;
+ esac;;
+ esac
+
+ if
+ $posix_mkdir && (
+ umask $mkdir_umask &&
+ $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
+ )
+ then :
+ else
+
+ # The umask is ridiculous, or mkdir does not conform to POSIX,
+ # or it failed possibly due to a race condition. Create the
+ # directory the slow way, step by step, checking for races as we go.
+
+ case $dstdir in
+ /*) prefix='/';;
+ -*) prefix='./';;
+ *) prefix='';;
+ esac
+
+ eval "$initialize_posix_glob"
+
+ oIFS=$IFS
+ IFS=/
+ $posix_glob set -f
+ set fnord $dstdir
+ shift
+ $posix_glob set +f
+ IFS=$oIFS
+
+ prefixes=
+
+ for d
+ do
+ test -z "$d" && continue
+
+ prefix=$prefix$d
+ if test -d "$prefix"; then
+ prefixes=
+ else
+ if $posix_mkdir; then
+ (umask=$mkdir_umask &&
+ $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
+ # Don't fail if two instances are running concurrently.
+ test -d "$prefix" || exit 1
+ else
+ case $prefix in
+ *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
+ *) qprefix=$prefix;;
+ esac
+ prefixes="$prefixes '$qprefix'"
+ fi
+ fi
+ prefix=$prefix/
+ done
+
+ if test -n "$prefixes"; then
+ # Don't fail if two instances are running concurrently.
+ (umask $mkdir_umask &&
+ eval "\$doit_exec \$mkdirprog $prefixes") ||
+ test -d "$dstdir" || exit 1
+ obsolete_mkdir_used=true
+ fi
+ fi
+ fi
+
+ if test -n "$dir_arg"; then
+ { test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
+ { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
+ { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
+ test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
+ else
+
+ # Make a couple of temp file names in the proper directory.
+ dsttmp=$dstdir/_inst.$$_
+ rmtmp=$dstdir/_rm.$$_
+
+ # Trap to clean up those temp files at exit.
+ trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
+
+ # Copy the file name to the temp name.
+ (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
+
+ # and set any options; do chmod last to preserve setuid bits.
+ #
+ # If any of these fail, we abort the whole thing. If we want to
+ # ignore errors from any of these, just make sure not to ignore
+ # errors from the above "$doit $cpprog $src $dsttmp" command.
+ #
+ { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
+ { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
+ { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
+ { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
+
+ # If -C, don't bother to copy if it wouldn't change the file.
+ if $copy_on_change &&
+ old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
+ new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
+
+ eval "$initialize_posix_glob" &&
+ $posix_glob set -f &&
+ set X $old && old=:$2:$4:$5:$6 &&
+ set X $new && new=:$2:$4:$5:$6 &&
+ $posix_glob set +f &&
+
+ test "$old" = "$new" &&
+ $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
+ then
+ rm -f "$dsttmp"
+ else
+ # Rename the file to the real destination.
+ $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
+
+ # The rename failed, perhaps because mv can't rename something else
+ # to itself, or perhaps because mv is so ancient that it does not
+ # support -f.
+ {
+ # Now remove or move aside any old file at destination location.
+ # We try this two ways since rm can't unlink itself on some
+ # systems and the destination file might be busy for other
+ # reasons. In this case, the final cleanup might fail but the new
+ # file should still install successfully.
+ {
+ test ! -f "$dst" ||
+ $doit $rmcmd -f "$dst" 2>/dev/null ||
+ { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
+ { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
+ } ||
+ { echo "$0: cannot unlink or rename $dst" >&2
+ (exit 1); exit 1
+ }
+ } &&
+
+ # Now rename the file to the real destination.
+ $doit $mvcmd "$dsttmp" "$dst"
+ }
+ fi || exit 1
+
+ trap '' 0
+ fi
+done
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
+# End:
diff --git a/build-aux/missing b/build-aux/missing
new file mode 100755
index 0000000..28055d2
--- /dev/null
+++ b/build-aux/missing
@@ -0,0 +1,376 @@
+#! /bin/sh
+# Common stub for a few missing GNU programs while installing.
+
+scriptversion=2009-04-28.21; # UTC
+
+# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
+# 2008, 2009 Free Software Foundation, Inc.
+# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+if test $# -eq 0; then
+ echo 1>&2 "Try \`$0 --help' for more information"
+ exit 1
+fi
+
+run=:
+sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
+sed_minuso='s/.* -o \([^ ]*\).*/\1/p'
+
+# In the cases where this matters, `missing' is being run in the
+# srcdir already.
+if test -f configure.ac; then
+ configure_ac=configure.ac
+else
+ configure_ac=configure.in
+fi
+
+msg="missing on your system"
+
+case $1 in
+--run)
+ # Try to run requested program, and just exit if it succeeds.
+ run=
+ shift
+ "$@" && exit 0
+ # Exit code 63 means version mismatch. This often happens
+ # when the user try to use an ancient version of a tool on
+ # a file that requires a minimum version. In this case we
+ # we should proceed has if the program had been absent, or
+ # if --run hadn't been passed.
+ if test $? = 63; then
+ run=:
+ msg="probably too old"
+ fi
+ ;;
+
+ -h|--h|--he|--hel|--help)
+ echo "\
+$0 [OPTION]... PROGRAM [ARGUMENT]...
+
+Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
+error status if there is no known handling for PROGRAM.
+
+Options:
+ -h, --help display this help and exit
+ -v, --version output version information and exit
+ --run try to run the given command, and emulate it if it fails
+
+Supported PROGRAM values:
+ aclocal touch file \`aclocal.m4'
+ autoconf touch file \`configure'
+ autoheader touch file \`config.h.in'
+ autom4te touch the output file, or create a stub one
+ automake touch all \`Makefile.in' files
+ bison create \`y.tab.[ch]', if possible, from existing .[ch]
+ flex create \`lex.yy.c', if possible, from existing .c
+ help2man touch the output file
+ lex create \`lex.yy.c', if possible, from existing .c
+ makeinfo touch the output file
+ tar try tar, gnutar, gtar, then tar without non-portable flags
+ yacc create \`y.tab.[ch]', if possible, from existing .[ch]
+
+Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
+\`g' are ignored when checking the name.
+
+Send bug reports to <bug-automake@gnu.org>."
+ exit $?
+ ;;
+
+ -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
+ echo "missing $scriptversion (GNU Automake)"
+ exit $?
+ ;;
+
+ -*)
+ echo 1>&2 "$0: Unknown \`$1' option"
+ echo 1>&2 "Try \`$0 --help' for more information"
+ exit 1
+ ;;
+
+esac
+
+# normalize program name to check for.
+program=`echo "$1" | sed '
+ s/^gnu-//; t
+ s/^gnu//; t
+ s/^g//; t'`
+
+# Now exit if we have it, but it failed. Also exit now if we
+# don't have it and --version was passed (most likely to detect
+# the program). This is about non-GNU programs, so use $1 not
+# $program.
+case $1 in
+ lex*|yacc*)
+ # Not GNU programs, they don't have --version.
+ ;;
+
+ tar*)
+ if test -n "$run"; then
+ echo 1>&2 "ERROR: \`tar' requires --run"
+ exit 1
+ elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
+ exit 1
+ fi
+ ;;
+
+ *)
+ if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
+ # We have it, but it failed.
+ exit 1
+ elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
+ # Could not run --version or --help. This is probably someone
+ # running `$TOOL --version' or `$TOOL --help' to check whether
+ # $TOOL exists and not knowing $TOOL uses missing.
+ exit 1
+ fi
+ ;;
+esac
+
+# If it does not exist, or fails to run (possibly an outdated version),
+# try to emulate it.
+case $program in
+ aclocal*)
+ echo 1>&2 "\
+WARNING: \`$1' is $msg. You should only need it if
+ you modified \`acinclude.m4' or \`${configure_ac}'. You might want
+ to install the \`Automake' and \`Perl' packages. Grab them from
+ any GNU archive site."
+ touch aclocal.m4
+ ;;
+
+ autoconf*)
+ echo 1>&2 "\
+WARNING: \`$1' is $msg. You should only need it if
+ you modified \`${configure_ac}'. You might want to install the
+ \`Autoconf' and \`GNU m4' packages. Grab them from any GNU
+ archive site."
+ touch configure
+ ;;
+
+ autoheader*)
+ echo 1>&2 "\
+WARNING: \`$1' is $msg. You should only need it if
+ you modified \`acconfig.h' or \`${configure_ac}'. You might want
+ to install the \`Autoconf' and \`GNU m4' packages. Grab them
+ from any GNU archive site."
+ files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
+ test -z "$files" && files="config.h"
+ touch_files=
+ for f in $files; do
+ case $f in
+ *:*) touch_files="$touch_files "`echo "$f" |
+ sed -e 's/^[^:]*://' -e 's/:.*//'`;;
+ *) touch_files="$touch_files $f.in";;
+ esac
+ done
+ touch $touch_files
+ ;;
+
+ automake*)
+ echo 1>&2 "\
+WARNING: \`$1' is $msg. You should only need it if
+ you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
+ You might want to install the \`Automake' and \`Perl' packages.
+ Grab them from any GNU archive site."
+ find . -type f -name Makefile.am -print |
+ sed 's/\.am$/.in/' |
+ while read f; do touch "$f"; done
+ ;;
+
+ autom4te*)
+ echo 1>&2 "\
+WARNING: \`$1' is needed, but is $msg.
+ You might have modified some files without having the
+ proper tools for further handling them.
+ You can get \`$1' as part of \`Autoconf' from any GNU
+ archive site."
+
+ file=`echo "$*" | sed -n "$sed_output"`
+ test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
+ if test -f "$file"; then
+ touch $file
+ else
+ test -z "$file" || exec >$file
+ echo "#! /bin/sh"
+ echo "# Created by GNU Automake missing as a replacement of"
+ echo "# $ $@"
+ echo "exit 0"
+ chmod +x $file
+ exit 1
+ fi
+ ;;
+
+ bison*|yacc*)
+ echo 1>&2 "\
+WARNING: \`$1' $msg. You should only need it if
+ you modified a \`.y' file. You may need the \`Bison' package
+ in order for those modifications to take effect. You can get
+ \`Bison' from any GNU archive site."
+ rm -f y.tab.c y.tab.h
+ if test $# -ne 1; then
+ eval LASTARG="\${$#}"
+ case $LASTARG in
+ *.y)
+ SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
+ if test -f "$SRCFILE"; then
+ cp "$SRCFILE" y.tab.c
+ fi
+ SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
+ if test -f "$SRCFILE"; then
+ cp "$SRCFILE" y.tab.h
+ fi
+ ;;
+ esac
+ fi
+ if test ! -f y.tab.h; then
+ echo >y.tab.h
+ fi
+ if test ! -f y.tab.c; then
+ echo 'main() { return 0; }' >y.tab.c
+ fi
+ ;;
+
+ lex*|flex*)
+ echo 1>&2 "\
+WARNING: \`$1' is $msg. You should only need it if
+ you modified a \`.l' file. You may need the \`Flex' package
+ in order for those modifications to take effect. You can get
+ \`Flex' from any GNU archive site."
+ rm -f lex.yy.c
+ if test $# -ne 1; then
+ eval LASTARG="\${$#}"
+ case $LASTARG in
+ *.l)
+ SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
+ if test -f "$SRCFILE"; then
+ cp "$SRCFILE" lex.yy.c
+ fi
+ ;;
+ esac
+ fi
+ if test ! -f lex.yy.c; then
+ echo 'main() { return 0; }' >lex.yy.c
+ fi
+ ;;
+
+ help2man*)
+ echo 1>&2 "\
+WARNING: \`$1' is $msg. You should only need it if
+ you modified a dependency of a manual page. You may need the
+ \`Help2man' package in order for those modifications to take
+ effect. You can get \`Help2man' from any GNU archive site."
+
+ file=`echo "$*" | sed -n "$sed_output"`
+ test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
+ if test -f "$file"; then
+ touch $file
+ else
+ test -z "$file" || exec >$file
+ echo ".ab help2man is required to generate this page"
+ exit $?
+ fi
+ ;;
+
+ makeinfo*)
+ echo 1>&2 "\
+WARNING: \`$1' is $msg. You should only need it if
+ you modified a \`.texi' or \`.texinfo' file, or any other file
+ indirectly affecting the aspect of the manual. The spurious
+ call might also be the consequence of using a buggy \`make' (AIX,
+ DU, IRIX). You might want to install the \`Texinfo' package or
+ the \`GNU make' package. Grab either from any GNU archive site."
+ # The file to touch is that specified with -o ...
+ file=`echo "$*" | sed -n "$sed_output"`
+ test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
+ if test -z "$file"; then
+ # ... or it is the one specified with @setfilename ...
+ infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
+ file=`sed -n '
+ /^@setfilename/{
+ s/.* \([^ ]*\) *$/\1/
+ p
+ q
+ }' $infile`
+ # ... or it is derived from the source name (dir/f.texi becomes f.info)
+ test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
+ fi
+ # If the file does not exist, the user really needs makeinfo;
+ # let's fail without touching anything.
+ test -f $file || exit 1
+ touch $file
+ ;;
+
+ tar*)
+ shift
+
+ # We have already tried tar in the generic part.
+ # Look for gnutar/gtar before invocation to avoid ugly error
+ # messages.
+ if (gnutar --version > /dev/null 2>&1); then
+ gnutar "$@" && exit 0
+ fi
+ if (gtar --version > /dev/null 2>&1); then
+ gtar "$@" && exit 0
+ fi
+ firstarg="$1"
+ if shift; then
+ case $firstarg in
+ *o*)
+ firstarg=`echo "$firstarg" | sed s/o//`
+ tar "$firstarg" "$@" && exit 0
+ ;;
+ esac
+ case $firstarg in
+ *h*)
+ firstarg=`echo "$firstarg" | sed s/h//`
+ tar "$firstarg" "$@" && exit 0
+ ;;
+ esac
+ fi
+
+ echo 1>&2 "\
+WARNING: I can't seem to be able to run \`tar' with the given arguments.
+ You may want to install GNU tar or Free paxutils, or check the
+ command line arguments."
+ exit 1
+ ;;
+
+ *)
+ echo 1>&2 "\
+WARNING: \`$1' is needed, and is $msg.
+ You might have modified some files without having the
+ proper tools for further handling them. Check the \`README' file,
+ it often tells you about the needed prerequisites for installing
+ this package. You may also peek at any GNU archive site, in case
+ some other package would contain this missing \`$1' program."
+ exit 1
+ ;;
+esac
+
+exit 0
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
+# End:
diff --git a/common/include/media-server-common.h b/common/include/media-server-common.h
new file mode 100755
index 0000000..68daba6
--- /dev/null
+++ b/common/include/media-server-common.h
@@ -0,0 +1,153 @@
+/*
+ * Media Server
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Yong Yeon Kim <yy9875.kim@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.
+ *
+ */
+
+/**
+ * This file defines api utilities of contents manager engines.
+ *
+ * @file media-server-common.h
+ * @author Yong Yeon Kim(yy9875.kim@samsung.com)
+ * @version 1.0
+ * @brief
+ */
+
+#ifndef __FEXPLORER_ENGINE_DB_PUBLIC_H__
+#define __FEXPLORER_ENGINE_DB_PUBLIC_H__
+
+#include <sqlite3.h>
+#include "media-server-global.h"
+
+#define MS_SQL_MAX_LEN 4096
+
+int ms_update_valid_type(char *path);
+
+int ms_set_db_status(ms_db_status_type_t status);
+
+int ms_db_init(bool need_db_create);
+
+int ms_media_db_open(void);
+
+int ms_media_db_close(void);
+
+int ms_update_mmc_info(void);
+
+void ms_mmc_removed_handler(void);
+
+void ms_mmc_vconf_cb(void *data);
+
+bool ms_is_mmc_supported(void);
+
+ms_dir_scan_type_t ms_get_mmc_state(void);
+
+void ms_usb_vconf_cb(void *data);
+
+void ms_register_start(void);
+
+void ms_register_end(void);
+
+int ms_register_file(const char *path, GAsyncQueue* queue);
+
+int ms_register_scanfile(const char *path);
+
+int ms_start(bool need_db_create);
+
+void ms_end(void);
+
+int ms_get_full_path_from_node(ms_dir_scan_info * const node, char *ret_path);
+
+ms_store_type_t ms_get_store_type_by_full(const char *path);
+
+int ms_strappend(char *res, const int size, const char *pattern,
+ const char *str1, const char *str2);
+
+int ms_strcopy(char *res, const int size, const char *pattern,
+ const char *str1);
+
+#ifdef _WITH_SETTING_AND_NOTI_
+bool ms_config_get_int(const char *key, int *value);
+
+bool ms_config_set_int(const char *key, int value);
+
+bool ms_config_get_str(const char *key, char *value);
+
+bool ms_config_set_str(const char *key, const char *value);
+#endif
+
+void ms_check_db_updating(void);
+
+int ms_get_category_from_mime(const char *path, int *category);
+
+bool fex_make_default_path(void);
+
+bool fex_make_default_path_mmc(void);
+
+/****************************************************************************************************
+LIBMEDIA_INFO
+*****************************************************************************************************/
+#ifdef _WITH_MP_PB_
+
+void ms_update_valid_type_start(void);
+
+void ms_update_valid_type_end(void);
+
+int ms_change_valid_type(ms_store_type_t table_id, bool validation);
+#ifdef THUMB_THREAD
+int ms_media_db_insert_with_thumb(const char *path, int category);
+#endif
+int ms_media_db_insert(const char *path, int category, bool bulk);
+
+int ms_check_file_exist_in_db(const char *file_full_path);
+
+int ms_media_db_delete(const char *full_file_path);
+
+void ms_media_db_move_start(void);
+
+void ms_media_db_move_end(void);
+
+int ms_media_db_move(ms_store_type_t src_store_type,
+ ms_store_type_t dest_store_type,
+ const char *src_file_full_path,
+ const char *dest_file_full_path);
+
+bool ms_delete_all_record(ms_store_type_t store_type);
+
+#ifdef FMS_PERF
+void ms_check_start_time(struct timeval *start_time);
+
+void ms_check_end_time(struct timeval *end_time);
+
+void ms_check_time_diff(struct timeval *start_time, struct timeval *end_time);
+#endif /*FMS_PERF */
+#endif/*_WITH_MP_PB_*/
+
+#ifdef PROGRESS
+struct quickpanel;
+
+void ms_create_quickpanel(struct quickpanel *ms_quickpanel);
+
+void ms_update_progress(struct quickpanel *ms_quickpanel, double progress);
+
+void ms_delete_quickpanel(struct quickpanel *ms_quickpanel);
+#endif /*PROGRSS*/
+/**
+ * @}
+ */
+#endif /*__FEXPLORER_ENGINE_DB_PUBLIC_H__*/
+
diff --git a/common/include/media-server-error.h b/common/include/media-server-error.h
new file mode 100755
index 0000000..131a273
--- /dev/null
+++ b/common/include/media-server-error.h
@@ -0,0 +1,91 @@
+/*
+ * Media Server
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Yong Yeon Kim <yy9875.kim@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.
+ *
+ */
+
+/**
+ * This file defines api utilities of contents manager engines.
+ *
+ * @file media-server-error.h
+ * @author Yong Yeon Kim(yy9875.kim@samsung.com)
+ * @version 1.0
+ * @brief
+ */
+
+#ifndef _FEXPLORER_ENGINE_ERROR_H_
+#define _FEXPLORER_ENGINE_ERROR_H_
+
+#define ERROR_MASKL16 0xFFFF
+#define ERROR(X) (X & ERROR_MASKL16)
+
+#define MID_CONTENTS_MGR_ERROR 0 /*MID_CONTENTS_MGR_SERVICE */
+
+#define MS_ERR_NONE 0
+
+/*internal operation error*/
+#define MS_ERR_ARG_INVALID (MID_CONTENTS_MGR_ERROR - ERROR(0x01)) /**< invalid argument */
+#define MS_ERR_ALLOCATE_MEMORY_FAIL (MID_CONTENTS_MGR_ERROR - ERROR(0x02)) /**< exception of memory allocation */
+#define MS_ERR_OUT_OF_RANGE (MID_CONTENTS_MGR_ERROR - ERROR(0x03))
+#define MS_ERR_INVALID_DIR_PATH (MID_CONTENTS_MGR_ERROR - ERROR(0x04)) /**< exception of invalid dir path */
+#define MS_ERR_INVALID_FILE_PATH (MID_CONTENTS_MGR_ERROR - ERROR(0x05)) /**< exception of invalid file path */
+#define MS_ERR_NOW_REGISTER_FILE (MID_CONTENTS_MGR_ERROR - ERROR(0x06)) /**< exception of invalid file path */
+
+/*directory operation error*/
+#define MS_ERR_DIR_OPEN_FAIL (MID_CONTENTS_MGR_ERROR - ERROR(0x10)) /**< exception of dir open*/
+#define MS_ERR_DIR_NOT_FOUND (MID_CONTENTS_MGR_ERROR - ERROR(0x11)) /**< exception of dir doesn't exist*/
+#define MS_ERR_DIR_READ_FAIL (MID_CONTENTS_MGR_ERROR - ERROR(0x13)) /**< exception of dir read*/
+
+/*file operation error*/
+#define MS_ERR_FILE_NOT_FOUND (MID_CONTENTS_MGR_ERROR - ERROR(0x20)) /**< exception of file doesn't exist*/
+#define MS_ERR_FILE_OPEN_FAIL (MID_CONTENTS_MGR_ERROR - ERROR(0x21)) /**< exception of file doesn't exist*/
+
+/*db operation error*/
+#define MS_ERR_DB_TRUNCATE_TABLE_FAIL (MID_CONTENTS_MGR_ERROR - ERROR(0x30)) /**< truncating table fails */
+#define MS_ERR_DB_INSERT_RECORD_FAIL (MID_CONTENTS_MGR_ERROR - ERROR(0x31)) /**< inserting record fails */
+#define MS_ERR_DB_DELETE_RECORD_FAIL (MID_CONTENTS_MGR_ERROR - ERROR(0x32)) /**< deleting record fails */
+#define MS_ERR_DB_UPDATE_RECORD_FAIL (MID_CONTENTS_MGR_ERROR - ERROR(0x33)) /**< updating record fails */
+#define MS_ERR_DB_CONNECT_FAIL (MID_CONTENTS_MGR_ERROR - ERROR(0x34)) /**< connecting database fails */
+#define MS_ERR_DB_DISCONNECT_FAIL (MID_CONTENTS_MGR_ERROR - ERROR(0x35)) /**< connecting database fails */
+#define MS_ERR_DB_OPERATION_FAIL (MID_CONTENTS_MGR_ERROR - ERROR(0x36)) /**< connecting database fails */
+
+/*drm operation error*/
+#define MS_ERR_DRM_GET_TYPE (MID_CONTENTS_MGR_ERROR - ERROR(0x40))
+#define MS_ERR_DRM_MOVE_FAIL (MID_CONTENTS_MGR_ERROR - ERROR(0x41)) /**< can't copy/move drm file because of permission */
+#define MS_ERR_DRM_REGISTER_FAIL (MID_CONTENTS_MGR_ERROR - ERROR(0x42))
+#define MS_ERR_DRM_EXTRACT_FAIL (MID_CONTENTS_MGR_ERROR - ERROR(0x43))
+
+/*IPC operation error*/
+#define MS_ERR_SOCKET_CONN (MID_CONTENTS_MGR_ERROR - ERROR(0x50)) /**< Socket connect error */
+#define MS_ERR_SOCKET_BIND (MID_CONTENTS_MGR_ERROR - ERROR(0x51)) /**< Socket connect error */
+#define MS_ERR_SOCKET_MSG (MID_CONTENTS_MGR_ERROR - ERROR(0x52)) /**< Socket message error */
+#define MS_ERR_SOCKET_SEND (MID_CONTENTS_MGR_ERROR - ERROR(0x53)) /**< Socket send error */
+#define MS_ERR_SOCKET_RECEIVE (MID_CONTENTS_MGR_ERROR - ERROR(0x54)) /**< Socket receive error */
+
+/*ETC*/
+#define MS_ERR_LOW_MEMORY (MID_CONTENTS_MGR_ERROR - ERROR(0x60)) /**< low memory*/
+#define MS_ERR_UNKNOWN_ERROR (MID_CONTENTS_MGR_ERROR - ERROR(0x61)) /**< unknow error*/
+#define MS_ERR_VCONF_SET_FAIL (MID_CONTENTS_MGR_ERROR - ERROR(0x62)) /**< vconf set fail*/
+#define MS_ERR_VCONF_GET_FAIL (MID_CONTENTS_MGR_ERROR - ERROR(0x63)) /**< vconf get fail*/
+#define MS_ERR_NOT_MEDIA_FILE (MID_CONTENTS_MGR_ERROR - ERROR(0x64)) /**< not media file*/
+
+#define MS_ERR_MAX (MID_CONTENTS_MGR_ERROR - ERROR(0xff)) /**< Max count*/
+#endif /* _FEXPLORER_ENGINE_ERROR_H_ */
+/**
+ * @}
+ */
diff --git a/common/include/media-server-global.h b/common/include/media-server-global.h
new file mode 100755
index 0000000..a3c588e
--- /dev/null
+++ b/common/include/media-server-global.h
@@ -0,0 +1,123 @@
+/*
+ * Media Server
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Yong Yeon Kim <yy9875.kim@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.
+ *
+ */
+
+/**
+ * This file defines api utilities of contents manager engines.
+ *
+ * @file media-server-global.h
+ * @author Yong Yeon Kim(yy9875.kim@samsung.com)
+ * @version 1.0
+ * @brief
+ */
+
+#ifndef _FEXPLORER_ENGINEGLOBAL_H_
+#define _FEXPLORER_ENGINEGLOBAL_H_
+#include <malloc.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+#include <time.h>
+#include <stdbool.h>
+#include <unistd.h>
+#include <glib.h>
+#include <fcntl.h>
+#include <dirent.h>
+#include <sys/file.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <sys/stat.h>
+#include <sys/vfs.h>
+#include <sys/syscall.h>
+#include <dlfcn.h>
+#include <errno.h>
+
+#include <dlog.h>
+
+#include "media-server-error.h"
+#include "media-server-types.h"
+
+#define _WITH_MP_PB_
+#define _WITH_DRM_SERVICE_ /*drm-servic3 */
+#define _WITH_SETTING_AND_NOTI_ /*replace gconf-dbus */
+#define FMS_PERF
+
+/* To enable hibernation callback */
+/*#define _USE_HIB*/
+
+/* To enable progress bar in quickpanel */
+/*#define PROGRESS*/
+
+/* To enable thumbnail thread*/
+/*#define THUMB_THREAD*/
+
+#define FEXPLORER_DEBUG
+#ifndef DEPRECATED /*temp definition for deprecated */
+#define DEPRECATED __attribute__((deprecated))
+#endif
+
+#ifdef FEXPLORER_DEBUG
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "MEDIA-SERVER"
+#define MS_DBG_START() LOGD("[%d, %s-%d] ========[ START ]========\n" , syscall(__NR_gettid), __func__ , __LINE__);
+#define MS_DBG_END() LOGD("[%d, %s-%d] ========[ END ]========\n" ,syscall(__NR_gettid), __func__ , __LINE__);
+#define MS_DBG_FUNC_LINE() LOGD("[%s-%d] debug\n" , __func__ , __LINE__);
+#define MS_DBG(fmt, args...) LOGD("[%d, %s-%d] " fmt "\n" , syscall(__NR_gettid), __func__ , __LINE__ , ##args);
+#endif /*FEXPLORER_DEBUG */
+
+#define MS_DRM_CONTENT_TYPE_LENGTH 100
+#define MS_REGISTER_COUNT 100 /*For bundle commit*/
+#define MS_VALID_COUNT 100 /*For bundle commit*/
+#define MS_MOVE_COUNT 100 /*For bundle commit*/
+
+/* in case of 32 bytes machine*/
+#define DUMMY_FIELD_LEN_32(n) ((((n-1) / 8 + 1) * 2) / sizeof(long) + 6)
+
+#define MALLOC(a) malloc(a)
+#define FREE(a) free(a)
+
+#define MS_PHONE_ROOT_PATH "opt/media"
+#define MS_MMC_ROOT_PATH "opt/storage/sdcard"
+#define MS_DB_UPDATE_NOTI_PATH "/opt/data/file-manager-service"
+
+#define end_thread 100
+
+/*This macro is used to check the lastest usb mode*/
+#define MS_USB_MODE_KEY "db/Apps/mediaserver/usbmode"
+enum {
+ MS_VCONFKEY_NORMAL_MODE = 0x00,
+ MS_VCONFKEY_MASS_STORAGE_MODE = 0x01
+};
+#define MS_MMC_INFO_KEY "db/Apps/mediaserver/mmc_info"
+
+#define MS_THUMB_STATUS "db/Apps/mediaserver/thumb_status"
+enum {
+ MS_VCONFKEY_THUMB_NONE = 0x00,
+ MS_VCONFKEY_THUMB_PAUSE = 0x01,
+ MS_VCONFKEY_THUMB_RESUME = 0x02
+};
+/**
+ * @}
+ */
+
+#endif /*_FEXPLORER_ENGINEGLOBAL_H_*/
diff --git a/common/include/media-server-hibernation.h b/common/include/media-server-hibernation.h
new file mode 100755
index 0000000..53976ce
--- /dev/null
+++ b/common/include/media-server-hibernation.h
@@ -0,0 +1,40 @@
+/*
+ * Media Server
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Yong Yeon Kim <yy9875.kim@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.
+ *
+ */
+
+/**
+ * This file defines api utilities of contents manager engines.
+ *
+ * @file media-server-hibernation.h
+ * @author Yong Yeon Kim(yy9875.kim@samsung.com)
+ * @version 1.0
+ * @brief
+ */
+
+#ifdef _USE_HIB
+#ifndef _FEXPLORER_ENGINE_HIB_H_
+#define _FEXPLORER_ENGINE_HIB_H_
+
+int _hibernation_initialize(void);
+
+void _hibernation_fianalize(void);
+
+#endif /* _FEXPLORER_ENGINE_HIB_H_ */
+#endif
diff --git a/common/include/media-server-inotify-internal.h b/common/include/media-server-inotify-internal.h
new file mode 100755
index 0000000..88548be
--- /dev/null
+++ b/common/include/media-server-inotify-internal.h
@@ -0,0 +1,56 @@
+/*
+ * Media Server
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Yong Yeon Kim <yy9875.kim@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.
+ *
+ */
+
+/**
+ * This file defines api utilities of contents manager engines.
+ *
+ * @file media-server-inotify-internal.h
+ * @author Yong Yeon Kim(yy9875.kim@samsung.com)
+ * @version 1.0
+ * @brief
+ */
+#include <sys/inotify.h>
+#include <sqlite3.h>
+#include <drm-service.h>
+
+#define INOTI_EVENT_SIZE (sizeof(struct inotify_event))
+#define INOTI_BUF_LEN (1024*(INOTI_EVENT_SIZE+16))
+#define INOTI_FOLDER_COUNT_MAX 1024
+
+typedef struct ms_create_file_info {
+ char *name;
+ int wd;
+ struct ms_create_file_info *previous;
+ struct ms_create_file_info *next;
+} ms_create_file_info;
+
+int _ms_inoti_add_create_file_list(int wd, char *name);
+
+int _ms_inoti_delete_create_file_list(ms_create_file_info *node);
+
+ms_create_file_info *_ms_inoti_find_create_file_list(int wd, char *name);
+
+int _fex_is_default_path(const char *path);
+
+bool _ms_inoti_full_path(int wd, char *name, char *path, int sizeofpath);
+
+bool _ms_inoti_get_full_path(int wd, char *name, char *path, int sizeofpath);
+
diff --git a/common/include/media-server-inotify.h b/common/include/media-server-inotify.h
new file mode 100755
index 0000000..184a599
--- /dev/null
+++ b/common/include/media-server-inotify.h
@@ -0,0 +1,63 @@
+/*
+ * Media Server
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Yong Yeon Kim <yy9875.kim@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.
+ *
+ */
+
+/**
+ * This file defines api utilities of contents manager engines.
+ *
+ * @file media-server-inotify.h
+ * @author Yong Yeon Kim(yy9875.kim@samsung.com)
+ * @version 1.0
+ * @brief
+ */
+
+#ifndef _FEXPLORER_ENGINE_INOTI_H_
+#define _FEXPLORER_ENGINE_INOTI_H_
+
+#include <glib.h>
+
+typedef struct ms_ignore_file_info {
+ char *path;
+ struct ms_ignore_file_info *previous;
+ struct ms_ignore_file_info *next;
+} ms_ignore_file_info;
+
+int ms_inoti_init(void);
+
+gboolean ms_inoti_thread(gpointer data);
+
+void ms_inoti_add_watch(char *path);
+
+int ms_inoti_add_watch_with_node(ms_dir_scan_info * const current_node);
+
+void ms_inoti_remove_watch_recursive(char *path);
+
+void ms_inoti_remove_watch(char *path);
+
+void ms_inoti_modify_watch(char *path_from, char *path_to);
+
+int ms_inoti_add_ignore_file(const char *path);
+
+int ms_inoti_delete_ignore_file(ms_ignore_file_info * delete_node);
+
+ms_ignore_file_info *ms_inoti_find_ignore_file(const char *path);
+
+void ms_inoti_delete_mmc_ignore_file(void);
+#endif /* _FEXPLORER_ENGINE_INOTI_H_ */
diff --git a/common/include/media-server-scan-internal.h b/common/include/media-server-scan-internal.h
new file mode 100755
index 0000000..7837792
--- /dev/null
+++ b/common/include/media-server-scan-internal.h
@@ -0,0 +1,38 @@
+/*
+ * Media Server
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Yong Yeon Kim <yy9875.kim@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.
+ *
+ */
+
+/**
+ * This file defines api utilities of contents manager engines.
+ *
+ * @file media-server-scan-internal.h
+ * @author Yong Yeon Kim(yy9875.kim@samsung.com)
+ * @version 1.0
+ * @brief
+ */
+#include "media-server-global.h"
+#include "media-server-types.h"
+
+#ifdef PROGRESS
+struct quickpanel;
+void _ms_dir_scan(ms_scan_data_t * scan_data, struct quickpanel *ms_quickpanel);
+#else
+void _ms_dir_scan(ms_scan_data_t * scan_data);
+#endif
diff --git a/common/include/media-server-scan.h b/common/include/media-server-scan.h
new file mode 100755
index 0000000..1cea90b
--- /dev/null
+++ b/common/include/media-server-scan.h
@@ -0,0 +1,31 @@
+/*
+ * Media Server
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Yong Yeon Kim <yy9875.kim@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.
+ *
+ */
+
+/**
+ * This file defines api utilities of contents manager engines.
+ *
+ * @file media-server-scan.h
+ * @author Yong Yeon Kim(yy9875.kim@samsung.com)
+ * @version 1.0
+ * @brief
+ */
+
+gboolean ms_scan_thread(void *data);
diff --git a/common/include/media-server-socket.h b/common/include/media-server-socket.h
new file mode 100755
index 0000000..934c0bd
--- /dev/null
+++ b/common/include/media-server-socket.h
@@ -0,0 +1,34 @@
+/*
+ * Media Server
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Yong Yeon Kim <yy9875.kim@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.
+ *
+ */
+
+/**
+ * This file defines api utilities of contents manager engines.
+ *
+ * @file media-server-thumb.c
+ * @author Yong Yeon Kim(yy9875.kim@samsung.com)
+ * @version 1.0
+ * @brief
+ */
+ #include "media-server-global.h"
+#include "media-server-types.h"
+
+gboolean ms_socket_thread(void *data);
+
diff --git a/common/include/media-server-thumb.h b/common/include/media-server-thumb.h
new file mode 100755
index 0000000..064c0f9
--- /dev/null
+++ b/common/include/media-server-thumb.h
@@ -0,0 +1,35 @@
+/*
+ * Media Server
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Yong Yeon Kim <yy9875.kim@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.
+ *
+ */
+
+/**
+ * This file defines api utilities of contents manager engines.
+ *
+ * @file media-server-thumb.h
+ * @author Yong Yeon Kim(yy9875.kim@samsung.com)
+ * @version 1.0
+ * @brief
+ */
+#include "media-server-global.h"
+#include "media-server-types.h"
+
+#ifdef THUMB_THREAD
+gboolean ms_thumb_thread(void *data);
+#endif
diff --git a/common/include/media-server-types.h b/common/include/media-server-types.h
new file mode 100755
index 0000000..da63a7c
--- /dev/null
+++ b/common/include/media-server-types.h
@@ -0,0 +1,99 @@
+/*
+ * Media Server
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Yong Yeon Kim <yy9875.kim@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.
+ *
+ */
+
+/**
+ * This file defines api utilities of contents manager engines.
+ *
+ * @file media-server-types.h
+ * @author Yong Yeon Kim(yy9875.kim@samsung.com)
+ * @version 1.0
+ * @brief
+ */
+
+#include <stdbool.h>
+#include <glib.h>
+
+#ifndef _FEXPLORER_TYPES_H_
+#define _FEXPLORER_TYPES_H_
+
+#if !defined(__TYPEDEF_INT64__)
+#define __TYPEDEF_INT64__
+typedef long long int64;
+#endif
+
+/*System default folder definition*/
+#define FAT_FILENAME_LEN_MAX 255 /* not inc null */
+#define FAT_FILEPATH_LEN_MAX 4096 /* inc null */
+#define FAT_DIRECTORY_LEN_MAX 244
+
+/* The following MACROs(TAF_XXX) are defined in "fs-limit.h"*/
+#define MS_FILE_NAME_LEN_MAX FAT_FILENAME_LEN_MAX /**< File name max length on file system */
+#define MS_FILE_PATH_LEN_MAX FAT_FILEPATH_LEN_MAX /**< File path max length (include file name) on file system */
+
+#define MS_CATEGORY_UNKNOWN 0x00000000 /**< Default */
+#define MS_CATEGORY_ETC 0x00000001 /**< ETC category */
+#define MS_CATEGORY_IMAGE 0x00000002 /**< Image category */
+#define MS_CATEGORY_VIDEO 0x00000004 /**< Video category */
+#define MS_CATEGORY_MUSIC 0x00000008 /**< Music category */
+#define MS_CATEGORY_SOUND 0x00000010 /**< Sound category */
+#define MS_CATEGORY_DRM 0x00000020 /**< DRM category */
+
+typedef enum {
+ MS_PHONE, /**< Stored only in phone */
+ MS_MMC, /**< Stored only in MMC */
+} ms_store_type_t;
+
+typedef enum {
+ MS_SCAN_NONE,
+ MS_SCAN_VALID,
+ MS_SCAN_PART,
+ MS_SCAN_ALL,
+} ms_dir_scan_type_t;
+
+typedef enum {
+ MS_DB_UPDATING = 0,
+ MS_DB_UPDATED = 1
+} ms_db_status_type_t;
+
+typedef struct ms_dir_scan_info {
+ char *name;
+ struct ms_dir_scan_info *parent;
+ struct ms_dir_scan_info *Rbrother;
+ struct ms_dir_scan_info *next;
+} ms_dir_scan_info;
+
+typedef struct {
+ ms_store_type_t db_type;
+ ms_dir_scan_type_t scan_type;
+} ms_scan_data_t;
+
+typedef struct ms_dir_data {
+ char *name;
+ int wd;
+ bool db_updated;
+ struct ms_dir_data *next;
+} ms_dir_data;
+
+/**
+ * @}
+ */
+
+#endif /*_FEXPLORER_TYPES_H_*/
diff --git a/common/media-server-common.c b/common/media-server-common.c
new file mode 100755
index 0000000..3f007cd
--- /dev/null
+++ b/common/media-server-common.c
@@ -0,0 +1,1780 @@
+/*
+ * Media Server
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Yong Yeon Kim <yy9875.kim@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.
+ *
+ */
+
+/**
+ * This file defines api utilities of contents manager engines.
+ *
+ * @file media-server-common.c
+ * @author Yong Yeon Kim(yy9875.kim@samsung.com)
+ * @version 1.0
+ * @brief This file implements main database operation.
+ */
+#include <media-svc.h>
+#include <media-thumbnail.h>
+#include <audio-svc-error.h>
+#include <audio-svc.h>
+#include <db-util.h>
+#include <pmapi.h>
+#include <vconf.h>
+#include <drm-service.h>
+#ifdef PROGRESS
+#include <quickpanel.h>
+#endif
+#include <aul/aul.h>
+#include <mmf/mm_file.h>
+
+#include "media-server-global.h"
+#include "media-server-common.h"
+#include "media-server-inotify.h"
+
+#ifdef FMS_PERF
+#include <sys/time.h>
+#define MILLION 1000000L
+#endif
+
+#define CONTENT_TYPE_NUM 4
+#define MUSIC_MIME_NUM 28
+#define SOUND_MIME_NUM 1
+#define MIME_TYPE_LENGTH 255
+#define MIME_LENGTH 50
+#define _3GP_FILE ".3gp"
+#define _MP4_FILE ".mp4"
+#define MMC_INFO_SIZE 256
+
+int mmc_state = 0;
+int ums_mode = 0;
+int current_usb_mode = 0;
+
+extern GAsyncQueue *scan_queue;
+
+struct timeval g_mmc_start_time;
+struct timeval g_mmc_end_time;
+
+typedef struct {
+ char content_type[15];
+ int category_by_mime;
+} fex_content_table_t;
+
+static const fex_content_table_t content_category[CONTENT_TYPE_NUM] = {
+ {"audio", MS_CATEGORY_SOUND},
+ {"image", MS_CATEGORY_IMAGE},
+ {"video", MS_CATEGORY_VIDEO},
+ {"application", MS_CATEGORY_ETC},
+};
+
+static const char music_mime_table[MUSIC_MIME_NUM][MIME_LENGTH] = {
+ /*known mime types of normal files*/
+ "mpeg",
+ "ogg",
+ "x-ms-wma",
+ "x-flac",
+ "mp4",
+ /* known mime types of drm files*/
+ "mp3",
+ "x-mp3", /*alias of audio/mpeg*/
+ "x-mpeg", /*alias of audio/mpeg*/
+ "3gpp",
+ "x-ogg", /*alias of audio/ogg*/
+ "vnd.ms-playready.media.pya:*.pya", /*playready*/
+ "wma",
+ "aac",
+ "x-m4a", /*alias of audio/mp4*/
+ /* below mimes are rare*/
+ "x-vorbis+ogg",
+ "x-flac+ogg",
+ "x-matroska",
+ "ac3",
+ "mp2",
+ "x-ape",
+ "x-ms-asx",
+ "vnd.rn-realaudio",
+
+ "x-vorbis", /*alias of audio/x-vorbis+ogg*/
+ "vorbis", /*alias of audio/x-vorbis+ogg*/
+ "x-oggflac",
+ "x-mp2", /*alias of audio/mp2*/
+ "x-pn-realaudio", /*alias of audio/vnd.rn-realaudio*/
+ "vnd.m-realaudio", /*alias of audio/vnd.rn-realaudio*/
+};
+
+static const char sound_mime_table[SOUND_MIME_NUM][MIME_LENGTH] = {
+ "x-smaf",
+};
+
+int ms_update_valid_type(char *path)
+{
+ MS_DBG_START();
+
+ int res = MS_ERR_NONE;
+ int err;
+ int category = MS_CATEGORY_UNKNOWN;
+
+ MS_DBG("%s", path);
+
+ err = ms_get_category_from_mime(path, &category);
+ if (err < 0) {
+ MS_DBG("ms_get_category_from_mime fails");
+ return err;
+ }
+
+ /*if music, call mp_svc_set_item_valid() */
+ if (category & MS_CATEGORY_MUSIC || category & MS_CATEGORY_SOUND) {
+ /*check exist in Music DB, If file is not exist, insert data in DB. */
+ err = audio_svc_check_item_exist(path);
+ if (err == AUDIO_SVC_ERROR_DB_NO_RECORD) {
+ MS_DBG("not exist in Music DB. insert data");
+#ifdef THUMB_THREAD
+ err = ms_media_db_insert_with_thumb(path, category);
+#else
+ err = ms_media_db_insert(path, category, true);
+#endif
+ if (err != MS_ERR_NONE) {
+ MS_DBG ("ms_media_db_insert() error %d", err);
+ res = err;
+ }
+ }
+ else if (err == AUDIO_SVC_ERROR_NONE) {
+ /*if meta data of file exist, change valid field to "1" */
+ MS_DBG("Item exist");
+
+ err = audio_svc_set_item_valid(path, true);
+ if (err != AUDIO_SVC_ERROR_NONE)
+ MS_DBG("audio_svc_set_item_valid() error : %d", err);
+ }
+ else
+ {
+ MS_DBG("audio_svc_check_item_exist() error : %d", err);
+ res = MS_ERR_DB_OPERATION_FAIL;
+ }
+ }
+ /*if file is image file, call mb_svc_set_db_item_valid() */
+ else if (category & MS_CATEGORY_VIDEO || category & MS_CATEGORY_IMAGE) {
+ ms_store_type_t store_type;
+ minfo_store_type mb_stroage;
+
+ store_type = ms_get_store_type_by_full(path);
+ mb_stroage = (store_type == MS_MMC) ? MINFO_MMC : MINFO_PHONE;
+
+ err = minfo_set_item_valid(mb_stroage, path, true);
+ if (err != MB_SVC_ERROR_NONE) {
+ MS_DBG("not exist in Media DB. insert data");
+
+ ms_update_valid_type_end();
+
+#ifdef THUMB_THREAD
+ err = ms_media_db_insert_with_thumb(path, category);
+#else
+ err = ms_media_db_insert(path, category, true);
+#endif
+ if (err != MS_ERR_NONE)
+ MS_DBG("ms_media_db_insert() error : %d", err);
+
+ ms_update_valid_type_start();
+ }
+ else {
+ MS_DBG("Item exist");
+ }
+ }
+
+ if (category & MS_CATEGORY_DRM) {
+ DRM_RESULT drm_res;
+
+ ms_inoti_add_ignore_file(path);
+ drm_res = drm_svc_register_file(path);
+ if (drm_res != DRM_RESULT_SUCCESS) {
+ MS_DBG("drm_svc_register_file error : %d", drm_res);
+ res = MS_ERR_DRM_REGISTER_FAIL;
+ }
+ }
+
+ MS_DBG_END();
+
+ return res;
+}
+
+static int _ms_set_power_mode(ms_db_status_type_t status)
+{
+ int res = MS_ERR_NONE;
+ int err;
+
+ switch (status) {
+ case MS_DB_UPDATING:
+ err = pm_lock_state(LCD_OFF, STAY_CUR_STATE, 0);
+ if (err != 0)
+ res = MS_ERR_UNKNOWN_ERROR;
+ break;
+ case MS_DB_UPDATED:
+ err = pm_unlock_state(LCD_OFF, STAY_CUR_STATE);
+ if (err != 0)
+ res = MS_ERR_UNKNOWN_ERROR;
+ break;
+ default:
+ MS_DBG("Unacceptable type : %d", status);
+ break;
+ }
+
+ return res;
+}
+
+int ms_set_db_status(ms_db_status_type_t status)
+{
+ int res = MS_ERR_NONE;
+ int err = 0;
+
+ if (status == MS_DB_UPDATING) {
+ if (ms_config_set_int(VCONFKEY_FILEMANAGER_DB_STATUS, VCONFKEY_FILEMANAGER_DB_UPDATING))
+ res = MS_ERR_VCONF_SET_FAIL;
+ } else if (status == MS_DB_UPDATED) {
+ if(ms_config_set_int(VCONFKEY_FILEMANAGER_DB_STATUS, VCONFKEY_FILEMANAGER_DB_UPDATED))
+ res = MS_ERR_VCONF_SET_FAIL;
+ }
+
+ err = _ms_set_power_mode(status);
+ if (err != MS_ERR_NONE) {
+ MS_DBG("_ms_set_power_mode fail");
+ res = err;
+ }
+
+ return res;
+}
+
+GMutex * db_mutex;
+
+int ms_db_init(bool need_db_create)
+{
+ MS_DBG_START();
+
+ ms_scan_data_t *phone_scan_data;
+ ms_scan_data_t *mmc_scan_data;
+
+ phone_scan_data = malloc(sizeof(ms_scan_data_t));
+ mmc_scan_data = malloc(sizeof(ms_scan_data_t));
+ MS_DBG("*********************************************************");
+ MS_DBG("*** Begin to check tables of file manager in database ***");
+ MS_DBG("*********************************************************");
+
+ fex_make_default_path();
+
+ phone_scan_data->db_type = MS_PHONE;
+
+ if (need_db_create) {
+ /*insert records */
+ MS_DBG("Create DB");
+
+ phone_scan_data->scan_type = MS_SCAN_ALL;
+ } else {
+ MS_DBG("JUST ADD WATCH");
+ phone_scan_data->scan_type = MS_SCAN_NONE;
+ }
+
+ /*push data to fex_dir_scan_cb */
+ g_async_queue_push(scan_queue, GINT_TO_POINTER(phone_scan_data));
+
+ if (ms_is_mmc_supported()) {
+ mmc_state = VCONFKEY_SYSMAN_MMC_MOUNTED;
+
+#ifdef _WITH_DRM_SERVICE_
+ if (drm_svc_insert_ext_memory() == DRM_RESULT_SUCCESS)
+ MS_DBG
+ ("fex_db_service_init : drm_svc_insert_ext_memory OK");
+#endif
+
+ fex_make_default_path_mmc();
+
+ mmc_scan_data->scan_type = ms_get_mmc_state();
+ mmc_scan_data->db_type = MS_MMC;
+
+ MS_DBG("ms_get_mmc_state is %d", mmc_scan_data->scan_type);
+
+ g_async_queue_push(scan_queue, GINT_TO_POINTER(mmc_scan_data));
+ }
+
+ MS_DBG_END();
+ return 0;
+}
+
+int ms_media_db_open(void)
+{
+ int err;
+
+ /*Lock mutex for openning db*/
+ g_mutex_lock(db_mutex);
+
+ err = minfo_init();
+ if (err != MB_SVC_ERROR_NONE) {
+ MS_DBG("minfo_init() error : %d", err);
+
+ g_mutex_unlock(db_mutex);
+
+ return MS_ERR_DB_CONNECT_FAIL;
+ }
+
+ err = audio_svc_open();
+ if (err != AUDIO_SVC_ERROR_NONE) {
+ MS_DBG("audio_svc_open() error : %d", err);
+ err = minfo_finalize();
+ if (err != MB_SVC_ERROR_NONE)
+ MS_DBG("minfo_finalize() error: %d", err);
+
+ g_mutex_unlock(db_mutex);
+
+ return MS_ERR_DB_CONNECT_FAIL;
+ }
+ MS_DBG("connect Media DB");
+
+ g_mutex_unlock(db_mutex);
+
+ return MS_ERR_NONE;
+}
+
+int ms_media_db_close(void)
+{
+ int err;
+
+ err = audio_svc_close();
+ if (err != AUDIO_SVC_ERROR_NONE) {
+ MS_DBG("audio_svc_close() error : %d", err);
+ return MS_ERR_DB_DISCONNECT_FAIL;
+ }
+
+ err = minfo_finalize();
+ if (err != MB_SVC_ERROR_NONE) {
+ MS_DBG("minfo_finalize() error: %d", err);
+ return MS_ERR_DB_DISCONNECT_FAIL;
+ }
+
+ MS_DBG("Disconnect Media DB");
+
+ return MS_ERR_NONE;
+}
+
+int
+_ms_update_mmc_info(const char *cid)
+{
+ MS_DBG_START();
+ bool res;
+
+ if (cid == NULL) {
+ MS_DBG("Parameters are invalid");
+ return MS_ERR_ARG_INVALID;
+ }
+
+ res = ms_config_set_str(MS_MMC_INFO_KEY, cid);
+ if (!res) {
+ MS_DBG("fail to get MS_MMC_INFO_KEY");
+ return MS_ERR_VCONF_SET_FAIL;
+ }
+
+ MS_DBG_END();
+
+ return MS_ERR_NONE;
+}
+
+bool
+_ms_check_mmc_info(const char *cid)
+{
+ MS_DBG_START();
+
+ char pre_mmc_info[MMC_INFO_SIZE] = { 0 };
+ bool res = false;
+
+ if (cid == NULL) {
+ MS_DBG("Parameters are invalid");
+ return false;
+ }
+
+ res = ms_config_get_str(MS_MMC_INFO_KEY, pre_mmc_info);
+ if (!res) {
+ MS_DBG("fail to get MS_MMC_INFO_KEY");
+ return false;
+ }
+
+ MS_DBG("Last MMC info = %s", pre_mmc_info);
+ MS_DBG("Current MMC info = %s", cid);
+
+ if (strcmp(pre_mmc_info, cid) == 0) {
+ return true;
+ }
+
+ MS_DBG_END();
+ return false;
+}
+
+static int _get_contents(const char *filename, char *buf)
+{
+ FILE *fp;
+
+ MS_DBG("%s", filename);
+
+ fp = fopen(filename, "rt");
+ if (fp == NULL) {
+ MS_DBG("fp is NULL");
+ return MS_ERR_FILE_OPEN_FAIL;
+ }
+ fgets(buf, 255, fp);
+
+ fclose(fp);
+
+ return MS_ERR_NONE;
+}
+
+/*need optimize*/
+int _ms_get_mmc_info(char *cid)
+{
+ MS_DBG_START();
+
+ int i;
+ int j;
+ int len;
+ int err = -1;
+ bool getdata = false;
+ bool bHasColon = false;
+ char path[MS_FILE_PATH_LEN_MAX] = { 0 };
+ char mmcpath[MS_FILE_PATH_LEN_MAX] = { 0 };
+
+ DIR *dp;
+ struct dirent ent;
+ struct dirent *res = NULL;
+
+ /* mmcblk0 and mmcblk1 is reserved for movinand */
+ for (j = 1; j < 3; j++) {
+ len = snprintf(mmcpath, MS_FILE_PATH_LEN_MAX, "/sys/class/mmc_host/mmc%d/", j);
+ if (len < 0) {
+ MS_DBG("FAIL : snprintf");
+ return MS_ERR_UNKNOWN_ERROR;
+ }
+ else {
+ mmcpath[len] = '\0';
+ }
+
+ dp = opendir(mmcpath);
+
+ if (dp == NULL) {
+ MS_DBG("dp is NULL");
+ {
+ return MS_ERR_DIR_OPEN_FAIL;
+ }
+ }
+
+ while (!readdir_r(dp, &ent, &res)) {
+ /*end of read dir*/
+ if (res == NULL)
+ break;
+
+ bHasColon = false;
+ if (ent.d_name[0] == '.')
+ continue;
+
+ if (ent.d_type == DT_DIR) {
+ /*ent->d_name is including ':' */
+ for (i = 0; i < strlen(ent.d_name); i++) {
+ if (ent.d_name[i] == ':') {
+ bHasColon = true;
+ break;
+ }
+ }
+
+ if (bHasColon) {
+ /*check serial */
+ err = ms_strappend(path, sizeof(path), "%s%s/cid", mmcpath, ent.d_name);
+ if (err < 0) {
+ MS_DBG("FAIL : ms_strappend");
+ continue;
+ }
+
+ if (_get_contents(path, cid) != MS_ERR_NONE)
+ break;
+ else
+ getdata = true;
+ MS_DBG("MMC serial : %s", cid);
+ }
+ }
+ }
+ closedir(dp);
+
+ if (getdata == true) {
+ break;
+ }
+ }
+
+ MS_DBG_END();
+
+ return MS_ERR_NONE;
+}
+
+int ms_update_mmc_info(void)
+{
+ int err;
+ char cid[MMC_INFO_SIZE] = { 0 };
+
+ err = _ms_get_mmc_info(cid);
+
+ err = _ms_update_mmc_info(cid);
+
+ /*Active flush */
+ if (malloc_trim(0))
+ MS_DBG("SUCCESS malloc_trim");
+
+ return err;
+}
+
+void ms_mmc_removed_handler(void)
+{
+ ms_scan_data_t *mmc_scan_data;
+
+ mmc_scan_data = malloc(sizeof(ms_scan_data_t));
+
+ mmc_scan_data->scan_type = MS_SCAN_VALID;
+ mmc_scan_data->db_type = MS_MMC;
+
+ g_async_queue_push(scan_queue, GINT_TO_POINTER(mmc_scan_data));
+
+ /*remove added watch descriptors */
+ ms_inoti_remove_watch_recursive(MS_MMC_ROOT_PATH);
+
+ ms_inoti_delete_mmc_ignore_file();
+
+ if (drm_svc_extract_ext_memory() == DRM_RESULT_SUCCESS)
+ MS_DBG("drm_svc_extract_ext_memory OK");
+}
+
+void ms_mmc_vconf_cb(void *data)
+{
+ MS_DBG_START();
+
+ int status = 0;
+ ms_scan_data_t *scan_data;
+
+ MS_DBG("Received MMC noti from vconf : %d", status);
+
+ if (!ms_config_get_int(VCONFKEY_SYSMAN_MMC_STATUS, &status)) {
+ MS_DBG("........Get VCONFKEY_SYSMAN_MMC_STATUS failed........");
+ }
+
+ MS_DBG("ms_config_get_int : VCONFKEY_SYSMAN_MMC_STATUS END = %d",
+ status);
+
+ mmc_state = status;
+
+ if (current_usb_mode != VCONFKEY_USB_STORAGE_STATUS_OFF)
+ return;
+
+ if (mmc_state == VCONFKEY_SYSMAN_MMC_REMOVED ||
+ mmc_state == VCONFKEY_SYSMAN_MMC_INSERTED_NOT_MOUNTED) {
+ ms_mmc_removed_handler();
+ }
+ else if (mmc_state == VCONFKEY_SYSMAN_MMC_MOUNTED) {
+ scan_data = malloc(sizeof(ms_scan_data_t));
+#ifdef _WITH_DRM_SERVICE_
+ if (drm_svc_insert_ext_memory() == DRM_RESULT_SUCCESS)
+ MS_DBG("drm_svc_insert_ext_memory OK");
+#endif
+ fex_make_default_path_mmc();
+
+ scan_data->scan_type = ms_get_mmc_state();
+ scan_data->db_type = MS_MMC;
+
+ MS_DBG("ms_get_mmc_state is %d", scan_data->scan_type);
+
+ g_async_queue_push(scan_queue, GINT_TO_POINTER(scan_data));
+ }
+
+ MS_DBG_END();
+
+ return;
+}
+
+#ifdef FMS_PERF
+
+void ms_check_start_time(struct timeval *start_time)
+{
+ gettimeofday(start_time, NULL);
+}
+
+void ms_check_end_time(struct timeval *end_time)
+{
+ gettimeofday(end_time, NULL);
+}
+
+void ms_check_time_diff(struct timeval *start_time, struct timeval *end_time)
+{
+ struct timeval time;
+ long difftime;
+
+ time.tv_sec = end_time->tv_sec - start_time->tv_sec;
+ time.tv_usec = end_time->tv_usec - start_time->tv_usec;
+ difftime = MILLION * time.tv_sec + time.tv_usec;
+ MS_DBG("The function_to_time took %ld microseconds or %f seconds.",
+ difftime, difftime / (double)MILLION);
+}
+
+#endif
+
+void ms_usb_vconf_cb(void *data)
+{
+ MS_DBG_START();
+
+ int status = 0;
+
+ MS_DBG("Received usb noti from vconf : %d", status);
+
+ if (!ms_config_get_int(VCONFKEY_USB_STORAGE_STATUS, &status)) {
+ MS_DBG
+ ("........Get VCONFKEY_USB_STORAGE_STATUS failed........");
+ }
+
+ MS_DBG("ms_config_get_int : VCONFKEY_USB_STORAGE_STATUS END = %d",
+ status);
+ current_usb_mode = status;
+
+ if (current_usb_mode == VCONFKEY_USB_STORAGE_STATUS_OFF) {
+ if (ums_mode != VCONFKEY_USB_STORAGE_STATUS_OFF) {
+ ms_scan_data_t *int_scan;
+
+ fex_make_default_path();
+
+ int_scan = malloc(sizeof(ms_scan_data_t));
+
+ int_scan->db_type = MS_PHONE;
+ int_scan->scan_type = MS_SCAN_PART;
+
+ /*push data to fex_dir_scan_cb */
+ g_async_queue_push(scan_queue, GINT_TO_POINTER(int_scan));
+
+ if (ms_is_mmc_supported()) {
+ ms_scan_data_t *ext_scan;
+
+ /*prepare to insert drm data and delete previous drm datas */
+ if (drm_svc_insert_ext_memory() ==
+ DRM_RESULT_SUCCESS)
+ MS_DBG("drm_svc_insert_ext_memory OK");
+
+ ext_scan = malloc(sizeof(ms_scan_data_t));
+ mmc_state = VCONFKEY_SYSMAN_MMC_MOUNTED;
+
+ ext_scan->db_type = MS_MMC;
+ ext_scan->scan_type = MS_SCAN_PART;
+
+ /*push data to fex_dir_scan_cb */
+ g_async_queue_push(scan_queue, GINT_TO_POINTER(ext_scan));
+ }
+ }
+ ums_mode = VCONFKEY_USB_STORAGE_STATUS_OFF;
+ ms_config_set_int(MS_USB_MODE_KEY, MS_VCONFKEY_NORMAL_MODE);
+ }
+ else {
+ if (ums_mode == VCONFKEY_USB_STORAGE_STATUS_OFF) {
+ MS_DBG("VCONFKEY_USB_STORAGE_STATUS : %d", current_usb_mode);
+ ms_scan_data_t *int_scan;
+
+ ums_mode = current_usb_mode;
+
+ int_scan = malloc(sizeof(ms_scan_data_t));
+ int_scan->scan_type = MS_SCAN_VALID;
+ int_scan->db_type = MS_PHONE;
+
+ g_async_queue_push(scan_queue, GINT_TO_POINTER(int_scan));
+
+ ms_inoti_remove_watch_recursive(MS_PHONE_ROOT_PATH);
+
+ if (ums_mode == VCONFKEY_USB_STORAGE_STATUS_UMS_MMC_ON) {
+
+ ms_scan_data_t *ext_scan;
+
+ ext_scan = malloc(sizeof(ms_scan_data_t));
+ ext_scan->scan_type = MS_SCAN_VALID;
+ ext_scan->db_type = MS_MMC;
+
+ g_async_queue_push(scan_queue, GINT_TO_POINTER(ext_scan));
+
+ ms_inoti_remove_watch_recursive(MS_MMC_ROOT_PATH);
+
+ /*notify to drm-server */
+ if (drm_svc_extract_ext_memory() == DRM_RESULT_SUCCESS)
+ MS_DBG("drm_svc_extract_ext_memory OK");
+ }
+
+ /*delete all drm contect from drm server */
+ if (drm_svc_unregister_all_contents() == DRM_RESULT_SUCCESS)
+ MS_DBG("drm_svc_unregister_all_contents OK");
+
+ ms_config_set_int(MS_USB_MODE_KEY, MS_VCONFKEY_MASS_STORAGE_MODE);
+ }
+ }
+
+ MS_DBG_END();
+ return;
+}
+
+bool ms_is_mmc_supported(void)
+{
+ MS_DBG_START();
+
+ /*TODO-Q: simulator support? */
+ if (0)
+ /* if (strcmp(FEXPLORER_MMC_ROOT_PATH, "/mnt/mmc") == 0) //simulator */
+ {
+ return true;
+ } else {
+ int data = -1;
+ ms_config_get_int(VCONFKEY_SYSMAN_MMC_STATUS, &data);
+ MS_DBG("%s is %d ", VCONFKEY_SYSMAN_MMC_STATUS, data);
+ if (data != VCONFKEY_SYSMAN_MMC_MOUNTED)
+ return false;
+ else
+ return true;
+ }
+
+ MS_DBG_END();
+ return false;
+}
+
+ms_dir_scan_type_t ms_get_mmc_state(void)
+{
+ char cid[MMC_INFO_SIZE] = { 0 };
+ ms_dir_scan_type_t ret = MS_SCAN_ALL;
+
+ /*get new info */
+ _ms_get_mmc_info(cid);
+
+ /*check it's same mmc */
+ if (_ms_check_mmc_info(cid)) {
+ MS_DBG("Detected same MMC! but needs to update the changes...");
+ ret = MS_SCAN_PART;
+ }
+
+ return ret;
+}
+
+GAsyncQueue* soc_queue;
+GArray *reg_list;
+GMutex *list_mutex;
+GMutex *queue_mutex;
+
+void _ms_insert_reg_list(const char *path)
+{
+ char *reg_path = strdup(path);
+
+ g_mutex_lock(list_mutex);
+
+ g_array_append_val(reg_list, reg_path);
+
+ g_mutex_unlock(list_mutex);
+}
+
+bool _ms_find_reg_list(const char *path)
+{
+ int i;
+ int len = reg_list->len;
+ char *data;
+ bool ret = false;
+
+ g_mutex_lock(list_mutex);
+ MS_DBG("array length : %d", len);
+
+ for(i = 0; i < len; i++) {
+ data = g_array_index (reg_list, char*, i);
+ if(!strcmp(data, path))
+ ret = true;
+ }
+
+ g_mutex_unlock(list_mutex);
+
+ return ret;
+}
+
+void _ms_delete_reg_list(const char *path)
+{
+ int i;
+ int len = reg_list->len;
+ char *data;
+
+ MS_DBG("Delete : %s", path);
+ g_mutex_lock(list_mutex);
+
+ for(i = 0; i < len; i++) {
+ data = g_array_index (reg_list, char*, i);
+ MS_DBG("%s", data);
+ if(!strcmp(data, path)) {
+ MS_DBG("Delete complete : %s", data);
+ free(data);
+ g_array_remove_index(reg_list, i);
+ break;
+ }
+ }
+
+ g_mutex_unlock(list_mutex);
+}
+
+void ms_register_start(void)
+{
+ minfo_add_media_start(MS_REGISTER_COUNT);
+ audio_svc_insert_item_start(MS_REGISTER_COUNT);
+}
+
+void ms_register_end(void)
+{
+ minfo_add_media_end();
+ audio_svc_insert_item_end();
+}
+
+int ms_register_file(const char *path, GAsyncQueue* queue)
+{
+ MS_DBG_START();
+ MS_DBG("[%d]register file : %s", syscall(__NR_gettid), path);
+
+ int err;
+ int category = MS_CATEGORY_UNKNOWN;
+
+ if (path == NULL) {
+ MS_DBG("path == NULL");
+ return MS_ERR_ARG_INVALID;
+ }
+
+ g_mutex_lock(queue_mutex);
+ /*first request for this file*/
+ if(!_ms_find_reg_list(path)) {
+ /*insert registering file list*/
+ _ms_insert_reg_list(path);
+ } else {
+ MS_DBG("______________________ALREADY INSERTING");
+ if(queue != NULL) {
+ MS_DBG("Need reply");
+ soc_queue = queue;
+ }
+ g_mutex_unlock(queue_mutex);
+ return MS_ERR_NOW_REGISTER_FILE;
+ }
+ g_mutex_unlock(queue_mutex);
+
+ err = ms_get_category_from_mime(path, &category);
+ if (err != MS_ERR_NONE) {
+ MS_DBG("ms_get_category_from_mime error : %d", err);
+ goto FREE_RESOURCE;
+ }
+
+ if (category <= MS_CATEGORY_ETC) {
+ MS_DBG("This is not media contents");
+ err = MS_ERR_NOT_MEDIA_FILE;
+ goto FREE_RESOURCE;
+ } else {
+#ifdef THUMB_THREAD
+ err = ms_media_db_insert_with_thumb(path, category);
+#else
+ err = ms_media_db_insert(path, category, false);
+#endif
+ if (err != MS_ERR_NONE) {
+ MS_DBG("ms_media_db_insert error : %d", err);
+
+ /*if music, call mp_svc_set_item_valid() */
+ if (category & MS_CATEGORY_MUSIC || category & MS_CATEGORY_SOUND) {
+ /*check exist in Music DB, If file is not exist, insert data in DB. */
+ err = audio_svc_check_item_exist(path);
+ if (err == AUDIO_SVC_ERROR_NONE) {
+ MS_DBG("Audio Item exist");
+ err = MS_ERR_NONE;
+ }
+ } else if (category & MS_CATEGORY_VIDEO || category & MS_CATEGORY_IMAGE) {
+ Mitem *mi = NULL;
+
+ /*get an item based on its url. */
+ err = minfo_get_item(path, &mi);
+ if (err == MB_SVC_ERROR_NONE) {
+ MS_DBG("Visual Item exist");
+ err = MS_ERR_NONE;
+ }
+
+ minfo_destroy_mtype_item(mi);
+ }
+ }
+
+ if (category & MS_CATEGORY_DRM) {
+ MS_DBG("THIS IS DRM FILE");
+ DRM_RESULT res;
+
+ ms_inoti_add_ignore_file(path);
+ res = drm_svc_register_file(path);
+ if (res != DRM_RESULT_SUCCESS) {
+ MS_DBG("drm_svc_register_file error : %d", res);
+ err = MS_ERR_DRM_REGISTER_FAIL;
+ }
+ }
+ }
+
+FREE_RESOURCE:
+ g_mutex_lock(queue_mutex);
+
+ _ms_delete_reg_list(path);
+
+ if (soc_queue != NULL) {
+ MS_DBG("%d", err);
+ g_async_queue_push(soc_queue, GINT_TO_POINTER(err+MS_ERR_MAX));
+ MS_DBG("Return OK");
+ }
+ soc_queue = NULL;
+ g_mutex_unlock(queue_mutex);
+ MS_DBG_END();
+ return err;
+}
+
+int ms_register_scanfile(const char *path)
+{
+ MS_DBG_START();
+ MS_DBG("register scanfile : %s", path);
+
+ int err = MS_ERR_NONE;
+ bool res = false;
+ int category = MS_CATEGORY_UNKNOWN;
+
+ if (path == NULL) {
+ MS_DBG("path == NULL");
+ return MS_ERR_ARG_INVALID;
+ }
+
+ err = ms_get_category_from_mime(path, &category);
+ if (err != MS_ERR_NONE) {
+ MS_DBG("ms_get_category_from_mime error : %d", err);
+ return err;
+ }
+
+ if (category <= MS_CATEGORY_ETC) {
+ MS_DBG("This is not media contents");
+ return MS_ERR_NOT_MEDIA_FILE;
+ }
+
+ err = ms_media_db_insert(path, category, true);
+ if (err != MS_ERR_NONE) {
+ MS_DBG("ms_media_db_insert error : %d", err);
+ }
+
+ if (category & MS_CATEGORY_DRM) {
+ MS_DBG("THIS IS DRM FILE");
+ DRM_RESULT res;
+
+ ms_inoti_add_ignore_file(path);
+
+ res = drm_svc_register_file(path);
+ if (res != DRM_RESULT_SUCCESS) {
+ MS_DBG("drm_svc_register_file error : %d", err);
+ err = MS_ERR_DRM_REGISTER_FAIL;
+ }
+ }
+
+ MS_DBG_END();
+ return err;
+}
+
+
+int ms_start(bool need_db_create)
+{
+ int err = 0;
+
+ err = vconf_notify_key_changed(VCONFKEY_SYSMAN_MMC_STATUS,
+ (vconf_callback_fn) ms_mmc_vconf_cb, NULL);
+ if (err == -1)
+ MS_DBG("add call back function for event %s fails",
+ VCONFKEY_SYSMAN_MMC_STATUS);
+
+ err = vconf_notify_key_changed(VCONFKEY_USB_STORAGE_STATUS,
+ (vconf_callback_fn) ms_usb_vconf_cb, NULL);
+ if (err == -1)
+ MS_DBG("add call back function for event %s fails",
+ VCONFKEY_USB_STORAGE_STATUS);
+
+ ms_db_init(need_db_create);
+
+ malloc_trim(0);
+
+ return err;
+}
+
+void ms_end(void)
+{
+ /***********
+ **remove call back functions
+ ************/
+ vconf_ignore_key_changed(VCONFKEY_SYSMAN_MMC_STATUS,
+ (vconf_callback_fn) ms_mmc_vconf_cb);
+ vconf_ignore_key_changed(VCONFKEY_USB_STORAGE_STATUS,
+ (vconf_callback_fn) ms_usb_vconf_cb);
+
+ /*Clear db mutex variable*/
+ g_mutex_free (db_mutex);
+}
+
+int ms_get_full_path_from_node(ms_dir_scan_info * const node, char *ret_path)
+{
+ int err = 0;
+ ms_dir_scan_info *cur_node;
+ char path[MS_FILE_PATH_LEN_MAX] = { 0 };
+ char tmp_path[MS_FILE_PATH_LEN_MAX] = { 0 };
+
+ cur_node = node;
+ MS_DBG("%s", cur_node->name);
+
+ while (1) {
+ err = ms_strappend(path, sizeof(path), "/%s%s", cur_node->name, tmp_path);
+ if (err < 0) {
+ MS_DBG("ms_strappend error : %d", err);
+ return err;
+ }
+
+ strncpy(tmp_path, path, MS_FILE_PATH_LEN_MAX);
+
+ if (cur_node->parent == NULL)
+ break;
+
+ cur_node = cur_node->parent;
+ memset(path, 0, MS_FILE_PATH_LEN_MAX);
+ }
+
+ strncpy(ret_path, path, MS_FILE_PATH_LEN_MAX);
+
+ return err;
+}
+
+ms_store_type_t ms_get_store_type_by_full(const char *path)
+{
+ if (strncmp(path + 1, MS_PHONE_ROOT_PATH, strlen(MS_PHONE_ROOT_PATH)) == 0) {
+ return MS_PHONE;
+ } else
+ if (strncmp(path + 1, MS_MMC_ROOT_PATH, strlen(MS_MMC_ROOT_PATH)) == 0) {
+ return MS_MMC;
+ } else
+ return MS_ERR_INVALID_FILE_PATH;
+}
+
+int
+ms_strappend(char *res, const int size, const char *pattern,
+ const char *str1, const char *str2)
+{
+ int len = 0;
+ int real_size = size - 1;
+
+ if (!res ||!pattern || !str1 ||!str2 )
+ return MS_ERR_ARG_INVALID;
+
+ if (real_size < (strlen(str1) + strlen(str2)))
+ return MS_ERR_OUT_OF_RANGE;
+
+ len = snprintf(res, real_size, pattern, str1, str2);
+ if (len < 0) {
+ MS_DBG("MS_ERR_ARG_INVALID");
+ return MS_ERR_ARG_INVALID;
+ }
+
+ res[len] = '\0';
+
+ return MS_ERR_NONE;
+}
+
+int
+ms_strcopy(char *res, const int size, const char *pattern, const char *str1)
+{
+ int len = 0;
+ int real_size = size - 1;
+
+ if (!res || !pattern || !str1)
+ return MS_ERR_ARG_INVALID;
+
+ if (real_size < strlen(str1))
+ return MS_ERR_OUT_OF_RANGE;
+
+ len = snprintf(res, real_size, pattern, str1);
+ if (len < 0) {
+ MS_DBG("MS_ERR_ARG_INVALID");
+ return MS_ERR_ARG_INVALID;
+ }
+
+ res[len] = '\0';
+
+ return MS_ERR_NONE;
+}
+
+#ifdef _WITH_SETTING_AND_NOTI_
+bool ms_config_get_int(const char *key, int *value)
+{
+ int err;
+
+ if (!key || !value) {
+ MS_DBG("Arguments key or value is NULL");
+ return false;
+ }
+
+ err = vconf_get_int(key, value);
+ if (err == 0)
+ return true;
+ else if (err == -1)
+ return false;
+ else
+ MS_DBG("Unexpected error code: %d", err);
+
+ return false;
+}
+
+bool ms_config_set_int(const char *key, int value)
+{
+ int err;
+
+ if (!key) {
+ MS_DBG("Arguments key is NULL");
+ return false;
+ }
+
+ err = vconf_set_int(key, value);
+ if (err == 0)
+ return true;
+ else if (err == -1)
+ return false;
+ else
+ MS_DBG("Unexpected error code: %d", err);
+
+ return false;
+}
+
+bool ms_config_get_str(const char *key, char *value)
+{
+ char *res;
+ if (!key || !value) {
+ MS_DBG("Arguments key or value is NULL");
+ return false;
+ }
+
+ res = vconf_get_str(key);
+ if (res) {
+ strncpy(value, res, strlen(res) + 1);
+ return true;
+ }
+
+ return false;
+}
+
+bool ms_config_set_str(const char *key, const char *value)
+{
+ int err;
+
+ if (!key || !value) {
+ MS_DBG("Arguments key or value is NULL");
+ return false;
+ }
+
+ err = vconf_set_str(key, value);
+ if (err == 0)
+ return true;
+ else
+ MS_DBG("fail to vconf_set_str %d", err);
+
+ return false;
+}
+#endif /* _WITH_SETTING_AND_NOTI_ */
+
+bool fex_make_default_path(void)
+{
+ int i = 0;
+ int ret = 0;
+ bool create_flag = false;
+ DIR *dp = NULL;
+
+ char default_path[10][256] = {
+ {"/opt/media/Images and videos"},
+ {"/opt/media/Images and videos/Wallpapers"},
+ {"/opt/media/Sounds and music"},
+ {"/opt/media/Sounds and music/Music"},
+ {"/opt/media/Sounds and music/Ringtones"},
+ {"/opt/media/Sounds and music/Alerts"},
+ {"/opt/media/Sounds and music/FM Radio"},
+ {"/opt/media/Sounds and music/Voice recorder"},
+ {"/opt/media/Downloads"},
+ {"/opt/media/Camera shots"}
+ };
+
+ for (i = 0; i < 10; ++i) {
+ dp = opendir(default_path[i]);
+ if (dp == NULL) {
+ ret = mkdir(default_path[i], 0777);
+ if (ret < 0) {
+ MS_DBG("make fail");
+ } else {
+ create_flag = true;
+ ms_inoti_add_watch(default_path[i]);
+ }
+ } else {
+ closedir(dp);
+ }
+ }
+
+ return create_flag;
+}
+
+bool fex_make_default_path_mmc(void)
+{
+ MS_DBG_START();
+
+ int i = 0;
+ int ret = 0;
+ bool create_flag = false;
+ DIR *dp = NULL;
+
+ char default_path[10][256] = {
+ {"/opt/storage/sdcard/Images and videos"},
+ {"/opt/storage/sdcard/Images and videos/Wallpapers"},
+ {"/opt/storage/sdcard/Sounds and music"},
+ {"/opt/storage/sdcard/Sounds and music/Music"},
+ {"/opt/storage/sdcard/Sounds and music/Ringtones"},
+ {"/opt/storage/sdcard/Sounds and music/Alerts"},
+ {"/opt/storage/sdcard/Sounds and music/FM Radio"},
+ {"/opt/storage/sdcard/Sounds and music/Voice recorder"},
+ {"/opt/storage/sdcard/Downloads"},
+ {"/opt/storage/sdcard/Camera shots"}
+ };
+
+ for (i = 0; i < 10; ++i) {
+ dp = opendir(default_path[i]);
+ if (dp == NULL) {
+ ret = mkdir(default_path[i], 0777);
+ if (ret < 0) {
+ MS_DBG("make fail");
+ } else {
+ create_flag = true;
+ ms_inoti_add_watch(default_path[i]);
+ }
+ } else {
+ closedir(dp);
+ }
+ }
+
+ MS_DBG_END();
+
+ return create_flag;
+}
+
+static int _ms_get_mime_by_drm_info(const char *path, char *mime)
+{
+#ifdef _WITH_DRM_SERVICE_
+ int res = MS_ERR_NONE;
+ drm_content_info_t contentInfo = { 0 };
+
+ if (path == NULL || mime == NULL)
+ return MS_ERR_ARG_INVALID;
+
+ res = drm_svc_get_content_info(path, &contentInfo);
+ if (res != DRM_RESULT_SUCCESS) {
+ MS_DBG("drm_svc_get_content_info() fails. ");
+ return res;
+ }
+
+ strncpy(mime, contentInfo.contentType, MS_DRM_CONTENT_TYPE_LENGTH);
+
+ return res;
+#else
+ return MS_ERR_NONE;
+#endif
+}
+
+int ms_get_category_from_mime(const char *path, int *category)
+{
+ int i = 0;
+ int err = 0;
+ char mimetype[MIME_TYPE_LENGTH];
+
+ if (path == NULL || category == NULL)
+ return MS_ERR_ARG_INVALID;
+
+ *category = MS_CATEGORY_UNKNOWN;
+
+ /*get content type and mime type from file. */
+ /*in case of drm file. */
+ if (drm_svc_is_drm_file(path) == DRM_TRUE) {
+ DRM_FILE_TYPE drm_type = DRM_FILE_TYPE_NONE;
+ drm_type = drm_svc_get_drm_type(path);
+ if (drm_type == DRM_FILE_TYPE_NONE) {
+ *category = MS_CATEGORY_UNKNOWN;
+ return err;
+ }
+ else {
+ err = _ms_get_mime_by_drm_info(path, mimetype);
+ if (err < 0) {
+ *category = MS_CATEGORY_UNKNOWN;
+ return err;
+ }
+ *category |= MS_CATEGORY_DRM;
+ }
+ }
+ else {
+ /*in case of normal files */
+ if (aul_get_mime_from_file(path, mimetype, sizeof(mimetype)) < 0) {
+ MS_DBG("aul_get_mime_from_file fail");
+ *category = MS_CATEGORY_UNKNOWN;
+ return MS_ERR_ARG_INVALID;
+ }
+ }
+
+ MS_DBG("mime type : %s", mimetype);
+
+ /*categorize from mimetype */
+ for (i = 0; i < CONTENT_TYPE_NUM; i++) {
+ if (strstr(mimetype, content_category[i].content_type) != NULL) {
+ *category = (*category | content_category[i].category_by_mime);
+ break;
+ }
+ }
+
+ /*in application type, exitst sound file ex) x-smafs */
+ if (*category & MS_CATEGORY_ETC) {
+ int prefix_len = strlen(content_category[0].content_type);
+
+ for (i = 0; i < SOUND_MIME_NUM; i++) {
+ if (strstr(mimetype + prefix_len, sound_mime_table[i]) != NULL) {
+ *category ^= MS_CATEGORY_ETC;
+ *category |= MS_CATEGORY_SOUND;
+ break;
+ }
+ }
+ }
+
+ /*check music file in soun files. */
+ if (*category & MS_CATEGORY_SOUND) {
+ int prefix_len = strlen(content_category[0].content_type) + 1;
+
+ MS_DBG("mime_type : %s", mimetype + prefix_len);
+
+ for (i = 0; i < MUSIC_MIME_NUM; i++) {
+ if (strcmp(mimetype + prefix_len, music_mime_table[i]) == 0) {
+ *category ^= MS_CATEGORY_SOUND;
+ *category |= MS_CATEGORY_MUSIC;
+ break;
+ }
+ }
+ } else if (*category & MS_CATEGORY_VIDEO) {
+ /*some video files don't have video stream. in this case it is categorize as music. */
+ char *ext;
+ /*"3gp" and "mp4" must check video stream and then categorize in directly. */
+ ext = strrchr(path, '.');
+ if (ext != NULL) {
+ if ((strncasecmp(ext, _3GP_FILE, 4) == 0) || (strncasecmp(ext, _MP4_FILE, 5) == 0)) {
+ int audio = 0;
+ int video = 0;
+
+ err = mm_file_get_stream_info(path, &audio, &video);
+ if (err == 0) {
+ if (audio > 0 && video == 0) {
+ *category ^= MS_CATEGORY_VIDEO;
+ *category |= MS_CATEGORY_MUSIC;
+ }
+ }
+ }
+ }
+ }
+
+ MS_DBG("category_from_ext : %d", *category);
+
+ return err;
+}
+
+void ms_check_db_updating(void)
+{
+ int vconf_value = 0;
+
+ /*wait if phone init is not finished. */
+ while (1) {
+ ms_config_get_int(VCONFKEY_FILEMANAGER_DB_STATUS, &vconf_value);
+
+ if (vconf_value != VCONFKEY_FILEMANAGER_DB_UPDATED) {
+ MS_DBG("iNoti waits till init_phone finishes...");
+ sleep(2);
+ } else {
+ return;
+ }
+ }
+}
+
+/****************************************************************************************************
+LIBMEDIA_INFO
+*****************************************************************************************************/
+
+#ifdef _WITH_MP_PB_
+void ms_update_valid_type_start(void)
+{
+ audio_svc_set_item_valid_start(MS_VALID_COUNT);
+ minfo_set_item_valid_start(MS_VALID_COUNT);
+}
+
+void ms_update_valid_type_end(void)
+{
+ audio_svc_set_item_valid_end();
+ minfo_set_item_valid_end();
+}
+
+int ms_change_valid_type(ms_store_type_t store_type, bool validation)
+{
+ MS_DBG_START();
+ int res = MS_ERR_NONE;
+ int err;
+
+ audio_svc_storage_type_e audio_storage;
+ minfo_store_type visual_storage;
+
+ audio_storage = (store_type == MS_PHONE)
+ ? AUDIO_SVC_STORAGE_PHONE : AUDIO_SVC_STORAGE_MMC;
+ visual_storage = (store_type == MS_PHONE)
+ ? MINFO_PHONE : MINFO_MMC;
+
+ err = audio_svc_set_db_valid(audio_storage, validation);
+ if (err < AUDIO_SVC_ERROR_NONE) {
+ MS_DBG("audio_svc_set_db_valid error :%d", err);
+ res = MS_ERR_DB_OPERATION_FAIL;
+ }
+
+ err = minfo_set_db_valid(visual_storage, validation);
+ if (err < MB_SVC_ERROR_NONE) {
+ MS_DBG("minfo_set_db_valid : error %d", err);
+ res = MS_ERR_DB_OPERATION_FAIL;
+ }
+
+ MS_DBG_END();
+
+ return res;
+}
+
+#ifdef THUMB_THREAD
+int ms_media_db_insert_with_thumb(const char *path, int category)
+{
+ MS_DBG_START();
+ MS_DBG("%s", path);
+
+ int ret = MS_ERR_NONE;
+ int err;
+ ms_store_type_t store_type;
+ audio_svc_category_type_e audio_category;
+ minfo_file_type visual_category;
+ audio_svc_storage_type_e storage;
+
+ if (category & MS_CATEGORY_VIDEO ||category & MS_CATEGORY_IMAGE) {
+ visual_category = (category & MS_CATEGORY_IMAGE)
+ ? MINFO_ITEM_IMAGE : MINFO_ITEM_VIDEO;
+ err = minfo_add_media(path, visual_category);
+ if (err < 0) {
+ MS_DBG(" minfo_add_media error %d", err);
+ ret = MS_ERR_DB_INSERT_RECORD_FAIL;
+ } else {
+ char thumb_path[1024];
+
+ err = thumbnail_request_from_db(path, thumb_path, sizeof(thumb_path));
+ if (err < 0) {
+ MS_DBG("thumbnail_request_from_db falied: %d", err);
+ } else {
+ MS_DBG("thumbnail_request_from_db success: %s", thumb_path);
+ }
+ }
+
+ MS_DBG("IMAGE");
+ }
+ else if (category & MS_CATEGORY_SOUND || category & MS_CATEGORY_MUSIC) {
+ store_type = ms_get_store_type_by_full(path);
+
+ storage = (store_type == MS_MMC)
+ ? AUDIO_SVC_STORAGE_MMC : AUDIO_SVC_STORAGE_PHONE;
+ audio_category = (category & MS_CATEGORY_SOUND)
+ ? AUDIO_SVC_CATEGORY_SOUND : AUDIO_SVC_CATEGORY_MUSIC;
+
+ err = audio_svc_insert_item(storage, path, audio_category);
+ if (err < 0) {
+ MS_DBG("mp_svc_insert_item fails error %d", err);
+ ret = MS_ERR_DB_INSERT_RECORD_FAIL;
+ }
+ MS_DBG("SOUND");
+ }
+
+ MS_DBG_END();
+ return ret;
+}
+#endif
+
+int ms_media_db_insert(const char *path, int category, bool bulk)
+{
+ MS_DBG_START();
+ MS_DBG("%s", path);
+
+ int ret = MS_ERR_NONE;
+ int err;
+ ms_store_type_t store_type;
+ audio_svc_category_type_e audio_category;
+ minfo_file_type visual_category;
+ audio_svc_storage_type_e storage;
+
+ if (category & MS_CATEGORY_VIDEO ||category & MS_CATEGORY_IMAGE) {
+ visual_category = (category & MS_CATEGORY_IMAGE)
+ ? MINFO_ITEM_IMAGE : MINFO_ITEM_VIDEO;
+ if(bulk)
+ err = minfo_add_media_batch(path, visual_category);
+ else
+ err = minfo_add_media(path, visual_category);
+ if (err < 0) {
+ MS_DBG(" minfo_add_media error %d", err);
+ ret = MS_ERR_DB_INSERT_RECORD_FAIL;
+ }
+#ifndef THUMB_THREAD
+ else {
+ char thumb_path[1024];
+
+ err = thumbnail_request_from_db(path, thumb_path, sizeof(thumb_path));
+ if (err < 0) {
+ MS_DBG("thumbnail_request_from_db falied: %d", err);
+ } else {
+ MS_DBG("thumbnail_request_from_db success: %s", thumb_path);
+ }
+#endif
+ }
+
+ MS_DBG("IMAGE");
+ }
+ else if (category & MS_CATEGORY_SOUND || category & MS_CATEGORY_MUSIC) {
+ store_type = ms_get_store_type_by_full(path);
+
+ storage = (store_type == MS_MMC)
+ ? AUDIO_SVC_STORAGE_MMC : AUDIO_SVC_STORAGE_PHONE;
+ audio_category = (category & MS_CATEGORY_SOUND)
+ ? AUDIO_SVC_CATEGORY_SOUND : AUDIO_SVC_CATEGORY_MUSIC;
+
+ err = audio_svc_insert_item(storage, path, audio_category);
+ if (err < 0) {
+ MS_DBG("mp_svc_insert_item fails error %d", err);
+ ret = MS_ERR_DB_INSERT_RECORD_FAIL;
+ }
+ MS_DBG("SOUND");
+ }
+
+ MS_DBG_END();
+ return ret;
+}
+
+int ms_check_file_exist_in_db(const char *path)
+{
+ int err;
+ int category;
+ Mitem *mi = NULL;
+
+ /*get an item based on its url. */
+ err = minfo_get_item(path, &mi);
+ if (err != MS_ERR_NONE) {
+ err = audio_svc_check_item_exist(path);
+ if (err != MS_ERR_NONE)
+ category = MS_CATEGORY_UNKNOWN;
+ else
+ category = MS_CATEGORY_MUSIC;
+ } else {
+ category = MS_CATEGORY_IMAGE;
+ }
+
+ minfo_destroy_mtype_item(mi);
+ MS_DBG("Category : %d", category);
+
+ return category;
+}
+
+int ms_media_db_delete(const char *path)
+{
+ MS_DBG_START();
+ int ret = MS_ERR_NONE;
+ int category;
+ ms_ignore_file_info *ignore_file;
+
+ category = ms_check_file_exist_in_db(path);
+
+ if (category & MS_CATEGORY_VIDEO || category & MS_CATEGORY_IMAGE) {
+ ret = minfo_delete_media(path);
+ if (ret != MS_ERR_NONE) {
+ MS_DBG("minfo_delete_media error : %d", ret);
+ return ret;
+ }
+ MS_DBG("VIDEO or IMAGE");
+ } else if (category & MS_CATEGORY_MUSIC || category & MS_CATEGORY_SOUND) {
+ ret = audio_svc_delete_item_by_path(path);
+ if (ret != MS_ERR_NONE) {
+ MS_DBG("audio_svc_delete_item_by_path error : %d", ret);
+ return ret;
+ }
+ MS_DBG("MUSIC or SOUND");
+ }
+#ifdef _WITH_DRM_SERVICE_
+ drm_svc_unregister_file(path, false);
+#endif
+
+ ignore_file = ms_inoti_find_ignore_file(path);
+ if (ignore_file != NULL)
+ ms_inoti_delete_ignore_file(ignore_file);
+
+ MS_DBG_END();
+
+ return ret;
+}
+
+void ms_media_db_move_start(void)
+{
+ audio_svc_move_item_start(MS_MOVE_COUNT);
+}
+
+void ms_media_db_move_end(void)
+{
+ audio_svc_move_item_end();
+}
+
+int
+ms_media_db_move(ms_store_type_t src_store, ms_store_type_t dst_store,
+ const char *src_path, const char *dst_path)
+{
+ MS_DBG_START();
+
+ int category = MS_CATEGORY_UNKNOWN;
+ minfo_file_type visual_category;
+ audio_svc_storage_type_e dst_storage;
+ audio_svc_storage_type_e src_storage;
+ int ret = 0;
+
+ ret = ms_get_category_from_mime(dst_path, &category);
+ if (ret != MS_ERR_NONE) {
+ MS_DBG("ms_get_category_from_mime error %d", ret);
+ return ret;
+ }
+
+ MS_DBG("category = %d", category);
+
+ if (category & MS_CATEGORY_IMAGE || category & MS_CATEGORY_VIDEO) {
+ visual_category = (category & MS_CATEGORY_IMAGE) ? MINFO_ITEM_IMAGE : MINFO_ITEM_VIDEO;
+ ret = minfo_move_media(src_path, dst_path, visual_category);
+ if (ret != MB_SVC_ERROR_NONE) {
+ MS_DBG("minfo_move_media error : %d", ret);
+ return ret;
+ }
+ MS_DBG("VISUAL");
+ } else if (category & MS_CATEGORY_MUSIC || category & MS_CATEGORY_SOUND) {
+ src_storage = (src_store == MS_MMC) ? AUDIO_SVC_STORAGE_MMC : AUDIO_SVC_STORAGE_PHONE;
+ dst_storage = (dst_store == MS_MMC) ? AUDIO_SVC_STORAGE_MMC : AUDIO_SVC_STORAGE_PHONE;
+
+ ret = audio_svc_move_item(src_storage, src_path, dst_storage, dst_path);
+ if (ret < 0) {
+ MS_DBG("mp_svc_move_item error : %d", ret);
+ if (ret == AUDIO_SVC_ERROR_DB_NO_RECORD) {
+ MS_DBG(" This is a new file, Add DB");
+ /*if source file does not exist in DB, it is new file. */
+
+ ret = ms_register_file(dst_path, NULL);
+
+ if (ret != MS_ERR_NONE) {
+ MS_DBG("ms_register_file error : %d", ret);
+ return MS_ERR_DB_INSERT_RECORD_FAIL;
+ }
+ }
+
+ return ret;
+ }
+ MS_DBG("AUDIO");
+ }
+
+ MS_DBG_END();
+
+ return ret;
+}
+
+bool ms_delete_all_record(ms_store_type_t store_type)
+{
+ MS_DBG_START();
+ int err = 0;
+ minfo_store_type visual_storage;
+ audio_svc_storage_type_e audio_storage;
+
+ visual_storage = (store_type == MS_PHONE) ? MINFO_PHONE : MINFO_MMC;
+ audio_storage = (store_type == MS_PHONE) ? AUDIO_SVC_STORAGE_PHONE : AUDIO_SVC_STORAGE_MMC;
+
+ /* To reset media db when differnet mmc is inserted. */
+ err = audio_svc_delete_all(audio_storage);
+ if (err != AUDIO_SVC_ERROR_NONE) {
+ MS_DBG("audio_svc_delete_all error : %d\n", err);
+#if 0 /*except temporary*/
+ return false;
+#endif
+ }
+
+ err = minfo_delete_invalid_media_records(visual_storage);
+ if (err != MB_SVC_ERROR_NONE) {
+ MS_DBG("minfo_delete_invalid_media_records error : %d\n", err);
+ return false;
+ }
+
+ MS_DBG_END();
+
+ return true;
+}
+#endif/*_WITH_MP_PB_*/
+
+#ifdef PROGRESS
+void ms_create_quickpanel(struct quickpanel *ms_quickpanel)
+{
+ MS_DBG_START();
+ int type_id;
+ int ret;
+
+ struct quickpanel_type *qp_type;
+
+ ret = quickpanel_get_type_id(NULL,
+ "/opt/apps/com.samsung.myfile/res/icons/default/small/com.samsung.myfile.png",
+ 0);
+ MS_DBG("return value of quickpanel_get_type_id : %d", ret);
+
+ ms_quickpanel->type = ret;
+ ms_quickpanel->priv_id = getpid();
+ ms_quickpanel->group_id = 0;
+ ms_quickpanel->title = "Media scanning";
+ ms_quickpanel->content = NULL;
+ ms_quickpanel->progress = 0;
+ ms_quickpanel->args = NULL;
+ ms_quickpanel->args_group = NULL;
+ ms_quickpanel->evt = QP_E_ONGOING;
+
+ ret = quickpanel_insert(ms_quickpanel);
+ MS_DBG("return value of quickpanel_insert : %d", ret);
+
+ MS_DBG_END();
+}
+
+void ms_update_progress(struct quickpanel *ms_quickpanel, double progress)
+{
+ MS_DBG_START();
+
+ MS_DBG("%lf", progress)
+ quickpanel_update_progress(ms_quickpanel->type,
+ ms_quickpanel->priv_id, progress);
+
+ MS_DBG_END();
+}
+
+void ms_delete_quickpanel(struct quickpanel *ms_quickpanel)
+{
+ MS_DBG_START();
+ int ret = 0;
+
+ ret = quickpanel_delete(ms_quickpanel->type, ms_quickpanel->priv_id);
+ MS_DBG("return value of quickpanel_delete : %d", ret);
+
+ MS_DBG_END();
+}
+#endif /*PROGRESS*/
+
diff --git a/common/media-server-hibernation.c b/common/media-server-hibernation.c
new file mode 100755
index 0000000..8efe944
--- /dev/null
+++ b/common/media-server-hibernation.c
@@ -0,0 +1,132 @@
+/*
+ * Media Server
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Yong Yeon Kim <yy9875.kim@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.
+ *
+ */
+
+/**
+ * This file defines api utilities of contents manager engines.
+ *
+ * @file media-server-hibernation.c
+ * @author Yong Yeon Kim(yy9875.kim@samsung.com)
+ * @version 1.0
+ * @brief This file defines api utilities of contents manager engines.
+ */
+#ifdef _USE_HIB
+
+#include <vconf.h>
+#include <heynoti.h>
+
+#include "media-server-common.h"
+#include "media-server-hibernation.h"
+#include "media-server-inotify.h"
+#include "media-server-scan.h"
+extern int hib_fd;
+extern GAsyncQueue *scan_queue;
+extern GMutex *db_mutex;
+
+void _hibernation_leave_callback(void *data)
+{
+ GThread *inoti_tid;
+ GThread *scan_tid;
+ GMainLoop *mainloop = NULL;
+
+ MS_DBG("hibernation leave callback\n");
+ MS_DBG("MEDIA SERVER START[HIB]");
+
+ if (!g_thread_supported()) {
+ g_thread_init(NULL);
+ }
+
+ if (!scan_queue)
+ scan_queue = g_async_queue_new();
+
+ /*Init db mutex variable*/
+ if (!db_mutex)
+ db_mutex = g_mutex_new();
+
+ ms_inoti_init();
+
+ inoti_tid = g_thread_create((GThreadFunc) ms_inoti_thread, NULL, FALSE, NULL);
+ scan_tid = g_thread_create((GThreadFunc) ms_scan_thread, NULL, TRUE, NULL);
+#ifdef THUMB_THREAD
+ /*create making thumbnail thread*/
+ thumb_tid = g_thread_create((GThreadFunc) ms_thumb_thread, NULL, TRUE, NULL);
+#endif
+ mainloop = g_main_loop_new(NULL, FALSE);
+
+ ms_start();
+
+ MS_DBG("*****************************************");
+ MS_DBG("*** Server of File Manager is running ***");
+ MS_DBG("*****************************************");
+
+ g_main_loop_run(mainloop);
+
+ /*free all associated memory */
+ g_main_loop_unref(mainloop);
+
+ if (scan_queue)
+ g_async_queue_unref(scan_queue);
+
+ ms_end();
+ exit(0);
+}
+
+void _hibernation_enter_callback(void *data)
+{
+
+ MS_DBG("[fm-server] hibernation enter callback\n");
+
+ /* IMPORTANT : this is for kill inotify thread
+ * it is essential for hibernation */
+ ms_scan_data_t *scan_data;
+
+ scan_data = malloc(sizeof(ms_scan_data_t));
+ scan_data->scan_type = end_thread;
+
+ g_async_queue_push(scan_queue, GINT_TO_POINTER(scan_data));
+
+ mkdir("/opt/media/_HIBERNATION_END", 0777);
+ rmdir("/opt/media/_HIBERNATION_END");
+
+ if (scan_queue)
+ g_async_queue_unref(scan_queue);
+
+ ms_end();
+
+ if (hib_fd != 0)
+ heynoti_close(hib_fd);
+}
+
+int _hibernation_initialize(void)
+{
+ hib_fd = heynoti_init();
+ heynoti_subscribe(hib_fd, "HIBERNATION_ENTER",
+ _hibernation_enter_callback, (void *)hib_fd);
+ heynoti_subscribe(hib_fd, "HIBERNATION_LEAVE",
+ _hibernation_leave_callback, (void *)hib_fd);
+ heynoti_attach_handler(hib_fd);
+ return hib_fd;
+}
+
+void _hibernation_fianalize(void)
+{
+ heynoti_close(hib_fd);
+}
+#endif
diff --git a/common/media-server-inotify-internal.c b/common/media-server-inotify-internal.c
new file mode 100755
index 0000000..78e2d74
--- /dev/null
+++ b/common/media-server-inotify-internal.c
@@ -0,0 +1,142 @@
+/*
+ * Media Server
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Yong Yeon Kim <yy9875.kim@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.
+ *
+ */
+
+/**
+ * This file defines api utilities of contents manager engines.
+ *
+ * @file media-server-inotify-internal.c
+ * @author Yong Yeon Kim(yy9875.kim@samsung.com)
+ * @version 1.0
+ * @brief23
+ */
+#include "media-server-global.h"
+#include "media-server-common.h"
+#include "media-server-inotify-internal.h"
+
+int inoti_fd;
+ms_create_file_info *latest_create_file;
+extern ms_dir_data *first_inoti_node;
+
+int _ms_inoti_add_create_file_list(int wd, char *name)
+{
+ ms_create_file_info *new_node;
+
+ new_node = malloc(sizeof(ms_create_file_info));
+ new_node->name = strdup(name);
+ new_node->wd = wd;
+
+ /*first created file */
+ if (latest_create_file == NULL) {
+ latest_create_file = malloc(sizeof(ms_create_file_info));
+ new_node->previous = NULL;
+ } else {
+ latest_create_file->next = new_node;
+ new_node->previous = latest_create_file;
+ }
+ new_node->next = NULL;
+
+ latest_create_file = new_node;
+
+ return MS_ERR_NONE;
+}
+
+int _ms_inoti_delete_create_file_list(ms_create_file_info *node)
+{
+ if (node->previous != NULL)
+ node->previous->next = node->next;
+ if (node->next != NULL)
+ node->next->previous = node->previous;
+
+ if (node == latest_create_file) {
+ latest_create_file = node->previous;
+ }
+
+ free(node->name);
+ free(node);
+
+ return MS_ERR_NONE;
+}
+
+ms_create_file_info *_ms_inoti_find_create_file_list(int wd, char *name)
+{
+ ms_create_file_info *node = NULL;
+ node = latest_create_file;
+
+ while (node != NULL) {
+ if ((node->wd == wd) && (strcmp(node->name, name) == 0)) {
+ return node;
+ }
+
+ node = node->previous;
+ }
+
+ return NULL;
+}
+
+int _fex_is_default_path(const char *path)
+{
+ int ret = false;
+
+ if ((strcmp(path, "Images and videos") == 0) ||
+ (strcmp(path, "Sounds and music") == 0) ||
+ (strcmp(path, "Downloads") == 0) ||
+ (strcmp(path, "Camera shots") == 0) ||
+ (strcmp(path, "Wallpapers") == 0) ||
+ (strcmp(path, "Music") == 0) ||
+ (strcmp(path, "Ringtones and Alerts") == 0) ||
+ (strcmp(path, "FM Radio") == 0) ||
+ (strcmp(path, "Voice recorder") == 0)) {
+ ret = true;
+ }
+
+ return ret;
+}
+
+bool _ms_inoti_get_full_path(int wd, char *name, char *path, int sizeofpath)
+{
+ int err;
+ ms_dir_data *node = NULL;
+
+ if (name == NULL || path == NULL)
+ return false;
+
+ if (first_inoti_node != NULL) {
+ node = first_inoti_node;
+ while (node->next != NULL) {
+ if (wd == node->wd) {
+ MS_DBG("find parent directory: %s", node->name);
+ break;
+ }
+ node = node->next;
+ }
+ } else {
+ MS_DBG("first_node is NULL");
+ return false;
+ }
+
+ err = ms_strappend(path, sizeofpath, "%s/%s", node->name, name);
+ if (err != MS_ERR_NONE) {
+ MS_DBG("ms_strappend error : %d", err);
+ return false;
+ }
+ MS_DBG("full path : %s", path);
+ return true;
+}
diff --git a/common/media-server-inotify.c b/common/media-server-inotify.c
new file mode 100755
index 0000000..845cfd6
--- /dev/null
+++ b/common/media-server-inotify.c
@@ -0,0 +1,707 @@
+/*
+ * Media Server
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Yong Yeon Kim <yy9875.kim@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.
+ *
+ */
+
+/**
+ * This file defines api utilities of contents manager engines.
+ *
+ * @file media-server-inotify.c
+ * @author Yong Yeon Kim(yy9875.kim@samsung.com)
+ * @version 1.0
+ * @brief
+ */
+#include "media-server-global.h"
+#include "media-server-common.h"
+#include "media-server-inotify-internal.h"
+#include "media-server-inotify.h"
+
+extern int inoti_fd;
+ms_dir_data *first_inoti_node;
+ms_ignore_file_info *latest_ignore_file;
+
+int _ms_inoti_directory_scan_and_register_file(char *dir_path)
+{
+ MS_DBG_START();
+ struct dirent ent;
+ struct dirent *res = NULL;
+ DIR *dp = NULL;
+ char path[MS_FILE_PATH_LEN_MAX] = { 0 };
+ int err;
+
+ if (dir_path == NULL)
+ return MS_ERR_INVALID_DIR_PATH;
+
+ dp = opendir(dir_path);
+ if (dp == NULL) {
+ MS_DBG("Fail to open dir");
+ return MS_ERR_DIR_OPEN_FAIL;
+ }
+
+ ms_inoti_add_watch(dir_path);
+
+ while (!readdir_r(dp, &ent, &res)) {
+ if (res == NULL)
+ break;
+
+ if (ent.d_name[0] == '.')
+ continue;
+
+ err = ms_strappend(path, sizeof(path), "%s/%s", dir_path, ent.d_name);
+ if (err != MS_ERR_NONE) {
+ MS_DBG("ms_strappend error : %d", err);
+ continue;
+ }
+
+ /*in case of directory */
+ if (ent.d_type == DT_DIR) {
+ _ms_inoti_directory_scan_and_register_file(path);
+ } else {
+
+ err = ms_register_file(path, NULL);
+ if (err != MS_ERR_NONE) {
+ MS_DBG("ms_register_file error : %d", err);
+ continue;
+ }
+ }
+ }
+
+ closedir(dp);
+
+ MS_DBG_END();
+
+ return 0;
+}
+
+int _ms_inoti_scan_renamed_folder(char *org_path, char *chg_path)
+{
+ if (org_path == NULL || chg_path == NULL) {
+ MS_DBG("Parameter is wrong");
+ return MS_ERR_ARG_INVALID;
+ }
+
+ MS_DBG_START();
+
+ int err = -1;
+ struct dirent ent;
+ struct dirent *res = NULL;
+
+ DIR *dp = NULL;
+ char path_from[MS_FILE_PATH_LEN_MAX] = { 0 };
+ char path_to[MS_FILE_PATH_LEN_MAX] = { 0 };
+ ms_store_type_t src_storage = 0;
+ ms_store_type_t des_storage = 0;
+
+ dp = opendir(chg_path);
+ if (dp == NULL) {
+ MS_DBG("Fail to open dir");
+ return MS_ERR_DIR_OPEN_FAIL;
+ } else {
+ MS_DBG("Modify added watch");
+ ms_inoti_modify_watch(org_path, chg_path);
+ }
+
+ while (!readdir_r(dp, &ent, &res)) {
+ if (res == NULL)
+ break;
+
+ if (ent.d_name[0] == '.')
+ continue;
+
+ err = ms_strappend(path_from, sizeof(path_from), "%s/%s", org_path, ent.d_name);
+ if (err != MS_ERR_NONE) {
+ MS_DBG("ms_strappend error : %d", err);
+ continue;
+ }
+
+ err = ms_strappend(path_to, sizeof(path_to), "%s/%s", chg_path, ent.d_name);
+ if (err != MS_ERR_NONE) {
+ MS_DBG("ms_strappend error : %d", err);
+ continue;
+ }
+
+ /*in case of directory */
+ if (ent.d_type == DT_DIR) {
+ _ms_inoti_scan_renamed_folder(path_from, path_to);
+ }
+
+ /*in case of file */
+ if (ent.d_type == DT_REG) {
+ src_storage = ms_get_store_type_by_full(path_from);
+ des_storage = ms_get_store_type_by_full(path_to);
+
+ if ((src_storage != MS_ERR_INVALID_FILE_PATH)
+ && (des_storage != MS_ERR_INVALID_FILE_PATH))
+ ms_media_db_move(src_storage, des_storage, path_from, path_to);
+ else {
+ MS_DBG("ms_get_store_type_by_full error");
+ }
+ }
+ }
+
+ closedir(dp);
+
+ MS_DBG_END();
+ return 0;
+}
+
+int ms_inoti_add_ignore_file(const char *path)
+{
+ ms_ignore_file_info *new_node;
+
+ new_node = malloc(sizeof(ms_ignore_file_info));
+ new_node->path = strdup(path);
+
+ /*first created file */
+ if (latest_ignore_file == NULL) {
+ latest_ignore_file = malloc(sizeof(ms_ignore_file_info));
+ new_node->previous = NULL;
+ } else {
+ latest_ignore_file->next = new_node;
+ new_node->previous = latest_ignore_file;
+ }
+ new_node->next = NULL;
+
+ latest_ignore_file = new_node;
+
+ return MS_ERR_NONE;
+}
+
+int ms_inoti_delete_ignore_file(ms_ignore_file_info * delete_node)
+{
+ MS_DBG("");
+ if (delete_node->previous != NULL)
+ delete_node->previous->next = delete_node->next;
+ if (delete_node->next != NULL)
+ delete_node->next->previous = delete_node->previous;
+
+ if (delete_node == latest_ignore_file) {
+ latest_ignore_file = delete_node->previous;
+ }
+
+ free(delete_node->path);
+ free(delete_node);
+
+ MS_DBG("");
+
+ return MS_ERR_NONE;
+}
+
+ms_ignore_file_info *ms_inoti_find_ignore_file(const char *path)
+{
+ ms_ignore_file_info *node = NULL;
+
+ node = latest_ignore_file;
+ while (node != NULL) {
+ if (strcmp(node->path, path) == 0) {
+ return node;
+ }
+
+ node = node->previous;
+ }
+
+ return NULL;
+}
+
+void ms_inoti_delete_mmc_ignore_file(void)
+{
+ MS_DBG_START();
+ ms_ignore_file_info *prv_node = NULL;
+ ms_ignore_file_info *cur_node = NULL;
+ ms_ignore_file_info *del_node = NULL;
+
+ if (latest_ignore_file != NULL) {
+ cur_node = latest_ignore_file;
+ while (cur_node != NULL) {
+ if (strstr(cur_node->path, MS_MMC_ROOT_PATH) != NULL) {
+ if (prv_node != NULL) {
+ prv_node->previous = cur_node->previous;
+ }
+
+ if (cur_node == latest_ignore_file)
+ latest_ignore_file = latest_ignore_file->previous;
+
+ del_node = cur_node;
+ } else {
+ prv_node = cur_node;
+ }
+
+ cur_node = cur_node->previous;
+
+ if (del_node != NULL) {
+ free(del_node->path);
+ free(del_node);
+ del_node = NULL;
+ }
+ }
+ }
+
+ /*active flush */
+ malloc_trim(0);
+
+ MS_DBG_END();
+}
+
+int ms_inoti_init(void)
+{
+ inoti_fd = inotify_init();
+ if (inoti_fd < 0) {
+ perror("inotify_init");
+ MS_DBG("inotify_init failed");
+ return inoti_fd;
+ }
+
+ return MS_ERR_NONE;
+}
+
+void ms_inoti_add_watch(char *path)
+{
+ MS_DBG("");
+ ms_dir_data *current_dir = NULL;
+ ms_dir_data *prv_node = NULL;
+ ms_dir_data *last_node = NULL;
+
+ /*find same folder */
+ if (first_inoti_node != NULL) {
+ MS_DBG("find same folder");
+ last_node = first_inoti_node;
+ while (last_node != NULL) {
+ if (strcmp(path, last_node->name) == 0) {
+ MS_DBG("watch is already added: %s", path);
+ return;
+ }
+ prv_node = last_node;
+ last_node = last_node->next;
+ }
+ }
+
+ MS_DBG("start add watch");
+
+ /*there is no same path. */
+ current_dir = malloc(sizeof(ms_dir_data));
+ current_dir->name = strdup(path);
+ current_dir->wd = inotify_add_watch(inoti_fd, path,
+ IN_CLOSE_WRITE | IN_CREATE | IN_DELETE |
+ IN_MOVED_FROM | IN_MOVED_TO);
+ current_dir->next = NULL;
+
+ if (first_inoti_node == NULL) {
+ first_inoti_node = current_dir;
+ } else {
+ /*if next node of current node is NULL, it is the lastest node. */
+ MS_DBG("last_node : %s", prv_node->name);
+ prv_node->next = current_dir;
+ }
+
+ MS_DBG("add watch : %s", path);
+}
+
+int ms_inoti_add_watch_with_node(ms_dir_scan_info * const node)
+{
+ char full_path[MS_FILE_PATH_LEN_MAX] = { 0 };
+ ms_dir_data *current_dir = NULL;
+ ms_dir_data *last_node = NULL;
+
+ ms_get_full_path_from_node(node, full_path);
+
+ /*find same folder */
+ if (first_inoti_node != NULL) {
+ last_node = first_inoti_node;
+ while (last_node->next != NULL) {
+ if (strcmp(full_path, last_node->name) == 0) {
+ MS_DBG("watch is already added: %s", full_path);
+ return MS_ERR_NONE;
+ }
+ last_node = last_node->next;
+ }
+ }
+
+ /*there is no same path. */
+ current_dir = malloc(sizeof(ms_dir_data));
+ current_dir->name = strdup(full_path);
+ current_dir->wd =
+ inotify_add_watch(inoti_fd, full_path,
+ IN_CLOSE_WRITE | IN_CREATE | IN_DELETE |
+ IN_MOVED_FROM | IN_MOVED_TO);
+ current_dir->next = NULL;
+ current_dir->db_updated = false;
+
+ if (first_inoti_node == NULL) {
+ first_inoti_node = current_dir;
+ } else {
+ /*if next node of current node is NULL, it is the lastest node. */
+ MS_DBG("last_node : %s", last_node->name);
+ last_node->next = current_dir;
+ }
+ MS_DBG("add watch : %s", full_path);
+
+ return MS_ERR_NONE;
+}
+
+void ms_inoti_remove_watch_recursive(char *path)
+{
+ MS_DBG_START();
+ ms_dir_data *prv_node = NULL;
+ ms_dir_data *cur_node = NULL;
+ ms_dir_data *del_node = NULL;
+
+ if (first_inoti_node != NULL) {
+ cur_node = first_inoti_node;
+ while (cur_node != NULL) {
+ if (strstr(cur_node->name, path) != NULL) {
+ if (prv_node != NULL) {
+ prv_node->next =
+ cur_node->next;
+ }
+
+ if (cur_node == first_inoti_node)
+ first_inoti_node =
+ first_inoti_node->next;
+
+ del_node = cur_node;
+ } else {
+ prv_node = cur_node;
+ }
+
+ cur_node = cur_node->next;
+
+ if (del_node != NULL) {
+ free(del_node->name);
+ free(del_node);
+ del_node = NULL;
+ }
+ }
+ }
+
+ /*active flush */
+ malloc_trim(0);
+
+ MS_DBG_END();
+}
+
+void ms_inoti_remove_watch(char *path)
+{
+ ms_dir_data *del_node = NULL;
+ ms_dir_data *prv_node = NULL;
+
+ if (strcmp(first_inoti_node->name, path) == 0) {
+ del_node = first_inoti_node;
+ first_inoti_node = first_inoti_node->next;
+ } else {
+ /*find same folder */
+ if (first_inoti_node != NULL) {
+ del_node = first_inoti_node;
+ while (del_node != NULL) {
+ MS_DBG("current node %s", del_node->name);
+ if (strcmp(path, del_node->name) == 0) {
+ MS_DBG("find delete node: %s", del_node->name);
+ if (prv_node != NULL) {
+ MS_DBG("previous_node : %s", prv_node->name);
+ prv_node->next = del_node->next;
+ }
+ /*free deleted node */
+ free(del_node->name);
+ free(del_node);
+ break;
+ }
+ prv_node = del_node;
+ del_node = del_node->next;
+ }
+ }
+ }
+
+ /*active flush */
+ malloc_trim(0);
+}
+
+void ms_inoti_modify_watch(char *path_from, char *path_to)
+{
+ ms_dir_data *mod_node;
+
+ if (strcmp(first_inoti_node->name, path_from) == 0) {
+ mod_node = first_inoti_node;
+ } else {
+ /*find same folder */
+ if (first_inoti_node != NULL) {
+ mod_node = first_inoti_node;
+ while (mod_node->next != NULL) {
+ if (strcmp(path_from, mod_node->name) == 0) {
+ MS_DBG("find change node: %s",
+ mod_node->name);
+ break;
+ }
+ mod_node = mod_node->next;
+ }
+ }
+ }
+
+ /*free previous name of node */
+ free(mod_node->name);
+ mod_node->name = NULL;
+
+ /*add new name */
+ mod_node->name = strdup(path_to);
+
+ /*active flush */
+ malloc_trim(0);
+}
+
+
+gboolean ms_inoti_thread(void *data)
+{
+ uint32_t i;
+ int length;
+ int err;
+ int prev_mask = 0;
+ int prev_wd = -1;
+ bool res;
+ char name[MS_FILE_NAME_LEN_MAX + 1] = { 0 };
+ char prev_name[MS_FILE_NAME_LEN_MAX + 1] = { 0 };
+ char buffer[INOTI_BUF_LEN] = { 0 };
+ char path[MS_FILE_PATH_LEN_MAX] = { 0 };
+ struct inotify_event *event;
+
+ MS_DBG("START INOTIFY");
+
+ err = ms_media_db_open();
+ if (err != MS_ERR_NONE) {
+ MS_DBG(" INOTIFY : sqlite3_open: ret = %d", err);
+ return false;
+ }
+
+ while (1) {
+ i = 0;
+ length = read(inoti_fd, buffer, sizeof(buffer) - 1);
+
+ if (length < 0 || length > sizeof(buffer)) { /*this is error */
+ MS_DBG("fail read");
+ perror("read");
+ continue;
+ }
+
+ while (i < length && i < INOTI_BUF_LEN) {
+ /*it's possible that ums lets reset phone data... */
+ event = (struct inotify_event *)&buffer[i];
+
+ /*stop this threadfor hibernation */
+ if (strcmp(event->name, "_HIBERNATION_END") == 0) {
+ /*db close before capture hibernatio image */
+ err = ms_media_db_close();
+ if (err != MS_ERR_NONE) {
+ MS_DBG("failed ms_media_db_close : ret = (%d)", err);
+ }
+ return false;
+ } else if(strcmp(event->name, "_FILEOPERATION_END") == 0) {
+ /*file operation is end*/
+ /* announce db is updated*/
+ ms_set_db_status(MS_DB_UPDATED);
+ rmdir("/opt/media/_FILEOPERATION_END");
+ goto NEXT_INOTI_EVENT;
+ } else if (event->name[0] == '.') {
+ /*event of hidden folder is ignored */
+ MS_DBG("Ignore : First character of event->name includes invalid character");
+ goto NEXT_INOTI_EVENT;
+ } else if (event->wd < 1) {
+ /*this is error */
+ MS_DBG("invalid wd : %d", event->wd);
+ goto NEXT_INOTI_EVENT;
+ }
+
+ /*start of one event */
+ if (event->len && (event->len <= MS_FILE_NAME_LEN_MAX)) {
+ /*Add for fixing prevent defect 2011-02-15 */
+ err = ms_strcopy(name, sizeof(name), "%s", event->name);
+ if (err != MS_ERR_NONE) {
+ MS_DBG("ms_strcopy error : %d", err);
+ goto NEXT_INOTI_EVENT;
+ }
+
+ /*get full path of file or directory */
+ res = _ms_inoti_get_full_path(event->wd, name, path, sizeof(path));
+ if (res == false) {
+ MS_DBG("_ms_inoti_get_full_path error");
+ goto NEXT_INOTI_EVENT;
+ }
+
+ MS_DBG("INOTIFY[%d : %s]", event->wd, name);
+ if (event->mask & IN_ISDIR) {
+ MS_DBG("DIRECTORY INOTIFY");
+
+ if (event->mask & IN_MOVED_FROM) {
+ MS_DBG("MOVED_FROM");
+
+ prev_mask = event->mask;
+ prev_wd = event->wd;
+
+ err = ms_strcopy(prev_name, sizeof(prev_name), "%s", event->name);
+ if (err != MS_ERR_NONE) {
+ MS_DBG("ms_strcopy fail");
+ goto NEXT_INOTI_EVENT;
+ }
+ }
+ else if (event->mask & IN_MOVED_TO) {
+ MS_DBG("MOVED_TO");
+
+ char full_path_from[MS_FILE_PATH_LEN_MAX] = { 0 };
+
+ res = _ms_inoti_get_full_path(prev_wd, prev_name, full_path_from, sizeof(full_path_from));
+ if (res == false) {
+ MS_DBG("_ms_inoti_get_full_path error");
+ goto NEXT_INOTI_EVENT;
+ }
+ /*enable bundle commit*/
+ ms_media_db_move_start();
+
+ /*need update file information under renamed directory */
+ _ms_inoti_scan_renamed_folder(full_path_from, path);
+
+ /*disable bundle commit*/
+ ms_media_db_move_end();
+
+ if (_fex_is_default_path(prev_name)) {
+ if (strstr(path, MS_PHONE_ROOT_PATH)) {
+ fex_make_default_path();
+ } else {
+ fex_make_default_path_mmc();
+ }
+ }
+ prev_mask = prev_wd = 0; /*reset */
+ }
+ else if (event->mask & IN_CREATE) {
+ MS_DBG("CREATE");
+
+ _ms_inoti_directory_scan_and_register_file(path);
+ prev_mask = event->mask;
+ }
+ else if (event->mask & IN_DELETE) {
+ MS_DBG("DELETE");
+
+ ms_inoti_remove_watch(path);
+
+ if (_fex_is_default_path(name)) {
+ if (strstr(path, MS_PHONE_ROOT_PATH)) {
+ fex_make_default_path();
+ } else {
+ fex_make_default_path_mmc();
+ }
+ }
+ }
+ }
+ else {
+ MS_DBG("FILE INOTIFY");
+
+ if (event->mask & IN_MOVED_FROM) {
+ MS_DBG("MOVED_FROM");
+
+ err = ms_media_db_delete(path);
+ if (err != MS_ERR_NONE) {
+ MS_DBG("ms_media_db_delete fail error : %d", err);
+ }
+ }
+ else if (event->mask & IN_MOVED_TO) {
+ MS_DBG("MOVED_TO");
+
+ err = ms_register_file(path, NULL);
+ if (err != MS_ERR_NONE) {
+ MS_DBG("ms_register_file error : %d", err);
+ }
+ }
+ else if (event->mask & IN_CREATE) {
+ MS_DBG("CREATE");
+
+ _ms_inoti_add_create_file_list(event->wd, name);
+ }
+ else if (event->mask & IN_DELETE) {
+ MS_DBG("DELETE");
+
+ err = ms_media_db_delete(path);
+ if (err != MS_ERR_NONE) {
+ MS_DBG("ms_media_db_delete error : %d", err);
+ }
+ }
+ else if (event->mask & IN_CLOSE_WRITE) {
+ MS_DBG("CLOSE_WRITE");
+
+ ms_create_file_info *node;
+ node = _ms_inoti_find_create_file_list (event->wd, name);
+
+ if (node != NULL || ((prev_mask & IN_ISDIR) & IN_CREATE)) {
+
+ err = ms_register_file(path, NULL);
+ if (err != MS_ERR_NONE) {
+ MS_DBG("ms_register_file error : %d", err);
+ }
+ if (node != NULL)
+ _ms_inoti_delete_create_file_list(node);
+ }
+ else {
+ /*in case of replace */
+ MS_DBG("This case is replacement or changing meta data.");
+ ms_ignore_file_info *ignore_file;
+
+ ignore_file = ms_inoti_find_ignore_file(path);
+ if (ignore_file == NULL) {
+ err = ms_media_db_delete(path);
+ if (err != MS_ERR_NONE) {
+ MS_DBG("ms_media_db_delete error : %d", err);
+ }
+ /*update = delete + regitster */
+ err = ms_register_file(path, NULL);
+ if (err != MS_ERR_NONE) {
+ MS_DBG("ms_register_file error : %d", err);
+ goto NEXT_INOTI_EVENT;
+ }
+ } else {
+ MS_DBG(" Ignore this file");
+ }
+ }
+ prev_mask = prev_wd = 0; /*reset */
+ }
+ }
+ } /*end of one event */
+ else {
+ MS_DBG("Event length is zero or over MS_FILE_NAME_LEN_MAX");
+ if (event->mask & IN_IGNORED) {
+ MS_DBG("This case is ignored");
+ }
+ }
+ NEXT_INOTI_EVENT: ;
+ i += INOTI_EVENT_SIZE + event->len;
+ }
+ /*Active flush */
+ sqlite3_release_memory(-1);
+ malloc_trim(0);
+ }
+
+ ms_inoti_remove_watch(MS_DB_UPDATE_NOTI_PATH);
+
+ ms_inoti_remove_watch_recursive(MS_PHONE_ROOT_PATH);
+ ms_inoti_remove_watch_recursive(MS_MMC_ROOT_PATH);
+
+ close(inoti_fd);
+
+ err = ms_media_db_close();
+ if (err != MS_ERR_NONE) {
+ MS_DBG("ms_media_db_close error : %d", err);
+ return false;
+ }
+ MS_DBG("Disconnect MEDIA DB");
+
+ return false;
+}
diff --git a/common/media-server-main.c b/common/media-server-main.c
new file mode 100755
index 0000000..1f15753
--- /dev/null
+++ b/common/media-server-main.c
@@ -0,0 +1,240 @@
+/*
+ * Media Server
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Yong Yeon Kim <yy9875.kim@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.
+ *
+ */
+
+/**
+ * This file defines api utilities of contents manager engines.
+ *
+ * @file media-server-mainl.c
+ * @author Yong Yeon Kim(yy9875.kim@samsung.com)
+ * @version 1.0
+ * @brief
+ */
+#include <vconf.h>
+
+#include "media-server-common.h"
+#include "media-server-hibernation.h"
+#include "media-server-inotify.h"
+#include "media-server-scan.h"
+#include "media-server-socket.h"
+#ifdef THUMB_THREAD
+#include "media-server-thumb.h"
+#endif
+
+#include <heynoti.h>
+
+#define APP_NAME "media-server"
+
+#ifdef _USE_HIB
+int hib_fd = 0;
+#endif
+extern GAsyncQueue *scan_queue;
+extern GAsyncQueue* ret_queue;
+extern GMutex *db_mutex;
+extern GMutex *list_mutex;
+extern GMutex *queue_mutex;
+extern GArray *reg_list;
+
+bool check_process(pid_t current_pid)
+{
+ MS_DBG_START();
+ DIR *pdir;
+ struct dirent pinfo;
+ struct dirent *result = NULL;
+ bool ret = false;
+ int find_pid = 0;
+
+ pdir = opendir("/proc");
+ if (pdir == NULL) {
+ MS_DBG("err: NO_DIR\n");
+ return 0;
+ }
+
+ while (!readdir_r(pdir, &pinfo, &result)) {
+ if (result == NULL)
+ break;
+
+ if (pinfo.d_type != 4 || pinfo.d_name[0] == '.'
+ || pinfo.d_name[0] > 57)
+ continue;
+
+ FILE *fp;
+ char buff[128];
+ char path[128];
+
+ ms_strcopy(path, sizeof(path), "/proc/%s/status", pinfo.d_name);
+ fp = fopen(path, "rt");
+ if (fp) {
+ fgets(buff, 128, fp);
+ fclose(fp);
+
+ if (strstr(buff, APP_NAME)) {
+ MS_DBG("pinfo->d_name : %s", pinfo.d_name);
+ find_pid = atoi(pinfo.d_name);
+ MS_DBG(" find_pid : %d", find_pid);
+ MS_DBG(" current_pid : %d", current_pid);
+ if (find_pid == current_pid)
+ ret = true;
+ else {
+ ret = false;
+ break;
+ }
+ }
+ } else {
+ MS_DBG("Can't read file [%s]", path);
+ }
+ }
+
+ closedir(pdir);
+
+ MS_DBG_END();
+
+ return ret;
+}
+
+void init_process()
+{
+
+}
+
+static bool _db_clear(void)
+ {
+ int err;
+ int db_status;
+ int usb_status;
+ bool need_db_create = false;
+
+ /*connect to media db, if conneting is failed, db updating is stopped*/
+ ms_media_db_open();
+
+ /*update just valid type*/
+ err = ms_change_valid_type(MS_MMC, false);
+ if (err != MS_ERR_NONE)
+ MS_DBG("ms_change_valid_type fail");
+
+ ms_config_get_int(VCONFKEY_FILEMANAGER_DB_STATUS, &db_status);
+ ms_config_get_int(MS_USB_MODE_KEY, &usb_status);
+
+ MS_DBG("finish_phone_init_data db = %d", db_status);
+ MS_DBG("finish_phone_init_data usb = %d", usb_status);
+
+ if (db_status == VCONFKEY_FILEMANAGER_DB_UPDATING
+ || usb_status == MS_VCONFKEY_MASS_STORAGE_MODE) {
+
+ need_db_create = true;
+
+ err = ms_change_valid_type(MS_PHONE, false);
+ if (err != MS_ERR_NONE)
+ MS_DBG("ms_change_valid_type fail");
+ }
+
+ ms_set_db_status(MS_DB_UPDATED);
+
+ /*disconnect form media db*/
+ ms_media_db_close();
+
+ return need_db_create;
+}
+
+int main(int argc, char **argv)
+{
+ GThread *inoti_tid;
+ GThread *scan_tid;
+ GThread *scoket_tid;
+
+ GMainLoop *mainloop = NULL;
+ pid_t current_pid = 0;
+ bool check_result = false;
+ int err;
+ bool need_db_create;
+
+ current_pid = getpid();
+ check_result = check_process(current_pid);
+ if (check_result == false)
+ exit(0);
+
+ if (!g_thread_supported()) {
+ g_thread_init(NULL);
+ }
+
+ /*Init db mutex variable*/
+ if (!db_mutex)
+ db_mutex = g_mutex_new();
+
+ need_db_create = _db_clear();
+
+#ifdef _USE_HIB
+ _hibernation_initialize();
+#endif
+
+ MS_DBG("MEDIA SERVER START");
+
+ if (!scan_queue)
+ scan_queue = g_async_queue_new();
+ if (!ret_queue)
+ ret_queue = g_async_queue_new();
+
+ /*Init for register file*/
+ if (!list_mutex)
+ list_mutex = g_mutex_new();
+ if (!queue_mutex)
+ queue_mutex = g_mutex_new();
+ if (!reg_list)
+ reg_list = g_array_new(TRUE, TRUE, sizeof(char*));
+
+ ms_inoti_init();
+
+ ms_inoti_add_watch(MS_DB_UPDATE_NOTI_PATH);
+
+ /*inotify setup */
+ inoti_tid = g_thread_create((GThreadFunc) ms_inoti_thread, NULL, FALSE, NULL);
+ scan_tid = g_thread_create((GThreadFunc) ms_scan_thread, NULL, TRUE, NULL);
+ scoket_tid = g_thread_create((GThreadFunc) ms_socket_thread, NULL, TRUE, NULL);
+
+ mainloop = g_main_loop_new(NULL, FALSE);
+
+ ms_start(need_db_create);
+
+ MS_DBG("*****************************************");
+ MS_DBG("*** Server of File Manager is running ***");
+ MS_DBG("*****************************************");
+
+ g_main_loop_run(mainloop);
+
+ /*free all associated memory */
+ g_main_loop_unref(mainloop);
+
+ if (scan_queue)
+ g_async_queue_unref(scan_queue);
+
+ if (ret_queue)
+ g_async_queue_unref(ret_queue);
+
+ if(reg_list)
+ g_array_free(reg_list, true);
+
+ ms_end();
+
+#ifdef _USE_HIB
+ _hibernation_fianalize();
+#endif
+
+ exit(0);
+}
diff --git a/common/media-server-scan-internal.c b/common/media-server-scan-internal.c
new file mode 100755
index 0000000..e3bfcba
--- /dev/null
+++ b/common/media-server-scan-internal.c
@@ -0,0 +1,404 @@
+/*
+ * Media Server
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Yong Yeon Kim <yy9875.kim@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.
+ *
+ */
+
+/**
+ * This file defines api utilities of contents manager engines.
+ *
+ * @file media-server-scan-internal.c
+ * @author Yong Yeon Kim(yy9875.kim@samsung.com)
+ * @version 1.0
+ * @brief
+ */
+
+#include <vconf.h>
+#include <audio-svc-error.h>
+#include <audio-svc.h>
+#include <media-svc.h>
+#include "media-server-common.h"
+#include "media-server-inotify.h"
+#include "media-server-scan-internal.h"
+
+#ifdef PROGRESS
+#include <quickpanel.h>
+#endif
+
+extern int mmc_state;
+extern int current_usb_mode;
+extern ms_dir_data *first_inoti_node;
+
+#ifdef PROGRESS
+#define SIZE_OF_PBARRAY 100
+#endif
+
+int _ms_get_path_from_current_node(int find_folder,
+ ms_dir_scan_info **current_root,
+ ms_dir_scan_info **real_root, char **path)
+{
+ MS_DBG_START();
+
+ int err = 0;
+ char get_path[FAT_FILEPATH_LEN_MAX + 1] = { 0 };
+
+ if (find_folder == 0) {
+ if ((*current_root)->Rbrother != NULL) {
+ *current_root = (*current_root)->Rbrother;
+ } else {
+ while (1) {
+ if ((*current_root)->parent == *real_root
+ || (*current_root)->parent == NULL) {
+ *current_root = NULL;
+ MS_DBG_END();
+ return 0;
+ } else if ((*current_root)->parent->Rbrother ==
+ NULL) {
+ *current_root = (*current_root)->parent;
+ } else {
+ *current_root =
+ (*current_root)->parent->Rbrother;
+ break;
+ }
+ }
+ }
+ }
+
+ err = ms_get_full_path_from_node(*current_root, get_path);
+
+ *path = strdup(get_path);
+
+ MS_DBG_END();
+
+ return err;
+}
+
+#ifdef PROGRESS
+void _ms_dir_check(char *start_path, ms_store_type_t db_type, unsigned short *file_count)
+#else
+void _ms_dir_check(char *start_path, ms_store_type_t db_type)
+#endif
+{
+ MS_DBG_START();
+
+ int err = 0;
+ int find_folder = 0;
+ char get_path[MS_FILE_PATH_LEN_MAX] = { 0 };
+ char *path;
+ DIR *dp = NULL;
+ struct dirent entry;
+ struct dirent *result;
+
+ ms_dir_scan_info *root;
+ ms_dir_scan_info *tmp_root = NULL;
+ ms_dir_scan_info *cur_node = NULL; /*current node*/
+ ms_dir_scan_info *prv_node = NULL; /*previous node*/
+ ms_dir_scan_info *next_node = NULL;
+
+ root = malloc(sizeof(ms_dir_scan_info));
+ if (root == NULL) {
+ MS_DBG("malloc fail");
+ return;
+ }
+
+ root->name = strdup(start_path);
+ if (root->name == NULL) {
+ MS_DBG("strdup fail");
+ free(root);
+ return;
+ }
+
+ root->parent = NULL;
+ root->Rbrother = NULL;
+ root->next = NULL;
+ tmp_root = root;
+ prv_node = root;
+
+ err = ms_get_full_path_from_node(tmp_root, get_path);
+ MS_DBG("full_path : %s", get_path);
+
+ path = strdup(get_path);
+ if (path == NULL) {
+ MS_DBG("strdup fail");
+ free(root);
+ return;
+ }
+
+ ms_inoti_add_watch_with_node(root);
+
+ while (1) {
+ dp = opendir(path);
+ if (dp == NULL) {
+ MS_DBG("%s folder opendir fails", path);
+ goto NEXT_DIR;
+ }
+
+ while (!readdir_r(dp, &entry, &result)) {
+ if (result == NULL)
+ break;
+
+ if (entry.d_name[0] == '.')
+ continue;
+
+ /*check usb in out*/
+ if (current_usb_mode != VCONFKEY_USB_STORAGE_STATUS_OFF
+ ||(( mmc_state != VCONFKEY_SYSMAN_MMC_MOUNTED) && (db_type == MS_MMC))) {
+
+ goto FREE_RESOURCES;
+ }
+
+ if (entry.d_type & DT_DIR) {
+ DIR *tmp_dp = NULL;
+ err = ms_strappend(get_path, sizeof(get_path), "%s/%s",path, entry.d_name);
+ if (err != MS_ERR_NONE) {
+ MS_DBG("ms_strappend error");
+ continue;
+ }
+
+ tmp_dp = opendir(get_path);
+ if (tmp_dp == NULL) {
+ MS_DBG("%s folder opendir fails", get_path);
+ continue;
+ }
+ else
+ closedir(tmp_dp);
+
+ cur_node = malloc(sizeof(ms_dir_scan_info));
+ if (cur_node == NULL) {
+ MS_DBG("malloc fail");
+
+ goto FREE_RESOURCES;
+ }
+
+ cur_node->name = strdup(entry.d_name);
+ cur_node->Rbrother = NULL;
+ cur_node->next = NULL;
+
+ /*1. 1st folder */
+ if (find_folder == 0) {
+ cur_node->parent = tmp_root;
+ tmp_root = cur_node;
+ } else {
+ cur_node->parent = tmp_root->parent;
+ prv_node->Rbrother = cur_node;
+ }
+ prv_node->next = cur_node;
+
+ /*add watch */
+ ms_inoti_add_watch_with_node(cur_node);
+
+ /*change previous */
+ prv_node = cur_node;
+ find_folder++;
+ }
+#ifdef PROGRESS
+ else if (entry.d_type & DT_REG) {
+ (*file_count)++;
+ }
+#endif
+ }
+NEXT_DIR:
+ if (dp) closedir(dp);
+ if (path) free(path);
+ dp = NULL;
+ path = NULL;
+
+ err = _ms_get_path_from_current_node(find_folder, &tmp_root, &root, &path);
+ if (err < 0)
+ break;
+
+ if (tmp_root == NULL)
+ break;
+
+ find_folder = 0;
+ }
+
+FREE_RESOURCES:
+ /*free allocated memory */
+ if (path) free(path);
+ if (dp) closedir(dp);
+
+ cur_node = root;
+ while (cur_node != NULL) {
+ next_node = cur_node->next;
+ free(cur_node->name);
+ free(cur_node);
+ cur_node = next_node;
+ }
+
+ MS_DBG_END();
+}
+
+#ifdef PROGRESS
+void _ms_dir_scan(ms_scan_data_t * scan_data, struct quickpanel *ms_quickpanel)
+#else
+void _ms_dir_scan(ms_scan_data_t * scan_data)
+#endif
+{
+ MS_DBG_START();
+ int err = 0;
+ char path[MS_FILE_PATH_LEN_MAX] = { 0 };
+ ms_dir_data *node;
+ DIR *dp = NULL;
+#ifdef PROGRESS
+ int i;
+ unsigned short file_count = 0;
+ unsigned short update_count = 0;
+ unsigned short proress_array[SIZE_OF_PBARRAY] = { 0 };
+#endif
+
+ if (scan_data->db_type == MS_PHONE)
+ err = ms_strcopy(path, sizeof(path), "%s", MS_PHONE_ROOT_PATH);
+ else
+ err = ms_strcopy(path, sizeof(path), "%s", MS_MMC_ROOT_PATH);
+
+ if (err < MS_ERR_NONE) {
+ MS_DBG("fail ms_strcopy");
+ }
+
+#ifdef PROGRESS
+ /*Add inotify watch */
+ _ms_dir_check(path, scan_data->db_type,&file_count);
+#else
+ /*Add inotify watch */
+ _ms_dir_check(path, scan_data->db_type);
+#endif
+
+#ifdef PROGRESS
+ for (i = 0; i < SIZE_OF_PBARRAY; i++) {
+ proress_array[i] = ((i + 1) * file_count) / SIZE_OF_PBARRAY;
+ if (proress_array[i] == 0)
+ proress_array[i] = 1;
+ }
+ i = 0;
+#endif
+
+ /*if scan type is not MS_SCAN_NONE, check data in db. */
+ if (scan_data->scan_type == MS_SCAN_ALL
+ || scan_data->scan_type == MS_SCAN_PART) {
+ struct dirent entry;
+ struct dirent *result = NULL;
+
+ node = first_inoti_node;
+#ifdef PROGRESS
+ int progress = 0;
+ int pre_progress = 0;
+#endif
+ if (scan_data->scan_type == MS_SCAN_PART) {
+ /*enable bundle commit*/
+ ms_update_valid_type_start();
+ }
+
+ while (node != NULL) {
+ /*check usb in out */
+ if (current_usb_mode != VCONFKEY_USB_STORAGE_STATUS_OFF
+ || ((mmc_state != VCONFKEY_SYSMAN_MMC_MOUNTED) && (scan_data->db_type == MS_MMC))) {
+ MS_DBG("Directory scanning is stopped");
+ goto STOP_SCAN;
+ }
+ if (node->db_updated != true) {
+ dp = opendir(node->name);
+ if (dp != NULL) {
+ while (!readdir_r(dp, &entry, &result)) {
+ if (result == NULL)
+ break;
+
+ if (entry.d_name[0] == '.')
+ continue;
+
+ /*check usb in out */
+ if (current_usb_mode != VCONFKEY_USB_STORAGE_STATUS_OFF
+ || ((mmc_state != VCONFKEY_SYSMAN_MMC_MOUNTED) && (scan_data->db_type == MS_MMC))) {
+ MS_DBG("Directory scanning is stopped");
+ goto STOP_SCAN;
+ }
+
+ if (entry.d_type & DT_REG) {
+ MS_DBG("THIS IS FEX_DIR_SCAN_CB");
+#ifdef PROGRESS
+ /*update progress bar */
+ update_count++;
+ if (ms_quickpanel != NULL) {
+ if (proress_array[i] == update_count) {
+ while(1) {
+ ms_update_progress(ms_quickpanel, ((double)i) / 100);
+ i++;
+ if (proress_array[i] != update_count)
+ break;
+ }
+ }
+ }
+#endif/*PROGRESS*/
+ err = ms_strappend(path, sizeof(path), "%s/%s", node->name, entry.d_name);
+ if (err < 0) {
+ MS_DBG("FAIL : ms_strappend");
+ continue;
+ }
+
+ if (scan_data->scan_type == MS_SCAN_PART)
+ err = ms_update_valid_type(path);
+ else
+ err = ms_register_scanfile(path);
+
+ if (err < 0) {
+ MS_DBG("failed to update db : %d , %d\n", err, scan_data->scan_type);
+ continue;
+ }
+ }
+ }
+ } else {
+ MS_DBG("%s folder opendir fails", node->name);
+ }
+ if (dp) closedir(dp);
+ dp = NULL;
+
+ if (node == NULL) {
+ MS_DBG("");
+ MS_DBG("DB updating is done");
+ MS_DBG("");
+ break;
+ }
+ node->db_updated = true;
+ }
+ node = node->next;
+ } /*db update while */
+
+ if (scan_data->scan_type == MS_SCAN_PART) {
+ /*disable bundle commit*/
+ ms_update_valid_type_end();
+
+ audio_svc_delete_invalid_items(scan_data->db_type);
+ minfo_delete_invalid_media_records(scan_data->db_type);
+ }
+ } else {
+ node = first_inoti_node;
+
+ while (node != NULL) {
+ node->db_updated = true;
+ node = node->next;
+ }
+ }
+STOP_SCAN:
+ if (dp) closedir(dp);
+
+ sync();
+
+ MS_DBG_END();
+
+ return;
+}
diff --git a/common/media-server-scan.c b/common/media-server-scan.c
new file mode 100755
index 0000000..ae440d5
--- /dev/null
+++ b/common/media-server-scan.c
@@ -0,0 +1,239 @@
+/*
+ * Media Server
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Yong Yeon Kim <yy9875.kim@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.
+ *
+ */
+
+/**
+ * This file defines api utilities of contents manager engines.
+ *
+ * @file media-server-scan.c
+ * @author Yong Yeon Kim(yy9875.kim@samsung.com)
+ * @version 1.0
+ * @brief
+ */
+#include <vconf.h>
+#include <minfo-types.h>
+
+#include "media-server-common.h"
+#include "media-server-thumb.h"
+#include "media-server-scan-internal.h"
+#include "media-server-scan.h"
+
+#ifdef PROGRESS
+#include <quickpanel.h>
+#endif
+
+GAsyncQueue *scan_queue;
+extern int mmc_state;
+
+#ifdef FMS_PERF
+extern struct timeval g_mmc_start_time;
+extern struct timeval g_mmc_end_time;
+#endif
+
+static void _insert_array(GArray *garray, ms_scan_data_t *insert_data)
+{
+ ms_scan_data_t *data;
+ bool insert_ok = false;
+ int len = garray->len;
+ int i;
+
+ MS_DBG("the length of array : %d", len);
+ MS_DBG("db_type : %d", insert_data->db_type);
+ MS_DBG("scan_type : %d", insert_data->scan_type);
+
+ for (i=0; i < len; i++)
+ {
+ data = g_array_index(garray, ms_scan_data_t*, i);
+
+ if (data->db_type == insert_data->db_type) {
+ if(data->scan_type > insert_data->scan_type) {
+ g_array_remove_index (garray, i);
+ g_array_insert_val(garray, i, insert_data);
+ insert_ok = true;
+ }
+ }
+ }
+
+ if (insert_ok == false)
+ g_array_append_val(garray, insert_data);
+}
+
+gboolean ms_scan_thread(void *data)
+{
+ MS_DBG_START();
+
+ ms_scan_data_t *scan_data = NULL;
+ ms_scan_data_t *insert_data;
+ GArray *garray = NULL;
+ bool res;
+ int length;
+ int err;
+
+#ifdef PROGRESS
+ struct quickpanel *ms_quickpanel = NULL;
+#endif
+
+ /*create array for processing overlay data*/
+ garray = g_array_new (FALSE, FALSE, sizeof (ms_scan_data_t *));
+ if (garray == NULL) {
+ MS_DBG("g_array_new error");
+ return false;
+ }
+
+ while (1) {
+ length = g_async_queue_length(scan_queue);
+
+ /*updating requests remain*/
+ if (garray->len != 0 && length == 0) {
+ scan_data = g_array_index(garray, ms_scan_data_t*, 0);
+ g_array_remove_index (garray, 0);
+ } else if (length != 0) {
+ insert_data = g_async_queue_pop(scan_queue);
+ _insert_array(garray, insert_data);
+ continue;
+ } else if (garray->len == 0 && length == 0) {
+ /*Threre is no request, Wait until pushung new request*/
+ insert_data = g_async_queue_pop(scan_queue);
+ _insert_array(garray, insert_data);
+ continue;
+ }
+
+ if (scan_data->scan_type == end_thread) {
+ MS_DBG("RECEIVE END THREAD");
+ free(scan_data);
+
+ if(garray) g_array_free (garray, TRUE);
+
+ return false;
+ } else if (scan_data->scan_type != MS_SCAN_VALID) {
+ /*connect to media db, if conneting is failed, db updating is stopped*/
+ err = ms_media_db_open();
+ if (err != MS_ERR_NONE)
+ continue;
+
+ /*start db updating */
+ if (scan_data->scan_type != MS_SCAN_NONE ) {
+ int status;
+
+ ms_set_db_status(MS_DB_UPDATING);
+ /*check UMS status and change configuration value*/
+ ms_config_get_int(MS_USB_MODE_KEY, &status);
+ if (status == MS_VCONFKEY_MASS_STORAGE_MODE) {
+ ms_config_get_int(VCONFKEY_USB_STORAGE_STATUS, &status);
+ if(status == VCONFKEY_USB_STORAGE_STATUS_OFF) {
+ ms_config_set_int(MS_USB_MODE_KEY, MS_VCONFKEY_NORMAL_MODE);
+ }
+ }
+#ifdef PROGRESS
+ ms_quickpanel = malloc(sizeof(struct quickpanel));
+ ms_create_quickpanel(ms_quickpanel);
+#endif /*PROGRESS*/
+ }
+
+ if (scan_data->scan_type == MS_SCAN_ALL) {
+ res = ms_delete_all_record(scan_data->db_type);
+ if (res != true) {
+ MS_DBG("ms_delete_all_record fails");
+ }
+ }
+
+#ifdef FMS_PERF
+ if (scan_data->db_type == MS_MMC) {
+ ms_check_start_time(&g_mmc_start_time);
+ }
+#endif
+ /*call for bundle commit*/
+ ms_register_start();
+
+#ifdef PROGRESS
+ /*add inotify watch and insert data into media db */
+ _ms_dir_scan(scan_data, ms_quickpanel);
+
+ if (ms_quickpanel != NULL) {
+ ms_delete_quickpanel(ms_quickpanel);
+ free(ms_quickpanel);
+ ms_quickpanel = NULL;
+ }
+#else
+ /*add inotify watch and insert data into media db */
+ _ms_dir_scan(scan_data);
+#endif
+ /*call for bundle commit*/
+ ms_register_end();
+
+#ifdef FMS_PERF
+ if (scan_data->db_type == MS_MMC) {
+ ms_check_end_time(&g_mmc_end_time);
+ ms_check_time_diff(&g_mmc_start_time, &g_mmc_end_time);
+ }
+#endif
+
+ /*set vconf key mmc loading for indicator */
+ if (scan_data->scan_type != MS_SCAN_NONE )
+ ms_set_db_status(MS_DB_UPDATED);
+
+ /*disconnect form media db*/
+ ms_media_db_close();
+#ifdef THUMB_THREAD
+ /*create making thumbnail thread*/
+ if (scan_data->scan_type == MS_SCAN_ALL) {
+ minfo_folder_type db;
+ if(scan_data->db_type == MS_PHONE)
+ db = MINFO_CLUSTER_TYPE_LOCAL_PHONE;
+ else
+ db = MINFO_CLUSTER_TYPE_LOCAL_MMC;
+ g_thread_create((GThreadFunc) ms_thumb_thread, &db, TRUE, NULL);
+ }
+#endif
+ /*Active flush */
+ sqlite3_release_memory(-1);
+
+ if (scan_data->db_type == MS_MMC) {
+ ms_update_mmc_info();
+ }
+ } else {
+ /*connect to media db, if conneting is failed, db updating is stopped*/
+ err = ms_media_db_open();
+ if (err != MS_ERR_NONE)
+ continue;
+
+ /*update just valid type*/
+ err = ms_change_valid_type(scan_data->db_type, false);
+ if (err != MS_ERR_NONE)
+ MS_DBG("ms_change_valid_type fail");
+
+ ms_set_db_status(MS_DB_UPDATED);
+
+ /*disconnect form media db*/
+ ms_media_db_close();
+
+ /*Active flush */
+ sqlite3_release_memory(-1);
+ }
+
+ free(scan_data);
+ } /*thread while*/
+
+ if(garray) g_array_free (garray, TRUE);
+
+ MS_DBG_END();
+
+ return true;
+}
diff --git a/common/media-server-socket.c b/common/media-server-socket.c
new file mode 100755
index 0000000..bda3145
--- /dev/null
+++ b/common/media-server-socket.c
@@ -0,0 +1,147 @@
+/*
+ * Media Server
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Yong Yeon Kim <yy9875.kim@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.
+ *
+ */
+
+/**
+ * This file defines api utilities of contents manager engines.
+ *
+ * @file media-server-thumb.c
+ * @author Yong Yeon Kim(yy9875.kim@samsung.com)
+ * @version 1.0
+ * @brief
+ */
+#include <arpa/inet.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <media-util-err.h>
+#include <media-info.h>
+
+#include "media-server-global.h"
+#include "media-server-common.h"
+#include "media-server-socket.h"
+
+#define MINFO_REGISTER_PORT 1001
+
+GAsyncQueue* ret_queue;
+
+gboolean ms_socket_thread(void *data)
+{
+ int ret;
+ int err;
+ int state;
+ int sockfd;
+ int send_msg = MEDIA_INFO_ERROR_NONE;
+ int client_addr_size;
+
+ struct sockaddr_in server_addr;
+ struct sockaddr_in client_addr;
+
+ char recv_buff[MS_FILE_PATH_LEN_MAX];
+
+ sockfd = socket(PF_INET, SOCK_DGRAM, 0);
+
+ if(sockfd < 0)
+ {
+ MS_DBG("socket create error");
+ perror("socket error : ");
+ return MS_ERR_SOCKET_CONN;
+ }
+
+ memset(&server_addr, 0, sizeof(server_addr));
+ server_addr.sin_family = AF_INET;
+ server_addr.sin_port = htons(MINFO_REGISTER_PORT);
+ server_addr.sin_addr.s_addr = htonl(INADDR_ANY);
+
+ state = bind(sockfd, (struct sockaddr*)&server_addr, sizeof(server_addr));
+ if(state < 0)
+ {
+ MS_DBG("bind error");
+ perror("bind error : ");
+ return MS_ERR_SOCKET_BIND;
+ }
+
+ err = ms_media_db_open();
+ if (err != MS_ERR_NONE) {
+ MS_DBG("SOCKET : sqlite3_open: ret = %d", err);
+ return false;
+ }
+
+ while(1)
+ {
+ client_addr_size = sizeof(client_addr);
+ err = recvfrom(sockfd, recv_buff, sizeof(recv_buff), 0 ,
+ (struct sockaddr*)&client_addr, (socklen_t *)&client_addr_size);
+ if(err < 0){
+ MS_DBG("recvfrom error :%d", errno);
+ perror("recvfrom error : ");
+ goto NEXT;
+ } else {
+ MS_DBG("receive: %s\n", recv_buff);
+ }
+
+ ret = ms_register_file(recv_buff, ret_queue);
+ if (ret == MS_ERR_NOW_REGISTER_FILE) {
+ MS_DBG("WAIT");
+ ret= GPOINTER_TO_INT(g_async_queue_pop(ret_queue)) - MS_ERR_MAX;
+ MS_DBG("RECEIVE REPLAY");
+ }
+
+ if (ret != MS_ERR_NONE) {
+ MS_DBG("ms_register_file error : %d", ret);
+
+ if(ret == MS_ERR_ARG_INVALID) {
+ send_msg = MS_MEDIA_ERR_INVALID_PARAMETER;
+ } else if (ret == MS_ERR_NOT_MEDIA_FILE) {
+ send_msg = MS_MEDIA_ERR_INVALID_MEDIA;
+ } else if (ret == MS_ERR_DB_INSERT_RECORD_FAIL) {
+ send_msg = MS_MEDIA_ERR_INSERT_FAIL;
+ } else if (ret == MS_ERR_DRM_REGISTER_FAIL) {
+ send_msg = MS_MEDIA_ERR_DRM_INSERT_FAIL;
+ }
+ } else {
+ MS_DBG("SOCKET INSERT SECCESS");
+ send_msg = MS_MEDIA_ERR_NONE;
+ }
+
+ err = sendto(sockfd, &send_msg, sizeof(send_msg), 0,
+ (struct sockaddr*)&client_addr, sizeof(client_addr));
+ if(err < 0){
+ MS_DBG("SOCKET SEND FAIL :%d", errno);
+ perror("send error : ");
+ } else {
+ MS_DBG("SOCKET SEND SUCCESS");
+ }
+NEXT:
+ memset(recv_buff, 0, MS_FILE_PATH_LEN_MAX);
+ }
+
+ close(sockfd);
+ MS_DBG("END SOCKET THREAD");
+
+ err = ms_media_db_close();
+ if (err != MS_ERR_NONE) {
+ MS_DBG("ms_media_db_close error : %d", err);
+ return false;
+ }
+ MS_DBG("Disconnect MEDIA DB");
+
+ return 0;
+}
+
diff --git a/common/media-server-thumb.c b/common/media-server-thumb.c
new file mode 100755
index 0000000..e2eeaad
--- /dev/null
+++ b/common/media-server-thumb.c
@@ -0,0 +1,108 @@
+/*
+ * Media Server
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Yong Yeon Kim <yy9875.kim@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.
+ *
+ */
+
+/**
+ * This file defines api utilities of contents manager engines.
+ *
+ * @file media-server-thumb.c
+ * @author Yong Yeon Kim(yy9875.kim@samsung.com)
+ * @version 1.0
+ * @brief
+ */
+#include <media-svc.h>
+#include <media-thumbnail.h>
+#include <vconf.h>
+
+#include "media-server-common.h"
+#include "media-server-thumb.h"
+
+#ifdef THUMB_THREAD
+extern int mmc_state;
+extern int current_usb_mode;
+
+static int _ite_fn(Mitem * item, void *user_data)
+{
+ GList **list = (GList **) user_data;
+ *list = g_list_append(*list, item);
+
+ return 0;
+}
+
+gboolean ms_thumb_thread(void *data)
+{
+ int err = -1;
+ int i = 0;
+ Mitem *mitem = NULL;
+ GList *p_list = NULL;
+ minfo_item_filter item_filter;
+ char thumb_path[1024];
+
+ memset(&item_filter, 0x00, sizeof(minfo_item_filter));
+
+ item_filter.file_type = MINFO_ITEM_ALL;
+ item_filter.sort_type = MINFO_MEDIA_SORT_BY_DATE_ASC;
+ item_filter.start_pos = -1;
+ item_filter.end_pos = -1;
+ item_filter.with_meta = FALSE;
+ item_filter.favorite = MINFO_MEDIA_FAV_ALL;
+
+ ms_media_db_open();
+
+ MS_DBG("data : %d", *(minfo_folder_type*)data);
+
+ err = minfo_get_all_item_list(*(minfo_folder_type*)data, item_filter, _ite_fn, &p_list);
+ if (err < 0) {
+ MS_DBG("minfo_get_all_item_list error : %d", err);
+ return err;
+ }
+
+ for (i = 0; i < g_list_length(p_list); i++) {
+ //check usb in out
+ if (current_usb_mode != VCONFKEY_USB_STORAGE_STATUS_OFF
+ || ((mmc_state != VCONFKEY_SYSMAN_MMC_MOUNTED) && (*(minfo_folder_type*)data == MINFO_CLUSTER_TYPE_LOCAL_MMC))) {
+ MS_DBG("BREAK");
+ break;
+ }
+ mitem = (Mitem *) g_list_nth_data(p_list, i);
+
+ if (mitem) {
+ MS_DBG("Start to extracting thumbnails [%s] ( %s )", mitem->uuid, mitem->file_url);
+ err = minfo_extract_thumbnail(mitem->uuid, mitem->type);
+ if (err < 0) {
+ MS_DBG("thumbnail_request_from_db falied: %d", err);
+ } else {
+ MS_DBG("thumbnail_request_from_db success: %s", thumb_path);
+ }
+
+ minfo_destroy_mtype_item(mitem);
+ } else {
+ MS_DBG("mitem[%d] is NULL", i);
+ }
+ }
+
+ ms_media_db_close();
+
+ if (p_list != NULL) {
+ g_list_free(p_list);
+ p_list = NULL;
+ }
+}
+#endif
diff --git a/config.in b/config.in
new file mode 100644
index 0000000..e4e5149
--- /dev/null
+++ b/config.in
@@ -0,0 +1,161 @@
+/* config.in. Generated from configure.ac by autoheader. */
+
+/* Define to 1 if the `closedir' function returns void instead of `int'. */
+#undef CLOSEDIR_VOID
+
+/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
+ */
+#undef HAVE_DIRENT_H
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#undef HAVE_DLFCN_H
+
+/* Define to 1 if you have the <fcntl.h> header file. */
+#undef HAVE_FCNTL_H
+
+/* Define to 1 if you have the `fork' function. */
+#undef HAVE_FORK
+
+/* Define to 1 if you have the `gettimeofday' function. */
+#undef HAVE_GETTIMEOFDAY
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#undef HAVE_INTTYPES_H
+
+/* Define to 1 if `lstat' has the bug that it succeeds when given the
+ zero-length file name argument. */
+#undef HAVE_LSTAT_EMPTY_STRING_BUG
+
+/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
+ to 0 otherwise. */
+#undef HAVE_MALLOC
+
+/* Define to 1 if you have the <memory.h> header file. */
+#undef HAVE_MEMORY_H
+
+/* Define to 1 if you have the `memset' function. */
+#undef HAVE_MEMSET
+
+/* Define to 1 if you have the `mkdir' function. */
+#undef HAVE_MKDIR
+
+/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
+#undef HAVE_NDIR_H
+
+/* Define to 1 if stdbool.h conforms to C99. */
+#undef HAVE_STDBOOL_H
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#undef HAVE_STDINT_H
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#undef HAVE_STDLIB_H
+
+/* Define to 1 if you have the `strcasecmp' function. */
+#undef HAVE_STRCASECMP
+
+/* Define to 1 if you have the <strings.h> header file. */
+#undef HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#undef HAVE_STRING_H
+
+/* Define to 1 if you have the `strstr' function. */
+#undef HAVE_STRSTR
+
+/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
+ */
+#undef HAVE_SYS_DIR_H
+
+/* Define to 1 if you have the <sys/file.h> header file. */
+#undef HAVE_SYS_FILE_H
+
+/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
+ */
+#undef HAVE_SYS_NDIR_H
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#undef HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#undef HAVE_SYS_TYPES_H
+
+/* Define to 1 if you have the <sys/vfs.h> header file. */
+#undef HAVE_SYS_VFS_H
+
+/* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */
+#undef HAVE_SYS_WAIT_H
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* Define to 1 if you have the `vfork' function. */
+#undef HAVE_VFORK
+
+/* Define to 1 if you have the <vfork.h> header file. */
+#undef HAVE_VFORK_H
+
+/* Define to 1 if `fork' works. */
+#undef HAVE_WORKING_FORK
+
+/* Define to 1 if `vfork' works. */
+#undef HAVE_WORKING_VFORK
+
+/* Define to 1 if the system has the type `_Bool'. */
+#undef HAVE__BOOL
+
+/* Define to 1 if `lstat' dereferences a symlink specified with a trailing
+ slash. */
+#undef LSTAT_FOLLOWS_SLASHED_SYMLINK
+
+/* Define to the sub-directory in which libtool stores uninstalled libraries.
+ */
+#undef LT_OBJDIR
+
+/* Name of package */
+#undef PACKAGE
+
+/* Define to the address where bug reports for this package should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#undef PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#undef PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#undef PACKAGE_TARNAME
+
+/* Define to the home page for this package. */
+#undef PACKAGE_URL
+
+/* Define to the version of this package. */
+#undef PACKAGE_VERSION
+
+/* Define to 1 if you have the ANSI C header files. */
+#undef STDC_HEADERS
+
+/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
+#undef TIME_WITH_SYS_TIME
+
+/* Define to 1 if your <sys/time.h> declares `struct tm'. */
+#undef TM_IN_SYS_TIME
+
+/* Version number of package */
+#undef VERSION
+
+/* Define to empty if `const' does not conform to ANSI C. */
+#undef const
+
+/* Define to rpl_malloc if the replacement function should be used. */
+#undef malloc
+
+/* Define to `int' if <sys/types.h> does not define. */
+#undef pid_t
+
+/* Define to `unsigned int' if <sys/types.h> does not define. */
+#undef size_t
+
+/* Define as `fork' if `vfork' does not work. */
+#undef vfork
diff --git a/configure.ac b/configure.ac
new file mode 100755
index 0000000..1b9ba34
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,138 @@
+# -*- Autoconf -*-
+# Process this file with autoconf to produce a configure script.
+
+AC_PREREQ(2.61)
+AC_INIT([media-server], [1.0])
+AC_CONFIG_AUX_DIR([build-aux])
+AC_CONFIG_HEADERS([config.h:config.in])
+
+AM_INIT_AUTOMAKE([-Wall -Werror foreign])
+
+# for platform setting
+AC_CONFIG_MACRO_DIR([m4])
+
+# Checks for programs.
+AC_PROG_CC
+AC_PROG_INSTALL
+AC_PROG_MAKE_SET
+AC_PROG_LIBTOOL
+
+# Check target
+if ! (test "x$ARCH" = "xarmel" -o "x$ARCH" = "xi386"); then
+ echo "$ARCH"
+# ARCH=ARM
+fi
+
+#if test "x$MACHINE" = "xfloater"; then
+ CPPFLAGS="$CPPFLAGS -D _FM_GENERIC_ -D EXPORT_API=\"__attribute__((visibility(\\\"default\\\")))\""
+ echo ""
+ echo $CPPFLAGS
+ echo "### check point ###"
+ echo ""
+#fi
+
+CPPFLAGS="${CPPFLAGS} -DRND_LINUX"
+
+# FMS_DEBUG - File Manager Service debug options
+# To open debug options:
+# export FMS_DEBUG=1 or configure --enable-debug
+AC_ARG_ENABLE([debug],
+ [AS_HELP_STRING([--enable-debug], [Enable debug options])],
+ [case "x$enableval" in
+ xyes) debug=true;;
+ xno) debug=false;;
+ *) AC_MSG_ERROR([Bad value %enableval for --enable-debug]);;
+ esac],
+ [debug=false])
+if test "x$debug" = "xtrue" -o "x$FMS_DEBUG" = "x1"; then
+ FMS_DEBUG_FLAGS="-D FEXPLORER_DEBUG -g"
+else
+ FMS_DEBUG_FLAGS=""
+fi
+AC_SUBST(FMS_DEBUG_FLAGS)
+
+# Checks for libraries.
+PKG_CHECK_MODULES(GTHREAD, gthread-2.0)
+AC_SUBST(GTHREAD_CFLAGS)
+AC_SUBST(GTHREAD_LIBS)
+
+PKG_CHECK_MODULES(GLIB, glib-2.0)
+AC_SUBST(GLIB_CFLAGS)
+AC_SUBST(GLIB_LIBS)
+
+PKG_CHECK_MODULES(DLOG, dlog)
+AC_SUBST(DLOG_CFLAGS)
+AC_SUBST(DLOG_LIBS)
+
+PKG_CHECK_MODULES(DB_UTIL, db-util)
+AC_SUBST(DB_UTIL_CFLAGS)
+AC_SUBST(DB_UTIL_LIBS)
+
+PKG_CHECK_MODULES(DRM_SERVICE, drm-service)
+AC_SUBST(DRM_SERVICE_CFLAGS)
+AC_SUBST(DRM_SERVICE_LIBS)
+
+PKG_CHECK_MODULES(PHONESTATUS, vconf)
+AC_SUBST(PHONESTATUS_CFLAGS)
+AC_SUBST(PHONESTATUS_LIBS)
+
+PKG_CHECK_MODULES(UTIL, heynoti)
+AC_SUBST(UTIL_CFLAGS)
+AC_SUBST(UTIL_LIBS)
+
+PKG_CHECK_MODULES(MM_FILEINFO, mm-fileinfo)
+AC_SUBST(MM_FILEINFO_CFLAGS)
+AC_SUBST(MM_FILEINFO_LIBS)
+
+PKG_CHECK_MODULES(MEDIA_INFO, libmedia-service)
+AC_SUBST(MEDIA_INFO_CFLAGS)
+AC_SUBST(MEDIA_INFO_LIBS)
+
+PKG_CHECK_MODULES(AUL, aul)
+AC_SUBST(AUL_CFLAGS)
+AC_SUBST(AUL_LIBS)
+
+PKG_CHECK_MODULES(DBUS, dbus-1)
+AC_SUBST(DBUS_CFLAGS)
+AC_SUBST(DBUS_LIBS)
+
+# pm, replace libpmcontrol
+PKG_CHECK_MODULES(LIBPMCONTROL, pmapi)
+AC_SUBST(LIBPMCONTROL_CFLAGS)
+AC_SUBST(LIBPMCONTROL_LIBS)
+
+# quickpanel library
+#PKG_CHECK_MODULES(LIBQUICKPANEL, quickpanel)
+#AC_SUBST(LIBQUICKPANEL_CFLAGS)
+#AC_SUBST(LIBQUICKPANEL_LIBS)
+
+# thumb-gen library
+PKG_CHECK_MODULES(THUMB_GEN, media-thumbnail)
+AC_SUBST(THUMB_GEN_CFLAGS)
+AC_SUBST(THUMB_GEN_LIBS)
+
+#Checks for header files.
+AC_HEADER_DIRENT
+AC_HEADER_STDC
+AC_HEADER_SYS_WAIT
+AC_CHECK_HEADERS([fcntl.h stdlib.h string.h sys/file.h sys/vfs.h unistd.h])
+
+# Checks for typedefs, structures, and compiler characteristics.
+AC_HEADER_STDBOOL
+AC_C_CONST
+AC_TYPE_SIZE_T
+AC_HEADER_TIME
+AC_STRUCT_TM
+
+# Checks for library functions.
+AC_FUNC_CLOSEDIR_VOID
+AC_FUNC_FORK
+AC_FUNC_LSTAT
+AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
+AC_FUNC_MALLOC
+AC_CHECK_FUNCS([gettimeofday memset mkdir strcasecmp strstr])
+
+AC_CONFIG_FILES([Makefile
+ libmedia-utils.pc
+ ])
+AC_OUTPUT
diff --git a/data/mediasvr b/data/mediasvr
new file mode 100755
index 0000000..d109017
--- /dev/null
+++ b/data/mediasvr
@@ -0,0 +1,3 @@
+#!/bin/sh
+/usr/bin/media-server&
+
diff --git a/debian/changelog b/debian/changelog
new file mode 100755
index 0000000..6a1cf0b
--- /dev/null
+++ b/debian/changelog
@@ -0,0 +1,7 @@
+media-server (0.1.51) unstable; urgency=low
+
+ * Initial debinization edition.
+ * Git : pkgs/m/media-server
+ * Tag : media-server_0.1.51
+
+ -- Yong Yeon Kim <yy9875.kim@samsung.com> Wed, 07 Dec 2011 12:33:12 +0800
diff --git a/debian/compat b/debian/compat
new file mode 100644
index 0000000..7ed6ff8
--- /dev/null
+++ b/debian/compat
@@ -0,0 +1 @@
+5
diff --git a/debian/control b/debian/control
new file mode 100755
index 0000000..6ca4c50
--- /dev/null
+++ b/debian/control
@@ -0,0 +1,43 @@
+Source: media-server
+Section: misc
+Priority: extra
+Maintainer: Yong Yeon Kim <yy9875.kim@samsung.com>, Byungwook Jang <bw.jang@samsung.com>
+Uploaders:
+Build-Depends: debhelper (>= 5), autotools-dev,
+ libglib2.0-dev,
+ libslp-setting-dev,
+ libheynoti-dev,
+ libmedia-service-dev,
+ dlog-dev,
+ drm-service-dev,
+ libslp-db-util-dev,
+ libmm-fileinfo-dev,
+ libaul-1-dev,
+ libslp-pm-dev,
+ libmedia-thumbnail-dev
+Standards-Version: 0.1.0
+
+Package: media-server
+Section: utils
+Architecture: any
+Depends: ${misc:Depends}
+Description: multimedia contents managing server.
+
+Package: media-server-dbg
+Section: debug
+Architecture: any
+Depends: ${misc:Depends}, libmedia-utils (= ${Source-Version})
+Description: media-server and libmedia-utils debug pkg.
+
+Package: libmedia-utils
+Section: libs
+Architecture: any
+Depends:
+Description: media utils runtime library.
+
+Package: libmedia-utils-dev
+Section: devel
+Architecture: any
+Depends: libmedia-utils (= ${Source-Version})
+Description: media utils development library.
+
diff --git a/debian/copyright b/debian/copyright
new file mode 100644
index 0000000..4ec25ed
--- /dev/null
+++ b/debian/copyright
@@ -0,0 +1,14 @@
+Copyright (c) 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.
+
diff --git a/debian/libmedia-utils-dev.install.in b/debian/libmedia-utils-dev.install.in
new file mode 100755
index 0000000..d1d8077
--- /dev/null
+++ b/debian/libmedia-utils-dev.install.in
@@ -0,0 +1,2 @@
+@PREFIX@/lib/pkgconfig/libmedia-utils.pc
+@PREFIX@/include/media-utils/*
diff --git a/debian/libmedia-utils.install.in b/debian/libmedia-utils.install.in
new file mode 100755
index 0000000..f700d1c
--- /dev/null
+++ b/debian/libmedia-utils.install.in
@@ -0,0 +1 @@
+@PREFIX@/lib/libmedia-utils.*
diff --git a/debian/libmedia-utils.postinst.in b/debian/libmedia-utils.postinst.in
new file mode 100755
index 0000000..1a24852
--- /dev/null
+++ b/debian/libmedia-utils.postinst.in
@@ -0,0 +1 @@
+#!/bin/sh
diff --git a/debian/media-server.install.in b/debian/media-server.install.in
new file mode 100644
index 0000000..fabd1aa
--- /dev/null
+++ b/debian/media-server.install.in
@@ -0,0 +1,4 @@
+@PREFIX@/bin/*
+/etc/rc.d/init.d/mediasvr
+/etc/rc.d/rc3.d/S48mediasvr
+/etc/rc.d/rc5.d/S48mediasvr
diff --git a/debian/media-server.postinst.in b/debian/media-server.postinst.in
new file mode 100755
index 0000000..78f538c
--- /dev/null
+++ b/debian/media-server.postinst.in
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+####################################################################
+
+
+vconftool set -t int db/filemanager/dbupdate "1"
+vconftool set -t int memory/filemanager/Mmc "0" -i
+
+vconftool set -t int db/Apps/mediaserver/usbmode "0"
+vconftool set -t string db/Apps/mediaserver/mmc_info ""
+
diff --git a/debian/prerm.in b/debian/prerm.in
new file mode 100755
index 0000000..a0df112
--- /dev/null
+++ b/debian/prerm.in
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+#set -e
+
+#PATH=$PATH:${prefix}/bin
+
+#unregister_noti_info User.FileManager.UpdateDB
+#unregister_noti_info User.FileManager.SetOpenedFile
+#unregister_noti_info User.FileManager.GetOpenedFile
+
+#. /etc/ipkg/functions
+
+#installer.sh uninstall 1016 -t ${arch_type}
+#installer.sh uninstall com.samsung.filemanager-service -t ${arch_type}
diff --git a/debian/rules b/debian/rules
new file mode 100755
index 0000000..7272284
--- /dev/null
+++ b/debian/rules
@@ -0,0 +1,125 @@
+#!/usr/bin/make -f
+# -*- makefile -*-
+# Sample debian/rules that uses debhelper.
+# This file was originally written by Joey Hess and Craig Small.
+# As a special exception, when this file is copied by dh-make into a
+# dh-make output file, you may use that output file without restriction.
+# This special exception was added by Craig Small in version 0.37 of dh-make.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+
+# These are used for cross-compiling and for saving the configure script
+# from having to guess our platform (since we know it already)
+DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
+DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
+
+CFLAGS ?=
+LDFLAGS ?=
+PREFIX ?= /usr
+DATADIR ?= /opt
+
+CFLAGS += -Wall -g -fPIC
+
+ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
+ CFLAGS += -O0
+else
+ CFLAGS += -O2
+endif
+
+LDFLAGS += -Wl,--rpath=$(PREFIX)/lib -Wl,--hash-style=both -Wl,--as-needed
+
+configure: configure.ac
+ ./autogen.sh
+
+config.status: configure
+ dh_testdir
+ # Add here commands to configure the package.
+ CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" ./configure --prefix=$(PREFIX)
+
+build: build-stamp
+
+build-stamp: config.status
+ dh_testdir
+
+ # Add here commands to compile the package.
+ $(MAKE)
+ #docbook-to-man debian/ncurses.sgml > ncurses.1
+
+ for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
+ cat $$f > $${f%.in}; \
+ sed -i -e "s#@PREFIX@#$(PREFIX)#g" $${f%.in}; \
+ sed -i -e "s#@DATADIR@#$(DATADIR)#g" $${f%.in}; \
+ done
+
+ touch $@
+
+clean:
+ dh_testdir
+ dh_testroot
+ rm -f build-stamp
+
+ # Add here commands to clean up after the build process.
+ -$(MAKE) distclean
+ifneq "$(wildcard /usr/share/misc/config.sub)" ""
+ cp -f /usr/share/misc/config.sub config.sub
+endif
+ifneq "$(wildcard /usr/share/misc/config.guess)" ""
+ cp -f /usr/share/misc/config.guess config.guess
+endif
+
+ for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
+ rm -f $${f%.in}; \
+ done
+
+ dh_clean
+
+install: build
+ dh_testdir
+ dh_testroot
+ dh_clean -k
+ dh_installdirs
+
+ # Add here commands to install the package into debian/ncurses.
+ $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
+ chmod 700 $(CURDIR)/debian/tmp/etc/rc.d/init.d/mediasvr
+
+
+# Build architecture-independent files here.
+binary-indep: build install
+# We have nothing to do by default.
+
+# Build architecture-dependent files here.
+binary-arch: build install
+ dh_testdir
+ dh_testroot
+ dh_installchangelogs
+ dh_installdocs
+ dh_installexamples
+ dh_install --sourcedir=debian/tmp
+# dh_installmenu
+# dh_installdebconf
+# dh_installlogrotate
+# dh_installemacsen
+# dh_installpam
+# dh_installmime
+# dh_python
+# dh_installinit
+# dh_installcron
+# dh_installinfo
+ dh_installman
+ dh_link
+ dh_strip --dbg-package=media-server-dbg
+ dh_compress
+ dh_fixperms
+# dh_perl
+ dh_makeshlibs
+ dh_installdeb
+ dh_shlibdeps
+ dh_gencontrol
+ dh_md5sums
+ dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install
diff --git a/lib/include/media-util-dbg.h b/lib/include/media-util-dbg.h
new file mode 100755
index 0000000..10b72b9
--- /dev/null
+++ b/lib/include/media-util-dbg.h
@@ -0,0 +1,45 @@
+/*
+ * Media Utility
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Yong Yeon Kim <yy9875.kim@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.
+ *
+ */
+
+/**
+ * This file defines api utilities of contents manager engines.
+ *
+ * @file media-util-dbg.h
+ * @author Yong Yeon Kim(yy9875.kim@samsung.com)
+ * @version 1.0
+ * @brief
+ */
+#ifndef _MEDIA_UTIL_DBG_H_
+#define _MEDIA_UTIL_DBG_H_
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "MEDIA-UTIL"
+
+#define MSAPI_DBG(fmt, arg...) LOGD("[%s : %d] [%s] " fmt "\n", __FILE__, __LINE__, __FUNCTION__, ##arg)
+
+#endif /*_MEDIA_UTIL_DBG_H_*/
diff --git a/lib/include/media-util-err.h b/lib/include/media-util-err.h
new file mode 100755
index 0000000..f658582
--- /dev/null
+++ b/lib/include/media-util-err.h
@@ -0,0 +1,53 @@
+/*
+ * Media Utility
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Yong Yeon Kim <yy9875.kim@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.
+ *
+ */
+
+/**
+ * This file defines api utilities of contents manager engines.
+ *
+ * @file media-util-err.h
+ * @author Yong Yeon Kim(yy9875.kim@samsung.com)
+ * @version 1.0
+ * @brief
+ */
+#ifndef _MEDIA_UTIL_ERR_H_
+#define _MEDIA_UTIL_ERR_H_
+
+#define MS_ERROR_MASKL16 0xFFFF
+#define MS_ERROR(X) (X & MS_ERROR_MASKL16)
+
+#define MS_MEDIA_ERR_NONE 0
+#define MS_MEDIA_ERR_OCCURRED (MS_MEDIA_ERR_NONE - MS_ERROR(0x01))
+#define MS_MEDIA_ERR_INVALID_PARAMETER (MS_MEDIA_ERR_NONE - MS_ERROR(0x01)) /**< invalid parameter(s) */
+#define MS_MEDIA_ERR_INVALID_PATH (MS_MEDIA_ERR_NONE - MS_ERROR(0x02)) /**< Invalid file path */
+
+#define MS_MEDIA_ERR_SOCKET_CONN (MS_MEDIA_ERR_NONE - MS_ERROR(0x03))/**< Socket connect error */
+#define MS_MEDIA_ERR_SOCKET_MSG (MS_MEDIA_ERR_NONE - MS_ERROR(0x04))/**< Socket message error */
+#define MS_MEDIA_ERR_SOCKET_SEND (MS_MEDIA_ERR_NONE - MS_ERROR(0x05))/**< Socket send error */
+#define MS_MEDIA_ERR_SOCKET_RECEIVE (MS_MEDIA_ERR_NONE - MS_ERROR(0x06))/**< Socket receive error */
+#define MS_MEDIA_ERR_SOCKET_RECEIVE_TIMEOUT (MS_MEDIA_ERR_NONE - MS_ERROR(0x07))/**< Socket time out */
+
+#define MS_MEDIA_ERR_INVALID_MEDIA (MS_MEDIA_ERR_NONE - MS_ERROR(0x08))/**< Invalid media content */
+#define MS_MEDIA_ERR_INSERT_FAIL (MS_MEDIA_ERR_NONE - MS_ERROR(0x09))/**< DB insert fail */
+#define MS_MEDIA_ERR_DRM_INSERT_FAIL (MS_MEDIA_ERR_NONE - MS_ERROR(0x0a))/**< DRM file insert fail */
+
+#define MS_MEDIA_ERR_UNKNOWN (MS_MEDIA_ERR_NONE - MS_ERROR(0x10)) /**<Unknown error*/
+
+#endif /*_MEDIA_UTIL_ERR_H_*/
diff --git a/lib/include/media-util-internal.h b/lib/include/media-util-internal.h
new file mode 100755
index 0000000..690a367
--- /dev/null
+++ b/lib/include/media-util-internal.h
@@ -0,0 +1,43 @@
+/*
+ * Media Utility
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Yong Yeon Kim <yy9875.kim@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.
+ *
+ */
+
+/**
+ * This file defines api utilities of contents manager engines.
+ *
+ * @file media-util-global.h
+ * @author Yong Yeon Kim(yy9875.kim@samsung.com)
+ * @version 1.0
+ * @brief
+ */
+
+#ifndef _MEDIA_UTIL_GLOBAL_H_
+#define _MEDIA_UTIL_GLOBAL_H_
+
+#define MS_MEDIA_TIMEOUT_SEC 10 /*timeout of waiting reponse for IPC*/
+
+#define MS_MEDIA_UPDATE_NOTI_PATH "/opt/data/file-manager-service/_FILEOPERATION_END"
+
+#define MS_MEDIA_REGISTER_PORT 1001
+
+#define MS_MEDIA_PHONE_ROOT_PATH "/opt/media"
+#define MS_MEDIA_MMC_ROOT_PATH "/opt/storage/sdcard"
+
+#endif /*_MEDIA_UTIL_GLOBAL_H_*/
diff --git a/lib/include/media-util-noti.h b/lib/include/media-util-noti.h
new file mode 100755
index 0000000..6665e05
--- /dev/null
+++ b/lib/include/media-util-noti.h
@@ -0,0 +1,85 @@
+/*
+ * Media Utility
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Yong Yeon Kim <yy9875.kim@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.
+ *
+ */
+
+/**
+ * This file defines api utilities of contents manager engines.
+ *
+ * @file media-util-noti.h
+ * @author Yong Yeon Kim(yy9875.kim@samsung.com)
+ * @version 1.0
+ * @brief
+ */
+ #ifndef _MEDIA_UTIL_NOTI_H_
+#define _MEDIA_UTIL_NOTI_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+* @fn int ms_noti_db_update_complete(void);
+* @brief This function announce media database is updated to other applications.<br>
+* @return This function returns 0 on success, and -1 on failure.
+* @param[in] none
+* @remark This function is recommandation for other application being aware of database updating.<br>
+* @par example
+* @code
+
+#include <stdio.h>
+#include <string.h>
+#include <media-service-noti.h>
+
+ int main()
+ {
+ int result;
+
+ ....
+ file operation (copy/move/delete)
+ ....
+
+ result = ms_noti_db_update_complete();
+ if( result < 0 )
+ {
+ printf("FAIL to ms_noti_db_update_complete\n");
+ return 0;
+ }
+ else
+ {
+ printf("SUCCESS to ms_noti_db_update_complete\n");
+ }
+
+ return 0;
+ }
+
+* @endcode
+*/
+
+int ms_noti_db_update_complete(void);
+
+/**
+* @}
+*/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*_MEDIA_UTIL_NOTI_H_*/
diff --git a/lib/include/media-util-register.h b/lib/include/media-util-register.h
new file mode 100755
index 0000000..e61d19d
--- /dev/null
+++ b/lib/include/media-util-register.h
@@ -0,0 +1,99 @@
+/*
+ * Media Utility
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Yong Yeon Kim <yy9875.kim@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.
+ *
+ */
+
+/**
+ * This file defines api utilities of contents manager engines.
+ *
+ * @file media-util-register.h
+ * @author Yong Yeon Kim(yy9875.kim@samsung.com)
+ * @version 1.0
+ * @brief
+ */
+ #ifndef _MEDIA_UTIL_REGISTER_H_
+#define _MEDIA_UTIL_REGISTER_H_
+
+#include <glib.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @fn int ms_media_file_register(const char *file_full_path);
+ * @brief This function registers multimedia file to media DB
+ * When you did some file operations such as Create, Copy, Move, Rename, and Delete in phone or mmc storage, media-server registers the result to database automatically by inotify mechanism.
+ * However, automatic registration will have a little delay because the method is asynchronous.
+ * If you want to register some files to database immediately, you should use this API.
+ *
+ * @param file_full_path [in] full path of file for register
+ * @return This function returns zero(MEDIA_INFO_ERROR_NONE) on success, or negative value with error code.
+ * Please refer 'media-info-error.h' to know the exact meaning of the error.
+ * @see None.
+ * @pre None.
+ * @post None.
+ * @remark The database name is "/opt/dbspace/.media.db".
+ * You have to use this API only for registering multimedia files. If you try to register no multimedia file, this API returns error.
+ * @par example
+ * @code
+
+#include <media-info.h>
+
+int main()
+{
+ int result = -1;
+
+ result = ms_media_file_register("/opt/media/test.mp3");
+ if( result < 0 )
+ {
+ printf("FAIL to mediainfo_register_file\n");
+ return 0;
+ }
+ else
+ {
+ printf("SUCCESS to register file\n");
+ }
+
+ return 0;
+}
+
+ * @endcode
+ */
+int media_file_register(const char *file_full_path);
+
+ typedef GArray* media_list;
+
+int media_list_new(media_list *list);
+
+int media_list_add(media_list list, const char* file_full_path);
+
+int media_list_free(media_list list);
+
+int media_files_register(const media_list list);
+
+/**
+* @}
+*/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*_MEDIA_UTIL_REGISTER_H_*/
diff --git a/lib/media-util-noti.c b/lib/media-util-noti.c
new file mode 100755
index 0000000..f5de153
--- /dev/null
+++ b/lib/media-util-noti.c
@@ -0,0 +1,50 @@
+/*
+ * Media Utility
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Yong Yeon Kim <yy9875.kim@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.
+ *
+ */
+
+/**
+ * This file defines api utilities of contents manager engines.
+ *
+ * @file media-util-noti.c
+ * @author Yong Yeon Kim(yy9875.kim@samsung.com)
+ * @version 1.0
+ * @brief
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include "media-util-err.h"
+#include "media-util-internal.h"
+#include "media-util-noti.h"
+
+ int ms_noti_update_complete(void)
+{
+ int ret;
+ int err = MS_MEDIA_ERR_NONE;
+
+ ret = mkdir(MS_MEDIA_UPDATE_NOTI_PATH, 0777);
+ if (ret != 0) {
+ err = MS_MEDIA_ERR_OCCURRED;
+ }
+
+ return err;
+}
+
diff --git a/lib/media-util-register.c b/lib/media-util-register.c
new file mode 100755
index 0000000..4793d69
--- /dev/null
+++ b/lib/media-util-register.c
@@ -0,0 +1,212 @@
+/*
+ * Media Utility
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Yong Yeon Kim <yy9875.kim@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.
+ *
+ */
+
+/**
+ * This file defines api utilities of contents manager engines.
+ *
+ * @file media-util-register.c
+ * @author Yong Yeon Kim(yy9875.kim@samsung.com)
+ * @version 1.0
+ * @brief
+ */
+#include <errno.h>
+#include <unistd.h>
+#include <arpa/inet.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/socket.h>
+#include <string.h>
+
+#include <media-svc.h>
+#include <audio-svc.h>
+#include <audio-svc-error.h>
+
+#include "media-util-dbg.h"
+#include "media-util-err.h"
+#include "media-util-internal.h"
+#include "media-util-register.h"
+
+static bool _is_valid_path(const char *path)
+{
+ if (path == NULL)
+ return false;
+
+ if (strncmp(path, MS_MEDIA_PHONE_ROOT_PATH, strlen(MS_MEDIA_PHONE_ROOT_PATH)) == 0) {
+ return true;
+ } else if (strncmp(path, MS_MEDIA_MMC_ROOT_PATH, strlen(MS_MEDIA_MMC_ROOT_PATH)) == 0) {
+ return true;
+ } else
+ return false;
+
+ return true;
+}
+
+int media_file_register(const char *file_full_path)
+{
+ int exist;
+ int err;
+ int sockfd;
+ int recv_msg = MS_MEDIA_ERR_NONE;
+ int server_addr_size;
+ struct sockaddr_in server_addr;
+ struct timeval tv_timeout = { MS_MEDIA_TIMEOUT_SEC, 0 };
+
+ if(!_is_valid_path(file_full_path)) {
+ MSAPI_DBG("Invalid path : %s", file_full_path);
+ return MS_MEDIA_ERR_INVALID_PATH;
+ }
+
+ exist = open(file_full_path, O_RDONLY);
+ if(exist < 0) {
+ MSAPI_DBG("Not exist path : %s", file_full_path);
+ return MS_MEDIA_ERR_INVALID_PATH;
+ }
+ close(exist);
+
+ sockfd = socket(PF_INET, SOCK_DGRAM, 0);
+ if(sockfd < 0)
+ {
+ MSAPI_DBG("socket create fail");
+ return MS_MEDIA_ERR_SOCKET_CONN;
+ }
+
+ /*add timeout : timeout is 10 sec.*/
+ if (setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, &tv_timeout, sizeof(tv_timeout)) == -1) {
+ MSAPI_DBG("setsockopt failed");
+ return MS_MEDIA_ERR_SOCKET_CONN;
+ }
+
+ memset(&server_addr, 0, sizeof(server_addr));
+ server_addr.sin_family = AF_INET;
+ server_addr.sin_port = htons(MS_MEDIA_REGISTER_PORT);
+ server_addr.sin_addr.s_addr = inet_addr("127.0.0.1");
+
+ err = sendto(sockfd, file_full_path, strlen(file_full_path), 0, (struct sockaddr*)&server_addr, sizeof(server_addr));
+ if (err < 0) {
+ MSAPI_DBG("sendto error");
+ perror("sendto error : ");
+ return MS_MEDIA_ERR_SOCKET_SEND;
+ } else {
+ MSAPI_DBG("SEND OK");
+ }
+
+ server_addr_size = sizeof(server_addr);
+ err = recvfrom(sockfd, &recv_msg, sizeof(recv_msg), 0 , (struct sockaddr*)&server_addr, (socklen_t *)&server_addr_size);
+ if (err < 0) {
+ if (errno == EWOULDBLOCK) {
+ MSAPI_DBG("recvfrom timeout");
+ return MS_MEDIA_ERR_SOCKET_RECEIVE_TIMEOUT;
+ } else {
+ MSAPI_DBG("recvfrom error");
+ perror("recvfrom error : ");
+ return MS_MEDIA_ERR_SOCKET_RECEIVE;
+ }
+ } else {
+ MSAPI_DBG("RECEIVE OK");
+ MSAPI_DBG("client receive: %d", recv_msg);
+ }
+
+ close(sockfd);
+
+ return recv_msg;
+}
+
+int media_list_new(media_list *list)
+{
+ *list = g_array_new(TRUE, TRUE, sizeof(char*));
+
+ return MS_MEDIA_ERR_NONE;
+}
+
+int media_list_add(media_list list, const char* file_full_path)
+{
+ MSAPI_DBG("");
+
+ if (!list) {
+ MSAPI_DBG("list == NULL");
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
+ }
+
+ if (!file_full_path) {
+ MSAPI_DBG("file_full_path == NULL");
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
+ }
+
+ media_list ret_list = NULL;
+ char *path = strdup(file_full_path);
+
+ int len = list->len + 1;
+ int i;
+ char *data = NULL;
+
+ ret_list = g_array_append_val(list, path);
+ if(ret_list == NULL) {
+ MSAPI_DBG("g_array_append_val fails");
+ return MS_MEDIA_ERR_UNKNOWN;
+ }
+
+ list = ret_list;
+
+ for(i = 0; i < len; i++) {
+ data = g_array_index(list, char*, i);
+ MSAPI_DBG("%d, %s", i, data);
+ }
+
+ return MS_MEDIA_ERR_NONE;
+}
+
+int media_list_free(media_list list)
+{
+ if (!list)
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
+
+ int len = list->len + 1;
+ int i;
+ char *data = NULL;
+
+ for(i = 0; i < len; i++) {
+ data = g_array_index(list, char*, i);
+ free(data);
+ }
+
+ g_array_free(list, TRUE);
+
+ return MS_MEDIA_ERR_NONE;
+}
+
+int media_files_register(const media_list list)
+{
+ if (!list)
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
+
+ int len = list->len + 1;
+ int i;
+ char *data;
+
+ for(i = 0; i < len; i++) {
+ data = g_array_index(list, char*, i);
+ media_file_register(data);
+ }
+
+ return MS_MEDIA_ERR_NONE;
+}
+
diff --git a/libmedia-utils.pc.in b/libmedia-utils.pc.in
new file mode 100755
index 0000000..886d52d
--- /dev/null
+++ b/libmedia-utils.pc.in
@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: media contents managing service
+Description: media contents managing service API
+Requires:
+Version: @VERSION@
+Libs: -L${libdir} -lmedia-utils
+Cflags: -I${includedir}/media-utils
diff --git a/packaging/media-server.spec b/packaging/media-server.spec
new file mode 100644
index 0000000..50edff5
--- /dev/null
+++ b/packaging/media-server.spec
@@ -0,0 +1,290 @@
+Name: media-server
+Summary: Media Server.
+Version: 0.1.18
+Release: 1
+Group: utils
+License: Samsung
+Source0: %{name}-%{version}.tar.gz
+
+Requires(post): /usr/bin/sqlite3
+Requires(post): /usr/bin/vconftool
+
+BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(vconf)
+BuildRequires: pkgconfig(dbus-1)
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(db-util)
+BuildRequires: pkgconfig(drm-service)
+BuildRequires: pkgconfig(heynoti)
+BuildRequires: pkgconfig(mm-fileinfo)
+BuildRequires: pkgconfig(libmedia-info)
+BuildRequires: pkgconfig(aul)
+BuildRequires: pkgconfig(pmapi)
+BuildRequires: pkgconfig(quickpanel)
+
+%description
+Media service server..
+
+%package devel
+Summary: Media server headers and libraries
+Group: utils
+Requires: %{name} = %{version}-%{release}
+
+%description devel
+Media server headers and libraries (development)
+
+%prep
+%setup -q
+
+%build
+
+%autogen
+
+LDFLAGS="$LDFLAGS -Wl,--rpath=%{prefix}/lib -Wl,--hash-style=both -Wl,--as-needed "; export LDFLAGS
+
+%configure --prefix=/usr
+
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+%make_install
+
+
+%post
+
+if [ ! -f /opt/dbspace/.filemanager.db ]
+then
+ sqlite3 /opt/dbspace/.filemanager.db 'PRAGMA journal_mode = PERSIST;
+
+ CREATE TABLE mmc_info (serial text, date text, manfid text);
+'
+fi
+
+if [ ! -f /opt/dbspace/.media.db ]
+then
+ sqlite3 /opt/dbspace/.media.db 'PRAGMA journal_mode = PERSIST;
+
+ CREATE TABLE audio_media (audio_id integer primary key autoincrement, path text unique, basename text, thumbnail_path text, title text, title_key text, album text, album_id integer, artist text, artist_id integer, genre text, author text, year integer default -1, copyright text, description text, format text, bitrate integer default -1, track_num integer default -1, duration integer default -1, rating integer default 0, played_count integer default 0, last_played_time integer default -1, added_time integer, rated_time integer, album_rating integer default 0, modified_date integer default 0, size integer default 0, mime_type text, is_ringtone INTEGER default 0, is_music INTEGER default 1, is_alarm INTEGER default 0, is_notification INTEGER default 0, is_podcast INTEGER default 0, bookmark INTEGER default 0, category INTEGER default 0, valid integer default 0, folder_id integer default -1, storage_type integer, content_type integer default 3);
+ INSERT INTO "audio_media" VALUES(1,"/opt/media/Sounds and music/Ringtones/Basic_Cuisine.mp3","Basic_Cuisine.mp3","/opt/data/file-manager-service/.thumb/phone/.mp3-2b1eb83d4d987ad847b9d56d044321a4.png","Cuisine","Cuisine","Samsung",1,"Samsung",1,"Ringtone","Unknown",-1,"","","128kbps 44.1kHz 2ch",128000,-1,15804,0,0,0,1303362789,NULL,0,1300757280,253889,"audio/mpeg",0,1,0,0,0,0,1,1,1,0,3);
+ INSERT INTO "audio_media" VALUES(2,"/opt/media/Sounds and music/Ringtones/Global_Rhythm of the rain.mp3","Global_Rhythm of the rain.mp3","/opt/data/file-manager-service/.thumb/phone/.mp3-2b1eb83d4d987ad847b9d56d044321a4.png","Rhythm of the rain","Rhythm of the rain","Samsung",1,"Samsung",1,"Ringtone","Unknown",-1,"","Samsung","128kbps 44.1kHz 2ch",128000,-1,36780,0,0,0,1303362789,NULL,0,1257745924,589696,"audio/mpeg",0,1,0,0,0,0,1,1,1,0,3);
+ INSERT INTO "audio_media" VALUES(3,"/opt/media/Sounds and music/Ringtones/Global_Imagine.mp3","Global_Imagine.mp3","/opt/data/file-manager-service/.thumb/phone/.mp3-2b1eb83d4d987ad847b9d56d044321a4.png","Imagine","Imagine","Samsung",1,"Samsung",1,"Ringtone","Unknown",-1,"","Samsung","128kbps 44.1kHz 2ch",128000,-1,40620,0,0,0,1303362789,NULL,0,1257745880,651136,"audio/mpeg",0,1,0,0,0,0,1,1,1,0,3);
+ INSERT INTO "audio_media" VALUES(4,"/opt/media/Sounds and music/Ringtones/Global_Avemaria.mp3","Global_Avemaria.mp3","/opt/data/file-manager-service/.thumb/phone/.mp3-2b1eb83d4d987ad847b9d56d044321a4.png","Avemaria","Avemaria","Samsung",1,"Samsung",1,"Ringtone","Unknown",-1,"","Samsung","128kbps 44.1kHz 2ch",128000,-1,40489,0,0,0,1303362789,NULL,0,1257745780,649088,"audio/mpeg",0,1,0,0,0,0,1,1,1,0,3);
+ INSERT INTO "audio_media" VALUES(5,"/opt/media/Sounds and music/Ringtones/Global_Sunshine.mp3","Global_Sunshine.mp3","/opt/data/file-manager-service/.thumb/phone/.mp3-2b1eb83d4d987ad847b9d56d044321a4.png","Sunshine","Sunshine","Samsung",1,"Samsung",1,"Ringtone","Unknown",-1,"","Samsung","128kbps 44.1kHz 2ch",128000,-1,33280,0,0,0,1303362789,NULL,0,1257745966,534400,"audio/mpeg",0,1,0,0,0,0,1,1,1,0,3);
+ INSERT INTO "audio_media" VALUES(6,"/opt/media/Sounds and music/Ringtones/Global_Do it now.mp3","Global_Do it now.mp3","/opt/data/file-manager-service/.thumb/phone/.mp3-2b1eb83d4d987ad847b9d56d044321a4.png","Do it now","Do it now","Samsung",1,"Samsung",1,"Ringtone","Unknown",-1,"","Samsung","128kbps 44.1kHz 2ch",128000,-1,37250,0,0,0,1303362789,NULL,0,1257759968,598016,"audio/mpeg",0,1,0,0,0,0,1,1,1,0,3);
+ INSERT INTO "audio_media" VALUES(7,"/opt/media/Sounds and music/Ringtones/Global_Brain wave.mp3","Global_Brain wave.mp3","/opt/data/file-manager-service/.thumb/phone/.mp3-2b1eb83d4d987ad847b9d56d044321a4.png","Brain wave","Brain wave","Samsung",1,"Samsung",1,"Ringtone","Unknown",-1,"","Samsung","128kbps 44.1kHz 2ch",128000,-1,36022,0,0,0,1303362789,NULL,0,1257745594,577408,"audio/mpeg",0,1,0,0,0,0,1,1,1,0,3);
+ INSERT INTO "audio_media" VALUES(8,"/opt/media/Sounds and music/Ringtones/General_Crossingwalk.mp3","General_Crossingwalk.mp3","/opt/data/file-manager-service/.thumb/phone/.mp3-2b1eb83d4d987ad847b9d56d044321a4.png","Crossingwalk","Crossingwalk","Samsung",1,"Samsung",1,"Ringtone","Unknown",-1,"","Samsung","128kbps 44.1kHz 2ch",128000,-1,13296,0,0,0,1303362789,NULL,0,1296193320,213765,"audio/mpeg",0,1,0,0,0,0,1,1,1,0,3);
+ INSERT INTO "audio_media" VALUES(9,"/opt/media/Sounds and music/Ringtones/General_One fine day.mp3","General_One fine day.mp3","/opt/data/file-manager-service/.thumb/phone/.mp3-2b1eb83d4d987ad847b9d56d044321a4.png","One fine day","One fine day","Samsung",1,"Samsung",1,"Ringtone","Unknown",-1,"","","128kbps 44.1kHz 2ch",128000,0,14497,0,0,0,1303362790,NULL,0,1276820740,233611,"audio/mpeg",0,1,0,0,0,0,1,1,1,0,3);
+ INSERT INTO "audio_media" VALUES(10,"/opt/media/Sounds and music/Ringtones/Global_Vocalise.mp3","Global_Vocalise.mp3","/opt/data/file-manager-service/.thumb/phone/.mp3-2b1eb83d4d987ad847b9d56d044321a4.png","Vocalise","Vocalise","Samsung",1,"Samsung",1,"Ringtone","Unknown",-1,"","Samsung","128kbps 44.1kHz 2ch",128000,-1,44617,0,0,0,1303362790,NULL,0,1257746032,714624,"audio/mpeg",0,1,0,0,0,0,1,1,1,0,3);
+ INSERT INTO "audio_media" VALUES(11,"/opt/media/Sounds and music/Ringtones/Basic_Basic tone.mp3","Basic_Basic tone.mp3","/opt/data/file-manager-service/.thumb/phone/.mp3-2b1eb83d4d987ad847b9d56d044321a4.png","Basic tone","Basic tone","Samsung",1,"Samsung",1,"Ringtone","Unknown",-1,"","","128kbps 44.1kHz 2ch",128000,-1,3500,0,0,0,1303362790,NULL,0,1271843334,57216,"audio/mpeg",0,1,0,0,0,0,1,1,1,0,3);
+ INSERT INTO "audio_media" VALUES(12,"/opt/media/Sounds and music/Ringtones/Basic_Minimal tone.mp3","Basic_Minimal tone.mp3","/opt/data/file-manager-service/.thumb/phone/.mp3-2b1eb83d4d987ad847b9d56d044321a4.png","Minimal tone","Minimal tone","Samsung",1,"Samsung",1,"Ringtone","Unknown",-1,"","","128kbps 44.1kHz 2ch",128000,-1,5355,0,0,0,1303362790,NULL,0,1301545764,86706,"audio/mpeg",0,1,0,0,0,0,1,1,1,0,3);
+ INSERT INTO "audio_media" VALUES(13,"/opt/media/Sounds and music/Ringtones/General_Emotive sensation.mp3","General_Emotive sensation.mp3","/opt/data/file-manager-service/.thumb/phone/.mp3-2b1eb83d4d987ad847b9d56d044321a4.png","Emotive sensation","Emotive sensation","Samsung",1,"Samsung",1,"Ringtone","Unknown",-1,"","","128kbps 44.1kHz 2ch",128000,-1,19226,0,0,0,1303362790,NULL,0,1300950722,308642,"audio/mpeg",0,1,0,0,0,0,1,1,1,0,3);
+ INSERT INTO "audio_media" VALUES(14,"/opt/media/Sounds and music/Ringtones/General_Just spinning.mp3","General_Just spinning.mp3","/opt/data/file-manager-service/.thumb/phone/.mp3-2b1eb83d4d987ad847b9d56d044321a4.png","Just spinning","Just spinning","Samsung",1,"Samsung",1,"Ringtone","Unknown",-1,"","","128kbps 44.1kHz 2ch",128000,-1,19356,0,0,0,1303362790,NULL,0,1300950870,310919,"audio/mpeg",0,1,0,0,0,0,1,1,1,0,3);
+ INSERT INTO "audio_media" VALUES(15,"/opt/media/Sounds and music/Ringtones/Global_You'\''re my love song.mp3","Global_You'\''re my love song.mp3","/opt/data/file-manager-service/.thumb/phone/.mp3-2b1eb83d4d987ad847b9d56d044321a4.png","You'\''re my love song","You'\''re my love song","Samsung",1,"Samsung",1,"Ringtone","Unknown",-1,"","Samsung","128kbps 44.1kHz 2ch",128000,-1,32104,0,0,0,1303362790,NULL,0,1257746058,513920,"audio/mpeg",0,1,0,0,0,0,1,1,1,0,3);
+ INSERT INTO "audio_media" VALUES(16,"/opt/media/Sounds and music/Ringtones/General_City drivin.mp3","General_City drivin.mp3","/opt/data/file-manager-service/.thumb/phone/.mp3-2b1eb83d4d987ad847b9d56d044321a4.png","City drivin","City drivin","Samsung",1,"Samsung",1,"Ringtone","Unknown",-1,"","","128kbps 44.1kHz 2ch",128000,-1,18076,0,0,0,1303362790,NULL,0,1300692200,290857,"audio/mpeg",0,1,0,0,0,0,1,1,1,0,3);
+ INSERT INTO "audio_media" VALUES(17,"/opt/media/Sounds and music/Ringtones/Basic_Single tone.mp3","Basic_Single tone.mp3","/opt/data/file-manager-service/.thumb/phone/.mp3-2b1eb83d4d987ad847b9d56d044321a4.png","Single tone","Single tone","Samsung",1,"Samsung",1,"Ringtone","Unknown",-1,"","","80kbps 44.1kHz 1ch",80000,-1,3683,0,0,0,1303362790,NULL,0,1300950830,38849,"audio/mpeg",0,1,0,0,0,0,1,1,1,0,3);
+ INSERT INTO "audio_media" VALUES(18,"/opt/media/Sounds and music/Ringtones/Basic_Popple tone.mp3","Basic_Popple tone.mp3","/opt/data/file-manager-service/.thumb/phone/.mp3-2b1eb83d4d987ad847b9d56d044321a4.png","Popple tone","Popple tone","Samsung",1,"Samsung",1,"Ringtone","Unknown",-1,"","","128kbps 44.1kHz 2ch",128000,-1,16613,0,0,0,1303362790,NULL,0,1300757442,267870,"audio/mpeg",0,1,0,0,0,0,1,1,1,0,3);
+ INSERT INTO "audio_media" VALUES(19,"/opt/media/Sounds and music/Ringtones/Global_Ringing to you.mp3","Global_Ringing to you.mp3","/opt/data/file-manager-service/.thumb/phone/.mp3-2b1eb83d4d987ad847b9d56d044321a4.png","Ringing to you","Ringing to you","Samsung",1,"Samsung",1,"Ringtone","Unknown",-1,"","Samsung","128kbps 44.1kHz 2ch",128000,-1,31895,0,0,0,1303362790,NULL,0,1272851802,513253,"audio/mpeg",0,1,0,0,0,0,1,1,1,0,3);
+ INSERT INTO "audio_media" VALUES(20,"/opt/media/Sounds and music/Ringtones/Global_Tell me.mp3","Global_Tell me.mp3","/opt/data/file-manager-service/.thumb/phone/.mp3-2b1eb83d4d987ad847b9d56d044321a4.png","Tell me","Tell me","Samsung",1,"Samsung",1,"Ringtone","Unknown",-1,"","Samsung","128kbps 44.1kHz 2ch",128000,-1,32052,0,0,0,1303362790,NULL,0,1257745984,513920,"audio/mpeg",0,1,0,0,0,0,1,1,1,0,3);
+ INSERT INTO "audio_media" VALUES(21,"/opt/media/Sounds and music/Ringtones/Basic_Crossing tone.mp3","Basic_Crossing tone.mp3","/opt/data/file-manager-service/.thumb/phone/.mp3-2b1eb83d4d987ad847b9d56d044321a4.png","Crossing tone","Crossing tone","Samsung",1,"Samsung",1,"Ringtone","Unknown",-1,"","","128kbps 44.1kHz 2ch",128000,-1,7314,0,0,0,1303362790,NULL,0,1300757250,118808,"audio/mpeg",0,1,0,0,0,0,1,1,1,0,3);
+ INSERT INTO "audio_media" VALUES(22,"/opt/media/Sounds and music/Ringtones/Global_The secret only 4U.mp3","Global_The secret only 4U.mp3","/opt/data/file-manager-service/.thumb/phone/.mp3-2b1eb83d4d987ad847b9d56d044321a4.png","The secret only 4U","The secret only 4U","Samsung",1,"Samsung",1,"Ringtone","Unknown",-1,"","Samsung","128kbps 44.1kHz 2ch",128000,-1,41482,0,0,0,1303362790,NULL,0,1257746014,665472,"audio/mpeg",0,1,0,0,0,0,1,1,1,0,3);
+ INSERT INTO "audio_media" VALUES(23,"/opt/media/Sounds and music/Ringtones/Global_On my mind.mp3","Global_On my mind.mp3","/opt/data/file-manager-service/.thumb/phone/.mp3-2b1eb83d4d987ad847b9d56d044321a4.png","On my mind","On my mind","Samsung",1,"Samsung",1,"Ringtone","Unknown",-1,"","Samsung","128kbps 44.1kHz 2ch",128000,-1,29675,0,0,0,1303362790,NULL,0,1298452646,475008,"audio/mpeg",0,1,0,0,0,0,1,1,1,0,3);
+ INSERT INTO "audio_media" VALUES(24,"/opt/media/Sounds and music/Ringtones/General_Ring a ring.mp3","General_Ring a ring.mp3","/opt/data/file-manager-service/.thumb/phone/.mp3-2b1eb83d4d987ad847b9d56d044321a4.png","Ring a ring","Ring a ring","Samsung",1,"Samsung",1,"Ringtone","Unknown",-1,"","","128kbps 44.1kHz 2ch",128000,-1,20062,0,0,0,1303362790,NULL,0,1300757470,322017,"audio/mpeg",0,1,0,0,0,0,1,1,1,0,3);
+ INSERT INTO "audio_media" VALUES(25,"/opt/media/Sounds and music/Ringtones/Global_Drawing the night.mp3","Global_Drawing the night.mp3","/opt/data/file-manager-service/.thumb/phone/.mp3-2b1eb83d4d987ad847b9d56d044321a4.png","Drawing the night","Drawing the night","Samsung",1,"Samsung",1,"Ringtone","Unknown",-1,"","Samsung","128kbps 44.1kHz 2ch",128000,-1,32078,0,0,0,1303362790,NULL,0,1257745832,513920,"audio/mpeg",0,1,0,0,0,0,1,1,1,0,3);
+ INSERT INTO "audio_media" VALUES(26,"/opt/media/Sounds and music/Ringtones/Global_Anymore.mp3","Global_Anymore.mp3","/opt/data/file-manager-service/.thumb/phone/.mp3-2b1eb83d4d987ad847b9d56d044321a4.png","Anymore","Anymore","Samsung",1,"Samsung",1,"Ringtone","Unknown",-1,"","Samsung","128kbps 44.1kHz 2ch",128000,-1,32156,0,0,0,1303362790,NULL,0,1257745756,516096,"audio/mpeg",0,1,0,0,0,0,1,1,1,0,3);
+ INSERT INTO "audio_media" VALUES(27,"/opt/media/Sounds and music/Ringtones/Global_Hypnotize.mp3","Global_Hypnotize.mp3","","Hypnotize","Hypnotize","Samsung",1,"Samsung",1,"Ringtone","Unknown",-1,"","Samsung","128kbps 44.1kHz 2ch",128000,-1,49319,0,0,0,1303362791,NULL,0,1257745856,790400,"audio/mpeg",0,1,0,0,0,0,1,1,1,0,3);
+ INSERT INTO "audio_media" VALUES(28,"/opt/media/Sounds and music/Ringtones/General_Digital cloud.mp3","General_Digital cloud.mp3","/opt/data/file-manager-service/.thumb/phone/.mp3-2b1eb83d4d987ad847b9d56d044321a4.png","Digital cloud","Digital cloud","Samsung",1,"Samsung",1,"Ringtone","Unknown",-1,"","","128kbps 44.1kHz 2ch",128000,-1,20297,0,0,0,1303362791,NULL,0,1300692232,326802,"audio/mpeg",0,1,0,0,0,0,1,1,1,0,3);
+ INSERT INTO "audio_media" VALUES(29,"/opt/media/Sounds and music/Ringtones/General_Mis en scene.mp3","General_Mis en scene.mp3","/opt/data/file-manager-service/.thumb/phone/.mp3-2b1eb83d4d987ad847b9d56d044321a4.png","Mis en scene","Mis en scene","Samsung",1,"Samsung",1,"Ringtone","Unknown",-1,"","","128kbps 44.1kHz 2ch",128000,-1,30667,0,0,0,1303362791,NULL,0,1300757424,491708,"audio/mpeg",0,1,0,0,0,0,1,1,1,0,3);
+ INSERT INTO "audio_media" VALUES(30,"/opt/media/Sounds and music/Ringtones/General_Reverie.mp3","General_Reverie.mp3","/opt/data/file-manager-service/.thumb/phone/.mp3-2b1eb83d4d987ad847b9d56d044321a4.png","Reverie","Reverie","Samsung",1,"Samsung",1,"Ringtone","Unknown",-1,"","","128kbps 44.1kHz 2ch",128000,-1,25391,0,0,0,1303362791,NULL,0,1300757454,407280,"audio/mpeg",0,1,0,0,0,0,1,1,1,0,3);
+ INSERT INTO "audio_media" VALUES(31,"/opt/media/Sounds and music/Music/Over the horizon.mp3","Over the horizon.mp3","/opt/data/file-manager-service/.thumb/phone/.mp3-2b1eb83d4d987ad847b9d56d044321a4.png","Over the horizon","Over the horizon","Samsung",1,"Samsung",1,"Rock","Unknown",2011,"","Samsung","128kbps 44.1kHz 2ch",128000,-1,185521,0,0,0,1303362791,NULL,0,1303267153,3179820,"audio/mpeg",0,1,0,0,0,0,0,1,2,0,3);
+ INSERT INTO "audio_media" VALUES(32,"/opt/media/Sounds and music/Alerts/Glittering Light.mp3","Glittering Light.mp3","/opt/data/file-manager-service/.thumb/phone/.mp3-2b1eb83d4d987ad847b9d56d044321a4.png","Glittering light","Glittering light","Samsung",1,"Samsung",1,"Alert tone","Unknown",-1,"","","96kbps 44.1kHz 2ch",96000,-1,2560,0,0,0,1303362791,NULL,0,1298442334,31744,"audio/mpeg",0,1,0,0,0,0,1,1,3,0,3);
+ INSERT INTO "audio_media" VALUES(33,"/opt/media/Sounds and music/Alerts/Bubbles.mp3","Bubbles.mp3","/opt/data/file-manager-service/.thumb/phone/.mp3-2b1eb83d4d987ad847b9d56d044321a4.png","Bubbles","Bubbles","Samsung",1,"Samsung",1,"Alert tone","Unknown",-1,"","","96kbps 44.1kHz 1ch",96000,-1,574,0,0,0,1303362791,NULL,0,1298442388,8944,"audio/mpeg",0,1,0,0,0,0,1,1,3,0,3);
+ INSERT INTO "audio_media" VALUES(34,"/opt/media/Sounds and music/Alerts/Chirp Chrip.mp3","Chirp Chrip.mp3","/opt/data/file-manager-service/.thumb/phone/.mp3-2b1eb83d4d987ad847b9d56d044321a4.png","Chirp Chirp","Chirp Chirp","Samsung",1,"Samsung",1,"Alert tone","Unknown",-1,"","","96kbps 44.1kHz 1ch",96000,-1,1253,0,0,0,1303362791,NULL,0,1298540588,17095,"audio/mpeg",0,1,0,0,0,0,1,1,3,0,3);
+ INSERT INTO "audio_media" VALUES(35,"/opt/media/Sounds and music/Alerts/Pianissimo.mp3","Pianissimo.mp3","/opt/data/file-manager-service/.thumb/phone/.mp3-2b1eb83d4d987ad847b9d56d044321a4.png","Pianissimo","Pianissimo","Samsung",1,"Samsung",1,"Alert tone","Unknown",-1,"","","96kbps 44.1kHz 1ch",96000,-1,3474,0,0,0,1303362791,NULL,0,1298442184,43739,"audio/mpeg",0,1,0,0,0,0,1,1,3,0,3);
+ INSERT INTO "audio_media" VALUES(36,"/opt/media/Sounds and music/Alerts/Cloud.mp3","Cloud.mp3","/opt/data/file-manager-service/.thumb/phone/.mp3-2b1eb83d4d987ad847b9d56d044321a4.png","Cloud","Cloud","Samsung",1,"Samsung",1,"Alert tone","Unknown",-1,"","Samsung","96kbps 44.1kHz 1ch",96000,-1,1933,0,0,0,1303362791,NULL,0,1282182420,24448,"audio/mpeg",0,1,0,0,0,0,1,1,3,0,3);
+ INSERT INTO "audio_media" VALUES(37,"/opt/media/Sounds and music/Alerts/Charming bell.mp3","Charming bell.mp3","/opt/data/file-manager-service/.thumb/phone/.mp3-2b1eb83d4d987ad847b9d56d044321a4.png","Charming bell","Charming bell","Samsung",1,"Samsung",1,"Alert tone","Unknown",-1,"","","96kbps 44.1kHz 1ch",96000,-1,2481,0,0,0,1303362791,NULL,0,1298442370,31828,"audio/mpeg",0,1,0,0,0,0,1,1,3,0,3);
+ INSERT INTO "audio_media" VALUES(38,"/opt/media/Sounds and music/Alerts/Good News.mp3","Good News.mp3","/opt/data/file-manager-service/.thumb/phone/.mp3-2b1eb83d4d987ad847b9d56d044321a4.png","Good news","Good news","Samsung",1,"Samsung",1,"Alert tone","Unknown",-1,"","","96kbps 44.1kHz 2ch",96000,-1,1645,0,0,0,1303362791,NULL,0,1298442316,20773,"audio/mpeg",0,1,0,0,0,0,1,1,3,0,3);
+ INSERT INTO "audio_media" VALUES(39,"/opt/media/Sounds and music/Alerts/Knock.mp3","Knock.mp3","/opt/data/file-manager-service/.thumb/phone/.mp3-2b1eb83d4d987ad847b9d56d044321a4.png","Knock","Knock","Samsung",1,"Samsung",1,"Alert tone","Unknown",-1,"","","96kbps 44.1kHz 1ch",96000,-1,1018,0,0,0,1303362791,NULL,0,1298442242,14273,"audio/mpeg",0,1,0,0,0,0,1,1,3,0,3);
+ INSERT INTO "audio_media" VALUES(40,"/opt/media/Sounds and music/Alerts/Transparent piano.mp3","Transparent piano.mp3","/opt/data/file-manager-service/.thumb/phone/.mp3-2b1eb83d4d987ad847b9d56d044321a4.png","Transparent piano","Transparent piano","Samsung",1,"Samsung",1,"Alert tone","Unknown",-1,"","Samsung","96kbps 44.1kHz 1ch",96000,-1,3160,0,0,0,1303362791,NULL,0,1300842836,38912,"audio/mpeg",0,1,0,0,0,0,1,1,3,0,3);
+ INSERT INTO "audio_media" VALUES(41,"/opt/media/Sounds and music/Alerts/Stepping stones.mp3","Stepping stones.mp3","/opt/data/file-manager-service/.thumb/phone/.mp3-2b1eb83d4d987ad847b9d56d044321a4.png","Stepping stones","Stepping stones","Samsung",1,"Samsung",1,"Alert tone","Unknown",-1,"","Samsung","96kbps 44.1kHz 1ch",96000,-1,1854,0,0,0,1303362791,NULL,0,1282182694,22528,"audio/mpeg",0,1,0,0,0,0,1,1,3,0,3);
+ INSERT INTO "audio_media" VALUES(42,"/opt/media/Sounds and music/Alerts/Harmonics.mp3","Harmonics.mp3","/opt/data/file-manager-service/.thumb/phone/.mp3-2b1eb83d4d987ad847b9d56d044321a4.png","Harmonics","Harmonics","Samsung",1,"Samsung",1,"Alert tone","Unknown",-1,"","","96kbps 44.1kHz 1ch",96000,-1,4597,0,0,0,1303362792,NULL,0,1298442284,57219,"audio/mpeg",0,1,0,0,0,0,1,1,3,0,3);
+ INSERT INTO "audio_media" VALUES(43,"/opt/media/Sounds and music/Alerts/A toy watch.mp3","A toy watch.mp3","/opt/data/file-manager-service/.thumb/phone/.mp3-2b1eb83d4d987ad847b9d56d044321a4.png","A toy watch","A toy watch","Samsung",1,"Samsung",1,"Alert tone","Unknown",-1,"","Samsung","96kbps 44.1kHz 1ch",96000,-1,3030,0,0,0,1303362792,NULL,0,1282181478,36736,"audio/mpeg",0,1,0,0,0,0,1,1,3,0,3);
+ INSERT INTO "audio_media" VALUES(44,"/opt/media/Sounds and music/Alerts/Good morning.mp3","Good morning.mp3","/opt/data/file-manager-service/.thumb/phone/.mp3-2b1eb83d4d987ad847b9d56d044321a4.png","Good morning","Good morning","Samsung",1,"Samsung",1,"Alert tone","Unknown",-1,"","Samsung","96kbps 44.1kHz 1ch",96000,-1,5694,0,0,0,1303362792,NULL,0,1282181594,69632,"audio/mpeg",0,1,0,0,0,0,1,1,3,0,3);
+ INSERT INTO "audio_media" VALUES(45,"/opt/media/Sounds and music/Alerts/Opener.mp3","Opener.mp3","/opt/data/file-manager-service/.thumb/phone/.mp3-2b1eb83d4d987ad847b9d56d044321a4.png","Opener","Opener","Samsung",1,"Samsung",1,"Alert tone","Unknown",-1,"","","96kbps 44.1kHz 1ch",96000,-1,1671,0,0,0,1303362792,NULL,0,1298442202,22110,"audio/mpeg",0,1,0,0,0,0,1,1,3,0,3);
+ INSERT INTO "audio_media" VALUES(46,"/opt/media/Sounds and music/Alerts/Starry night.mp3","Starry night.mp3","/opt/data/file-manager-service/.thumb/phone/.mp3-2b1eb83d4d987ad847b9d56d044321a4.png","Starry night","Starry night","Samsung",1,"Samsung",1,"Alert tone","Unknown",-1,"","","96kbps 44.1kHz 1ch",96000,-1,5015,0,0,0,1303362792,NULL,0,1298442082,62234,"audio/mpeg",0,1,0,0,0,0,1,1,3,0,3);
+ INSERT INTO "audio_media" VALUES(47,"/opt/media/Sounds and music/Alerts/On time.mp3","On time.mp3","/opt/data/file-manager-service/.thumb/phone/.mp3-2b1eb83d4d987ad847b9d56d044321a4.png","On time","On time","Samsung",1,"Samsung",1,"Alert tone","Unknown",-1,"","Samsung","96kbps 44.1kHz 1ch",96000,-1,2560,0,0,0,1303362792,NULL,0,1282182136,32640,"audio/mpeg",0,1,0,0,0,0,1,1,3,0,3);
+ INSERT INTO "audio_media" VALUES(48,"/opt/media/Sounds and music/Alerts/Postman.mp3","Postman.mp3","/opt/data/file-manager-service/.thumb/phone/.mp3-2b1eb83d4d987ad847b9d56d044321a4.png","Postman","Postman","Samsung",1,"Samsung",1,"Alert tone","Unknown",-1,"","","96kbps 44.1kHz 1ch",96000,-1,2220,0,0,0,1303362792,NULL,0,1298442162,28693,"audio/mpeg",0,1,0,0,0,0,1,1,3,0,3);
+ INSERT INTO "audio_media" VALUES(49,"/opt/media/Sounds and music/Alerts/Pure Bell.mp3","Pure Bell.mp3","/opt/data/file-manager-service/.thumb/phone/.mp3-2b1eb83d4d987ad847b9d56d044321a4.png","Pure bell","Pure bell","Samsung",1,"Samsung",1,"Alert tone","Unknown",-1,"","","96kbps 44.1kHz 2ch",96000,0,2063,0,0,0,1303362792,NULL,0,1298442768,25916,"audio/mpeg",0,1,0,0,0,0,1,1,3,0,3);
+ INSERT INTO "audio_media" VALUES(50,"/opt/media/Sounds and music/Alerts/Haze.mp3","Haze.mp3","/opt/data/file-manager-service/.thumb/phone/.mp3-2b1eb83d4d987ad847b9d56d044321a4.png","Haze","Haze","Samsung",1,"Samsung",1,"Alert tone","Unknown",-1,"","Samsung","96kbps 44.1kHz 1ch",96000,-1,1071,0,0,0,1303362792,NULL,0,1282182480,14208,"audio/mpeg",0,1,0,0,0,0,1,1,3,0,3);
+ INSERT INTO "audio_media" VALUES(51,"/opt/media/Sounds and music/Alerts/Sherbet.mp3","Sherbet.mp3","/opt/data/file-manager-service/.thumb/phone/.mp3-2b1eb83d4d987ad847b9d56d044321a4.png","Sherbet","Sherbet","Samsung",1,"Samsung",1,"Alert tone","Unknown",-1,"","","96kbps 44.1kHz 1ch",96000,-1,1436,0,0,0,1303362792,NULL,0,1298442114,19289,"audio/mpeg",0,1,0,0,0,0,1,1,3,0,3);
+
+ CREATE TABLE audio_folder (_id integer primary key autoincrement, path text, folder_name text, storage_type integer);
+ INSERT INTO "audio_folder" VALUES(1,"/opt/media/Sounds and music/Ringtones","Ringtones",0);
+ INSERT INTO "audio_folder" VALUES(2,"/opt/media/Sounds and music/Music","Music",0);
+ INSERT INTO "audio_folder" VALUES(3,"/opt/media/Sounds and music/Alerts","Alerts",0);
+
+ CREATE TABLE album_art (album_id INTEGER PRIMARY KEY, _data TEXT);
+ INSERT INTO "album_art" VALUES(1,"");
+
+ CREATE TABLE albums (album_id INTEGER PRIMARY KEY AUTOINCREMENT, album_key TEXT NOT NULL UNIQUE, album TEXT NOT NULL);
+ INSERT INTO "albums" VALUES(1,"Samsung","Samsung");
+
+ CREATE TABLE artists (artist_id INTEGER PRIMARY KEY AUTOINCREMENT,artist_key TEXT NOT NULL UNIQUE,artist TEXT NOT NULL);
+ INSERT INTO "artists" VALUES(1,"Samsung","Samsung");
+
+ CREATE TABLE audio_genres (_id INTEGER PRIMARY KEY AUTOINCREMENT,name TEXT NOT NULL);
+ INSERT INTO "audio_genres" VALUES(1,"Ringtone");
+ INSERT INTO "audio_genres" VALUES(2,"Rock");
+ INSERT INTO "audio_genres" VALUES(3,"Alert tone");
+
+ CREATE TABLE audio_genres_map (_id INTEGER PRIMARY KEY AUTOINCREMENT,audio_id INTEGER NOT NULL,genre_id INTEGER NOT NULL);
+ INSERT INTO "audio_genres_map" VALUES(1,1,1);
+ INSERT INTO "audio_genres_map" VALUES(2,2,1);
+ INSERT INTO "audio_genres_map" VALUES(3,3,1);
+ INSERT INTO "audio_genres_map" VALUES(4,4,1);
+ INSERT INTO "audio_genres_map" VALUES(5,5,1);
+ INSERT INTO "audio_genres_map" VALUES(6,6,1);
+ INSERT INTO "audio_genres_map" VALUES(7,7,1);
+ INSERT INTO "audio_genres_map" VALUES(8,8,1);
+ INSERT INTO "audio_genres_map" VALUES(9,9,1);
+ INSERT INTO "audio_genres_map" VALUES(10,10,1);
+ INSERT INTO "audio_genres_map" VALUES(11,11,1);
+ INSERT INTO "audio_genres_map" VALUES(12,12,1);
+ INSERT INTO "audio_genres_map" VALUES(13,13,1);
+ INSERT INTO "audio_genres_map" VALUES(14,14,1);
+ INSERT INTO "audio_genres_map" VALUES(15,15,1);
+ INSERT INTO "audio_genres_map" VALUES(16,16,1);
+ INSERT INTO "audio_genres_map" VALUES(17,17,1);
+ INSERT INTO "audio_genres_map" VALUES(18,18,1);
+ INSERT INTO "audio_genres_map" VALUES(19,19,1);
+ INSERT INTO "audio_genres_map" VALUES(20,20,1);
+ INSERT INTO "audio_genres_map" VALUES(21,21,1);
+ INSERT INTO "audio_genres_map" VALUES(22,22,1);
+ INSERT INTO "audio_genres_map" VALUES(23,23,1);
+ INSERT INTO "audio_genres_map" VALUES(24,24,1);
+ INSERT INTO "audio_genres_map" VALUES(25,25,1);
+ INSERT INTO "audio_genres_map" VALUES(26,26,1);
+ INSERT INTO "audio_genres_map" VALUES(27,27,1);
+ INSERT INTO "audio_genres_map" VALUES(28,28,1);
+ INSERT INTO "audio_genres_map" VALUES(29,29,1);
+ INSERT INTO "audio_genres_map" VALUES(30,30,1);
+ INSERT INTO "audio_genres_map" VALUES(31,31,2);
+ INSERT INTO "audio_genres_map" VALUES(32,32,3);
+ INSERT INTO "audio_genres_map" VALUES(33,33,3);
+ INSERT INTO "audio_genres_map" VALUES(34,34,3);
+ INSERT INTO "audio_genres_map" VALUES(35,35,3);
+ INSERT INTO "audio_genres_map" VALUES(36,36,3);
+ INSERT INTO "audio_genres_map" VALUES(37,37,3);
+ INSERT INTO "audio_genres_map" VALUES(38,38,3);
+ INSERT INTO "audio_genres_map" VALUES(39,39,3);
+ INSERT INTO "audio_genres_map" VALUES(40,40,3);
+ INSERT INTO "audio_genres_map" VALUES(41,41,3);
+ INSERT INTO "audio_genres_map" VALUES(42,42,3);
+ INSERT INTO "audio_genres_map" VALUES(43,43,3);
+ INSERT INTO "audio_genres_map" VALUES(44,44,3);
+ INSERT INTO "audio_genres_map" VALUES(45,45,3);
+ INSERT INTO "audio_genres_map" VALUES(46,46,3);
+ INSERT INTO "audio_genres_map" VALUES(47,47,3);
+ INSERT INTO "audio_genres_map" VALUES(48,48,3);
+ INSERT INTO "audio_genres_map" VALUES(49,49,3);
+ INSERT INTO "audio_genres_map" VALUES(50,50,3);
+ INSERT INTO "audio_genres_map" VALUES(51,51,3);
+
+ CREATE TABLE audio_playlists (_id integer primary key autoincrement, name text, thumbnail_uri TEXT, _data TEXT, date_added INTEGER, date_modified INTEGER);
+
+ CREATE TABLE audio_playlists_map (_id integer primary key autoincrement, playlist_id integer, audio_id integer, play_order INTEGER);
+
+ DELETE FROM sqlite_sequence;
+ INSERT INTO "sqlite_sequence" VALUES("audio_folder",3);
+ INSERT INTO "sqlite_sequence" VALUES("audio_genres",3);
+ INSERT INTO "sqlite_sequence" VALUES("artists",1);
+ INSERT INTO "sqlite_sequence" VALUES("albums",1);
+ INSERT INTO "sqlite_sequence" VALUES("audio_media",51);
+ INSERT INTO "sqlite_sequence" VALUES("audio_genres_map",51);
+
+ CREATE INDEX titlekey_index on audio_media(title_key);
+ CREATE INDEX albumkey_index on albums(album_key);
+ CREATE TRIGGER albumart_cleanup1 DELETE ON albums BEGIN DELETE FROM album_art WHERE album_id = old.album_id;END;
+ CREATE INDEX artistkey_index on artists(artist_key);
+ CREATE TRIGGER audio_genres_cleanup DELETE ON audio_genres BEGIN DELETE FROM audio_genres_map WHERE genre_id = old._id;END;
+ CREATE TRIGGER audio_playlists_map_cleanup_1 DELETE ON audio_media BEGIN DELETE FROM audio_playlists_map WHERE audio_id = old.audio_id;END;
+ CREATE VIEW audio_meta AS SELECT audio_id AS _id, path AS _data, basename AS _display_name, size AS _size, mime_type, added_time AS date_added, modified_date, title, title_key, duration, artist_id, author AS composer, album_id, track_num, year, is_ringtone, is_music, is_alarm, is_notification, is_podcast, bookmark FROM audio_media where valid = 1;
+ CREATE VIEW audio as SELECT * FROM audio_meta LEFT OUTER JOIN artists ON audio_meta.artist_id=artists.artist_id LEFT OUTER JOIN albums ON audio_meta.album_id=albums.album_id;
+ CREATE VIEW album_info AS SELECT audio.album_id AS _id, album, album_key, MIN(year) AS minyear, MAX(year) AS maxyear, artist, artist_id, artist_key, count(*) AS numsongs,album_art._data AS album_art FROM audio LEFT OUTER JOIN album_art ON audio.album_id=album_art.album_id WHERE is_music=1 GROUP BY audio.album_id;
+ CREATE VIEW artist_info AS SELECT artist_id AS _id, artist, artist_key, COUNT(DISTINCT album) AS number_of_albums, COUNT(*) AS number_of_tracks FROM audio WHERE is_music=1 GROUP BY artist_key;
+ CREATE VIEW artists_albums_map AS SELECT DISTINCT artist_id, album_id FROM audio_meta;
+ CREATE VIEW searchhelpertitle AS SELECT * FROM audio ORDER BY title_key;
+ CREATE VIEW search AS SELECT _id,artist AS mime_type,artist,NULL AS album, NULL AS title,artist AS text1,NULL AS text2,number_of_albums AS data1, number_of_tracks AS data2,artist_key AS match, "content://media/external/audio/artists/"||_id AS suggest_intent_data, 1 AS grouporder FROM artist_info WHERE (artist!="Unknown") UNION ALL SELECT _id,album AS mime_type,artist,album,NULL AS title, album AS text1,artist AS text2,NULL AS data1,NULL AS data2, artist_key|| " " ||album_key AS match, "content://media/external/audio/albums/"||_id AS suggest_intent_data, 2 AS grouporder FROM album_info WHERE (album!="Unknown") UNION ALL SELECT searchhelpertitle._id AS _id,mime_type,artist,album,title, title AS text1,artist AS text2,NULL AS data1,NULL AS data2, artist_key||" "||album_key||" "||title_key AS match, "content://media/external/audio/media/"||searchhelpertitle._id AS suggest_intent_data, 3 AS grouporder FROM searchhelpertitle WHERE (title != "");
+
+ CREATE TABLE visual_folder(_id INTEGER, path VARCHAR(256), folder_name VARCHAR(256), modified_date INT, web_account_id VARCHAR(256), storage_type INT, sns_type INT, lock_status INT, web_album_id VARCHAR(256), valid INT, primary key (path, folder_name, storage_type) );
+
+ CREATE TABLE image_meta(_id INTEGER, media_id INT, longitude DOUBLE, latitude DOUBLE, description VARCHAR(256), width INT, height INT, orientation INT, datetaken INT, primary key (media_id) );
+
+ CREATE TABLE visual_media(_id INTEGER, path VARCHAR(256), folder_id INT, display_name VARCHAR(256), content_type INT, rating INT, modified_date INT, thumbnail_path VARCHAR(256), http_url VARCHAR(256), valid INT, primary key (path, folder_id, display_name) );
+
+ CREATE TABLE video_bookmark(_id INTEGER, media_id INT, marked_time INT, thumbnail_path VARCHAR(256), primary key ( media_id, marked_time) );
+
+ CREATE TABLE video_meta(_id INTEGER, media_id INT, album VARCHAR(256), artist VARCHAR(256), title VARCHAR(256), description VARCHAR(256), youtube_category VARCHAR(256), last_played_time INT, duration INT, longitude DOUBLE, latitude DOUBLE, width INT, height INT, datetaken INT, primary key ( media_id) );
+
+ CREATE TABLE web_streaming(_id INTEGER, folder_id INT, title VARCHAR(256), duration INT, url VARCHAR(256), thumb_path VARCHAR(256), primary key (_id) );
+
+ CREATE TABLE visual_tag_map(_id INTEGER, media_id INT, tag_id INT, primary key ( media_id, tag_id) );
+ CREATE TABLE visual_tag(_id INTEGER, tag_name VARCHAR(256), primary key ( tag_name) );
+
+ INSERT INTO "visual_folder" VALUES(5000001,"/opt/media/Images and videos/My photo clips","My photo clips",1298917858,"",0,0,0,"",1);
+ INSERT INTO "visual_folder" VALUES(5000002,"/opt/media/Images and videos/My video clips","My video clips",1298917858,"",0,0,0,"",1);
+ INSERT INTO "visual_folder" VALUES(5000003,"/opt/media/Images and videos/Wallpapers","Wallpapers",1298917858,"",0,0,0,"",1);
+
+ INSERT INTO "image_meta" VALUES(1,1,1000.0,1000.0,"No description", 480, 800, 1, 1275064496);
+ INSERT INTO "image_meta" VALUES(2,2,1000.0,1000.0,"", 800, 480, 0, 0);
+ INSERT INTO "image_meta" VALUES(3,3,1000.0,1000.0,"", 800, 480, 0, 0);
+ INSERT INTO "image_meta" VALUES(4,4,1000.0,1000.0,"No description", 480, 800, 1, 1281973593);
+ INSERT INTO "image_meta" VALUES(5,5,1000.0,1000.0,"No description", 480, 800, 1, 1281973895);
+ INSERT INTO "image_meta" VALUES(6,7,1000.0,1000.0,"", 480, 800, 0, 0);
+ INSERT INTO "image_meta" VALUES(7,8,1000.0,1000.0,"", 480, 800, 0, 0);
+
+ INSERT INTO "visual_media" VALUES(1,"/opt/media/Images and videos/My photo clips/5_photo.JPG", 5000001,"5_photo.JPG",1,0,1298917858,"/opt/data/file-manager-service/.thumb/phone/.JPG-8ddcdba99df472b448908d21d13854ad.png","",1);
+ INSERT INTO "visual_media" VALUES(2,"/opt/media/Images and videos/My photo clips/2_photo.jpg", 5000001,"2_photo.jpg",1,0,1298917858,"/opt/data/file-manager-service/.thumb/phone/.jpg-1bf63a4205303cb894a1564d603d85e8.png","",1);
+ INSERT INTO "visual_media" VALUES(3,"/opt/media/Images and videos/My photo clips/1_photo.jpg", 5000001,"1_photo.jpg",1,0,1298917858,"/opt/data/file-manager-service/.thumb/phone/.jpg-d78db813538100657fe67bb739b391ce.png","",1);
+ INSERT INTO "visual_media" VALUES(4,"/opt/media/Images and videos/My photo clips/4_photo.jpg", 5000001,"4_photo.jpg",1,0,1298917858,"/opt/data/file-manager-service/.thumb/phone/.jpg-4681c28ed65b83f59c5af7f84be4487a.png","",1);
+ INSERT INTO "visual_media" VALUES(5,"/opt/media/Images and videos/My photo clips/3_photo.jpg", 5000001,"3_photo.jpg",1,0,1298917858,"/opt/data/file-manager-service/.thumb/phone/.jpg-871f45a1520706c878122ff456b67d1a.png","",1);
+ INSERT INTO "visual_media" VALUES(6,"/opt/media/Images and videos/My video clips/Helicopter.mp4", 5000002,"Helicopter.mp4",2,0,1298917858,"/opt/data/file-manager-service/.thumb/phone/.mp4-0c401c836306fcb51ff1ffa0f6bd5289.png","",1);
+ INSERT INTO "visual_media" VALUES(7,"/opt/media/Images and videos/Wallpapers/Default.png", 5000003,"Default.png",1,0,1298917858,"/opt/data/file-manager-service/.thumb/phone/.png-e860d4acbabab8388203316f9193bf1d.png","",1);
+ INSERT INTO "visual_media" VALUES(8,"/opt/media/Images and videos/Wallpapers/Home_default.png", 5000003,"Home_default.png",1,0,1298917858,"/opt/data/file-manager-service/.thumb/phone/.png-7fb48e238a87f86506fc9670004327f4.png","",1);
+
+ INSERT INTO "video_meta" VALUES(1, 6, "Unknown", "Unknown","Unknown", "Unknown","", 0, 99800, 1000.0, 1000.0, 640, 352, 0 );
+
+ CREATE VIEW mediainfo_folder AS select _id, path, folder_name as name, storage_type from visual_folder where valid=1 union select _id, path, folder_name, storage_type from audio_folder;
+
+ CREATE VIEW item_view AS select _id as item_id, path as file_path, display_name,thumbnail_path as thumbnail,modified_date as date_modified, valid,folder_id,content_type from visual_media where 1 union select audio_id ,path ,title ,thumbnail_path, modified_date, valid,folder_id,content_type from audio_media where 1;'
+fi
+
+vconftool set -t int db/filemanager/dbupdate "1"
+vconftool set -t int memory/filemanager/Mmc "0" -i
+
+if [ -f /opt/dbspace/.filemanager.db ]
+then
+ chown root:6017 /opt/dbspace/.filemanager.db
+ chown root:6017 /opt/dbspace/.filemanager.db-journal
+fi
+
+if [ -f /opt/dbspace/.media.db ]
+then
+ chown root:6017 /opt/dbspace/.media.db
+ chown root:6017 /opt/dbspace/.media.db-journal
+fi
+
+
+%files
+%defattr(-,root,root,-)
+%{_bindir}/media-server
+/etc/rc.d/init.d/mediasvr
+/etc/rc.d/rc3.d/S60mediasvr
+/etc/rc.d/rc5.d/S60mediasvr
+/usr/lib/libmedia-server.so.0
+/usr/lib/libmedia-server.so.0.0.0
+
+%files devel
+/usr/include/media-server/media-server-api.h
+/usr/lib/libmedia-server.so
+/usr/lib/pkgconfig/libmedia-server.pc