* @return An error code
* @param[in] pUriData A pointer to the URI data
* @param[in] pDataType A pointer to the MIME type (RFC 2046) data
- * @param[in] pExtraData A pointer to an argument map of key and value pair where the key is of type String and the value is of type String to deliver to the resolved application @n
+ * @param[in] pExtraData A pointer to an argument map of key and value pair where the key is of type String and the value is of type String or of type ArrayList of String to deliver to the resolved application @n
* The maximum size is 16 kilo bytes.
* @param[in] pListener The application control callback listener @n
* Some application need to get the result by implementing the IAppControlResponseListener interface.
result
-_AppArg::AddStrArray(bundle* b, const char* key, const IList* pList)
+_AppArg::AddStrArray(bundle* pb, const char* key, const IList* pList)
{
- bundle* pb = b;
SysTryReturnResult(NID_APP, pb != NULL, E_INVALID_ARG, "Empty bundle.");
if (pList == null || pList->GetCount() == 0)
return E_SUCCESS;
}
- int i = 0;
- const int count = pList->GetCount();
-
- const char** pSa = new (std::nothrow) const char*[count];
- SysTryReturnResult(NID_APP, pSa != null, E_OUT_OF_MEMORY, "Memory allocation failure with cound %d.", count);
-
- for (i = 0; i < count; i++)
- {
- pSa[i] = null;
-
- const String* pStr = static_cast<const String*>(pList->GetAt(i));
- if (pStr)
- {
- pSa[i] = _StringConverter::CopyToCharArrayN(*pStr);
- }
- }
-
- result r = E_SUCCESS;
-
- int ret = bundle_add_str_array(pb, key, pSa, count);
- if (ret >= 0)
- {
- _AppMessageImpl::AddData(pb, pList);
- }
- else
- {
- SysLog(NID_APP, "Bundle add failre :%d.", ret);
- r = E_SYSTEM;
- }
+ _AppMessageImpl::AddValueArray(pb, key, pList);
_AppMessageImpl::AddData(pb, pList);
-//CATCH:
- for (i = 0; i < count; i++)
- {
- delete[] pSa[i];
- }
-
- delete[] pSa;
-
- return r;
+ return E_SUCCESS;
}
else if (typeid(*pObj) == typeid(const ArrayList))
{
const ArrayList* pList = static_cast<const ArrayList*>(pEnum->GetValue());
- if (pList && *pKey == TIZEN_APPCONTROL_DATA_LEGACY)
+ if (pList)
{
- SysLog(NID_APP, "Legacy AppControl argument");
- _AppArg::AddStrArray(pb, OSP_K_ARG, pList);
- _AppMessageImpl::AddData(pb, pList);
+ SysLog(NID_APP, "ArrayList type");
+
+ _AppMessageImpl::AddValueArray(pb, *pKey, pList);
}
}
else if (typeid(*pObj) == typeid(const ByteBuffer))
return pArray;
}
+result
+_AppMessageImpl::AddValueArray(bundle* pBundle, const String& key, const IList* pList)
+{
+ std::unique_ptr<char[]> pKey(_StringConverter::CopyToCharArrayN(key));
+
+ return AddValueArray(pBundle, pKey.get(), pList);
+}
+
+result
+_AppMessageImpl::AddValueArray(bundle* pBundle, const char* pKey, const IList* pList)
+{
+ SysTryReturnResult(NID_APP, pBundle != NULL, E_INVALID_ARG, "Empty bundle.");
+
+ if (pList == null || pList->GetCount() == 0)
+ {
+ SysLog(NID_APP, "No element added for bundle.");
+ return E_SUCCESS;
+ }
+
+ int i = 0;
+ const int count = pList->GetCount();
+
+ const char** pSa = new (std::nothrow) const char*[count];
+ SysTryReturnResult(NID_APP, pSa != null, E_OUT_OF_MEMORY, "Memory allocation failure with cound %d.", count);
+
+ // element is deliverately iterate with GetAt() for IList
+ for (i = 0; i < count; i++)
+ {
+ pSa[i] = null;
+
+ const String* pStr = static_cast<const String*>(pList->GetAt(i));
+ if (pStr)
+ {
+ pSa[i] = _StringConverter::CopyToCharArrayN(*pStr);
+ //SysLog(NID_APP, "%s", pSa[i]);
+ }
+ }
+
+ int ret = bundle_add_str_array(pBundle, pKey, pSa, count);
+
+ for (i = 0; i < count; i++)
+ {
+ delete[] pSa[i];
+ }
+
+ delete[] pSa;
+
+ return (ret == 0) ? E_SUCCESS : E_SYSTEM;
+}
+
}} // Tizen::App
static result AddStringMap(bundle* pBundle, const Tizen::Base::Collection::IMap* pMap);
static Tizen::Base::Collection::ArrayList* GetValueArray(bundle* pBundle, const char* pKey);
-
static Tizen::Base::Collection::ArrayList* GetValueArray(bundle* pBundle, const Tizen::Base::String& key);
+ static result AddValueArray(bundle* pBundle, const char* pKey, const Tizen::Base::Collection::IList* pList);
+ static result AddValueArray(bundle* pBundle, const Tizen::Base::String& key, const Tizen::Base::Collection::IList* pList);
+
private:
bundle* __pBundle;
};