Merge "Flow control for DataControl" into tizen_2.1
authorSunwook Bae <sunwook45.bae@samsung.com>
Wed, 3 Apr 2013 12:02:57 +0000 (21:02 +0900)
committerGerrit Code Review <gerrit2@kim11>
Wed, 3 Apr 2013 12:02:57 +0000 (21:02 +0900)
src/io/FIo_DataRowImpl.cpp [changed mode: 0644->0755]
src/io/FIo_DataSetEnumeratorImpl.cpp [changed mode: 0644->0755]
src/security/pkcs/FSecPkcsPkcs08Attribute.cpp
src/security/pkcs/FSecPkcs_Pkcs08AttributeImpl.cpp
src/security/pkcs/FSecPkcs_PkcsUtility.cpp
src/system/CMakeLists.txt
src/system/FSys_SystemClient.cpp [new file with mode: 0644]
src/system/FSys_SystemClient.h [new file with mode: 0644]
src/system/FSys_SystemInfoImpl.cpp

old mode 100644 (file)
new mode 100755 (executable)
index 6e6f7be..97f211c
@@ -135,6 +135,7 @@ _DataRowImpl::SetDateTimeAt(int columnIndex, const Tizen::Base::DateTime& value)
        result r = E_SUCCESS;
        Integer* pColumnType = null;
        int nColumnType = DB_COLUMNTYPE_UNDEFINED;
+       char* pDateTimeStr;
 
        SysTryReturnResult(NID_IO, columnIndex >= 0 && columnIndex < __columnCount, E_INVALID_ARG,
                                   "Wrong column index.");
@@ -145,7 +146,9 @@ _DataRowImpl::SetDateTimeAt(int columnIndex, const Tizen::Base::DateTime& value)
                E_TYPE_MISMATCH, "Type mismatch");
 
        unique_ptr<_DataItem>pItem(new (std::nothrow) _DataItem());
-       unique_ptr<String> pString(new (std::nothrow) String(_StringConverter::CopyToCharArrayN(value.ToString())));
+       pDateTimeStr = _StringConverter::CopyToCharArrayN(value.ToString());
+       unique_ptr<String> pString(new (std::nothrow) String(pDateTimeStr));
+       delete pDateTimeStr;
        SysTryReturnResult(NID_IO, pItem != null && pString != null, E_OUT_OF_MEMORY,
                        "The memory is insufficient.");
 
old mode 100644 (file)
new mode 100755 (executable)
index c8daadd..b3e5d8f
@@ -346,10 +346,9 @@ _DataSetEnumeratorImpl::GetDateTimeAt(int columnIndex, DateTime& value) const
                }
 
                pStr = (String*)pDataItem->pObj;
+               r = DateTime::Parse(*pStr, value);
        }
 
-       r = DateTime::Parse(*pStr, value);
-
        // fall thru
 CATCH:
        return r;
index 786622c..5f3451e 100644 (file)
@@ -98,6 +98,17 @@ Pkcs08Attribute::RemoveAttributeValue(const Pkcs08AttributeValue& value)
        return r;
 }
 
+Tizen::Base::String
+Pkcs08Attribute::GetAttributeType(void) const
+{
+       ClearLastResult();
+
+       SysAssertf(__pPkcs08AttributeImpl != null, "Not yet constructed. Reconstructor the object.");
+
+       return __pPkcs08AttributeImpl->GetAttributeType();
+
+}
+
 const Tizen::Base::Collection::ArrayList&
 Pkcs08Attribute::GetAttributeValues(void) const
 {
index f82d0ac..87e5bde 100644 (file)
@@ -156,6 +156,16 @@ _Pkcs08AttributeImpl::RemoveAttributeValue(const Pkcs08AttributeValue& value)
        return __attributeValues.Remove(value);
 }
 
