Switch to gmodule from linux dl functions 79/67779/1
authorMu-Woong Lee <muwoong.lee@samsung.com>
Thu, 28 Apr 2016 08:00:44 +0000 (17:00 +0900)
committerMu-Woong Lee <muwoong.lee@samsung.com>
Thu, 28 Apr 2016 08:00:44 +0000 (17:00 +0900)
Change-Id: Ia754d27ff650ad393ca8a3ec6d958bb9ab793341
Signed-off-by: Mu-Woong Lee <muwoong.lee@samsung.com>
packaging/context-provider.spec
src/media-stats/CMakeLists.txt
src/media-stats/MediaContentMonitor.cpp

index 9d7b30b..cc70bb4 100644 (file)
@@ -14,6 +14,7 @@ ExcludeArch: %{arm} aarch64 %ix86 x86_64
 
 BuildRequires: cmake
 
+BuildRequires: pkgconfig(gmodule-2.0)
 BuildRequires: pkgconfig(libcontext-server)
 BuildRequires: pkgconfig(vconf)
 BuildRequires: pkgconfig(capi-system-info)
index 19c9ea4..e30fdf2 100644 (file)
@@ -1,6 +1,7 @@
 SET(target "${target_prefix}-media-stats")
 
 SET(DEPS ${DEPS}
+       gmodule-2.0
        libmedia-utils
 )
 
@@ -14,7 +15,7 @@ FOREACH(flag ${PKG_MEDIA_STATS_CFLAGS})
 ENDFOREACH(flag)
 
 ADD_LIBRARY(${target} SHARED ${SRCS})
-TARGET_LINK_LIBRARIES(${target} ${PKG_MEDIA_STATS_LDFLAGS} ${target_shared} -ldl)
+TARGET_LINK_LIBRARIES(${target} ${PKG_MEDIA_STATS_LDFLAGS} ${target_shared})
 
 INSTALL(TARGETS ${target} DESTINATION ${CMAKE_INSTALL_LIBDIR}/${target_dir})
 
index 634de43..d99da36 100644 (file)
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-#include <dlfcn.h>
+#include <gmodule.h>
 #include <time.h>
 #include <media-util-noti-common.h>
 #include <Types.h>
@@ -82,18 +82,20 @@ void ctx::MediaContentMonitor::onSignal(const char *sender, const char *path, co
 
 bool ctx::MediaContentMonitor::__getPlayCount(int updateItem, int updateType, int mediaType, char *uuid, int *count)
 {
-       void *soHandle = dlopen(SO_PATH, RTLD_LAZY | RTLD_GLOBAL);
-       IF_FAIL_RETURN_TAG(soHandle, false, _E, "%s", dlerror());
+       GModule *soHandle = g_module_open(SO_PATH, G_MODULE_BIND_LAZY);
+       IF_FAIL_RETURN_TAG(soHandle, false, _E, "%s", g_module_error());
 
-       get_play_count_t getCount = reinterpret_cast<get_play_count_t>(dlsym(soHandle, "getMediaPlayCount"));
-       if (!getCount) {
-               _E("%s", dlerror());
-               dlclose(soHandle);
+       gpointer symbol;
+       if (!g_module_symbol(soHandle, "getMediaPlayCount", &symbol) || symbol == NULL) {
+               _E("%s", g_module_error());
+               g_module_close(soHandle);
                return false;
        }
 
+       get_play_count_t getCount = reinterpret_cast<get_play_count_t>(symbol);
+
        bool ret = getCount(updateItem, updateType, mediaType, uuid, count);
-       dlclose(soHandle);
+       g_module_close(soHandle);
 
        return ret;
 }