Update for handling bytebuffer
authorJaesung Ku <jaesung.ku@samsung.com>
Thu, 25 Apr 2013 11:58:58 +0000 (20:58 +0900)
committerJaesung Ku <jaesung.ku@samsung.com>
Thu, 25 Apr 2013 11:58:58 +0000 (20:58 +0900)
Change-Id: I532bc2fc65996e8236ae1243e698c07eac316231
Signed-off-by: Jaesung Ku <jaesung.ku@samsung.com>
src/app/FApp_AppArg.cpp [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index e8ba5b7..f1796ba
@@ -431,6 +431,24 @@ BundleIterFnCb(const char* pKey, const int type, const bundle_keyval_t* pVal, vo
                                }
                        }
                        break;
+               case BUNDLE_TYPE_BYTE:
+                       bundle_keyval_get_basic_val(const_cast<bundle_keyval_t*>(pVal), reinterpret_cast<void**>(&pStr), &size);
+
+                       SysLog(NID_IO, "Bundle byte value = %s, size = %d", pStr, size);
+
+                       if (pStr)
+                       {
+                               ByteBuffer* pBuffer = new (std::nothrow) ByteBuffer();
+                               SysTryLog(NID_IO, pBuffer != null, "The memory is insufficient.");
+                               result r = pBuffer->Construct(size);
+                               SysTryLog(NID_IO, r == E_SUCCESS, "Constructing pBuffer is failed.");
+
+                               pBuffer->SetArray((const byte*)pStr, 0, size);
+                               pBuffer->Flip();
+
+                               pMap->Add(new (std::nothrow) String(pKey), pBuffer);
+                       }
+                       break;
                default:
                        SysLog(NID_APP, "Invalid type for %s : %d", pKey, type);
                        break;
@@ -702,6 +720,10 @@ _AppArg::AddStrMap(bundle* b, const IMap* pMap)
                        else if (typeid(*pObj) == typeid(const ByteBuffer))
                        {
                                SysLog(NID_APP, "ByteBuffer type");
+                               const ByteBuffer* pBuffer = static_cast<const ByteBuffer*>(pObj);
+
+                               std::unique_ptr<char[]> pBundleKey(_StringConverter::CopyToCharArrayN(*pKey));
+                               bundle_add_byte(b, pBundleKey.get(), pBuffer->GetPointer(), pBuffer->GetLimit());
                        }
                }
        }