From: Adeel Kazmi Date: Wed, 22 Mar 2017 11:27:35 +0000 (-0700) Subject: Merge "Fix svace issue - uninitialized class member" into devel/master X-Git-Tag: dali_1.2.32~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=af268ee211630f7fc27cd0fe08df8251e6813bd0;hp=059c95901a8e85c965fad95888269e5cb7d44db4;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git Merge "Fix svace issue - uninitialized class member" into devel/master --- diff --git a/README.md b/README.md index 1a5642e..d415a76 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ To build the repository enter the 'build/tizen' folder: Then run the following commands: $ autoreconf --install - $ /configure --prefix=$DESKTOP_PREFIX + $ ./configure --prefix=$DESKTOP_PREFIX $ make install -j8 ### Build target options diff --git a/adaptors/common/adaptor-impl.h b/adaptors/common/adaptor-impl.h index 479e10e..4cbbdc2 100644 --- a/adaptors/common/adaptor-impl.h +++ b/adaptors/common/adaptor-impl.h @@ -563,7 +563,7 @@ private: // Data Any mNativeWindow; ///< window identifier RenderSurface* mSurface; ///< Current surface - TizenPlatform::TizenPlatformAbstraction* mPlatformAbstraction; ///< Platform abstraction + TizenPlatform::TizenPlatformAbstraction* mPlatformAbstraction; ///< Platform abstraction EventHandler* mEventHandler; ///< event handler CallbackManager* mCallbackManager; ///< Used to install callbacks diff --git a/adaptors/devel-api/adaptor-framework/image-loading.cpp b/adaptors/devel-api/adaptor-framework/image-loading.cpp index 68cb698..c194a76 100644 --- a/adaptors/devel-api/adaptor-framework/image-loading.cpp +++ b/adaptors/devel-api/adaptor-framework/image-loading.cpp @@ -19,10 +19,19 @@ // INTERNAL INCLUDES #include "image-loaders/image-loader.h" +#include +#include +#include namespace Dali { +namespace +{ +// limit maximum image down load size to 50 MB +const size_t MAXIMUM_DOWNLOAD_IMAGE_SIZE = 50 * 1024 * 1024 ; +} + PixelData LoadImageFromFile( const std::string& url, ImageDimensions size, FittingMode::Type fittingMode, SamplingMode::Type samplingMode, bool orientationCorrection ) { Integration::BitmapResourceType resourceType( size, fittingMode, samplingMode, orientationCorrection ); @@ -44,4 +53,68 @@ PixelData LoadImageFromFile( const std::string& url, ImageDimensions size, Fitti return Dali::PixelData(); } +ImageDimensions GetClosestImageSize( const std::string& filename, + ImageDimensions size, + FittingMode::Type fittingMode, + SamplingMode::Type samplingMode, + bool orientationCorrection ) +{ + return TizenPlatform::ImageLoader::GetClosestImageSize( filename, size, fittingMode, samplingMode, orientationCorrection ); +} + + +PixelData DownloadImageSynchronously( const std::string& url, ImageDimensions size, FittingMode::Type fittingMode, SamplingMode::Type samplingMode, bool orientationCorrection ) +{ + Integration::BitmapResourceType resourceType( size, fittingMode, samplingMode, orientationCorrection ); + + bool succeeded; + Dali::Vector dataBuffer; + size_t dataSize; + + succeeded = TizenPlatform::Network::DownloadRemoteFileIntoMemory( url, dataBuffer, dataSize, + MAXIMUM_DOWNLOAD_IMAGE_SIZE ); + if( succeeded ) + { + void *blobBytes = static_cast(&dataBuffer[0]); + size_t blobSize = dataBuffer.Size(); + + DALI_ASSERT_DEBUG( blobSize > 0U ); + DALI_ASSERT_DEBUG( blobBytes != 0U ); + + if( blobBytes != 0 && blobSize > 0U ) + { + // Open a file handle on the memory buffer: + Dali::Internal::Platform::FileCloser fileCloser( blobBytes, blobSize, "rb" ); + FILE * const fp = fileCloser.GetFile(); + if ( NULL != fp ) + { + Integration::BitmapPtr bitmap; + bool result = TizenPlatform::ImageLoader::ConvertStreamToBitmap( + resourceType, + url, + fp, + TizenPlatform::StubbedResourceLoadingClient(), + bitmap ); + + if ( result && bitmap ) + { + return Dali::PixelData::New( bitmap->GetBufferOwnership(), + bitmap->GetBufferSize(), + bitmap->GetImageWidth(), + bitmap->GetImageHeight(), + bitmap->GetPixelFormat(), + Dali::PixelData::FREE ); + } + else + { + DALI_LOG_WARNING( "Unable to decode bitmap supplied as in-memory blob.\n" ); + } + } + } + + } + return Dali::PixelData(); +} + + } // namespace Dali diff --git a/adaptors/devel-api/adaptor-framework/image-loading.h b/adaptors/devel-api/adaptor-framework/image-loading.h index 3f20bb4..124b27b 100644 --- a/adaptors/devel-api/adaptor-framework/image-loading.h +++ b/adaptors/devel-api/adaptor-framework/image-loading.h @@ -2,7 +2,7 @@ #define DALI_IMAGE_LOADING_H /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 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. @@ -38,11 +38,54 @@ namespace Dali * @param [in] orientationCorrection Reorient the image to respect any orientation metadata in its header. * @return handle to the loaded PixelData object or an empty handle in case loading failed. */ -DALI_IMPORT_API PixelData LoadImageFromFile( const std::string& url, - ImageDimensions size = ImageDimensions( 0, 0 ), - FittingMode::Type fittingMode = FittingMode::DEFAULT, - SamplingMode::Type samplingMode = SamplingMode::BOX_THEN_LINEAR, - bool orientationCorrection = true ); +DALI_IMPORT_API PixelData LoadImageFromFile( + const std::string& url, + ImageDimensions size = ImageDimensions( 0, 0 ), + FittingMode::Type fittingMode = FittingMode::DEFAULT, + SamplingMode::Type samplingMode = SamplingMode::BOX_THEN_LINEAR, + bool orientationCorrection = true ); + +/** + * @brief Determine the size of an image that LoadImageFromFile will provide when + * given the same image loading parameters. + * + * This is a synchronous request. + * This function is used to determine the size of an image before it has loaded. + * @param[in] filename name of the image. + * @param[in] size The requested size for the image. + * @param[in] fittingMode The method to use to map the source image to the desired + * dimensions. + * @param[in] samplingMode The image filter to use if the image needs to be + * downsampled to the requested size. + * @param[in] orientationCorrection Whether to use image metadata to rotate or + * flip the image, e.g., from portrait to landscape. + * @return dimensions that image will have if it is loaded with given parameters. + */ +DALI_IMPORT_API ImageDimensions GetClosestImageSize( + const std::string& filename, + ImageDimensions size = ImageDimensions(0, 0), + FittingMode::Type fittingMode = FittingMode::DEFAULT, + SamplingMode::Type samplingMode = SamplingMode::BOX_THEN_LINEAR , + bool orientationCorrection = true ); + +/** + * @brief Load an image synchronously from a remote resource. + * + * @param [in] url The URL of the image file to load. + * @param [in] size The width and height to fit the loaded image to, 0.0 means whole image + * @param [in] fittingMode The method used to fit the shape of the image before loading to the shape defined by the size parameter. + * @param [in] samplingMode The filtering method used when sampling pixels from the input image while fitting it to desired size. + * @param [in] orientationCorrection Reorient the image to respect any orientation metadata in its header. + * + * @return handle to the loaded PixelData object or an empty handle in case downloading or decoding failed. + */ +DALI_IMPORT_API PixelData DownloadImageSynchronously( + const std::string& url, + ImageDimensions size = ImageDimensions( 0, 0 ), + FittingMode::Type fittingMode = FittingMode::DEFAULT, + SamplingMode::Type samplingMode = SamplingMode::BOX_THEN_LINEAR, + bool orientationCorrection = true ); + } // Dali diff --git a/adaptors/wearable/watch/watch-time.cpp b/adaptors/wearable/watch/watch-time.cpp index 73890c2..df7b0f4 100644 --- a/adaptors/wearable/watch/watch-time.cpp +++ b/adaptors/wearable/watch/watch-time.cpp @@ -21,6 +21,7 @@ // EXTERNAL INCLUDES #ifdef APPCORE_WATCH_AVAILABLE #include +#include #endif namespace Dali @@ -92,8 +93,79 @@ int WatchTime::GetSecond() const return second; } -#else +int WatchTime::GetMillisecond() const +{ + int millisecond; + + watch_time_get_millisecond(reinterpret_cast(mImpl->mTimeHandle), &millisecond); + return millisecond; +} + +int WatchTime::GetYear() const +{ + int year; + + watch_time_get_year(reinterpret_cast(mImpl->mTimeHandle), &year); + return year; +} + +int WatchTime::GetMonth() const +{ + int month; + watch_time_get_month(reinterpret_cast(mImpl->mTimeHandle), &month); + return month; +} + +int WatchTime::GetDay() const +{ + int day; + + watch_time_get_day(reinterpret_cast(mImpl->mTimeHandle), &day); + return day; +} + +int WatchTime::GetDayOfWeek() const +{ + int dayOfWeek; + + watch_time_get_day_of_week(reinterpret_cast(mImpl->mTimeHandle), &dayOfWeek); + return dayOfWeek; +} + +struct tm WatchTime::GetUtcTime() const +{ + struct tm UtcTime; + + watch_time_get_utc_time(reinterpret_cast(mImpl->mTimeHandle), &UtcTime); + return UtcTime; +} + +time_t WatchTime::GetUtcTimeStamp() const +{ + time_t UtcTimeStamp; + + watch_time_get_utc_timestamp(reinterpret_cast(mImpl->mTimeHandle), &UtcTimeStamp); + return UtcTimeStamp; +} + +const char* WatchTime::GetTimeZone() const +{ + char* timeZone; + + watch_time_get_time_zone(reinterpret_cast(mImpl->mTimeHandle), &timeZone); + return timeZone; +} + +bool WatchTime::GetDaylightSavingTimeStatus() const +{ + bool daylight; + + watch_time_get_daylight_time_status(reinterpret_cast(mImpl->mTimeHandle), &daylight); + return daylight; +} + +#else WatchTime::WatchTime() :mImpl(NULL) { @@ -119,6 +191,52 @@ int WatchTime::GetSecond() const return 0; } -#endif // APPCORE_WATCH_AVAILABLE +int WatchTime::GetMillisecond() const +{ + return 0; +} + +int WatchTime::GetYear() const +{ + return 0; +} + +int WatchTime::GetMonth() const +{ + return 0; +} + +int WatchTime::GetDay() const +{ + return 0; +} + +int WatchTime::GetDayOfWeek() const +{ + return 0; +} + +struct tm WatchTime::GetUtcTime() const +{ + time_t zero = time(0); + return *localtime(&zero); +} + +time_t WatchTime::GetUtcTimeStamp() const +{ + return 0; +} + +const char* WatchTime::GetTimeZone() const +{ + return 0; +} + +bool WatchTime::GetDaylightSavingTimeStatus() const +{ + return 0; +} + +#endif } // namespace Dali diff --git a/adaptors/wearable/watch/watch-time.h b/adaptors/wearable/watch/watch-time.h index 1a304b5..df2d907 100644 --- a/adaptors/wearable/watch/watch-time.h +++ b/adaptors/wearable/watch/watch-time.h @@ -19,6 +19,7 @@ */ // EXTERNAL INCLUDES +#include // INTERNAL INCLUDES #include @@ -34,7 +35,8 @@ namespace Dali * @brief The WatchTime class is used to get time for the WatchApplication. * * A WatchTime has a time handle from watch application framework. - * You can get time(hour, minute, second) on receiving timeTick signal + * You can get time(hour, minute, second, millisecond) and date(year, month, day) + * on receiving timeTick signal. * @SINCE_1_1.37 */ class DALI_IMPORT_API WatchTime @@ -42,53 +44,152 @@ class DALI_IMPORT_API WatchTime public: /** - * @brief Constructor + * @brief Constructor. * @SINCE_1_1.37 */ WatchTime(); /** - * @brief Destructor + * @brief Destructor. * @SINCE_1_1.37 */ ~WatchTime(); /** - * @brief return current hour + * @brief Returns the current hour. * * @SINCE_1_1.37 - * @return the current hour + * @return The current hour + * @note The return value is always positive. * @pre The WatchTime needs to be initialized. */ int GetHour() const; /** - * @brief return current hour24 + * @brief Returns the current hour24. * * @SINCE_1_1.37 - * @return the current hour(the 24-hour clock) + * @return The current hour(the 24-hour clock) + * @note The return value is always positive. * @pre The WatchTime needs to be initialized. */ int GetHour24() const; /** - * @brief return current minute + * @brief Returns the current minute. * * @SINCE_1_1.37 - * @return the current minute + * @return The current minute + * @note The return value is always positive. * @pre The WatchTime needs to be initialized. */ int GetMinute() const; /** - * @brief return current second + * @brief Returns the current second. * * @SINCE_1_1.37 - * @return the current second + * @return The current second + * @note The return value is always positive. * @pre The WatchTime needs to be initialized. */ int GetSecond() const; + /** + * @brief Returns the current millisecond. + * + * @SINCE_1_2_32 + * @return The current millisecond + * @note The return value is always positive. + * @pre The WatchTime needs to be initialized. + */ + int GetMillisecond() const; + + /** + * @brief Returns the current year. + * + * @SINCE_1_2_32 + * @return The current year + * @note The return value is always positive. + * @pre The WatchTime needs to be initialized. + */ + int GetYear() const; + + /** + * @brief Returns the current month. + * + * @SINCE_1_2_32 + * @return The current month + * @note The return value is always positive. + * @pre The WatchTime needs to be initialized. + */ + int GetMonth() const; + + /** + * @brief Returns the current day. + * + * @SINCE_1_2_32 + * @return The current day + * @note The return value is always positive. + * @pre The WatchTime needs to be initialized. + */ + int GetDay() const; + + /** + * @brief Returns the current day of week. + * + * @details The value returns from 1 (Sunday) to 7 (Saturday). + * + * @SINCE_1_2_32 + * @return The current day of week + * @note The return value is always positive. + * @pre The WatchTime needs to be initialized. + */ + int GetDayOfWeek() const; + + /** + * @brief Returns the UTC time. (Coordinated Universal Time) + * + * @details Regarding struct tm (the return value), please refer to the site : + * http://www.cplusplus.com/reference/ctime/tm/ + * + * @SINCE_1_2_32 + * @return The UTC time + * @pre The WatchTime needs to be initialized. + */ + struct tm GetUtcTime() const; + + /** + * @brief Returns the UTC timestamp. + * + * @SINCE_1_2_32 + * @return The UTC timestamp + * @pre The WatchTime needs to be initialized. + */ + time_t GetUtcTimeStamp() const; + + /** + * @brief Returns the ID of timezone. + * + * @details The timezone ID, according to the IANA(Internet Assigned Numbers Authority) + * If you want to see more information, please refer to the site : + * https://en.wikipedia.org/wiki/List_of_tz_database_time_zones/ + * + * @SINCE_1_2_32 + * @return The ID of timezone + * @pre The WatchTime needs to be initialized. + */ + const char* GetTimeZone() const; + + /** + * @brief Returns the daylight saving time status. + * + * @SINCE_1_2_32 + * @return The Daylight Saving Time status + * @pre The WatchTime needs to be initialized. + */ + bool GetDaylightSavingTimeStatus() const; + public: // Not intended for application developers DALI_INTERNAL WatchTime(void *time_handle); diff --git a/automated-tests/src/dali-adaptor/CMakeLists.txt b/automated-tests/src/dali-adaptor/CMakeLists.txt index 462eafe..90bb7ec 100644 --- a/automated-tests/src/dali-adaptor/CMakeLists.txt +++ b/automated-tests/src/dali-adaptor/CMakeLists.txt @@ -17,6 +17,7 @@ SET(TC_SOURCES utc-Dali-TtsPlayer.cpp utc-Dali-Window.cpp #utc-Dali-Watch.cpp + #utc-Dali-Watch-Time.cpp #utc-Dali-KeyGrab.cpp ) diff --git a/automated-tests/src/dali-adaptor/utc-Dali-ImageLoading.cpp b/automated-tests/src/dali-adaptor/utc-Dali-ImageLoading.cpp index 75c2957..a4682bc 100644 --- a/automated-tests/src/dali-adaptor/utc-Dali-ImageLoading.cpp +++ b/automated-tests/src/dali-adaptor/utc-Dali-ImageLoading.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 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. @@ -67,3 +67,35 @@ int UtcDaliLoadImageN(void) END_TEST; } + + +int UtcDaliDownloadImageP(void) +{ + std::string url("file://"); + url.append( gImage_34_RGBA ); + + std::string url2("file://"); + url2.append( gImage_128_RGB ); + + PixelData pixelData = Dali::DownloadImageSynchronously( url ); + DALI_TEST_CHECK( pixelData ); + DALI_TEST_EQUALS( pixelData.GetWidth(), 34u, TEST_LOCATION ); + DALI_TEST_EQUALS( pixelData.GetHeight(), 34u, TEST_LOCATION ); + DALI_TEST_EQUALS( pixelData.GetPixelFormat(), Pixel::RGBA8888, TEST_LOCATION ); + + PixelData pixelData2 = Dali::DownloadImageSynchronously( url2 ); + DALI_TEST_CHECK( pixelData2 ); + DALI_TEST_EQUALS( pixelData2.GetWidth(), 128u, TEST_LOCATION ); + DALI_TEST_EQUALS( pixelData2.GetHeight(), 128u, TEST_LOCATION ); + DALI_TEST_EQUALS( pixelData2.GetPixelFormat(), Pixel::RGB888, TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliDownloadImageN(void) +{ + PixelData pixelData = Dali::DownloadImageSynchronously( gImageNonExist ); + DALI_TEST_CHECK( !pixelData ); + + END_TEST; +} diff --git a/automated-tests/src/dali-adaptor/utc-Dali-Watch-Time.cpp b/automated-tests/src/dali-adaptor/utc-Dali-Watch-Time.cpp new file mode 100644 index 0000000..5fd739e --- /dev/null +++ b/automated-tests/src/dali-adaptor/utc-Dali-Watch-Time.cpp @@ -0,0 +1,302 @@ +/* + * Copyright (c) 2017 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 "public-api/dali-wearable.h" +#include +#include +#include +#define TIMEZONE_BUFFER_MAX 102 + +using namespace Dali; + +void utc_dali_watchtime_startup(void) +{ + test_return_value = TET_UNDEF; +} + +void utc_dali_watchtime_cleanup(void) +{ + test_return_value = TET_PASS; +} + +namespace +{ + +struct MyTestApp : public ConnectionTracker +{ + MyTestApp( WatchApplication& app) + : initCalled( false ), + mApplication( app ) + { + mApplication.InitSignal().Connect( this, &MyTestApp::Create ); + } + + void Create(Application& app) + { + initCalled = true; + } + + void Quit() + { + mApplication.Quit(); + } + + // Data + bool initCalled; + WatchApplication& mApplication; +}; + +} // unnamed namespace + +int UtcDaliWatchTimeNew(void) +{ + WatchTime watchTime; + WatchTime *watchTimeRef = &watchTime; + + DALI_TEST_CHECK( watchTimeRef ); + + END_TEST; +} + +int UtcDaliWatchTimeGetHour(void) +{ + int ret, hour; + WatchTime watchTime; + watch_time_h watch_time = {0,}; + + ret = watch_time_get_current_time(&watch_time); + + DALI_TEST_CHECK( ret == APP_ERROR_NONE ); + + ret = watch_time_get_hour(watch_time, &hour); + + DALI_TEST_CHECK( ret == APP_ERROR_NONE ); + + DALI_TEST_CHECK( watchTime.GetHour() == hour ); + + END_TEST; +} + +int UtcDaliWatchTimeGetHour24(void) +{ + int ret, hour24; + WatchTime watchTime; + watch_time_h watch_time = {0,}; + + ret = watch_time_get_current_time(&watch_time); + DALI_TEST_CHECK( ret == APP_ERROR_NONE ); + + ret = watch_time_get_hour24(watch_time, &hour24); + DALI_TEST_CHECK( ret == APP_ERROR_NONE ); + + DALI_TEST_CHECK( watchTime.GetHour24() == hour24 ); + + END_TEST; +} + +int UtcDaliWatchTimeGetMinute(void) +{ + int ret, minute; + WatchTime watchTime; + watch_time_h watch_time = {0,}; + + ret = watch_time_get_current_time(&watch_time); + DALI_TEST_CHECK( ret == APP_ERROR_NONE ); + + ret = watch_time_get_minute(watch_time, &minute); + DALI_TEST_CHECK( ret == APP_ERROR_NONE ); + + DALI_TEST_CHECK( watchTime.GetMinute() == minute ); + + END_TEST; +} + +int UtcDaliWatchTimeGetSecond(void) +{ + int ret, second; + WatchTime watchTime; + watch_time_h watch_time = {0,}; + + ret = watch_time_get_current_time(&watch_time); + DALI_TEST_CHECK( ret == APP_ERROR_NONE ); + + ret = watch_time_get_second(watch_time, &second); + DALI_TEST_CHECK( ret == APP_ERROR_NONE ); + + DALI_TEST_CHECK( watchTime.GetSecond() == second ); + + END_TEST; +} + +int UtcDaliWatchTimeGetMillisecond(void) +{ + int ret, millisecond; + WatchTime watchTime; + watch_time_h watch_time = {0,}; + + ret = watch_time_get_current_time(&watch_time); + DALI_TEST_CHECK( ret == APP_ERROR_NONE ); + + ret = watch_time_get_millisecond(watch_time, &millisecond); + DALI_TEST_CHECK( ret == APP_ERROR_NONE ); + + DALI_TEST_CHECK( watchTime.GetMillisecond() == millisecond ); + + END_TEST; +} + +int UtcDaliWatchTimeGetYear(void) +{ + int ret, year; + WatchTime watchTime; + watch_time_h watch_time = {0,}; + + ret = watch_time_get_current_time(&watch_time); + DALI_TEST_CHECK( ret == APP_ERROR_NONE ); + + ret = watch_time_get_year(watch_time, &year); + DALI_TEST_CHECK( ret == APP_ERROR_NONE ); + + DALI_TEST_CHECK( watchTime.GetYear() == year ); + + END_TEST; +} + +int UtcDaliWatchTimeGetMonth(void) +{ + int ret, month; + WatchTime watchTime; + watch_time_h watch_time = {0,}; + + ret = watch_time_get_current_time(&watch_time); + DALI_TEST_CHECK( ret == APP_ERROR_NONE ); + + ret = watch_time_get_month(watch_time, &month); + DALI_TEST_CHECK( ret == APP_ERROR_NONE ); + + DALI_TEST_CHECK( watchTime.GetMonth() == month ); + + END_TEST; +} + +int UtcDaliWatchTimeGetDay(void) +{ + int ret, day; + WatchTime watchTime; + watch_time_h watch_time = {0,}; + + ret = watch_time_get_current_time(&watch_time); + DALI_TEST_CHECK( ret == APP_ERROR_NONE ); + + ret = watch_time_get_day(watch_time, &day); + DALI_TEST_CHECK( ret == APP_ERROR_NONE ); + + DALI_TEST_CHECK( watchTime.GetDay() == day ); + + END_TEST; +} + +int UtcDaliWatchTimeGetDayOfWeek(void) +{ + int ret, dayOfWeek; + WatchTime watchTime; + watch_time_h watch_time = {0,}; + + ret = watch_time_get_current_time(&watch_time); + DALI_TEST_CHECK( ret == APP_ERROR_NONE ); + + ret = watch_time_get_day_of_week(watch_time, &dayOfWeek); + DALI_TEST_CHECK( ret == APP_ERROR_NONE ); + + DALI_TEST_CHECK( watchTime.GetDayOfWeek() == dayOfWeek ); + + END_TEST; +} + +int UtcDaliWatchTimeGetUtcTime(void) +{ + int ret; + struct tm *utcTime = (struct tm *)calloc( 1, sizeof( struct tm ) ); + WatchTime watchTime; + watch_time_h watch_time = {0,}; + + ret = watch_time_get_current_time(&watch_time); + DALI_TEST_CHECK( ret == APP_ERROR_NONE ); + + ret = watch_time_get_day(watch_time, utcTime); + DALI_TEST_CHECK( ret == APP_ERROR_NONE ); + + DALI_TEST_CHECK( watchTime.GetUtcTime().tm_sec == (*utcTime).tm_sec ); + + END_TEST; +} + +int UtcDaliWatchTimeGetUtcTimeStamp(void) +{ + int ret; + time_t *timeStamp = (time_t *)calloc( 1, sizeof( time_t ) ); + WatchTime watchTime; + watch_time_h watch_time = {0,}; + + ret = watch_time_get_current_time(&watch_time); + DALI_TEST_CHECK( ret == APP_ERROR_NONE ); + + ret = watch_time_get_day(watch_time, timeStamp); + DALI_TEST_CHECK( ret == APP_ERROR_NONE ); + + DALI_TEST_CHECK( watchTime.GetUtcTimeStamp() == *timeStamp ); + + END_TEST; +} + +int UtcDaliWatchTimeGetTimeZone(void) +{ + int ret; + char *timeZone[TIMEZONE_BUFFER_MAX] = {0,}; + WatchTime watchTime; + watch_time_h watch_time = {0,}; + + ret = watch_time_get_current_time(&watch_time); + DALI_TEST_CHECK( ret == APP_ERROR_NONE ); + + ret = watch_time_get_day(watch_time, timeZone); + DALI_TEST_CHECK( ret == APP_ERROR_NONE ); + + DALI_TEST_CHECK( watchTime.GetTimeZone() == timeZone ); + + END_TEST; +} + +int UtcDaliWatchTimeGetDaylightSavingTimeStatus(void) +{ + int ret; + bool daylight; + WatchTime watchTime; + watch_time_h watch_time = {0,}; + + ret = watch_time_get_current_time(&watch_time); + DALI_TEST_CHECK( ret == APP_ERROR_NONE ); + + ret = watch_time_get_day(watch_time, &daylight); + DALI_TEST_CHECK( ret == APP_ERROR_NONE ); + + DALI_TEST_CHECK( watchTime.GetDaylightSavingTimeStatus() == daylight ); + + END_TEST; +} diff --git a/platform-abstractions/tizen/resource-loader/network/file-download.cpp b/platform-abstractions/tizen/resource-loader/network/file-download.cpp index 0352421..1e33dc3 100755 --- a/platform-abstractions/tizen/resource-loader/network/file-download.cpp +++ b/platform-abstractions/tizen/resource-loader/network/file-download.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 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. @@ -48,6 +48,13 @@ const long INCLUDE_HEADER = 1L; const long INCLUDE_BODY = 0L; const long EXCLUDE_BODY = 1L; +/** + * Curl library environment. Direct initialize ensures it's constructed before adaptor + * or application creates any threads. + */ +static Dali::TizenPlatform::Network::CurlEnvironment gCurlEnvironment; + + void ConfigureCurlOptions( CURL* curl_handle, const std::string& url ) { curl_easy_setopt( curl_handle, CURLOPT_URL, url.c_str() ); @@ -138,14 +145,31 @@ bool DownloadFile( CURL* curl_handle, } return true; } + + } // unnamed namespace +namespace Network +{ + +CurlEnvironment::CurlEnvironment() +{ + // Must be called before we attempt any loads. e.g. by using curl_easy_init() + // and before we start any threads. + curl_global_init(CURL_GLOBAL_ALL); +} + +CurlEnvironment::~CurlEnvironment() +{ + curl_global_cleanup(); +} + -bool Network::DownloadRemoteFileIntoMemory( const std::string& url, - Dali::Vector& dataBuffer, - size_t& dataSize, - size_t maximumAllowedSizeBytes ) +bool DownloadRemoteFileIntoMemory( const std::string& url, + Dali::Vector& dataBuffer, + size_t& dataSize, + size_t maximumAllowedSizeBytes ) { if( url.empty() ) { @@ -171,6 +195,7 @@ bool Network::DownloadRemoteFileIntoMemory( const std::string& url, return result; } +} // namespace Network } // namespace TizenPlatform diff --git a/platform-abstractions/tizen/resource-loader/network/file-download.h b/platform-abstractions/tizen/resource-loader/network/file-download.h index 0d31953..ee3d0f5 100644 --- a/platform-abstractions/tizen/resource-loader/network/file-download.h +++ b/platform-abstractions/tizen/resource-loader/network/file-download.h @@ -2,7 +2,7 @@ #define __DALI_TIZEN_PLATFORM_NETWORK_FILE_DOWNLOAD_H__ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 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. @@ -33,8 +33,30 @@ namespace Network { /** + * Set up the cURL environment - this will ensure curl_global_init is called on startup + * and curl_global_cleanup is called on shutdown. + * Having this environment enables curl to be used in a single or multi-threaded + * program safely. + */ +class CurlEnvironment +{ +public: + /** + * Constructor calls curl_global_init() + */ + CurlEnvironment(); + + /** + * Destructor calls curl_global_cleanup() + */ + ~CurlEnvironment(); +}; + + +/** * Download a requested file into a memory buffer. - * Threading notes: This function can be called from multiple threads, however l + * + * @note Threading notes: This function can be called from multiple threads, however * we must explicitly call curl_global_init() from a single thread before using curl * as the global function calls are not thread safe. * diff --git a/platform-abstractions/tizen/resource-loader/network/http-utils.cpp b/platform-abstractions/tizen/resource-loader/network/http-utils.cpp index 517dfbd..a20142d 100644 --- a/platform-abstractions/tizen/resource-loader/network/http-utils.cpp +++ b/platform-abstractions/tizen/resource-loader/network/http-utils.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 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. diff --git a/platform-abstractions/tizen/resource-loader/network/http-utils.h b/platform-abstractions/tizen/resource-loader/network/http-utils.h index e7d225c..01bd89c 100644 --- a/platform-abstractions/tizen/resource-loader/network/http-utils.h +++ b/platform-abstractions/tizen/resource-loader/network/http-utils.h @@ -2,7 +2,7 @@ #define __DALI_TIZEN_PLATFORM_NETWORK_UTILS_H__ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 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. diff --git a/plugins/dali-feedback.cpp b/plugins/dali-feedback.cpp index 1be8589..14ae644 100644 --- a/plugins/dali-feedback.cpp +++ b/plugins/dali-feedback.cpp @@ -29,7 +29,7 @@ #include -#define DEBUG_PRINTF(fmt, arg...) LOGD(" "fmt, ##arg) +#define DEBUG_PRINTF(fmt, arg...) LOGD(" " fmt, ##arg) using std::string; using namespace Dali;