+Tizen::Base::String
+_Pkcs08AttributeImpl::GetAttributeType(void) const
+{
+       SysAssertf(__attributeType.GetLength() > 0, "Not yet constructed. Construct () should be called before use.");
+
+       return __attributeType;
+
+}
+
+
 const Tizen::Base::Collection::ArrayList&
 _Pkcs08AttributeImpl::GetAttributeValues(void) const
 {
index 078eb34..05d0ad9 100644 (file)
@@ -58,7 +58,7 @@ bool
 _PkcsUtility::IsParameterSupported(Tizen::Base::String algorithm)
 {
        if (algorithm == OID_PBKDF2 || algorithm == OID_PBES2 || algorithm == OID_PBMAC1 || algorithm == OID_DES_CBC || algorithm == OID_DES_CBC_EDE3
-               || algorithm == OID_AES_128_CBC || algorithm == OID_AES_192_CBC || algorithm == OID_AES_256_CBC || algorithm == OID_RC2_CBC)
+                       || algorithm == OID_AES_128_CBC || algorithm == OID_AES_192_CBC || algorithm == OID_AES_256_CBC || algorithm == OID_RC2_CBC)
        {
                return true;
        }
@@ -830,7 +830,7 @@ _PkcsUtility::EncryptDecryptN(const AlgorithmIdentifier& algo, const Tizen::Base
                }
 
        }
-               return pOutBuffer.release();
+       return pOutBuffer.release();
 
        case _OID_TYPE_RSA_ENCRYPTION:
        {
@@ -855,7 +855,7 @@ _PkcsUtility::EncryptDecryptN(const AlgorithmIdentifier& algo, const Tizen::Base
                }
        }
 
-               return pOutBuffer.release();
+       return pOutBuffer.release();
 
        default:
                r = E_UNSUPPORTED_ALGORITHM;
