"Calling Construct() twice or more on a same instance is not allowed for this class.");
std::unique_ptr<_QrCodeGeneratorImpl> pQrCodeGeneratorImpl(new (std::nothrow) _QrCodeGeneratorImpl());
- SysTryReturn(NID_UIX, pQrCodeGeneratorImpl != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+ SysSecureTryReturn(NID_UIX, pQrCodeGeneratorImpl != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
__pQrCodeGeneratorImpl = pQrCodeGeneratorImpl.release();
return E_SUCCESS;
{
SysAssertf(__pQrCodeGeneratorImpl != null, "Not yet constructed! Consruct() should be called before use.");
- SysTryReturnResult(NID_UIX, !message.IsEmpty(), null,
+ SysSecureTryReturnResult(NID_UIX, !message.IsEmpty(), null,
"message must not be empty. [E_INVALID_ARG]");
Tizen::Text::Utf8Encoding utf8;
- __pQrCodeGeneratorImpl->Encode((char*) utf8.GetBytesN(message)->GetPointer(), mode, error_level, compatibility);
+ std::unique_ptr<Tizen::Base::ByteBuffer> pMessageBuffer(utf8.GetBytesN(message));
+ __pQrCodeGeneratorImpl->Encode((char*) pMessageBuffer->GetPointer(), mode, error_level, compatibility);
__pQrCodeGeneratorImpl->GetSize(width, height);
std::unique_ptr<Tizen::Base::ByteBuffer> pBuffer(new (std::nothrow) Tizen::Base::ByteBuffer());
- SysTryReturn(NID_UIX, pBuffer != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+ SysSecureTryReturn(NID_UIX, pBuffer != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
pBuffer->Construct(width * height);
result
QrCodeGenerator::EncodeToFile(const Tizen::Base::String& message, QrCodeMode mode, QrCodeErrorCorrectionLevel errorCorrectionLevel, bool compatibility, const Tizen::Base::String& imageFilePath, Tizen::Media::ImageFormat imageFormat, int& width, int& height)
{
+ result r = E_SUCCESS;
SysAssertf(__pQrCodeGeneratorImpl != null, "Not yet constructed! Consruct() should be called before use.");
- SysTryReturnResult(NID_UIX, !message.IsEmpty(), E_INVALID_ARG,
- "message must not be empty. [E_INVALID_ARG]");
+ SysSecureTryReturnResult(NID_UIX, !message.IsEmpty(), E_INVALID_ARG,
+ "message must not be empty. [E_INVALID_ARG]");
+
+ SysSecureTryReturnResult(NID_UIX, !imageFilePath.IsEmpty(), E_INVALID_ARG,
+ "image path must not be empty. [E_INVALID_ARG]");
+
+ Tizen::Text::Utf8Encoding utf8;
+ std::unique_ptr<Tizen::Base::ByteBuffer> pBuffer(utf8.GetBytesN(message));
+ if (!__pQrCodeGeneratorImpl->Encode((char*) pBuffer->GetPointer(), mode, errorCorrectionLevel, compatibility))
+ {
+ return E_FAILURE;
+ }
- SysTryReturnResult(NID_UIX, !imageFilePath.IsEmpty(), E_INVALID_ARG,
- "image path must not be empty. [E_INVALID_ARG]");
+ if(!__pQrCodeGeneratorImpl->SaveToFile(imageFilePath, imageFormat,width, height))
+ {
+ r = GetLastResult();
+ if( r == E_ILLEGAL_ACCESS || r == E_OUT_OF_RANGE)
+ {
+ r = E_FILE_NOT_FOUND;
+ }
+ else if (r == E_UNSUPPORTED_FORMAT)
+ {
+ r = E_INVALID_ARG;
+ }
+ else
+ {
+ r = E_FAILURE;
+ }
- Tizen::Text::Utf8Encoding utf8;
- if (!__pQrCodeGeneratorImpl->Encode((char*) utf8.GetBytesN(message)->GetPointer(), mode, errorCorrectionLevel, compatibility))
- {
- return E_FAILURE;
- }
+ }
- return __pQrCodeGeneratorImpl->SaveToFile(imageFilePath, imageFormat) ? E_SUCCESS : E_FAILURE;
+ return r;
}
Tizen::Base::Collection::IListT<Tizen::Media::ImageFormat>*
{
std::unique_ptr<Tizen::Base::Collection::ArrayListT<Tizen::Media::ImageFormat> > pFormatList(
new (std::nothrow) Tizen::Base::Collection::ArrayListT<Tizen::Media::ImageFormat>);
- SysTryReturn(NID_UIX, pFormatList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+ SysSecureTryReturn(NID_UIX, pFormatList != null, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
pFormatList->Add(Tizen::Media::IMG_FORMAT_BMP);