"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());
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.");
- SysSecureTryReturnResult(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;
+ }
- SysSecureTryReturnResult(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, width, height) ? E_SUCCESS : E_FAILURE;
+ return r;
}
Tizen::Base::Collection::IListT<Tizen::Media::ImageFormat>*