@@ -881,6 +881,13 @@ _PkcsUtility::EncryptDecryptN(const AlgorithmIdentifier& algo, const Tizen::Base
 
        memset(pOut.get(), 0, tempLen);
 
+       if (dataLen % pCipherAlgorithm->block_size != 0)
+       {
+               // set padding
+               ret = EVP_CIPHER_CTX_set_padding(&cipherCtx, static_cast< int >(true));
+               SysTryCatch(NID_SEC_CRYPTO, ret == 1, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
+       }
+
        //cipher update operation
        ret = EVP_CipherUpdate(&cipherCtx, pOut.get(), static_cast< int* >(&outLen), pData, dataLen);
        SysTryCatch(NID_SEC_CRYPTO, ret == 1, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The method cannot proceed due to a severe system error.");
@@ -904,7 +911,7 @@ _PkcsUtility::EncryptDecryptN(const AlgorithmIdentifier& algo, const Tizen::Base
 
        pOutBuffer->Flip();
 
-CATCH:
+       CATCH:
 
        if (IsFailed(r))
        {
@@ -981,7 +988,7 @@ _PkcsUtility::GenerateKdfParametersN(int iter, unsigned char* pSaltValue, int sa
        PBKDF2PARAM_free(pKdf);
        return pKeyfunc;
 
-CATCH:
+       CATCH:
 
        PBKDF2PARAM_free(pKdf);
        X509_ALGOR_free(pKeyfunc);
@@ -1022,13 +1029,13 @@ _PkcsUtility::GernerateParametersFromOidN(Tizen::Base::String algoOid, X509_ALGO
        switch (oidValue)
        {
        case _OID_TYPE_DES_CBC:
-       // fall through
+               // fall through
        case _OID_TYPE_DES_CBC_EDE3:
-       // fall through
+               // fall through
        case _OID_TYPE_AES_128_CBC:
-       // fall through
+               // fall through
        case _OID_TYPE_AES_192_CBC:
-       // fall through
+               // fall through
        case _OID_TYPE_AES_256_CBC:
        {
                X509_ALGOR_get0(&pAlgoObj->algorithm, &pType, &pVal, pAlgoObj);
@@ -1127,15 +1134,15 @@ _PkcsUtility::GernerateParametersFromOidN(Tizen::Base::String algoOid, X509_ALGO
        break;
 
        case _OID_TYPE_HMAC_SHA1:
-       // fall through
+               // fall through
        case _OID_TYPE_HMAC_SHA2_224:
-       // fall through
+               // fall through
        case _OID_TYPE_HMAC_SHA2_256:
-       // fall through
+               // fall through
        case _OID_TYPE_HMAC_SHA2_384:
-       // fall through
+               // fall through
        case _OID_TYPE_HMAC_SHA2_512:
-       // fall through
+               // fall through
        case _OID_TYPE_RSA_ENCRYPTION:
        {
                pAlgoParams = null;
@@ -1270,13 +1277,13 @@ _PkcsUtility::GenerateAlgorithmIdentifierStructureN(Tizen::Base::String algoOid,
        switch (oidValue)
        {
        case _OID_TYPE_DES_CBC:
-       // fall through
+               // fall through
        case _OID_TYPE_DES_CBC_EDE3:
-       // fall through
+               // fall through
        case _OID_TYPE_AES_128_CBC:
-       // fall through
+               // fall through
        case _OID_TYPE_AES_192_CBC:
-       // fall through
+               // fall through
        case _OID_TYPE_AES_256_CBC:
        {
                SysTryReturn(NID_SEC_CRYPTO, pAlgoParam != null, null, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid.");
@@ -1342,15 +1349,15 @@ _PkcsUtility::GenerateAlgorithmIdentifierStructureN(Tizen::Base::String algoOid,
        break;
 
        case _OID_TYPE_HMAC_SHA1:
-       // fall through
+               // fall through
        case _OID_TYPE_HMAC_SHA2_224:
-       // fall through
+               // fall through
        case _OID_TYPE_HMAC_SHA2_256:
-       // fall through
+               // fall through
        case _OID_TYPE_HMAC_SHA2_384:
-       // fall through
+               // fall through
        case _OID_TYPE_RSA_ENCRYPTION:
-       // fall through
+               // fall through
        case _OID_TYPE_HMAC_SHA2_512:
        {
                ret = X509_ALGOR_set0(pAlgoObj, OBJ_nid2obj(algoNid), V_ASN1_NULL, NULL);
index 6b9d0c6..edf5e85 100755 (executable)
@@ -49,6 +49,7 @@ SET (${this_target}_SOURCE_FILES
        FSys_EnvironmentImpl.cpp
        FSys_DeviceEventListenerContainer.cpp
        FSys_SettingClient.cpp
+       FSys_SystemClient.cpp
 )
 
 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
diff --git a/src/system/FSys_SystemClient.cpp b/src/system/FSys_SystemClient.cpp
new file mode 100644 (file)
index 0000000..4b1bb56
--- /dev/null
@@ -0,0 +1,142 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FSys_SettingClient.cpp
+ * @brief              This is the implementation file for _SettingClient class.
+ */
+
+#include <unique_ptr.h>
+
+#include "FSys_SystemClient.h"
+
+#include <FBaseSysLog.h>
+
+#include <FIo_AppServiceIpcMessages.h>
+#include "FSys_CommunicationDispatcherClient.h"
+
+using namespace std;
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Base::Runtime;
+using namespace Tizen::Io;
+
+namespace Tizen { namespace System
+{
+
+static const wchar_t* _SYSTEM_SERVICE_ID = L"osp.system.service";
+static const wchar_t* _SYSTEM_COMMAND_SUPPORTED = L"osp.system.command.system.get.bool";
+
+static const wchar_t* _SYSTEM_OK = L"osp.system.result.ok";
+static const wchar_t* _SYSTEM_INVALID_ARG = L"osp.system.result.invalid_arg";
+static const wchar_t* _SYSTEM_ERROR = L"osp.system.result.error";
+
+_SystemClient* _SystemClient::__pSystemClient = null;
+
+_SystemClient*
+_SystemClient::GetInstance(void)
+{
+       if(__pSystemClient == null)
+       {
+               __pSystemClient = new (std::nothrow) _SystemClient();
+       }
+       return __pSystemClient;
+}
+
+_SystemClient::_SystemClient()
+       :__pIpcClient(null)
+{
+       result r = E_SUCCESS;
+       _CommunicationDispatcherClient* pCommunicationDispatcherClient = _CommunicationDispatcherClient::GetInstance();
+       r = pCommunicationDispatcherClient->RegisterCommunicationListener(_SYSTEM_SERVICE_ID, *this);
+       __pIpcClient = pCommunicationDispatcherClient->GetIpcClient();
+}
+
+_SystemClient::~_SystemClient()
+{
+}
+
+result
+_SystemClient::ConvertResultCode(String code)
+{
+       result r = E_SYSTEM;
+       if(code == _SYSTEM_OK)
+       {
+               r = E_SUCCESS;
+       }
+       else if(code == _SYSTEM_INVALID_ARG)
+       {
+               r = E_INVALID_ARG;
+       }
+       return r;
+}
+
+result
+_SystemClient::GetValue(const Tizen::Base::String& key, bool& value)
+{
+       result r = E_SUCCESS;
+       String requestKey(key);
+       String serviceId(_SYSTEM_SERVICE_ID);
+       String commandId(_SYSTEM_COMMAND_SUPPORTED);
+
+       _CommunicationDispatcherClient* pCommunicationDispatcherClient = _CommunicationDispatcherClient::GetInstance();
+
+       __pIpcClient = pCommunicationDispatcherClient->GetIpcClient();
+
+       ArrayList requestMessages;
+       ArrayList responseMessages;
+
+       requestMessages.Construct();
+       responseMessages.Construct();
+
+       requestMessages.Add(serviceId);
+       requestMessages.Add(commandId);
+       requestMessages.Add(requestKey);
+
+       unique_ptr<IoService_Request> pMsg(new (std::nothrow) IoService_Request(requestMessages, &responseMessages));
+
+       r = __pIpcClient->SendRequest(*pMsg);
+       SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to send request by IPC [%s]", GetErrorMessage(r));
+
+       String* pResult = (String*)responseMessages.GetAt(2);
+       SysTryReturnResult(NID_SYS, pResult != null, E_SYSTEM, "There is no result code.");
+
+       r = ConvertResultCode(*pResult);
+       SysTryReturnResult(NID_SYS, r == E_SUCCESS, r, "Error is occured.");
+
+       String* pValue = (String*)responseMessages.GetAt(3);
+       SysTryReturnResult(NID_SYS, pValue != null, E_SYSTEM, "There is no result value.");
+       if(pValue->GetPointer() == L"1")
+       {
+               value = true;
+       }
+       else
+       {
+               value = false;
+       }
+
+       responseMessages.RemoveAll(true);
+       return r;
+}
+
+void
+_SystemClient::OnDataReceived(const Tizen::Base::Collection::ArrayList& data)
+{
+}
+
+} } // Tizen::System
diff --git a/src/system/FSys_SystemClient.h b/src/system/FSys_SystemClient.h
new file mode 100644 (file)
index 0000000..b06a6b2
--- /dev/null
@@ -0,0 +1,59 @@
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+/**
+ * @file               FSys_SystemClient.h
+ * @brief              This is the header file for _SystemClient class.
+ */
+
+#ifndef _FSYSTEM_INTERNAL_SYSTEM_CLIENT_H_
+#define _FSYSTEM_INTERNAL_SYSTEM_CLIENT_H_
+
+#include <FIo_IpcClient.h>
+
+#include <FBaseColArrayList.h>
+#include <FBaseObject.h>
+#include <FBaseString.h>
+#include <FBaseInteger.h>
+#include <FSys_ICommunicationDispatcherListener.h>
+
+namespace Tizen { namespace System
+{
+
+class _SystemClient
+       : public Tizen::Base::Object
+       , public Tizen::System::_ICommunicationDispatcherListener
+{
+private:
+       _SystemClient(void);
+       virtual ~_SystemClient(void);
+
+public:
+       result GetValue(const Tizen::Base::String& key, bool& value);
+       static _SystemClient* GetInstance(void);
+
+private:
+       void OnDataReceived(const Tizen::Base::Collection::ArrayList& data);
+       result ConvertResultCode(Tizen::Base::String code);
+private:
+       Tizen::Io::_IpcClient*  __pIpcClient;   
+       static _SystemClient*   __pSystemClient;
+};
+
+} } // Tizen::System
+
+#endif //_FSYSTEM_INTERNAL_SYSTEM_CLIENT_H_
index 6cd8e41..b92aa5e 100644 (file)
@@ -30,7 +30,9 @@
 #include <FSys_SystemInfoImpl.h>
 #include <FIo_AppServiceIpcMessages.h>
 #include <FIo_IpcClient.h>
-#include <FSys_Types.h>
+
+#include "FSys_Types.h"
+#include "FSys_SystemClient.h"
 
 using namespace std;
 
@@ -179,7 +181,7 @@ _SystemInfoImpl::ConvertToTizen(const String& key)
        }
        else if(code == _KEYBOARD_TYPE)
        {
-               code == _INPUT_KEYBOARD_LAYOUT;
+               code = _INPUT_KEYBOARD_LAYOUT;
        }
        else if(code == _SCREEN_BITS_PER_PIXEL)
        {
@@ -268,6 +270,7 @@ _SystemInfoImpl::GetSysInfo(const String& key, String& value)
        if(pValue != null)
        {
                value = *pValue;
+               r = E_SUCCESS;
        }
 
        if (key == _NETWORK_TYPE) //Compatibility
@@ -368,7 +371,7 @@ _SystemInfoImpl::GetSysInfo(const String& key, String& value)
 
                        value.Append(L"CDMA");
                }
-
+               r = E_SUCCESS;
        }
        else if (key == _OPENGL_ES_VERSION)
        {
@@ -389,6 +392,7 @@ _SystemInfoImpl::GetSysInfo(const String& key, String& value)
 
                        value.Append(L"2.0");
                }
+               r = E_SUCCESS;
        }
        else if(key == _BLUETOOTH_SUPPORTED)
        {
@@ -398,6 +402,7 @@ _SystemInfoImpl::GetSysInfo(const String& key, String& value)
                        value = _SUPPORTED;
                else
                        value = _UNSUPPORTED;
+               r = E_SUCCESS;
        }
        else if (key == _GPS_SUPPORTED)
        {
@@ -407,6 +412,7 @@ _SystemInfoImpl::GetSysInfo(const String& key, String& value)
                        value = _SUPPORTED;
                else
                        value = _UNSUPPORTED;
+               r = E_SUCCESS;
        }
        else if (key == _WIFI_SUPPORTED)
        {
@@ -416,6 +422,7 @@ _SystemInfoImpl::GetSysInfo(const String& key, String& value)
                        value = _SUPPORTED;
                else
                        value = _UNSUPPORTED;
+               r = E_SUCCESS;
        }
        else if (key == _WAC_VERSION)
        {
@@ -678,6 +685,10 @@ _SystemInfoImpl::GetFromRegistry(const String& key, int& value)
 result
 _SystemInfoImpl::GetFromRegistry(const String& key, bool& value)
 {
+/*
+       _SystemClient* pSystemClient = _SystemClient::GetInstance();
+       pSystemClient->GetValue(key, value);
+*/
        result r = E_SUCCESS;
        _RegistryImpl _reg;
        String valStr;
@@ -701,6 +712,7 @@ _SystemInfoImpl::GetFromRegistry(const String& key, bool& value)
        }
        return E_SUCCESS;
 }
+
 _SystemInfoImpl*
 _SystemInfoImpl::GetInstance(SystemInfo& systeminfo)
 {