#include "config.h"
#include "TizenLinkEffect.h"
+#if ENABLE(TIZEN_LINK_EFFECT)
#include "feedback.h"
+#include <dlfcn.h>
-#if ENABLE(TIZEN_LINK_EFFECT)
namespace WebCore {
+static int (*feedback_initialize)();
+static int (*feedback_play)(int);
+static int (*feedback_deinitialize)();
+
+static void* getHandle()
+{
+ void* handle = dlopen("libfeedback.so.0", RTLD_NOW);
+ if (!handle)
+ return 0;
+
+ feedback_initialize = (int(*)(void))dlsym(handle, "feedback_initialize");
+ if (!feedback_initialize) {
+ dlclose(handle);
+ return 0;
+ }
+
+ feedback_play = (int(*)(int))dlsym(handle, "feedback_play");
+ if (!feedback_play) {
+ dlclose(handle);
+ return 0;
+ }
+
+ feedback_deinitialize = (int(*)(void))dlsym(handle, "feedback_deinitialize");
+ if (!feedback_deinitialize) {
+ dlclose(handle);
+ return 0;
+ }
+
+ return handle;
+}
+
void TizenLinkEffect::playLinkEffect()
{
+ static void* handle = getHandle();
+
+ if (!handle)
+ return;
+
feedback_initialize();
feedback_play(FEEDBACK_PATTERN_TAP);
feedback_deinitialize();
#
# feedback_FOUND - system has feedback
# feedback_INCLUDE_DIRS - the feedback include directories
-# feedback_LIBRARIES - link these to use feedback
include(LibFindMacros)
PATH_SUFFIXES feedback
)
-# Finally the library itself
-find_library(feedback_LIBRARY
- NAMES feedback
- PATHS ${feedback_PKGCONF_LIBRARY_DIRS}
-)
-
-# Set the include dir variables and the libraries and let libfind_process do the rest.
-# NOTE: Singular variables for this library, plural for libraries this this lib depends on.
+# Set the include dir variables.
set(feedback_PROCESS_INCLUDES feedback_INCLUDE_DIR feddback_INCLUDE_DIRS)
-set(feedback_PROCESS_LIBS feedback_LIBRARY feedback_LIBRARIES)
-libfind_process(libfeedback)