From: Rafal Galka Date: Tue, 3 Mar 2015 10:55:14 +0000 (+0100) Subject: [Exif] Old code removed X-Git-Tag: submit/tizen_tv/20150603.064601~1^2~329 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b9b38b407c9e1fdb7c426ba55707da7ef0b22749;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git [Exif] Old code removed [Verification] TCT results without change (60 / 63) Change-Id: I81156e2c1d3fc476a3dbb89efb99e0cae5487240 Signed-off-by: Rafal Galka --- diff --git a/src/exif/old/CMakeLists.txt b/src/exif/old/CMakeLists.txt deleted file mode 100644 index d3e6672a..00000000 --- a/src/exif/old/CMakeLists.txt +++ /dev/null @@ -1,85 +0,0 @@ -SET(TARGET_NAME ${exif_target}) -SET(DESTINATION_NAME ${exif_dest}) -SET(TARGET_IMPL_NAME ${exif_impl}) - -PKG_CHECK_MODULES(platform_pkgs_exif REQUIRED libexif) - -ADD_DEFINITIONS("-fvisibility=hidden") - -IF(ENABLE_TV) -INCLUDE_DIRECTORIES( - ${INCLUDE_COMMON} - ${tizen_include} - ${timeutil_include} - ${filesystem.old_include} - ${platform_pkgs_exif_INCLUDE_DIRS} -) -ELSE() -INCLUDE_DIRECTORIES( - ${INCLUDE_COMMON} - ${tizen_include} - ${timeutil_include} - ${filesystem_include} - ${platform_pkgs_exif_INCLUDE_DIRS} -) -ENDIF(ENABLE_TV) - -IF(ENABLE_TV) -SET(CMAKE_INSTALL_RPATH - ${CMAKE_INSTALL_RPATH} - ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${timeutil_dest} - ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${filesystem.old_dest} - ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME} -) -ELSE() -SET(CMAKE_INSTALL_RPATH - ${CMAKE_INSTALL_RPATH} - ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${timeutil_dest} - ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${filesystem_dest} - ${CMAKE_INSTALL_PREFIX}/${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME} -) -ENDIF(ENABLE_TV) - -SET(SRCS_IMPL - JSExifManager.cpp - ExifManager.cpp - JSExifInformation.cpp - ExifInformation.cpp - ExifManagerCallbacks.cpp - ExifUtil.cpp - ExifTagSaver.cpp - ExifGPSLocation.cpp - ExifGPSTime.cpp - Rational.cpp - JpegFile.cpp -) - -ADD_LIBRARY(${TARGET_IMPL_NAME} SHARED ${SRCS_IMPL}) - -TARGET_LINK_LIBRARIES(${TARGET_IMPL_NAME} - ${LIBS_COMMON} - ${tizen_impl} - ${timeutil_impl} - ${filesystem_impl} - ${filesystem_config} - ${platform_pkgs_exif_LIBRARIES} -) - -SET(SRCS - plugin_config.cpp - plugin_initializer.cpp -) - -ADD_LIBRARY(${TARGET_NAME} SHARED ${SRCS}) - -TARGET_LINK_LIBRARIES(${TARGET_NAME} - ${TARGET_IMPL_NAME} -) - -INSTALL(TARGETS ${TARGET_NAME} ${TARGET_IMPL_NAME} LIBRARY DESTINATION ${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME}) -INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/config.xml DESTINATION ${DESTINATION_LIB_PREFIX}/${DESTINATION_NAME}) - -INSTALL( - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${DESTINATION_HEADER_PREFIX}/exif - FILES_MATCHING PATTERN "*.h" PATTERN "CMakeFiles" EXCLUDE -) diff --git a/src/exif/old/ExifGPSTime.cpp b/src/exif/old/ExifGPSTime.cpp deleted file mode 100644 index db8d45a1..00000000 --- a/src/exif/old/ExifGPSTime.cpp +++ /dev/null @@ -1,275 +0,0 @@ -// -// Tizen Web Device API -// Copyright (c) 2014 Samsung Electronics Co., Ltd. -// -// Licensed under the Apache License, Version 2.0 (the License); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -#include "ExifGPSTime.h" - -#include -#include -#include - -#include -#include -#include - -namespace extension { -namespace exif { - -bool isValidDateFormat(const std::string& date) -{ - //Exif 2.2 spec: "YYYY:MM:DD." - //There is no trailig '.' at the end it is just null terminate sign - //Example: tag name:GPSDateStamp type:ASCII size:11 components:11 value:2014:06:25 - // RAW DATA:[32 30 31 34 3a 30 36 3a 32 35 00] - - if (date.length() != 10) { - return false; - } - - //"YYYY:MM:DD" - // 0123456789 - // : : - for(size_t i = 0; i < date.length(); ++i) { - const char& cur = date[i]; - - if (4 == i || 7 == i) { - if (cur != ':') { - return false; - } - } - else { - if (cur < '0' || cur > '9') { - return false; - } - } - } - return true; -} - -bool extractDateFromString(const std::string& date, int& out_year, int& out_month, - int& out_day) -{ - if (!isValidDateFormat(date)) { - return false; - } - - if (3 != sscanf(date.c_str(), "%d:%d:%d", &out_year, &out_month, &out_day)) { - LOGE("Couldn't parse date string: [%s]", date.c_str()); - return false; - } - - return true; -} - -bool isValidTime(const Rationals& time) -{ - return (time.size() >= 3) && - time[0].isValid() && - time[1].isValid() && - time[2].isValid() && - (time[0].nominator % time[0].denominator == 0) && - (time[1].nominator % time[1].denominator == 0) && - (time[2].nominator % time[2].denominator == 0); -} - -ExifGPSTime::ExifGPSTime() : - m_time_is_set(false), - m_date_is_set(false), - m_time_and_date(0) -{ - m_time.push_back(Rational()); - m_time.push_back(Rational()); - m_time.push_back(Rational()); -} - -bool ExifGPSTime::isValid() const -{ - return isComplete() && isValidDateFormat(m_date) && isValidTime(m_time); -} - -bool ExifGPSTime::isComplete() const -{ - return m_time_is_set && m_date_is_set; -} - -void ExifGPSTime::unsetAll() -{ - m_date_is_set = false; - m_time_is_set = false; -} - -void ExifGPSTime::setTime(const Rationals& time) -{ - if (time.size() < 3) { - LOGE("time is not having enought members: %d needed 3!", time.size()); - return; - } - - if (time.size() > 3) { - LOGW("time is having more members: %d then needed 3!", time.size()); - } - - if (!isValidTime(time)) { - LOGE("time is invalid: [%s]h [%s]m [%s]s", time[0].toString().c_str(), - time[1].toString().c_str(), - time[2].toString().c_str()); - return; - } - - //Copy just 3 Rationals - m_time_is_set = true; - for(size_t i = 0; i < 3 && i < time.size(); ++i) { - m_time[i] = time[i]; - } -} - -const Rationals& ExifGPSTime::getTime() const -{ - return m_time; -} - -bool ExifGPSTime::isTimeSet() const -{ - return m_time_is_set; -} - -void ExifGPSTime::setDate(const std::string& date) -{ - if (!isValidDateFormat(date)) { - LOGW("Trying to set incorrect date: [%s]", date.c_str()); - return; - } - - m_date_is_set = true; - m_date = date; -} - -const std::string& ExifGPSTime::getDate() const -{ - return m_date; -} - -bool ExifGPSTime::isDateSet() const -{ - return m_date_is_set; -} - -time_t ExifGPSTime::getDateAndTime() const -{ - if (!isValid()) { - LOGE("ExifGPSTime object is not valid!"); - return 0; - } - - int year, month, day; - if (!extractDateFromString(m_date, year, month, day)) { - LOGE("Couldn't extract date from m_date string"); - return 0; - } - - time_t out_time = ExifUtil::convertToTimeT(year, month, day, - m_time[0].nominator / m_time[0].denominator, - m_time[1].nominator / m_time[1].denominator, - m_time[2].nominator / m_time[2].denominator); - - LOGD("[%s] [%s]h [%s]m [%s]s ---> time_t: %d", m_date.c_str(), - m_time[0].toString().c_str(), - m_time[1].toString().c_str(), - m_time[2].toString().c_str(), - out_time); - - return out_time; -} - -void ExifGPSTime::setDateAndTime(time_t new_time) -{ - struct tm* utc = gmtime(&new_time); - - int year, month, day, hour, min, sec; - ExifUtil::extractFromTimeT(new_time, year, month, day, hour, min, sec); - - std::stringstream new_date_ss; - new_date_ss << std::setfill('0') << std::setw(4) << year << ':' ; - new_date_ss << std::setfill('0') << std::setw(2) << month << ':'; - new_date_ss << std::setfill('0') << std::setw(2) << day; - m_date = new_date_ss.str(); - m_date_is_set = true; - - m_time[0] = Rational(static_cast(hour), 1); - m_time[1] = Rational(static_cast(min), 1); - m_time[2] = Rational(static_cast(sec), 1); - m_time_is_set = true; - - LOGD("time_t: %d ---> [%s] [%s]h [%s]m [%s]s", - new_time, - m_date.c_str(), - m_time[0].toString().c_str(), - m_time[1].toString().c_str(), - m_time[2].toString().c_str()); -} - -Time::TZDatePtr ExifGPSTime::getTZDate() const -{ - if(!isValid()) { - LOGW("ExifGPSTime is not valid"); - return Time::TZDatePtr(); - } - - int year, month, day; - extractDateFromString(m_date, year, month, day); - - const int hour = static_cast(m_time[0].nominator / m_time[0].denominator); - const int min = static_cast(m_time[1].nominator / m_time[1].denominator); - const int sec = static_cast(m_time[2].nominator / m_time[2].denominator); - - Time::TZDate* new_time = new (std::nothrow) Time::TZDate(year, month-1, day, - hour, min, sec, 0, "UTC"); - if(!new_time) { - LOGE("Couldn't create TZDate!"); - return Time::TZDatePtr(); - } - - return Time::TZDatePtr(new_time); -} - -void ExifGPSTime::setDateAndTime(Time::TZDatePtr new_time) -{ - if(!new_time) { - LOGW("TZDate new_time is NULL"); - } - - std::stringstream new_date_ss; - new_date_ss << std::setfill('0') << std::setw(4) << new_time->getUTCFullYear() << ':'; - new_date_ss << std::setfill('0') << std::setw(2) << new_time->getUTCMonth()+1 << ':'; - new_date_ss << std::setfill('0') << std::setw(2) << new_time->getUTCDate(); - m_date = new_date_ss.str(); - m_date_is_set = true; - - m_time[0] = Rational(static_cast(new_time->getUTCHours()), 1); - m_time[1] = Rational(static_cast(new_time->getUTCMinutes()), 1); - m_time[2] = Rational(static_cast(new_time->getUTCSeconds()), 1); - m_time_is_set = true; - - LOGD("TZDatePtr: %d ---> [%s] [%s]h [%s]m [%s]s", - new_time->toString().c_str(), - m_date.c_str(), - m_time[0].toString().c_str(), - m_time[1].toString().c_str(), - m_time[2].toString().c_str()); -} - -} // exif -} // extension diff --git a/src/exif/old/ExifGPSTime.h b/src/exif/old/ExifGPSTime.h deleted file mode 100644 index 3ac21f2f..00000000 --- a/src/exif/old/ExifGPSTime.h +++ /dev/null @@ -1,84 +0,0 @@ -// -// Tizen Web Device API -// Copyright (c) 2014 Samsung Electronics Co., Ltd. -// -// Licensed under the Apache License, Version 2.0 (the License); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -#ifndef __TIZEN_EXIF_EXIF_GPS_TIME_H_ -#define __TIZEN_EXIF_EXIF_GPS_TIME_H_ - -#include - -#include - -#include "ExifUtil.h" - -namespace extension { -namespace exif { - -class ExifGPSTime -{ -public: - ExifGPSTime(); - - /** - * Returns true if both and time is set and valid - */ - bool isValid() const; - - /** - * Returns true if both date and time has been set - */ - bool isComplete() const; - - /** - * Unset both date and time - */ - void unsetAll(); - - void setTime(const Rationals& date); - const Rationals& getTime() const; - bool isTimeSet() const; - - void setDate(const std::string& date); - const std::string& getDate() const; - bool isDateSet() const; - - time_t getDateAndTime() const; - void setDateAndTime(time_t new_time); - - /** - * Returns NULL pointer if this ExifGPSTime is not valid - */ - Time::TZDatePtr getTZDate() const; - - /** - * If new_time is NULL nothing is done - */ - void setDateAndTime(Time::TZDatePtr new_time); - -private: - Rationals m_time; - bool m_time_is_set; - - std::string m_date; - bool m_date_is_set; - - time_t m_time_and_date; -}; - -} // exif -} // extension - -#endif // __TIZEN_EXIF_EXIF_GPS_TIME_H_ diff --git a/src/exif/old/ExifManager.cpp b/src/exif/old/ExifManager.cpp deleted file mode 100644 index deb31734..00000000 --- a/src/exif/old/ExifManager.cpp +++ /dev/null @@ -1,434 +0,0 @@ -// -// Tizen Web Device API -// Copyright (c) 2014 Samsung Electronics Co., Ltd. -// -// Licensed under the Apache License, Version 2.0 (the License); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -#include "ExifManager.h" - -#include -#include - -#include -#include -#include -#include - -#include "ExifUtil.h" -#include "JSExifInformation.h" - -using namespace DeviceAPI::Common; -using namespace DeviceAPI::Time; - -namespace DeviceAPI { -namespace Exif { - -ExifManager::ExifManager() -{ -} - -ExifManager::~ExifManager() -{ -} - -ExifManager& ExifManager::getInstance() -{ - static ExifManager instance; - return instance; -} - -gboolean ExifManager::getExifInfoCompleted(void *data) -{ - LOGD("Entered"); - - auto callback = static_cast(data); - if (!callback) { - LOGE("callback is null"); - return false; - } - - JSContextRef context = callback->getContext(); - if (!Common::GlobalContextManager::getInstance()->isAliveGlobalContext(context)) { - LOGE("context was closed"); - delete callback; - callback = NULL; - return false; - } - - try { - if (callback->isError()) { - JSObjectRef error_obj = Common::JSWebAPIErrorFactory::makeErrorObject( - context, - callback->getErrorName(), - callback->getErrorMessage()); - callback->callErrorCallback(error_obj); - } - else { - JSValueRef js_value = JSExifInformation::makeJSObject(context, - callback->getExifInfo()); - callback->callSuccessCallback(js_value); - } - } - catch (const Common::BasePlatformException &error) { - LOGE("%s (%s)", (error.getName()).c_str(), (error.getMessage()).c_str()); - } - catch (...) { - LOGE("Unknown error occured when calling getExifInfo callback"); - } - - delete callback; - callback = NULL; - return false; -} - -void verifyThatURIIsFile(const std::string& uri, - const std::string& req_permission) -{ - if(!ExifUtil::isValidAbsoluteURI(uri)) { - LOGE("URI [%s] is not valid absolute URI", uri.c_str()); - throw InvalidValuesException("URI is not valid"); - } - - bool exists = false, granted = false; - Filesystem::NodeType type = Filesystem::NT_FILE; - ExifUtil::getURIInfo(uri, Filesystem::NT_FILE, req_permission, exists, type, granted); - - if(!exists) { - LOGE("URI [%s] is not pointing at existing file", uri.c_str()); - throw NotFoundException("URI is not pointing at existing file"); - } - - if(type != Filesystem::NT_FILE) { - LOGE("URI [%s] is not pointing at file", uri.c_str()); - throw NotFoundException("URI is not pointing at file"); - } - - if(!granted) { - LOGE("URI [%s] is pointing at file which cannot be accesed (not: %s)", - uri.c_str(), req_permission.c_str()); - throw IOException("URI is pointing at file which cannot be accessed" - " - not enough permissions"); - } -} - -void* ExifManager::getExifInfoThread(void* data) -{ - LOGD("Entered"); - ExifInfoCallbackData* callback = NULL; - - try { - callback = static_cast(data); - if (!callback) { - LOGE("Callback is NULL!"); - return NULL; - } - - verifyThatURIIsFile(callback->getUri(), "r"); - callback->setExifInfo(ExifInformation::loadFromURI(callback->getUri())); - } - catch (const BasePlatformException& err) { - LOGE("%s (%s)", (err.getName()).c_str(), (err.getMessage()).c_str()); - callback->setError(err.getName(), err.getMessage()); - } - catch (...) { - LOGE("Get Exif from file failed"); - callback->setError(JSWebAPIErrorFactory::UNKNOWN_ERROR, - "Get Exif from file failed"); - } - - if (0 == g_idle_add(getExifInfoCompleted, static_cast(callback))) { - delete callback; - callback = NULL; - LOGE("g_idle addition failed"); - } - - return NULL; -} - -void ExifManager::getExifInfo(ExifInfoCallbackData* cbdata) -{ - LOGD("Entered"); - if (!cbdata) { - LOGE("cbdata is NULL"); - throw DeviceAPI::Common::UnknownException("NULL callback error"); - } - - pthread_t thread; - if (pthread_create(&thread, NULL, getExifInfoThread, - static_cast(cbdata))) { - LOGE("Failed to create pthread for getExifInfo()"); - throw UnknownException("Could not load Exif from file"); - } - - if (pthread_detach(thread)) { - LOGE("Failed to detach the pthread for getExifInfo()"); - } -} - -gboolean ExifManager::saveExifInfoCompleted(void* data) -{ - LOGD("Entered"); - - auto callback = static_cast(data); - if (!callback) { - LOGE("callback is null"); - return false; - } - - JSContextRef context = callback->getContext(); - if (!Common::GlobalContextManager::getInstance()->isAliveGlobalContext(context)) { - LOGE("context was closed"); - delete callback; - callback = NULL; - return false; - } - - try { - if (callback->isError()) { - JSObjectRef error_obj = Common::JSWebAPIErrorFactory::makeErrorObject( - context, - callback->getErrorName(), - callback->getErrorMessage()); - callback->callErrorCallback(error_obj); - } - else { - callback->callSuccessCallback(); - } - } - catch (const Common::BasePlatformException &error) { - LOGE("%s (%s)", (error.getName()).c_str(), (error.getMessage()).c_str()); - } - catch (...) { - LOGE("Unknown error occured when calling saveExifInfo callback"); - } - - delete callback; - callback = NULL; - return false; -} - -void* ExifManager::saveExifInfoThread(void* data) -{ - LOGD("Entered"); - ExifInfoCallbackData* callback = NULL; - - try { - callback = static_cast(data); - if (!callback) { - LOGE("Callback is NULL!"); - return NULL; - } - - verifyThatURIIsFile(callback->getUri(), "rw"); - - const std::string file_path = ExifUtil::convertUriToPath(callback->getUri()); - callback->getExifInfo()->saveToFile(file_path); - } - catch (const BasePlatformException& err) { - LOGE("%s (%s)", (err.getName()).c_str(), (err.getMessage()).c_str()); - callback->setError(err.getName(), err.getMessage()); - } - catch (...) { - LOGE("Save Exif to file failed"); - callback->setError(JSWebAPIErrorFactory::UNKNOWN_ERROR, - "Save Exif to file failed"); - } - - if (0 == g_idle_add(saveExifInfoCompleted, static_cast(callback))) { - delete callback; - callback = NULL; - LOGE("g_idle addition failed"); - } - - return NULL; -} - -void ExifManager::saveExifInfo(ExifInfoCallbackData* cbdata) -{ - LOGD("Entered"); - if (!cbdata) { - LOGE("cbdata is NULL"); - throw DeviceAPI::Common::UnknownException("NULL callback error"); - } - - pthread_t thread; - if (pthread_create(&thread, NULL, saveExifInfoThread, - static_cast(cbdata))) { - LOGE("Failed to create pthread for saveExifInfo()"); - throw UnknownException("Could not save Exif to file"); - } - - if (pthread_detach(thread)) { - LOGE("Failed to detach the pthread for saveExifInfo()"); - } -} - -gboolean ExifManager::getThumbnailCompleted(void* data) -{ - LOGD("Entered"); - auto callback = static_cast(data); - if (!callback) { - LOGE("Callback is null"); - return false; - } - - JSContextRef context = callback->getContext(); - if (!GlobalContextManager::getInstance()->isAliveGlobalContext(context)) { - LOGE("context was closed"); - delete callback; - callback = NULL; - return false; - } - - try { - if (callback->isError()) { - LOGD("Calling error callback"); - JSObjectRef errobj = JSWebAPIErrorFactory::makeErrorObject(context, - callback->getErrorName(), - callback->getErrorMessage()); - callback->callErrorCallback(errobj); - } - else { - const std::string& thumbnail_uri = callback->getThumbnailUri(); - JSValueRef js_result = NULL; - if (thumbnail_uri.empty()) { - js_result = JSValueMakeNull(context); - } - else { - js_result = JSUtil::toJSValueRef(context, thumbnail_uri); - } - callback->callSuccessCallback(js_result); - } - } - catch (const BasePlatformException& err) { - LOGE("Error while calling getThumbnail callback: %s (%s)", - (err.getName()).c_str(), (err.getMessage()).c_str()); - } - catch (...) { - LOGE("Unknown error occured when calling getThumbnail callback"); - } - - delete callback; - callback = NULL; - - return false; -} - -void* ExifManager::getThumbnailThread(void* data) -{ - LOGD("Entered"); - GetThumbnailCallbackUserData* callback = NULL; - ExifLoader* exif_loader = NULL; - ExifData* exif_data = NULL; - - try { - callback = static_cast(data); - if (!callback) { - LOGE("Callback is NULL!"); - return NULL; - } - - verifyThatURIIsFile(callback->getUri(), "r"); - - exif_loader = exif_loader_new(); - if (!exif_loader) { - LOGE("exif_loader_new failed -> returned NULL"); - throw UnknownException("Could not get thumbnail from Exif"); - } - - const std::string file_path = ExifUtil::convertUriToPath(callback->getUri()); - LOGD("Get thumbnail from Exif in file: [%s]", file_path.c_str()); - - exif_loader_write_file(exif_loader, file_path.c_str()); - exif_data = exif_loader_get_data(exif_loader); - if (!exif_data) { - LOGE("exif_loader_get_data failed -> returned NULL"); - throw UnknownException("Could not get thumbnail from Exif"); - } - - if (exif_data->data && exif_data->size) { - gchar* ch_uri = g_base64_encode(exif_data->data, exif_data->size); - - std::string ext = file_path.substr(file_path.find_last_of(".") + 1); - std::transform(ext.begin(), ext.end(), ext.begin(), ::tolower); - - if ("jpg" == ext) { - ext = "jpeg"; - } - - if ("jpeg" == ext || "png" == ext || "gif" == ext) { - std::string uri ="data:image/"+ext+";base64," + ch_uri; - callback->setThumbnailUri(uri); - } - else { - LOGE("extension: %s is not valid (jpeg/jpg/png/gif is supported)"); - throw InvalidValuesException("Invalid file type"); - } - } - else { - callback->setThumbnailUri(std::string()); - } - - } - catch (const BasePlatformException& err) { - LOGE("%s (%s)", (err.getName()).c_str(), (err.getMessage()).c_str()); - callback->setError(err.getName(), err.getMessage()); - } - catch (...) { - LOGE("Get thumbnail from Exif failed"); - callback->setError(JSWebAPIErrorFactory::UNKNOWN_ERROR, - "Get thumbnail from Exif failed"); - } - - if (exif_loader) { - exif_loader_unref(exif_loader); - exif_loader = NULL; - } - - if (exif_data) { - exif_data_unref(exif_data); - exif_data = NULL; - } - - if (!g_idle_add(getThumbnailCompleted, static_cast(callback))) { - LOGE("g_idle addition failed"); - delete callback; - callback = NULL; - } - - return NULL; -} - -void ExifManager::getThumbnail(GetThumbnailCallbackUserData* cbdata) -{ - LOGD("Entered"); - if (!cbdata) { - LOGE("cbdata is NULL"); - throw DeviceAPI::Common::UnknownException("NULL callback error"); - } - - pthread_t thread; - if (pthread_create(&thread, NULL, getThumbnailThread, - static_cast(cbdata))) { - LOGE("Failed to create pthread for getThumbnail()"); - throw UnknownException("Could not get thumbnail from Exif"); - } - - if (pthread_detach(thread)) { - LOGE("Failed to detach the pthread for getThumbnail()"); - } -} - -} // Exif -} // DeviceAPI diff --git a/src/exif/old/ExifManager.h b/src/exif/old/ExifManager.h deleted file mode 100644 index f425da42..00000000 --- a/src/exif/old/ExifManager.h +++ /dev/null @@ -1,59 +0,0 @@ -// -// Tizen Web Device API -// Copyright (c) 2014 Samsung Electronics Co., Ltd. -// -// Licensed under the Apache License, Version 2.0 (the License); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -#ifndef __TIZEN_EXIF_EXIFMANAGER_H_ -#define __TIZEN_EXIF_EXIFMANAGER_H_ - -#include -#include -#include - -#include "ExifManagerCallbacks.h" -#include "ExifInformation.h" - -namespace DeviceAPI { -namespace Exif { - -class ExifManager: public Common::SecurityAccessor -{ -public: - static ExifManager& getInstance(); - virtual ~ExifManager(); - - void getExifInfo(ExifInfoCallbackData* cbdata); - void saveExifInfo(ExifInfoCallbackData* cbdata); - void getThumbnail(GetThumbnailCallbackUserData* cbdata); - -private: - ExifManager(); - ExifManager(const ExifManager&); - ExifManager& operator=(const ExifManager&); - - static gboolean getExifInfoCompleted(void* data); - static void* getExifInfoThread(void* data); - - static gboolean saveExifInfoCompleted(void* data); - static void* saveExifInfoThread(void* data); - - static gboolean getThumbnailCompleted(void* data); - static void* getThumbnailThread(void* data); -}; - -} // Exif -} // DeviceAPI - -#endif // __TIZEN_EXIF_EXIFMANAGER_H_ diff --git a/src/exif/old/ExifManagerCallbacks.cpp b/src/exif/old/ExifManagerCallbacks.cpp deleted file mode 100644 index 5c0f43e2..00000000 --- a/src/exif/old/ExifManagerCallbacks.cpp +++ /dev/null @@ -1,119 +0,0 @@ -// -// Tizen Web Device API -// Copyright (c) 2014 Samsung Electronics Co., Ltd. -// -// Licensed under the Apache License, Version 2.0 (the License); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -#include "ExifManagerCallbacks.h" - -namespace DeviceAPI { -namespace Exif { - -///////////////// ExifManagerCallbackUserData //////////////////////// -ExifManagerCallbackUserData::ExifManagerCallbackUserData(JSContextRef globalCtx, - std::string uri) : - CallbackUserData(globalCtx), - m_uri(uri), - m_is_error(false) -{ - LOGD("Entered"); -} - -ExifManagerCallbackUserData::~ExifManagerCallbackUserData() -{ -} - -void ExifManagerCallbackUserData::setError(const std::string& err_name, -const std::string& err_message) -{ - // keep only first error in chain - if (!m_is_error) { - m_is_error = true; - m_err_name = err_name; - m_err_message = err_message; - } -} - -std::string& ExifManagerCallbackUserData::getUri() -{ - return m_uri; -} - -void ExifManagerCallbackUserData::setUri(const std::string& uri) -{ - m_uri = uri; -} - -bool ExifManagerCallbackUserData::isError() const -{ - return m_is_error; -} - -const std::string& ExifManagerCallbackUserData::getErrorName() const -{ - return m_err_name; -} - -const std::string& ExifManagerCallbackUserData::getErrorMessage() const -{ - return m_err_message; -} - - -///////////////// ExifInfoCallbackData //////////////////////// -ExifInfoCallbackData::ExifInfoCallbackData( - JSContextRef globalCtx, std::string uri): - ExifManagerCallbackUserData(globalCtx, uri) -{ - LOGD("Entered"); -} - -ExifInfoCallbackData::~ExifInfoCallbackData() -{ - LOGD("Entered"); -} - -void ExifInfoCallbackData::setExifInfo(ExifInformationPtr info) -{ - m_exif_info = info; -} - -ExifInformationPtr ExifInfoCallbackData::getExifInfo() const -{ - return m_exif_info; -} - -///////////////// GetThumbnailCallbackUserData //////////////////////// -GetThumbnailCallbackUserData::GetThumbnailCallbackUserData(JSContextRef global_ctx, - std::string uri) : - ExifManagerCallbackUserData(global_ctx, uri) -{ -} - -GetThumbnailCallbackUserData::~GetThumbnailCallbackUserData() -{ -} - -std::string& GetThumbnailCallbackUserData::getThumbnailUri() -{ - return m_thumbnail_uri; -} - -void GetThumbnailCallbackUserData::setThumbnailUri(const std::string& uri) -{ - m_thumbnail_uri = uri; -} - -} // Exif -} // DeviceAPI diff --git a/src/exif/old/ExifManagerCallbacks.h b/src/exif/old/ExifManagerCallbacks.h deleted file mode 100644 index 18de865b..00000000 --- a/src/exif/old/ExifManagerCallbacks.h +++ /dev/null @@ -1,93 +0,0 @@ -// -// Tizen Web Device API -// Copyright (c) 2014 Samsung Electronics Co., Ltd. -// -// Licensed under the Apache License, Version 2.0 (the License); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -#ifndef __TIZEN_EXIF_EXIFMANAGER_CALLBACK_USER_DATA_H_ -#define __TIZEN_EXIF_EXIFMANAGER_CALLBACK_USER_DATA_H_ - -#include -#include -#include -#include "ExifInformation.h" - - -namespace DeviceAPI { -namespace Exif { - -///////////////// ExifManagerCallbackUserData //////////////////////// -class ExifManagerCallbackUserData: public Common::CallbackUserData { -public: - ExifManagerCallbackUserData(JSContextRef globalCtx, - std::string uri); - virtual ~ExifManagerCallbackUserData(); - - std::string& getUri(); - void setUri(const std::string& uri); - - void setError(const std::string& err_name, - const std::string& err_message); - bool isError() const; - const std::string& getErrorName() const; - const std::string& getErrorMessage() const; - -private: - std::string m_uri; - - bool m_is_error; - std::string m_err_name; - std::string m_err_message; -}; - - -///////////////// ExifInfoCallbackData //////////////////////// -class ExifInfoCallbackData; -typedef std::shared_ptr ExifInfoCallbackDataPtr; - -struct ExifInfoCallbackDataHolder { - ExifInfoCallbackDataPtr ptr; -}; - -class ExifInfoCallbackData : public ExifManagerCallbackUserData -{ -public: - ExifInfoCallbackData(JSContextRef globalCtx, std::string uri); - virtual ~ExifInfoCallbackData(); - - void setExifInfo(ExifInformationPtr info); - ExifInformationPtr getExifInfo() const; - -private: - ExifInformationPtr m_exif_info; -}; - -///////////////// GetThumbnailCallbackUserData //////////////////////// -class GetThumbnailCallbackUserData: public ExifManagerCallbackUserData { -public: - GetThumbnailCallbackUserData(JSContextRef global_ctx, - std::string uri); - virtual ~GetThumbnailCallbackUserData(); - - std::string& getThumbnailUri(); - void setThumbnailUri(const std::string& uri); - -private: - std::string m_thumbnail_uri; -}; - -} // Exif -} // DeviceAPI - -#endif // __TIZEN_EXIF_EXIFMANAGER_CALLBACK_USER_DATA_H_ diff --git a/src/exif/old/config.xml b/src/exif/old/config.xml deleted file mode 100644 index 351b1cc0..00000000 --- a/src/exif/old/config.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - libwrt-plugins-tizen-exif.so - exif.install.uri - - - http://tizen.org/privilege/exif.read - exif.read - - - - http://tizen.org/privilege/exif.write - exif.write - - - \ No newline at end of file diff --git a/src/exif/old/plugin_config.cpp b/src/exif/old/plugin_config.cpp deleted file mode 100644 index 75835cde..00000000 --- a/src/exif/old/plugin_config.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// -// Tizen Web Device API -// Copyright (c) 2014 Samsung Electronics Co., Ltd. -// -// Licensed under the Apache License, Version 2.0 (the License); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an AS IS BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -#include -#include -#include -#include -#include - -#include "plugin_config.h" - -using namespace WrtDeviceApis::Commons; - -namespace DeviceAPI { -namespace Exif { - -static FunctionMapping createExifFunctions(); - -static FunctionMapping ExifFunctions = - createExifFunctions(); - -#pragma GCC visibility push(default) -DEFINE_FUNCTION_GETTER(Exif, ExifFunctions); -#pragma GCC visibility pop - -static FunctionMapping createExifFunctions() -{ - /** - * Functions - */ - FunctionMapping exifMapping; - - return exifMapping; -} - -} -} diff --git a/src/exif/old/plugin_config.h b/src/exif/old/plugin_config.h deleted file mode 100644 index 09126f23..00000000 --- a/src/exif/old/plugin_config.h +++ /dev/null @@ -1,39 +0,0 @@ -// -// Tizen Web Device API -// Copyright (c) 2014 Samsung Electronics Co., Ltd. -// -// Licensed under the Apache License, Version 2.0 (the License); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an AS IS BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -#ifndef _EXIF_PLUGIN_CONFIG_H_ -#define _EXIF_PLUGIN_CONFIG_H_ - -#include -#include -#include -#include "plugin_config_impl.h" - -namespace DeviceAPI { -namespace Exif { - -DECLARE_FUNCTION_GETTER(Exif); - -#define EXIF_CHECK_ACCESS(functionName) \ - aceCheckAccess >( \ - getExifFunctionData, \ - functionName) - -} -} -#endif // _EXIF_PLUGIN_CONFIG_H_ - diff --git a/src/exif/old/plugin_config_impl.h b/src/exif/old/plugin_config_impl.h deleted file mode 100644 index 1f07ee5d..00000000 --- a/src/exif/old/plugin_config_impl.h +++ /dev/null @@ -1,25 +0,0 @@ -// -// Tizen Web Device API -// Copyright (c) 2014 Samsung Electronics Co., Ltd. -// -// Licensed under the Apache License, Version 2.0 (the License); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an AS IS BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -#ifndef _EXIF_PLUGIN_CONFIG_IMPL_H_ -#define _EXIF_PLUGIN_CONFIG_IMPL_H_ - -#define TIZEN_EXIF_MANAGER_CLASS "exif" -#define TIZEN_EXIF_EXIF_INFORMATION_INTERFACE "ExifInformation" - -#endif //_EXIF_PLUGIN_CONFIG_IMPL_H_ - diff --git a/src/exif/old/plugin_initializer.cpp b/src/exif/old/plugin_initializer.cpp deleted file mode 100644 index 0061b317..00000000 --- a/src/exif/old/plugin_initializer.cpp +++ /dev/null @@ -1,112 +0,0 @@ -// -// Tizen Web Device API -// Copyright (c) 2014 Samsung Electronics Co., Ltd. -// -// Licensed under the Apache License, Version 2.0 (the License); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -#include -#include -#include - -#include -#include -#include - -#include "JSExifInformation.h" -#include "JSExifManager.h" -#include "plugin_config.h" - -using namespace WrtDeviceApis; -using namespace WrtDeviceApis::Commons; -using namespace DeviceAPI::Common; - -namespace DeviceAPI { -namespace Exif { - -class_definition_options_t ConstructorClassOptions = -{ - JS_INTERFACE, - CREATE_INSTANCE, - NONE_NOTICE, - USE_OVERLAYED, - NULL, - NULL, - NULL -}; - -class_definition_options_t ClassOptions = -{ - JS_CLASS, - CREATE_INSTANCE, - NONE_NOTICE, - IGNORED, - NULL, - NULL, - NULL -}; - -void on_widget_start_callback(int widgetId) -{ - LOGD("[Tizen\\Exif] on_widget_start_callback (%d)", widgetId); - TIME_TRACER_INIT(); - try { - WrtAccessSingleton::Instance().initialize(widgetId); - } catch (...) { - LOGE("WrtAccess initialization failed"); - } -} - -void on_widget_stop_callback(int widgetId) -{ - LOGD("[Tizen\\Exif] on_widget_stop_callback (%d)", widgetId); - std::string name = "Exif"; - TIME_TRACER_EXPORT_REPORT_TO(TIME_TRACER_EXPORT_FILE, const_cast(name.c_str())); - TIME_TRACER_RELEASE(); - try { - WrtAccessSingleton::Instance().deinitialize(widgetId); - } catch (...) { - LOGE("WrtAccess deinitialization failed"); - } -} - -void on_frame_load_callback(const void * context) -{ - LOGD("[Tizen\\Exif] on_frame_load_callback (%p)", context); - GlobalContextManager::getInstance()->addGlobalContext(static_cast(context)); -} - -void on_frame_unload_callback(const void * context) -{ - LOGD("[Tizen\\Exif] on_frame_unload_callback (%p)", context); - GlobalContextManager::getInstance()->removeGlobalContext(static_cast(context)); -} - -PLUGIN_ON_WIDGET_START (on_widget_start_callback) -PLUGIN_ON_WIDGET_STOP (on_widget_stop_callback) - -PLUGIN_ON_FRAME_LOAD (on_frame_load_callback) -PLUGIN_ON_FRAME_UNLOAD (on_frame_unload_callback) - -PLUGIN_CLASS_MAP_BEGIN -PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN, - TIZEN_EXIF_MANAGER_CLASS, - (js_class_template_getter) JSExifManager::getClassRef, - &ClassOptions) -PLUGIN_CLASS_MAP_ADD_INTERFACE(WRT_JS_EXTENSION_OBJECT_TIZEN, - TIZEN_EXIF_EXIF_INFORMATION_INTERFACE, - (js_class_template_getter)JSExifInformation::getClassRef, - (js_class_constructor_cb_t)JSExifInformation::constructor, - &ConstructorClassOptions) -PLUGIN_CLASS_MAP_END -}}