*
* @return An error code
* @param[in] pMessage A pointer to an argument map of key (String) and value (String or ByteBuffer) pair @n
- * The recommended message size is under 4KB.
+ * The recommended message size is under 16KB.
* @exception E_SUCCESS The method is successful.
* @exception E_INVALID_ARG The message argument is not a map of key (String) and value (String or ByteBuffer) pair.
* @exception E_OBJ_NOT_FOUND The message port of the target application is not found.
* @exception E_MAX_EXCEEDED The size of @c pMessage has exceeded the maximum limit.
* @exception E_SYSTEM The method has failed due to a severe system error.
- * @remarks The recommended message size is under 4KB because severe system performance degradation may occur for large messages. E_MAX_EXCEEDED may be returned for messages over 4KB size.
+ * @remarks The recommended message size is under 16KB because severe system performance degradation may occur for large messages. E_MAX_EXCEEDED may be returned for messages over 16KB size.
*/
result SendMessage(const Tizen::Base::Collection::IMap* pMessage);
* @return An error code
* @param[in] pLocalMessagePort The local message port
* @param[in] pMessage A pointer to an argument map of key (String) and value (String or ByteBuffer) pair @n
- * The recommended message size is under 4KB.
+ * The recommended message size is under 16KB.
* @exception E_SUCCESS The method is successful.
* @exception E_INVALID_ARG Either of the following conditions has occurred: @n
* - The local message port is @c null. @n
* @exception E_OBJ_NOT_FOUND The message port of the target application is not found.
* @exception E_MAX_EXCEEDED The size of @c pMessage has exceeded the maximum limit.
* @exception E_SYSTEM The method has failed due to a severe system error.
- * @remarks The recommended message size is under 4KB because severe system performance degradation may occur for large messages. E_MAX_EXCEEDED may be returned for messages over 4KB size.
+ * @remarks The recommended message size is under 16KB because severe system performance degradation may occur for large messages. E_MAX_EXCEEDED may be returned for messages over 16KB size.
*/
result SendMessage(const LocalMessagePort* pLocalMessagePort, const Tizen::Base::Collection::IMap* pMessage);
namespace Tizen { namespace Io
{
+static const int MAX_MESSAGE_SIZE = 16 * 1024;
+
static void
ConvertBundleToMap(const char *pKey, const int type, const bundle_keyval_t *pVal, void *pData)
{
SysLog(NID_IO, "Send a unidirectional message to remote port [%ls:%ls]", remoteAppId.GetPointer(), remotePort.GetPointer());
int ret = 0;
+ int size = 0;
// Convert Map to bundle
- bundle* b = ConvertMapToBundleN(pMap);
- SysTryReturnResult(NID_IO, b != null, E_SYSTEM, "Internal system errors.");
+ bundle* b = ConvertMapToBundleN(pMap, &size);
+ SysTryReturnResult(NID_IO, b != null, E_INVALID_ARG, "The argument is invalid.");
+ SysTryReturnResult(NID_IO, size <= MAX_MESSAGE_SIZE, E_MAX_EXCEEDED, "The size of the message has exceeded the maximum limit.");
unique_ptr<char[]> pRemoteAppId(_StringConverter::CopyToCharArrayN(remoteAppId));
unique_ptr<char[]> pRemotePort(_StringConverter::CopyToCharArrayN(remotePort));
SysTryReturnResult(NID_IO, r != E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "The remote message port is not found.");
SysTryReturnResult(NID_IO, r != E_CERTIFICATE_VERIFICATION_FAILED, E_CERTIFICATE_VERIFICATION_FAILED, "The target application is not signed with the same certificate.");
- SysTryReturnResult(NID_IO, r != E_MAX_EXCEEDED, E_MAX_EXCEEDED, "The size of the message has exceeded the maximum limit.");
-
SysLogException(NID_IO, E_SYSTEM, "[E_SYSTEM] Failed to request the remote message port.");
return r;
SysTryReturnResult(NID_IO, r == E_SUCCESS, E_SYSTEM, "Internal system errors.");
+ int size = 0;
+
// Convert Map to bundle
- bundle* b = ConvertMapToBundleN(pMap);
- SysTryReturnResult(NID_IO, b != null, E_SYSTEM, "Internal system errors.");
+ bundle* b = ConvertMapToBundleN(pMap, &size);
+ SysTryReturnResult(NID_IO, b != null, E_INVALID_ARG, "The argument is invalid.");
+ SysTryReturnResult(NID_IO, size <= MAX_MESSAGE_SIZE, E_MAX_EXCEEDED, "The size of the message has exceeded the maximum limit.");
unique_ptr<char[]> pRemoteAppId(_StringConverter::CopyToCharArrayN(remoteAppId));
unique_ptr<char[]> pRemotePort(_StringConverter::CopyToCharArrayN(remotePort));
}
bundle*
-_MessagePortProxy::ConvertMapToBundleN(const HashMap* pMap)
+_MessagePortProxy::ConvertMapToBundleN(const HashMap* pMap, int* pSize)
{
bundle *b = bundle_create();
+ int size = 0;
std::unique_ptr<IMapEnumerator> pEnum (pMap->GetMapEnumeratorN());
while(pEnum->MoveNext() == E_SUCCESS)
if (typeid(*pValue) == typeid(const String)) // String
{
- unique_ptr<char[]> pValueData(_StringConverter::CopyToCharArrayN(*(static_cast<const String*>(pValue))));
+ const String* pStr = static_cast<const String*>(pValue);
+ size += pStr->GetLength() * sizeof(wchar_t);
+
+ unique_ptr<char[]> pValueData(_StringConverter::CopyToCharArrayN(*pStr));
//SysLog(NID_IO, "key: %s, value: %s", pKeyData.get(), pValueData.get());
if (typeid(*pValue) == typeid(const ByteBuffer)) // ByteBuffer
{
const ByteBuffer* pBuffer = static_cast<const ByteBuffer*>(pValue);
+ size += pBuffer->GetLimit();
- // Add a byte data to bundle
- SysLog(NID_IO, "Add a string key: %s, byte value: %s", pKeyData.get(), pBuffer->GetPointer());
+ //SysLog(NID_IO, "Add a string key: %s, byte value: %s", pKeyData.get(), pBuffer->GetPointer());
bundle_add_byte(b, pKeyData.get(), pBuffer->GetPointer(), pBuffer->GetLimit());
}
else
{
- SysLog(NID_IO, "Not supported");
+ SysLog(NID_IO, "The value type is not supported.");
bundle_free(b);
return null;
}
else
{
- SysLog(NID_IO, "Not supported");
+ SysLog(NID_IO, "The key type is not supported.");
bundle_free(b);
return null;
}
}
+ *pSize = size;
return b;
}
_RemoteMessagePortImpl::SendMessage(const IMap* pMessage)
{
SysTryReturnResult(NID_IO, pMessage != null, E_INVALID_ARG, "The argument is null.");
- SysTryReturnResult(NID_IO, CheckMessageType(pMessage), E_INVALID_ARG, "The argument is invalid.");
return _MessagePortProxy::GetProxy()->SendMessage(__remoteAppId, __remotePort, __isTrusted, (HashMap*)pMessage);
}
{
SysTryReturnResult(NID_IO, pLocalMessagePort != null, E_INVALID_ARG, "The argument is null.");
SysTryReturnResult(NID_IO, pMessage != null, E_INVALID_ARG, "The argument is null.");
- SysTryReturnResult(NID_IO, CheckMessageType(pMessage), E_INVALID_ARG, "The argument is invalid.");
return _MessagePortProxy::GetProxy()->SendMessage(pLocalMessagePort->GetName(), pLocalMessagePort->IsTrusted(), __remoteAppId, __remotePort, __isTrusted, (HashMap*)pMessage);
}
-bool
-_RemoteMessagePortImpl::CheckMessageType(const IMap* pMessage)
-{
- std::unique_ptr<IMapEnumerator> pEnum (pMessage->GetMapEnumeratorN());
- while(pEnum->MoveNext() == E_SUCCESS)
- {
- const String* pKey = dynamic_cast<const String*>(pEnum->GetKey());
- const Object* pValue = pEnum->GetValue();
-
- if (pKey && pValue)
- {
- if (typeid(*pValue) != typeid(const String))
- {
- if (typeid(*pValue) != typeid(const ByteBuffer))
- {
- return false;
- }
- }
- }
- else
- {
- return false;
- }
- }
-
- return true;
-}
-
RemoteMessagePort*
_RemoteMessagePortImpl::GetMessagePort(const AppId& remoteAppId, const String& remotePort, bool isTrusted)
{
SysTryCatch(NID_IO, pImpl != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
r = pImpl->Construct(remoteAppId, remotePort, isTrusted);
- //SysTryCatch(NID_IO, r != E_OBJ_NOT_FOUND, , E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The remote message port is not found.");
- //SysTryCatch(NID_IO, r != E_CERTIFICATE_VERIFICATION_FAILED, , E_CERTIFICATE_VERIFICATION_FAILED, "[E_CERTIFICATE_VERIFICATION_FAILED] The target application is not signed with the same certificate.");
SysTryCatch(NID_IO, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
pRemoteMessagePort->__pRemoteMessagePortImpl = pImpl.release();
static _MessagePortProxy* GetProxy(void);
- bundle* ConvertMapToBundleN(const Tizen::Base::Collection::HashMap* pMap);
+ bundle* ConvertMapToBundleN(const Tizen::Base::Collection::HashMap* pMap, int* pSize);
private:
result ConvertToResult(int error);
_RemoteMessagePortImpl& operator =(const _RemoteMessagePortImpl& value);
- bool CheckMessageType(const Tizen::Base::Collection::IMap* pMessage);
-
private:
Tizen::App::AppId __remoteAppId;
Tizen::Base::String __remotePort;